thus:
EQ= { f'[x] == f[f[x]], f[0]== 1} ; NDSolve[EQ,f,{x,0,2}];
But gives an error. NDSolve::ndnum: Differential equation does not
evaluate to a number at x = 0.
Also does not work even with other f[0] values. Any way to do that?
it can't work because f[0]==1 give in your
differential equation
f'[0]==f[1] and NDSolve[] can't find the value for
f[1] until it
has integrated the equation.
The neted dependence is equvalent to a infinite
system of
ordinary differential equations and it seems to be
hard to do
this by a finte computer.
Regards
Jens
"Narasimham" <math...@hotmail.com> schrieb im
Newsbeitrag news:dmha20$932$1...@smc.vnet.net...
> it can't work because f [0] ==1 given in your differential equation
> f ' [0]==f [1] and NDSolve[] can't find the value for
> f[1] until it has integrated the equation.
???
> The nested dependence is equivalent to an infinite
> system of ordinary differential equations and it seems to be
> hard to do this by a finte computer.
I cannot understand this. In the following two examples the first one
works, not the second.
Clear[x,f,EQ];
EQ={f'[x] == f[Cos[x]],f[0]== 1};
NDSolve[EQ,f,{x,0,4}];
f[x_]=f[x]/.First[%];
Plot[f[x],{x,0,4}];
Clear[x,f,EQ];
EQ={f'[x] == Cos[f[x]],f[0]== 1};
NDSolve[EQ,f,{x,0,4}];
f[x_]=f[x]/.First[%];
Plot[f[x],{x,0,4}];
It appears (to me) the power of programming with functions in
Mathematica has not been used to the full.
Regards
Narasimham
> Jens-Peer Kuska wrote:
>
>> it can't work because f [0] ==1 given in your differential equation
>> f ' [0]==f [1] and NDSolve[] can't find the value for
>> f[1] until it has integrated the equation.
>
> ???
>
>> The nested dependence is equivalent to an infinite
>> system of ordinary differential equations and it seems to be
>> hard to do this by a finte computer.
>
> I cannot understand this. In the following two examples the first one
> works, not the second.
>
> Clear[x,f,EQ];
> EQ={f'[x] == f[Cos[x]],f[0]== 1};
> NDSolve[EQ,f,{x,0,4}];
> f[x_]=f[x]/.First[%];
> Plot[f[x],{x,0,4}];
>
> Clear[x,f,EQ];
> EQ={f'[x] == Cos[f[x]],f[0]== 1};
> NDSolve[EQ,f,{x,0,4}];
> f[x_]=f[x]/.First[%];
> Plot[f[x],{x,0,4}];
Surely, you mean the second one works, the first one does not!? Also,
I think I agree with Jens. These cases are quite different and the
problem he mentione does not arise in the second case. Ine the second
case the derivative at a point x is defined only in terms of the
value of the function at x. Thus values of the function, it's
derivative, function etc, can be computed sequentially. In the first
case, however, in order to compute the derivative at x you need to
know the value of the function at Cos[x], which in general will not
be known yet. This is, I think, what Jens meant and it seems to me
clearly right.
>
> It appears (to me) the power of programming with functions in
> Mathematica has not been used to the full.
>
>
What do you mean? Can you suggest an approximation scheme for this
sort of problem?
Andrzej Kozlowski
"Narasimham" <math...@hotmail.com> schrieb im
Newsbeitrag news:dmjrv9$638$1...@smc.vnet.net...
| Jens-Peer Kuska wrote:
|
| > it can't work because f [0] ==1 given in your
differential equation
| > f ' [0]==f [1] and NDSolve[] can't find the
value for
| > f[1] until it has integrated the equation.
|
| ???
|
You don't understand, that in
EQ= { f'[x] == f[f[x]], f[0]== 1} ;
NDSolve[EQ,f,{x,0,2}];
the right hand side must be evaluated by NDSolve[]
at x==0 and this
gives
f'[x]==f[f[x]] /. x->0
f'[0]==f[f[0]]
and with your initial condition f[0]==1
one ends up with
f'[0]==f[1]
and this can only evaluated when NDSolve[] has
escaped from x==0
but it can't, because it is not able to get a
numerical value for the
derivative at x==0 ???
| > The nested dependence is equivalent to an
infinite
| > system of ordinary differential equations and
it seems to be
| > hard to do this by a finte computer.
|
| I cannot understand this. In the following two
examples the first one
| works, not the second.
|
| Clear[x,f,EQ];
| EQ={f'[x] == f[Cos[x]],f[0]== 1};
| NDSolve[EQ,f,{x,0,4}];
| f[x_]=f[x]/.First[%];
| Plot[f[x],{x,0,4}];
|
| Clear[x,f,EQ];
| EQ={f'[x] == Cos[f[x]],f[0]== 1};
| NDSolve[EQ,f,{x,0,4}];
| f[x_]=f[x]/.First[%];
| Plot[f[x],{x,0,4}];
the first example can't work (and it does not)
because
EQ={f'[x] == f[Cos[x]],f[0]== 1};
at x==0 gives
f'[0]==f[Cos[0]]
and
f'[0]==f[1]
but nobody can find f[1]
That has *nothing* to do with Mathematica because
it is a
functional equation that can't be solved. Even the
simpler case
f'[x]==g[f[x-tau]]
has an infinite number of degrees of freedom
because you have to
supply a function for f[] in the interval
[x0-tau,x0] to integrate
the equation numerical.
Regards
Jens
The second one gives a result, the first does not. This is a consequence
of mathematics, not Mathematica. A first order ODE is of the form
dy/dx=F(y,x) where F is some "reasonable" function e.g. piecewise
analytic. Your second equation conforms to this description whereas your
first does not.
My guess is one might approach your first using ansatz from integral
equations methods. One such might be to expand f as a power series with
unknown coefficients and try to find constraints to give linear
equations in those coefficients.
Another method might be to form a sequence of functions where
f'[n,x] == f[n-1,Cos[x]]. Make f[0,x] something reasonable (perhaps
constant) and iterate the process a few times in hope of getting the
f[n,x] to converge for all x of interest. The code below may give an
idea of what I have in mind.
f[0][x_] := 1
deq[n_] := {f[n]'[x]==f[n-1][Cos[x]],f[n][0]==1};
sol[n_] := (f[n][x] = f[n][x]/.First[NDSolve[deq[n],f[n][x],{x,0,4}]];
f[n][t_] := f[n][x]/.x->t)
For example, if I now do
Do[sol[j], {j, 100}]
then I get a bunch of messages telling me extrapolation was needed to go
outside the domain. But then I evaluate
Table[f[j][1.8], {j, 100}]
I see that it is converging to about 10.5214, and similarly f[j][2.8]
appears to be converging to about 5.08. Let's check the differential
condition.
Max[Abs[Table[f[100]'[j] - f[100][Cos[j]], {j, 0, 4, .1}]]]
also gives a bunch of extrapolation messages, and a value of around
.035, which I think is not too bad. Going to 500 iterations brings the
residual to .0039. So this appears to be a viable approach. It may also
be a bit naive as I'm never certain when such a method is really
justified. Probably requires a bit of analysis to decide if we have some
sort of contraction principle to tell us to expect a fixed point. Also
those extrapolations might be problematic, and evaluations of f[n][2.8]
do not seem to converge terribly well, so it may be that the range needs
to be expanded or contracted in order to get reliable results.
Daniel Lichtblau
Wolfram Research
Regards
Narasimham
We want to solve the system:
Clear[x, f, EQ];
EQ = {f'[x] == f[Cos[x]], f[0] == 1};
We are going to try to approximate the entire function f over the
range [0,1]. This is actually a case when it can be done.We need a
starting function that satisfies the initial condition f[0]=1. The
functions Cos[x] itself will do. We now do the following:
Do[f[n] = f[n] /.
First[NDSolve[{D[
f[n][x], x] == f[n - 1][Cos[
x]], f[n][0] == 1}, f[n], {x, 0, 1}]], {n, 1, 100}]
The solutions is
Plot[f[100][x], {x, 0, 1}]
By plotting
Plot[{f[100]'[x], , f[100][Cos[x]]}, {x, 0, 1}, PlotStyle -> {Red,
Green}]
we see that the two curves coincide perfectly.
Obviously you could not expect NDSOlve to do this by itself!
Andrzej Kozlowski
f[0][x_]:=Cos[x]
Andrzej