I get some results z1 from an equation
s1 = y''[x] + Sin[y[x]] y[x];
sol1 = NDSolve[{s1 == 0, y[0] == 1, y'[0] == 0}, y, {x, 0, 30}];
sy[x_] = {y[x]} /. s;
z1 = Table[Take[sy[x]], {x, 5, 30, 5}]
{{{-4.56095}}, {{0.999889}}, {{-4.55976}}, {{0.999555}},{{-4.55738}}, {{0.998999}}}
Now a new equation s2 contains a and b
s2 = a*y2''[x] + b*Sin[y2[x]] y2[x]
The results z2 should be solved using the same method.
sol2 = NDSolve[{s2 == 0, y2[0] == 1, y2'[0] == 0}, y2, {x, 0, 30}];
sy2[x_] = {y2[x]} /. s;
z2 = Table[Take[sy2[x]], {x, 5, 30, 5}]
Then I want to minimize (z1-z2).(z1-z2) and find a and b
Nminimize[(z1 - z2).(z1 - z2), {a, b}]
I know my codes can’t work, but I’m trying to express thought. I’m new to Mathematica. I really appreciate your help.