2
$\begingroup$

For example, take the implicit equation for the unit circle

$\qquad x^2 + y^2 = 1$.

Is there a function Parameterize[x^2 + y^2 == 1] that would return a vector valued function

$\qquad v(t) = \{\cos(t),\,\sin(t)\}$

I've come across ParametricNDSolve, but can't seem to figure out how it works.

I may be asking the wrong question, please let me know if you think that's the case.

$\endgroup$
0

2 Answers 2

3
$\begingroup$

This is usually a tough problem to solve symbolically. The following function doesn't check whether system was solve, nor does it remove singular solutions.

ClearAll[parametrize];
(* Polar parametrization centered at basepoint *)
parametrize[eqn_, v : {x_, y_}, t_, basepoint : {_, _}] :=      
  parametrize[eqn, v, t, 
   Function[{param, elim}, basepoint + elim*{Cos[param], Sin[param]}]];
(* Default: polar parametrization centered at origin as in OP *)
parametrize[eqn_, v : {x_, y_}, t_, 
   paramform_ : Function[{param, elim}, elim*{Cos[param], Sin[param]}]
   ] :=
  Module[{r},
   Simplify@Solve[
     Eliminate[Flatten@{eqn, v == paramform[t, r]}, r],
     {x, y}
     ]
   ];

Examples:

parametrize[x^2 + y^2 == 1, {x, y}, t]
(*  {{x -> -Cos[t], y -> -Sin[t]}, {x -> Cos[t], y -> Sin[t]}}  *)
parametrize[x^2 + y^2 == 1, {x, y}, t, {1, 0}]
(*  {{x -> 1, y -> 0}, {x -> -Cos[2 t], y -> -2 Cos[t] Sin[t]}}  *)
(* The "Pythagorean Triples" parametrization *)
parametrize[x^2 + y^2 == 1, {x, y}, m, 
 Function[{m, x}, {x, m*(x + 1)}]]
(*  {{x -> -1, y -> 0}, {x -> (1 - m^2)/(1 + m^2), y -> (2 m)/(1 + m^2)}}  *)
$\endgroup$
2
  • 1
    $\begingroup$ See here how Maple does it. $\endgroup$
    – user64494
    Oct 4, 2020 at 17:10
  • 1
    $\begingroup$ @user64494 The generic Maple approach is similar to my last example, an algebraic (rational) parameterization of the pencil of lines through a point on the curve. The approach tends to produce a parametrization that misses a point (which is the limit as the parameter approaches infinity). The form OP desired was different, and I made a parametrization based on a polar angle the default. I added the optional paramform to show the algebraic approach. $\endgroup$
    – Michael E2
    Oct 5, 2020 at 14:15
2
$\begingroup$

Here's a numerical complement to my other answer. Just integrate orthogonally to the gradient. The code below produces a parameterization by arc length. It should fail (stop integration) if it reaches a singular point. NDSolve does not allow the domain of integration to be infinite on both sides, that is, {t, -Infinity, Infinity}. If you want to start in the middle and integrate both ways, alter {t, 0, Infinity} in nParametrize accordingly.

ClearAll[nParametrize];
ClearAll[periodify];
periodify[list_List] := ReplacePart[list, -1 -> First@list];

ClearAll[closeIF];
closeIF[ifn_InterpolatingFunction] := Interpolation[Transpose@{
     ifn["Grid"],
     periodify@ifn["ValuesOnGrid"], 
     periodify@Derivative[1][ifn]["ValuesOnGrid"]}, 
   PeriodicInterpolation -> True];
nParametrize[eqn_, v : {x_, y_}, basepoint : {x0_, y0_}, 
   tol_ : 0.001] :=
  Module[{vel, t, periodicQ = False},
   vel = Simplify[
     ComplexExpand@Normalize@Cross@D[eqn /. Equal -> Subtract, {v}],
     eqn];
   With[{res = NDSolve[
       {{x'[t], y'[t]} == (vel /. u : x | y :> u[t]),
        x[0] == x0, y[0] == y0,
        WhenEvent[
         x[t] == x0 && 
          Abs[y[t] - y0] < (tol + Sqrt@$MachineEpsilon*Abs[y0]),
         periodicQ = True; "StopIntegration"],
        WhenEvent[
         y[t] == y0 && 
          Abs[x[t] - x0] < (tol + Sqrt@$MachineEpsilon*Abs[x0]),
         periodicQ = True; "StopIntegration"]},
       v, {t, 0, Infinity}]},
    res /. if_InterpolatingFunction /; periodicQ :> closeIF[if]
    ]
   ];

Example:

psol = nParametrize[x^2 + y^2 == 1, {x, y}, {1, 0}]

In this case, nParametrize constructs a periodic solution, so in effect the domain is all real numbers (up to machine float limitations).

ParametricPlot[{x[t], y[t]} /. psol // Evaluate, {t, 10, 14}]
$\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.