# Exact vs decimal input and imaginary solutions to ODEs

Posted 3 months ago
501 Views
|
4 Replies
|
2 Total Likes
|
 When I enter the following command I get imaginary solutions: R = 5; **L = 0.05**; EMF = 5 Cos[120 t]; cur1 = DSolve[{R i [t] + L i'[t] == EMF, i[0] == 1}, i, t][[1, 1, 2]][ t] Solution: (0.409836 - 4.3368110^-17 I) E^(-100. t) ((1.44 + 2.5819610^-16 I) + (1. + 0. I) E^(100. t) Cos[120. t] + (1.2 + 1.26982*10^-16 I) E^(100. t) Sin[120. t])But if I enter the following i get real solutions: R = 5; **L = 1/20**; EMF = 5 Cos[120 t]; cur1 = DSolve[{R i [t] + L i'[t] == EMF, i[0] == 1}, i, t][[1, 1, 2]][ t] Solution:1/61 E^(-100 t) (36 + 25 E^(100 t) Cos[120 t] + 30 E^(100 t) Sin[120 t])Any help understanding this would be appreciated. I am currently using Mathematica v11.1. But I have the same issue on Wolfram Cloud.
4 Replies
Sort By:
Posted 3 months ago
 You can use Chop function: https://reference.wolfram.com/language/ref/Chop.html In[1]:= R=5;L=0.05;EMF=5 Cos[120 t]; In[3]:= sol=Chop@DSolve[{R i[t]+L i'[t]==EMF,i[0]==1},i,t] Out[3]= {{i->Function[{t},0.409836 E^(-100. t) (1.44 +1. E^(100. t) Cos[120. t]+1.2 E^(100. t) Sin[120. t])]}} In[4]:= i[2]/.sol[[1]] Out[4]= 0.59849 
Posted 3 months ago
 A matrix exponential is being computed. With approximate numeric input it is using methods that show explicit numeric fuzz in the imaginary (oscillatory) part. As noted, Chop can be used to remove it.