1
$\begingroup$

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?

$\endgroup$
3
  • $\begingroup$ Plug in any value of $x\leq r$ and solve for $y$. In general, if you just want to find some points on the curve of an equation of two variables, try to figure out the allowed values of one variable and plug in any allowed value. If you are lucky, you will be able to solve for the other variable. Unfortunately, there are times when you will get an equation in one variable which you cannot solve for directly; you should rely on graphing software in that case. $\endgroup$ – SystematicDisintegration Jun 16 '18 at 9:09
  • $\begingroup$ How can i find this without just plugging in values? Also it isn't a function so you cant just do that. $\endgroup$ – Mitchell Browne Jun 16 '18 at 9:12
  • $\begingroup$ There is no general answer; one has to analyze the given equation and exploit facts about it. For example, if $r^2=3$ for the circle equation above, you will not be able to find any points neatly without plugging in some value. $\endgroup$ – SystematicDisintegration Jun 16 '18 at 9:15
1
$\begingroup$

@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.

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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