aplogon
(Ashish Patel)
February 4, 2019, 3:27pm
1
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.58196 10^-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.
shenghuiy
(Shenghui Yang)
February 4, 2019, 4:22pm
2
You can use Chop function: Chop—Wolfram Documentation
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
danl
(Daniel Lichtblau)
February 4, 2019, 7:18pm
3
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.
aplogon
(Ashish Patel)
February 5, 2019, 1:31am
4
Thanks Shenghui Yang and Daniel Lichtblau, for the solutions and explanation.
Ashish
The situation is not specific to ODE solving. see Help: tutorial/ExactAndApproximateResults. it effect most anything you do in Mathematica.