Re: How to include a constraint in NonlinearFit?

*To*: mathgroup at smc.vnet.net*Subject*: [mg44677] Re: How to include a constraint in NonlinearFit?*From*: "Curt Fischer" <crf3 at po.cwru.edu>*Date*: Thu, 20 Nov 2003 03:16:42 -0500 (EST)*References*: <bpffju$lua$1@smc.vnet.net>*Sender*: owner-wri-mathgroup at wolfram.com

"L. Vergara" <lvergara at lauca.usach.cl> wrote in message news:bpffju$lua$1 at smc.vnet.net... > Hi, > > thanks to Curt Fisher, now I know how to to fit an array of preexisting > data with a function defined by NDSolve (see http://tinyurl.com/v0n1) The thanks should be to Carl Woll. But I'm glad to have been able to help you, Lautaro Vergra. > f[y_,a_,b_] :=NDSolve[x'[y] == (y^2/2 + a y + b)/Sqrt[1 -(y^2/2 + a y + > b)^2], x[0] == .6}, y, {y, 0, 1.5}]; > > Here there is a constraint that must be satisfied: Abs[(y^2/2 + a y > +b)^2]<1. > Do you know how include this into NonlinearFit (or perhaps better, into > NDSolve)? One approach might be to abandon NonlinearFit[] and use Minimize[] instead. I think this will work only if you have version 5.0. Anyway, Minimize[] accepts constraints as part of the input. In[1]:= ? Minimize Out[1]:= Minimize[f, {x, y, ... }] minimizes f with respect to x, y, ... . \ Minimize[{f, cons}, {x, y, ... }] minimizes f subject to the constraints \ cons. You'll need to change your fitting function from your "model" (the NDSolve solution) to a cost function (the root-mean-square difference between your NDSolve solution and your data, for example). Happy minimizing. -- Curt Fischer > Thanks! > Lautaro Vergara > >