MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Delayed Evaluation of NDSolve Arguments


Hi,

f[t_?NumericQ] := 1;


sol = NDSolve[{x'[t] == f[t], x[0] == 0}, x[t], 
{t, 0, 1}];

Plot[Evaluate[x[t] /. sol[[1]]], {t, 0, 1}]

Regards

  Jens

"ben" <benjamin.friedrich at gmail.com> schrieb im 
Newsbeitrag news:dnbmas$5ks$1 at smc.vnet.net...
| Dear All,
|
| is there a way to prevent NDSolve to evaluate 
its arguments
| right on the spot?
|
| Inside my differential equation
|
| x'[t]=F[x[t],t,f[x[t],t]],
|
| I want to use a function f[x,t] which
| makes only sense, when called with
| numeric arguments.
| So everything would be fine, if NDSolve
| would evaluate the differential equation
| at each time step.
| However, the differential equation is only
| evaluated once at the beginning, and
| then only numerical values are plugged
| into the evaluated equation at each time step.
|
| Below is a baby example of my problem
|
| f[t_]:=If[NumericQ[t],1,0];
|
| sol=NDSolve[{x'[t]==f[t],x[0]==0},x[t],{t,0,1}];
|
| x[t]/.sol[[1]]
| 0.
| (* I want x[t]=t ! *)
|
| Any help would be appreciated
| Benjamin
| 



  • Prev by Date: Re: General--tracing the solver
  • Next by Date: Re: Types in Mathematica, a practical example
  • Previous by thread: Delayed Evaluation of NDSolve Arguments
  • Next by thread: exponential diophantine equations - correction!