# RLC Circuit Differential Equation

• Engineering

## Homework Statement

For RLC circuit determine and solve differential equation. R, L, C, E0 values are constants, E = E(t) = E0*sin(ω*t) (E is marked as V in the image). Then make program which calculates values of I(t) when R, L, C, E0, ω are given.
In short, I need to get function I(t), so I could get values at given time steps to plot graph.

## Homework Equations

Kirchoff's Voltage Law

## The Attempt at a Solution

Most of this was provided by our teacher, but I'm still having troubles solving it (I generally suck at math).
We've got this equation which is built off R, L, C, E components ( I = I(t) ):

LI' + RI + 1/C * ∫Idt = E0*sin(ω*t)

Then got differencial equation, by finding derivative (to get rid of integral):

LI'' + RI' + I/C = E0*ω*cos(ω*t)

Tried to find solution for I by combining one solution and homogeneous equation's solution (I = Ip + Ih):

Ip = a*cos(ω*t) + b*sin(ω*t), where
a = -(E0S) / (R2 + S2)
b = (E0R) / (R2 + S2)
S = ω*L - 1 / (ω*C)

Ip = I0*sin(w*t - omega), where
I0 = sqrt(a2 + b2) = E0 / sqrt(R2 + S2)
tg(omega) = - a/b = S/R

And for homogeneous part we used characteristic equation:

Ih = C1*eX1*t + C2*eX2*t
X2 + R/L*X + 1/(L*C) = 0

Solving equation above using simple discriminant:

X1 = -R/(2*L) + sqrt(R2 / L2 - 4/(L*C))
X2 = -R/(2*L) - sqrt(R2 / L2 - 4/(L*C))

Assuming when t = 0 we have I(t) = 0, inserting this into Ih we get:

C1 + C2 = 0

But that's not enough to find C1 and C2 values and this is where I got stuck. I should be able to make program, but I need to at least solve it on paper first. Hopefully someone can help me out here.

