Group Abstract Group Abstract

Message Boards Message Boards

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

Trying to run a Manipulate function

Posted 6 years ago

I am trying to run a manipulate function for my calculus class and I believe I followed the professor's instructions for writing it 100%. However, I am relatively new to Mathematica and I can't seem to get the program to run. Any help? Program is pictured below.

Picture of the program

POSTED BY: DJ Seaton
3 Replies
Posted 6 years ago

NDSolve will evaluate to an InterpolatingFunction. In your code the domain of the NDSolve is {t, 0, 5}, however the Plot uses a domain of {t, 0, 10}. The interpolating function may not return accurate values outside of the domain over which it was generated.

Unless there is a reason for using a numeric solution, why not use the analytic solution?

soln = DSolve[{A'[t] == 8/100 A[t] - 12 k, A[0] == 20000}, A[t], t]

(* {{A[t] -> -50 (-400 E^(2 t/25) - 3 k + 3 E^(2 t/25) k)}} *)
POSTED BY: Rohit Namjoshi
Posted 6 years ago

Restart Mathematica and, before you do anything else, scrape-n-paste this into the notebook

Manipulate[soln=NDSolve[{A'[t]==.08A[t]-12k,A[0]==20000},A,{t,0,5}];
Plot[A[t]/.soln,{t,0,10},PlotRange->{0,25000}],{{k,1},0,500}]

and tap <shift> and <enter> and see if your plot appears.

I don't think that made any substantial changes to your code except for increasing the vertical plot range just a bit so you could see that the plot starts above the top edge of what you had specified.

If all that works then you can start adding back in your plot decorations one at a time and verifying that it works after each tiny change, so you can try to back out if it stops working at any point.

One possible reason for your difficulty is that Mathematica keeps a cache of previous calculations and a prior assignment might have been responsible for you not seeing what you needed. But there is probably no way of verifying that at this point.

POSTED BY: Bill Nelson

Wrap Evaluate around the first argument of Plot: Plot[Evaluate[A[t] /. soln], ...

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