Can FindMinimum solve boundary value problems?
- To: mathgroup at smc.vnet.net
- Subject: [mg23421] Can FindMinimum solve boundary value problems?
- From: Hans-Peter Kunzle <HP.Kunzle at UAlberta.ca>
- Date: Sun, 7 May 2000 21:18:06 -0400 (EDT)
- Organization: University of Alberta
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
I am trying to use 'FindMinimum' to solve a complicated
boundary value problem using the shooting method.
As a simple example I made up a function that generates
values from some parameters using NDSolve:
sh[b_List]:= Module[{f,x,y},
f = y/.Flatten[NDSolve[
{y''[x]+b[[1]]^2 x y[x]==0,y[0]==0,y'[0]==b[[2]]},y,{x,0,1}
]];
Abs[f[1]-2]
];
and tried to feed it into the FindMinimum function using
<<LinearAlgebra`MatrixManipulation`
fmSh[fct_,par0_] := Module[
{ par=ToExpression["a"], l=Length[par0], vars },
vars = Transpose[AppendColumns[{Array[par,l]},{par0,1.01*par0}]];
FindMinimum[ Evaluate[sh[Array[par,l]]], Evaluate[Sequence@@vars] ]
];
I get, for example,
In[3]:= sh[{5.3,-10.7869}]
Out[3]:= 4.355775244491156*10^(-6)
So, this is probably close to a minimum.
But my function 'fmSh' is quite unable to find these parameter values:
In[4]:= fmSh[sh,{5.2,-10.8}]
produces error messages,
NDSolve::ndinn: Initial condition 1. a[2.] is not a number.
ReplaceAll::reps: {NDSolve[<<1>>]} is neither a list of
replacement rules nor a valid dispatch table, and so
cannot be used for replacing.
Function::flpar: Parameter specification a[1],a[2]} in
Function[{a[1],a[2]}, {(y$53 /.NDSolve[<<1>>))[1]}]
should be a symbol or a list of symbols.
etc.
and returns
FindMinimum[
Abs[-2+(y$1/.NDSolve[{x$1 a[1]^2 y$1[x$1]''[x$1]==0,
y$1[0]==0,y$1'[0]==a[2]},y$1,{x$1,0,1}])[1]],
{a[1],5.2,5.252},{a[2],-10.8,-10.908}]
The problem seems to be that NDSolve does not get
numerical values for its initial conditions.
Is there a way to pass the parameters so that NDSolve
can start with numerical values.
I have tried to put 'Evaluate's inside the NDSolve in the
function 'sh', but this did not help.
Any comments will be appreciated.
Hans
--
H.P. Künzle | Office: (780)492-3798,492-3396
Dept. of Mathematical Sciences | Fax: (780)492-6826
University of Alberta | E-mail: HP.Kunzle at UAlberta.ca
Edmonton, Canada T6G 2G1 | WWW:http://www.math.ualberta.ca/~hpk