rtoy / maxima

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

bessel_simplify error #647

Closed rtoy closed 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:30 Created by billingd on 2023-09-25 12:52:49 Original: https://sourceforge.net/p/maxima/bugs/4184


Reported by Daniel Volinski on maxima list on 25/09/2023

I was trying bessel_simplify on contrib_ode package and I found the following problem. I was testing the examples of bessel_simplify in the Maxima documentation.

load('contrib_ode)$

bessel_simplify(4*bessel_j(n,x^2)*(x^2-n^2/x^2)
  +x*((bessel_j(n-2,x^2)-bessel_j(n,x^2))*x
  -(bessel_j(n,x^2)-bessel_j(n+2,x^2))*x)
  -2*bessel_j(n+1,x^2)+2*bessel_j(n-1,x^2)); => 0

bessel_simplify(-2*bessel_j(1,z)*z^3-10*bessel_j(2,z)*z^2
 +15*%pi*bessel_j(1,z)*struve_h(3,z)*z-15*%pi*struve_h(1,z)*bessel_j(3,z)*z
 -15*%pi*bessel_j(0,z)*struve_h(2,z)*z+15*%pi*struve_h(0,z)*bessel_j(2,z)*z
 -30*%pi*bessel_j(1,z)*struve_h(2,z)+30*%pi*struve_h(1,z)*bessel_j(2,z)); => 0

So far so good.

If I put the following command before the two bessel_simplify commands:

f(x):=2$

I get the two results 2, as if the function definition overwrites the command.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:32 Created by billingd on 2023-09-25 12:54:21 Original: https://sourceforge.net/p/maxima/bugs/4184/#2a17


Diff:


--- old
+++ new
@@ -3,6 +3,7 @@
 I was trying bessel_simplify on contrib_ode package and I found the following problem.
 I was testing the examples of bessel_simplify in the Maxima documentation.

+~~~
 load('contrib_ode)$

 bessel_simplify(4*bessel_j(n,x^2)*(x^2-n^2/x^2)
@@ -14,11 +15,14 @@
  +15*%pi*bessel_j(1,z)*struve_h(3,z)*z-15*%pi*struve_h(1,z)*bessel_j(3,z)*z
  -15*%pi*bessel_j(0,z)*struve_h(2,z)*z+15*%pi*struve_h(0,z)*bessel_j(2,z)*z
  -30*%pi*bessel_j(1,z)*struve_h(2,z)+30*%pi*struve_h(1,z)*bessel_j(2,z)); => 0
+~~~

 So far so good.

 If I put the following command before the two bessel_simplify commands:

+~~~
 f(x):=2$
+~~~

 I get the two results 2, as if the function definition overwrites the command.
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:35 Created by billingd on 2023-09-25 12:54:21 Original: https://sourceforge.net/p/maxima/bugs/4184/#95ae


Well spotted. The following patch should fix it. I will have a proper look tomorrow.

diff --git a/share/contrib/diffequations/contrib_ode.mac b/share/contrib/diffequations/contrib_ode.mac
index ab9afbd39..25c020411 100644
--- a/share/contrib/diffequations/contrib_ode.mac
+++ b/share/contrib/diffequations/contrib_ode.mac
@@ -218,7 +218,7 @@ ode_check_tidy(e) := block(
 /*  This Bessel function simplification code can be improved,
     but is does work well on the contrib_ode testsuite.
 */
-bessel_simplify(e) := block(
+bessel_simplify(e) := block(local(f),
  for f in ['besksimp, 'besisimp, 'besysimp, 'besjsimp,
            'hankel1simp, 'hankel2simp, 'struvehsimp, 'struvelsimp]
  do
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:39 Created by billingd on 2023-09-25 13:27:04 Original: https://sourceforge.net/p/maxima/bugs/4184/#384b


Similar problem a few lines above

--- a/share/contrib/diffequations/contrib_ode.mac
+++ b/share/contrib/diffequations/contrib_ode.mac
@@ -208,7 +208,7 @@ ode_check(e_,a_) := block(
 )$

 /* Attempt to simplify the result from ode_check() */
-ode_check_tidy(e) := block(
+ode_check_tidy(e) := block(local(f),
   for f in ['bessel_simplify, 'expintegral_e_simplify,'ode_trig_simp]
rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:42 Created by billingd on 2023-09-28 04:31:28 Original: https://sourceforge.net/p/maxima/bugs/4184/#e411


Fixed with commit [1d63a5]

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:46 Created by billingd on 2023-09-28 04:31:51 Original: https://sourceforge.net/p/maxima/bugs/4184/#8864


rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:49 Created by richardgobeli on 2024-01-06 18:24:22 Original: https://sourceforge.net/p/maxima/bugs/4184/#7aed


I have a work file that when loading contrib_ode I get thses warnings. My work sheet uses N,Q,V, and X. I don't know, if the intenal variables will affect or be affected by the external variables.

(%i405) load( "contrib_ode"); ; file: C:/maxima-current/share/maxima/branch_5_47_base_526_g08584e36f/share/contrib/diffequations/odelin.lisp

; in: DEFUN HYPERGEO21-XI-DENOM-FILTER ; (IGNORE MAXIMA::N) ; ; caught STYLE-WARNING: ; Declaring special variable N to be IGNORE ; file: C:/maxima-current/share/maxima/branch_5_47_base_526_g08584e36f/share/contrib/diffequations/odelin.lisp ; in: DEFUN HYPERGEO21-XI-DEGREE-BOUND ; (IGNORE MAXIMA::Q MAXIMA::V MAXIMA::X) ; ; caught STYLE-WARNING: ; Declaring special variable X to be IGNORE ; ; compilation unit finished ; caught 2 STYLE-WARNING conditions (%o405) "C:/maxima-current/share/maxima/branch_5_47_base_526_g08584e36f/share/contrib/diffequations/contrib_ode.mac"

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-03 03:08:53 Created by billingd on 2024-01-08 03:41:23 Original: https://sourceforge.net/p/maxima/bugs/4184/#80f1


Last post moved to new bug [#4242 ] as it is not related.