rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

maxima variable prefer_d undocumented #337

Closed rtoy closed 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:04 Created by billingd on 2023-01-26 03:19:47 Original: https://sourceforge.net/p/maxima/bugs/4088


The maxima variable prefer_d is defined and used in src/hypgeo.lisp. It isn't documented.

(defmvar $prefer_d nil "When NIL express a parabolic cylinder function as hypergeometric function.")

i will follow up when I have time, but won't be offended if someone else takes it up.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:05 Created by rtoy on 2023-01-26 15:16:13 Original: https://sourceforge.net/p/maxima/bugs/4088/#d5f3


I just happened to notice this yesterday by chance. I can add documentation for it

I'm curious, though. Do you want to use this variable to control this?

Would teaching maxima more about parabolic_cylinder_d be helpful to you?

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:08 Created by billingd on 2023-01-26 22:14:09 Original: https://sourceforge.net/p/maxima/bugs/4088/#46f4


I noticed the variable prefer_d while scanning maxima-commits emails. It was directly below a change in commit [8f7b8d]. I have never used parabolic_cylinder_d and have no plans.

I thought I would check if it was documented, as I didn't recall seeing it. It wasn't. I tried to find an example of its use but failed.

Edit: wrong commit cited.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:10 Created by macrakis on 2023-01-26 22:32:56 Original: https://sourceforge.net/p/maxima/bugs/4088/#34b1


prefer_d is a terrible name for a variable, the true/false convention is screwy, and the docstring is incorrect -- only under some special circumstances (which I can't figure out) does the parabolic_cylinder_d function get expressed as a hg-function.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:12 Created by rtoy on 2023-01-27 16:55:11 Original: https://sourceforge.net/p/maxima/bugs/4088/#12af


From reading the code, whittindtest has to be true to produce such a function.  whittindtest is only called from dtford, which is onlyu called from f24p146 or f35p147. The comments above these functions show what the integrands are being handled.

For f24p146, it appears that whittindtest gets the args 1/4-v/2, and 1/4 (from tracing this function and some specint integrals). For whittindtest to be true, one of the following cases must be true:

Clearly i2+i2 can't be since i2=1/4. For the second test, we have 1/2-1/4-(1/4-v/2) = v/2. So this is a negative integer only if v=-2*n for some positive integer n. Likewise for the third test, we get v/2+1/2 must be a negative integer. That is, v=-2*n-1 for positive integer n.

But in f24p146test, which calls f24p146, the comment says v must be positive. Hence, f24p146 can never pass the whittindtest test and thus can't produce a parabolic cylinder function. Thus we always call simpdtf where the comments show how to write parabolic cylinder d function in terms of hypergeometrics.

Assuming I did the math right.

I assume something similar happens for the f35p147 integral.

It's possible that the whittindtest is wrong. The comments for simpdtf show that D[v](z) = U(-v-1/2,z) where U is the second Kummer function.

Probably not worth fixing up whittindtest if it is, indeed, wrong.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:14 Created by billingd on 2023-01-28 04:34:50 Original: https://sourceforge.net/p/maxima/bugs/4088/#fb51


Some of the function names are from Erdelyi, Tables of Integral Transforms Vol 1. f24p146 is formula (24) from page 146 and f35p147 is formula (35) from page 147. These are both Laplace transforms with results containing cylindrical_parabolic_d functions.

Erdelyi, Arthur. Tables of Integral Transforms Vol 1. (1954). https://authors.library.caltech.edu/43489/.

Equation (24) has the condition nu>0 but generates a parabolic_cylinder_d with order -nu. Perhaps a sign is wrong somewhere.

This gives me a case to investigate, but at low priority.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:16 Created by billingd on 2023-01-28 08:34:16 Original: https://sourceforge.net/p/maxima/bugs/4088/#929d


The option variable has an effect.

Table of Integral Transforms, p. 146, formula 24 (from hypgeo.lisp:1425)

t^(v-1)*exp(-t^2/8/a)
   -> gamma(v)*2^v*a^(v/2)*exp(a*p^2)*D[-v](2*p*sqrt(a))
   Re(a) > 0, Re(v) > 0

With v=1 and a=1

(%i1) display2d:false$
(%i2) assume(p>0)$
(%i3) specint(%e^-(t^2/8)*exp(-p*t),t);
(%o3) 2*%e^p^2
       *((sqrt(%pi)*%e^p^2)/sqrt(2)-(sqrt(%pi)*%e^p^2*erf(sqrt(2)*p))/sqrt(2))
(%i4) specint(%e^-(t^2/8)*exp(-p*t),t),prefer_d=true;
(%o4) 2*parabolic_cylinder_d(-1,2*p)*%e^p^2
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:18 Created by billingd on 2023-01-28 10:28:37 Original: https://sourceforge.net/p/maxima/bugs/4088/#7174


Fixed with commit [ff719e]

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:20 Created by billingd on 2023-01-28 10:29:33 Original: https://sourceforge.net/p/maxima/bugs/4088/#2755


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-02 16:31:23 Created by billingd on 2023-01-28 10:49:32 Original: https://sourceforge.net/p/maxima/bugs/4088/#7371


mention prefer_d under specint in commit [cec761]