Passenger Posted April 25, 2021 Share Posted April 25, 2021 /****************************************************************************** * Jouni Aro * * 20.2.20 * * * * The multidimensional algebra * * * * The possibilities of algebra is associated with a sort of tool, with which * * parallel causations can be harnessed and approximated into compact * * functions. When you draw a roughly smooth curve into the screen with the * * mouse, the algebra is able to approximate the given set of dots into a * * short function. The craft of algebra is in its ability to describe * * phenomenons and the nature. * * * * What if you draw curves of different colors into the screen? The white set * * of dots is the temperature, the yellow is the direction of the wind, the * * orange is the time of year, the blue would represent the humidity etc. * * Every set of dots can be described as an individual phenomenon, but what * * about the function, that alone would describe the causations of the whole * * set? * * * * The relation of the function can also be asymmetrical. When the input of * * the weather function can be n number of initations, the output can only be * * a relatively blurry parameter between 0 to 1, whether you should go fishing * * or not. * * * * *** * * * * The computer can be programmed to study mathematics. With the solid axioms * * of algebra and the consistent development of series, the bit monster can * * immerse itself further into geometry and symmetry. In the final solution * * the computer was partly forced to abandon the symbolic concepts which * * include the positive, the negative, the real and the imaginary. The algebra * * doesn't need to share its opinion on in what direction the monitor is put * * on the table. * * * * The algorithms of algebra are constant and its objects can describe * * whatsoever. One of the most beautiful formulae of the algebra is the * * polynomial adaption of the smallest sum of squares: * * * * If the object that is placed in the formula is valid and balanced with * * itself, the algebra will process the substance with rational results, * * otherwise not. A good example is the quaternion. The algebra does not * * editorialise to the inner calculation logic of the quartenion. * * * * *** * * * * i^2 is -1, but what is the object that gives the result of -i when squared? * * There's an interesting connection between the companions of the i, * * |e^(xi+yj+zk+...)| = 1. The multidimensional algebra also connects the pi * * and the number one. pi^z limit on the real axis approaches the value of 1, * * when the z-unit vector is excited further and further from the real axis. * * At the same time, the sum of the absolute values of the axises approaches * * to the pi. * * * * Next up are the simple calculation rules of the recomplex number with the * * C++ examples. The class itself can do almost as such in the MatLab -tool. * * * * ~ recomplex * * ~ order * * ~ specification of class * * ~ addition * * ~ subtraction * * ~ multiplication * * ~ products of vector basis * * ~ division * * ~ abs(recomplex) * * ~ pow(recomplex, int) * * ~ ln(recomplex) * * ~ exp(recomplex) * * ~ pow(recomplex, double) * * ~ pow(recomplex, recomplex) * * ~ sin(recomplex) * * ~ cos(recomplex) * * ~ the port example of the smallest sum of squares * * ~ the connection of the pi and number one * * ~ code attachment * * * * *** * * * * The complex number is a real subset of the recomplex number. Real numbers * * and imaginary numbers for their parts are real subsets of the complex * * number. The prefix "re" points to the feedback, repeating the same basic * * logic in the next scale. * * * * ~~~ order ~~~ * * * * The order goes in power of two, 1, 2, 4, ..., 2^n. The real numbers are * * adjusted with the order of 1. The complex numbers come into effect with the * * order of 2. In the order of 4 the complex numbers get a complex object on * * their side, functioning by the stopper logic. The union of these makes * * simple function maps for the parallel causation phenomena possible, among * * other things. * /*****************************************************************************/ /****************************************************************************** * ~~~ class specification ~~~ * * * * C++ implemented an operator load, when especially the calculation * * operations of the numeric structures on the computer don't differ from the * * regular straightforwardness. * ******************************************************************************/ #include <math.h> #include <stdio.h> #include <conio.h> #include <memory.h> #include <stdlib.h> class recomplex { public: /************************************ * The dimension should be: * * 1, 2, 4, ..., 2^n * * DIMENSION 1 -> real numbers * * DIMENSION 2 -> complex numbers * * DIMENSION 4 -> 4D complex numbers * * DIMENSION 8 -> 8D complex numbers * ************************************/ #define DIMENSION 4 double e[DIMENSION]; recomplex(void); ~recomplex(void); recomplex(double*); recomplex(int); recomplex(int, int); recomplex(int, int, int, int); recomplex(double); recomplex(double, double); recomplex(double, double, double, double); friend void print(recomplex); friend double abs(recomplex); friend recomplex sqrt(recomplex); friend recomplex operator-(recomplex); friend recomplex operator+(recomplex, recomplex); friend recomplex operator-(recomplex, recomplex); friend recomplex operator*(recomplex, recomplex); friend recomplex operator/(recomplex, recomplex); friend recomplex operator*(recomplex, double); friend recomplex operator/(recomplex, double); friend recomplex operator*(double, recomplex); friend recomplex operator/(double, recomplex); friend recomplex pow(recomplex, int); }; /****************************************************************************** * ~~~ addition ~~~ * * * * If you're unfamiliar with the C, a few words about it. The basis of C is * * to save sheets. Every excessive and unnecessary rambling is eliminated * * from the syntax. The operators if C are very effective. For example +=, *=, * * /=, ... perform the operation in question and after that the assignment. * * a.e[n]+=b.e[n] means the same that a.e[n]=a.e[n]+b.e[n]. Because the latter * * style consumes more of paper, the shorter version of the same thing * * a.e[n]+=b.e[n] is used in the C. * ******************************************************************************/ recomplex operator+(recomplex a, recomplex b) { for (int n=0; n<DIMENSION; n++) a.e[n]+=b.e[n]; return a; } /****************************************************************************** * For example: * * * * recomplex A(2, 3, -5, 7); * * recomplex B(7, 5, -3, 2); * * print(A + B); * * * * Prints a value of 9 + 8i - 8j + 9k. * ******************************************************************************/ /****************************************************************************** * ~~~ subtraction ~~~ * ******************************************************************************/ recomplex operator-(recomplex a, recomplex b) { for (int n=0; n<DIMENSION; n++) a.e[n]-=b.e[n]; return a; } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A-B); * * * * The value of the difference is -5 - 2i + 2j + 5k * ******************************************************************************/ /****************************************************************************** * ~~~ multiplication ~~~ * * * * The multiplication first requires a product definition of the base vectors. * * Looping the product does not editorialise to the formal positive, negative, * * real, imaginary, etc. definitions. The product of the multiplication is * * returned to the sum form so far only in the last loop. * ******************************************************************************/ recomplex operator*(recomplex a, recomplex b) { int *BasisVectors(void); int *R = BasisVectors(); int i, j, n=DIMENSION*2; double x[DIMENSION*2]; double y[DIMENSION*2]; double t[DIMENSION*2]; for (i=j=0; i<DIMENSION; i++, j+=2) x[j+1]=y[j+1]=t[j]=t[j+1]=0.0, x[j]=a.e[i], y[j]=b.e[i]; for (i=0; i<n; i++) for (j=0; j<n; j++) t[R[i*n+j]]+=x[i]*y[j]; for (i=j=0; i<DIMENSION; i++, j+=2) t[i]=(double)(t[j] - t[j+1]); return *(recomplex*) t; } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A * B); * * * * The outcome is -32 + 32i + 87k. The multiplication is commutative. If A and * * B are complex, the outcome is complex. * * * * recomplex A(2, 3, 0, 0); * * recomplex B(7, 5, 0, 0); * * print(A * B); * * * * You'll get the output -1 + 31i * ******************************************************************************/ /****************************************************************************** * ~~~ the products of the base vectors ~~~ * * * * The products of the base vectors are generated by the recursive function. * * All the products of the base vectors associated with the order of 4 are * * assembled in the chart: * * * * # 1 | -1 | i | -i | j | -j | k | -k | * * ############################################ * * 1 # 1 | -1 | i | -i | j | -j | k | -k | * * ---#----|----|----|----|----|----|----|----| * * -1 # -1 | 1 | -i | i | -j | j | -k | k | * * ---#----|----|----|----|----|----|----|----| * * i # i | -i | -1 | 1 | k | -k | -j | j | * * ---#----|----|----|----|----|----|----|----| * * -i # -i | i | 1 | -1 | -k | k | j | -j | * * ---#----|----|----|----|----|----|----|----| * * j # j | -j | k | -k | i | -i | -1 | 1 | * * ---#----|----|----|----|----|----|----|----| * * -j # -j | j | -k | k | -i | i | 1 | -1 | * * ---#----|----|----|----|----|----|----|----| * * k # k | -k | -j | j | -1 | 1 | -i | i | * * ---#----|----|----|----|----|----|----|----| * * -k # -k | k | j | -j | 1 | -1 | i | -i | * * ---#----|----|----|----|----|----|----|----| * * * * For example ijk = -i, and particularly k^2 = -i. Commutativity remains, * * because still: * * * * ikj = jik = jki = kij = kji = -i * ******************************************************************************/ void GenerateTheProductsOfTheBaseVectors(int *R, int n) { int I=0, J=n-1, i; int X=n, Y=J+n, j; int k=DIMENSION*2; for (i=I; i<=J; i++) for (j=I; j<=J; j++) { R[i*k+X+j]=R[i*k+j]+X; R[(X+j)*k+i]=R[i*k+j]+X; R[(Y-i)*k+Y-j]=J-R[i*k+j]; } if (n+n < DIMENSION*2) { GenerateTheProductsOfTheBaseVectors(R, n+n); } } int* BasisVectors(void) { static int R[DIMENSION*DIMENSION*4]={-1}; if (R[0] == -1) { int FirstThereWasZero=0; R[0x00]=(int)FirstThereWasZero; GenerateTheProductsOfTheBaseVectors(R, 1); } return R; } /****************************************************************************** * ~~~ division ~~~ * * * * In division, a complex conjugate is produced for the divisor, with which * * the divisor and the dividend are multiplied. In the end of every loop step * * there's a half less of axel values of the divisor (the rest are summed up * * to nulls). When the value of the divisor is real, the elements of the * * dividend are divided by the value. For example 2 + 3i + 5j + 7k the mounted * * number is 2 + 3i - 5j - 7k. * ******************************************************************************/ recomplex operator/(recomplex x, recomplex y) { recomplex z; for (int i, n=DIMENSION; n>=2; n/=2) { for (z=y, i=n/2; i<n; i++) z.e[i] = -z.e[i]; x=x*z; y=y*z; } return x/y.e[0]; } /****************************************************************************** * For exsample * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A / B); * * * * The product of division is 0.5488136 - 0.1575801i + 0.7181670j + 0.3977540k.* * If A and B are complex, the result is complex: * * * * recomplex A(2, 3, 0, 0); * * recomplex B(7, 5, 0, 0); * * * print(A / B); * * * * The output of the value is 0.3918919 + 0.1486486i * ******************************************************************************/ recomplex operator/(recomplex x, double k) { for (int i=0; i<DIMENSION; i++) x.e[i]/=(double)k; return x; } recomplex operator*(double k, recomplex x) { for (int i=0; i<DIMENSION; i++) x.e[i]*=(double)k; return x; } recomplex operator*(recomplex x, double k) { return k*x; } recomplex operator/(double k, recomplex x) { return recomplex(k)/x; } /****************************************************************************** * ~~~ abs(recomplex) ~~~ * * * * In the absolute value x is multiplied by its complex conjugate repeatedly. * * The value then returns the breaking power collected by j. * ******************************************************************************/ double abs(recomplex x) { recomplex z; double r, c; int i, j=1, n; for (n=DIMENSION; n>=2; n/=2, j+=j) { for (z=x, i=n/2; i<n; i++) z.e[i]=-z.e[i]; x=x*z; } r=fabs(x.e[0]); c=1.0/(double)j; return pow(r, c); } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * printf("%25.20f\n", abs(A/B)); * * * * The double of the C is precise, because the absolute value of the result is * * exactly 1.00000000000000000000 * ******************************************************************************/ /****************************************************************************** * ~~~ pow(recomplex, int) ~~~ * * * * The limit of x^0 is 1, when x approaches the null. Calculators have * * variable interpretations, whether the 0^0 is about 1 or is the calculation * * aborted and is the output of the status an error. In the polynomial * * adaption of the smallest sum of squares x^0 has to be 1 also with the x's * * limit null. An exponent n can be a positive or a negative integer. * ******************************************************************************/ recomplex pow(recomplex x, int n) { if (n) { recomplex t=x; int i=n<0? -n: n; for (--i; i; i--) t=t*x; return n>0? t: recomplex(1) / t; } else { return recomplex(1); } } /****************************************************************************** * ~~~ print(recomplex) ~~~ * * * * Somewhere around 20 element, when the marking of the base vector is bigger * * than 'z', the marking of the base vector can be a symbol differentiated * * from the letter. In the calculations themselves the symbols are not * * editorialised. * ******************************************************************************/ void print(recomplex a) { printf("%0.9f ", a.e[0]); for (int n=1; n<DIMENSION; n++) printf("%c %0.9f%c ", a.e[n]<0? '-': '+', fabs(a.e[n]), 'h'+n); printf("\n"); } /****************************************************************************** * These functions still need to be explored * * * * ~~~ ln(recomplex) ~~~ * * ~~~ exp(recomplex) ~~~ * * ~~~ pow(recomplex, double) ~~~ * * ~~~ pow(recomplex, recomplex) ~~~ * * ~~~ sin(recomplex) ~~~ * * ~~~ cos(recomplex) ~~~ * ******************************************************************************/ recomplex::recomplex(void) { memset(this, 0, sizeof(recomplex)); } recomplex::~recomplex(void) { } recomplex::recomplex(double *a) { memset(this, 0, sizeof(recomplex)); for (int i=0x00; i<DIMENSION; i++) e[i]=a[i]; } recomplex::recomplex(int a) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; } recomplex::recomplex(double a) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; } recomplex::recomplex(int a, int b) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; } recomplex::recomplex(double a, double b) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; } recomplex::recomplex(int a, int b, int c, int d) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; e[2]=(double)c; e[3]=(double)d; } recomplex::recomplex(double a, double b, double c, double d) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; e[2]=(double)c; e[3]=(double)d; } /*************************************************** * Returns the square root of parameter c. Function * * has been implemented in Newton's processing. * ***************************************************/ recomplex sqrt(recomplex c) { int i; recomplex x; double R[DIMENSION]; for (i=0; i<DIMENSION; i++) { int sgn = rand()%0x02? -1: +1; R[i]=sgn*rand()/(double)32767; } x=recomplex((double*)R); for (i=0; i<1024; i++) x=x-(x*x-c)/(2.0*x); return (recomplex)x; } /********************************************** * the mainfunction tests the income swap law. * **********************************************/ int main(void) { recomplex x(0.12, -0.34, 0.56, -0.78); recomplex y(0.98, -0.76, 0.54, -0.32); printf("x = "); print(x); printf("y = "); print(y); printf("\n"); printf("x*y = "); print(x*y); printf("y*x = "); print(y*x); printf("\n"); getch(); return 0; } Link to comment Share on other sites More sharing options...

