Message Boards Message Boards

GROUPS:

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

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

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.

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.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract