{
  "id": "parallel-perpendicular-line",
  "version": "ec41f8911b78",
  "status": "published",
  "name": "Parallel and Perpendicular Line Calculator",
  "question": "Parallel and perpendicular lines?",
  "summary": "Parallel and perpendicular line calculator: the lines through a point that are parallel and perpendicular to a given line, in slope-intercept and standard form, with the foot of the perpendicular and the distance.",
  "category": "math",
  "subcategory": "algebra",
  "url": "https://www.acalculator.org/math/parallel-perpendicular-line-calculator",
  "markdown": "https://www.acalculator.org/math/parallel-perpendicular-line-calculator.md",
  "kind": "function",
  "method": "Given line ax + by = c and point (p, q): parallel ax + by = ap + bq (slope m = −a/b); perpendicular bx − ay = bp − aq (slope −1/m); foot (p − ta, q − tb) with t = (ap + bq − c) ÷ (a² + b²); distance |ap + bq − c| ÷ √(a² + b²).",
  "assumptions": [
    "Every number is read exactly as typed: 0.1 is 1/10, so slopes, intercepts and the foot are exact fractions.",
    "A vertical line (x = c) has no slope; the line perpendicular to it is horizontal, and the reverse."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "given": {
        "title": "The line",
        "description": "How you know the given line: its slope and y-intercept, two points on it, or Ax + By = C.",
        "type": "string",
        "enum": [
          "slope",
          "points",
          "standard"
        ]
      },
      "m": {
        "title": "Slope (m)",
        "description": "The slope of the given line.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "b": {
        "title": "y-intercept (b)",
        "description": "Where the given line crosses the y axis.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "x1": {
        "title": "x₁",
        "description": "The x coordinate of a point on the given line.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "y1": {
        "title": "y₁",
        "description": "The y coordinate of that point.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "x2": {
        "title": "x₂",
        "description": "The x coordinate of a second point on the given line.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "y2": {
        "title": "y₂",
        "description": "The y coordinate of the second point.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "A": {
        "title": "A",
        "description": "The number in front of x in Ax + By = C.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "B": {
        "title": "B",
        "description": "The number in front of y in Ax + By = C.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "C": {
        "title": "C",
        "description": "The number on the right of Ax + By = C.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "px": {
        "title": "Point x",
        "description": "The x coordinate of the point the new lines pass through.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      },
      "py": {
        "title": "Point y",
        "description": "The y coordinate of the point the new lines pass through.",
        "type": "string",
        "pattern": "^-?\\d+( \\d+)?(/\\d+)?$"
      }
    }
  },
  "outputs": {
    "lines": {
      "label": "Parallel; perpendicular",
      "description": "The parallel line, then the perpendicular line, each through the point.",
      "format": "text"
    },
    "parallel": {
      "label": "Parallel line",
      "description": "The line through the point with the same slope: y = mx + b, or x = c.",
      "format": "text"
    },
    "parallelStandard": {
      "label": "Parallel line, standard form",
      "description": "The parallel line as Ax + By = C in whole numbers.",
      "format": "text"
    },
    "perpendicular": {
      "label": "Perpendicular line",
      "description": "The line through the point with the negative reciprocal slope: y = mx + b, or x = c.",
      "format": "text"
    },
    "perpendicularStandard": {
      "label": "Perpendicular line, standard form",
      "description": "The perpendicular line as Ax + By = C in whole numbers.",
      "format": "text"
    },
    "givenLine": {
      "label": "Given line",
      "description": "The given line in slope-intercept form, or x = c when it is vertical.",
      "format": "text"
    },
    "slope": {
      "label": "Slope of the given line",
      "description": "m, also the slope of the parallel line. None for a vertical line.",
      "format": "number"
    },
    "perpendicularSlope": {
      "label": "Perpendicular slope",
      "description": "−1 ÷ m. None when the given line is horizontal or vertical.",
      "format": "number"
    },
    "foot": {
      "label": "Foot of the perpendicular",
      "description": "Where the perpendicular line crosses the given line, exactly.",
      "format": "text"
    },
    "distance": {
      "label": "Distance from the point to the line",
      "description": "The length from the point to the foot.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "given": "slope",
      "m": "3",
      "b": "6",
      "x1": "-2",
      "y1": "6",
      "x2": "4",
      "y2": "5",
      "A": "2",
      "B": "3",
      "C": "6",
      "px": "3",
      "py": "0"
    },
    "outputs": {
      "lines": "y = 3x − 9; y = −(1/3)x + 1",
      "parallel": "y = 3x − 9",
      "parallelStandard": "3x − y = 9",
      "perpendicular": "y = −(1/3)x + 1",
      "perpendicularStandard": "x + 3y = 3",
      "givenLine": "y = 3x + 6",
      "slope": 3,
      "perpendicularSlope": -0.3333333333333333,
      "foot": "(−3/2, 3/2)",
      "distance": 4.743416490252569
    },
    "text": "Through (3, 0): parallel y = 3x − 9; perpendicular y = −(1/3)x + 1."
  },
  "examples": [
    {
      "given": {
        "given": "slope",
        "m": "3",
        "b": "6",
        "px": "3",
        "py": "0"
      },
      "expect": {
        "parallel": "y = 3x − 9",
        "perpendicular": "y = −(1/3)x + 1",
        "parallelStandard": "3x − y = 9",
        "perpendicularStandard": "x + 3y = 3",
        "slope": 3,
        "perpendicularSlope": -0.3333333333333333
      },
      "source": "OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18), Example 19: the line parallel to f(x) = 3x + 6 through (3, 0) is g(x) = 3x − 9; Example 20 (perpendicular slope −1/3 through (3, 0) gives −(1/3)x + 1)"
    },
    {
      "given": {
        "given": "slope",
        "m": "3",
        "b": "1",
        "px": "1",
        "py": "7"
      },
      "expect": {
        "parallel": "y = 3x + 4",
        "lines": "y = 3x + 4; y = −(1/3)x + 22/3"
      },
      "source": "OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18), Writing Equations of Parallel Lines: f(x) = 3x + 1 through (1, 7) gives y = 3x + 4; perpendicular by hand: 7 = −(1/3) × 1 + b, b = 22/3"
    },
    {
      "given": {
        "given": "slope",
        "m": "2",
        "b": "4",
        "px": "4",
        "py": "0"
      },
      "expect": {
        "perpendicular": "y = −(1/2)x + 2",
        "perpendicularSlope": -0.5,
        "foot": "(−4/5, 12/5)"
      },
      "source": "OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18), Writing Equations of Perpendicular Lines: f(x) = 2x + 4 and (4, 0) give y = −(1/2)x + 2; foot by hand in content.mdx"
    },
    {
      "given": {
        "given": "points",
        "x1": "-2",
        "y1": "6",
        "x2": "4",
        "y2": "5",
        "px": "4",
        "py": "5"
      },
      "expect": {
        "perpendicular": "y = 6x − 19",
        "givenLine": "y = −(1/6)x + 17/3",
        "parallel": "y = −(1/6)x + 17/3",
        "slope": -0.16666666666666666,
        "perpendicularSlope": 6,
        "distance": 0
      },
      "source": "OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18), Example 21: slope −1/6, perpendicular slope 6, y = 6x − 19"
    },
    {
      "given": {
        "given": "standard",
        "A": "2",
        "B": "3",
        "C": "6",
        "px": "1",
        "py": "1"
      },
      "expect": {
        "parallel": "y = −(2/3)x + 5/3",
        "parallelStandard": "2x + 3y = 5",
        "perpendicular": "y = (3/2)x − 1/2",
        "perpendicularStandard": "3x − 2y = 1",
        "foot": "(15/13, 16/13)",
        "distance": 0.2773500981126146
      },
      "source": "hand calculation in content.mdx (OpenStax College Algebra 2e §2.1 distance formula and §7.1 systems of two equations); OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18)"
    },
    {
      "given": {
        "given": "points",
        "x1": "2",
        "y1": "1",
        "x2": "2",
        "y2": "5",
        "px": "-1",
        "py": "3"
      },
      "expect": {
        "givenLine": "x = 2",
        "parallel": "x = −1",
        "perpendicular": "y = 3",
        "foot": "(2, 3)",
        "distance": 3
      },
      "source": "hand calculation in content.mdx: a vertical line has no slope, its perpendicular is horizontal; OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18)"
    },
    {
      "given": {
        "given": "slope",
        "m": "0.5",
        "b": "-1.25",
        "px": "0.1",
        "py": "0.2"
      },
      "expect": {
        "parallel": "y = (1/2)x + 3/20",
        "perpendicular": "y = −2x + 2/5",
        "perpendicularSlope": -2
      },
      "source": "hand calculation in content.mdx: 0.2 − 0.5 × 0.1 = 3/20 and 0.2 + 2 × 0.1 = 2/5; OpenStax, College Algebra 2e, §4.1 Linear Functions (parallel lines have the same slope; perpendicular slopes are negative reciprocals whose product is −1), https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions (retrieved 2026-10-18)"
    }
  ],
  "sources": [
    "OpenStax, College Algebra 2e, §4.1 Linear Functions: Determining Whether Lines are Parallel or Perpendicular; Writing Equations of Parallel Lines and of Perpendicular Lines; Examples 19, 20 and 21, retrieved 2026-10-18. https://openstax.org/books/college-algebra-2e/pages/4-1-linear-functions",
    "OpenStax, College Algebra 2e, §2.1 The Rectangular Coordinate Systems and Graphs: the distance formula d = √((x₂ − x₁)² + (y₂ − y₁)²), retrieved 2026-10-18. https://openstax.org/books/college-algebra-2e/pages/2-1-the-rectangular-coordinate-systems-and-graphs",
    "OpenStax, College Algebra 2e, §7.1 Systems of Linear Equations: Two Variables (two lines with different slopes meet at one point), retrieved 2026-10-18. https://openstax.org/books/college-algebra-2e/pages/7-1-systems-of-linear-equations-two-variables"
  ],
  "related": [
    "slope",
    "slope-intercept",
    "point-slope-form",
    "distance-formula"
  ],
  "changelog": []
}
