|
From: Richard F. <fa...@gm...> - 2021-02-26 17:39:39
|
There are a bunch of oddities in the definition of conjugate-acos. 1. say one calls conjugate(acos(foo+bar)). It would make sense for conjugate-acos to be called on acos(foo+bar), i.e. ((%acos simp) ((mplus simp) $foo $bar)) in which case the expression -- with simp flag -- would be readily available. 2. since the call to conjugate-acos is a list ( $x) or in this case ( ((mplus simp) $foo $bar) ) always, and it always computes (car ..) , then*** the call*** like (conjugate-acos ww) should be (conjugate-acos( car ww)) , and the internal car is made unnecessary. finally, if nothing else is changed, it is simple to put the simp flag on,: that last line could be (cons '($conjugate simp) (take '(%acos) x)) in which case the acos would still be resimplified unnecessarily once, but the simp flag would be on it. I discovered..... There is a really terrible something going on with simplification of acos, though. do this :lisp (trace simplifier) acos(z) you can see the simplifier being called many many times, on expressions like 3^(1/2)/2 expressions not involving z at all. RJF On 2/25/21 4:55 AM, Barton Willis via Maxima-discuss wrote: > A simplified expression of the form conjugate(XXX) can include > subexpressions that are /not/ marked as simplified. That's not good. > For example: > > (%i1) declare(z,complex)$ > > (%i2) conjugate(acos(z)); > (%o2) conjugate(acos(z)) > > (%i3) ?print(%); > (($CONJUGATE SIMP) ((%ACOS) $Z) > > Maybe the missing simp flag on acos isn't terrible, but doesn't it > cause an inefficacy? Doing, for example, first(conjugate(acos(z)) > forces a > re-simplification of acos(z). > > The function for the conjugate of an acosine expression is > > (defun conjugate-acos (x) > (setq x (car x)) > (if (in-domain-of-asin x) (take '(%acos) (take '($conjugate) x)) > `(($conjugate simp) ((%acos) ,x)))) > > So the reason for the missing simp flag isn't a mystery. > > As I understand the conjugate code, it wouldn't be wrong for a > conjugate function, such as conjugate-acos, to paste in the simp flag > without doing a re-simplification--that's because the acos expression > has been simplified at a higher level. Pasting in simp flags makes me > uncomfortable but doing (take '(%acos) x) seems inefficient. > > Likely conjugate functions, such as conjugate-acos should receive the > entire expression acos(XXX), not just XXX. That way for a nounform > return, it could return `(($conjugate simp) ,XXX) and be safe. But > changing this seems too error prone (conjugate functions are scattered > throughout src) and I'm not pretty sure the gain in speed is not > worthwhile. > > Arguably, even doing `(($conjugate simp) ...) is a wrong--if > $conjugate had a msimpind property (it doesn't), doing `(($conjugate > simp) would circumvent the msimpind flag. Maybe the msimpind flag is a > never-mind feature? > > Maybe all this is trifling, All advice is welcomed. > > --Barton > > > > > _______________________________________________ > Maxima-discuss mailing list > Max...@li... > https://lists.sourceforge.net/lists/listinfo/maxima-discuss |