0
$\begingroup$

We have the function $\gamma(u,v)$ defined implicitly as the solution of

\begin{align} \sin\gamma(u,v)=g\left(u-v\cos\gamma(u,v) \right), \end{align}

being $g$ a given function. I can solve for $\gamma$ using NSolve or FindRoot, as for instance

  gt[x_] := x^4; 
  num\[Gamma][(u_)?NumberQ, (v_)?NumberQ] := \[Gamma] /. FindRoot[{gt[u - v*Cos[\[Gamma]]] == Sin[\[Gamma]]}, {\[Gamma], 0.5, 0, Pi}]
  Plot3D[{0, num\[Gamma][u, v]}, {u, 0, 1}, {v, 0, 1}, PlotRange -> All, AxesLabel -> Automatic]

however when I want to take derivatives of this $\gamma$ for plotting and further manipulating, simple D does not work. What would be a better approach ? Also, for the case where $g$ is an interpolation function.


We would like to not only take derivatives of $\gamma$ but also integrating and further manipulating, so instead of simply using ImplicitD what I am looking for is to get it as an interpolation function or the like.

$\endgroup$
2
  • $\begingroup$ Do you know about ImplicitD? $\endgroup$
    – Domen
    Commented Apr 14 at 17:55
  • $\begingroup$ @Domen Thank you. I don't. Does it work with non-analytic, numeric functions ? $\endgroup$ Commented Apr 14 at 17:57

3 Answers 3

3
+50
$\begingroup$
$Version

"14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)"

Clear["Global`*"]

eqn = gt[u - v*Cos[γ]] == Sin[γ];

gt[x_] := x^4;

numγ[uv_?NumericQ, vv_?NumericQ] :=
 Module[{u = Rationalize[uv, 0], v = Rationalize[vv, 0]},
  γ /. FindRoot[{gt[u - v*Cos[γ]] == Sin[γ]}, 
    {γ, 1/2, 0, Pi},
    WorkingPrecision -> 15]]

As suggested by Domen, use ImplicitD

dγu[u_, v_] = (ImplicitD[eqn, γ, u] // FullSimplify) /. 
   γ -> numγ[u, v]

(* 1/(Cos[numγ[u, v]]/(4 (u - v Cos[numγ[u, v]])^3) - 
 v Sin[numγ[u, v]]) *)

dγv[u_, v_] = (ImplicitD[eqn, γ, v] // FullSimplify) /. 
   γ -> numγ[u, v]

(* 1/(-(1/(4 (u - v Cos[numγ[u, v]])^3)) + 
 v Tan[numγ[u, v]]) *)

Plot3D[Evaluate@dγu[u, v], {u, 0, 1}, {v, 0, 1},
 Exclusions -> {u == v},
 ClippingStyle -> None,
 PlotRange -> {-1.5, 5},
 WorkingPrecision -> 15,
 PlotPoints -> 50,
 MaxRecursion -> 5,
 AxesLabel -> Automatic]

enter image description here

Plot3D[Evaluate@dγv[u, v], {u, 0, 1}, {v, 0, 1},
 Exclusions -> {u == v},
 ClippingStyle -> None,
 PlotRange -> {-4, 2},
 WorkingPrecision -> 15,
 PlotPoints -> 50,
 MaxRecursion -> 5,
 AxesLabel -> Automatic]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you. In version 13.1 it's quite slow, tho. I also wanted to avoid ImplicitD because if we want to integrate instead of differentiate, or perform any other operation, it will not be direct as with for instance an interpolation function. $\endgroup$ Commented Apr 15 at 7:37
1
$\begingroup$

This is an abusing of NDSolveValue to solve non-differential equation by adding D[γ[u, v], v] to both sides of the equation.

Works well also with derivation or integration of $\gamma$.

gt[x_] := x^4

gama = NDSolveValue[
    gt[u - v*Cos[γ[u, v]]] + D[γ[u, v], v] == 
     Sin[γ[u, v]] + D[γ[u, v], v], γ, {u, 0, 1}, {v, 0, 1}] // Quiet;

Plot3D[gama[u, v], {u, 0, 1}, {v, 0, 1}, PlotRange -> All]

Plot3D[Derivative[0, 1][gama][u, v], {u, 0, 1}, {v, 0, 1}, PlotRange -> All]

Plot3D[NIntegrate[gama[u, v], {u, 0, 1}], {u, 0, 1}, {v, 0, 1}, PlotRange -> All]

enter image description here

$\endgroup$
0
$\begingroup$

Perhaps this?:

\[Gamma]IFN = 
 FunctionInterpolation[num\[Gamma][u, v], {u, 0, 1}, {v, 0, 1}]

Then

Plot3D[{0, num\[Gamma][u, v], \[Gamma]IFN[u, v]},
 {u, 0, 1}, {v, 0, 1}, PlotRange -> All, AxesLabel -> Automatic]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.