ManimBench Easy
Prompt
====================================================================== 1. FIDELITY TO THE GIVEN SOLUTION ====================================================================== - Follow the official solution's logic, notation and final result exactly. Do not re-derive, "improve", or change any step, constant or number. - If the solution offers several approaches, pick ONE and name it in the header comment. - If the solution is an order-of-magnitude estimate, visualize scalings and regimes; never present false precision. - Every equation, claim and number shown on screen must trace back to the solution text. ====================================================================== 2. INTERACTIVE, THINK-FIRST STYLE (REQUIRED) ====================================================================== Make the viewer participate rather than watch: - At least 3 "PAUSE & PREDICT" moments: show a short question in a highlighted box (e.g. "Which way does the upper friction force point at t = 0?"), self.wait(4), then reveal the answer and tie it to the solution. - Progressive disclosure: build each key equation term-by-term (Write in parts, TransformMatchingTex, ReplacementTransform), never one wall of symbols. - Link math to picture: when a term appears in an equation, Indicate / Circumscribe the matching element in the diagram. Use ONE consistent colour per physical quantity across diagram AND equations (tex_to_color_map or set_color_by_tex). - Make the physics live: use ValueTracker + always_redraw / add_updater so objects move according to the solution's equations. Compute any trajectory or curve in code with numpy from the governing equations (vectorized or a short RK4/Euler loop). Never hand-type a list of positions or fake motion with hardcoded shifts. - Where the result depends on a parameter, include a short "what if" sweep: animate a ValueTracker over the parameter with the on-screen value/curve updating. - After each major step: a one-line checkpoint recap. At the end: a 2–3 line summary of the key insight and the final answer in a box. ====================================================================== 3. STRUCTURE ====================================================================== A. Title card: problem statement (long text split into multiple Text lines in a VGroup, scaled to fit). self.wait(5). FadeOut everything. B. Setup: build the physical picture with labels. Persistent diagram stays on the LEFT (~40% of frame width) for the whole walkthrough; all math goes on the RIGHT. C. Walkthrough: one idea per screen, interleaved with PAUSE & PREDICT moments. D. Live simulation / parameter sweep (the "aha" visual). E. Final answer + takeaway. Pacing (minimum): wait(2) after every new equation or text line; wait(3) after each major step; wait(4) during each prediction prompt; wait(5) on the final answer. Target total length: 2–4 minutes. Quality over brevity. ====================================================================== 4. LAYOUT RULES (THESE PREVENT MOST VISUAL BUGS) ====================================================================== - Max 3 equations / text lines visible at once on the right side. Start every new idea by fading out the previous right-side group (or self.play(FadeOut(*self.mobjects)) for a full reset). Never let content pile up. - Position objects BEFORE animating their creation. Build diagrams as a VGroup, then .center() / .to_edge() the group. Never move a parent after labels are attached. - Cap sizes: right-side content .scale_to_fit_width(config.frame_width * 0.45); diagrams .scale_to_fit_height(config.frame_height * 0.6). Use .to_edge(..., buff=0.8). - Nothing may leave the frame (14.2 x 8). Nothing may overlap. ====================================================================== 5. TECHNICAL REQUIREMENTS ====================================================================== - Manim Community Edition >= 0.18 only. Imports: `from manim import *` and `import numpy as np`. No other libraries, no plugins (no manim_physics / manim_chemistry), no network calls, no external files (no ImageMobject / SVGMobject from disk), no renderer or config changes. - Exactly ONE class: `class GeneratedScene(Scene)` (ThreeDScene only if the physics is genuinely 3D). It must render with: manim -ql file.py GeneratedScene - Typography: Text(...) for prose, MathTex(r"...") for math. Never put English sentences inside MathTex; never mix the two in one object — combine with VGroup. - All LaTeX in raw strings; standard LaTeX only; no custom macros or extra packages. - Current API names only (Create, Write, FadeIn, Transform, ReplacementTransform, TransformMatchingTex, Indicate, Circumscribe, Flash, ValueTracker, always_redraw, DecimalNumber, Axes, Arrow, Vector, Dot, Line, Polygon, SurroundingRectangle). Do not use removed names (ShowCreation, TextMobject, TexMobject, GraphScene, ...). - Header comment block at the top of the file: (1) which solution approach is animated, (2) the key insight, (3) segment list with approximate timestamps, (4) the PAUSE & PREDICT questions asked. - Self-contained and deterministic (no randomness unless seeded). ====================================================================== 6. OUTPUT FORMAT ====================================================================== Return ONLY one ```python code block containing the complete file. No prose outside it. ====================================================================== PROBLEM ====================================================================== A thin equi-convex glass lens (mu = 1.5) is being placed on the top of a vessel of height h = 20 cm as shown in the figure. A luminous point source is being placed at the bottom of the vessel on the principle axis of the lens. When air is on both the sides of the lens, the image of luminous point source is found at a distance 20 cm from the lens outside the vessel. When the air inside the vessel is being replaced by a liquid of refractive index 'mu_l', the image of the same source is formed at a distance 30 cm from the lens outside the vessel. The value of 'mu_l' is (A) 10/9 (B) 20/9 (C) 15/9 (D) 12/9 FIGURE (as in the original diagram): a tall cylinder of height h filled with a medium of refractive index mu_l; the thin equiconvex lens caps the cylinder at the top (glass index mu = 1.5); the point source sits on the axis at the bottom of the cylinder, 20 cm below the lens; the image forms on the axis outside, above the lens. ====================================================================== OFFICIAL SOLUTION ====================================================================== METHOD ANIMATED: two-step paraxial calculation - first the ordinary thin-lens (lens-maker) formula to get the radius of curvature R, then the general thin-lens formula for a lens that has DIFFERENT media on its two sides to get mu_l. Given: equiconvex glass lens, mu_g = 1.5; vessel height h = 20 cm, so in BOTH parts the source is 20 cm below the lens, i.e. the object distance is u = -20 cm (sign convention: light travels upward, distances measured from the lens, real object on the incident side is negative). Radius of curvature of each face is R, with R1 = +R and R2 = -R. STEP 1 - air on both sides: find R. Thin lens in air: 1/v - 1/u = (mu_g - 1)(1/R1 - 1/R2) The image is 20 cm from the lens on the side away from the source (outside the vessel), so v = +20 cm: 1/20 - 1/(-20) = (1.5 - 1)(1/R + 1/R) 1/20 + 1/20 = 0.5 x (2/R) 1/10 = 1/R => R = 10 cm. STEP 2 - liquid inside (medium on the object side = liquid, medium on the image side = air): find mu_l. For a thin lens with refractive index mu_g whose two faces (radii R1, R2) touch media mu_1 (object side) and mu_2 (image side): mu_2/v - mu_1/u = (mu_g - mu_1)/R1 + (mu_2 - mu_g)/R2 Here mu_1 = mu_l, mu_2 = 1 (air above the lens), mu_g = 1.5, R1 = +10 cm, R2 = -10 cm, u = -20 cm and the new image is 30 cm outside, v = +30 cm: 1/30 - mu_l/(-20) = (1.5 - mu_l)/(+10) + (1 - 1.5)/(-10) 1/30 + mu_l/20 = (1.5 - mu_l)/10 + 1/20 1/30 + mu_l/20 = 3/20 - mu_l/10 mu_l(1/20 + 1/10) = 3/20 - 1/30 (3/20) mu_l = 1/5 - 1/30 = 1/6 mu_l = 20/18 = 10/9 = 1.111... FINAL ANSWER: mu_l = 10/9 ~ 1.11 => option (A). (Consistency check with mu_l = 10/9: LHS = 1/30 + 1/18 = 8/90; RHS = (1.5 - 1.111)/10 + 0.05 = 0.0389 + 0.05 = 0.0889 = 8/90.) ```markdown # Manim Physics AI Reference Guide This documentation covers the `manim_physics` library. Use this reference to generate Python code for physical simulations in Manim. ## Table of Contents 1. [Rigid Mechanics](#rigid-mechanics) 2. [Electromagnetism](#electromagnetism) 3. [Waves](#waves) 4. [Optics](#optics) --- ## Rigid Mechanics **Import:** `from manim_physics import *` To use rigid body physics, your scene **must** inherit from `SpaceScene` instead of `Scene`. ### `SpaceScene` Bases: `Scene` A scene that handles gravity and collisions using Pymunk. **Key Methods:** * **`make_rigid_body(*mobs, elasticity=0.8, density=1, friction=0.8)`** Makes the provided Mobjects move according to gravity and collisions. * `mobs`: The Mobjects to animate. * `elasticity`: Bounciness (0 to 1). * `friction`: Surface friction (0 to 1). * **`make_static_body(*mobs, elasticity=1, friction=0.8)`** Makes the provided Mobjects physical obstacles that do not move (e.g., floors, walls). * **`stop_rigidity(*mobs)`** Removes physical properties from the mobjects. **Example Usage:** ```python class TwoObjectsFalling(SpaceScene): def construct(self): circle = Circle().shift(UP) rect = Square().shift(UP * 2).rotate(PI / 4) ground = Line([-4, -3.5, 0], [4, -3.5, 0]) self.add(circle, rect, ground) # Make walls static self.make_static_body(ground) # Make objects fall and bounce self.make_rigid_body(rect, circle) self.wait(5) ``` ### `MultiPendulum` Bases: `VGroup` A multipendulum simulation. **Constructor:** `MultiPendulum(*bobs, pivot_point=array([0., 2., 0.]), rod_style={}, bob_style={}, **kwargs)` * `bobs`: Iterable of positions (e.g., `[RIGHT, LEFT]`). * `pivot_point`: The anchor point. **Methods:** * `start_swinging()`: Begins the physics simulation for the pendulum. * `end_swinging()`: Stops the simulation. ### `Pendulum` Bases: `MultiPendulum` A single pendulum. **Constructor:** `Pendulum(length=3.5, initial_theta=0.3, pivot_point=array([0., 2., 0.]), rod_style={}, bob_style={}, **kwargs)` **Example Usage:** ```python class PendulumExample(SpaceScene): def construct(self): p = Pendulum(length=3) self.add(p) self.make_rigid_body(*p.bobs) # Important: Make the bob rigid p.start_swinging() self.wait(5) ``` --- ## Electromagnetism **Import:** `from manim_physics import *` ### `Charge` Bases: `VGroup` A point charge used to generate an `ElectricField`. **Constructor:** `Charge(magnitude=1, point=array([0., 0., 0.]), add_glow=True, **kwargs)` * `magnitude`: Strength of the charge (positive or negative). * `point`: Position `np.array`. * `add_glow`: Adds visual glowing rings. ### `ElectricField` Bases: `ArrowVectorField` **Constructor:** `ElectricField(*charges, **kwargs)` * `charges`: One or more `Charge` objects. **Example Usage:** ```python class ElectricFieldExampleScene(Scene): def construct(self): charge1 = Charge(-1, LEFT + DOWN) charge2 = Charge(2, RIGHT + DOWN) field = ElectricField(charge1, charge2) self.add(charge1, charge2, field) ``` ### `Wire` Bases: `VMobject` A current-carrying wire used to generate a `MagneticField`. **Constructor:** `Wire(stroke, current=1, samples=16, **kwargs)` * `stroke`: The VMobject defining the shape (e.g., `Circle()`, `Line()`). * `current`: Magnitude of current. ### `MagneticField` Bases: `ArrowVectorField` **Constructor:** `MagneticField(*wires, **kwargs)` * `wires`: One or more `Wire` objects. **Example Usage:** ```python class MagneticFieldExample(ThreeDScene): def construct(self): wire_shape = Circle(2).rotate(PI / 2, UP) wire = Wire(wire_shape) mag_field = MagneticField(wire) self.add(wire, mag_field) ``` --- ## Waves **Import:** `from manim_physics import *` ### `LinearWave` Bases: `Surface` (3D Object) A 3D surface representing a linear wave. **Constructor:** `LinearWave(wavelength=1, period=1, amplitude=0.1, x_range=[-5, 5], y_range=[-5, 5], **kwargs)` **Methods:** * `start_wave()`: Starts the animation. * `stop_wave()`: Stops the animation. ### `RadialWave` Bases: `Surface` (3D Object) A 3D surface representing waves rippling out from specific points. **Constructor:** `RadialWave(*sources, wavelength=1, period=1, amplitude=0.1, x_range=[-5, 5], y_range=[-5, 5], **kwargs)` * `sources`: Positions (np.array) where the waves originate. **Example Usage:** ```python class RadialWaveExampleScene(ThreeDScene): def construct(self): wave = RadialWave(ORIGIN, wavelength=2) self.add(wave) wave.start_wave() self.wait() ``` ### `StandingWave` Bases: `ParametricFunction` (2D Object) A 2D line representing a standing wave. **Constructor:** `StandingWave(n=2, length=4, period=1, amplitude=1, **kwargs)` * `n`: Harmonic number (integer). **Methods:** * `start_wave()`: Starts the oscillation. --- ## Optics **Import:** `from manim_physics import *` ### `Lens` Bases: `VMobject` A lens object that refracts `Ray` objects. **Constructor:** `Lens(f, d, n=1.52, **kwargs)` * `f`: Focal length. Positive for convex, negative for concave. * `d`: Lens thickness. * `n`: Refractive index (default 1.52 for glass). ### `Ray` Bases: `Line` A light ray that can pass through lenses. **Constructor:** `Ray(start, direction, init_length=5, propagate=None, **kwargs)` * `start`: Start point `np.array`. * `direction`: Vector direction `np.array`. * `propagate`: A list of `Lens` objects to interact with (e.g., `[lens1, lens2]`). **Methods:** * `propagate(*lenses)`: Calculates the path of the ray through the provided lenses. **Example Usage:** ```python class RayExampleScene(Scene): def construct(self): lens = Lens(f=5, d=1).shift(RIGHT) # Create a ray and tell it to propagate through the lens ray = Ray(start=LEFT*5, direction=RIGHT, propagate=[lens], color=RED) self.add(lens, ray) ``` ```
Response not available
Response not available