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

MathGroup Archive 2010

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

Search the Archive

[Question] NonlinearRegress with two independent variables.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg114207] [Question] NonlinearRegress with two independent variables.
  • From: Jiwan Kim <hwoarang.kim at gmail.com>
  • Date: Sat, 27 Nov 2010 03:36:11 -0500 (EST)

To whom it may concern,

I am using the mathematica 6.0.
And I want to extract several parameters (K2, Ms) using
NonlinearRegress function.
The independent variables of NonlinearRegress is two, Kel and H.
Experimental data is given as dat = (Kel, H, Freq).
So I want to fit the experimental value of Freq with calculated value of
Freq.
Freq calculation is given in the NDsolve function.
And theta in Freq equation is given by the derivative condition of FE
equation.

I have no idea why this equation doen't work properly.
I attched the source code.

Jiwan.

Remove["Global`*"];
<< Statistics`NonlinearFit`
$RecursionLimit = \[Infinity];
Subscript[\[Mu], 0] := 4 \[Pi] 10^-7; K1eff :=
 2.5 10^4; Kel =.; K2 =.; \[Phi] :=
 72 \[Pi]/180; H =.; Ms =.; \[Theta] =.;
FE[\[Theta]_, K2_, Ms_, Kel_, H_] := (K1eff - Kel) Sin[\[Theta]]^2 +
   K2 Sin[\[Theta]]^4 -
   Subscript[\[Mu], 0] H Ms Cos[\[Phi] - \[Theta]];
dat = {{0, 198944, 8.12}, {0, 278521, 10.89}, {0, 350141,
    12.56}, {2 10^4, 198944, 8.6}, {2 10^4, 278521, 11.49}, {2 10^4,
    350141, 13.32}};
modelTheta[K2_?NumericQ, Ms_?NumericQ, Kel_?NumericQ,
  H_?NumericQ] := \[Theta][Kel, H] /.
  NDSolve[{D[FE[\[Theta], K2, Ms, Kel, H], \[Theta]] == 0,
     Freq[Kel, H] -
       1/(2 \[Pi]) ((1.76 10^2 Subscript[\[Mu],
            0])^2 ((2 (K1eff - Kel))/(Subscript[\[Mu], 0] Ms)
             Cos[\[Theta]]^2 + (4 K2)/(Subscript[\[Mu], 0] Ms)
              Cos[\[Theta]]^4 + H Cos[\[Theta] - \[Phi]]))^0.5*(((
            2 (K1eff - Kel) + 2 K2)/(Subscript[\[Mu], 0] Ms)
            Cos[2 \[Theta]] + (2 K2 )/(Subscript[\[Mu], 0] Ms)
            Cos[2 \[Theta]] + H Cos[\[Theta] - \[Phi]]))^0.5 ==
      0, \[Theta][0, 0] == 0}, {\[Theta], Freq}, {Kel, 0, 3 10^4}, {H,
      0, 3.6 10^5}, MaxSteps -> Infinity][[1]]
modelFreq[K2_?NumericQ, Ms_?NumericQ, Kel_?NumericQ, H_?NumericQ] :=
 Freq[Kel, H] /.
  NDSolve[{D[FE[\[Theta], K2, Ms, Kel, H], \[Theta]] == 0,
     Freq[Kel, H] -
       1/(2 \[Pi]) ((1.76 10^2 Subscript[\[Mu],
            0])^2 ((2 (K1eff - Kel))/(Subscript[\[Mu], 0] Ms)
             Cos[\[Theta]]^2 + (4 K2)/(Subscript[\[Mu], 0] Ms)
              Cos[\[Theta]]^4 + H Cos[\[Theta] - \[Phi]]))^0.5*(((
            2 (K1eff - Kel) + 2 K2)/(Subscript[\[Mu], 0] Ms)
            Cos[2 \[Theta]] + (2 K2 )/(Subscript[\[Mu], 0] Ms)
            Cos[2 \[Theta]] + H Cos[\[Theta] - \[Phi]]))^0.5 ==
      0, \[Theta][0, 0] == 0}, {\[Theta], Freq}, {Kel, 0, 3 10^4}, {H,
      0, 3.6 10^5}, MaxSteps -> Infinity][[1]]
NonlinearRegress[dat,
 modelFreq[K2, Ms, Kel, H], {Kel, H}, {{K2, 5 10^4}, {Ms, 4 10^5}},
 ShowProgress -> True]
b = ListPlot3D[dat, Mesh -> All, PlotRange -> All]


  • Prev by Date: Re: disappointing CUDA speed
  • Next by Date: Re: Problems with Mathematica 8.0 Solve
  • Previous by thread: [Question] NonlinearRegress with two independent variables.
  • Next by thread: Why this can't be reduced by mathematica?!