calculus25 min

Curve Sketching

Using first and second derivatives to determine intervals of increase, decrease, concavity, and inflection points

0/9Not Started

Why This Matters

Knowing the formula of a function is not the same as understanding its shape. Increasing and decreasing intervals tell you where the function rises and falls. Concavity tells you whether it curves upward like a bowl or downward like a hill. Together, these properties let you sketch an accurate picture of any function without plotting hundreds of points.

The first derivative reveals direction: where f prime(x) is positive, the function is increasing; where f prime(x) is negative, it is decreasing. The second derivative reveals curvature: where f double-prime(x) is positive, the function is concave up; where f double-prime(x) is negative, it is concave down.

An inflection point is where the concavity changes -- the function transitions from curving up to curving down (or vice versa). These points are important in physics (where acceleration changes sign), statistics (the inflection points of the normal distribution curve), and data analysis (identifying transitions in growth patterns).

Define Terms

Visual Model

First Derivative f prime(x)Sign determines direction
Increasingf prime(x) positive
Decreasingf prime(x) negative
Second Derivative f double-prime(x)Sign determines curvature
Concave Upf double-prime(x) positive
Concave Downf double-prime(x) negative
Inflection PointConcavity changes sign
Complete SketchDirection + curvature + special points

The full process at a glance. Click Start tour to walk through each step.

First derivative gives direction (increasing/decreasing), second derivative gives curvature (concave up/down), and together they produce the full curve shape.

Code Example

Code
function deriv(f, x, h = 0.00001) {
  return (f(x + h) - f(x - h)) / (2 * h);
}

function secondDeriv(f, x, h = 0.0001) {
  return (f(x + h) - 2 * f(x) + f(x - h)) / (h * h);
}

// Analyze f(x) = x^3 - 3x^2 + 2
const f = x => x * x * x - 3 * x * x + 2;

console.log("Curve analysis: f(x) = x^3 - 3x^2 + 2\n");

// Find intervals of increase/decrease
console.log("Sign of f prime(x):");
for (let x = -1; x <= 4; x += 0.5) {
  const fp = deriv(f, x);
  const direction = fp > 0.01 ? "increasing" : fp < -0.01 ? "decreasing" : "zero";
  console.log(`  x = ${x.toFixed(1)}: f prime = ${fp.toFixed(3)}, ${direction}`);
}

// Find intervals of concavity
console.log("\nSign of f double-prime(x):");
for (let x = -1; x <= 4; x += 0.5) {
  const fpp = secondDeriv(f, x);
  const concavity = fpp > 0.01 ? "concave up" : fpp < -0.01 ? "concave down" : "inflection?";
  console.log(`  x = ${x.toFixed(1)}: f double-prime = ${fpp.toFixed(3)}, ${concavity}`);
}

// Find inflection points (where f double-prime changes sign)
function findInflectionPoints(f, a, b, steps = 1000) {
  const points = [];
  const dx = (b - a) / steps;
  for (let i = 0; i < steps; i++) {
    const x1 = a + i * dx;
    const x2 = x1 + dx;
    const d1 = secondDeriv(f, x1);
    const d2 = secondDeriv(f, x2);
    if (d1 * d2 < 0) {
      let lo = x1, hi = x2;
      for (let j = 0; j < 50; j++) {
        const mid = (lo + hi) / 2;
        if (secondDeriv(f, mid) * secondDeriv(f, lo) <= 0) hi = mid;
        else lo = mid;
      }
      points.push(parseFloat(((lo + hi) / 2).toFixed(4)));
    }
  }
  return points;
}

const inflections = findInflectionPoints(f, -2, 5);
console.log("\nInflection points:", inflections);
for (const ip of inflections) {
  console.log(`  x = ${ip}: f(x) = ${f(ip).toFixed(4)}`);
}

Interactive Experiment

Try these exercises:

  • Analyze f(x) = sin(x) on [0, 2*pi]. Find all intervals of increase, decrease, concavity, and inflection points.
  • Try f(x) = x^4 - 4x^3. Where is it concave up? Concave down? Where are the inflection points?
  • Create a function that is always increasing but changes concavity (like x^3 at the origin). What does this look like?
  • Compare x^2 (always concave up) with -x^2 (always concave down). How does the second derivative confirm this?
  • Analyze e^(-x^2) (the Gaussian bell curve). Where are its inflection points? This is the famous normal distribution shape.

Quick Quiz

Coding Challenge

Determine Increase/Decrease Intervals from Derivative Sign

Write a function called `analyzeIntervals` that takes a function f and interval endpoints a and b. Scan the interval with 100 evenly spaced sample points. For each point, determine whether the function is increasing (derivative exceeds 0.001), decreasing (derivative below -0.001), or stationary. Return an object with two properties: `increasing` (count of sample points where function is increasing) and `decreasing` (count where function is decreasing). Use central difference with h = 0.00001.

Loading editor...

Real-World Usage

Curve sketching analysis appears throughout science and industry:

  • Data analysis: Identifying trends (increasing/decreasing) and transitions (inflection points) in time series data like stock prices, COVID case counts, or user growth.
  • Physics: Determining when an object is accelerating vs decelerating, and finding points where the acceleration changes (jerk).
  • Statistics: The normal distribution has inflection points at one standard deviation from the mean. Understanding the curve shape is fundamental to statistics.
  • Product management: Growth curves for products often show an inflection point (the "hockey stick") where growth transitions from slow to rapid.
  • Medicine: Drug concentration curves show how medication levels increase, peak, and decrease in the body. Inflection points indicate changes in absorption or elimination rate.

Connections