Jonathan
Jonathan

Reputation: 139

Mathematica DSolve

Hey, I have this little equation that I am trying to solve on Mathematica, but for some reason I cannot get it to work. Any help would be appreciated. Thanks

f[x_, t_] = x^2 - x^3;

eso = x[t] /. DSolve[{[t] == f[x_, t_], x[0] == 0.2}, x, t]

I tried this next, but I keep getting an error

f[x_, t_] = x[t]^2 - x[t]^3;

eso = x[t] /. DSolve[{x'[t] == f[x_, t_], x[0] == 0.2}, x, t]

Upvotes: 0

Views: 1375

Answers (3)

Simon
Simon

Reputation: 14731

Mathematica can solve the DE

f[x_]:=x^2-x^3;

DSolve[{x'[t]==f[x[t]]},x,t]

But only in an implicit form. The error message comes from the routine that tries to solve the implicit solution for x[t].

For a quick look at the resulting function, you can try Wolfram alpha.

Upvotes: 1

rcollyer
rcollyer

Reputation: 10695

Your second attempt approaches being correct in that you specify both sides of the equation, unlike in your first attempt. However, it fails because the second side is not written correctly. Using FullForm you can see that Mathematica interprets x_ and t_ as patterns, not variables. So, instead write:

eso = x[t] /. DSolve[{x'[t] == f[x, t], x[0] == 0.2}, x, t]

where both x and t will now be correctly viewed as variables. If you are using a recent version of Mathematica, they will now change color to reflect this interpretation.

Upvotes: 3

Adam S.
Adam S.

Reputation: 1271

What equation are you trying to solve? The above doesn't really make sense, DSolve is for differential equations, also [t] doesn't have meaning. When you define f[x,t] you need to use x[t]^2 and x[t]^3 if x is a function of t.

Upvotes: 3

Related Questions