{
  "id": "tangent-line",
  "version": "f6589a4cbe9f",
  "status": "published",
  "name": "Tangent Line Calculator",
  "question": "What is the tangent line at a point?",
  "summary": "Finds the equation of the tangent line to y = f(x) at x = a, with its slope, checked numerically.",
  "category": "math",
  "subcategory": "calculus",
  "url": "https://www.acalculator.org/math/tangent-line-calculator",
  "markdown": "https://www.acalculator.org/math/tangent-line-calculator.md",
  "kind": "function",
  "method": "y = f(a) + f′(a)(x − a). A computer algebra system finds f′(a); it is shown only when f′ matches a difference quotient at 20 points and at a.",
  "assumptions": [
    "The variable is x; angles are in radians; ln is the natural logarithm.",
    "An answer that fails its check is not shown."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "f": {
        "title": "Function f(x)",
        "description": "The curve y = f(x), typed like x^2, sqrt(x) or sin(x).",
        "type": "string",
        "maxLength": 200
      },
      "a": {
        "title": "At x = a",
        "description": "The point of tangency: a number or a constant such as pi/4.",
        "type": "string",
        "maxLength": 40
      }
    }
  },
  "outputs": {
    "line": {
      "label": "Tangent line y =",
      "description": "The tangent line y = f(a) + f′(a)(x − a), expanded, with exact numbers.",
      "format": "math"
    },
    "slope": {
      "label": "Slope f′(a)",
      "description": "The slope of the tangent line.",
      "format": "number"
    },
    "y": {
      "label": "Point f(a)",
      "description": "The y value of the point of tangency (a, f(a)).",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "f": "x^2",
      "a": "3"
    },
    "outputs": {
      "line": "6x - 9",
      "slope": 6,
      "y": 9
    },
    "text": "The tangent line to x^2 at x = 3 is y = 6x - 9."
  },
  "examples": [
    {
      "given": {
        "f": "x^2",
        "a": "3"
      },
      "expect": {
        "line": "6x - 9",
        "slope": 6,
        "y": 9
      },
      "source": "OpenStax, Calculus Volume 1, section 3.1 Defining the Derivative, Example 3.1. https://openstax.org/books/calculus-volume-1/pages/3-1-defining-the-derivative"
    },
    {
      "given": {
        "f": "1/x",
        "a": "2"
      },
      "expect": {
        "line": "1 - x/4",
        "slope": -0.25,
        "y": 0.5
      },
      "source": "OpenStax, Calculus Volume 1, section 3.1 Defining the Derivative, Example 3.3"
    }
  ],
  "sources": [
    "OpenStax, Calculus Volume 1, section 3.1 Defining the Derivative: https://openstax.org/books/calculus-volume-1/pages/3-1-defining-the-derivative"
  ],
  "related": [
    "instantaneous-rate-of-change",
    "linear-approximation",
    "integral",
    "slope"
  ],
  "changelog": []
}
