In MAXIMA, how do I get entire call stack printed?

僤鯓⒐⒋嵵緔 提交于 2019-12-10 11:38:18

问题


Sorry if this is a novice question, but I couldn't find any documentation or other stackoverflow questions on this. I want to see entire stack trace of all maxima functions called in solving an expression or an equation. I tried trace, backtrace, and debugmode. Looked at different display and print functions, but none worked.

Example1:

(%i1) is(equal( (a+b)^2, a^2+b^2+2*a*b ));
(%o1) true

Example2:

(%i2) trace(factor);
(%o2) [factor]
(%i3) trace_options(factor, info);
(%o3) [info]
(%i4) factor( (x^2 - 7*x + 10) / (x - 5) );
1 Enter ?factor [(x^2-7*x+10)/(x-5)] -> true
1 Exit  ?factor x-2 -> true
(%o4) x-2

I want to see every intermediate step Maxima executed and its result in the derivation of these solutions or conclusions.Info on minutest level calls is even better.

Thanks, RB


回答1:


As a hack you can trace all functions listed in builtins-list.txt:

l: read_list("builtins-list.txt") $
for e in l do errcatch(apply('trace, [e])) $
untrace(bfloatp) $ /* to limit output */
is(equal( (a+b)^2, a^2+b^2+2*a*b )) $

returns:

(%i5) is(equal( (a+b)^2, a^2+b^2+2*a*b )) $
                            2   2    2
1 Enter is [is(equal((a + b) , a  + b  + 2 a b))]
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b + a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b + a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [a]
 1 Exit  ratp false
 1 Enter ratp [2]
 1 Exit  ratp false
 1 Enter ratp [b]
 1 Exit  ratp false
                      2
 1 Enter setp [(b + a) ]
 1 Exit  setp false
                   2            2
 1 Enter subvarp [b  + 2 a b + a ]
 1 Exit  subvarp false
                   2            2
 1 Enter subvarp [b  + 2 a b + a ]
 1 Exit  subvarp false
                         2    2            2
 1 Enter ratsimp [(b + a)  - b  - 2 a b - a ]
                       2    2            2
  1 Enter ratp [(b + a)  - b  - 2 a b - a ]
  1 Exit  ratp false
                              2    2            2
  1 Enter totaldisrep [(b + a)  - b  - 2 a b - a ]
                             2    2            2
  1 Exit  totaldisrep (b + a)  - b  - 2 a b - a
  1 Enter ratdisrep [0]
   1 Enter ratp [0]
   1 Exit  ratp true
  1 Exit  ratdisrep 0
 1 Exit  ratsimp 0
 1 Enter facts []
 1 Exit  facts []
 1 Enter niceindices [0]
 1 Exit  niceindices 0
 1 Enter constantp [0]
  1 Enter numberp [0]
   1 Enter ratnump [0]
   1 Exit  ratnump true
  1 Exit  numberp true
 1 Exit  constantp true
 1 Enter rectform [0]
 1 Exit  rectform 0
 1 Enter sign [0]
 1 Exit  sign zero
1 Exit  is true
1 Enter concat [, %o, 5]
1 Exit  concat %o5
1 Enter concat [, %i, 5]
1 Exit  concat %i5
1 Enter concat [, %i, 6]
1 Exit  concat %i6


来源:https://stackoverflow.com/questions/39607812/in-maxima-how-do-i-get-entire-call-stack-printed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!