TransWikia.com

Reduce the time to find six integer numbers so that the angle of two vectors equal to Pi/6

Mathematica Asked on May 22, 2021

I am trying to find six integer numbers a, b, c, x, y, z so that the angle of two vector {a, b, c and {x, y, z} equal to Pi/6. I tried

Clear[a, b, c]
u = {x, y, z};
v = {a, b, c};
list = {u, v} /. 
   Solve[{4*(a*x + b*y + c*z)^2 == 
      3*(a^2 + b^2 + c^2)*(x^2 + y^2 + z^2), a b c x y z != 0, a > x, 
     0 < a*x + b*y + c*z, GCD[a, b, c] == 1, GCD[x, y, z] == 1, 
     Sequence @@ Thread[0 < {a, b, c, x, y, z} < 15]}, {x, y, z, a, b,
      c}, Integers];
Select[list, (6 == Length[Union @@ #] &)]

If I use

Sequence @@ Thread[0 < {a, b, c, x, y, z} < 9]}

I got

{{{1, 2, 7}, {4, 3, 5}}, {{1, 3, 4}, {5, 2, 7}}, {{1, 4, 3}, {5, 7,
2}}, {{1, 7, 2}, {4, 5, 3}}, {{1, 7, 8}, {3, 2, 5}}, {{1, 8,
7}, {3, 5, 2}}, {{2, 1, 7}, {3, 4, 5}}, {{2, 3, 5}, {7, 1,
8}}, {{2, 5, 3}, {7, 8, 1}}, {{2, 5, 7}, {3, 1, 4}}, {{2, 7,
1}, {3, 5, 4}}, {{2, 7, 5}, {3, 4, 1}}, {{4, 1, 3}, {7, 5,
2}}, {{4, 3, 1}, {7, 2, 5}}, {{5, 2, 3}, {8, 7, 1}}, {{5, 3,
2}, {8, 1, 7}}, {{5, 3, 4}, {7, 2, 1}}, {{5, 4, 3}, {7, 1, 2}}}

The time is longer If I use

Sequence @@ Thread[0 < {a, b, c, x, y, z} < 15]}

How can I reduce timing?

One Answer

If you can allow an upper limit for the components, we may simply check all possibilities. As the angle of Pi/3 is less than Pi, we may restrict the search to one quadrant. Further solutions may be obtained by reflection at the coordinate planes.

n = 10;
res = Reap[
   Do[
    If[4 ({j1, j2, j3}.{i1, i2, i3})^2 == {i1, i2, i3}.{i1, i2, 
         i3} {j1, j2, j3}.{j1, j2, j3}, Sow[{i1, i2, i3, j1, j2, j3}]]
    , {i1, n}, {i2, n}, {i3, n}, {j1, n}, {j2, n}, {j3, n}]
   ][[2, 1]]

This results in:

enter image description here

Answered by Daniel Huber on May 22, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP