Quaternions

index.htm - Russian text  

quaternion.zip - archived directory. 

The software package Jnl, accessible to addresses here was used.

www.vni.com

http://www.vni.com/products/wpd/jnl/

ftp://wig.ethz.ch/pub/VNI/wpd/jnl/jnl.zip

The package was decompiled at the help Jad.exe, is now posed in the directory VisualNumerics of the application quaternion.zip.

There was a problem, whether it is possible to use Jad at supercompilation. The given example gives the positive answer to this problem.

In VisualNumerics I used programs for operation with complex matrixes.

Through the supercompiler it is possible easily to receive operations above quaternions.

The quaternions can be defined by different ways.

The small programs addQ, subQ, mulQ quaternion.java, were written which on two arrays from 4 real numbers create the indicated complex matrixes and access to the necessary operation above matrixes. The residual programs are indicated in  quaternion.js

Through quaternions it is possible to receive numerical equalities, in which the sum of four quadrates multiplied on other sum of four quadrates, is again peer to the sum of four quadrates. For example,

( 12 + 22 + 32 + 42 ) ( 22 + 32 + 42 + 52 ) = 362 + 62 + 122 + 122

The numbers in brackets can be taken by any..

For obtaining such equalities in the program quaternion.java method main was written so

    public static int[] qInt =  {1, 2, 3, 4};
    public static int[] pInt =  {2, 3, 4, 5};
    public static double[] qres = new double[4];

    public static void main (String[] args) {
        double[] q = new double[4];
        double[] p = new double[4];

        q[0] = qInt[0];
        q[1] = qInt[1];
        q[2] = qInt[2];
        q[3] = qInt[3];

        p[0] = pInt[0];
        p[1] = pInt[1];
        p[2] = pInt[2];
        p[3] = pInt[3];

        qres = mulQ(q, p);

        int[] qresInt = new int[4];
        qresInt[0] = (int)qres[0];
        qresInt[1] = (int)qres[1];
        qresInt[2] = (int)qres[2];
        qresInt[3] = (int)qres[3];

        System.out.println( "( " + qInt[0] + "^2 + " + qInt[1] + "^2 + " + qInt[2] + "^2 + " + qInt[3] + "^2 ) " +
                            "( " + pInt[0] + "^2 + " + pInt[1] + "^2 + " + pInt[2] + "^2 + " + pInt[3] + "^2 ) = " +
                           " " + qresInt[0] + "^2 + " + qresInt[1] + "^2 + " + qresInt[2] + "^2 + " + qresInt[3] + "^2" );
    }

The residual program is those

//--------------------------------------   6 sec - postprocessing...
	public static void main (final java.lang.String[] args_139)
	{
	  final double q_0_144 = (double)Quaternion.qInt[0];
	  final double q_1_147 = (double)Quaternion.qInt[1];
	  final double q_2_150 = (double)Quaternion.qInt[2];
	  final double q_3_153 = (double)Quaternion.qInt[3];
	  final double p_0_156 = (double)Quaternion.pInt[0];
	  final double p_1_159 = (double)Quaternion.pInt[1];
	  final double p_2_162 = (double)Quaternion.pInt[2];
	  final double p_3_165 = (double)Quaternion.pInt[3];
	  final double[] c_166 = new double[4];
	  final double im_204 = -p_3_165;
	  final double re_209 = -p_1_159;
	  final double im_215 = -(-p_2_162);
	  final double re_381 = q_1_147 * p_0_156 - q_2_150 * im_204 + (q_0_144 * p_1_159 - q_3_153 * p_2_162);
	  final double im_382 = q_1_147 * im_204 + q_2_150 * p_0_156 + (q_0_144 * p_2_162 + q_3_153 * p_1_159);
	  final double im_431 = q_1_147 * im_215 + q_2_150 * re_209 + (q_0_144 * p_3_165 + q_3_153 * p_0_156);
	  c_166[0] = q_1_147 * re_209 - q_2_150 * im_215 + (q_0_144 * p_0_156 - q_3_153 * p_3_165);
	  c_166[1] = re_381;
	  c_166[2] = im_382;
	  c_166[3] = im_431;
	  Quaternion.qres = c_166;
	  java.lang.System.out.println("( " + Quaternion.qInt[0] + "^2 + " + Quaternion.qInt[1] + "^2 + " + Quaternion.qInt[2] + "^2 + " + Quaternion.qInt[3] + "^2 ) ( " + Quaternion.pInt[0] + "^2 + " + Quaternion.pInt[1] + "^2 + " + Quaternion.pInt[2] + "^2 + " + Quaternion.pInt[3] + "^2 ) =  " + (int)Quaternion.qres[0] + "^2 + " + (int)Quaternion.qres[1] + "^2 + " + (int)Quaternion.qres[2] + "^2 + " + (int)Quaternion.qres[3] + "^2") /*virtual*/;
	  return;
	}
//--------------------------------------   7 sec - JScp version 0.0.76

I shall remind, that in the source program on four numbers the quaternion by the way of complex square matrix of a size 2 is created. Neither matrixes, nor complex numbers in the residual program is not supervised. The package Jnl too misses.