Changes between Version 7 and Version 8 of Ticket #11653
 Timestamp:
 08/07/11 15:32:29 (9 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Ticket #11653

Property
Summary
changed from
desolve failed to solve an ODE whose rhs contains a function
todesolve failed to solve an ODE whose solution implies integration limits
 Property Owner changed from burcin to JGuzman

Property
Summary
changed from

Ticket #11653 – Description
v7 v8 1 When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output .1 When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output if this contains integration limits. 2 2 3 Here a minimal example is 3 == A minimal example == 4 4 5 5 {{{ … … 7 7 sage: v=function('v', x) # dependent variable 8 8 }}} 9 if we now define a custom square pulse function 9 10 10 # we define a custom square pulse function11 11 {{{ 12 #!python 12 13 def pulse(tonset, tdur, amp): 13 """14 """ 14 15 returns a square pulse as a function of x, f(x) 15 16 the pulse is defined as follows: … … 18 19 amp  amplitude of pulse 19 20 """ 21 20 22 f(x)= amp*(sign(xtonset)/2sign(xtonsettdur)/2) 21 23 return f 22 24 }}} 25 now we create a pulse function 23 26 24 now we create a pulse function25 27 {{{ 26 28 sage: mypulse = pulse(tonset=5, tdur=5, amp=2) 27 29 }}} 28 and define differential equation 30 and define differential equation 31 29 32 {{{ 30 33 sage: dvdx = diff(v, x)x mypulse == 0 # mypulse(x) is function 31 34 }}} 35 To get the evolution of v we can use **desolve** 32 36 33 To get the evolution of v we can use **desolve**34 37 {{{ 35 38 myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]) 36 39 }}} 37 38 39 40 The error message is: 40 41 41 ''TypeError: unable to make sense of Maxima expression 'v(x)=(2*(at(integrate(signum(x5)signum(x13),x),[x=0,v(x)=0]))2*int\ egrate(signum(x5)signum(x13),x)x^2)/2' in Sage^'' 42 {{{ 43 #!python 44 TypeError: unable to make sense of Maxima expression 'v(x)=(2*(at(integrate(signum(x5)signum(x13),x),[x=0,v(x)=0]))2*int\egrate(signum(x5)signum(x13),x)x^2)/2' in Sage^ 45 }}} 42 46 43 47 desolve_laplace leads to similar error: … … 47 51 }}} 48 52 49 ''TypeError: unable to make sense of Maxima expression 'ilt(((laplace(signum(x5),x,?g2733)laplace(signum(x13),x,?g2733)+v(0)\ )*?g2733^2+1)/?g2733^3,?g2733,x)' in Sage'' 53 {{{ 54 #!python 55 TypeError: unable to make sense of Maxima expression 'ilt(((laplace(signum(x5),x,?g2733)laplace(signum(x13),x,?g2733)+v(0)\ )*?g2733^2+1)/?g2733^3,?g2733,x)' in Sage 56 }}} 50 57 51 58 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. 52 59 53 Strange enough, when using other functions, the solver works nicely 60 == Expressions that work == 61 And adding the '''sign''' function to the differential function does not affect the solution. 54 62 55 63 {{{ 56 sage: dvdx = diff(v, x) x sin(x) == 064 sage: dvdx = diff(v, x)v sign(x) == 0 57 65 sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]"]) 66 sage: (c + integrate(e^(x)*sgn(x), x))*e^x 58 67 }}} 59 68 60 now Sage returns 1/2*x!^2  cos(x) + 1 69 However, adding initial conditions produces an output that Sage is not able to evaluate 61 70 62 Detailed information (and a real example) can be found here: http://groups.google.com/group/sagesupport/browse_thread/thread/8cc67d39510faca2 71 {{{ 72 sage: desolve(de = dvdx, ivar=x, dvar=v, ics=[0,0]) 73 }}} 74 75 The output is: 76 {{{ 77 #!python 78 TypeError: unable to make sense of Maxima expression 'v(x)=e^x*integrate(e^x*signum(x),x)e^x*(at(integrate(e^x*signum(x),x),[x=0,v(x)=0]))' in Sage 79 80 }}} 81 82 I guess Sage is not able to interpret the integrations limits prompted by Maxima (e.g [t=0,v(t)=0]). 83 84 Detailed information (and a more realistic example) can be found here: http://groups.google.com/group/sagesupport/browse_thread/thread/8cc67d39510faca2