ahmet Posted April 25, 2021 Share Posted April 25, 2021 23 minutes ago, Passenger said: /****************************************************************************** * Jouni Aro * * 20.2.20 * * * * The multidimensional algebra * * * * The possibilities of algebra is associated with a sort of tool, with which * * parallel causations can be harnessed and approximated into compact * * functions. When you draw a roughly smooth curve into the screen with the * * mouse, the algebra is able to approximate the given set of dots into a * * short function. The craft of algebra is in its ability to describe * * phenomenons and the nature. * * * * What if you draw curves of different colors into the screen? The white set * * of dots is the temperature, the yellow is the direction of the wind, the * * orange is the time of year, the blue would represent the humidity etc. * * Every set of dots can be described as an individual phenomenon, but what * * about the function, that alone would describe the causations of the whole * * set? * * * * The relation of the function can also be asymmetrical. When the input of * * the weather function can be n number of initations, the output can only be * * a relatively blurry parameter between 0 to 1, whether you should go fishing * * or not. * * * * *** * * * * The computer can be programmed to study mathematics. With the solid axioms * * of algebra and the consistent development of series, the bit monster can * * immerse itself further into geometry and symmetry. In the final solution * * the computer was partly forced to abandon the symbolic concepts which * * include the positive, the negative, the real and the imaginary. The algebra * * doesn't need to share its opinion on in what direction the monitor is put * * on the table. * * * * The algorithms of algebra are constant and its objects can describe * * whatsoever. One of the most beautiful formulae of the algebra is the * * polynomial adaption of the smallest sum of squares: * * * * If the object that is placed in the formula is valid and balanced with * * itself, the algebra will process the substance with rational results, * * otherwise not. A good example is the quaternion. The algebra does not * * editorialise to the inner calculation logic of the quartenion. * * * * *** * * * * i^2 is -1, but what is the object that gives the result of -i when squared? * * There's an interesting connection between the companions of the i, * * |e^(xi+yj+zk+...)| = 1. The multidimensional algebra also connects the pi * * and the number one. pi^z limit on the real axis approaches the value of 1, * * when the z-unit vector is excited further and further from the real axis. * * At the same time, the sum of the absolute values of the axises approaches * * to the pi. * * * * Next up are the simple calculation rules of the recomplex number with the * * C++ examples. The class itself can do almost as such in the MatLab -tool. * * * * ~ recomplex * * ~ order * * ~ specification of class * * ~ addition * * ~ subtraction * * ~ multiplication * * ~ products of vector basis * * ~ division * * ~ abs(recomplex) * * ~ pow(recomplex, int) * * ~ ln(recomplex) * * ~ exp(recomplex) * * ~ pow(recomplex, double) * * ~ pow(recomplex, recomplex) * * ~ sin(recomplex) * * ~ cos(recomplex) * * ~ the port example of the smallest sum of squares * * ~ the connection of the pi and number one * * ~ code attachment * * * * *** * * * * The complex number is a real subset of the recomplex number. Real numbers * * and imaginary numbers for their parts are real subsets of the complex * * number. The prefix "re" points to the feedback, repeating the same basic * * logic in the next scale. * * * * ~~~ order ~~~ * * * * The order goes in power of two, 1, 2, 4, ..., 2^n. The real numbers are * * adjusted with the order of 1. The complex numbers come into effect with the * * order of 2. In the order of 4 the complex numbers get a complex object on * * their side, functioning by the stopper logic. The union of these makes * * simple function maps for the parallel causation phenomena possible, among * * other things. * /*****************************************************************************/ /****************************************************************************** * ~~~ class specification ~~~ * * * * C++ implemented an operator load, when especially the calculation * * operations of the numeric structures on the computer don't differ from the * * regular straightforwardness. * ******************************************************************************/ #include <math.h> #include <stdio.h> #include <conio.h> #include <memory.h> #include <stdlib.h> class recomplex { public: /************************************ * The dimension should be: * * 1, 2, 4, ..., 2^n * * DIMENSION 1 -> real numbers * * DIMENSION 2 -> complex numbers * * DIMENSION 4 -> 4D complex numbers * * DIMENSION 8 -> 8D complex numbers * ************************************/ #define DIMENSION 4 double e[DIMENSION]; recomplex(void); ~recomplex(void); recomplex(double*); recomplex(int); recomplex(int, int); recomplex(int, int, int, int); recomplex(double); recomplex(double, double); recomplex(double, double, double, double); friend void print(recomplex); friend double abs(recomplex); friend recomplex sqrt(recomplex); friend recomplex operator-(recomplex); friend recomplex operator+(recomplex, recomplex); friend recomplex operator-(recomplex, recomplex); friend recomplex operator*(recomplex, recomplex); friend recomplex operator/(recomplex, recomplex); friend recomplex operator*(recomplex, double); friend recomplex operator/(recomplex, double); friend recomplex operator*(double, recomplex); friend recomplex operator/(double, recomplex); friend recomplex pow(recomplex, int); }; /****************************************************************************** * ~~~ addition ~~~ * * * * If you're unfamiliar with the C, a few words about it. The basis of C is * * to save sheets. Every excessive and unnecessary rambling is eliminated * * from the syntax. The operators if C are very effective. For example +=, *=, * * /=, ... perform the operation in question and after that the assignment. * * a.e[n]+=b.e[n] means the same that a.e[n]=a.e[n]+b.e[n]. Because the latter * * style consumes more of paper, the shorter version of the same thing * * a.e[n]+=b.e[n] is used in the C. * ******************************************************************************/ recomplex operator+(recomplex a, recomplex b) { for (int n=0; n<DIMENSION; n++) a.e[n]+=b.e[n]; return a; } /****************************************************************************** * For example: * * * * recomplex A(2, 3, -5, 7); * * recomplex B(7, 5, -3, 2); * * print(A + B); * * * * Prints a value of 9 + 8i - 8j + 9k. * ******************************************************************************/ /****************************************************************************** * ~~~ subtraction ~~~ * ******************************************************************************/ recomplex operator-(recomplex a, recomplex b) { for (int n=0; n<DIMENSION; n++) a.e[n]-=b.e[n]; return a; } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A-B); * * * * The value of the difference is -5 - 2i + 2j + 5k * ******************************************************************************/ /****************************************************************************** * ~~~ multiplication ~~~ * * * * The multiplication first requires a product definition of the base vectors. * * Looping the product does not editorialise to the formal positive, negative, * * real, imaginary, etc. definitions. The product of the multiplication is * * returned to the sum form so far only in the last loop. * ******************************************************************************/ recomplex operator*(recomplex a, recomplex b) { int *BasisVectors(void); int *R = BasisVectors(); int i, j, n=DIMENSION*2; double x[DIMENSION*2]; double y[DIMENSION*2]; double t[DIMENSION*2]; for (i=j=0; i<DIMENSION; i++, j+=2) x[j+1]=y[j+1]=t[j]=t[j+1]=0.0, x[j]=a.e[i], y[j]=b.e[i]; for (i=0; i<n; i++) for (j=0; j<n; j++) t[R[i*n+j]]+=x[i]*y[j]; for (i=j=0; i<DIMENSION; i++, j+=2) t[i]=(double)(t[j] - t[j+1]); return *(recomplex*) t; } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A * B); * * * * The outcome is -32 + 32i + 87k. The multiplication is commutative. If A and * * B are complex, the outcome is complex. * * * * recomplex A(2, 3, 0, 0); * * recomplex B(7, 5, 0, 0); * * print(A * B); * * * * You'll get the output -1 + 31i * ******************************************************************************/ /****************************************************************************** * ~~~ the products of the base vectors ~~~ * * * * The products of the base vectors are generated by the recursive function. * * All the products of the base vectors associated with the order of 4 are * * assembled in the chart: * * * * # 1 | -1 | i | -i | j | -j | k | -k | * * ############################################ * * 1 # 1 | -1 | i | -i | j | -j | k | -k | * * ---#----|----|----|----|----|----|----|----| * * -1 # -1 | 1 | -i | i | -j | j | -k | k | * * ---#----|----|----|----|----|----|----|----| * * i # i | -i | -1 | 1 | k | -k | -j | j | * * ---#----|----|----|----|----|----|----|----| * * -i # -i | i | 1 | -1 | -k | k | j | -j | * * ---#----|----|----|----|----|----|----|----| * * j # j | -j | k | -k | i | -i | -1 | 1 | * * ---#----|----|----|----|----|----|----|----| * * -j # -j | j | -k | k | -i | i | 1 | -1 | * * ---#----|----|----|----|----|----|----|----| * * k # k | -k | -j | j | -1 | 1 | -i | i | * * ---#----|----|----|----|----|----|----|----| * * -k # -k | k | j | -j | 1 | -1 | i | -i | * * ---#----|----|----|----|----|----|----|----| * * * * For example ijk = -i, and particularly k^2 = -i. Commutativity remains, * * because still: * * * * ikj = jik = jki = kij = kji = -i * ******************************************************************************/ void GenerateTheProductsOfTheBaseVectors(int *R, int n) { int I=0, J=n-1, i; int X=n, Y=J+n, j; int k=DIMENSION*2; for (i=I; i<=J; i++) for (j=I; j<=J; j++) { R[i*k+X+j]=R[i*k+j]+X; R[(X+j)*k+i]=R[i*k+j]+X; R[(Y-i)*k+Y-j]=J-R[i*k+j]; } if (n+n < DIMENSION*2) { GenerateTheProductsOfTheBaseVectors(R, n+n); } } int* BasisVectors(void) { static int R[DIMENSION*DIMENSION*4]={-1}; if (R[0] == -1) { int FirstThereWasZero=0; R[0x00]=(int)FirstThereWasZero; GenerateTheProductsOfTheBaseVectors(R, 1); } return R; } /****************************************************************************** * ~~~ division ~~~ * * * * In division, a complex conjugate is produced for the divisor, with which * * the divisor and the dividend are multiplied. In the end of every loop step * * there's a half less of axel values of the divisor (the rest are summed up * * to nulls). When the value of the divisor is real, the elements of the * * dividend are divided by the value. For example 2 + 3i + 5j + 7k the mounted * * number is 2 + 3i - 5j - 7k. * ******************************************************************************/ recomplex operator/(recomplex x, recomplex y) { recomplex z; for (int i, n=DIMENSION; n>=2; n/=2) { for (z=y, i=n/2; i<n; i++) z.e[i] = -z.e[i]; x=x*z; y=y*z; } return x/y.e[0]; } /****************************************************************************** * For exsample * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * print(A / B); * * * * The product of division is 0.5488136 - 0.1575801i + 0.7181670j + 0.3977540k.* * If A and B are complex, the result is complex: * * * * recomplex A(2, 3, 0, 0); * * recomplex B(7, 5, 0, 0); * * * print(A / B); * * * * The output of the value is 0.3918919 + 0.1486486i * ******************************************************************************/ recomplex operator/(recomplex x, double k) { for (int i=0; i<DIMENSION; i++) x.e[i]/=(double)k; return x; } recomplex operator*(double k, recomplex x) { for (int i=0; i<DIMENSION; i++) x.e[i]*=(double)k; return x; } recomplex operator*(recomplex x, double k) { return k*x; } recomplex operator/(double k, recomplex x) { return recomplex(k)/x; } /****************************************************************************** * ~~~ abs(recomplex) ~~~ * * * * In the absolute value x is multiplied by its complex conjugate repeatedly. * * The value then returns the breaking power collected by j. * ******************************************************************************/ double abs(recomplex x) { recomplex z; double r, c; int i, j=1, n; for (n=DIMENSION; n>=2; n/=2, j+=j) { for (z=x, i=n/2; i<n; i++) z.e[i]=-z.e[i]; x=x*z; } r=fabs(x.e[0]); c=1.0/(double)j; return pow(r, c); } /****************************************************************************** * For exsample: * * * * recomplex A(2, 3, 5, 7); * * recomplex B(7, 5, 3, 2); * * printf("%25.20f\n", abs(A/B)); * * * * The double of the C is precise, because the absolute value of the result is * * exactly 1.00000000000000000000 * ******************************************************************************/ /****************************************************************************** * ~~~ pow(recomplex, int) ~~~ * * * * The limit of x^0 is 1, when x approaches the null. Calculators have * * variable interpretations, whether the 0^0 is about 1 or is the calculation * * aborted and is the output of the status an error. In the polynomial * * adaption of the smallest sum of squares x^0 has to be 1 also with the x's * * limit null. An exponent n can be a positive or a negative integer. * ******************************************************************************/ recomplex pow(recomplex x, int n) { if (n) { recomplex t=x; int i=n<0? -n: n; for (--i; i; i--) t=t*x; return n>0? t: recomplex(1) / t; } else { return recomplex(1); } } /****************************************************************************** * ~~~ print(recomplex) ~~~ * * * * Somewhere around 20 element, when the marking of the base vector is bigger * * than 'z', the marking of the base vector can be a symbol differentiated * * from the letter. In the calculations themselves the symbols are not * * editorialised. * ******************************************************************************/ void print(recomplex a) { printf("%0.9f ", a.e[0]); for (int n=1; n<DIMENSION; n++) printf("%c %0.9f%c ", a.e[n]<0? '-': '+', fabs(a.e[n]), 'h'+n); printf("\n"); } /****************************************************************************** * These functions still need to be explored * * * * ~~~ ln(recomplex) ~~~ * * ~~~ exp(recomplex) ~~~ * * ~~~ pow(recomplex, double) ~~~ * * ~~~ pow(recomplex, recomplex) ~~~ * * ~~~ sin(recomplex) ~~~ * * ~~~ cos(recomplex) ~~~ * ******************************************************************************/ recomplex::recomplex(void) { memset(this, 0, sizeof(recomplex)); } recomplex::~recomplex(void) { } recomplex::recomplex(double *a) { memset(this, 0, sizeof(recomplex)); for (int i=0x00; i<DIMENSION; i++) e[i]=a[i]; } recomplex::recomplex(int a) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; } recomplex::recomplex(double a) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; } recomplex::recomplex(int a, int b) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; } recomplex::recomplex(double a, double b) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; } recomplex::recomplex(int a, int b, int c, int d) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; e[2]=(double)c; e[3]=(double)d; } recomplex::recomplex(double a, double b, double c, double d) { memset(this, 0, sizeof(recomplex)); e[0]=(double)a; e[1]=(double)b; e[2]=(double)c; e[3]=(double)d; } /*************************************************** * Returns the square root of parameter c. Function * * has been implemented in Newton's processing. * ***************************************************/ recomplex sqrt(recomplex c) { int i; recomplex x; double R[DIMENSION]; for (i=0; i<DIMENSION; i++) { int sgn = rand()%0x02? -1: +1; R[i]=sgn*rand()/(double)32767; } x=recomplex((double*)R); for (i=0; i<1024; i++) x=x-(x*x-c)/(2.0*x); return (recomplex)x; } /********************************************** * the mainfunction tests the income swap law. * **********************************************/ int main(void) { recomplex x(0.12, -0.34, 0.56, -0.78); recomplex y(0.98, -0.76, 0.54, -0.32); printf("x = "); print(x); printf("y = "); print(y); printf("\n"); printf("x*y = "); print(x*y); printf("y*x = "); print(y*x); printf("\n"); getch(); return 0; } could you summarize what you have found and what you ask here please? maybe someone from computer sciences better help you. Link to comment Share on other sites More sharing options...

