Simplifying ODE solutions by introducing arbitrary constants
Subject: Simplifying ODE solutions by introducing arbitrary constants
From: Aleksas Domarkas
Date: Wed, 23 Oct 2013 23:04:33 +0300
On Wed, 23 Oct 2013 15:38:30 +0100
Jaime Villate <villate at fe.up.pt>
wrote:
Hi,
if you already know this and it does not answer your question I
apologize (I have not looked at the thread you refer), but just in case,
have you tried using atvalue?:
(%i2) atvalue(f(x),x=0,%c1)$
(%i3) atvalue('diff(f(x),x,1),x=0,%c2)$
(%i4) atvalue('diff(f(x),x,2),x=0,%c3)$
(%i5) desolve('diff(f(x),x,3)-2*'diff(f(x),x,2)+'diff(f(x),x)=0, f(x));
(%o5) f(x) = %c3*x*%e^x-%c2*x*%e^x+(2*%c2-%c3)*%e^x+%c3-2*%c2+%c1
Regards,
Jaime
On 23-10-2013 13:57, Robert Pollak wrote:
> Hello list,
>
> referring to ODE solutions like
>
> (%i1) desolve('diff(f(x),x,3)-2*'diff(f(x),x,2)+'diff(f(x),x)=0, f(x));
> (%o1)
>
f(x)=x*%e^x*(at('diff(f(x),x,2),x=0))+at('diff(f(x),x,2),x=0)+%e^x*(2*(at('diff(f(x),x,1),x=0))-at('diff(f(x),x,2),x=0))-x*%e^x*(at('diff(f(x),x,1),x=0))-2*(at('diff(f(x),x,1),x=0))+f(0)
>
> , Dan Stanger unsuccessfully asked this list in 2006 [1]:
>> Does anyone know a convenient way of converting from the form
>> returned from desolve, to the form involving arbitrary constants?
>
> For my teaching, I would now need the same: some way to replace all the
> 'at' terms by constants %c1 to %cn to get a form like
>
> f(x)=%c1+%c2*%e^x+%c3*x*%e^x
>
> . I don't want to raise any expectations, but: If someone wrote a Maxima
> patch (presumably to src/desoln.lisp [2]) to get this functionality,
> would it be ok to offer it via a keyword (e.g. 'mergeconst') as optional
> 'desolve' parameter?
>
>
> Best regards,
> Robert Pollak
I have created a package "odes". Some examples:
(%i1) load(odes);
(%o1) "C:/Users/Aleksas/maxima/odes.mac"
(%i2) load(contrib_ode)$
Example 1 f'''-2f''+f=0
(%i3) eq:eq:'diff(f,x,3)-2*'diff(f,x,2)+'diff(f,x) = 0$
(%i4) sol:odeL(eq,f,x);
(%o4) f=x*%e^x*C3+%e^x*C2+C1
Example 2
y''''-y=8*exp(x), y(0)=0, y'(0)=2, y''(0)=4, y'''(0)=6.
Maple: dsolve({diff(y(x), x$4)-y(x) = 8*exp(x), y(0) = 0, (D(y))(0) = 2,
((D@@2)(y))(0) = 4, ((D@@3)(y))(0) = 6})
Maxima:
(%i152) eq:'diff(y,x,4)-y=8*exp(x);
(%o152) 'diff(y,x,4)-y=8*%e^x
(%i153) odeL(eq,y,x);
(%o153) y=sin(x)*C4+cos(x)*C3+%e^x*C2+%e^(-x)*C1+2*x*%e^x
(%i154) odeL_ic('diff(y,x,4)-y=8*exp(x),y,x,[0,0,2,4,6]);
(%o154) y=2*x*%e^x
Example 3
(%i3) eq:'diff(f,x,3)-3*'diff(f,x,2)+f=sin(x)^3;
(%o3) 'diff(f,x,3)-3*('diff(f,x,2))+f=sin(x)^3
(%i4) sol:odeL(eq,f,x);
(%o4)
f=%e^(2*cos((7*%pi)/9)*x+x)*C3+%e^(2*cos((5*%pi)/9)*x+x)*C2+%e^(2*cos(%pi/9)*x+x)*C1-(28*sin(3*x)+27*cos(3*x)-1068*sin(x)-267*cos(x))/6052
Test:
(%i5) ode_check(eq,sol);
(%o5) 0
Maple, Mathematica - ???
best
Aleksas D