0
$\begingroup$

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

$\endgroup$
10
  • 3
    $\begingroup$ This is the equation of a sphere in four dimensions. There are infinitely many solutions, so your question is not very clear $\endgroup$ Jun 1 '16 at 11:14
  • $\begingroup$ I basically want to find some random point (a1,b1,c1,d1) which satisfies this $\endgroup$ Jun 1 '16 at 11:15
  • 1
    $\begingroup$ are you looking for real or integer solutions? $\endgroup$
    – user340508
    Jun 1 '16 at 11:16
  • 1
    $\begingroup$ there is a nontrivial theorem on numbers that can be represent as sum of 4 squares: en.wikipedia.org/wiki/Lagrange's_four-square_theorem $\endgroup$
    – user340508
    Jun 1 '16 at 11:20
  • 1
    $\begingroup$ I think this is a good reference. $\endgroup$
    – N74
    Jun 1 '16 at 13:35
1
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Or he could set $$\begin{cases} a=\sqrt\alpha\cos(29)\\ b=\sqrt\alpha\sin(29)\cos\left(\sqrt[3]\pi\right)\\ c=\frac{\sqrt{3\alpha}}2\sin(29)\sin\left(\sqrt[3]\pi\right)\\ d=-\frac{\sqrt\alpha}2\sin(29)\sin\left(\sqrt[3]\pi\right)\end{cases}$$ How is this observation sensible? The poster said in the comments he needs to find random points. $\endgroup$
    – user228113
    Jun 1 '16 at 11:28
0
$\begingroup$

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

$\endgroup$
0
$\begingroup$

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

$\endgroup$
2
  • $\begingroup$ Yeah. But I have mentioned this solution already in question but for 2 variables and then solving for c and d. Is there any other alternative? $\endgroup$ Jun 1 '16 at 11:16
  • $\begingroup$ In your question you say that we can set $a,b$ and solve for $c,d$. This a bit different. Obviously you can also solve, in the same manner, for $b$ or $c$ or $d$, but the point is that a solution does depend on the other three variables that can be chosen as we want ( at random). $\endgroup$ Jun 1 '16 at 11:21
0
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thanks for your reply. But I need them to be integers $\endgroup$ Jun 1 '16 at 11:39

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.