# Plotting an implicit function

Suppose I am given an equation of the following form: $$f(x,y)=0$$. I would like to find $$y$$ as a function of $$x$$. i.e. find the function $$y=y(x)$$. In general, it is impossible to find a closed-form solution. I can use ContourPlot to visualize the solution. Now, suppose I would like to plot a function $$z=g(y(x))$$ in terms of $$x$$. How can I do this in Mathematica?

• Is $y$ a function of $x$ in general? Or can $f$ be something like $f(x,y)=x^2+y^2-1$? People here generally like users to post a minimal working example in Mathematica code. It makes it convenient for them to copy-paste it and test their ideas. It's more likely you will get someone to help you. – Michael E2 Apr 29 at 21:42

Here's generic approach, if you can pick a initial point:

Block[{f, g, a, b, x0, y0 ics},
(* set up problem *)
f[x_, y_] := x^2 + y^2 - 1;
g[y_] := Sin[Pi y];
a = -1;
b = 1;
{x0, y0} = {0, 1};

(* generic solution *)
ics = {y[x0] == y0, z[x0] == g[y0]};
ListLinePlot@
NDSolveValue[{D[z[x] == g[y[x]], x], D[f[x, y[x]] == 0, x], ics},
z, {x, a, b}]
] Thanks @Michael E2 provide an example.

f[x_, y_] := x^2 + y^2 - 1;
g[t_] := Sin[Pi*t];
ParametricPlot[{x, g[y]}, {x, -1, 1}, {y, -1, 1},
MeshFunctions -> Function[{x, y, u, v}, f[u, v]], Mesh -> {{0}},
MeshStyle -> Red, PlotStyle -> Opacity[.01], PlotPoints -> 80,
BoundaryStyle -> None] Another way is use ParametricRegion.

f[x_, y_] := x^2 + y^2 - 1;
g[t_] := Sin[Pi*t];
RegionPlot[
DiscretizeRegion[ParametricRegion[{{x, g[y]}, f[x, y] == 0}, {x, y}],
MaxCellMeasure -> {Length -> 0.01}]] 