Message Boards Message Boards

0
|
2316 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Solving differential equation gives complex number

Posted 3 years ago

Differential Equation Modeling a Disease

I have been trying to sole the following IVP but get an answer with complex solutions although ALL the parameters are real.

eq = i'[t] + (\[Gamma] + \[Mu] - \[Lambda]) i[t] == -\[Lambda] i[t]^2

DSolve[{eq, i[0] == i0}, i[t], t]

How should I use the fact that all parameters are real as is i and t ? Thank you

Attachments:
2 Replies

The solution uses complex numbers, but its values are real and correct:

sol1 = DSolveValue[{eq, i[0] == i0}, i, t]
FullSimplify[{eq, i[0] == i0} /. i -> sol1]
Block[{\[Gamma] = 1, \[Mu] = 1, \[Lambda] = 1, i0 = 1}, 
 Plot[sol1[t], {t, 0, 1}]]

You can get an expression that uses only real objects this way:

sol = DSolveValue[eq, i, t]
param = Solve[sol[0] == i0, C[1], Reals]
mySol[t_] = 
 FullSimplify[
  sol[t] /. param[[1]] /. ConditionalExpression -> (#1 &)]
Simplify[{eq, i[0] == i0} /. i -> mySol]
POSTED BY: Gianluca Gorni

Dear Gianluca Giorni, Thank you so much.

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