Fitting Explicit Functions
- To: mathgroup at smc.vnet.net
- Subject: [mg6780] Fitting Explicit Functions
- From: CULMAN at MPS.OHIO-STATE.EDU
- Date: Fri, 18 Apr 1997 02:37:50 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
From: culman at ohstpy.mps.ohio-state.edu To: mathgroup at smc.vnet.net Subject: [mg6780] Fitting Explicit Functions Organization: The Ohio State University, Department of Physics News-Moderator: Approval required for posting to comp.soft-sys.math.mathematica Hello, I would like to fit some data to an implicit function. I have data for x and y for the following equation: 1/x = exp( b*y/x ). I would like to fit for b. It appears that one cannot use the Levenberg-Marquardt method in Mathematica because that method takes the derivatives wrt the parameters explicitly. However, using the method of steepest descent (FindMinimum), the derivatives are taken numerically, so it should work. Nevertheless, I have not been able to do this. Below is an example. The data are such that the parameter b = -0.5. Does anyone have any ideas of how to do this in Mathematica? Thanks in advance, Todd Culman Physics Dept., The Ohio State University In[1]:= f[x_,b_] :=Limit[y, FindRoot[1/x == Exp[b y/x], {y,1}]] In[2]:= data = {{0.5,-.693147},{1.,0.},{2.,2.7759},{3,6.59167}} In[3]:= << Statistics`NonlinearFit` In[4]:= NonlinearRegress[data,f[x,b],x,{b,-.1,-2},Method->FindMinimum] \!\(FindRoot::"frnum" \( : \ \) "Function \!\({\(\(-1.`\)\\ 2.71828182845904509`\^\(\(1.`\\ b\)\/x\)\) + \ 1\/x}\) is not a length \!\(1\) list of numbers at \!\({y}\) = \ \!\({1.`}\)."\) \!\(Limit::"lim" \( : \ \) "Limit specification \!\(FindRoot[\(\(1\/x == \(Exp[\(\(b\\ \ y\)\/x\)]\)\), \({y, 1}\)\)]\) is not of the form x -> x0."\) \!\(FindRoot::"frnum" \( : \ \) "Function \!\({\(\(-1.`\)\\ 2.71828182845904509`\^\(\(1.`\\ b\)\/x\)\) + \ 1\/x}\) is not a length \!\(1\) list of numbers at \!\({y}\) = \ \!\({1.`}\)."\) \!\(Limit::"lim" \( : \ \) "Limit specification \!\(FindRoot[\(\(1\/x == \(Exp[\(\(b\\ \ y\)\/x\)]\)\), \({y, 1}\)\)]\) is not of the form x -> x0."\) Thread::"normal": "Nonatomic expression expected at position \!\(1\) in \ \!\(Thread[False]\)." FindRoot::"frnum": "Function \!\({\(\(-1.`\)\\ 2.71828182845904509`\^\(\(1.`\\ b\)\/x\)\) + \ 1\/x}\) is not a length \!\(1\) list of numbers at \!\({y}\) = \!\({1.`}\)." General::"stop": "Further output of \!\(FindRoot :: \"frnum\"\) will be suppressed during \ this calculation." Limit::"lim": "Limit specification \!\(FindRoot[\(\(1\/x == \(Exp[\(\(b\\ \ y\)\/x\)]\)\), \({y, 1}\)\)]\) is not of the form x -> x0." General::"stop": "Further output of \!\(Limit :: \"lim\"\) will be suppressed during this \ calculation." First::"first": "\!\({}\) has a length of zero and no first element." Thread::"tdlen": "Objects of unequal length in \!\(\({b}\) \\[Rule] \({}\)\) cannot be \ combined." Join::"heads": "Heads \!\(Rule\) and \!\(List\) at positions \!\(1\) and \!\(2\) are \ expected to be the same." ReplaceAll::"reps": "\!\({Join[\(\(\({b}\) \\[Rule] \({}\)\), \({x \\[Rule] \*StyleBox[\"0.5`\ \", Rule[PrintPrecision, 16], Rule[StyleBoxAutoDelete, True]]}\)\)]}\) is \ neither a list of replacement rules nor a valid dispatch table, and so cannot \ be used for replacing." Join::"heads": "Heads \!\(Rule\) and \!\(List\) at positions \!\(1\) and \!\(2\) are \ expected to be the same." ReplaceAll::"reps": "\!\({Join[\(\(\({b}\) \\[Rule] \({}\)\), \({x \\[Rule] 0.5`}\)\)]}\) is \ neither a list of replacement rules nor a valid dispatch table, and so cannot \ be used for replacing." ReplaceAll::"reps": "\!\({Join[\(\(\({b}\) \\[Rule] \({}\)\), \({x \\[Rule] 0.5`}\)\)]}\) is \ neither a list of replacement rules nor a valid dispatch table, and so cannot \ be used for replacing." General::"stop": "Further output of \!\(ReplaceAll :: \"reps\"\) will be suppressed during \ this calculation." NonlinearRegress::"nonnum": "The model is not numerical at \!\(Join[\(\(\({b}\) \\[Rule] \({}\)\), \ \({x \\[Rule] \*StyleBox[\"0.5`\", Rule[PrintPrecision, 16], \ Rule[StyleBoxAutoDelete, True]]}\)\)]\). Check that all model parameters are \ included in the parameter list." NonlinearRegress[{{0.5,-0.693147},{1.,0.},{2.,2.7759},{3,6.59167}}, Limit[y,FindRoot[1\/x==Exp[b y\/x],{y,1}]],x,{b,-0.1,-2}, Method\[Rule]FindMinimum]