Home
Courses
Information Technology Courses
>
Infrastructure
>
Operating Systems Funadmentals and Administration
IT Infrastructure
Networking Fundamentals
Network Administration
Computer Security Fundamentals
Fault Tolerant Systems
Programming
>
IT Theory Fundamentals (Discrete Mathematics)
Introduction to Programming
Human Computer Interaction
Data Structures
Web Programming
Mobile and Pervasive Technologies
Database Administration
>
Database Management Systems
Data Centers
Database Administration
Project Management, Analysis, & Design Courses
>
Systems Analysis
Systems Design
Business Architecture and Process
Quality Management Standards
IT Project Management
General Education Courses
>
Contemporary Communication
English Composition
Introduction to Philosophy
College Algebra
Introduction to Psychology
Creative Writing: Short Fiction
Statistical Methods and Applications
Social Responsibility
Contact
About
MATH-1001 College Algebra
/*This script was built in order to solve second and third order equations. */ /*The user inputs the determinant Order they would like to calculate, then the */ /*user must input the number located at each element in the matrix of the equation.*/ /*After this, equations are solved for their x,y, and in the case of a third order */ /*linear equation, z as well, using Cramer's Rule. This is then output via */ /*document.write. */ /* You may use this script, but please give credit to myself. */ /* ~~~~~~Jered McClure~~~~~~~ */ /*-----------------------------BEGIN INPUT-----------------------------------------*/ var order=prompt("Please enter the Determinant Order number you would like to calculate (e.g. type 2 for second order and 3 for third order):") var a1=prompt("Please enter the number located at the a1 element of the matrix."); var b1=prompt("Please enter the number located at the b1 element of the matrix."); var c1=prompt("Please enter the number located at the c1 element of the matrix."); var a2=prompt("Please enter the number located at the a2 element of the matrix."); var b2=prompt("Please enter the number located at the b2 element of the matrix."); var c2=prompt("Please enter the number located at the c2 element of the matrix."); var a3="not defined"; var b3="not defined"; var c3="not defined"; if(order==3){ var a3=prompt("Please enter the number located at the a3 element of the matrix."); var b3=prompt("Please enter the number located at the b3 element of the matrix."); var c3=prompt("Please enter the number located at the c3 element of the matrix."); var d1=prompt("Please enter the number located at the d1 element of the matrix."); var d2=prompt("Please enter the number located at the d2 element of the matrix."); var d3=prompt("Please enter the number located at the d3 element of the matrix."); } /*-----------------------------END INPUT-------------------------------------------*/ /*----------------------------BEGIN SCRIPT-----------------------------------------*/ //trycatch non-numerical input, if a non-number is found, throw error, and reload page. try{ if(isNaN(order) || isNaN(a1) || isNaN(b1) || isNaN(c1) || isNaN(a2) || isNaN(b2) || isNaN(c2)){ throw "Err1"; } } catch(er){ if(er=="Err1"){ alert("Error! Please only input numbers."); location.reload(true); } } //Begin the second order determinant function for linear equations in two variables. function secondOrderDeterminant(a1, b1, c1, a2, b2, c2){ //each variable is based upon the element position in the second order equation's determinant matrix. var A1=a1; var B1=b1; var C1=c1; var A2=a2; var B2=b2; var C2=c2; var x="not defined"; //generic modifier in case of false input by user, also thrown if equation is inconsistent. var y="not defined"; //generic modifier in case of false input by user, also thrown if equation is inconsistent. //Math based on Cramer's Rule for linear equations in two variables. var d=(A1*B2)-(A2*B1); var dx=(C1*B2)-(C2*B1); var dy=(A1*C2)-(A2*C1); if (d!=0){ //checks to make sure a 0 is not in the denominator posistion of the equation. x=(dx/d); y=(dy/d); } document.write("x= " + x + " y= " + y); }//end function secondOrderDeterminant() //Begin third order determinant function for eqations in three variables. function thirdOrderDeterminant(a1, b1, c1, a2, b2, c2, a3, b3, c3, d1, d2, d3){ //each variable is based upon the element position in the third order equation's determinant matrix. var A1=a1; var B1=b1; var C1=c1; var A2=a2; var B2=b2; var C2=c2; var A3=a3; var B3=b3; var C3=c3; var D1=d1; var D2=d2; var D3=d3; var x="not defined";//generic modifier in case of false input by user, also thrown if equation is inconsistent. var y="not defined";//generic modifier in case of false input by user, also thrown if equation is inconsistent. var z="not defined";//generic modifier in case of false input by user, also thrown if equation is inconsistent. //Math based on Cramer's Rule for linear equations in three variables. var d=((A1*((B2*C3)-(B3*C2)))-(A2*((B1*C3)-(B3*C1)))+(A3*((B1*C2)-(B2*C1)))); var dx=((D1*((B2*C3)-(B3*C2)))-(D2*((B1*C3)-(B3*C1)))+(D3*((B1*C2)-(B2*C1)))); var dy=((A1*((D2*C3)-(D3*C2)))-(A2*((D1*C3)-(D3*C1)))+(A3*((D1*C2)-(D2*C1)))); var dz=((A1*((B2*D3)-(B3*D2)))-(A2*((B1*D3)-(B3*D1)))+(A3*((B1*D2)-(B2*D1)))); if (d!=0){ //checks to make sure a 0 is not in the denominator posistion of the equation. x=(dx/d); //solve for x y=(dy/d); //solve for y z=(dz/d); //solve for z } document.write("x= " + x + " y= " + y + " z= " + z); //output answer via document.write }//end function thirdOrderDeterminant()
Comment Box
is loading comments...