From: Helmut J. <jar...@ig...> - 2014-04-06 07:20:10
|
On 04/05/2014 11:16:22 PM, Leo Butler wrote: > Leo Butler <l_b...@us...> writes: > > > "Edwin Woollett" <woo...@ch...> writes: > > > >> I have tried out rkf45 with success on several problems > >> but am getting a weird error return (initial should be > >> a list of numbers) with a driven > >> simple harmonic oscillator case. The built-in rk() > >> function returns a solution without complaint. > >> -------------------------------------- > >> (%i1) fpprintprec:7$ > >> (%i2) load(rkf45); > >> (%o2) > >> > "C:/PROGRA~1/MAXIMA~3.2/share/maxima/5.31.2/share/contrib/rkf45/rkf45.mac" > >> (%i3) dx_dt : vx$ > >> (%i4) dvx_dt : -4*%pi^2*x + 100*sin(4*%pi*t + %pi/4)/(0.5 + t^2)$ > > > > After looking at rkf45.mac, the error is being thrown because > dvx_dt is > > not evaluating to a float. If you add the numer option to %i4, then > %pi > > will be coerced to a float and the integration will succeed. > > > > The error message needs to be improved because I think the > intention is > > to check to see if the odes will evaluate to floats at the initial > > conditions. > > Ted, when I replace line 112 of rkf45.mac by the following 3 lines > > if member(false,map(numberp,initial)) then error("Error: initial > should be a list of numbers, but found",initial,"instead."), > block([initial_values:apply(f_rhs,cons(xi,yi))], > if member(false,map(numberp,initial_values)) then error("Error: > odes should evaluate to a list of numbers at initial, but > found",initial_values,"instead.")), > > I get the error message > > Error: odes should evaluate to a list of numbers at initial, but found > [0,200.0*sin(0.25*%pi)-39.47841760435743] instead. > #0: > rkf45(odes=[vx,100*sin(4*%pi*t+%pi/4)/(t^2+0.5)-4*%pi^2*x],funcs=[x,vx],initial=[1,0],interval=[t,0,1],options=[])(rkf45.mac > line 114) > > Can you tell me if you see the same thing when you make the > alteration? > > Leo > Hi, having applied Leo's patch I get the strange error messages which probably needs a similar patch: (%i9) rkf45(odes = [vx,100*sin(%pi/4+4*%pi*t)/(0.5+t^2)-4*%pi^2*x], funcs = [x,vx],initial = [1,0],interval = [t,0,1],options = []) Error: interval should be a list, but found interval = [t, 0, 1] instead. #0: rkf45(odes=odes = [vx,100*sin(4*%pi*t+%pi/4)/(t^2+0.5)-4*%pi^2*x],funcs=funcs = [x,vx],initial=initial = [1,0],interval=interval = [t,0,1],options=[options = []])(rkf45.mac line 94) Helmut |