0
$\begingroup$

I'm attempting to plot a differential equation solution but mathematica is giving me trouble. The plot is showing up blank. Here is what I have.

differentialequation4 = {u''[t] + u'[t] == .5 Cos[.8 t], u[0] == 0, 
u'[0] == 0}

I use DSolve:

solution5 = Simplify[DSolve[differentialequation4, u[t], t]]

And I get a really weird answer that's different from the one in the book:

u[t] -> -5.55112*10^-17 + 0.304878 E^(-1. t) - 0.304878 Cos[0.8 t] + 
0.381098 Sin[0.8 t]

In the book, the answer is: u = 2.77778(sin0.1t)(sin0.9t). I try to plot my answer to compare my graph with the book's graph and it shows up blank.

Plot[Evaluate[y[t] /. solution5], {t, 0, 60}, PlotRange -> {-2, 2}]

What am I doing wrong?

Edit: I now notice the stupid mistake of trying to graph y while I've been defining my equations with u, but the fact remains that the graph of my solution is drastically different than the graph of the actual solution I have in the book in front of me. Why is this? The line of the graph should stop and hit 30 before starting a new period, and the amplitude should be at its max, not min, at 15.

$\endgroup$

closed as off-topic by halirutan, bbgodfrey, Kuba, Jens, m_goldberg May 26 '15 at 16:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – halirutan, bbgodfrey, Jens, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Although I provided an answer for quick help, I vote to close this as simple mistake. $\endgroup$ – halirutan May 26 '15 at 10:41
  • $\begingroup$ I would check the original problem carefully (differential equation, initial conditions) to make sure you're working on the correct problem. One possibility is that you're missing information. $\endgroup$ – TransferOrbit May 26 '15 at 11:23
0
$\begingroup$

I believe you've mistyped the differential equation as well by using u'[t] instead of u[t]. It should probably be:

enter image description here

In which case you get an answer which should match your book:

de4 = {u''[t] + u[t] == .5 Cos[.8 t], u[0] == 0, u'[0] == 0}
soln5 = Simplify[DSolve[de4, u[t], t]]
Plot[u[t] /. soln5, {t, 0, 60}, PlotRange -> {-3, 3}]

enter image description here

The solution to the differential equation may look different from the one in your book, but an appropriate application of trigonometric identities should produce the same. This, too, can be checked in Mathematica.

$\endgroup$
  • $\begingroup$ You are much smarter than me. Thank you so much. I think the lesson here is don't try to work on Mathematica at 4 am. 2 simple mistakes, I'm sorry for asking this question and I vote to close it, and possibly delete it to hide my mediocracy from the internet. $\endgroup$ – afryingpan May 26 '15 at 19:27
  • $\begingroup$ Everyone has to start somewhere; without asking questions, you cannot learn. Of course, double-checking your work when you're well-rested is always a good policy. 😉 Become more familiar with Mathematica, and you'll work wonders. $\endgroup$ – TransferOrbit May 26 '15 at 19:36
0
$\begingroup$

First of all, you should not use 0.5 and 0.8 when you are looking for an analytic solution. Then, when you use u[t] in your equation, why do you use y[t] in the plot? This will never work and you could have found out by replacing Plot with e.g. blot which is an undefined function

plot[Evaluate[y[t] /. solution5], {t, 0, 60}, 
 PlotRange -> {-2, 2}]
(* plot[{y[t]}, {t, 0, 60}, PlotRange -> {-2, 2}] *)

Note that you solution does not appear.

Therefore, the solution to your problem is

differentialequation4 = {u''[t] + u'[t] == 1/2 Cos[8/10 t], u[0] == 0, u'[0] == 0}
solution5 = Simplify[DSolve[differentialequation4, u[t], t]]

Plot[Evaluate[u[t] /. solution5], {t, 0, 60}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Ah, yes, thank you for catching my mistake. 4 am, tired eyes. While this solves the first part of my question, I would like clarification on why the solutions are different for Mathematica and my Differential Equations textbook. The graph of the solution in the book has a different period with amplitudes that vary within the period. $\endgroup$ – afryingpan May 26 '15 at 10:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.