{"id": "adaption-unified-manim-instructions_000212", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that visualizes Euler's Formula, where it starts by displaying the title \"Euler's Formula\", then moves it to the top of the screen and introduces the formula \"e^(iθ) = cos(θ) + i*sin(θ)\" in the center? Then, can you show a complex plane and illustrate an angle θ traced by a line from the origin to the edge of a circle, with a dot marking the end of the line, to demonstrate how as θ varies, the expression traces out the unit circle in the complex plane? After completing one full rotation, can you then briefly clear the screen and conclude by re-displaying only Euler's Formula at the end? The narration and explanation for each step of the animation would be added later, just provide the visual elements and the sequence of events."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulersFormula(Scene):\n def construct(self):\n title = Text(\"Euler's Formula\")\n self.play(Write(title))\n self.play(title.animate.to_edge(UP))\n self.wait(1)\n\n formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\")\n self.play(Write(formula))\n self.wait(2)\n self.play(formula.animate.scale(0.8).next_to(title, DOWN))\n\n plane = ComplexPlane(x_range=[-2, 2], y_range=[-2, 2]).add_coordinates()\n unit_circle = Circle(radius=1, color=BLUE)\n self.play(Create(plane), Create(unit_circle))\n\n theta_val = ValueTracker(0)\n\n line = always_redraw(lambda: Line(\n start=ORIGIN,\n end=[np.cos(theta_val.get_value()), np.sin(theta_val.get_value()), 0],\n color=YELLOW\n ))\n\n dot = always_redraw(lambda: Dot(\n point=[np.cos(theta_val.get_value()), np.sin(theta_val.get_value()), 0],\n color=RED\n ))\n\n arc = always_redraw(lambda: Arc(\n radius=0.5,\n start_angle=0,\n angle=theta_val.get_value(),\n color=GREEN\n ))\n\n theta_label = always_redraw(lambda: MathTex(r\"\\theta\").move_to(\n [0.7 * np.cos(theta_val.get_value() / 2), 0.7 * np.sin(theta_val.get_value() / 2), 0]\n ))\n\n trace = TracedPath(lambda: dot.get_center(), stroke_width=2, stroke_color=YELLOW)\n\n self.add(line, dot, arc, theta_label, trace)\n self.play(theta_val.animate.set_value(TAU), run_time=4, rate_func=linear)\n self.wait(1)\n\n self.clear()\n\n final_title = Text(\"Euler's Formula\")\n self.play(Write(final_title))\n self.wait()\n```"}]} {"id": "multi_act_v2_00563", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 3 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: I need to create an educational animation that explains the first part of the Fundamental Theorem of Calculus. The animation should start by showing the mathematical expression of the theorem, displaying the derivative o\n- Act 2: I would like to create an educational animation that visually demonstrates the concept of equivalent fractions. The animation should begin with a white background, and three fractions should be displayed horizontally acr\n- Act 3: I would like to see an animated educational video that illustrates the concept of a quadratic function and its derivative. The video should start with a graph of the function f(x) = x^2 on a set of blue axes that range f"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0563(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_fundamentaltheoremcalcul()\n self.clear_stage()\n self.act_2_equivalentfractions()\n self.clear_stage()\n self.act_3_quadraticderivativescene()\n\n def act_1_fundamentaltheoremcalcul(self):\n title = Text(\n \"Fundamental Theorem of Calculus, Part 1\",\n font_size=36,\n color=YELLOW\n ).to_edge(UP)\n \n formula1 = MathTex(\n r\"\\frac{d}{dx}\", r\"\\int_a^x\", r\"f(t)\", r\"\\,dt\", \"=\", r\"f(x)\",\n font_size=48,\n color=TEAL\n ).next_to(title, DOWN, buff=1.0)\n \n self.play(Write(title), run_time=2.0)\n self.play(Write(formula1), run_time=2.0)\n self.wait(1.5)\n\n # --- Step 2: Transformation Phase ---\n title2 = Text(\n \"Condition: f(x) must be continuous on [a, b]\",\n font_size=30,\n color=YELLOW\n ).to_edge(UP)\n \n formula2 = MathTex(\n r\"f(x)\", \"=\", r\"\\frac{d}{dx}\", r\"F(x)\",\n font_size=48,\n color=TEAL\n ).move_to(formula1)\n \n note = Text(\n \"F(x) is an antiderivative of f(x)\",\n font_size=28,\n color=BLUE_B\n ).next_to(formula2, DOWN, buff=0.8)\n \n self.play(\n ReplacementTransform(formula1, formula2),\n Transform(title, title2),\n run_time=2.5\n )\n self.play(FadeIn(note, shift=UP * 0.3), run_time=1.5)\n self.wait(2.0)\n\n # --- Step 3: Reinforcement Loop ---\n all_objects = VGroup(title, formula2, note)\n self.play(FadeOut(all_objects), run_time=1.5)\n self.wait(1.0)\n \n final_title = Text(\n \"Fundamental Theorem of Calculus, Part 1\",\n font_size=36,\n color=YELLOW\n ).to_edge(UP)\n \n final_formula = MathTex(\n r\"\\frac{d}{dx}\", r\"\\int_a^x\", r\"f(t)\", r\"\\,dt\", \"=\", r\"f(x)\",\n font_size=48,\n color=TEAL\n ).next_to(final_title, DOWN, buff=1.0)\n \n self.play(Write(final_title), run_time=2.0)\n self.play(Write(final_formula), run_time=2.0)\n self.wait(2.0)\n\n def act_2_equivalentfractions(self):\n self.camera.background_color = WHITE\n\n # Create fractions with large size and black color\n frac1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=72)\n frac2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=72)\n frac3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=72)\n\n # Arrange fractions horizontally with sufficient spacing for arrows\n fractions = VGroup(frac1, frac2, frac3)\n fractions.arrange(RIGHT, buff=3.0)\n\n # Create blue arrows between fractions\n arrow1 = Arrow(\n start=frac1.get_right(),\n end=frac2.get_left(),\n color=BLUE,\n buff=0.5\n )\n arrow2 = Arrow(\n start=frac2.get_right(),\n end=frac3.get_left(),\n color=BLUE,\n buff=0.5\n )\n\n # Create blue labels above arrows\n label1 = Text(\"times 2\", color=BLUE, font_size=36).next_to(arrow1, UP, buff=0.2)\n label2 = Text(\"times 4\", color=BLUE, font_size=36).next_to(arrow2, UP, buff=0.2)\n\n # Animation Sequence\n\n # 1. Write the fraction 1/2\n self.play(Write(frac1))\n\n # 2. Grow arrow from 1/2 towards 2/4 and display \"times 2\"\n self.play(GrowArrow(arrow1), Write(label1))\n\n # 3. Write the fraction 2/4\n self.play(Write(frac2))\n\n # 4. Grow arrow from 2/4 towards 4/8 and display \"times 4\"\n self.play(GrowArrow(arrow2), Write(label2))\n\n # 5. Write the fraction 4/8\n self.play(Write(frac3))\n\n # 6. Pause briefly with all elements visible\n self.wait(2)\n\n # 7. Fade out the entire scene\n all_elements = VGroup(frac1, frac2, frac3, arrow1, arrow2, label1, label2)\n self.play(FadeOut(all_elements))\n\n def act_3_quadraticderivativescene(self):\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n \n # Plot f(x) = x^2 as a green curve\n func = axes.plot(lambda x: x**2, color=GREEN)\n \n # Animate elements sequentially for clarity\n self.play(Create(axes), run_time=2)\n self.play(Create(func), run_time=2)\n \n # Pause for observation\n self.wait(3)\n \n # 2. Annotation Phase\n # Yellow dashed vertical line from (1, 0) to the curve at (1, 1)\n vertical_line = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, 1), \n color=YELLOW\n )\n \n # Green label near the curve\n label = MathTex(\"x^2\", color=GREEN).next_to(func, UR, buff=0.1)\n \n # Annotate with appropriate pacing\n self.play(Create(vertical_line), run_time=1)\n self.play(Write(label), run_time=1)\n \n # Pause for observation\n self.wait(3)\n \n # 3. Derivative Visualization\n # Draw the derivative f'(x) = 2x as a purple curve\n derivative = axes.plot(lambda x: 2*x, color=PURPLE)\n \n # Animate derivative appearance\n self.play(Create(derivative), run_time=2)\n \n # Final pause to observe relationship\n self.wait(3)\n```"}]} {"id": "adaption-unified-manim-instructions_001222", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animation that visually demonstrates the process of solving a first-order linear ordinary differential equation (ODE), specifically showing the ODE y' - 3y = 0, and then methodically solving it by using an integrating factor, resulting in the general solution y(x) = Ce^(3x)? The steps should include writing down the equation, displaying text cues for each step like 'Solve the differential equation', 'Use the integrating factor', and 'General solution of the first-order ODE', following with the appropriate mathematical expressions and animations that transform one step to the next. Lastly, can you conclude the animation by clearing the screen and highlighting the general solution?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SolveODE(Scene):\n def construct(self):\n # --- Colors and Styling ---\n cue_color = BLUE_B\n highlight_color = YELLOW\n\n # --- 1. Initialization ---\n # Write down the initial equation: y' - 3y = 0\n initial_eq = MathTex(\"y' - 3y = 0\").scale(1.2)\n self.play(Write(initial_eq))\n self.wait(1)\n\n # --- 2. Step 1: Solve the differential equation ---\n cue_1 = Tex(\"Solve the differential equation\", color=cue_color).to_edge(UP)\n self.play(FadeIn(cue_1))\n self.wait(1)\n\n # --- 3. Step 2: Use the integrating factor ---\n cue_2 = Tex(\"Use the integrating factor\", color=cue_color).to_edge(UP)\n \n # Calculation of integrating factor: mu(x) = e^(integral of -3 dx)\n if_calc = MathTex(\n r\"\\mu(x) = e^{\\int -3 \\, dx} = e^{-3x}\"\n ).next_to(initial_eq, DOWN, buff=1)\n\n self.play(\n Transform(cue_1, cue_2),\n FadeIn(if_calc)\n )\n self.wait(2)\n\n # Multiply the ODE by the integrating factor\n eq_multiplied = MathTex(\"e^{-3x}(y' - 3y) = 0\").scale(1.2)\n self.play(ReplacementTransform(initial_eq, eq_multiplied))\n self.wait(1)\n\n # Transform to the derivative of the product\n eq_product_rule = MathTex(\n r\"\\frac{d}{dx}\\left( e^{-3x}y \\right) = 0\"\n ).scale(1.2)\n self.play(ReplacementTransform(eq_multiplied, eq_product_rule))\n self.wait(2)\n\n # --- 4. Step 3: General solution of the first-order ODE ---\n cue_3 = Tex(\"General solution of the first-order ODE\", color=cue_color).to_edge(UP)\n \n # Animate the integration process\n eq_integrated = MathTex(\"e^{-3x}y = C\").scale(1.2)\n self.play(\n Transform(cue_1, cue_3),\n ReplacementTransform(eq_product_rule, eq_integrated)\n )\n self.wait(2)\n\n # Transform the expression into the final result\n final_eq = MathTex(\"y(x) = Ce^{3x}\").scale(1.2)\n self.play(ReplacementTransform(eq_integrated, final_eq))\n self.wait(1)\n\n # --- 5. Conclusion ---\n # Clear the screen of intermediate steps\n self.play(\n FadeOut(cue_1),\n FadeOut(if_calc)\n )\n \n # Highlight the final general solution prominently\n self.play(\n final_eq.animate.scale(1.5).set_color(highlight_color).move_to(ORIGIN)\n )\n \n # Add a surrounding rectangle for emphasis\n box = SurroundingRectangle(final_eq, color=highlight_color, buff=MED_LARGE_BUFF)\n self.play(Create(box))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql solve_ode.py SolveODE\n```"}]} {"id": "adaption-unified-manim-instructions_002717", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Please create an educational animation that visualizes the process of integrating the function sin(x)cos(x) with respect to x. Start by showing the integral of sin(x)cos(x), then introduce the trigonometric identity that sin(2x) is equal to 2sin(x)cos(x), and use it to rewrite the integral. Perform the integration and show the result. Throughout the animation, include pauses to allow the viewer time to understand each step. After completing the integration, clear the screen and present the final integrated result again for emphasis."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSinCos(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Show the integral expression\n # ------------------------------------------------------------------\n initial_integral = MathTex(r\"\\int\", r\"\\sin(x)\", r\"\\cos(x)\", r\"\\,dx\")\n initial_integral.scale(1.2)\n \n self.play(Write(initial_integral))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 2. Identity Introduction: Show sin(2x) = 2sin(x)cos(x)\n # ------------------------------------------------------------------\n identity = MathTex(r\"\\sin(2x)\", \"=\", r\"2\", r\"\\sin(x)\", r\"\\cos(x)\")\n identity.scale(0.9)\n identity.set_color(BLUE)\n identity.next_to(initial_integral, DOWN, buff=0.75)\n \n self.play(Write(identity))\n self.wait(2)\n\n # Rearrange the identity to isolate sin(x)cos(x)\n rearranged_identity = MathTex(r\"\\sin(x)\\cos(x)\", \"=\", r\"\\frac{1}{2}\", r\"\\sin(2x)\")\n rearranged_identity.scale(0.9)\n rearranged_identity.set_color(BLUE)\n rearranged_identity.next_to(identity, DOWN, buff=0.5)\n \n self.play(Write(rearranged_identity))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 3. Rewrite Step: Use identity to rewrite the integral\n # ------------------------------------------------------------------\n rewritten_integral = MathTex(r\"\\int\", r\"\\frac{1}{2}\", r\"\\sin(2x)\", r\"\\,dx\")\n rewritten_integral.scale(1.2)\n rewritten_integral.move_to(initial_integral)\n\n # Transform the integral and fade out the identities\n self.play(\n ReplacementTransform(initial_integral, rewritten_integral),\n FadeOut(identity),\n FadeOut(rearranged_identity)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 4. Integration: Perform integration step-by-step\n # ------------------------------------------------------------------\n # Step A: Pull out the constant\n step_constant = MathTex(r\"=\", r\"\\frac{1}{2}\", r\"\\int\", r\"\\sin(2x)\", r\"\\,dx\")\n step_constant.scale(1.2)\n step_constant.next_to(rewritten_integral, DOWN, buff=0.8)\n \n self.play(Write(step_constant))\n self.wait(2)\n\n # Step B: Perform the integration\n step_antiderivative = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(\", r\"-\", r\"\\frac{1}{2}\", r\"\\cos(2x)\", r\"\\right)\", r\"+\", r\"C\"\n )\n step_antiderivative.scale(1.2)\n step_antiderivative.next_to(step_constant, DOWN, buff=0.8)\n \n self.play(Write(step_antiderivative))\n self.wait(2)\n\n # Step C: Simplify the result\n simplified_result = MathTex(r\"=\", r\"-\", r\"\\frac{1}{4}\", r\"\\cos(2x)\", r\"+\", r\"C\")\n simplified_result.scale(1.2)\n simplified_result.set_color(YELLOW)\n simplified_result.next_to(step_antiderivative, DOWN, buff=0.8)\n \n self.play(Write(simplified_result))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # 5. & 6. Pacing & Final Emphasis: Clear screen and present result\n # ------------------------------------------------------------------\n # Clear the screen to focus solely on the final result\n self.play(\n FadeOut(rewritten_integral),\n FadeOut(step_constant),\n FadeOut(step_antiderivative),\n FadeOut(simplified_result)\n )\n self.wait()\n\n # Present the final integrated result again for emphasis\n emphasized_result = MathTex(\n r\"\\int\", r\"\\sin(x)\", r\"\\cos(x)\", r\"\\,dx\", \n r\"=\", r\"-\", r\"\\frac{1}{4}\", r\"\\cos(2x)\", r\"+\", r\"C\"\n )\n emphasized_result.scale(1.5)\n emphasized_result.set_color(GREEN)\n \n self.play(Write(emphasized_result))\n self.play(Indicate(emphasized_result))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_001661", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to see an educational animation that helps visualize division of the number 5 by numbers from 1 to 5. It should show the quotient and the remainder for each division, and these calculations should be color-coded for easy understanding. Also, I want the animation to highlight the divisions by 1 and 5 with a surrounding red rectangle to emphasize that they yield no remainder. Can the background be a light cream color, and the main text in a dark grey to contrast with the background? All numbers should be large and easily readable, and please ensure a smooth transition between each division being displayed. Can the final scene gracefully fade out all elements at the end?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DivisionVisualization(Scene):\n def construct(self):\n # Set background color to light cream\n self.camera.background_color = \"#FFFDD0\"\n \n # Define color palette for clarity and contrast\n DARK_GREY = \"#333333\"\n QUOTIENT_COLOR = \"#2E86AB\" # Blue for Quotient\n REMAINDER_COLOR = \"#E94F37\" # Orange for Remainder\n HIGHLIGHT_COLOR = RED # Red for special cases\n FONT_SIZE = 72\n \n dividend_val = 5\n divisors = range(1, 6)\n \n current_equation = None\n current_rect = None\n \n for d in divisors:\n # Core Logic: Calculate quotient and remainder\n q = dividend_val // d\n r = dividend_val % d\n \n # Construct Equation Parts\n # Using individual MathTex objects allows precise color coding\n parts = [\n MathTex(str(dividend_val), color=DARK_GREY, font_size=FONT_SIZE),\n MathTex(\"\\\\div\", color=DARK_GREY, font_size=FONT_SIZE),\n MathTex(str(d), color=DARK_GREY, font_size=FONT_SIZE),\n MathTex(\"=\", color=DARK_GREY, font_size=FONT_SIZE),\n MathTex(str(q), color=QUOTIENT_COLOR, font_size=FONT_SIZE),\n MathTex(\"\\\\text{ R }\", color=DARK_GREY, font_size=FONT_SIZE),\n MathTex(str(r), color=REMAINDER_COLOR, font_size=FONT_SIZE),\n ]\n \n # Group parts and arrange horizontally\n new_equation = VGroup(*parts).arrange(RIGHT, buff=0.15)\n \n # Specific Highlight: Red rectangle for divisions by 1 and 5 (zero remainder)\n if r == 0:\n new_rect = SurroundingRectangle(new_equation, color=HIGHLIGHT_COLOR, buff=0.3, corner_radius=0.1)\n else:\n new_rect = None\n \n # Animation Flow\n if current_equation is None:\n # Initial appearance\n self.play(FadeIn(new_equation, shift=UP * 0.3), run_time=0.8)\n if new_rect:\n self.play(Create(new_rect))\n else:\n # Smooth transition between steps using FadeTransform\n self.play(FadeTransform(current_equation, new_equation))\n \n # Handle rectangle state changes\n if current_rect and new_rect:\n # Transform existing rectangle to new bounds\n self.play(Transform(current_rect, new_rect))\n elif current_rect and not new_rect:\n # Remove rectangle if no longer needed\n self.play(FadeOut(current_rect))\n elif not current_rect and new_rect:\n # Create rectangle if newly needed\n self.play(Create(new_rect))\n \n # Update state for next iteration\n current_equation = new_equation\n current_rect = new_rect\n \n # Pause for readability\n self.wait(1.5)\n \n # Conclusion: Graceful fade out of all elements\n fade_out_group = VGroup()\n if current_equation:\n fade_out_group.add(current_equation)\n if current_rect:\n fade_out_group.add(current_rect)\n \n self.play(FadeOut(fade_out_group))\n self.wait()\n```"}]} {"id": "bespoke-manim_000077", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create an educational ManimCE animation on 'Homotopy' (Unraveling the Mysteries of Knots: A Homotopy Adventure): In what ways can homotopy demonstrate the difference between knots and unknot?\nVisual style guidance: A blend of hand-drawn and digital art style, characterized by soft pastel colors and smooth transitions. Emphasizes clarity and emphasizes the complexity and beauty inherent in mathematical structures."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass HomotopyKnotsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling the Mysteries of Knots: A Homotopy Adventure\", font_size=28)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n \n # Introduction: Simple loop (unknot)\n unknot = Circle(radius=1, color=BLUE).shift(LEFT*3)\n unknot_label = Text(\"Unknot\", font_size=24).next_to(unknot, DOWN)\n \n # Simple representation of a knot using a circle with crossing lines\n knot_circle = Circle(radius=1, color=RED).shift(RIGHT*3)\n # Add a cross in the middle to suggest it's knotted\n cross1 = Line(RIGHT*2.7 + UP*0.3, RIGHT*3.3 + DOWN*0.3, color=RED)\n cross2 = Line(RIGHT*2.7 + DOWN*0.3, RIGHT*3.3 + UP*0.3, color=RED)\n knot_label = Text(\"Knot\", font_size=24).next_to(knot_circle, DOWN)\n \n self.play(Create(unknot), Write(unknot_label))\n self.wait(0.5)\n self.play(Create(knot_circle), Create(cross1), Create(cross2), Write(knot_label))\n self.wait(0.5)\n \n # Key Insight: Homotopy\n insight_text = Text(\"Homotopy: Continuous transformation without cutting\", font_size=24)\n insight_text.next_to(title, DOWN)\n \n self.play(Write(insight_text))\n self.wait(0.5)\n \n # Homotopy function\n homotopy_eq = Text(\"f: [0,1] \\times X \\rightarrow Y\", font_size=20)\n homotopy_eq.next_to(insight_text, DOWN)\n \n self.play(Write(homotopy_eq))\n self.wait(0.5)\n \n # Show non-equivalence\n arrow = Arrow(start=LEFT*1, end=RIGHT*1, color=YELLOW).move_to(DOWN*1)\n non_equiv = Text(\"\\neq \", font_size=32).next_to(arrow, UP, buff=0.2)\n \n self.play(Create(arrow), Write(non_equiv))\n self.wait(0.5)\n \n # Explanation\n explanation = Text(\"Knot groups reveal this difference\", font_size=24)\n explanation.next_to(arrow, DOWN)\n \n self.play(Write(explanation))\n self.wait(0.5)\n \n # Knot group equation\n knot_group_eq = Text(\"\\pi ₁(S^3, knot) = knot group\", font_size=20)\n knot_group_eq.next_to(explanation, DOWN)\n \n self.play(Write(knot_group_eq))\n self.wait(0.5)\n \n # Conclusion\n conclusion = Text(\"Homotopy preserves fundamental topological properties\", font_size=24)\n conclusion.next_to(knot_group_eq, DOWN)\n \n self.play(Write(conclusion))\n self.wait(1)\n \n # Final fade out\n self.play(FadeOut(title), FadeOut(insight_text), FadeOut(homotopy_eq), \n FadeOut(arrow), FadeOut(non_equiv), FadeOut(explanation), \n FadeOut(knot_group_eq), FadeOut(conclusion),\n FadeOut(unknot), FadeOut(unknot_label), FadeOut(knot_circle), \n FadeOut(cross1), FadeOut(cross2), FadeOut(knot_label))\n self.wait(0.5)\n```"}]} {"id": "adaption-unified-manim-instructions_005024", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that shows step-by-step how to solve a triple integral problem, specifically the integral of xyz over the range from -1 to 1 for all variables? The animation should include writing out the problem, followed by a series of steps and explanations for integrating with respect to each variable z, y, and x, in that order, with a delay after each major step so it's clear to the viewer. Also, include the final solution at the end and make sure the text explaining the steps is easy to read and positioned at the top of the screen."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralAnimation(Scene):\n def construct(self):\n # Define styling constants for consistency, high contrast, and readability\n HEADER_STYLE = {\"font_size\": 40, \"color\": YELLOW}\n MATH_STYLE = {\"font_size\": 44, \"color\": WHITE}\n \n # --- Introduction ---\n # Display the problem statement clearly at the top\n header = Text(\"Problem Statement\", **HEADER_STYLE).to_edge(UP)\n problem_math = MathTex(\n r\"\\int_{-1}^{1} \\int_{-1}^{1} \\int_{-1}^{1} x y z \\, dz \\, dy \\, dx\",\n **MATH_STYLE\n )\n problem_math.next_to(header, DOWN, buff=0.75)\n \n self.play(Write(header), Write(problem_math))\n self.wait(3)\n \n # --- Step 1: Integrate with respect to z ---\n new_header = Text(\"Step 1: Integrate with respect to $z$\", **HEADER_STYLE).to_edge(UP)\n \n step1_part1 = MathTex(\n r\"\\int_{-1}^{1} x y z \\, dz = x y \\left[ \\frac{z^2}{2} \\right]_{-1}^{1}\",\n **MATH_STYLE\n )\n step1_part1.next_to(new_header, DOWN, buff=0.75)\n \n step1_part2 = MathTex(\n r\"= x y \\left( \\frac{1}{2} - \\frac{1}{2} \\right) = 0\",\n **MATH_STYLE\n )\n step1_part2.next_to(step1_part1, DOWN, buff=0.5)\n \n step1_content = VGroup(step1_part1, step1_part2)\n \n self.play(Transform(header, new_header))\n self.play(FadeOut(problem_math), FadeIn(step1_content))\n self.wait(3) # Deliberate delay for clarity\n \n # --- Step 2: Integrate with respect to y ---\n new_header = Text(\"Step 2: Integrate with respect to $y$\", **HEADER_STYLE).to_edge(UP)\n \n step2_part1 = MathTex(\n r\"\\int_{-1}^{1} 0 \\, dy = \\left[ 0 \\cdot y \\right]_{-1}^{1}\",\n **MATH_STYLE\n )\n step2_part1.next_to(new_header, DOWN, buff=0.75)\n \n step2_part2 = MathTex(\n r\"= 0 - 0 = 0\",\n **MATH_STYLE\n )\n step2_part2.next_to(step2_part1, DOWN, buff=0.5)\n \n step2_content = VGroup(step2_part1, step2_part2)\n \n self.play(Transform(header, new_header))\n self.play(FadeOut(step1_content), FadeIn(step2_content))\n self.wait(3) # Deliberate delay for clarity\n \n # --- Step 3: Integrate with respect to x ---\n new_header = Text(\"Step 3: Integrate with respect to $x$\", **HEADER_STYLE).to_edge(UP)\n \n step3_part1 = MathTex(\n r\"\\int_{-1}^{1} 0 \\, dx = \\left[ 0 \\cdot x \\right]_{-1}^{1}\",\n **MATH_STYLE\n )\n step3_part1.next_to(new_header, DOWN, buff=0.75)\n \n step3_part2 = MathTex(\n r\"= 0 - 0 = 0\",\n **MATH_STYLE\n )\n step3_part2.next_to(step3_part1, DOWN, buff=0.5)\n \n step3_content = VGroup(step3_part1, step3_part2)\n \n self.play(Transform(header, new_header))\n self.play(FadeOut(step2_content), FadeIn(step3_content))\n self.wait(3) # Deliberate delay for clarity\n \n # --- Conclusion ---\n new_header = Text(\"Final Solution\", font_size=40, color=GREEN).to_edge(UP)\n \n final_math = MathTex(\n r\"\\int_{-1}^{1} \\int_{-1}^{1} \\int_{-1}^{1} x y z \\, dz \\, dy \\, dx = 0\",\n font_size=50,\n color=GREEN\n )\n final_math.next_to(new_header, DOWN, buff=0.75)\n \n # Box the final result for emphasis\n box = SurroundingRectangle(final_math, color=WHITE, buff=0.3)\n \n self.play(Transform(header, new_header))\n self.play(FadeOut(step3_content), FadeIn(final_math))\n self.play(Create(box))\n self.wait(4)\n```"}]} {"id": "adaption-unified-manim-instructions_005837", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Demonstrate transformation of equations by superimposing variables, showcasing match and substitution changes with animations."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass VariableSubstitutionScene(Scene):\n def construct(self):\n # Step 1: Define and position equations\n eq1 = MathTex(\"y\", \"=\", \"2x\", \"+\", \"3\")\n eq2 = MathTex(\"x\", \"+\", \"y\", \"=\", \"15\")\n eq1.to_edge(UP).shift(DOWN * 0.5)\n eq2.next_to(eq1, DOWN, buff=1.5)\n \n # Step 2: Apply consistent color semantics\n eq1[0].set_color(BLUE) # 'y' in Eq1\n eq2[2].set_color(BLUE) # 'y' in Eq2\n substitution_group = VGroup(eq1[2], eq1[3], eq1[4])\n substitution_group.set_color(GREEN) # '2x + 3'\n \n # Step 3: Display and Indicate the Match\n self.play(Write(eq1), Write(eq2))\n self.wait(0.5)\n self.play(\n Indicate(eq1[0], scale_factor=1.2, color=BLUE),\n Indicate(eq2[2], scale_factor=1.2, color=BLUE),\n run_time=1.5\n )\n \n # Step 4: Animate the Superimposition (Overlay & Swap)\n substitute_copy = substitution_group.copy()\n substitute_copy.set_color(GREEN)\n substitute_copy.move_to(eq2[2]) # Move directly from source to destination\n \n self.play(FadeOut(eq2[2]), FadeIn(substitute_copy), run_time=1)\n \n # Step 5: Formalize the substitution with parentheses\n new_eq2 = MathTex(\"x\", \"+\", \"(\", \"2x\", \"+\", \"3\", \")\", \"=\", \"15\")\n new_eq2.move_to(eq2)\n new_eq2[3:6].set_color(GREEN) # Maintain color continuity\n \n self.play(Transform(substitute_copy, new_eq2[3:6]), run_time=1)\n self.remove(substitute_copy)\n self.add(new_eq2)\n \n # Step 6: Final Simplification\n final_eq = MathTex(\"3x\", \"+\", \"3\", \"=\", \"15\")\n final_eq.move_to(new_eq2)\n final_eq[0].set_color(GREEN) # Lineage of x + 2x\n \n self.play(Transform(new_eq2, final_eq), run_time=1.5)\n box = SurroundingRectangle(final_eq, color=YELLOW, buff=0.3)\n self.play(Create(box))\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_002186", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here is the enhanced animation description with additional features:\n\nThe animation begins by transforming the initial text into \"animate.align_on_border\" positioned at the top of the screen, while simultaneously fading in an explanatory subtitle below it that reads \"Demonstrating border alignment with vector direction [0,1,0]\". A square appears from the left side of the screen, then smoothly moves upward to align with the top border while its color gradually shifts from blue to green to visualize the transformation. As the square reaches the top, a coordinate axis fades in to show the y-direction vector [0,1,0] as a bright red arrow pointing upward, with the mathematical notation for vector direction appearing beside it. The square then rotates 90 degrees while shrinking slightly, transforming into an upward-pointing triangle that pulses to emphasize the final aligned position before fading out, leaving only the text and coordinate axis which then gracefully fade out together. Throughout the animation, smooth easing functions are applied to all movements for a polished look, and a subtle grid background provides spatial reference."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass BorderAlignmentAnimation(Scene):\n def construct(self):\n # Create initial text\n main_text = Text(\"animate.align_on_border\").scale(1.2)\n subtitle = Text(\"Demonstrating border alignment with vector direction [0,1,0]\", font_size=24)\n subtitle.next_to(main_text, DOWN, buff=0.5)\n \n # Create square\n square = Square(color=BLUE, fill_opacity=0.8).scale(0.5).to_edge(LEFT)\n \n # Create coordinate axes and vector\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-2, 2, 1],\n x_length=6,\n y_length=4,\n axis_config={\"color\": WHITE},\n )\n vector = Arrow(start=ORIGIN, end=[0, 1, 0], color=RED, buff=0)\n vector_label = MathTex(r\"\\begin{bmatrix}0\\\\1\\\\0\\end{bmatrix}\").next_to(vector, RIGHT)\n \n # Create grid background\n grid = NumberPlane(\n x_range=[-7, 7],\n y_range=[-4, 4],\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n )\n \n # Create final triangle\n triangle = Triangle(color=GREEN, fill_opacity=0.8).scale(0.4)\n triangle.align_to(ORIGIN, UP)\n \n # Animation sequence\n self.add(grid)\n self.play(Write(main_text), FadeIn(subtitle, shift=UP))\n self.play(Create(square))\n self.play(\n square.animate.align_to(ORIGIN, UP).shift(UP * 2),\n square.animate.set_color(GREEN),\n run_time=2,\n rate_func=smooth\n )\n self.play(\n FadeIn(axes),\n GrowArrow(vector),\n Write(vector_label),\n run_time=1.5\n )\n self.play(\n Transform(square, triangle),\n Rotate(square, angle=PI/2),\n square.animate.scale(0.8),\n run_time=1.5,\n rate_func=smooth\n )\n self.play(\n triangle.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=0.8\n )\n self.play(FadeOut(triangle))\n self.play(\n FadeOut(main_text),\n FadeOut(subtitle),\n FadeOut(axes),\n FadeOut(vector),\n FadeOut(vector_label),\n run_time=1.5\n )\n```"}]} {"id": "adaption-unified-manim-instructions_007819", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you please create an educational animation using Manim that visually explains the process of evaluating a double integral in polar coordinates? Specifically, I want to show the step-by-step solution to the integral from 0 to pi for theta and from 0 to 1 for r, of the function r dr dtheta. The steps should include: writing the problem, integrating with respect to r, simplifying, then integrating with respect to theta, and finally, presenting the numerical solution. Each step should be accompanied by a text explanation and animated transitions between steps."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # Configure colors for educational clarity\n color_r = BLUE\n color_theta = GREEN\n color_result = GOLD\n\n tex_config = {\"font_size\": 42}\n text_config = {\"font_size\": 28, \"color\": YELLOW}\n\n # ------------------------------------------------------------------\n # Step 1: Problem Statement\n # ------------------------------------------------------------------\n # Define the initial integral expression\n eq1 = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r\", \n r\"\\, dr\", \n r\"\\, d\\theta\",\n **tex_config\n )\n eq1.set_color_by_tex(\"r\", color_r)\n eq1.set_color_by_tex(\"dr\", color_r)\n eq1.set_color_by_tex(\"d\\\\theta\", color_theta)\n \n title = Text(\"Evaluate the Double Integral\", **text_config).to_edge(UP)\n eq1.next_to(title, DOWN, buff=1)\n \n step1_text = Text(\"1. Problem Statement\", **text_config).next_to(eq1, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(eq1))\n self.play(Write(step1_text))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Inner Integration\n # ------------------------------------------------------------------\n # Highlight the inner integral part before transforming\n inner_box = SurroundingRectangle(eq1[1:4], color=color_r, buff=0.1)\n self.play(Create(inner_box))\n self.wait(0.5)\n\n # Transform to show antiderivative with respect to r\n eq2 = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\left[ \\frac{r^2}{2} \\right]_{0}^{1}\", \n r\"\\, d\\theta\",\n **tex_config\n )\n eq2.set_color_by_tex(\"r\", color_r)\n eq2.set_color_by_tex(\"d\\\\theta\", color_theta)\n eq2.next_to(title, DOWN, buff=1)\n\n step2_text = Text(\"2. Inner Integration (w.r.t r)\", **text_config).next_to(eq2, DOWN, buff=1)\n\n self.play(Transform(step1_text, step2_text))\n self.play(TransformMatchingTex(eq1, eq2))\n self.play(FadeOut(inner_box))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Simplification\n # ------------------------------------------------------------------\n # Evaluate the bounds for r: (1^2/2 - 0^2/2) = 1/2\n eq3 = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\frac{1}{2}\", \n r\"\\, d\\theta\",\n **tex_config\n )\n eq3.set_color_by_tex(\"d\\\\theta\", color_theta)\n eq3.set_color_by_tex(\"\\\\frac{1}{2}\", color_result)\n eq3.next_to(title, DOWN, buff=1)\n\n step3_text = Text(\"3. Simplify Inner Result\", **text_config).next_to(eq3, DOWN, buff=1)\n\n self.play(Transform(step2_text, step3_text))\n self.play(TransformMatchingTex(eq2, eq3))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Outer Integration\n # ------------------------------------------------------------------\n # Highlight the remaining integral\n outer_box = SurroundingRectangle(eq3, color=color_theta, buff=0.1)\n self.play(Create(outer_box))\n self.wait(0.5)\n\n # Integrate constant 1/2 with respect to theta\n eq4 = MathTex(\n r\"\\left[ \\frac{\\theta}{2} \\right]_{0}^{\\pi}\",\n **tex_config\n )\n eq4.set_color_by_tex(\"theta\", color_theta)\n eq4.set_color_by_tex(\"\\\\frac{1}{2}\", color_result)\n eq4.next_to(title, DOWN, buff=1)\n\n step4_text = Text(\"4. Outer Integration (w.r.t theta)\", **text_config).next_to(eq4, DOWN, buff=1)\n\n self.play(Transform(step3_text, step4_text))\n self.play(TransformMatchingTex(eq3, eq4))\n self.play(FadeOut(outer_box))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Final Solution\n # ------------------------------------------------------------------\n # Evaluate bounds for theta: (pi/2 - 0) = pi/2\n eq5 = MathTex(\n r\"\\frac{\\pi}{2}\",\n **tex_config\n )\n eq5.set_color(color_result)\n eq5.next_to(title, DOWN, buff=1)\n eq5.scale(1.5) # Emphasize the final result\n\n step5_text = Text(\"5. Final Solution\", **text_config).next_to(eq5, DOWN, buff=1)\n\n self.play(Transform(step4_text, step5_text))\n self.play(TransformMatchingTex(eq4, eq5))\n \n # Add a box around the final answer for clarity\n final_box = SurroundingRectangle(eq5, color=color_result, buff=0.2)\n self.play(Create(final_box))\n \n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_002216", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like an educational animation that begins by writing Euler's formula \"e^(ix) = cos(x) + i*sin(x)\" on the screen. Following this, can you display a sentence above explaining that Euler's formula relates complex exponentials to trigonometric functions? Then visually transform the formula to show just the real part \"cos(x) = Re{e^(ix)}\" and after a short pause, to its imaginary part \"sin(x) = Im{e^(ix)}\". Next, can the animation morph Euler's formula into its polar form representation \"e^(iθ) = cos(θ) + i*sin(θ)\"? Afterwards, I want to see a point on a circle that represents the polar form of complex numbers, along with a dashed line from the center to the point, and a small arc indicating the angle θ. Could this be accompanied by a label for θ? Finally, clear the animation and conclude by showing Euler's formula again on the screen. I would like pauses between the steps to give viewers enough time to understand each part."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass EulerFormulaAnimation(Scene):\n def construct(self):\n # --- Step 1: Write Euler's Formula ---\n euler_formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\")\n \n self.play(Write(euler_formula))\n self.wait(2)\n\n # --- Step 2: Display Explanatory Sentence ---\n explanation = Text(\n \"Euler's formula relates complex exponentials to trigonometric functions\",\n font_size=28\n )\n explanation.next_to(euler_formula, UP, buff=0.5)\n \n self.play(FadeIn(explanation))\n self.wait(3)\n\n # --- Step 3: Transform to Real Part ---\n real_part = MathTex(r\"\\cos(x) = \\text{Re}\\{e^{ix}\\}\")\n real_part.move_to(euler_formula)\n \n self.play(\n ReplacementTransform(euler_formula, real_part),\n FadeOut(explanation)\n )\n self.wait(2)\n\n # --- Step 4: Transform to Imaginary Part ---\n imag_part = MathTex(r\"\\sin(x) = \\text{Im}\\{e^{ix}\\}\")\n imag_part.move_to(real_part)\n \n self.play(ReplacementTransform(real_part, imag_part))\n self.wait(2)\n\n # --- Step 5: Morph to Polar Form (x -> \\theta ) ---\n polar_form = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\")\n polar_form.move_to(imag_part)\n \n self.play(ReplacementTransform(imag_part, polar_form))\n self.wait(2)\n\n # --- Step 6: Visualize Polar Form on Unit Circle ---\n # Move formula up to make room for the geometric representation\n self.play(polar_form.animate.to_edge(UP, buff=0.5))\n self.wait(1)\n\n # Define circle properties and shift it down\n circle_radius = 1.5\n circle_center = np.array([0, -1.5, 0])\n unit_circle = Circle(radius=circle_radius, color=BLUE)\n unit_circle.move_to(circle_center)\n\n # Define angle theta (e.g., 60 degrees)\n theta_val = PI / 3\n point_coords = circle_center + np.array([\n circle_radius * np.cos(theta_val), \n circle_radius * np.sin(theta_val), \n 0\n ])\n \n # Create geometric elements\n point_on_circle = Dot(point=point_coords, color=YELLOW)\n dashed_line = DashedLine(start=circle_center, end=point_coords, color=WHITE)\n \n angle_arc = Arc(\n radius=0.5, \n start_angle=0, \n angle=theta_val, \n color=GREEN\n )\n angle_arc.move_to(circle_center)\n \n theta_label = MathTex(r\"\\theta\", font_size=30)\n theta_label.next_to(angle_arc, RIGHT, buff=0.15)\n\n # Animate the creation of geometric elements\n self.play(Create(unit_circle))\n self.play(Create(dashed_line), GrowFromCenter(point_on_circle))\n self.play(Create(angle_arc), Write(theta_label))\n self.wait(4)\n\n # --- Step 7: Clear and Conclude ---\n self.clear()\n self.wait(1)\n\n # Conclude by redisplaying the original Euler's formula\n final_formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\")\n final_formula.scale(1.5)\n \n self.play(Write(final_formula))\n self.wait(3)\n```"}]} {"id": "manim-sft-10k_006867", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### Using Tools for Analysis\n- Briefly introduce tools such as Valgrind (Helgrind) that can automatically detect data race risks in code.\n- Understand the basic principles of deadlock detection (such as identifying circular wait conditions).\n\n## Scheduling from the Perspective of CPU and Memory Usage\n\n### CPU Utilization in top\n- In multi-core systems, a single process's CPU usage can exceed 100% (e.g., a multi-threaded program fully utilizing multiple cores).\n- Distinguish between user state time (us) and kernel state time (sy) to determine whether the program is busy with computation or system calls.\n\n\nThe context location of this section (from highest to current level):\n# Process and Thread Practices and Linux Examples\n## Practical Observations of Thread Synchronization Issues\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ThreadAnalysisAndScheduling(Scene):\n\n def construct(self):\n title = Text('Thread Analysis Tools & CPU Scheduling', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n tools_title = Text('1. Thread Analysis Tools', font_size=28, color=BLUE)\n tools_title.next_to(title_group, DOWN, buff=0.5).to_edge(LEFT, buff=1.0)\n tool1 = Text('- Valgrind (Helgrind): Detects data races', font_size=24)\n tool2 = Text('- Deadlock Detection: Identifies circular waits', font_size=24)\n tools_list = VGroup(tool1, tool2).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n tools_list.next_to(tools_title, DOWN, buff=0.3).align_to(tools_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(tools_title, run_time=0.8))\n self.play(FadeIn(tools_list, shift=RIGHT, run_time=1.0))\n node_t1 = Text('T1', font_size=20, color=YELLOW)\n node_l1 = Text('Lock A', font_size=20, color=RED)\n node_t2 = Text('T2', font_size=20, color=YELLOW)\n node_l2 = Text('Lock B', font_size=20, color=RED)\n dl_center = RIGHT * 4 + UP * 1.2\n node_t1.move_to(dl_center + LEFT * 1.5 + UP * 0.8)\n node_l1.move_to(dl_center + RIGHT * 1.5 + UP * 0.8)\n node_t2.move_to(dl_center + RIGHT * 1.5 + DOWN * 0.8)\n node_l2.move_to(dl_center + LEFT * 1.5 + DOWN * 0.8)\n a1 = Arrow(node_t1.get_right(), node_l1.get_left(), buff=0.2, max_tip_length_to_length_ratio=0.2)\n a2 = Arrow(node_l1.get_bottom(), node_t2.get_top(), buff=0.2, max_tip_length_to_length_ratio=0.2)\n a3 = Arrow(node_t2.get_left(), node_l2.get_right(), buff=0.2, max_tip_length_to_length_ratio=0.2)\n a4 = Arrow(node_l2.get_top(), node_t1.get_bottom(), buff=0.2, max_tip_length_to_length_ratio=0.2)\n dl_elements = VGroup(node_t1, node_l1, node_t2, node_l2, a1, a2, a3, a4)\n dl_box = SurroundingRectangle(dl_elements, color=GRAY, buff=0.25)\n dl_label = Text('Circular Wait', font_size=18, color=GRAY).next_to(dl_box, UP, buff=0.1)\n deadlock_group = VGroup(dl_box, dl_label, dl_elements)\n deadlock_group.to_edge(RIGHT, buff=1.0).align_to(tools_title, UP)\n self.play(FadeIn(deadlock_group, shift=LEFT, run_time=1.2))\n cpu_title = Text('2. CPU Utilization (top command)', font_size=28, color=GREEN)\n cpu_title.next_to(tools_list, DOWN, buff=0.8).align_to(tools_title, LEFT)\n cpu1 = Text('- Multi-core CPU: Single process usage can exceed 100%', font_size=24)\n cpu2 = Text('- State differentiation: user (us) vs kernel (sy)', font_size=24)\n cpu_list = VGroup(cpu1, cpu2).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n cpu_list.next_to(cpu_title, DOWN, buff=0.3).align_to(cpu_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(cpu_title, run_time=0.8))\n self.play(FadeIn(cpu_list, shift=RIGHT, run_time=1.0))\n us_val = Text('us', font_size=20)\n us_rect = SurroundingRectangle(us_val, color=ORANGE, buff=0.15)\n us_text = Text('User State\\n(Computation)', font_size=18).next_to(us_rect, RIGHT, buff=0.2)\n us_group = VGroup(us_rect, us_val, us_text)\n sy_val = Text('sy', font_size=20)\n sy_rect = SurroundingRectangle(sy_val, color=RED, buff=0.15)\n sy_text = Text\n```"}]} {"id": "manim-sft-10k_006048", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "What is the effect of varying contour shapes on the application of Rouche's Theorem when analyzing polynomial functions?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass RouchesTheorem(Scene):\n def construct(self):\n # Set background color to deep indigo\n self.camera.background_color = \"#1a1a3a\" # For older versions\n # For newer versions, you may need: config.background_color = \"#1a1a3a\"\n \n # Title\n title = Text(\"Dancing Curves: Insights from Rouche's Theorem\", font_size=32)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Introduction\n intro = Text(\"Welcome to the realm of complex analysis\", font_size=28)\n intro.to_edge(UP)\n self.play(Write(intro))\n self.wait(1)\n \n # Create a complex plane\n plane = NumberPlane(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 0.5,\n \"stroke_opacity\": 0.3\n }\n )\n \n # Add labels for the real and imaginary axes\n x_label = Text(\"Re\", font_size=20).next_to(plane.x_axis, RIGHT)\n y_label = Text(\"Im\", font_size=20).next_to(plane.y_axis, UP)\n \n self.play(Create(plane), Write(x_label), Write(y_label))\n self.wait(1)\n \n # Add the zeros of f(z) = z^3 - 1 (cube roots of unity)\n zeros = VGroup(\n Dot(plane.c2p(1, 0), color=RED),\n Dot(plane.c2p(-0.5, 0.866), color=RED),\n Dot(plane.c2p(-0.5, -0.866), color=RED)\n )\n \n self.play(FadeOut(intro))\n zeros_label = Text(\"Zeros of f(z) = z^3 - 1\", font_size=28).to_edge(UP)\n self.play(Write(zeros_label))\n self.play(Create(zeros))\n self.wait(1)\n \n # Create a circular contour\n contour = Circle(radius=2, color=YELLOW)\n \n self.play(FadeOut(zeros_label))\n contour_label = Text(\"Circular Contour\", font_size=28).to_edge(UP)\n self.play(Write(contour_label))\n self.play(Create(contour))\n self.wait(1)\n \n # Show Rouche's theorem condition\n theorem = Text(\"|g(z)| < |f(z)| for all z on C\", font_size=24).to_edge(DOWN)\n function_text = Text(\"where g(z) = 0.1z\", font_size=20).next_to(theorem, DOWN)\n self.play(Write(theorem), Write(function_text))\n self.wait(1)\n \n # Transform to ellipse\n ellipse = Ellipse(width=4, height=3, color=GREEN)\n \n self.play(FadeOut(contour_label))\n ellipse_label = Text(\"Elliptical Contour\", font_size=28).to_edge(UP)\n self.play(Write(ellipse_label))\n self.play(Transform(contour, ellipse))\n self.wait(1)\n \n # Key insight\n self.play(FadeOut(ellipse_label))\n insight = Text(\"Same number of zeros with different contours!\", font_size=28).to_edge(UP)\n self.play(Write(insight))\n \n # Highlight zeros\n self.play(zeros.animate.set_color(YELLOW))\n self.wait(0.5)\n self.play(zeros.animate.set_color(RED))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(insight))\n conclusion = Text(\"Mathematics dances on the stage of complex analysis\", font_size=24).to_edge(UP)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Fade everything out\n self.play(\n FadeOut(conclusion),\n FadeOut(theorem),\n FadeOut(function_text),\n FadeOut(plane),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(contour),\n FadeOut(zeros)\n )\n```"}]} {"id": "manim-sft-10k_001876", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "In what ways do kernel and image of a homomorphism influence the partitioning and 'folding' process of group diagrams such as quilts or tiling patterns?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass HomomorphismFoldingPatterns(Scene):\n def construct(self):\n # Title\n title = Text(\"Folding Patterns: Homomorphisms in Group Theory\", font_size=36)\n title.to_edge(UP)\n \n # Introduction\n self.play(Write(title))\n self.wait(1)\n \n # Section 1: Introducing Homomorphisms\n concept1_text = Text(\"A homomorphism preserves group operation\", font_size=28)\n concept1_text.next_to(title, DOWN, buff=1)\n \n # Homomorphism equation\n homo_eq = MathTex(r\"f(g_1 * g_2) = f(g_1) * f(g_2)\")\n homo_eq.next_to(concept1_text, DOWN, buff=0.5)\n \n self.play(Write(concept1_text))\n self.play(Write(homo_eq))\n self.wait(1)\n \n # Clear for next section\n self.play(FadeOut(concept1_text), FadeOut(homo_eq))\n \n # Section 2: Exploring Kernels and Images\n concept2_text = Text(\"Kernel and Image\", font_size=28)\n concept2_text.next_to(title, DOWN, buff=1)\n \n # Kernel and Image equations\n kernel_eq = MathTex(r\"\\text{Kernel: } \\operatorname{Ker}(f) = \\{g \\in G | f(g) = e'\\}\")\n image_eq = MathTex(r\"\\text{Image: } \\operatorname{Im}(f) = \\{f(g) | g \\in G\\}\")\n \n kernel_eq.next_to(concept2_text, DOWN, buff=0.5)\n image_eq.next_to(kernel_eq, DOWN, buff=0.5)\n \n self.play(Write(concept2_text))\n self.play(Write(kernel_eq))\n self.play(Write(image_eq))\n self.wait(1)\n \n # Visual representation of kernel and image\n g_group = VGroup()\n h_group = VGroup()\n \n # Source group (4 squares)\n for i in range(4):\n square = Square(side_length=0.5)\n if i < 2: # Kernel elements\n square.set_fill(BLUE_D, opacity=0.7)\n else:\n square.set_fill(BLUE_B, opacity=0.7)\n square.move_to([-2 + i*0.7, -2, 0])\n g_group.add(square)\n \n # Target group (2 circles)\n for i in range(2):\n circle = Circle(radius=0.25)\n circle.set_fill(RED_C, opacity=0.7)\n circle.move_to([1.5 + i*0.7, -2, 0])\n h_group.add(circle)\n \n # Arrow for the mapping\n arrow = Arrow([-0.3, -2, 0], [1, -2, 0], buff=0.1)\n \n self.play(Create(g_group), Create(h_group), Create(arrow))\n \n # Labels\n g_label = Text(\"Group G\", font_size=20).next_to(g_group, DOWN)\n h_label = Text(\"Group H\", font_size=20).next_to(h_group, DOWN)\n kernel_label = Text(\"Kernel\", font_size=16).next_to(g_group[0:2], UP)\n image_label = Text(\"Image\", font_size=16).next_to(h_group, UP)\n \n self.play(Write(g_label), Write(h_label))\n self.play(Write(kernel_label), Write(image_label))\n self.wait(1)\n \n # Clear for next section\n self.play(\n FadeOut(concept2_text), FadeOut(kernel_eq), FadeOut(image_eq),\n FadeOut(g_group), FadeOut(h_group), FadeOut(arrow),\n FadeOut(g_label), FadeOut(h_label), \n FadeOut(kernel_label), FadeOut(image_label)\n )\n \n # Section 3: Partitioning and Folding\n insight_text = Text(\"Partitioning and Folding\", font_size=28)\n insight_text.next_to(title, DOWN, buff=1)\n \n self.play(Write(insight_text))\n self.wait(1)\n \n # Create a pattern grid (2x4)\n pattern = VGroup()\n colors = [BLUE_B, BLUE_C, BLUE_D, BLUE_E]\n \n for i in range(4):\n for j in range(2):\n square = Square(side_length=0.5)\n square.set_fill(colors[(i+j) % len(colors)], opacity=0.7)\n square.move_to([i*0.6-0.9, j*0.6-2, 0])\n pattern.add(square)\n \n self.play(Create(pattern))\n self.wait(1)\n \n # Fold line\n fold_line = DashedLine(\n [0, -1.7, 0],\n [0, -2.3, 0],\n dash_length=0.1,\n stroke_width=3,\n color=YELLOW\n )\n \n fold_label = Text(\"Fold Line\", font_size=16).next_to(fold_line, UP)\n \n self.play(Create(fold_line), Write(fold_label))\n self.wait(1)\n \n # Simple representation of folding result\n folded_pattern = pattern.copy()\n folded_pattern.scale(0.6)\n folded_pattern.move_to([2.5, -2, 0])\n \n arrow = Arrow([0.5, -2, 0], [1.5, -2, 0], buff=0.1)\n \n self.play(Create(arrow), Create(folded_pattern))\n folded_label = Text(\"Folded Pattern\", font_size=16).next_to(folded_pattern, DOWN)\n self.play(Write(folded_label))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(insight_text), FadeOut(pattern), FadeOut(fold_line),\n FadeOut(fold_label), FadeOut(folded_pattern), \n FadeOut(arrow), FadeOut(folded_label)\n )\n \n conclusion_text = Text(\"Mathematical beauty in symmetry and patterns\", font_size=24)\n conclusion_text.next_to(title, DOWN, buff=1)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Final fadeout\n self.play(FadeOut(title), FadeOut(conclusion_text))\n self.wait(1)\n```"}]} {"id": "adaption-unified-manim-instructions_004643", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to have an animated video explaining the Pythagorean theorem visually. The video should start by displaying the theorem \"a^2 + b^2 = c^2\" on the screen. Then it should show a right-angled triangle and label its sides as \"a\", \"b\", and \"c\". Next to each side of the triangle, I want to see squares with the corresponding side lengths. Then the equation \"c^2 = a^2 + b^2\" should appear and the labels \"a\", \"b\", and \"c\" should move to their respective places in the equation. The areas of these squares should be highlighted with different colors to show the difference. At the end of the video, I want it to state \"Pythagorean theorem demonstrated\" as a conclusion and then clear the screen before showing the conclusion once more to reinforce the message. The animation should be engaging but simple enough for educational purposes. Can you make this for me?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- 1. Display the initial equation ---\n initial_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=60)\n self.play(Write(initial_eq))\n self.wait(1)\n self.play(FadeOut(initial_eq))\n\n # --- 2. Construct a right-angled triangle ---\n # 3-4-5 right triangle with the right angle at the origin\n p1 = [0, 0, 0]\n p2 = [3, 0, 0]\n p3 = [0, 4, 0]\n \n triangle = Polygon(p1, p2, p3, color=WHITE)\n \n # Labels for sides\n label_a = MathTex(\"a\", color=BLUE).next_to(Line(p1, p3), LEFT, buff=0.2)\n label_b = MathTex(\"b\", color=GREEN).next_to(Line(p1, p2), DOWN, buff=0.2)\n label_c = MathTex(\"c\", color=RED).next_to(Line(p2, p3), UR, buff=0.2)\n \n self.play(Create(triangle))\n self.play(Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n\n # --- 3. Construct squares on each side ---\n # Square on side b (bottom, length 3)\n sq_b = Polygon(p1, p2, [3, -3, 0], [0, -3, 0], color=GREEN)\n \n # Square on side a (left, length 4)\n sq_a = Polygon(p1, p3, [-4, 4, 0], [-4, 0, 0], color=BLUE)\n \n # Square on side c (hypotenuse, length 5)\n # Vector p2->p3 is (-3, 4). Perpendicular outward is (4, 3).\n p4 = [p3[0] + 4, p3[1] + 3, 0]\n p5 = [p2[0] + 4, p2[1] + 3, 0]\n sq_c = Polygon(p2, p3, p4, p5, color=RED)\n \n self.play(Create(sq_a), Create(sq_b), Create(sq_c))\n self.wait(1)\n\n # --- 4. Rearranged equation and label movement ---\n # Build target equation components at the top of the screen\n t_c = MathTex(\"c\", color=RED).move_to([-3, 3, 0])\n t_c2 = MathTex(\"^2\").next_to(t_c, RIGHT, buff=0.05)\n t_eq = MathTex(\"=\").next_to(t_c2, RIGHT, buff=0.3)\n t_a = MathTex(\"a\", color=BLUE).next_to(t_eq, RIGHT, buff=0.3)\n t_a2 = MathTex(\"^2\").next_to(t_a, RIGHT, buff=0.05)\n t_plus = MathTex(\"+\").next_to(t_a2, RIGHT, buff=0.3)\n t_b = MathTex(\"b\", color=GREEN).next_to(t_plus, RIGHT, buff=0.3)\n t_b2 = MathTex(\"^2\").next_to(t_b, RIGHT, buff=0.05)\n \n static_parts = VGroup(t_c2, t_eq, t_a2, t_plus, t_b2)\n \n # Animate labels moving from triangle to equation\n self.play(\n FadeIn(static_parts),\n Transform(label_c, t_c),\n Transform(label_a, t_a),\n Transform(label_b, t_b),\n run_time=2\n )\n self.wait(1)\n\n # --- 5. Highlight areas of the squares ---\n self.play(\n sq_a.animate.set_fill(BLUE, opacity=0.6),\n sq_b.animate.set_fill(GREEN, opacity=0.6),\n sq_c.animate.set_fill(RED, opacity=0.6),\n run_time=2\n )\n self.wait(2)\n\n # --- 6. Display conclusion ---\n conclusion = Text(\"Pythagorean theorem demonstrated\", font_size=42)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # --- 7. Clear screen ---\n self.clear()\n self.wait(0.5)\n\n # --- 8. Re-display conclusion to reinforce message ---\n conclusion_final = Text(\"Pythagorean theorem demonstrated\", font_size=48, color=YELLOW)\n conclusion_final.move_to(ORIGIN)\n self.play(Write(conclusion_final))\n self.wait(3)\n self.play(FadeOut(conclusion_final))\n```"}]} {"id": "multi_act_v2_00215", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 3 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: Here's an enhanced version of the animation that maintains all original features while adding significant new elements:\n- Act 2: How can I create an animation where text transitions to a new message with an upward shift, followed by a circle with a star inside it expanding so that the star moves away from the center, and then both shapes disappear\n- Act 3: Implement an animation using Manim to illustrate the concept of transformations (e.g., translation, rotation, reflection). Choose a geometric figure and show how it transforms under different transformations."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0215(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_enhancedsquaretransforma()\n self.clear_stage()\n self.act_2_textandshapeanimation()\n self.clear_stage()\n self.act_3_transformationsillustrat()\n\n def act_1_enhancedsquaretransforma(self):\n square = Square(color=WHITE, fill_opacity=0.5)\n square.set_stroke(width=5)\n \n # Add color cycle animation to the boundary\n colors = [PURPLE, TEAL, YELLOW]\n color_cycle = Succession(\n *[square.animate.set_stroke(color) for color in colors],\n rate_func=linear\n )\n self.add(square)\n self.play(color_cycle, run_time=3, rate_func=linear)\n \n # Add area formula above the square\n area_formula = MathTex(\"A = s^2\", color=WHITE).scale(0.8).to_edge(UP)\n s_value = DecimalNumber(2, num_decimal_places=1).next_to(area_formula, RIGHT)\n s_label = Tex(\"s = \").next_to(area_formula, RIGHT)\n s_group = VGroup(s_label, s_value).scale(0.8)\n formula_group = VGroup(area_formula, s_group)\n self.play(Write(formula_group))\n \n # Scale the square and update the formula\n self.play(\n square.animate.scale(1.5),\n s_value.animate.set_value(3),\n run_time=2\n )\n self.wait()\n \n # Transform to rotation matrix and rotate\n rotation_formula = MathTex(\n \"R(\\\\theta) = \\\\begin{bmatrix} \\\\cos\\\\theta & -\\\\sin\\\\theta \\\\\\\\ \\\\sin\\\\theta & \\\\cos\\\\theta \\\\end{bmatrix}\",\n color=WHITE\n ).scale(0.8).to_edge(UP)\n \n self.play(\n Transform(area_formula, rotation_formula),\n FadeOut(s_group),\n square.animate.rotate(PI/2),\n run_time=3\n )\n \n # Stop color cycle and freeze final color\n self.play(\n square.animate.set_stroke(TEAL),\n run_time=1\n )\n \n # Add explanatory text\n explanation = Tex(\"Area Scaling and Rotation Transformations\").scale(0.8)\n explanation.next_to(square, DOWN)\n self.play(FadeIn(explanation))\n \n self.wait(2)\n\n def act_2_textandshapeanimation(self):\n initial_text = Text(\"Initial Message\", font_size=48)\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # Create the new text positioned above the original\n new_text = Text(\"New Message\", font_size=48).next_to(initial_text, UP, buff=1)\n \n # Transform the text, animating both the content change and upward shift\n self.play(ReplacementTransform(initial_text, new_text))\n self.wait(0.5)\n\n # --- Step 2: Shape Expansion ---\n # Create a circle and a star\n circle = Circle(radius=1.0, color=BLUE)\n star = Star(n=5, outer_radius=0.5, color=YELLOW, fill_opacity=1)\n \n # Group and position the shapes below the text to avoid overlap\n shapes = VGroup(circle, star)\n shapes.next_to(new_text, DOWN, buff=1)\n \n # Animate the creation of the shapes\n self.play(Create(circle), FadeIn(star))\n self.wait(0.5)\n\n # Animate expansion: the circle scales up, and the star moves away from the center\n self.play(\n circle.animate.scale(2.0),\n star.animate.shift(UP * 1.5).scale(1.5),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # --- Step 3: Disappearance ---\n # Fade out both the circle and the star from the screen\n self.play(FadeOut(circle), FadeOut(star))\n self.wait(0.5)\n\n def act_3_transformationsillustrat(self):\n title = Text(\"Transformations Illustration\", font_size=24, color=YELLOW).to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # Step 1: Create a square\n square = Square(side_length=1, color=BLUE, fill_opacity=0.7)\n self.play(Create(square))\n self.wait(1)\n\n # Transformation labels\n translation_label = Text(\"Translation\").next_to(square, DOWN)\n rotation_label = Text(\"Rotation\").next_to(square, DOWN)\n reflection_label = Text(\"Reflection\").next_to(square, DOWN)\n\n # Step 2: Translate the square\n translated_square = square.copy().shift(2 * RIGHT)\n self.play(Transform(square, translated_square), Write(translation_label))\n self.wait(1)\n\n # Step 3: Rotate the square\n rotated_square = square.copy().rotate(np.pi/4)\n self.play(Transform(square, rotated_square), ReplacementTransform(translation_label, rotation_label))\n self.wait(1)\n\n # Step 4: Reflect the square\n reflected_square = square.copy().flip(UP)\n self.play(Transform(square, reflected_square), ReplacementTransform(rotation_label, reflection_label))\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_000408", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "How do complex power series exhibit different convergence properties when expanded around essential singularities as opposed to regular points?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass ComplexPowerSeriesScene(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Diving into the Kaleidoscope of Complex Power Series\", font_size=28)\n self.play(Write(title))\n self.wait()\n self.play(title.animate.to_edge(UP))\n \n # Simple kaleidoscope effect using colored shapes\n kaleidoscope = VGroup()\n for i in range(6):\n triangle = RegularPolygon(n=3, fill_opacity=0.5, \n color=interpolate_color(BLUE, RED, i/6))\n triangle.scale(1.2)\n triangle.rotate(i * PI/3)\n kaleidoscope.add(triangle)\n \n self.play(FadeIn(kaleidoscope))\n self.play(Rotate(kaleidoscope, angle=PI), run_time=2)\n self.play(FadeOut(kaleidoscope))\n \n # Section for regular point\n reg_point_text = Text(\"Regular Point:\", font_size=24).to_edge(LEFT).shift(UP)\n self.play(Write(reg_point_text))\n \n # Create a dot representing a regular point with a convergence circle\n dot1 = Dot(point=RIGHT*2 + UP, color=BLUE)\n circle1 = Circle(radius=1, color=GREEN).move_to(dot1)\n \n self.play(Create(dot1))\n self.play(Create(circle1))\n \n # Display the power series equation\n power_eq = MathTex(r\"f(z) = \\sum_{n=0}^{\\infty} a_n(z-c)^n\")\n power_eq.next_to(reg_point_text, DOWN).shift(RIGHT)\n self.play(Write(power_eq))\n \n # Create concentric circles to show orderly convergence\n small_circles = VGroup()\n for i in range(1, 4):\n c = Circle(radius=i*0.2, color=BLUE_C).move_to(dot1)\n small_circles.add(c)\n \n self.play(Create(small_circles))\n self.wait()\n \n # Section for essential singularity\n sing_point_text = Text(\"Essential Singularity:\", font_size=24).to_edge(LEFT).shift(DOWN*2)\n self.play(Write(sing_point_text))\n \n # Create a dot representing an essential singularity\n dot2 = Dot(point=RIGHT*2 + DOWN*2, color=RED)\n self.play(Create(dot2))\n \n # Display the Laurent series equation\n laurent_eq = MathTex(r\"f(z) = \\sum_{n=-\\infty}^{\\infty} a_n(z-c)^n\")\n laurent_eq.next_to(sing_point_text, DOWN).shift(RIGHT)\n self.play(Write(laurent_eq))\n \n # Create circles with different radii to represent erratic behavior\n c1 = Circle(radius=0.7, color=RED).move_to(dot2)\n c2 = Circle(radius=0.4, color=YELLOW).move_to(dot2)\n c3 = Circle(radius=1.0, color=ORANGE).move_to(dot2)\n \n self.play(Create(c1))\n self.play(Create(c2))\n self.play(Create(c3))\n \n # Animate the circles to visualize unpredictable behavior\n self.play(\n c1.animate.scale(1.3),\n c2.animate.scale(1.8),\n c3.animate.scale(0.6),\n run_time=2\n )\n self.wait()\n \n # Clear screen and show conclusion\n self.play(\n FadeOut(reg_point_text), FadeOut(dot1), FadeOut(circle1), FadeOut(small_circles),\n FadeOut(sing_point_text), FadeOut(dot2), FadeOut(c1), FadeOut(c2), FadeOut(c3),\n FadeOut(power_eq), FadeOut(laurent_eq), FadeOut(title)\n )\n \n conclusion = Text(\"Complex power series exhibit different convergence\\nproperties around essential singularities\", font_size=28)\n self.play(Write(conclusion))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_007535", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I want to create an animation where a piece of text transforms into the words \"ShowSubmobjectsOneByOne\" and moves to the top of the screen. After that transformation, I'd like to sequentially display three circles: one at the top center, and the other two placed diagonally below it to the left and right respectively. Once all the circles are displayed, they should all disappear at once. Can you describe how this animation would be created step-by-step or provide a script to produce it?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TextToCircles(Scene):\n def construct(self):\n # 1. Create and display initial text\n initial_text = Text(\"Transform Me\")\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # 2. Transform text into \"ShowSubmobjectsOneByOne\"\n target_text = Text(\"ShowSubmobjectsOneByOne\")\n self.play(ReplacementTransform(initial_text, target_text))\n self.wait(0.5)\n\n # 3. Move the transformed text to the top of the screen\n self.play(target_text.animate.to_edge(UP))\n self.wait(0.5)\n\n # 4. Define the three circles\n # Circle 1: Top Center (below the text)\n circle_1 = Circle(color=BLUE).shift(UP * 0.5)\n \n # Circle 2: Diagonally below to the left\n circle_2 = Circle(color=RED).shift(DOWN * 0.5 + LEFT * 2)\n \n # Circle 3: Diagonally below to the right\n circle_3 = Circle(color=GREEN).shift(DOWN * 0.5 + RIGHT * 2)\n\n # Group circles to manage them together\n circles_group = VGroup(circle_1, circle_2, circle_3)\n\n # 5. Sequentially display the circles\n self.play(Create(circle_1))\n self.play(Create(circle_2))\n self.play(Create(circle_3))\n self.wait(1)\n\n # 6. Simultaneously fade out all three circles\n self.play(FadeOut(circles_group))\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_003816", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### ORB: FAST Corner Detector + BRIEF Binary Descriptor\nCombining the extremely fast FAST detector with the BRIEF binary descriptor based on pixel pair comparisons, using Hamming distance for matching, it is two orders of magnitude faster than SIFT.\n\n\nThe context of this section (from highest to current level):\n# Feature Concepts in Traditional Computer Vision and Course Introduction (Lesson 3)\n## Other Classic Descriptors: SURF and ORB\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ORBFeatureScene(Scene):\n\n def construct(self):\n context_text = 'Lesson 3: Feature Concepts in Traditional Computer Vision'\n context = Text(context_text, font_size=20, color=GRAY)\n context.to_corner(UL)\n subtitle_text = 'Other Classic Descriptors: SURF and ORB'\n subtitle = Text(subtitle_text, font_size=24, color=BLUE_B)\n subtitle.next_to(context, DOWN, aligned_edge=LEFT)\n title = Text('ORB: FAST Corner Detector + BRIEF Binary Descriptor', font_size=32, weight=BOLD)\n title.to_edge(UP, buff=1.2)\n self.play(FadeIn(context), FadeIn(subtitle))\n self.play(Write(title))\n self.wait(0.5)\n center_dot = Dot(color=RED)\n circle = Circle(radius=0.8, color=BLUE).move_to(center_dot)\n angles = [0, PI / 4, PI / 2, 3 * PI / 4, PI, 5 * PI / 4, 3 * PI / 2, 7 * PI / 4]\n points = [Dot(circle.point_at_angle(a), color=YELLOW, radius=0.06) for a in angles]\n fast_vis = VGroup(circle, center_dot, *points)\n fast_label = Text('FAST Detector', font_size=24, color=BLUE).next_to(fast_vis, DOWN)\n fast_desc = Text('(Extremely Fast)', font_size=18, color=GRAY).next_to(fast_label, DOWN, buff=0.1)\n fast_group = VGroup(fast_vis, fast_label, fast_desc).move_to(LEFT * 3.5 + UP * 0.3)\n patch = Square(side_length=1.6, color=GREEN)\n p1 = Dot(patch.get_center() + UL * 0.4, radius=0.05, color=WHITE)\n p2 = Dot(patch.get_center() + DR * 0.3, radius=0.05, color=WHITE)\n l1 = Line(p1, p2, color=WHITE, stroke_width=2)\n p3 = Dot(patch.get_center() + UR * 0.5, radius=0.05, color=WHITE)\n p4 = Dot(patch.get_center() + DL * 0.3, radius=0.05, color=WHITE)\n l2 = Line(p3, p4, color=WHITE, stroke_width=2)\n brief_vis = VGroup(patch, p1, p2, l1, p3, p4, l2)\n brief_label = Text('BRIEF Descriptor', font_size=24, color=GREEN).next_to(brief_vis, DOWN)\n brief_desc = Text('(Binary / Pixel Pairs)', font_size=18, color=GRAY).next_to(brief_label, DOWN, buff=0.1)\n brief_group = VGroup(brief_vis, brief_label, brief_desc).move_to(RIGHT * 3.5 + UP * 0.3)\n plus = MathTex('+', font_size=64).move_to(UP * 0.3)\n self.play(Create(fast_vis), Write(fast_label), FadeIn(fast_desc))\n self.play(Write(plus))\n self.play(Create(brief_vis), Write(brief_label), FadeIn(brief_desc))\n self.wait(1)\n prop1 = Text('• Binary descriptor based on pixel pair comparisons', font_size=24, t2c={'Binary descriptor': GREEN, 'pixel pair': BLUE_B})\n prop2 = Text('• Uses Hamming distance for matching', font_size=24, t2c={'Hamming distance': YELLOW})\n prop3 = Text('• Two orders of magnitude faster than SIFT', font_size=24, t2c={'Two orders of magnitude faster': RED})\n props = VGroup(prop1, prop2, prop3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n props_box = SurroundingRectangle(props, color=WHITE, buff=0.4, corner_radius=0.2)\n props_group = VGroup(props_box, props).move_to(DOWN * 2.4)\n self.play(Create(props_box))\n for prop in props:\n self.play(Write(prop), run_time=0.8)\n else:\n pass\n self.wait(2)\n```"}]} {"id": "manim-sft-10k_001803", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\nIt is recommended to first simulate the recursive expansion process on paper with a small dataset (e.g., n=3) to verify the logic before writing the code.\n\n## Comparison of Recursion and Iteration\n\nRecursion and iteration (loops) are theoretically equivalent, but they have their own advantages and disadvantages in practical engineering applications. When choosing between them, one must balance code readability and system resource consumption.\n\n\nThe context location of this section (from highest level to current):\n# Recursion and Problem Solving — Course Notes\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass RecursionVsIteration(Scene):\n\n def construct(self):\n title = Text('Recursion vs Iteration', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n sim_text = Text('1. Simulate Expansion on Paper (e.g., n=3)', font_size=28, color=BLUE)\n sim_text.next_to(title_group, DOWN, buff=0.6).to_edge(LEFT, buff=1.0)\n self.play(Write(sim_text, run_time=1))\n node3 = MathTex('f(3)', font_size=36)\n node2 = MathTex('f(2)', font_size=36)\n node1 = MathTex('f(1)', font_size=36)\n nodes = VGroup(node3, node2, node1).arrange(RIGHT, buff=1.5)\n nodes.next_to(sim_text, DOWN, buff=0.4).shift(RIGHT * 1.5)\n arrow1 = Arrow(node3.get_right(), node2.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n arrow2 = Arrow(node2.get_right(), node1.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n self.play(FadeIn(node3, shift=UP * 0.3), run_time=0.8)\n self.play(GrowArrow(arrow1), FadeIn(node2, shift=UP * 0.3), run_time=0.8)\n self.play(GrowArrow(arrow2), FadeIn(node1, shift=UP * 0.3), run_time=0.8)\n comp_text = Text('2. The Trade-off (Theoretically Equivalent)', font_size=28, color=BLUE)\n comp_text.next_to(nodes, DOWN, buff=0.8).to_edge(LEFT, buff=1.0)\n self.play(Write(comp_text, run_time=1))\n col1_title = Text('Recursion', font_size=26, color=YELLOW)\n col1_p1 = Text('+ High Readability', font_size=22, color=GREEN)\n col1_p2 = Text('- High Resource Use', font_size=22, color=RED)\n col1 = VGroup(col1_title, col1_p1, col1_p2).arrange(DOWN, buff=0.3)\n col2_title = Text('Iteration', font_size=26, color=YELLOW)\n col2_p1 = Text('+ Low Resource Use', font_size=22, color=GREEN)\n col2_p2 = Text('- Lower Readability', font_size=22, color=RED)\n col2 = VGroup(col2_title, col2_p1, col2_p2).arrange(DOWN, buff=0.3)\n cols = VGroup(col1, col2).arrange(RIGHT, buff=2.5).next_to(comp_text, DOWN, buff=0.6)\n cols.set_x(0)\n rect1 = SurroundingRectangle(col1, color=WHITE, buff=0.25)\n rect2 = SurroundingRectangle(col2, color=WHITE, buff=0.25)\n self.play(Write(col1_title), Write(col2_title), run_time=1)\n self.play(Create(rect1), Create(rect2), run_time=1)\n self.play(Write(col1_p1), Write(col2_p2), run_time=1)\n self.play(Write(col1_p2), Write(col2_p1), run_time=1)\n self.wait(0.5)\n```"}]} {"id": "adaption-unified-manim-instructions_002354", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that demonstrates the formation of an oxygen molecule by showing two oxygen atoms coming together, sharing an electron, creating a bond, and then having the entire molecule shift upwards, shrink in size, rotate, and finally disappear?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass OxygenFormation(Scene):\n def construct(self):\n self.camera.background_color = \"#1a1a1a\"\n\n # 1. Initial State: Display two individual oxygen atoms\n def create_oxygen_atom():\n nucleus = Circle(radius=0.5, color=RED, fill_opacity=0.8).set_stroke(color=WHITE, width=2)\n label = MathTex(\"O\", color=WHITE).scale(0.8)\n shell = Circle(radius=1.2, color=BLUE_A, fill_opacity=0.1).set_stroke(color=BLUE_A, width=1)\n group = VGroup(shell, nucleus, label)\n \n # Add 6 valence electrons\n electrons = VGroup()\n angles = np.linspace(0, 2 * PI, 6, endpoint=False)\n for angle in angles:\n electron = Dot(color=YELLOW, radius=0.06).move_to(\n group.get_center() + np.array([np.cos(angle), np.sin(angle), 0]) * 1.2\n )\n electrons.add(electron)\n group.add(electrons)\n return group\n\n atom_left = create_oxygen_atom().shift(LEFT * 3)\n atom_right = create_oxygen_atom().shift(RIGHT * 3)\n \n label_left = Text(\"6 Valence Electrons\", font_size=20, color=WHITE).next_to(atom_left, DOWN)\n label_right = Text(\"6 Valence Electrons\", font_size=20, color=WHITE).next_to(atom_right, DOWN)\n\n self.play(FadeIn(atom_left), FadeIn(atom_right), Write(label_left), Write(label_right))\n self.wait(1)\n\n # 2. Bond Formation\n self.play(\n atom_left.animate.shift(RIGHT * 1.5),\n atom_right.animate.shift(LEFT * 1.5),\n FadeOut(label_left),\n FadeOut(label_right),\n run_time=2\n )\n \n # Simulate electron sharing: color change for bonding electrons\n # Indices 0 and 3 are the inner electrons for each atom's VGroup\n bonding_electrons = VGroup(atom_left[3][0], atom_left[3][3], atom_right[3][0], atom_right[3][3])\n self.play(bonding_electrons.animate.set_color(GREEN), run_time=1)\n \n # Add a visual bond line indicator\n bond_line = Line(LEFT * 0.2, RIGHT * 0.2, color=WHITE, stroke_width=4).shift(UP * 0.2)\n bond_line2 = Line(LEFT * 0.2, RIGHT * 0.2, color=WHITE, stroke_width=4).shift(DOWN * 0.2)\n self.play(Create(bond_line), Create(bond_line2), run_time=1)\n \n o2_label = Text(\"O₂ Molecule (Double Covalent Bond)\", font_size=24, color=WHITE).next_to(atom_left, DOWN * 2.5)\n self.play(Write(o2_label))\n self.wait(1)\n\n # Group them for transformation sequence\n o2_molecule = VGroup(atom_left, atom_right, bond_line, bond_line2, o2_label)\n\n # 3. Transformation Sequence\n \n # Step A: Shift the entire molecule upwards\n self.play(o2_molecule.animate.shift(UP * 2), run_time=1)\n \n # Step B: Shrink the molecule in size\n self.play(o2_molecule.animate.scale(0.4), run_time=1)\n \n # Step C: Rotate the molecule\n self.play(Rotate(o2_molecule, angle=2 * PI), run_time=1.5)\n \n # Step D: Fade the molecule out until it disappears\n self.play(FadeOut(o2_molecule), run_time=1.5)\n \n self.wait(1)\n```"}]} {"id": "adaption-unified-manim-instructions_003697", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animated educational video segment that shows how to calculate the definite integral of x cubed from 0 to 2, including an explanation of the power rule for integrals, and ending with a clear presentation of the final answer?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # --- 1. Introduction of the Problem ---\n title = Text(\"Calculating a Definite Integral\", font_size=40).to_edge(UP)\n problem = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=60)\n \n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n\n # --- 2. Explaining the Power Rule ---\n # Move problem to the side to make room for the rule\n self.play(problem.animate.shift(UP * 1.5 + LEFT * 3))\n \n rule_text = Text(\"The Power Rule for Integrals:\", font_size=30).shift(UP * 1)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=45)\n rule_group = VGroup(rule_text, rule_formula).arrange(DOWN).shift(RIGHT * 3)\n\n self.play(Write(rule_text))\n self.play(Write(rule_formula))\n self.wait(2)\n\n # Highlight the application of the rule to x^3\n # n = 3, so n+1 = 4\n application = MathTex(r\"n = 3 \\implies \\frac{x^{3+1}}{3+1} = \\frac{x^4}{4}\", font_size=40)\n application.next_to(rule_formula, DOWN, buff=0.5)\n \n self.play(Write(application))\n self.wait(2)\n \n # Clear the rule explanation to focus on the calculation\n self.play(FadeOut(rule_group), FadeOut(application), FadeOut(title))\n\n # --- 3. Step-by-Step Calculation ---\n # Reset the problem to center\n self.play(problem.animate.move_to(UP * 2))\n\n # Step 1: Apply the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=60)\n step1.next_to(problem, DOWN, buff=0.5)\n \n self.play(Write(step1))\n self.wait(1)\n\n # Step 2: Substitute the limits (Upper - Lower)\n step2 = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=60)\n step2.next_to(step1, DOWN, buff=0.5)\n \n self.play(Write(step2))\n self.wait(1)\n\n # Step 3: Simplify the powers\n step3 = MathTex(r\"= \\frac{16}{4} - 0\", font_size=60)\n step3.next_to(step2, DOWN, buff=0.5)\n \n self.play(Write(step3))\n self.wait(1)\n\n # Step 4: Final numerical result\n step4 = MathTex(r\"= 4\", font_size=60, color=YELLOW)\n step4.next_to(step3, DOWN, buff=0.5)\n \n self.play(Write(step4))\n self.wait(2)\n\n # --- 4. Final Presentation ---\n # Create a box around the final answer\n final_box = SurroundingRectangle(step4, color=WHITE, buff=0.2)\n final_text = Text(\"Final Answer\", font_size=30).next_to(final_box, UP)\n\n # Fade out the intermediate steps to highlight the result\n self.play(\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n step4.animate.move_to(ORIGIN).scale(1.5),\n Create(final_box),\n Write(final_text)\n )\n \n # Final emphasis\n self.play(Indicate(step4))\n self.wait(3)\n\n# To run this code, use the command:\n# manim -pql filename.py DefiniteIntegralCalculation\n```"}]} {"id": "adaption-unified-manim-instructions_003575", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that visualizes the concept of finding the area under a curve, specifically the graph of f(x) = x^2, between the points x=0 and x=2? The animation should begin by displaying the coordinate axes with labeled x and y-axes, followed by plotting the curve f(x) = x^2. After the graph is shown, illustrate the actual area under the curve from 0 to 2 by shading it. Then, bring in the integral notation for the area we're considering at the top of the screen. Finally, step through the calculation of this definite integral, showing how to find the numerical value of the area under the curve, and then fade all elements out at the end of the animation."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n Educational animation visualizing the area under f(x) = x^2 from x=0 to x=2.\n Demonstrates setup, plotting, shading, integral notation, calculation, and cleanup.\n \"\"\"\n def construct(self):\n # 1. Setup: Display coordinate axes with clearly labeled x and y-axes\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True},\n )\n \n # Add axis labels and coordinate numbers for clarity\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n axes.add_coordinates()\n \n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # 2. Plotting: Plot the curve defined by f(x) = x^2\n # We plot slightly beyond x=2 for visual context\n curve = axes.plot(lambda x: x**2, color=YELLOW, x_range=[0, 2.5])\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\")\n \n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # 3. Shading: Illustrate the specific area under the curve from x=0 to x=2\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait(0.5)\n\n # 4. Notation: Introduce the definite integral notation at the top of the screen\n integral_text = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n \n self.play(Write(integral_text))\n self.wait(0.5)\n\n # 5. Calculation: Step through the calculation of the definite integral\n # Step 1: Find the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(integral_text, DOWN, aligned_edge=LEFT)\n \n # Step 2: Evaluate at the bounds\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(step1, DOWN, aligned_edge=LEFT)\n \n # Step 3: Final Result\n step3 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW).next_to(step2, DOWN, aligned_edge=LEFT)\n \n # Group calculation steps for easier management\n calculation_group = VGroup(step1, step2, step3)\n \n self.play(Write(step1))\n self.wait(1)\n self.play(Write(step2))\n self.wait(1)\n self.play(Write(step3))\n self.wait(2)\n\n # 6. Conclusion: Fade all elements out at the end of the animation\n all_elements = VGroup(axes, labels, curve, curve_label, area, integral_text, calculation_group)\n \n self.play(FadeOut(all_elements))\n self.wait(0.5)\n```"}]} {"id": "manim-sft-10k_002464", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "How does the Brouwer Topological Degree categorize mappings that perturb a circle into itself?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass BrouwerDegreeScene(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Unraveling the Mystery of the Brouwer Degree\", font_size=36)\n subtitle = Text(\"Mapping Circles into Themselves\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title), Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Key concept 1: Circle with a fixed point\n circle = Circle(radius=2, color=BLUE)\n point = Dot(np.array([2, 0, 0]), color=RED) # Point on circle at angle 0\n point_label = Text(\"Fixed Point\", font_size=24).next_to(point, RIGHT)\n \n self.play(Create(circle))\n self.play(Create(point), Write(point_label))\n self.wait(1)\n \n # Key concept 2: Transformation and preimages\n self.play(FadeOut(point_label))\n \n # Degree 1 mapping - rotation\n degree1_text = Text(\"Degree 1: Simple Rotation\", font_size=30).to_edge(UP)\n self.play(Write(degree1_text))\n self.play(\n Rotate(circle, angle=2*PI, run_time=2),\n Rotate(point, angle=2*PI, about_point=ORIGIN, run_time=2)\n )\n self.wait(1)\n \n # Key concept 3: Different degrees\n self.play(FadeOut(degree1_text))\n degree2_text = Text(\"Degree 2: Double Winding\", font_size=30).to_edge(UP)\n self.play(Write(degree2_text))\n \n # Make preimage visualization clearer\n # Clear previous animation\n self.play(FadeOut(circle), FadeOut(point))\n \n # Create new circle for better visualization\n new_circle = Circle(radius=2, color=BLUE)\n self.play(Create(new_circle))\n \n # Visualize preimages for degree 2 with clearer positioning\n target_point = Dot(np.array([0, 2, 0]), color=YELLOW, radius=0.15) # Point at top of circle\n target_label = Text(\"Target point\", font_size=20).next_to(target_point, UP, buff=0.2)\n \n preimage1 = Dot(np.array([1.414, 1.414, 0]), color=GREEN) # 45 degrees\n preimage2 = Dot(np.array([-1.414, 1.414, 0]), color=GREEN) # 135 degrees\n preimage_label = Text(\"Preimages\", font_size=20).to_edge(RIGHT).shift(UP)\n \n arrow1 = Arrow(preimage1.get_center(), target_point.get_center(), buff=0.1, color=GREEN)\n arrow2 = Arrow(preimage2.get_center(), target_point.get_center(), buff=0.1, color=GREEN)\n \n self.play(Create(target_point), Write(target_label))\n self.play(Create(preimage1), Create(preimage2), Write(preimage_label))\n self.play(Create(arrow1), Create(arrow2))\n \n preimage_text = Text(\"2 preimages = Degree 2\", font_size=24).next_to(degree2_text, DOWN)\n self.play(Write(preimage_text))\n self.wait(1)\n \n # Key Insight: Formula\n self.play(\n FadeOut(new_circle), FadeOut(target_point), FadeOut(target_label),\n FadeOut(preimage1), FadeOut(preimage2), FadeOut(preimage_label),\n FadeOut(arrow1), FadeOut(arrow2), FadeOut(degree2_text), \n FadeOut(preimage_text)\n )\n \n formula = MathTex(r\"\\text{deg}(f) = \\sum_{y \\in S^1} i(f, y)\")\n self.play(Write(formula))\n formula_text = Text(\"The degree counts preimages with orientation\", font_size=24)\n formula_text.next_to(formula, DOWN)\n self.play(Write(formula_text))\n self.wait(1)\n \n # Second formula\n self.play(FadeOut(formula), FadeOut(formula_text))\n formula2 = MathTex(r\"f(S^1) \\rightarrow g(S^1) \\implies \\text{deg}(f) = \\text{deg}(g)\")\n self.play(Write(formula2))\n formula2_text = Text(\"Homotopic maps have the same degree\", font_size=24)\n formula2_text.next_to(formula2, DOWN)\n self.play(Write(formula2_text))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(formula2), FadeOut(formula2_text))\n conclusion = Text(\"The Brouwer Degree categorizes\", font_size=30)\n conclusion2 = Text(\"mappings between circles\", font_size=30)\n conclusion2.next_to(conclusion, DOWN)\n self.play(Write(conclusion), Write(conclusion2))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(conclusion2))\n```"}]} {"id": "adaption-unified-manim-instructions_000751", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that explains the process of solving a simple first-order differential equation. The content should begin by showing the differential equation y' - y = 0, and then proceed to explain how to form its characteristic equation. After forming the characteristic equation, r - 1 = 0, it should demonstrate how to find the roots of this equation. Once we have the root r = 1, the animation should then present the general solution to the differential equation which is y = C e^x, where C is an arbitrary constant. Throughout the animation, it would be helpful to have written explanations that appear at the top of the screen guiding viewers through each step of the process. Lastly, the entire solution process should conclude with the final general solution displayed clearly on the screen. Can this be visualized in an animation?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SolveFirstOrderODE(Scene):\n def construct(self):\n # --- Configuration ---\n guide_color = BLUE\n highlight_color = YELLOW\n final_highlight = GREEN\n \n # --- Step 1: Initial Display ---\n guide_text = Text(\n \"Step 1: The Differential Equation\", \n font_size=32, \n color=guide_color\n ).to_edge(UP)\n \n diff_eq = MathTex(\"y' - y = 0\", font_size=60).shift(UP * 0.5)\n \n self.play(Write(guide_text))\n self.play(Write(diff_eq))\n self.wait(1.5)\n\n # --- Step 2: Characteristic Equation ---\n new_guide = Text(\n \"Step 2: Forming the Characteristic Equation\", \n font_size=32, \n color=guide_color\n ).to_edge(UP)\n \n # Explain the ansatz y = e^(rx) to justify the characteristic equation\n ansatz = MathTex(\"y = e^{rx}\", \"\\\\implies\", \"y' = r e^{rx}\", font_size=40).next_to(diff_eq, DOWN, buff=0.6)\n \n self.play(Transform(guide_text, new_guide))\n self.play(FadeIn(ansatz))\n self.wait(1.5)\n\n # Transform the differential equation into the characteristic equation\n char_eq = MathTex(\"r - 1 = 0\", font_size=60).move_to(diff_eq)\n self.play(FadeOut(ansatz), ReplacementTransform(diff_eq, char_eq))\n self.wait(1.5)\n\n # --- Step 3: Root Finding ---\n new_guide = Text(\n \"Step 3: Finding the Root\", \n font_size=32, \n color=guide_color\n ).to_edge(UP)\n \n # Solve for r and highlight the result\n root_eq = MathTex(\"r = 1\", font_size=60).move_to(diff_eq).set_color(highlight_color)\n \n self.play(Transform(guide_text, new_guide))\n self.play(ReplacementTransform(char_eq, root_eq))\n self.wait(1.5)\n\n # --- Step 4: General Solution ---\n new_guide = Text(\n \"Step 4: General Solution\", \n font_size=32, \n color=guide_color\n ).to_edge(UP)\n \n # Present the general solution y = C e^x\n general_sol = MathTex(\"y = C e^{x}\", font_size=60).move_to(diff_eq)\n constant_note = Text(\"where C is an arbitrary constant\", font_size=28).next_to(general_sol, DOWN, buff=0.5)\n \n self.play(Transform(guide_text, new_guide))\n self.play(ReplacementTransform(root_eq, general_sol))\n self.play(Write(constant_note))\n self.wait(2)\n\n # --- Step 5: Conclusion ---\n new_guide = Text(\n \"Conclusion: Final General Solution\", \n font_size=32, \n color=final_highlight\n ).to_edge(UP)\n \n # Highlight the final solution with a surrounding box\n box = SurroundingRectangle(general_sol, color=final_highlight, buff=0.3)\n \n self.play(Transform(guide_text, new_guide))\n self.play(FadeOut(constant_note))\n self.play(\n general_sol.animate.scale(1.2).set_color(final_highlight),\n Create(box)\n )\n self.wait(3)\n\n# To run this animation:\n# manim -pql your_filename.py SolveFirstOrderODE\n```"}]} {"id": "multi_act_v2_00070", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 3 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: I want an animated presentation of Euler's Formula and its transformation. Start the video by writing the phrase \"Euler's Formula:\" followed by the mathematical representation \"e^(ix) = cos(x) + isin(x)\" appearing just b\n- Act 2: Could you create an educational animation in which you graph the function y=x^2 using an x and y axes range from 0 to 4, highlight the area under the curve from x=0 to x=2, label the curve with its equation, display a st\n- Act 3: Here’s an enhanced version of the animation that retains all the original features while adding explanatory text, a mathematical formula, and a more dynamic transformation sequence:"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0070(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_eulersformulascene()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_enhancedgrowarrow()\n\n def act_1_eulersformulascene(self):\n title = Text(\"Euler's Formula:\", font_size=48)\n title.to_edge(UP)\n \n formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\", font_size=48)\n formula.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.play(Write(formula))\n self.wait(1)\n\n # --- 2. Derivation Step ---\n arrow = Arrow(\n start=formula.get_bottom() + DOWN * 0.2,\n end=formula.get_bottom() + DOWN * 1.2,\n buff=0,\n color=WHITE\n )\n \n derived_formula = MathTex(r\"\\cos(x) = \\frac{e^{ix} + e^{-ix}}{2}\", font_size=48)\n derived_formula.next_to(arrow, DOWN, buff=0.3)\n \n self.play(GrowArrow(arrow))\n self.play(Write(derived_formula))\n self.wait(2)\n\n # --- 3. Transition ---\n self.play(FadeOut(VGroup(title, formula, arrow, derived_formula)))\n self.wait(1)\n \n transform_title = Text(\"Euler's Formula Transformation\", font_size=48, color=YELLOW)\n transform_title.to_edge(UP)\n \n self.play(Write(transform_title))\n self.wait(1)\n\n # --- 4. Final Scene ---\n identity_title = Text(\"Euler's Identity\", font_size=48)\n identity_title.to_edge(UP)\n \n identity_eq = MathTex(r\"e^{i\\pi} + 1 = 0\", font_size=48)\n identity_eq.next_to(identity_title, DOWN, buff=0.5)\n \n self.play(ReplacementTransform(transform_title, identity_title))\n self.play(Write(identity_eq))\n self.wait(3)\n\n def act_2_areaundercurve(self):\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # 2. Function Graph\n # Plot y = x^2 in green\n graph = axes.plot(lambda x: x**2, color=GREEN, x_range=[0, 2])\n \n # Label attached directly to the curve\n label = MathTex(\"y = x^2\", color=GREEN).next_to(graph, UR, buff=0.2)\n \n # 3. Area Highlight\n # Highlight area under the curve from x=0 to x=2\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # 4. Text Elements\n # Top Statement\n top_text = Text(\"Area under y=x^2 from x=0 to x=2\", font_size=36).to_edge(UP)\n \n # Conclusion Lower-thirds Banner\n conclusion_text = Text(\"Area is 8/3\", font_size=36, color=WHITE)\n banner_rect = Rectangle(\n width=conclusion_text.width + 1, \n height=conclusion_text.height + 0.5, \n fill_color=BLACK, \n fill_opacity=0.8, \n stroke_width=0\n ).move_to(conclusion_text)\n conclusion_banner = VGroup(banner_rect, conclusion_text).to_edge(DOWN, buff=1.0)\n \n # Animation Sequence\n self.play(Create(axes))\n self.play(Write(top_text))\n self.wait(1)\n \n self.play(Create(graph), Write(label), run_time=2)\n self.wait(1)\n \n self.play(FadeIn(area))\n self.wait(1)\n \n self.play(FadeIn(conclusion_banner))\n self.wait(3)\n\n def act_3_enhancedgrowarrow(self):\n text = Text(\"GrowArrow\").to_edge(UP)\n self.play(Write(text))\n self.wait(0.5)\n\n # Add coordinate axes\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 3, 1],\n x_length=5,\n y_length=3,\n axis_config={\"color\": BLUE},\n )\n axes.to_edge(DOWN)\n self.play(Create(axes))\n self.wait(0.5)\n\n # Create explanatory text\n explanation = Text(\"The arrow represents a vector in 2D space\", font_size=24)\n explanation.next_to(text, DOWN)\n \n # Create formula\n formula = MathTex(r\"\\|\\vec{v}\\| = \\sqrt{x^2 + y^2}\", font_size=32)\n formula.next_to(axes, UP)\n\n # Grow the arrow while showing explanation and formula\n arrow = Arrow(start=axes.c2p(1, 1), end=axes.c2p(1, 1), color=YELLOW)\n self.play(\n GrowArrow(arrow),\n FadeIn(explanation),\n FadeIn(formula)\n )\n \n # Animate the arrow growing to final position\n final_arrow = Arrow(start=axes.c2p(1, 1), end=axes.c2p(4, 2), color=YELLOW)\n self.play(Transform(arrow, final_arrow))\n self.wait()\n\n # Transform arrow to dashed line\n dashed_line = DashedLine(\n start=axes.c2p(1, 1),\n end=axes.c2p(4, 2),\n color=YELLOW\n )\n self.play(\n Transform(arrow, dashed_line),\n FadeOut(explanation),\n FadeOut(formula)\n )\n self.wait(2)\n```"}]} {"id": "autoresearch-manim_000082", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a 30-second Manim scene that explains a supply-demand chart with one curve shifting. Show the initial equilibrium, animate the supply shift, and update the equilibrium point with captions."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass EconomicsSupplyDemandShiftStory(Scene):\n def construct(self):\n title = Text(\"Supply Shifts Move Market Equilibrium\", font_size=34).to_edge(UP)\n axes = Axes(x_range=[0, 10, 1], y_range=[0, 10, 1], x_length=6.6, y_length=4.8, tips=False).shift(LEFT * 0.8 + DOWN * 0.25)\n demand = axes.plot(lambda x: 8 - 0.55 * x, x_range=[1, 9], color=BLUE_D)\n supply_a = axes.plot(lambda x: 2 + 0.45 * x, x_range=[1, 9], color=ORANGE)\n supply_b = axes.plot(lambda x: 1.2 + 0.45 * x, x_range=[1, 9], color=TEAL_D)\n eq_a = Dot(axes.c2p(5.45, 5.0), color=YELLOW, radius=0.08)\n eq_b = Dot(axes.c2p(6.0, 4.7), color=GREEN_D, radius=0.08)\n demand_label = Text(\"demand\", font_size=22, color=BLUE_D).next_to(demand, UP, buff=0.15)\n supply_label = Text(\"supply\", font_size=22, color=ORANGE).next_to(supply_a, RIGHT, buff=0.15)\n shifted_label = Text(\"shifted supply\", font_size=22, color=TEAL_D).next_to(supply_b, RIGHT, buff=0.15)\n caption_a = Text(\"Start from the initial market crossing of supply and demand.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_b = Text(\"When supply shifts, the intersection moves to a new equilibrium.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_c = Text(\"The chart turns a qualitative story into a visible quantity change.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(axes), Create(demand), Create(supply_a), FadeIn(demand_label), FadeIn(supply_label), FadeIn(eq_a), FadeIn(caption_a), run_time=5)\n self.play(ReplacementTransform(supply_a.copy(), supply_b), FadeIn(shifted_label), ReplacementTransform(eq_a, eq_b), ReplacementTransform(caption_a, caption_b), run_time=6)\n self.play(Indicate(eq_b), ReplacementTransform(caption_b, caption_c), run_time=4)\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_008239", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animated video using math visualizations that explains the process of integrating the trigonometric function sine of x times cosine of x, demonstrates the use of the trigonometric identity sin(2x) = 2sin(x)cos(x), shows step-by-step how to solve the integral, and concludes by displaying the final solution?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSinCos(Scene):\n def construct(self):\n # --- Configuration ---\n sin_color = BLUE\n cos_color = RED\n highlight_color = YELLOW\n result_color = GREEN\n \n # --- Step 1: Visualize the Problem ---\n title = Text(\"Integrating $\\\\sin(x)\\\\cos(x)$\", font_size=36, color=BLUE_B)\n title.to_edge(UP)\n \n problem = MathTex(\n r\"\\int\", r\"\\sin(x)\", r\"\\cos(x)\", r\"\\,dx\", font_size=48\n )\n problem[1].set_color(sin_color)\n problem[2].set_color(cos_color)\n \n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n \n # Move problem up to make space for the identity\n self.play(problem.animate.shift(UP * 2))\n \n # --- Step 2: Demonstrate the Identity ---\n identity_title = Text(\"Trigonometric Identity:\", font_size=30)\n identity = MathTex(\n r\"\\sin(2x)\", \"=\", r\"2\", r\"\\sin(x)\", r\"\\cos(x)\", font_size=42\n )\n identity[0].set_color(result_color)\n identity[3].set_color(sin_color)\n identity[4].set_color(cos_color)\n \n identity_group = VGroup(identity_title, identity).arrange(DOWN, buff=0.3)\n identity_group.next_to(problem, DOWN, buff=1.0)\n \n self.play(Write(identity_group))\n self.wait(1)\n \n # Rearrange identity to isolate sin(x)cos(x)\n rearranged = MathTex(\n r\"\\sin(x)\", r\"\\cos(x)\", \"=\", r\"\\frac{1}{2}\", r\"\\sin(2x)\", font_size=42\n )\n rearranged[0].set_color(sin_color)\n rearranged[1].set_color(cos_color)\n rearranged[4].set_color(result_color)\n rearranged.move_to(identity)\n \n self.play(Transform(identity, rearranged))\n self.play(FadeOut(identity_title))\n self.wait(1)\n \n # --- Step 3: Step-by-Step Solution ---\n # Substitute the identity into the integral\n step1 = MathTex(\n r\"\\int\", r\"\\frac{1}{2}\", r\"\\sin(2x)\", r\"\\,dx\", font_size=48\n )\n step1[1].set_color(highlight_color)\n step1[2].set_color(result_color)\n step1.move_to(problem)\n \n self.play(ReplacementTransform(problem, step1), FadeOut(identity))\n self.wait(1)\n \n # Factor out the constant\n step2 = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\int\", r\"\\sin(2x)\", r\"\\,dx\", font_size=48\n )\n step2[1].set_color(highlight_color)\n step2[3].set_color(result_color)\n step2.next_to(step1, DOWN, buff=0.5)\n \n self.play(Write(step2))\n self.wait(1)\n \n # Perform the integration\n step3 = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(\", r\"-\", r\"\\frac{1}{2}\", r\"\\cos(2x)\", r\"\\right)\", r\"+ C\", font_size=48\n )\n step3[1].set_color(highlight_color)\n step3[5].set_color(result_color)\n step3.next_to(step2, DOWN, buff=0.5)\n \n self.play(Write(step3))\n self.wait(1)\n \n # --- Step 4: Final Conclusion ---\n # Simplify to the final result\n final_result = MathTex(\n r\"-\", r\"\\frac{1}{4}\", r\"\\cos(2x)\", r\"+ C\", font_size=56\n )\n final_result[2].set_color(result_color)\n \n # Transition to the final prominent display\n self.play(\n FadeOut(step1), FadeOut(step2),\n ReplacementTransform(step3, final_result)\n )\n final_result.move_to(ORIGIN)\n \n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=highlight_color, buff=0.3)\n conclusion = Text(\"Final Result\", font_size=36, color=result_color)\n conclusion.next_to(box, UP, buff=0.3)\n \n self.play(Create(box), Write(conclusion))\n self.play(Indicate(final_result))\n self.wait(2)\n\n# To render the animation, run the following command in your terminal:\n# manim -pql integrate_sin_cos.py IntegrateSinCos\n```"}]} {"id": "manim-sft-10k_006567", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### New Questions Leading to Quantum Mechanics: Further Theoretical Explanation of Stability: The Emergence of Wave-Particle Duality and the Schrödinger Equation\n\n\nThe contextual location of this section (from highest to current level):\n# The Birth of Quantum Physics\n## The Bohr Model and the Revolution in Atomic Structure\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass QuantumMechanicsTransition(Scene):\n\n def construct(self):\n context_text = Text('The Birth of Quantum Physics', font_size=32, color=BLUE)\n context_text.to_edge(UP, buff=0.3)\n chapter_text = Text('The Bohr Model and the Revolution in Atomic Structure', font_size=24, color=LIGHT_GREY)\n chapter_text.next_to(context_text, DOWN, buff=0.2)\n self.play(FadeIn(context_text, shift=DOWN), FadeIn(chapter_text, shift=DOWN))\n self.wait(0.5)\n title1 = Text('New Questions Leading to Quantum Mechanics:', font_size=36, weight=BOLD)\n title2 = Text('Further Theoretical Explanation of Stability', font_size=30)\n title3 = Text('The Emergence of Wave-Particle Duality', font_size=32, color=YELLOW)\n title4 = Text('and the Schrödinger Equation', font_size=32, color=YELLOW)\n title_group = VGroup(title1, title2, title3, title4).arrange(DOWN, buff=0.4)\n title_group.next_to(chapter_text, DOWN, buff=1)\n self.play(Write(title1))\n self.play(FadeIn(title2, shift=UP))\n self.play(Write(title3), Write(title4))\n self.wait(2.5)\n self.play(FadeOut(title_group))\n self.wait(0.5)\n wp_title = Text('Wave-Particle Duality', font_size=28, color=TEAL)\n particle = Dot(color=BLUE, radius=0.15)\n particle_label = Text('Particle', font_size=20).next_to(particle, DOWN, buff=0.3)\n particle_group = VGroup(particle, particle_label)\n arrow = DoubleArrow(start=LEFT, end=RIGHT, color=WHITE).scale(0.8)\n wave = ParametricFunction(lambda t: np.array([t, 0.4 * np.sin(4 * t), 0]), t_range=[0, 3], color=BLUE)\n wave.move_to(ORIGIN)\n wave_label = Text('Wave', font_size=20).next_to(wave, DOWN, buff=0.3)\n wave_group = VGroup(wave, wave_label)\n wp_visual = VGroup(particle_group, arrow, wave_group).arrange(RIGHT, buff=0.8)\n wp_full = VGroup(wp_title, wp_visual).arrange(DOWN, buff=0.6).shift(UP * 1)\n self.play(FadeIn(wp_title, shift=UP))\n self.play(FadeIn(particle_group), FadeIn(wave_group))\n self.play(GrowArrow(arrow))\n self.wait(1.5)\n se_title = Text('Schrödinger Equation', font_size=28, color=ORANGE)\n equation = MathTex('i\\\\hbar \\\\frac{\\\\partial}{\\\\partial t} \\\\Psi(\\\\mathbf{r}, t) = \\\\left[ -\\\\frac{\\\\hbar^2}{2m}\\\\nabla^2 + V(\\\\mathbf{r}, t) \\\\right] \\\\Psi(\\\\mathbf{r}, t)', font_size=40)\n se_full = VGroup(se_title, equation).arrange(DOWN, buff=0.5).next_to(wp_full, DOWN, buff=1)\n self.play(FadeIn(se_title, shift=UP))\n self.play(Write(equation))\n self.wait(3)\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_004443", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here’s the enhanced animation instruction, which retains the original hexagon while adding dynamic transformations, explanatory text, and a mathematical formula to deepen understanding:\n\nBegin by drawing a yellow regular hexagon with a radius of 2, centered on the screen. As the hexagon appears, simultaneously fade in a label below it reading \"Regular Hexagon\" in bold white text. Next, animate the hexagon rotating smoothly by 60 degrees to emphasize its sixfold symmetry, while a related mathematical formula (e.g., \"Interior Angle = (n-2)×180°/n = 120°\") materializes above it, typeset in a monospace font with a surrounding rectangular highlight. After a brief pause, morph the hexagon into its circumscribed circle (retaining the yellow color) with a smooth transformation, then back to the hexagon, while the formula updates to display the circle's area formula (\"Area = πr²\"). Finally, split the hexagon into six equilateral triangles radiating outward, each labeled with \"60°\" at their vertices, before reassembling them into the original hexagon. Throughout, use smooth transitions, color consistency, and synchronized text updates to reinforce the geometric concepts. The scene concludes by fading out all elements except the original hexagon, which pulses gently to draw attention."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport math\n\nclass HexagonTransformation(Scene):\n def construct(self):\n # Create a regular hexagon\n hexagon = RegularPolygon(n=6, radius=2, color=YELLOW)\n hexagon.move_to(ORIGIN)\n \n # Label for the hexagon\n hex_label = Tex(\"Regular Hexagon\", color=WHITE, font_size=36).to_edge(DOWN)\n hex_label.set_color(WHITE).set_opacity(0)\n \n # Mathematical formulas\n interior_angle_formula = MathTex(\n r\"\\text{Interior Angle} = \\frac{(n-2) \\times 180^\\circ}{n} = 120^\\circ\",\n color=WHITE,\n font_size=32\n )\n interior_angle_formula.move_to(UP * 2.5)\n formula_box = SurroundingRectangle(interior_angle_formula, color=BLUE, buff=0.2)\n formula_box.set_fill(BLUE, opacity=0.2)\n formula_group = VGroup(formula_box, interior_angle_formula)\n formula_group.set_opacity(0)\n \n area_formula = MathTex(\n r\"\\text{Area} = \\pi r^2\",\n color=WHITE,\n font_size=32\n )\n area_formula.move_to(UP * 2.5)\n area_box = SurroundingRectangle(area_formula, color=BLUE, buff=0.2)\n area_box.set_fill(BLUE, opacity=0.2)\n area_group = VGroup(area_box, area_formula)\n area_group.set_opacity(0)\n \n # Animation sequence\n self.play(\n Create(hexagon),\n FadeIn(hex_label, shift=UP*0.5),\n run_time=2\n )\n self.wait(1)\n \n # Rotate hexagon and show interior angle formula\n self.play(\n Rotate(hexagon, angle=PI/3, about_point=ORIGIN),\n FadeIn(formula_group, shift=DOWN*0.5),\n run_time=2\n )\n self.wait(2)\n \n # Morph to circle and show area formula\n circle = Circle(radius=2, color=YELLOW)\n circle.move_to(ORIGIN)\n \n self.play(\n Transform(hexagon, circle),\n FadeOut(formula_group),\n FadeIn(area_group, shift=DOWN*0.5),\n run_time=2\n )\n self.wait(2)\n \n # Morph back to hexagon\n self.play(\n Transform(hexagon, RegularPolygon(n=6, radius=2, color=YELLOW)),\n FadeOut(area_group),\n run_time=2\n )\n self.wait(1)\n \n # Split into triangles\n triangles = VGroup()\n angle_labels = VGroup()\n \n for i in range(6):\n angle = i * PI / 3\n next_angle = (i + 1) * PI / 3\n \n triangle = Polygon(\n ORIGIN,\n [2 * math.cos(angle), 2 * math.sin(angle), 0],\n [2 * math.cos(next_angle), 2 * math.sin(next_angle), 0],\n color=YELLOW,\n fill_opacity=0.5\n )\n \n angle_label = Tex(\"60°\", color=WHITE, font_size=24)\n angle_label.move_to(1.8 * np.array([math.cos(angle), math.sin(angle), 0]))\n \n triangles.add(triangle)\n angle_labels.add(angle_label)\n \n self.play(\n Transform(hexagon, triangles),\n FadeIn(angle_labels),\n run_time=2\n )\n self.wait(2)\n \n # Reassemble hexagon\n self.play(\n Transform(triangles, RegularPolygon(n=6, radius=2, color=YELLOW)),\n FadeOut(angle_labels),\n run_time=2\n )\n self.wait(1)\n \n # Fade out all except hexagon\n self.play(\n FadeOut(hex_label),\n FadeOut(triangles),\n run_time=1\n )\n \n # Pulse the hexagon\n self.play(\n hexagon.animate.scale(1.2).set_opacity(0.8),\n run_time=0.5\n )\n self.play(\n hexagon.animate.scale(1/1.2).set_opacity(1),\n run_time=0.5\n )\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_003515", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like an animated video that visualizes a simple atom model. The video should begin by fading in a blue nucleus representing eight protons and eight neutrons, labeled accordingly. Around this nucleus, electrons should orbit in two separate paths: the first orbit with two electrons and the second orbit with four electrons. The electrons themselves should be tiny red dots moving around grey elliptical paths that represent their orbits. The animation should show the electrons starting to move along these paths one after the other, with a slight delay between each electron's movement. Once all electrons are in motion, the animation should play for a short while before ending."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AtomicModel(Scene):\n def construct(self):\n # 1. Nucleus Visualization\n # Appearance: Blue sphere\n nucleus = Sphere(radius=0.5, color=BLUE, resolution=(20, 20))\n nucleus.set_shade_in_3d(True)\n \n # Composition: Label indicating 8 protons and 8 neutrons\n nucleus_label = Text(\"8 Protons\\n8 Neutrons\", font_size=24, color=WHITE)\n nucleus_label.next_to(nucleus, DOWN, buff=0.5)\n \n # Entry: Fade in at the start\n self.play(FadeIn(nucleus), Write(nucleus_label), run_time=1.5)\n self.wait(0.5)\n\n # 2. Electron Orbits\n # Structure: Two distinct grey elliptical paths\n inner_orbit = Ellipse(width=3.0, height=1.5, color=GREY, stroke_width=2)\n outer_orbit = Ellipse(width=5.5, height=2.5, color=GREY, stroke_width=2)\n \n # Tilt orbits slightly for 3D perspective\n inner_orbit.rotate(PI/6, axis=RIGHT)\n outer_orbit.rotate(PI/6, axis=RIGHT)\n \n self.play(Create(inner_orbit), Create(outer_orbit), run_time=1.0)\n\n # 3. Electrons\n # Electron Style: Tiny red dots\n # Inner Orbit: 2 electrons\n inner_electrons = [\n Dot(radius=0.08, color=RED).move_to(inner_orbit.point_from_proportion(i / 2)) \n for i in range(2)\n ]\n # Outer Orbit: 4 electrons\n outer_electrons = [\n Dot(radius=0.08, color=RED).move_to(outer_orbit.point_from_proportion(i / 4)) \n for i in range(4)\n ]\n \n # Add electrons to scene statically\n self.play(*[FadeIn(e) for e in inner_electrons + outer_electrons], run_time=0.5)\n\n # 4. Animation Sequence\n # Movement Initiation: Sequentially with slight delay\n animations = []\n for e in inner_electrons:\n animations.append(MoveAlongPath(e, inner_orbit, rate_func=linear))\n for e in outer_electrons:\n animations.append(MoveAlongPath(e, outer_orbit, rate_func=linear))\n\n # LaggedStart handles the \"one after another\" requirement while keeping \n # previous electrons in motion, avoiding a blocking sequential loop.\n self.play(LaggedStart(*animations, lag_ratio=0.15), run_time=6, rate_func=linear)\n\n # Duration: Allow animation to play for a short duration once all are in motion\n self.wait(2)\n \n # Conclude\n self.play(*[FadeOut(mob) for mob in self.mobjects], run_time=1)\n```"}]} {"id": "adaption-unified-manim-instructions_001530", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that visually explains the concept of a circle, its radius, and the formulas for its area and circumference? Start with the animation showing a circle and a line representing the radius, with a label 'r'. Then, have a text appear that explains that the area of a circle is given by the formula 'Area = πr^2'. Next, transform that text into a formula and position it at the bottom of the screen. Finally, animate a dot moving around the circumference of the circle to illustrate the concept of circumference, and conclude with the text 'Circumference = 2πr' appearing below the circle. Make sure to have pauses throughout the animation to give viewers time to understand each step."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass CircleConcepts(Scene):\n def construct(self):\n # --- 1. Circle and Radius Setup ---\n # Create the circle\n circle = Circle(radius=2, color=BLUE)\n \n # Create the radius line from center to the right edge\n center = circle.get_center()\n edge = circle.point_at_angle(0)\n radius_line = Line(center, edge, color=YELLOW)\n \n # Create the label 'r' for the radius\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n \n # Animate the creation of the circle, radius, and label\n self.play(Create(circle), Create(radius_line), Write(radius_label))\n self.wait(2) # Pause for viewer to understand the geometry\n \n # --- 2. Area Formula Sequence ---\n # Display explanatory text\n area_explanation = Text(\"The area of a circle is given by the formula:\", font_size=30).shift(UP * 2.5)\n area_formula_initial = MathTex(\"Area = \\\\pi r^2\", font_size=36).next_to(area_explanation, DOWN)\n \n self.play(Write(area_explanation))\n self.play(Write(area_formula_initial))\n self.wait(2) # Pause to read the explanation\n \n # Transform the text into a clean mathematical formula and move it to the bottom\n area_formula_final = MathTex(\"A\", \"=\", \"\\\\pi\", \"r^2\", font_size=48).to_edge(DOWN, buff=0.5)\n \n self.play(ReplacementTransform(VGroup(area_explanation, area_formula_initial), area_formula_final))\n self.wait(2) # Pause to let the formula sink in\n \n # --- 3. Circumference Sequence ---\n # Create a dot at the starting point (right edge of circle)\n dot = Dot(color=RED).move_to(edge)\n \n self.play(Create(dot))\n # Animate the dot moving along the circumference\n self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)\n self.wait(1) # Pause after the dot completes the circle\n \n # --- 4. Circumference Formula ---\n # Create the circumference formula positioned below the circle\n circ_formula = MathTex(\"Circumference\", \"=\", \"2\", \"\\\\pi\", \"r\", font_size=48)\n circ_formula.next_to(circle, DOWN, buff=0.5)\n \n self.play(Write(circ_formula))\n self.wait(3) # Final pause to review all elements\n```"}]} {"id": "adaption-unified-manim-instructions_005726", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that visually demonstrates the concept of finding the area under a curve using calculus. Specifically, I want to show a parabolic curve on a graph labelled with its equation, highlight the area between the curve and the x-axis from x=1 to x=4, and then display the integral that represents this area. After that, I would like to walk through the steps of calculating the definite integral, showing the antiderivative formula, evaluating it at the limits of integration, and finally presenting the numerical solution. Can you create an animation that accomplishes this?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. GRAPH SETUP\n # ------------------------------------------------------------------\n # Create a coordinate system. \n # x and y ranges are set to comfortably fit the curve and area.\n # Axes are shifted left to make room for the calculation steps.\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 20, 5],\n x_length=6,\n y_length=6,\n axis_config={\"include_tip\": True},\n ).shift(LEFT * 3)\n\n # Add axis labels\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n\n # Define the parabolic function f(x) = x^2\n func = lambda x: x**2\n curve = axes.plot(func, color=BLUE, x_range=[0, 4.5])\n\n # Create a label for the function equation\n curve_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^2\"), x_val=4, direction=UP)\n\n # Animate the graph setup\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. AREA HIGHLIGHTING\n # ------------------------------------------------------------------\n # Create the area object between the curve and the x-axis from x=1 to x=4\n area = axes.get_area(curve, x_range=[1, 4], color=GREEN, opacity=0.5)\n\n # Add vertical dashed lines to clearly bound the area at x=1 and x=4\n left_bound = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, func(1)), \n color=YELLOW\n )\n right_bound = DashedLine(\n start=axes.c2p(4, 0), \n end=axes.c2p(4, func(4)), \n color=YELLOW\n )\n\n # Label the limits on the x-axis\n label_1 = MathTex(\"1\").next_to(axes.c2p(1, 0), DOWN)\n label_4 = MathTex(\"4\").next_to(axes.c2p(4, 0), DOWN)\n\n # Animate the area highlighting\n self.play(\n FadeIn(area), \n Create(left_bound), \n Create(right_bound),\n Write(label_1), \n Write(label_4)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. INTEGRAL DISPLAY & STEP-BY-STEP CALCULATION\n # ------------------------------------------------------------------\n # Position the calculation text to the right of the graph\n # Step 1: The Definite Integral Expression\n integral_expr = MathTex(\n r\"\\text{Area} = \\int_{1}^{4} x^2 \\, dx\", \n color=YELLOW\n ).scale(0.9).move_to(RIGHT * 3 + UP * 2)\n\n # Step 2: Antiderivative Formula (Power Rule)\n antideriv_expr = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{4}\"\n ).scale(0.9).next_to(integral_expr, DOWN, aligned_edge=LEFT, buff=0.6)\n\n # Step 3: Evaluation at upper and lower limits\n eval_expr = MathTex(\n r\"= \\frac{4^3}{3} - \\frac{1^3}{3}\"\n ).scale(0.9).next_to(antideriv_expr, DOWN, aligned_edge=LEFT, buff=0.6)\n\n # Step 4: Arithmetic simplification\n simplification_expr = MathTex(\n r\"= \\frac{64}{3} - \\frac{1}{3}\"\n ).scale(0.9).next_to(eval_expr, DOWN, aligned_edge=LEFT, buff=0.6)\n\n # Step 5: Final numerical solution\n final_expr = MathTex(\n r\"= \\frac{63}{3} = 21\", \n color=GREEN\n ).scale(0.9).next_to(simplification_expr, DOWN, aligned_edge=LEFT, buff=0.6)\n\n # Highlight box for the final answer\n final_box = SurroundingRectangle(final_expr, color=YELLOW, buff=0.1)\n\n # Animate the solution process step-by-step\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Show antiderivative\n self.play(Write(antideriv_expr))\n self.wait(1)\n\n # Show evaluation\n self.play(Write(eval_expr))\n self.wait(1)\n\n # Show simplification\n self.play(Write(simplification_expr))\n self.wait(1)\n\n # Show final result and highlight it\n self.play(Write(final_expr))\n self.play(Create(final_box))\n self.wait(3)\n```"}]} {"id": "adaption-unified-manim-instructions_006477", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that visually explains how to use the p-test to determine the convergence of the series ∑ 1/n^2. Can you showcase the series, explain the p-test, apply the p-test to the series, conclude that the series converges based on the p-test, and finish with a clear statement confirming the series convergence?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PTestConvergence(Scene):\n def construct(self):\n # =====================================================================\n # Step 1: Showcase the Series\n # Display the mathematical notation for \\sum 1/n^2 and its first terms.\n # =====================================================================\n series_formula = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=60)\n series_expansion = MathTex(\n r\"= 1 + \\frac{1}{4} + \\frac{1}{9} + \\frac{1}{16} + \\dots\", font_size=45\n )\n series_group = VGroup(series_formula, series_expansion).arrange(DOWN, buff=0.5)\n \n self.play(Write(series_formula))\n self.wait(1)\n self.play(Write(series_expansion))\n self.wait(2)\n \n # Move the series to the top to make room for the explanation\n self.play(series_group.animate.to_edge(UP))\n \n # =====================================================================\n # Step 2: Explain the p-test\n # Visually define the p-test rule for convergence and divergence.\n # =====================================================================\n p_test_title = Text(\"The p-Series Test\", font_size=40, color=BLUE)\n p_test_title.next_to(series_group, DOWN, buff=0.8)\n \n p_test_general = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^p}\", font_size=50)\n p_test_general.next_to(p_test_title, DOWN, buff=0.5)\n \n rule_converge = MathTex(r\"\\text{Converges if } p > 1\", font_size=40, color=GREEN)\n rule_diverge = MathTex(r\"\\text{Diverges if } p \\le 1\", font_size=40, color=RED)\n \n rules_group = VGroup(rule_converge, rule_diverge).arrange(\n DOWN, aligned_edge=LEFT, buff=0.3\n )\n rules_group.next_to(p_test_general, DOWN, buff=0.5)\n \n self.play(Write(p_test_title))\n self.play(Write(p_test_general))\n self.wait(1)\n self.play(Write(rule_converge), Write(rule_diverge))\n self.wait(2)\n \n # =====================================================================\n # Step 3: Apply the p-test\n # Explicitly identify that for this series, p = 2.\n # =====================================================================\n # Highlight the 'p' in the general formula and the '2' in our series\n p_box = SurroundingRectangle(p_test_general[0][4], color=YELLOW) # Index for 'p'\n two_box = SurroundingRectangle(series_formula[0][5], color=YELLOW) # Index for '2'\n \n identification = MathTex(r\"\\text{For our series, } p = 2\", font_size=45, color=YELLOW)\n identification.to_edge(DOWN)\n \n self.play(Create(p_box), Create(two_box))\n self.play(Write(identification))\n self.wait(2)\n \n # =====================================================================\n # Step 4: Logical Deduction\n # Animate the comparison showing that since 2 > 1, the condition is met.\n # =====================================================================\n # Dim the divergence rule to focus on the convergence condition\n self.play(\n FadeOut(p_box), \n FadeOut(two_box),\n FadeOut(p_test_title),\n FadeOut(p_test_general),\n FadeOut(rule_diverge),\n rule_converge.animate.move_to(UP * 1.5),\n identification.animate.move_to(UP * 0.5),\n )\n \n comparison = MathTex(r\"2 > 1\", font_size=60, color=GREEN)\n check_mark = Tex(r\"$\\checkmark$\", font_size=60, color=GREEN).next_to(comparison, RIGHT, buff=0.3)\n comparison_group = VGroup(comparison, check_mark).move_to(DOWN * 0.5)\n \n self.play(Write(comparison))\n self.play(FadeIn(check_mark, scale=0.5))\n self.wait(2)\n \n # =====================================================================\n # Step 5: Conclusion\n # End with a clear, prominent text statement confirming convergence.\n # =====================================================================\n self.play(\n FadeOut(series_group),\n FadeOut(rule_converge),\n FadeOut(identification),\n FadeOut(comparison_group)\n )\n \n conclusion = MathTex(\n r\"\\text{The series } \\sum_{n=1}^{\\infty} \\frac{1}{n^2} \\text{ converges.}\", \n font_size=50, \n color=GREEN\n )\n conclusion_box = SurroundingRectangle(conclusion, color=GREEN, buff=MED_LARGE_BUFF)\n \n self.play(Write(conclusion))\n self.play(Create(conclusion_box))\n self.wait(3)\n```"}]} {"id": "manim-sft-10k_006064", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with five balls arranged horizontally, each with a unique color gradient (BLUE, GREEN, YELLOW, ORANGE, RED) and a subtle glow effect to make them visually distinct. A solid black floor line appears at the bottom of the screen. As the balls are introduced, a dynamic title (\"Elastic Collisions\") fades in above them, accompanied by a formula (e.g., \\( v' = \\frac{(m_1 - m_2)v_1 + 2m_2v_2}{m_1 + m_2} \\)) that briefly animates in the corner to hint at the physics involved. The balls then fall one by one, but instead of stopping at the floor, they bounce back with decreasing height (simulating energy loss), each collision producing a small shockwave effect. After all balls have bounced, they roll toward the center, where they merge into a single large ball that pulses with a wave-like distortion effect before the scene fades out. Throughout the animation, a smooth camera pan follows the motion of the balls, and a subtle background grid provides spatial reference. \n\nThis version retains the original falling motion but adds color, physics-based bouncing, formula context, merging transformations, and enhanced visual effects for a more engaging and educational experience."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedCollisionScene(Scene):\n def construct(self):\n # Setup\n colors = [BLUE, GREEN, YELLOW, ORANGE, RED]\n balls = VGroup(*[\n Circle(radius=0.3, color=color, fill_opacity=1)\n .set_color_by_gradient(color, color + WHITE)\n .set_glow_effect(0.5)\n for color in colors\n ])\n balls.arrange(RIGHT, buff=1)\n balls.shift(UP * 2)\n \n floor = Line(LEFT * 6, RIGHT * 6, color=BLACK).shift(DOWN * 2)\n \n title = Text(\"Elastic Collisions\", font_size=36).to_edge(UP)\n formula = MathTex(\n r\"v' = \\frac{(m_1 - m_2)v_1 + 2m_2v_2}{m_1 + m_2}\",\n font_size=24\n ).to_corner(UR)\n \n grid = NumberPlane(\n x_range=(-6, 6),\n y_range=(-3, 3),\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n )\n \n # Animations\n self.add(grid)\n self.play(\n FadeIn(balls),\n Create(floor),\n FadeIn(title),\n Write(formula),\n run_time=2\n )\n self.wait(1)\n \n # Bouncing balls\n for i, ball in enumerate(balls):\n self.play(\n ball.animate.shift(DOWN * (2 + i * 0.1)),\n rate_func=linear,\n run_time=0.5\n )\n for bounce in range(3):\n height = 2 - bounce * 0.6\n shockwave = Circle(radius=0.1, color=WHITE, fill_opacity=0.5).move_to(ball.get_bottom())\n self.play(\n ball.animate.shift(UP * height),\n FadeIn(shockwave, scale=3),\n rate_func=lambda t: np.abs(np.sin(t * PI)),\n run_time=0.4\n )\n self.play(\n ball.animate.shift(DOWN * height),\n FadeOut(shockwave),\n rate_func=lambda t: np.abs(np.sin(t * PI)),\n run_time=0.4\n )\n \n # Rolling to center\n self.play(\n balls.animate.arrange(RIGHT, buff=0.1).move_to(ORIGIN),\n run_time=2\n )\n \n # Merging into one ball\n merged_ball = Circle(radius=0.6, color=WHITE, fill_opacity=1)\n merged_ball.set_color_by_gradient(BLUE, RED)\n merged_ball.set_glow_effect(1.0)\n \n self.play(\n ReplacementTransform(balls, merged_ball),\n run_time=1.5\n )\n \n # Pulsing effect\n for _ in range(2):\n self.play(\n merged_ball.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=1\n )\n \n # Fade out\n self.play(\n FadeOut(merged_ball),\n FadeOut(floor),\n FadeOut(title),\n FadeOut(formula),\n run_time=1\n )\n```"}]} {"id": "multi_act_v2_00798", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 2 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: Here is the enhanced animation instruction that includes all original features plus significant new elements:\n- Act 2: I would like to create an educational animation that shows the concept of a lithium-ion moving through the grid of metal oxides in a battery, along with an electron. The animation should start with both a grid of metal o"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0798(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_enhancedheptagonanimatio()\n self.clear_stage()\n self.act_2_areabetweencurves()\n\n def act_1_enhancedheptagonanimatio(self):\n heptagon = RegularPolygon(n=7, radius=3, color=GREEN, fill_opacity=0.7)\n heptagon.move_to(ORIGIN)\n \n # Create the circumcircle\n circumcircle = Circle(radius=3, color=PURPLE, fill_opacity=0.2)\n circumcircle.move_to(ORIGIN)\n \n # Create the area formula\n formula = MathTex(\"A = \\\\frac{7}{4}r^2\\\\cot\\\\left(\\\\frac{\\\\pi}{7}\\\\right)\")\n formula.next_to(heptagon, DOWN, buff=1)\n \n # Create the starburst lines\n lines = VGroup()\n for vertex in heptagon.get_vertices():\n line = Line(vertex, vertex*2, color=WHITE, stroke_width=1)\n line.set_opacity(0.7)\n lines.add(line)\n \n # Animation sequence\n self.play(Create(heptagon))\n self.play(FadeIn(circumcircle))\n \n # Rotation and starburst animation\n self.play(\n Rotate(heptagon, angle=60*DEGREES, about_point=ORIGIN, run_time=2),\n *[Create(line) for line in lines],\n circumcircle.animate(run_time=2).set_opacity(0.3),\n rate_func=smooth,\n )\n \n # Pulsing circumcircle\n self.play(\n circumcircle.animate(run_time=1).set_opacity(0.1),\n rate_func=there_and_back\n )\n self.play(\n circumcircle.animate(run_time=1).set_opacity(0.2),\n rate_func=there_and_back\n )\n \n # Formula appearance and color effects\n self.play(Write(formula))\n \n # Color cycling\n colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, PINK]\n for color in colors:\n self.play(\n formula.animate.set_color(color),\n heptagon.animate.set_color(interpolate_color(GREEN, BLUE, colors.index(color)/len(colors))),\n run_time=0.5\n )\n \n self.wait(2)\n\n def act_2_areabetweencurves(self):\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n\n # Labels for the axes\n x_label = axes.get_x_axis_label(MathTex(\"x\"))\n y_label = axes.get_y_axis_label(MathTex(\"y\")).shift(LEFT)\n\n # Functions\n func_graph1 = axes.plot(lambda x: x**2, color=RED)\n func_graph2 = axes.plot(lambda x: 0.8*x**2 + 1, color=GREEN)\n\n # Area between curves\n area = axes.get_area(func_graph2, [0, 2], bounded_graph=func_graph1, color=ORANGE, opacity=0.5)\n\n # Display the axes, labels, and functions\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(func_graph1), Create(func_graph2))\n self.wait(1)\n\n # Highlight the area\n self.play(FadeIn(area))\n self.wait(1)\n\n # Problem setup\n problem_text = MathTex(r\"\\text{Find area between }\", \"y = x^2\", r\"\\text{ and }\", \"y = 0.8x^2 + 1\")\n problem_text.to_edge(UP)\n self.play(Write(problem_text))\n self.wait(1)\n\n # Solving step 1: highlighting the functions\n self.play(Indicate(func_graph1), Indicate(func_graph2))\n self.wait(1)\n\n # Solving step 2: showing the integral\n integral_text = MathTex(\n r\"\\int_{0}^{2} \", \"(0.8x^2 + 1)\", \" - \", \"(x^2)\", r\"\\, dx\"\n ).to_edge(DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # Solving step 3: show the calculated area's value\n calculated_area = MathTex(r\"= \", \"4/3\").next_to(integral_text, DOWN)\n self.play(Write(calculated_area))\n self.wait(1)\n\n # Conclusion: clear and show the final answer\n self.clear()\n final_answer = MathTex(\n r\"\\text{Area} = \\frac{4}{3}\"\n ).scale(1.5).to_edge(DOWN)\n self.play(Write(final_answer))\n self.wait(2)\n```"}]} {"id": "AOS-Manim-SFT_000160", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I'm studying hierarchical decoders; visualize the downsampling and upsampling paths with skip connections, showing how information flows from coarse to fine scales and back in a decoder."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass HierarchicalDecodersScene(Scene):\n\n def construct(self):\n title = Text('Hierarchical Decoders', font_size=36, color=BLUE)\n title.to_edge(UP, buff=0.4)\n subtitle = Text('Visualizing structured decoding in AI', font_size=20, color=GRAY)\n subtitle.next_to(title, DOWN, buff=0.15)\n self.play(Write(title), run_time=2.0 * 0.5)\n self.play(FadeIn(subtitle), run_time=2.0 * 0.5)\n self.wait(2.0)\n self.play(FadeOut(subtitle))\n root_rect = RoundedRectangle(width=2.2, height=0.6, corner_radius=0.1, color=YELLOW, fill_opacity=0.15)\n root_rect.move_to([0, 2.0, 0])\n root_text = Text('Encoded Input', font_size=18, color=YELLOW)\n root_text.move_to(root_rect.get_center())\n root_group = VGroup(root_rect, root_text)\n self.play(FadeIn(root_group), run_time=2.0)\n mid_left_rect = RoundedRectangle(width=1.8, height=0.55, corner_radius=0.1, color=GREEN, fill_opacity=0.15)\n mid_left_rect.move_to([-2.5, 0.4, 0])\n mid_left_text = Text('Decoder A', font_size=18, color=GREEN)\n mid_left_text.move_to(mid_left_rect.get_center())\n mid_left = VGroup(mid_left_rect, mid_left_text)\n mid_right_rect = RoundedRectangle(width=1.8, height=0.55, corner_radius=0.1, color=GREEN, fill_opacity=0.15)\n mid_right_rect.move_to([2.5, 0.4, 0])\n mid_right_text = Text('Decoder B', font_size=18, color=GREEN)\n mid_right_text.move_to(mid_right_rect.get_center())\n mid_right = VGroup(mid_right_rect, mid_right_text)\n arrow_r_ml = Arrow(root_rect.get_bottom(), mid_left_rect.get_top(), buff=0.15, color=WHITE, stroke_width=2)\n arrow_r_mr = Arrow(root_rect.get_bottom(), mid_right_rect.get_top(), buff=0.15, color=WHITE, stroke_width=2)\n self.play(FadeIn(mid_left, mid_right), Create(arrow_r_ml), Create(arrow_r_mr), run_time=2.0)\n leaf_positions = [(-4.2, -1.4), (-1.2, -1.4), (1.2, -1.4), (4.2, -1.4)]\n leaf_labels = ['Token 1', 'Token 2', 'Token 3', 'Token 4']\n leaf_colors = [BLUE, BLUE, BLUE, BLUE]\n leaf_nodes = []\n leaf_arrows = []\n for i, ((x, y), label, col) in enumerate(zip(leaf_positions, leaf_labels, leaf_colors)):\n rect = RoundedRectangle(width=1.4, height=0.5, corner_radius=0.08, color=col, fill_opacity=0.15)\n rect.move_to([x, y, 0])\n txt = Text(label, font_size=16, color=col)\n txt.move_to(rect.get_center())\n node = VGroup(rect, txt)\n leaf_nodes.append(node)\n if i < 2:\n src = mid_left_rect\n else:\n src = mid_right_rect\n arr = Arrow(src.get_bottom(), rect.get_top(), buff=0.15, color=WHITE, stroke_width=2)\n leaf_arrows.append(arr)\n self.play(*[FadeIn(n) for n in leaf_nodes], *[Create(a) for a in leaf_arrows], run_time=2.0)\n level0_label = Text('Level 0: Root', font_size=16, color=GRAY).to_edge(LEFT).shift(UP * 2.0 + RIGHT * 0.3)\n level1_label = Text('Level 1: Sub-decoder', font_size=16, color=GRAY).to_edge(LEFT).shift(UP * 0.4 + RIGHT * 0.3)\n level2_label = Text('Level 2: Output', font_size=16, color=GRAY).to_edge(LEFT).shift(DOWN * 1.4 + RIGHT * 0.3)\n self.play(FadeIn(level0_label), FadeIn(level1_label), FadeIn(level2_label), run_time=2.0)\n flow_dots = []\n for arr in [arrow_r_ml, arrow_r_mr]:\n dot = Dot(color=YELLOW, radius=0.06)\n dot.move_to(arr.get_start())\n flow_dots.append(dot)\n self.play(*[FadeIn(d) for d in flow_dots], run_time=0.5)\n self.play(*[MoveAlongPath(d, arr, run_time=2.0 - 0.6) for d, arr in zip(flow_dots, [arrow_r_ml, arrow_r_mr])])\n flow_dots2 = []\n for arr in leaf_arrows:\n dot = Dot(color=GREEN, radius=0.05)\n dot.move_to(arr.get_start())\n flow_dots2.append(dot)\n self.play(*[FadeIn(d) for d in flow_dots2], run_time=0.5)\n self.play(*[MoveAlongPath(d, arr, run_time=1.5) for d, arr in zip(flow_dots2, leaf_arrows)])\n highlight_box = SurroundingRectangle(leaf_nodes[1], buff=0.05, color=YELLOW, stroke_width=2)\n self.play(Create(highlight_box), run_time=2.0 * 0.5)\n self.play(FadeOut(highlight_box), run_time=2.0 * 0.5)\n outcomes = VGroup(Text('Understand hierarchical decoders', font_size=18), Text('Visualize decoding structured levels', font_size=18), Text('Explore parent-child relationships', font_size=18), Text('Gain practical application insights', font_size=18))\n outcomes.arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n outcomes.scale_to_fit_width(6)\n outcomes.move_to([0, 0, 0])\n outcomes.to_edge(DOWN, buff=0.4)\n outcome_box = SurroundingRectangle(outcomes, color=BLUE, buff=0.2, corner_radius=0.1)\n outcome_box.stretch_to_fit_width(6.5)\n outcome_box.move_to(outcomes.get_center())\n self.play(FadeOut(root_group, mid_left, mid_right, *leaf_nodes, *leaf_arrows, arrow_r_ml, arrow_r_mr, level0_label, level1_label, level2_label, *flow_dots, *flow_dots2), FadeIn(outcome_box), *[Write(t) for t in outcomes], run_time=2.0)\n self.wait(1)\n```"}]} {"id": "adaption-unified-manim-instructions_005551", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that illustrates the concept of the area under a curve as represented in calculus. It should show a simple parabolic function on a graph, and I want to visualize the area between the curve and the x-axis, from a starting point 'a' to an ending point 'b'. Along with the graphical representation, I want to include the integral symbol with the limits 'a' and 'b' as seen in integral calculus. The animation should start by displaying the integral formula at the top of the frame, followed by drawing a blue shaded rectangle that represents the area under the curve, even though the curve itself is not exactly matching the rectangle's shape. Once the area is shaded, I would like the actual curve to be drawn on top. Next to the shaded area, there should be a text annotation that says \"Shaded Area represents A\". I would like this text to be updated later in the animation to \"Area under the curve from a to b\". At the bottom of the rectangle representing the area, I need a couple of braces that label the starting point 'a' and the ending point 'b'. After some time, the animation should clear everything from the screen and conclude with the text \"Visualization Complete!\" appearing in the center. This should be designed for someone with no prior knowledge of ManimCE or animation coding."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ==========================================\n # 1. Setup: Axes and Function Definition\n # ==========================================\n # Create a coordinate system.\n # x_range and y_range are formatted as [min, max, step_size].\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True}\n )\n \n # Define a simple parabolic function f(x) = x^2.\n # We use a lambda function so Manim can calculate y-values for plotting.\n func = lambda x: x**2\n \n # Define the integration limits 'a' and 'b'.\n a = 1\n b = 3\n \n # ==========================================\n # 2. Initial Display: Integral Formula\n # ==========================================\n # MathTex is used for LaTeX mathematical notation.\n # r\"...\" denotes a raw string to properly handle LaTeX backslashes.\n integral_formula = MathTex(r\"\\int_a^b f(x) \\, dx\", font_size=40)\n \n # Position the formula at the top edge of the frame.\n integral_formula.to_edge(UP)\n \n # Animate the creation of the axes and the formula.\n self.play(Create(axes), Write(integral_formula))\n self.wait(1)\n \n # ==========================================\n # 3. Rectangle Approximation\n # ==========================================\n # Create a single blue rectangle to approximate the area under the curve.\n # By setting dx = b - a, we ensure only one rectangle is drawn from a to b.\n # input_sample_type=\"left\" uses the function's value at x=a for the rectangle's height.\n # Note: The rectangle does not need to perfectly match the curve at this stage.\n curve_for_rect = axes.plot(func, x_range=[a, b])\n rectangle = axes.get_riemann_rectangles(\n curve_for_rect,\n x_range=[a, b],\n dx=b - a,\n fill_opacity=0.5,\n color=BLUE,\n input_sample_type=\"left\"\n )\n \n # Animate the appearance of the shaded rectangle.\n self.play(Create(rectangle))\n self.wait(1)\n \n # ==========================================\n # 4. Curve Drawing\n # ==========================================\n # Draw the actual parabolic curve on top of the rectangle.\n # This visually demonstrates the difference between the approximation and the true curve.\n curve = axes.plot(func, x_range=[0, 4], color=YELLOW)\n self.play(Create(curve))\n self.wait(1)\n \n # ==========================================\n # 5. Text Annotation\n # ==========================================\n # Create the initial text annotation next to the shaded area.\n text_initial = Text(\"Shaded Area represents A\", font_size=24)\n text_initial.next_to(rectangle, RIGHT, buff=0.5)\n \n # Create the updated text annotation.\n text_updated = Text(\"Area under the curve from a to b\", font_size=24)\n # Match the position of the updated text to the initial text.\n text_updated.move_to(text_initial)\n \n # Animate the writing of the initial text.\n self.play(Write(text_initial))\n self.wait(1)\n \n # Smoothly transform the initial text into the updated text.\n self.play(Transform(text_initial, text_updated))\n self.wait(1)\n \n # ==========================================\n # 6. Braces and Labels\n # ==========================================\n # Create a line segment on the x-axis from point 'a' to 'b' to attach the brace.\n # axes.c2p converts graph coordinates (x, y) to scene screen coordinates.\n line_segment = Line(axes.c2p(a, 0), axes.c2p(b, 0), color=WHITE)\n \n # Create a brace below the line segment to indicate the integration range.\n brace = Brace(line_segment, direction=DOWN, color=WHITE)\n \n # Create labels for 'a' and 'b', positioning them at the left and right ends.\n label_a = MathTex(\"a\", font_size=24).next_to(brace, DOWN, buff=0.1).shift(LEFT * 0.5)\n label_b = MathTex(\"b\", font_size=24).next_to(brace, DOWN, buff=0.1).shift(RIGHT * 0.5)\n \n # Animate the creation of the brace and labels.\n self.play(Create(line_segment), Create(brace), Write(label_a), Write(label_b))\n self.wait(2)\n \n # ==========================================\n # 7. Conclusion\n # ==========================================\n # Clear all elements (mobjects) from the screen.\n self.clear()\n \n # Display the final completion message in the center of the frame.\n final_text = Text(\"Visualization Complete!\", font_size=48, color=GREEN)\n self.play(Write(final_text))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_005422", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates how to calculate the definite integral of x cubed from 0 to 2 using the power rule for integration, showing each step of the process including the integral setup, application of the power rule, evaluation of the integral at the bounds, and the final simplified solution, with explanatory texts for each step and pauses between them?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Title Sequence\n # ------------------------------------------------------------------\n title = Tex(\"Definite Integral of $x^3$ from 0 to 2\", font_size=44)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 1: Integral Setup\n # ------------------------------------------------------------------\n step1_label = Text(\"Step 1: Set up the definite integral\", color=BLUE_B, font_size=36)\n step1_label.next_to(title, DOWN, buff=0.6)\n\n integral_setup = MathTex(r\"\\int_{0}^{2}\", \"x^3\", r\"\\, dx\", font_size=60)\n integral_setup.next_to(step1_label, DOWN, buff=0.8)\n\n self.play(Write(step1_label), Write(integral_setup))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Apply Power Rule\n # ------------------------------------------------------------------\n step2_label = Text(\"Step 2: Apply the Power Rule\", color=BLUE_B, font_size=36)\n step2_label.next_to(title, DOWN, buff=0.6)\n\n power_rule_formula = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=32, \n color=YELLOW\n ).to_edge(RIGHT).shift(UP * 0.5)\n\n # Show the intermediate step with (3+1)\n antiderivative_step = MathTex(\n r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=60\n )\n antiderivative_step.move_to(integral_setup)\n\n self.play(\n ReplacementTransform(step1_label, step2_label),\n ReplacementTransform(integral_setup, antiderivative_step)\n )\n self.play(FadeIn(power_rule_formula, shift=LEFT))\n self.wait(2)\n\n # Simplify the antiderivative to x^4 / 4\n antiderivative_simplified = MathTex(\n r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=60\n )\n antiderivative_simplified.move_to(antiderivative_step)\n\n self.play(\n ReplacementTransform(antiderivative_step, antiderivative_simplified),\n FadeOut(power_rule_formula)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Evaluate at Bounds\n # ------------------------------------------------------------------\n step3_label = Text(\"Step 3: Evaluate at the bounds\", color=BLUE_B, font_size=36)\n step3_label.next_to(title, DOWN, buff=0.6)\n\n evaluation_expr = MathTex(\n r\"\\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=60\n )\n evaluation_expr.move_to(antiderivative_simplified)\n\n self.play(\n ReplacementTransform(step2_label, step3_label),\n ReplacementTransform(antiderivative_simplified, evaluation_expr)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Simplify Arithmetic\n # ------------------------------------------------------------------\n step4_label = Text(\"Step 4: Final Calculation\", color=BLUE_B, font_size=36)\n step4_label.next_to(title, DOWN, buff=0.6)\n\n simplification_expr = MathTex(\n r\"\\frac{16}{4} - 0 = 4\", font_size=60\n )\n simplification_expr.move_to(evaluation_expr)\n\n self.play(\n ReplacementTransform(step3_label, step4_label),\n ReplacementTransform(evaluation_expr, simplification_expr)\n )\n \n # Highlight the final answer\n box = SurroundingRectangle(simplification_expr, color=YELLOW, buff=0.15)\n self.play(Create(box))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # Outro\n # ------------------------------------------------------------------\n self.play(\n FadeOut(title),\n FadeOut(step4_label),\n FadeOut(simplification_expr),\n FadeOut(box)\n )\n\n conclusion = Text(\"The area under the curve is 4\", color=YELLOW, font_size=44)\n self.play(Write(conclusion))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_007292", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an animation that visually demonstrates how to solve a triple integral step by step, particularly the integral of xyz from 0 to 1 with respect to x, y, and z? I'd like to see the integral displayed, then an explanation of integrating with respect to x first, followed by y, and then z, with each step showing the intermediate results. Finally, display the final solved value."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n \"\"\"\n Animates the step-by-step evaluation of the triple integral:\n \\int _0^1 \\int _0^1 \\int _0^1 xyz dx dy dz = 1/8\n \"\"\"\n def construct(self):\n # --- Configuration ---\n # Define colors for variables to track them visually throughout the animation\n COLOR_X = RED\n COLOR_Y = GREEN\n COLOR_Z = BLUE\n COLOR_TEXT = YELLOW\n COLOR_FINAL = GOLD\n\n # --- Step 0: Original Integral ---\n # Separate LaTeX components into individual arguments for MathTex\n # to allow independent coloring of variables and differentials.\n eq_initial = MathTex(\n r\"\\int_0^1\", r\"\\int_0^1\", r\"\\int_0^1\",\n r\"x\", r\"y\", r\"z\",\n r\"\\, dx\", r\"\\, dy\", r\"\\, dz\"\n )\n # Apply colors to variables and their corresponding differentials\n eq_initial[3].set_color(COLOR_X) # x\n eq_initial[4].set_color(COLOR_Y) # y\n eq_initial[5].set_color(COLOR_Z) # z\n eq_initial[6].set_color(COLOR_X) # dx\n eq_initial[7].set_color(COLOR_Y) # dy\n eq_initial[8].set_color(COLOR_Z) # dz\n\n title = Text(\"Solving a Triple Integral\", font_size=36).to_edge(UP)\n\n # --- Step 1: Integrate with respect to x ---\n # Inner integral: \\int _0^1 x dx = [x^2/2]_0^1 = 1/2\n # Resulting expression: (1/2)yz\n eq_step1 = MathTex(\n r\"\\int_0^1\", r\"\\int_0^1\",\n r\"\\frac{1}{2}\", r\"y\", r\"z\",\n r\"\\, dy\", r\"\\, dz\"\n )\n eq_step1[2].set_color(COLOR_X) # 1/2 comes from x integration\n eq_step1[3].set_color(COLOR_Y) # y\n eq_step1[4].set_color(COLOR_Z) # z\n eq_step1[5].set_color(COLOR_Y) # dy\n eq_step1[6].set_color(COLOR_Z) # dz\n\n text_step1 = Text(\"Step 1: Integrate with respect to x\", font_size=28, color=COLOR_X)\n\n # --- Step 2: Integrate with respect to y ---\n # Middle integral: \\int _0^1 (1/2)y dy = (1/2)[y^2/2]_0^1 = 1/4\n # Resulting expression: (1/4)z\n eq_step2 = MathTex(\n r\"\\int_0^1\",\n r\"\\frac{1}{4}\", r\"z\",\n r\"\\, dz\"\n )\n eq_step2[1].set_color(COLOR_Y) # 1/4 comes from y integration\n eq_step2[2].set_color(COLOR_Z) # z\n eq_step2[3].set_color(COLOR_Z) # dz\n\n text_step2 = Text(\"Step 2: Integrate with respect to y\", font_size=28, color=COLOR_Y)\n\n # --- Step 3: Integrate with respect to z ---\n # Outer integral: \\int _0^1 (1/4)z dz = (1/4)[z^2/2]_0^1 = 1/8\n eq_step3 = MathTex(\n r\"\\left[ \\frac{1}{8}z^2 \\right]_0^1\"\n )\n eq_step3.set_color(COLOR_Z)\n\n text_step3 = Text(\"Step 3: Integrate with respect to z\", font_size=28, color=COLOR_Z)\n\n # --- Final Result ---\n eq_final = MathTex(r\"= \\frac{1}{8}\", font_size=60, color=COLOR_FINAL)\n \n text_final = Text(\"Solution Complete\", font_size=36, color=COLOR_FINAL)\n\n # --- Animation Sequence ---\n\n # 1. Introduction: Display Title and Original Integral\n self.play(Write(title))\n self.play(Write(eq_initial))\n self.wait(1)\n\n # 2. Step 1 Animation\n text_step1.next_to(eq_initial, DOWN, buff=0.5)\n self.play(Write(text_step1))\n self.wait(1)\n \n # Highlight the variable and differential being integrated\n self.play(\n eq_initial[3].animate.set_color(YELLOW),\n eq_initial[6].animate.set_color(YELLOW),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Morph the equation to the result of the first integration\n self.play(\n FadeOut(title),\n ReplacementTransform(eq_initial, eq_step1),\n ReplacementTransform(text_step1, text_step2)\n )\n text_step2.next_to(eq_step1, DOWN, buff=0.5)\n self.wait(1)\n\n # 3. Step 2 Animation\n # Highlight y and dy\n self.play(\n eq_step1[3].animate.set_color(YELLOW),\n eq_step1[5].animate.set_color(YELLOW),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Morph to the result of the second integration\n self.play(\n ReplacementTransform(eq_step1, eq_step2),\n ReplacementTransform(text_step2, text_step3)\n )\n text_step3.next_to(eq_step2, DOWN, buff=0.5)\n self.wait(1)\n\n # 4. Step 3 Animation\n # Highlight z and dz\n self.play(\n eq_step2[2].animate.set_color(YELLOW),\n eq_step2[3].animate.set_color(YELLOW),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Morph to the evaluated bracket expression\n self.play(\n ReplacementTransform(eq_step2, eq_step3),\n FadeOut(text_step3)\n )\n self.wait(1)\n\n # 5. Conclusion: Highlight Final Value\n eq_final.next_to(eq_step3, RIGHT, buff=0.3)\n box = SurroundingRectangle(eq_final, color=COLOR_FINAL, buff=0.1)\n \n self.play(Write(eq_final))\n self.play(Create(box))\n self.wait(1)\n \n # Emphasize the result with a scale animation\n self.play(eq_step3.animate.scale(0.8).shift(LEFT), eq_final.animate.scale(1.5).shift(RIGHT*0.5))\n \n text_final.to_edge(DOWN, buff=1.5)\n self.play(Write(text_final))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_005832", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational chemistry animation using ManimCE that shows the following sequence:\n1. Start by fading in individual particles: an electron, an oxygen atom, a metal atom, a positive ion, and a negative ion.\n2. After a brief pause, these particles should combine, or transform, into a grid pattern that represents a metal oxide on a 3x3 grid.\n3. Wait for a moment, then transform this metal oxide grid into a lithium grid structure made of a 2x2 grid pattern.\n4. Wait again, and then change this lithium grid to a carbon grid structure, which is made up of a single element in a 3x3 grid pattern.\n5. Finally, I want the initial electron to move along a complex path made of 9 points that form a loop with stops at the 3rd and 6th points in the pattern. The electron should complete this path loop within 2 seconds.\nThe animation should include waiting periods between each major step so the viewers can understand the changes happening on the screen. Can you help create this animation?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # Set background for better visibility of dark elements like Carbon\n self.camera.background_color = \"#1e1e1e\"\n\n # --- Step 1: Initial Particle Fade-In ---\n electron = Dot(color=BLUE_E, radius=0.15).shift(LEFT * 3 + UP * 2)\n e_label = Text(\"e⁻\", font_size=24, color=BLUE_E).next_to(electron, UP, buff=0.1)\n\n oxygen = Circle(radius=0.4, color=RED, fill_opacity=0.8).shift(LEFT * 1 + UP * 2)\n o_label = Text(\"O\", font_size=24, color=WHITE).move_to(oxygen.get_center())\n\n metal = Circle(radius=0.5, color=GREY, fill_opacity=0.8).shift(RIGHT * 1 + UP * 2)\n m_label = Text(\"M\", font_size=24, color=WHITE).move_to(metal.get_center())\n\n pos_ion = Circle(radius=0.4, color=BLUE, fill_opacity=0.6).shift(RIGHT * 3 + UP * 2)\n p_label = Text(\"+\", font_size=30, color=WHITE).move_to(pos_ion.get_center())\n\n neg_ion = Circle(radius=0.4, color=RED, fill_opacity=0.6).shift(RIGHT * 3 + DOWN * 2)\n n_label = Text(\"-\", font_size=30, color=WHITE).move_to(neg_ion.get_center())\n\n initial_particles = VGroup(\n VGroup(electron, e_label), VGroup(oxygen, o_label), \n VGroup(metal, m_label), VGroup(pos_ion, p_label), VGroup(neg_ion, n_label)\n )\n\n self.play(FadeIn(initial_particles), run_time=2)\n self.wait(1.5)\n\n # --- Step 2: Metal Oxide Formation (3x3 Grid) ---\n metal_oxide_grid = VGroup()\n colors = [GREY, RED, GREY, RED, GREY, RED, GREY, RED, GREY]\n for i in range(3):\n for j in range(3):\n idx = i * 3 + j\n atom = Circle(radius=0.3, color=colors[idx], fill_opacity=0.8)\n atom.move_to(np.array([j * 0.8 - 0.8, -i * 0.8 + 0.8, 0]))\n metal_oxide_grid.add(atom)\n metal_oxide_grid.move_to(ORIGIN)\n\n # Transform the 5 primary shapes, fade out labels, fade in remaining 4 grid atoms\n initial_shapes = VGroup(electron, oxygen, metal, pos_ion, neg_ion)\n labels = VGroup(e_label, o_label, m_label, p_label, n_label)\n\n self.play(\n FadeOut(labels),\n Transform(initial_shapes, metal_oxide_grid[:5]),\n FadeIn(metal_oxide_grid[5:]),\n run_time=2\n )\n self.wait(1.5)\n\n # --- Step 3: Lithium Grid Transformation (2x2 Grid) ---\n lithium_grid = VGroup()\n for i in range(2):\n for j in range(2):\n atom = Circle(radius=0.4, color=PURPLE, fill_opacity=0.9)\n atom.move_to(np.array([j * 1.0 - 0.5, -i * 1.0 + 0.5, 0]))\n lithium_grid.add(atom)\n lithium_grid.move_to(ORIGIN)\n\n self.play(\n Transform(metal_oxide_grid[:4], lithium_grid),\n FadeOut(metal_oxide_grid[4:]),\n run_time=2\n )\n self.wait(1.5)\n\n # --- Step 4: Carbon Grid Transformation (3x3 Grid) ---\n carbon_grid = VGroup()\n for i in range(3):\n for j in range(3):\n atom = Circle(radius=0.3, color=BLACK, stroke_color=WHITE, stroke_width=2, fill_opacity=1)\n atom.move_to(np.array([j * 0.8 - 0.8, -i * 0.8 + 0.8, 0]))\n carbon_grid.add(atom)\n carbon_grid.move_to(ORIGIN)\n\n self.play(\n Transform(lithium_grid, carbon_grid[:4]),\n FadeIn(carbon_grid[4:]),\n run_time=2\n )\n self.wait(1.5)\n\n # --- Step 5: Electron Path Animation ---\n # Transform the tracked atom back into a free electron\n free_electron = Dot(color=BLUE_E, radius=0.15)\n lattice_atom = lithium_grid[0] # Tracked atom\n self.play(Transform(lattice_atom, free_electron), run_time=1)\n\n # Define 9 specific points for a complex closed loop\n points = [\n np.array([0, 2, 0]), # 1 (Start)\n np.array([1, 1.5, 0]), # 2\n np.array([2, 0, 0]), # 3 (Pause 1)\n np.array([1.5, -1, 0]), # 4\n np.array([0.5, -1.5, 0]), # 5\n np.array([-0.5, -1.5, 0]),# 6 (Pause 2)\n np.array([-1.5, -1, 0]), # 7\n np.array([-2, 0, 0]), # 8\n np.array([-1, 1.5, 0]) # 9\n ]\n\n # Create path segments to handle pauses and proportional timing\n path1 = VMobject().set_points_as_corners([points[0], points[1], points[2]])\n path2 = VMobject().set_points_as_corners([points[2], points[3], points[4], points[5]])\n path3 = VMobject().set_points_as_corners([points[5], points[6], points[7], points[8], points[0]])\n\n # Calculate proportional movement times so the entire loop takes exactly 2.0 seconds\n len1, len2, len3 = path1.get_arc_length(), path2.get_arc_length(), path3.get_arc_length()\n total_len = len1 + len2 + len3\n time1 = (len1 / total_len) * 2.0\n time2 = (len2 / total_len) * 2.0\n time3 = (len3 / total_len) * 2.0\n\n # Animate the electron along the path with brief pauses\n pause_time = 0.2\n\n self.play(MoveAlongPath(lattice_atom, path1), run_time=time1)\n self.wait(pause_time) # Pause at 3rd point\n \n self.play(MoveAlongPath(lattice_atom, path2), run_time=time2)\n self.wait(pause_time) # Pause at 6th point\n \n self.play(MoveAlongPath(lattice_atom, path3), run_time=time3)\n\n self.wait(1)\n```"}]} {"id": "adaption-unified-manim-instructions_005242", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates how to calculate the definite integral of x cubed from 0 to 2 using the power rule for integration, showing each step of the process including the integral setup, application of the power rule, evaluation of the integral at the bounds, and the final simplified solution, with explanatory texts for each step and pauses between them?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # Title\n title = Text(\"Calculating a Definite Integral\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # --- Step 1: Integral Setup ---\n step1_label = Text(\"Step 1: Set up the integral\", font_size=24, color=BLUE)\n step1_label.next_to(title, DOWN, buff=0.5)\n \n integral_setup = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=48)\n integral_setup.next_to(step1_label, DOWN, buff=0.5)\n \n self.play(Write(step1_label))\n self.play(Write(integral_setup))\n self.wait(2)\n\n # --- Step 2: Application of the Power Rule ---\n step2_label = Text(\"Step 2: Apply the Power Rule\", font_size=24, color=BLUE)\n step2_label.move_to(step1_label)\n \n power_rule_expr = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=48)\n power_rule_expr.move_to(integral_setup)\n \n rule_hint = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=30, color=YELLOW)\n rule_hint.next_to(power_rule_expr, DOWN, buff=0.5)\n \n self.play(Transform(step1_label, step2_label))\n self.play(ReplacementTransform(integral_setup, power_rule_expr))\n self.play(Write(rule_hint))\n self.wait(2)\n self.play(FadeOut(rule_hint))\n\n # --- Step 3: Evaluation at Bounds ---\n step3_label = Text(\"Step 3: Evaluate at Bounds\", font_size=24, color=BLUE)\n step3_label.move_to(step2_label)\n \n evaluation_expr = MathTex(\n r\"\\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=48\n )\n evaluation_expr.move_to(power_rule_expr)\n \n self.play(Transform(step2_label, step3_label))\n self.play(ReplacementTransform(power_rule_expr, evaluation_expr))\n self.wait(2)\n\n # --- Step 4: Final Simplified Solution ---\n step4_label = Text(\"Step 4: Simplify the Result\", font_size=24, color=GREEN)\n step4_label.move_to(step3_label)\n \n intermediate_expr = MathTex(r\"\\frac{16}{4} - 0\", font_size=48)\n intermediate_expr.move_to(evaluation_expr)\n \n final_solution = MathTex(r\"4\", font_size=48, color=YELLOW)\n final_solution.move_to(intermediate_expr)\n \n self.play(Transform(step3_label, step4_label))\n self.play(ReplacementTransform(evaluation_expr, intermediate_expr))\n self.wait(1)\n self.play(ReplacementTransform(intermediate_expr, final_solution))\n \n # Box the final answer for emphasis\n box = SurroundingRectangle(final_solution, color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup\n self.play(\n FadeOut(title),\n FadeOut(step4_label),\n FadeOut(final_solution),\n FadeOut(box)\n )\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_001513", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n#### Protocol Design\n##### Protocol Format Design\n* **Text Protocol**: Such as JSON, XML, good readability, easy to debug, but large in size and slow to parse.\n* **Binary Protocol**: Such as Protobuf, compact and fast to parse, but not readable.\n\n##### Error Handling\nThe protocol should clearly define error code and error message structures so that the other end can correctly identify and handle abnormal situations.\n\n##### Version Compatibility\nProtocol design should consider future expansion, usually negotiating version numbers during the handshake phase to ensure coexistence of new and old versions of clients and servers.\n\n\nThe context location of this section (from highest level to current):\n# Inter-process Communication\n## Main Content\n### Communication Protocol\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ProtocolDesign(Scene):\n\n def construct(self):\n title = Text('Protocol Design', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n format_title = Text('1. Protocol Format Design', font_size=26, color=TEAL)\n format_title.next_to(title_group, DOWN, buff=0.5).to_edge(LEFT, buff=1.0)\n text_proto = Text('- Text (JSON/XML): Readable, easy to debug, larger size', font_size=22)\n bin_proto = Text('- Binary (Protobuf): Compact, fast to parse, unreadable', font_size=22)\n format_group = VGroup(text_proto, bin_proto).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n format_group.next_to(format_title, DOWN, buff=0.2).align_to(format_title, LEFT).shift(RIGHT * 0.4)\n self.play(Write(format_title, run_time=0.8))\n self.play(FadeIn(format_group, shift=RIGHT * 0.5, run_time=1.0))\n error_title = Text('2. Error Handling', font_size=26, color=TEAL)\n error_title.next_to(format_group, DOWN, buff=0.5).align_to(format_title, LEFT)\n error_desc = Text('- Define error codes and messages to identify abnormal states', font_size=22)\n error_desc.next_to(error_title, DOWN, buff=0.2).align_to(format_group, LEFT)\n error_box = Text('{ err_code: 404, message: Not Found }', font_size=20, color=YELLOW)\n error_rect = SurroundingRectangle(error_box, color=YELLOW, buff=0.15)\n error_vg = VGroup(error_box, error_rect)\n error_vg.next_to(error_desc, DOWN, buff=0.25).align_to(error_desc, LEFT).shift(RIGHT * 0.5)\n self.play(Write(error_title, run_time=0.8))\n self.play(FadeIn(error_desc, shift=RIGHT * 0.5, run_time=0.8))\n self.play(Create(error_rect), Write(error_box), run_time=1.0)\n version_title = Text('3. Version Compatibility', font_size=26, color=TEAL)\n version_title.next_to(error_vg, DOWN, buff=0.5).align_to(format_title, LEFT)\n version_desc = Text('- Negotiate version during handshake to ensure coexistence', font_size=22)\n version_desc.next_to(version_title, DOWN, buff=0.2).align_to(format_group, LEFT)\n client_box = Text('Client v1', font_size=20)\n client_rect = SurroundingRectangle(client_box, color=GREEN, buff=0.15)\n client_vg = VGroup(client_box, client_rect)\n server_box = Text('Server v1 / v2', font_size=20)\n server_rect = SurroundingRectangle(server_box, color=GREEN, buff=0.15)\n server_vg = VGroup(server_box, server_rect)\n arrow = DoubleArrow(start=LEFT, end=RIGHT, color=WHITE).scale(0.6)\n version_diagram = VGroup(client_vg, arrow, server_vg).arrange(RIGHT, buff=0.4)\n version_diagram.next_to(version_desc, DOWN, buff=0.25).align_to(version_desc, LEFT).shift(RIGHT * 0.5)\n self.play(Write(version_title, run_time=0.8))\n self.play(FadeIn(version_desc, shift=RIGHT * 0.5, run_time=0.8))\n self.play(FadeIn(client_vg, run_time=0.8), GrowArrow(arrow, run_time=0.8), FadeIn(server_vg, run_time=0.8))\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_003842", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a green `Line` stretching diagonally from (-2, -2) to (2, 2), as in the original. However, the line now smoothly transforms into a right triangle by animating a second line from (2, 2) to (2, -2) in red, followed by a third line from (2, -2) back to (-2, -2) in blue, completing the shape. Simultaneously, the Pythagorean theorem formula \\( a^2 + b^2 = c^2 \\) fades in above the triangle, with each term color-coded to match its corresponding side (red for \\( a \\), blue for \\( b \\), and green for \\( c \\)). To reinforce the relationship, the lengths of the sides dynamically update as the lines form, displaying their numerical values (e.g., \"4 units\" for the legs and \\( 4\\sqrt{2} \\) units for the hypotenuse). Finally, the triangle rotates 360 degrees around its center while the formula scales slightly for emphasis before the scene fades out. This enhanced version not only visualizes the geometric construction but also explicitly connects it to the underlying mathematical principle."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # Create hypotenuse (green)\n hypotenuse = Line(start=[-2, -2, 0], end=[2, 2, 0], color=GREEN)\n hypotenuse_label = MathTex(\"c\", color=GREEN).next_to(hypotenuse, UR, buff=0.1)\n hypotenuse_length = DecimalNumber(0, unit=\"\\\\text{ units}\").next_to(hypotenuse, UR, buff=0.5)\n \n # Create first leg (red)\n leg_a = Line(start=[2, 2, 0], end=[2, -2, 0], color=RED)\n leg_a_label = MathTex(\"a\", color=RED).next_to(leg_a, RIGHT, buff=0.1)\n leg_a_length = DecimalNumber(0, unit=\"\\\\text{ units}\").next_to(leg_a, RIGHT, buff=0.5)\n \n # Create second leg (blue)\n leg_b = Line(start=[2, -2, 0], end=[-2, -2, 0], color=BLUE)\n leg_b_label = MathTex(\"b\", color=BLUE).next_to(leg_b, DOWN, buff=0.1)\n leg_b_length = DecimalNumber(0, unit=\"\\\\text{ units}\").next_to(leg_b, DOWN, buff=0.5)\n \n # Pythagorean theorem formula\n formula = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.5).to_edge(UP)\n formula.set_color_by_tex(\"a^2\", RED)\n formula.set_color_by_tex(\"b^2\", BLUE)\n formula.set_color_by_tex(\"c^2\", GREEN)\n \n # Animate hypotenuse\n self.play(Create(hypotenuse), Write(hypotenuse_label))\n self.play(\n hypotenuse_length.animate.set_value(4 * np.sqrt(2)),\n run_time=2\n )\n \n # Animate first leg\n self.play(Create(leg_a), Write(leg_a_label))\n self.play(\n leg_a_length.animate.set_value(4),\n run_time=2\n )\n \n # Animate second leg\n self.play(Create(leg_b), Write(leg_b_label))\n self.play(\n leg_b_length.animate.set_value(4),\n run_time=2\n )\n \n # Show formula\n self.play(FadeIn(formula, shift=DOWN))\n \n # Rotate triangle and emphasize formula\n triangle = VGroup(hypotenuse, leg_a, leg_b)\n self.play(\n Rotate(triangle, angle=2 * PI, about_point=triangle.get_center()),\n formula.animate.scale(1.2),\n run_time=3\n )\n self.play(formula.animate.scale(1/1.2))\n \n # Fade out\n self.play(FadeOut(triangle), FadeOut(formula), FadeOut(hypotenuse_label), \n FadeOut(leg_a_label), FadeOut(leg_b_label), FadeOut(hypotenuse_length), \n FadeOut(leg_a_length), FadeOut(leg_b_length))\n```"}]} {"id": "adaption-unified-manim-instructions_007931", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that walks through the process of solving a basic definite integral using the Fundamental Theorem of Calculus? Start by displaying the integral of x cubed from 1 to 2. Then, introduce the concept of the Fundamental Theorem of Calculus with a textual explanation at the top of the screen. Next, show the anti-derivative of the function being integrated. Afterward, evaluate the anti-derivative at the upper and lower bounds of the integral and display the subtraction of these values. Include another text explanation emphasizing the subtraction step for finding the definite integral. Finally, present the simplified numeric answer and clear the scene before showing the solution alone for emphasis."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass FundamentalTheoremOfCalculus(Scene):\n def construct(self):\n # 1. Initial Display: Render the definite integral of x^3 from 1 to 2\n integral = MathTex(r\"\\int_{1}^{2} x^3 \\, dx\")\n integral.scale(1.5)\n self.play(Write(integral))\n self.wait(1)\n\n # 2. Concept Introduction: Display FTC explanation at the top\n ftc_title = Text(\"Fundamental Theorem of Calculus\", font_size=36)\n ftc_title.to_edge(UP)\n ftc_title.set_color_by_gradient(BLUE, WHITE)\n self.play(Write(ftc_title))\n self.wait(1)\n\n # 3. Anti-derivative: Visually present the anti-derivative\n antiderivative_label = Text(\"Anti-derivative:\", font_size=24)\n antiderivative_expr = MathTex(r\"F(x) = \\frac{x^4}{4}\")\n antiderivative_group = VGroup(antiderivative_label, antiderivative_expr).arrange(RIGHT)\n antiderivative_group.next_to(integral, DOWN, buff=0.5)\n self.play(FadeIn(antiderivative_group))\n self.wait(1)\n\n # Transition the integral to its evaluated anti-derivative form\n bounds_notation = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{1}^{2}\")\n bounds_notation.move_to(integral)\n self.play(Transform(integral, bounds_notation))\n self.wait(1)\n\n # 4. Evaluation: Show substitution of upper and lower bounds\n substitution = MathTex(r\"\\frac{2^4}{4} - \\frac{1^4}{4}\")\n substitution.next_to(antiderivative_group, DOWN, buff=0.5)\n self.play(Write(substitution))\n self.wait(1)\n\n # Show simplification of the terms\n simplification = MathTex(r\"\\frac{16}{4} - \\frac{1}{4}\")\n simplification.move_to(substitution)\n self.play(Transform(substitution, simplification))\n self.wait(1)\n\n # 5. Emphasis: Text explanation highlighting the subtraction step\n emphasis_text = Text(\n \"The definite integral is the difference between\\nthe anti-derivative evaluated at the bounds.\",\n font_size=24,\n line_spacing=1.0\n )\n emphasis_text.to_edge(DOWN, buff=1)\n emphasis_text.set_color(YELLOW)\n self.play(FadeIn(emphasis_text, shift=UP))\n self.wait(2)\n\n # 6. Solution: Reveal the simplified numeric answer\n final_result = MathTex(r\"= \\frac{15}{4} = 3.75\")\n final_result.next_to(substitution, DOWN, buff=0.5)\n final_result.set_color(GREEN)\n self.play(Write(final_result))\n self.wait(1)\n\n # 7. Conclusion: Clear the scene elements, leaving only the final solution\n final_display = MathTex(r\"\\int_{1}^{2} x^3 \\, dx = \\frac{15}{4}\")\n final_display.scale(1.5)\n final_display.set_color(GREEN)\n\n self.play(\n FadeOut(ftc_title),\n FadeOut(antiderivative_group),\n FadeOut(integral),\n FadeOut(substitution),\n FadeOut(emphasis_text),\n Transform(final_result, final_display)\n )\n self.play(final_display.animate.move_to(ORIGIN))\n self.play(Indicate(final_display))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_002091", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like an animation that demonstrates how to solve a basic definite integral step by step. Start by showing the integral of x squared from 0 to 1. Afterwards, I'd like a written explanation that we're evaluating this definite integral to appear, followed by the general power rule for integrals displayed. Next, show the actual calculations with the limits of 0 and 1 being applied to the integral. Continue with transforming this into the solution after substituting the limits. Finally, present the final answer and end with the explanation that this value represents the area under the curve between 0 and 1. Once the calculation is complete, clear everything and then bring back only the final solution along with the explanation for a strong conclusion."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Render the definite integral of x^2 from 0 to 1\n # ------------------------------------------------------------------\n integral = MathTex(r\"\\int_0^1 x^2 \\, dx\")\n integral.scale(1.5)\n self.play(Write(integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Contextual Explanation: Text stating evaluation is happening\n # ------------------------------------------------------------------\n eval_text = Text(\"Evaluating this definite integral...\", font_size=36, color=BLUE)\n eval_text.next_to(integral, DOWN, buff=0.5)\n self.play(FadeIn(eval_text, shift=UP))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Rule Presentation: Display the general power rule for integrals\n # ------------------------------------------------------------------\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36)\n power_rule.next_to(eval_text, DOWN, buff=0.5)\n self.play(Write(power_rule))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 4. Calculation Phase: Apply limits (0 and 1) to the antiderivative\n # ------------------------------------------------------------------\n # Clear intermediate text to focus on calculation\n self.play(FadeOut(eval_text), FadeOut(power_rule))\n \n antiderivative = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_0^1\")\n antiderivative.scale(1.5)\n self.play(ReplacementTransform(integral, antiderivative))\n self.wait(1)\n\n # Show substitution step clearly\n substitution = MathTex(r\"\\left( \\frac{1^3}{3} \\right) - \\left( \\frac{0^3}{3} \\right)\")\n substitution.scale(1.5)\n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Solution Derivation: Transform to substitution and then result\n # ------------------------------------------------------------------\n final_calc = MathTex(r\"\\frac{1}{3} - 0 = \\frac{1}{3}\")\n final_calc.scale(1.5)\n self.play(ReplacementTransform(substitution, final_calc))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Interpretation: Present answer and area explanation\n # ------------------------------------------------------------------\n area_text = Text(\n \"This value represents the area under the curve between 0 and 1.\", \n font_size=32, \n color=YELLOW\n )\n area_text.next_to(final_calc, DOWN, buff=0.5)\n self.play(Write(area_text))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 7. Conclusion: Clear screen, bring back only final solution + explanation\n # ------------------------------------------------------------------\n self.clear()\n \n # Define the clean final solution object for the conclusion\n final_solution = MathTex(r\"\\int_0^1 x^2 \\, dx = \\frac{1}{3}\")\n final_solution.scale(1.5)\n \n conclusion_text = Text(\n \"This value represents the area under the curve between 0 and 1.\", \n font_size=32, \n color=YELLOW\n )\n conclusion_text.next_to(final_solution, DOWN, buff=0.5)\n \n final_group = VGroup(final_solution, conclusion_text).move_to(ORIGIN)\n \n self.play(Write(final_solution), Write(conclusion_text))\n self.wait(3)\n\n# To run this animation:\n# manim -pql filename.py DefiniteIntegralSolution\n```"}]} {"id": "adaption-unified-manim-instructions_001867", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that shows the process of chemical bonding between an oxygen atom and a metal atom. The animation should start by showing the oxygen atom at the top of the screen and the metal atom appearing below it. Then, it should depict a bond forming between the oxygen and the metal atom, followed by a second bond forming from the bottom of the metal atom to the edge of the screen. Once the bonds are formed, the resulting molecule should move to the right and then back to its original position. Lastly, I want to introduce an electron into the scene, have it appear from the center, and then have all the elements and bonds fade away at the end. Can you do this in a simple, visually engaging way that would be suitable for a classroom setting?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\n# To render this animation, use the following command in your terminal:\n# manim -pql script_name.py ChemicalBondingScene\n\nclass ChemicalBondingScene(Scene):\n def construct(self):\n # Define distinct colors for clarity\n O_COLOR = RED\n METAL_COLOR = GREY\n BOND_COLOR = YELLOW\n ELECTRON_COLOR = BLUE\n \n # ---------------------------------------------------------\n # 1. Initial Setup: Display an oxygen atom at the top\n # ---------------------------------------------------------\n oxygen = Circle(radius=0.6, color=O_COLOR, fill_opacity=0.8)\n o_label = Text(\"O\", font_size=36, color=WHITE).move_to(oxygen.get_center())\n oxygen_atom = VGroup(oxygen, o_label)\n oxygen_atom.shift(UP * 2.5)\n \n self.play(FadeIn(oxygen_atom), run_time=1)\n self.wait(0.5)\n \n # ---------------------------------------------------------\n # 2. Appearance: Have a metal atom appear below\n # ---------------------------------------------------------\n metal = Circle(radius=0.6, color=METAL_COLOR, fill_opacity=0.8)\n m_label = Text(\"M\", font_size=36, color=WHITE).move_to(metal.get_center())\n metal_atom = VGroup(metal, m_label)\n metal_atom.shift(DOWN * 0.5)\n \n self.play(FadeIn(metal_atom), run_time=1)\n self.wait(0.5)\n \n # ---------------------------------------------------------\n # 3. Bond Formation (Step 1): Between Oxygen and Metal\n # ---------------------------------------------------------\n bond1 = Line(\n oxygen_atom.get_bottom(), \n metal_atom.get_top(), \n color=BOND_COLOR, \n stroke_width=6\n )\n self.play(Create(bond1), run_time=1)\n self.wait(0.5)\n \n # ---------------------------------------------------------\n # 4. Bond Formation (Step 2): Metal bottom to screen edge\n # ---------------------------------------------------------\n edge_point = DOWN * (config.frame_height / 2 - 0.5)\n \n bond2 = Line(\n metal_atom.get_bottom(), \n edge_point, \n color=BOND_COLOR, \n stroke_width=6\n )\n \n # Add updater to keep bond2 connected to the metal atom during movement\n bond2.add_updater(lambda b: b.become(\n Line(metal_atom.get_bottom(), edge_point, color=BOND_COLOR, stroke_width=6)\n ))\n \n self.play(Create(bond2), run_time=1)\n self.wait(0.5)\n \n # ---------------------------------------------------------\n # 5. Movement: Move molecule right, then return\n # ---------------------------------------------------------\n molecule = VGroup(oxygen_atom, metal_atom, bond1)\n \n self.play(molecule.animate.shift(RIGHT * 3), run_time=1.5)\n self.wait(0.5)\n self.play(molecule.animate.shift(LEFT * 3), run_time=1.5)\n self.wait(0.5)\n \n # Remove updater so bond2 stays static for the fade out\n bond2.remove_updater(bond2.updaters[0])\n \n # ---------------------------------------------------------\n # 6. Electron Introduction: Appear from center\n # ---------------------------------------------------------\n electron = Dot(radius=0.2, color=ELECTRON_COLOR)\n self.play(GrowFromCenter(electron), run_time=1)\n self.wait(0.5)\n \n # ---------------------------------------------------------\n # 7. Conclusion: Fade away all elements\n # ---------------------------------------------------------\n all_elements = VGroup(oxygen_atom, metal_atom, bond1, bond2, electron)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait()\n```"}]} {"id": "adaption-unified-manim-instructions_006472", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that shows a simple chemical bonding process between an oxygen atom and a hydrogen atom leading to the formation of a water molecule, visually illustrating the transfer of an electron, and then transforming the individual oxygen and hydrogen atoms into a water molecule?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass WaterFormation(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n O_COLOR = RED\n H_COLOR = WHITE\n ELECTRON_COLOR = YELLOW\n BOND_COLOR = BLUE\n \n # --- Step 1: Create Atoms ---\n # Oxygen Atom (Larger)\n oxygen_nucleus = Circle(radius=0.6, color=O_COLOR, fill_opacity=0.8)\n oxygen_label = Tex(\"O\", font_size=48).move_to(oxygen_nucleus.get_center())\n oxygen_group = VGroup(oxygen_nucleus, oxygen_label).shift(LEFT * 3)\n \n # Hydrogen Atoms (Smaller) - Water requires 2 Hydrogens (H₂O)\n h1_nucleus = Circle(radius=0.35, color=H_COLOR, fill_opacity=0.8)\n h1_label = Tex(\"H\", font_size=36, color=BLACK).move_to(h1_nucleus.get_center())\n h1_group = VGroup(h1_nucleus, h1_label).shift(RIGHT * 3 + UP * 1.5)\n \n h2_nucleus = Circle(radius=0.35, color=H_COLOR, fill_opacity=0.8)\n h2_label = Tex(\"H\", font_size=36, color=BLACK).move_to(h2_nucleus.get_center())\n h2_group = VGroup(h2_nucleus, h2_label).shift(RIGHT * 3 + DOWN * 1.5)\n \n # --- Step 2: Create Valence Electrons ---\n # Oxygen has 6 valence electrons, shown orbiting; 2 are highlighted for bonding\n o_electrons = VGroup(*[\n Dot(radius=0.1, color=ELECTRON_COLOR).move_to(\n oxygen_nucleus.get_center() + np.array([np.cos(a), np.sin(a), 0]) * 0.85\n ) for a in np.linspace(0, 2 * PI, 6, endpoint=False)\n ])\n \n # Specific Oxygen electrons that will form bonds\n bonding_e_o1 = o_electrons[2]\n bonding_e_o2 = o_electrons[4]\n \n # Hydrogen has 1 valence electron each\n e_h1 = Dot(radius=0.15, color=ELECTRON_COLOR).next_to(h1_nucleus, LEFT, buff=0.1)\n e_h2 = Dot(radius=0.15, color=ELECTRON_COLOR).next_to(h2_nucleus, LEFT, buff=0.1)\n \n # --- Step 3: Initial Layout ---\n title = Tex(\"Formation of Water (H$_2$O)\", font_size=36).to_edge(UP)\n self.play(Write(title))\n self.play(\n FadeIn(oxygen_group), FadeIn(o_electrons),\n FadeIn(h1_group), FadeIn(e_h1),\n FadeIn(h2_group), FadeIn(e_h2),\n run_time=2\n )\n self.wait(1)\n \n # --- Step 4: Bring Atoms Together ---\n # Define final positions for the characteristic bent shape (~104.5°)\n final_o_pos = ORIGIN\n final_h1_pos = LEFT * 1.2 + UP * 0.8\n final_h2_pos = LEFT * 1.2 + DOWN * 0.8\n \n self.play(\n oxygen_group.animate.move_to(final_o_pos),\n h1_group.animate.move_to(final_h1_pos),\n h2_group.animate.move_to(final_h2_pos),\n e_h1.animate.move_to(final_h1_pos + RIGHT * 0.4),\n e_h2.animate.move_to(final_h2_pos + RIGHT * 0.4),\n run_time=2\n )\n self.wait(0.5)\n \n # --- Step 5: Animate Electron Interaction ---\n # Visualize electrons moving into the bonding region (Covalent Sharing)\n # While the prompt mentions \"transfer\", water forms via covalent sharing.\n # We animate movement to the inter-nuclear space to illustrate bond formation.\n bond_pos_1 = (final_o_pos + final_h1_pos) / 2\n bond_pos_2 = (final_o_pos + final_h2_pos) / 2\n \n process_label = Tex(\"Covalent Bonding: Electron Sharing\", font_size=28, color=BOND_COLOR)\n process_label.next_to(oxygen_group, DOWN, buff=1.5)\n \n self.play(\n e_h1.animate.move_to(bond_pos_1 + UP * 0.15),\n bonding_e_o1.animate.move_to(bond_pos_1 + DOWN * 0.15),\n e_h2.animate.move_to(bond_pos_2 + DOWN * 0.15),\n bonding_e_o2.animate.move_to(bond_pos_2 + UP * 0.15),\n Write(process_label),\n run_time=2\n )\n self.wait(1)\n self.play(FadeOut(process_label))\n \n # --- Step 6: Form the Molecule ---\n # Create visual bonds (lines)\n bond_1 = Line(final_o_pos, final_h1_pos, color=BOND_COLOR, stroke_width=6)\n bond_2 = Line(final_o_pos, final_h2_pos, color=BOND_COLOR, stroke_width=6)\n \n self.play(\n Create(bond_1), Create(bond_2),\n # Fade out individual electrons as they are now \"in the bond\"\n FadeOut(e_h1), FadeOut(e_h2),\n FadeOut(bonding_e_o1), FadeOut(bonding_e_o2),\n FadeOut(o_electrons), # Simplify view by fading non-bonding electrons\n run_time=1.5\n )\n \n # --- Step 7: Final Labeling ---\n molecule_label = MathTex(\"H_2O\", font_size=60, color=BOND_COLOR)\n molecule_label.next_to(oxygen_group, DOWN, buff=1.5)\n self.play(Write(molecule_label))\n self.play(Indicate(molecule_label))\n \n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_001532", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to see an animated explanation of how to calculate the definite integral of x^3 from 0 to 2, with each step of the process displayed, including the use of the power rule for integration, the evaluation of the integral at the boundaries, and the final simplified answer. Can you also make sure to pause briefly after each new piece of information is shown so I can understand it fully before moving on?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # --- 1. Problem Statement ---\n # Show the integral expression: \\int (x^3)dx from 0 to 2\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.2)\n problem.to_edge(UP)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- 2. Power Rule Application ---\n # Demonstrate the use of the power rule for integration\n rule_text = Text(\"Apply the Power Rule:\", font_size=30).next_to(problem, DOWN, buff=0.5).shift(LEFT * 3)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40).next_to(rule_text, RIGHT, buff=0.5)\n rule_group = VGroup(rule_text, rule_formula).shift(UP * 0.5)\n\n self.play(Write(rule_text), Write(rule_formula))\n self.wait(2)\n\n # Show the antiderivative application\n antiderivative = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=45).next_to(problem, DOWN, buff=0.7)\n antiderivative_simplified = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=45).next_to(antiderivative, DOWN, buff=0.5)\n\n self.play(Write(antiderivative))\n self.wait(2)\n self.play(Transform(antiderivative, antiderivative_simplified))\n self.wait(2)\n\n # --- 3. Boundary Evaluation ---\n # Show the substitution of the upper limit (2) and lower limit (0)\n eval_text = Text(\"Substitute boundaries:\", font_size=30).shift(LEFT * 3 + DOWN * 1)\n substitution = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=45\n ).next_to(antiderivative_simplified, DOWN, buff=0.7)\n\n self.play(Write(eval_text))\n self.play(Write(substitution))\n self.wait(2)\n\n # --- 4. Final Calculation ---\n # Display the arithmetic simplification leading to the final answer\n calc_step1 = MathTex(\n r\"= \\frac{16}{4} - 0\", \n font_size=45\n ).next_to(substitution, DOWN, buff=0.5)\n \n final_answer = MathTex(\n r\"= 4\", \n font_size=50, \n color=YELLOW\n ).next_to(calc_step1, DOWN, buff=0.5)\n\n self.play(Write(calc_step1))\n self.wait(2)\n self.play(Write(final_answer))\n self.wait(3)\n\n # Final highlight\n box = SurroundingRectangle(final_answer, color=YELLOW, buff=0.1)\n self.play(Create(box))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_006780", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that visually demonstrates how one can calculate the area under a parabola. The graph should be of the function f(x) = x^2, and the specific area from x = -2 to x = 2 needs to be shaded to represent the area being calculated. Initially, a blue curve represents the function, and the related mathematical integral equation should also appear next to it. The equation should then move to the top of the screen while the area gets shaded in blue beneath the curve. Thereafter, I want the animation to show the step-by-step calculation of the integral, including writing the antiderivative, evaluating the definite integral at the boundaries, and simplifying the final answer. Each mathematical step should replace the previous one in a clear and understandable manner. Finally, when the full calculation is complete, the animation should clear all content except for the final solution, and then re-display that solution for emphasis. Can you create an animation like this for my mathematics students to help them visualize the integration process?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. INITIAL STATE\n # ------------------------------------------------------------------\n # Create a clean coordinate system focused on the relevant domain\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_ticks\": True},\n tips=False\n )\n \n # Axis labels for clarity\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n # Plot the parabola f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[-2, 2])\n \n # Display the integral equation next to the graph initially\n integral_eq = MathTex(\n r\"\\int_{-2}^{2} x^2 \\, dx\",\n font_size=40\n ).next_to(axes, RIGHT, buff=1.0)\n \n # Animate the creation of the environment\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(integral_eq))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. TRANSITION\n # ------------------------------------------------------------------\n # Move the equation to the top to make room for calculation steps\n integral_eq_top = integral_eq.copy().to_edge(UP)\n self.play(ReplacementTransform(integral_eq, integral_eq_top))\n \n # Shade the area under the curve to visualize the integral\n area = axes.get_area(graph, x_range=[-2, 2], color=BLUE, opacity=0.3)\n self.play(FadeIn(area))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 3. STEP-BY-STEP CALCULATION\n # ------------------------------------------------------------------\n # Prepare calculation steps positioned below the main equation\n # Step 1: Antiderivative\n step1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\",\n font_size=40\n ).next_to(integral_eq_top, DOWN, buff=0.5)\n \n # Step 2: Evaluate at boundaries\n # Positioned exactly where step1 was to ensure smooth transition\n step2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\",\n font_size=40\n ).move_to(step1.get_center())\n \n # Step 3: Simplify to final value\n step3 = MathTex(\n r\"= \\frac{8}{3} - \\left(-\\frac{8}{3}\\right) = \\frac{16}{3}\",\n font_size=40\n ).move_to(step1.get_center())\n \n # Execute sequential animation with pauses for cognitive processing\n self.play(Write(step1))\n self.wait(2) # Time to recognize the power rule application\n \n self.play(ReplacementTransform(step1, step2))\n self.wait(2) # Time to verify boundary substitution\n \n self.play(ReplacementTransform(step2, step3))\n self.wait(2) # Time to confirm arithmetic\n \n # ------------------------------------------------------------------\n # 4. FINAL EMPHASIS\n # ------------------------------------------------------------------\n # Clear all visual aids to focus attention solely on the result\n self.play(\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(graph),\n FadeOut(area),\n FadeOut(integral_eq_top),\n FadeOut(step3)\n )\n \n # Display the final solution prominently in the center\n final_solution = MathTex(\n r\"\\text{Area} = \\frac{16}{3}\",\n font_size=72,\n color=YELLOW\n )\n self.play(Write(final_solution))\n self.play(Indicate(final_solution))\n self.wait(3)\n```"}]} {"id": "ry_manim_codegen_000037", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Why do geodesics on a hyperbolic surface diverge exponentially from each other, and how can this phenomenon be visualized?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass HyperbolicGeodesics(Scene):\n def construct(self):\n # Title\n title = Text(\"The Curious Dance of Hyperbolic Geodesics\")\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Introduction - flat space\n intro_text = Text(\"On a flat plane, parallel lines stay equidistant\", font_size=28)\n intro_text.next_to(title, DOWN, buff=0.5)\n \n flat_plane = Rectangle(height=3, width=4, color=BLUE, fill_opacity=0.2)\n line1 = Line(start=LEFT*1.5, end=RIGHT*1.5, color=YELLOW)\n line2 = Line(start=LEFT*1.5+DOWN*0.5, end=RIGHT*1.5+DOWN*0.5, color=YELLOW)\n \n flat_group = VGroup(flat_plane, line1, line2).shift(DOWN)\n \n self.play(Write(intro_text))\n self.play(Create(flat_group))\n self.wait(1)\n \n # Transition to hyperbolic space\n hyperbolic_text = Text(\"In hyperbolic space, geodesics diverge exponentially\", font_size=28)\n hyperbolic_text.next_to(title, DOWN, buff=0.5)\n \n # Two curves diverging from a point\n start_point = DOWN\n \n curve1 = CubicBezier(\n start_point,\n start_point + UP*0.5 + LEFT*0.2,\n UP + LEFT*1,\n UP*1.5 + LEFT*2,\n color=YELLOW\n )\n \n curve2 = CubicBezier(\n start_point,\n start_point + UP*0.5 + RIGHT*0.2,\n UP + RIGHT*1,\n UP*1.5 + RIGHT*2,\n color=ORANGE\n )\n \n # Distance markers\n distance1 = Line(\n curve1.point_from_proportion(0.3),\n curve2.point_from_proportion(0.3),\n color=RED\n )\n \n distance2 = Line(\n curve1.point_from_proportion(0.6),\n curve2.point_from_proportion(0.6),\n color=RED\n )\n \n distance3 = Line(\n curve1.point_from_proportion(0.9),\n curve2.point_from_proportion(0.9),\n color=RED\n )\n \n # Formula\n formula = Text(\"d(t) = e^(kt)\")\n formula.next_to(curve1, DOWN, buff=1)\n \n # Animation sequence\n self.play(FadeOut(flat_group))\n self.play(ReplacementTransform(intro_text, hyperbolic_text))\n self.play(Create(curve1))\n self.play(Create(curve2))\n self.wait(1)\n \n self.play(Create(distance1))\n self.play(Create(distance2))\n self.play(Create(distance3))\n self.wait(1)\n \n self.play(Write(formula))\n self.wait(2)\n \n # Conclusion\n conclusion_text = Text(\"The beauty of hyperbolic geometry\")\n conclusion_text.next_to(title, DOWN, buff=1.5)\n \n self.play(\n FadeOut(hyperbolic_text),\n FadeOut(curve1),\n FadeOut(curve2),\n FadeOut(distance1),\n FadeOut(distance2),\n FadeOut(distance3),\n FadeOut(formula)\n )\n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(title), FadeOut(conclusion_text))\n```"}]} {"id": "manim-sft-10k_002774", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "What is the impact of introducing uncertainty in payoff values on Nash equilibria in mixed strategy games?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass UncertaintyInGameTheory(Scene):\n def construct(self):\n # Title\n title = Text(\"Uncertainty in Game Theory\")\n subtitle = Text(\"The Ripple Effect on Nash Equilibria\").next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Create a 2x2 grid for the game matrix\n square1 = Square(side_length=2).move_to([-1, 1, 0])\n square2 = Square(side_length=2).move_to([1, 1, 0])\n square3 = Square(side_length=2).move_to([-1, -1, 0])\n square4 = Square(side_length=2).move_to([1, -1, 0])\n \n grid = VGroup(square1, square2, square3, square4)\n \n payoff1 = Text(\"(3,3)\").move_to(square1.get_center())\n payoff2 = Text(\"(0,5)\").move_to(square2.get_center())\n payoff3 = Text(\"(5,0)\").move_to(square3.get_center())\n payoff4 = Text(\"(1,1)\").move_to(square4.get_center())\n \n payoffs = VGroup(payoff1, payoff2, payoff3, payoff4)\n \n matrix_title = Text(\"Game Matrix (Without Uncertainty)\").next_to(grid, UP)\n \n self.play(Create(grid))\n self.play(Write(payoffs))\n self.play(Write(matrix_title))\n self.wait(1)\n \n # Nash Equilibrium point\n eq_point = Dot(color=RED).move_to([0, 0, 0])\n eq_label = Text(\"Nash Equilibrium\").next_to(eq_point, DOWN)\n \n self.play(Create(eq_point))\n self.play(Write(eq_label))\n self.wait(1)\n \n # Uncertainty - changing payoffs\n uncertain_payoff1 = Text(\"(3±0.5,3±0.5)\").move_to(square1.get_center())\n uncertain_payoff2 = Text(\"(0±0.5,5±0.5)\").move_to(square2.get_center())\n uncertain_payoff3 = Text(\"(5±0.5,0±0.5)\").move_to(square3.get_center())\n uncertain_payoff4 = Text(\"(1±0.5,1±0.5)\").move_to(square4.get_center())\n \n uncertain_payoffs = VGroup(uncertain_payoff1, uncertain_payoff2, uncertain_payoff3, uncertain_payoff4)\n \n uncertain_matrix_title = Text(\"Game Matrix (With Uncertainty)\").next_to(grid, UP)\n \n self.play(FadeOut(payoffs))\n self.play(Write(uncertain_payoffs))\n self.play(FadeOut(matrix_title))\n self.play(Write(uncertain_matrix_title))\n self.wait(1)\n \n # Uncertainty circle - showing range of equilibria\n circle = Circle(radius=1, color=RED).move_to([0, 0, 0])\n uncertainty_label = Text(\"Equilibrium Range with Uncertainty\").next_to(circle, UP)\n \n self.play(Create(circle))\n self.play(Write(uncertainty_label))\n self.wait(1)\n \n # Clear the screen for equation\n self.play(FadeOut(grid), FadeOut(uncertain_payoffs), FadeOut(uncertain_matrix_title))\n self.play(FadeOut(eq_point), FadeOut(eq_label))\n self.play(FadeOut(circle), FadeOut(uncertainty_label))\n \n # Show equation\n eq = Text(\"p*x(A) + (1-p)*x(B) = C\")\n \n self.play(Write(eq))\n self.wait(2)\n \n # Final message\n final_message = Text(\"Uncertainty broadens strategic possibilities\")\n \n self.play(FadeOut(eq))\n self.play(Write(final_message))\n self.wait(2)\n self.play(FadeOut(final_message))\n```"}]} {"id": "adaption-unified-manim-instructions_007091", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animation that visually demonstrates the process of solving a first-order linear ordinary differential equation (ODE), specifically showing the ODE y' - 3y = 0, and then methodically solving it by using an integrating factor, resulting in the general solution y(x) = Ce^(3x)? The steps should include writing down the equation, displaying text cues for each step like 'Solve the differential equation', 'Use the integrating factor', and 'General solution of the first-order ODE', following with the appropriate mathematical expressions and animations that transform one step to the next. Lastly, can you conclude the animation by clearing the screen and highlighting the general solution?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SolveLinearODE(Scene):\n def construct(self):\n # --- Configuration ---\n cue_color = BLUE_B\n math_color = WHITE\n highlight_color = YELLOW\n\n # --- 1. Initialization ---\n # Write down the initial equation: y' - 3y = 0\n initial_eq = MathTex(r\"y' - 3y = 0\", color=math_color).scale(1.2)\n \n self.play(Write(initial_eq))\n self.wait(1)\n\n # --- 2. Step-by-Step Solution ---\n # Step 1: Display the text cue: \"Solve the differential equation\"\n cue1 = Text(\"Solve the differential equation\", font_size=36, color=cue_color)\n cue1.to_edge(UP)\n \n self.play(Write(cue1))\n initial_eq.next_to(cue1, DOWN, buff=1)\n self.play(initial_eq.animate.next_to(cue1, DOWN, buff=1))\n self.wait(1)\n\n # Step 2: Display the text cue: \"Use the integrating factor\"\n cue2 = Text(\"Use the integrating factor\", font_size=36, color=cue_color)\n cue2.to_edge(UP)\n \n self.play(Transform(cue1, cue2))\n\n # Identify P(x) = -3\n p_text = MathTex(r\"P(x) = -3\", color=math_color).scale(0.9)\n p_text.next_to(initial_eq, DOWN, buff=0.8)\n \n self.play(Write(p_text))\n self.wait(1)\n\n # Calculate Integrating Factor mu(x) = e^(-3x)\n integrating_factor = MathTex(\n r\"\\mu(x) = e^{\\int -3 \\, dx} = e^{-3x}\", \n color=math_color\n ).scale(0.9)\n integrating_factor.next_to(p_text, DOWN, buff=0.5)\n \n self.play(Write(integrating_factor))\n self.wait(1)\n\n # Multiply equation by integrating factor\n eq_multiplied = MathTex(r\"e^{-3x}(y' - 3y) = 0\", color=math_color).scale(1.1)\n eq_multiplied.move_to(initial_eq)\n \n self.play(\n ReplacementTransform(initial_eq, eq_multiplied),\n p_text.animate.shift(LEFT * 3 + DOWN * 0.5).scale(0.8),\n integrating_factor.animate.shift(LEFT * 3 + DOWN * 0.5).scale(0.8)\n )\n self.wait(1)\n\n # Recognize the product rule (The core of the integrating factor method)\n eq_derivative = MathTex(\n r\"\\frac{d}{dx} \\left[ e^{-3x} y \\right] = 0\", \n color=math_color\n ).scale(1.1).move_to(eq_multiplied)\n \n self.play(ReplacementTransform(eq_multiplied, eq_derivative))\n self.wait(1)\n\n # Integrate both sides\n eq_integrated = MathTex(r\"e^{-3x} y = C\", color=math_color).scale(1.1)\n eq_integrated.move_to(eq_derivative)\n \n self.play(ReplacementTransform(eq_derivative, eq_integrated))\n self.wait(1)\n\n # Step 3: Display the text cue: \"General solution of the first-order ODE\"\n cue3 = Text(\"General solution of the first-order ODE\", font_size=36, color=cue_color)\n cue3.to_edge(UP)\n \n self.play(Transform(cue1, cue3))\n\n # Final algebraic step to isolate y\n final_solution = MathTex(r\"y(x) = Ce^{3x}\", color=math_color).scale(1.2)\n final_solution.move_to(eq_integrated)\n \n self.play(\n ReplacementTransform(eq_integrated, final_solution),\n FadeOut(p_text),\n FadeOut(integrating_factor)\n )\n self.wait(2)\n\n # --- 3. Conclusion ---\n # Clear the screen of intermediate steps and text cues\n self.play(FadeOut(cue1))\n \n # Highlight the final general solution y(x) = Ce^(3x) prominently\n self.play(\n final_solution.animate.move_to(ORIGIN).set_color(highlight_color).scale(1.5)\n )\n \n # Create a box around the final solution for emphasis\n box = SurroundingRectangle(final_solution, color=highlight_color, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n```"}]} {"id": "adaption-unified-manim-instructions_000060", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation that visually demonstrates how one can calculate the area under a parabola. The graph should be of the function f(x) = x^2, and the specific area from x = -2 to x = 2 needs to be shaded to represent the area being calculated. Initially, a blue curve represents the function, and the related mathematical integral equation should also appear next to it. The equation should then move to the top of the screen while the area gets shaded in blue beneath the curve. Thereafter, I want the animation to show the step-by-step calculation of the integral, including writing the antiderivative, evaluating the definite integral at the boundaries, and simplifying the final answer. Each mathematical step should replace the previous one in a clear and understandable manner. Finally, when the full calculation is complete, the animation should clear all content except for the final solution, and then re-display that solution for emphasis. Can you create an animation like this for my mathematics students to help them visualize the integration process?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # --- 1. Initial Scene ---\n # Create axes tailored to the function range\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_tip\": True}\n )\n \n # Plot the function f(x) = x^2 as a blue curve\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[-2, 2])\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\")\n \n # Initial Integral Equation positioned next to the graph\n integral_eq = MathTex(\n r\"\\int_{-2}^{2} x^2 \\, dx\",\n font_size=40\n ).to_edge(RIGHT, buff=1.5).shift(UP * 0.5)\n \n self.play(Create(axes), Create(curve), Write(curve_label), Write(integral_eq))\n self.wait(1)\n \n # --- 2. Transition ---\n # Move equation to the top center to act as a header for the calculation\n integral_top = integral_eq.copy().to_edge(UP).shift(DOWN * 0.5)\n \n # Shade the area beneath the curve in blue to visualize the geometric meaning\n area = axes.get_area(curve, x_range=[-2, 2], color=BLUE, opacity=0.5)\n \n self.play(\n Transform(integral_eq, integral_top),\n FadeIn(area),\n run_time=1.5\n )\n self.wait(1)\n \n # --- 3. Step-by-Step Calculation ---\n # Each step replaces the previous one to maintain focus and reduce cognitive load\n \n # Step A: Antiderivative\n step_a = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\",\n font_size=40\n ).move_to(integral_top)\n self.play(Transform(integral_eq, step_a))\n self.wait(2) # Pause allows students to verify the power rule\n \n # Step B: Evaluate at boundaries\n step_b = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\",\n font_size=40\n ).move_to(integral_top)\n self.play(Transform(integral_eq, step_b))\n self.wait(2) # Pause for arithmetic processing\n \n # Step C: Simplify arithmetic\n step_c = MathTex(\n r\"= \\frac{8}{3} - \\left(-\\frac{8}{3}\\right)\",\n font_size=40\n ).move_to(integral_top)\n self.play(Transform(integral_eq, step_c))\n self.wait(2)\n \n # Step D: Final Answer (Intermediate)\n step_d = MathTex(\n r\"= \\frac{16}{3}\",\n font_size=40\n ).move_to(integral_top)\n self.play(Transform(integral_eq, step_d))\n self.wait(1)\n \n # --- 4. Final Emphasis ---\n # Clear all content except the solution to remove potential distractions\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(area),\n run_time=1\n )\n \n # Scale up the final solution for prominence\n final_result = MathTex(\n r\"\\text{Area} = \\frac{16}{3}\",\n font_size=72,\n color=BLUE\n )\n \n # Transform the small result to the large centered result\n self.play(Transform(integral_eq, final_result))\n self.play(Indicate(final_result))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_003020", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "\"Can you create an animated video that visually demonstrates how data flows through a simple convolutional neural network with the following layer configuration: one input channel followed by three convolutional layers with 8, 6, and 2 filters respectively, and the second and third convolutional layers having a kernel size of 3 and 2, and include a max pooling layer with a kernel size of 2 between the second and third convolutional layers? Also, please make sure that the network is centered on the screen and add a pause for one second before showing the data flow animation.\""}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass CNNDataFlow(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Configuration & Architecture Definitions\n # ------------------------------------------------------------------\n # (num_filters, name, color, label)\n layer_configs = [\n (1, \"Input\", BLUE, \"1 Channel\"),\n (8, \"Conv1\", GOLD, \"8 Filters\"),\n (6, \"Conv2\", GOLD, \"6 Filters\\nK=3\"),\n (6, \"MaxPool\", ORANGE, \"Max Pool\\nK=2\"), # Preserves 6 channels, reduces spatial size\n (2, \"Conv3\", GOLD, \"2 Filters\\nK=2\"),\n ]\n\n layers = VGroup()\n labels = VGroup()\n \n spacing = 2.5\n\n # ------------------------------------------------------------------\n # Build Network Visualization\n # ------------------------------------------------------------------\n for i, (num_filters, name, color, label_text) in enumerate(layer_configs):\n layer_group = VGroup()\n \n # Size decreases to visually represent spatial reduction through the network\n size_factor = 1.0 - (i * 0.1)\n rect_w = 0.6 * size_factor\n rect_h = 0.6 * size_factor\n \n for j in range(num_filters):\n rect = Rectangle(\n width=rect_w, height=rect_h,\n stroke_width=1, stroke_color=WHITE, fill_opacity=0.5\n )\n # 3D stack effect\n rect.shift(UP * (j * 0.1) + RIGHT * (j * 0.05))\n layer_group.add(rect)\n \n layer_group.set_color(color)\n # Center horizontally based on number of layers\n layer_group.move_to([i * spacing - (len(layer_configs)-1)*spacing/2, 0, 0])\n layers.add(layer_group)\n \n lbl = Text(label_text, font_size=16).next_to(layer_group, DOWN, buff=0.5)\n labels.add(lbl)\n\n # Add arrows between layers\n arrows = VGroup()\n for i in range(len(layers) - 1):\n arrow = Arrow(\n start=layers[i].get_right(),\n end=layers[i+1].get_left(),\n buff=0.15,\n color=WHITE,\n max_tip_length_to_length_ratio=0.15\n )\n arrows.add(arrow)\n\n # Group everything and center on screen\n network = VGroup(layers, labels, arrows)\n network.move_to(ORIGIN)\n\n # ------------------------------------------------------------------\n # Animation Sequence\n # ------------------------------------------------------------------\n # 1. Introduce Network Structure\n self.play(Create(network), run_time=2)\n \n # 2. Requirement: 1-second pause before initiating data flow\n self.wait(1)\n\n # 3. Visualize Data Flow (Propagation)\n for i in range(len(layers) - 1):\n current_layer = layers[i]\n next_layer = layers[i+1]\n \n # Highlight current layer briefly to signify processing\n self.play(current_layer.animate.set_fill(opacity=1.0), run_time=0.3)\n \n # Create multiple pulses to signify \"data flow\"\n pulses = VGroup()\n for _ in range(3):\n pulse = Dot(color=next_layer[0].get_color(), radius=0.08).move_to(current_layer.get_center())\n pulses.add(pulse)\n \n self.play(FadeIn(pulses), run_time=0.2)\n \n # Animate pulses moving to the next layer\n self.play(pulses.animate.move_to(next_layer.get_center()), run_time=0.8, rate_func=linear)\n \n # Reset current layer opacity and fade out pulses upon arrival\n self.play(\n current_layer.animate.set_fill(opacity=0.5),\n FadeOut(pulses),\n run_time=0.3\n )\n\n # Final highlight on the output layer\n self.play(layers[-1].animate.set_fill(opacity=1.0), run_time=0.5)\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_000684", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational animation that visually shows the area under the curve of y = x^2 from x=0 to x=2, includes the integral symbol with the corresponding limits, demonstrates the calculation of the definite integral, and then displays the final numerical result of the integral calculation? Additionally, after showing the final result, can you make sure that all elements are cleared from the screen?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # 1. Setup Axes and Graph\n # Create axes with appropriate ranges to clearly view x=0 to x=2\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 4]},\n ).shift(LEFT * 3)\n\n # Define the function y = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-1, 2.5])\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\", x_val=2.2, direction=UR)\n\n # 2. Shade the Area Under the Curve\n # Strictly between x=0 and x=2\n area = axes.get_area(\n graph,\n x_range=[0, 2],\n color=GREEN,\n opacity=0.5\n )\n\n # 3. Prepare Integral Calculation Steps\n # Step 1: The Definite Integral Notation\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42)\n \n # Step 2: Antiderivative\n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n \n # Step 3: Evaluation of Limits\n evaluation = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n \n # Step 4: Final Numerical Result\n result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=42, color=YELLOW)\n\n # Group calculation steps and position them to the right of the graph\n calculation_group = VGroup(integral_expr, antiderivative, evaluation, result)\n calculation_group.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n calculation_group.next_to(axes, RIGHT, buff=1.5)\n calculation_group.shift(UP * 0.5)\n\n # --- Animation Sequence ---\n\n # Draw Axes and Graph\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # Shade the Area\n self.play(FadeIn(area))\n self.wait(1)\n\n # Display Integral Notation\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Demonstrate Step-by-Step Calculation\n self.play(Write(antiderivative))\n self.wait(1)\n \n self.play(Write(evaluation))\n self.wait(1)\n \n self.play(Write(result))\n self.wait(2)\n\n # 4. Cleanup: Clear all visual elements from the screen\n # FadeOut for visual smoothness, followed by clear command to reset scene state\n self.play(FadeOut(*self.mobjects))\n self.clear()\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_002364", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here’s an enhanced version of the animation that retains the original dodecagon while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the educational value: \n\nThe animation begins by drawing a pink dodecagon (12-sided polygon) at the center of the screen with a smooth `Create` animation. Once fully formed, the dodecagon pulsates gently to draw attention. Then, text appears above it reading *\"Regular Dodecagon: 12 Sides, 150° Interior Angles\"*, while the formula for interior angles, *θ = (n-2)×180° / n*, fades in below, dynamically solving for *n=12* to display *150°*. Next, the dodecagon morphs into a star dodecagon (12-pointed star) by connecting every fifth vertex, with the transformation highlighted by a glowing outline. Finally, the star rotates smoothly, emphasizing its symmetry, while the original dodecagon faintly remains in the background for comparison. The animation concludes by fading out all elements except the star, leaving a lasting visual impression. \n\nThis enhanced version not only displays the shape but also educates viewers about its properties and demonstrates a geometric transformation, making it more engaging and informative."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass EnhancedDodecagon(Scene):\n def construct(self):\n # Create the dodecagon\n dodecagon = RegularPolygon(n=12, color=PINK, fill_opacity=0.8)\n dodecagon.scale(2)\n\n # Draw the dodecagon\n self.play(Create(dodecagon), run_time=2)\n self.play(\n dodecagon.animate.scale(1.1),\n run_time=0.5,\n rate_func=there_and_back\n )\n\n # Add text and formula\n text = Tex(\"Regular Dodecagon: 12 Sides, 150° Interior Angles\", color=WHITE)\n text.to_edge(UP)\n\n formula = MathTex(r\"\\theta = \\frac{(n-2) \\times 180^\\circ}{n}\", color=YELLOW)\n solution = MathTex(r\"\\theta = \\frac{(12-2) \\times 180^\\circ}{12} = 150^\\circ\", color=YELLOW)\n formula.next_to(dodecagon, DOWN)\n solution.next_to(formula, DOWN)\n\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n self.play(Write(formula), run_time=1.5)\n self.wait(0.5)\n self.play(Write(solution), run_time=1.5)\n self.wait(1)\n\n # Morph into a star dodecagon\n star = Star(12, outer_radius=2, color=BLUE, fill_opacity=0.8)\n star_dodecagon = VGroup(dodecagon.copy(), star)\n\n self.play(\n Transform(dodecagon, star),\n run_time=2,\n rate_func=smooth\n )\n\n # Highlight the transformation\n glow = SurroundingRectangle(star, color=BLUE, buff=0.1, fill_opacity=0.2)\n self.play(\n Create(glow),\n run_time=1,\n rate_func=there_and_back\n )\n self.remove(glow)\n\n # Rotate the star\n self.play(\n Rotate(star, angle=PI/6, about_point=ORIGIN),\n run_time=3,\n rate_func=smooth\n )\n\n # Fade out everything except the star\n self.play(\n FadeOut(text),\n FadeOut(formula),\n FadeOut(solution),\n run_time=1.5\n )\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_007099", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an animation that explains how to integrate the function sin(x)cos(x) using a trigonometric identity, with the steps clearly shown and the final answer highlighted?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSinCos(Scene):\n def construct(self):\n # --- Title ---\n title = Text(\"Integrating sin(x)cos(x)\", font_size=40).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # --- Step 1: Original Integral ---\n integral_orig = MathTex(r\"\\int\", r\"\\sin(x)\", r\"\\cos(x)\", r\"\\,dx\")\n integral_orig.next_to(title, DOWN, buff=1)\n self.play(Write(integral_orig))\n self.wait(1)\n\n # --- Step 2: Trigonometric Identity ---\n identity_label = Text(\"Using Identity:\", font_size=24).next_to(integral_orig, DOWN, buff=0.6)\n identity_eq = MathTex(r\"\\sin(2x)\", \"=\", r\"2\", r\"\\sin(x)\", r\"\\cos(x)\")\n identity_eq.next_to(identity_label, DOWN, buff=0.2)\n \n # Color code the identity for visual clarity\n identity_eq.set_color_by_tex(\"2x\", BLUE)\n identity_eq.set_color_by_tex(\"2\", GREEN)\n \n self.play(Write(identity_label), Write(identity_eq))\n self.wait(1)\n\n # Rearrange identity to show the substitution term\n identity_sub = MathTex(r\"\\Rightarrow\", r\"\\sin(x)\\cos(x)\", \"=\", r\"\\frac{1}{2}\\sin(2x)\")\n identity_sub.next_to(identity_eq, DOWN, buff=0.2)\n identity_sub.set_color_by_tex(\"frac\", GREEN)\n identity_sub.set_color_by_tex(\"2x\", BLUE)\n \n self.play(Write(identity_sub))\n self.wait(1)\n\n # --- Step 3: Apply Substitution to Integral ---\n integral_step1 = MathTex(r\"=\", r\"\\int\", r\"\\frac{1}{2}\\sin(2x)\", r\"\\,dx\")\n integral_step1.next_to(identity_sub, DOWN, buff=0.8)\n integral_step1.set_color_by_tex(\"frac\", GREEN)\n integral_step1.set_color_by_tex(\"2x\", BLUE)\n \n # Animate the transition from the original integral to the substituted one\n self.play(ReplacementTransform(integral_orig.copy(), integral_step1))\n self.wait(1)\n\n # Fade out the identity helper lines to make room for the rest of the derivation\n self.play(FadeOut(identity_label), FadeOut(identity_eq), FadeOut(identity_sub))\n integral_step1.generate_target()\n integral_step1.target.next_to(title, DOWN, buff=1)\n self.play(MoveToTarget(integral_step1))\n self.wait(0.5)\n\n # --- Step 4: Pull out the constant ---\n integral_step2 = MathTex(r\"=\", r\"\\frac{1}{2}\", r\"\\int\", r\"\\sin(2x)\", r\"\\,dx\")\n integral_step2.next_to(integral_step1, DOWN, buff=0.6, aligned_edge=LEFT)\n integral_step2.set_color_by_tex(\"frac\", GREEN)\n integral_step2.set_color_by_tex(\"2x\", BLUE)\n \n self.play(ReplacementTransform(integral_step1.copy(), integral_step2))\n self.wait(1)\n\n # --- Step 5: Perform the Integration ---\n integral_step3 = MathTex(\n r\"=\", r\"\\frac{1}{2}\", \n r\"\\left(\", r\"-\", r\"\\frac{1}{2}\", r\"\\cos(2x)\", r\"\\right)\", \n r\"+\", \"C\"\n )\n integral_step3.next_to(integral_step2, DOWN, buff=0.6, aligned_edge=LEFT)\n integral_step3.set_color_by_tex(\"frac\", GREEN)\n integral_step3.set_color_by_tex(\"2x\", BLUE)\n \n self.play(ReplacementTransform(integral_step2.copy(), integral_step3))\n self.wait(1)\n\n # --- Step 6: Final Simplification ---\n final_result = MathTex(r\"=\", r\"-\", r\"\\frac{1}{4}\", r\"\\cos(2x)\", r\"+\", \"C\")\n final_result.next_to(integral_step3, DOWN, buff=0.6, aligned_edge=LEFT)\n final_result.set_color_by_tex(\"frac\", GREEN)\n final_result.set_color_by_tex(\"2x\", BLUE)\n \n self.play(ReplacementTransform(integral_step3.copy(), final_result))\n self.wait(1)\n\n # Highlight the final answer distinctly\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n label = Text(\"Final Answer\", font_size=24, color=YELLOW).next_to(box, DOWN, buff=0.1)\n \n self.play(Create(box), Write(label))\n self.play(Indicate(final_result))\n \n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py IntegrateSinCos\n```"}]} {"id": "adaption-unified-manim-instructions_006838", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that visually explains how to find the area under the curve of the function f(x) = x^2 from x=1 to x=3, by demonstrating the process of setting up the integral, evaluating it step by step, and concluding with the exact numerical value of the area?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Setup Axes and Plot ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 3]},\n ).scale(0.8).to_edge(LEFT, buff=1.5)\n\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Define the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.2])\n curve_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(curve, UR, buff=0.2)\n\n # --- 2. Highlight the Region ---\n # Fill the area under the curve between x=1 and x=3\n area = axes.get_area(curve, x_range=[1, 3], color=GREEN, opacity=0.5)\n\n # Create vertical lines to bound the region clearly\n line_left = axes.get_vertical_line(axes.c2p(1, 1), color=WHITE, stroke_width=2)\n line_right = axes.get_vertical_line(axes.c2p(3, 9), color=WHITE, stroke_width=2)\n\n # --- 3. Prepare Mathematical Steps ---\n # Position for the equations on the right side of the screen\n eq_setup = MathTex(r\"\\text{Area} = \\int_{1}^{3} x^2 \\, dx\")\n eq_antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\")\n eq_substitution = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\")\n eq_arithmetic = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\")\n eq_final = MathTex(r\"= \\frac{26}{3} \\approx 8.67\", color=YELLOW)\n\n # Group math steps and arrange them vertically\n math_steps = VGroup(\n eq_setup, eq_antiderivative, eq_substitution, eq_arithmetic, eq_final\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n math_steps.to_edge(RIGHT, buff=1).shift(UP * 1.5)\n\n # --- 4. Animation Sequence ---\n\n # Draw the coordinate system and function\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # Show the bounds and the area\n self.play(Create(line_left), Create(line_right))\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # Display the integral setup\n self.play(Write(eq_setup))\n self.wait(1)\n\n # Step-by-step Evaluation\n # 1. Find Antiderivative\n self.play(Write(eq_antiderivative))\n self.wait(1)\n\n # 2. Substitute Limits\n self.play(Write(eq_substitution))\n self.wait(1)\n\n # 3. Simplify Arithmetic\n self.play(Write(eq_arithmetic))\n self.wait(1)\n\n # 4. Show Final Result\n self.play(Write(eq_final))\n self.play(Indicate(eq_final))\n self.wait(1)\n\n # Conclusion emphasis\n self.play(\n FadeOut(eq_setup),\n FadeOut(eq_antiderivative),\n FadeOut(eq_substitution),\n FadeOut(eq_arithmetic)\n )\n self.play(eq_final.animate.shift(UP * 2).scale(1.5).set_color(GOLD))\n self.wait(2)\n```"}]} {"id": "manim-sft-10k_001706", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "How do we represent the transformation of a Schwartz function under the Fourier transform?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SchwartzFourierTransform(Scene):\n def construct(self):\n # Set dark background\n self.camera.background_color = \"#1A1A1A\"\n \n # Introduction\n title = Text(\"The Elegant Dance of Schwartz Functions\", \n font_size=32, color=BLUE)\n subtitle = Text(\"and Fourier Transforms\", \n font_size=32, color=BLUE)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Key Concept 1: Schwartz Function\n concept1 = Text(\"What is a Schwartz Function?\", font_size=28, color=YELLOW)\n concept1.to_edge(UP)\n self.play(Write(concept1))\n \n # Simple axes\n x_axis = Line([-4, 0, 0], [4, 0, 0], color=BLUE)\n y_axis = Line([0, -1.5, 0], [0, 1.5, 0], color=BLUE)\n axes = VGroup(x_axis, y_axis)\n \n # Create a simple bell curve using an arc\n bell = Arc(\n radius=2,\n start_angle=-PI/2,\n angle=PI,\n color=GOLD\n )\n bell.stretch_to_fit_width(6)\n bell.stretch_to_fit_height(2)\n bell.move_to([0, 0, 0])\n \n # Show the axes and bell curve\n self.play(Create(axes))\n self.play(Create(bell))\n \n # Label the function\n function_label = Text(\"f(x)\", font_size=24, color=GOLD)\n function_label.next_to(bell, UP)\n self.play(Write(function_label))\n \n # Equation for Schwartz space\n eq1 = Text(\"f(x) in S(R)\", font_size=24, color=WHITE)\n eq1.next_to(axes, DOWN, buff=0.5)\n self.play(Write(eq1))\n self.wait(1)\n \n # Key Concept 2: Fourier Transform\n concept2 = Text(\"Fourier Transform\", font_size=28, color=YELLOW)\n concept2.to_edge(UP)\n self.play(ReplacementTransform(concept1, concept2))\n \n # Fourier transform equation\n eq2 = Text(\"F[f(x)] = \\int f(x)e^(-2\\pi ixy) dx\", font_size=24, color=WHITE)\n eq2.next_to(axes, DOWN, buff=0.5)\n self.play(ReplacementTransform(eq1, eq2))\n self.wait(1)\n \n # Transform to a simple wavy line\n # Just use a few dots connected by lines to represent a wavy function\n wave_dots = VGroup()\n wave_dots.add(Dot([-3, 0, 0], color=GREEN))\n wave_dots.add(Dot([-2, 0.7, 0], color=GREEN))\n wave_dots.add(Dot([-1, -0.5, 0], color=GREEN))\n wave_dots.add(Dot([0, 0.7, 0], color=GREEN))\n wave_dots.add(Dot([1, -0.5, 0], color=GREEN))\n wave_dots.add(Dot([2, 0.7, 0], color=GREEN))\n wave_dots.add(Dot([3, 0, 0], color=GREEN))\n \n wave_line = VGroup()\n for i in range(len(wave_dots) - 1):\n line = Line(wave_dots[i].get_center(), wave_dots[i+1].get_center(), color=GREEN)\n wave_line.add(line)\n \n # Transform the bell curve to the wave\n self.play(\n FadeOut(bell),\n FadeIn(wave_dots),\n FadeIn(wave_line)\n )\n \n # Transform the label\n new_label = Text(\"F[f(x)]\", font_size=24, color=GREEN)\n new_label.next_to(wave_dots, UP)\n self.play(ReplacementTransform(function_label, new_label))\n self.wait(1)\n \n # Key Concept 3: Remain in Schwartz Space\n concept3 = Text(\"Remain in Schwartz Space\", font_size=28, color=YELLOW)\n concept3.to_edge(UP)\n self.play(ReplacementTransform(concept2, concept3))\n \n # Key Insight\n insight = Text(\"The transformed function remains in S(R)!\", \n font_size=28, color=BLUE)\n insight.to_edge(DOWN, buff=1)\n self.play(Write(insight))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(concept3), FadeOut(axes), FadeOut(wave_dots), \n FadeOut(wave_line), FadeOut(new_label), FadeOut(eq2), FadeOut(insight)\n )\n \n conclusion = Text(\"The beauty of Functional Analysis\", \n font_size=32, color=GOLD)\n conclusion2 = Text(\"revealed through Schwartz Space\", \n font_size=32, color=GOLD)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.play(Write(conclusion2))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(conclusion2))\n```"}]} {"id": "adaption-unified-manim-instructions_004668", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create a vertical animation that shows all the unique ways to divide the number 10, displaying one-by-one, with the divisors and the results of each division getting larger, and then highlighting the divisors 1, 2, 5, and 10 with a red border before everything fades out? The background color should be customizable, and the animation should be suitable for a 1080x1920 portrait video format with the aspect ratio maintained at 9:16."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\n# ==============================================================================\n# Configuration Settings\n# ==============================================================================\n# Set resolution to 1080x1920 for Portrait (9:16 Aspect Ratio)\nconfig.pixel_width = 1080\nconfig.pixel_height = 1920\n\n# Customizable background color variable\nCUSTOM_BACKGROUND_COLOR = \"#1a1a1a\" # Dark Gray\n\nclass DivisorsOfTen(Scene):\n def construct(self):\n # Apply the customizable background color to the camera\n self.camera.background_color = CUSTOM_BACKGROUND_COLOR\n\n # ======================================================================\n # 1. Data Preparation\n # ======================================================================\n number = 10\n # Calculate all unique integer divisors of 10\n divisors = [d for d in range(1, number + 1) if number % d == 0]\n \n # Groups to manage animation elements\n all_equations = VGroup()\n divisor_tex_objects = VGroup()\n\n # ======================================================================\n # 2. Sequence & 3. Visualization\n # ======================================================================\n # Iterate through divisors in ascending order (1, 2, 5, 10)\n # Note: While the prompt mentions results getting larger, \n # ascending divisors mathematically result in descending quotients.\n # We follow the explicit instruction to list divisors in ascending order.\n \n for i, d in enumerate(divisors):\n result = number // d\n \n # Create MathTex equation with separate arguments for easy indexing\n # Format: 10 / d = result\n # Indices: 0->10, 1->/, 2->divisor, 3->=, 4->result\n equation = MathTex(\n str(number), \"/\", str(d), \"=\", str(result),\n font_size=72 # Optimized for portrait mobile viewing\n )\n \n # Store the divisor part (index 2) for later highlighting\n divisor_tex = equation[2]\n divisor_tex_objects.add(divisor_tex)\n \n # Apply a subtle scaling effect so equations \"get larger\" visually\n scale_factor = 1 + (i * 0.15)\n equation.scale(scale_factor)\n \n all_equations.add(equation)\n\n # Arrange equations vertically in the center with consistent spacing\n all_equations.arrange(DOWN, buff=0.6)\n all_equations.move_to(ORIGIN)\n\n # Animate each equation appearing one-by-one with a \"pop\" effect\n for equation in all_equations:\n self.play(Write(equation), run_time=0.8)\n self.play(equation.animate.scale(1.05), run_time=0.15)\n self.play(equation.animate.scale(1/1.05), run_time=0.15)\n self.wait(0.3)\n\n self.wait(1.0)\n\n # ======================================================================\n # 4. Highlighting\n # ======================================================================\n # Highlight divisors 1, 2, 5, and 10 with a red border\n highlight_borders = VGroup()\n \n for d_tex in divisor_tex_objects:\n # Create a red surrounding rectangle\n border = SurroundingRectangle(\n d_tex, \n color=RED, \n buff=0.15, \n stroke_width=4,\n corner_radius=0.1\n )\n highlight_borders.add(border)\n \n # Animate the creation of the highlight borders\n self.play(Create(highlight_borders), run_time=1.5)\n self.wait(1.5)\n\n # ======================================================================\n # 5. Conclusion\n # ======================================================================\n # Fade out all elements smoothly to end the scene\n all_elements = VGroup(all_equations, highlight_borders)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait()\n```"}]} {"id": "manim-sft-10k_003849", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### Kleene Star and Repetition Structures\nThe Kleene star ($A^*$) denotes that the elements of language $A$ can be repeated zero or more times. This is the core operator for describing loops and infinite sequences.\n\n\nContextual location of this section (from highest to current level):\n# Introduction to Formal Languages and Automata\n## Basic Operations on Languages\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass KleeneStar(Scene):\n\n def construct(self):\n title = Tex('\\\\textbf{Kleene Star and Repetition Structures}', color=BLUE)\n title.to_edge(UP)\n def_text = Tex('The Kleene star ($A^*$) denotes that the elements of language $A$\\\\\\\\ ', 'can be repeated zero or more times.')\n def_text.scale(0.8)\n def_text.next_to(title, DOWN, buff=0.6)\n example_A = MathTex('A = \\\\{a, b\\\\}')\n expansion = MathTex('A^* = A^0 \\\\cup A^1 \\\\cup A^2 \\\\cup \\\\dots')\n example_star = MathTex('A^* = \\\\{\\\\epsilon, a, b, aa, ab, ba, bb, aaa, \\\\dots\\\\}')\n math_group = VGroup(example_A, expansion, example_star).arrange(DOWN, buff=0.6)\n math_group.next_to(def_text, DOWN, buff=0.8)\n box = SurroundingRectangle(example_star, color=YELLOW, buff=0.2)\n core_text = Text('This is the core operator for describing loops and infinite sequences.', font_size=28, color=YELLOW)\n core_text.next_to(math_group, DOWN, buff=0.8)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(def_text, shift=UP * 0.3))\n self.wait(1)\n self.play(Write(example_A))\n self.wait(0.5)\n self.play(Write(expansion))\n self.wait(0.5)\n self.play(Write(example_star))\n self.play(Create(box))\n self.wait(1)\n self.play(FadeIn(core_text, shift=UP * 0.3))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_008130", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create a short animation video using 2D shapes, where a circle transforms into a square. The video should start with a circle appearing on screen, then after a moment, the circle should seamlessly morph into a square. Once the square appears, I want it to change to a blue color with some transparency. After that, can the square rotate 45 degrees? Finally, clear everything off the screen and display the phrase \"Transformation complete!\" in the center. Can you make this sequence of animations for me?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TransformationSequence(Scene):\n def construct(self):\n # 1. Initial State: A circle appears on the screen.\n circle = Circle(radius=1.5, color=WHITE)\n self.play(Create(circle))\n self.wait(0.5)\n\n # 2. Morphing: The circle seamlessly transforms into a square.\n square = Square(side_length=3, color=WHITE)\n self.play(ReplacementTransform(circle, square))\n self.wait(0.5)\n\n # 3. Styling: Change color to blue and apply partial transparency.\n self.play(\n square.animate.set_fill(BLUE, opacity=0.5).set_stroke(BLUE, opacity=0.8)\n )\n self.wait(0.5)\n\n # 4. Rotation: Rotate the square by 45 degrees.\n self.play(Rotate(square, angle=45 * DEGREES))\n self.wait(0.5)\n\n # 5. Conclusion: Clear all objects from the screen and display the text.\n self.play(FadeOut(square))\n \n text = Text(\"Transformation complete!\", font_size=36)\n self.play(Write(text))\n self.wait(2)\n```"}]} {"id": "ry_manim_codegen_000013", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "How does the Kullback-Leibler Divergence distinguish between two normal distributions with varying means and identical variances?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass KLDivergenceScene(Scene):\n def construct(self):\n # Title with smaller font size to fit better\n title = Text(\"Seeing through the Lens of KL Divergence\", font_size=36)\n subtitle = Text(\"A Journey between Bell Curves\", font_size=24)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Set up axes for bell curves\n axes = Axes(\n x_range=[-5, 5, 1],\n y_range=[0, 0.5, 0.1],\n axis_config={\"color\": BLUE}\n ).scale(0.9) # Scale down slightly to fit better\n \n # Define normal distributions with different means\n mean1, mean2 = -1.5, 1.5\n std_dev = 1\n \n # Function to create normal distribution curve\n def normal_dist(x, mean=0, std_dev=1):\n return np.exp(-0.5 * ((x - mean) / std_dev) ** 2) / (std_dev * np.sqrt(2 * np.pi))\n \n # Create bell curves\n curve1 = axes.plot(lambda x: normal_dist(x, mean=mean1, std_dev=std_dev), color=BLUE_C)\n curve2 = axes.plot(lambda x: normal_dist(x, mean=mean2, std_dev=std_dev), color=PURPLE_C)\n \n # Show the axes and curves\n self.play(Create(axes))\n self.play(Create(curve1))\n self.wait(0.5)\n self.play(Create(curve2))\n self.wait(1)\n \n # Labels for curves\n p_label = Text(\"P(x)\", color=BLUE_C).move_to(axes.c2p(-3, 0.4))\n q_label = Text(\"Q(x)\", color=PURPLE_C).move_to(axes.c2p(3, 0.4))\n self.play(Write(p_label), Write(q_label))\n \n # KL Divergence formula (simplified)\n kl_formula = Text(\"D_KL(P || Q) = \\int p(x) log(p(x)/q(x)) dx\", font_size=28)\n kl_formula.to_edge(UP)\n \n self.play(Write(kl_formula))\n self.wait(1)\n \n # Shading area between curves to highlight divergence (simplified approach)\n shading = Rectangle(width=3, height=0.3, fill_opacity=0.3, fill_color=RED_C, stroke_width=0)\n shading.move_to(axes.c2p(0, 0.15))\n self.play(FadeIn(shading))\n self.wait(1)\n self.play(FadeOut(shading))\n \n # Show the means as campfires\n campfire1 = Circle(radius=0.2, fill_opacity=0.8, fill_color=YELLOW, stroke_color=YELLOW_D).move_to(axes.c2p(mean1, 0))\n campfire2 = Circle(radius=0.2, fill_opacity=0.8, fill_color=YELLOW, stroke_color=YELLOW_D).move_to(axes.c2p(mean2, 0))\n \n mean1_label = Text(\"μ₁\", color=BLUE_C).next_to(campfire1, DOWN)\n mean2_label = Text(\"μ₂\", color=PURPLE_C).next_to(campfire2, DOWN)\n \n self.play(Create(campfire1), Write(mean1_label))\n self.play(Create(campfire2), Write(mean2_label))\n \n # Arrow showing the inefficiency path\n arrow = Arrow(campfire1.get_center(), campfire2.get_center(), color=RED_C)\n arrow_label = Text(\"Inefficiency\", font_size=20, color=RED_C).next_to(arrow, UP, buff=0.1)\n \n self.play(Create(arrow))\n self.play(Write(arrow_label))\n self.wait(1)\n \n # Final explanation (shortened to fit better)\n explanation = Text(\"KL Divergence: The cost of incorrect assumptions\", font_size=28)\n explanation.to_edge(DOWN)\n \n self.play(Write(explanation))\n self.wait(2)\n \n # Clean up\n self.play(\n *[FadeOut(mob) for mob in self.mobjects]\n )\n```"}]} {"id": "multi_act_v2_00448", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 3 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: Could you create an animation using Manim where three separate texts appear one below the other with some space between them, each surrounded by a rectangle that highlights them? The first text says \"This is a sample,\" t\n- Act 2: You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not outp\n- Act 3: **Enhanced Animation Description:** "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0448(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_frameboxanimation()\n self.clear_stage()\n self.act_2_performanceoptimization()\n self.clear_stage()\n self.act_3_hexagonrotationwithformu()\n\n def act_1_frameboxanimation(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange them one below the other with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n texts.center()\n\n # Animate the appearance of the text objects\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n \n # Step A: Highlight the first text with a blue rectangle\n rect = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n self.play(Create(rect))\n self.wait(0.5)\n\n # Step B: Replace blue rectangle with a green rectangle around the second text\n rect_green = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n self.play(ReplacementTransform(rect, rect_green))\n self.wait(0.5)\n\n # Step C: Replace green rectangle with a red rectangle around the third text\n rect_red = SurroundingRectangle(text3, color=RED, buff=0.1)\n self.play(ReplacementTransform(rect_green, rect_red))\n self.wait(0.5)\n\n # 3. Final Animation\n # Add an updater to the red rectangle to ensure it tracks/follows the text position\n rect_red.add_updater(lambda r: r.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n\n # Animate the text moving upwards; the rectangle will follow due to the updater\n self.play(text3.animate.shift(UP * 2), run_time=3)\n \n # Hold the final state briefly before ending\n self.wait(1)\n \n # Remove updater to clean up\n rect_red.clear_updaters()\n\n def act_2_performanceoptimization(self):\n title = Text('Data Tiling Strategy', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n sram_box = SurroundingRectangle(Square(side_length=1.5), color=BLUE, buff=0)\n sram_label = Text('SRAM (Limited)', font_size=24).next_to(sram_box, UP)\n sram_group = VGroup(sram_box, sram_label).to_edge(LEFT, buff=1.5).shift(UP * 0.5)\n dram_box = SurroundingRectangle(Square(side_length=3.0), color=GREY, buff=0)\n dram_label = Text('DRAM (Large)', font_size=24).next_to(dram_box, UP)\n dram_group = VGroup(dram_box, dram_label).to_edge(RIGHT, buff=1.5).shift(UP * 0.5)\n tiles = VGroup(*[Square(side_length=0.5, color=YELLOW, stroke_width=2) for _ in range(9)])\n tiles.arrange_in_grid(rows=3, cols=3, buff=0.1)\n tiles.move_to(dram_box.get_center())\n self.play(FadeIn(sram_group), FadeIn(dram_group))\n self.play(Create(tiles))\n target_tile = tiles[0].copy()\n self.play(target_tile.animate.move_to(sram_box.get_center()), run_time=1.5)\n points = BulletedList('Divide maps into smaller blocks (tiles)', 'Balance tile size vs. SRAM capacity', 'Optimize Loop Ordering for DRAM access', buff=0.4, font_size=28).next_to(title_line, DOWN, buff=3.5)\n points.to_edge(LEFT, buff=1.0)\n self.play(Write(points[0]))\n self.play(Write(points[1]))\n formula = MathTex('TileSize \\\\propto \\\\text{SRAM Capacity}', color=YELLOW, font_size=32).next_to(points[1], RIGHT, buff=0.5)\n self.play(FadeIn(formula))\n self.play(Write(points[2]))\n self.wait(2)\n\n def act_3_hexagonrotationwithformu(self):\n hexagon = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8)\n hexagon.scale(2)\n \n # Add small circular dots at each vertex\n dots = VGroup(*[Dot(hexagon.get_vertices()[i], color=RED, radius=0.1) for i in range(6)])\n \n # Create the formula\n formula = MathTex(\"\\\\text{Rotation: } R(\\\\theta) = -120^\\\\circ\", color=WHITE)\n formula.next_to(hexagon, DOWN, buff=1)\n \n # Create a translucent circular path\n circle_path = Circle(radius=2, color=BLUE, fill_opacity=0.1, stroke_width=2)\n \n # Initial display\n self.play(Create(hexagon), Create(dots))\n self.wait(0.5)\n \n # Animate rotation and formula appearance\n self.play(\n Rotate(hexagon, angle=-120 * DEGREES, about_point=ORIGIN, run_time=3),\n Rotate(dots, angle=-120 * DEGREES, about_point=ORIGIN, run_time=3),\n FadeIn(formula, run_time=2),\n Create(circle_path, run_time=3)\n )\n \n # Morph into a hexagram halfway through rotation\n hexagram = Star(n=6, outer_radius=2, color=YELLOW, fill_opacity=0.8)\n self.play(Transform(hexagon, hexagram), run_time=1.5)\n self.wait(0.5)\n \n # Morph back to hexagon\n self.play(Transform(hexagon, RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8).scale(2)), run_time=1.5)\n \n # Pulsing dots animation\n for _ in range(3):\n self.play(\n dots.animate.scale(1.2),\n run_time=0.3\n )\n self.play(\n dots.animate.scale(1/1.2),\n run_time=0.3\n )\n \n self.wait(1)\n```"}]} {"id": "manim-sft-10k_005936", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here is the enhanced animation description that includes all original features plus significant new elements:\n\nThe animation begins with the three rounded rectangle layers (blue, green, red) arranged vertically with connecting arrows, each labeled \"Layer 1\", \"Layer 2\", and \"Layer 3\" respectively, fading in from the bottom. As the neural network diagram settles at the center, mathematical equations appear to the right showing the basic feedforward computation (z = Wx + b) for each layer, with the weights (W) and biases (b) highlighted in yellow. When each layer activates (changing to yellow fill), corresponding animated data flows appear along the arrows - small circles representing activation values moving between layers, with their sizes dynamically changing to represent different activation strengths. A new \"Output\" label appears above the final layer as it activates, and a performance metric (e.g., \"Accuracy: 92%\") fades in below the network. The animation concludes with the entire diagram, including all new elements, smoothly compressing horizontally into a simplified version before fading out, demonstrating how complex networks can be distilled into their essential components. Throughout the animation, subtle glow effects highlight currently active elements, and a timeline at the bottom tracks the progression through the network's forward pass."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedNeuralNetworkAnimation(Scene):\n def construct(self):\n # Colors\n blue = \"#1F77B4\"\n green = \"#2CA02C\"\n red = \"#D62728\"\n yellow = \"#FFD700\"\n \n # Create layers\n layer1 = RoundedRectangle(corner_radius=0.2, height=1.5, width=3, fill_color=blue, fill_opacity=1, stroke_color=WHITE)\n layer2 = RoundedRectangle(corner_radius=0.2, height=1.5, width=3, fill_color=green, fill_opacity=1, stroke_color=WHITE)\n layer3 = RoundedRectangle(corner_radius=0.2, height=1.5, width=3, fill_color=red, fill_opacity=1, stroke_color=WHITE)\n \n # Position layers vertically\n layers = VGroup(layer1, layer2, layer3).arrange(DOWN, buff=1).move_to(ORIGIN)\n \n # Add layer labels\n label1 = Text(\"Layer 1\").next_to(layer1, UP)\n label2 = Text(\"Layer 2\").next_to(layer2, UP)\n label3 = Text(\"Layer 3\").next_to(layer3, UP)\n \n # Create arrows between layers\n arrow1 = Arrow(layer1.get_bottom(), layer2.get_top(), buff=0.1)\n arrow2 = Arrow(layer2.get_bottom(), layer3.get_top(), buff=0.1)\n \n # Create equations\n equation1 = MathTex(r\"z = Wx + b\").next_to(layers, RIGHT, buff=1)\n equation2 = MathTex(r\"a = \\sigma(z)\").next_to(equation1, DOWN, buff=0.5)\n \n # Highlight weights and biases\n w_highlight = SurroundingRectangle(equation1[0][2:3], color=yellow, fill_opacity=0.3)\n b_highlight = SurroundingRectangle(equation1[0][6:7], color=yellow, fill_opacity=0.3)\n \n # Create output label and metric\n output_label = Text(\"Output\").next_to(layer3, UP)\n accuracy = Text(\"Accuracy: 92%\").next_to(layers, DOWN, buff=1)\n \n # Create timeline\n timeline = NumberLine(x_range=[0, 3], length=5, include_numbers=True)\n timeline_label = Text(\"Forward Pass Progress\").next_to(timeline, DOWN, buff=0.2)\n timeline_group = VGroup(timeline, timeline_label).to_edge(DOWN, buff=0.5)\n pointer = Triangle(fill_opacity=1, color=YELLOW).scale(0.1).rotate(-PI/2)\n pointer.next_to(timeline.n2p(0), UP, buff=0.1)\n \n # Animation sequence\n self.play(\n LaggedStart(\n FadeIn(layer1, shift=UP),\n FadeIn(label1, shift=UP),\n lag_ratio=0.3\n )\n )\n self.wait(0.5)\n \n self.play(\n LaggedStart(\n FadeIn(layer2, shift=UP),\n FadeIn(label2, shift=UP),\n FadeIn(arrow1, shift=UP),\n lag_ratio=0.3\n )\n )\n self.wait(0.5)\n \n self.play(\n LaggedStart(\n FadeIn(layer3, shift=UP),\n FadeIn(label3, shift=UP),\n FadeIn(arrow2, shift=UP),\n lag_ratio=0.3\n )\n )\n self.wait(0.5)\n \n # Show equations\n self.play(FadeIn(equation1))\n self.play(Create(w_highlight), Create(b_highlight))\n self.wait(0.5)\n self.play(FadeIn(equation2))\n self.wait(0.5)\n \n # Animate data flow\n self.play(\n layer1.animate.set_fill(yellow),\n Flash(layer1, color=yellow, line_length=0.3)\n )\n \n # Create moving activation dots\n dots1 = [Dot(radius=0.1*np.random.rand(), color=WHITE).move_to(layer1.get_bottom()) for _ in range(5)]\n self.play(\n *[GrowFromCenter(dot) for dot in dots1],\n run_time=0.5\n )\n self.play(\n *[dot.animate.move_to(layer2.get_top()) for dot in dots1],\n MoveAlongPath(pointer, Line(timeline.n2p(0), timeline.n2p(1))),\n run_time=1.5\n )\n self.play(FadeOut(*dots1))\n \n self.play(\n layer2.animate.set_fill(yellow),\n Flash(layer2, color=yellow, line_length=0.3)\n )\n \n dots2 = [Dot(radius=0.1*np.random.rand(), color=WHITE).move_to(layer2.get_bottom()) for _ in range(5)]\n self.play(\n *[GrowFromCenter(dot) for dot in dots2],\n run_time=0.5\n )\n self.play(\n *[dot.animate.move_to(layer3.get_top()) for dot in dots2],\n MoveAlongPath(pointer, Line(timeline.n2p(1), timeline.n2p(2))),\n run_time=1.5\n )\n self.play(FadeOut(*dots2))\n \n self.play(\n layer3.animate.set_fill(yellow),\n Flash(layer3, color=yellow, line_length=0.3),\n Transform(label3, output_label),\n FadeIn(accuracy),\n MoveAlongPath(pointer, Line(timeline.n2p(2), timeline.n2p(3))),\n run_time=1.5\n )\n self.wait(1)\n \n # Show timeline\n self.play(FadeIn(timeline_group))\n self.wait(0.5)\n \n # Compress diagram\n simplified_layers = layers.copy().scale(0.5, about_point=ORIGIN).stretch(0.5, 0)\n simplified_arrows = VGroup(arrow1.copy().scale(0.5), arrow2.copy().scale(0.5))\n \n self.play(\n layers.animate.scale(0.5, about_point=ORIGIN).stretch(0.5, 0),\n arrow1.animate.scale(0.5),\n arrow2.animate.scale(0.5),\n equation1.animate.scale(0.7).shift(LEFT*0.5),\n equation2.animate.scale(0.7).shift(LEFT*0.5),\n w_highlight.animate.scale(0.7).shift(LEFT*0.5),\n b_highlight.animate.scale(0.7).shift(LEFT*0.5),\n output_label.animate.scale(0.7),\n accuracy.animate.scale(0.7),\n timeline_group.animate.scale(0.7),\n pointer.animate.scale(0.7),\n run_time=2\n )\n self.wait(1)\n \n # Fade out\n self.play(\n FadeOut(layers),\n FadeOut(arrow1),\n FadeOut(arrow2),\n FadeOut(equation1),\n FadeOut(equation2),\n FadeOut(w_highlight),\n FadeOut(b_highlight),\n FadeOut(output_label),\n FadeOut(accuracy),\n FadeOut(timeline_group),\n FadeOut(pointer),\n run_time=2\n )\n```"}]} {"id": "adaption-unified-manim-instructions_001238", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animation that visually demonstrates the process of solving a first-order linear ordinary differential equation (ODE), specifically showing the ODE y' - 3y = 0, and then methodically solving it by using an integrating factor, resulting in the general solution y(x) = Ce^(3x)? The steps should include writing down the equation, displaying text cues for each step like 'Solve the differential equation', 'Use the integrating factor', and 'General solution of the first-order ODE', following with the appropriate mathematical expressions and animations that transform one step to the next. Lastly, can you conclude the animation by clearing the screen and highlighting the general solution?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SolveLinearODE(Scene):\n def construct(self):\n # --- Step 1: Display Equation ---\n cue_solve = Text(\"Solve the differential equation\", font_size=36)\n cue_solve.to_edge(UP)\n \n ode_initial = MathTex(\"y' - 3y = 0\", font_size=48)\n ode_initial.next_to(cue_solve, DOWN, buff=1)\n \n self.play(Write(cue_solve))\n self.play(Write(ode_initial))\n self.wait(1)\n \n # --- Step 2: Integrating Factor Method ---\n cue_if = Text(\"Use the integrating factor\", font_size=36)\n cue_if.to_edge(UP)\n \n tex_p = MathTex(\"P(x) = -3\", font_size=36)\n tex_p.next_to(cue_if, DOWN, buff=0.5)\n \n tex_mu = MathTex(r\"\\mu(x) = e^{\\int -3 \\, dx} = e^{-3x}\", font_size=36)\n tex_mu.next_to(tex_p, DOWN, buff=0.5)\n \n self.play(ReplacementTransform(cue_solve, cue_if))\n self.play(Write(tex_p), Write(tex_mu))\n self.wait(1)\n \n # Multiply the ODE by the integrating factor\n ode_mult = MathTex(r\"e^{-3x}(y' - 3y) = 0\", font_size=48)\n ode_mult.next_to(tex_mu, DOWN, buff=1)\n self.play(ReplacementTransform(ode_initial.copy(), ode_mult))\n self.wait(1)\n \n # Expand the multiplication\n ode_expanded = MathTex(r\"e^{-3x}y' - 3e^{-3x}y = 0\", font_size=48)\n ode_expanded.move_to(ode_mult.get_center())\n self.play(Transform(ode_mult, ode_expanded))\n self.wait(1)\n \n # Show the transformation to product rule derivative\n ode_deriv = MathTex(r\"\\frac{d}{dx}(e^{-3x}y) = 0\", font_size=48)\n ode_deriv.move_to(ode_mult.get_center())\n self.play(Transform(ode_mult, ode_deriv))\n self.wait(1)\n \n # --- Step 3: General Solution ---\n cue_gen = Text(\"General solution of the first-order ODE\", font_size=36)\n cue_gen.to_edge(UP)\n \n # Integrate both sides\n ode_int = MathTex(r\"e^{-3x}y = C\", font_size=48)\n ode_int.move_to(ode_mult.get_center())\n \n self.play(\n ReplacementTransform(cue_if, cue_gen),\n FadeOut(tex_p), FadeOut(tex_mu),\n Transform(ode_mult, ode_int)\n )\n self.wait(1)\n \n # Isolate y to reveal the final result\n solution_final = MathTex(r\"y(x) = Ce^{3x}\", font_size=48)\n solution_final.move_to(ode_int.get_center())\n self.play(Transform(ode_mult, solution_final))\n self.wait(1)\n \n # --- Conclusion: Clear screen and highlight the general solution ---\n self.play(FadeOut(cue_gen), FadeOut(ode_mult))\n \n # Create a prominent final version\n final_solution = MathTex(r\"y(x) = Ce^{3x}\", font_size=72, color=YELLOW)\n final_solution.move_to(ORIGIN)\n \n box = SurroundingRectangle(final_solution, color=BLUE, buff=0.3)\n \n self.play(FadeIn(final_solution), Create(box))\n self.play(Indicate(final_solution, scale_factor=1.1))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_008112", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like an educational animation that introduces the concept of simple harmonic motion. It should start by displaying the differential equation that describes the motion, and then proceed with text explanations for each component. First, I'd like a brief introduction stating that the equation represents a simple harmonic oscillator. Then, I want an explanation that the term \"omega\" in the equation stands for angular frequency. Next, the animation should show the general solution of the motion equation which involves cosine. Please include a note clarifying that the 'A' in the solution represents amplitude and 'phi' represents the phase of the motion. Finally, end the animation by clearing the explanations and focusing on the final solution of the differential equation. Can you make this visualization engaging and easy to follow for students learning physics?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Differential Equation and Title\n # ------------------------------------------------------------------\n # Split the equation into substrings to allow for individual highlighting\n diff_eq = MathTex(\n r\"\\frac{d^2 x}{dt^2}\", \" + \", r\"\\omega^2\", \"x\", \" = \", \"0\",\n font_size=48\n )\n diff_eq.to_edge(UP, buff=1.0)\n\n intro_text = Text(\n \"This equation represents a simple harmonic oscillator.\",\n font_size=30\n )\n intro_text.next_to(diff_eq, DOWN, buff=0.5)\n\n self.play(Write(diff_eq))\n self.play(FadeIn(intro_text, shift=UP * 0.3))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 2. Component Explanation: Angular Frequency\n # ------------------------------------------------------------------\n # Access the omega term (index 2 based on the split above)\n omega_term = diff_eq[2]\n\n omega_explanation = Text(\n \"ω = Angular Frequency\",\n font_size=28,\n color=YELLOW\n )\n omega_explanation.next_to(intro_text, DOWN, buff=0.6)\n\n # Highlight omega in the equation and display the explanation\n self.play(omega_term.animate.set_color(YELLOW))\n self.play(Write(omega_explanation))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 3. General Solution and Parameters\n # ------------------------------------------------------------------\n # Split the solution to allow for individual parameter highlighting\n solution_eq = MathTex(\n \"x(t)\", \" = \", \"A\", r\"\\cos(\", r\"\\omega\", \"t\", \" + \", r\"\\phi\", \")\",\n font_size=48\n )\n solution_eq.next_to(omega_explanation, DOWN, buff=0.8)\n\n # Labels for A and phi\n # Indices: A is [2], phi is [7]\n amplitude_label = Text(\"Amplitude\", font_size=22, color=GREEN)\n phase_label = Text(\"Phase\", font_size=22, color=PURPLE)\n\n amplitude_label.next_to(solution_eq[2], DOWN, buff=0.4)\n phase_label.next_to(solution_eq[7], DOWN, buff=0.4)\n\n # Animate the solution, then highlight and label A and phi\n self.play(Write(solution_eq))\n self.play(\n solution_eq[2].animate.set_color(GREEN),\n Write(amplitude_label)\n )\n self.play(\n solution_eq[7].animate.set_color(PURPLE),\n Write(phase_label)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 4. Conclusion: Focus on Final Solution\n # ------------------------------------------------------------------\n # Group all intermediate elements to be cleared from the screen\n elements_to_clear = VGroup(\n diff_eq,\n intro_text,\n omega_explanation,\n amplitude_label,\n phase_label\n )\n\n self.play(FadeOut(elements_to_clear))\n\n # Move the final solution to the center and scale up for emphasis\n self.play(\n solution_eq.animate.move_to(ORIGIN).scale(1.5),\n run_time=1.5\n )\n \n # Final highlight to draw attention\n self.play(Indicate(solution_eq))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_003761", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "How can I create an animated video that visually represents the forward propagation process in a simple neural network with three layers, where the first layer has three neurons, the second layer has five neurons, and the third layer has three neurons again, using a Python library for creating animations?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass ForwardPropagationScene(Scene):\n def construct(self):\n # --- Configuration ---\n layer_sizes = [3, 5, 3] # Input: 3, Hidden: 5, Output: 3\n layer_colors = [BLUE, GREEN, RED]\n signal_color = YELLOW\n neuron_radius = 0.25\n layer_spacing = 3.0\n neuron_spacing = 1.0\n\n neurons = []\n connections = []\n\n # --- 1. Create Neurons ---\n for i, size in enumerate(layer_sizes):\n layer = VGroup()\n for j in range(size):\n neuron = Circle(\n radius=neuron_radius,\n color=layer_colors[i],\n fill_opacity=0.3,\n stroke_width=2\n )\n # Position neurons: x varies by layer, y centers around 0\n neuron.move_to(RIGHT * (i - 1) * layer_spacing + UP * (j - (size - 1) / 2) * neuron_spacing)\n layer.add(neuron)\n neurons.append(layer)\n\n # --- 2. Create Connections ---\n for i in range(len(layer_sizes) - 1):\n layer_edges = VGroup()\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n edge = Line(\n n1.get_center(),\n n2.get_center(),\n color=GRAY,\n stroke_width=1,\n stroke_opacity=0.3\n )\n layer_edges.add(edge)\n connections.append(layer_edges)\n\n # --- 3. Animation Sequence ---\n\n # Display Title\n title = Text(\"Neural Network: Forward Propagation\", font_size=36).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Show Network Architecture\n self.play(LaggedStart(*[FadeIn(layer) for layer in neurons], lag_ratio=0.2))\n self.play(LaggedStart(*[Create(edge_group) for edge_group in connections], lag_ratio=0.2))\n self.wait(0.5)\n\n # Add Labels\n labels = VGroup(\n Text(\"Input\", font_size=24).next_to(neurons[0], DOWN),\n Text(\"Hidden\", font_size=24).next_to(neurons[1], DOWN),\n Text(\"Output\", font_size=24).next_to(neurons[2], DOWN)\n )\n self.play(FadeIn(labels))\n self.wait(0.5)\n\n # --- Propagation Logic ---\n # Activate Input Layer\n self.play(neurons[0].animate.set_fill(layer_colors[0], opacity=1).set_stroke(width=4))\n self.wait(0.5)\n\n # Propagate Input -> Hidden\n self.propagate_signals(neurons[0], neurons[1], connections[0], signal_color)\n \n # Activate Hidden Layer\n self.play(neurons[1].animate.set_fill(layer_colors[1], opacity=1).set_stroke(width=4))\n self.play(neurons[0].animate.set_fill(opacity=0.5)) # Dim previous layer\n self.wait(0.5)\n\n # Propagate Hidden -> Output\n self.propagate_signals(neurons[1], neurons[2], connections[1], signal_color)\n\n # Activate Output Layer\n self.play(neurons[2].animate.set_fill(layer_colors[2], opacity=1).set_stroke(width=4))\n self.play(neurons[1].animate.set_fill(opacity=0.5)) # Dim previous layer\n self.wait(0.5)\n\n # Final highlight of the output layer\n self.play(neurons[2].animate.scale(1.2).set_stroke(width=5))\n self.wait(2)\n\n def propagate_signals(self, source_layer, target_layer, edge_group, color):\n \"\"\"Helper method to animate data signals traveling along edges.\"\"\"\n signals = VGroup()\n for line in edge_group:\n dot = Dot(radius=0.08, color=color)\n dot.move_to(line.get_start())\n signals.add(dot)\n\n self.add(signals)\n animations = [\n MoveAlongPath(signal, line, run_time=1.5, rate_func=linear)\n for signal, line in zip(signals, edge_group)\n ]\n self.play(LaggedStart(*animations, lag_ratio=0.02))\n self.remove(signals) # Clean up signals after movement\n```"}]} {"id": "adaption-unified-manim-instructions_000030", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an animated video that visually explains how to calculate the definite integral of the function x cubed from the limits 2 to 4 by following these steps: First, display the integral problem on the screen. Then, write a text that says \"Using the power rule of integration\" at the top. Show the general power rule formula for integration and its application to the definite integral with the given limits. Replace the integral display with the first step of the solution, incorporating the power rule. Next, change the text at the top to \"Evaluate at the limits\" and show the result of substituting the upper and lower limits into the integrated function. Simplify these calculations on-screen and show the final value of the definite integral. Conclude the animation by clearing everything and displaying just the final numerical solution to the definite integral. Can you do that in a simple and educational way that would be easy for students to follow?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralExample(Scene):\n def construct(self):\n # Step 1: Display Problem\n problem = MathTex(r\"\\int_{2}^{4} x^3 \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem))\n self.wait(1)\n\n # Step 2: Introduce Rule\n rule_title = Text(\"Using the power rule of integration\").to_edge(UP)\n general_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n specific_rule = MathTex(r\"\\int_{2}^{4} x^3 \\, dx = \\left[ \\frac{x^{3+1}}{3+1} \\right]_{2}^{4}\")\n \n rules_group = VGroup(general_rule, specific_rule).arrange(DOWN, buff=0.5)\n rules_group.next_to(rule_title, DOWN, buff=0.5)\n\n self.play(Write(rule_title))\n self.play(Write(general_rule))\n self.wait(0.5)\n self.play(Write(specific_rule))\n self.wait(1)\n\n # Step 3: Apply Rule\n solution_step_1 = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{2}^{4}\")\n solution_step_1.scale(1.5).move_to(problem.get_center())\n \n self.play(\n FadeOut(rules_group),\n ReplacementTransform(problem, solution_step_1)\n )\n self.wait(1)\n\n # Step 4: Evaluate Limits\n eval_title = Text(\"Evaluate at the limits\").to_edge(UP)\n solution_step_2 = MathTex(r\"\\frac{4^4}{4} - \\frac{2^4}{4}\")\n solution_step_2.scale(1.5).move_to(solution_step_1.get_center())\n\n self.play(Transform(rule_title, eval_title))\n self.play(ReplacementTransform(solution_step_1, solution_step_2))\n self.wait(1)\n\n # Step 5: Simplify\n solution_step_3 = MathTex(r\"\\frac{256}{4} - \\frac{16}{4}\")\n solution_step_3.scale(1.5).move_to(solution_step_2.get_center())\n \n solution_step_4 = MathTex(r\"64 - 4\")\n solution_step_4.scale(1.5).move_to(solution_step_3.get_center())\n\n solution_step_5 = MathTex(r\"60\")\n solution_step_5.scale(1.5).move_to(solution_step_4.get_center())\n\n self.play(ReplacementTransform(solution_step_2, solution_step_3))\n self.wait(0.5)\n self.play(ReplacementTransform(solution_step_3, solution_step_4))\n self.wait(0.5)\n self.play(ReplacementTransform(solution_step_4, solution_step_5))\n self.wait(1)\n\n # Step 6: Conclusion\n self.play(FadeOut(eval_title))\n self.clear()\n \n final_solution = MathTex(r\"60\")\n final_solution.scale(3)\n self.play(Write(final_solution))\n self.wait(2)\n```"}]} {"id": "manim-sft-10k_003115", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### Trunk vs Access Port Concepts\n* **Access**: Connects to end devices, processes untagged standard Ethernet frames.\n* **Trunk**: Connects switches, allows transmission of tagged traffic for multiple VLANs.\n\n\nContext location within the document (from highest to current level):\n# Computer Network Course - Lesson 11 Outline (Switched LAN: ARP, VLAN, and Spanning Tree Protocol STP, 90 minutes)\n## VLAN: Logical Isolation and Broadcast Domain Control (20 minutes)\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TrunkAccessConcepts(Scene):\n\n def construct(self):\n title = Text('Trunk vs Access Port Concepts', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n access_title = Text('Access Port', font_size=28, color=BLUE)\n access_list = BulletedList('Connects to end devices', 'Processes untagged frames', font_size=24)\n access_group = VGroup(access_title, access_list).arrange(DOWN, aligned_edge=LEFT)\n sw1 = Text('Switch', font_size=20)\n sw1_box = SurroundingRectangle(sw1, color=WHITE)\n sw1_group = VGroup(sw1, sw1_box)\n pc1 = Text('PC', font_size=20)\n pc1_box = SurroundingRectangle(pc1, color=WHITE)\n pc1_group = VGroup(pc1, pc1_box)\n access_vis = VGroup(sw1_group, pc1_group).arrange(RIGHT, buff=2.5)\n access_line = Line(sw1_group.get_right(), pc1_group.get_left(), color=BLUE)\n frame1 = Text('Untagged Frame', font_size=16, color=YELLOW)\n frame1_box = SurroundingRectangle(frame1, color=YELLOW)\n frame1_group = VGroup(frame1, frame1_box).next_to(access_line, UP, buff=0.1)\n access_diagram = VGroup(access_vis, access_line, frame1_group)\n access_col = VGroup(access_group, access_diagram).arrange(DOWN, buff=1.0)\n trunk_title = Text('Trunk Port', font_size=28, color=GREEN)\n trunk_list = BulletedList('Connects switches', 'Transmits tagged traffic', 'Multiple VLANs', font_size=24)\n trunk_group = VGroup(trunk_title, trunk_list).arrange(DOWN, aligned_edge=LEFT)\n sw2 = Text('Switch A', font_size=20)\n sw2_box = SurroundingRectangle(sw2, color=WHITE)\n sw2_group = VGroup(sw2, sw2_box)\n sw3 = Text('Switch B', font_size=20)\n sw3_box = SurroundingRectangle(sw3, color=WHITE)\n sw3_group = VGroup(sw3, sw3_box)\n trunk_vis = VGroup(sw2_group, sw3_group).arrange(RIGHT, buff=2.5)\n trunk_line = Line(sw2_group.get_right(), sw3_group.get_left(), color=GREEN)\n frame2 = Text('Tagged Frame', font_size=16, color=RED)\n frame2_box = SurroundingRectangle(frame2, color=RED)\n frame2_group = VGroup(frame2, frame2_box).next_to(trunk_line, UP, buff=0.1)\n trunk_diagram = VGroup(trunk_vis, trunk_line, frame2_group)\n trunk_col = VGroup(trunk_group, trunk_diagram).arrange(DOWN, buff=1.0)\n main_content = VGroup(access_col, trunk_col).arrange(RIGHT, buff=1.5, aligned_edge=UP)\n main_content.next_to(title_group, DOWN, buff=0.8)\n self.play(FadeIn(access_title, run_time=0.5))\n self.play(Write(access_list, run_time=1.5))\n self.play(Create(sw1_group), Create(pc1_group), run_time=1)\n self.play(Create(access_line), run_time=0.5)\n self.play(FadeIn(frame1_group, run_time=0.5))\n self.play(FadeIn(trunk_title, run_time=0.5))\n self.play(Write(trunk_list, run_time=1.5))\n self.play(Create(sw2_group), Create(sw3_group), run_time=1)\n self.play(Create(trunk_line), run_time=0.5)\n self.play(FadeIn(frame2_group, run_time=0.5))\n self.wait(1)\n```"}]} {"id": "bespoke-manim_000049", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create an educational ManimCE animation on 'Goldbach's Conjecture' (Unveiling Patterns: Goldbach's Conjecture Through Graphical Art): Can a graphical representation of even numbers and their respective prime pairs reveal inconsistencies or suggest patterns for exceptions to Goldbach's Conjecture?\nVisual style guidance: Rich blues and golds dominate the scene, with primes indicated in a sparkling gold and even numbers as serene blues and whites. Smooth transitions flow between segments, echoing a celestial map with arcs and connections as constellations."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass GoldbachConjecture(Scene):\n def construct(self):\n # Set background color to a deep blue\n self.camera.background_color = \"#0A1128\"\n \n # Introduction\n title = Text(\"Unveiling Patterns: Goldbach's Conjecture\", color=WHITE, font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Key Concept 1: The Conjecture\n concept = Text(\"Every even number > 2 is the sum of two primes\", color=WHITE, font_size=30)\n concept.next_to(title, DOWN)\n self.play(Write(concept))\n self.wait(2)\n \n # Show the equation\n equation = MathTex(r\"2n = p_1 + p_2 \\ (\\text{where } p_1, p_2 \\text{ are primes})\", color=GOLD)\n equation.next_to(concept, DOWN, buff=1)\n self.play(Write(equation))\n self.wait(2)\n \n # Examples - simplified\n examples = VGroup()\n examples_text = [\n \"4 = 2 + 2\",\n \"6 = 3 + 3\",\n \"8 = 3 + 5\",\n \"10 = 3 + 7 or 5 + 5\"\n ]\n \n for text in examples_text:\n example = Text(text, color=WHITE, font_size=28)\n examples.add(example)\n \n examples.arrange(DOWN, buff=0.5)\n examples.next_to(equation, DOWN, buff=1)\n \n self.play(Create(examples))\n self.wait(2)\n \n # Key Insight\n insight = Text(\"Could graphical patterns reveal insights or exceptions?\", color=GOLD, font_size=30)\n insight.next_to(examples, DOWN, buff=1)\n self.play(Write(insight))\n self.wait(2)\n \n # Conclusion\n self.play(FadeOut(title), FadeOut(concept), FadeOut(equation), \n FadeOut(examples), FadeOut(insight))\n \n conclusion = Text(\"The beauty of mathematics lies in its patterns\", color=WHITE, font_size=32)\n conclusion2 = Text(\"and the mysteries that remain unsolved\", color=GOLD, font_size=32)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.wait(1)\n self.play(Write(conclusion2))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_007533", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Can you create an educational video animation that starts by writing the mathematical function for e to the power of x at the top of the screen, followed by showing the general form of its nth Taylor polynomial? After that, can you visually display the function's graph with its label and then present an explanation for calculating the 4th Taylor polynomial, also modifying the previously shown general polynomial to the specific 4th polynomial? Next, can you show the graph of this 4th Taylor polynomial in blue with its label, and conclude by stating that the blue curve represents the 4th Taylor Polynomial of e to the x? Finally, end the video by fading out all elements from the screen."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass TaylorExpansionExp(Scene):\n def construct(self):\n # --- 1. Display Function ---\n func_title = MathTex(r\"f(x) = e^x\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(1)\n\n # --- 2. Show General Form ---\n general_formula = MathTex(\n r\"P_n(x) = \\sum_{k=0}^{n} \\frac{f^{(k)}(0)}{k!} x^k\"\n ).next_to(func_title, DOWN, buff=0.5)\n self.play(Write(general_formula))\n self.wait(1)\n\n # Setup Axes for plotting\n axes = Axes(\n x_range=[-2, 2, 1],\n y_range=[-1, 8, 1],\n axis_config={\"include_tip\": True},\n ).scale(0.8).shift(DOWN * 0.5)\n\n # --- 3. Plot Original Function ---\n exp_curve = axes.plot(lambda x: np.exp(x), color=YELLOW)\n exp_label = MathTex(\"e^x\", color=YELLOW).next_to(axes.c2p(2, np.exp(2)), RIGHT, buff=0.2)\n \n self.play(Create(axes), Create(exp_curve), Write(exp_label))\n self.wait(1)\n\n # --- 4. Explain Specific Case ---\n explanation = Tex(\n \"For $n=4$, since $f^{(k)}(0) = 1$ for all $k$:\"\n ).scale(0.8).next_to(general_formula, DOWN, buff=0.5)\n \n specific_formula = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\"\n ).move_to(general_formula)\n\n self.play(Write(explanation))\n self.wait(1)\n \n # Update the general formula to the specific case\n self.play(ReplacementTransform(general_formula, specific_formula))\n self.play(FadeOut(explanation))\n self.wait(1)\n\n # --- 5. Plot Approximation ---\n # Define the 4th degree Taylor polynomial function\n def taylor_4(x):\n return 1 + x + (x**2)/2 + (x**3)/6 + (x**4)/24\n\n poly_curve = axes.plot(taylor_4, color=BLUE)\n poly_label = MathTex(\"P_4(x)\", color=BLUE).next_to(axes.c2p(2, 7), RIGHT, buff=0.2)\n\n self.play(Create(poly_curve), Write(poly_label))\n self.wait(2)\n\n # --- 6. Conclusion ---\n conclusion = Tex(\n r\"The blue curve represents the 4th Taylor Polynomial of $e^x$.\"\n ).scale(0.9).to_edge(DOWN, buff=0.5)\n\n self.play(Write(conclusion))\n self.wait(2)\n\n # --- 7. Cleanup ---\n all_elements = VGroup(\n func_title, specific_formula, axes, exp_curve, \n exp_label, poly_curve, poly_label, conclusion\n )\n self.play(FadeOut(all_elements))\n self.wait(1)\n```"}]} {"id": "manim-sft-10k_005671", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n#### **Empty and Full Queue Problem** needs to be illustrated:\n\n##### Problem: Relying solely on front==rear cannot distinguish between empty and full.\nWhen the queue is full and when it is empty, the pointer states may be identical.\n\n##### Solution: Sacrifice one unit.\nIt is agreed upon that the maximum capacity of the queue is one less than the array length, reserving one position to differentiate between states.\n\n##### Queue is empty condition: $rear == front$.\n\n##### Queue is full condition: $(rear + 1) \\% maxSize == front$.\n\n\nThe context of this section (from highest to current level):\n# Queue\n## Sequential Queue\n### Circular Sequential Queue\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass QueueEmptyFullProblem(Scene):\n\n def construct(self):\n title = Text('Circular Sequential Queue: Empty vs Full Problem', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title))\n\n def create_queue(size, filled_indices, front_idx, rear_idx, title_text):\n group = VGroup()\n q_title = Text(title_text, font_size=24).set_color(BLUE)\n squares = VGroup(*[Square(side_length=0.7) for _ in range(size)])\n squares.arrange(RIGHT, buff=0)\n for i in filled_indices:\n squares[i].set_fill(BLUE, opacity=0.4)\n else:\n pass\n indices = VGroup()\n for i in range(size):\n idx_text = Text(str(i), font_size=16).next_to(squares[i], UP, buff=0.1)\n indices.add(idx_text)\n else:\n pass\n front_arrow = Arrow(start=UP * 0.8, end=DOWN * 0.1, color=RED, buff=0)\n front_arrow.next_to(squares[front_idx], UP, buff=0.5)\n front_text = Text('front', font_size=20, color=RED).next_to(front_arrow, UP, buff=0.1)\n rear_arrow = Arrow(start=DOWN * 0.8, end=UP * 0.1, color=GREEN, buff=0)\n rear_arrow.next_to(squares[rear_idx], DOWN, buff=0.2)\n rear_text = Text('rear', font_size=20, color=GREEN).next_to(rear_arrow, DOWN, buff=0.1)\n q_title.next_to(squares, UP, buff=1.6)\n group.add(q_title, squares, indices, front_arrow, front_text, rear_arrow, rear_text)\n return group\n empty_q = create_queue(6, [], 0, 0, 'Empty Queue')\n empty_q.move_to(LEFT * 3.5 + UP * 0.5)\n full_q = create_queue(6, [0, 1, 2, 3, 4, 5], 0, 0, 'Full Queue (Naive)')\n full_q.move_to(RIGHT * 3.5 + UP * 0.5)\n self.play(FadeIn(empty_q), FadeIn(full_q))\n eq_text1 = MathTex('\\\\text{front} == \\\\text{rear}', font_size=32).next_to(empty_q, DOWN, buff=0.5)\n eq_text2 = MathTex('\\\\text{front} == \\\\text{rear}', font_size=32).next_to(full_q, DOWN, buff=0.5)\n self.play(Write(eq_text1), Write(eq_text2))\n problem_text1 = Text('Problem: Relying solely on front == rear', font_size=26, color=RED)\n problem_text2 = Text('cannot distinguish between empty and full.', font_size=26, color=RED)\n problem_group = VGroup(problem_text1, problem_text2).arrange(DOWN, buff=0.2)\n problem_group.to_edge(DOWN, buff=0.8)\n self.play(Write(problem_group))\n self.wait(3)\n self.play(FadeOut(empty_q), FadeOut(full_q), FadeOut(eq_text1), FadeOut(eq_text2), FadeOut(problem_group))\n sol_title = Text('Solution: Sacrifice one unit', font_size=32, color=YELLOW)\n sol_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(sol_title))\n```"}]} {"id": "manim-sft-10k_003235", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not output any explanatory or descriptive text outside the code. Pay special attention to avoiding common errors such as LaTeX syntax issues and index out-of-range errors, and ensure the code can run directly. The Markdown lecture notes are as follows:\n\n### Combined Loss for Classification + Regression\nAfter a match is successful, calculate the classification loss and the bounding box regression loss (L1 + GIoU).\n\n\nThe context location of this section (from highest to current level):\n# Object Detection (Part 2) Course Introduction and This Lesson's Focus (Introduction to Lesson 10)\n## Key Mechanisms of DETR\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CombinedLossScene(Scene):\n\n def construct(self):\n title = Text('Combined Loss for Classification & Regression', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.3)\n subtitle = Text('DETR Key Mechanisms', font_size=24, color=GRAY)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title), FadeIn(subtitle))\n match_box = RoundedRectangle(corner_radius=0.2, height=0.8, width=6, color=YELLOW, fill_opacity=0.1)\n match_text = Text('After a Successful Match', font_size=28, color=YELLOW)\n match_group = VGroup(match_box, match_text)\n match_text.move_to(match_box.get_center())\n match_group.next_to(subtitle, DOWN, buff=0.5)\n self.play(Create(match_box), Write(match_text))\n self.wait(1)\n total_loss = MathTex('\\\\mathcal{L}_{total}', '=', '\\\\mathcal{L}_{cls}', '+', '\\\\mathcal{L}_{box}', font_size=48)\n total_loss.next_to(match_group, DOWN, buff=1.5)\n self.play(FadeIn(total_loss, shift=DOWN))\n self.wait(1)\n cls_brace = Brace(total_loss[2], UP, color=BLUE)\n cls_text = Text('Classification Loss', font_size=20, color=BLUE).next_to(cls_brace, UP, buff=0.1)\n self.play(GrowFromCenter(cls_brace), FadeIn(cls_text))\n box_brace = Brace(total_loss[4], UP, color=GREEN)\n box_text = Text('Bounding Box Loss', font_size=20, color=GREEN).next_to(box_brace, UP, buff=0.1)\n self.play(GrowFromCenter(box_brace), FadeIn(box_text))\n self.wait(1)\n arrow2 = Arrow(start=total_loss[4].get_bottom() + DOWN * 0.1, end=total_loss[4].get_bottom() + DOWN * 0.8, color=GREEN, buff=0)\n box_expansion = MathTex('\\\\mathcal{L}_{box}', '=', '\\\\lambda_{L1} \\\\mathcal{L}_{L1}', '+', '\\\\lambda_{giou} \\\\mathcal{L}_{giou}', font_size=48)\n box_expansion.next_to(arrow2, DOWN, buff=0.2)\n self.play(GrowArrow(arrow2), FadeIn(box_expansion, shift=DOWN))\n self.wait(1)\n l1_brace = Brace(box_expansion[2], DOWN, color=ORANGE)\n l1_text = Text('L1 Loss', font_size=20, color=ORANGE).next_to(l1_brace, DOWN, buff=0.1)\n giou_brace = Brace(box_expansion[4], DOWN, color=PURPLE)\n giou_text = Text('GIoU Loss', font_size=20, color=PURPLE).next_to(giou_brace, DOWN, buff=0.1)\n self.play(GrowFromCenter(l1_brace), FadeIn(l1_text), GrowFromCenter(giou_brace), FadeIn(giou_text))\n self.wait(2)\n formula_group = VGroup(total_loss, cls_brace, cls_text, box_brace, box_text, arrow2, box_expansion, l1_brace, l1_text, giou_brace, giou_text)\n rect = SurroundingRectangle(formula_group, color=WHITE, buff=0.3, corner_radius=0.2)\n self.play(Create(rect))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_001455", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an educational animation video that visually represents the concept of powers of two. The video should start with a title called \"Powers of Two\" in a light green color at the top of the screen. Right below it, put a subtitle with the series \"2, 4, 8, 16, 32, ...\" in a more neutral color. The background of the video should be a warm, light cream color, providing a soft contrast to the titles and the animations that will follow.\n\nAfter the titles fade in, I want a sequence of colored squares, each labeled with a power of two, to appear one by one. The size of the square should correspond to the value it represents, starting from 2 and going up to 32. Alternate the colors of the squares between light blue and light purple for visual variety.\n\nEach subsequent square should transform from the previous one and position itself a bit to the right, creating a nice visual flow. After all the squares are displayed, they should arrange themselves in a horizontal line at the center of the screen and then uniformly scale down to fit nicely.\n\nFinally, all the squares should change their color to a light yellow to signify completion, and then the whole scene should fade out. Add some nice smooth transitions, and let each step in the animation have a little pause to let the viewers register the change. The overall feel should be simple, clean, and educational."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PowersOfTwo(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n # Background: Warm, light cream color\n self.camera.background_color = \"#FFFDD0\"\n \n COLOR_TITLE = \"#90EE90\" # Light Green\n COLOR_SUBTITLE = \"#808080\" # Neutral Gray\n COLOR_BLUE = \"#ADD8E6\" # Light Blue\n COLOR_PURPLE = \"#D8BFD8\" # Light Purple\n COLOR_FINAL = \"#FFFFE0\" # Light Yellow\n \n # --- 1. Intro ---\n title = Text(\"Powers of Two\", font_size=48, color=COLOR_TITLE)\n title.to_edge(UP, buff=0.8)\n \n subtitle = Text(\"2, 4, 8, 16, 32, ...\", font_size=36, color=COLOR_SUBTITLE)\n subtitle.next_to(title, DOWN, buff=0.3)\n \n self.play(FadeIn(title), FadeIn(subtitle), run_time=1.5)\n self.wait(0.5)\n \n # --- 2. Square Generation ---\n values = [2, 4, 8, 16, 32]\n colors = [COLOR_BLUE, COLOR_PURPLE]\n \n # Scale factor for side length to be proportional to value\n scale_factor = 0.15\n \n squares = []\n prev_group = None\n \n for i, val in enumerate(values):\n color = colors[i % 2]\n side_length = val * scale_factor\n \n # Create square and label\n square = Square(\n side_length=side_length, \n fill_color=color, \n fill_opacity=0.9, \n stroke_color=WHITE, \n stroke_width=2\n )\n label = Text(str(val), font_size=36, color=BLACK)\n label.move_to(square)\n \n # Scale label to fit comfortably inside the square\n if label.width > square.width * 0.8:\n label.scale_to_fit_width(square.width * 0.8)\n \n group = VGroup(square, label)\n \n if i == 0:\n # First square appears at center-left\n group.move_to(LEFT * 3 + UP * 0.5)\n self.play(FadeIn(group), run_time=1)\n else:\n # Position slightly to the right of the previous one for visual flow\n group.next_to(prev_group, RIGHT, buff=0.3)\n # Transform from a copy of the previous square\n self.play(TransformFromCopy(prev_group, group), run_time=1)\n \n squares.append(group)\n prev_group = group\n self.wait(0.5)\n \n # --- 3. Arrangement ---\n all_squares = VGroup(*squares)\n \n # Animate arranging into a horizontal line at the center\n self.play(\n all_squares.animate.arrange(RIGHT, buff=0.3).move_to(ORIGIN),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Uniformly scale down the entire group to fit nicely\n self.play(\n all_squares.animate.scale(0.6),\n run_time=1\n )\n self.wait(1)\n \n # --- 4. Conclusion ---\n # Change the color of all squares to light yellow\n yellow_anims = []\n for group in all_squares:\n # group[0] is the Square, group[1] is the Text\n yellow_anims.append(group[0].animate.set_fill(COLOR_FINAL, opacity=1))\n \n self.play(*yellow_anims, run_time=1.5)\n self.wait(1)\n \n # Fade out the entire scene\n self.play(FadeOut(VGroup(title, subtitle, all_squares)), run_time=1.5)\n self.wait(0.5)\n```"}]} {"id": "manim-sft-10k_000337", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Here’s an enhanced version of the animation that retains all the original features while adding explanatory text, a dynamic formula, and a smooth transformation sequence: \n\nThe animation begins by drawing concentric circles with radii increasing in increments of 5% of the x-axis, while simultaneously adding yellow squares with side lengths scaled to twice the percentage of the y-axis, creating an expanding grid-like effect. As each shape appears, a dynamic percentage label fades in next to it, tracking the current scaling factor (e.g., \"5%\", \"10%\"). Meanwhile, a dot smoothly moves 100 pixels to the right, leaving a fading trail behind it. A LaTeX formula then materializes at the top of the screen, displaying the scaling relationship: \\( \\text{radius} = \\text{perc} \\cdot \\% \\cdot X_{\\text{axis}} \\) and \\( \\text{side\\_length} = 2 \\cdot \\text{perc} \\cdot \\% \\cdot Y_{\\text{axis}} \\). Finally, the shapes dissolve into a single large circle and square, which then morph into a new composite shape—a yellow square with a circular cutout—demonstrating how percentage-based scaling can be used in more complex transformations. The animation concludes with all elements fading out sequentially."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PercentageScalingAnimation(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n x_length=7,\n y_length=7,\n axis_config={\"color\": BLUE},\n )\n axes.to_edge(LEFT)\n \n # Add axes labels\n x_label = axes.get_x_axis_label(\"X-axis\", direction=UP)\n y_label = axes.get_y_axis_label(\"Y-axis\", direction=RIGHT)\n \n # Create formula\n formula = MathTex(\n r\"\\text{radius} = \\text{perc} \\cdot \\% \\cdot X_{\\text{axis}} \\\\\",\n r\"\\text{side\\_length} = 2 \\cdot \\text{perc} \\cdot \\% \\cdot Y_{\\text{axis}}\",\n font_size=24\n )\n formula.to_edge(UP)\n \n # Create dot and trail\n dot = Dot(color=RED).move_to(axes.c2p(0, 0))\n trail = VMobject()\n trail.set_points_as_corners([dot.get_center(), dot.get_center()])\n trail.set_stroke(RED, 3, opacity=0.7)\n \n # Animation sequences\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(FadeIn(dot))\n \n circles = VGroup()\n squares = VGroup()\n labels = VGroup()\n \n for perc in range(5, 55, 5):\n # Calculate dimensions\n radius = perc * 0.01 * axes.x_length\n side_length = 2 * perc * 0.01 * axes.y_length\n \n # Create shapes\n circle = Circle(radius=radius, color=BLUE)\n circle.move_to(axes.c2p(5, 5))\n \n square = Square(side_length=side_length, color=YELLOW)\n square.move_to(axes.c2p(5, 5))\n \n # Create label\n label = Text(f\"{perc}%\", font_size=18)\n label.next_to(circle, UP)\n \n # Add to groups\n circles.add(circle)\n squares.add(square)\n labels.add(label)\n \n # Animate\n self.play(\n Create(circle),\n Create(square),\n Write(label),\n dot.animate.shift(RIGHT * 0.5),\n UpdateFromFunc(trail, lambda m: m.add_points_as_corners([dot.get_center()])),\n run_time=0.5\n )\n \n # Show formula\n self.play(Write(formula))\n self.wait(1)\n \n # Morph into composite shape\n final_circle = Circle(radius=2.5, color=BLUE)\n final_square = Square(side_length=5, color=YELLOW)\n final_circle.move_to(axes.c2p(5, 5))\n final_square.move_to(axes.c2p(5, 5))\n \n composite = Difference(final_square, final_circle, color=YELLOW)\n \n self.play(\n ReplacementTransform(circles, final_circle),\n ReplacementTransform(squares, final_square),\n FadeOut(labels),\n run_time=2\n )\n self.wait(0.5)\n \n self.play(\n Transform(final_circle, composite),\n Transform(final_square, composite),\n run_time=2\n )\n self.wait(1)\n \n # Fade out\n self.play(\n FadeOut(final_circle),\n FadeOut(final_square),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(dot),\n FadeOut(trail),\n FadeOut(formula),\n run_time=1\n )\n```"}]} {"id": "autoresearch-manim_000034", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a 10-second Manim scene comparing Transform and ReplacementTransform. Show one shape morphing through two targets, keep a short caption explaining the difference, and make the transition visibly animation-focused rather than static."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TransformReplacementComparison(Scene):\n def construct(self):\n title = Text(\"Transform vs ReplacementTransform\", font_size=34).to_edge(UP)\n source = Circle(radius=0.9, color=BLUE_D, fill_opacity=0.18)\n target_a = Square(side_length=1.8, color=TEAL_D, fill_opacity=0.18)\n target_b = Triangle(color=YELLOW_D, fill_opacity=0.18).scale(1.1)\n label = Text(\"Transform keeps reusing the same scene object\", font_size=24, color=GRAY_D).to_edge(DOWN)\n followup = Text(\"ReplacementTransform swaps the old object for the new one\", font_size=24, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(source), FadeIn(label), run_time=3)\n self.play(Transform(source, target_a), run_time=2)\n self.play(ReplacementTransform(source, target_b), Transform(label, followup), run_time=3)\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_006874", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like to create an animated New Year's greeting video that starts with a scene simulating a rocket shooting upwards, then exploding into multiple colorful sparks, followed by a celebratory message and some festive flashing lights. The rocket should follow a realistic trajectory, defined by a physics equation for projectile motion. After the explosion, the sparks should scatter in all directions, somewhat resembling a burst of fireworks, and gradually fade out. As the sparks disappear, I want a math equation representing the rocket's path to slowly fade in at the bottom left corner of the screen. The equation should comprise of a 2D trajectory formula broken into 'x' and 'y' components over time, 't', to give a hint of the science behind the movement. Last but not least, I'd like the animation to end with a fun visual element, such as a banner of the software or animation studio responsible for this creation, popping up in the bottom right corner and then disappearing after a few seconds. The overall feel should be one of celebration and the wonders of math and science."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\nimport random\n\nclass NewYearRocketScene(Scene):\n def construct(self):\n # Set background color for night sky\n self.camera.background_color = \"#0b0f19\"\n\n # --- 1. Rocket Launch Sequence ---\n # Physics Constants (Scaled for visual appeal within Manim coordinates)\n g = 9.8\n v_x = 2.0\n v_y = 8.0\n start_pos = np.array([-5.0, -3.0, 0.0])\n t_peak = v_y / g # Time to reach maximum height\n\n # Create Rocket Shape\n body = Rectangle(height=0.6, width=0.2, color=WHITE, fill_opacity=1, fill_color=GRAY)\n nose = Triangle(color=RED, fill_opacity=1, fill_color=RED).scale(0.5).next_to(body, UP, buff=0)\n fin_l = Triangle(color=RED, fill_opacity=1, fill_color=RED).scale(0.3).rotate(-PI/2).next_to(body, DOWN, buff=0).shift(LEFT*0.1)\n fin_r = Triangle(color=RED, fill_opacity=1, fill_color=RED).scale(0.3).rotate(PI/2).next_to(body, DOWN, buff=0).shift(RIGHT*0.1)\n rocket = VGroup(body, nose, fin_l, fin_r)\n rocket.move_to(start_pos)\n\n # Add a trailing effect\n trail = TracedPath(rocket.get_center, stroke_color=YELLOW, stroke_width=3)\n self.add(rocket, trail)\n\n # Time tracker for physics simulation\n t_tracker = ValueTracker(0)\n\n # Rocket updater based on projectile motion equations\n def rocket_updater(mob):\n t = t_tracker.get_value()\n # x(t) = x0 + vx * t\n x = start_pos[0] + v_x * t\n # y(t) = y0 + vy * t - 0.5 * g * t^2\n y = start_pos[1] + v_y * t - 0.5 * g * t**2\n mob.move_to([x, y, 0])\n \n # Rotate rocket to match trajectory tangent\n if t > 0.01:\n dy_dt = v_y - g * t\n dx_dt = v_x\n # Object is built vertically, so subtract PI/2 to align local Y with velocity vector\n angle = np.arctan2(dy_dt, dx_dt) - PI / 2\n mob.set_angle(angle)\n\n rocket.add_updater(rocket_updater)\n\n # Animate launch until peak\n self.play(t_tracker.animate.set_value(t_peak), run_time=t_peak, rate_func=linear)\n \n explosion_pos = rocket.get_center()\n rocket.remove_updater(rocket_updater)\n self.remove(rocket)\n self.play(FadeOut(trail), run_time=1)\n\n # --- 2. Explosion and Sparks ---\n sparks = VGroup()\n spark_data = []\n colors = [RED, GOLD, GREEN, BLUE, WHITE, PINK, ORANGE, YELLOW]\n\n for _ in range(120):\n color = random.choice(colors)\n spark = Dot(radius=0.1, color=color)\n spark.move_to(explosion_pos)\n sparks.add(spark)\n\n # Random radial velocity\n angle = np.random.uniform(0, 2 * PI)\n speed = np.random.uniform(1.5, 5.0)\n vel = np.array([speed * np.cos(angle), speed * np.sin(angle), 0])\n spark_data.append({\"vel\": vel, \"age\": 0})\n\n self.add(sparks)\n spark_time = ValueTracker(0)\n\n # Spark updater (physics + fade)\n def update_sparks(mob):\n dt = 1 / 60 # Approximate frame time\n for i, dot in enumerate(mob):\n data = spark_data[i]\n # Apply slight gravity to sparks\n data[\"vel\"][1] -= g * 0.25 * dt \n data[\"age\"] += dt\n \n # Update position\n dot.shift(data[\"vel\"] * dt)\n \n # Fade out effect\n opacity = max(0, 1 - (data[\"age\"] / 2.0))\n dot.set_opacity(opacity)\n dot.set_radius(max(0.02, 0.1 - data[\"age\"] * 0.04))\n\n sparks.add_updater(update_sparks)\n self.play(spark_time.animate.set_value(2.0), run_time=2.0)\n sparks.remove_updater(update_sparks)\n self.play(FadeOut(sparks), run_time=0.5)\n\n # --- 3. Mathematical Overlay ---\n equation = MathTex(\n r\"x(t) = v_x t\",\n r\"y(t) = v_y t - \\frac{1}{2}gt^2\",\n font_size=36\n ).arrange(DOWN, aligned_edge=LEFT)\n equation.to_corner(DL, buff=1)\n equation.set_color(WHITE)\n\n # Fade in equation as sparks disappear\n self.play(FadeIn(equation), run_time=1.5)\n\n # --- 4. Celebratory Elements ---\n celebration_text = Text(\"Happy New Year!\", font_size=48, gradient=(YELLOW, ORANGE))\n celebration_text.to_edge(UP, buff=1)\n\n # Flashing Lights (decorative circles around text)\n lights = VGroup()\n for i in range(20):\n light = Circle(radius=0.1, color=random.choice(colors))\n # Arrange in an ellipse around the text\n angle = i * 2 * PI / 20\n light.move_to(celebration_text.get_center() + np.array([np.cos(angle)*3.5, np.sin(angle)*1.5, 0]))\n lights.add(light)\n\n # Light flashing updater\n def light_updater(mob):\n time = self.time\n for i, light in enumerate(mob):\n # Staggered flashing using sine wave\n opacity = 0.5 + 0.5 * np.sin(time * 5 + i)\n light.set_opacity(opacity)\n\n lights.add_updater(light_updater)\n self.add(lights)\n self.play(FadeIn(celebration_text), run_time=1)\n self.wait(2)\n\n # --- 5. Closing Branding ---\n banner_bg = RoundedRectangle(\n corner_radius=0.1, \n height=1, \n width=3.5, \n color=BLUE, \n fill_opacity=0.8, \n fill_color=BLUE_E\n )\n banner_text = Text(\"ManimCE Studio\", font_size=24, color=WHITE).move_to(banner_bg.get_center())\n banner = VGroup(banner_bg, banner_text).to_corner(DR, buff=1)\n\n # Pop up animation\n self.play(GrowFromCenter(banner), run_time=0.5)\n self.wait(2)\n self.play(FadeOut(banner), run_time=0.5)\n\n # Final fade out\n self.play(FadeOut(equation), FadeOut(celebration_text), FadeOut(lights), run_time=1)\n self.wait()\n```"}]} {"id": "multi_act_v2_00483", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 2 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: Create a Manim animation scene that includes the following visual elements and transformations step-by-step: \n- Act 2: You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not outp"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0483(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_sequentialanimationscene()\n self.clear_stage()\n self.act_2_naivebayesrule()\n\n def act_1_sequentialanimationscene(self):\n dot = Dot(point=ORIGIN)\n self.add(dot)\n\n # 2. Add Line: Add a horizontal Line extending from coordinates (3, 0, 0) to (5, 0, 0).\n line = Line(start=[3, 0, 0], end=[5, 0, 0])\n self.play(Create(line))\n\n # 3. Grow Circle: Animate a blue Circle (radius 1) growing from its center point.\n circle = Circle(radius=1, color=BLUE)\n self.play(GrowFromCenter(circle))\n\n # 4. Transform Dot: Transition the initial Dot into a second Dot positioned to the right.\n target_dot = Dot(point=[1, 0, 0])\n self.play(Transform(dot, target_dot))\n\n # 5. Circular Motion: Move the Dot along the circumference of the Circle for exactly 2 seconds using linear motion.\n self.play(MoveAlongPath(dot, circle), run_time=2, rate_func=linear)\n\n # 6. Rotation: Rotate the Dot around the point (2, 0, 0) for 1.5 seconds.\n self.play(Rotate(dot, angle=TAU, about_point=[2, 0, 0]), run_time=1.5)\n\n # 7. Conclusion: End the scene with a brief pause using self.wait().\n self.wait()\n\n def act_2_naivebayesrule(self):\n title = Text('Naive Bayes Classification Rule', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n orig_label = Text('Product Form:', font_size=28, color=LIGHT_GREY)\n orig_math = MathTex('\\\\hat{y} = \\\\arg\\\\max_y P(y) \\\\prod_{j=1}^d P(x_j \\\\mid y)', font_size=38)\n orig_group = VGroup(orig_label, orig_math).arrange(RIGHT, buff=0.3)\n orig_group.next_to(title_group, DOWN, buff=0.7)\n self.play(Write(orig_group))\n self.wait(0.5)\n problem_text = Text('Issue: Multiplying small probabilities causes numerical underflow.', font_size=24, color=RED)\n problem_text.next_to(orig_group, DOWN, buff=0.6)\n self.play(FadeIn(problem_text, shift=UP * 0.2))\n self.wait(0.5)\n solution_text = Text('Solution: Use logarithmic form to convert products into sums.', font_size=24, color=GREEN)\n solution_text.next_to(problem_text, DOWN, buff=0.4)\n self.play(FadeIn(solution_text, shift=UP * 0.2))\n self.wait(0.5)\n log_label = Text('Log Form:', font_size=28, color=LIGHT_GREY)\n log_math = MathTex('\\\\hat{y} = \\\\arg\\\\max_y \\\\Big(\\\\log P(y) + \\\\sum_{j=1}^d \\\\log P(x_j \\\\mid y)\\\\Big)', font_size=42)\n log_group = VGroup(log_label, log_math).arrange(RIGHT, buff=0.3)\n log_group.next_to(solution_text, DOWN, buff=0.7)\n box = SurroundingRectangle(log_group, color=YELLOW, buff=0.2)\n self.play(Write(log_group))\n self.play(Create(box))\n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_000934", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "I would like an animated video that explains how to integrate the function sin(x)cos(x) with respect to x using a trigonometric identity. The animation should start by displaying the integral problem, then present a step-by-step solution, including the use of the identity sin(2x)=2sin(x)cos(x). After simplifying the integral using this identity, show the integration step and the final result, which is -1/4 cos(2x) + C. Conclude the video by fading out the working process and emphasizing the initial problem and final solution."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSinCos(Scene):\n def construct(self):\n # 1. Introduction: Display the initial integral problem\n problem = MathTex(r\"\\int \\sin(x) \\cos(x) \\, dx\")\n problem.set_color(BLUE)\n problem.to_edge(UP)\n \n self.play(Write(problem))\n self.wait(1)\n\n # 2. Step-by-Step Solution\n \n # Introduce the trigonometric identity\n identity = MathTex(r\"\\sin(2x) = 2 \\sin(x) \\cos(x)\")\n identity.next_to(problem, DOWN, buff=0.5)\n identity.set_color(YELLOW)\n identity_box = SurroundingRectangle(identity, color=YELLOW, buff=0.2)\n \n self.play(Write(identity), Create(identity_box))\n self.wait(1)\n\n # Show the rearranged identity for substitution\n rearranged = MathTex(r\"\\sin(x) \\cos(x) = \\frac{1}{2} \\sin(2x)\")\n rearranged.move_to(identity)\n \n self.play(ReplacementTransform(identity, rearranged), identity_box.animate.set_color(WHITE))\n self.wait(1)\n\n # Group intermediate steps for easy fading later\n steps = VGroup()\n\n # Show the algebraic simplification of the integral\n step1 = MathTex(r\"= \\int \\frac{1}{2} \\sin(2x) \\, dx\")\n step1.next_to(rearranged, DOWN, buff=0.5).align_to(problem, LEFT)\n steps.add(step1)\n \n self.play(Write(step1))\n self.wait(1)\n\n # Factor out constant\n step2 = MathTex(r\"= \\frac{1}{2} \\int \\sin(2x) \\, dx\")\n step2.next_to(step1, DOWN, buff=0.5).align_to(step1, LEFT)\n steps.add(step2)\n \n self.play(ReplacementTransform(step1.copy(), step2))\n self.wait(1)\n\n # Perform the integration step explicitly\n step3 = MathTex(r\"= \\frac{1}{2} \\left( -\\frac{1}{2} \\cos(2x) \\right) + C\")\n step3.next_to(step2, DOWN, buff=0.5).align_to(step2, LEFT)\n steps.add(step3)\n \n self.play(Write(step3))\n self.wait(1)\n\n # Reveal the final result\n final_result = MathTex(r\"= -\\frac{1}{4} \\cos(2x) + C\")\n final_result.next_to(step3, DOWN, buff=0.5).align_to(step3, LEFT)\n final_result.set_color(GREEN)\n steps.add(final_result)\n \n self.play(Write(final_result))\n self.wait(2)\n\n # 3. Conclusion: Fade out intermediate working steps\n # Keep the initial problem and the final solution emphasized\n intermediate_steps = VGroup(*steps[:-1], rearranged, identity_box)\n \n self.play(\n FadeOut(intermediate_steps),\n final_result.animate.next_to(problem, DOWN, buff=1.0).align_to(problem, LEFT),\n run_time=1.5\n )\n \n # Emphasize the initial problem and final solution\n conclusion_group = VGroup(problem, final_result)\n box = SurroundingRectangle(conclusion_group, color=GOLD, buff=0.3)\n \n self.play(\n problem.animate.set_color(WHITE).scale(1.2),\n final_result.animate.set_color(GOLD).scale(1.2),\n Create(box)\n )\n self.wait(2)\n```"}]} {"id": "multi_act_v2_00159", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 2 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: I'd like to create an animation where a text element transitions into another text that says \"animate.match_width\" and moves upwards, followed by a square changing its width to match the width of a larger circle, with bo\n- Act 2: I would like to create an animation where the text \"animate.arrange\" is transformed and shifted upwards at the beginning, run over a short period. Then, I want three numbers \"3\", \"1\", \"2\" to appear on the screen from lef"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0159(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_matchwidthanimation()\n self.clear_stage()\n self.act_2_arrangeanimation()\n\n def act_1_matchwidthanimation(self):\n initial_text = Text(\"Transforming Text\", font_size=36)\n target_text = Text(\"animate.match_width\", font_size=36, color=BLUE)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n \n # Quick transition transforming the text and moving it upwards\n self.play(\n ReplacementTransform(initial_text, target_text),\n target_text.animate.shift(UP * 2),\n run_time=0.8,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # --- 2. Shape Transformation ---\n # Create a square and a visibly larger circle with appealing colors\n square = Square(side_length=1.5, color=GREEN, fill_opacity=0.5)\n circle = Circle(radius=1.5, color=RED, fill_opacity=0.5)\n \n # Position shapes below the text\n shapes = VGroup(square, circle).arrange(RIGHT, buff=1.5)\n shapes.next_to(target_text, DOWN, buff=1)\n \n self.play(Create(shapes), run_time=1)\n self.wait(0.5)\n\n # Smoothly change the square's width to match the circle's width\n self.play(\n square.animate.match_width(circle),\n run_time=2,\n rate_func=smooth\n )\n self.wait(1)\n\n # --- 3. Disappearance ---\n # Animate both the square and the circle disappearing\n self.play(\n FadeOut(square, shift=DOWN),\n FadeOut(circle, shift=DOWN),\n FadeOut(target_text, shift=UP),\n run_time=1\n )\n self.wait(1)\n\n def act_2_arrangeanimation(self):\n title = Text(\"animate.arrange\", font_size=48)\n self.play(Write(title))\n \n # Shift text upwards over a short duration\n self.play(title.animate.shift(UP * 2.5), run_time=0.5)\n\n # 2. Number Appearance\n # Create individual text objects for independent rearrangement\n num_3 = Text(\"3\", font_size=48)\n num_1 = Text(\"1\", font_size=48)\n num_2 = Text(\"2\", font_size=48)\n\n # Group in specific visual order: 3, 1, 2 from left to right\n numbers = VGroup(num_3, num_1, num_2)\n numbers.arrange(RIGHT, buff=1.0)\n numbers.next_to(title, DOWN, buff=1.5)\n\n # Display numbers from left to right\n self.play(LaggedStart(*[FadeIn(num) for num in numbers], lag_ratio=0.2))\n\n # 3. Rearrangement\n # Brief pause after numbers appear\n self.wait(0.5)\n\n # Calculate target positions for ascending numerical order (1, 2, 3)\n sorted_targets = VGroup(num_1, num_2, num_3)\n sorted_targets.arrange(RIGHT, buff=1.0)\n \n # Match center to prevent the group from jumping to a new location\n sorted_targets.move_to(numbers.get_center())\n\n # Animate rearrangement with equal spacing\n self.play(\n num_1.animate.move_to(sorted_targets[0].get_center()),\n num_2.animate.move_to(sorted_targets[1].get_center()),\n num_3.animate.move_to(sorted_targets[2].get_center()),\n run_time=1.5\n )\n\n # 4. Cleanup\n self.wait(0.5)\n self.play(FadeOut(title), FadeOut(numbers))\n```"}]} {"id": "multi_act_v2_00381", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 2 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: I would like to create an educational animation that starts by displaying a 2x2 matrix A with entries [[2, 1], [1, 3]] on the screen. Then, after showing the matrix, I want to add text above it that says \"Visualize a lin\n- Act 2: Here’s an enhanced version of the animation that retains the original features while adding significant new elements: "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0381(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_lineartransformation()\n self.clear_stage()\n self.act_2_enhancedrotationmorphing()\n\n def act_1_lineartransformation(self):\n matrix_data = [[2, 1], [1, 3]]\n matrix = Matrix(matrix_data)\n self.play(Write(matrix))\n self.wait()\n\n # 2. Contextual Text\n title = Text(\"Visualize a linear transformation\", font_size=36)\n title.next_to(matrix, UP, buff=0.5)\n self.play(Write(title))\n self.wait(2)\n\n # Clear intro elements before Scene Setup\n self.play(FadeOut(matrix), FadeOut(title))\n\n # 3. Scene Setup: Grid and Vector v\n plane = NumberPlane()\n \n # Vector v from (0,0) to (1,2)\n vector_v = Arrow(start=ORIGIN, end=np.array([1, 2, 0]), color=YELLOW, buff=0)\n v_label = MathTex(\"v\").next_to(vector_v.get_end(), RIGHT)\n\n self.play(Create(plane), GrowArrow(vector_v), Write(v_label))\n self.wait(2)\n\n # 4. Transformation Animation\n # Using 3x3 matrix for 3D coordinate compatibility in Manim\n trans_matrix = [\n [2, 1, 0],\n [1, 3, 0],\n [0, 0, 1]\n ]\n \n # Calculate transformed end point manually for label accuracy: A * [1, 2] = [4, 7]\n av_label = MathTex(\"Av\").next_to(np.array([4, 7, 0]), RIGHT)\n\n self.play(\n ApplyMatrix(trans_matrix, plane),\n ApplyMatrix(trans_matrix, vector_v),\n ReplacementTransform(v_label, av_label),\n run_time=2\n )\n self.wait(2)\n\n # 5. Conclusion\n # Clear all elements\n self.play(FadeOut(plane), FadeOut(vector_v), FadeOut(av_label))\n\n # Redraw the original matrix A to reinforce the concept\n final_matrix = Matrix(matrix_data)\n self.play(Write(final_matrix))\n self.wait(2)\n\n def act_2_enhancedrotationmorphing(self):\n square = Square(color=BLUE, fill_opacity=0.5)\n circle = Circle(color=RED, fill_opacity=0.5)\n group = VGroup(square, circle).arrange(RIGHT, buff=1)\n group.rotate(-30 * DEGREES)\n \n # Display initial shapes\n self.play(Create(square), Create(circle))\n self.wait(0.5)\n \n # Morph square to pentagon and scale circle\n pentagon = RegularPolygon(n=5, color=BLUE, fill_opacity=0.5)\n pentagon.move_to(square.get_center())\n pentagon.rotate(-30 * DEGREES)\n scaled_circle = circle.copy().scale(0.5)\n \n # Show transformation\n self.play(\n Transform(square, pentagon),\n Transform(circle, scaled_circle),\n run_time=2\n )\n self.wait(0.5)\n \n # Add rotation formula\n formula = MathTex(\n r\"VGroup.rotate(\\theta) = \\text{Transformation}\",\n font_size=24\n ).to_edge(DOWN)\n self.play(Write(formula))\n self.wait(1)\n \n # Add title with glow effect\n title = Text(\"Rotation & Morphing\", font_size=36)\n title.to_edge(UP)\n glow = SurroundingRectangle(\n title,\n color=YELLOW,\n fill_opacity=0.2,\n stroke_width=2,\n buff=0.5\n )\n \n self.play(\n Write(title),\n Create(glow),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Pulse effect\n for _ in range(2):\n self.play(\n group.animate.scale(1.1),\n run_time=0.3,\n rate_func=there_and_back\n )\n self.wait(0.2)\n \n self.wait(2)\n```"}]} {"id": "adaption-unified-manim-instructions_001944", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Could you create an educational animation that illustrates the process of solving an integration by parts problem, specifically integrating the function x times e to the power of x? I would like the animation to first display the problem, then show the steps for setting 'u' and 'dv', followed by an explanation of the integration by parts formula, and finally demonstrate the calculation steps with the final solution including the constant of integration. Each step should be shown clearly and give enough time for the viewer to follow along."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrationByParts(Scene):\n def construct(self):\n # Configure text size for readability\n tex_kwargs = {\"font_size\": 36}\n\n # --- 1. Problem Display ---\n title = Text(\"Integration by Parts\", font_size=40).to_edge(UP)\n \n problem = MathTex(r\"\\int\", \"x\", \"e^x\", r\"\\, dx\", **tex_kwargs)\n problem[1].set_color(BLUE) # x\n problem[2].set_color(YELLOW) # e^x\n problem.next_to(title, DOWN, buff=0.5)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- 2. Variable Assignment ---\n u_def = MathTex(\"u\", \"=\", \"x\", color=BLUE, **tex_kwargs)\n dv_def = MathTex(\"dv\", \"=\", \"e^x\", r\"\\, dx\", color=YELLOW, **tex_kwargs)\n \n choice_group = VGroup(u_def, dv_def).arrange(RIGHT, buff=1.5)\n choice_group.next_to(problem, DOWN, buff=0.8)\n \n self.play(Write(u_def))\n self.play(Write(dv_def))\n self.wait(2)\n\n # --- 3. Calculate du and v ---\n du_def = MathTex(\"du\", \"=\", \"dx\", color=BLUE, **tex_kwargs)\n v_def = MathTex(\"v\", \"=\", \"e^x\", color=YELLOW, **tex_kwargs)\n \n calc_group = VGroup(du_def, v_def).arrange(RIGHT, buff=1.5)\n calc_group.next_to(choice_group, DOWN, buff=0.8)\n \n self.play(Write(du_def))\n self.play(Write(v_def))\n self.wait(2)\n\n # --- 4. Formula Explanation ---\n formula = MathTex(r\"\\int\", \"u\", r\"\\, dv\", \"=\", \"u\", \"v\", \"-\", r\"\\int\", \"v\", r\"\\, du\", **tex_kwargs)\n # Color code the formula variables for consistency\n formula[1].set_color(BLUE) # u\n formula[2].set_color(YELLOW) # dv\n formula[4].set_color(BLUE) # u\n formula[5].set_color(YELLOW) # v\n formula[8].set_color(YELLOW) # v\n formula[9].set_color(BLUE) # du\n \n formula.next_to(calc_group, DOWN, buff=0.8)\n formula_box = SurroundingRectangle(formula, color=YELLOW, buff=0.2)\n\n self.play(Write(formula))\n self.play(Create(formula_box))\n self.wait(3)\n\n # --- 5. Step-by-Step Substitution ---\n substitution = MathTex(r\"\\int\", \"x\", \"e^x\", r\"\\, dx\", \"=\", \"x\", \"e^x\", \"-\", r\"\\int\", \"e^x\", r\"\\, dx\", **tex_kwargs)\n # Color code the substituted terms\n substitution[1].set_color(BLUE) # x\n substitution[2].set_color(YELLOW) # e^x\n substitution[5].set_color(BLUE) # x\n substitution[6].set_color(YELLOW) # e^x\n substitution[9].set_color(YELLOW) # e^x\n \n substitution.next_to(formula, DOWN, buff=0.8)\n substitution.align_to(formula, LEFT)\n\n self.play(Write(substitution))\n self.wait(2)\n\n # --- 6. Final Solution ---\n solution = MathTex(\"=\", \"x\", \"e^x\", \"-\", \"e^x\", \"+\", \"C\", **tex_kwargs)\n solution[1].set_color(BLUE) # x\n solution[2].set_color(YELLOW) # e^x\n solution[4].set_color(YELLOW) # e^x\n solution.next_to(substitution, DOWN, buff=0.5)\n solution.align_to(substitution, LEFT)\n\n self.play(Write(solution))\n self.wait(1)\n\n # Highlight the final result\n final_box = SurroundingRectangle(solution, color=GREEN, buff=0.2)\n self.play(Create(final_box))\n self.wait(3)\n\n # --- 7. Clean up and present factored form ---\n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(choice_group),\n FadeOut(calc_group),\n FadeOut(formula),\n FadeOut(formula_box),\n FadeOut(substitution),\n FadeOut(final_box)\n )\n\n final_answer = MathTex(r\"\\int x e^x \\, dx\", \"=\", \"e^x\", \"(\", \"x\", \"-\", \"1\", \")\", \"+\", \"C\", font_size=48, color=GREEN)\n final_box_2 = SurroundingRectangle(final_answer, color=GREEN, buff=0.3)\n \n self.play(Transform(solution, final_answer.move_to(ORIGIN)))\n self.play(Create(final_box_2))\n self.wait(4)\n```"}]} {"id": "multi_act_v2_00180", "messages": [{"role": "system", "content": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`."}, {"role": "user", "content": "Create a long, multi-act 3Blue1Brown-style ManimCE animation video structured into 2 modular acts with clean `FadeOut` stage transitions between acts:\n- Act 1: Please create an educational animation that visually demonstrates the process for calculating the definite integral of x^3 from 0 to 2, showing step-by-step how to integrate using limits, evaluating the function at the u\n- Act 2: I would like to create an educational animation that visually demonstrates a linear algebra concept, specifically how a 2D vector is transformed by a matrix. The animation should start by displaying a 2x2 matrix at the t"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0180(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_definiteintegralofx3()\n self.clear_stage()\n self.act_2_lineartransformationscen()\n\n def act_1_definiteintegralofx3(self):\n integral_expr = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n integral_expr.scale(1.5)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 2: Show the step-by-step integration process (Antiderivative)\n antiderivative_expr = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative_expr.scale(1.5)\n antiderivative_expr.next_to(integral_expr, RIGHT, buff=0.3)\n \n full_line_1 = VGroup(integral_expr, antiderivative_expr).move_to(UP * 1.5)\n self.play(Write(antiderivative_expr))\n self.wait(1)\n\n # Step 3: Animate the evaluation at the upper and lower limits\n evaluation_expr = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n evaluation_expr.scale(1.5)\n evaluation_expr.next_to(full_line_1, DOWN, buff=0.8)\n self.play(Write(evaluation_expr))\n self.wait(1)\n\n # Step 4: Clearly display the final calculation resulting in 4\n simplification_expr = MathTex(r\"= \\frac{16}{4} - 0\")\n simplification_expr.scale(1.5)\n simplification_expr.next_to(evaluation_expr, DOWN, buff=0.8)\n self.play(Write(simplification_expr))\n self.wait(1)\n\n final_result = MathTex(r\"= 4\")\n final_result.scale(2.0).set_color(YELLOW)\n final_result.next_to(simplification_expr, DOWN, buff=0.8)\n self.play(Write(final_result))\n self.play(Indicate(final_result))\n self.wait(1)\n\n # Step 5: Present a concluding message reinforcing the integral result\n conclusion = Text(\"The definite integral of x^3 from 0 to 2 is 4!\", font_size=36, color=GREEN)\n conclusion.next_to(final_result, DOWN, buff=1.0)\n self.play(FadeIn(conclusion, shift=UP))\n self.wait(3)\n\n def act_2_lineartransformationscen(self):\n matrix_values = [[2, 1], [0, 1]]\n matrix_mob = Matrix(matrix_values).to_edge(UP)\n self.play(Write(matrix_mob))\n self.wait(0.5)\n\n # 2. Title\n title = Text(\"Linear transformation effect\").next_to(matrix_mob, DOWN)\n self.play(Write(title))\n self.wait(0.5)\n\n # 3. Scene Setup: Grid and Yellow Vector\n plane = NumberPlane()\n start_coords = [1, 1, 0]\n vector = Arrow(ORIGIN, start_coords, color=YELLOW, buff=0)\n \n self.play(Create(plane), GrowArrow(vector))\n self.wait(0.5)\n\n # 4. Transformation\n # ApplyMatrix automatically handles the matrix multiplication logic,\n # transforming the vector's coordinates. Simultaneously, the color\n # transitions from Yellow to Red to highlight the effect.\n self.play(\n ApplyMatrix(matrix_values, vector),\n vector.animate.set_color(RED),\n run_time=2\n )\n self.wait(0.5)\n\n # 5. Conclusion: Text at the bottom\n conclusion_text = Text(\"Transformed Vector\").to_edge(DOWN)\n self.play(Write(conclusion_text))\n self.wait(1)\n\n # 6. Cleanup: Clear the screen at the end\n self.clear()\n```"}]}