Given an equation that is not a function of $x$, how can you find points on the graph without trial and error?
E.g. $$ x^2 +y^2=r^2$$
How could I find $n$ points that lay on that line?
Given an equation that is not a function of $x$, how can you find points on the graph without trial and error?
E.g. $$ x^2 +y^2=r^2$$
How could I find $n$ points that lay on that line?
Copyright © 2021 JogjaFile Inc.
@SystematicDisintegration has a good hint of how to find one first solution.
If you know some calculus and linear algebra, once you get any one point on the curve, you can calculate the gradient and take small steps orthogonal to the gradient. The gradient of your function is $$[2x,2y]^T$$ A vector orthogonal to that one is for example $$[2y,-2x]^T$$ and will point somewhere in tangent plane. Since we are in two dimensions tangent plane has 2-1=1 dimension so 1 vector will be good enough. When you have taken small steps in the tangent direction you can make corrections taking you back to the level set you want to plot. When doing these corrections you can for example aim to make $x^2+y^2-r^2$ minimized, because you want to solve $x^2+y^2-r^2=0$, right? One way to do that is to take small steps in the (negative) gradient of $$(x^2+y^2-r^2)^2$$
Now you have everything you need to start experimenting.
EDIT We can derive the partial derivatives:
$$\frac{\partial}{\partial x} (x^2+y^2-r^2)^2 =/\text{ chain rule }/= 2(x^2+y^2-r^2)\cdot 2x$$
$$\frac{\partial}{\partial y} (x^2+y^2-r^2)^2 =/\text{ chain rule }/= 2(x^2+y^2-r^2)\cdot 2y$$
So now we can finally do the update. Here is what it looks like if we start with points equidistantly spaced on the unit square sides.