Re: Simplify and then discretize a set of equations with derivatives and integrals

• To: mathgroup at smc.vnet.net
• Subject: [mg126682] Re: Simplify and then discretize a set of equations with derivatives and integrals
• From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
• Date: Thu, 31 May 2012 02:45:50 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com

```Hi,

I'm new to Mathematica, but as I professionally have access to it, I'd
like to use it to simplify this problem.

I have a set of equations (from http://www.simulanalog.org/statevariable.pdf)
explaining how a simple electronic system works. My input is e(t) and
my output is vd(t). f(v) can be written as an exponential function
(f(v) = a * e^(b * v + c) for instance).
Here are the equations :

eqns = {e[t] - i[t] * R - vc[t] - vd[t] == 0,
vc[t] == 1/C * Integrate[i[t], t],
i[t] == f[vd[t]]}

What I'd like is first to simplify this set of equations to a simple
one with only e(t) and vd(t). At one point, I could get the correct
result, but I could get the correct result after resetting the kernel.

Once this is done, I'd like to discretize the resulting function with
the bilinear transform.

Of course, it easy to get the result by hand in this case. But my next
set of equations is so complicated that I don't want to try to solve
it (my main issue is the first step, the discretization is 'just"
symbolic computation once the replacement is done), so I'm back at
Mathematica.

Is it possible do this in Mathematica? Is it complicated to do?

Matthieu

Hi, Matthieu,

Just to give an idea of what can easily be done. You can slightly rewrite the system as follows:

Clear[t];
f[v_] := a*Exp[b*v + c];
eqns = {e[t] - i[t]*R - vc[t] - vd[t] == 0, vc'[t] == CC^-1*i[t],
i[t] == f[vd[t]]}

Here I use CC instead of C, since in Mathematica C is reserved. There are besides an syntax error in the expression f(v) = a * e^(b * v + c). In addition the second equation is differential instead of the integral.
You may then eliminate the variable i[t]:

expr = Eliminate[eqns, i[t]]

the result is:

a E^(c + b vd[t]) == CC Derivative[1][vc][t] &&
vd[t] == e[t] - vc[t] - CC R Derivative[1][vc][t] && CC != 0

Its first and second parts are your desired equations. Indeed

expr[[1]]
expr[[2]]

E^(1 + vd[t]) == Derivative[1][vc][t]

vd[t] == Sin[t] - vc[t] - Derivative[1][vc][t]

This you may solve numerically, if you fix the function e[t] and parameters to be numeric. You can discretize it, but you need not.
Instead you might better apply the built-in function NDSolve. Have a look in Menu/Help/NDSolve. To give an idea, I put below all constants equal to 1, e[t]=Sin[t], and numerically solve the obtained system:

e[t_] := Sin[t];
c = 1; b = 1; CC = 1; a = 1; R = 1;

s = NDSolve[{expr[[1]], expr[[2]], vc[0] == 0}, {vc[t], vd[t]}, {t, 0,
30}][[1]] // Quiet

Execute it. The result is expressed in terms of two InterpolatingFunctions.  To have a look what it gives, execute this:

Plot[Evaluate[{vc[t], vd[t]} /. s], {t, 0, 30}]

Finally, in this problem it was no need to exclude the variable, just solve all the three equations at once numerically.

I have chosen the initial values arbitrarily. Execute this:

e[t_] := Sin[t];
c = 1; b = 1; CC = 1; a = 1; R = 1;

s1 = NDSolve[{eqns, vc[0] == 0, vd[0] == 1, i[0] == 0}, {vc[t], vd[t],
i[t]}, {t, 0, 30}][[1]] // Quiet

and have a look at the result here:

Plot[Evaluate[{vc[t], vd[t], i[t]} /. s1], {t, 0, 30},
PlotStyle -> {Red, Green, Blue}]

Here red gives vc, green - vd and blue - i.

Have fun, Alexei

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu

```

• Prev by Date: Re: Sqrt of complex number
• Next by Date: Re: Simplify and then discretize a set of equations with derivatives and integrals
• Previous by thread: Simplify and then discretize a set of equations with derivatives and integrals
• Next by thread: Re: Simplify and then discretize a set of equations with derivatives and integrals