Comprehensive Calculus

Limits • Derivatives • Integrals • Trigonometric Functions • Series • Proofs • GNU Octave Examples • Applications including Cryptography

Self-contained HTML5 Tutorial • Comprehensive & Complete

1. Introduction to Calculus

Calculus is the mathematical study of continuous change. It consists of two main branches:

The Fundamental Theorem of Calculus links them.

Historical Context

Developed independently by Isaac Newton and Gottfried Wilhelm Leibniz in the late 17th century.

2. Limits and Continuity

The limit of \( f(x) \) as \( x \) approaches \( a \) is \( L \), written:

\[\lim_{x \to a} f(x) = L\]

ε-δ Definition (Rigorous)

\( \lim_{x \to a} f(x) = L \) if for every \( \epsilon > 0 \), there exists \( \delta > 0 \) such that if \( 0 < |x - a| < \delta \), then \( |f(x) - L| < \epsilon \).

Key Limit Laws

RuleExpression
Sum\( \lim (f+g) = \lim f + \lim g \)
Product\( \lim (f \cdot g) = (\lim f)(\lim g) \)
Quotient\( \lim \frac{f}{g} = \frac{\lim f}{\lim g} \) (g ≠ 0)

Continuity

A function is continuous at \( a \) if \( \lim_{x\to a} f(x) = f(a) \).

3. Derivatives

The derivative of \( f \) at \( x \) is:

\[ f'(x) = \lim_{h \to 0} \frac{f(x+h) - f(x)}{h} \]

Basic Rules

Applications

Velocity, acceleration, optimization, related rates.

4. Trigonometric Functions in Calculus

Key Derivatives

\[ \frac{d}{dx} \sin x = \cos x, \quad \frac{d}{dx} \cos x = -\sin x, \quad \frac{d}{dx} \tan x = \sec^2 x \]

Proof of \( (\sin x)' = \cos x \) uses limit \( \lim_{h\to0} \frac{\sin h}{h} = 1 \) and angle addition.

Integrals of Trig Functions

\[ \int \sin x \, dx = -\cos x + C, \quad \int \cos x \, dx = \sin x + C \]

Trig Identities for Integration

\( \sin^2 x = \frac{1 - \cos 2x}{2} \), \( \int \sec x \, dx = \ln|\sec x + \tan x| + C \)

5. Integrals

The definite integral from a to b:

\[\int_a^b f(x) \, dx = \lim_{n\to\infty} \sum_{i=1}^n f(x_i^*) \Delta x\]

Fundamental Theorem of Calculus

Part 1: If \( F(x) = \int_a^x f(t) dt \), then \( F'(x) = f(x) \).

Part 2: \( \int_a^b f(x) dx = F(b) - F(a) \) where \( F' = f \).

Integration Techniques

6. Infinite Series and Taylor Expansions

Taylor Series for \( f(x) \) around a:

\[ f(x) = \sum_{n=0}^\infty \frac{f^{(n)}(a)}{n!} (x - a)^n \]

Maclaurin Series (a=0)

\[ \sin x = x - \frac{x^3}{3!} + \frac{x^5}{5!} - \cdots \] \[ \cos x = 1 - \frac{x^2}{2!} + \frac{x^4}{4!} - \cdots \] \[ e^x = 1 + x + \frac{x^2}{2!} + \frac{x^3}{3!} + \cdots \]

7. GNU Octave Examples

Octave is a free MATLAB-compatible language. Install from octave.org.

Example 1: Plotting sin(x) and derivative

% octave script: trig_deriv.m
x = linspace(-2*pi, 2*pi, 200);
y = sin(x);
dy = cos(x);

plot(x, y, 'b-', 'linewidth', 2);
hold on;
plot(x, dy, 'r--', 'linewidth', 2);
legend('sin(x)', 'cos(x) = d(sin)/dx');
xlabel('x'); ylabel('y');
title('Trigonometric Derivative');
grid on;

Example 2: Numerical Integration (Trapezoidal Rule)

function I = trap_integral(f, a, b, n)
    h = (b-a)/n;
    x = a:h:b;
    y = f(x);
    I = h/2 * (y(1) + 2*sum(y(2:end-1)) + y(end));
end

f = @(x) sin(x).^2;  % example
area = trap_integral(f, 0, pi, 1000);
disp(['Integral ≈ ', num2str(area)]);  % Should be near π/2

Example 3: Newton's Method for Roots

function root = newton(f, df, x0, tol=1e-8, maxit=50)
    for i = 1:maxit
        x1 = x0 - f(x0)/df(x0);
        if abs(x1 - x0) < tol
            root = x1; return;
        end
        x0 = x1;
    end
    root = x0;
end

f = @(x) x.^3 - 2*x - 5;
df = @(x) 3*x.^2 - 2;
root = newton(f, df, 2)

8. Calculus in Cryptography & Security

Calculus appears in several cryptographic contexts:

Octave: Simple ECC Slope Calculation (Conceptual)

% Slope of tangent to y^2 = x^3 + ax + b at point (x1,y1)
a = -3;  % curve parameter example
x1 = 2; y1 = 3;
slope = (3*x1^2 + a) / (2*y1);  % derivative implicit
disp(slope);

9. Selected Proofs

Proof: Derivative of sin(x)

Using angle addition:

\[ \lim_{h\to0} \frac{\sin(x+h) - \sin x}{h} = \lim_{h\to0} \left( \cos x \cdot \frac{\sin h}{h} - \sin x \cdot \frac{1 - \cos h}{h} \right) \]

Since \( \lim \frac{\sin h}{h} = 1 \), \( \lim \frac{1-\cos h}{h} = 0 \), result is \( \cos x \).

Mean Value Theorem

If f continuous on [a,b], differentiable on (a,b), then ∃ c ∈ (a,b) s.t. f'(c) = [f(b)-f(a)]/(b-a).