2
$\begingroup$

I want to print the values of y for a range of x for an implicit function f(x,y). My equation is f(x,y)=x^2+y^2+2. The range of x is (2,10). I want the corresponding values of y.

$\endgroup$
1
  • 2
    $\begingroup$ An implicit equation needs to be of the form x^2 + y^2 + 2 = Constant in order to be solved. In your equation y is unconstrained meaning it can be literally any value. To find actual values for y, we need to be able to rearrange the equation into something like y = ± Sqrt[Constant - x^2 - 2]. $\endgroup$
    – MassDefect
    Dec 4, 2018 at 18:23

4 Answers 4

1
$\begingroup$

As pointed out earlier, if your equation is in the form x^2 + y^2 + 2 = Constant, then you can solve for y:

Clear[x, y];
eq = x^2 + y^2 + 2 == 0
sol = Solve[eq, y]

{{y -> -Sqrt[-2 - x^2]}, {y -> Sqrt[-2 - x^2]}}

These solutions can then be evaluated at some x-values of your choosing:

Table[{x, y /. sol}, {x, 2, 10}] // MatrixForm

![enter image description here

$\endgroup$
1
$\begingroup$

Before starting to Solve as in @MelaGo's solution, I would recommend you define and discretize an implicit region to get an idea of where the $xy$ values are:

J = ImplicitRegion[x^2 + y^2 + 2 == 5, {x, y}];
DiscretizeRegion[J, Frame -> True]

enter image description here

$\endgroup$
0
$\begingroup$

Using InverseFunction:

ClearAll[f]
f[x_, y_] := x^2 + y^2 + 2
finv = Quiet @ InverseFunction[f, 2, 2]

-Sqrt[-2 - #1^2 + #2] &

TableForm[Table[Row[{1, -1} finv[i, k], ","], {i, 1, 10}, {k, {5, 50, 100}}], 
 TableHeadings -> {"x = " <> ToString @ # & /@ Range[2, 10], 
   " f[x, y] = " <> ToString @ # & /@ {5, 50, 100}}]

enter image description here

$\endgroup$
-1
$\begingroup$

As @MassDefect has pointed out, you need to constrain y to some value (it can be dependent on x, but the relationship must be known). If you are just asking how to input a function and have it print the result you can try the following

myFunction[x0_,y0_] := Module[{x=x0,y=y0},
x^2 + y^2 +2];

For[i=2, i<11, i++,
Print[myFunction[i,3]]]

Note in my code i have specified y=3, but you could have a line directly above it saying y=x^2 -5 or something similar and then replace the 3 in the Print function with y.

Hope this helps

$\endgroup$

Your Answer

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

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