How to solve quadratic equation in 4 variables?

4.3k Views Asked by At

I am trying to solve the equation $a^2 + b^2 + c^2 + d^2 = \alpha$ where alpha is a constant and $a, b, c$, and $d$ are the $4$ variables. I need to find some integer values of $a, b, c$ and $d$ which satisfies this equation

I know that I can make $a, b$, and $c$ as $0$ and then $d = \sqrt\alpha$ but this is one very trivial solution.

Another approach which I have in mind is to set $a, b$ as constant and then solve for $c$ and $d$ using brute-force method but that again is very computation intensive method of doing this.

Is there any better way of solving this

5

There are 5 best solutions below

0
On

You need 4 equations to solve for 4 variables, or in general n equations to solve a n degree polynomial. But if you have no other equations, only thing that can be done is putting values and verifying

2
On

You can chose any value for $b,c,d$ and find: $$ a=\pm \sqrt{\alpha-(b^2+c^2+d^2)} $$

obviously $a$ is a real number only if $(b^2+c^2+d^2)\le \alpha$.

1
On

There is an infinity number of solutoins, but you could set $a=b=c=d =\sqrt(\alpha/4)$.

As @Aditya Singh state in a comment to his question "I basically want to find some random point (a1,b1,c1,d1) which satisfies this" I suggest the following algorithm to find (more or less) random points:

  1. Take/sample a value for $a$ between $\pm \sqrt(\alpha)$
  2. Take/sample a value for $b$ between $\pm \sqrt(\alpha - a^2)$
  3. Take/sample a value for $c$ between $\pm \sqrt(\alpha - a^2 - b^2)$
  4. Finally $d = \pm \sqrt(\alpha -a^2 - b^2 - c^2)$

in R:

alpha <- 5

a1 <- runif(1, min = -sqrt(alpha), max = sqrt(alpha))
b1 <- runif(1, min = -sqrt(alpha - a1^2), max = sqrt(alpha - a1^2))
c1 <- runif(1, min = -sqrt(alpha - a1^2 - b1^2), max = sqrt(alpha - a1^2 - b1^2))
d1 <- sqrt(alpha - a1^2 - b1^2 - c1^2) * sample(c(-1, 1), 1)

a1^2 + b1^2 + c1^2 + d1^2 #gives 5

As he later stated in another comment, that he need integers as solution, he might want to read https://stackoverflow.com/questions/11732555/how-to-find-all-possible-values-of-four-variables-when-squared-sum-to-n or https://cs.stackexchange.com/questions/2988/how-fast-can-we-find-all-four-square-combinations-that-sum-to-n.

1
On

To find a "random point" $(a,b,c,d)$ (as you say in a comment) satisfying $a^2+b^2+c^2+d^2= \alpha$, uniformly on the hypersphere surface:

  • generate $W,X,Y,Z$ independently each normally distributed $N(0,1)$
  • find $r = \sqrt{ W^2+X^2+Y^2+Z^2}$
  • set $a=\dfrac{\sqrt{\alpha}}{r}W$, $b=\dfrac{\sqrt{\alpha}}{r}X$, $c=\dfrac{\sqrt{\alpha}}{r}Y$, $d=\dfrac{\sqrt{\alpha}}{r}Z$

but these are unlikely to be integers

0
On

The integer solutions to $a^2+b^2+c^2+d^2=n$ for a positive integer $n$ can be found by using the norm for the Hurwitz integers, see here.