Maths and Computing
Home
Book
Calculator
Coding
Binary
Resources
Information
Home
Book
Calculator
Coding
Binary
Resources
Information
A+
Home
Book
Calculator
Coding
Binary
Resources
Information
A-
Maths and Computing JavaScript Examples
This tool will run small JavaScript programs. It is essentially intended for use with the book "An Introduction to Mathematics for Computing and IT Practitioners". Click an entry on the right to select one of the book's code examples.
1.3.2: Working out the triangular numbers
2.3.1: Storing a vector in an array
2.3.2: Storing a matrix in an array
3.2.3: Multiplying two 2 by 2 matrices
5.3.2: Solving a simultaneous equation
6.4.2: Finding the minimum spanning tree
7.5.1: Calculating the nth term of a given sequence V1
7.5.2: Calculating the nth term of a given sequence V2
8.2.2: Quick Sort
9.6.3: Simulation Scenario 1
9.6.4: Simulation Scenario 2
11.1.5: Converting a decimal number to binary
11.5.3: Converting binary numbers to Gray code
13.4.3: Converting an 8-bit character to MIME Base 64
15.1.2: Calculating a sequence of prime numbers
15.2.3: Euclids Algorithm
15.3.2: Calculating the square root of a binary number
15.5.2: Working out the day of the week
<html>
<body>
<script type ="text/javascript">
<title>
Solving simultaneous equations
</title>
</head>
<body>
<script type ="text/javascript">
// Define the matrix A and its values A = new Array(2); A[0]=["4", "-1"]; A[1]=["3", "2"]; // Define the matrix B and its values B = new Array("3", "16"); // Find the determinant D = A[0][0]*A[1][1]-A[0][1]*A[1][0]; // Find the inverse of A J = new Array(2); J[0]=new Array(A[1][1], -A[0][1]); J[1]=new Array(-A[1][0], A[0][0]); // Multiply the matrix elements X = (J[0][0]*B[0] + J[0][1]*B[1])/D; Y = (J[1][0]*B[0] + J[1][1]*B[1])/D; // Display the values of x and y document.writeln("x=" + X + ", y=" + Y);
</script>
</body>
</html>