Changes between Version 5 and Version 7 of Ticket #11653
- Timestamp:
- 08/06/11 08:15:33 (9 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #11653 – Description
v5 v7 1 1 When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output. 2 2 3 Here a minimal example is 3 Here a minimal example is 4 4 5 {{{ 5 #=====================6 6 sage: x=var('x') # independent variable 7 7 sage: v=function('v', x) # dependent variable 8 }}} 8 9 9 10 # we define a custom square pulse function 11 {{{ 10 12 def pulse(tonset, tdur, amp): 11 13 """ 12 returns a square pulse as a function of x, f(x) 13 the pulse is defined as follows: 14 t onset -- start of pulse 15 tdur -- duration of pulse 16 amp -- amplitude of pulse 17 """ 18 f(x)= amp*(sign(x-tonset)/2-sign(x-tonset-tdur)/2) 19 return f 14 returns a square pulse as a function of x, f(x) 15 the pulse is defined as follows: 16 t onset -- start of pulse 17 tdur -- duration of pulse 18 amp -- amplitude of pulse 19 """ 20 f(x)= amp*(sign(x-tonset)/2-sign(x-tonset-tdur)/2) 21 return f 22 }}} 20 23 21 # create my pulse function 24 now we create a pulse function 25 {{{ 22 26 sage: mypulse = pulse(tonset=5, tdur=5, amp=2) 27 }}} 28 and define differential equation 29 {{{ 30 sage: dvdx = diff(v, x)-x -mypulse == 0 # mypulse(x) is function 31 }}} 23 32 24 # define differential equation s 25 sage: dvdx = diff(v, x)-x -mypulse == 0 # mypulse(x) is function 33 To get the evolution of v we can use **desolve** 34 {{{ 35 myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]) 36 }}} 26 37 27 # get the evolution of v28 myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])29 38 30 #=======31 39 The error message is: 32 40 33 41 ''TypeError: unable to make sense of Maxima expression 'v(x)=-(2*(at(integrate(signum(x-5)-signum(x-13),x),[x=0,v(x)=0]))-2*int\ egrate(signum(x-5)-signum(x-13),x)-x^2)/2' in Sage^'' 34 }}} 42 35 43 desolve_laplace leads to similar error: 44 36 45 {{{ 37 46 sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]) 47 }}} 38 48 39 49 ''TypeError: unable to make sense of Maxima expression 'ilt(((laplace(signum(x-5),x,?g2733)-laplace(signum(x-13),x,?g2733)+v(0)\ )*?g2733^2+1)/?g2733^3,?g2733,x)' in Sage'' 40 }}} 50 41 51 According to Nils Bruin, the problem is that Maxima 'at' function. As described in Ticket #385, this can be a problem with the implementation of 'at' for SR. 42 52 43 53 Strange enough, when using other functions, the solver works nicely 54 44 55 {{{ 45 56 sage: dvdx = diff(v, x)-x -sin(x) == 0 57 sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]"]) 58 }}} 46 59 47 sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[http://trac.sagemath.org/sage_trac/log/?revs=0 "[0,0]"])48 }}}49 60 now Sage returns 1/2*x!^2 - cos(x) + 1 50 61