1
$\begingroup$

My equation is as follows:

sol = 
  ParametricNDSolve[{(f'[r]^2 - 1) f'[r] r == 6.2 (f'[1])^2/1000, f[1] == a}, 
    {f}, {r, 1, 3}, {a}]

where the function f[r] needs to satisfies a constraint 6.2 (f'[1])^2/1000 = 6 (f'[3])^2/1000

Then I plot f[r]

Plot[Evaluate[{(f'[a])^2[1],6(f'[a])^2[3]/6.2} /. sol], {a, 0, 2}]

I am getting the message

ParametricNDSolve::litarg: To avoid possible ambiguity, the arguments of the dependent variable in {r (NDSolvef$1$1^\[Prime])[r] (-1+(NDSolvef$1$1^[Prime])[r]^2)==0.0062 NDSolvef$1$1[1]^2,2 r (NDSolvef$1$1^[Prime])[r]^2 (NDSolvef$1$2^\[Prime])[r]+r (-1+ (NDSolvef$1$1^[Prime])[r]^2) (NDSolvef$1$2^\[Prime])[r]==0.0124 NDSolvef$1$1[1] NDSolve`f$1$2[1]} should literally match the independent variables. >>

I do not know how to avoid the error message and solve the function f[r]

$\endgroup$
2
$\begingroup$

The error message arises because there are three possible values for f'[1] that satisfy your DE:

Solve[(f'[r]^2 - 1) f'[r] r == 62/10 (f'[1])^2/1000 /. r -> 1, f'[1]]
% // N

(*
  {{Derivative[1][f][1] -> 0},
   {Derivative[1][f][1] -> (31 - Sqrt[100000961])/10000},
   {Derivative[1][f][1] -> (31 + Sqrt[100000961])/10000}}

  {{Derivative[1][f][1.] -> 0.},
   {Derivative[1][f][1.] -> -0.996905},
   {Derivative[1][f][1.] -> 1.0031}}
*)

If you pick one, the equation is solved:

sol = With[{df1 = (31 + Sqrt[100000961])/10000}, 
  ParametricNDSolve[{(f'[r]^2 - 1) f'[r] r == 62/10 (df1)^2/1000, 
    f[1] == a}, {f[r], f'[r]}, {r, 1, 3}, {a}]
  ];

Another problem is how sol is used in Plot. You have to pass the parameter a to ParametricFunction to get an InterpolatingFunction; after that, then one can take the derivative and plug in r. The easiest way that occurred to me was to ask ParametricNDSolve to return f'[r] in addition to f[r] and use that. It's important not to use Evaluate here, because r cannot be replaced with a number until after Plot has replaced a with a number.

Plot[{(f'[r][a])^2 /. sol /. r -> 1, 
       6 (f'[r][a])^2/6.2 /. sol /. r -> 3},
 {a, 0, 2}]

The last problem is that the DE is inconsistent with the constraint 6.2 (f'[1])^2/1000 == 6 (f'[3])^2/1000, but that I will leave with the OP. For example, for the initial value for f'[1] used above, none of the solutions for f'[3] satisfy the constraint:

df1 = (31 + Sqrt[100000961])/10000;
df3 = Chop@
   N[f'[3] /. 
     Solve[(f'[r]^2 - 1) f'[r] r == 62/10 (df1)^2/1000 /. r -> 3, 
      f'[3]]];
6.2 (df1)^2/1000 - 6 (df3)^2/1000
(*
  {0.000251049, 0.00623853, 0.000226095}
*)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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