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.

I could not figure out how to get a plot of the results of my coupled differential equations. I am sure that the equations are written correctly. I tried solving a basic Lotka Volterra set of equations but could't figure out how to graph the results of that either. Please Help!

a = 2; b = 1; c = 1; d = 2;

DSolve[{x'[t] == a x[t] - b x[t] y[t], 
  y'[t] == -c y[t] + d x[t] y[t]}, {x[t], y[t]}, t]

I haven't read anything that made sense for graphing... I tried variations of this: Plot[y[t] /. s, {t, 0, 10}]

share|improve this question
    
Right, but the initial conditions did not help. –  squiggles Aug 1 '13 at 17:44
    
DSolve[{x'[t] == a x[t] - b x[t] y[t], y'[t] == -c y[t] + d x[t] y[t], x[0] = 1, y[0] = 1}, {x[t], y[t]}, t] Plot[y[t] /. s, {t, 0, 10}] –  squiggles Aug 2 '13 at 14:08
    
with parameters of course –  squiggles Aug 2 '13 at 14:09
add comment

2 Answers

I do not understand why NDSolve can't be used here? What exactly is the issue? This is a simple use of NDSolve

a = 2; b = 1; c = 1; d = 2;
eq1 = x'[t] == a x[t] - b x[t] y[t];
eq2 = y'[t] == -c y[t] + d x[t] y[t];
sol = NDSolve[{eq1, eq2, x[0] == 1, y[0] == 1}, {x[t], y[t]}, {t, 5}];

and plot it

Plot[{x[t] /. sol, y[t] /. sol}, {t, 0, 5}, Frame -> True, 
 FrameLabel -> {{"solution", None}, {t, {x[t], y[t]}}}, 
 PlotLegends -> {"x(t)", "y(t)"}]

Mathematica graphics

share|improve this answer
add comment

Lets assume

equ1 = {x'[t] == a x[t] - b y[t] x[t],
        y'[t] == c x[t] y[t] - d y[t]}

Than se2 = DSolve[equ1, {x, y}, t]

Than plot is,

Plot[Evaluate[{x[t], y[t]} /. se2 /. {C[1] -> 1, C[2] -> 1}], {t, -10,
   10}, PlotRange -> All]

This plot is taking exceptional time, so I took a very simple example as under,

equ = {x'[t] == -y[t] + 2,  y'[t] == x[t] - 1}

Plotting it ,

Plot[Evaluate[{x[t], y[t]} /. se /. {C[1] -> 1, C[2] -> 1}], {t, -10, 
  10}, PlotRange -> All]

Plot

I hope it answers your question.

share|improve this answer
    
Thank you so much for your help, but when I do just what you did, the plot is blank. –  squiggles Aug 1 '13 at 17:53
    
it is blank for which one..equ1 or equ ? –  Rorschach Aug 1 '13 at 17:57
    
They are both blank..... –  squiggles Aug 1 '13 at 18:34
    
equ1 was taking exceptionally long time on my machine(2gb RAM) so I chose this simplified equation equ and it has corresponding plot.May be you made some mistake! –  Rorschach Aug 1 '13 at 18:39
1  
Thank you so much for your help, but this doesn't work either, and I have a lot of memory... –  squiggles Aug 1 '13 at 18:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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