Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

FindRoot within a FindRoot Problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84212] FindRoot within a FindRoot Problem
  • From: stephen.a.mccormack at baesystems.com
  • Date: Fri, 14 Dec 2007 03:56:54 -0500 (EST)

I need to find mu1 and sigma1 such that the two errors are zero (or at
least minimized). The following code works but is manual and iterative
in that I need to manually guess the values for mu1 and sigma1, check
the errors and guess again, and so on.

\[Mu]1 = 80.(* a guessed value *);
\[Sigma]1 = 107.0     (* a guessed value *);
\!\(TraditionalForm\`\(\(solution1 = FindRoot[{\[Mu]1 ==
\*SuperscriptBox[\(E\), \(M1 +
\*FractionBox[
SuperscriptBox[\(S1\), \(2\)], \(2\)]\)], \[Sigma]1 ==
\*SqrtBox[\(
\*SuperscriptBox[\(E\), \(
\*SuperscriptBox[\(S1\), \(2\)] + 2*M1\)]*\((
\*SuperscriptBox[\(E\),
SuperscriptBox[\(S1\), \(2\)]] -
            1)\)\)]}, {M1,  .1}, {S1,  .1}];\)\[IndentingNewLine]
\(m1 = ReplaceAll[M1,
      solution1[\([\)\(1\)\(]\)]];\)\[IndentingNewLine]
s1 = ReplaceAll[S1, solution1[\([\)\(2\)\(]\)]]\)\);
dist1 = LogNormalDistribution[m1, s1];
dist1pdf = PDF[dist1, x];
ivalue2a = Integrate[dist1pdf, {x, 0, 10}]*100
ivalue13a = 100 - Integrate[dist1pdf, {x, 0, 1000}]*100
error1 = (ivalue2a - 2.78*10^-16)/(2.78*10^-16)*100

error2 = (ivalue13a - .2)/.2*100
{m1, s1}

I tried wrapping the code within FindRoot but get error messages (see
below). Does anyone know how to force Mathematica to solve for mu1 and
sigma1 while setting both errors to zero ?

Thanks

\!\(TraditionalForm\`\(\(solution1 = FindRoot[{\[Mu]1 ==
\*SuperscriptBox[\(E\), \(M1 +
\*FractionBox[
SuperscriptBox[\(S1\), \(2\)], \(2\)]\)], \[Sigma]1 ==
\*SqrtBox[\(
\*SuperscriptBox[\(E\), \(
\*SuperscriptBox[\(S1\), \(2\)] + 2*M1\)]*\((
\*SuperscriptBox[\(E\),
SuperscriptBox[\(S1\), \(2\)]] -
            1)\)\)]}, {M1,  .1}, {S1,  .1}];\)\[IndentingNewLine]
\(m1 = ReplaceAll[M1,
      solution1[\([\)\(1\)\(]\)]];\)\[IndentingNewLine]
s1 = ReplaceAll[S1, solution1[\([\)\(2\)\(]\)]]\)\);
dist1 = LogNormalDistribution[m1, s1];
dist1pdf = PDF[dist1, x];
ivalue2a = Integrate[dist1pdf, {x, 0, 10}]*100
ivalue13a = 100 - Integrate[dist1pdf, {x, 0, 1000}]*100
solution2 =
 FindRoot[{0. == (ivalue2a - 2.78*10^-16)/(2.78*10^-16)*100.,
   0. == (ivalue13a - .2)/.2*100. == 0.}, {\[Mu]1, 95.}, {\[Sigma]1,
   107.}]





  • Prev by Date: Re: Invert Black/White Colors of Binary Images
  • Next by Date: Re: Re: Expanding powers of cosine
  • Previous by thread: Re: Have I found a bug?
  • Next by thread: Re: FindRoot within a FindRoot Problem