Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

The following code include the system of differential equations:

    Derivative[1][x][t] == -10^12 x[t] - y[t]+2*10^-10, 
    Derivative[1][y][t] == x[t] - 10^12 y[t] + z[t]-2, 
    Derivative[1][z][t] == - 2*y[t], 
    x[0] == y[0] == 0, z[0] == 1

I want to plot z[t] vs t. But, unfortunately Mathematics cannot plot it. How can I plot it?

share|improve this question

marked as duplicate by Artes, m_goldberg, Sjoerd C. de Vries, István Zachar, Pinguin Dirk Sep 9 '13 at 10:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Dig into the online documentation a bit, e.g. at DSolve and NDSolve. There are plenty of examples. –  István Zachar Sep 9 '13 at 8:28
add comment

1 Answer

Ok Farhad, I think I have what you wanted. First you have to actually solve the system. Please let me know if I did not interperet what you intended in my modification here. The next thing you do is plot the results. This will certainly get you rolling:

 soln = NDSolve[{
     x'[t] == -10^(12) x[t] - y[t] + 2*10^(-10),
     y'[t] == x[t] - 10^(12) y[t] + z[t] - 2,
     z'[t] == -2*y[t],
     x[0] == y[0] == 0, z[0] == 1}, {x, y, z}, {t, 0, 50}, 
    MaxSteps -> Infinity];

Here is your plotting interface:

 Plot[Evaluate[z[t] /. soln], {t, 0, 50}, PlotRange->{0,2}]

Consider modifying or completely removing the plot range option as you modify your system.

share|improve this answer
    
That's it. Thank you so much J. W. Perry. But what's wrong with the vertical axes. It shows a lot of 1 numbers. –  Farhad Sep 8 '13 at 20:45
    
The code seems fine, I have solved a millions systems the same way, but yeah I have never seen a result like this. It must have something to do with the parameters on your 3 dimensional linear system. Try poking around with the parameters and initial conditions. –  J. W. Perry Sep 8 '13 at 20:58
    
Ok I figured it out. It is the aspect ratio. Your z solution is constant 1 over time with these parameters, and without specifying any other options. Indeed strange though. If there is any error here some bright person will walk in here and correct us shortly. The code should be good though although options could be added. Add PlotRange -> {0, 2} to see what I mean. –  J. W. Perry Sep 8 '13 at 21:04
    
Also, with these coefficients, your system seems to be zapping from a source or toward a sink very quickly. If you lighten up on the coefficients you will see a large variety of behavior in the x, y, z solutions. –  J. W. Perry Sep 8 '13 at 21:18
    
Yes. You are right. But the behavior is strange. Because all of eigenvalues of the Jacobian matrix have negative real parts. So, the solutions should attract to the stationary point (which is approximately 0,0,0). But. it seems that z doesn't change from initial value for a fairly large range of time . Even after that z converge to larger values. What do you think about this? –  Farhad Sep 8 '13 at 21:20
show 3 more comments

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