# numerical solution of nonlinear differential equation : parameter fitting

I want to fit data

X-axis and Y-axis are L and P, respectively

n'[L,t] == L a - b n[L,t]^2 - c n[t]^3, n[L,0]==0


a,b,c is independent parameters.

P value is square integrate n^2 about t from 0 to 30

K is just scaling factor about y-axis (because y-axis is arbitrary unit.)

If fit that data using above mathematical expression, the graph (maybe) look like the below figure (log-log).

After fitting, the parameters a, b, and c are derived.

1. I want to fit the data (like above figure)
2. I want to know parameter value a, b, and c

the data {X-axis (L),Y-axis (P)}= {0,0}, {3.69E+12,50.65}, {5.67E+12,134.875}, {7.05E+12,225.275}, {9.03E+12,381.65}, {1.09E+13,509.5}, {1.25E+13,595.3}, {1.45E+13,815.325}, {1.76E+13,1225}, {2.10E+13,1624.125}, {2.46E+13,2018.725}, {2.84E+13,2488.775}, {3.18E+13,2942.9}, {3.68E+13,3630}, {4.39E+13,4558.65}, {5.52E+13,5925.925}, {6.45E+13,7044.075}, {7.23E+13,7972.2}, {8.18E+13,9119.575}, {9.38E+13,10545}, {1.06E+14,11749.1}, {1.28E+14,13760.475}, {1.42E+14,15055.65}, {1.57E+14,16484.475}

Thank you.

• What did you try so far? Jan 10, 2019 at 11:18

Normalizing the data

data =
{{0, 0}, {3.69 10^12, 50.65}, {5.67 10^12, 134.875},
{7.05 10^12, 225.275}, {9.03 10^12, 381.65}, {1.09 10^13, 509.5},
{1.25 10^13, 595.3}, {1.45 10^13, 815.325}, {1.76 10^13, 1225},
{2.10 10^13, 1624.125}, {2.46 10^13,2018.725}, {2.84 10^13, 2488.775},
{3.18 10^13, 2942.9}, {3.68 10^13, 3630}, {4.39 10^13, 4558.65},
{5.52 10^13, 5925.925}, {6.45 10^13, 7044.075}, {7.23 10^13, 7972.2},
{8.18 10^13, 9119.575}, {9.38 10^13, 10545}, {1.06 10^14,11749.1},
{1.28 10^14, 13760.475}, {1.42 10^14, 15055.65}, {1.57 10^14, 16484.475}};

data0 = Table[{data[[k]][[1]]/(1.57*10^14), data[[k]][[2]]/16484.475}, {k, 1, Length[data]}]


Solving the parametric DE

pfun = ParametricNDSolveValue[{n'[t] == t a - b n[t]^2 - c n[t]^3, n[0] == 0}, n, {t, 0, 1}, {a, b, c}]


Calculating the best fit

fit = FindFit[data0, pfun[a, b, c, L][t], {{a, 10}, {b, 10}, {c, 10}, {L, 1}}, t, Method -> {NMinimize, Method -> "DifferentialEvolution"}] // Quiet
(*{a -> 9.47593, b -> 18.5274, c -> -10.2934}*)


Verifying

Show[ListPlot[data0, PlotStyle -> Red], Plot[pfun[a, b, c][t] /. fit, {t, 0, 1}], ImageSize -> Medium]


• Thank you for your kind explanation Cesareo! Can we manipulate pure x-y data that not normalized? (I hope pure data because x-axis is not arbitrary unit but physical quantity.) I thought your answer omit the Integral calculation about n[L,t]. after solving the parametric DE pfun = ParametricNDSolveValue[{n'[t] == L a - b n[t]^2 - c n[t]^3, n[0] == 0}, n, {t, 0, 1}, {a, b, c, L}] P=NIntegrate[pfun^2, {t,0,30}] (sorry but, I don't know well the integration code) then P is function of L. (L is independent variable, a b and c are constant parameter) I want to fit P(L) [the graph of x-axis is L Jan 11, 2019 at 5:38
• @hongsunRyu please see help/merging-accounts. Then you will be able to comment under answers for your questions. If you have a completely different question, create a separate topic.
– Kuba
Jan 11, 2019 at 8:35
• @hongsunRyu Regarding the equation n'[L,t] == L a - b n[L,t]^2 - c n[t]^3, n[L,0]==0 I assume it as n'[t] == t a - b n[t]^2 - c n[t]^3, n[0]==0 because otherwise the required data should be a three-dimensional set. Two independent variables L,t and one outcome n. Regarding the scaling it is t is advisable in these cases to scale the independent variable to ensure the numerical stability of the results. The scaling that I introduced is not appropriate but I did it as a suggestion of what should be done. It is advisable to use your own techniques for this section Jan 11, 2019 at 10:13