|
From: Barton W. <wi...@un...> - 2025-11-24 16:23:21
|
The share package solve_rec is also unable to handle your recursion: (%i1) load(solve_rec)$ (%i2) display2d : false$ (%i3) solve_rec(a[n]=n/(n+1)*a[n-1], a[n]); (%o3) a[n] = %k[1]/(n+1) (%i4) solve_rec((n+1)*f[n]-(n-1)*f[n-1]=(n+1)/(n-1),f[n]); expt: undefined: 0 to a negative exponent. #0: solve_rec_lin_1(%a=n^2/(n^2+2*n),%b=n/(n^2+2*n)+2/(n^2+2*n),%f=f,%n=n,cond=[]) (solve_rec.mac line 341) #1: solve_rec_order_1(std_form=shift_op(f,n,1)*n^2-shift_op(f,n,0)*n^2+2*shift_op(f,n,1)*n-n-2,%f=f,%n=n,cond=[]) (solve_rec.mac line 199) #2: solve_rec(eq=(n+1)*f[n]-f[n-1]*(n-1) = (n+1)/(n-1),fn=f[n],cond=[]) (solve_rec.mac line 180) -- an error. To debug this try: debugmode(true) ________________________________ From: Barton Willis via Maxima-discuss <max...@li...> Sent: Sunday, November 23, 2025 12:31 PM To: max...@li... <max...@li...>; Daniel Volinski <dan...@ya...> Subject: Re: [Maxima-discuss] Fail to understand result of funcsolve Caution: Non-NU Email Guess: funcsolve doesn't properly check that solve returned an empty solution, making all the unknowns, including %0 undetermined. My evidence: (%i2) trace(solve); (%o2) [solve] Here solve returns the empty list, but it goes ahead and returns a bogus solution: %i3) funcsolve((n+1)*f(n)-(n-1)*f(n-1)=(n+1)/(n-1),f(n)); 1" Enter "solve" "[[%1-%0-1,2*%2-2*%1+4*%0-1,-%2+3*%1-5*%0,4*%0-%1,-%0],[%2,%1,%0]] 1" Exit "solve" "[] (%o3) f(n)=(%0*n^2+%1*n+%2)/((n-1)*(n+1)) Here solve finds a solution and returns a correct solution: (%i4) funcsolve(f(n+1) - f(n) = (n^2+5*n+1)/((n+2)*(n+3)),f(n)); 1" Enter "solve" "[%+1,%] 1" Exit "solve" "[%=-1] 1" Enter "solve" "[%-1,%] 1" Exit "solve" "[%=1] 1" Enter "solve" "[[-%2+2*%1+2*%0-1,5*%0-5,%0-1],[%2,%1,%0]] solve: dependent equations eliminated: (3) 1" Exit "solve" "[[%2=%r1,%1=(%r1-1)/2,%0=1]] (%o4) f(n)=(2*n^2+%r1*n-n+2*%r1)/(2*(n+2)) Maybe you could file a bug report—even better, maybe you could fix the bug too. ________________________________ From: Daniel Volinski via Maxima-discuss <max...@li...> Sent: Sunday, November 23, 2025 10:02 AM To: max...@li... <max...@li...> Subject: [Maxima-discuss] Fail to understand result of funcsolve Caution: Non-NU Email Hi All, I have the following lines: eq:(n+1)*f(n)-(n-1)*f(n-1)=(n+1)/(n-1); funcsolve(eq,f(n)); I get the following result: (n+1)*f(n)-f(n-1)*(n-1) = (n+1)/(n-1) f(n) = (%0*n^2+%1*n+%2)/((n-1)*(n+1)) What is the meaning of %0, %1, %2 in this result? Thanks, Daniel Volinski |