{
  "id": "foil",
  "version": "77ac617d3659",
  "status": "published",
  "name": "FOIL Calculator",
  "question": "How do I FOIL binomials?",
  "summary": "Multiplies two binomials by the FOIL method: the first, outer, inner and last products, their sum, and the answer with like terms combined, in exact fractions.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/foil-calculator",
  "markdown": "https://www.acalculator.org/math/foil-calculator.md",
  "kind": "function",
  "method": "(a + b)(c + d) = ac + ad + bc + bd: First ac, Outer ad, Inner bc, Last bd; then like terms are combined in exact fractions.",
  "assumptions": [
    "Each bracket holds exactly two unlike terms. Coefficients are exact fractions: 0.5 is 1/2.",
    "The first and last term of each bracket are taken in the order typed."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "e": {
        "title": "Two binomials",
        "description": "Two binomials in brackets, such as (2x + 3)(x − 5).",
        "type": "string",
        "maxLength": 120
      }
    }
  },
  "outputs": {
    "result": {
      "label": "Product",
      "description": "The product with like terms combined.",
      "format": "math"
    },
    "first": {
      "label": "First",
      "description": "First term × first term.",
      "format": "text"
    },
    "outer": {
      "label": "Outer",
      "description": "First term of the first bracket × last term of the second.",
      "format": "text"
    },
    "inner": {
      "label": "Inner",
      "description": "Last term of the first bracket × first term of the second.",
      "format": "text"
    },
    "last": {
      "label": "Last",
      "description": "Last term × last term.",
      "format": "text"
    },
    "steps": {
      "label": "FOIL steps",
      "description": "Each product, their sum, and the sum with like terms combined.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "e": "(2x - 18)(3x + 3)"
    },
    "outputs": {
      "result": "6x^2 - 48x - 54",
      "first": "6x²",
      "outer": "6x",
      "inner": "−54x",
      "last": "−54",
      "steps": "First: 2x × 3x = 6x²; Outer: 2x × 3 = 6x; Inner: (−18) × 3x = −54x; Last: (−18) × 3 = −54; Add: 6x² + 6x − 54x − 54; Combine like terms: 6x² − 48x − 54"
    },
    "text": "(2x - 18)(3x + 3) = 6x^2 - 48x - 54."
  },
  "examples": [
    {
      "given": {
        "e": "(2x - 18)(3x + 3)"
      },
      "expect": {
        "result": "6x^2 - 48x - 54",
        "first": "6x²",
        "outer": "6x",
        "inner": "−54x",
        "last": "−54",
        "steps": "First: 2x × 3x = 6x²; Outer: 2x × 3 = 6x; Inner: (−18) × 3x = −54x; Last: (−18) × 3 = −54; Add: 6x² + 6x − 54x − 54; Combine like terms: 6x² − 48x − 54"
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §1.4 Polynomials, Example 5 ((2x − 18)(3x + 3) = 6x² − 48x − 54), https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-4-polynomials"
    },
    {
      "given": {
        "e": "(9x + 4)(9x - 4)"
      },
      "expect": {
        "result": "81x^2 - 16",
        "outer": "−36x",
        "inner": "36x"
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §1.4 Polynomials, Example 7 ((9x + 4)(9x − 4) = 81x² − 16), https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-4-polynomials"
    },
    {
      "given": {
        "e": "(3x - 8)(3x - 8)"
      },
      "expect": {
        "result": "9x^2 - 48x + 64"
      },
      "source": "OpenStax, Algebra and Trigonometry 2e, §1.4 Polynomials, Example 6 ((3x − 8)² = 9x² − 48x + 64), https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-4-polynomials"
    },
    {
      "given": {
        "e": "(x + 2y)(0.5x - y)"
      },
      "expect": {
        "result": "x^2/2 - 2y^2",
        "first": "x²/2",
        "outer": "−x y",
        "inner": "x y",
        "last": "−2y²"
      },
      "source": "hand calculation in content.mdx: x × x/2 = x²/2, x × (−y) = −xy, 2y × x/2 = xy, 2y × (−y) = −2y²"
    }
  ],
  "sources": [
    "OpenStax, Algebra and Trigonometry 2e, §1.4 Polynomials (FOIL: multiply the first, outer, inner and last terms; Example 5: (2x − 18)(3x + 3) = 6x² − 48x − 54; Example 6: (3x − 8)² = 9x² − 48x + 64; Example 7: (9x + 4)(9x − 4) = 81x² − 16). https://openstax.org/books/algebra-and-trigonometry-2e/pages/1-4-polynomials (retrieved 2026-10-05)"
  ],
  "related": [
    "distributive-property",
    "combine-like-terms",
    "polynomial",
    "binomial-theorem",
    "factoring"
  ],
  "changelog": []
}
