Message Boards Message Boards

Simultaneously solving two equations and fitting with one set of datapoints

Posted 1 year ago

Dear All,

I am new in Mathematica.

I am trying to fit two equations (Ferromagnetic Resonance equations) simultaneously by FindRoot. And then fitting with one set of data to estimate the two parameters.

First I simulate the two equations by FindRoot. It is working well. (attached file 1)

Second I am trying to fit with data points, It showing some error. (attached file 2)

Could please give suggestions how to Improve it and where is incorrect code.

The equations are given. The data points are in the file. X-> thetaH (in radian) and y-> H (Magnetic field in Gauss)

I would like to estimate the value of Ku and K4.

In equation3(a) is the function of two angle thetha H and theta. Only ThetaH is know. To calculate the theta, I solve equation 1(a) and 3(a) simultaneously.

Please have a look the Mathematica file.

Thanks, Best Regards, Sukanta

Attachments

10 Replies

Dear Sukanta,

ok. theta is unknown. I am afraid that your problem is next to impossiible, this can be due to numeric problems and / or the existence of multiple solutions. At least I got several times error messages (fail to converge...).

Look at the notbook attached (last part). I tried to simplify eq3a by rescaling the variables and parameters. There are several solutions to eq3a, see the 1st Manipulate. Well ok, this approach does not take eq1a into accout..... . But I think rescaling is a good idea for numerical purposes. One can recalculate the wanted parameters from the rescaled ones.

Then there is fH2rez. For given theta, Ku, K4 it returns thetaH and H, the coordinates of the points in T1. dist calculates the square of the distance between the point given by fH2rez and a point (here #5) of T1. (You could as well use Norm).

In the example given I found a set of values which gives quite a small distance. But I failed to get it done by FindMinimum. And...this must be done for each point contained in T1, which probably gives different Ku and K4's.

Attachments:
POSTED BY: Hans Dolhaine

Dear Hans,

Good Morning. Thank you.

You are right. T1 = { { thetaH, H } } are the experimental values and I want to find Ku and K4 using eq1a and eq3a.

Yes, these depend from theta (θ) as well.

**Has theta a defined value? No. But it depends upon θH value.

Yes, theta (θ) is unknown parameter. By simultaneously fitting eq1a and eq3a to the experimental data T1, one can get the value of θ for each value of θH. And, θH and H are known from T1.

So, I am trying to fit both equations eq1a and eq3a simultaneously.

And, also one can get the value of Ku and K4.

Thanks, Best Regards, Sukanta

Dear Sukanta,

if I understand you correctly that means, T1 = { { thetaH, H } } are your experimental values and you want to find Ku and K4 using eq1a and eq3a. But these depend from theta as well. Which theta is to be used? What is theta? Has theta a defined vlaue?

What about this? (theta is unknown...?, I put it to 1 in this example with the 4th entry of T1))

feq1a[\[Theta]H_, H_] := Evaluate[eq1a]
feq3a[\[Theta]H_, H_] := Evaluate[eq3a]

NSolve[{feq1a[\[Pi]/30, 1280], feq3a[\[Pi]/30, 1280]} /. \[Theta] -> 1, {Ku, K4}]
POSTED BY: Hans Dolhaine

Dear Hans,

I would like to add one point.

**You have equations eq1a and eq3a. They depend on theta, H and thetaH. For a given thetaH (in the procedure called thetaH1) you can find for some given Ku and K4 theta and H (This is done in fH1rez - see the attached notebook). If you change Ku and / or K4 these values change as well.

Ans- I understood this. But, I would like to find Ku and K4 value for some given thetaH and H value.

And, then try to fit with the experimental data points for better estimation of K4 and Ku value.

Thanks, Sukanta

Dear Hans,

Sorry for my words. T1 is the data point from the experiment. It is thetaH vs H. I can say we measure the ferromagnetic resonance at different angle from 0 deg to 180 deg. For every angle, there is resonance field H for Co. Here we measure 10nm of Co thin film. So, T1 is the experimental data. However, I changed degree to radian.

****You have equations eq1a and eq3a. They depend on theta, H and thetaH. For a given thetaH (in the procedure called thetaH1) you can find for some given Ku and K4 theta and H (This is done in fH1rez - see the attached notebook). If you change Ku and / or K4 these values change as well.

Ans-Yes. They depend on theta, H and thetaH.

However, I trying to fit with T1 data points to evaluate Ku and K4.

It is the Points { thetaH, H } .

For your reference, I attached a paper here. Please see figure-3.

Thanks, Best Regards, Sukanta

Attachments:

Dear Sukanta,

no, I don't understand your problem - sorry. But mere repetition of your words doesn't make it clearer.

What is T1? Which data are given (I understand theta and H ? Or something else? )

You have equations eq1a and eq3a. They depend on theta, H and thetaH. For a given thetaH (in the procedure called thetaH1) you can find for some given Ku and K4 theta and H (This is done in fH1rez - see the attached notebook). If you change Ku and / or K4 these values change as well.

You can substitute these all these values in eq1a and eq3a ( This is done for the time being in fitfunc , see notebook ) and get two equations depending only on thetaH. Hmmm, that is for sure not what we want.

So once again: what is T1? Points { thetaH, H } or what?

Attachments:
POSTED BY: Hans Dolhaine

Dear Hans,

I have the value of all the parameters excluding θ, K4 and Ku in file-2. I have to calculate K4 and Ku value. For each value of θH , I can get the value of θ . Because θ depends upon θH.

In file-2, I am trying to calculate first K4 and Ku value by simultaneously solving eq1a and eq3a and fitting with data points. Again, I attached file-2.

And for your clarification, I have made some kind of simulation in file-1 by putting the values of all the parameters. This file-1 is only to show the simulation. Not for fitting.

For file-2 I am trying to fit with the data points to evaluate the value of K4 and K4.

** θH is the angle of applied magnetic field, whereas θ is the angle of magnetisation.

I hope you understand the problem.

Thanks, Best Regards, Sukanta

Attachments:

Hello Sukanta,

sorry, I don't understand what you mean?

Which values are given, which are to be calculated?

In File 1 you specify a ThetaH1 and FHrez gives you Theta and H for the given Ku and K4.

How to get a data-point of T1 given Theta and H?

POSTED BY: Hans Dolhaine

Hello Sukanta,

I had a look into your File-2. It could be helpful to know, what exactly you want to do.

For me it seems that your function

fitfunc[ a, b, x ]

doesn't even come near to your data in T1. (See the notebook attached. I modified it a bit to see where things start to go wrong) . Do you have any idea what numbers are expected for a and b ?

And obviously your data don't follow an Exp-function.

Attachments:
POSTED BY: Hans Dolhaine

Dear Hans,

Thank you very much for your suggestions. I would like to estimate the two parameters K4 and K4 by using the equation eq1a and eq3a simultaneously and fitting them with data points T1 in the attached file.

The data is H vs θH. These two parameters are known. The magnetisation angle θ is unknown in eq1a and eq3a. However, By solving simultaneously eq1a and eq3a, one can get the θ vs θH as I have done in file-1.

Here θH is the x-axis and H is the y-axis.

I am using the fitfunc command for fitting as shown in the attached file. However, It is showing some errors. Please have a look.

Thanks, Best Regards, Sukanta

Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract