First, I rewrote and renamed a few parameters and equations for clarity
First, I rewrote and renamed a few parameters and equations for clarity
In[]:=
ClearAll[Ω,h,z,a0,b0,c0,goal,Ω0];(*Ourdesirablefunction*)goal[z_]:=*(4*h[z]*Ω[z]-Ω[z]^2-2*(1+z)*h[z]*D[Ω[z],z])+a+b**(2*h[z]*Ω[z]-Ω[z]^2)+c;Ω0=1.+
0.3075*(1+z)^3+0.6911
;(*Initialvaluesforparametersσ0->a,σa->b,λ->c*)a0=-2.;b0=0.04;c0=2.1;eq1=-2.*(1+z)*h[z]*D[h[z],z]+3*h[z]^2-4*h[z]*Ω[z]+Ω[z]^2+2*(1+z)*h[z]*D[Ω[z],z];eq2=-1.
3
z
1+z
0.3089
;In[]:=
fullSolution=ParametricNDSolve[{deq20,deq3==0,h[0]1,Ω[0]Ω0},{h,Ω},{z,0,4},{a,b,c}];solution=h/.fullSolution
Out[]=
ParametricFunction
Using manipulate (with relatively good initial parameters) we can manually find better values
Using manipulate (with relatively good initial parameters) we can manually find better values
In[]:=
Manipulate[Plot[{solution[a,b,c][z],goal[z]},{z,0,4}],{{a,a0},-5,5,0.01},{{b,b0},-5,5,0.01},{{c,c0},-5,5,0.01},SaveDefinitions->True]
Out[]=
I’ve found next:
In[]:=
a1=-1.86;b1=2.69;c1=1.89;
Now get table of values of goal function (you could decrease step ):
data=Table[goal[z],{z,0,4,0.01}];
And try to find best fitting of these data, using our solution and manually found initial approximations for parameters.
Please read carefully FindFit documentation and use the best method and approach!
Please read carefully FindFit documentation and use the best method and approach!
fit=Quiet@FindFit[data,solution[a,b,c][x],{{a,a1},{b,b1},{c,c1}},x,Method->"Newton"]
Out[]=
{a-1.84723,b2.65435,c1.89321}
In[]:=
Plot[{goal[z],solution[a,b,c][z]/.fit},{z,0,4}]
Out[]=

