0
$\begingroup$

Can anyone help me? This is my code:

f[x_ ] = x Exp[I z]] (Cos[z]] BesselJ[l, a *x] - BesselY[l, a *x] Sin[z])
u=0.1
v=6

on the other hand hand:

s2 = ParametricNDSolve[{(a^2 - (l (l + 1))/x^2 + E^(-(x/b))/x) g[x] + g''[x] == 0, g[u] == 1, g'[u] == (l + 1)/u}, g, {x, u, v}, {a, b, l}]

In the above two equations a,b and l are free parameters. I want to find z for different values of these free parameters. I want to manipulate these three parameters and see how z behaves under their variations. This is my code:

NSolve[(v f'[v]/f[v]) - 1 == v ( (D[Evaluate[g[a, b, l][x] /. s2], x] /. x -> v) / Evaluate[g[a, b, l][v] /. s2]) - 1 && 0 <=  z <=  \[Pi] , z]

The first problem is that NSolve can not solve the parametric equation. I do not know what code I should use. The second problem is when I manipulate the parameters, nothing happens:

Manipulate[NSolve[(v \f'[v]/f[v]) - 1 ==  v ( (D[Evaluate[g[a, b, l][x]. s2], x] /. x -> v) / Evaluate[g[a, b, l][v] /. s2]) - 1 && 0 <=  z <=\[Pi] , z], {a, .001, 10, 0.00001}, {b,0.1,1000,0.00001}, {l, 0, 1000, 1}] 

Nothing happens. Or maybe the correct one is this code:

NSolve[Manipulate[(v \f'[v]/f[v]) - 1 ==  v ( (D[Evaluate[g[a, b, l][x]. s2], x] /. x -> v) / Evaluate[g[a, b, l][v] /. s2]) - 1, {a, .001, 10, 0.00001}, {b,0.1,1000,0.00001}, {l, 0, 1000, 1}] && 0 <=  z <=\[Pi] , z], 

Again, nothing happens. Thanks a lot.

$\endgroup$
1
  • $\begingroup$ Please correct f[x_] := x Exp[I z] (Cos[z] BesselJ[l, a*x] - BesselY[l, a*x] Sin[z]). NSolve can't evaluate because of undefined parameters a,b,l! $\endgroup$ Jun 19, 2019 at 13:09

1 Answer 1

1
$\begingroup$

Try (f[x] modified)

f[x_] := x Exp[I z] (Cos[z]  BesselJ[l, a*x] - BesselY[l, a*x] Sin[z])
u = 0.1
v = 6

solution of the ode

G = ParametricNDSolveValue[{(a^2 - (l (l + 1))/x^2 + E^(-(x/b))/x) g[x] + g''[x] == 0, g[u] == 1, g'[u] == (l + 1)/u},g, {x, u, v}, {a, b, l}]

G[a,b,l][x] is the parametric solution.

If I understand your NSolveright you try to solve f[v]== G[a, b, l][v]

sol[a_?NumericQ, b_?NumericQ, l_?NumericQ] :=NSolve[{6 E^(I z) (BesselJ[l, 6 a] Cos[z] - BesselY[l, 6 a] Sin[z]) ==G[a, b, l][v], 0 <= z <= Pi}, z, Reals]
$\endgroup$
3
  • $\begingroup$ Thank you a lot. I want to solve f'[v]/f[v]==G'[a,b,l][v]/G[a,b,l][v]. This is the error I get when I want to find sol[1,2,1]: ParametricNDSolveValue::ndsv: Cannot find starting value for the variable g. $\endgroup$
    – Mehrdad
    Jun 19, 2019 at 16:50
  • $\begingroup$ Please show your code! f'[v]/f[v]==G'[a,b,l][v]/G[a,b,l][v] is wrong, try f'[v]/f[v]==G[a,b,l]'[v]/G[a,b,l][v] instead. $\endgroup$ Jun 19, 2019 at 19:42
  • $\begingroup$ I copied the above codes, everything is OK. But, when I want to test to see what will be z for different values of a, b and l, it does not give me the answer. This is the code: 'sol[a_?NumericQ, b_?NumericQ, l_?NumericQ] := NSolve[{f'[v]/f[v] == G[a, b, l]'[v]/G[a, b, l][v], 0 <= z <= Pi}, z]' . Now, I want to see what is z for a=1, b=2, l=1. I write this code f[1,2,1], but it does not give me any answe. $\endgroup$
    – Mehrdad
    Jun 20, 2019 at 0:19

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.