# How to force Wolfram solve the ODE with respect to h[s]?

I have a problem with the DSolve operator. It just gives me the initial ODE as an answer, however, obviously, I need to find the answer h[s] as a function of f[s] and its powers (or whatever else). It is an differential-algebraic equation, but I do not have any connection between f[s] and h[s], they're independent.

r[s_, t_] := {s, f[s]*Cos[t], h[s]*Sin[t]}
r1[s_, t_] := D[r[s, t], s] // Simplify
r2[s_, t_] := D[r[s, t], t] // Simplify
g11[s, t] := r1[s, t].r1[s, t] // Simplify
g22[s, t] := r2[s, t].r2[s, t] // Simplify
g12[s, t] := r1[s, t].r2[s, t] // Simplify

detG := g11[s, t] g22[s, t] - g12[s, t] g12[s, t] // Simplify
derivG = 1/2*D[detG, s] // FullSimplify

DSolve[derivG == 0, h[s], s]


So, how does one force Mathematica to solve the eqn? Could someone point me on some mistakes if there are any? Thanks in advance.

• it is not likely you can get analytical solution for $h(s)$ because your second order ode is nonlinear. how does one force Mathematica to solve the eqn? some ode's can't be solved analytically. In this case you could try numerical solution. Sep 18, 2023 at 6:53
• @Nasser but what should I print? Please, I'm begging, help me! I need to find the h[s]... Sep 18, 2023 at 7:51

but what should I print?

Mathematica can't solve it analytically. Even if you replace all other terms by parameters

ClearAll["Global*"]
r[s_, t_] := {s, f[s]*Cos[t], h[s]*Sin[t]}
r1[s_, t_] := D[r[s, t], s] // Simplify
r2[s_, t_] := D[r[s, t], t] // Simplify
g11[s, t] := r1[s, t] . r1[s, t] // Simplify
g22[s, t] := r2[s, t] . r2[s, t] // Simplify
g12[s, t] := r1[s, t] . r2[s, t] // Simplify

detG = g11[s, t] g22[s, t] - g12[s, t] g12[s, t] // Simplify;
derivG = 1/2*D[detG, s] // FullSimplify;
ode = derivG == 0


ode=ode/.{Sin[t]->m,Cos[t]^2->a}


DSolve[ode,h[s],s]
(* no solution *)


If you must have analytic solution, then the next best thing is series solution (here is one using 3 terms)

ClearAll["Global*"]
r[s_, t_] := {s, f[s]*Cos[t], h[s]*Sin[t]}
r1[s_, t_] := D[r[s, t], s] // Simplify
r2[s_, t_] := D[r[s, t], t] // Simplify
g11[s, t] := r1[s, t] . r1[s, t] // Simplify
g22[s, t] := r2[s, t] . r2[s, t] // Simplify
g12[s, t] := r1[s, t] . r2[s, t] // Simplify

detG = g11[s, t] g22[s, t] - g12[s, t] g12[s, t] // Simplify;
derivG = 1/2*D[detG, s] // FullSimplify;
ode = derivG == 0;
ode=ode/.{Sin[t]->m,Cos[t]^2->a};
sol=AsymptoticDSolveValue[ode, h[s], {s, 0, 3}];
sol/.{m->Sin[t],a->Cos[t]^2}


The above is the solution $$h(s)$$ near $$s=0$$ as function of $$f,f',f'',\sin(t),\cos(t)$$. The values of $$f,f',f''$$ at $$s=0$$ zero are needed to evaluate the above.

• thank yo VERY much! I'm not a pro in Mathematica, so i didn't know how to calculate the series within the program Sep 18, 2023 at 9:22