Related Engineering and Comp Sci Homework Help News on Phys.org
gneill
Mentor
You know that C1 + C2 = 0, or in other words, C2 = -C1. So eliminate one or the other in your homogeneous solution so you have a single constant. Next, you can differentiate this solution (twice) and plug the derivatives (i.e. I'', I', and I) into your original equation. Set t = 0 there. You should be able to solve for the constant.

I used C1 = -C2, so my equations became
Ih = C2(ex2t - ex1t)
Ih' = C2(x2ex2t - x1ex1t)
Ih'' = C2(x22ex2t - x12ex1t)

By "plug the derivatives into your original equation" you mean LI'' + RI' + 1/C * I = E0ωcos(ωt) ? If yes this leads to
LC2(x22ex2t - x12ex1t) + RC2(x2ex2t - x1ex1t) + 1/C * C2(ex2t - ex1t) = E0ωcos(ωt)

According to Wolfram Alpha I get some result (X = C2).

Have I done everything correctly?

gneill
Mentor
I used C1 = -C2, so my equations became
Ih = C2(ex2t - ex1t)
Ih' = C2(x2ex2t - x1ex1t)
Ih'' = C2(x22ex2t - x12ex1t)

By "plug the derivatives into your original equation" you mean LI'' + RI' + 1/C * I = E0ωcos(ωt) ? If yes this leads to
LC2(x22ex2t - x12ex1t) + RC2(x2ex2t - x1ex1t) + 1/C * C2(ex2t - ex1t) = E0ωcos(ωt)

According to Wolfram Alpha I get some result (X = C2).

Have I done everything correctly?
Yes, that's the idea. But I can't tell if everything done correctly because you only hint at your final expression for C2. But the method looks good.

Note that your 'substitution efforts' can be greatly simplified if you set t=0 in the equations before you do the substitutions. All the exponentials then become 1's and the algebra can be done without recourse to Wolfram!

Yes, that's the idea. But I can't tell if everything done correctly because you only hint at your final expression for C2. But the method looks good.
I had troubles with indexes, so I made X = C2, A = x1, B = x2, E = E0, w = ω.

Well my assignment is to make program which draws graph. R, L, C, E0, ω will be provided, t is time which will be X axis. Therefore I have to keep all these constants and variables to get correct result.
Currently it plots this. However that's only when discriminant > 0. Still have to solve when it's = 0 and < 0.

Sorry for double post if it's against rules.

Now I'm assuming D = R2/L2 - 4/(L*C) = 0, meaning both roots are x = -R/(2*L)
Therefore homogeneous equation is
Ih = C1ext+C2ext
Ih = ext(C1+C2)
Ih = Bext (C letter is already in use, using B)
Ih' = Bxext
Ih'' = Bx2ext
Trying to plug it into LI'' + RI' + 1/C * I = E0ωcos(ωt)
L(Bx2ext) + R(Bxext) + 1/C * (Bext) = E0ωcos(ωt)
Using Wolfram Alpha I find value of B (link). It seems Wolfram assumed 4L != CR2, however according to discriminant it is equal. If I specify it is equal, Wolfram cannot find solution (link).

What have I done wrong?

gneill
Mentor
Automated solvers like Wolfram Alpha can be a bit picky about the assumptions made, and if you aren't explicit they may take it into their heads to make assumptions that you didn't expect, didn't specify, and didn't want!

B should be a constant that doesn't depend on time. So to solve for B you can specify a convenient value for t. Zero is a convenient value! Specify t = 0 as a condition for the solver. Here's the result.

Hm... Interesting. For some reason I though I shouldn't specify t value. But this seems to work :D
Graph looks like this now.

Last part left, discriminant < 0. It seems my notes have more information on this case.
Lets say x1 = α + iβ and x2 = α - iβ where α = -R/(2*L) and β = sqrt(R2/L2 - 4/(L*C))

Homogeneous equation now looks like this:
Ih = C1e(α + iβ)t + C2e(α - iβ)t

Using our previous assumption of I(0) = 0 once again we get C1 = -C2
Ih = C2e(α - iβ)t - C2e(α + iβ)t

Using Euler's Formula splitting complex exponential into trigonometry functions:
Ih = C2eαt(cos(βt) - isin(βt)) - C2eαt(cos(βt) + isin(βt))
Ih = -2C2eαtisin(βt)

Notes suggest to pick complex C2 to eliminate i next to sin. So lets assume it is complex and join constants: B = 2C2i. In result we have
Ih = -Beαtsin(βt)
Ih' = -Beαtcos(βt)β
Ih'' = Beαtsin(βt)β2

Plugging into LI'' + RI' + 1/C * I = E0ωcos(ωt)
L(Beαtsin(βt)β2) + R(-Beαtcos(βt)β) + 1/C * (-Beαtsin(βt)) = E0ωcos(ωt)

Seems it's too complex for Wolfram to solve (link), I tried second iteration in second window but still same result, it just doesn't substitute α and β, then I tried Maple and result is
B = - (Eω) / (R * sqrt((R2C-4L) / (L2C)))
I wonder where all trigonometry disappeared, but result is wrong. Again. Square root is negative and whole idea of getting rid of complex numbers is gone.

Seems I really fail at this. Could you help out once more please?

gneill
Mentor
Notes suggest to pick complex C2 to eliminate i next to sin. So lets assume it is complex and join constants: B = 2C2i. In result we have
Ih = -Beαtsin(βt)
Ih' = -Beαtcos(βt)β
Ih'' = Beαtsin(βt)β2
You'll need to apply the chain rule to differentiate the function, since it is composed of the product of two functions each of which depend upon t. So, for example,

Ih' = (-α sin(βt) - β cos(βt)) B e(αt)

After you find the derivatives, plug in t=0 right away! This will clear away a LOT of clutter! Then substitute into the differential equation (and be sure to set t=0 there too!). You should be able to do the resulting algebra by hand.

I guess I rushed it too much, failed to notice variable in exponent.

Ih = -Beαtsin(βt) = 0
Ih' = -Bαeαtsin(βt) - Bβeαtcos(βt) = -Bβ
Ih'' = -Bα2eαtsin(βt) - 2Bαβeαtcos(βt) + Bβ2eαtsin(βt) = -2Bαβ

L(-2Bαβ) + R(-Bβ) + 1/C * (0) = E0ωcos(ωt)
-2LBαβ - RBβ = E0ωcos(ωt)
Bβ(-2Lα - R) = E0ωcos(ωt)
B = (E0ωcos(ωt)) / (β(-2Lα - R))
Plugging in α
B = (E0ωcos(ωt)) / (β(-2L(-R/(2L)) - R))
B = (E0ωcos(ωt)) / (β(R - R))

That's division by zero. Once again I failed somewhere :(

Last edited:
rude man
Homework Helper
Gold Member

## Homework Statement

For RLC circuit determine and solve differential equation. R, L, C, E0 values are constants, E = E(t) = E0*sin(ω*t) (E is marked as V in the image). Then make program which calculates values of I(t) when R, L, C, E0, ω are given.
In short, I need to get function I(t), so I could get values at given time steps to plot graph.

## Homework Equations

Kirchoff's Voltage Law

## The Attempt at a Solution

Most of this was provided by our teacher, but I'm still having troubles solving it (I generally suck at math).
We've got this equation which is built off R, L, C, E components ( I = I(t) ):

LI' + RI + 1/C * ∫Idt = E0*sin(ω*t)

Then got differencial equation, by finding derivative (to get rid of integral):

LI'' + RI' + I/C = E0*ω*cos(ω*t)

Tried to find solution for I by combining one solution and homogeneous equation's solution (I = Ip + Ih):

Ip = a*cos(ω*t) + b*sin(ω*t), where
a = -(E0S) / (R2 + S2)
b = (E0R) / (R2 + S2)
S = ω*L - 1 / (ω*C)

Ip = I0*sin(w*t - omega), where
I0 = sqrt(a2 + b2) = E0 / sqrt(R2 + S2)
tg(omega) = - a/b = S/R

And for homogeneous part we used characteristic equation:

Ih = C1*eX1*t + C2*eX2*t
X2 + R/L*X + 1/(L*C) = 0

Solving equation above using simple discriminant:

X1 = -R/(2*L) + sqrt(R2 / L2 - 4/(L*C))
X2 = -R/(2*L) - sqrt(R2 / L2 - 4/(L*C))

Assuming when t = 0 we have I(t) = 0, inserting this into Ih we get:

C1 + C2 = 0

But that's not enough to find C1 and C2 values and this is where I got stuck. I should be able to make program, but I need to at least solve it on paper first. Hopefully someone can help me out here.

You need two equations to obtain C1 and C2.

One of them you already have, based on i(0) = 0.

Ok, what can you say about di/dt(0+)? How about at t = 0+, I know the capacitor hasn't had any time to build up any voltage, so E is totally across R and L alone.
But since i(0+) = 0 also, iR(0+) = 0 so E must all be across L alone. So Ldi/dt(0+) = E(0+).

Now you have your two equations for C1 and C2. The rest you seem to have a good handle on.

gneill
Mentor
You need two equations to obtain C1 and C2.

One of them you already have, based on i(0) = 0.

Ok, what can you say about di/dt(0+)? How about at t = 0+, I know the capacitor hasn't had any time to build up any voltage, so E is totally across R and L alone.
But since i(0+) = 0 also, iR(0+) = 0 so E must all be across L alone. So Ldi/dt(0+) = E(0+).

Now you have your two equations for C1 and C2. The rest you seem to have a good handle on.
It's a good thought, but since the driving function is sin(ωt) , E(0+) is zero, making dI/dt at t = 0+ also zero.

rude man
Homework Helper
Gold Member

## Homework Statement

For RLC circuit determine and solve differential equation. R, L, C, E0 values are constants, E = E(t) = E0*sin(ω*t) (E is marked as V in the image). Then make program which calculates values of I(t) when R, L, C, E0, ω are given.
In short, I need to get function I(t), so I could get values at given time steps to plot graph.

## Homework Equations

Kirchoff's Voltage Law

## The Attempt at a Solution

Most of this was provided by our teacher, but I'm still having troubles solving it (I generally suck at math).
We've got this equation which is built off R, L, C, E components ( I = I(t) ):

LI' + RI + 1/C * ∫Idt = E0*sin(ω*t)

Then got differencial equation, by finding derivative (to get rid of integral):

LI'' + RI' + I/C = E0*ω*cos(ω*t)

Tried to find solution for I by combining one solution and homogeneous equation's solution (I = Ip + Ih):

Ip = a*cos(ω*t) + b*sin(ω*t), where
a = -(E0S) / (R2 + S2)
b = (E0R) / (R2 + S2)
S = ω*L - 1 / (ω*C)

Ip = I0*sin(w*t - omega), where
I0 = sqrt(a2 + b2) = E0 / sqrt(R2 + S2)
tg(omega) = - a/b = S/R

And for homogeneous part we used characteristic equation:

Ih = C1*eX1*t + C2*eX2*t
X2 + R/L*X + 1/(L*C) = 0

Solving equation above using simple discriminant:

X1 = -R/(2*L) + sqrt(R2 / L2 - 4/(L*C))
X2 = -R/(2*L) - sqrt(R2 / L2 - 4/(L*C))
Assuming when t = 0 we have I(t) = 0, inserting this into Ih we get:/
Also check math.
Looks like you divided the -b terms by 2 OK but you forgot about the +/-b^2 - 4ac terms.

rude man
Homework Helper
Gold Member
It's a good thought, but since the driving function is sin(ωt) , E(0+) is zero, making dI/dt at t = 0+ also zero.
The driving function in your all-differential equation is not E0sin(ωt). It's ωE0cos(ωt).
And so you need to rewrite your A and B equations to accord with the equation you're dealing with, not the original integro-differential equation you eliminated (quite correctly, I might add).

Last edited:
gneill
Mentor
The driving function in your all-differential equation is not E0sin(ωt). It's ωE0cos(ωt).
And so you need to rewrite your A and B equations to accord with the equation you're dealing with, not the original integro-differential equation you eliminated (quite correctly, I might add).
While it is true that the function in the differential equation is (ω/L)Eocos(ωt), which yields amps/sec2 (the 'acceleration' of the current), in the original circuit it is a voltage of the form Eosin(ωt) that drives the circuit, and that's where we must find our initial conditions. The current in the circuit and the current modeled by the differential equation must be the same. The initial conditions come from the circuit: At time t = 0 the driving voltage is zero, capacitor is uncharged and the current is zero.

Last edited:
gneill
Mentor
Okay, I've revived some braincells that have been laying dormant for lo these many years.

If the roots of the characteristic equation are complex, then they are a conjugate pair of the form $a \pm j b$. The homogeneous solution then looks like:

$I_h = C_1 e^{a + j b} + C_2 e^{a - j b}$

In our case we have $a = -\alpha$ and $b = \omega_c$ where $\omega_c = \sqrt{\omega_o^2 - \alpha^2}$

After applying Euler's relations this can be wrestled into the form:

$I_h = e^{-\alpha t} \left[ (C_1 + C_2) cos(\omega_c t) + j (C_1 - C_2)sin(\omega_c t) \right]$

In order for this to yield a real solution constants C1 and C2 must be also be a conjugate pair (Then the sum is real, and the difference imaginary but then multiplied by j to make it real).

So replace the constants (including the j) with two new arbitrary real constants:

$I_h = e^{-\alpha t} \left[ c_1 \; cos(\omega_c t) + c_2 \; sin(\omega_c t) \right]$

That's the homogeneous solution to work with. It remains to find values for its constants.

At this point you need to bring the Particular Solution back into the picture. The initial conditions that you obtain from the circuit apply to the sum of Ih and Ip. For example, I noted that the Particular Solution that you derived earlier does not yield a value of zero current for time t = 0. So the difference must be taken up by the homogeneous solution.

Set t = 0 in both Ip and Ih and equate the sum to the initial current in the circuit (we've determined that it's zero). That should yield a value for c1. Proceed to do the same for dI/dt, where you also know the initial condition. Solve for c2.

rude man
Homework Helper
Gold Member
As a preamble to admitting what I did was irrelevant, let me say that I, and you too probably, would never dream of resorting to classical diff eq's for something like this- that's because God gave us Pierre-Simon, marquis de LaPlace!

Very embarrassingn , nonetheless. Ih = C1*eX1*t + C2*eX2*t

C1 and C2 are both zero, I think we all have that figured out by now, me last. C1 and C2 are associated with the initial conditions.

So we look for - what did they call it? - the complementary function or particular integral, I don't remember.

So we "guess" i(t) = Asin(wt) + Bcos(wt) & stick that into our diff eq., equate coefficients of sin and cos, and away we go. Does that sound better, gneill?

gneill
Mentor
As a preamble to admitting what I did was irrelevant, let me say that I, and you too probably, would never dream of resorting to classical diff eq's for something like this- that's because God gave us Pierre-Simon, marquis de LaPlace!
Yep. Laplace Transforms are like putting away the bone knife and picking up a chainsaw.
Very embarrassingn , nonetheless. Ih = C1*eX1*t + C2*eX2*t

C1 and C2 are both zero, I think we all have that figured out by now, me last. C1 and C2 are associated with the initial conditions.

So we look for - what did they call it? - the complementary function or particular integral, I don't remember.

So we "guess" i(t) = Asin(wt) + Bcos(wt) & stick that into our diff eq., equate coefficients of sin and cos, and away we go. Does that sound better, gneill?
The Particular Solution will be necessary, yes, but there should still be a homogeneous solution to add to it. The complete solution is always the sum of the two. This particular problem seems to be a bugger because the initial conditions for the circuit are all zero. So there's nothing for the homogenous solution, by the usual procedure, to come to grips with. It's like saying, "here's a circuit with no charges, no currents, and no power source. What will happen?".

I finally got around that by using both the Particular Solution and the homogeneous solution together with the initial conditions to find the coefficients for the homogeneous solution. Quite a bother. It doesn't help that I'm rather rusty in the "bone knives and bearskins" approach to differential equation solving!

I took a moment to graph the resulting total solution and compared it to a spice simulation (picked suitable component values). The plots seem to match remarkably well.

Hopefully the OP will be able complete the problem in a similar manner with the hints given.

rude man
Homework Helper
Gold Member
I think you have it right.
Why don't they teach Laplace before doing these relatively complex networks I can't imagine.

On the other hand I have to admit loss of memory on the classical way to solve this sort of thing, not good if you're trying to help undergrads. Thanks for your posts.

Teacher suggested to assume I(0) = I'(0) = 0 and use same equation Ip(0) + Ih(0) = 0 for all cases, I'll post results later, if I manage to get any.

Well I've got some reason. But I don't feel they're correct. Could anyone proof-check please?

Ip=a*cos(w*t) + b*sin(w*t)
Ip' = -a*w*sin(w*t) + b*w*cos(w*t)
Ip(0) = a
Ip'(0) = b*w

Discriminant > 0
Ih = C1 * e^At + C2 * e^Bt
Ih' = C1 * A * e^At + C2 * B * e^Bt
Ih(0) = C1 + C2
Ih' = C1 * A + C2 * B
Solving Ip(0) + Ih(0) = 0 and Ip'(0) + Ih'(0) = 0 results in C2 = (b*w-a*A)/(A*B), C1 = -C2 - a

Discriminant = 0
Ih = e^Xt(C1 + C2*t)
Ih' = e^Xt(C1*X + C2 + C2*X)
Ih(0) = C1
Ih'(0) = C1*X + C2 + C2*X
Solving Ip(0) + Ih(0) = 0 and Ip'(0) + Ih'(0) = 0 results in C1 = -a, C2 = (-b*w+a*X)/(1+X)

Discriminant < 0
Ih = e^αt*cos(βt)*(C1 + C2) + e^αt*i*sin(βt)*(C1 - C2)
Defining B1 = (C1 + C2), B2 = i(C1 - C2)
Ih = B1*e^αt*cos(βt) + B2*e^αt*sin(βt)
Ih' = e^(t*α)*((B1*α + B2*β)*cos[t*β] + (B2*α - B1*β)*sin[t*β])
Ih(0) = B1
Ih'(0) = B1*α + β * B2
Solving Ip(0) + Ih(0) = 0 and Ip'(0) + Ih'(0) = 0 results in B1 = -a, B2 = (α*α - b*w)/β

Graphs of D>0 and D=0 look similar, only D<0 is different, therefore I feel it's wrong.

rude man
Homework Helper
Gold Member
Since gneill is obviously doing a much better job than I at handling the classical solution, I will just provide the answer from the Laplace analysis. I like to use lower case for time variables and upper case for the corresponding transformed variables:

e(t) = e0sin(ωt)
so E(s) = e0ω/(s2+ω2)
Then
I(s) = E(s)/(sL + R + 1/sC) = e0ω/[(s2+ω2)(sL+R+1/sC)] or

I(s) = s(e0C/ω)/[(1+s2/ω2)(s2LC + RCs + 1)

Let
w^2 = 1/LC
2ζ/w = RC

Then I(s) = s(e0C/ω)/[(1+s2/ω2)(1+2ζs/w+s2/w2)]

Let
ψ1 = arc tan(2ζωw/(w2-ω2)
ψ2 = -arc tan{√[(1-ζ2)]/(-ζ)} - arc tan{(2ζw2√(1-ζ2)/(ω2 + 2(ζ2)(w2 - w2)}

Let A = (e0/R)(2ζωw)/√[(ω2-w2)^2 + 4(ζ2)(ω2)(w2)]

Then i(t) = A{cos(ωt - ψ1) + [exp(-t/T)/√(1-ζ2)]sin[w√(1-ζ2)t - ψ2]}
where T = 1/wζ.

Notes:
If ω = w and R = 2ζ = 0, i = ∞. This is the case for an undamped circuit excited by its resonant frequency. If ω = w, i = e/R as expected.

The first term in i(t) is the steady-state solution, corresponding to the A and B used by the OP. (Note that cos(ωt - ψ1) = cosωtcosψ1 + sinωtsinψ1 etc).

The second term is the transient solution corresponding to the OP's C1 and C2 . The transient envelope dies down with time constant T.

Maybe gneill will check it out?