Thanks Robert, this seems to be the problem. I wish I were a lisp programmer so that I could dive into Maxima and put in a call to coerce-float-fun myself, but while I'm eager to tinker with this, I'm not sure I can be succesful in a reasonable amount of time.
In the meantime, I will write my own little RK4 routine in python -- while browsing the mailing list yesterday I read about "fast_float", so I have good hopes that the result will be fast. Sage is so powerful! Thanks a lot for your time, Joris Vankerschaver On 19 apr, 20:52, Robert Dodier <robert.dod...@gmail.com> wrote: > Looks like the rk function in Maxima doesn't try hard enough to > float-ify its argument. I haven't looked at the code, but > maybe rk can call COERCE-FLOAT-FUN to construct a > function to evaluate the expression. At least that would > bring it into line with other Maxima functions which > evaluate expressions to numbers (e.g. plotting, quadpack). > > Follow-ups to the Maxima mailing list. I've appended > the original message below. > > best > > Robert Dodier > > PS. > > On Apr 19, 8:38 am, jvkersch <joris.vankerscha...@gmail.com> wrote: > > > > > Technically, this is not a Sage problem, but I figured I would post it > > here anyway since others might have run into the same problem, and I'm > > also trying to solve the problem using some Sage/python trickery. > > > The problem concerns the use of symbolic constants such as pi in > > numerical integration with desolve_rk4. The following code is adapted > > from the manual page for desolve_rk4 -- note especially the constant > > pi in the specification of the ODE: > > > x, y = var('x y') > > desolve_rk4(x*y*(2-y) + pi, y, ics=[0, 1], end_points=1, step=0.5) > > > and raises the following error: > > > TypeError: Error executing code in Maxima > > CODE: > > sage1 : rk(%pi-x*(y-2)*y,y,1,[x,0,1,0.500000000000000]) $ > > Maxima ERROR: Inconsistent set of equations and variables > > > This same error occurs whenever you have an ODE with pi in it, no > > matter how simple. The error persists when directly running this > > command in Maxima, but works fine (both in Sage and Maxima) when > > manually replacing pi by 3.14... Since I don't know any Maxima, I > > have no idea of what the problem could be or where to look. > > > So, I was wondering if there is a way to have Sage replace the %pi > > when invoking Maxima by the corresponding numerical value? I guess I > > could store my ODE in a string and use a regular expression to get rid > > of any pi's myself, but that seems very inelegant. Is there anything > > you would recommend? > > > Thanks a lot, > > Joris > > -- > To post to this group, send email to sage-support@googlegroups.com > To unsubscribe from this group, send email to > sage-support+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/sage-support > URL:http://www.sagemath.org -- To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org