Message Boards Message Boards

0
|
3299 Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Exact vs decimal input and imaginary solutions to ODEs

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.

POSTED BY: Ashish Patel
4 Replies
Anonymous User
Anonymous User
Posted 5 years ago

The situation is not specific to ODE solving. see Help: tutorial/ExactAndApproximateResults. it effect most anything you do in Mathematica.

POSTED BY: Anonymous User

Thanks Shenghui Yang and Daniel Lichtblau, for the solutions and explanation.

Ashish

POSTED BY: Ashish Patel

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.

POSTED BY: Daniel Lichtblau

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 BY: Shenghui Yang
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