Group Abstract Group Abstract

Message Boards Message Boards

0
|
10.8K Views
|
4 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Plotting DSolve outputs?

Posted 11 years ago
POSTED BY: Tim Kirkpatrick
4 Replies
POSTED BY: Tim Kirkpatrick

Hi Tim,

the reason is that variables controlled by Manipulate are local within Manipulate. To see this try:

f[x_] := Sin[a x]
Manipulate[a f[x], {x, 0, Pi}, {a, 1, 2}]

Consequently the 'a' inside Sin and 'a' inside Manipulate are different variables.

Cheers Henrik

POSTED BY: Henrik Schachner

That definitely fixed the problem. Thank you! I have absolutely no idea why that variable replacement in the Plot command corrects the issue though. Can you offer any feedback as to why this is the solution? Is the issue with Plot or Manipulate?

POSTED BY: Tim Kirkpatrick
Posted 11 years ago

In the first part of the code you can replace the alphas, etc, by adding a 0 to the end:

Eqn1 = D[f[t], {t, 2}] + \[Omega]0^2*f[t] == 0;

Sol1 = DSolve[Eqn1, f[t], t];

IC1 = f[0] == \[Alpha]0;

IC2 = (D[f[t], {t, 1}] == \[Gamma]0) /. t -> 0;

Sol2[t_] = Simplify[DSolve[{Eqn1, IC1, IC2}, f[t], t]];

x[t_] = Replace[f[t], Sol2[t]];

Then this works:

Manipulate[{Plot[
   x[t] /. {\[Omega]0 -> \[Omega], \[Gamma]0 -> \[Gamma], \[Alpha]0 \
->  \[Alpha]} , {t, 0, 10}], 
  x[1] /. {\[Omega]0 -> \[Omega], \[Gamma]0 -> \[Gamma], \[Alpha]0 -> \
 \[Alpha]}}, {\[Omega], 1, 5, 1}, {\[Gamma], 1, 5, 1}, {\[Alpha], 1, 
  5, 1}]

Should help you figure what was wrong.

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