Message Boards Message Boards

0
|
10004 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

syntax problem in code

Hi there.. i have a set of differential equations given by the following. But i am not able to solve them as it says the expression cannot begin with (x(t)*y(t))^2.. [{x'[t]== 0.5x[t]y[t][1+x[t]][2-x[t]], y'[t]==[x[t]^2][y[t]^2]-0.5[y[t]^2][x[t]+1][x[t]+2],x[0]==4,y[0]==10000},{x,y},{t,1000}] And it also says Expression cannot begin with "[x[t]y[t]]^2". syntax::tsntxi: "[x[t]y[t]]" is incomplete; more input is needed. Can you please help me in this regard?

2 Replies

Thanks a lot Marco sir...

Hi,

try this:

NDSolve[{x'[t] == 0.5 x[t] y[t] (1 + x[t]) (2 - x[t]), y'[t] == x[t]^2 (y[t]^2) - 0.5 (y[t]^2) (x[t] + 1) (x[t] + 2), x[0] == 4, y[0] == 10000}, {x, y}, {t, 0, 1000}]

You should use the [ ] only for functions. If you want to set normal parenthesis, use ( ).

Plotting the result

Plot[{x[t] /. sols, y[t] /. sols}, {t, 0, 10}]

gives

enter image description here

Cheers, Marco.

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

Group Abstract Group Abstract