# Equation for a square.



## Adikshith Ojha (Feb 4, 2014)

I'm new here and this is my first post. The title is pretty much it, I have been trying a lot lately to get an equation for a square and I haven't succeeded, any mathematician here who can help me out? I doubt of there is one cause till my knowledge, equations exists only for curves.
This is what I started if with.
(x^2-a^2)(y^2-a^2)=0
But the equation was satisfied only by 8 points and after that, the more I think more difficult it seems, I'd appreciate if any of you guys help me out.
(I'm currently in high school so my knowledge is limited please bear with me)


----------



## UnicornRainbowLove (May 8, 2014)

I don't know if I should make a full calculation for you, but one thing you can do is to make a square with a center in (0,0) and calculate from there. Like when you make the equation of a circle, you can define D to be the distance between the origo and a coordinate (x,y) on the square. Use pythagoras to find an equation for D^2.

Now, unfortunately D^2 is varying depending on where you are on the square. You can try to make a different equation for D by using sine and arctan, and then in the end take your two equations for D and eliminate it for one big equation with only x,y and the length of the square as variables. It probably won't be pretty, but I'm quite sure it's doable.


----------



## Mimic octopus (May 3, 2014)

rectangle + rectangle = square


----------



## I_destroyedtheuniverse (Jul 24, 2014)

"An equation for a square". Could you specify, please? What components would be in the equation? What is being calculated?


----------



## knife (Jul 10, 2013)

Ever wonder why raising something to the second power is called _squaring_ it?

Well. It's pretty simple. If a x b = area, then since in squares a = b, a x b = a x a = a[SUP]2[/SUP]. And so to find a square you literally _square_ the length of the side. Try it out: most common proofs of the Pythagorean Theorem start by squaring all three of the triangle's sides.

The perimeter is 4a: a + a + a + a = a x 4 = 4a.

This assumes that one corner of the square lies at the origin, of course.


----------



## Tezcatlipoca (Jun 6, 2014)

To be fair that is only true in euclidean geometry with the lines 90 degrees apart.


----------



## HAL (May 10, 2014)

The best way to do it in one single function y=f(x), you can draw a square wave using a fourier transform. (google it)
Ok it's a square without a base. But that's the best you can get in a single function.

Otherwise you'll need to cheat and say something like:

for a<x<b, y=c, y=c-(b-a), x=b, x=a,

which is essentially just a way of saying, "Hey I'm gonna draw four different lines here."


----------



## Psychophant (Nov 29, 2013)

Why would you even want this? I think Hal probably has the closest thing, but that's still not going to do it since this can't be done with a function in Cartesian space. I guess if you used polar coordinates...


----------



## HAL (May 10, 2014)

Yomiel said:


> I guess if you used polar coordinates...


I've just spent ages staring at a polar plot on Mathematica, playing with a load of functions to see how they come out.

I think the problem is still there. There's still the whole issue of having to put a kink an otherwise smooth function.

There may be some kind of Fourier-style transform thingy to make a square in polar. I'm too lazy to figure it out though.


----------



## suremarc (Jan 13, 2013)

If you don't want to "cheat", you can do it in a couple of ways. This one is my favorite:





​
This is actually equivalent to saying "if x is not 1 or -1, then y is 1 or -1" and vice versa. Unfortunately the corners aren't included in the set of (x, y) that satisfy the equation. However I like this solution because it's fairly intuitive--it's the limit of a superellipse.

This equation pretty much nails it:





​
This one is a little less straightforward unless you know about linear transformations. Basically this is a diamond rotated by 45 degrees.


----------



## VyMajoris (Mar 6, 2015)

cool stuff.


----------



## ThatOneWeirdGuy (Nov 22, 2012)

I kind of cheated:

abs(x) + abs = c

(c being some constant) 










Then you can mess with that equation to rotate it and such.


----------



## suremarc (Jan 13, 2013)

BTW If anyone is wondering about "linear transformations" and how to rotate graphs, here's a hint


----------



## Adikshith Ojha (Feb 4, 2014)

suremarc said:


> If you don't want to "cheat", you can do it in a couple of ways. This one is my favorite:
> View attachment 283650​
> This is actually equivalent to saying "if x is not 1 or -1, then y is 1 or -1" and vice versa. Unfortunately the corners aren't included in the set of (x, y) that satisfy the equation. However I like this solution because it's fairly intuitive--it's the limit of a superellipse.
> 
> ...


Started of similarly but then I just expanded the modulus function (which was kinda stupid) and arrived at an equation which was pretty much useless, but the second equations works though, even if my base idea was to just draw 2 parallel lines intersecting at 90° :tounge:


----------

