|
From: Barton W. <wi...@un...> - 2021-02-27 01:17:48
|
FYI: Running the testsuite + the share test suite, I counted the number of times conjugate receives an expression that has a defined conjugate function.
The gamma_incomplete function is by far the leader with 559 calls. Guesses: (1) most of these calls come from the integration code; and (2) most of them indicate something fishy.
(Operators, such as sin, that commute with the conjugate aren't counted--such cases are handled with a different mechanism that is fast and efficient.)
(%SUM 2)
(%LOG 26)
(%ATAN 1)
(%HANKEL_2 4)
(MEXPT 63428)
(%HANKEL_1 4)
(%BESSEL_I 5)
(%BESSEL_K 4)
(%LOG_GAMMA 2)
(%ATANH 4)
(%GAMMA_INCOMPLETE_GENERALIZED 3)
(%GAMMA_INCOMPLETE 559)
(%BESSEL_J 5)
(%ASIN 6)
(%BERNSTEIN_POLY 3)
(%BESSEL_Y 4)
(%PRODUCT 62)
(%EXPINTEGRAL_E 8)
($HYPERGEOMETRIC 6)
I'll paste in more tests to check some other functions.
--Barton
________________________________
From: Barton Willis via Maxima-discuss <max...@li...>
Sent: Friday, February 26, 2021 15:05
To: Richard Fateman <fa...@gm...>; max...@li... <max...@li...>
Subject: Re: [Maxima-discuss] bad simp of acos, conjugate(acos..) was Re: sub expression with missing simp flags.
Non-NU Email
________________________________
Thanks to all for the advice. I'll fix up conjugate.lisp so that all subexpressions are fully simplified.
I don't plan to alter the various conjugate functions so that they take the full expression--e conjugate functions will do a re-simplification when they return a nounform.
--Barton
________________________________
From: Richard Fateman <fa...@gm...>
Sent: Friday, February 26, 2021 11:39
To: max...@li... <max...@li...>
Subject: [Maxima-discuss] bad simp of acos, conjugate(acos..) was Re: sub expression with missing simp flags.
Non-NU Email
________________________________
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...<mailto:Max...@li...>
https://lists.sourceforge.net/lists/listinfo/maxima-discuss<https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_maxima-2Ddiscuss&d=DwMD-g&c=Cu5g146wZdoqVuKpTNsYHeFX_rg6kWhlkLF8Eft-wwo&r=Ln0CjFotuA7GyhsRS-QpQA&m=b9iKyLHvSIDH4nv8f83gIXKKBCQXDV9oKckbg3ri1Z0&s=RvFgwfb-N8bnuikdSjpepLVKUjSn88Bw-Iu_DZ3mvMY&e=>
|