Changes between Version 7 and Version 8 of Ticket #11653


Ignore:
Timestamp:
08/07/11 15:32:29 (9 years ago)
Author:
JGuzman
Comment:

I changed the summary to delimit the error more carefully. Additional, a more detailed explanation is given of cases in which Sage is able to interpret Maxima output. I guess, the problem is that Sage is not able to interpret the integration limits prompted by the maxima expression.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11653

    • Property Summary changed from desolve failed to solve an ODE whose rhs contains a function to desolve failed to solve an ODE whose solution implies integration limits
    • Property Owner changed from burcin to JGuzman
  • 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.
     1When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output if this contains integration limits.
    22
    3 Here a minimal example is
     3== A minimal example ==
    44
    55{{{
     
    77sage: v=function('v', x) # dependent variable
    88}}}
     9if we now define a custom square pulse function
    910
    10 # we define a custom square pulse function
    1111{{{
     12#!python
    1213def pulse(tonset, tdur, amp):
    13 """
     14    """
    1415    returns a square pulse as a function of x, f(x)
    1516    the pulse is defined as follows: 
     
    1819    amp    -- amplitude of pulse
    1920    """
     21
    2022    f(x)= amp*(sign(x-tonset)/2-sign(x-tonset-tdur)/2)
    2123    return f
    2224}}}
     25now we create a pulse function
    2326
    24 now we create a pulse function
    2527{{{
    2628sage: mypulse = pulse(tonset=5, tdur=5, amp=2)
    2729}}}
    28 and define differential equation
     30and define differential equation
     31
    2932{{{
    3033sage: dvdx = diff(v, x)-x -mypulse == 0 # mypulse(x) is function
    3134}}}
     35To get the evolution of v we can use **desolve**
    3236
    33 To get the evolution of v we can use **desolve**
    3437{{{
    3538myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])
    3639}}}
    37 
    38 
    3940The error message is:
    4041
    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^''
     42{{{
     43#!python
     44TypeError: 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^
     45}}}
    4246
    4347desolve_laplace leads to similar error:
     
    4751}}}
    4852
    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''
     53{{{
     54#!python
     55TypeError: 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
     56}}}
    5057
    5158According 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.
    5259
    53 Strange enough, when using other functions, the solver works nicely
     60== Expressions that work ==
     61And adding the '''sign''' function to the differential function does not affect the solution.
    5462
    5563{{{
    56 sage: dvdx = diff(v, x)-x -sin(x) == 0
     64sage: dvdx = diff(v, x)-v -sign(x) == 0
    5765sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0]"])
     66sage: (c + integrate(e^(-x)*sgn(x), x))*e^x
    5867}}}
    5968
    60 now Sage returns 1/2*x!^2 - cos(x) + 1
     69However, adding initial conditions produces an output that Sage is not able to evaluate
    6170
    62 Detailed information (and a real example) can be found here: http://groups.google.com/group/sage-support/browse_thread/thread/8cc67d39510faca2
     71{{{
     72sage: desolve(de = dvdx, ivar=x, dvar=v, ics=[0,0])
     73}}}
     74
     75The output is:
     76{{{
     77#!python
     78TypeError: 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
     82I guess Sage is not able to interpret the integrations limits prompted by Maxima (e.g [t=0,v(t)=0]).
     83
     84Detailed information (and a more realistic example) can be found here: http://groups.google.com/group/sage-support/browse_thread/thread/8cc67d39510faca2