Scientific Calculator
RRRaguindin/matrix3
Solution of 3x3 Matrix Equations
Tagged:
var matrix3 = function() {
var promptForNumber = function (text, title, default) {
var result = false;
while (result == false) -> result = number(prompt(text, title, default));
result;
};
var a11 = promptForNumber( "Enter a value for a11", "1st Equation [A 11]", 1 );
var a12 = promptForNumber( "Enter a value for a12", "1st Equation [A 12]", 0 );
var a13 = promptForNumber( "Enter a value for a13", "1st Equation [A 13]", 0 );
var k1 = promptForNumber( "Enter a value for k1", "1st Equation < K1 >", 1+1i );
var a21 = promptForNumber( "Enter a value for a21", "2nd Equation [A 21]", 0 );
var a22 = promptForNumber( "Enter a value for a22", "2nd Equation [A 22]", 1 );
var a23 = promptForNumber( "Enter a value for a23", "2nd Equation [A 23]", 0 );
var k2 = promptForNumber( "Enter a value for k2", "2nd Equation < K2 >",3-4i );
var a31 = promptForNumber( "Enter a value for a31", "3rd Equation [A 31]", 0 );
var a32 = promptForNumber( "Enter a value for a32", "3rd Equation [A 32]", 0 );
var a33 = promptForNumber( "Enter a value for a33", "3rd Equation [A 33]", 1 );
var k3 = promptForNumber( "Enter a value for k3", "3rd Equation < K3 >", 5+6i );
var coeff=[[a11,a12,a13],[a21,a22,a23],[a31,a32,a33]];
var coeffk1=[[k1,a12,a13],[k2,a22,a23],[k3,a32,a33]];
var coeffk2=[[a11,k1,a13],[a21,k2,a23],[a31,k3,a33]];
var coeffk3=[[a11,a12,k1],[a21,a22,k2],[a31,a32,k3]];
var x=det(coeffk1)/det(coeff);
var y=det(coeffk2)/det(coeff);
var z=det(coeffk3)/det(coeff);
var magx=abs(x);
var argx=arg(x)*180/pi;
var magy=abs(y);
var argy=arg(y)*180/pi;
var magz=abs(z);
var argz=arg(z)*180/pi;
alert(concat(string(x),"\\n",string(magx)," @ ",string(argx),"°","\\n\\n",
string(y),"\\n",string(magy)," @ ",string(argy),"°","\\n\\n",
string(z),"\\n",string(magz)," @ ",string(argz),"°"),
"SOLUTION:");
};
0 Comments
Sign in to leave a comment