[Date Index]
[Thread Index]
[Author Index]
Re: problems with DSolve
*To*: mathgroup at smc.vnet.net
*Subject*: [mg99405] Re: problems with DSolve
*From*: Bill Rowe <readnews at sbcglobal.net>
*Date*: Tue, 5 May 2009 05:40:29 -0400 (EDT)
On 5/4/09 at 6:00 AM, szymon.stoma at gmail.com wrote:
>i am new to mathematica, therefore sorry if my question is trivial.
>I would like to understand why the following line does not work:
>Plot[(x[t] /. DSolve[{x'[t] == y[t], y'[t] == -x[t], x[0] == 1=
, y[0]
>== 2}, {x, y}, t]), {t, 0, 5}]
>whereas after splitting into two lines it works: sol = DSolve[{x'[t]
>== y[t], y'[t] == -x[t], x[0] == 1, y[0] == 2}, {x, y}, t]
>Plot[(x[t] /. sol), {t, 0, 5}]
The problem is due to the way Plot evaluates its arguments. The
first thing that happens is a numerical value is substituted for
the plot variable. Then the argument is evaluated. And of
course, DSolve cannot do its thing with a number in place of t.
The solution is to force evaluation of the arguments to Plot
before a numerical value is substituted for the plot variable.
This can be done using Evaluate. That is
Plot[Evaluate[(x[t] /. DSolve[{x'[t] == y[t], y'[t] == -x[t],
x[0] == 1, y[0]
== 2}, {x, y}, t])], {t, 0, 5}]
will do what you want.
Prev by Date:
**Re: why does DownValues not return all downvalues for a**
Next by Date:
**Re: why does DownValues not return all downvalues for a symbol?**
Previous by thread:
**Re: problems with DSolve**
Next by thread:
**Re: problems with DSolve**
| |