rtoy / maxima

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

differ.mac has many bugs #2126

Closed rtoy closed 4 months ago

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:34:28 Created by willisbl on 2003-11-18 16:25:24 Original: https://sourceforge.net/p/maxima/bugs/447


differ.mac solves finite difference equations; it has many bugs. And I can't find any user documentation for it either. Specifically

It redefines the functions system and eigenvalues

(C1) load("differ.mac"); Warning - you are redefining the MACSYMA function EIGENVALUES Warning - you are redefining the MACSYMA function SYSTEM (D1)
C:/maxima/Maxima/share/maxima/5.9.0/share/algebra/diff er.mac (C2) display2d : false; (D2) FALSE

It solves this one correctly (C3) difference(x[k+1] = x[k] / 5, x[k]); (D3) x[k] = x[0]/5^k

But make the equation nonhomogeneous and the solution is wrong

(C4) difference(x[k+1] = x[k] / 5 + 1, x[k]); (D4) x[k] = 0 <=== BOGUS

I don't think differ.mac can solve non-constant coefficient equations, but it doesn't check that the coefficients are constant

(C5) difference(x[k+1] = k * x[k], x[k]); (D5) x[k] = x[0]*k^k <=== BOGUS

It can't solve this degenerate equation

(C6) difference(x[k+2] + 2 * x[k+1] + x[k], x[k]); Non-square matrix in inverse #0: SYSTEM(eqnlist=[x[k+1] = -(x[k+2]+x[k])/2,x[k+1] = x[k+1]],varlist=[x[k+1],x[k]])(differ.mac line 91) #1: second_order_difference(eqn=x[k+1] = -(x[k+2]+x [k])/2,var=x[k])(differ.mac line 73) #2: difference(eqn=x[k+2]+2*x[k+1]+x[k],var=x[k]) (differ.mac line 113) -- an error. Quitting. To debug this try DEBUGMODE (TRUE);)

But the non-degenerate equation is okay

(C7) difference(x[k+2] + 8 * x[k+1] + x[k], x[k]); (D7) x[k] = (-SQRT(15)-4)^k*(SQRT(15)-4)*((SQRT(15) + ....

differ.mac doesn't check that the equation is linear and may give an incorrect solution when it is

(C12) difference(x[k+1] - x[k]^2 + x[k] = 0,x[k]); (D12) x[k] = x[0]*(-1)^k-((-1)^k-1)*x[k]^2/2 <== BOGUS

Bugs in differ.mac are far too easy to find. I haven't tried recur.mac; maybe it is somewhat better?

Barton

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:34:29 Created by robert_dodier on 2006-07-13 05:59:37 Original: https://sourceforge.net/p/maxima/bugs/447/#ec2e


Logged In: YES user_id=501686

differ package is superseded by solve_rec, which returns valid results (to the best of my knowledge) for the bug examples shown in this report. Also, the solve_rec package is documented. I've moved differ.mac and differ.dem to archive/share/trash/. Closing this report as fixed.

rtoy commented 4 months ago

Imported from SourceForge on 2024-07-05 19:34:33 Created by robert_dodier on 2006-07-13 05:59:37 Original: https://sourceforge.net/p/maxima/bugs/447/#584e