# Solve ODE with initial values using Laplace transform

I am trying to solve ordinary differential equations with initial conditions using Laplace transform. A simple test setup includes

• an exponential discharge of RC circuit and

• an integrator from coil and voltage source.

While the result of the first example is as expected, the second one is not. What am I missing?

Matlab code:

function ilap_test

syms s RC vc vc0 il il0 L vin

% vc_dot = -1/RC * vc      exponential discharge
% il_dot = 1/L * vin       current integrator

% s*vc - vc0 = -1/RC * vc  % transform with initial conditions
% s*il - il0 = 1/L * vin

vc = vc0/(s + 1/RC);
il = vin/L/s + il0/s;

simplify(ilaplace(vc))
% vc0*exp(-t/RC)        (ok)

simplify(ilaplace(il))
% il0 + vin/L           shouldn't this be il0 + vin/L*t ???

• I'm voting to close this question as off-topic because it belongs on math.SE. – David Ketcheson Aug 28 '16 at 3:32

Not all right hand sides are created equal. Arranging by degree of derivative:

x_dot      x             const

vc_dot     + 1/RC*vc     + 0         = 0
il_dot                   - 1/L*vin   = 0


Laplace transform:

s*vc - vc0     + 1/RC*vc                 = 0
s*il - il0                   -1/L*vin/s  = 0  % const div by s was missing


Solve:

vc = vc0/(s + 1/RC)
il = il0 + vin/L/s^2


Back-transform:

vc = vc0*exp(-t/RC)
il = il0 + t*vin/L