Visualizing Newton's Method for √2

Loading...

Loading video...

Pro
0:00 / 0:00

Manim Animation Specification: Newton's Method with Default Settings

1. Animation Description & Purpose

Create a clear visual demonstration of Newton's method for finding a root of a function. The animation will show the function curve, the tangent line at the current iterate, and the successive approximations converging to the root. This helps viewers understand how the tangent line intersects the x‑axis and provides the next approximation.

2. Mathematical Elements

  • Function: f(x)=x22f(x) = x^2 - 2
  • Derivative: f(x)=2xf'(x) = 2x
  • Newton Update Formula: xn+1=xnf(xn)f(xn)x_{n+1} = x_n - \frac{f(x_n)}{f'(x_n)}
  • Initial Guess: x0=2x_0 = 2
  • Number of Iterations Displayed: 5 (i.e., x0x_0 through x5x_5)
  • Root: 21.4142\sqrt{2} \approx 1.4142

3. Visual Elements

Element Description Color Style
Axes Standard Cartesian axes with tick marks from 1-1 to 33 on x‑axis and 1-1 to 33 on y‑axis. Gray Axes with x_range=[-1,3,1], y_range=[-1,3,1]
Function Curve Plot of f(x)f(x). Blue (#1f77b4) Smooth Graph with stroke_width=3
Tangent Lines Tangent at each iterate xnx_n extending to intersect the x‑axis. Red (#d62728) Dashed line, stroke_width=2
Iterate Points Small circles at each xnx_n on the curve. Green (#2ca02c) Dot with radius 0.08
Root Marker Larger dot at the true root 2\sqrt{2}. Gold (#ffbf00) Dot radius 0.12
Text Annotations Formula, iteration number, and convergence note. Black Tex objects

4. Animation Timing & Transitions

Step Action Duration
1 Fade‑in axes and function curve. 1.5 s
2 Show initial point x0x_0 on curve (dot) and display formula xn+1=xnf(xn)f(xn)x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}. 2 s
3‑7 For each iteration n=04n = 0 \dots 4:
  • Draw tangent line at xnx_n.
  • Extend line to x‑axis, highlight intersection as next point xn+1x_{n+1}.
  • Fade‑in new dot at xn+1x_{n+1}.
  • Update on‑screen iteration counter.
    | 2 s per iteration (total 10 s) |
    | 8 | Highlight convergence: draw a small gold dot at 2\sqrt{2} and fade‑out previous tangents, leaving only the curve and final point. | 2 s |
    | 9 | Pause for 2 s, then fade‑out everything. | 2 s |

Total runtime ≈ 19.5 seconds.

5. Camera Angles & Perspective

  • Static Camera: The camera remains fixed, showing the full view of the axes and curve throughout the animation. No zoom or pan is required because the default view comfortably contains all elements.

6. Additional Annotations

  • Formula Display: At the start, a Tex object shows the Newton update formula centered above the axes.
  • Iteration Counter: A Tex object in the top‑right corner updates each iteration (e.g., "Iteration 1", "Iteration 2", …).
  • Root Label: After convergence, a small label "2\sqrt{2}" appears next to the gold dot.

7. Implementation Sketch (Manim Community Edition)

from manim import *

class NewtonMethodDefault(Scene):
    def construct(self):
        # Axes
        axes = Axes(x_range=[-1, 3, 1], y_range=[-1, 3, 1],
                    axis_config={"include_numbers": True})
        axes_labels = axes.get_axis_labels(x_label="x", y_label="y")
        self.play(FadeIn(axes), FadeIn(axes_labels))

        # Function
        f = lambda x: x**2 - 2
        graph = axes.plot(f, x_range=[-1, 3], color=BLUE)
        self.play(Create(graph))

        # Newton method parameters
        x_n = 2.0
        iterations = 5
        dot_radius = 0.08
        formula = MathTex(r"x_{n+1}=x_n-\frac{f(x_n)}{f'(x_n)}").to_edge(UP)
        self.play(Write(formula))

        # Initial point
        point = Dot(axes.c2p(x_n, f(x_n)), radius=dot_radius, color=GREEN)
        self.play(FadeIn(point))

        # Iteration counter
        counter = MathTex(r"Iteration\ 0").to_corner(UR)
        self.play(Write(counter))

        for i in range(iterations):
            # Tangent line
            slope = 2 * x_n
            tangent = axes.get_tangent_line(x_n, graph, length=6, color=RED).set_style(stroke_dasharray=[6, 3])
            self.play(Create(tangent))

            # Intersection with x‑axis -> next x
            x_next = x_n - f(x_n) / slope
            intersect = Dot(axes.c2p(x_next, 0), radius=dot_radius, color=RED)
            self.play(FadeIn(intersect))

            # New point on curve
            new_point = Dot(axes.c2p(x_next, f(x_next)), radius=dot_radius, color=GREEN)
            self.play(FadeIn(new_point))

            # Update counter
            new_counter = MathTex(fr"Iteration\ {i+1}").to_corner(UR)
            self.play(Transform(counter, new_counter))

            # Prepare for next iteration
            self.remove(tangent, intersect)
            point = new_point
            x_n = x_next

        # Show true root
        root_dot = Dot(axes.c2p(np.sqrt(2), 0), radius=0.12, color=GOLD)
        root_label = MathTex(r"\sqrt{2}").next_to(root_dot, DOWN)
        self.play(FadeIn(root_dot), Write(root_label))
        self.wait(2)
        self.play(FadeOut(VGroup(*self.mobjects)))

8. Summary

This specification uses sensible defaults to illustrate Newton's method on f(x)=x22f(x)=x^2-2 starting from x0=2x_0=2 over five iterations. The visual style, timing, and annotations are chosen to make the convergence process intuitive and engaging.

Created By

Kang Liang (tiga)Kang Liang (tiga)

Description

An animation of Newton's method applied to f(x)=x²‑2. Starting from x₀=2, the curve, tangent lines, and successive points are shown for five iterations, converging to the true root √2. The axes, formula, iteration counter, and a gold marker highlight the process, using blue, red, green, and gold colors to illustrate each step.

Created At

Dec 25, 2025, 06:58 AM

Tags

newton-methodroot-findingcalculusnumerical-methodsmanim

Status

Completed
AI Model
openai/gpt-oss-120b