{
  "id": "dot-product",
  "version": "112a6ad95566",
  "status": "published",
  "name": "Dot Product Calculator",
  "question": "What is the dot product?",
  "summary": "Multiplies matrix A by matrix B: each entry of A × B is the dot product of a row of A with a column of B, and a 1 × n row times an n × 1 column gives the vector dot product.",
  "category": "math",
  "subcategory": "linear-algebra",
  "url": "https://www.acalculator.org/math/dot-product-calculator",
  "markdown": "https://www.acalculator.org/math/dot-product-calculator.md",
  "kind": "function",
  "method": "The entry in row i, column j of A × B is the dot product of row i of A with column j of B: cᵢⱼ = Σₖ aᵢₖbₖⱼ.",
  "assumptions": [
    "A has m rows and n columns, B has n rows and p columns, so A × B has m rows and p columns (1 to 10 each).",
    "A 1 × n matrix A times an n × 1 matrix B is the vector dot product a₁b₁ + … + aₙbₙ.",
    "The product text rounds each number to 10 significant figures; the dot product is shown at full precision."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "a": {
        "title": "Matrix A",
        "description": "The first matrix, 1 to 10 rows and columns.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "b": {
        "title": "Matrix B",
        "description": "The second matrix. It needs as many rows as A has columns.",
        "type": "array",
        "items": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      }
    }
  },
  "outputs": {
    "product": {
      "label": "A × B",
      "description": "The product matrix, rows separated by semicolons, each number rounded to 10 significant figures.",
      "format": "text"
    },
    "dot": {
      "label": "Dot product",
      "description": "The single number of a 1 × 1 result: the dot product of the row A with the column B.",
      "format": "number"
    },
    "size": {
      "label": "Size of A × B",
      "description": "Rows × columns of the product.",
      "format": "text"
    },
    "steps": {
      "label": "Working",
      "description": "Each entry as a row of A times a column of B, for the first 25 entries.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "a": [
        [
          1,
          2
        ],
        [
          3,
          4
        ]
      ],
      "b": [
        [
          5,
          6
        ],
        [
          7,
          8
        ]
      ]
    },
    "outputs": {
      "product": "[19, 22; 43, 50]",
      "size": "2×2",
      "steps": "c1,1 = 1×5 + 2×7 = 19; c1,2 = 1×6 + 2×8 = 22; c2,1 = 3×5 + 4×7 = 43; c2,2 = 3×6 + 4×8 = 50"
    },
    "text": "A × B = [19, 22; 43, 50]."
  },
  "examples": [
    {
      "given": {
        "a": [
          [
            1,
            2
          ],
          [
            3,
            4
          ]
        ],
        "b": [
          [
            5,
            6
          ],
          [
            7,
            8
          ]
        ]
      },
      "expect": {
        "product": "[19, 22; 43, 50]",
        "size": "2×2"
      },
      "source": "hand calculation in content.mdx: 1×5 + 2×7 = 19, 1×6 + 2×8 = 22, 3×5 + 4×7 = 43, 3×6 + 4×8 = 50; OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    },
    {
      "given": {
        "a": [
          [
            1,
            2,
            3
          ]
        ],
        "b": [
          [
            4
          ],
          [
            5
          ],
          [
            6
          ]
        ]
      },
      "expect": {
        "dot": 32,
        "product": "[32]",
        "size": "1×1"
      },
      "source": "hand calculation in content.mdx: 1×4 + 2×5 + 3×6 = 32 (Strang, Introduction to Linear Algebra, 5th ed., 1.2); OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    },
    {
      "given": {
        "a": [
          [
            1,
            2,
            3
          ],
          [
            4,
            5,
            6
          ]
        ],
        "b": [
          [
            7,
            8
          ],
          [
            9,
            10
          ],
          [
            11,
            12
          ]
        ]
      },
      "expect": {
        "product": "[58, 64; 139, 154]",
        "size": "2×2"
      },
      "source": "hand calculation in content.mdx: 1×7 + 2×9 + 3×11 = 58, …, 4×8 + 5×10 + 6×12 = 154; OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    },
    {
      "given": {
        "a": [
          [
            -1.5,
            2
          ]
        ],
        "b": [
          [
            4
          ],
          [
            0.5
          ]
        ]
      },
      "expect": {
        "dot": -5
      },
      "source": "hand calculation in content.mdx: −1.5×4 + 2×0.5 = −6 + 1 = −5; OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 3, §2.3 The Dot Product. https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product"
  ],
  "related": [],
  "changelog": [
    {
      "date": "2026-09-28",
      "note": "The size message matches the matrix multiplication page."
    },
    {
      "date": "2026-09-28",
      "note": "B has its own size, so a link whose sizes differ shows an error; negative factors in the working are in brackets."
    },
    {
      "date": "2026-09-29",
      "note": "Worked examples name a published reference for their rule."
    }
  ]
}
