Risultati

Visual Limits for Programmers

Limits β€” a curve approaching a value as x gets close to a point

Plain English first

A limit asks: what value is a function heading toward, even if it never quite gets there?

Think of driving toward a wall. You slow down as you approach. A limit is the wall β€” the value everything is moving toward β€” even if you never touch it.

You do not need to stand exactly on the point. You just need to watch where the outputs are heading.

The picture

x getting closer to 2 from the left:  1.9 β†’ 1.99 β†’ 1.999 β†’ ...
x getting closer to 2 from the right: 2.1 β†’ 2.01 β†’ 2.001 β†’ ...

Both sides squeeze toward the same output β†’ that output is the limit.

Standard math notation

lim f(x) = L
x β†’ a

Read as: "the limit of f(x) as x approaches a equals L"

Verbose Python with descriptive names

def estimate_limit_by_approaching(function, target_input, number_of_steps=10):
    """
    Estimate the limit of a function at a given input by computing
    the function at inputs that get progressively closer to the target.

    This is how you would check a limit numerically β€” approach from both
    sides and see if the outputs converge to the same value.
    """
    print(f"Approaching {target_input} from the left:")
    for step in range(1, number_of_steps + 1):
        # Each step gets ten times closer to the target
        distance_from_target = 10 ** (-step)
        input_from_left = target_input - distance_from_target
        output_value = function(input_from_left)
        print(f"  x = {input_from_left:.10f}  β†’  f(x) = {output_value:.10f}")

    print(f"\nApproaching {target_input} from the right:")
    for step in range(1, number_of_steps + 1):
        distance_from_target = 10 ** (-step)
        input_from_right = target_input + distance_from_target
        output_value = function(input_from_right)
        print(f"  x = {input_from_right:.10f}  β†’  f(x) = {output_value:.10f}")


# Example: limit of (xΒ² - 4) / (x - 2) as x β†’ 2
# At exactly x=2, this is 0/0 (undefined). But the limit is 4.
def tricky_function(x):
    return (x * x - 4) / (x - 2)

estimate_limit_by_approaching(tricky_function, target_input=2)
# Both sides converge to 4.0

Why limits matter for programming

Limits make derivatives possible. To find the slope of a curve at one point:
- Pick two points very close together
- Compute the slope between them
- The limit is what happens as the distance shrinks to zero

def approximate_slope_at_point(function, input_value):
    """
    Estimate the slope (derivative) of a function at a specific input.
    This is the limit of (f(x+h) - f(x)) / h as h β†’ 0.
    """
    tiny_step = 0.000001  # h, very small but not zero

    output_at_x       = function(input_value)
    output_at_x_plus_h = function(input_value + tiny_step)

    rise = output_at_x_plus_h - output_at_x
    run  = tiny_step

    slope_approximation = rise / run
    return slope_approximation

Common mistakes

  • Thinking the function must be defined at the target point. It does not β€” the limit only cares about nearby values.
  • Confusing the limit (what the output approaches) with the actual output (what the function equals at that point). These can differ.
  • Expecting limits to always exist. If the left and right approaches give different values, the limit does not exist.

See also

Commenti

Nessun commento ancora. Sii il primo!


I commenti sono moderati e appariranno dopo l'approvazione.