Message Boards Message Boards

0
|
3465 Views
|
6 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Solve ODEs and avoid complex solutions?

How do I solve the following IVP problem in Mathematica so that I get real solutions?

Q?(t)=b?Q(t)(100?t);Q(0)=250

I tried the following:

$Assumptions=b>0;$Assumptions=t>0;

f=DSolve[{Q?[t]=b?Q[t](100?t),Q[0]=250},Q,t][[1,1,2]]

f(t)

which results in the following:

12(?2i?bt?2btlog(100)?200blog(t?100)+2btlog(t?100)+200i?b+200blog(100)?5t+500)

Any help would be much appreciated. Thanks!!!

POSTED BY: Ashish Patel
6 Replies

In Mathematica 11.3, DSolve does work, giving real solutions in terms of b:

      DSolve[{Q'[t] == b - Q[t] 100 - t, Q[0] == 250}, Q[t], t]
 (*  {{Q[t] -> (
    E^(-100 t) (2499999 - 100 b + E^(100 t) + 100 b E^(100 t) - 
       100 E^(100 t) t))/10000}}  *)

You have several syntax errors in your original input: using parentheses instead of square brackets around arguments of Q; and using the assignment single equals sign instead of the double-equal sign when forming equations.

Also, by any chance did you mean (100-t)Q[t] rather than Q[t] 100 - t ?

POSTED BY: Murray Eisenberg

Murray, thanks for the reply. I did make those typos while I was posting the problem here but didn't while I entered the command in Mathematica. It could be my version of Mathematica (11.1). But I also tried it on Wolfram Cloud and got the same imaginary solution.

I did fix my original post.

POSTED BY: Ashish Patel

Murray,

If you have time can you also please take a look at my other questions related to ODEs. I would appreciate any input.

https://community.wolfram.com/groups/-/m/t/1605312

Thanks!

POSTED BY: Ashish Patel

I think that other question was correclty answered by Shenghui Yang there.

I'd just add that we don't know the details of how Mathematica solves a given real-coefficient ODE "behind the scenes", so that using approximate numbers within the differential equation or initial conditions does have the potential to generate solutions that are complex but with nearly-vanishing imaginary parts. So either, as in that answer, Chop the results or else use exact numbers in the coefficients and initial-conditions.

POSTED BY: Murray Eisenberg

Thanks Mariusz. But why does DSolve not work?

When I do the problem by hand, I get the following:Q(t)=?b(100?t)ln|100?t|+C(100?t) which results in C=2.5+bln(100).

POSTED BY: Ashish Patel
$Version
(*"11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)" *)

DSolveValue[{Q'[t] == b - Q[t]*(100 - t), Q[0] == 250}, Q[t], t]

(* 1/2 E^(-100 t) (500 E^(t^2/2) + 
   b E^(5000 + t^2/2) Sqrt[2 \[Pi]] Erf[50 Sqrt[2]] + 
   b E^(5000 + t^2/2) Sqrt[2 \[Pi]] Erf[(-100 + t)/Sqrt[2]]) *)

Give me Real solution.

POSTED BY: Mariusz Iwaniuk
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