Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
902 views
in Technique[技术] by (71.8m points)

tex - (wx)Maxima: texput for powers of expressions

I have used texput to set the tex1 output of log(x) to be ln(x) with

texput('log, lambda([e],[a]:args(e), printf(false, "\ln(~a)", tex1(a))));

and am wondering if it is possible to also set the output for something like (log(x))^n? In particular I'd like to use the ln^n(x) convention.

question from:https://stackoverflow.com/questions/66056058/wxmaxima-texput-for-powers-of-expressions

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The strangeness around TeX output for log is a bug, which I'm working on. But here is a work around which gets the behavior you want, I think.

Here I'm calling both texput(log, "\ln ") and texput(log, "\ln ", prefix), to set the TeX output for log in different contexts, and also :lisp (push log *tex-mexpt-trig-like-fns*) to have log treated similarly to trig functions.

(%i1) stringdisp: true $
(%i2) map (tex1, [log(x), log(x+1), log(x)^n]);                              
(%o2)   ["log x", "log left(x+1
ight)", "left(log x
ight)^{n}"]
(%i3) texput (log, "\ln ");
(%o3)                               "ln "
(%i4) texput (log, "\ln ", prefix);
(%o4)                               "ln "
(%i5) map (tex1, [log(x), log(x+1), log(x)^n]); 
(%o5)           ["ln x", "ln left(x+1
ight)", "ln x^{n}"]

Hmm, that's not quite enough. Oh, that's right, I forgot the bit about trig functions.

(%i6) :lisp (push '%log *tex-mexpt-trig-like-fns*)
(%LOG %SIN %COS %TAN %SINH %COSH %TANH %ASIN %ACOS %ATAN %ASINH %ACOSH %ATANH)
(%i6) map (tex1, [log(x), log(x+1), log(x)^n]); 
(%o6)           ["ln x", "ln left(x+1
ight)", "ln ^{n}x"]

Does that seem right?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...