Message Boards Message Boards

Plot complex solution obtained using DSolve?

Posted 6 years ago

Hi, I need to plot this stuff, but unfortunately that doesn't work and I don't understand why. If someone could help me?

diffeq3 = x3''[t] + 10*x3[t] + 0.5*(x3[t] - x4[t]) == 0

diffeq4 = x4''[t] + 10*x4[t] + 0.5*(x4[t] - x3[t]) == 0

sol1 := DSolve[{diffeq3, diffeq4, x3'[0] == 0, x4'[0] == 0, 
    x3[0] == xo3, x4[0] == xo4}, {x3[t], x4[t]}, t];

posx3[t_, xo3_, xo4_] = x3[t] /. sol1;

posx4[t_, xo3_, xo4_] = x4[t] /. sol1;

Plot[{posx3[t, 1, -1], posx4[t, 1, -1]}, {t, 0, 40}]

The problem is at the end of my file.

Attachments:
POSTED BY: Razvan Burcea
7 Replies
Posted 6 years ago

ty mate

POSTED BY: Razvan Burcea
Posted 6 years ago

Ty mate

POSTED BY: Razvan Burcea

See my updated.

Read this it can help you.

Reagards, MI

Attachments:
POSTED BY: Mariusz Iwaniuk
Posted 6 years ago

Well that doesn't work again. Wich version of the software have u got ? Because mine is 11.0 Student Version and i think my version isn t updated or kind of.

POSTED BY: Razvan Burcea
Posted 6 years ago

Thank u both

POSTED BY: Razvan Burcea

See my adjustments.

Tested on:

$Version
(* "11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)" *)

(* "10.2.0 for Microsoft Windows (64-bit) (July 7, 2015)"  *)
Attachments:
POSTED BY: Mariusz Iwaniuk

Razvan,

Your general solution to the differential equation has complex numbers which go to zero when you ask for solutions that are real. However, because of machine precision, you have some VERY small complex parts. For example,

In[20]:= posx3[0, 1, -1]

Out[20]= {1. + 1.38667*10^-32 I}

You must use Chop[] to get rid of infinitesimal imaginary parts. For example:

sol1 := Chop[DSolve[{diffeq3, diffeq4, x3'[0] == 0, x4'[0] == 0, x3[0] == xo3, x4[0] == xo4}, {x3[t], x4[t]}, t]];

will fix this by Choping the numbers when evaluating posx3, posx4 or you can Chop it later at Plot time.

Regards,

Neil

POSTED BY: Neil Singer
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