0

Regarding my previous question, which command I can use to obtain the numerical solutions of a general two-variable equation:

f[x_, y_] := 0

for some specific domains of $0<x<5$ and $0<y<6$.

More precisely, how can I ask Mathematica to consider $x={0,1,2,3,4,5}$ and provide the values of $y$ for them?

  • 2
    f[x_, y_] := 0 is not an equation. It's a function definition. Equation could be f[x,y]==0 – yarchik Feb 25 '20 at 18:23
  • 2
    I've answered your question there, 'FindRoot' is the numerical solver, which you need. – Artes Feb 25 '20 at 18:37
  • 1
    The list of numerical solutions in my answer is nsol, which I've obtained with FindRoot in Table. – Artes Feb 25 '20 at 19:29

1 Answers1

0

If you want to be general, one way to do it is:

eq = f[x, y] == 0

sol = Table[Solve[eq /. x -> a, y], {a, 0, 5}] // Flatten

The result is a table of inverse functions.

To get specific you specify f[x,y] then look at sol

f[x_, y_] := 3 x + 4 y

sol
(*{y -> 0, y -> -(3/4), y -> -(3/2), y -> -(9/4), y -> -3, y -> -(15/4)}*)

You should realize that Mathematica may not always be able to find solutions for every f.

For numerics, NSolve does work.

solN = Table[NSolve[eq /. x -> a, y], {a, 0, 5}]

f[x_, y_] := BesselJ[0, x^2 + Sin[y^2]]

solN // N

{{{y -> -0.55588 - 1.37106 I}, {y -> 
0.55588 + 1.37106 I}}, {{y -> -0.667605 - 1.42003 I}, {y -> 
0.667605 + 1.42003 I}}, {{y -> -0.842353 - 1.51008 I}, {y -> 
0.842353 + 1.51008 I}}, {{y -> -0.981582 - 1.59195 I}, {y -> 
0.981582 + 1.59195 I}}, {{y -> -1.08664 - 1.65879 I}, {y -> 
1.08664 + 1.65879 I}}, {{y -> -1.1683 - 1.7134 I}, {y -> 
1.1683 + 1.7134 I}}}

But to look for a specific range if there is more that one root, FindRoot may be better.

Bill Watts
  • 8,217
  • 1
  • 11
  • 28
  • 1
    Th OP asked about numerical solutions, not symbolic,, i.e. FindRoot is more powerful in this aspect. than Solve or NSolve. – Artes Feb 25 '20 at 21:40