uncool Posted April 25, 2021 Share Posted April 25, 2021 1 hour ago, Passenger said: i^2 is -1, but what is the object that gives the result of -i when squared? plus or minus (sqrt(2)/2 - i*sqrt(2)/2). Alternatively: if I've skim-understood correctly, you've defined j such that j^2 = -i. In that case, what do you get when you multiply (sqrt(2)*j - i + 1) and (sqrt(2)*j + i - 1)? Link to comment Share on other sites More sharing options...

uncool Posted April 26, 2021 Share Posted April 26, 2021 (edited) Sorry, I didn't quite read closely enough; replace j in the above with k. When you have an answer for that: I think that you have not understood what is so essential about the complex numbers. They are algebraically closed, that is, any nonconstant polynomial with complex coefficients will have a complex root. For example, the complex polynomial x^2 - i will have a complex root. As such, any "addition" of the type you have constructed will, inevitably, result in some kind of redundancy. In most cases, all that happens is that you essentially come up with something equivalent to "multiple copies of the complex numbers". In this case: any "recomplex" number can be expressed as: a + b*(1/2 + j*sqrt(2)/4 - k*sqrt(2)/4) for some complex numbers a and b. I'll call the constant in the above C. Then (a1 + b1*C) + (a2 + b2*C) = (a1 + a2) + (b1 + b2)*C, and (a1 + b1*C)*(a2 + b2*C) = (a1*a2) + (b1*b2*C), if I haven't made any arithmetic errors. You can see some effects of this, e.g. if you try to find (sqrt(2)*j - i + 1)/(sqrt(2)*j + i - 1). Depending how close you approximate sqrt(2), you will get absurdly large values, which are an artifact of the fact that you are, in essence, dividing by 0. Edited April 26, 2021 by uncool Link to comment Share on other sites More sharing options...

Passenger Posted August 14, 2021 Author Share Posted August 14, 2021 On 4/25/2021 at 8:49 PM, ahmet said: maybe someone from computer sciences better help you. Where do I need an IT expert. Link to comment Share on other sites More sharing options...

dimreepr Posted August 14, 2021 Share Posted August 14, 2021 1 hour ago, Passenger said: Where do I need an IT expert. Depends on the intent of the OP; is it a question or a blog? Link to comment Share on other sites More sharing options...

Sensei Posted August 15, 2021 Share Posted August 15, 2021 If it is RFC, you don't have copy-constructor (input other recomplex), assignment operator (various inputs), comparison operators (various inputs). The number of dimensions you can try to implement using C++ template class instead of hard-cording constant value with macro.. In the division operator and some other places, you don't check to see if you divide by zero, which can lead to an exception and a code crash. It would be also good to implement +=, -=, *=, /= operators etc. Link to comment Share on other sites More sharing options...

Passenger Posted November 28, 2021 Author Share Posted November 28, 2021 If someone divides by zero, your own reason. For example, division by zero is allowed in the generation of the least squares polynomial. Link to comment Share on other sites More sharing options...

## Recommended Posts

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account## Sign in

Already have an account? Sign in here.

Sign In Now