MathGroup Archive 2009

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

Search the Archive

Re: Help with FindRoot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101621] Re: Help with FindRoot
  • From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
  • Date: Fri, 10 Jul 2009 23:27:04 -0400 (EDT)
  • References: <h2nbe6$h7q$1@smc.vnet.net>

Quite some errors in your code:

1. k has no value when solution is used in the Sum
2. solution is a function, you use it as a list with double brackets
3. You define solution with two arguments, yet you call it with one
4. The Conc that is used as one of the arguments of solution cannor be
used at the same time as an iterator
5. Same for f. It's used as an argument but it's also present in the
replacement.
6. FindMinimum is missing a {

Cheers -- Sjoerd

On Jul 4, 12:37 pm, "versianel... at gmail.com" <versianel... at gmail.com>
wrote:
> 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}]



  • Prev by Date: Re: Is it possible to impose a condition on an iterator of
  • Next by Date: Re: Add syntax highlighting to own command
  • Previous by thread: Help with FindRoot
  • Next by thread: Re: Separating real part and imaginary part from each