This is a simple web application that allows users to input 4 real numbers and a power, which are then used to create a 2x2 matrix. The program raises the matrix to the power entered by the user. I want to create a webpage that performs useful actions on matrices while also maintaining it simple enough so that users can modify it to their liking.
- Open the matrixPower.html file in a web browser.
- Enter four real numbers and a power into the form.
- Click the "Calculate" button.
- The result will be displayed in a new window.
- matrixPower.html: This is the main HTML file that contains the form for user input.
- matrixPower.js: This is the JavaScript file that performs the matrix operations.
The HTML file contains a form with five input fields for the four numbers and the power. The JavaScript file contains three functions:
- calculateMatrixPower(): This function is called when the "Calculate" button is clicked. It gets the input values from the form, calls the matrixPower function to calculate the result, and then opens a new window to display the result.
- matrixPower(matrix, power): This function raises the matrix to the power. It repeatedly multiplies the matrix by itself for the number of times specified by the power.
- multiplyMatrices(matrixA, matrixB): This function multiplies two matrices together.
You can customize the look and feel of the form by modifying the CSS rules in the <style> block in the HTML file.
This program assumes that the input is always valid (i.e., the user always provides real numbers and a non-negative integer for the power). If you want to handle invalid input, you should add an error checking code.
I also plan to expand on this program and add more features like:
- Allowing the user to adjust the size of the matrix.
- Outputing more information about the matrix like the determinant, its inverse, eigenvalues, etc.
- Or simply just making it visually better.