       Re: Using NDSolve for 2-variables function ?

• To: mathgroup at smc.vnet.net
• Subject: [mg31161] Re: Using NDSolve for 2-variables function ?
• From: BobHanlon at aol.com
• Date: Sun, 14 Oct 2001 04:11:54 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```In a message dated 2001/10/13 4:38:18 PM,  writes:

>In a message dated 2001/10/10 8:29:49 PM,
Florent.Saulnier at college-de-france.fr
>writes:
>
>>I'm trying to solve a quasi-linear PDE using the method of characteristics.
>>For this, I need to calculate a function - for instance f[r_,t_] - by
>
>>NDSolve (I simplified the equation for clarity) and then use it again
>in
>>
>>another differential equation :
>>
>>Input
>>f[r_,t_]=f[r]/.NDSolve[{f'[u]+u*f[u]==0,f[Sqrt[t]]==t^2},f,{u,Sqrt[t],10^9}]
>>
>>[][]
>>
>>... gives the following error messages :
>>         NDSolve::ndnl : Endpoint Sqrt[t] in {u,Sqrt[t],1000000000} is
>>not
>>a real number
>>         ReplaceAll::reps : {uf[u]+f'[u]==0} is neither a list of
>>replacement rules nor a valid dispatch table, and so cannot be used for
>>
>>replacing.
>>Output Null (f[r]/.uf[u]+f'[u]==0)
>>
>>If I give the definition of f[r,t] with the sign :=, it gives me the
>>correct result at any given point, with the correct boundary conditions
>>:
>>
>>Input
>>f[r_,t_]:=f[r]/.NDSolve[{f'[u]+u*f[u]==0,f[Sqrt[t]]==t^2},f,{u,Sqrt[t],10^9}
>>
>>][][]
>>Out Null^2
>>Input f[3,5]
>>Out  3.3834
>>Input f[2,4]
>>Out  16
>>
>>The main problem is that I need f[r,t] for a second equation, and of course
>>
>>its resolution cannot be achieved :
>>
>>Input
g[t_]=h[t]/.NDSolve[{h'[u]-f[h[u],u]==0,h==1},h,{u,1,10}][][]
>>
>>         ...which gives the same error messages :
>>         NDSolve::ndnl : Endpoint Sqrt[t] in {u,Sqrt[t],1000000000} is
>>not
>>a real number
>>         ReplaceAll::reps : {uf[u]+f'[u]==0} is neither a list of
>>replacement rules nor a valid dispatch table, and so cannot be used for
>>
>>replacing.
>>
>>Is there any other instructions or objects I could use for it ?
>>
>
>soln = (f[u] /. DSolve[f'[u]+u*f[u] == 0, f[u], u][])
>
>C/E^(u^2/2)
>
>soln /. Solve[(soln /. u -> Sqrt[t]) == t^2, C][]
>
>E^(t/2 - u^2/2)*t^2
>
>f[u_, t_] := t^2 * Exp[(t-u^2)/2];
>
>D[f[u,t],u]+u*f[u,t] == 0
>
>True
>
>f[Sqrt[t], t] == t^2
>
>True
>
>f[3,5]
>
>25/E^2
>
>%//N
>
>3.3833820809153177
>
>f[2,4]
>
>16
>

I hadn't checked whether Mathematica would handle the boundary conditions directly.
It does.  Just use:

Clear[f,u,t];

f[u_, t_] :=
Evaluate[Simplify[f[u, t] /.
DSolve[{D[f[u,t],u]+u*f[u,t] == 0,
f[Sqrt[t],t] == t^2}, f[u,t],
u][]]];

Bob Hanlon
Chantilly, VA  USA

```

• Prev by Date: Re: Using NDSolve for 2-variables function ?
• Next by Date: Resume calculation
• Previous by thread: Re: Using NDSolve for 2-variables function ?
• Next by thread: Solving simultaneous equations with inequalities