Skip to content

desolve failed to solve an ODE whose solution implies integration limits #11653

Open
@sagetrac-JGuzman

Description

@sagetrac-JGuzman

When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output if this contains integration limits.

A minimal example

sage: x=var('x') # independent variable
sage: v=function('v', x) # dependent variable

if we now define a custom square pulse function

def pulse(tonset, tdur, amp):
    """
    returns a square pulse as a function of x, f(x) 
    the pulse is defined as follows:  
    t onset -- start of pulse  
    tdur   -- duration of pulse  
    amp    -- amplitude of pulse 
    """

    f(x)= amp*(sign(x-tonset)/2-sign(x-tonset-tdur)/2)
    return f

now we create a pulse function

sage: mypulse = pulse(tonset=5, tdur=5, amp=2)

and define differential equation

sage: dvdx = diff(v, x)-x -mypulse == 0 # mypulse(x) is function

To get the evolution of v we can use desolve

myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])

The error message is:

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

desolve_laplace leads to similar error:

sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])
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

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.

Expressions that work

And adding the sign function to the differential function does not affect the solution.

sage: dvdx = diff(v, x)-v -sign(x) == 0 
sage: desolve(de=dvdx, ivar=x, dvar=v) 
sage: (c + integrate(e^(-x)*sgn(x), x))*e^x

However, adding initial conditions produces an output that Sage is not able to evaluate

sage: desolve(de = dvdx, ivar=x, dvar=v, ics=[0,0])

The output is:

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

I guess Sage is not able to interpret the integrations limits prompted by Maxima (e.g [t=0,v(t)=0]).

Detailed information (and a more realistic example) can be found here: http://groups.google.com/group/sage-support/browse_thread/thread/8cc67d39510faca2

CC: @kcrisman @nbruin

Component: calculus

Keywords: maxima, at, desolve

Issue created by migration from https://trac.sagemath.org/ticket/11653

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions