Enhanced Laplace transforms and desolve for Maxima
Subject: Enhanced Laplace transforms and desolve for Maxima
From: Mark H Weaver
Date: Thu, 20 Jan 2011 01:51:47 -0500
I've been working on improving our support for Laplace transforms and
inverse Laplace transforms. Michael and Razif, I've CC'd you because,
as you will see below, these improvements solve your recent problems
with Maxima more satisfactorily.
The attached preliminary patches and new files provide the following
improvements:
* Added hstep(x), a simplifying Heaviside step function which is like
unit_step(x) except that hstep(0)=1/2.
* laplace(expr,t,s) now supports expressions containing step functions,
and also now distributes itself over lists and matrices.
* ilt(expr,s,t) is now able to return Dirac delta when the expression is
free of s.
* Added pwilt(expr,s,t), an improved inverse Laplace transform, which is
able to return piecewise and periodic functions, and also handles some
cases where ilt() fails, e.g. where the degree of the denominator is
greater than 3.
* Added support for hstep(x) to abs_integrate.mac.
* Modified desoln.mac to use pwilt() instead of ilt().
Note that this is a work in progress, and probably not yet ready for
submission. I have decided to post them now because they solve the
following problems from Razif Razali and Michael Heidinger.
razif razali <razif66 at gmail.com> wrote:
> eq1:diff(f(s),s)=-sqrt(3)*g(s)*k$
> eq2:diff(g(s),s)=k*(sqrt(3)*f(s)-2^(3/2)*h(s))$
> eq3:diff(h(s),s)=k*(2^(2/3)*g(s)-3*l(s))$
> eq4:diff(l(s),s)=3*k*h(s)$
>
> atvalue(f(s),s=0,f610)$
> atvalue(g(s),s=0,0)$
> atvalue(h(s),s=0,1/2*sqrt(3)*k*f610/sqrt(2))$
> atvalue(l(s),s=0,0)$
>
> desolve([eq1,eq2,eq3,eq4],[f(s),g(s),h(s),l(s)]);
With these enhancements, the commands above now produce the correct
solution. I recommend using radcan(%) to simplify the results.
Michael Heidinger <mch.heidinger at gmx.de> wrote:
> Well, I want to simulate an electrical circuit, which has two
> operation condition, each of them is discribed with a diffential
> equation. After a certain time i want to switch to the other equation.
> 1. Equation: 'diff(I,t)=(U-R*I)/L (eg. 1 second in this operating
> mode=t_equation1)
> 2. Equation: 'diff(I,t)=-(R*I+U)/L (eg. 2 second in this operation
> mode=t_equation2)
[...]
> I want to stay in eq1 for x seconds, than switch over to eq2, stay
> there y seconds, and then switch over to eq1 and stay there x seconds,
> and so on. I think you understand what I mean.
With these enhancements, the following commands will do this job:
load(desoln);
de: diff(I(t),t) = -R*I(t)/L + U/L*(-hstep(t)+2*sum(hstep(t-k*y-k*x)-hstep(t-k*y-k*x-x), k,0,n));
de1: de, n=20, x=1, y=2, simpsum;
sol: desolve(de1,I(t));
sol1: sol, I(0)=0, R=1, L=1, U=1;
plot2d(rhs(sol1),[t,0,10]);
The patches and new files are attached below. The patches are against
the 5.23 branch.
Note that the new laplac.lisp must be recompiled into the executable.
At least on my system (using GCL), I am not able to dynamically load the
modified version, due to issues with proclaimed special variables.
However, the changes to laplac.lisp are only needed if you use piecewise
functions. Even if you do, it *may* be sufficient to simply load
abs_integrate.mac, since laplace() will fall back to integration if all
else fails, though that method is less efficient and may fail.
Comments and suggestions welcome.
Mark
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hstep.lisp
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110120/3faee652/attachment-0002.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: pwilt.lisp
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110120/3faee652/attachment-0003.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: laplac.diff
Type: text/x-diff
Size: 2617 bytes
Desc: laplac.lisp patch
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110120/3faee652/attachment-0003.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: abs_integrate.diff
Type: text/x-diff
Size: 6200 bytes
Desc: abs_integrate.mac patch
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110120/3faee652/attachment-0004.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: desoln.diff
Type: text/x-diff
Size: 598 bytes
Desc: desoln.mac patch
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20110120/3faee652/attachment-0005.diff>