Linear Algebra Calculator

.la-calc-container { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; max-width: 800px; margin: 20px auto; padding: 25px; border: 1px solid #e0e0e0; border-radius: 12px; background-color: #ffffff; color: #333; box-shadow: 0 4px 6px rgba(0,0,0,0.05); } .la-calc-container h2 { color: #2c3e50; border-bottom: 2px solid #3498db; padding-bottom: 10px; margin-top: 0; } .la-calc-section { margin-bottom: 30px; padding: 20px; background: #f8f9fa; border-radius: 8px; } .la-calc-section h3 { margin-top: 0; color: #2980b9; font-size: 1.2rem; } .la-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px; } .matrix-grid { display: grid; grid-template-columns: repeat(2, 80px); gap: 10px; justify-content: center; margin-bottom: 15px; } .la-input-group { display: flex; flex-direction: column; } .la-input-group label { font-size: 0.85rem; margin-bottom: 5px; font-weight: 600; color: #555; } .la-input-group input { padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; text-align: center; } .la-btn { background-color: #3498db; color: white; border: none; padding: 12px 20px; border-radius: 5px; cursor: pointer; font-weight: bold; width: 100%; transition: background 0.3s; } .la-btn:hover { background-color: #2980b9; } .la-result { margin-top: 20px; padding: 15px; border-left: 5px solid #27ae60; background: #ecfdf5; display: none; } .la-result-title { font-weight: bold; color: #27ae60; margin-bottom: 5px; } .matrix-display { display: inline-block; border-left: 2px solid #333; border-right: 2px solid #333; padding: 5px 10px; border-radius: 10px; font-family: monospace; line-height: 1.5; } .la-article { line-height: 1.6; color: #444; margin-top: 40px; } .la-article h2 { color: #2c3e50; font-size: 1.5rem; margin-top: 30px; } .la-article p { margin-bottom: 15px; }

Linear Algebra Calculator

Vector Dot Product (3D)

Calculate A · B = (x1 * x2) + (y1 * y2) + (z1 * z2)

Dot Product Result:

2×2 Matrix Determinant & Inverse

Input matrix values for A = [[a, b], [c, d]]

Matrix Analysis:

Understanding Linear Algebra Fundamentals

Linear algebra is the branch of mathematics concerning linear equations, vectors, and matrices. It is the mathematical foundation for modern data science, computer graphics, and engineering. This calculator helps you solve two of the most common operations: the Vector Dot Product and 2×2 Matrix Inversion.

The Vector Dot Product

The dot product is an algebraic operation that takes two equal-length sequences of numbers (usually coordinate vectors) and returns a single number. Geometrically, it represents the product of the Euclidean magnitudes of the two vectors and the cosine of the angle between them.

Example: If Vector A = [2, 3, 1] and Vector B = [4, -1, 2], the dot product is:
(2 * 4) + (3 * -1) + (1 * 2) = 8 – 3 + 2 = 7.

Matrix Determinants and Inverses

A 2×2 matrix determinant is calculated as ad – bc. This value is crucial because it tells us if a matrix can be inverted. If the determinant is zero, the matrix is "singular" and has no inverse.

The inverse of a matrix A is another matrix, denoted as A⁻¹, such that A multiplied by A⁻¹ results in the Identity Matrix. For a 2×2 matrix, the formula is:
A⁻¹ = (1/Determinant) * [[d, -b], [-c, a]].

Why These Calculations Matter

  • Machine Learning: Weights in neural networks are often adjusted using matrix multiplications and dot products.
  • Physics: Dot products are used to calculate work done by a force.
  • Computer Graphics: Matrices handle rotations, scaling, and translations of 3D objects on your screen.
function calculateDotProduct() { var ax = parseFloat(document.getElementById('vax').value); var ay = parseFloat(document.getElementById('vay').value); var az = parseFloat(document.getElementById('vaz').value); var bx = parseFloat(document.getElementById('vbx').value); var by = parseFloat(document.getElementById('vby').value); var bz = parseFloat(document.getElementById('vbz').value); if (isNaN(ax) || isNaN(ay) || isNaN(az) || isNaN(bx) || isNaN(by) || isNaN(bz)) { alert("Please enter valid numbers for all vector components."); return; } var result = (ax * bx) + (ay * by) + (az * bz); document.getElementById('dotResultValue').innerText = result.toFixed(4).replace(/\.?0+$/, ""); document.getElementById('dotResultBox').style.display = 'block'; } function calculateMatrix() { var a = parseFloat(document.getElementById('ma').value); var b = parseFloat(document.getElementById('mb').value); var c = parseFloat(document.getElementById('mc').value); var d = parseFloat(document.getElementById('md').value); if (isNaN(a) || isNaN(b) || isNaN(c) || isNaN(d)) { alert("Please enter valid numbers for all matrix elements."); return; } var det = (a * d) – (b * c); var detDisplay = document.getElementById('detResult'); var invDisplay = document.getElementById('invResult'); detDisplay.innerHTML = "Determinant (Δ): " + det.toFixed(4).replace(/\.?0+$/, ""); if (det === 0) { invDisplay.innerHTML = "Inverse: None (Singular Matrix)"; } else { var ia = d / det; var ib = -b / det; var ic = -c / det; var id = a / det; invDisplay.innerHTML = "Inverse Matrix A⁻¹:
" + ia.toFixed(3).replace(/\.?0+$/, "") + " " + ib.toFixed(3).replace(/\.?0+$/, "") + "" + ic.toFixed(3).replace(/\.?0+$/, "") + " " + id.toFixed(3).replace(/\.?0+$/, "") + "
"; } document.getElementById('matrixResultBox').style.display = 'block'; }

Leave a Comment