MATH 302-010
Ordinary Differential Equations
Prof. D. A. Edwards
Copyright 2024

Complex Roots

We begin with our standard command:

Quit[]

Complex Roots

Consider the following equation, which has complex roots in its characteristic equation:

eq2=y''[t]+3*y'[t]+10*y[t]==0
chareqn =λ^2+3*λ+10==0
Solve[chareqn,λ]

When working with the complex number i in Mathematica, you use the expression I, not lower-case i, which Mathematica treats like any other variable:

I^2
i^2

As far as the ODE is concerned, Mathematica will usually express the solution in real form:

DSolve[eq2,y[t],t]

The same holds true for higher-order equations as well:

high=D[y[t],{t,4}]-2*D[y[t],{t,3}]-y''[t]-2*y'[t]-2*y[t]==0
charhigh = λ^4-2*λ^3-λ^2-2*λ-2==0
Solve[charhigh,λ]
DSolve[high,y[t],t]

Mathematica also uses real arithmetic when solving initial conditions:

hic1 = y[0]==1
hic2 = y'[0]==0
hic3 = y''[0]==1
hic4 = (D[y[t],{t,3}]/.(t->0))==-1
DSolve[{high,hic1,hic2,hic3,hic4},y[t],t]

However, for some purposes it is good to be able to work with complex numbers in Mathematica.  Given a complex expression, using the command ComplexExpand will break it down into its real and imaginary parts:

comp1 = Exp[-(1+3*I)*x]
ComplexExpand[comp1]

If you just want the real or imaginary parts, use the commands Re and Im, though you may have to use ComplexExpand later:

Re[comp1]
ComplexExpand[%]
Im[comp1]
ComplexExpand[%]

Sometimes when using Simplify or other commands, you may have to tell Mathematica something about the variables you are using.   You do this with the Assumptions command:

ambig = Exp[I*Sqrt[Omega]]
Simplify[Re[ComplexExpand[ambig]]]
Simplify[Re[ComplexExpand[ambig]],Assumptions->{Omega>0}]

Exercises

1.  Find the real and imaginary parts of (e^(-(3+2ι)t))cos((1+ι)t).

Solution

f1 = Exp[-(3+2*I)*t]*Cos[(1+I)*t]
ComplexExpand[Re[f1]]
ComplexExpand[Im[f1]]

2.  Write the solution of (((d^4)y)/(dt^4))+7(((d^3)y)/(dt^3))+19y''+27y'+18y=0, y(0)=a, y'(0)=0, y''(0)=0,  (((d^3)y)/(dt^3))(0)=0.  Plot the solution for  a=1, 2, 3, 4, and 5, and for 0<t<5.

Solution

p2eq = D[y[t],{t,4}]+7*D[y[t],{t,3}]+19*y''[t]+27*y'[t]+18*y[t]==0
ic2a = y[0]==a
ic2b = y'[0]==0
ic2c = y''[0]==0
ic2d = (D[y[t],{t,3}]/.(t->0))==0

sol2=DSolve[{p2eq,ic2a,ic2b,ic2c,ic2d},y[t],t]

Table[sol2,{a,1,5}];
Plot[y[t]/.%,{t,0,5}]