Help with FindRoot
- To: mathgroup at smc.vnet.net
- Subject: [mg101390] Help with FindRoot
- From: "versianeleao at gmail.com" <versianeleao at gmail.com>
- Date: Sat, 4 Jul 2009 06:44:05 -0400 (EDT)
Deal All I need some help with the code presented below. I=B4m using FindRoot to find the solutions of 2 algebric equations (eq1 and eq 2) since one of them is nonlinear. Futhermore, I need to find a value of k that fit the data on "Fa" to "solution". In order to do so, I=B4m trying to minimize "fit" using FindMinimum. However it is falling even when I use "_?NumericQ" to define "f and Conc", the roots of eq1 and eq2. Does anyone have any ideia how to address this? Thank you very much. ClearAll[k, Conc, f] n = 1.3; Deff = 1/10^9; data = {1, 0.89, 0.82, 0.75, 0.68, 0.58, 0.48, 0.4} Fa = {-6.15/10^15, -5.62/10^15, -5.1/10^15, -4.58/10^15, -4.06/10^15, -3.01/10^15, -1.96/10^15, -0.92/10^15}; eq1 = Table[f == -4*Pi*k*data[[i]]*(Conc)^n, {i, 1, Length[Fa]}] eq2 = Table[f == -4*Pi*Deff*data[[i]]*(6 - Conc), {i, 1, Length[Fa]}] solution[(f_)?NumericQ, (Conc_)?NumericQ] := Table[f /. FindRoot[{eq1 [[i]], eq2[[i]]}, {{f, 10}, {Conc, 0.01}}], {i, 1, Length[Fa]}] fit = Sum[(solution[[i]] - Fa[[i]])^2, {i, 1, Length[Fa]}] FindMinimum[fit, k > 0}, {k, 1.5}]