# Circuit Theory/1Source Excitement/Example 7/code

In Matlab:

```R = 10;
L = .01;
w = 377;
Vm = 120*2^.5;
omega = 2*pi/3;
Im = Vm/(R^2+(L*w)^2)^.5;
alpha = omega - atan(L*w/R);
syms t A C;
I = Im * cos(w*t+alpha) + A*exp(-t/(L/R)) + C;
leftSide = Vm*cos(w*t + omega) - I*R;
rightSide = L * diff(I,t);
vpa(leftSide, 3);
vpa(rightSide,3);
t=0;
teq = subs(leftSide) - subs(rightSide)
vpa(teq,3)
Ieval = subs(I);
vpa(Ieval,3)
S = solve(Ieval,teq,A,C);
S = [S.A S.C];
vpa(S(1),3)
vpa(S(2),3)
```

In MuPad and MatLab (have to cut and paste)

```R := 10;
L := .01;
w := 377;
Vm := 120*2^.5;
omega := 2*pi/3;
Imagnitude := Vm/(R^2+(L*w)^2)^.5;
alpha := omega - atan(L*w/R);
Itime := Imagnitude * cos(w*t+alpha) + A*exp(-t/(L/R)) + C;
dItime := diff(Itime,t);
t:=0;
numeric::solve([Itime=0,Vm*cos(w*t + omega) - Itime*R -  L * dItime = 0],[A,C],FixedPrecision)

sig1 = 5.986596875*sin(2*pi/3 - atan(0.377));
sig2 = cos(2*pi/3 - atan(0.377));
A = -16.97056275*cos(2*pi/3) - 2.775557562*10^-17*sig2 - sig1
C =   16.97056275*cos(2*pi/3) - 15.87956731*sig2+ sig1

```
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}