Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Can FindMinimum solve boundary value problems?

  • To: mathgroup at
  • Subject: [mg23421] Can FindMinimum solve boundary value problems?
  • From: Hans-Peter Kunzle <HP.Kunzle at>
  • Date: Sun, 7 May 2000 21:18:06 -0400 (EDT)
  • Organization: University of Alberta
  • Sender: owner-wri-mathgroup at


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}

and tried to feed it into the FindMinimum function using


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.


and returns 

   Abs[-2+(y$1/.NDSolve[{x$1 a[1]^2 y$1[x$1]''[x$1]==0,

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.


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 
Edmonton, Canada T6G 2G1 | WWW:

  • Prev by Date: Re: Symbols & Legend Fonts in MultipleListPlot...
  • Next by Date: Re: [Q] Solve?
  • Previous by thread: Re: Modifying Fit[] using SingularValues
  • Next by thread: contours