Changes between Version 3 and Version 5 of Ticket #11653


Ignore:
Timestamp:
08/06/11 02:09:19 (9 years ago)
Author:
kcrisman
Comment:

Thanks, Jose! Just a few pointers:

  • You can use some formatting to do stuff here. There are links on the main Trac page, but the most useful one is putting code examples in triples { braces.
  • The 'author' is the author of the patch. You are the reporter :) though perhaps also the eventual author as well!

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #11653

    • Property Cc kcrisman nbruin added; sjm.guzman@… removed
    • Property Keywords maxima at desolve added
    • Property Authors changed from JGuzman to
  • Ticket #11653 – Description

    v3 v5  
    11When trying to solve a simple ODE whose rhs contains a function, Sage fails to interpret the Maxima output.
    22
    3 Here a minimal example is  #========================================================================= sage: x=var('x') # independent variable
    4 
     3Here a minimal example is 
     4{{{
     5#=====================
     6sage: x=var('x') # independent variable
    57sage: v=function('v', x) # dependent variable
    68
    79# we define a custom square pulse function
    8 
    910def pulse(tonset, tdur, amp):
    10 
    11   """ 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 """
    12 
     11"""
     12returns a square pulse as a function of x, f(x)
     13the pulse is defined as follows: 
     14t onset -- start of pulse 
     15tdur   -- duration of pulse 
     16amp    -- amplitude of pulse
     17"""
    1318  f(x)= amp*(sign(x-tonset)/2-sign(x-tonset-tdur)/2)
    14 
    1519  return f
    1620
    1721# create my pulse function
    18 
    1922sage: mypulse = pulse(tonset=5, tdur=5, amp=2)
    2023
    2124# define differential equation s
    22 
    2325sage: dvdx = diff(v, x)-x -mypulse == 0 # mypulse(x) is function
    2426
    2527# get the evolution of v
    26 
    2728myvolt = desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])
    2829
    29 #========================================================================= The error message is:
     30#=======
     31The error message is:
    3032
    3133''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^''
    32 
     34}}}
    3335desolve_laplace leads to similar error:
    34 
     36{{{
    3537sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[0,0])
    3638
    3739''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''
    38 
     40}}}
    3941According 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.
    4042
    4143Strange enough, when using other functions, the solver works nicely
    42 
     44{{{
    4345sage: dvdx = diff(v, x)-x -sin(x) == 0
    4446
    4547sage: desolve(de=dvdx, ivar=x, dvar=v, ics=[http://trac.sagemath.org/sage_trac/log/?revs=0 "[0,0]"])
    46 
     48}}}
    4749now Sage returns 1/2*x!^2 - cos(x) + 1
    4850