{"id": "adaption-unified-manim-instructions_000212", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "EulersFormula", "num_animations": 7, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_00260", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0260", "num_animations": 24, "prompt": "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 retains the original hexagon while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n- Act 2: 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 3: Can you create an educational animation that visually explains how to calculate the area under the curve of y = x^2 from x = 0 to x = 2? I'd like to see a coordinate system with labeled axes and the curve graphed in gree", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0260(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_enhancedhexagonscene()\n self.clear_stage()\n self.act_2_eulersformulascene()\n self.clear_stage()\n self.act_3_areaundercurve()\n\n def act_1_enhancedhexagonscene(self):\n hexagon = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8)\n hexagon.scale(2)\n \n # Display the hexagon\n self.play(Create(hexagon))\n self.wait(1)\n \n # Transform hexagon into a circle\n circle = Circle(radius=2, color=BLUE, fill_opacity=0.5)\n self.play(Transform(hexagon, circle))\n self.wait(1)\n \n # Show the formula and text\n formula = MathTex(\"s = r\").scale(1.5).next_to(hexagon, DOWN)\n text = Text(\"A regular hexagon's side length equals its radius\", font_size=24).next_to(formula, DOWN)\n \n self.play(FadeIn(formula), FadeIn(text))\n self.wait(2)\n \n # Transform back to hexagon\n hexagon2 = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8)\n hexagon2.scale(2)\n self.play(Transform(hexagon, hexagon2))\n self.wait(1)\n \n # Divide hexagon into 6 triangles\n triangles = VGroup()\n center = hexagon.get_center()\n vertices = hexagon.get_vertices()\n for i in range(6):\n triangle = Polygon(center, vertices[i], vertices[(i+1)%6], color=RED, fill_opacity=0.5)\n triangles.add(triangle)\n \n self.play(Transform(hexagon, triangles))\n self.wait(1)\n \n # Rotate triangles outward\n for i, triangle in enumerate(triangles):\n angle = i * 60 * DEGREES\n self.play(Rotate(triangle, angle=PI/6, about_point=center))\n \n self.wait(1)\n \n # Reassemble hexagon\n self.play(Transform(hexagon, hexagon2))\n self.wait(1)\n \n # Fade out formula and text\n self.play(FadeOut(formula), FadeOut(text))\n self.wait(1)\n\n def act_2_eulersformulascene(self):\n title1 = Text(\"Euler's Formula:\", font_size=40).to_edge(UP)\n eq1 = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\", font_size=48).next_to(title1, DOWN, buff=0.5)\n\n self.play(Write(title1))\n self.play(Write(eq1))\n self.wait(1)\n\n # --- 2. Transformation Step ---\n arrow = Arrow(start=UP, end=DOWN).next_to(eq1, DOWN, buff=0.5)\n eq2 = MathTex(r\"\\cos(x) = \\frac{e^{ix} + e^{-ix}}{2}\", font_size=48).next_to(arrow, DOWN, buff=0.5)\n\n self.play(Create(arrow))\n self.play(Write(eq2))\n self.wait(1)\n\n # --- 3. Transition ---\n self.play(FadeOut(VGroup(title1, eq1, arrow, eq2)))\n self.wait(0.5)\n\n title2 = Text(\"Euler's Formula Transformation\", color=YELLOW, font_size=40).to_edge(UP)\n self.play(Write(title2))\n self.wait(1)\n\n # --- 4. Final Scene ---\n title3 = Text(\"Euler's Identity\", font_size=40).to_edge(UP)\n eq3 = MathTex(r\"e^{i\\pi} + 1 = 0\", font_size=60).next_to(title3, DOWN, buff=1)\n\n self.play(ReplacementTransform(title2, title3))\n self.play(Write(eq3))\n self.wait(2)\n\n def act_3_areaundercurve(self):\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().shift(LEFT * 2 + DOWN * 0.25)\n\n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot the function y = x^2 in green\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=GREEN)\n\n # Shade the area under the curve from x=0 to x=2 with reduced opacity\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=GREEN,\n opacity=0.3\n )\n\n # Animate the setup\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), FadeIn(area))\n self.wait(2)\n\n # --- Step 2 to 4: Mathematical Expressions ---\n \n # Group the calculation steps for clean vertical alignment\n calc_group = VGroup(\n MathTex(r\"\\int_{0}^{2} x^2 \\, dx\"),\n MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\"),\n MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3} = \\frac{8}{3}\")\n ).arrange(DOWN, aligned_edge=LEFT).to_corner(UR, buff=0.5)\n\n # Step 2: Introduce the integral symbol and notation\n self.play(Write(calc_group[0]))\n self.wait(2)\n\n # Step 3: Show the antiderivative evaluated at the boundaries\n self.play(Write(calc_group[1]))\n self.wait(2)\n\n # Step 4: Reveal the final numerical calculation and result\n self.play(Write(calc_group[2]))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 retains the original hexagon while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n- Act 2: 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 3: Can you create an educational animation that visually explains how to calculate the area under the curve of y = x^2 from x = 0 to x = 2? I'd like to see a coordinate system with labeled axes and the curve graphed in gree"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0260(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_enhancedhexagonscene()\n self.clear_stage()\n self.act_2_eulersformulascene()\n self.clear_stage()\n self.act_3_areaundercurve()\n\n def act_1_enhancedhexagonscene(self):\n hexagon = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8)\n hexagon.scale(2)\n \n # Display the hexagon\n self.play(Create(hexagon))\n self.wait(1)\n \n # Transform hexagon into a circle\n circle = Circle(radius=2, color=BLUE, fill_opacity=0.5)\n self.play(Transform(hexagon, circle))\n self.wait(1)\n \n # Show the formula and text\n formula = MathTex(\"s = r\").scale(1.5).next_to(hexagon, DOWN)\n text = Text(\"A regular hexagon's side length equals its radius\", font_size=24).next_to(formula, DOWN)\n \n self.play(FadeIn(formula), FadeIn(text))\n self.wait(2)\n \n # Transform back to hexagon\n hexagon2 = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.8)\n hexagon2.scale(2)\n self.play(Transform(hexagon, hexagon2))\n self.wait(1)\n \n # Divide hexagon into 6 triangles\n triangles = VGroup()\n center = hexagon.get_center()\n vertices = hexagon.get_vertices()\n for i in range(6):\n triangle = Polygon(center, vertices[i], vertices[(i+1)%6], color=RED, fill_opacity=0.5)\n triangles.add(triangle)\n \n self.play(Transform(hexagon, triangles))\n self.wait(1)\n \n # Rotate triangles outward\n for i, triangle in enumerate(triangles):\n angle = i * 60 * DEGREES\n self.play(Rotate(triangle, angle=PI/6, about_point=center))\n \n self.wait(1)\n \n # Reassemble hexagon\n self.play(Transform(hexagon, hexagon2))\n self.wait(1)\n \n # Fade out formula and text\n self.play(FadeOut(formula), FadeOut(text))\n self.wait(1)\n\n def act_2_eulersformulascene(self):\n title1 = Text(\"Euler's Formula:\", font_size=40).to_edge(UP)\n eq1 = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\", font_size=48).next_to(title1, DOWN, buff=0.5)\n\n self.play(Write(title1))\n self.play(Write(eq1))\n self.wait(1)\n\n # --- 2. Transformation Step ---\n arrow = Arrow(start=UP, end=DOWN).next_to(eq1, DOWN, buff=0.5)\n eq2 = MathTex(r\"\\cos(x) = \\frac{e^{ix} + e^{-ix}}{2}\", font_size=48).next_to(arrow, DOWN, buff=0.5)\n\n self.play(Create(arrow))\n self.play(Write(eq2))\n self.wait(1)\n\n # --- 3. Transition ---\n self.play(FadeOut(VGroup(title1, eq1, arrow, eq2)))\n self.wait(0.5)\n\n title2 = Text(\"Euler's Formula Transformation\", color=YELLOW, font_size=40).to_edge(UP)\n self.play(Write(title2))\n self.wait(1)\n\n # --- 4. Final Scene ---\n title3 = Text(\"Euler's Identity\", font_size=40).to_edge(UP)\n eq3 = MathTex(r\"e^{i\\pi} + 1 = 0\", font_size=60).next_to(title3, DOWN, buff=1)\n\n self.play(ReplacementTransform(title2, title3))\n self.play(Write(eq3))\n self.wait(2)\n\n def act_3_areaundercurve(self):\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().shift(LEFT * 2 + DOWN * 0.25)\n\n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot the function y = x^2 in green\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=GREEN)\n\n # Shade the area under the curve from x=0 to x=2 with reduced opacity\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=GREEN,\n opacity=0.3\n )\n\n # Animate the setup\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), FadeIn(area))\n self.wait(2)\n\n # --- Step 2 to 4: Mathematical Expressions ---\n \n # Group the calculation steps for clean vertical alignment\n calc_group = VGroup(\n MathTex(r\"\\int_{0}^{2} x^2 \\, dx\"),\n MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\"),\n MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3} = \\frac{8}{3}\")\n ).arrange(DOWN, aligned_edge=LEFT).to_corner(UR, buff=0.5)\n\n # Step 2: Introduce the integral symbol and notation\n self.play(Write(calc_group[0]))\n self.wait(2)\n\n # Step 3: Show the antiderivative evaluated at the boundaries\n self.play(Write(calc_group[1]))\n self.wait(2)\n\n # Step 4: Reveal the final numerical calculation and result\n self.play(Write(calc_group[2]))\n self.wait(2)\n```"}]}
{"id": "multi_act_v2_00563", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0563", "num_animations": 21, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_002974", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralEvaluation", "num_animations": 8, "num_rich_primitives": 2, "prompt": "Create an educational animation that explains how to evaluate the definite integral of x cubed from 0 to 2. First, display the integral problem on the screen. Then, add text to clarify that we are evaluating from 0 to 2, followed by an explanation of the general rule for integrating powers of x. Show the application of the integration rule to our specific problem and then demonstrate the simplification of the power expression. Next, include a step to evaluate the simplified expression at the upper and lower limits of the integral. Finally, present the numerical solution after the evaluation and keep it displayed on the screen once everything else is cleared. The animation should be slow enough to follow but not too long between steps.", "code": "from manim import *\n\nclass IntegralEvaluation(Scene):\n def construct(self):\n # 1. Display Problem\n problem = MathTex(r\"\\int_{0}^{2}\", \"x^3\", r\"\\, dx\")\n problem.scale(1.5)\n self.play(Write(problem))\n self.wait(1)\n\n # 2. Clarify Limits\n limits_text = Text(\"Evaluation Range: 0 to 2\", font_size=28)\n limits_text.next_to(problem, DOWN, buff=0.5)\n self.play(FadeIn(limits_text))\n self.wait(1)\n\n # 3. Explain Rule\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", color=BLUE)\n power_rule.next_to(limits_text, DOWN, buff=0.5)\n power_rule_label = Text(\"Power Rule:\", font_size=24, color=BLUE).next_to(power_rule, LEFT)\n self.play(Write(power_rule_label), Write(power_rule))\n self.wait(2)\n\n # 4. Apply Rule\n applied_raw = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=45)\n applied_raw.next_to(power_rule, DOWN, buff=0.5)\n self.play(Write(applied_raw))\n self.wait(1)\n\n # 5. Simplify\n applied_simple = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=45)\n applied_simple.move_to(applied_raw)\n self.play(ReplacementTransform(applied_raw, applied_simple))\n self.wait(1)\n\n # 6. Evaluate Limits\n evaluation = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=45)\n evaluation.move_to(applied_simple)\n self.play(ReplacementTransform(applied_simple, evaluation))\n self.wait(1)\n\n # 7. Final Solution\n calculation = MathTex(r\"\\frac{16}{4} - 0 = 4\", font_size=45)\n calculation.move_to(evaluation)\n self.play(ReplacementTransform(evaluation, calculation))\n self.wait(1)\n\n # 8. Conclusion\n final_result = MathTex(r\"4\", font_size=80, color=YELLOW)\n final_result.move_to(ORIGIN)\n \n intermediates = VGroup(problem, limits_text, power_rule, power_rule_label, calculation)\n \n self.play(\n ReplacementTransform(calculation, final_result),\n FadeOut(intermediates)\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Create an educational animation that explains how to evaluate the definite integral of x cubed from 0 to 2. First, display the integral problem on the screen. Then, add text to clarify that we are evaluating from 0 to 2, followed by an explanation of the general rule for integrating powers of x. Show the application of the integration rule to our specific problem and then demonstrate the simplification of the power expression. Next, include a step to evaluate the simplified expression at the upper and lower limits of the integral. Finally, present the numerical solution after the evaluation and keep it displayed on the screen once everything else is cleared. The animation should be slow enough to follow but not too long between steps."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralEvaluation(Scene):\n def construct(self):\n # 1. Display Problem\n problem = MathTex(r\"\\int_{0}^{2}\", \"x^3\", r\"\\, dx\")\n problem.scale(1.5)\n self.play(Write(problem))\n self.wait(1)\n\n # 2. Clarify Limits\n limits_text = Text(\"Evaluation Range: 0 to 2\", font_size=28)\n limits_text.next_to(problem, DOWN, buff=0.5)\n self.play(FadeIn(limits_text))\n self.wait(1)\n\n # 3. Explain Rule\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", color=BLUE)\n power_rule.next_to(limits_text, DOWN, buff=0.5)\n power_rule_label = Text(\"Power Rule:\", font_size=24, color=BLUE).next_to(power_rule, LEFT)\n self.play(Write(power_rule_label), Write(power_rule))\n self.wait(2)\n\n # 4. Apply Rule\n applied_raw = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=45)\n applied_raw.next_to(power_rule, DOWN, buff=0.5)\n self.play(Write(applied_raw))\n self.wait(1)\n\n # 5. Simplify\n applied_simple = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=45)\n applied_simple.move_to(applied_raw)\n self.play(ReplacementTransform(applied_raw, applied_simple))\n self.wait(1)\n\n # 6. Evaluate Limits\n evaluation = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=45)\n evaluation.move_to(applied_simple)\n self.play(ReplacementTransform(applied_simple, evaluation))\n self.wait(1)\n\n # 7. Final Solution\n calculation = MathTex(r\"\\frac{16}{4} - 0 = 4\", font_size=45)\n calculation.move_to(evaluation)\n self.play(ReplacementTransform(evaluation, calculation))\n self.wait(1)\n\n # 8. Conclusion\n final_result = MathTex(r\"4\", font_size=80, color=YELLOW)\n final_result.move_to(ORIGIN)\n \n intermediates = VGroup(problem, limits_text, power_rule, power_rule_label, calculation)\n \n self.play(\n ReplacementTransform(calculation, final_result),\n FadeOut(intermediates)\n )\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_003642", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 8, "num_rich_primitives": 2, "prompt": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Graph Visualization\n # Shift axes left to make room for equations on the right\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n ).add_coordinates().shift(LEFT * 3)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot f(x) = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.5], color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # 2. Area Shading\n # Shade the region under the curve from x=0 to x=2\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Dashed lines to highlight the integration limits\n limit_lines = VGroup(\n axes.get_vertical_line(axes.input_to_graph_point(0, graph), color=WHITE, dashed=True),\n axes.get_vertical_line(axes.input_to_graph_point(2, graph), color=WHITE, dashed=True)\n )\n\n self.play(FadeIn(area), Create(limit_lines))\n self.wait(1)\n\n # 3. Step-by-Step Calculation\n # Position the calculation steps on the right side of the screen\n step1 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").shift(RIGHT * 3 + UP * 1.5)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(step1, DOWN, aligned_edge=LEFT)\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(step2, DOWN, aligned_edge=LEFT)\n \n # 4. Final Result\n final_result = MathTex(r\"\\text{Area} = \\frac{8}{3} \\approx 2.67\", color=YELLOW).next_to(step3, DOWN, aligned_edge=LEFT)\n\n # Display calculation steps sequentially\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(1)\n self.play(Write(final_result))\n self.wait(2)\n\n # 5. Conclusion\n # Fade out all elements from the scene\n all_elements = VGroup(\n axes, labels, graph, graph_label, area, limit_lines,\n step1, step2, step3, final_result\n )\n self.play(FadeOut(all_elements))\n self.wait()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Graph Visualization\n # Shift axes left to make room for equations on the right\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n ).add_coordinates().shift(LEFT * 3)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot f(x) = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.5], color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # 2. Area Shading\n # Shade the region under the curve from x=0 to x=2\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Dashed lines to highlight the integration limits\n limit_lines = VGroup(\n axes.get_vertical_line(axes.input_to_graph_point(0, graph), color=WHITE, dashed=True),\n axes.get_vertical_line(axes.input_to_graph_point(2, graph), color=WHITE, dashed=True)\n )\n\n self.play(FadeIn(area), Create(limit_lines))\n self.wait(1)\n\n # 3. Step-by-Step Calculation\n # Position the calculation steps on the right side of the screen\n step1 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").shift(RIGHT * 3 + UP * 1.5)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(step1, DOWN, aligned_edge=LEFT)\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(step2, DOWN, aligned_edge=LEFT)\n \n # 4. Final Result\n final_result = MathTex(r\"\\text{Area} = \\frac{8}{3} \\approx 2.67\", color=YELLOW).next_to(step3, DOWN, aligned_edge=LEFT)\n\n # Display calculation steps sequentially\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(1)\n self.play(Write(final_result))\n self.wait(2)\n\n # 5. Conclusion\n # Fade out all elements from the scene\n all_elements = VGroup(\n axes, labels, graph, graph_label, area, limit_lines,\n step1, step2, step3, final_result\n )\n self.play(FadeOut(all_elements))\n self.wait()\n```"}]}
{"id": "adaption-unified-manim-instructions_001222", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SolveODE", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSinCos", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DivisionVisualization", "num_animations": 7, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "bespokelabs/bespoke-manim", "tier": 1, "scene_name": "HomotopyKnotsScene", "num_animations": 10, "num_rich_primitives": 1, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralAnimation", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "VariableSubstitutionScene", "num_animations": 6, "num_rich_primitives": 3, "prompt": "Demonstrate transformation of equations by superimposing variables, showcasing match and substitution changes with animations.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "BorderAlignmentAnimation", "num_animations": 8, "num_rich_primitives": 4, "prompt": "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.", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_001782", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TaylorSeriesExponential", "num_animations": 19, "num_rich_primitives": 3, "prompt": "I would like to create an animated video explaining the concept of Taylor series approximation for the exponential function e^x. The animation should start by displaying the function \"f(x) = e^x\", then introduce the Taylor series approximation at x=0 with text and the general formula. Afterward, I want to show the first few terms of the series expansion, specifically stopping at the fourth degree. The reasoning for this choice should be presented as text on the screen. Finally, the video should display a graph comparing the original function with the fourth-degree Taylor polynomial over a suitable range, highlighting the accuracy of the approximation. A legend should clearly label the original function and the approximation. After the explanatory part, please clear all elements from the scene and finish the video by showing the polynomial terms again briefly.", "code": "from manim import *\nimport numpy as np\n\nclass TaylorSeriesExponential(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction\n # ------------------------------------------------------------------\n intro_text = MathTex(\"f(x) = e^x\", font_size=72)\n self.play(Write(intro_text))\n self.wait(1.5)\n self.play(FadeOut(intro_text))\n\n # ------------------------------------------------------------------\n # 2. Taylor Series Concept\n # ------------------------------------------------------------------\n concept_title = Text(\"Taylor Series Approximation\", font_size=40).to_edge(UP)\n center_text = Text(\"Centered at x = 0 (Maclaurin Series)\", font_size=30, color=BLUE).next_to(concept_title, DOWN, buff=0.4)\n \n general_formula = MathTex(\n r\"f(x) = \\sum_{n=0}^{\\infty} \\frac{f^{(n)}(0)}{n!} x^n\",\n font_size=42\n ).shift(UP * 0.5)\n \n exp_formula = MathTex(\n r\"e^x = \\sum_{n=0}^{\\infty} \\frac{x^n}{n!}\",\n font_size=42,\n color=YELLOW\n ).next_to(general_formula, DOWN, buff=0.8)\n\n self.play(Write(concept_title), Write(center_text))\n self.wait(1)\n self.play(Write(general_formula))\n self.play(Write(exp_formula))\n self.wait(2)\n \n self.play(\n FadeOut(concept_title), FadeOut(center_text),\n FadeOut(general_formula), FadeOut(exp_formula)\n )\n\n # ------------------------------------------------------------------\n # 3. Series Expansion\n # ------------------------------------------------------------------\n expansion_title = Text(\"Series Expansion\", font_size=40).to_edge(UP)\n \n poly_formula = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\",\n font_size=42\n ).shift(UP * 0.5)\n\n reasoning_text = Text(\n \"4th Degree: Balances accuracy\\nand computational simplicity\",\n font_size=28,\n color=GREY_B\n ).next_to(poly_formula, DOWN, buff=1)\n\n self.play(Write(expansion_title))\n self.play(Write(poly_formula))\n self.wait(1)\n self.play(Write(reasoning_text))\n self.wait(2)\n \n self.play(FadeOut(expansion_title), FadeOut(poly_formula), FadeOut(reasoning_text))\n\n # ------------------------------------------------------------------\n # 4. Graphical Comparison\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-1, 12, 2],\n axis_config={\"include_tip\": True},\n x_length=7,\n y_length=5\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Original function e^x\n exp_func = lambda x: np.exp(x)\n graph_exp = axes.plot(exp_func, color=BLUE, x_range=[-2.5, 2.5], stroke_width=3)\n\n # 4th degree Taylor Polynomial\n taylor_func = lambda x: 1 + x + (x**2)/2 + (x**3)/6 + (x**4)/24\n graph_approx = axes.plot(taylor_func, color=YELLOW, x_range=[-2.5, 2.5], stroke_width=3)\n\n # Legend\n legend_items = VGroup(\n MathTex(r\"e^x\", color=BLUE, font_size=30),\n MathTex(r\"P_4(x)\", color=YELLOW, font_size=30)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n \n legend_box = SurroundingRectangle(legend_items, color=WHITE, buff=0.3)\n legend_group = VGroup(legend_items, legend_box).to_corner(UL, buff=1)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph_exp), Write(legend_items[0]))\n self.wait(0.5)\n self.play(Create(graph_approx), Write(legend_items[1]))\n self.play(Create(legend_box))\n \n # Highlight accuracy near x=0\n accuracy_text = Text(\"High accuracy near x = 0\", font_size=28, color=GREEN).next_to(axes, UP, buff=0.3)\n self.play(Write(accuracy_text))\n self.play(graph_approx.animate.set_stroke(width=6), rate_func=there_and_back, run_time=1.5)\n self.wait(2)\n \n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(graph_exp),\n FadeOut(graph_approx), FadeOut(legend_group), FadeOut(accuracy_text)\n )\n\n # ------------------------------------------------------------------\n # 5. Conclusion\n # ------------------------------------------------------------------\n # Clear all elements from the scene\n self.clear()\n \n final_poly = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\frac{x^4}{24}\",\n font_size=60,\n color=YELLOW\n )\n \n conclusion_text = Text(\"Taylor Polynomial Approximation\", font_size=40).next_to(final_poly, UP, buff=1)\n\n self.play(Write(conclusion_text), Write(final_poly))\n self.wait(3)\n self.play(FadeOut(conclusion_text), FadeOut(final_poly))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an animated video explaining the concept of Taylor series approximation for the exponential function e^x. The animation should start by displaying the function \"f(x) = e^x\", then introduce the Taylor series approximation at x=0 with text and the general formula. Afterward, I want to show the first few terms of the series expansion, specifically stopping at the fourth degree. The reasoning for this choice should be presented as text on the screen. Finally, the video should display a graph comparing the original function with the fourth-degree Taylor polynomial over a suitable range, highlighting the accuracy of the approximation. A legend should clearly label the original function and the approximation. After the explanatory part, please clear all elements from the scene and finish the video by showing the polynomial terms again briefly."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass TaylorSeriesExponential(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction\n # ------------------------------------------------------------------\n intro_text = MathTex(\"f(x) = e^x\", font_size=72)\n self.play(Write(intro_text))\n self.wait(1.5)\n self.play(FadeOut(intro_text))\n\n # ------------------------------------------------------------------\n # 2. Taylor Series Concept\n # ------------------------------------------------------------------\n concept_title = Text(\"Taylor Series Approximation\", font_size=40).to_edge(UP)\n center_text = Text(\"Centered at x = 0 (Maclaurin Series)\", font_size=30, color=BLUE).next_to(concept_title, DOWN, buff=0.4)\n \n general_formula = MathTex(\n r\"f(x) = \\sum_{n=0}^{\\infty} \\frac{f^{(n)}(0)}{n!} x^n\",\n font_size=42\n ).shift(UP * 0.5)\n \n exp_formula = MathTex(\n r\"e^x = \\sum_{n=0}^{\\infty} \\frac{x^n}{n!}\",\n font_size=42,\n color=YELLOW\n ).next_to(general_formula, DOWN, buff=0.8)\n\n self.play(Write(concept_title), Write(center_text))\n self.wait(1)\n self.play(Write(general_formula))\n self.play(Write(exp_formula))\n self.wait(2)\n \n self.play(\n FadeOut(concept_title), FadeOut(center_text),\n FadeOut(general_formula), FadeOut(exp_formula)\n )\n\n # ------------------------------------------------------------------\n # 3. Series Expansion\n # ------------------------------------------------------------------\n expansion_title = Text(\"Series Expansion\", font_size=40).to_edge(UP)\n \n poly_formula = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\",\n font_size=42\n ).shift(UP * 0.5)\n\n reasoning_text = Text(\n \"4th Degree: Balances accuracy\\nand computational simplicity\",\n font_size=28,\n color=GREY_B\n ).next_to(poly_formula, DOWN, buff=1)\n\n self.play(Write(expansion_title))\n self.play(Write(poly_formula))\n self.wait(1)\n self.play(Write(reasoning_text))\n self.wait(2)\n \n self.play(FadeOut(expansion_title), FadeOut(poly_formula), FadeOut(reasoning_text))\n\n # ------------------------------------------------------------------\n # 4. Graphical Comparison\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-1, 12, 2],\n axis_config={\"include_tip\": True},\n x_length=7,\n y_length=5\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Original function e^x\n exp_func = lambda x: np.exp(x)\n graph_exp = axes.plot(exp_func, color=BLUE, x_range=[-2.5, 2.5], stroke_width=3)\n\n # 4th degree Taylor Polynomial\n taylor_func = lambda x: 1 + x + (x**2)/2 + (x**3)/6 + (x**4)/24\n graph_approx = axes.plot(taylor_func, color=YELLOW, x_range=[-2.5, 2.5], stroke_width=3)\n\n # Legend\n legend_items = VGroup(\n MathTex(r\"e^x\", color=BLUE, font_size=30),\n MathTex(r\"P_4(x)\", color=YELLOW, font_size=30)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n \n legend_box = SurroundingRectangle(legend_items, color=WHITE, buff=0.3)\n legend_group = VGroup(legend_items, legend_box).to_corner(UL, buff=1)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph_exp), Write(legend_items[0]))\n self.wait(0.5)\n self.play(Create(graph_approx), Write(legend_items[1]))\n self.play(Create(legend_box))\n \n # Highlight accuracy near x=0\n accuracy_text = Text(\"High accuracy near x = 0\", font_size=28, color=GREEN).next_to(axes, UP, buff=0.3)\n self.play(Write(accuracy_text))\n self.play(graph_approx.animate.set_stroke(width=6), rate_func=there_and_back, run_time=1.5)\n self.wait(2)\n \n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(graph_exp),\n FadeOut(graph_approx), FadeOut(legend_group), FadeOut(accuracy_text)\n )\n\n # ------------------------------------------------------------------\n # 5. Conclusion\n # ------------------------------------------------------------------\n # Clear all elements from the scene\n self.clear()\n \n final_poly = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6} + \\frac{x^4}{24}\",\n font_size=60,\n color=YELLOW\n )\n \n conclusion_text = Text(\"Taylor Polynomial Approximation\", font_size=40).next_to(final_poly, UP, buff=1)\n\n self.play(Write(conclusion_text), Write(final_poly))\n self.wait(3)\n self.play(FadeOut(conclusion_text), FadeOut(final_poly))\n```"}]}
{"id": "adaption-unified-manim-instructions_007819", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolarDoubleIntegral", "num_animations": 16, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_001956", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralVisualization", "num_animations": 8, "num_rich_primitives": 3, "prompt": "Can you create an educational animation using math visualization software that shows the area under the curve of a simple quadratic function from x=2 to x=4, including the axes, function curve, and a labeled shaded area representing integral calculation? Also, after showing the graph, I would like a brief written explanation on-screen about how the area under the curve is related to definite integrals. Finally, end the animation with a clear and prominent message that reinforces the concept that the area calculated is the result of a definite integral.", "code": "from manim import *\n\nclass IntegralVisualization(Scene):\n def construct(self):\n # --- 1. Graph Construction ---\n \n # Define the quadratic function: f(x) = x^2\n func = lambda x: x**2\n \n # Create axes with clear labels and appropriate ranges\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 20, 5],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [2, 4]},\n y_axis_config={\"numbers_to_include\": [5, 10, 15, 20]},\n ).add_coordinates()\n \n # Label axes\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n # Plot the function curve\n curve = axes.plot(func, color=BLUE, x_range=[0, 4.5], stroke_width=4)\n curve_label = MathTex(\"f(x) = x^2\").next_to(curve, UR, buff=0.5)\n \n # Define the domain for the integral (x=2 to x=4)\n area = axes.get_area(\n graph=curve,\n x_range=[2, 4],\n color=GREEN,\n opacity=0.5\n )\n \n # Vertical lines to bound the region clearly\n line_left = axes.get_vertical_line(axes.c2p(2, func(2)), color=YELLOW, stroke_width=3)\n line_right = axes.get_vertical_line(axes.c2p(4, func(4)), color=YELLOW, stroke_width=3)\n \n # Label the shaded region\n area_label = MathTex(r\"\\int_{2}^{4} x^2 \\, dx\").set_color(WHITE)\n area_label.move_to(axes.c2p(3, 5))\n \n # Animation Sequence: Setup -> Curve -> Domain -> Area\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n \n self.play(Create(line_left), Create(line_right))\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n \n # --- 2. Explanatory Content ---\n \n # Explanation text appearing after the graph is established\n explanation_text = VGroup(\n Text(\"The shaded region represents the accumulation\", font_size=24),\n Text(\"of the function's values over the interval [2, 4].\", font_size=24),\n Text(\"Geometrically, this area corresponds to the\", font_size=24),\n Text(\"Definite Integral.\", font_size=24, color=YELLOW)\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(UP)\n \n explanation_box = SurroundingRectangle(explanation_text, color=WHITE, buff=0.3)\n \n self.play(Create(explanation_box), Write(explanation_text))\n self.wait(3)\n \n # --- 3. Conclusion ---\n \n # Clear previous text to focus on the conclusion\n self.play(FadeOut(explanation_text), FadeOut(explanation_box))\n \n # Prominent final message\n conclusion_message = VGroup(\n Text(\"CONCLUSION:\", font_size=36, color=BLUE, weight=BOLD),\n MathTex(r\"\\text{Area} = \\int_{2}^{4} f(x) \\, dx\", font_size=48),\n Text(\"The calculated area is the specific\", font_size=28),\n Text(\"result of the Definite Integral.\", font_size=28, color=GREEN, weight=BOLD)\n ).arrange(DOWN, buff=0.4).move_to(ORIGIN)\n \n conclusion_box = SurroundingRectangle(conclusion_message, color=GREEN, buff=0.5, stroke_width=3)\n \n # Highlight the integral label on the graph one last time, then display conclusion\n self.play(area_label.animate.scale(1.5).set_color(YELLOW))\n self.play(Create(conclusion_box), Write(conclusion_message))\n \n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation using math visualization software that shows the area under the curve of a simple quadratic function from x=2 to x=4, including the axes, function curve, and a labeled shaded area representing integral calculation? Also, after showing the graph, I would like a brief written explanation on-screen about how the area under the curve is related to definite integrals. Finally, end the animation with a clear and prominent message that reinforces the concept that the area calculated is the result of a definite integral."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralVisualization(Scene):\n def construct(self):\n # --- 1. Graph Construction ---\n \n # Define the quadratic function: f(x) = x^2\n func = lambda x: x**2\n \n # Create axes with clear labels and appropriate ranges\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 20, 5],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [2, 4]},\n y_axis_config={\"numbers_to_include\": [5, 10, 15, 20]},\n ).add_coordinates()\n \n # Label axes\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n # Plot the function curve\n curve = axes.plot(func, color=BLUE, x_range=[0, 4.5], stroke_width=4)\n curve_label = MathTex(\"f(x) = x^2\").next_to(curve, UR, buff=0.5)\n \n # Define the domain for the integral (x=2 to x=4)\n area = axes.get_area(\n graph=curve,\n x_range=[2, 4],\n color=GREEN,\n opacity=0.5\n )\n \n # Vertical lines to bound the region clearly\n line_left = axes.get_vertical_line(axes.c2p(2, func(2)), color=YELLOW, stroke_width=3)\n line_right = axes.get_vertical_line(axes.c2p(4, func(4)), color=YELLOW, stroke_width=3)\n \n # Label the shaded region\n area_label = MathTex(r\"\\int_{2}^{4} x^2 \\, dx\").set_color(WHITE)\n area_label.move_to(axes.c2p(3, 5))\n \n # Animation Sequence: Setup -> Curve -> Domain -> Area\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n \n self.play(Create(line_left), Create(line_right))\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n \n # --- 2. Explanatory Content ---\n \n # Explanation text appearing after the graph is established\n explanation_text = VGroup(\n Text(\"The shaded region represents the accumulation\", font_size=24),\n Text(\"of the function's values over the interval [2, 4].\", font_size=24),\n Text(\"Geometrically, this area corresponds to the\", font_size=24),\n Text(\"Definite Integral.\", font_size=24, color=YELLOW)\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(UP)\n \n explanation_box = SurroundingRectangle(explanation_text, color=WHITE, buff=0.3)\n \n self.play(Create(explanation_box), Write(explanation_text))\n self.wait(3)\n \n # --- 3. Conclusion ---\n \n # Clear previous text to focus on the conclusion\n self.play(FadeOut(explanation_text), FadeOut(explanation_box))\n \n # Prominent final message\n conclusion_message = VGroup(\n Text(\"CONCLUSION:\", font_size=36, color=BLUE, weight=BOLD),\n MathTex(r\"\\text{Area} = \\int_{2}^{4} f(x) \\, dx\", font_size=48),\n Text(\"The calculated area is the specific\", font_size=28),\n Text(\"result of the Definite Integral.\", font_size=28, color=GREEN, weight=BOLD)\n ).arrange(DOWN, buff=0.4).move_to(ORIGIN)\n \n conclusion_box = SurroundingRectangle(conclusion_message, color=GREEN, buff=0.5, stroke_width=3)\n \n # Highlight the integral label on the graph one last time, then display conclusion\n self.play(area_label.animate.scale(1.5).set_color(YELLOW))\n self.play(Create(conclusion_box), Write(conclusion_message))\n \n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_001205", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "CNNForwardPass", "num_animations": 16, "num_rich_primitives": 2, "prompt": "I would like to create an educational animation that visually demonstrates how a Convolutional Neural Network (CNN) processes an input image step by step. Can you show the image going through various layers like convolutional layers with filters, followed by fully connected feed-forward layers, and finally outputting the classification into a few categories? Additionally, I'd like the animation to be high-definition and the scene to start with fading in the CNN, then performing a forward pass through the network, and ending with a short pause to see the final result. Also, if possible, include some customizable aspects such as the number of filters in the convolutional layer and the dimensions of the subsequent feed-forward layers.", "code": "from manim import *\n\n# --- Customizable Parameters ---\nNUM_FILTERS = 8\nFC_LAYER_DIMS = [64, 32]\nINPUT_SHAPE = (4, 4)\nOUTPUT_CLASSES = [\"Cat\", \"Dog\", \"Car\", \"Plane\"]\nANIM_SPEED = 1.0\n# -------------------------------\n\nclass CNNForwardPass(Scene):\n def construct(self):\n self.wait_time = lambda t: t / ANIM_SPEED\n\n # 1. INTRO: Fade in Architecture\n self.intro_architecture()\n \n # 2. PROCESS: Convolutional Layers\n feature_maps = self.animate_convolution()\n \n # 3. PROCESS: Fully Connected Layers\n self.animate_fully_connected(feature_maps)\n \n # 4. CONCLUSION: Output Classification\n self.show_classification()\n\n def intro_architecture(self):\n title = Text(\"Convolutional Neural Network\", font_size=36)\n title.to_edge(UP)\n self.play(FadeIn(title), run_time=self.wait_time(2))\n self.wait(self.wait_time(1))\n self.play(FadeOut(title))\n\n def animate_convolution(self):\n # Represent Input Image\n input_grid = NumberPlane(\n x_range=[0, INPUT_SHAPE[0]], y_range=[0, INPUT_SHAPE[1]], \n background_line_style={\"stroke_color\": BLUE}\n )\n input_grid.scale(0.5)\n input_label = Text(\"Input Image\", font_size=24).next_to(input_grid, DOWN)\n \n self.play(Create(input_grid), Write(input_label))\n self.wait(self.wait_time(0.5))\n\n # Represent Filters\n filters = VGroup()\n for i in range(NUM_FILTERS):\n f = Square(side_length=0.5, stroke_color=CYAN, fill_color=CYAN, fill_opacity=0.3)\n filters.add(f)\n filters.arrange(RIGHT, buff=0.2)\n filters.to_edge(LEFT)\n filter_label = Text(\"Filters\", font_size=24).next_to(filters, DOWN)\n \n self.play(Create(filters), Write(filter_label))\n\n # Animate Sliding Window & Feature Maps\n feature_maps = VGroup()\n for i in range(NUM_FILTERS):\n fm = Square(side_length=0.5, stroke_color=GREEN, fill_color=GREEN, fill_opacity=0.5)\n feature_maps.add(fm)\n feature_maps.arrange(RIGHT, buff=0.2)\n feature_maps.to_edge(RIGHT)\n fm_label = Text(\"Feature Maps\", font_size=24).next_to(feature_maps, DOWN)\n\n self.play(\n input_grid.animate.move_to(ORIGIN),\n filters.animate.move_to(LEFT * 3),\n run_time=self.wait_time(2)\n )\n \n self.play(Create(feature_maps), Write(fm_label))\n self.wait(self.wait_time(1))\n \n # Cleanup for next stage\n self.play(FadeOut(input_grid), FadeOut(input_label), FadeOut(filters), FadeOut(filter_label), FadeOut(fm_label))\n feature_maps.move_to(ORIGIN)\n self.play(feature_maps.animate.scale(0.8))\n return feature_maps\n\n def animate_fully_connected(self, feature_maps):\n # Flatten Visualization\n flatten_text = Text(\"Flatten\", font_size=24).to_edge(UP)\n self.play(Write(flatten_text))\n \n vector_line = Line(LEFT * 2, RIGHT * 2, color=GREEN)\n self.play(Transform(feature_maps, vector_line), FadeOut(flatten_text))\n \n # Create FC Layers\n prev_layer = vector_line\n for i, dim in enumerate(FC_LAYER_DIMS):\n layer_nodes = VGroup()\n for j in range(min(dim, 10)): # Limit visual nodes for clarity\n node = Circle(radius=0.1, color=ORANGE, fill_opacity=0.8)\n layer_nodes.add(node)\n layer_nodes.arrange(DOWN, buff=0.15)\n layer_nodes.move_to(RIGHT * (i + 1) * 2)\n \n self.play(Create(layer_nodes), run_time=self.wait_time(1.5))\n prev_layer = layer_nodes\n\n self.wait(self.wait_time(1))\n self.play(FadeOut(prev_layer), FadeOut(vector_line))\n\n def show_classification(self):\n labels = VGroup()\n bars = VGroup()\n \n for i, cls in enumerate(OUTPUT_CLASSES):\n label = Text(cls, font_size=24)\n label.move_to(LEFT * 3 + DOWN * i * 0.8)\n labels.add(label)\n \n bar = Rectangle(height=0.4, width=0.1, color=WHITE, fill_opacity=0.2)\n bar.next_to(label, RIGHT, buff=0.5)\n bars.add(bar)\n \n self.play(Create(labels), Create(bars))\n \n # Animate Winning Class\n winning_bar = bars[0] # Assuming first class is the target\n self.play(\n winning_bar.animate.set_width(2.5).set_color(GREEN).set_fill(GREEN, 0.8),\n run_time=self.wait_time(1.5)\n )\n \n result_text = Text(f\"Classification: {OUTPUT_CLASSES[0]} (98%)\", font_size=32, color=GREEN)\n result_text.to_edge(DOWN)\n self.play(Write(result_text))\n \n # Pause to display result\n self.wait(self.wait_time(3))\n self.play(FadeOut(labels), FadeOut(bars), FadeOut(result_text))\n\n# Render commands:\n# Low Quality (Preview): manim -pql cnn_visualization.py CNNForwardPass\n# High Definition: manim -pqh cnn_visualization.py CNNForwardPass\n# 4K Quality: manim -qk cnn_visualization.py CNNForwardPass", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that visually demonstrates how a Convolutional Neural Network (CNN) processes an input image step by step. Can you show the image going through various layers like convolutional layers with filters, followed by fully connected feed-forward layers, and finally outputting the classification into a few categories? Additionally, I'd like the animation to be high-definition and the scene to start with fading in the CNN, then performing a forward pass through the network, and ending with a short pause to see the final result. Also, if possible, include some customizable aspects such as the number of filters in the convolutional layer and the dimensions of the subsequent feed-forward layers."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\n# --- Customizable Parameters ---\nNUM_FILTERS = 8\nFC_LAYER_DIMS = [64, 32]\nINPUT_SHAPE = (4, 4)\nOUTPUT_CLASSES = [\"Cat\", \"Dog\", \"Car\", \"Plane\"]\nANIM_SPEED = 1.0\n# -------------------------------\n\nclass CNNForwardPass(Scene):\n def construct(self):\n self.wait_time = lambda t: t / ANIM_SPEED\n\n # 1. INTRO: Fade in Architecture\n self.intro_architecture()\n \n # 2. PROCESS: Convolutional Layers\n feature_maps = self.animate_convolution()\n \n # 3. PROCESS: Fully Connected Layers\n self.animate_fully_connected(feature_maps)\n \n # 4. CONCLUSION: Output Classification\n self.show_classification()\n\n def intro_architecture(self):\n title = Text(\"Convolutional Neural Network\", font_size=36)\n title.to_edge(UP)\n self.play(FadeIn(title), run_time=self.wait_time(2))\n self.wait(self.wait_time(1))\n self.play(FadeOut(title))\n\n def animate_convolution(self):\n # Represent Input Image\n input_grid = NumberPlane(\n x_range=[0, INPUT_SHAPE[0]], y_range=[0, INPUT_SHAPE[1]], \n background_line_style={\"stroke_color\": BLUE}\n )\n input_grid.scale(0.5)\n input_label = Text(\"Input Image\", font_size=24).next_to(input_grid, DOWN)\n \n self.play(Create(input_grid), Write(input_label))\n self.wait(self.wait_time(0.5))\n\n # Represent Filters\n filters = VGroup()\n for i in range(NUM_FILTERS):\n f = Square(side_length=0.5, stroke_color=CYAN, fill_color=CYAN, fill_opacity=0.3)\n filters.add(f)\n filters.arrange(RIGHT, buff=0.2)\n filters.to_edge(LEFT)\n filter_label = Text(\"Filters\", font_size=24).next_to(filters, DOWN)\n \n self.play(Create(filters), Write(filter_label))\n\n # Animate Sliding Window & Feature Maps\n feature_maps = VGroup()\n for i in range(NUM_FILTERS):\n fm = Square(side_length=0.5, stroke_color=GREEN, fill_color=GREEN, fill_opacity=0.5)\n feature_maps.add(fm)\n feature_maps.arrange(RIGHT, buff=0.2)\n feature_maps.to_edge(RIGHT)\n fm_label = Text(\"Feature Maps\", font_size=24).next_to(feature_maps, DOWN)\n\n self.play(\n input_grid.animate.move_to(ORIGIN),\n filters.animate.move_to(LEFT * 3),\n run_time=self.wait_time(2)\n )\n \n self.play(Create(feature_maps), Write(fm_label))\n self.wait(self.wait_time(1))\n \n # Cleanup for next stage\n self.play(FadeOut(input_grid), FadeOut(input_label), FadeOut(filters), FadeOut(filter_label), FadeOut(fm_label))\n feature_maps.move_to(ORIGIN)\n self.play(feature_maps.animate.scale(0.8))\n return feature_maps\n\n def animate_fully_connected(self, feature_maps):\n # Flatten Visualization\n flatten_text = Text(\"Flatten\", font_size=24).to_edge(UP)\n self.play(Write(flatten_text))\n \n vector_line = Line(LEFT * 2, RIGHT * 2, color=GREEN)\n self.play(Transform(feature_maps, vector_line), FadeOut(flatten_text))\n \n # Create FC Layers\n prev_layer = vector_line\n for i, dim in enumerate(FC_LAYER_DIMS):\n layer_nodes = VGroup()\n for j in range(min(dim, 10)): # Limit visual nodes for clarity\n node = Circle(radius=0.1, color=ORANGE, fill_opacity=0.8)\n layer_nodes.add(node)\n layer_nodes.arrange(DOWN, buff=0.15)\n layer_nodes.move_to(RIGHT * (i + 1) * 2)\n \n self.play(Create(layer_nodes), run_time=self.wait_time(1.5))\n prev_layer = layer_nodes\n\n self.wait(self.wait_time(1))\n self.play(FadeOut(prev_layer), FadeOut(vector_line))\n\n def show_classification(self):\n labels = VGroup()\n bars = VGroup()\n \n for i, cls in enumerate(OUTPUT_CLASSES):\n label = Text(cls, font_size=24)\n label.move_to(LEFT * 3 + DOWN * i * 0.8)\n labels.add(label)\n \n bar = Rectangle(height=0.4, width=0.1, color=WHITE, fill_opacity=0.2)\n bar.next_to(label, RIGHT, buff=0.5)\n bars.add(bar)\n \n self.play(Create(labels), Create(bars))\n \n # Animate Winning Class\n winning_bar = bars[0] # Assuming first class is the target\n self.play(\n winning_bar.animate.set_width(2.5).set_color(GREEN).set_fill(GREEN, 0.8),\n run_time=self.wait_time(1.5)\n )\n \n result_text = Text(f\"Classification: {OUTPUT_CLASSES[0]} (98%)\", font_size=32, color=GREEN)\n result_text.to_edge(DOWN)\n self.play(Write(result_text))\n \n # Pause to display result\n self.wait(self.wait_time(3))\n self.play(FadeOut(labels), FadeOut(bars), FadeOut(result_text))\n\n# Render commands:\n# Low Quality (Preview): manim -pql cnn_visualization.py CNNForwardPass\n# High Definition: manim -pqh cnn_visualization.py CNNForwardPass\n# 4K Quality: manim -qk cnn_visualization.py CNNForwardPass\n```"}]}
{"id": "adaption-unified-manim-instructions_002216", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "EulerFormulaAnimation", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "ThreadAnalysisAndScheduling", "num_animations": 6, "num_rich_primitives": 3, "prompt": "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", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00224", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0224", "num_animations": 18, "prompt": "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 retains all the original features while adding significant new elements: \n- Act 2: Create a 12-second Manim scene that explains neural network function approximation. Show a target curve with sample points, an initial rough model curve, then morph it into a much better fit while a small loss card decre\n- Act 3: Could you create an animation using Manim that shows two red oxygen atoms coming together to form a molecule? I would like the atoms to first fade into view, then rotate around, and finally scale up to double their size ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0224(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_enhancedrectangleanimati()\n self.clear_stage()\n self.act_2_functionapproximationsto()\n self.clear_stage()\n self.act_3_oxygenmoleculescene()\n\n def act_1_enhancedrectangleanimati(self):\n rect = Rectangle(width=3, height=4, color=ORANGE)\n \n # Animate the rectangle fading in while rotating\n self.play(\n Create(rect),\n Rotate(rect, angle=2*PI, rate_func=linear),\n run_time=2\n )\n self.wait(0.5)\n \n # Split the rectangle into four smaller rectangles\n colors = [BLUE, GREEN, RED, PURPLE]\n small_rects = VGroup(*[\n Rectangle(width=1.5, height=2, color=color).move_to(\n rect.get_center() + np.array([dx, dy, 0])\n )\n for color, (dx, dy) in zip(\n colors,\n [(-0.75, 1), (0.75, 1), (-0.75, -1), (0.75, -1)]\n )\n ])\n \n # Transform the original rectangle into the four smaller ones\n self.play(\n Transform(rect, small_rects),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Show the area formula\n formula = MathTex(\n r\"\\text{Area} = \\text{width} \\times \\text{height} = 3 \\times 4 = 12\",\n font_size=36\n ).next_to(small_rects, DOWN, buff=1)\n \n # Fade in the formula with a bounce effect\n self.play(\n Write(formula),\n formula.animate.scale(1.2).set_color(YELLOW),\n run_time=1\n )\n self.play(\n formula.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show the original rectangle as a faint outline\n ghost_rect = rect.copy().set_fill(opacity=0).set_stroke(ORANGE, opacity=0.3)\n self.add(ghost_rect)\n self.wait(1)\n \n # Fade out all elements in sequence\n self.play(\n FadeOut(small_rects),\n FadeOut(formula),\n FadeOut(ghost_rect),\n run_time=1.5\n )\n\n def act_2_functionapproximationsto(self):\n title = Text('Training Improves The Function Approximation', font_size=28).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[-1.6, 1.8, 1], x_length=7.5, y_length=4.8, tips=False).shift(DOWN * 0.15)\n target = axes.plot(lambda x: 0.9 * np.sin(0.95 * x) + 0.2 * np.cos(2.1 * x), x_range=[0, 8], color=GRAY_B)\n rough = axes.plot(lambda x: 0.35 * np.sin(0.95 * x - 0.4), x_range=[0, 8], color=ORANGE)\n refined = axes.plot(lambda x: 0.86 * np.sin(0.95 * x) + 0.16 * np.cos(2.1 * x + 0.1), x_range=[0, 8], color=BLUE_D)\n samples = VGroup(*[\n Dot(axes.c2p(x, 0.9 * np.sin(0.95 * x) + 0.2 * np.cos(2.1 * x)), color=GRAY_A, radius=0.05)\n for x in [0.6, 1.4, 2.1, 2.9, 3.8, 4.7, 5.6, 6.5, 7.3]\n ])\n card = RoundedRectangle(corner_radius=0.12, width=1.8, height=1.0, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.12).to_corner(UR).shift(DOWN * 0.6)\n loss_label = Text('loss', font_size=18, color=TEAL_D).move_to(card.get_center() + UP * 0.18)\n loss_start = DecimalNumber(1.82, num_decimal_places=2, font_size=28, color=ORANGE).move_to(card.get_center() + DOWN * 0.18)\n loss_end = DecimalNumber(0.34, num_decimal_places=2, font_size=28, color=BLUE_D).move_to(card.get_center() + DOWN * 0.18)\n caption = Text('The model starts with the wrong shape, then training bends it toward the target while the loss falls.', font_size=21, color=WHITE).to_edge(DOWN)\n caption_group = VGroup(BackgroundRectangle(caption, fill_opacity=0.88, buff=0.14), caption)\n\n self.play(FadeIn(title), Create(axes), Create(target), FadeIn(samples), FadeIn(card), FadeIn(loss_label), FadeIn(loss_start), run_time=2.3)\n self.play(Create(rough), run_time=1.6)\n self.play(ReplacementTransform(rough, refined), ReplacementTransform(loss_start, loss_end), run_time=2.6)\n self.play(FadeIn(caption_group), Indicate(refined, color=YELLOW_A), run_time=1.6)\n self.wait(1)\n\n def act_3_oxygenmoleculescene(self):\n atom_radius = 0.5\n atom_color = RED\n bond_color = WHITE\n\n # Create two distinct red circles representing oxygen atoms\n atom1 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n atom2 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n \n # Position atoms apart initially\n atom1.move_to(LEFT * 3)\n atom2.move_to(RIGHT * 3)\n \n # Animation Sequence: Fade In\n self.play(FadeIn(atom1), FadeIn(atom2))\n \n # Move atoms closer to form the molecule structure\n self.play(\n atom1.animate.move_to(LEFT * 0.6),\n atom2.animate.move_to(RIGHT * 0.6)\n )\n \n # Create a double bond connecting the atoms\n # Lines span the gap between the atom edges, offset vertically for a double bond\n bond_top = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_bottom = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_top.shift(UP * 0.15)\n bond_bottom.shift(DOWN * 0.15)\n bond = VGroup(bond_top, bond_bottom)\n \n # Animate the bond formation\n self.play(Create(bond))\n \n # Group all elements to ensure synchronized transformation\n # Placing bond first ensures atoms render on top of the bond\n molecule = VGroup(bond, atom1, atom2)\n \n # Animation Sequence: Rotation around the central point\n self.play(Rotate(molecule, angle=TAU, about_point=ORIGIN, run_time=2))\n \n # Animation Sequence: Scale up to exactly 2x size\n self.play(molecule.animate.scale(2, scale_stroke=True))\n \n # Animation Sequence: Fade Out\n self.play(FadeOut(molecule))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 retains all the original features while adding significant new elements: \n- Act 2: Create a 12-second Manim scene that explains neural network function approximation. Show a target curve with sample points, an initial rough model curve, then morph it into a much better fit while a small loss card decre\n- Act 3: Could you create an animation using Manim that shows two red oxygen atoms coming together to form a molecule? I would like the atoms to first fade into view, then rotate around, and finally scale up to double their size "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0224(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_enhancedrectangleanimati()\n self.clear_stage()\n self.act_2_functionapproximationsto()\n self.clear_stage()\n self.act_3_oxygenmoleculescene()\n\n def act_1_enhancedrectangleanimati(self):\n rect = Rectangle(width=3, height=4, color=ORANGE)\n \n # Animate the rectangle fading in while rotating\n self.play(\n Create(rect),\n Rotate(rect, angle=2*PI, rate_func=linear),\n run_time=2\n )\n self.wait(0.5)\n \n # Split the rectangle into four smaller rectangles\n colors = [BLUE, GREEN, RED, PURPLE]\n small_rects = VGroup(*[\n Rectangle(width=1.5, height=2, color=color).move_to(\n rect.get_center() + np.array([dx, dy, 0])\n )\n for color, (dx, dy) in zip(\n colors,\n [(-0.75, 1), (0.75, 1), (-0.75, -1), (0.75, -1)]\n )\n ])\n \n # Transform the original rectangle into the four smaller ones\n self.play(\n Transform(rect, small_rects),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Show the area formula\n formula = MathTex(\n r\"\\text{Area} = \\text{width} \\times \\text{height} = 3 \\times 4 = 12\",\n font_size=36\n ).next_to(small_rects, DOWN, buff=1)\n \n # Fade in the formula with a bounce effect\n self.play(\n Write(formula),\n formula.animate.scale(1.2).set_color(YELLOW),\n run_time=1\n )\n self.play(\n formula.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show the original rectangle as a faint outline\n ghost_rect = rect.copy().set_fill(opacity=0).set_stroke(ORANGE, opacity=0.3)\n self.add(ghost_rect)\n self.wait(1)\n \n # Fade out all elements in sequence\n self.play(\n FadeOut(small_rects),\n FadeOut(formula),\n FadeOut(ghost_rect),\n run_time=1.5\n )\n\n def act_2_functionapproximationsto(self):\n title = Text('Training Improves The Function Approximation', font_size=28).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[-1.6, 1.8, 1], x_length=7.5, y_length=4.8, tips=False).shift(DOWN * 0.15)\n target = axes.plot(lambda x: 0.9 * np.sin(0.95 * x) + 0.2 * np.cos(2.1 * x), x_range=[0, 8], color=GRAY_B)\n rough = axes.plot(lambda x: 0.35 * np.sin(0.95 * x - 0.4), x_range=[0, 8], color=ORANGE)\n refined = axes.plot(lambda x: 0.86 * np.sin(0.95 * x) + 0.16 * np.cos(2.1 * x + 0.1), x_range=[0, 8], color=BLUE_D)\n samples = VGroup(*[\n Dot(axes.c2p(x, 0.9 * np.sin(0.95 * x) + 0.2 * np.cos(2.1 * x)), color=GRAY_A, radius=0.05)\n for x in [0.6, 1.4, 2.1, 2.9, 3.8, 4.7, 5.6, 6.5, 7.3]\n ])\n card = RoundedRectangle(corner_radius=0.12, width=1.8, height=1.0, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.12).to_corner(UR).shift(DOWN * 0.6)\n loss_label = Text('loss', font_size=18, color=TEAL_D).move_to(card.get_center() + UP * 0.18)\n loss_start = DecimalNumber(1.82, num_decimal_places=2, font_size=28, color=ORANGE).move_to(card.get_center() + DOWN * 0.18)\n loss_end = DecimalNumber(0.34, num_decimal_places=2, font_size=28, color=BLUE_D).move_to(card.get_center() + DOWN * 0.18)\n caption = Text('The model starts with the wrong shape, then training bends it toward the target while the loss falls.', font_size=21, color=WHITE).to_edge(DOWN)\n caption_group = VGroup(BackgroundRectangle(caption, fill_opacity=0.88, buff=0.14), caption)\n\n self.play(FadeIn(title), Create(axes), Create(target), FadeIn(samples), FadeIn(card), FadeIn(loss_label), FadeIn(loss_start), run_time=2.3)\n self.play(Create(rough), run_time=1.6)\n self.play(ReplacementTransform(rough, refined), ReplacementTransform(loss_start, loss_end), run_time=2.6)\n self.play(FadeIn(caption_group), Indicate(refined, color=YELLOW_A), run_time=1.6)\n self.wait(1)\n\n def act_3_oxygenmoleculescene(self):\n atom_radius = 0.5\n atom_color = RED\n bond_color = WHITE\n\n # Create two distinct red circles representing oxygen atoms\n atom1 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n atom2 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n \n # Position atoms apart initially\n atom1.move_to(LEFT * 3)\n atom2.move_to(RIGHT * 3)\n \n # Animation Sequence: Fade In\n self.play(FadeIn(atom1), FadeIn(atom2))\n \n # Move atoms closer to form the molecule structure\n self.play(\n atom1.animate.move_to(LEFT * 0.6),\n atom2.animate.move_to(RIGHT * 0.6)\n )\n \n # Create a double bond connecting the atoms\n # Lines span the gap between the atom edges, offset vertically for a double bond\n bond_top = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_bottom = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_top.shift(UP * 0.15)\n bond_bottom.shift(DOWN * 0.15)\n bond = VGroup(bond_top, bond_bottom)\n \n # Animate the bond formation\n self.play(Create(bond))\n \n # Group all elements to ensure synchronized transformation\n # Placing bond first ensures atoms render on top of the bond\n molecule = VGroup(bond, atom1, atom2)\n \n # Animation Sequence: Rotation around the central point\n self.play(Rotate(molecule, angle=TAU, about_point=ORIGIN, run_time=2))\n \n # Animation Sequence: Scale up to exactly 2x size\n self.play(molecule.animate.scale(2, scale_stroke=True))\n \n # Animation Sequence: Fade Out\n self.play(FadeOut(molecule))\n```"}]}
{"id": "manim-sft-10k_006048", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "RouchesTheorem", "num_animations": 21, "num_rich_primitives": 2, "prompt": "What is the effect of varying contour shapes on the application of Rouche's Theorem when analyzing polynomial functions?", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_002592", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "WordEmbeddingsScene", "num_animations": 8, "num_rich_primitives": 2, "prompt": "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**Key Breakthroughs**:\n\n#### Word Embeddings\n- Map discrete words to a continuous vector space, addressing the \"curse of dimensionality\" and the semantic gap.\n- Word2Vec, GloVe, fastText: capture semantic similarity between words.\n\n$$\\vec{w} \\in \\mathbb{R}^d, \\quad d \\ll |V|$$\n\n\nThe context location of this section (from highest to current level):\n# Introduction and Overview of Natural Language Processing\n## The Evolution of Natural Language Processing\n### The Deep Learning Era (2010s-present)\n", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass WordEmbeddingsScene(Scene):\n\n def construct(self):\n context_text = Text('The Deep Learning Era (2010s-present)', font_size=24, color=GRAY)\n context_text.to_corner(UL)\n title = Tex('\\\\textbf{Key Breakthroughs:} ', 'Word Embeddings')\n title.set_color_by_tex('Word Embeddings', BLUE)\n title.next_to(context_text, DOWN, aligned_edge=LEFT, buff=0.4)\n b1 = Text('• Map discrete words to a continuous vector space, addressing\\n the \"curse of dimensionality\" and the semantic gap.', font_size=28, t2c={'\"curse of dimensionality\"': YELLOW, 'semantic gap': YELLOW})\n b2 = Text('• Word2Vec, GloVe, fastText: capture semantic similarity\\n between words.', font_size=28, t2c={'Word2Vec': GREEN, 'GloVe': GREEN, 'fastText': GREEN})\n bullets = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bullets.next_to(title, DOWN, aligned_edge=LEFT, buff=0.5)\n equation = MathTex('\\\\vec{w} \\\\in \\\\mathbb{R}^d, \\\\quad d \\\\ll |V|', font_size=44)\n equation.next_to(bullets, DOWN, buff=0.6).set_x(0)\n word_cat = Text('cat', font_size=32)\n arrow_cat = MathTex('\\\\rightarrow', font_size=40)\n vec_cat = Matrix([[0.2], [-0.5], [0.8]]).scale(0.6)\n group_cat = VGroup(word_cat, arrow_cat, vec_cat).arrange(RIGHT, buff=0.3)\n word_dog = Text('dog', font_size=32)\n arrow_dog = MathTex('\\\\rightarrow', font_size=40)\n vec_dog = Matrix([[0.3], [-0.4], [0.7]]).scale(0.6)\n group_dog = VGroup(word_dog, arrow_dog, vec_dog).arrange(RIGHT, buff=0.3)\n visual = VGroup(group_cat, group_dog).arrange(RIGHT, buff=2)\n visual.next_to(equation, DOWN, buff=0.6).set_x(0)\n self.play(FadeIn(context_text))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(b1, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(b2, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(Write(equation))\n self.wait(0.5)\n self.play(FadeIn(word_cat, shift=UP * 0.2), FadeIn(word_dog, shift=UP * 0.2))\n self.play(Write(arrow_cat), Write(arrow_dog))\n self.play(FadeIn(vec_cat, shift=LEFT * 0.2), FadeIn(vec_dog, shift=LEFT * 0.2))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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**Key Breakthroughs**:\n\n#### Word Embeddings\n- Map discrete words to a continuous vector space, addressing the \"curse of dimensionality\" and the semantic gap.\n- Word2Vec, GloVe, fastText: capture semantic similarity between words.\n\n$$\\vec{w} \\in \\mathbb{R}^d, \\quad d \\ll |V|$$\n\n\nThe context location of this section (from highest to current level):\n# Introduction and Overview of Natural Language Processing\n## The Evolution of Natural Language Processing\n### The Deep Learning Era (2010s-present)\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass WordEmbeddingsScene(Scene):\n\n def construct(self):\n context_text = Text('The Deep Learning Era (2010s-present)', font_size=24, color=GRAY)\n context_text.to_corner(UL)\n title = Tex('\\\\textbf{Key Breakthroughs:} ', 'Word Embeddings')\n title.set_color_by_tex('Word Embeddings', BLUE)\n title.next_to(context_text, DOWN, aligned_edge=LEFT, buff=0.4)\n b1 = Text('• Map discrete words to a continuous vector space, addressing\\n the \"curse of dimensionality\" and the semantic gap.', font_size=28, t2c={'\"curse of dimensionality\"': YELLOW, 'semantic gap': YELLOW})\n b2 = Text('• Word2Vec, GloVe, fastText: capture semantic similarity\\n between words.', font_size=28, t2c={'Word2Vec': GREEN, 'GloVe': GREEN, 'fastText': GREEN})\n bullets = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bullets.next_to(title, DOWN, aligned_edge=LEFT, buff=0.5)\n equation = MathTex('\\\\vec{w} \\\\in \\\\mathbb{R}^d, \\\\quad d \\\\ll |V|', font_size=44)\n equation.next_to(bullets, DOWN, buff=0.6).set_x(0)\n word_cat = Text('cat', font_size=32)\n arrow_cat = MathTex('\\\\rightarrow', font_size=40)\n vec_cat = Matrix([[0.2], [-0.5], [0.8]]).scale(0.6)\n group_cat = VGroup(word_cat, arrow_cat, vec_cat).arrange(RIGHT, buff=0.3)\n word_dog = Text('dog', font_size=32)\n arrow_dog = MathTex('\\\\rightarrow', font_size=40)\n vec_dog = Matrix([[0.3], [-0.4], [0.7]]).scale(0.6)\n group_dog = VGroup(word_dog, arrow_dog, vec_dog).arrange(RIGHT, buff=0.3)\n visual = VGroup(group_cat, group_dog).arrange(RIGHT, buff=2)\n visual.next_to(equation, DOWN, buff=0.6).set_x(0)\n self.play(FadeIn(context_text))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(b1, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(b2, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(Write(equation))\n self.wait(0.5)\n self.play(FadeIn(word_cat, shift=UP * 0.2), FadeIn(word_dog, shift=UP * 0.2))\n self.play(Write(arrow_cat), Write(arrow_dog))\n self.play(FadeIn(vec_cat, shift=LEFT * 0.2), FadeIn(vec_dog, shift=LEFT * 0.2))\n self.wait(2)\n```"}]}
{"id": "manim-sft-10k_001876", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "HomomorphismFoldingPatterns", "num_animations": 19, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PythagoreanTheorem", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_001442", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralX3", "num_animations": 15, "num_rich_primitives": 4, "prompt": "I would like to create an educational animation that visually explains how to compute the definite integral of the function x^3 from 0 to 2. The animation should begin by displaying the integral problem, then highlight the integration bounds, and explain how to apply the power rule of integration. After that, I want to see the integration carried out step by step, how to insert the limits of integration, and finally, evaluate and simplify the solution to find the area under the curve. The conclusion should emphasize the result, which is the area under the curve between 0 and 2. Can you create and describe a video that covers all these steps in an accessible and engaging way for my students learning calculus?", "code": "from manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_BOUNDS = YELLOW\n COLOR_RULE = BLUE\n COLOR_RESULT = GREEN\n\n # --- Step 1: Introduction - Display the Integral Problem ---\n problem = MathTex(r\"\\int_{0}^{2}\", \"x^3\", r\"\\,dx\", font_size=72)\n problem.to_edge(UP)\n \n title = Text(\"Computing a Definite Integral\", font_size=36)\n title.next_to(problem, UP, buff=0.5)\n \n self.play(Write(title), Write(problem))\n self.wait(1)\n\n # --- Step 2: Bounds Highlighting ---\n # Isolate bounds for highlighting\n lower_bound_box = SurroundingRectangle(problem[0][2], color=COLOR_BOUNDS)\n upper_bound_box = SurroundingRectangle(problem[0][1], color=COLOR_BOUNDS)\n bounds_label = Text(\"Limits of Integration\", font_size=24, color=COLOR_BOUNDS)\n bounds_label.next_to(problem, DOWN, buff=0.5)\n \n self.play(\n Create(lower_bound_box), \n Create(upper_bound_box), \n FadeIn(bounds_label)\n )\n self.wait(1)\n self.play(\n FadeOut(lower_bound_box), \n FadeOut(upper_bound_box), \n FadeOut(bounds_label)\n )\n\n # --- Step 3: Concept Explanation - Power Rule ---\n power_rule = MathTex(r\"\\int x^n \\,dx = \\frac{x^{n+1}}{n+1}\", font_size=48, color=COLOR_RULE)\n power_rule.next_to(problem, DOWN, buff=1)\n \n rule_label = Text(\"Applying the Power Rule:\", font_size=28)\n rule_label.next_to(power_rule, UP, buff=0.2)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(2)\n self.play(FadeOut(rule_label), FadeOut(power_rule))\n\n # --- Step 4: Step-by-Step Execution ---\n # 4a: Antiderivative calculation\n step1 = MathTex(r\"=\", r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=60)\n step1.next_to(problem, DOWN, buff=0.8, aligned_edge=LEFT)\n \n step1_simplified = MathTex(r\"=\", r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=60)\n step1_simplified.move_to(step1)\n\n self.play(Write(step1))\n self.wait(1)\n self.play(ReplacementTransform(step1, step1_simplified))\n self.wait(1)\n\n # 4b: Substitution of limits\n step2 = MathTex(r\"=\", r\"\\left( \\frac{2^4}{4} \\right)\", \"-\", r\"\\left( \\frac{0^4}{4} \\right)\", font_size=60)\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(1)\n\n # 4c: Arithmetic evaluation\n step3 = MathTex(r\"=\", r\"\\frac{16}{4}\", \"-\", \"0\", font_size=60)\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # 4d: Final Result\n final_result = MathTex(r\"=\", \"4\", font_size=72, color=COLOR_RESULT)\n final_result.next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(final_result))\n self.wait(1)\n\n # --- Step 5: Conclusion - Area Under the Curve ---\n # Shift the algebraic solution to the left to make room for the graph\n solution_group = VGroup(problem, step1, step2, step3, final_result)\n self.play(solution_group.animate.shift(LEFT * 4))\n\n # Create Axes and Plot\n axes = Axes(\n x_range=[0, 2.5, 1],\n y_range=[0, 10, 2],\n x_length=4,\n y_length=3,\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 1.5 + RIGHT * 3)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n curve = axes.plot(lambda x: x**3, x_range=[0, 2], color=WHITE)\n graph_label = axes.get_graph_label(curve, label=\"f(x) = x^3\", x_val=1.5, direction=UR)\n \n # Fill Area\n area = axes.get_area(curve, x_range=[0, 2], color=COLOR_RESULT, opacity=0.5)\n area_label = Text(\"Area = 4\", font_size=30, color=COLOR_RESULT).next_to(axes, UP)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(graph_label))\n self.play(FadeIn(area), Write(area_label))\n \n # Final emphasis\n result_box = SurroundingRectangle(final_result, color=COLOR_RESULT, buff=0.2)\n self.play(Create(result_box))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that visually explains how to compute the definite integral of the function x^3 from 0 to 2. The animation should begin by displaying the integral problem, then highlight the integration bounds, and explain how to apply the power rule of integration. After that, I want to see the integration carried out step by step, how to insert the limits of integration, and finally, evaluate and simplify the solution to find the area under the curve. The conclusion should emphasize the result, which is the area under the curve between 0 and 2. Can you create and describe a video that covers all these steps in an accessible and engaging way for my students learning calculus?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_BOUNDS = YELLOW\n COLOR_RULE = BLUE\n COLOR_RESULT = GREEN\n\n # --- Step 1: Introduction - Display the Integral Problem ---\n problem = MathTex(r\"\\int_{0}^{2}\", \"x^3\", r\"\\,dx\", font_size=72)\n problem.to_edge(UP)\n \n title = Text(\"Computing a Definite Integral\", font_size=36)\n title.next_to(problem, UP, buff=0.5)\n \n self.play(Write(title), Write(problem))\n self.wait(1)\n\n # --- Step 2: Bounds Highlighting ---\n # Isolate bounds for highlighting\n lower_bound_box = SurroundingRectangle(problem[0][2], color=COLOR_BOUNDS)\n upper_bound_box = SurroundingRectangle(problem[0][1], color=COLOR_BOUNDS)\n bounds_label = Text(\"Limits of Integration\", font_size=24, color=COLOR_BOUNDS)\n bounds_label.next_to(problem, DOWN, buff=0.5)\n \n self.play(\n Create(lower_bound_box), \n Create(upper_bound_box), \n FadeIn(bounds_label)\n )\n self.wait(1)\n self.play(\n FadeOut(lower_bound_box), \n FadeOut(upper_bound_box), \n FadeOut(bounds_label)\n )\n\n # --- Step 3: Concept Explanation - Power Rule ---\n power_rule = MathTex(r\"\\int x^n \\,dx = \\frac{x^{n+1}}{n+1}\", font_size=48, color=COLOR_RULE)\n power_rule.next_to(problem, DOWN, buff=1)\n \n rule_label = Text(\"Applying the Power Rule:\", font_size=28)\n rule_label.next_to(power_rule, UP, buff=0.2)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(2)\n self.play(FadeOut(rule_label), FadeOut(power_rule))\n\n # --- Step 4: Step-by-Step Execution ---\n # 4a: Antiderivative calculation\n step1 = MathTex(r\"=\", r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=60)\n step1.next_to(problem, DOWN, buff=0.8, aligned_edge=LEFT)\n \n step1_simplified = MathTex(r\"=\", r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=60)\n step1_simplified.move_to(step1)\n\n self.play(Write(step1))\n self.wait(1)\n self.play(ReplacementTransform(step1, step1_simplified))\n self.wait(1)\n\n # 4b: Substitution of limits\n step2 = MathTex(r\"=\", r\"\\left( \\frac{2^4}{4} \\right)\", \"-\", r\"\\left( \\frac{0^4}{4} \\right)\", font_size=60)\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(1)\n\n # 4c: Arithmetic evaluation\n step3 = MathTex(r\"=\", r\"\\frac{16}{4}\", \"-\", \"0\", font_size=60)\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # 4d: Final Result\n final_result = MathTex(r\"=\", \"4\", font_size=72, color=COLOR_RESULT)\n final_result.next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(final_result))\n self.wait(1)\n\n # --- Step 5: Conclusion - Area Under the Curve ---\n # Shift the algebraic solution to the left to make room for the graph\n solution_group = VGroup(problem, step1, step2, step3, final_result)\n self.play(solution_group.animate.shift(LEFT * 4))\n\n # Create Axes and Plot\n axes = Axes(\n x_range=[0, 2.5, 1],\n y_range=[0, 10, 2],\n x_length=4,\n y_length=3,\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 1.5 + RIGHT * 3)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n curve = axes.plot(lambda x: x**3, x_range=[0, 2], color=WHITE)\n graph_label = axes.get_graph_label(curve, label=\"f(x) = x^3\", x_val=1.5, direction=UR)\n \n # Fill Area\n area = axes.get_area(curve, x_range=[0, 2], color=COLOR_RESULT, opacity=0.5)\n area_label = Text(\"Area = 4\", font_size=30, color=COLOR_RESULT).next_to(axes, UP)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(graph_label))\n self.play(FadeIn(area), Write(area_label))\n \n # Final emphasis\n result_box = SurroundingRectangle(final_result, color=COLOR_RESULT, buff=0.2)\n self.play(Create(result_box))\n self.wait(3)\n```"}]}
{"id": "multi_act_v2_00215", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0215", "num_animations": 19, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "ComplexPowerSeriesScene", "num_animations": 19, "num_rich_primitives": 2, "prompt": "How do complex power series exhibit different convergence properties when expanded around essential singularities as opposed to regular points?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00153", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0153", "num_animations": 18, "prompt": "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: 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 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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0153(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_simplificationlaw()\n self.clear_stage()\n self.act_2_corollaryuncomputablefun()\n\n def act_1_simplificationlaw(self):\n context = Tex('\\\\textit{Discrete Mathematics: Consequence Relation}')\n context.scale(0.6)\n context.set_color(GRAY)\n context.to_corner(UL)\n title = Tex('\\\\textbf{Example 19: Simplification Law}')\n title.scale(1.2)\n title.to_edge(UP, buff=1.0)\n title_underline = Underline(title, color=BLUE)\n premise = Tex('\\\\textbf{Premise:} I bought an apple and a pear ($A \\\\land B$).')\n conclusion = Tex('\\\\textbf{Conclusion:} I bought an apple ($A$).')\n formal = Tex('\\\\textbf{Formal representation:} $\\\\{A \\\\land B\\\\} \\\\models A$.')\n formal.set_color(YELLOW)\n content = VGroup(premise, conclusion, formal)\n content.arrange(DOWN, aligned_edge=LEFT, buff=1.5)\n content.next_to(title, DOWN, buff=1.2)\n arrow1 = MathTex('\\\\Downarrow').scale(1.2).set_color(BLUE)\n arrow1.move_to((premise.get_bottom() + conclusion.get_top()) / 2)\n arrow1.align_to(premise, LEFT).shift(RIGHT * 1.5)\n arrow2 = MathTex('\\\\Downarrow').scale(1.2).set_color(BLUE)\n arrow2.move_to((conclusion.get_bottom() + formal.get_top()) / 2)\n arrow2.align_to(conclusion, LEFT).shift(RIGHT * 1.5)\n self.play(FadeIn(context))\n self.play(Write(title), Create(title_underline))\n self.wait(0.5)\n self.play(FadeIn(premise, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(arrow1, shift=DOWN))\n self.play(FadeIn(conclusion, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(arrow2, shift=DOWN))\n self.play(Write(formal))\n box = SurroundingRectangle(formal, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_corollaryuncomputablefun(self):\n context = Tex('Discrete Mathematics: Countable Sets', color=GRAY)\n context.scale(0.6).to_edge(UP, buff=0.3)\n title = Tex('\\\\textbf{Corollary (Inference)}', color=BLUE)\n title.scale(1.1).next_to(context, DOWN, buff=0.4)\n line1 = Tex('Since computer programs are essentially finite-length strings')\n line2 = Tex('composed of a finite set of characters (ASCII or Unicode):')\n group1 = VGroup(line1, line2).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n line3 = Tex('$\\\\Rightarrow$ \\\\textbf{The set of all possible computer programs is countable.}', color=YELLOW)\n line4 = Tex('Although the set of real numbers $\\\\mathbb{R}$ and the set of all')\n line5 = Tex('functions from $\\\\mathbb{N}$ to $\\\\{0, 1\\\\}$ are \\\\textbf{uncountable},')\n line6 = Tex('the number of programs we can write is only \\\\textbf{countable}.')\n group2 = VGroup(line4, line5, line6).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n line7 = Tex('$\\\\Rightarrow$ \\\\textbf{Uncomputable functions exist!}', color=GREEN_C)\n line8 = Tex('(There are many more functions than there are programs)', color=LIGHT_GREY).scale(0.9)\n group3 = VGroup(line7, line8).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n content = VGroup(group1, line3, group2, group3).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content.scale(0.8).next_to(title, DOWN, buff=0.5)\n content.set_x(0)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(group1, shift=UP * 0.1))\n self.wait(0.5)\n self.play(Write(line3))\n self.wait(1)\n self.play(FadeIn(group2, shift=UP * 0.1))\n self.wait(1)\n self.play(Write(line7))\n self.play(FadeIn(line8, shift=UP * 0.1))\n box = SurroundingRectangle(group3, color=GREEN_C, buff=0.2, corner_radius=0.1)\n self.play(Create(box))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 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_0153(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_simplificationlaw()\n self.clear_stage()\n self.act_2_corollaryuncomputablefun()\n\n def act_1_simplificationlaw(self):\n context = Tex('\\\\textit{Discrete Mathematics: Consequence Relation}')\n context.scale(0.6)\n context.set_color(GRAY)\n context.to_corner(UL)\n title = Tex('\\\\textbf{Example 19: Simplification Law}')\n title.scale(1.2)\n title.to_edge(UP, buff=1.0)\n title_underline = Underline(title, color=BLUE)\n premise = Tex('\\\\textbf{Premise:} I bought an apple and a pear ($A \\\\land B$).')\n conclusion = Tex('\\\\textbf{Conclusion:} I bought an apple ($A$).')\n formal = Tex('\\\\textbf{Formal representation:} $\\\\{A \\\\land B\\\\} \\\\models A$.')\n formal.set_color(YELLOW)\n content = VGroup(premise, conclusion, formal)\n content.arrange(DOWN, aligned_edge=LEFT, buff=1.5)\n content.next_to(title, DOWN, buff=1.2)\n arrow1 = MathTex('\\\\Downarrow').scale(1.2).set_color(BLUE)\n arrow1.move_to((premise.get_bottom() + conclusion.get_top()) / 2)\n arrow1.align_to(premise, LEFT).shift(RIGHT * 1.5)\n arrow2 = MathTex('\\\\Downarrow').scale(1.2).set_color(BLUE)\n arrow2.move_to((conclusion.get_bottom() + formal.get_top()) / 2)\n arrow2.align_to(conclusion, LEFT).shift(RIGHT * 1.5)\n self.play(FadeIn(context))\n self.play(Write(title), Create(title_underline))\n self.wait(0.5)\n self.play(FadeIn(premise, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(arrow1, shift=DOWN))\n self.play(FadeIn(conclusion, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(arrow2, shift=DOWN))\n self.play(Write(formal))\n box = SurroundingRectangle(formal, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_corollaryuncomputablefun(self):\n context = Tex('Discrete Mathematics: Countable Sets', color=GRAY)\n context.scale(0.6).to_edge(UP, buff=0.3)\n title = Tex('\\\\textbf{Corollary (Inference)}', color=BLUE)\n title.scale(1.1).next_to(context, DOWN, buff=0.4)\n line1 = Tex('Since computer programs are essentially finite-length strings')\n line2 = Tex('composed of a finite set of characters (ASCII or Unicode):')\n group1 = VGroup(line1, line2).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n line3 = Tex('$\\\\Rightarrow$ \\\\textbf{The set of all possible computer programs is countable.}', color=YELLOW)\n line4 = Tex('Although the set of real numbers $\\\\mathbb{R}$ and the set of all')\n line5 = Tex('functions from $\\\\mathbb{N}$ to $\\\\{0, 1\\\\}$ are \\\\textbf{uncountable},')\n line6 = Tex('the number of programs we can write is only \\\\textbf{countable}.')\n group2 = VGroup(line4, line5, line6).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n line7 = Tex('$\\\\Rightarrow$ \\\\textbf{Uncomputable functions exist!}', color=GREEN_C)\n line8 = Tex('(There are many more functions than there are programs)', color=LIGHT_GREY).scale(0.9)\n group3 = VGroup(line7, line8).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n content = VGroup(group1, line3, group2, group3).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content.scale(0.8).next_to(title, DOWN, buff=0.5)\n content.set_x(0)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(group1, shift=UP * 0.1))\n self.wait(0.5)\n self.play(Write(line3))\n self.wait(1)\n self.play(FadeIn(group2, shift=UP * 0.1))\n self.wait(1)\n self.play(Write(line7))\n self.play(FadeIn(line8, shift=UP * 0.1))\n box = SurroundingRectangle(group3, color=GREEN_C, buff=0.2, corner_radius=0.1)\n self.play(Create(box))\n self.wait(3)\n```"}]}
{"id": "manim-sft-10k_002831", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "StreamCiphersLecture", "num_animations": 12, "num_rich_primitives": 2, "prompt": "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# Stream Ciphers\n\nThis section of the course delves into the operational mechanisms of stream ciphers, elucidates the mathematical principles behind their core component, the Linear Feedback Shift Register (LFSR), and analyzes the design and security of classic algorithms such as RC4.\n\n## Course Objectives\n### Understanding the Basic Principles of Stream Ciphers\nStudents should be able to explain how stream ciphers achieve encryption by performing an XOR operation between the plaintext and the keystream, and understand the connection to the one-time pad.", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass StreamCiphersLecture(Scene):\n\n def construct(self):\n title = Title('Stream Ciphers')\n self.play(Write(title))\n intro_text = Text('This section of the course delves into the operational mechanisms\\nof stream ciphers, elucidates the mathematical principles behind\\ntheir core component, the Linear Feedback Shift Register (LFSR),\\nand analyzes the design and security of classic algorithms such as RC4.', font_size=28, line_spacing=1.2)\n intro_text.next_to(title, DOWN, buff=1)\n self.play(FadeIn(intro_text, shift=UP))\n self.wait(4)\n self.play(FadeOut(intro_text))\n obj_title = Title('Course Objectives')\n self.play(Transform(title, obj_title))\n sub_title = Text('Understanding the Basic Principles of Stream Ciphers', font_size=32, color=BLUE)\n sub_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(sub_title))\n obj_content = Text('Students should be able to explain how stream ciphers achieve\\nencryption by performing an XOR operation between the plaintext\\nand the keystream, and understand the connection to the one-time pad.', font_size=24, line_spacing=1.2)\n obj_content.next_to(sub_title, DOWN, buff=0.5)\n self.play(FadeIn(obj_content, shift=UP))\n self.wait(2)\n pt = Text('Plaintext', font_size=36, color=GREEN)\n xor_sym = MathTex('\\\\oplus', font_size=48)\n ks = Text('Keystream', font_size=36, color=YELLOW)\n eq_sym = MathTex('=', font_size=48)\n ct = Text('Ciphertext', font_size=36, color=RED)\n equation = VGroup(pt, xor_sym, ks, eq_sym, ct).arrange(RIGHT, buff=0.4)\n equation.next_to(obj_content, DOWN, buff=1.0)\n self.play(Write(pt))\n self.play(Write(xor_sym), Write(ks))\n self.play(Write(eq_sym), Write(ct))\n self.wait(2)\n otp_box = SurroundingRectangle(equation, color=WHITE, buff=0.25, corner_radius=0.1)\n otp_label = Text('Conceptual Basis: One-Time Pad (OTP)', font_size=28, color=ORANGE)\n otp_label.next_to(otp_box, DOWN, buff=0.4)\n self.play(Create(otp_box))\n self.play(FadeIn(otp_label, shift=UP))\n self.wait(4)\n self.play(FadeOut(title), FadeOut(sub_title), FadeOut(obj_content), FadeOut(equation), FadeOut(otp_box), FadeOut(otp_label))\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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# Stream Ciphers\n\nThis section of the course delves into the operational mechanisms of stream ciphers, elucidates the mathematical principles behind their core component, the Linear Feedback Shift Register (LFSR), and analyzes the design and security of classic algorithms such as RC4.\n\n## Course Objectives\n### Understanding the Basic Principles of Stream Ciphers\nStudents should be able to explain how stream ciphers achieve encryption by performing an XOR operation between the plaintext and the keystream, and understand the connection to the one-time pad."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass StreamCiphersLecture(Scene):\n\n def construct(self):\n title = Title('Stream Ciphers')\n self.play(Write(title))\n intro_text = Text('This section of the course delves into the operational mechanisms\\nof stream ciphers, elucidates the mathematical principles behind\\ntheir core component, the Linear Feedback Shift Register (LFSR),\\nand analyzes the design and security of classic algorithms such as RC4.', font_size=28, line_spacing=1.2)\n intro_text.next_to(title, DOWN, buff=1)\n self.play(FadeIn(intro_text, shift=UP))\n self.wait(4)\n self.play(FadeOut(intro_text))\n obj_title = Title('Course Objectives')\n self.play(Transform(title, obj_title))\n sub_title = Text('Understanding the Basic Principles of Stream Ciphers', font_size=32, color=BLUE)\n sub_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(sub_title))\n obj_content = Text('Students should be able to explain how stream ciphers achieve\\nencryption by performing an XOR operation between the plaintext\\nand the keystream, and understand the connection to the one-time pad.', font_size=24, line_spacing=1.2)\n obj_content.next_to(sub_title, DOWN, buff=0.5)\n self.play(FadeIn(obj_content, shift=UP))\n self.wait(2)\n pt = Text('Plaintext', font_size=36, color=GREEN)\n xor_sym = MathTex('\\\\oplus', font_size=48)\n ks = Text('Keystream', font_size=36, color=YELLOW)\n eq_sym = MathTex('=', font_size=48)\n ct = Text('Ciphertext', font_size=36, color=RED)\n equation = VGroup(pt, xor_sym, ks, eq_sym, ct).arrange(RIGHT, buff=0.4)\n equation.next_to(obj_content, DOWN, buff=1.0)\n self.play(Write(pt))\n self.play(Write(xor_sym), Write(ks))\n self.play(Write(eq_sym), Write(ct))\n self.wait(2)\n otp_box = SurroundingRectangle(equation, color=WHITE, buff=0.25, corner_radius=0.1)\n otp_label = Text('Conceptual Basis: One-Time Pad (OTP)', font_size=28, color=ORANGE)\n otp_label.next_to(otp_box, DOWN, buff=0.4)\n self.play(Create(otp_box))\n self.play(FadeIn(otp_label, shift=UP))\n self.wait(4)\n self.play(FadeOut(title), FadeOut(sub_title), FadeOut(obj_content), FadeOut(equation), FadeOut(otp_box), FadeOut(otp_label))\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_000468", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaveEquationExplanation", "num_animations": 13, "num_rich_primitives": 4, "prompt": "Can you create an animation that explains the wave equation, its general solution for waves moving in both directions, and shows a specific sinusoidal wave solution along with corresponding descriptive text for each part?", "code": "from manim import *\nimport numpy as np\n\nclass WaveEquationExplanation(Scene):\n def construct(self):\n # --- Styling Constants ---\n eq_color = BLUE\n wave_color = YELLOW\n pulse_color = GREEN\n text_color = WHITE\n\n # ==========================================\n # 1. The Wave Equation (PDE)\n # ==========================================\n title = Text(\"The Wave Equation\", font_size=48).to_edge(UP)\n \n # ∂^2u/∂t^2 = c^2 ∂^2u/∂x^2\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n color=eq_color, font_size=50\n ).shift(UP * 0.5)\n \n desc_1 = Text(\n \"This PDE relates spatial curvature to temporal acceleration,\\n\"\n \"governing how disturbances propagate at speed c.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(wave_eq, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(wave_eq))\n self.play(FadeIn(desc_1))\n self.wait(3)\n \n # Transition\n self.play(\n FadeOut(desc_1),\n wave_eq.animate.shift(UP * 1.5),\n title.animate.scale(0.8).to_corner(UL)\n )\n\n # ==========================================\n # 2. General Solution (D'Alembert)\n # ==========================================\n # u(x,t) = f(x-ct) + g(x+ct)\n gen_sol = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n color=eq_color, font_size=48\n ).shift(UP * 0.5)\n \n # Indicators for direction\n arrow_right = Arrow(START, RIGHT, color=RED, buff=0).scale(0.5)\n arrow_right.next_to(gen_sol[2], DOWN, buff=0.2)\n label_right = Text(\"Right-moving\", font_size=24, color=RED).next_to(arrow_right, DOWN, buff=0.1)\n \n arrow_left = Arrow(START, LEFT, color=PURPLE, buff=0).scale(0.5)\n arrow_left.next_to(gen_sol[4], DOWN, buff=0.2)\n label_left = Text(\"Left-moving\", font_size=24, color=PURPLE).next_to(arrow_left, DOWN, buff=0.1)\n \n desc_2 = Text(\n \"D'Alembert's Solution: Superposition of\\nwaves traveling in opposite directions.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(gen_sol, DOWN, buff=1)\n\n self.play(Write(gen_sol))\n self.play(\n GrowArrow(arrow_right), FadeIn(label_right),\n GrowArrow(arrow_left), FadeIn(label_left),\n FadeIn(desc_2)\n )\n self.wait(2)\n\n # Visualizing Moving Pulses\n axes = Axes(\n x_range=[-6, 6, 1], y_range=[-2, 2, 1],\n axis_config={\"include_tip\": False},\n x_length=10, y_length=4\n ).shift(DOWN * 2)\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n t_tracker = ValueTracker(0)\n \n def pulse_right(x):\n return np.exp(-(x - t_tracker.get_value())**2)\n \n def pulse_left(x):\n return np.exp(-(x + t_tracker.get_value())**2)\n\n graph_right = always_redraw(lambda: axes.plot(pulse_right, color=RED))\n graph_left = always_redraw(lambda: axes.plot(pulse_left, color=PURPLE))\n\n self.play(Create(axes), FadeIn(axes_labels))\n self.add(graph_left, graph_right)\n \n self.play(t_tracker.animate.set_value(2), run_time=3, rate_func=linear)\n self.wait(1)\n \n # Transition\n self.play(\n FadeOut(axes), FadeOut(axes_labels),\n FadeOut(graph_left), FadeOut(graph_right),\n FadeOut(gen_sol), FadeOut(desc_2),\n FadeOut(arrow_right), FadeOut(label_right),\n FadeOut(arrow_left), FadeOut(label_left)\n )\n\n # ==========================================\n # 3. Specific Sinusoidal Solution\n # ==========================================\n # u(x,t) = A sin(kx - ωt)\n sin_sol = MathTex(\n r\"u(x, t)\", \"=\", r\"A \\sin(kx - \\omega t)\",\n color=eq_color, font_size=48\n ).to_edge(UP, buff=0.5)\n \n desc_3 = Text(\n \"Harmonic Wave: A specific periodic solution\\n\"\n \"characterized by amplitude A and frequency ω.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(sin_sol, DOWN, buff=0.5)\n\n # Coordinate System for Animation\n axes_sin = Axes(\n x_range=[-2 * PI, 2 * PI, PI], y_range=[-2, 2, 1],\n x_length=10, y_length=4,\n axis_config={\"include_tip\": False, \"include_numbers\": False}\n ).shift(DOWN * 1.5)\n axes_sin_labels = axes_sin.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n t_tracker_sin = ValueTracker(0)\n \n # u(x,t) = sin(x - t) for visualization\n wave_graph = always_redraw(lambda: axes_sin.plot(\n lambda x: np.sin(x - t_tracker_sin.get_value()),\n x_range=[-2 * PI, 2 * PI],\n color=wave_color, stroke_width=4\n ))\n\n self.play(Write(sin_sol), FadeIn(desc_3))\n self.play(Create(axes_sin), FadeIn(axes_sin_labels))\n self.add(wave_graph)\n \n # Animate the wave propagation for one full period\n self.play(\n t_tracker_sin.animate.set_value(2 * PI),\n run_time=4, rate_func=linear\n )\n self.wait(2)\n\n # Final Fade Out\n self.play(*[FadeOut(mob) for mob in self.mobjects])", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animation that explains the wave equation, its general solution for waves moving in both directions, and shows a specific sinusoidal wave solution along with corresponding descriptive text for each part?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaveEquationExplanation(Scene):\n def construct(self):\n # --- Styling Constants ---\n eq_color = BLUE\n wave_color = YELLOW\n pulse_color = GREEN\n text_color = WHITE\n\n # ==========================================\n # 1. The Wave Equation (PDE)\n # ==========================================\n title = Text(\"The Wave Equation\", font_size=48).to_edge(UP)\n \n # ∂^2u/∂t^2 = c^2 ∂^2u/∂x^2\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n color=eq_color, font_size=50\n ).shift(UP * 0.5)\n \n desc_1 = Text(\n \"This PDE relates spatial curvature to temporal acceleration,\\n\"\n \"governing how disturbances propagate at speed c.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(wave_eq, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(wave_eq))\n self.play(FadeIn(desc_1))\n self.wait(3)\n \n # Transition\n self.play(\n FadeOut(desc_1),\n wave_eq.animate.shift(UP * 1.5),\n title.animate.scale(0.8).to_corner(UL)\n )\n\n # ==========================================\n # 2. General Solution (D'Alembert)\n # ==========================================\n # u(x,t) = f(x-ct) + g(x+ct)\n gen_sol = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n color=eq_color, font_size=48\n ).shift(UP * 0.5)\n \n # Indicators for direction\n arrow_right = Arrow(START, RIGHT, color=RED, buff=0).scale(0.5)\n arrow_right.next_to(gen_sol[2], DOWN, buff=0.2)\n label_right = Text(\"Right-moving\", font_size=24, color=RED).next_to(arrow_right, DOWN, buff=0.1)\n \n arrow_left = Arrow(START, LEFT, color=PURPLE, buff=0).scale(0.5)\n arrow_left.next_to(gen_sol[4], DOWN, buff=0.2)\n label_left = Text(\"Left-moving\", font_size=24, color=PURPLE).next_to(arrow_left, DOWN, buff=0.1)\n \n desc_2 = Text(\n \"D'Alembert's Solution: Superposition of\\nwaves traveling in opposite directions.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(gen_sol, DOWN, buff=1)\n\n self.play(Write(gen_sol))\n self.play(\n GrowArrow(arrow_right), FadeIn(label_right),\n GrowArrow(arrow_left), FadeIn(label_left),\n FadeIn(desc_2)\n )\n self.wait(2)\n\n # Visualizing Moving Pulses\n axes = Axes(\n x_range=[-6, 6, 1], y_range=[-2, 2, 1],\n axis_config={\"include_tip\": False},\n x_length=10, y_length=4\n ).shift(DOWN * 2)\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n t_tracker = ValueTracker(0)\n \n def pulse_right(x):\n return np.exp(-(x - t_tracker.get_value())**2)\n \n def pulse_left(x):\n return np.exp(-(x + t_tracker.get_value())**2)\n\n graph_right = always_redraw(lambda: axes.plot(pulse_right, color=RED))\n graph_left = always_redraw(lambda: axes.plot(pulse_left, color=PURPLE))\n\n self.play(Create(axes), FadeIn(axes_labels))\n self.add(graph_left, graph_right)\n \n self.play(t_tracker.animate.set_value(2), run_time=3, rate_func=linear)\n self.wait(1)\n \n # Transition\n self.play(\n FadeOut(axes), FadeOut(axes_labels),\n FadeOut(graph_left), FadeOut(graph_right),\n FadeOut(gen_sol), FadeOut(desc_2),\n FadeOut(arrow_right), FadeOut(label_right),\n FadeOut(arrow_left), FadeOut(label_left)\n )\n\n # ==========================================\n # 3. Specific Sinusoidal Solution\n # ==========================================\n # u(x,t) = A sin(kx - ωt)\n sin_sol = MathTex(\n r\"u(x, t)\", \"=\", r\"A \\sin(kx - \\omega t)\",\n color=eq_color, font_size=48\n ).to_edge(UP, buff=0.5)\n \n desc_3 = Text(\n \"Harmonic Wave: A specific periodic solution\\n\"\n \"characterized by amplitude A and frequency ω.\",\n font_size=28, color=text_color, line_spacing=1.5\n ).next_to(sin_sol, DOWN, buff=0.5)\n\n # Coordinate System for Animation\n axes_sin = Axes(\n x_range=[-2 * PI, 2 * PI, PI], y_range=[-2, 2, 1],\n x_length=10, y_length=4,\n axis_config={\"include_tip\": False, \"include_numbers\": False}\n ).shift(DOWN * 1.5)\n axes_sin_labels = axes_sin.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n t_tracker_sin = ValueTracker(0)\n \n # u(x,t) = sin(x - t) for visualization\n wave_graph = always_redraw(lambda: axes_sin.plot(\n lambda x: np.sin(x - t_tracker_sin.get_value()),\n x_range=[-2 * PI, 2 * PI],\n color=wave_color, stroke_width=4\n ))\n\n self.play(Write(sin_sol), FadeIn(desc_3))\n self.play(Create(axes_sin), FadeIn(axes_sin_labels))\n self.add(wave_graph)\n \n # Animate the wave propagation for one full period\n self.play(\n t_tracker_sin.animate.set_value(2 * PI),\n run_time=4, rate_func=linear\n )\n self.wait(2)\n\n # Final Fade Out\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n```"}]}
{"id": "adaption-unified-manim-instructions_007535", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TextToCircles", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000577", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "ProbabilisticSampling", "num_animations": 3, "num_rich_primitives": 1, "prompt": "I'm teaching an undergrad course on sequence models and want a probabilistic sampling visualization. Animate a spinning wheel divided into character slices, landing on the next character according to the learned distribution. Show the probability weights as arc lengths and reflect the sample decision with a glow and a landing pointer. Include a short, repeatable loop with different temperature settings to compare sampling diversity.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass ProbabilisticSampling(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: WHEEL]\n with self.voiceover(text=\"Probabilistic sampling can be visualized as a spinning wheel divided into character slices. The arc lengths represent the probability weights of each character.\") as tracker:\n title = Text(\"Probabilistic Sampling\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n wheel = Circle(radius=2, color=WHITE)\n slices = VGroup()\n angles = [0, PI/2, PI, 3*PI/2, 2*PI]\n colors = [RED, GREEN, BLUE, YELLOW]\n for i in range(4):\n sector = AnnularSector(inner_radius=0, outer_radius=2, angle=angles[i+1]-angles[i], start_angle=angles[i], color=colors[i], fill_opacity=0.5)\n slices.add(sector)\n \n self.wait_until_bookmark(\"WHEEL\")\n self.play(Write(title), Create(wheel), Create(slices), run_time=tracker.duration)\n \n with self.voiceover(text=\"The wheel lands on the next character according to the learned distribution. The landing pointer glows to reflect the sample decision.\") as tracker:\n pointer = Polygon(ORIGIN, UP*0.3, LEFT*0.1, RIGHT*0.1, color=WHITE, fill_opacity=1)\n pointer.next_to(wheel, UP, buff=0)\n \n self.wait_until_bookmark(\"POINTER\")\n self.play(Create(pointer), run_time=tracker.duration)\n \n with self.voiceover(text=\"By adjusting the temperature setting, we can compare the sampling diversity. Lower temperatures make the distribution peakier, while higher temperatures flatten it.\") as tracker:\n temp_text = Text(\"Temperature = 1.0\", font_size=24, color=YELLOW)\n temp_text.to_edge(DOWN)\n \n self.wait_until_bookmark(\"TEMP\")\n self.play(Write(temp_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an undergrad course on sequence models and want a probabilistic sampling visualization. Animate a spinning wheel divided into character slices, landing on the next character according to the learned distribution. Show the probability weights as arc lengths and reflect the sample decision with a glow and a landing pointer. Include a short, repeatable loop with different temperature settings to compare sampling diversity."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass ProbabilisticSampling(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: WHEEL]\n with self.voiceover(text=\"Probabilistic sampling can be visualized as a spinning wheel divided into character slices. The arc lengths represent the probability weights of each character.\") as tracker:\n title = Text(\"Probabilistic Sampling\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n wheel = Circle(radius=2, color=WHITE)\n slices = VGroup()\n angles = [0, PI/2, PI, 3*PI/2, 2*PI]\n colors = [RED, GREEN, BLUE, YELLOW]\n for i in range(4):\n sector = AnnularSector(inner_radius=0, outer_radius=2, angle=angles[i+1]-angles[i], start_angle=angles[i], color=colors[i], fill_opacity=0.5)\n slices.add(sector)\n \n self.wait_until_bookmark(\"WHEEL\")\n self.play(Write(title), Create(wheel), Create(slices), run_time=tracker.duration)\n \n with self.voiceover(text=\"The wheel lands on the next character according to the learned distribution. The landing pointer glows to reflect the sample decision.\") as tracker:\n pointer = Polygon(ORIGIN, UP*0.3, LEFT*0.1, RIGHT*0.1, color=WHITE, fill_opacity=1)\n pointer.next_to(wheel, UP, buff=0)\n \n self.wait_until_bookmark(\"POINTER\")\n self.play(Create(pointer), run_time=tracker.duration)\n \n with self.voiceover(text=\"By adjusting the temperature setting, we can compare the sampling diversity. Lower temperatures make the distribution peakier, while higher temperatures flatten it.\") as tracker:\n temp_text = Text(\"Temperature = 1.0\", font_size=24, color=YELLOW)\n temp_text.to_edge(DOWN)\n \n self.wait_until_bookmark(\"TEMP\")\n self.play(Write(temp_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "manim-sft-10k_003816", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "ORBFeatureScene", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_007935", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 11, "num_rich_primitives": 2, "prompt": "Could you create an educational animation that visually demonstrates how to calculate the area under the curve of the function f(x) = 3 - x^2 from x = -1 to x = 2? First, show the function itself, then display the integral of the function within the given bounds. Next, plot the function's graph and highlight the area under the curve. After that, show the antiderivative of the function and demonstrate how to evaluate the definite integral by substituting the upper and lower bounds. Finally, display the numerical result of the integral's evaluation, and conclude by showing only the result on the screen.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Function Introduction ---\n func_text = MathTex(r\"f(x) = 3 - x^2\", font_size=48)\n func_text.to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Integral Setup ---\n integral_text = MathTex(r\"\\int_{-1}^{2} (3 - x^2) \\, dx\", font_size=48)\n integral_text.next_to(func_text, DOWN, buff=0.5)\n self.play(Write(integral_text))\n self.wait(1)\n\n # --- 3. Graph Visualization ---\n axes = Axes(\n x_range=[-2.5, 3.5, 1],\n y_range=[-1, 4, 1],\n x_axis_config={\"numbers_to_include\": [-1, 2]},\n y_axis_config={\"numbers_to_include\": [3]},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: 3 - x**2, color=BLUE)\n area = axes.get_area(graph, x_range=[-1, 2], color=GREEN, opacity=0.5)\n \n graph_group = VGroup(axes, axes_labels, graph, area)\n graph_group.scale(0.7).to_edge(DOWN)\n \n self.play(\n FadeOut(func_text),\n FadeOut(integral_text),\n Create(axes),\n Write(axes_labels),\n Create(graph),\n FadeIn(area)\n )\n self.wait(1)\n \n # Move graph to the left to make room for calculations\n self.play(graph_group.animate.to_edge(LEFT).scale(0.8))\n\n # --- 4. Antiderivative Display ---\n antiderivative = MathTex(\n r\"F(x) = \\int (3 - x^2) \\, dx = 3x - \\frac{x^3}{3}\", font_size=36\n )\n antiderivative.to_edge(RIGHT).shift(UP * 2)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # --- 5. Evaluation Demonstration ---\n ftoc = MathTex(\n r\"\\int_{-1}^{2} (3 - x^2) \\, dx = \\left[ 3x - \\frac{x^3}{3} \\right]_{-1}^{2}\", \n font_size=36\n )\n ftoc.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n self.play(Write(ftoc))\n self.wait(1)\n\n substitution = MathTex(\n r\"= \\left( 3(2) - \\frac{2^3}{3} \\right) - \\left( 3(-1) - \\frac{(-1)^3}{3} \\right)\", \n font_size=36\n )\n substitution.next_to(ftoc, DOWN, aligned_edge=LEFT)\n self.play(Write(substitution))\n self.wait(1)\n\n # --- 6. Numerical Result ---\n simp1 = MathTex(\n r\"= \\left( 6 - \\frac{8}{3} \\right) - \\left( -3 + \\frac{1}{3} \\right)\", \n font_size=36\n )\n simp1.next_to(substitution, DOWN, aligned_edge=LEFT)\n self.play(Write(simp1))\n self.wait(1)\n\n simp2 = MathTex(\n r\"= \\frac{10}{3} - \\left( -\\frac{8}{3} \\right)\", font_size=36\n )\n simp2.next_to(simp1, DOWN, aligned_edge=LEFT)\n self.play(Write(simp2))\n self.wait(1)\n\n final_calc = MathTex(r\"= \\frac{18}{3} = 6\", font_size=36)\n final_calc.next_to(simp2, DOWN, aligned_edge=LEFT)\n self.play(Write(final_calc))\n self.wait(1)\n\n # --- 7. Conclusion ---\n result_text = MathTex(r\"6\", font_size=96, color=YELLOW)\n \n self.play(\n FadeOut(graph_group),\n FadeOut(antiderivative),\n FadeOut(ftoc),\n FadeOut(substitution),\n FadeOut(simp1),\n FadeOut(simp2),\n FadeOut(final_calc),\n Write(result_text)\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that visually demonstrates how to calculate the area under the curve of the function f(x) = 3 - x^2 from x = -1 to x = 2? First, show the function itself, then display the integral of the function within the given bounds. Next, plot the function's graph and highlight the area under the curve. After that, show the antiderivative of the function and demonstrate how to evaluate the definite integral by substituting the upper and lower bounds. Finally, display the numerical result of the integral's evaluation, and conclude by showing only the result on the screen."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Function Introduction ---\n func_text = MathTex(r\"f(x) = 3 - x^2\", font_size=48)\n func_text.to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Integral Setup ---\n integral_text = MathTex(r\"\\int_{-1}^{2} (3 - x^2) \\, dx\", font_size=48)\n integral_text.next_to(func_text, DOWN, buff=0.5)\n self.play(Write(integral_text))\n self.wait(1)\n\n # --- 3. Graph Visualization ---\n axes = Axes(\n x_range=[-2.5, 3.5, 1],\n y_range=[-1, 4, 1],\n x_axis_config={\"numbers_to_include\": [-1, 2]},\n y_axis_config={\"numbers_to_include\": [3]},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: 3 - x**2, color=BLUE)\n area = axes.get_area(graph, x_range=[-1, 2], color=GREEN, opacity=0.5)\n \n graph_group = VGroup(axes, axes_labels, graph, area)\n graph_group.scale(0.7).to_edge(DOWN)\n \n self.play(\n FadeOut(func_text),\n FadeOut(integral_text),\n Create(axes),\n Write(axes_labels),\n Create(graph),\n FadeIn(area)\n )\n self.wait(1)\n \n # Move graph to the left to make room for calculations\n self.play(graph_group.animate.to_edge(LEFT).scale(0.8))\n\n # --- 4. Antiderivative Display ---\n antiderivative = MathTex(\n r\"F(x) = \\int (3 - x^2) \\, dx = 3x - \\frac{x^3}{3}\", font_size=36\n )\n antiderivative.to_edge(RIGHT).shift(UP * 2)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # --- 5. Evaluation Demonstration ---\n ftoc = MathTex(\n r\"\\int_{-1}^{2} (3 - x^2) \\, dx = \\left[ 3x - \\frac{x^3}{3} \\right]_{-1}^{2}\", \n font_size=36\n )\n ftoc.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n self.play(Write(ftoc))\n self.wait(1)\n\n substitution = MathTex(\n r\"= \\left( 3(2) - \\frac{2^3}{3} \\right) - \\left( 3(-1) - \\frac{(-1)^3}{3} \\right)\", \n font_size=36\n )\n substitution.next_to(ftoc, DOWN, aligned_edge=LEFT)\n self.play(Write(substitution))\n self.wait(1)\n\n # --- 6. Numerical Result ---\n simp1 = MathTex(\n r\"= \\left( 6 - \\frac{8}{3} \\right) - \\left( -3 + \\frac{1}{3} \\right)\", \n font_size=36\n )\n simp1.next_to(substitution, DOWN, aligned_edge=LEFT)\n self.play(Write(simp1))\n self.wait(1)\n\n simp2 = MathTex(\n r\"= \\frac{10}{3} - \\left( -\\frac{8}{3} \\right)\", font_size=36\n )\n simp2.next_to(simp1, DOWN, aligned_edge=LEFT)\n self.play(Write(simp2))\n self.wait(1)\n\n final_calc = MathTex(r\"= \\frac{18}{3} = 6\", font_size=36)\n final_calc.next_to(simp2, DOWN, aligned_edge=LEFT)\n self.play(Write(final_calc))\n self.wait(1)\n\n # --- 7. Conclusion ---\n result_text = MathTex(r\"6\", font_size=96, color=YELLOW)\n \n self.play(\n FadeOut(graph_group),\n FadeOut(antiderivative),\n FadeOut(ftoc),\n FadeOut(substitution),\n FadeOut(simp1),\n FadeOut(simp2),\n FadeOut(final_calc),\n Write(result_text)\n )\n self.wait(2)\n```"}]}
{"id": "manim-sft-10k_000248", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "IntegralVisualization", "num_animations": 9, "num_rich_primitives": 3, "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins by displaying the integral equation `\\int_0^4 0.1x^2 \\,dx` at the top of the screen. The axes and the quadratic curve `y = 0.1x²` then animate in smoothly, followed by the area under the curve from `x=0` to `x=4`, which fills with a gradient from blue to green. As the area appears, a Riemann sum visualization emerges, showing rectangles under the curve that gradually increase in number, transitioning from a coarse approximation to a smooth integral representation. Simultaneously, the solution unfolds step-by-step: first transforming the integral into its antiderivative `\\left[\\frac{1}{30} x^3 \\right]_0^4`, then expanding it into `\\frac{1}{30} (4)^3 - \\frac{1}{30} (0)^3`, and finally simplifying to `\\frac{64}{30}` and `\\frac{32}{15}`. To reinforce understanding, a dynamic text box appears below the equation, explaining each step (e.g., \"Applying the power rule for integration\" or \"Evaluating at the bounds\"). The axes and graph fade out, leaving only the final simplified answer, which pulses gently to emphasize the result. This enhanced version not only visualizes the integral and its solution but also clarifies the mathematical reasoning behind each step, making it more instructive.", "code": "from manim import *\n\nclass IntegralVisualization(Scene):\n def construct(self):\n # Define the integral equation\n integral = MathTex(r\"\\int_0^4 0.1x^2 \\,dx\").to_edge(UP)\n \n # Create axes and curve\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 2, 0.5],\n x_length=6,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n axes.shift(DOWN * 0.5)\n \n curve = axes.plot(lambda x: 0.1 * x**2, color=YELLOW)\n \n # Area under the curve\n area = axes.get_area(curve, x_range=(0, 4), color=[BLUE, GREEN])\n \n # Riemann sum rectangles\n riemann_rects = always_redraw(lambda: axes.get_riemann_rectangles(\n curve,\n x_range=[0, 4],\n dx=0.5,\n input_sample_type=\"right\",\n fill_opacity=0.6,\n stroke_width=0.5,\n color=[BLUE, GREEN],\n ))\n \n # Solution steps\n solution_steps = VGroup(\n MathTex(r\"\\left[\\frac{1}{30} x^3 \\right]_0^4\"),\n MathTex(r\"\\frac{1}{30} (4)^3 - \\frac{1}{30} (0)^3\"),\n MathTex(r\"\\frac{64}{30}\"),\n MathTex(r\"\\frac{32}{15}\"),\n )\n \n solution_steps.arrange(DOWN, buff=0.5)\n solution_steps.next_to(integral, DOWN, buff=1)\n \n # Explanations for each step\n explanations = VGroup(\n Text(\"Applying the power rule for integration\").scale(0.5),\n Text(\"Evaluating at the bounds\").scale(0.5),\n Text(\"Simplifying the expression\").scale(0.5),\n Text(\"Final simplified answer\").scale(0.5),\n )\n \n for i, explanation in enumerate(explanations):\n explanation.next_to(solution_steps[i], RIGHT, buff=0.5)\n \n # Animation sequence\n self.play(Write(integral))\n self.wait(0.5)\n \n self.play(Create(axes), Create(curve), run_time=2)\n self.wait(0.5)\n \n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n \n self.play(Create(riemann_rects), run_time=2)\n for i in range(4):\n new_rects = always_redraw(lambda: axes.get_riemann_rectangles(\n curve,\n x_range=[0, 4],\n dx=0.5 / (2**i),\n input_sample_type=\"right\",\n fill_opacity=0.6,\n stroke_width=0.5,\n color=[BLUE, GREEN],\n ))\n self.play(Transform(riemann_rects, new_rects), run_time=1.5)\n self.wait(0.5)\n \n self.wait(1)\n \n # Show solution steps with explanations\n for i in range(len(solution_steps)):\n self.play(Write(solution_steps[i]), Write(explanations[i]))\n self.wait(1)\n \n # Fade out axes and graph\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(riemann_rects),\n FadeOut(integral),\n FadeOut(solution_steps[:-1]),\n FadeOut(explanations),\n )\n \n # Pulse the final answer\n final_answer = solution_steps[-1]\n self.play(\n final_answer.animate.scale(1.5).set_color(GREEN),\n run_time=1.5\n )\n self.play(\n final_answer.animate.scale(1/1.5).set_color(WHITE),\n run_time=1.5\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins by displaying the integral equation `\\int_0^4 0.1x^2 \\,dx` at the top of the screen. The axes and the quadratic curve `y = 0.1x²` then animate in smoothly, followed by the area under the curve from `x=0` to `x=4`, which fills with a gradient from blue to green. As the area appears, a Riemann sum visualization emerges, showing rectangles under the curve that gradually increase in number, transitioning from a coarse approximation to a smooth integral representation. Simultaneously, the solution unfolds step-by-step: first transforming the integral into its antiderivative `\\left[\\frac{1}{30} x^3 \\right]_0^4`, then expanding it into `\\frac{1}{30} (4)^3 - \\frac{1}{30} (0)^3`, and finally simplifying to `\\frac{64}{30}` and `\\frac{32}{15}`. To reinforce understanding, a dynamic text box appears below the equation, explaining each step (e.g., \"Applying the power rule for integration\" or \"Evaluating at the bounds\"). The axes and graph fade out, leaving only the final simplified answer, which pulses gently to emphasize the result. This enhanced version not only visualizes the integral and its solution but also clarifies the mathematical reasoning behind each step, making it more instructive."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralVisualization(Scene):\n def construct(self):\n # Define the integral equation\n integral = MathTex(r\"\\int_0^4 0.1x^2 \\,dx\").to_edge(UP)\n \n # Create axes and curve\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 2, 0.5],\n x_length=6,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n axes.shift(DOWN * 0.5)\n \n curve = axes.plot(lambda x: 0.1 * x**2, color=YELLOW)\n \n # Area under the curve\n area = axes.get_area(curve, x_range=(0, 4), color=[BLUE, GREEN])\n \n # Riemann sum rectangles\n riemann_rects = always_redraw(lambda: axes.get_riemann_rectangles(\n curve,\n x_range=[0, 4],\n dx=0.5,\n input_sample_type=\"right\",\n fill_opacity=0.6,\n stroke_width=0.5,\n color=[BLUE, GREEN],\n ))\n \n # Solution steps\n solution_steps = VGroup(\n MathTex(r\"\\left[\\frac{1}{30} x^3 \\right]_0^4\"),\n MathTex(r\"\\frac{1}{30} (4)^3 - \\frac{1}{30} (0)^3\"),\n MathTex(r\"\\frac{64}{30}\"),\n MathTex(r\"\\frac{32}{15}\"),\n )\n \n solution_steps.arrange(DOWN, buff=0.5)\n solution_steps.next_to(integral, DOWN, buff=1)\n \n # Explanations for each step\n explanations = VGroup(\n Text(\"Applying the power rule for integration\").scale(0.5),\n Text(\"Evaluating at the bounds\").scale(0.5),\n Text(\"Simplifying the expression\").scale(0.5),\n Text(\"Final simplified answer\").scale(0.5),\n )\n \n for i, explanation in enumerate(explanations):\n explanation.next_to(solution_steps[i], RIGHT, buff=0.5)\n \n # Animation sequence\n self.play(Write(integral))\n self.wait(0.5)\n \n self.play(Create(axes), Create(curve), run_time=2)\n self.wait(0.5)\n \n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n \n self.play(Create(riemann_rects), run_time=2)\n for i in range(4):\n new_rects = always_redraw(lambda: axes.get_riemann_rectangles(\n curve,\n x_range=[0, 4],\n dx=0.5 / (2**i),\n input_sample_type=\"right\",\n fill_opacity=0.6,\n stroke_width=0.5,\n color=[BLUE, GREEN],\n ))\n self.play(Transform(riemann_rects, new_rects), run_time=1.5)\n self.wait(0.5)\n \n self.wait(1)\n \n # Show solution steps with explanations\n for i in range(len(solution_steps)):\n self.play(Write(solution_steps[i]), Write(explanations[i]))\n self.wait(1)\n \n # Fade out axes and graph\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(riemann_rects),\n FadeOut(integral),\n FadeOut(solution_steps[:-1]),\n FadeOut(explanations),\n )\n \n # Pulse the final answer\n final_answer = solution_steps[-1]\n self.play(\n final_answer.animate.scale(1.5).set_color(GREEN),\n run_time=1.5\n )\n self.play(\n final_answer.animate.scale(1/1.5).set_color(WHITE),\n run_time=1.5\n )\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_002331", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolarDoubleIntegral", "num_animations": 12, "num_rich_primitives": 2, "prompt": "I would like you to create an educational animation that explains how to solve a double integral in polar coordinates. The specific example I want demonstrated is the double integral of r-squared sine of theta with respect to r and theta, where r goes from 0 to 1, and theta goes from 0 to pi. I'd like the animation to show each step of the integration process starting with the initial integral expression, followed by the calculation of the integral with respect to r, and then the integral with respect to theta. After each step, please include a brief pause and then transition to explaining the next part. At the end, conclude with the solution to the integral and tie it to the concept of finding the area inside a unit semicircle. Can you also include some text explanations that appear at the top of each step, guiding viewers through the problem?", "code": "from manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Configuration ---\n step_text_color = BLUE_B\n math_color = WHITE\n \n # --- Title ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36, color=step_text_color)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # --- Step 1: Initial Expression ---\n step1_label = Text(\"1. Initial Expression\", font_size=28, color=GREEN).next_to(title, DOWN, buff=0.5)\n eq1 = MathTex(r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\", font_size=40)\n eq1.next_to(step1_label, DOWN, buff=0.8)\n \n self.play(Write(step1_label), Write(eq1))\n self.wait(2)\n\n # --- Step 2: Inner Integration ---\n step2_label = Text(\"2. Inner Integration (w.r.t r)\", font_size=28, color=YELLOW).next_to(title, DOWN, buff=0.5)\n \n # Antiderivative of r^2\n eq2 = MathTex(r\"\\int_{0}^{\\pi} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1} \\, d\\theta\", font_size=40)\n eq2.next_to(step2_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(step1_label, step2_label), ReplacementTransform(eq1, eq2))\n self.wait(1.5)\n \n # Evaluate limits for r\n eq2_simp = MathTex(r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\", font_size=40)\n eq2_simp.next_to(step2_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq2, eq2_simp))\n self.wait(2)\n\n # --- Step 3: Outer Integration ---\n step3_label = Text(\"3. Outer Integration (w.r.t \\theta )\", font_size=28, color=ORANGE).next_to(title, DOWN, buff=0.5)\n \n # Antiderivative of sin(theta)\n eq3 = MathTex(r\"\\frac{1}{3} \\left[ -\\cos(\\theta) \\right]_{0}^{\\pi}\", font_size=40)\n eq3.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(step2_label, step3_label), ReplacementTransform(eq2_simp, eq3))\n self.wait(1.5)\n \n # Evaluate limits for theta\n eq3_eval = MathTex(r\"\\frac{1}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\", font_size=40)\n eq3_eval.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq3, eq3_eval))\n self.wait(1.5)\n \n # Simplify trigonometric values\n eq3_final = MathTex(r\"\\frac{1}{3} (1 + 1) = \\frac{2}{3}\", font_size=40)\n eq3_final.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq3_eval, eq3_final))\n self.wait(2)\n\n # --- Step 4: Final Solution ---\n step4_label = Text(\"4. Final Solution\", font_size=28, color=RED).next_to(title, DOWN, buff=0.5)\n final_eq = MathTex(r\"\\frac{2}{3}\", font_size=60)\n final_eq.next_to(step4_label, DOWN, buff=0.8)\n box = SurroundingRectangle(final_eq, color=RED, buff=0.3)\n \n self.play(\n ReplacementTransform(step3_label, step4_label), \n ReplacementTransform(eq3_final, final_eq), \n Write(box)\n )\n self.wait(2)\n\n # --- Step 5: Conceptual Connection ---\n # Clear screen for the visualization\n self.play(FadeOut(final_eq), FadeOut(box), FadeOut(step4_label))\n\n step5_label = Text(\"5. Conceptual Connection\", font_size=28, color=PURPLE).next_to(title, DOWN, buff=0.5)\n region_text = Text(\"The limits define a Unit Semicircle Region\", font_size=24, color=GRAY)\n region_text.next_to(step5_label, DOWN, buff=0.5)\n \n # Draw the semicircle region\n semicircle = Sector(\n radius=2, \n start_angle=0, \n angle=PI, \n color=BLUE, \n fill_opacity=0.3\n )\n semicircle.next_to(region_text, DOWN, buff=0.8)\n \n # Add bounds labels\n limits_label = MathTex(r\"0 \\leq r \\leq 1, \\quad 0 \\leq \\theta \\leq \\pi\", font_size=30)\n limits_label.next_to(semicircle, DOWN, buff=0.5)\n \n self.play(Write(step5_label), Write(region_text))\n self.play(Create(semicircle))\n self.play(Write(limits_label))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like you to create an educational animation that explains how to solve a double integral in polar coordinates. The specific example I want demonstrated is the double integral of r-squared sine of theta with respect to r and theta, where r goes from 0 to 1, and theta goes from 0 to pi. I'd like the animation to show each step of the integration process starting with the initial integral expression, followed by the calculation of the integral with respect to r, and then the integral with respect to theta. After each step, please include a brief pause and then transition to explaining the next part. At the end, conclude with the solution to the integral and tie it to the concept of finding the area inside a unit semicircle. Can you also include some text explanations that appear at the top of each step, guiding viewers through the problem?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Configuration ---\n step_text_color = BLUE_B\n math_color = WHITE\n \n # --- Title ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36, color=step_text_color)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # --- Step 1: Initial Expression ---\n step1_label = Text(\"1. Initial Expression\", font_size=28, color=GREEN).next_to(title, DOWN, buff=0.5)\n eq1 = MathTex(r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\", font_size=40)\n eq1.next_to(step1_label, DOWN, buff=0.8)\n \n self.play(Write(step1_label), Write(eq1))\n self.wait(2)\n\n # --- Step 2: Inner Integration ---\n step2_label = Text(\"2. Inner Integration (w.r.t r)\", font_size=28, color=YELLOW).next_to(title, DOWN, buff=0.5)\n \n # Antiderivative of r^2\n eq2 = MathTex(r\"\\int_{0}^{\\pi} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1} \\, d\\theta\", font_size=40)\n eq2.next_to(step2_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(step1_label, step2_label), ReplacementTransform(eq1, eq2))\n self.wait(1.5)\n \n # Evaluate limits for r\n eq2_simp = MathTex(r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\", font_size=40)\n eq2_simp.next_to(step2_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq2, eq2_simp))\n self.wait(2)\n\n # --- Step 3: Outer Integration ---\n step3_label = Text(\"3. Outer Integration (w.r.t \\theta )\", font_size=28, color=ORANGE).next_to(title, DOWN, buff=0.5)\n \n # Antiderivative of sin(theta)\n eq3 = MathTex(r\"\\frac{1}{3} \\left[ -\\cos(\\theta) \\right]_{0}^{\\pi}\", font_size=40)\n eq3.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(step2_label, step3_label), ReplacementTransform(eq2_simp, eq3))\n self.wait(1.5)\n \n # Evaluate limits for theta\n eq3_eval = MathTex(r\"\\frac{1}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\", font_size=40)\n eq3_eval.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq3, eq3_eval))\n self.wait(1.5)\n \n # Simplify trigonometric values\n eq3_final = MathTex(r\"\\frac{1}{3} (1 + 1) = \\frac{2}{3}\", font_size=40)\n eq3_final.next_to(step3_label, DOWN, buff=0.8)\n \n self.play(ReplacementTransform(eq3_eval, eq3_final))\n self.wait(2)\n\n # --- Step 4: Final Solution ---\n step4_label = Text(\"4. Final Solution\", font_size=28, color=RED).next_to(title, DOWN, buff=0.5)\n final_eq = MathTex(r\"\\frac{2}{3}\", font_size=60)\n final_eq.next_to(step4_label, DOWN, buff=0.8)\n box = SurroundingRectangle(final_eq, color=RED, buff=0.3)\n \n self.play(\n ReplacementTransform(step3_label, step4_label), \n ReplacementTransform(eq3_final, final_eq), \n Write(box)\n )\n self.wait(2)\n\n # --- Step 5: Conceptual Connection ---\n # Clear screen for the visualization\n self.play(FadeOut(final_eq), FadeOut(box), FadeOut(step4_label))\n\n step5_label = Text(\"5. Conceptual Connection\", font_size=28, color=PURPLE).next_to(title, DOWN, buff=0.5)\n region_text = Text(\"The limits define a Unit Semicircle Region\", font_size=24, color=GRAY)\n region_text.next_to(step5_label, DOWN, buff=0.5)\n \n # Draw the semicircle region\n semicircle = Sector(\n radius=2, \n start_angle=0, \n angle=PI, \n color=BLUE, \n fill_opacity=0.3\n )\n semicircle.next_to(region_text, DOWN, buff=0.8)\n \n # Add bounds labels\n limits_label = MathTex(r\"0 \\leq r \\leq 1, \\quad 0 \\leq \\theta \\leq \\pi\", font_size=30)\n limits_label.next_to(semicircle, DOWN, buff=0.5)\n \n self.play(Write(step5_label), Write(region_text))\n self.play(Create(semicircle))\n self.play(Write(limits_label))\n self.wait(3)\n```"}]}
{"id": "multi_act_v2_00665", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0665", "num_animations": 22, "prompt": "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: Can you create an educational animation that shows the formation of a water molecule by combining one oxygen atom with two hydrogen atoms, illustrating the bonding process, rotating the molecule to give a 3D perspective,\n- Act 2: Here’s an enhanced version of the animation with additional features while preserving the original elements: \n- Act 3: **Enhanced Animation Instruction:** ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0665(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_sinecurveunitcircle()\n self.clear_stage()\n self.act_2_enhancedwaveanimation()\n self.clear_stage()\n self.act_3_heptagonanimation()\n\n def act_1_sinecurveunitcircle(self):\n circle = Circle(radius=1)\n sine_curve = ParametricFunction(\n lambda t : np.array([t, np.sin(t), 0]),\n t_range = np.array([-PI, PI]),\n color = BLUE\n )\n\n # Display the circle and sine curve\n self.play(Create(circle))\n self.play(Create(sine_curve))\n self.wait(1)\n\n # Create a dot that will move around the circle\n dot = Dot(radius=0.08)\n self.play(FadeIn(dot))\n\n # This updater will move the dot along the unit circle\n def update_dot(mob, dt):\n rate = dt * 0.5 # speed of the dot\n mob.move_to(circle.point_at_angle(rate + mob.get_center()[0]))\n\n dot.add_updater(update_dot)\n\n # Create a vertical line that will be used to trace the sine curve\n vertical_line = always_redraw(\n lambda: DashedLine(\n start=sine_curve.get_start(),\n end=[dot.get_center()[0], dot.get_center()[1], 0],\n stroke_width=2,\n dashed_ratio=0.6\n ).set_color(RED)\n )\n\n # Display the vertical line and let it trace the sine curve with the dot\n self.add(vertical_line)\n self.wait(PI / 0.5) # Wait until the dot makes half a revolution\n\n # Remove the tracer line and the dot updater\n dot.clear_updaters()\n vertical_line.clear_updaters()\n\n # Draw label for the sine curve\n sine_label = Tex(\"Sine Curve\").next_to(sine_curve, DOWN)\n self.play(Write(sine_label))\n\n # Wait and clear the scene\n self.wait(2)\n self.clear()\n\n # Show a static image of the sine curve\n self.play(Create(sine_curve), FadeIn(sine_label))\n self.wait(2)\n\n def act_2_enhancedwaveanimation(self):\n placeholder = Text(\"Placeholder\").to_edge(UP)\n apply_wave_text = Text(\"ApplyWave\").to_edge(UP)\n self.play(Transform(placeholder, apply_wave_text))\n self.wait(0.5)\n\n # Main text appearance\n main_text = Text(\"Mathematical Animations\").scale(1.2)\n self.play(Write(main_text))\n self.wait(1)\n\n # First wave effect (upward)\n self.play(ApplyWave(main_text, direction=UP))\n self.wait(0.5)\n\n # Second wave effect (horizontal)\n self.play(ApplyWave(main_text, direction=RIGHT))\n self.wait(0.5)\n\n # Transform text into formula\n formula = MathTex(\"e^{i\\\\pi} + 1 = 0\").scale(1.5)\n self.play(Transform(main_text, formula))\n self.wait(1.5)\n\n # Add explanatory subtitle\n subtitle = Text(\"Wave transformations in animations\").scale(0.7).next_to(formula, DOWN)\n self.play(FadeIn(subtitle))\n self.wait(2)\n\n # Transform formula into sine wave graph\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1.5, 1.5, 1],\n x_length=6,\n y_length=3,\n )\n graph = axes.plot(lambda x: np.sin(x), color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"sin(x)\")\n\n self.play(\n ReplacementTransform(formula, axes),\n FadeOut(subtitle),\n )\n self.play(Create(graph), Write(graph_label))\n self.wait(2)\n\n # Fade out all elements\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n self.wait(0.5)\n\n def act_3_heptagonanimation(self):\n heptagon = RegularPolygon(n=7, radius=3, color=GREEN)\n heptagon.set_fill(GREEN, opacity=0.5)\n \n # Animate drawing the heptagon vertex by vertex\n self.play(Create(heptagon), run_time=3)\n self.wait(1)\n \n # Rotate and scale down the heptagon\n self.play(\n heptagon.animate.rotate(2 * PI).scale(0.5),\n run_time=4\n )\n self.wait(1)\n \n # Display the formula\n formula = MathTex(\n r\"\\text{Interior Angle} = \\frac{(n-2) \\times 180^\\circ}{n} = 128.57^\\circ\",\n color=WHITE\n )\n formula.to_edge(DOWN)\n \n # Add explanatory text\n explanation = Text(\n \"For a heptagon (n=7), each interior angle is approximately 128.57°\",\n font_size=24,\n color=YELLOW\n )\n explanation.next_to(formula, UP)\n \n # Fade in formula and explanation\n self.play(\n FadeIn(formula),\n Write(explanation),\n run_time=2\n )\n self.wait(1)\n \n # Draw dashed lines from center to vertices\n center = heptagon.get_center()\n dashed_lines = VGroup()\n for vertex in heptagon.get_vertices():\n line = DashedLine(center, vertex, color=WHITE, dash_length=0.1)\n dashed_lines.add(line)\n \n self.play(\n LaggedStart(*[Create(line) for line in dashed_lines], lag_ratio=0.2),\n run_time=3\n )\n self.wait(2)\n \n # Morph heptagon into a seven-pointed star\n star = Star(n=7, outer_radius=1.5, color=BLUE)\n star.set_fill(BLUE, opacity=0.5)\n star.move_to(heptagon.get_center())\n \n self.play(\n Transform(heptagon, star),\n dashed_lines.animate.set_color(BLUE),\n run_time=3\n )\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: Can you create an educational animation that shows the formation of a water molecule by combining one oxygen atom with two hydrogen atoms, illustrating the bonding process, rotating the molecule to give a 3D perspective,\n- Act 2: Here’s an enhanced version of the animation with additional features while preserving the original elements: \n- Act 3: **Enhanced Animation Instruction:** "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0665(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_sinecurveunitcircle()\n self.clear_stage()\n self.act_2_enhancedwaveanimation()\n self.clear_stage()\n self.act_3_heptagonanimation()\n\n def act_1_sinecurveunitcircle(self):\n circle = Circle(radius=1)\n sine_curve = ParametricFunction(\n lambda t : np.array([t, np.sin(t), 0]),\n t_range = np.array([-PI, PI]),\n color = BLUE\n )\n\n # Display the circle and sine curve\n self.play(Create(circle))\n self.play(Create(sine_curve))\n self.wait(1)\n\n # Create a dot that will move around the circle\n dot = Dot(radius=0.08)\n self.play(FadeIn(dot))\n\n # This updater will move the dot along the unit circle\n def update_dot(mob, dt):\n rate = dt * 0.5 # speed of the dot\n mob.move_to(circle.point_at_angle(rate + mob.get_center()[0]))\n\n dot.add_updater(update_dot)\n\n # Create a vertical line that will be used to trace the sine curve\n vertical_line = always_redraw(\n lambda: DashedLine(\n start=sine_curve.get_start(),\n end=[dot.get_center()[0], dot.get_center()[1], 0],\n stroke_width=2,\n dashed_ratio=0.6\n ).set_color(RED)\n )\n\n # Display the vertical line and let it trace the sine curve with the dot\n self.add(vertical_line)\n self.wait(PI / 0.5) # Wait until the dot makes half a revolution\n\n # Remove the tracer line and the dot updater\n dot.clear_updaters()\n vertical_line.clear_updaters()\n\n # Draw label for the sine curve\n sine_label = Tex(\"Sine Curve\").next_to(sine_curve, DOWN)\n self.play(Write(sine_label))\n\n # Wait and clear the scene\n self.wait(2)\n self.clear()\n\n # Show a static image of the sine curve\n self.play(Create(sine_curve), FadeIn(sine_label))\n self.wait(2)\n\n def act_2_enhancedwaveanimation(self):\n placeholder = Text(\"Placeholder\").to_edge(UP)\n apply_wave_text = Text(\"ApplyWave\").to_edge(UP)\n self.play(Transform(placeholder, apply_wave_text))\n self.wait(0.5)\n\n # Main text appearance\n main_text = Text(\"Mathematical Animations\").scale(1.2)\n self.play(Write(main_text))\n self.wait(1)\n\n # First wave effect (upward)\n self.play(ApplyWave(main_text, direction=UP))\n self.wait(0.5)\n\n # Second wave effect (horizontal)\n self.play(ApplyWave(main_text, direction=RIGHT))\n self.wait(0.5)\n\n # Transform text into formula\n formula = MathTex(\"e^{i\\\\pi} + 1 = 0\").scale(1.5)\n self.play(Transform(main_text, formula))\n self.wait(1.5)\n\n # Add explanatory subtitle\n subtitle = Text(\"Wave transformations in animations\").scale(0.7).next_to(formula, DOWN)\n self.play(FadeIn(subtitle))\n self.wait(2)\n\n # Transform formula into sine wave graph\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1.5, 1.5, 1],\n x_length=6,\n y_length=3,\n )\n graph = axes.plot(lambda x: np.sin(x), color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"sin(x)\")\n\n self.play(\n ReplacementTransform(formula, axes),\n FadeOut(subtitle),\n )\n self.play(Create(graph), Write(graph_label))\n self.wait(2)\n\n # Fade out all elements\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n self.wait(0.5)\n\n def act_3_heptagonanimation(self):\n heptagon = RegularPolygon(n=7, radius=3, color=GREEN)\n heptagon.set_fill(GREEN, opacity=0.5)\n \n # Animate drawing the heptagon vertex by vertex\n self.play(Create(heptagon), run_time=3)\n self.wait(1)\n \n # Rotate and scale down the heptagon\n self.play(\n heptagon.animate.rotate(2 * PI).scale(0.5),\n run_time=4\n )\n self.wait(1)\n \n # Display the formula\n formula = MathTex(\n r\"\\text{Interior Angle} = \\frac{(n-2) \\times 180^\\circ}{n} = 128.57^\\circ\",\n color=WHITE\n )\n formula.to_edge(DOWN)\n \n # Add explanatory text\n explanation = Text(\n \"For a heptagon (n=7), each interior angle is approximately 128.57°\",\n font_size=24,\n color=YELLOW\n )\n explanation.next_to(formula, UP)\n \n # Fade in formula and explanation\n self.play(\n FadeIn(formula),\n Write(explanation),\n run_time=2\n )\n self.wait(1)\n \n # Draw dashed lines from center to vertices\n center = heptagon.get_center()\n dashed_lines = VGroup()\n for vertex in heptagon.get_vertices():\n line = DashedLine(center, vertex, color=WHITE, dash_length=0.1)\n dashed_lines.add(line)\n \n self.play(\n LaggedStart(*[Create(line) for line in dashed_lines], lag_ratio=0.2),\n run_time=3\n )\n self.wait(2)\n \n # Morph heptagon into a seven-pointed star\n star = Star(n=7, outer_radius=1.5, color=BLUE)\n star.set_fill(BLUE, opacity=0.5)\n star.move_to(heptagon.get_center())\n \n self.play(\n Transform(heptagon, star),\n dashed_lines.animate.set_color(BLUE),\n run_time=3\n )\n self.wait(3)\n```"}]}
{"id": "manim-sft-10k_001803", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "RecursionVsIteration", "num_animations": 10, "num_rich_primitives": 3, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000423", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "SVDGeometricScene", "num_animations": 6, "num_rich_primitives": 2, "prompt": "I'm learning an undergrad course on numerical linear algebra and want a visual explanation of SVD. Show geometrically how a matrix A transforms the unit circle into an ellipse, with singular vectors as axes and Σ as scaling. Then decompose A as UΣV^T and illustrate the transformation step by step, including a noisy perturbation to show conditioning. Include multiple scenes: constructing the ellipse, applying A to the circle, and a real-world data example to motivate use. I’d like the animation to have clear pacing, smooth transitions, and both intuition and rigorous definitions.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass SVDGeometricScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: FORMULA]\n with self.voiceover(text=\"Singular Value Decomposition, or SVD, factors any matrix A into three distinct operations: U, Sigma, and V transpose.\") as tracker:\n title = Text(\"Geometric Interpretation of SVD\", font_size=36)\n self.fit_in_frame(title)\n formula = MathTex(\"A = U\", \"\\\\Sigma\", \"V^T\", font_size=32)\n formula[0][2:].set_color(BLUE)\n formula[1].set_color(RED)\n formula[2].set_color(GREEN)\n group = VGroup(title, formula).arrange(DOWN)\n self.wait_until_bookmark(\"FORMULA\")\n self.play(Write(group), run_time=tracker.duration)\n self.play(group.animate.scale(0.6).to_edge(UP), run_time=0.5)\n\n with self.voiceover(text=\"We start with a unit circle. First, V transpose rotates the input space to align with the principal axes.\") as tracker:\n circle = Circle(radius=1.5, color=WHITE)\n self.wait_until_bookmark(\"VT\")\n self.play(Create(circle), run_time=tracker.duration * 0.5)\n \n vt_group = circle.copy()\n self.play(ApplyMatrix([[-0.8, -0.6], [0.6, -0.8]], vt_group), run_time=tracker.duration * 0.5)\n\n with self.voiceover(text=\"Next, Sigma scales the space along these new axes, stretching the circle into an ellipse. The scaling factors are the singular values.\") as tracker:\n self.wait_until_bookmark(\"SIGMA\")\n self.play(vt_group.animate.stretch(2.5, dim=0).stretch(0.8, dim=1).set_color(YELLOW), run_time=tracker.duration)\n\n with self.voiceover(text=\"Finally, U rotates the ellipse to its final output orientation. This rotate-scale-rotate pattern is the geometric essence of SVD.\") as tracker:\n self.wait_until_bookmark(\"U\")\n self.play(Rotate(vt_group, angle=PI/4), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm learning an undergrad course on numerical linear algebra and want a visual explanation of SVD. Show geometrically how a matrix A transforms the unit circle into an ellipse, with singular vectors as axes and Σ as scaling. Then decompose A as UΣV^T and illustrate the transformation step by step, including a noisy perturbation to show conditioning. Include multiple scenes: constructing the ellipse, applying A to the circle, and a real-world data example to motivate use. I’d like the animation to have clear pacing, smooth transitions, and both intuition and rigorous definitions."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass SVDGeometricScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: FORMULA]\n with self.voiceover(text=\"Singular Value Decomposition, or SVD, factors any matrix A into three distinct operations: U, Sigma, and V transpose.\") as tracker:\n title = Text(\"Geometric Interpretation of SVD\", font_size=36)\n self.fit_in_frame(title)\n formula = MathTex(\"A = U\", \"\\\\Sigma\", \"V^T\", font_size=32)\n formula[0][2:].set_color(BLUE)\n formula[1].set_color(RED)\n formula[2].set_color(GREEN)\n group = VGroup(title, formula).arrange(DOWN)\n self.wait_until_bookmark(\"FORMULA\")\n self.play(Write(group), run_time=tracker.duration)\n self.play(group.animate.scale(0.6).to_edge(UP), run_time=0.5)\n\n with self.voiceover(text=\"We start with a unit circle. First, V transpose rotates the input space to align with the principal axes.\") as tracker:\n circle = Circle(radius=1.5, color=WHITE)\n self.wait_until_bookmark(\"VT\")\n self.play(Create(circle), run_time=tracker.duration * 0.5)\n \n vt_group = circle.copy()\n self.play(ApplyMatrix([[-0.8, -0.6], [0.6, -0.8]], vt_group), run_time=tracker.duration * 0.5)\n\n with self.voiceover(text=\"Next, Sigma scales the space along these new axes, stretching the circle into an ellipse. The scaling factors are the singular values.\") as tracker:\n self.wait_until_bookmark(\"SIGMA\")\n self.play(vt_group.animate.stretch(2.5, dim=0).stretch(0.8, dim=1).set_color(YELLOW), run_time=tracker.duration)\n\n with self.voiceover(text=\"Finally, U rotates the ellipse to its final output orientation. This rotate-scale-rotate pattern is the geometric essence of SVD.\") as tracker:\n self.wait_until_bookmark(\"U\")\n self.play(Rotate(vt_group, angle=PI/4), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_006012", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralSolution", "num_animations": 17, "num_rich_primitives": 2, "prompt": "Can you create an animated video that visually explains the steps to solve a triple integral, specifically the integral of xyz from x ranging from -1 to 1, y ranging from -1 to 1, and z ranging from 0 to 1? I would like it to show the written problem, then step-by-step integration for each variable with short explanations for each step, and finally, clear the screen and present the final answer.", "code": "from manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Define colors for variables to enhance visual distinction\n color_x = RED\n color_y = GREEN\n color_z = BLUE\n \n # --- 1. Problem Statement ---\n title = Tex(\"Triple Integral Evaluation\", font_size=42)\n title.to_edge(UP)\n \n # Integral: \\int_{0}^{1} \\int_{-1}^{1} \\int_{-1}^{1} xyz \\, dx \\, dy \\, dz\n problem = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\int_{-1}^{1}\", \n r\"\\int_{-1}^{1}\", \n \"x\", \"y\", \"z\", \n r\"\\, dx\", r\"\\, dy\", r\"\\, dz\",\n font_size=40\n )\n # Color coding variables and differentials\n problem[3].set_color(color_x) # x\n problem[4].set_color(color_y) # y\n problem[5].set_color(color_z) # z\n problem[6].set_color(color_x) # dx\n problem[7].set_color(color_y) # dy\n problem[8].set_color(color_z) # dz\n \n problem.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title), Write(problem))\n self.wait(2)\n\n # --- 2. Step-by-Step Integration ---\n \n # Step 1: Integration with respect to x\n step1_text = Tex(\"Step 1: Integrate with respect to $x$\", font_size=30, color=BLUE)\n step1_text.next_to(problem, DOWN, buff=0.7)\n \n step1_eq = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} yz \\left[ \\frac{x^2}{2} \\right]_{-1}^{1} \\, dy \\, dz\",\n font_size=36\n )\n step1_eq.next_to(step1_text, DOWN, buff=0.4)\n \n eval_x = MathTex(\n r\"\\frac{(1)^2}{2} - \\frac{(-1)^2}{2} = 0\",\n font_size=32\n )\n eval_x.next_to(step1_eq, DOWN, buff=0.3)\n \n note1 = Tex(\"Odd function over symmetric interval $[-1, 1]$ yields $0$\", font_size=26, color=BLUE)\n note1.next_to(eval_x, DOWN, buff=0.4)\n \n self.play(Write(step1_text))\n self.play(Write(step1_eq))\n self.wait(1)\n self.play(Write(eval_x))\n self.play(Write(note1))\n self.wait(2)\n \n # Transition: Clear step 1\n step1_group = VGroup(step1_text, step1_eq, eval_x, note1)\n self.play(FadeOut(step1_group))\n\n # Step 2: Integration with respect to y\n step2_text = Tex(\"Step 2: Integrate with respect to $y$\", font_size=30, color=GREEN)\n step2_text.next_to(problem, DOWN, buff=0.7)\n \n step2_eq = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} 0 \\, dy \\, dz\",\n font_size=36\n )\n step2_eq.next_to(step2_text, DOWN, buff=0.4)\n \n step2_res = MathTex(\n r\"= \\int_{0}^{1} 0 \\, dz\",\n font_size=36\n )\n step2_res.next_to(step2_eq, DOWN, buff=0.3)\n \n note2 = Tex(\"Integral of zero is zero\", font_size=26, color=GREEN)\n note2.next_to(step2_res, DOWN, buff=0.4)\n \n self.play(Write(step2_text))\n self.play(Write(step2_eq))\n self.wait(1)\n self.play(Write(step2_res))\n self.play(Write(note2))\n self.wait(2)\n \n # Transition: Clear step 2\n step2_group = VGroup(step2_text, step2_eq, step2_res, note2)\n self.play(FadeOut(step2_group))\n\n # Step 3: Integration with respect to z\n step3_text = Tex(\"Step 3: Integrate with respect to $z$\", font_size=30, color=RED)\n step3_text.next_to(problem, DOWN, buff=0.7)\n \n step3_eq = MathTex(\n r\"\\int_{0}^{1} 0 \\, dz = 0\",\n font_size=36\n )\n step3_eq.next_to(step3_text, DOWN, buff=0.4)\n \n note3 = Tex(\"Final result remains zero\", font_size=26, color=RED)\n note3.next_to(step3_eq, DOWN, buff=0.4)\n \n self.play(Write(step3_text))\n self.play(Write(step3_eq))\n self.play(Write(note3))\n self.wait(2)\n \n # Transition: Clear step 3\n step3_group = VGroup(step3_text, step3_eq, note3)\n self.play(FadeOut(step3_group))\n\n # --- 3. Conclusion ---\n # Clear the screen completely\n self.play(FadeOut(title), FadeOut(problem))\n self.wait(1)\n \n final_text = Tex(\"Final Answer\", font_size=42)\n final_answer = MathTex(\"0\", font_size=72, color=YELLOW)\n final_answer.next_to(final_text, DOWN, buff=0.5)\n \n # Create a box around the final answer\n box = SurroundingRectangle(final_answer, color=WHITE, buff=MED_LARGE_BUFF)\n \n group = VGroup(final_text, final_answer, box)\n group.move_to(ORIGIN)\n \n self.play(Write(final_text), Write(final_answer), Create(box))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animated video that visually explains the steps to solve a triple integral, specifically the integral of xyz from x ranging from -1 to 1, y ranging from -1 to 1, and z ranging from 0 to 1? I would like it to show the written problem, then step-by-step integration for each variable with short explanations for each step, and finally, clear the screen and present the final answer."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Define colors for variables to enhance visual distinction\n color_x = RED\n color_y = GREEN\n color_z = BLUE\n \n # --- 1. Problem Statement ---\n title = Tex(\"Triple Integral Evaluation\", font_size=42)\n title.to_edge(UP)\n \n # Integral: \\int_{0}^{1} \\int_{-1}^{1} \\int_{-1}^{1} xyz \\, dx \\, dy \\, dz\n problem = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\int_{-1}^{1}\", \n r\"\\int_{-1}^{1}\", \n \"x\", \"y\", \"z\", \n r\"\\, dx\", r\"\\, dy\", r\"\\, dz\",\n font_size=40\n )\n # Color coding variables and differentials\n problem[3].set_color(color_x) # x\n problem[4].set_color(color_y) # y\n problem[5].set_color(color_z) # z\n problem[6].set_color(color_x) # dx\n problem[7].set_color(color_y) # dy\n problem[8].set_color(color_z) # dz\n \n problem.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title), Write(problem))\n self.wait(2)\n\n # --- 2. Step-by-Step Integration ---\n \n # Step 1: Integration with respect to x\n step1_text = Tex(\"Step 1: Integrate with respect to $x$\", font_size=30, color=BLUE)\n step1_text.next_to(problem, DOWN, buff=0.7)\n \n step1_eq = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} yz \\left[ \\frac{x^2}{2} \\right]_{-1}^{1} \\, dy \\, dz\",\n font_size=36\n )\n step1_eq.next_to(step1_text, DOWN, buff=0.4)\n \n eval_x = MathTex(\n r\"\\frac{(1)^2}{2} - \\frac{(-1)^2}{2} = 0\",\n font_size=32\n )\n eval_x.next_to(step1_eq, DOWN, buff=0.3)\n \n note1 = Tex(\"Odd function over symmetric interval $[-1, 1]$ yields $0$\", font_size=26, color=BLUE)\n note1.next_to(eval_x, DOWN, buff=0.4)\n \n self.play(Write(step1_text))\n self.play(Write(step1_eq))\n self.wait(1)\n self.play(Write(eval_x))\n self.play(Write(note1))\n self.wait(2)\n \n # Transition: Clear step 1\n step1_group = VGroup(step1_text, step1_eq, eval_x, note1)\n self.play(FadeOut(step1_group))\n\n # Step 2: Integration with respect to y\n step2_text = Tex(\"Step 2: Integrate with respect to $y$\", font_size=30, color=GREEN)\n step2_text.next_to(problem, DOWN, buff=0.7)\n \n step2_eq = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} 0 \\, dy \\, dz\",\n font_size=36\n )\n step2_eq.next_to(step2_text, DOWN, buff=0.4)\n \n step2_res = MathTex(\n r\"= \\int_{0}^{1} 0 \\, dz\",\n font_size=36\n )\n step2_res.next_to(step2_eq, DOWN, buff=0.3)\n \n note2 = Tex(\"Integral of zero is zero\", font_size=26, color=GREEN)\n note2.next_to(step2_res, DOWN, buff=0.4)\n \n self.play(Write(step2_text))\n self.play(Write(step2_eq))\n self.wait(1)\n self.play(Write(step2_res))\n self.play(Write(note2))\n self.wait(2)\n \n # Transition: Clear step 2\n step2_group = VGroup(step2_text, step2_eq, step2_res, note2)\n self.play(FadeOut(step2_group))\n\n # Step 3: Integration with respect to z\n step3_text = Tex(\"Step 3: Integrate with respect to $z$\", font_size=30, color=RED)\n step3_text.next_to(problem, DOWN, buff=0.7)\n \n step3_eq = MathTex(\n r\"\\int_{0}^{1} 0 \\, dz = 0\",\n font_size=36\n )\n step3_eq.next_to(step3_text, DOWN, buff=0.4)\n \n note3 = Tex(\"Final result remains zero\", font_size=26, color=RED)\n note3.next_to(step3_eq, DOWN, buff=0.4)\n \n self.play(Write(step3_text))\n self.play(Write(step3_eq))\n self.play(Write(note3))\n self.wait(2)\n \n # Transition: Clear step 3\n step3_group = VGroup(step3_text, step3_eq, note3)\n self.play(FadeOut(step3_group))\n\n # --- 3. Conclusion ---\n # Clear the screen completely\n self.play(FadeOut(title), FadeOut(problem))\n self.wait(1)\n \n final_text = Tex(\"Final Answer\", font_size=42)\n final_answer = MathTex(\"0\", font_size=72, color=YELLOW)\n final_answer.next_to(final_text, DOWN, buff=0.5)\n \n # Create a box around the final answer\n box = SurroundingRectangle(final_answer, color=WHITE, buff=MED_LARGE_BUFF)\n \n group = VGroup(final_text, final_answer, box)\n group.move_to(ORIGIN)\n \n self.play(Write(final_text), Write(final_answer), Create(box))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_006003", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ODESolutionScene", "num_animations": 17, "num_rich_primitives": 4, "prompt": "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?", "code": "from manim import *\n\nclass ODESolutionScene(Scene):\n def construct(self):\n # --- 1. Initial Display ---\n equation = MathTex(\"y' - 3y = 0\").scale(1.5)\n self.play(Write(equation))\n self.wait(2)\n\n # --- 2. Step 1: Solve the differential equation ---\n step1_text = Text(\"Solve the differential equation\", font_size=36).to_edge(UP)\n standard_form = MathTex(\"y' + P(x)y = Q(x)\").next_to(equation, DOWN, buff=0.5)\n p_ident = MathTex(\"P(x) = -3\").next_to(standard_form, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.play(equation.animate.shift(UP * 0.5))\n self.play(Write(standard_form))\n self.play(Write(p_ident))\n self.wait(1)\n\n # --- 3. Step 2: Use the integrating factor ---\n step2_text = Text(\"Use the integrating factor\", font_size=36).to_edge(UP)\n self.play(ReplacementTransform(step1_text, step2_text))\n\n # Calculate Factor\n mu_formula = MathTex(\"\\\\mu(x) = e^{\\\\int P(x) \\\\, dx}\").next_to(p_ident, DOWN, buff=0.5)\n mu_calc = MathTex(\"\\\\mu(x) = e^{\\\\int -3 \\\\, dx} = e^{-3x}\").next_to(mu_formula, DOWN, buff=0.5)\n \n self.play(Write(mu_formula))\n self.play(Transform(mu_formula, mu_calc))\n self.wait(1)\n\n # Apply Factor\n applied_eq = MathTex(\"e^{-3x}(y' - 3y) = 0\").next_to(mu_calc, DOWN, buff=0.5)\n self.play(Write(applied_eq))\n \n multiplied_eq = MathTex(\"e^{-3x}y' - 3e^{-3x}y = 0\").next_to(applied_eq, DOWN, buff=0.5)\n self.play(Write(multiplied_eq))\n self.wait(1)\n \n # Collapse to derivative (Product Rule)\n derivative_form = MathTex(\"\\\\frac{d}{dx}[e^{-3x}y] = 0\").next_to(multiplied_eq, DOWN, buff=0.5)\n self.play(Transform(multiplied_eq, derivative_form))\n self.wait(1)\n\n # --- 4. Step 3: General solution of the first-order ODE ---\n step3_text = Text(\"General solution of the first-order ODE\", font_size=36).to_edge(UP)\n self.play(ReplacementTransform(step2_text, step3_text))\n\n # Integrate\n integrated_eq = MathTex(\"e^{-3x}y = C\").next_to(derivative_form, DOWN, buff=0.5)\n self.play(Write(integrated_eq))\n \n # Solve for y\n final_solution = MathTex(\"y(x) = Ce^{3x}\").next_to(integrated_eq, DOWN, buff=0.5)\n final_solution.set_color(GOLD)\n self.play(Write(final_solution))\n self.wait(1)\n\n # --- 5 & 6. Transitions and Conclusion ---\n # Clear the screen of all intermediate work\n to_remove = VGroup(\n step3_text, equation, standard_form, p_ident, \n mu_formula, applied_eq, derivative_form, integrated_eq\n )\n \n self.play(\n FadeOut(to_remove),\n final_solution.animate.scale(1.5).move_to(ORIGIN)\n )\n \n # Highlight only the final general solution\n box = SurroundingRectangle(final_solution, color=GOLD, buff=0.3)\n self.play(Create(box))\n self.play(Indicate(final_solution, color=YELLOW))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 ODESolutionScene(Scene):\n def construct(self):\n # --- 1. Initial Display ---\n equation = MathTex(\"y' - 3y = 0\").scale(1.5)\n self.play(Write(equation))\n self.wait(2)\n\n # --- 2. Step 1: Solve the differential equation ---\n step1_text = Text(\"Solve the differential equation\", font_size=36).to_edge(UP)\n standard_form = MathTex(\"y' + P(x)y = Q(x)\").next_to(equation, DOWN, buff=0.5)\n p_ident = MathTex(\"P(x) = -3\").next_to(standard_form, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.play(equation.animate.shift(UP * 0.5))\n self.play(Write(standard_form))\n self.play(Write(p_ident))\n self.wait(1)\n\n # --- 3. Step 2: Use the integrating factor ---\n step2_text = Text(\"Use the integrating factor\", font_size=36).to_edge(UP)\n self.play(ReplacementTransform(step1_text, step2_text))\n\n # Calculate Factor\n mu_formula = MathTex(\"\\\\mu(x) = e^{\\\\int P(x) \\\\, dx}\").next_to(p_ident, DOWN, buff=0.5)\n mu_calc = MathTex(\"\\\\mu(x) = e^{\\\\int -3 \\\\, dx} = e^{-3x}\").next_to(mu_formula, DOWN, buff=0.5)\n \n self.play(Write(mu_formula))\n self.play(Transform(mu_formula, mu_calc))\n self.wait(1)\n\n # Apply Factor\n applied_eq = MathTex(\"e^{-3x}(y' - 3y) = 0\").next_to(mu_calc, DOWN, buff=0.5)\n self.play(Write(applied_eq))\n \n multiplied_eq = MathTex(\"e^{-3x}y' - 3e^{-3x}y = 0\").next_to(applied_eq, DOWN, buff=0.5)\n self.play(Write(multiplied_eq))\n self.wait(1)\n \n # Collapse to derivative (Product Rule)\n derivative_form = MathTex(\"\\\\frac{d}{dx}[e^{-3x}y] = 0\").next_to(multiplied_eq, DOWN, buff=0.5)\n self.play(Transform(multiplied_eq, derivative_form))\n self.wait(1)\n\n # --- 4. Step 3: General solution of the first-order ODE ---\n step3_text = Text(\"General solution of the first-order ODE\", font_size=36).to_edge(UP)\n self.play(ReplacementTransform(step2_text, step3_text))\n\n # Integrate\n integrated_eq = MathTex(\"e^{-3x}y = C\").next_to(derivative_form, DOWN, buff=0.5)\n self.play(Write(integrated_eq))\n \n # Solve for y\n final_solution = MathTex(\"y(x) = Ce^{3x}\").next_to(integrated_eq, DOWN, buff=0.5)\n final_solution.set_color(GOLD)\n self.play(Write(final_solution))\n self.wait(1)\n\n # --- 5 & 6. Transitions and Conclusion ---\n # Clear the screen of all intermediate work\n to_remove = VGroup(\n step3_text, equation, standard_form, p_ident, \n mu_formula, applied_eq, derivative_form, integrated_eq\n )\n \n self.play(\n FadeOut(to_remove),\n final_solution.animate.scale(1.5).move_to(ORIGIN)\n )\n \n # Highlight only the final general solution\n box = SurroundingRectangle(final_solution, color=GOLD, buff=0.3)\n self.play(Create(box))\n self.play(Indicate(final_solution, color=YELLOW))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_002354", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "OxygenFormation", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralCalculation", "num_animations": 14, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_001461", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegratingFactorODE", "num_animations": 11, "num_rich_primitives": 2, "prompt": "Can you create an animated video using ManimCE that explains how to solve a first-order ordinary differential equation (ODE) using an integrating factor? I would like the video to include: \n\n1. The initial display of the ODE: dy/dx + 3y = x.\n2. A description and display of the integrating factor: mu(x) = e^(3x).\n3. The equation being multiplied by the integrating factor resulting in: e^(3x)*dy/dx + 3e^(3x)*y = xe^(3x).\n4. An announcement that we're looking at the general solution before integration, without actually displaying the integration step.\n5. The general solution after the integration of both sides: y(x) = (e^(-3x)/3)∫xe^(3x)dx + Ce^(-3x).\n6. The final general solution presented neatly: y = (1/3)x - (1/9) + Ce^(-3x).\n7. Then conclude by stating that we have solved the ODE and display the final solution again after clearing all previous writing off the screen. \n\nPlease ensure the transitions are smooth and allow for moments where the viewer can take in the information before moving on to the next step.", "code": "from manim import *\n\nclass IntegratingFactorODE(Scene):\n def construct(self):\n # 1. Initial Display: Show the ODE\n ode_initial = MathTex(r\"\\frac{dy}{dx} + 3y = x\").scale(1.2)\n self.play(Write(ode_initial))\n self.wait(2)\n\n # 2. Integrating Factor: Describe and display mu(x) = e^(3x)\n if_label = Text(\"Integrating Factor:\", font_size=36, color=BLUE_A)\n if_eq = MathTex(r\"\\mu(x) = e^{3x}\", color=YELLOW).scale(1.2)\n if_group = VGroup(if_label, if_eq).arrange(RIGHT, buff=0.5)\n if_group.next_to(ode_initial, DOWN, buff=1.0)\n \n self.play(FadeIn(if_group))\n self.wait(2)\n\n # 3. Multiplication Step: e^(3x)*dy/dx + 3e^(3x)*y = xe^(3x)\n ode_multiplied = MathTex(\n r\"e^{3x}\\frac{dy}{dx} + 3e^{3x}y = xe^{3x}\"\n ).scale(1.2).move_to(ode_initial.get_center())\n \n self.play(\n ReplacementTransform(ode_initial, ode_multiplied),\n FadeOut(if_group)\n )\n self.wait(3)\n\n # 4. Pre-Integration Announcement\n announcement = Text(\n \"Examining the general solution before integration...\", \n font_size=32, \n color=BLUE_A, \n italic=True\n ).next_to(ode_multiplied, DOWN, buff=1.0)\n \n self.play(Write(announcement))\n self.wait(3)\n self.play(FadeOut(announcement))\n\n # 5. Post-Integration Solution\n ode_integrated = MathTex(\n r\"y(x) = \\frac{e^{-3x}}{3} \\int xe^{3x} \\, dx + Ce^{-3x}\"\n ).scale(1.2).move_to(ode_multiplied.get_center())\n \n self.play(ReplacementTransform(ode_multiplied, ode_integrated))\n self.wait(4)\n\n # 6. Final Simplified Solution\n ode_final = MathTex(\n r\"y = \\frac{1}{3}x - \\frac{1}{9} + Ce^{-3x}\"\n ).scale(1.2).move_to(ode_integrated.get_center())\n ode_final.set_color(GREEN)\n \n self.play(ReplacementTransform(ode_integrated, ode_final))\n self.wait(3)\n\n # 7. Conclusion: State ODE is solved, clear screen, display final solution\n conclusion_text = Text(\n \"The ODE is solved.\", \n font_size=36, \n color=BLUE_A\n ).next_to(ode_final, UP, buff=1.0)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n self.play(FadeOut(conclusion_text), FadeOut(ode_final))\n self.wait(1)\n \n final_display = MathTex(\n r\"y = \\frac{1}{3}x - \\frac{1}{9} + Ce^{-3x}\"\n ).scale(1.5).set_color(GREEN)\n \n self.play(Write(final_display))\n self.wait(3)\n self.play(FadeOut(final_display))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animated video using ManimCE that explains how to solve a first-order ordinary differential equation (ODE) using an integrating factor? I would like the video to include: \n\n1. The initial display of the ODE: dy/dx + 3y = x.\n2. A description and display of the integrating factor: mu(x) = e^(3x).\n3. The equation being multiplied by the integrating factor resulting in: e^(3x)*dy/dx + 3e^(3x)*y = xe^(3x).\n4. An announcement that we're looking at the general solution before integration, without actually displaying the integration step.\n5. The general solution after the integration of both sides: y(x) = (e^(-3x)/3)∫xe^(3x)dx + Ce^(-3x).\n6. The final general solution presented neatly: y = (1/3)x - (1/9) + Ce^(-3x).\n7. Then conclude by stating that we have solved the ODE and display the final solution again after clearing all previous writing off the screen. \n\nPlease ensure the transitions are smooth and allow for moments where the viewer can take in the information before moving on to the next step."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegratingFactorODE(Scene):\n def construct(self):\n # 1. Initial Display: Show the ODE\n ode_initial = MathTex(r\"\\frac{dy}{dx} + 3y = x\").scale(1.2)\n self.play(Write(ode_initial))\n self.wait(2)\n\n # 2. Integrating Factor: Describe and display mu(x) = e^(3x)\n if_label = Text(\"Integrating Factor:\", font_size=36, color=BLUE_A)\n if_eq = MathTex(r\"\\mu(x) = e^{3x}\", color=YELLOW).scale(1.2)\n if_group = VGroup(if_label, if_eq).arrange(RIGHT, buff=0.5)\n if_group.next_to(ode_initial, DOWN, buff=1.0)\n \n self.play(FadeIn(if_group))\n self.wait(2)\n\n # 3. Multiplication Step: e^(3x)*dy/dx + 3e^(3x)*y = xe^(3x)\n ode_multiplied = MathTex(\n r\"e^{3x}\\frac{dy}{dx} + 3e^{3x}y = xe^{3x}\"\n ).scale(1.2).move_to(ode_initial.get_center())\n \n self.play(\n ReplacementTransform(ode_initial, ode_multiplied),\n FadeOut(if_group)\n )\n self.wait(3)\n\n # 4. Pre-Integration Announcement\n announcement = Text(\n \"Examining the general solution before integration...\", \n font_size=32, \n color=BLUE_A, \n italic=True\n ).next_to(ode_multiplied, DOWN, buff=1.0)\n \n self.play(Write(announcement))\n self.wait(3)\n self.play(FadeOut(announcement))\n\n # 5. Post-Integration Solution\n ode_integrated = MathTex(\n r\"y(x) = \\frac{e^{-3x}}{3} \\int xe^{3x} \\, dx + Ce^{-3x}\"\n ).scale(1.2).move_to(ode_multiplied.get_center())\n \n self.play(ReplacementTransform(ode_multiplied, ode_integrated))\n self.wait(4)\n\n # 6. Final Simplified Solution\n ode_final = MathTex(\n r\"y = \\frac{1}{3}x - \\frac{1}{9} + Ce^{-3x}\"\n ).scale(1.2).move_to(ode_integrated.get_center())\n ode_final.set_color(GREEN)\n \n self.play(ReplacementTransform(ode_integrated, ode_final))\n self.wait(3)\n\n # 7. Conclusion: State ODE is solved, clear screen, display final solution\n conclusion_text = Text(\n \"The ODE is solved.\", \n font_size=36, \n color=BLUE_A\n ).next_to(ode_final, UP, buff=1.0)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n self.play(FadeOut(conclusion_text), FadeOut(ode_final))\n self.wait(1)\n \n final_display = MathTex(\n r\"y = \\frac{1}{3}x - \\frac{1}{9} + Ce^{-3x}\"\n ).scale(1.5).set_color(GREEN)\n \n self.play(Write(final_display))\n self.wait(3)\n self.play(FadeOut(final_display))\n```"}]}
{"id": "adaption-unified-manim-instructions_007216", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralAnimation", "num_animations": 11, "num_rich_primitives": 4, "prompt": "Can you create an educational animation that visually demonstrates the concept of integrating the function y = x^2 from 0 to 2, including the representation of the area under the curve, the integrand written as a mathematical problem, the steps to solve the integration, and the final solution, while also adding a clean transition at the end that fades out the graph and only leaves the final answer on the screen?", "code": "from manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Configuration & Styling ---\n curve_color = BLUE\n area_color = BLUE_D\n text_color = WHITE\n result_color = YELLOW\n \n # ------------------------------------------------------------------\n # 1. Problem Statement\n # Display the mathematical expression for the integral\n # ------------------------------------------------------------------\n problem_statement = MathTex(\n r\"\\int_0^2 x^2 \\, dx\", \n font_size=48, \n color=text_color\n ).to_edge(UP)\n \n self.play(Write(problem_statement))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Graph Visualization\n # Plot y = x^2 and shade the area under the curve between x=0 and x=2\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n \n axis_labels = axes.get_axis_labels()\n \n # Plot the curve y = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=curve_color)\n graph_label = axes.get_graph_label(graph, label=r\"y=x^2\", x_val=2, direction=UR)\n \n # Shade the area under the curve representing the definite integral\n shaded_area = axes.get_area(graph, x_range=[0, 2], color=area_color, opacity=0.5)\n \n # Group graph elements for coordinated animation\n graph_group = VGroup(axes, axis_labels, graph, graph_label, shaded_area)\n graph_group.next_to(problem_statement, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n \n # Animate the graph\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(shaded_area))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Step-by-Step Solution\n # Visually demonstrate the integration steps to the right of the graph\n # ------------------------------------------------------------------\n # Step A: Show the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\", font_size=40)\n \n # Step B: Show the evaluation at limits\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=40)\n \n # Step C: Show the arithmetic simplification\n step3 = MathTex(r\"= \\frac{8}{3} - 0\", font_size=40)\n \n # Step D: Final Result styled distinctly\n final_result = MathTex(r\"= \\frac{8}{3}\", font_size=48, color=result_color)\n \n # Position the first step to the right of the graph\n step1.next_to(graph_group, RIGHT, buff=1).align_to(problem_statement, DOWN)\n \n # Animate the derivation steps sequentially\n self.play(Write(step1))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step1, step2))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step2, step3))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step3, final_result))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 4. Final Solution Highlight\n # Create a box around the final result for emphasis\n # ------------------------------------------------------------------\n box = SurroundingRectangle(final_result, color=result_color, buff=0.1)\n self.play(Create(box))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 5. Closing Transition\n # Fade out the graph and intermediate steps, centering the final answer\n # ------------------------------------------------------------------\n self.play(\n FadeOut(graph_group),\n FadeOut(problem_statement),\n FadeOut(box),\n run_time=1\n )\n \n # Transform the final result to be centered and remove the \"=\" sign\n final_answer_only = MathTex(r\"\\frac{8}{3}\", font_size=72, color=result_color).move_to(ORIGIN)\n self.play(ReplacementTransform(final_result, final_answer_only))\n \n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates the concept of integrating the function y = x^2 from 0 to 2, including the representation of the area under the curve, the integrand written as a mathematical problem, the steps to solve the integration, and the final solution, while also adding a clean transition at the end that fades out the graph and only leaves the final answer on the screen?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Configuration & Styling ---\n curve_color = BLUE\n area_color = BLUE_D\n text_color = WHITE\n result_color = YELLOW\n \n # ------------------------------------------------------------------\n # 1. Problem Statement\n # Display the mathematical expression for the integral\n # ------------------------------------------------------------------\n problem_statement = MathTex(\n r\"\\int_0^2 x^2 \\, dx\", \n font_size=48, \n color=text_color\n ).to_edge(UP)\n \n self.play(Write(problem_statement))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Graph Visualization\n # Plot y = x^2 and shade the area under the curve between x=0 and x=2\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n \n axis_labels = axes.get_axis_labels()\n \n # Plot the curve y = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=curve_color)\n graph_label = axes.get_graph_label(graph, label=r\"y=x^2\", x_val=2, direction=UR)\n \n # Shade the area under the curve representing the definite integral\n shaded_area = axes.get_area(graph, x_range=[0, 2], color=area_color, opacity=0.5)\n \n # Group graph elements for coordinated animation\n graph_group = VGroup(axes, axis_labels, graph, graph_label, shaded_area)\n graph_group.next_to(problem_statement, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n \n # Animate the graph\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(shaded_area))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Step-by-Step Solution\n # Visually demonstrate the integration steps to the right of the graph\n # ------------------------------------------------------------------\n # Step A: Show the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\", font_size=40)\n \n # Step B: Show the evaluation at limits\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=40)\n \n # Step C: Show the arithmetic simplification\n step3 = MathTex(r\"= \\frac{8}{3} - 0\", font_size=40)\n \n # Step D: Final Result styled distinctly\n final_result = MathTex(r\"= \\frac{8}{3}\", font_size=48, color=result_color)\n \n # Position the first step to the right of the graph\n step1.next_to(graph_group, RIGHT, buff=1).align_to(problem_statement, DOWN)\n \n # Animate the derivation steps sequentially\n self.play(Write(step1))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step1, step2))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step2, step3))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step3, final_result))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 4. Final Solution Highlight\n # Create a box around the final result for emphasis\n # ------------------------------------------------------------------\n box = SurroundingRectangle(final_result, color=result_color, buff=0.1)\n self.play(Create(box))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 5. Closing Transition\n # Fade out the graph and intermediate steps, centering the final answer\n # ------------------------------------------------------------------\n self.play(\n FadeOut(graph_group),\n FadeOut(problem_statement),\n FadeOut(box),\n run_time=1\n )\n \n # Transform the final result to be centered and remove the \"=\" sign\n final_answer_only = MathTex(r\"\\frac{8}{3}\", font_size=72, color=result_color).move_to(ORIGIN)\n self.play(ReplacementTransform(final_result, final_answer_only))\n \n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_003575", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 8, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_008250", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "FourierSeriesDemo", "num_animations": 11, "num_rich_primitives": 3, "prompt": "Could you create an educational animation that shows how Fourier series can be used to approximate functions, starting by displaying the title \"Fourier Series Demo,\" then showing the general equation of a Fourier series, followed by transforming it into a partial sum equation, adding an explanatory text at the top about approximating functions, and then showing a specific example of a three-term approximation of the series with coefficients a_0, a_1, a_2, b_1, b_2, b_3, and finally fading everything out?", "code": "from manim import *\nimport numpy as np\n\nclass FourierSeriesDemo(Scene):\n def construct(self):\n # 1. Title Screen\n title = Text(\"Fourier Series Demo\", font_size=48)\n self.play(Write(title))\n self.wait(1.5)\n self.play(FadeOut(title))\n\n # 2. General Equation\n general_eq = MathTex(\n r\"f(x) = \\frac{a_0}{2} + \\sum_{n=1}^{\\infty} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=36\n )\n self.play(Write(general_eq))\n self.wait(1.5)\n\n # 3. Partial Sum Transformation\n partial_sum_eq = MathTex(\n r\"S_N(x) = \\frac{a_0}{2} + \\sum_{n=1}^{N} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=36\n )\n self.play(TransformMatchingTex(general_eq, partial_sum_eq))\n self.wait(1.5)\n\n # 4. Explanatory Text\n explanation = Text(\n \"Approximating functions using finite sums of sines and cosines\",\n font_size=24\n ).to_edge(UP)\n self.play(FadeIn(explanation))\n self.play(partial_sum_eq.animate.shift(UP * 1))\n self.wait(1.5)\n\n # 5. Specific Example\n # Expanded three-term approximation explicitly using the required coefficients\n specific_eq = MathTex(\n r\"S_3(x) = a_0 + a_1 \\cos(x) + b_1 \\sin(x) + a_2 \\cos(2x) + b_2 \\sin(2x) + b_3 \\sin(3x)\",\n font_size=30\n ).next_to(partial_sum_eq, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(partial_sum_eq, specific_eq))\n self.wait(1)\n\n # Explicit coefficient labels as requested\n coeff_names = [\"a_0\", \"a_1\", \"a_2\", \"b_1\", \"b_2\", \"b_3\"]\n coeff_labels = VGroup(*[MathTex(name, font_size=24) for name in coeff_names])\n coeff_labels.arrange(RIGHT, buff=0.4).next_to(specific_eq, DOWN, buff=0.5)\n self.play(FadeIn(coeff_labels))\n self.wait(1)\n\n # Graph Visualization\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True},\n x_length=8,\n y_length=4\n ).next_to(coeff_labels, DOWN, buff=0.5)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Define the approximation function using numerical values for the plot\n def fourier_approx(x):\n a0, a1, a2 = 0.5, 0.3, 0.1\n b1, b2, b3 = 0.8, 0.4, 0.2\n return (a0/2 + \n a1 * np.cos(x) + a2 * np.cos(2*x) + \n b1 * np.sin(x) + b2 * np.sin(2*x) + b3 * np.sin(3*x))\n\n graph = axes.plot(fourier_approx, color=BLUE)\n \n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), run_time=2)\n self.wait(2)\n\n # 6. Conclusion\n self.play(\n FadeOut(specific_eq),\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(graph),\n FadeOut(explanation),\n FadeOut(coeff_labels)\n )\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that shows how Fourier series can be used to approximate functions, starting by displaying the title \"Fourier Series Demo,\" then showing the general equation of a Fourier series, followed by transforming it into a partial sum equation, adding an explanatory text at the top about approximating functions, and then showing a specific example of a three-term approximation of the series with coefficients a_0, a_1, a_2, b_1, b_2, b_3, and finally fading everything out?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass FourierSeriesDemo(Scene):\n def construct(self):\n # 1. Title Screen\n title = Text(\"Fourier Series Demo\", font_size=48)\n self.play(Write(title))\n self.wait(1.5)\n self.play(FadeOut(title))\n\n # 2. General Equation\n general_eq = MathTex(\n r\"f(x) = \\frac{a_0}{2} + \\sum_{n=1}^{\\infty} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=36\n )\n self.play(Write(general_eq))\n self.wait(1.5)\n\n # 3. Partial Sum Transformation\n partial_sum_eq = MathTex(\n r\"S_N(x) = \\frac{a_0}{2} + \\sum_{n=1}^{N} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=36\n )\n self.play(TransformMatchingTex(general_eq, partial_sum_eq))\n self.wait(1.5)\n\n # 4. Explanatory Text\n explanation = Text(\n \"Approximating functions using finite sums of sines and cosines\",\n font_size=24\n ).to_edge(UP)\n self.play(FadeIn(explanation))\n self.play(partial_sum_eq.animate.shift(UP * 1))\n self.wait(1.5)\n\n # 5. Specific Example\n # Expanded three-term approximation explicitly using the required coefficients\n specific_eq = MathTex(\n r\"S_3(x) = a_0 + a_1 \\cos(x) + b_1 \\sin(x) + a_2 \\cos(2x) + b_2 \\sin(2x) + b_3 \\sin(3x)\",\n font_size=30\n ).next_to(partial_sum_eq, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(partial_sum_eq, specific_eq))\n self.wait(1)\n\n # Explicit coefficient labels as requested\n coeff_names = [\"a_0\", \"a_1\", \"a_2\", \"b_1\", \"b_2\", \"b_3\"]\n coeff_labels = VGroup(*[MathTex(name, font_size=24) for name in coeff_names])\n coeff_labels.arrange(RIGHT, buff=0.4).next_to(specific_eq, DOWN, buff=0.5)\n self.play(FadeIn(coeff_labels))\n self.wait(1)\n\n # Graph Visualization\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True},\n x_length=8,\n y_length=4\n ).next_to(coeff_labels, DOWN, buff=0.5)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Define the approximation function using numerical values for the plot\n def fourier_approx(x):\n a0, a1, a2 = 0.5, 0.3, 0.1\n b1, b2, b3 = 0.8, 0.4, 0.2\n return (a0/2 + \n a1 * np.cos(x) + a2 * np.cos(2*x) + \n b1 * np.sin(x) + b2 * np.sin(2*x) + b3 * np.sin(3*x))\n\n graph = axes.plot(fourier_approx, color=BLUE)\n \n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), run_time=2)\n self.wait(2)\n\n # 6. Conclusion\n self.play(\n FadeOut(specific_eq),\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(graph),\n FadeOut(explanation),\n FadeOut(coeff_labels)\n )\n self.wait(1)\n```"}]}
{"id": "manim-sft-10k_002464", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "BrouwerDegreeScene", "num_animations": 24, "num_rich_primitives": 2, "prompt": "How does the Brouwer Topological Degree categorize mappings that perturb a circle into itself?", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SolveFirstOrderODE", "num_animations": 13, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0070", "num_animations": 21, "prompt": "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:", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_003531", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 12, "num_rich_primitives": 3, "prompt": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Scene Setup: Axes\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # 2. Visual Elements: Plot and Area\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 2.2])\n graph_label = axes.get_graph_label(graph, MathTex(\"x^2\"), x_val=2.2, direction=UR)\n\n # Generate the shaded area under the curve between x=0 and x=2\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # Vertical lines to mark the boundaries of the integral\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY, line_func=Line)\n\n # 3. Educational Sequence: Introduce elements sequentially\n # Introduce Axes and Labels\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # Introduce Curve\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Introduce Shaded Area\n self.play(Create(line_end))\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # 4. Step-by-step integral calculation\n calc_group = VGroup()\n\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n step4 = MathTex(r\"= \\frac{8}{3}\")\n step5 = MathTex(r\"\\approx 2.67\")\n\n # Align steps vertically and position to the right\n calc_group.add(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n calc_group.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # Animate the calculation sequence\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(step4))\n self.wait(0.5)\n self.play(Write(step5))\n self.wait(0.5)\n\n # 5. Conclusion: Highlight Final Result\n final_box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n result_text = Text(\"Final Area = 8/3\", font_size=36, color=YELLOW).next_to(final_box, DOWN, buff=0.5)\n\n self.play(Create(final_box))\n self.play(Write(result_text))\n self.wait(2)\n\n # 6. Cleanup: Fade out all elements from the scene\n self.play(FadeOut(*self.mobjects))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Scene Setup: Axes\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # 2. Visual Elements: Plot and Area\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 2.2])\n graph_label = axes.get_graph_label(graph, MathTex(\"x^2\"), x_val=2.2, direction=UR)\n\n # Generate the shaded area under the curve between x=0 and x=2\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # Vertical lines to mark the boundaries of the integral\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY, line_func=Line)\n\n # 3. Educational Sequence: Introduce elements sequentially\n # Introduce Axes and Labels\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # Introduce Curve\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Introduce Shaded Area\n self.play(Create(line_end))\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # 4. Step-by-step integral calculation\n calc_group = VGroup()\n\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n step4 = MathTex(r\"= \\frac{8}{3}\")\n step5 = MathTex(r\"\\approx 2.67\")\n\n # Align steps vertically and position to the right\n calc_group.add(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n calc_group.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # Animate the calculation sequence\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(step4))\n self.wait(0.5)\n self.play(Write(step5))\n self.wait(0.5)\n\n # 5. Conclusion: Highlight Final Result\n final_box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n result_text = Text(\"Final Area = 8/3\", font_size=36, color=YELLOW).next_to(final_box, DOWN, buff=0.5)\n\n self.play(Create(final_box))\n self.play(Write(result_text))\n self.wait(2)\n\n # 6. Cleanup: Fade out all elements from the scene\n self.play(FadeOut(*self.mobjects))\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000663", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "ReLUVsTanhComparison", "num_animations": 4, "num_rich_primitives": 2, "prompt": "I'm teaching an undergrad ML course and want a side-by-side comparison of ReLU and Tanh using two identical MLPs. Highlight dead ReLU neurons with static black bars, and show activations, gradients, and outputs in sync to illustrate where ReLU fails and where Tanh offers smoother saturation.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass ReLUVsTanhComparison(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: NETWORK]\n with self.voiceover(text=\"Let's compare two common activation functions in identical Multi-Layer Perceptrons. On the left, we have ReLU, and on the right, Tanh.\") as tracker:\n title = Text(\"ReLU vs Tanh in MLPs\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n # Create two simple 3-layer networks\n def create_mlp(color):\n layers = VGroup(\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(1)]).arrange(DOWN, buff=0.3)\n ).arrange(RIGHT, buff=1.5)\n return layers\n \n relu_net = create_mlp(GREEN).shift(LEFT * 3)\n tanh_net = create_mlp(ORANGE).shift(RIGHT * 3)\n \n self.wait_until_bookmark(\"NETWORK\")\n self.play(Write(title), Create(relu_net), Create(tanh_net), run_time=tracker.duration)\n \n with self.voiceover(text=\"During the forward pass with negative inputs, ReLU neurons die, outputting exactly zero, shown here as static black bars. Tanh, however, provides a smooth, bounded output.\") as tracker:\n dead_neuron = Rectangle(width=0.4, height=0.4, color=BLACK, fill_opacity=1).move_to(relu_net[1][0])\n \n self.wait_until_bookmark(\"ACTIVATION\")\n self.play(Create(dead_neuron), run_time=tracker.duration * 0.5)\n self.play(relu_net[1][0].animate.set_fill(BLACK, 1.0), run_time=tracker.duration * 0.5)\n \n with self.voiceover(text=\"In the backward pass, the dead ReLU neuron receives a gradient of zero, halting its learning. Tanh's gradient, while small in saturation, remains non-zero, allowing for continued, albeit slow, updates.\") as tracker:\n grad_relu = Arrow(LEFT * 2, LEFT * 4, color=RED, stroke_width=2)\n grad_tanh = Arrow(RIGHT * 4, RIGHT * 2, color=GREEN, stroke_width=2)\n \n self.wait_until_bookmark(\"GRADIENT\")\n self.play(Create(grad_relu), Create(grad_tanh), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an undergrad ML course and want a side-by-side comparison of ReLU and Tanh using two identical MLPs. Highlight dead ReLU neurons with static black bars, and show activations, gradients, and outputs in sync to illustrate where ReLU fails and where Tanh offers smoother saturation."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass ReLUVsTanhComparison(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: NETWORK]\n with self.voiceover(text=\"Let's compare two common activation functions in identical Multi-Layer Perceptrons. On the left, we have ReLU, and on the right, Tanh.\") as tracker:\n title = Text(\"ReLU vs Tanh in MLPs\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n # Create two simple 3-layer networks\n def create_mlp(color):\n layers = VGroup(\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=color, fill_opacity=0.5) for _ in range(1)]).arrange(DOWN, buff=0.3)\n ).arrange(RIGHT, buff=1.5)\n return layers\n \n relu_net = create_mlp(GREEN).shift(LEFT * 3)\n tanh_net = create_mlp(ORANGE).shift(RIGHT * 3)\n \n self.wait_until_bookmark(\"NETWORK\")\n self.play(Write(title), Create(relu_net), Create(tanh_net), run_time=tracker.duration)\n \n with self.voiceover(text=\"During the forward pass with negative inputs, ReLU neurons die, outputting exactly zero, shown here as static black bars. Tanh, however, provides a smooth, bounded output.\") as tracker:\n dead_neuron = Rectangle(width=0.4, height=0.4, color=BLACK, fill_opacity=1).move_to(relu_net[1][0])\n \n self.wait_until_bookmark(\"ACTIVATION\")\n self.play(Create(dead_neuron), run_time=tracker.duration * 0.5)\n self.play(relu_net[1][0].animate.set_fill(BLACK, 1.0), run_time=tracker.duration * 0.5)\n \n with self.voiceover(text=\"In the backward pass, the dead ReLU neuron receives a gradient of zero, halting its learning. Tanh's gradient, while small in saturation, remains non-zero, allowing for continued, albeit slow, updates.\") as tracker:\n grad_relu = Arrow(LEFT * 2, LEFT * 4, color=RED, stroke_width=2)\n grad_tanh = Arrow(RIGHT * 4, RIGHT * 2, color=GREEN, stroke_width=2)\n \n self.wait_until_bookmark(\"GRADIENT\")\n self.play(Create(grad_relu), Create(grad_tanh), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "multi_act_v2_00275", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0275", "num_animations": 23, "prompt": "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 would like an animation that demonstrates the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the \n- Act 2: Could you create an educational animation that visually demonstrates how the sine wave is generated from the movement of a point along the real axis on the complex plane? Include these specifics:\n- Act 3: 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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0275(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_sineapproximation()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_eulersformulascene()\n\n def act_1_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n )\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Create(axes), Write(title))\n\n # 3. Sine Wave Plot\n # Plot the actual sine wave function on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n self.play(Create(sine_curve))\n # Constraint: Pause briefly after this step to allow the viewer to observe the curve\n self.wait(2)\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series approximation)\n # P(x) = x - x^3/3! + x^5/5!\n polynomial_curve = axes.plot(\n lambda x: x - x**3/6 + x**5/120, \n color=GREEN,\n x_range=[0, 3.5] # Limit range so it stays within the y-axis bounds for visibility\n )\n self.play(Create(polynomial_curve))\n # Constraint: Pause briefly after this step\n self.wait(2)\n\n # 5. Specific Point Marker\n # Place a red dot exactly at the point on the sine curve where x = pi\n x_val = np.pi\n y_val = np.sin(x_val)\n point_on_sine = axes.c2p(x_val, y_val)\n red_dot = Dot(point_on_sine, color=RED)\n self.play(FadeIn(red_dot))\n\n # 6. Projection Line\n # From the red dot, draw a dashed yellow vertical line straight down to the x-axis\n projection_line = DashedLine(\n start=point_on_sine,\n end=axes.c2p(x_val, 0),\n color=YELLOW\n )\n self.play(Create(projection_line))\n \n # Final pause to observe the complete scene\n self.wait(3)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n area = Area(\n axes=Axes(x_range=[0, 3], y_range=[0, 9]),\n graph=ParametricFunction(func, t_range=[0, 3]),\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n\n # Displaying the function and the area under the curve\n self.play(Write(area.axes), Write(area.graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Displaying the integral notation\n integral_text = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n integral_text.next_to(area, UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # Explanation for the area under the curve\n explanation = Text(\"This shaded area represents the definite integral\", font_size=24)\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Solving the integral\n solution = MathTex(r\"= [\\frac{1}{3}x^3]_0^2\", r\"= \\frac{1}{3}(2^3) - \\frac{1}{3}(0^3)\", r\"= \\frac{8}{3}\")\n solution.next_to(integral_text, DOWN)\n self.play(ReplacementTransform(integral_text, solution))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The value of the definite integral is 8/3.\", font_size=24)\n conclusion.to_edge(DOWN + RIGHT)\n self.play(Transform(explanation, conclusion))\n self.wait(2)\n\n # Clear the scene and end\n self.clear()\n self.wait(1)\n self.play(Write(solution))\n self.wait(1)\n\n def act_3_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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 would like an animation that demonstrates the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the \n- Act 2: Could you create an educational animation that visually demonstrates how the sine wave is generated from the movement of a point along the real axis on the complex plane? Include these specifics:\n- Act 3: 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"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0275(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_sineapproximation()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_eulersformulascene()\n\n def act_1_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n )\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Create(axes), Write(title))\n\n # 3. Sine Wave Plot\n # Plot the actual sine wave function on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n self.play(Create(sine_curve))\n # Constraint: Pause briefly after this step to allow the viewer to observe the curve\n self.wait(2)\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series approximation)\n # P(x) = x - x^3/3! + x^5/5!\n polynomial_curve = axes.plot(\n lambda x: x - x**3/6 + x**5/120, \n color=GREEN,\n x_range=[0, 3.5] # Limit range so it stays within the y-axis bounds for visibility\n )\n self.play(Create(polynomial_curve))\n # Constraint: Pause briefly after this step\n self.wait(2)\n\n # 5. Specific Point Marker\n # Place a red dot exactly at the point on the sine curve where x = pi\n x_val = np.pi\n y_val = np.sin(x_val)\n point_on_sine = axes.c2p(x_val, y_val)\n red_dot = Dot(point_on_sine, color=RED)\n self.play(FadeIn(red_dot))\n\n # 6. Projection Line\n # From the red dot, draw a dashed yellow vertical line straight down to the x-axis\n projection_line = DashedLine(\n start=point_on_sine,\n end=axes.c2p(x_val, 0),\n color=YELLOW\n )\n self.play(Create(projection_line))\n \n # Final pause to observe the complete scene\n self.wait(3)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n area = Area(\n axes=Axes(x_range=[0, 3], y_range=[0, 9]),\n graph=ParametricFunction(func, t_range=[0, 3]),\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n\n # Displaying the function and the area under the curve\n self.play(Write(area.axes), Write(area.graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Displaying the integral notation\n integral_text = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n integral_text.next_to(area, UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # Explanation for the area under the curve\n explanation = Text(\"This shaded area represents the definite integral\", font_size=24)\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Solving the integral\n solution = MathTex(r\"= [\\frac{1}{3}x^3]_0^2\", r\"= \\frac{1}{3}(2^3) - \\frac{1}{3}(0^3)\", r\"= \\frac{8}{3}\")\n solution.next_to(integral_text, DOWN)\n self.play(ReplacementTransform(integral_text, solution))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The value of the definite integral is 8/3.\", font_size=24)\n conclusion.to_edge(DOWN + RIGHT)\n self.play(Transform(explanation, conclusion))\n self.wait(2)\n\n # Clear the scene and end\n self.clear()\n self.wait(1)\n self.play(Write(solution))\n self.wait(1)\n\n def act_3_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```"}]}
{"id": "autoresearch-manim_000082", "source": "sebastianboehler/autoresearch-manim", "tier": 1, "scene_name": "EconomicsSupplyDemandShiftStory", "num_animations": 3, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_000165", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PTestConvergence", "num_animations": 14, "num_rich_primitives": 2, "prompt": "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?", "code": "from manim import *\n\nclass PTestConvergence(Scene):\n def construct(self):\n # --- Colors ---\n COLOR_SERIES = BLUE\n COLOR_P = YELLOW\n COLOR_SUCCESS = GREEN\n COLOR_FAILURE = RED\n\n # --- Step 1: Showcase the Series ---\n title = Text(\"The p-Test for Series Convergence\", font_size=40).to_edge(UP)\n specific_series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", color=COLOR_SERIES, font_size=60)\n specific_series.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(specific_series))\n self.wait(2)\n\n # --- Step 2: Explain the p-test ---\n # Shift the specific series to the left to make room for the general rule\n self.play(specific_series.animate.shift(LEFT * 3.5))\n\n # Create the general p-test rule components\n p_test_title = Text(\"The p-Test Rule:\", font_size=36)\n p_test_title.next_to(title, DOWN, buff=1).shift(RIGHT * 3.5)\n\n general_series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^p}\", font_size=50)\n general_series.next_to(p_test_title, DOWN, buff=0.5)\n\n # Define convergence and divergence conditions with colors\n condition_converges = MathTex(r\"p > 1 \\implies \\text{Converges}\", color=COLOR_SUCCESS, font_size=40)\n condition_diverges = MathTex(r\"p \\le 1 \\implies \\text{Diverges}\", color=COLOR_FAILURE, font_size=40)\n\n conditions = VGroup(condition_converges, condition_diverges)\n conditions.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n conditions.next_to(general_series, DOWN, buff=0.5)\n\n # Group the p-test elements and animate appearance\n p_test_group = VGroup(p_test_title, general_series, conditions)\n\n self.play(Write(p_test_title))\n self.play(Write(general_series))\n self.play(Write(conditions))\n self.wait(2)\n\n # --- Step 3: Apply the Test ---\n # Highlight 'p' in the general series and '2' in the specific series\n general_series_colored = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^{\\color{yellow}p}}\", font_size=50)\n general_series_colored.move_to(general_series)\n\n specific_series_colored = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^{\\color{yellow}2}}\", color=COLOR_SERIES, font_size=60)\n specific_series_colored.move_to(specific_series)\n\n # Transform to colored versions to draw attention to the exponent\n self.play(\n Transform(general_series, general_series_colored),\n Transform(specific_series, specific_series_colored)\n )\n\n identification = Text(\"Identify p = 2\", font_size=36, color=COLOR_P)\n identification.next_to(conditions, DOWN, buff=0.5)\n\n self.play(Write(identification))\n self.wait(1)\n\n # --- Step 4: Conclude ---\n # Show the comparison logic\n comparison = MathTex(r\"2 > 1\", font_size=50, color=COLOR_SUCCESS)\n comparison.next_to(identification, DOWN, buff=0.5)\n\n self.play(Write(comparison))\n\n # Emphasize the converges condition and fade out the diverges condition\n self.play(\n condition_converges.animate.scale(1.1).set_color(WHITE),\n condition_diverges.animate.set_opacity(0.3)\n )\n\n conclusion_text = Text(\"Therefore, the series converges.\", font_size=36, color=COLOR_SUCCESS)\n conclusion_text.next_to(comparison, DOWN, buff=0.5)\n\n self.play(Write(conclusion_text))\n self.wait(2)\n\n # --- Step 5: Final Statement ---\n # Group all existing content to fade it out cleanly\n all_content = VGroup(\n title, specific_series, p_test_group,\n identification, comparison, conclusion_text\n )\n self.play(FadeOut(all_content))\n\n # Create the final clear statement\n final_line1 = Text(\"The Series\", font_size=60)\n final_line2 = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=70, color=COLOR_SERIES)\n final_line3 = Text(\"Converges!\", font_size=60, color=COLOR_SUCCESS)\n\n final_group = VGroup(final_line1, final_line2, final_line3)\n final_group.arrange(DOWN, buff=0.5)\n\n # Write the final conclusion and indicate the series\n self.play(Write(final_group))\n self.play(Indicate(final_line2))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 # --- Colors ---\n COLOR_SERIES = BLUE\n COLOR_P = YELLOW\n COLOR_SUCCESS = GREEN\n COLOR_FAILURE = RED\n\n # --- Step 1: Showcase the Series ---\n title = Text(\"The p-Test for Series Convergence\", font_size=40).to_edge(UP)\n specific_series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", color=COLOR_SERIES, font_size=60)\n specific_series.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(specific_series))\n self.wait(2)\n\n # --- Step 2: Explain the p-test ---\n # Shift the specific series to the left to make room for the general rule\n self.play(specific_series.animate.shift(LEFT * 3.5))\n\n # Create the general p-test rule components\n p_test_title = Text(\"The p-Test Rule:\", font_size=36)\n p_test_title.next_to(title, DOWN, buff=1).shift(RIGHT * 3.5)\n\n general_series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^p}\", font_size=50)\n general_series.next_to(p_test_title, DOWN, buff=0.5)\n\n # Define convergence and divergence conditions with colors\n condition_converges = MathTex(r\"p > 1 \\implies \\text{Converges}\", color=COLOR_SUCCESS, font_size=40)\n condition_diverges = MathTex(r\"p \\le 1 \\implies \\text{Diverges}\", color=COLOR_FAILURE, font_size=40)\n\n conditions = VGroup(condition_converges, condition_diverges)\n conditions.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n conditions.next_to(general_series, DOWN, buff=0.5)\n\n # Group the p-test elements and animate appearance\n p_test_group = VGroup(p_test_title, general_series, conditions)\n\n self.play(Write(p_test_title))\n self.play(Write(general_series))\n self.play(Write(conditions))\n self.wait(2)\n\n # --- Step 3: Apply the Test ---\n # Highlight 'p' in the general series and '2' in the specific series\n general_series_colored = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^{\\color{yellow}p}}\", font_size=50)\n general_series_colored.move_to(general_series)\n\n specific_series_colored = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^{\\color{yellow}2}}\", color=COLOR_SERIES, font_size=60)\n specific_series_colored.move_to(specific_series)\n\n # Transform to colored versions to draw attention to the exponent\n self.play(\n Transform(general_series, general_series_colored),\n Transform(specific_series, specific_series_colored)\n )\n\n identification = Text(\"Identify p = 2\", font_size=36, color=COLOR_P)\n identification.next_to(conditions, DOWN, buff=0.5)\n\n self.play(Write(identification))\n self.wait(1)\n\n # --- Step 4: Conclude ---\n # Show the comparison logic\n comparison = MathTex(r\"2 > 1\", font_size=50, color=COLOR_SUCCESS)\n comparison.next_to(identification, DOWN, buff=0.5)\n\n self.play(Write(comparison))\n\n # Emphasize the converges condition and fade out the diverges condition\n self.play(\n condition_converges.animate.scale(1.1).set_color(WHITE),\n condition_diverges.animate.set_opacity(0.3)\n )\n\n conclusion_text = Text(\"Therefore, the series converges.\", font_size=36, color=COLOR_SUCCESS)\n conclusion_text.next_to(comparison, DOWN, buff=0.5)\n\n self.play(Write(conclusion_text))\n self.wait(2)\n\n # --- Step 5: Final Statement ---\n # Group all existing content to fade it out cleanly\n all_content = VGroup(\n title, specific_series, p_test_group,\n identification, comparison, conclusion_text\n )\n self.play(FadeOut(all_content))\n\n # Create the final clear statement\n final_line1 = Text(\"The Series\", font_size=60)\n final_line2 = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=70, color=COLOR_SERIES)\n final_line3 = Text(\"Converges!\", font_size=60, color=COLOR_SUCCESS)\n\n final_group = VGroup(final_line1, final_line2, final_line3)\n final_group.arrange(DOWN, buff=0.5)\n\n # Write the final conclusion and indicate the series\n self.play(Write(final_group))\n self.play(Indicate(final_line2))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_008021", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaveEquationExplainer", "num_animations": 7, "num_rich_primitives": 3, "prompt": "Can you create an educational animation that introduces and explains the wave equation, including a transition from the general form to the one-dimensional version, and demonstrates possible solutions as waves moving in opposite directions?", "code": "from manim import *\nimport numpy as np\n\nclass WaveEquationExplainer(Scene):\n def construct(self):\n # --- SCENE 1 & 2: INTRODUCTION AND TRANSITION ---\n # Display the 1D wave equation at the top of the screen\n wave_eq_1d = MathTex(r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\")\n wave_eq_1d.to_edge(UP)\n self.play(Write(wave_eq_1d))\n self.wait(1)\n\n # --- SCENE 3: SOLUTION DEMONSTRATION ---\n # Define the axes for propagation\n axes = Axes(\n x_range=[-5, 5, 1],\n y_range=[-1, 2, 1],\n axis_config={\"include_tip\": True}\n ).scale(0.8).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n self.play(Create(axes), Write(labels))\n\n # Define the wave functions (Gaussian pulses)\n # F(x - ct) moves Right: As t increases, the peak shifts to positive x.\n def right_moving_wave(x, t):\n return np.exp(-((x - 2*t)**2)) \n \n # G(x + ct) moves Left: As t increases, the peak shifts to negative x.\n def left_moving_wave(x, t):\n return np.exp(-((x + 2*t - 4)**2)) # Offset start position to x=4\n\n # Superposition Principle: The total displacement is the sum of individual waves\n def superposition(x, t):\n return right_moving_wave(x, t) + left_moving_wave(x, t)\n\n # Use a ValueTracker to simulate time 't'\n time_tracker = ValueTracker(0)\n \n # Create Manim graph objects that update dynamically with the time tracker\n wave_right = always_redraw(lambda: axes.plot(\n lambda x: right_moving_wave(x, time_tracker.get_value()), \n color=CYAN\n ))\n \n wave_left = always_redraw(lambda: axes.plot(\n lambda x: left_moving_wave(x, time_tracker.get_value()), \n color=YELLOW\n ))\n \n wave_sum = always_redraw(lambda: axes.plot(\n lambda x: superposition(x, time_tracker.get_value()), \n color=WHITE,\n stroke_opacity=0.8\n ))\n\n # Label the waves\n label_right = MathTex(\"F(x - ct)\", color=CYAN).scale(0.7).next_to(wave_right, UP)\n label_left = MathTex(\"G(x + ct)\", color=YELLOW).scale(0.7).next_to(wave_left, UP)\n\n # Animate the creation of the waves\n self.play(Create(wave_right), Create(wave_left), Write(label_right), Write(label_left))\n self.wait(1)\n \n # Animate time from 0 to 2 seconds to show propagation and superposition\n self.play(time_tracker.animate.set_value(2), run_time=4, rate_func=linear)\n self.wait(1)\n \n # Add the superposition curve to visually demonstrate the sum of the waves\n self.play(Create(wave_sum))\n time_tracker.set_value(0) # Reset time\n self.play(time_tracker.animate.set_value(2), run_time=4, rate_func=linear)\n \n # Final explanation text\n conclusion = Text(\"Superposition: Waves pass through unchanged\", font_size=24)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that introduces and explains the wave equation, including a transition from the general form to the one-dimensional version, and demonstrates possible solutions as waves moving in opposite directions?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaveEquationExplainer(Scene):\n def construct(self):\n # --- SCENE 1 & 2: INTRODUCTION AND TRANSITION ---\n # Display the 1D wave equation at the top of the screen\n wave_eq_1d = MathTex(r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\")\n wave_eq_1d.to_edge(UP)\n self.play(Write(wave_eq_1d))\n self.wait(1)\n\n # --- SCENE 3: SOLUTION DEMONSTRATION ---\n # Define the axes for propagation\n axes = Axes(\n x_range=[-5, 5, 1],\n y_range=[-1, 2, 1],\n axis_config={\"include_tip\": True}\n ).scale(0.8).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n self.play(Create(axes), Write(labels))\n\n # Define the wave functions (Gaussian pulses)\n # F(x - ct) moves Right: As t increases, the peak shifts to positive x.\n def right_moving_wave(x, t):\n return np.exp(-((x - 2*t)**2)) \n \n # G(x + ct) moves Left: As t increases, the peak shifts to negative x.\n def left_moving_wave(x, t):\n return np.exp(-((x + 2*t - 4)**2)) # Offset start position to x=4\n\n # Superposition Principle: The total displacement is the sum of individual waves\n def superposition(x, t):\n return right_moving_wave(x, t) + left_moving_wave(x, t)\n\n # Use a ValueTracker to simulate time 't'\n time_tracker = ValueTracker(0)\n \n # Create Manim graph objects that update dynamically with the time tracker\n wave_right = always_redraw(lambda: axes.plot(\n lambda x: right_moving_wave(x, time_tracker.get_value()), \n color=CYAN\n ))\n \n wave_left = always_redraw(lambda: axes.plot(\n lambda x: left_moving_wave(x, time_tracker.get_value()), \n color=YELLOW\n ))\n \n wave_sum = always_redraw(lambda: axes.plot(\n lambda x: superposition(x, time_tracker.get_value()), \n color=WHITE,\n stroke_opacity=0.8\n ))\n\n # Label the waves\n label_right = MathTex(\"F(x - ct)\", color=CYAN).scale(0.7).next_to(wave_right, UP)\n label_left = MathTex(\"G(x + ct)\", color=YELLOW).scale(0.7).next_to(wave_left, UP)\n\n # Animate the creation of the waves\n self.play(Create(wave_right), Create(wave_left), Write(label_right), Write(label_left))\n self.wait(1)\n \n # Animate time from 0 to 2 seconds to show propagation and superposition\n self.play(time_tracker.animate.set_value(2), run_time=4, rate_func=linear)\n self.wait(1)\n \n # Add the superposition curve to visually demonstrate the sum of the waves\n self.play(Create(wave_sum))\n time_tracker.set_value(0) # Reset time\n self.play(time_tracker.animate.set_value(2), run_time=4, rate_func=linear)\n \n # Final explanation text\n conclusion = Text(\"Superposition: Waves pass through unchanged\", font_size=24)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_000522", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 15, "num_rich_primitives": 2, "prompt": "Could you create an educational animation that visually demonstrates how to calculate the area under the curve of the function f(x) = 3 - x^2 from x = -1 to x = 2? First, show the function itself, then display the integral of the function within the given bounds. Next, plot the function's graph and highlight the area under the curve. After that, show the antiderivative of the function and demonstrate how to evaluate the definite integral by substituting the upper and lower bounds. Finally, display the numerical result of the integral's evaluation, and conclude by showing only the result on the screen.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # Step 1: Function Display\n func_text = MathTex(\"f(x) = 3 - x^2\").scale(1.5)\n self.play(Write(func_text))\n self.wait(1)\n \n # Move function to corner\n func_text_corner = func_text.copy().to_corner(UL)\n self.play(Transform(func_text, func_text_corner))\n\n # Step 2: Integral Setup\n integral_expr = MathTex(\n \"\\\\int_{-1}^{2}\", \"(3 - x^2)\", \"\\\\,dx\"\n ).scale(1.2)\n integral_expr.next_to(func_text_corner, DOWN, buff=0.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 3: Graphical Representation\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 4, 1],\n axis_config={\"include_tip\": True},\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: 3 - x**2, x_range=[-1, 2], color=WHITE)\n \n area = axes.get_area(graph, x_range=[-1, 2], color=BLUE, opacity=0.5)\n \n bound_lines = VGroup(\n axes.get_vertical_line(graph.input_to_graph_point(-1, graph), color=GRAY),\n axes.get_vertical_line(graph.input_to_graph_point(2, graph), color=GRAY)\n )\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph))\n self.play(Create(bound_lines), FadeIn(area))\n self.wait(1)\n\n # Step 4: Antiderivative & Evaluation\n # Move integral to left for calculation space\n calc_group = VGroup(integral_expr).to_edge(LEFT).shift(DOWN)\n self.play(integral_expr.animate.to_edge(LEFT).shift(DOWN))\n\n antiderivative = MathTex(\n \"\\\\left[ 3x - \\\\frac{x^3}{3} \\\\right]_{-1}^{2}\"\n ).scale(1.1)\n antiderivative.next_to(integral_expr, DOWN, aligned_edge=LEFT)\n \n substitution = MathTex(\n \"= \\\\left( 3(2) - \\\\frac{2^3}{3} \\\\right) - \\\\left( 3(-1) - \\\\frac{(-1)^3}{3} \\\\right)\"\n ).scale(0.9)\n substitution.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n\n simplification = MathTex(\n \"= \\\\left( 6 - \\\\frac{8}{3} \\\\right) - \\\\left( -3 + \\\\frac{1}{3} \\\\right)\"\n ).scale(0.9)\n simplification.next_to(substitution, DOWN, aligned_edge=LEFT)\n\n result_frac = MathTex(\n \"= \\\\frac{10}{3} - \\\\left( -\\\\frac{8}{3} \\\\right)\"\n ).scale(0.9)\n result_frac.next_to(simplification, DOWN, aligned_edge=LEFT)\n\n self.play(Write(antiderivative))\n self.wait(0.5)\n self.play(Write(substitution))\n self.wait(0.5)\n self.play(Write(simplification))\n self.wait(0.5)\n self.play(Write(result_frac))\n self.wait(1)\n\n # Step 5: Numerical Result\n final_result = MathTex(\"= 6\").scale(1.5)\n final_result.next_to(result_frac, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_result), area.animate.set_fill(color=GOLD, opacity=0.8))\n self.wait(1)\n\n # Step 6: Conclusion\n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(graph), \n FadeOut(bound_lines), FadeOut(area), FadeOut(integral_expr),\n FadeOut(antiderivative), FadeOut(substitution), \n FadeOut(simplification), FadeOut(result_frac),\n FadeOut(func_text)\n )\n \n conclusion_text = MathTex(\"6\").scale(2)\n self.play(Write(conclusion_text))\n self.wait(3)\n self.play(FadeOut(conclusion_text))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that visually demonstrates how to calculate the area under the curve of the function f(x) = 3 - x^2 from x = -1 to x = 2? First, show the function itself, then display the integral of the function within the given bounds. Next, plot the function's graph and highlight the area under the curve. After that, show the antiderivative of the function and demonstrate how to evaluate the definite integral by substituting the upper and lower bounds. Finally, display the numerical result of the integral's evaluation, and conclude by showing only the result on the screen."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # Step 1: Function Display\n func_text = MathTex(\"f(x) = 3 - x^2\").scale(1.5)\n self.play(Write(func_text))\n self.wait(1)\n \n # Move function to corner\n func_text_corner = func_text.copy().to_corner(UL)\n self.play(Transform(func_text, func_text_corner))\n\n # Step 2: Integral Setup\n integral_expr = MathTex(\n \"\\\\int_{-1}^{2}\", \"(3 - x^2)\", \"\\\\,dx\"\n ).scale(1.2)\n integral_expr.next_to(func_text_corner, DOWN, buff=0.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 3: Graphical Representation\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 4, 1],\n axis_config={\"include_tip\": True},\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: 3 - x**2, x_range=[-1, 2], color=WHITE)\n \n area = axes.get_area(graph, x_range=[-1, 2], color=BLUE, opacity=0.5)\n \n bound_lines = VGroup(\n axes.get_vertical_line(graph.input_to_graph_point(-1, graph), color=GRAY),\n axes.get_vertical_line(graph.input_to_graph_point(2, graph), color=GRAY)\n )\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph))\n self.play(Create(bound_lines), FadeIn(area))\n self.wait(1)\n\n # Step 4: Antiderivative & Evaluation\n # Move integral to left for calculation space\n calc_group = VGroup(integral_expr).to_edge(LEFT).shift(DOWN)\n self.play(integral_expr.animate.to_edge(LEFT).shift(DOWN))\n\n antiderivative = MathTex(\n \"\\\\left[ 3x - \\\\frac{x^3}{3} \\\\right]_{-1}^{2}\"\n ).scale(1.1)\n antiderivative.next_to(integral_expr, DOWN, aligned_edge=LEFT)\n \n substitution = MathTex(\n \"= \\\\left( 3(2) - \\\\frac{2^3}{3} \\\\right) - \\\\left( 3(-1) - \\\\frac{(-1)^3}{3} \\\\right)\"\n ).scale(0.9)\n substitution.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n\n simplification = MathTex(\n \"= \\\\left( 6 - \\\\frac{8}{3} \\\\right) - \\\\left( -3 + \\\\frac{1}{3} \\\\right)\"\n ).scale(0.9)\n simplification.next_to(substitution, DOWN, aligned_edge=LEFT)\n\n result_frac = MathTex(\n \"= \\\\frac{10}{3} - \\\\left( -\\\\frac{8}{3} \\\\right)\"\n ).scale(0.9)\n result_frac.next_to(simplification, DOWN, aligned_edge=LEFT)\n\n self.play(Write(antiderivative))\n self.wait(0.5)\n self.play(Write(substitution))\n self.wait(0.5)\n self.play(Write(simplification))\n self.wait(0.5)\n self.play(Write(result_frac))\n self.wait(1)\n\n # Step 5: Numerical Result\n final_result = MathTex(\"= 6\").scale(1.5)\n final_result.next_to(result_frac, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_result), area.animate.set_fill(color=GOLD, opacity=0.8))\n self.wait(1)\n\n # Step 6: Conclusion\n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(graph), \n FadeOut(bound_lines), FadeOut(area), FadeOut(integral_expr),\n FadeOut(antiderivative), FadeOut(substitution), \n FadeOut(simplification), FadeOut(result_frac),\n FadeOut(func_text)\n )\n \n conclusion_text = MathTex(\"6\").scale(2)\n self.play(Write(conclusion_text))\n self.wait(3)\n self.play(FadeOut(conclusion_text))\n```"}]}
{"id": "adaption-unified-manim-instructions_000870", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "NeuralNetworkVisualization", "num_animations": 9, "num_rich_primitives": 2, "prompt": "Can you create an animation that visualizes a small neural network with input, hidden, and output layers, where the input has 784 nodes, the first hidden layer has 16 nodes, the second hidden layer has 32 nodes, then another hidden layer with 16 nodes that connect to an output layer with 10 nodes? I would like to see ReLU activation functions in the hidden layers and a Softmax activation function in the output layer. Also, can you add some skip connections directly from the input to the second hidden layer and from the first hidden layer to the output? During the animation, it would be great to watch a random forward pass through the network and see the output nodes get highlighted at the end.", "code": "from manim import *\nimport random\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n # Network architecture: Input(784), H1(16), H2(32), H3(16), Output(10)\n layer_sizes = [784, 16, 32, 16, 10]\n layer_labels = [\"Input\\n(784)\", \"Hidden 1\\n(ReLU)\", \"Hidden 2\\n(ReLU)\", \"Hidden 3\\n(ReLU)\", \"Output\\n(Softmax)\"]\n \n # Since rendering 784 individual nodes is impractical, we use a compressed\n # visual representation: a smaller number of dots symbolizing the full layer.\n visual_sizes = [20, 16, 32, 16, 10]\n \n # Colors\n node_color = WHITE\n edge_color = GRAY_B\n skip_color = BLUE_D\n signal_color = YELLOW\n highlight_color = GREEN\n \n # Layout\n x_spacing = 3.0\n y_spacing = 0.35\n start_x = -6.0\n \n # --- Create Nodes ---\n nodes_by_layer = []\n for i, size in enumerate(visual_sizes):\n layer = VGroup()\n total_height = (size - 1) * y_spacing\n start_y = -total_height / 2\n \n radius = 0.06 if size > 20 else 0.1\n for j in range(size):\n dot = Dot(radius=radius, color=node_color)\n dot.move_to([start_x + i * x_spacing, start_y + j * y_spacing, 0])\n layer.add(dot)\n \n nodes_by_layer.append(layer)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, label_text in enumerate(layer_labels):\n label = Text(label_text, font_size=16, color=GRAY)\n label.next_to(nodes_by_layer[i], DOWN, buff=0.4)\n labels.add(label)\n \n # --- Create Standard Connections ---\n all_edges = VGroup()\n for i in range(len(visual_sizes) - 1):\n layer_start = nodes_by_layer[i]\n layer_end = nodes_by_layer[i + 1]\n \n for start_node in layer_start:\n for end_node in layer_end:\n # Sample connections from large input layer to prevent clutter\n if i == 0 and random.random() > 0.3:\n continue\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=0.5, stroke_opacity=0.25, color=edge_color\n )\n all_edges.add(edge)\n \n # --- Create Skip Connections ---\n # Skip 1: Input (0) -> Hidden 2 (2)\n skip_1_edges = VGroup()\n for start_node in nodes_by_layer[0][::4]:\n for end_node in nodes_by_layer[2][::8]:\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=1, stroke_opacity=0.4, color=skip_color\n )\n skip_1_edges.add(edge)\n \n # Skip 2: Hidden 1 (1) -> Output (4)\n skip_2_edges = VGroup()\n for start_node in nodes_by_layer[1][::4]:\n for end_node in nodes_by_layer[4][::2]:\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=1, stroke_opacity=0.4, color=skip_color\n )\n skip_2_edges.add(edge)\n \n # --- Animation Sequence ---\n \n # 1. Visualize Network Structure\n self.play(FadeIn(VGroup(*nodes_by_layer)), FadeIn(labels), run_time=1.5)\n self.play(FadeIn(all_edges), run_time=1.5)\n self.play(Create(skip_1_edges), Create(skip_2_edges), run_time=1)\n self.wait(0.5)\n \n # 2. Animate Forward Pass (Signal Propagation)\n def animate_signal(start_idx, end_idx, color=signal_color, run_time=0.8):\n signals = VGroup()\n animations = []\n for _ in range(12):\n start_node = random.choice(nodes_by_layer[start_idx])\n end_node = random.choice(nodes_by_layer[end_idx])\n dot = Dot(radius=0.05, color=color)\n path = Line(start_node.get_center(), end_node.get_center())\n signals.add(dot)\n animations.append(MoveAlongPath(dot, path, run_time=run_time, rate_func=linear))\n self.add(signals)\n self.play(*animations, run_time=run_time)\n self.remove(signals)\n \n # Sequential forward pass\n for i in range(len(visual_sizes) - 1):\n animate_signal(i, i + 1)\n # Brief highlight of activated layer\n self.play(nodes_by_layer[i + 1].animate.set_color(YELLOW), run_time=0.1)\n self.play(nodes_by_layer[i + 1].animate.set_color(node_color), run_time=0.1)\n \n # Skip connection passes\n animate_signal(0, 2, color=BLUE_B, run_time=0.6)\n animate_signal(1, 4, color=BLUE_B, run_time=0.6)\n \n # 3. Highlight Output Nodes\n self.play(nodes_by_layer[4].animate.set_color(highlight_color), run_time=0.5)\n self.play(nodes_by_layer[4].animate.scale(1.2), run_time=0.3)\n \n result_text = Text(\"Classification Result\", font_size=24, color=highlight_color)\n result_text.next_to(nodes_by_layer[4], RIGHT, buff=0.5)\n self.play(Write(result_text), run_time=1)\n \n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animation that visualizes a small neural network with input, hidden, and output layers, where the input has 784 nodes, the first hidden layer has 16 nodes, the second hidden layer has 32 nodes, then another hidden layer with 16 nodes that connect to an output layer with 10 nodes? I would like to see ReLU activation functions in the hidden layers and a Softmax activation function in the output layer. Also, can you add some skip connections directly from the input to the second hidden layer and from the first hidden layer to the output? During the animation, it would be great to watch a random forward pass through the network and see the output nodes get highlighted at the end."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport random\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n # Network architecture: Input(784), H1(16), H2(32), H3(16), Output(10)\n layer_sizes = [784, 16, 32, 16, 10]\n layer_labels = [\"Input\\n(784)\", \"Hidden 1\\n(ReLU)\", \"Hidden 2\\n(ReLU)\", \"Hidden 3\\n(ReLU)\", \"Output\\n(Softmax)\"]\n \n # Since rendering 784 individual nodes is impractical, we use a compressed\n # visual representation: a smaller number of dots symbolizing the full layer.\n visual_sizes = [20, 16, 32, 16, 10]\n \n # Colors\n node_color = WHITE\n edge_color = GRAY_B\n skip_color = BLUE_D\n signal_color = YELLOW\n highlight_color = GREEN\n \n # Layout\n x_spacing = 3.0\n y_spacing = 0.35\n start_x = -6.0\n \n # --- Create Nodes ---\n nodes_by_layer = []\n for i, size in enumerate(visual_sizes):\n layer = VGroup()\n total_height = (size - 1) * y_spacing\n start_y = -total_height / 2\n \n radius = 0.06 if size > 20 else 0.1\n for j in range(size):\n dot = Dot(radius=radius, color=node_color)\n dot.move_to([start_x + i * x_spacing, start_y + j * y_spacing, 0])\n layer.add(dot)\n \n nodes_by_layer.append(layer)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, label_text in enumerate(layer_labels):\n label = Text(label_text, font_size=16, color=GRAY)\n label.next_to(nodes_by_layer[i], DOWN, buff=0.4)\n labels.add(label)\n \n # --- Create Standard Connections ---\n all_edges = VGroup()\n for i in range(len(visual_sizes) - 1):\n layer_start = nodes_by_layer[i]\n layer_end = nodes_by_layer[i + 1]\n \n for start_node in layer_start:\n for end_node in layer_end:\n # Sample connections from large input layer to prevent clutter\n if i == 0 and random.random() > 0.3:\n continue\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=0.5, stroke_opacity=0.25, color=edge_color\n )\n all_edges.add(edge)\n \n # --- Create Skip Connections ---\n # Skip 1: Input (0) -> Hidden 2 (2)\n skip_1_edges = VGroup()\n for start_node in nodes_by_layer[0][::4]:\n for end_node in nodes_by_layer[2][::8]:\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=1, stroke_opacity=0.4, color=skip_color\n )\n skip_1_edges.add(edge)\n \n # Skip 2: Hidden 1 (1) -> Output (4)\n skip_2_edges = VGroup()\n for start_node in nodes_by_layer[1][::4]:\n for end_node in nodes_by_layer[4][::2]:\n edge = Line(\n start_node.get_center(), end_node.get_center(),\n stroke_width=1, stroke_opacity=0.4, color=skip_color\n )\n skip_2_edges.add(edge)\n \n # --- Animation Sequence ---\n \n # 1. Visualize Network Structure\n self.play(FadeIn(VGroup(*nodes_by_layer)), FadeIn(labels), run_time=1.5)\n self.play(FadeIn(all_edges), run_time=1.5)\n self.play(Create(skip_1_edges), Create(skip_2_edges), run_time=1)\n self.wait(0.5)\n \n # 2. Animate Forward Pass (Signal Propagation)\n def animate_signal(start_idx, end_idx, color=signal_color, run_time=0.8):\n signals = VGroup()\n animations = []\n for _ in range(12):\n start_node = random.choice(nodes_by_layer[start_idx])\n end_node = random.choice(nodes_by_layer[end_idx])\n dot = Dot(radius=0.05, color=color)\n path = Line(start_node.get_center(), end_node.get_center())\n signals.add(dot)\n animations.append(MoveAlongPath(dot, path, run_time=run_time, rate_func=linear))\n self.add(signals)\n self.play(*animations, run_time=run_time)\n self.remove(signals)\n \n # Sequential forward pass\n for i in range(len(visual_sizes) - 1):\n animate_signal(i, i + 1)\n # Brief highlight of activated layer\n self.play(nodes_by_layer[i + 1].animate.set_color(YELLOW), run_time=0.1)\n self.play(nodes_by_layer[i + 1].animate.set_color(node_color), run_time=0.1)\n \n # Skip connection passes\n animate_signal(0, 2, color=BLUE_B, run_time=0.6)\n animate_signal(1, 4, color=BLUE_B, run_time=0.6)\n \n # 3. Highlight Output Nodes\n self.play(nodes_by_layer[4].animate.set_color(highlight_color), run_time=0.5)\n self.play(nodes_by_layer[4].animate.scale(1.2), run_time=0.3)\n \n result_text = Text(\"Classification Result\", font_size=24, color=highlight_color)\n result_text.next_to(nodes_by_layer[4], RIGHT, buff=0.5)\n self.play(Write(result_text), run_time=1)\n \n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_007957", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaveEquationVisualization", "num_animations": 11, "num_rich_primitives": 3, "prompt": "How can I create an educational animation using a tool that illustrates the one-dimensional wave equation, its general solution, and briefly touches on particular solutions with accompanied explanations, pausing between each step to allow the content to be absorbed?", "code": "from manim import *\nimport numpy as np\n\nclass WaveEquationVisualization(Scene):\n def construct(self):\n # 1. Introduction\n title = Text(\"The 1D Wave Equation\", font_size=40).to_edge(UP)\n equation = MathTex(r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\").scale(1.5)\n \n self.play(Write(title))\n self.wait(1)\n self.play(Write(equation))\n self.wait(3) # Introduction Pause\n \n explanation = Text(\"u(x,t): Displacement\\nc: Wave Speed\", font_size=24).next_to(equation, DOWN)\n self.play(FadeIn(explanation))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(equation), FadeOut(explanation))\n self.wait(1) # Transition Pause\n\n # 2. General Solution (d'Alembert)\n axes = Axes(x_range=[-10, 10, 1], y_range=[-2, 2, 1], x_length=10, y_length=4).shift(DOWN*0.5)\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n self.play(Create(axes), Write(labels))\n \n t = ValueTracker(0)\n c = 2\n \n wave_right = always_redraw(lambda: axes.plot(lambda x: np.exp(-(x - c * t.get_value())**2 / 2), color=BLUE))\n wave_left = always_redraw(lambda: axes.plot(lambda x: np.exp(-(x + c * t.get_value())**2 / 2), color=RED))\n \n dalembert_text = MathTex(r\"u(x,t) = f(x-ct) + g(x+ct)\").to_edge(UP)\n self.play(Write(dalembert_text))\n self.wait(2)\n \n self.add(wave_right, wave_left)\n self.play(t.animate.set_value(3), run_time=4, rate_func=linear)\n self.wait(2) # Observation Pause\n self.play(FadeOut(wave_right), FadeOut(wave_left), FadeOut(dalembert_text))\n self.wait(1) # Transition Pause\n\n # 3. Particular Solution (Standing Wave)\n standing_text = Text(\"Standing Wave Solution\", font_size=36).to_edge(UP)\n eq_standing = MathTex(r\"u(x,t) = \\sin(kx)\\cos(\\omega t)\").next_to(standing_text, DOWN)\n self.play(Write(standing_text), Write(eq_standing))\n self.wait(2)\n \n t2 = ValueTracker(0)\n standing_wave = always_redraw(lambda: axes.plot(lambda x: np.sin(x) * np.cos(t2.get_value()), color=YELLOW))\n \n self.add(standing_wave)\n self.play(t2.animate.set_value(2 * PI), run_time=6, rate_func=linear)\n \n nodes_text = Text(\"Notice the stationary Nodes\", font_size=24).to_corner(DR)\n self.play(Write(nodes_text))\n self.wait(3) # Final Observation Pause", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "How can I create an educational animation using a tool that illustrates the one-dimensional wave equation, its general solution, and briefly touches on particular solutions with accompanied explanations, pausing between each step to allow the content to be absorbed?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaveEquationVisualization(Scene):\n def construct(self):\n # 1. Introduction\n title = Text(\"The 1D Wave Equation\", font_size=40).to_edge(UP)\n equation = MathTex(r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\").scale(1.5)\n \n self.play(Write(title))\n self.wait(1)\n self.play(Write(equation))\n self.wait(3) # Introduction Pause\n \n explanation = Text(\"u(x,t): Displacement\\nc: Wave Speed\", font_size=24).next_to(equation, DOWN)\n self.play(FadeIn(explanation))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(equation), FadeOut(explanation))\n self.wait(1) # Transition Pause\n\n # 2. General Solution (d'Alembert)\n axes = Axes(x_range=[-10, 10, 1], y_range=[-2, 2, 1], x_length=10, y_length=4).shift(DOWN*0.5)\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n self.play(Create(axes), Write(labels))\n \n t = ValueTracker(0)\n c = 2\n \n wave_right = always_redraw(lambda: axes.plot(lambda x: np.exp(-(x - c * t.get_value())**2 / 2), color=BLUE))\n wave_left = always_redraw(lambda: axes.plot(lambda x: np.exp(-(x + c * t.get_value())**2 / 2), color=RED))\n \n dalembert_text = MathTex(r\"u(x,t) = f(x-ct) + g(x+ct)\").to_edge(UP)\n self.play(Write(dalembert_text))\n self.wait(2)\n \n self.add(wave_right, wave_left)\n self.play(t.animate.set_value(3), run_time=4, rate_func=linear)\n self.wait(2) # Observation Pause\n self.play(FadeOut(wave_right), FadeOut(wave_left), FadeOut(dalembert_text))\n self.wait(1) # Transition Pause\n\n # 3. Particular Solution (Standing Wave)\n standing_text = Text(\"Standing Wave Solution\", font_size=36).to_edge(UP)\n eq_standing = MathTex(r\"u(x,t) = \\sin(kx)\\cos(\\omega t)\").next_to(standing_text, DOWN)\n self.play(Write(standing_text), Write(eq_standing))\n self.wait(2)\n \n t2 = ValueTracker(0)\n standing_wave = always_redraw(lambda: axes.plot(lambda x: np.sin(x) * np.cos(t2.get_value()), color=YELLOW))\n \n self.add(standing_wave)\n self.play(t2.animate.set_value(2 * PI), run_time=6, rate_func=linear)\n \n nodes_text = Text(\"Notice the stationary Nodes\", font_size=24).to_corner(DR)\n self.play(Write(nodes_text))\n self.wait(3) # Final Observation Pause\n```"}]}
{"id": "adaption-unified-manim-instructions_008239", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSinCos", "num_animations": 12, "num_rich_primitives": 4, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00125", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0125", "num_animations": 21, "prompt": "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: How can I create a brief animation where text transforms into the word \"GrowArrow\" and shifts upwards, followed by an arrow that appears as if it's growing and then suddenly disappears?\n- Act 3: Can you create an educational math animation that visually demonstrates how to calculate the area under a parabolic curve between two points, including the display of the definite integral formula and the calculated area", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0125(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_eulerformulascene()\n self.clear_stage()\n self.act_2_growarrowanimation()\n self.clear_stage()\n self.act_3_areaunderparabola()\n\n def act_1_eulerformulascene(self):\n intro_text = Text(\"Euler's Formula:\").to_edge(UP)\n formula_1 = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\").next_to(intro_text, DOWN, buff=0.5)\n\n # Animate the introduction\n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Write(formula_1))\n self.wait(2)\n\n # --- 2. Derivation Step ---\n # Create the expanded form formula and the connecting arrow\n formula_2 = MathTex(\"\\\\cos(x)\", \"=\", \"\\\\frac{e^{ix} + e^{-ix}}{2}\").next_to(formula_1, DOWN, buff=2)\n arrow = Arrow(start=formula_1.get_bottom(), end=formula_2.get_top(), buff=0.2)\n\n # Animate the arrow and the second formula\n self.play(GrowArrow(arrow))\n self.play(Write(formula_2))\n self.wait(3)\n\n # --- 3. Transition ---\n # Group all current elements to fade them out together\n all_elements = VGroup(intro_text, formula_1, arrow, formula_2)\n self.play(FadeOut(all_elements))\n self.wait(1)\n\n # Display the transition title in yellow at the top\n trans_title = Text(\"Euler's Formula Transformation\", color=YELLOW).to_edge(UP)\n self.play(FadeIn(trans_title))\n self.wait(2)\n\n # --- 4. Conclusion ---\n # Create the final title and Euler's Identity\n final_title = Text(\"Euler's Identity\").to_edge(UP)\n identity = MathTex(\"e^{i\\\\pi}\", \"+\", \"1\", \"=\", \"0\").next_to(final_title, DOWN, buff=0.5)\n\n # Replace the yellow title with the new title and reveal the identity\n self.play(ReplacementTransform(trans_title, final_title))\n self.wait(0.5)\n self.play(Write(identity))\n self.wait(3)\n\n def act_2_growarrowanimation(self):\n initial_text = Text(\"Initializing...\", font_size=48)\n target_text = Text(\"GrowArrow\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n self.wait(0.2)\n\n # 2. Upward Shift\n # Immediately shift the transformed text upwards to make room\n self.play(target_text.animate.shift(UP * 2))\n\n # 3. Arrow Growth\n # Create an arrow and animate it growing from tail to head\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n\n # 4. Sudden Disappearance\n # Make the arrow disappear suddenly with a very short duration\n self.play(FadeOut(arrow, run_time=0.1))\n \n self.wait(1)\n\n def act_3_areaunderparabola(self):\n formula = MathTex(r\"\\text{Area} = \\int_{1}^{4} 0.1(x - 3)^2 \\, dx\", font_size=42)\n formula.to_edge(UP)\n self.play(Write(formula))\n self.wait(1)\n\n # 2. Draw Curve\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 1, 0.2],\n x_length=7,\n y_length=4.5,\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n func = lambda x: 0.1 * (x - 3)**2\n curve = axes.plot(func, color=BLUE, x_range=[0, 5])\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # 3. Highlight Area\n area = axes.get_area(curve, x_range=[1, 4], color=GREEN, opacity=0.5)\n \n # Add vertical lines for bounds clarity\n line_start = axes.get_vertical_line(axes.c2p(1, func(1)), color=WHITE, stroke_width=2)\n line_end = axes.get_vertical_line(axes.c2p(4, func(4)), color=WHITE, stroke_width=2)\n bounds_lines = VGroup(line_start, line_end)\n \n self.play(FadeIn(bounds_lines), FadeIn(area))\n self.wait(1)\n\n # 4. Show Result\n calc_steps = VGroup(\n MathTex(r\"= \\left[ \\frac{0.1(x - 3)^3}{3} \\right]_{1}^{4}\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\left( (4 - 3)^3 - (1 - 3)^3 \\right)\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\left( 1 - (-8) \\right)\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\times 9 = 0.3\", font_size=36, color=YELLOW)\n ).arrange(DOWN, aligned_edge=LEFT).scale(0.9)\n \n # Position directly below the highlighted section\n calc_steps.next_to(area, DOWN, buff=0.5).shift(RIGHT * 0.5)\n \n for step in calc_steps:\n self.play(Write(step))\n self.wait(1.5)\n \n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: How can I create a brief animation where text transforms into the word \"GrowArrow\" and shifts upwards, followed by an arrow that appears as if it's growing and then suddenly disappears?\n- Act 3: Can you create an educational math animation that visually demonstrates how to calculate the area under a parabolic curve between two points, including the display of the definite integral formula and the calculated area"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0125(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_eulerformulascene()\n self.clear_stage()\n self.act_2_growarrowanimation()\n self.clear_stage()\n self.act_3_areaunderparabola()\n\n def act_1_eulerformulascene(self):\n intro_text = Text(\"Euler's Formula:\").to_edge(UP)\n formula_1 = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\").next_to(intro_text, DOWN, buff=0.5)\n\n # Animate the introduction\n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Write(formula_1))\n self.wait(2)\n\n # --- 2. Derivation Step ---\n # Create the expanded form formula and the connecting arrow\n formula_2 = MathTex(\"\\\\cos(x)\", \"=\", \"\\\\frac{e^{ix} + e^{-ix}}{2}\").next_to(formula_1, DOWN, buff=2)\n arrow = Arrow(start=formula_1.get_bottom(), end=formula_2.get_top(), buff=0.2)\n\n # Animate the arrow and the second formula\n self.play(GrowArrow(arrow))\n self.play(Write(formula_2))\n self.wait(3)\n\n # --- 3. Transition ---\n # Group all current elements to fade them out together\n all_elements = VGroup(intro_text, formula_1, arrow, formula_2)\n self.play(FadeOut(all_elements))\n self.wait(1)\n\n # Display the transition title in yellow at the top\n trans_title = Text(\"Euler's Formula Transformation\", color=YELLOW).to_edge(UP)\n self.play(FadeIn(trans_title))\n self.wait(2)\n\n # --- 4. Conclusion ---\n # Create the final title and Euler's Identity\n final_title = Text(\"Euler's Identity\").to_edge(UP)\n identity = MathTex(\"e^{i\\\\pi}\", \"+\", \"1\", \"=\", \"0\").next_to(final_title, DOWN, buff=0.5)\n\n # Replace the yellow title with the new title and reveal the identity\n self.play(ReplacementTransform(trans_title, final_title))\n self.wait(0.5)\n self.play(Write(identity))\n self.wait(3)\n\n def act_2_growarrowanimation(self):\n initial_text = Text(\"Initializing...\", font_size=48)\n target_text = Text(\"GrowArrow\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n self.wait(0.2)\n\n # 2. Upward Shift\n # Immediately shift the transformed text upwards to make room\n self.play(target_text.animate.shift(UP * 2))\n\n # 3. Arrow Growth\n # Create an arrow and animate it growing from tail to head\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n\n # 4. Sudden Disappearance\n # Make the arrow disappear suddenly with a very short duration\n self.play(FadeOut(arrow, run_time=0.1))\n \n self.wait(1)\n\n def act_3_areaunderparabola(self):\n formula = MathTex(r\"\\text{Area} = \\int_{1}^{4} 0.1(x - 3)^2 \\, dx\", font_size=42)\n formula.to_edge(UP)\n self.play(Write(formula))\n self.wait(1)\n\n # 2. Draw Curve\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 1, 0.2],\n x_length=7,\n y_length=4.5,\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n func = lambda x: 0.1 * (x - 3)**2\n curve = axes.plot(func, color=BLUE, x_range=[0, 5])\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # 3. Highlight Area\n area = axes.get_area(curve, x_range=[1, 4], color=GREEN, opacity=0.5)\n \n # Add vertical lines for bounds clarity\n line_start = axes.get_vertical_line(axes.c2p(1, func(1)), color=WHITE, stroke_width=2)\n line_end = axes.get_vertical_line(axes.c2p(4, func(4)), color=WHITE, stroke_width=2)\n bounds_lines = VGroup(line_start, line_end)\n \n self.play(FadeIn(bounds_lines), FadeIn(area))\n self.wait(1)\n\n # 4. Show Result\n calc_steps = VGroup(\n MathTex(r\"= \\left[ \\frac{0.1(x - 3)^3}{3} \\right]_{1}^{4}\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\left( (4 - 3)^3 - (1 - 3)^3 \\right)\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\left( 1 - (-8) \\right)\", font_size=36),\n MathTex(r\"= \\frac{0.1}{3} \\times 9 = 0.3\", font_size=36, color=YELLOW)\n ).arrange(DOWN, aligned_edge=LEFT).scale(0.9)\n \n # Position directly below the highlighted section\n calc_steps.next_to(area, DOWN, buff=0.5).shift(RIGHT * 0.5)\n \n for step in calc_steps:\n self.play(Write(step))\n self.wait(1.5)\n \n self.wait(3)\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000496", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "MLPForwardPassScene", "num_animations": 4, "num_rich_primitives": 1, "prompt": "I'm teaching an undergrad ML course and want to visualize a forward pass through a 3-layer MLP where the input vector expands from 4 to 8 in the first hidden layer and then contracts to 3 at the output. Show activations propagating through each layer, with animated weight matrices and dimensionality changes clearly labeled. Include a single data packet moving through layers with a color trail and a side panel showing dimension counts. Use a few scene transitions to explain why widening then narrowing affects expressivity.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass MLPForwardPassScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: ARCHITECTURE]\n with self.voiceover(text=\"A forward pass transforms input data through successive linear projections and non-linear activations. Here, our input of dimension 4 expands to 8 hidden units, then contracts to 3 output classes.\") as tracker:\n title = Text(\"MLP Forward Pass\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n layers = VGroup(\n VGroup(*[Circle(radius=0.2, color=BLUE, fill_opacity=0.5) for _ in range(4)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.5) for _ in range(8)]).arrange(DOWN, buff=0.2),\n VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3)\n ).arrange(RIGHT, buff=1.5)\n \n dim_labels = VGroup(\n Text(\"d=4\", font_size=16).next_to(layers[0], DOWN),\n Text(\"d=8\", font_size=16).next_to(layers[1], DOWN),\n Text(\"d=3\", font_size=16).next_to(layers[2], DOWN)\n )\n \n self.wait_until_bookmark(\"ARCHITECTURE\")\n self.play(Write(title), Create(layers), Write(dim_labels), run_time=tracker.duration)\n \n with self.voiceover(text=\"Watch a single data packet flow through the network. As it passes through the weight matrices, it is projected into a higher-dimensional space, leaving a color trail that represents the activation values.\") as tracker:\n trail = TracedPath(layers[0][0].get_center, stroke_color=YELLOW, stroke_width=3)\n packet = Dot(color=YELLOW, radius=0.15).move_to(layers[0][0].get_center())\n \n self.wait_until_bookmark(\"PACKET\")\n self.add(trail, packet)\n self.play(\n packet.animate.move_to(layers[1][3].get_center()),\n run_time=tracker.duration * 0.5\n )\n self.play(\n packet.animate.move_to(layers[2][1].get_center()),\n run_time=tracker.duration * 0.5\n )\n \n with self.voiceover(text=\"Why widen then narrow? The expansion into 8 dimensions allows the network to learn complex, non-linear feature interactions. The subsequent contraction distills these rich features into the final class probabilities.\") as tracker:\n expressivity_text = VGroup(\n Text(\"Widening: Captures complex interactions\", font_size=20, color=GREEN),\n Text(\"Narrowing: Distills to class probabilities\", font_size=20, color=RED)\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(DOWN)\n \n self.wait_until_bookmark(\"EXPRESSIVITY\")\n self.play(Write(expressivity_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an undergrad ML course and want to visualize a forward pass through a 3-layer MLP where the input vector expands from 4 to 8 in the first hidden layer and then contracts to 3 at the output. Show activations propagating through each layer, with animated weight matrices and dimensionality changes clearly labeled. Include a single data packet moving through layers with a color trail and a side panel showing dimension counts. Use a few scene transitions to explain why widening then narrowing affects expressivity."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass MLPForwardPassScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: ARCHITECTURE]\n with self.voiceover(text=\"A forward pass transforms input data through successive linear projections and non-linear activations. Here, our input of dimension 4 expands to 8 hidden units, then contracts to 3 output classes.\") as tracker:\n title = Text(\"MLP Forward Pass\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n layers = VGroup(\n VGroup(*[Circle(radius=0.2, color=BLUE, fill_opacity=0.5) for _ in range(4)]).arrange(DOWN, buff=0.3),\n VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.5) for _ in range(8)]).arrange(DOWN, buff=0.2),\n VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=0.5) for _ in range(3)]).arrange(DOWN, buff=0.3)\n ).arrange(RIGHT, buff=1.5)\n \n dim_labels = VGroup(\n Text(\"d=4\", font_size=16).next_to(layers[0], DOWN),\n Text(\"d=8\", font_size=16).next_to(layers[1], DOWN),\n Text(\"d=3\", font_size=16).next_to(layers[2], DOWN)\n )\n \n self.wait_until_bookmark(\"ARCHITECTURE\")\n self.play(Write(title), Create(layers), Write(dim_labels), run_time=tracker.duration)\n \n with self.voiceover(text=\"Watch a single data packet flow through the network. As it passes through the weight matrices, it is projected into a higher-dimensional space, leaving a color trail that represents the activation values.\") as tracker:\n trail = TracedPath(layers[0][0].get_center, stroke_color=YELLOW, stroke_width=3)\n packet = Dot(color=YELLOW, radius=0.15).move_to(layers[0][0].get_center())\n \n self.wait_until_bookmark(\"PACKET\")\n self.add(trail, packet)\n self.play(\n packet.animate.move_to(layers[1][3].get_center()),\n run_time=tracker.duration * 0.5\n )\n self.play(\n packet.animate.move_to(layers[2][1].get_center()),\n run_time=tracker.duration * 0.5\n )\n \n with self.voiceover(text=\"Why widen then narrow? The expansion into 8 dimensions allows the network to learn complex, non-linear feature interactions. The subsequent contraction distills these rich features into the final class probabilities.\") as tracker:\n expressivity_text = VGroup(\n Text(\"Widening: Captures complex interactions\", font_size=20, color=GREEN),\n Text(\"Narrowing: Distills to class probabilities\", font_size=20, color=RED)\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(DOWN)\n \n self.wait_until_bookmark(\"EXPRESSIVITY\")\n self.play(Write(expressivity_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "manim-sft-10k_006567", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "QuantumMechanicsTransition", "num_animations": 11, "num_rich_primitives": 2, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_006219", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DoubleIntegralEvaluation", "num_animations": 23, "num_rich_primitives": 2, "prompt": "Could you create an animation that shows the process of evaluating the double integral of \\(e^{y^2}\\) with respect to y from 0 to x and then with respect to x from 0 to 1, including intermediate steps and relevant explanations at each step?", "code": "from manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # Color configurations\n color_original = BLUE\n color_switched = GREEN\n color_region = YELLOW\n color_highlight = YELLOW\n color_error = RED\n\n # --- 1. Introduction and the Problem ---\n title = Text(\"Evaluating a Double Integral\", font_size=40).to_edge(UP)\n \n original_integral = MathTex(\n r\"I = \\int_{0}^{1} \\int_{0}^{x} e^{y^2} \\, dy \\, dx\", font_size=42\n ).shift(UP * 1.5)\n \n problem_text = Text(\n \"Problem: \\int e^(y^2) dy has no elementary antiderivative.\", \n font_size=24, color=color_error\n ).next_to(original_integral, DOWN, buff=0.5)\n\n self.play(Write(title))\n self.play(Write(original_integral))\n self.wait(1)\n self.play(Write(problem_text))\n self.wait(2)\n self.play(FadeOut(problem_text))\n\n # --- 2. Visualizing the Region ---\n axes = Axes(\n x_range=[0, 1.2, 0.2],\n y_range=[0, 1.2, 0.2],\n x_label=MathTex(\"x\"),\n y_label=MathTex(\"y\"),\n axis_config={\"include_tip\": True}\n ).scale(2.5).shift(DOWN * 1 + LEFT * 2)\n\n # Region boundaries: y=0, x=1, y=x -> Vertices: (0,0), (1,0), (1,1)\n region_poly = Polygon(\n axes.c2p(0, 0), axes.c2p(1, 0), axes.c2p(1, 1),\n color=color_region, fill_opacity=0.3\n )\n \n region_label = MathTex(r\"0 \\le x \\le 1\", r\"0 \\le y \\le x\").scale(0.8).to_corner(UR)\n\n self.play(Create(axes), Create(region_poly), Write(region_label))\n self.wait(1)\n\n # Show Vertical Strips (dy first)\n v_strips = VGroup()\n for i in range(10):\n x_val = 0.1 + i * 0.09\n strip = Rectangle(\n width=0.04,\n height=x_val * axes.y_length / 1.2,\n stroke_width=0,\n fill_color=color_original,\n fill_opacity=0.5\n ).move_to(axes.c2p(x_val, x_val / 2))\n v_strips.add(strip)\n \n self.play(FadeIn(v_strips))\n v_strip_text = Text(\"Vertical Strips (dy dx)\", font_size=24, color=color_original).to_corner(DR)\n self.play(Write(v_strip_text))\n self.wait(1)\n self.play(FadeOut(v_strips), FadeOut(v_strip_text))\n\n # --- 3. Changing the Order of Integration ---\n switch_title = Text(\"Switching Order of Integration\", font_size=30, color=color_switched)\n self.play(Transform(title, switch_title))\n \n new_limits = MathTex(r\"0 \\le y \\le 1\", r\"y \\le x \\le 1\").scale(0.8)\n self.play(Transform(region_label, new_limits))\n \n # Show Horizontal Strips (dx first)\n h_strips = VGroup()\n for i in range(10):\n y_val = 0.1 + i * 0.09\n width = (1 - y_val) * axes.x_length / 1.2\n strip = Rectangle(\n width=width,\n height=0.04,\n stroke_width=0,\n fill_color=color_switched,\n fill_opacity=0.5\n ).move_to(axes.c2p((1 + y_val) / 2, y_val))\n h_strips.add(strip)\n \n self.play(FadeIn(h_strips))\n h_strip_text = Text(\"Horizontal Strips (dx dy)\", font_size=24, color=color_switched).to_corner(DR)\n self.play(Write(h_strip_text))\n self.wait(2)\n self.play(FadeOut(h_strips), FadeOut(h_strip_text))\n\n # --- 4. The New Integral ---\n new_integral = MathTex(\n r\"I = \\int_{0}^{1} \\int_{y}^{1} e^{y^2} \\, dx \\, dy\", font_size=42\n ).shift(UP * 1.5)\n \n self.play(Transform(original_integral, new_integral))\n self.wait(1)\n\n # --- 5. Step-by-Step Evaluation ---\n # Step A: Inner Integral\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=28).shift(UP * 0.2)\n inner_eval = MathTex(\n r\"\\int_{y}^{1} e^{y^2} \\, dx = e^{y^2} [x]_{y}^{1} = e^{y^2}(1 - y)\", font_size=36\n ).next_to(step1_text, DOWN, buff=0.5)\n\n self.play(Write(step1_text))\n self.play(Write(inner_eval))\n self.wait(2)\n\n # Step B: Outer Integral\n step2_text = Text(\"Step 2: Evaluate the outer integral\", font_size=28).next_to(inner_eval, DOWN, buff=0.5)\n outer_eval = MathTex(\n r\"I = \\int_{0}^{1} (1 - y)e^{y^2} \\, dy\", font_size=36\n ).next_to(step2_text, DOWN, buff=0.5)\n\n self.play(Write(step2_text))\n self.play(Write(outer_eval))\n self.wait(1)\n \n # Step C: Splitting the Integral\n step3_text = Text(\"Step 3: Split and solve\", font_size=28).next_to(outer_eval, DOWN, buff=0.5)\n split_eval = MathTex(\n r\"I = \\int_{0}^{1} e^{y^2} \\, dy - \\int_{0}^{1} y e^{y^2} \\, dy\", font_size=36\n ).next_to(step3_text, DOWN, buff=0.5)\n\n self.play(Write(step3_text))\n self.play(Write(split_eval))\n self.wait(2)\n\n # Explanation of Solvability\n note_text = Text(\n \"Note: \\int y*e^(y^2) dy is solvable via u-substitution.\\n\\int e^(y^2) dy requires the imaginary error function (erfi).\", \n font_size=20, color=GRAY\n ).next_to(split_eval, DOWN, buff=0.5)\n self.play(Write(note_text))\n self.wait(2)\n\n # Final Result\n final_result = MathTex(\n r\"I = \\frac{\\sqrt{\\pi}}{2} \\text{erfi}(1) - \\frac{1}{2}(e - 1)\", font_size=36, color=color_highlight\n ).next_to(note_text, DOWN, buff=0.5)\n \n self.play(Write(final_result))\n self.wait(3)\n\n # Cleanup\n self.play(*[FadeOut(mob) for mob in self.mobjects])", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an animation that shows the process of evaluating the double integral of \\(e^{y^2}\\) with respect to y from 0 to x and then with respect to x from 0 to 1, including intermediate steps and relevant explanations at each step?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # Color configurations\n color_original = BLUE\n color_switched = GREEN\n color_region = YELLOW\n color_highlight = YELLOW\n color_error = RED\n\n # --- 1. Introduction and the Problem ---\n title = Text(\"Evaluating a Double Integral\", font_size=40).to_edge(UP)\n \n original_integral = MathTex(\n r\"I = \\int_{0}^{1} \\int_{0}^{x} e^{y^2} \\, dy \\, dx\", font_size=42\n ).shift(UP * 1.5)\n \n problem_text = Text(\n \"Problem: \\int e^(y^2) dy has no elementary antiderivative.\", \n font_size=24, color=color_error\n ).next_to(original_integral, DOWN, buff=0.5)\n\n self.play(Write(title))\n self.play(Write(original_integral))\n self.wait(1)\n self.play(Write(problem_text))\n self.wait(2)\n self.play(FadeOut(problem_text))\n\n # --- 2. Visualizing the Region ---\n axes = Axes(\n x_range=[0, 1.2, 0.2],\n y_range=[0, 1.2, 0.2],\n x_label=MathTex(\"x\"),\n y_label=MathTex(\"y\"),\n axis_config={\"include_tip\": True}\n ).scale(2.5).shift(DOWN * 1 + LEFT * 2)\n\n # Region boundaries: y=0, x=1, y=x -> Vertices: (0,0), (1,0), (1,1)\n region_poly = Polygon(\n axes.c2p(0, 0), axes.c2p(1, 0), axes.c2p(1, 1),\n color=color_region, fill_opacity=0.3\n )\n \n region_label = MathTex(r\"0 \\le x \\le 1\", r\"0 \\le y \\le x\").scale(0.8).to_corner(UR)\n\n self.play(Create(axes), Create(region_poly), Write(region_label))\n self.wait(1)\n\n # Show Vertical Strips (dy first)\n v_strips = VGroup()\n for i in range(10):\n x_val = 0.1 + i * 0.09\n strip = Rectangle(\n width=0.04,\n height=x_val * axes.y_length / 1.2,\n stroke_width=0,\n fill_color=color_original,\n fill_opacity=0.5\n ).move_to(axes.c2p(x_val, x_val / 2))\n v_strips.add(strip)\n \n self.play(FadeIn(v_strips))\n v_strip_text = Text(\"Vertical Strips (dy dx)\", font_size=24, color=color_original).to_corner(DR)\n self.play(Write(v_strip_text))\n self.wait(1)\n self.play(FadeOut(v_strips), FadeOut(v_strip_text))\n\n # --- 3. Changing the Order of Integration ---\n switch_title = Text(\"Switching Order of Integration\", font_size=30, color=color_switched)\n self.play(Transform(title, switch_title))\n \n new_limits = MathTex(r\"0 \\le y \\le 1\", r\"y \\le x \\le 1\").scale(0.8)\n self.play(Transform(region_label, new_limits))\n \n # Show Horizontal Strips (dx first)\n h_strips = VGroup()\n for i in range(10):\n y_val = 0.1 + i * 0.09\n width = (1 - y_val) * axes.x_length / 1.2\n strip = Rectangle(\n width=width,\n height=0.04,\n stroke_width=0,\n fill_color=color_switched,\n fill_opacity=0.5\n ).move_to(axes.c2p((1 + y_val) / 2, y_val))\n h_strips.add(strip)\n \n self.play(FadeIn(h_strips))\n h_strip_text = Text(\"Horizontal Strips (dx dy)\", font_size=24, color=color_switched).to_corner(DR)\n self.play(Write(h_strip_text))\n self.wait(2)\n self.play(FadeOut(h_strips), FadeOut(h_strip_text))\n\n # --- 4. The New Integral ---\n new_integral = MathTex(\n r\"I = \\int_{0}^{1} \\int_{y}^{1} e^{y^2} \\, dx \\, dy\", font_size=42\n ).shift(UP * 1.5)\n \n self.play(Transform(original_integral, new_integral))\n self.wait(1)\n\n # --- 5. Step-by-Step Evaluation ---\n # Step A: Inner Integral\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=28).shift(UP * 0.2)\n inner_eval = MathTex(\n r\"\\int_{y}^{1} e^{y^2} \\, dx = e^{y^2} [x]_{y}^{1} = e^{y^2}(1 - y)\", font_size=36\n ).next_to(step1_text, DOWN, buff=0.5)\n\n self.play(Write(step1_text))\n self.play(Write(inner_eval))\n self.wait(2)\n\n # Step B: Outer Integral\n step2_text = Text(\"Step 2: Evaluate the outer integral\", font_size=28).next_to(inner_eval, DOWN, buff=0.5)\n outer_eval = MathTex(\n r\"I = \\int_{0}^{1} (1 - y)e^{y^2} \\, dy\", font_size=36\n ).next_to(step2_text, DOWN, buff=0.5)\n\n self.play(Write(step2_text))\n self.play(Write(outer_eval))\n self.wait(1)\n \n # Step C: Splitting the Integral\n step3_text = Text(\"Step 3: Split and solve\", font_size=28).next_to(outer_eval, DOWN, buff=0.5)\n split_eval = MathTex(\n r\"I = \\int_{0}^{1} e^{y^2} \\, dy - \\int_{0}^{1} y e^{y^2} \\, dy\", font_size=36\n ).next_to(step3_text, DOWN, buff=0.5)\n\n self.play(Write(step3_text))\n self.play(Write(split_eval))\n self.wait(2)\n\n # Explanation of Solvability\n note_text = Text(\n \"Note: \\int y*e^(y^2) dy is solvable via u-substitution.\\n\\int e^(y^2) dy requires the imaginary error function (erfi).\", \n font_size=20, color=GRAY\n ).next_to(split_eval, DOWN, buff=0.5)\n self.play(Write(note_text))\n self.wait(2)\n\n # Final Result\n final_result = MathTex(\n r\"I = \\frac{\\sqrt{\\pi}}{2} \\text{erfi}(1) - \\frac{1}{2}(e - 1)\", font_size=36, color=color_highlight\n ).next_to(note_text, DOWN, buff=0.5)\n \n self.play(Write(final_result))\n self.wait(3)\n\n # Cleanup\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n```"}]}
{"id": "adaption-unified-manim-instructions_002273", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolarDoubleIntegral", "num_animations": 14, "num_rich_primitives": 2, "prompt": "I would like to create an educational animation that walks through the process of evaluating a double integral in polar coordinates. Specifically, I’m interested in an animation that shows the integral of r^2 sin(theta) with respect to r and theta, where r goes from 0 to 1 and theta goes from 0 to pi. I want the animation to visually display the problem, then demonstrate step-by-step integration with respect to r first, followed by integrating with respect to theta. After each integration step, I would like the results to be displayed in mathematical notation, along with a brief text explanation of what is being done. Finally, the solution should be simplified to show the final numeric answer. Can you create such an animation?", "code": "from manim import *\n\nclass PolarDoubleIntegral(Scene):\n \"\"\"\n An educational animation demonstrating the step-by-step evaluation of a \n double integral in polar coordinates: \n \\int _0^\\pi \\int _0^1 r^2 sin(\\theta ) dr d\\theta \n \"\"\"\n def construct(self):\n # --- Configuration and Colors ---\n text_color = GRAY_A\n highlight_color = YELLOW\n math_color = WHITE\n step1_color = BLUE\n step2_color = GREEN\n\n # --- Scene Setup & Title ---\n title = Text(\"Evaluating a Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # --- Problem Visualization ---\n # Display the original double integral\n original_integral = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r^2 \\sin(\\theta)\", \n r\"\\, dr\", \n r\"\\, d\\theta\",\n color=math_color\n ).scale(1.3)\n original_integral.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(original_integral))\n self.wait(2)\n\n # --- Step 1: Inner Integral (with respect to r) ---\n step1_label = Text(\"Step 1: Integrate with respect to r\", font_size=28, color=step1_color)\n step1_label.next_to(original_integral, DOWN, buff=0.5)\n \n # Explanation for Power Rule application\n explanation1 = Text(\"Apply Power Rule: \\int r^2 dr = r^3/3\", font_size=24, color=text_color)\n explanation1.next_to(step1_label, DOWN, buff=0.3)\n \n self.play(Write(step1_label))\n self.play(Write(explanation1))\n self.wait(1)\n\n # Show intermediate result: [r^3/3 sin(theta)] evaluated from 0 to 1\n step1_intermediate = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1}\", \n r\"\\, d\\theta\"\n ).scale(1.3)\n step1_intermediate.move_to(original_integral)\n \n self.play(ReplacementTransform(original_integral, step1_intermediate))\n self.wait(2)\n\n # Show simplified outcome after evaluating r limits: 1/3 sin(theta)\n step1_simplified = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\frac{1}{3} \\sin(\\theta)\", \n r\"\\, d\\theta\"\n ).scale(1.3)\n step1_simplified.move_to(step1_intermediate)\n \n self.play(ReplacementTransform(step1_intermediate, step1_simplified))\n self.wait(1)\n \n # Clean up Step 1 text before proceeding\n self.play(FadeOut(step1_label), FadeOut(explanation1))\n\n # --- Step 2: Outer Integral (with respect to theta) ---\n step2_label = Text(\"Step 2: Integrate with respect to \\theta \", font_size=28, color=step2_color)\n step2_label.next_to(step1_simplified, DOWN, buff=0.5)\n \n # Explanation for Sine Integration\n explanation2 = Text(\"Recall: \\int sin(\\theta ) d\\theta = -cos(\\theta )\", font_size=24, color=text_color)\n explanation2.next_to(step2_label, DOWN, buff=0.3)\n \n self.play(Write(step2_label))\n self.play(Write(explanation2))\n self.wait(1)\n\n # Show antiderivative: [-1/3 cos(theta)] evaluated from 0 to pi\n step2_intermediate = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi}\"\n ).scale(1.3)\n step2_intermediate.move_to(step1_simplified)\n \n self.play(ReplacementTransform(step1_simplified, step2_intermediate))\n self.wait(2)\n\n # Show evaluation step with limits plugged in\n step2_eval = MathTex(\n r\"-\\frac{1}{3} \\left( \\cos(\\pi) - \\cos(0) \\right)\"\n ).scale(1.3)\n step2_eval.move_to(step2_intermediate)\n \n self.play(ReplacementTransform(step2_intermediate, step2_eval))\n self.wait(1)\n\n # --- Final Solution ---\n # Calculate and display final numeric answer (2/3)\n final_solution = MathTex(\n r\"-\\frac{1}{3} (-1 - 1) = \\frac{2}{3}\",\n color=highlight_color\n ).scale(1.5)\n final_solution.move_to(step2_eval)\n \n self.play(ReplacementTransform(step2_eval, final_solution))\n self.wait(1)\n\n # Create a box around the final answer for emphasis\n box = SurroundingRectangle(final_solution, color=highlight_color, buff=0.2)\n self.play(Create(box))\n \n # Cleanup and finish\n self.play(FadeOut(title), FadeOut(step2_label), FadeOut(explanation2))\n self.wait(3)\n\n# To run this animation, save the code in a file named integral_animation.py \n# and execute the following command in your terminal (assuming ManimCE is installed):\n# manim -pql integral_animation.py PolarDoubleIntegral", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that walks through the process of evaluating a double integral in polar coordinates. Specifically, I’m interested in an animation that shows the integral of r^2 sin(theta) with respect to r and theta, where r goes from 0 to 1 and theta goes from 0 to pi. I want the animation to visually display the problem, then demonstrate step-by-step integration with respect to r first, followed by integrating with respect to theta. After each integration step, I would like the results to be displayed in mathematical notation, along with a brief text explanation of what is being done. Finally, the solution should be simplified to show the final numeric answer. Can you create such an animation?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n \"\"\"\n An educational animation demonstrating the step-by-step evaluation of a \n double integral in polar coordinates: \n \\int _0^\\pi \\int _0^1 r^2 sin(\\theta ) dr d\\theta \n \"\"\"\n def construct(self):\n # --- Configuration and Colors ---\n text_color = GRAY_A\n highlight_color = YELLOW\n math_color = WHITE\n step1_color = BLUE\n step2_color = GREEN\n\n # --- Scene Setup & Title ---\n title = Text(\"Evaluating a Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # --- Problem Visualization ---\n # Display the original double integral\n original_integral = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r^2 \\sin(\\theta)\", \n r\"\\, dr\", \n r\"\\, d\\theta\",\n color=math_color\n ).scale(1.3)\n original_integral.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(original_integral))\n self.wait(2)\n\n # --- Step 1: Inner Integral (with respect to r) ---\n step1_label = Text(\"Step 1: Integrate with respect to r\", font_size=28, color=step1_color)\n step1_label.next_to(original_integral, DOWN, buff=0.5)\n \n # Explanation for Power Rule application\n explanation1 = Text(\"Apply Power Rule: \\int r^2 dr = r^3/3\", font_size=24, color=text_color)\n explanation1.next_to(step1_label, DOWN, buff=0.3)\n \n self.play(Write(step1_label))\n self.play(Write(explanation1))\n self.wait(1)\n\n # Show intermediate result: [r^3/3 sin(theta)] evaluated from 0 to 1\n step1_intermediate = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1}\", \n r\"\\, d\\theta\"\n ).scale(1.3)\n step1_intermediate.move_to(original_integral)\n \n self.play(ReplacementTransform(original_integral, step1_intermediate))\n self.wait(2)\n\n # Show simplified outcome after evaluating r limits: 1/3 sin(theta)\n step1_simplified = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\frac{1}{3} \\sin(\\theta)\", \n r\"\\, d\\theta\"\n ).scale(1.3)\n step1_simplified.move_to(step1_intermediate)\n \n self.play(ReplacementTransform(step1_intermediate, step1_simplified))\n self.wait(1)\n \n # Clean up Step 1 text before proceeding\n self.play(FadeOut(step1_label), FadeOut(explanation1))\n\n # --- Step 2: Outer Integral (with respect to theta) ---\n step2_label = Text(\"Step 2: Integrate with respect to \\theta \", font_size=28, color=step2_color)\n step2_label.next_to(step1_simplified, DOWN, buff=0.5)\n \n # Explanation for Sine Integration\n explanation2 = Text(\"Recall: \\int sin(\\theta ) d\\theta = -cos(\\theta )\", font_size=24, color=text_color)\n explanation2.next_to(step2_label, DOWN, buff=0.3)\n \n self.play(Write(step2_label))\n self.play(Write(explanation2))\n self.wait(1)\n\n # Show antiderivative: [-1/3 cos(theta)] evaluated from 0 to pi\n step2_intermediate = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi}\"\n ).scale(1.3)\n step2_intermediate.move_to(step1_simplified)\n \n self.play(ReplacementTransform(step1_simplified, step2_intermediate))\n self.wait(2)\n\n # Show evaluation step with limits plugged in\n step2_eval = MathTex(\n r\"-\\frac{1}{3} \\left( \\cos(\\pi) - \\cos(0) \\right)\"\n ).scale(1.3)\n step2_eval.move_to(step2_intermediate)\n \n self.play(ReplacementTransform(step2_intermediate, step2_eval))\n self.wait(1)\n\n # --- Final Solution ---\n # Calculate and display final numeric answer (2/3)\n final_solution = MathTex(\n r\"-\\frac{1}{3} (-1 - 1) = \\frac{2}{3}\",\n color=highlight_color\n ).scale(1.5)\n final_solution.move_to(step2_eval)\n \n self.play(ReplacementTransform(step2_eval, final_solution))\n self.wait(1)\n\n # Create a box around the final answer for emphasis\n box = SurroundingRectangle(final_solution, color=highlight_color, buff=0.2)\n self.play(Create(box))\n \n # Cleanup and finish\n self.play(FadeOut(title), FadeOut(step2_label), FadeOut(explanation2))\n self.wait(3)\n\n# To run this animation, save the code in a file named integral_animation.py \n# and execute the following command in your terminal (assuming ManimCE is installed):\n# manim -pql integral_animation.py PolarDoubleIntegral\n```"}]}
{"id": "manim-sft-10k_004443", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "HexagonTransformation", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AtomicModel", "num_animations": 5, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_002548", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurveIntegration", "num_animations": 10, "num_rich_primitives": 4, "prompt": "Can you create an animated video that explains how to calculate the area under the curve y = x^2 from x = 0 to x = 3, using the concept of integration, and visually shows the actual area under the curve, the integration process with steps, evaluation at the bounds, and conclude by highlighting that the definite integral represents the total area under the curve?", "code": "from manim import *\n\nclass AreaUnderCurveIntegration(Scene):\n def construct(self):\n # --- 1. Setup Axes and Curve ---\n # Shift axes left to make room for the math derivation on the right\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [1, 2, 3]},\n ).shift(LEFT * 3 + DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot y = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n curve_label = MathTex(r\"y = x^2\", color=BLUE).next_to(curve, UR, buff=0.2)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # --- 2. Visually Display the Area Under the Curve ---\n area = axes.get_area(curve, x_range=[0, 3], color=GREEN, opacity=0.5)\n area_label = MathTex(r\"\\text{Area} = ?\", color=WHITE).to_edge(UP).shift(RIGHT * 2)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # --- 3. Demonstrate the Integration Process Step-by-Step ---\n # Position the math derivation on the right side of the screen\n math_pos = RIGHT * 2 + UP * 1.5\n\n # Step 1: The Definite Integral\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{3} x^2 \\, dx\", font_size=40).move_to(math_pos)\n self.play(Write(step1))\n self.wait(1.5)\n\n # Step 2: The Antiderivative\n step2 = MathTex(r\"\\text{Area} = \\left[ \\frac{x^3}{3} \\right]_{0}^{3}\", font_size=40).move_to(math_pos)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1.5)\n\n # Step 3: Evaluation at the Bounds\n step3 = MathTex(r\"\\text{Area} = \\frac{3^3}{3} - \\frac{0^3}{3}\", font_size=40).move_to(math_pos)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1.5)\n\n # Step 4: Final Calculation\n step4 = MathTex(r\"\\text{Area} = \\frac{27}{3} - 0 = 9\", font_size=40, color=YELLOW).move_to(math_pos)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # --- 4. Conclude by Highlighting the Definite Integral Represents Total Area ---\n result_box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(result_box))\n\n # Update the area label with the calculated result\n final_area_label = MathTex(r\"\\text{Area} = 9\", color=YELLOW).to_edge(UP).shift(RIGHT * 2)\n self.play(Transform(area_label, final_area_label))\n\n # Visually connect the result to the shaded area\n conclusion = Text(\n \"The definite integral represents\\nthe total area under the curve.\",\n font_size=28,\n color=WHITE\n ).to_edge(DOWN)\n\n self.play(\n area.animate.set_fill(opacity=0.8),\n Indicate(area, color=GREEN),\n Write(conclusion)\n )\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animated video that explains how to calculate the area under the curve y = x^2 from x = 0 to x = 3, using the concept of integration, and visually shows the actual area under the curve, the integration process with steps, evaluation at the bounds, and conclude by highlighting that the definite integral represents the total area under the curve?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurveIntegration(Scene):\n def construct(self):\n # --- 1. Setup Axes and Curve ---\n # Shift axes left to make room for the math derivation on the right\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [1, 2, 3]},\n ).shift(LEFT * 3 + DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot y = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n curve_label = MathTex(r\"y = x^2\", color=BLUE).next_to(curve, UR, buff=0.2)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # --- 2. Visually Display the Area Under the Curve ---\n area = axes.get_area(curve, x_range=[0, 3], color=GREEN, opacity=0.5)\n area_label = MathTex(r\"\\text{Area} = ?\", color=WHITE).to_edge(UP).shift(RIGHT * 2)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # --- 3. Demonstrate the Integration Process Step-by-Step ---\n # Position the math derivation on the right side of the screen\n math_pos = RIGHT * 2 + UP * 1.5\n\n # Step 1: The Definite Integral\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{3} x^2 \\, dx\", font_size=40).move_to(math_pos)\n self.play(Write(step1))\n self.wait(1.5)\n\n # Step 2: The Antiderivative\n step2 = MathTex(r\"\\text{Area} = \\left[ \\frac{x^3}{3} \\right]_{0}^{3}\", font_size=40).move_to(math_pos)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1.5)\n\n # Step 3: Evaluation at the Bounds\n step3 = MathTex(r\"\\text{Area} = \\frac{3^3}{3} - \\frac{0^3}{3}\", font_size=40).move_to(math_pos)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1.5)\n\n # Step 4: Final Calculation\n step4 = MathTex(r\"\\text{Area} = \\frac{27}{3} - 0 = 9\", font_size=40, color=YELLOW).move_to(math_pos)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # --- 4. Conclude by Highlighting the Definite Integral Represents Total Area ---\n result_box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(result_box))\n\n # Update the area label with the calculated result\n final_area_label = MathTex(r\"\\text{Area} = 9\", color=YELLOW).to_edge(UP).shift(RIGHT * 2)\n self.play(Transform(area_label, final_area_label))\n\n # Visually connect the result to the shaded area\n conclusion = Text(\n \"The definite integral represents\\nthe total area under the curve.\",\n font_size=28,\n color=WHITE\n ).to_edge(DOWN)\n\n self.play(\n area.animate.set_fill(opacity=0.8),\n Indicate(area, color=GREEN),\n Write(conclusion)\n )\n self.wait(3)\n```"}]}
{"id": "multi_act_v2_00360", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0360", "num_animations": 18, "prompt": "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: Could you create an animated video that explains step by step how to evaluate the definite integral of the sine function from 0 to π, showing the integral problem, the integration process with the antiderivative, evaluat\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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0360(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_vectorclockproperties()\n\n def act_1_eulersformulascene(self):\n eulers_formula = MathTex(\"e^{i\\\\theta} = \\\\cos(\\\\theta) + i\\\\sin(\\\\theta)\")\n self.play(Write(eulers_formula))\n self.wait(2)\n\n # Explanation for Euler's formula\n explanation = Text(\"Euler's formula relates complex exponentials and trigonometry\", font_size=24)\n self.play(FadeIn(explanation, shift=UP))\n self.wait(2)\n\n # Transform theta into pi\n pi_transform = MathTex(\"e^{i\\\\pi} = \\\\cos(\\\\pi) + i\\\\sin(\\\\pi)\")\n self.play(TransformMatchingTex(eulers_formula, pi_transform))\n self.wait(2)\n\n # Simplify the expression\n simplified_expression = MathTex(\"e^{i\\\\pi} = -1 + 0 \\\\cdot i\")\n self.play(ReplacementTransform(pi_transform, simplified_expression))\n self.wait(2)\n\n # Show the famous identity\n identity = MathTex(\"e^{i\\\\pi} + 1 = 0\")\n self.play(ReplacementTransform(simplified_expression, identity))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"This is one of the most beautiful equations in mathematics\")\n self.play(Transform(explanation, conclusion))\n self.wait(3)\n\n # Clear the scene\n self.play(FadeOut(eulers_formula), FadeOut(explanation))\n self.wait(1)\n\n def act_2_vectorclockproperties(self):\n title = Text('Properties of Vector Clocks', 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.0), GrowFromCenter(title_line, run_time=0.8))\n core_cond_label = Text('Necessary and Sufficient Condition:', font_size=28, color=BLUE)\n core_cond = MathTex('V(a) < V(b) \\\\iff a \\\\rightarrow b', font_size=42)\n cond_group = VGroup(core_cond_label, core_cond).arrange(DOWN, buff=0.25)\n cond_group.next_to(title_group, DOWN, buff=0.5)\n self.play(FadeIn(core_cond_label), run_time=0.8)\n self.play(Write(core_cond), run_time=1.2)\n box = SurroundingRectangle(core_cond, color=ORANGE, buff=0.15)\n self.play(Create(box), run_time=0.8)\n def_label = Text('Definition of V(a) < V(b):', font_size=28, color=YELLOW)\n def_cond1 = MathTex('1.\\\\ \\\\forall k, V(a)[k] \\\\le V(b)[k]', font_size=36)\n def_cond2 = MathTex('2.\\\\ \\\\exists j, V(a)[j] < V(b)[j]', font_size=36)\n def_group = VGroup(def_label, def_cond1, def_cond2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n def_group.next_to(cond_group, DOWN, buff=0.6)\n self.play(FadeIn(def_label), run_time=0.8)\n self.play(Write(def_cond1), run_time=1.2)\n self.play(Write(def_cond2), run_time=1.2)\n conc_label = Text('Concurrent Events:', font_size=28, color=GREEN)\n conc_text = MathTex('\\\\text{If } V(a) \\\\not< V(b) \\\\text{ and } V(b) \\\\not< V(a) \\\\implies a \\\\parallel b', font_size=36)\n conc_group = VGroup(conc_label, conc_text).arrange(DOWN, buff=0.2)\n conc_group.next_to(def_group, DOWN, buff=0.6)\n self.play(FadeIn(conc_label), run_time=0.8)\n self.play(Write(conc_text), run_time=1.5)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: Could you create an animated video that explains step by step how to evaluate the definite integral of the sine function from 0 to π, showing the integral problem, the integration process with the antiderivative, evaluat\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_0360(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_vectorclockproperties()\n\n def act_1_eulersformulascene(self):\n eulers_formula = MathTex(\"e^{i\\\\theta} = \\\\cos(\\\\theta) + i\\\\sin(\\\\theta)\")\n self.play(Write(eulers_formula))\n self.wait(2)\n\n # Explanation for Euler's formula\n explanation = Text(\"Euler's formula relates complex exponentials and trigonometry\", font_size=24)\n self.play(FadeIn(explanation, shift=UP))\n self.wait(2)\n\n # Transform theta into pi\n pi_transform = MathTex(\"e^{i\\\\pi} = \\\\cos(\\\\pi) + i\\\\sin(\\\\pi)\")\n self.play(TransformMatchingTex(eulers_formula, pi_transform))\n self.wait(2)\n\n # Simplify the expression\n simplified_expression = MathTex(\"e^{i\\\\pi} = -1 + 0 \\\\cdot i\")\n self.play(ReplacementTransform(pi_transform, simplified_expression))\n self.wait(2)\n\n # Show the famous identity\n identity = MathTex(\"e^{i\\\\pi} + 1 = 0\")\n self.play(ReplacementTransform(simplified_expression, identity))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"This is one of the most beautiful equations in mathematics\")\n self.play(Transform(explanation, conclusion))\n self.wait(3)\n\n # Clear the scene\n self.play(FadeOut(eulers_formula), FadeOut(explanation))\n self.wait(1)\n\n def act_2_vectorclockproperties(self):\n title = Text('Properties of Vector Clocks', 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.0), GrowFromCenter(title_line, run_time=0.8))\n core_cond_label = Text('Necessary and Sufficient Condition:', font_size=28, color=BLUE)\n core_cond = MathTex('V(a) < V(b) \\\\iff a \\\\rightarrow b', font_size=42)\n cond_group = VGroup(core_cond_label, core_cond).arrange(DOWN, buff=0.25)\n cond_group.next_to(title_group, DOWN, buff=0.5)\n self.play(FadeIn(core_cond_label), run_time=0.8)\n self.play(Write(core_cond), run_time=1.2)\n box = SurroundingRectangle(core_cond, color=ORANGE, buff=0.15)\n self.play(Create(box), run_time=0.8)\n def_label = Text('Definition of V(a) < V(b):', font_size=28, color=YELLOW)\n def_cond1 = MathTex('1.\\\\ \\\\forall k, V(a)[k] \\\\le V(b)[k]', font_size=36)\n def_cond2 = MathTex('2.\\\\ \\\\exists j, V(a)[j] < V(b)[j]', font_size=36)\n def_group = VGroup(def_label, def_cond1, def_cond2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n def_group.next_to(cond_group, DOWN, buff=0.6)\n self.play(FadeIn(def_label), run_time=0.8)\n self.play(Write(def_cond1), run_time=1.2)\n self.play(Write(def_cond2), run_time=1.2)\n conc_label = Text('Concurrent Events:', font_size=28, color=GREEN)\n conc_text = MathTex('\\\\text{If } V(a) \\\\not< V(b) \\\\text{ and } V(b) \\\\not< V(a) \\\\implies a \\\\parallel b', font_size=36)\n conc_group = VGroup(conc_label, conc_text).arrange(DOWN, buff=0.2)\n conc_group.next_to(def_group, DOWN, buff=0.6)\n self.play(FadeIn(conc_label), run_time=0.8)\n self.play(Write(conc_text), run_time=1.5)\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_005565", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSinX", "num_animations": 13, "num_rich_primitives": 2, "prompt": "I would like an animated video that explains the process of integrating \\(\\sin(x)\\) from \\(0\\) to \\(\\pi\\), including the use of trigonometric identities and the evaluation of the definite integral, with the final answer displayed at the end. Can you create an animation that writes out the problem, provides a brief written explanation of the steps involved in solving it, shows the integration step where the trigonometric identity is used, and then evaluates the definite integral with the final solution appearing at the end? Please also make sure there is enough time for viewers to follow along with each step before moving on to the next.", "code": "from manim import *\n\nclass IntegrateSinX(Scene):\n def construct(self):\n # --- 1. Problem Statement ---\n title = Tex(\"Definite Integral of $\\\\sin(x)$\", font_size=40)\n title.to_edge(UP)\n \n problem = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\", font_size=48)\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. Step-by-Step Explanation ---\n explanation = Tex(\n \"Find the antiderivative of $\\\\sin(x)$ and apply the\",\n \"Fundamental Theorem of Calculus.\",\n font_size=30\n ).arrange(DOWN, aligned_edge=LEFT)\n explanation.next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(explanation))\n self.wait(3)\n self.play(FadeOut(explanation))\n\n # --- 3. Trigonometric Integration Rule ---\n rule_label = Tex(\"Fundamental Integration Rule:\", font_size=30)\n rule = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\", font_size=40, color=YELLOW)\n rule_group = VGroup(rule_label, rule).arrange(DOWN)\n rule_group.next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(rule_label), Write(rule))\n self.wait(3)\n\n # --- 4. Evaluation Step (Apply Limits) ---\n step1 = MathTex(\n r\"\\int_{0}^{\\pi} \\sin(x) \\, dx = \\left[ -\\cos(x) \\right]_{0}^{\\pi}\", \n font_size=40\n )\n step1.next_to(rule_group, DOWN, buff=0.5)\n\n self.play(Write(step1))\n self.wait(2)\n self.play(FadeOut(rule_group), step1.animate.next_to(problem, DOWN, buff=0.8))\n\n # --- 5. Substitute Limits ---\n step2 = MathTex(r\"= \\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\", font_size=40)\n step2.next_to(step1, DOWN, buff=0.5)\n\n self.play(Write(step2))\n self.wait(3)\n\n # --- 6. Evaluate Trigonometric Values ---\n step3 = MathTex(r\"= \\left( -(-1) \\right) - \\left( -(1) \\right)\", font_size=40)\n step3.next_to(step2, DOWN, buff=0.5)\n\n self.play(Write(step3))\n self.wait(3)\n\n # --- 7. Final Arithmetic ---\n step4 = MathTex(r\"= 1 + 1 = 2\", font_size=40, color=GREEN)\n step4.next_to(step3, DOWN, buff=0.5)\n\n self.play(Write(step4))\n self.wait(2)\n\n # --- 8. Final Solution Highlight ---\n box = SurroundingRectangle(step4, color=GREEN, buff=0.2)\n final_label = Tex(\"Final Solution\", font_size=30, color=GREEN)\n final_label.next_to(box, DOWN)\n\n self.play(Create(box), Write(final_label))\n self.wait(3)\n \n # Center the final result for emphasis\n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n FadeOut(box),\n FadeOut(final_label)\n )\n self.play(step4.animate.move_to(ORIGIN).scale(1.5))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like an animated video that explains the process of integrating \\(\\sin(x)\\) from \\(0\\) to \\(\\pi\\), including the use of trigonometric identities and the evaluation of the definite integral, with the final answer displayed at the end. Can you create an animation that writes out the problem, provides a brief written explanation of the steps involved in solving it, shows the integration step where the trigonometric identity is used, and then evaluates the definite integral with the final solution appearing at the end? Please also make sure there is enough time for viewers to follow along with each step before moving on to the next."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSinX(Scene):\n def construct(self):\n # --- 1. Problem Statement ---\n title = Tex(\"Definite Integral of $\\\\sin(x)$\", font_size=40)\n title.to_edge(UP)\n \n problem = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\", font_size=48)\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. Step-by-Step Explanation ---\n explanation = Tex(\n \"Find the antiderivative of $\\\\sin(x)$ and apply the\",\n \"Fundamental Theorem of Calculus.\",\n font_size=30\n ).arrange(DOWN, aligned_edge=LEFT)\n explanation.next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(explanation))\n self.wait(3)\n self.play(FadeOut(explanation))\n\n # --- 3. Trigonometric Integration Rule ---\n rule_label = Tex(\"Fundamental Integration Rule:\", font_size=30)\n rule = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\", font_size=40, color=YELLOW)\n rule_group = VGroup(rule_label, rule).arrange(DOWN)\n rule_group.next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(rule_label), Write(rule))\n self.wait(3)\n\n # --- 4. Evaluation Step (Apply Limits) ---\n step1 = MathTex(\n r\"\\int_{0}^{\\pi} \\sin(x) \\, dx = \\left[ -\\cos(x) \\right]_{0}^{\\pi}\", \n font_size=40\n )\n step1.next_to(rule_group, DOWN, buff=0.5)\n\n self.play(Write(step1))\n self.wait(2)\n self.play(FadeOut(rule_group), step1.animate.next_to(problem, DOWN, buff=0.8))\n\n # --- 5. Substitute Limits ---\n step2 = MathTex(r\"= \\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\", font_size=40)\n step2.next_to(step1, DOWN, buff=0.5)\n\n self.play(Write(step2))\n self.wait(3)\n\n # --- 6. Evaluate Trigonometric Values ---\n step3 = MathTex(r\"= \\left( -(-1) \\right) - \\left( -(1) \\right)\", font_size=40)\n step3.next_to(step2, DOWN, buff=0.5)\n\n self.play(Write(step3))\n self.wait(3)\n\n # --- 7. Final Arithmetic ---\n step4 = MathTex(r\"= 1 + 1 = 2\", font_size=40, color=GREEN)\n step4.next_to(step3, DOWN, buff=0.5)\n\n self.play(Write(step4))\n self.wait(2)\n\n # --- 8. Final Solution Highlight ---\n box = SurroundingRectangle(step4, color=GREEN, buff=0.2)\n final_label = Tex(\"Final Solution\", font_size=30, color=GREEN)\n final_label.next_to(box, DOWN)\n\n self.play(Create(box), Write(final_label))\n self.wait(3)\n \n # Center the final result for emphasis\n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n FadeOut(box),\n FadeOut(final_label)\n )\n self.play(step4.animate.move_to(ORIGIN).scale(1.5))\n self.wait(2)\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000612", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "LossComparisonScene", "num_animations": 3, "num_rich_primitives": 1, "prompt": "I'm teaching an undergrad ML course and want to compare Cross-Entropy Loss vs. MSE Loss. Visualize the penalty for confident wrong predictions, showing how CE skyrocket while MSE grows only quadratically.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nclass LossComparisonScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: PLOT]\n with self.voiceover(text=\"The choice of loss function dramatically affects how a model learns from its mistakes. Let's compare Cross-Entropy and Mean Squared Error as the predicted probability of the true class decreases.\") as tracker:\n title = Text(\"Cross-Entropy vs. MSE Loss\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n axes = Axes(x_range=[0.01, 1, 0.2], y_range=[0, 5, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n \n self.wait_until_bookmark(\"PLOT\")\n self.play(Write(title), Create(axes), run_time=tracker.duration)\n \n with self.voiceover(text=\"Mean Squared Error grows quadratically. While it penalizes wrong predictions, the penalty is relatively gentle, which can lead to slow learning for confident mistakes.\") as tracker:\n mse_curve = axes.plot(lambda x: (1 - x)**2, x_range=[0.01, 1], color=RED)\n mse_label = Text(\"MSE\", font_size=20, color=RED).next_to(axes.c2p(0.1, 0.81), RIGHT)\n \n self.wait_until_bookmark(\"MSE\")\n self.play(Create(mse_curve), Write(mse_label), run_time=tracker.duration)\n \n with self.voiceover(text=\"Cross-Entropy, however, grows logarithmically. As the predicted probability approaches zero, the loss skyrockets, heavily penalizing confident wrong predictions and forcing faster correction.\") as tracker:\n ce_curve = axes.plot(lambda x: -np.log(x), x_range=[0.01, 1], color=GREEN)\n ce_label = Text(\"Cross-Entropy\", font_size=20, color=GREEN).next_to(axes.c2p(0.1, 2.3), RIGHT)\n \n self.wait_until_bookmark(\"CE\")\n self.play(Create(ce_curve), Write(ce_label), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an undergrad ML course and want to compare Cross-Entropy Loss vs. MSE Loss. Visualize the penalty for confident wrong predictions, showing how CE skyrocket while MSE grows only quadratically."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nclass LossComparisonScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: PLOT]\n with self.voiceover(text=\"The choice of loss function dramatically affects how a model learns from its mistakes. Let's compare Cross-Entropy and Mean Squared Error as the predicted probability of the true class decreases.\") as tracker:\n title = Text(\"Cross-Entropy vs. MSE Loss\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n axes = Axes(x_range=[0.01, 1, 0.2], y_range=[0, 5, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n \n self.wait_until_bookmark(\"PLOT\")\n self.play(Write(title), Create(axes), run_time=tracker.duration)\n \n with self.voiceover(text=\"Mean Squared Error grows quadratically. While it penalizes wrong predictions, the penalty is relatively gentle, which can lead to slow learning for confident mistakes.\") as tracker:\n mse_curve = axes.plot(lambda x: (1 - x)**2, x_range=[0.01, 1], color=RED)\n mse_label = Text(\"MSE\", font_size=20, color=RED).next_to(axes.c2p(0.1, 0.81), RIGHT)\n \n self.wait_until_bookmark(\"MSE\")\n self.play(Create(mse_curve), Write(mse_label), run_time=tracker.duration)\n \n with self.voiceover(text=\"Cross-Entropy, however, grows logarithmically. As the predicted probability approaches zero, the loss skyrockets, heavily penalizing confident wrong predictions and forcing faster correction.\") as tracker:\n ce_curve = axes.plot(lambda x: -np.log(x), x_range=[0.01, 1], color=GREEN)\n ce_label = Text(\"Cross-Entropy\", font_size=20, color=GREEN).next_to(axes.c2p(0.1, 2.3), RIGHT)\n \n self.wait_until_bookmark(\"CE\")\n self.play(Create(ce_curve), Write(ce_label), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_001240", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 13, "num_rich_primitives": 2, "prompt": "Can you create an animated video that explains how to calculate the area under the curve for the function x squared between the values x equals 1 and x equals 3, including a step-by-step demonstration of evaluating the definite integral, and showing the final result?", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup the Axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_axis_config={\"numbers_to_include\": [1, 3]},\n y_axis_config={\"numbers_to_include\": [4, 9]},\n tips=False\n ).add_coordinates()\n\n # Label the axes\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n\n # 2. Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n func_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^2\"), x_val=3.5, direction=UR)\n func_label.set_color(BLUE)\n\n # 3. Highlight 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 # Vertical lines to bound the area visually\n line_left = axes.get_vertical_line(axes.c2p(1, 1), color=YELLOW)\n line_right = axes.get_vertical_line(axes.c2p(3, 9), color=YELLOW)\n \n # Labels for the bounds\n label_1 = MathTex(\"1\").next_to(axes.c2p(1, 0), DOWN)\n label_3 = MathTex(\"3\").next_to(axes.c2p(3, 0), DOWN)\n\n # 4. Prepare the Step-by-Step Integral Calculation\n # Step 1: The Integral Setup\n eq1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\")\n \n # Step 2: Antiderivative\n eq2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\")\n \n # Step 3: Evaluation\n eq3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Simplification\n eq4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\")\n \n # Step 5: Final Result\n eq5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\")\n\n # Group equations and align them vertically\n equations = VGroup(eq1, eq2, eq3, eq4, eq5).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # Title for the calculation\n calc_title = Text(\"Area Under the Curve\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n\n # Draw axes and plot\n self.play(Write(calc_title))\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(func_label))\n self.wait(0.5)\n\n # Highlight the integration bounds\n self.play(Create(line_left), Create(line_right))\n self.play(Write(label_1), Write(label_3))\n \n # Fill the area\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # Start the calculation explanation\n self.play(Write(eq1))\n self.wait(1)\n\n # Step through the integration steps\n self.play(Write(eq2))\n self.wait(1)\n \n self.play(Write(eq3))\n self.wait(1)\n \n self.play(Write(eq4))\n self.wait(1)\n \n self.play(Write(eq5))\n self.wait(1)\n\n # Emphasize the final result\n self.play(eq5.animate.set_color(YELLOW).scale(1.2))\n self.wait(2)\n\n # Fade out everything for a clean finish\n self.play(FadeOut(VGroup(\n calc_title, axes, x_label, y_label, curve, func_label, \n area, line_left, line_right, label_1, label_3, equations\n )))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animated video that explains how to calculate the area under the curve for the function x squared between the values x equals 1 and x equals 3, including a step-by-step demonstration of evaluating the definite integral, and showing the final result?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup the Axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_axis_config={\"numbers_to_include\": [1, 3]},\n y_axis_config={\"numbers_to_include\": [4, 9]},\n tips=False\n ).add_coordinates()\n\n # Label the axes\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n\n # 2. Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n func_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^2\"), x_val=3.5, direction=UR)\n func_label.set_color(BLUE)\n\n # 3. Highlight 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 # Vertical lines to bound the area visually\n line_left = axes.get_vertical_line(axes.c2p(1, 1), color=YELLOW)\n line_right = axes.get_vertical_line(axes.c2p(3, 9), color=YELLOW)\n \n # Labels for the bounds\n label_1 = MathTex(\"1\").next_to(axes.c2p(1, 0), DOWN)\n label_3 = MathTex(\"3\").next_to(axes.c2p(3, 0), DOWN)\n\n # 4. Prepare the Step-by-Step Integral Calculation\n # Step 1: The Integral Setup\n eq1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\")\n \n # Step 2: Antiderivative\n eq2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\")\n \n # Step 3: Evaluation\n eq3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Simplification\n eq4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\")\n \n # Step 5: Final Result\n eq5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\")\n\n # Group equations and align them vertically\n equations = VGroup(eq1, eq2, eq3, eq4, eq5).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # Title for the calculation\n calc_title = Text(\"Area Under the Curve\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n\n # Draw axes and plot\n self.play(Write(calc_title))\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(func_label))\n self.wait(0.5)\n\n # Highlight the integration bounds\n self.play(Create(line_left), Create(line_right))\n self.play(Write(label_1), Write(label_3))\n \n # Fill the area\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # Start the calculation explanation\n self.play(Write(eq1))\n self.wait(1)\n\n # Step through the integration steps\n self.play(Write(eq2))\n self.wait(1)\n \n self.play(Write(eq3))\n self.wait(1)\n \n self.play(Write(eq4))\n self.wait(1)\n \n self.play(Write(eq5))\n self.wait(1)\n\n # Emphasize the final result\n self.play(eq5.animate.set_color(YELLOW).scale(1.2))\n self.wait(2)\n\n # Fade out everything for a clean finish\n self.play(FadeOut(VGroup(\n calc_title, axes, x_label, y_label, curve, func_label, \n area, line_left, line_right, label_1, label_3, equations\n )))\n```"}]}
{"id": "adaption-unified-manim-instructions_001530", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "CircleConcepts", "num_animations": 7, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00476", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0476", "num_animations": 18, "prompt": "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: Create a 20-second Manim scene that explains a Jacobian as a local linear map. Show a point on a plane, a small input arrow, transform the formula with matching LaTeX, display a 2x2 matrix, and then show the output arrow\n- Act 2: Here is the enhanced animation instruction that maintains all original features while adding significant new elements:\n- Act 3: Here’s an enhanced version of the animation with additional features: ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0476(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_transformmatchingjacobia()\n self.clear_stage()\n self.act_2_enhanceddecagonanimation()\n self.clear_stage()\n self.act_3_enhancedshaperotation()\n\n def act_1_transformmatchingjacobia(self):\n title = Text(\"Jacobian = local linear map\", font_size=34).to_edge(UP)\n plane = NumberPlane(x_range=[-3, 3, 1], y_range=[-2, 2, 1], background_line_style={\"stroke_opacity\": 0.24}).shift(LEFT * 1.7)\n base = Dot(plane.c2p(0.8, 0.5), color=YELLOW_D)\n input_vec = Arrow(base.get_center(), base.get_center() + RIGHT * 0.9 + UP * 0.35, buff=0, color=BLUE_D)\n output_vec = Arrow(base.get_center(), base.get_center() + RIGHT * 0.55 + UP * 0.95, buff=0, color=GREEN_D)\n input_label = MathTex(r\"d\\vec{x}\", color=BLUE_D).next_to(input_vec, DOWN, buff=0.12)\n output_label = MathTex(r\"J d\\vec{x}\", color=GREEN_D).next_to(output_vec, RIGHT, buff=0.12)\n\n formula_a = MathTex(r\"f(\\vec{x}+d\\vec{x}) \\approx f(\\vec{x}) + J d\\vec{x}\", font_size=34).to_edge(DOWN)\n formula_b = MathTex(r\"d\\vec{y} = J d\\vec{x}\", font_size=38).to_edge(DOWN)\n matrix = Matrix([[\"1.2\", \"-0.4\"], [\"0.5\", \"0.9\"]]).scale(0.72).to_edge(RIGHT).shift(UP * 0.35)\n matrix_title = Text(\"local matrix\", font_size=24, color=WHITE).next_to(matrix, UP, buff=0.2)\n box = SurroundingRectangle(matrix, color=GREEN_D, buff=0.18)\n\n self.play(FadeIn(title), Create(plane), FadeIn(base), run_time=3)\n self.play(GrowArrow(input_vec), FadeIn(input_label), FadeIn(formula_a), run_time=3)\n self.play(TransformMatchingTex(formula_a, formula_b), FadeIn(matrix), FadeIn(matrix_title), run_time=3)\n self.play(Create(box), TransformFromCopy(input_vec, output_vec), FadeIn(output_label), run_time=4)\n self.play(Indicate(matrix, color=GREEN_A), Indicate(output_vec, color=GREEN_A), run_time=3)\n self.wait(2)\n\n def act_2_enhanceddecagonanimation(self):\n decagon = RegularPolygon(n=10, color=ORANGE, fill_opacity=0.8)\n decagon.scale(2)\n \n # Add decagon to scene\n self.play(Create(decagon), run_time=1.5)\n self.wait(0.5)\n \n # Create formula text\n formula = MathTex(r\"\\text{Central angle} = \\frac{360^\\circ}{10} = 36^\\circ\", color=WHITE)\n formula.to_edge(UP)\n \n # Create side length and apothem labels\n side_label = Tex(\"Side length\", color=BLUE).next_to(decagon, LEFT)\n apothem_label = Tex(\"Apothem\", color=GREEN).next_to(decagon, RIGHT)\n \n # Animate decagon moving down while showing properties\n self.play(\n decagon.animate.shift(DOWN * 1.5),\n Write(formula),\n run_time=1.5\n )\n \n # Draw radial symmetry lines\n center = decagon.get_center()\n vertices = decagon.get_vertices()\n radial_lines = VGroup()\n for vertex in vertices:\n line = Line(vertex, center, color=WHITE, stroke_width=1)\n radial_lines.add(line)\n \n # Flash measurements\n self.play(\n LaggedStart(*[Create(line) for line in radial_lines], lag_ratio=0.1),\n FadeIn(side_label, shift=UP*0.5),\n FadeIn(apothem_label, shift=UP*0.5),\n run_time=2\n )\n self.wait(0.5)\n \n # Remove measurements and lines\n self.play(\n FadeOut(radial_lines),\n FadeOut(side_label),\n FadeOut(apothem_label),\n run_time=0.5\n )\n \n # Transform decagon to circle with color change\n circle = Circle(radius=2, color=PURPLE, fill_opacity=0.8)\n circle.move_to(decagon.get_center())\n \n self.play(\n Transform(decagon, circle),\n decagon.animate.set_color(PURPLE),\n run_time=2\n )\n self.wait(1)\n\n def act_3_enhancedshaperotation(self):\n circle = Circle(color=BLUE, fill_opacity=0.5)\n triangle = Triangle(color=RED, fill_opacity=0.5)\n shapes = VGroup(circle, triangle).arrange(RIGHT, buff=1.0)\n \n # Animate shapes appearing\n self.play(FadeIn(shapes))\n self.wait(0.5)\n \n # Rotate the group\n self.play(shapes.animate.rotate(-45 * DEGREES))\n self.wait(0.5)\n \n # Transform shapes (circle -> square, triangle -> pentagon)\n square = Square(color=BLUE, fill_opacity=0.5)\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.5)\n transformed_shapes = VGroup(square, pentagon).arrange(RIGHT, buff=1.0)\n transformed_shapes.rotate(-45 * DEGREES)\n \n self.play(\n Transform(shapes[0], transformed_shapes[0]),\n Transform(shapes[1], transformed_shapes[1]),\n )\n self.wait(0.5)\n \n # Add Euler's formula and label\n formula = MathTex(\"V - E + F = 2\", color=YELLOW).scale(0.8)\n label = Text(\"Euler's Formula\", font_size=24, color=WHITE)\n formula_group = VGroup(formula, label).arrange(DOWN, buff=0.3)\n formula_group.next_to(shapes, DOWN, buff=1.0)\n \n self.play(\n FadeIn(formula, shift=UP * 0.5),\n Write(label),\n )\n self.wait(0.5)\n \n # Scale up the entire group for emphasis\n everything = VGroup(shapes, formula_group)\n self.play(everything.animate.scale(1.2))\n self.wait(1.0)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: Create a 20-second Manim scene that explains a Jacobian as a local linear map. Show a point on a plane, a small input arrow, transform the formula with matching LaTeX, display a 2x2 matrix, and then show the output arrow\n- Act 2: Here is the enhanced animation instruction that maintains all original features while adding significant new elements:\n- Act 3: Here’s an enhanced version of the animation with additional features: "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0476(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_transformmatchingjacobia()\n self.clear_stage()\n self.act_2_enhanceddecagonanimation()\n self.clear_stage()\n self.act_3_enhancedshaperotation()\n\n def act_1_transformmatchingjacobia(self):\n title = Text(\"Jacobian = local linear map\", font_size=34).to_edge(UP)\n plane = NumberPlane(x_range=[-3, 3, 1], y_range=[-2, 2, 1], background_line_style={\"stroke_opacity\": 0.24}).shift(LEFT * 1.7)\n base = Dot(plane.c2p(0.8, 0.5), color=YELLOW_D)\n input_vec = Arrow(base.get_center(), base.get_center() + RIGHT * 0.9 + UP * 0.35, buff=0, color=BLUE_D)\n output_vec = Arrow(base.get_center(), base.get_center() + RIGHT * 0.55 + UP * 0.95, buff=0, color=GREEN_D)\n input_label = MathTex(r\"d\\vec{x}\", color=BLUE_D).next_to(input_vec, DOWN, buff=0.12)\n output_label = MathTex(r\"J d\\vec{x}\", color=GREEN_D).next_to(output_vec, RIGHT, buff=0.12)\n\n formula_a = MathTex(r\"f(\\vec{x}+d\\vec{x}) \\approx f(\\vec{x}) + J d\\vec{x}\", font_size=34).to_edge(DOWN)\n formula_b = MathTex(r\"d\\vec{y} = J d\\vec{x}\", font_size=38).to_edge(DOWN)\n matrix = Matrix([[\"1.2\", \"-0.4\"], [\"0.5\", \"0.9\"]]).scale(0.72).to_edge(RIGHT).shift(UP * 0.35)\n matrix_title = Text(\"local matrix\", font_size=24, color=WHITE).next_to(matrix, UP, buff=0.2)\n box = SurroundingRectangle(matrix, color=GREEN_D, buff=0.18)\n\n self.play(FadeIn(title), Create(plane), FadeIn(base), run_time=3)\n self.play(GrowArrow(input_vec), FadeIn(input_label), FadeIn(formula_a), run_time=3)\n self.play(TransformMatchingTex(formula_a, formula_b), FadeIn(matrix), FadeIn(matrix_title), run_time=3)\n self.play(Create(box), TransformFromCopy(input_vec, output_vec), FadeIn(output_label), run_time=4)\n self.play(Indicate(matrix, color=GREEN_A), Indicate(output_vec, color=GREEN_A), run_time=3)\n self.wait(2)\n\n def act_2_enhanceddecagonanimation(self):\n decagon = RegularPolygon(n=10, color=ORANGE, fill_opacity=0.8)\n decagon.scale(2)\n \n # Add decagon to scene\n self.play(Create(decagon), run_time=1.5)\n self.wait(0.5)\n \n # Create formula text\n formula = MathTex(r\"\\text{Central angle} = \\frac{360^\\circ}{10} = 36^\\circ\", color=WHITE)\n formula.to_edge(UP)\n \n # Create side length and apothem labels\n side_label = Tex(\"Side length\", color=BLUE).next_to(decagon, LEFT)\n apothem_label = Tex(\"Apothem\", color=GREEN).next_to(decagon, RIGHT)\n \n # Animate decagon moving down while showing properties\n self.play(\n decagon.animate.shift(DOWN * 1.5),\n Write(formula),\n run_time=1.5\n )\n \n # Draw radial symmetry lines\n center = decagon.get_center()\n vertices = decagon.get_vertices()\n radial_lines = VGroup()\n for vertex in vertices:\n line = Line(vertex, center, color=WHITE, stroke_width=1)\n radial_lines.add(line)\n \n # Flash measurements\n self.play(\n LaggedStart(*[Create(line) for line in radial_lines], lag_ratio=0.1),\n FadeIn(side_label, shift=UP*0.5),\n FadeIn(apothem_label, shift=UP*0.5),\n run_time=2\n )\n self.wait(0.5)\n \n # Remove measurements and lines\n self.play(\n FadeOut(radial_lines),\n FadeOut(side_label),\n FadeOut(apothem_label),\n run_time=0.5\n )\n \n # Transform decagon to circle with color change\n circle = Circle(radius=2, color=PURPLE, fill_opacity=0.8)\n circle.move_to(decagon.get_center())\n \n self.play(\n Transform(decagon, circle),\n decagon.animate.set_color(PURPLE),\n run_time=2\n )\n self.wait(1)\n\n def act_3_enhancedshaperotation(self):\n circle = Circle(color=BLUE, fill_opacity=0.5)\n triangle = Triangle(color=RED, fill_opacity=0.5)\n shapes = VGroup(circle, triangle).arrange(RIGHT, buff=1.0)\n \n # Animate shapes appearing\n self.play(FadeIn(shapes))\n self.wait(0.5)\n \n # Rotate the group\n self.play(shapes.animate.rotate(-45 * DEGREES))\n self.wait(0.5)\n \n # Transform shapes (circle -> square, triangle -> pentagon)\n square = Square(color=BLUE, fill_opacity=0.5)\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.5)\n transformed_shapes = VGroup(square, pentagon).arrange(RIGHT, buff=1.0)\n transformed_shapes.rotate(-45 * DEGREES)\n \n self.play(\n Transform(shapes[0], transformed_shapes[0]),\n Transform(shapes[1], transformed_shapes[1]),\n )\n self.wait(0.5)\n \n # Add Euler's formula and label\n formula = MathTex(\"V - E + F = 2\", color=YELLOW).scale(0.8)\n label = Text(\"Euler's Formula\", font_size=24, color=WHITE)\n formula_group = VGroup(formula, label).arrange(DOWN, buff=0.3)\n formula_group.next_to(shapes, DOWN, buff=1.0)\n \n self.play(\n FadeIn(formula, shift=UP * 0.5),\n Write(label),\n )\n self.wait(0.5)\n \n # Scale up the entire group for emphasis\n everything = VGroup(shapes, formula_group)\n self.play(everything.animate.scale(1.2))\n self.wait(1.0)\n```"}]}
{"id": "adaption-unified-manim-instructions_005726", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PTestConvergence", "num_animations": 14, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_004757", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SimpleHarmonicMotion", "num_animations": 16, "num_rich_primitives": 2, "prompt": "Can you create an educational animation that explains the concept of simple harmonic motion using the mass-spring system? Start by displaying the differential equation that represents the motion, explain what each variable means, then show the formation of the characteristic equation from the differential equation. Afterwards, please show the characteristic roots and then present the general solution to the system. Finally, clear the scene and conclude with a text \"Visualizing Simple Harmonic Motion\" along with the general solution equation displayed once more.", "code": "from manim import *\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # --- Step 1: Introduction - Display the Differential Equation ---\n deq = MathTex(\n \"m\", \"\\\\frac{d^2x}{dt^2}\", \"+\", \"k\", \"x\", \"=\", \"0\",\n font_size=48\n )\n deq_title = Text(\"Equation of Motion\", font_size=36)\n deq_title.to_edge(UP)\n deq.next_to(deq_title, DOWN)\n\n self.play(Write(deq_title), Write(deq))\n self.wait(1)\n\n # --- Step 2: Variable Explanation ---\n label_m = MathTex(\"m\", \": \\\\text{Mass}\", font_size=30, color=BLUE)\n label_k = MathTex(\"k\", \": \\\\text{Spring Constant}\", font_size=30, color=GREEN)\n label_x = MathTex(\"x\", \": \\\\text{Displacement}\", font_size=30, color=YELLOW)\n\n # Color code variables in the main equation\n deq[0].set_color(BLUE)\n deq[3].set_color(GREEN)\n deq[4].set_color(YELLOW)\n\n # Position labels relative to the equation terms\n label_m.next_to(deq[0], DOWN, buff=0.5)\n label_k.next_to(deq[3], DOWN, buff=0.5)\n label_x.next_to(deq[4], DOWN, buff=0.5)\n\n # Add arrows for clarity\n arrow_m = Arrow(label_m.get_top(), deq[0].get_bottom(), buff=0.1, color=BLUE)\n arrow_k = Arrow(label_k.get_top(), deq[3].get_bottom(), buff=0.1, color=GREEN)\n arrow_x = Arrow(label_x.get_top(), deq[4].get_bottom(), buff=0.1, color=YELLOW)\n\n self.play(\n GrowArrow(arrow_m), FadeIn(label_m),\n GrowArrow(arrow_k), FadeIn(label_k),\n GrowArrow(arrow_x), FadeIn(label_x),\n run_time=2\n )\n self.wait(2)\n\n # Clean up labels before derivation\n self.play(\n FadeOut(label_m), FadeOut(arrow_m),\n FadeOut(label_k), FadeOut(arrow_k),\n FadeOut(label_x), FadeOut(arrow_x),\n run_time=1\n )\n\n # --- Step 3: Derivation - Characteristic Equation ---\n # Assume solution form\n derivation_text = Text(\"Assume solution: x(t) = e^{rt}\", font_size=28)\n derivation_text.to_edge(UP)\n self.play(FadeOut(deq_title), Write(derivation_text))\n self.wait(1)\n\n # Show substitution step\n substituted_eq = MathTex(\n \"m\", \"(r^2 e^{rt})\", \"+\", \"k\", \"(e^{rt})\", \"=\", \"0\",\n font_size=48\n )\n substituted_eq.move_to(deq.get_center())\n self.play(FadeOut(deq), Write(substituted_eq))\n self.wait(1)\n\n # Factor out e^rt\n factored_eq = MathTex(\n \"e^{rt}\", \"(\", \"m\", \"r^2\", \"+\", \"k\", \")\", \"=\", \"0\",\n font_size=48\n )\n factored_eq.move_to(substituted_eq.get_center())\n self.play(FadeOut(substituted_eq), Write(factored_eq))\n self.wait(1)\n\n # Characteristic Equation\n char_eq = MathTex(\n \"m\", \"r^2\", \"+\", \"k\", \"=\", \"0\",\n font_size=48\n )\n char_eq.move_to(factored_eq.get_center())\n self.play(FadeOut(factored_eq), Write(char_eq))\n \n char_label = Text(\"Characteristic Equation\", font_size=30)\n char_label.next_to(char_eq, DOWN, buff=0.5)\n self.play(Write(char_label))\n self.wait(2)\n\n # --- Step 4: Roots Calculation ---\n self.play(FadeOut(derivation_text), FadeOut(char_label))\n char_eq.shift(UP * 1.5)\n\n roots_step1 = MathTex(\n \"r^2\", \"=\", \"-\\\\frac{k}{m}\",\n font_size=42\n )\n roots_step1.next_to(char_eq, DOWN, buff=0.8)\n self.play(Write(roots_step1))\n self.wait(1)\n\n roots_final = MathTex(\n \"r\", \"=\", \"\\\\pm\", \"i\", \"\\\\sqrt{\\\\frac{k}{m}}\",\n font_size=42\n )\n roots_final.next_to(roots_step1, DOWN, buff=0.5)\n self.play(Write(roots_final))\n self.wait(1)\n\n # Define Omega for simplification\n omega_def = MathTex(\n \"\\\\omega\", \"=\", \"\\\\sqrt{\\\\frac{k}{m}}\",\n font_size=36,\n color=ORANGE\n )\n omega_def.next_to(roots_final, DOWN, buff=0.8)\n self.play(Write(omega_def))\n self.wait(2)\n\n # --- Step 5: General Solution ---\n self.play(\n FadeOut(char_eq), FadeOut(roots_step1), FadeOut(roots_final), FadeOut(omega_def)\n )\n \n sol_title = Text(\"General Solution\", font_size=36, color=ORANGE)\n sol_title.to_edge(UP)\n\n general_sol = MathTex(\n \"x(t)\", \"=\", \"A\", \"\\\\cos(\", \"\\\\omega\", \"t\", \")\", \"+\", \"B\", \"\\\\sin(\", \"\\\\omega\", \"t\", \")\",\n font_size=48\n )\n general_sol.next_to(sol_title, DOWN, buff=1)\n\n box = SurroundingRectangle(general_sol, color=BLUE, buff=0.2)\n\n self.play(Write(sol_title), Write(general_sol), Create(box))\n self.wait(3)\n\n # --- Step 6: Conclusion ---\n # Clear everything\n self.play(FadeOut(self.mobjects), run_time=1)\n self.wait(1)\n\n # Display Title and Final Equation\n final_title = Text(\"Visualizing Simple Harmonic Motion\", font_size=48, color=BLUE)\n final_title.to_edge(UP)\n \n final_eq = MathTex(\n \"x(t)\", \"=\", \"A\", \"\\\\cos(\", \"\\\\omega\", \"t\", \")\", \"+\", \"B\", \"\\\\sin(\", \"\\\\omega\", \"t\", \")\",\n font_size=50\n )\n final_eq.next_to(final_title, DOWN, buff=1.5)\n\n self.play(Write(final_title), Write(final_eq))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that explains the concept of simple harmonic motion using the mass-spring system? Start by displaying the differential equation that represents the motion, explain what each variable means, then show the formation of the characteristic equation from the differential equation. Afterwards, please show the characteristic roots and then present the general solution to the system. Finally, clear the scene and conclude with a text \"Visualizing Simple Harmonic Motion\" along with the general solution equation displayed once more."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # --- Step 1: Introduction - Display the Differential Equation ---\n deq = MathTex(\n \"m\", \"\\\\frac{d^2x}{dt^2}\", \"+\", \"k\", \"x\", \"=\", \"0\",\n font_size=48\n )\n deq_title = Text(\"Equation of Motion\", font_size=36)\n deq_title.to_edge(UP)\n deq.next_to(deq_title, DOWN)\n\n self.play(Write(deq_title), Write(deq))\n self.wait(1)\n\n # --- Step 2: Variable Explanation ---\n label_m = MathTex(\"m\", \": \\\\text{Mass}\", font_size=30, color=BLUE)\n label_k = MathTex(\"k\", \": \\\\text{Spring Constant}\", font_size=30, color=GREEN)\n label_x = MathTex(\"x\", \": \\\\text{Displacement}\", font_size=30, color=YELLOW)\n\n # Color code variables in the main equation\n deq[0].set_color(BLUE)\n deq[3].set_color(GREEN)\n deq[4].set_color(YELLOW)\n\n # Position labels relative to the equation terms\n label_m.next_to(deq[0], DOWN, buff=0.5)\n label_k.next_to(deq[3], DOWN, buff=0.5)\n label_x.next_to(deq[4], DOWN, buff=0.5)\n\n # Add arrows for clarity\n arrow_m = Arrow(label_m.get_top(), deq[0].get_bottom(), buff=0.1, color=BLUE)\n arrow_k = Arrow(label_k.get_top(), deq[3].get_bottom(), buff=0.1, color=GREEN)\n arrow_x = Arrow(label_x.get_top(), deq[4].get_bottom(), buff=0.1, color=YELLOW)\n\n self.play(\n GrowArrow(arrow_m), FadeIn(label_m),\n GrowArrow(arrow_k), FadeIn(label_k),\n GrowArrow(arrow_x), FadeIn(label_x),\n run_time=2\n )\n self.wait(2)\n\n # Clean up labels before derivation\n self.play(\n FadeOut(label_m), FadeOut(arrow_m),\n FadeOut(label_k), FadeOut(arrow_k),\n FadeOut(label_x), FadeOut(arrow_x),\n run_time=1\n )\n\n # --- Step 3: Derivation - Characteristic Equation ---\n # Assume solution form\n derivation_text = Text(\"Assume solution: x(t) = e^{rt}\", font_size=28)\n derivation_text.to_edge(UP)\n self.play(FadeOut(deq_title), Write(derivation_text))\n self.wait(1)\n\n # Show substitution step\n substituted_eq = MathTex(\n \"m\", \"(r^2 e^{rt})\", \"+\", \"k\", \"(e^{rt})\", \"=\", \"0\",\n font_size=48\n )\n substituted_eq.move_to(deq.get_center())\n self.play(FadeOut(deq), Write(substituted_eq))\n self.wait(1)\n\n # Factor out e^rt\n factored_eq = MathTex(\n \"e^{rt}\", \"(\", \"m\", \"r^2\", \"+\", \"k\", \")\", \"=\", \"0\",\n font_size=48\n )\n factored_eq.move_to(substituted_eq.get_center())\n self.play(FadeOut(substituted_eq), Write(factored_eq))\n self.wait(1)\n\n # Characteristic Equation\n char_eq = MathTex(\n \"m\", \"r^2\", \"+\", \"k\", \"=\", \"0\",\n font_size=48\n )\n char_eq.move_to(factored_eq.get_center())\n self.play(FadeOut(factored_eq), Write(char_eq))\n \n char_label = Text(\"Characteristic Equation\", font_size=30)\n char_label.next_to(char_eq, DOWN, buff=0.5)\n self.play(Write(char_label))\n self.wait(2)\n\n # --- Step 4: Roots Calculation ---\n self.play(FadeOut(derivation_text), FadeOut(char_label))\n char_eq.shift(UP * 1.5)\n\n roots_step1 = MathTex(\n \"r^2\", \"=\", \"-\\\\frac{k}{m}\",\n font_size=42\n )\n roots_step1.next_to(char_eq, DOWN, buff=0.8)\n self.play(Write(roots_step1))\n self.wait(1)\n\n roots_final = MathTex(\n \"r\", \"=\", \"\\\\pm\", \"i\", \"\\\\sqrt{\\\\frac{k}{m}}\",\n font_size=42\n )\n roots_final.next_to(roots_step1, DOWN, buff=0.5)\n self.play(Write(roots_final))\n self.wait(1)\n\n # Define Omega for simplification\n omega_def = MathTex(\n \"\\\\omega\", \"=\", \"\\\\sqrt{\\\\frac{k}{m}}\",\n font_size=36,\n color=ORANGE\n )\n omega_def.next_to(roots_final, DOWN, buff=0.8)\n self.play(Write(omega_def))\n self.wait(2)\n\n # --- Step 5: General Solution ---\n self.play(\n FadeOut(char_eq), FadeOut(roots_step1), FadeOut(roots_final), FadeOut(omega_def)\n )\n \n sol_title = Text(\"General Solution\", font_size=36, color=ORANGE)\n sol_title.to_edge(UP)\n\n general_sol = MathTex(\n \"x(t)\", \"=\", \"A\", \"\\\\cos(\", \"\\\\omega\", \"t\", \")\", \"+\", \"B\", \"\\\\sin(\", \"\\\\omega\", \"t\", \")\",\n font_size=48\n )\n general_sol.next_to(sol_title, DOWN, buff=1)\n\n box = SurroundingRectangle(general_sol, color=BLUE, buff=0.2)\n\n self.play(Write(sol_title), Write(general_sol), Create(box))\n self.wait(3)\n\n # --- Step 6: Conclusion ---\n # Clear everything\n self.play(FadeOut(self.mobjects), run_time=1)\n self.wait(1)\n\n # Display Title and Final Equation\n final_title = Text(\"Visualizing Simple Harmonic Motion\", font_size=48, color=BLUE)\n final_title.to_edge(UP)\n \n final_eq = MathTex(\n \"x(t)\", \"=\", \"A\", \"\\\\cos(\", \"\\\\omega\", \"t\", \")\", \"+\", \"B\", \"\\\\sin(\", \"\\\\omega\", \"t\", \")\",\n font_size=50\n )\n final_eq.next_to(final_title, DOWN, buff=1.5)\n\n self.play(Write(final_title), Write(final_eq))\n self.wait(3)\n```"}]}
{"id": "manim-sft-10k_006064", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "EnhancedCollisionScene", "num_animations": 8, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_000691", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "FruitDataVisualization", "num_animations": 5, "num_rich_primitives": 3, "prompt": "I would like an animated video that features a table with names and favorite fruits, which transitions into a colorful bar graph representing the count of people who favor each fruit. Can the table have black borders and black text with names like Pablo, Gabriela, Bianca, Murilo, Heitor, and Isabela paired with fruits such as Banana, Strawberry (Morango), and Orange (Laranja)? After the table appears, I want each fruit to be highlighted one by one in the table, with corresponding bars in a bar chart animating to show the quantity of people who prefer that fruit. The colors of the bars should be light yellow for bananas, light orange for oranges, and light red for strawberries. Also, include labels on both axes of the chart to indicate the type of fruit and the number of people. After completing the graph animation, all elements should fade out, leaving a blank screen. The background color throughout should be a soft cream, and please ensure the video format is suitable for a portrait orientation on mobile devices.", "code": "from manim import *\n\n# Configure Manim for Portrait Mode (Mobile Aspect Ratio 9:16)\n# and set the background color to Soft Cream\nconfig.frame_width = 9\nconfig.frame_height = 16\nconfig.background_color = \"#FFFDD0\"\n\nclass FruitDataVisualization(Scene):\n def construct(self):\n # --- 1. Data Content ---\n data_rows = [\n [\"Pablo\", \"Banana\"],\n [\"Gabriela\", \"Strawberry (Morango)\"],\n [\"Bianca\", \"Orange (Laranja)\"],\n [\"Murilo\", \"Banana\"],\n [\"Heitor\", \"Strawberry (Morango)\"],\n [\"Isabela\", \"Orange (Laranja)\"]\n ]\n \n headers = [\"Names\", \"Favorite Fruits\"]\n full_table_data = [headers] + data_rows\n\n # Chart Data Configuration\n chart_values = [2, 2, 2]\n chart_labels = [\"Banana\", \"Strawberry (Morango)\", \"Orange (Laranja)\"]\n chart_colors = [\"#FFF9C4\", \"#FFB6C1\", \"#FFCC80\"] # Light Yellow, Light Red, Light Orange\n\n # --- 2. Visual Style & Formatting ---\n \n # Table Style: Black borders and black text\n table = Table(\n full_table_data,\n include_outer_lines=True,\n line_config={\"color\": BLACK, \"stroke_width\": 2},\n element_config={\"color\": BLACK}\n )\n # Scale to fit top half of portrait screen\n table.scale(0.5)\n table.to_edge(UP, buff=1.5)\n\n # Bar Chart Style\n chart = BarChart(\n values=chart_values,\n bar_names=chart_labels,\n y_range=[0, 3, 1],\n bar_width=0.6,\n bar_colors=chart_colors,\n y_axis_config={\"color\": BLACK, \"numbers_config\": {\"color\": BLACK}},\n x_axis_config={\"color\": BLACK},\n )\n chart.scale(0.45)\n chart.next_to(table, DOWN, buff=1.5)\n\n # Add Axis Labels\n y_label = Text(\"Number of People\", color=BLACK, font_size=18)\n y_label.rotate(PI / 2)\n y_label.next_to(chart.get_y_axis(), LEFT, buff=0.3)\n y_label.shift(UP * 0.5) # Center vertically relative to axis\n \n x_label = Text(\"Fruit Type\", color=BLACK, font_size=18)\n x_label.next_to(chart.get_x_axis(), DOWN, buff=0.5)\n\n # Prepare Bars for Animation (Start with 0 height to animate growth)\n bars = chart.bars\n original_heights = [bar.get_height() for bar in bars]\n for bar in bars:\n bar.set_height(0, stretch=True)\n bar.align_to(chart.get_x_axis(), DOWN)\n \n # --- 3. Animation Sequence ---\n\n # Step 1: Intro - Display the full table\n self.play(Create(table))\n self.wait(1)\n\n # Step 2: Highlight & Build\n # Map fruit names to table row indices (Table rows include header at index 0)\n fruit_map = {\n \"Banana\": [1, 4], # Pablo, Murilo\n \"Strawberry (Morango)\": [2, 5], # Gabriela, Heitor\n \"Orange (Laranja)\": [3, 6] # Bianca, Isabela\n }\n\n # Add chart structure first\n self.play(Create(chart.get_axes()), Write(chart.x_labels), Write(y_label), Write(x_label))\n self.add(bars)\n\n for i, fruit_name in enumerate(chart_labels):\n # Highlight corresponding rows in the table\n indices = fruit_map[fruit_name]\n highlights = VGroup()\n for idx in indices:\n row = table.get_rows()[idx]\n # Create highlight rectangle\n rect = SurroundingRectangle(row, color=BLACK, fill_opacity=0.2, buff=0.05)\n highlights.add(rect)\n \n # Animate Highlight and Bar Growth simultaneously\n self.play(\n Create(highlights),\n bars[i].animate.set_height(original_heights[i], stretch=True).align_to(chart.get_x_axis(), DOWN),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Remove highlight before next iteration\n self.play(FadeOut(highlights))\n\n # Pause to show final chart state\n self.wait(1)\n\n # Step 4: Outro - Fade out all elements until the screen is blank\n all_elements = VGroup(table, chart, y_label, x_label)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait(0.5)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like an animated video that features a table with names and favorite fruits, which transitions into a colorful bar graph representing the count of people who favor each fruit. Can the table have black borders and black text with names like Pablo, Gabriela, Bianca, Murilo, Heitor, and Isabela paired with fruits such as Banana, Strawberry (Morango), and Orange (Laranja)? After the table appears, I want each fruit to be highlighted one by one in the table, with corresponding bars in a bar chart animating to show the quantity of people who prefer that fruit. The colors of the bars should be light yellow for bananas, light orange for oranges, and light red for strawberries. Also, include labels on both axes of the chart to indicate the type of fruit and the number of people. After completing the graph animation, all elements should fade out, leaving a blank screen. The background color throughout should be a soft cream, and please ensure the video format is suitable for a portrait orientation on mobile devices."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\n# Configure Manim for Portrait Mode (Mobile Aspect Ratio 9:16)\n# and set the background color to Soft Cream\nconfig.frame_width = 9\nconfig.frame_height = 16\nconfig.background_color = \"#FFFDD0\"\n\nclass FruitDataVisualization(Scene):\n def construct(self):\n # --- 1. Data Content ---\n data_rows = [\n [\"Pablo\", \"Banana\"],\n [\"Gabriela\", \"Strawberry (Morango)\"],\n [\"Bianca\", \"Orange (Laranja)\"],\n [\"Murilo\", \"Banana\"],\n [\"Heitor\", \"Strawberry (Morango)\"],\n [\"Isabela\", \"Orange (Laranja)\"]\n ]\n \n headers = [\"Names\", \"Favorite Fruits\"]\n full_table_data = [headers] + data_rows\n\n # Chart Data Configuration\n chart_values = [2, 2, 2]\n chart_labels = [\"Banana\", \"Strawberry (Morango)\", \"Orange (Laranja)\"]\n chart_colors = [\"#FFF9C4\", \"#FFB6C1\", \"#FFCC80\"] # Light Yellow, Light Red, Light Orange\n\n # --- 2. Visual Style & Formatting ---\n \n # Table Style: Black borders and black text\n table = Table(\n full_table_data,\n include_outer_lines=True,\n line_config={\"color\": BLACK, \"stroke_width\": 2},\n element_config={\"color\": BLACK}\n )\n # Scale to fit top half of portrait screen\n table.scale(0.5)\n table.to_edge(UP, buff=1.5)\n\n # Bar Chart Style\n chart = BarChart(\n values=chart_values,\n bar_names=chart_labels,\n y_range=[0, 3, 1],\n bar_width=0.6,\n bar_colors=chart_colors,\n y_axis_config={\"color\": BLACK, \"numbers_config\": {\"color\": BLACK}},\n x_axis_config={\"color\": BLACK},\n )\n chart.scale(0.45)\n chart.next_to(table, DOWN, buff=1.5)\n\n # Add Axis Labels\n y_label = Text(\"Number of People\", color=BLACK, font_size=18)\n y_label.rotate(PI / 2)\n y_label.next_to(chart.get_y_axis(), LEFT, buff=0.3)\n y_label.shift(UP * 0.5) # Center vertically relative to axis\n \n x_label = Text(\"Fruit Type\", color=BLACK, font_size=18)\n x_label.next_to(chart.get_x_axis(), DOWN, buff=0.5)\n\n # Prepare Bars for Animation (Start with 0 height to animate growth)\n bars = chart.bars\n original_heights = [bar.get_height() for bar in bars]\n for bar in bars:\n bar.set_height(0, stretch=True)\n bar.align_to(chart.get_x_axis(), DOWN)\n \n # --- 3. Animation Sequence ---\n\n # Step 1: Intro - Display the full table\n self.play(Create(table))\n self.wait(1)\n\n # Step 2: Highlight & Build\n # Map fruit names to table row indices (Table rows include header at index 0)\n fruit_map = {\n \"Banana\": [1, 4], # Pablo, Murilo\n \"Strawberry (Morango)\": [2, 5], # Gabriela, Heitor\n \"Orange (Laranja)\": [3, 6] # Bianca, Isabela\n }\n\n # Add chart structure first\n self.play(Create(chart.get_axes()), Write(chart.x_labels), Write(y_label), Write(x_label))\n self.add(bars)\n\n for i, fruit_name in enumerate(chart_labels):\n # Highlight corresponding rows in the table\n indices = fruit_map[fruit_name]\n highlights = VGroup()\n for idx in indices:\n row = table.get_rows()[idx]\n # Create highlight rectangle\n rect = SurroundingRectangle(row, color=BLACK, fill_opacity=0.2, buff=0.05)\n highlights.add(rect)\n \n # Animate Highlight and Bar Growth simultaneously\n self.play(\n Create(highlights),\n bars[i].animate.set_height(original_heights[i], stretch=True).align_to(chart.get_x_axis(), DOWN),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Remove highlight before next iteration\n self.play(FadeOut(highlights))\n\n # Pause to show final chart state\n self.wait(1)\n\n # Step 4: Outro - Fade out all elements until the screen is blank\n all_elements = VGroup(table, chart, y_label, x_label)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait(0.5)\n```"}]}
{"id": "adaption-unified-manim-instructions_006643", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ChemistryTransformations", "num_animations": 8, "num_rich_primitives": 4, "prompt": "I want to create an educational animation using Manim which visualizes different chemical elements and compounds. Could you illustrate the following sequence?\n\n1. Start with five individual chemical entities: denote an electron, an oxygen atom, a metallic atom, a positive ion, and a negative ion.\n2. Arrange these entities in a horizontal line with equal spacing.\n3. Sequentially fade each entity into visibility with a short delay between each one appearing.\n4. After they all appear, transform this line of elements into a 3 by 3 grid that represents a metal oxide compound.\n5. Then, change this grid into a layer of carbon atoms.\n6. Additionally, I want to showcase an electron taking a complex path through these elements. Have the electron move in a zigzag path, starting from the left off-screen, making two stops on its journey, and finally exiting to the right off-screen.\n7. This all should be paced well, with pauses in between major transformations to give viewers a moment to understand each step of the animation.\n\nCan this animation be done in such a way that holds attention and is informative for my chemistry students?", "code": "from manim import *\n\nclass ChemistryTransformations(Scene):\n def construct(self):\n # --- 1. Initial Entities ---\n # Helper to create labeled circles for educational clarity\n def create_entity(radius, color, label, label_color=WHITE, stroke_color=WHITE):\n circle = Circle(radius=radius, color=color, fill_opacity=0.8, stroke_width=2, stroke_color=stroke_color)\n text = Tex(label, color=label_color).scale(0.8).move_to(circle.get_center())\n return VGroup(circle, text)\n\n electron = create_entity(0.2, YELLOW, \"e^-\", label_color=BLACK)\n oxygen_atom = create_entity(0.4, RED, \"O\")\n metal_atom = create_entity(0.4, GREY_B, \"M\", label_color=BLACK)\n positive_ion = create_entity(0.4, BLUE, \"M^+\")\n negative_ion = create_entity(0.4, RED, \"O^{2-}\")\n\n initial_entities = VGroup(electron, oxygen_atom, metal_atom, positive_ion, negative_ion)\n\n # --- 2. Initial Layout ---\n # Arrange in a horizontal line with equal spacing\n initial_entities.arrange(RIGHT, buff=1.0)\n initial_entities.move_to(UP * 1.5)\n\n # --- 3. Entrance Animation ---\n # Sequentially fade in with short delays between each\n self.play(LaggedStart(*[FadeIn(entity) for entity in initial_entities], lag_ratio=0.4))\n self.wait(1.5)\n\n # --- 4. First Transformation: Line to 3x3 Grid (Metal Oxide) ---\n # Create a 3x3 grid representing an ionic lattice compound\n grid_entities = VGroup()\n # Alternating M+ and O2- pattern\n grid_styles = [\n (\"M^+\", BLUE), (\"O^{2-}\", RED), (\"M^+\", BLUE),\n (\"O^{2-}\", RED), (\"M^+\", BLUE), (\"O^{2-}\", RED),\n (\"M^+\", BLUE), (\"O^{2-}\", RED), (\"M^+\", BLUE)\n ]\n \n for label, color in grid_styles:\n atom = create_entity(0.35, color, label)\n grid_entities.add(atom)\n\n grid_entities.arrange_in_grid(rows=3, cols=3, buff=0.4)\n grid_entities.move_to(UP * 1.5)\n\n # Transform the 5 existing entities into the first 5 grid positions\n # and fade in the remaining 4\n transforms = [ReplacementTransform(initial_entities[i], grid_entities[i]) for i in range(5)]\n fades = [FadeIn(grid_entities[i], shift=UP * 0.2) for i in range(5, 9)]\n\n self.play(*transforms, *fades, run_time=2, rate_func=smooth)\n self.wait(2) # Deliberate pause for processing\n\n # --- 5. Second Transformation: Metal Oxide to Carbon Layer ---\n carbon_layer = VGroup()\n for _ in range(9):\n # Dark grey circle with white stroke and label to represent Carbon\n c_atom = create_entity(0.35, DARK_GREY, \"C\", stroke_color=WHITE)\n carbon_layer.add(c_atom)\n\n carbon_layer.arrange_in_grid(rows=3, cols=3, buff=0.4)\n carbon_layer.move_to(UP * 1.5)\n\n self.play(ReplacementTransform(grid_entities, carbon_layer), run_time=2, rate_func=smooth)\n self.wait(2) # Deliberate pause for processing\n\n # --- 6. Electron Trajectory ---\n # Create a small moving electron\n moving_electron = create_entity(0.15, YELLOW, \"e^-\", label_color=BLACK)\n \n # Define a complex zigzag path: Start off-screen left, two stops, exit off-screen right\n start_point = LEFT * 8 + UP * 2\n stop_1 = LEFT * 3 + DOWN * 1\n stop_2 = RIGHT * 3 + UP * 1\n end_point = RIGHT * 8 + DOWN * 2\n\n # Create the visible dashed path trajectory\n trajectory = VMobject().set_points_as_corners([start_point, stop_1, stop_2, end_point])\n trajectory.set_stroke(YELLOW, width=3, opacity=0.5)\n trajectory.set_dash_pattern((0.15, 0.15))\n\n moving_electron.move_to(start_point)\n\n # Animate path creation and electron movement in segments to allow for distinct stops\n self.play(Create(trajectory), run_time=1)\n \n # Segment 1: Start to Stop 1\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([start_point, stop_1])),\n run_time=1.5, rate_func=linear\n )\n self.wait(0.5) # First distinct stop\n\n # Segment 2: Stop 1 to Stop 2\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([stop_1, stop_2])),\n run_time=1.5, rate_func=linear\n )\n self.wait(0.5) # Second distinct stop\n\n # Segment 3: Stop 2 to Exit off-screen right\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([stop_2, end_point])),\n run_time=1.5, rate_func=linear\n )\n\n # --- 7. Final Pacing ---\n self.wait(2)\n self.play(FadeOut(moving_electron), FadeOut(trajectory), FadeOut(carbon_layer))\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I want to create an educational animation using Manim which visualizes different chemical elements and compounds. Could you illustrate the following sequence?\n\n1. Start with five individual chemical entities: denote an electron, an oxygen atom, a metallic atom, a positive ion, and a negative ion.\n2. Arrange these entities in a horizontal line with equal spacing.\n3. Sequentially fade each entity into visibility with a short delay between each one appearing.\n4. After they all appear, transform this line of elements into a 3 by 3 grid that represents a metal oxide compound.\n5. Then, change this grid into a layer of carbon atoms.\n6. Additionally, I want to showcase an electron taking a complex path through these elements. Have the electron move in a zigzag path, starting from the left off-screen, making two stops on its journey, and finally exiting to the right off-screen.\n7. This all should be paced well, with pauses in between major transformations to give viewers a moment to understand each step of the animation.\n\nCan this animation be done in such a way that holds attention and is informative for my chemistry students?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass ChemistryTransformations(Scene):\n def construct(self):\n # --- 1. Initial Entities ---\n # Helper to create labeled circles for educational clarity\n def create_entity(radius, color, label, label_color=WHITE, stroke_color=WHITE):\n circle = Circle(radius=radius, color=color, fill_opacity=0.8, stroke_width=2, stroke_color=stroke_color)\n text = Tex(label, color=label_color).scale(0.8).move_to(circle.get_center())\n return VGroup(circle, text)\n\n electron = create_entity(0.2, YELLOW, \"e^-\", label_color=BLACK)\n oxygen_atom = create_entity(0.4, RED, \"O\")\n metal_atom = create_entity(0.4, GREY_B, \"M\", label_color=BLACK)\n positive_ion = create_entity(0.4, BLUE, \"M^+\")\n negative_ion = create_entity(0.4, RED, \"O^{2-}\")\n\n initial_entities = VGroup(electron, oxygen_atom, metal_atom, positive_ion, negative_ion)\n\n # --- 2. Initial Layout ---\n # Arrange in a horizontal line with equal spacing\n initial_entities.arrange(RIGHT, buff=1.0)\n initial_entities.move_to(UP * 1.5)\n\n # --- 3. Entrance Animation ---\n # Sequentially fade in with short delays between each\n self.play(LaggedStart(*[FadeIn(entity) for entity in initial_entities], lag_ratio=0.4))\n self.wait(1.5)\n\n # --- 4. First Transformation: Line to 3x3 Grid (Metal Oxide) ---\n # Create a 3x3 grid representing an ionic lattice compound\n grid_entities = VGroup()\n # Alternating M+ and O2- pattern\n grid_styles = [\n (\"M^+\", BLUE), (\"O^{2-}\", RED), (\"M^+\", BLUE),\n (\"O^{2-}\", RED), (\"M^+\", BLUE), (\"O^{2-}\", RED),\n (\"M^+\", BLUE), (\"O^{2-}\", RED), (\"M^+\", BLUE)\n ]\n \n for label, color in grid_styles:\n atom = create_entity(0.35, color, label)\n grid_entities.add(atom)\n\n grid_entities.arrange_in_grid(rows=3, cols=3, buff=0.4)\n grid_entities.move_to(UP * 1.5)\n\n # Transform the 5 existing entities into the first 5 grid positions\n # and fade in the remaining 4\n transforms = [ReplacementTransform(initial_entities[i], grid_entities[i]) for i in range(5)]\n fades = [FadeIn(grid_entities[i], shift=UP * 0.2) for i in range(5, 9)]\n\n self.play(*transforms, *fades, run_time=2, rate_func=smooth)\n self.wait(2) # Deliberate pause for processing\n\n # --- 5. Second Transformation: Metal Oxide to Carbon Layer ---\n carbon_layer = VGroup()\n for _ in range(9):\n # Dark grey circle with white stroke and label to represent Carbon\n c_atom = create_entity(0.35, DARK_GREY, \"C\", stroke_color=WHITE)\n carbon_layer.add(c_atom)\n\n carbon_layer.arrange_in_grid(rows=3, cols=3, buff=0.4)\n carbon_layer.move_to(UP * 1.5)\n\n self.play(ReplacementTransform(grid_entities, carbon_layer), run_time=2, rate_func=smooth)\n self.wait(2) # Deliberate pause for processing\n\n # --- 6. Electron Trajectory ---\n # Create a small moving electron\n moving_electron = create_entity(0.15, YELLOW, \"e^-\", label_color=BLACK)\n \n # Define a complex zigzag path: Start off-screen left, two stops, exit off-screen right\n start_point = LEFT * 8 + UP * 2\n stop_1 = LEFT * 3 + DOWN * 1\n stop_2 = RIGHT * 3 + UP * 1\n end_point = RIGHT * 8 + DOWN * 2\n\n # Create the visible dashed path trajectory\n trajectory = VMobject().set_points_as_corners([start_point, stop_1, stop_2, end_point])\n trajectory.set_stroke(YELLOW, width=3, opacity=0.5)\n trajectory.set_dash_pattern((0.15, 0.15))\n\n moving_electron.move_to(start_point)\n\n # Animate path creation and electron movement in segments to allow for distinct stops\n self.play(Create(trajectory), run_time=1)\n \n # Segment 1: Start to Stop 1\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([start_point, stop_1])),\n run_time=1.5, rate_func=linear\n )\n self.wait(0.5) # First distinct stop\n\n # Segment 2: Stop 1 to Stop 2\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([stop_1, stop_2])),\n run_time=1.5, rate_func=linear\n )\n self.wait(0.5) # Second distinct stop\n\n # Segment 3: Stop 2 to Exit off-screen right\n self.play(\n MoveAlongPath(moving_electron, VMobject().set_points_as_corners([stop_2, end_point])),\n run_time=1.5, rate_func=linear\n )\n\n # --- 7. Final Pacing ---\n self.wait(2)\n self.play(FadeOut(moving_electron), FadeOut(trajectory), FadeOut(carbon_layer))\n self.wait(1)\n```"}]}
{"id": "multi_act_v2_00798", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0798", "num_animations": 17, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_000350", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 10, "num_rich_primitives": 3, "prompt": "Could you create an animated video using a math visualization tool that shows the process of calculating the area under the curve of the function 0.1x^2 - 1 from x = -3 to x = 3, including the graph of the function, the integral expression, and the step-by-step solution of the integral, ending with the numerical answer to the integral?", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Graph Visualization\n # Setup axes with appropriate ranges and labels to visualize the function clearly\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 1, 1],\n axis_config={\n \"include_tip\": True,\n \"include_numbers\": True,\n \"font_size\": 24,\n },\n x_axis_config={\"numbers_to_include\": [-3, 3]},\n y_axis_config={\"numbers_to_include\": [-1]},\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = 0.1x^2 - 1\n func = lambda x: 0.1 * x**2 - 1\n graph = axes.plot(func, x_range=[-3, 3], color=BLUE)\n graph_label = MathTex(\"f(x) = 0.1x^2 - 1\", color=BLUE).next_to(graph, UR)\n \n # Visualize the area between the curve and the x-axis\n area = axes.get_area(graph, x_range=[-3, 3], color=BLUE, opacity=0.3)\n \n # Group graph elements and shift to the left to make room for equations\n graph_group = VGroup(axes, labels, graph, graph_label, area)\n graph_group.shift(LEFT * 3)\n \n # 2. Integral Expression & Step-by-Step Solution\n # Define each step of the calculation as separate MathTex objects\n step_integral = MathTex(r\"\\int_{-3}^{3}\", r\"\\left(0.1x^2 - 1\\right)\", r\"\\,dx\")\n \n step_antiderivative = MathTex(r\"=\", r\"\\left[ \\frac{0.1x^3}{3} - x \\right]_{-3}^{3}\")\n \n step_substitution = MathTex(\n r\"=\", r\"\\left( \\frac{0.1(3)^3}{3} - 3 \\right)\", \n r\"-\", r\"\\left( \\frac{0.1(-3)^3}{3} - (-3) \\right)\"\n ).scale(0.85) # Scale down slightly to ensure it fits within the frame\n \n step_simplification = MathTex(\n r\"=\", r\"\\left( 0.9 - 3 \\right)\", \n r\"-\", r\"\\left( -0.9 + 3 \\right)\"\n )\n \n step_evaluation = MathTex(r\"=\", r\"-2.1\", r\"-\", r\"2.1\")\n \n step_final = MathTex(r\"=\", r\"-4.2\", color=YELLOW).scale(1.2)\n \n # Align equations to the right side of the screen\n equations = VGroup(\n step_integral, \n step_antiderivative, \n step_substitution, \n step_simplification, \n step_evaluation, \n step_final\n )\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n equations.to_edge(RIGHT).shift(UP * 1.5)\n \n # --- Animation Sequence ---\n \n # Draw Axes and Graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(0.5)\n \n # Display the Integral Expression\n self.play(Write(step_integral))\n self.wait(0.5)\n \n # Animate Step-by-Step Solution using ReplacementTransform for smooth transitions\n self.play(ReplacementTransform(step_integral, step_antiderivative))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_antiderivative, step_substitution))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_substitution, step_simplification))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_simplification, step_evaluation))\n self.wait(0.5)\n \n # Display Final Result\n self.play(ReplacementTransform(step_evaluation, step_final))\n self.wait(1)\n \n # Emphasize Final Result\n self.play(step_final.animate.scale(1.5).set_color(YELLOW))\n self.wait(1)\n\n# To run this code:\n# manim -pql filename.py AreaUnderCurve", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an animated video using a math visualization tool that shows the process of calculating the area under the curve of the function 0.1x^2 - 1 from x = -3 to x = 3, including the graph of the function, the integral expression, and the step-by-step solution of the integral, ending with the numerical answer to the integral?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Graph Visualization\n # Setup axes with appropriate ranges and labels to visualize the function clearly\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 1, 1],\n axis_config={\n \"include_tip\": True,\n \"include_numbers\": True,\n \"font_size\": 24,\n },\n x_axis_config={\"numbers_to_include\": [-3, 3]},\n y_axis_config={\"numbers_to_include\": [-1]},\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = 0.1x^2 - 1\n func = lambda x: 0.1 * x**2 - 1\n graph = axes.plot(func, x_range=[-3, 3], color=BLUE)\n graph_label = MathTex(\"f(x) = 0.1x^2 - 1\", color=BLUE).next_to(graph, UR)\n \n # Visualize the area between the curve and the x-axis\n area = axes.get_area(graph, x_range=[-3, 3], color=BLUE, opacity=0.3)\n \n # Group graph elements and shift to the left to make room for equations\n graph_group = VGroup(axes, labels, graph, graph_label, area)\n graph_group.shift(LEFT * 3)\n \n # 2. Integral Expression & Step-by-Step Solution\n # Define each step of the calculation as separate MathTex objects\n step_integral = MathTex(r\"\\int_{-3}^{3}\", r\"\\left(0.1x^2 - 1\\right)\", r\"\\,dx\")\n \n step_antiderivative = MathTex(r\"=\", r\"\\left[ \\frac{0.1x^3}{3} - x \\right]_{-3}^{3}\")\n \n step_substitution = MathTex(\n r\"=\", r\"\\left( \\frac{0.1(3)^3}{3} - 3 \\right)\", \n r\"-\", r\"\\left( \\frac{0.1(-3)^3}{3} - (-3) \\right)\"\n ).scale(0.85) # Scale down slightly to ensure it fits within the frame\n \n step_simplification = MathTex(\n r\"=\", r\"\\left( 0.9 - 3 \\right)\", \n r\"-\", r\"\\left( -0.9 + 3 \\right)\"\n )\n \n step_evaluation = MathTex(r\"=\", r\"-2.1\", r\"-\", r\"2.1\")\n \n step_final = MathTex(r\"=\", r\"-4.2\", color=YELLOW).scale(1.2)\n \n # Align equations to the right side of the screen\n equations = VGroup(\n step_integral, \n step_antiderivative, \n step_substitution, \n step_simplification, \n step_evaluation, \n step_final\n )\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n equations.to_edge(RIGHT).shift(UP * 1.5)\n \n # --- Animation Sequence ---\n \n # Draw Axes and Graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(0.5)\n \n # Display the Integral Expression\n self.play(Write(step_integral))\n self.wait(0.5)\n \n # Animate Step-by-Step Solution using ReplacementTransform for smooth transitions\n self.play(ReplacementTransform(step_integral, step_antiderivative))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_antiderivative, step_substitution))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_substitution, step_simplification))\n self.wait(0.5)\n \n self.play(ReplacementTransform(step_simplification, step_evaluation))\n self.wait(0.5)\n \n # Display Final Result\n self.play(ReplacementTransform(step_evaluation, step_final))\n self.wait(1)\n \n # Emphasize Final Result\n self.play(step_final.animate.scale(1.5).set_color(YELLOW))\n self.wait(1)\n\n# To run this code:\n# manim -pql filename.py AreaUnderCurve\n```"}]}
{"id": "AOS-Manim-SFT_000264", "source": "nabin2004/AOS-Manim-SFT", "tier": 1, "scene_name": "NLLLossVisualization", "num_animations": 26, "num_rich_primitives": 4, "prompt": "I'm studying sequence models and want to visualize the NLL loss per sample as a bar chart, highlighting the highest losses in red to expose outliers.", "code": "from manim import *\n\nclass NLLLossVisualization(Scene):\n\n def construct(self):\n title = Text('NLL Loss in Sequence Models', font_size=40)\n subtitle = Text('Understanding Negative Log-Likelihood', font_size=24, color=BLUE)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.3)\n self.play(Write(title), run_time=2.0 / 2)\n self.play(FadeIn(subtitle), run_time=2.0 / 2)\n self.wait(0.5)\n self.play(FadeOut(title_group))\n context_title = Text('The Sequence Prediction Problem', font_size=32, color=YELLOW)\n context_title.to_edge(UP, buff=0.5)\n sentence = Text('\"The cat sat on the...\"', font_size=28, color=WHITE)\n sentence.move_to(UP * 1.5)\n arrow = Arrow(UP * 0.8, DOWN * 0.2, color=BLUE)\n predictions = VGroup(Text('mat: 0.6', font_size=22, color=GREEN), Text('chair: 0.3', font_size=22, color=YELLOW), Text('floor: 0.1', font_size=22, color=RED)).arrange(DOWN, buff=0.3)\n predictions.move_to(DOWN * 1.5)\n self.play(Write(context_title), run_time=2.0 / 3)\n self.play(Write(sentence), run_time=2.0 / 3)\n self.play(GrowArrow(arrow), FadeIn(predictions), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(context_title), FadeOut(sentence), FadeOut(arrow), FadeOut(predictions))\n formula_title = Text('The NLL Loss Formula', font_size=32, color=YELLOW)\n formula_title.to_edge(UP, buff=0.5)\n formula = MathTex('NLL = -\\\\frac{1}{N} \\\\sum_{i=1}^{N} \\\\log(p(y_i | x_i))')\n formula.move_to(UP * 0.5)\n formula_parts = VGroup(Text('Negative: Penalizes wrong predictions', font_size=20, color=BLUE), Text('Log: Compresses probability range', font_size=20, color=GREEN), Text('Likelihood: Probability of true label', font_size=20, color=YELLOW)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n formula_parts.move_to(DOWN * 2)\n self.play(Write(formula_title), run_time=2.0 / 3)\n self.play(Write(formula), run_time=2.0 / 3)\n self.play(FadeIn(formula_parts), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(formula_title), FadeOut(formula), FadeOut(formula_parts))\n graph_title = Text('Why Log? Understanding the Curve', font_size=32, color=YELLOW)\n graph_title.to_edge(UP, buff=0.5)\n axes = Axes(x_range=[0, 1.1, 0.2], y_range=[0, 4, 1], x_length=6, y_length=4, axis_config={'include_tip': False})\n axes.move_to(DOWN * 0.3)\n x_label = Text('Probability p', font_size=20).next_to(axes.x_axis, DOWN)\n y_label = Text('-log(p)', font_size=20).next_to(axes.y_axis, LEFT)\n log_curve = axes.plot(lambda x: -np.log(x) if x > 0.01 else 4, x_range=[0.01, 1], color=BLUE)\n self.play(Write(graph_title), run_time=2.0 / 4)\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2.0 / 4)\n self.play(Create(log_curve), run_time=2.0 / 2)\n point_high = Dot(axes.c2p(0.9, -np.log(0.9)), color=GREEN)\n label_high = Text('0.9 prob -> low loss', font_size=16, color=GREEN).next_to(point_high, RIGHT)\n point_low = Dot(axes.c2p(0.1, -np.log(0.1)), color=RED)\n label_low = Text('0.1 prob -> high loss', font_size=16, color=RED).next_to(point_low, RIGHT)\n self.play(FadeIn(point_high), Write(label_high), run_time=2.0 / 2)\n self.play(FadeIn(point_low), Write(label_low), run_time=2.0 / 2)\n self.wait(0.3)\n self.play(FadeOut(graph_title), FadeOut(axes), FadeOut(x_label), FadeOut(y_label), FadeOut(log_curve), FadeOut(point_high), FadeOut(label_high), FadeOut(point_low), FadeOut(label_low))\n seq_title = Text('NLL Across a Sequence', font_size=32, color=YELLOW)\n seq_title.to_edge(UP, buff=0.5)\n words = ['The', 'cat', 'sat']\n probs = [0.9, 0.8, 0.3]\n losses = [round(-np.log(p), 2) for p in probs]\n word_group = VGroup()\n for i, (word, prob, loss) in enumerate(zip(words, probs, losses)):\n word_text = Text(f'\"{word}\"', font_size=24)\n prob_text = Text(f'p={prob}', font_size=18, color=BLUE)\n loss_text = Text(f'loss={loss:.2f}', font_size=18, color=RED)\n col = VGroup(word_text, prob_text, loss_text).arrange(DOWN, buff=0.2)\n word_group.add(col)\n word_group.arrange(RIGHT, buff=1)\n word_group.move_to(UP * 0.5)\n avg_loss = Text('Avg NLL = (0.11 + 0.22 + 1.20) / 3 = 0.51', font_size=24)\n avg_loss.move_to(DOWN * 2)\n self.play(Write(seq_title), run_time=2.0 / 3)\n self.play(FadeIn(word_group), run_time=2.0 / 3)\n self.play(Write(avg_loss), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(seq_title), FadeOut(word_group), FadeOut(avg_loss))\n takeaway_title = Text('Key Takeaways', font_size=32, color=YELLOW)\n takeaway_title.to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('- NLL penalizes confident wrong predictions heavily', font_size=22), Text('- Logarithm compresses the probability scale', font_size=22), Text('- Lower NLL = better model predictions', font_size=22), Text('- Averaging enables comparison across sequences', font_size=22)).arrange(DOWN, buff=0.5, aligned_edge=LEFT)\n takeaways.move_to(DOWN * 0.2)\n box = SurroundingRectangle(takeaways, buff=0.4, color=BLUE)\n self.play(Write(takeaway_title), run_time=2.0 / 3)\n self.play(Create(box), run_time=2.0 / 6)\n for item in takeaways:\n self.play(Write(item), run_time=2.0 / 8)\n self.wait(1)\n self.play(FadeOut(takeaway_title), FadeOut(takeaways), FadeOut(box))\n closing = Text('Happy Training!', font_size=40, color=GREEN)\n self.play(Write(closing), run_time=2.0)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm studying sequence models and want to visualize the NLL loss per sample as a bar chart, highlighting the highest losses in red to expose outliers."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass NLLLossVisualization(Scene):\n\n def construct(self):\n title = Text('NLL Loss in Sequence Models', font_size=40)\n subtitle = Text('Understanding Negative Log-Likelihood', font_size=24, color=BLUE)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.3)\n self.play(Write(title), run_time=2.0 / 2)\n self.play(FadeIn(subtitle), run_time=2.0 / 2)\n self.wait(0.5)\n self.play(FadeOut(title_group))\n context_title = Text('The Sequence Prediction Problem', font_size=32, color=YELLOW)\n context_title.to_edge(UP, buff=0.5)\n sentence = Text('\"The cat sat on the...\"', font_size=28, color=WHITE)\n sentence.move_to(UP * 1.5)\n arrow = Arrow(UP * 0.8, DOWN * 0.2, color=BLUE)\n predictions = VGroup(Text('mat: 0.6', font_size=22, color=GREEN), Text('chair: 0.3', font_size=22, color=YELLOW), Text('floor: 0.1', font_size=22, color=RED)).arrange(DOWN, buff=0.3)\n predictions.move_to(DOWN * 1.5)\n self.play(Write(context_title), run_time=2.0 / 3)\n self.play(Write(sentence), run_time=2.0 / 3)\n self.play(GrowArrow(arrow), FadeIn(predictions), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(context_title), FadeOut(sentence), FadeOut(arrow), FadeOut(predictions))\n formula_title = Text('The NLL Loss Formula', font_size=32, color=YELLOW)\n formula_title.to_edge(UP, buff=0.5)\n formula = MathTex('NLL = -\\\\frac{1}{N} \\\\sum_{i=1}^{N} \\\\log(p(y_i | x_i))')\n formula.move_to(UP * 0.5)\n formula_parts = VGroup(Text('Negative: Penalizes wrong predictions', font_size=20, color=BLUE), Text('Log: Compresses probability range', font_size=20, color=GREEN), Text('Likelihood: Probability of true label', font_size=20, color=YELLOW)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n formula_parts.move_to(DOWN * 2)\n self.play(Write(formula_title), run_time=2.0 / 3)\n self.play(Write(formula), run_time=2.0 / 3)\n self.play(FadeIn(formula_parts), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(formula_title), FadeOut(formula), FadeOut(formula_parts))\n graph_title = Text('Why Log? Understanding the Curve', font_size=32, color=YELLOW)\n graph_title.to_edge(UP, buff=0.5)\n axes = Axes(x_range=[0, 1.1, 0.2], y_range=[0, 4, 1], x_length=6, y_length=4, axis_config={'include_tip': False})\n axes.move_to(DOWN * 0.3)\n x_label = Text('Probability p', font_size=20).next_to(axes.x_axis, DOWN)\n y_label = Text('-log(p)', font_size=20).next_to(axes.y_axis, LEFT)\n log_curve = axes.plot(lambda x: -np.log(x) if x > 0.01 else 4, x_range=[0.01, 1], color=BLUE)\n self.play(Write(graph_title), run_time=2.0 / 4)\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2.0 / 4)\n self.play(Create(log_curve), run_time=2.0 / 2)\n point_high = Dot(axes.c2p(0.9, -np.log(0.9)), color=GREEN)\n label_high = Text('0.9 prob -> low loss', font_size=16, color=GREEN).next_to(point_high, RIGHT)\n point_low = Dot(axes.c2p(0.1, -np.log(0.1)), color=RED)\n label_low = Text('0.1 prob -> high loss', font_size=16, color=RED).next_to(point_low, RIGHT)\n self.play(FadeIn(point_high), Write(label_high), run_time=2.0 / 2)\n self.play(FadeIn(point_low), Write(label_low), run_time=2.0 / 2)\n self.wait(0.3)\n self.play(FadeOut(graph_title), FadeOut(axes), FadeOut(x_label), FadeOut(y_label), FadeOut(log_curve), FadeOut(point_high), FadeOut(label_high), FadeOut(point_low), FadeOut(label_low))\n seq_title = Text('NLL Across a Sequence', font_size=32, color=YELLOW)\n seq_title.to_edge(UP, buff=0.5)\n words = ['The', 'cat', 'sat']\n probs = [0.9, 0.8, 0.3]\n losses = [round(-np.log(p), 2) for p in probs]\n word_group = VGroup()\n for i, (word, prob, loss) in enumerate(zip(words, probs, losses)):\n word_text = Text(f'\"{word}\"', font_size=24)\n prob_text = Text(f'p={prob}', font_size=18, color=BLUE)\n loss_text = Text(f'loss={loss:.2f}', font_size=18, color=RED)\n col = VGroup(word_text, prob_text, loss_text).arrange(DOWN, buff=0.2)\n word_group.add(col)\n word_group.arrange(RIGHT, buff=1)\n word_group.move_to(UP * 0.5)\n avg_loss = Text('Avg NLL = (0.11 + 0.22 + 1.20) / 3 = 0.51', font_size=24)\n avg_loss.move_to(DOWN * 2)\n self.play(Write(seq_title), run_time=2.0 / 3)\n self.play(FadeIn(word_group), run_time=2.0 / 3)\n self.play(Write(avg_loss), run_time=2.0 / 3)\n self.wait(0.3)\n self.play(FadeOut(seq_title), FadeOut(word_group), FadeOut(avg_loss))\n takeaway_title = Text('Key Takeaways', font_size=32, color=YELLOW)\n takeaway_title.to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('- NLL penalizes confident wrong predictions heavily', font_size=22), Text('- Logarithm compresses the probability scale', font_size=22), Text('- Lower NLL = better model predictions', font_size=22), Text('- Averaging enables comparison across sequences', font_size=22)).arrange(DOWN, buff=0.5, aligned_edge=LEFT)\n takeaways.move_to(DOWN * 0.2)\n box = SurroundingRectangle(takeaways, buff=0.4, color=BLUE)\n self.play(Write(takeaway_title), run_time=2.0 / 3)\n self.play(Create(box), run_time=2.0 / 6)\n for item in takeaways:\n self.play(Write(item), run_time=2.0 / 8)\n self.wait(1)\n self.play(FadeOut(takeaway_title), FadeOut(takeaways), FadeOut(box))\n closing = Text('Happy Training!', font_size=40, color=GREEN)\n self.play(Write(closing), run_time=2.0)\n self.wait(1)\n```"}]}
{"id": "AOS-Manim-SFT_000160", "source": "nabin2004/AOS-Manim-SFT", "tier": 1, "scene_name": "HierarchicalDecodersScene", "num_animations": 14, "num_rich_primitives": 4, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralPowerRule", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_001264", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 7, "num_rich_primitives": 3, "prompt": "I want to create an animation that visually demonstrates the concept of finding the area under a curve on a graph. The curve should represent a quadratic function. Start by showing the axes and the curve. Then, shade the area under the curve between x=0 and x=4. Also, include a label for the equation of the curve near it. After that, display a text description explaining that the shaded area represents the integral from 0 to 4. Next, I would like to see the integral formula appear to replace the equation of the curve. Finally, show the actual calculated value of the area, clear everything else away, and leave only the solution on the screen for a moment. Can this animation also include pauses for emphasis at certain points?", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize axes\n # Setting ranges to accommodate f(x) = x^2 up to x=4 (y=16)\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 20, 5],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [0, 16]},\n )\n axes.add_coordinates()\n axis_labels = axes.get_axis_labels()\n\n # 2. Function Definition: Quadratic function f(x) = x^2\n func = lambda x: x**2\n curve = axes.plot(func, color=BLUE)\n\n # 3. Visualization Sequence\n\n # Draw axes and curve\n self.play(Create(axes), Create(axis_labels), Create(curve))\n self.wait(1)\n\n # Label for the equation\n eq_label = MathTex(\"f(x) = x^2\").next_to(curve, UR, buff=0.5)\n self.play(Write(eq_label))\n self.wait(1)\n\n # Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=(0, 4), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Text description explaining the shaded area\n description = Text(\n \"Shaded area represents\\nthe definite integral from 0 to 4\",\n font_size=24\n ).to_edge(DOWN)\n self.play(Write(description))\n self.wait(2)\n\n # Transition: Replace equation label with integral notation\n integral_label = MathTex(r\"\\int_{0}^{4} x^2 \\, dx\").move_to(eq_label)\n self.play(ReplacementTransform(eq_label, integral_label))\n self.wait(1)\n\n # Calculation: Show the actual calculated value\n # Integral of x^2 from 0 to 4 is 64/3\n solution_value = MathTex(r\"= \\frac{64}{3}\", font_size=48).next_to(integral_label, RIGHT)\n self.play(Write(solution_value))\n self.wait(2)\n\n # Group the final solution (Integral + Value)\n final_solution = VGroup(integral_label, solution_value)\n \n # Conclusion: Fade out everything except the solution\n # Enlarge the solution and move to center for emphasis\n self.play(\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(description),\n final_solution.animate.move_to(ORIGIN).scale(2)\n )\n \n # Leave only the solution on the screen for a moment\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I want to create an animation that visually demonstrates the concept of finding the area under a curve on a graph. The curve should represent a quadratic function. Start by showing the axes and the curve. Then, shade the area under the curve between x=0 and x=4. Also, include a label for the equation of the curve near it. After that, display a text description explaining that the shaded area represents the integral from 0 to 4. Next, I would like to see the integral formula appear to replace the equation of the curve. Finally, show the actual calculated value of the area, clear everything else away, and leave only the solution on the screen for a moment. Can this animation also include pauses for emphasis at certain points?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize axes\n # Setting ranges to accommodate f(x) = x^2 up to x=4 (y=16)\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 20, 5],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [0, 16]},\n )\n axes.add_coordinates()\n axis_labels = axes.get_axis_labels()\n\n # 2. Function Definition: Quadratic function f(x) = x^2\n func = lambda x: x**2\n curve = axes.plot(func, color=BLUE)\n\n # 3. Visualization Sequence\n\n # Draw axes and curve\n self.play(Create(axes), Create(axis_labels), Create(curve))\n self.wait(1)\n\n # Label for the equation\n eq_label = MathTex(\"f(x) = x^2\").next_to(curve, UR, buff=0.5)\n self.play(Write(eq_label))\n self.wait(1)\n\n # Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=(0, 4), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Text description explaining the shaded area\n description = Text(\n \"Shaded area represents\\nthe definite integral from 0 to 4\",\n font_size=24\n ).to_edge(DOWN)\n self.play(Write(description))\n self.wait(2)\n\n # Transition: Replace equation label with integral notation\n integral_label = MathTex(r\"\\int_{0}^{4} x^2 \\, dx\").move_to(eq_label)\n self.play(ReplacementTransform(eq_label, integral_label))\n self.wait(1)\n\n # Calculation: Show the actual calculated value\n # Integral of x^2 from 0 to 4 is 64/3\n solution_value = MathTex(r\"= \\frac{64}{3}\", font_size=48).next_to(integral_label, RIGHT)\n self.play(Write(solution_value))\n self.wait(2)\n\n # Group the final solution (Integral + Value)\n final_solution = VGroup(integral_label, solution_value)\n \n # Conclusion: Fade out everything except the solution\n # Enlarge the solution and move to center for emphasis\n self.play(\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(description),\n final_solution.animate.move_to(ORIGIN).scale(2)\n )\n \n # Leave only the solution on the screen for a moment\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_007292", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralSolution", "num_animations": 13, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "manim-sft-10k_001389", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "SetTheoryLecture", "num_animations": 11, "num_rich_primitives": 2, "prompt": "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#### Bidirectional Inclusion Proof Method\nTo prove that two sets are equal ($A = B$), the most commonly used standard method is the \"bidirectional inclusion proof method.\" This method is based on antisymmetry, which involves proving the following two propositions simultaneously:\n1. $A \\subseteq B$ (for any $x$, if $x \\in A$ then $x \\in B$);\n2. $B \\subseteq A$ (for any $x$, if $x \\in B$ then $x \\in A$).\n\n## Basic Set Operations\n\n### Union, Intersection, Difference\n\n#### Unions\nThe union of two sets $A$ and $B$ is the set consisting of all elements that belong to $A$ or to $B$ (or to both). It is denoted by $A \\cup B$.\nDefinition:\n$$ A \\cup B = \\{x \\mid x \\in A \\lor x \\in B\\} $$\n\n\nThe context of this section (from highest to current level):\n# Naive Set Theory\n## Basic Definitions and Relations\n### Subsets\n", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SetTheoryLecture(Scene):\n\n def construct(self):\n title1 = Title('Bidirectional Inclusion Proof Method')\n self.play(Write(title1))\n intro_text = Tex('To prove that two sets are equal ($A = B$), the most commonly used\\\\\\\\', \"standard method is the ``bidirectional inclusion proof method''.\\\\\\\\\", 'This method is based on antisymmetry, which involves proving\\\\\\\\', 'the following two propositions simultaneously:').scale(0.75)\n prop1 = Tex('1. $A \\\\subseteq B$ (for any $x$, if $x \\\\in A$ then $x \\\\in B$);').scale(0.75)\n prop2 = Tex('2. $B \\\\subseteq A$ (for any $x$, if $x \\\\in B$ then $x \\\\in A$).').scale(0.75)\n props = VGroup(prop1, prop2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n content1 = VGroup(intro_text, props).arrange(DOWN, buff=0.8)\n content1.next_to(title1, DOWN, buff=0.8)\n self.play(FadeIn(intro_text, shift=UP * 0.5))\n self.wait(2)\n self.play(Write(prop1))\n self.wait(1)\n self.play(Write(prop2))\n self.wait(3)\n self.play(FadeOut(content1), FadeOut(title1))\n self.wait(0.5)\n title2 = Title('Basic Set Operations: Unions')\n self.play(Write(title2))\n union_desc = Tex('The union of two sets $A$ and $B$ is the set consisting of\\\\\\\\', 'all elements that belong to $A$ or to $B$ (or to both).\\\\\\\\', 'It is denoted by $A \\\\cup B$.').scale(0.75)\n def_label = Tex('Definition:').scale(0.75)\n union_formula = MathTex('A \\\\cup B = \\\\{x \\\\mid x \\\\in A \\\\lor x \\\\in B\\\\}').scale(0.9)\n union_formula.set_color(YELLOW)\n formula_box = SurroundingRectangle(union_formula, color=YELLOW, buff=0.2)\n formula_group = VGroup(def_label, VGroup(formula_box, union_formula)).arrange(DOWN, buff=0.3)\n circle_a = Circle(radius=1.2, color=BLUE, stroke_width=4).shift(LEFT * 0.7)\n circle_b = Circle(radius=1.2, color=RED, stroke_width=4).shift(RIGHT * 0.7)\n label_a = MathTex('A').move_to(circle_a.get_center() + LEFT * 0.6)\n label_b = MathTex('B').move_to(circle_b.get_center() + RIGHT * 0.6)\n union_fill = Union(circle_a, circle_b, fill_opacity=0.4, fill_color=PURPLE, stroke_width=0)\n venn_diagram = VGroup(union_fill, circle_a, circle_b, label_a, label_b)\n content2 = VGroup(union_desc, formula_group, venn_diagram).arrange(DOWN, buff=0.5)\n content2.next_to(title2, DOWN, buff=0.5)\n self.play(FadeIn(union_desc, shift=UP * 0.5))\n self.wait(2)\n self.play(FadeIn(def_label), Write(union_formula), Create(formula_box))\n self.wait(2)\n self.play(Create(circle_a), Write(label_a))\n self.play(Create(circle_b), Write(label_b))\n self.play(FadeIn(union_fill))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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#### Bidirectional Inclusion Proof Method\nTo prove that two sets are equal ($A = B$), the most commonly used standard method is the \"bidirectional inclusion proof method.\" This method is based on antisymmetry, which involves proving the following two propositions simultaneously:\n1. $A \\subseteq B$ (for any $x$, if $x \\in A$ then $x \\in B$);\n2. $B \\subseteq A$ (for any $x$, if $x \\in B$ then $x \\in A$).\n\n## Basic Set Operations\n\n### Union, Intersection, Difference\n\n#### Unions\nThe union of two sets $A$ and $B$ is the set consisting of all elements that belong to $A$ or to $B$ (or to both). It is denoted by $A \\cup B$.\nDefinition:\n$$ A \\cup B = \\{x \\mid x \\in A \\lor x \\in B\\} $$\n\n\nThe context of this section (from highest to current level):\n# Naive Set Theory\n## Basic Definitions and Relations\n### Subsets\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SetTheoryLecture(Scene):\n\n def construct(self):\n title1 = Title('Bidirectional Inclusion Proof Method')\n self.play(Write(title1))\n intro_text = Tex('To prove that two sets are equal ($A = B$), the most commonly used\\\\\\\\', \"standard method is the ``bidirectional inclusion proof method''.\\\\\\\\\", 'This method is based on antisymmetry, which involves proving\\\\\\\\', 'the following two propositions simultaneously:').scale(0.75)\n prop1 = Tex('1. $A \\\\subseteq B$ (for any $x$, if $x \\\\in A$ then $x \\\\in B$);').scale(0.75)\n prop2 = Tex('2. $B \\\\subseteq A$ (for any $x$, if $x \\\\in B$ then $x \\\\in A$).').scale(0.75)\n props = VGroup(prop1, prop2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n content1 = VGroup(intro_text, props).arrange(DOWN, buff=0.8)\n content1.next_to(title1, DOWN, buff=0.8)\n self.play(FadeIn(intro_text, shift=UP * 0.5))\n self.wait(2)\n self.play(Write(prop1))\n self.wait(1)\n self.play(Write(prop2))\n self.wait(3)\n self.play(FadeOut(content1), FadeOut(title1))\n self.wait(0.5)\n title2 = Title('Basic Set Operations: Unions')\n self.play(Write(title2))\n union_desc = Tex('The union of two sets $A$ and $B$ is the set consisting of\\\\\\\\', 'all elements that belong to $A$ or to $B$ (or to both).\\\\\\\\', 'It is denoted by $A \\\\cup B$.').scale(0.75)\n def_label = Tex('Definition:').scale(0.75)\n union_formula = MathTex('A \\\\cup B = \\\\{x \\\\mid x \\\\in A \\\\lor x \\\\in B\\\\}').scale(0.9)\n union_formula.set_color(YELLOW)\n formula_box = SurroundingRectangle(union_formula, color=YELLOW, buff=0.2)\n formula_group = VGroup(def_label, VGroup(formula_box, union_formula)).arrange(DOWN, buff=0.3)\n circle_a = Circle(radius=1.2, color=BLUE, stroke_width=4).shift(LEFT * 0.7)\n circle_b = Circle(radius=1.2, color=RED, stroke_width=4).shift(RIGHT * 0.7)\n label_a = MathTex('A').move_to(circle_a.get_center() + LEFT * 0.6)\n label_b = MathTex('B').move_to(circle_b.get_center() + RIGHT * 0.6)\n union_fill = Union(circle_a, circle_b, fill_opacity=0.4, fill_color=PURPLE, stroke_width=0)\n venn_diagram = VGroup(union_fill, circle_a, circle_b, label_a, label_b)\n content2 = VGroup(union_desc, formula_group, venn_diagram).arrange(DOWN, buff=0.5)\n content2.next_to(title2, DOWN, buff=0.5)\n self.play(FadeIn(union_desc, shift=UP * 0.5))\n self.wait(2)\n self.play(FadeIn(def_label), Write(union_formula), Create(formula_box))\n self.wait(2)\n self.play(Create(circle_a), Write(label_a))\n self.play(Create(circle_b), Write(label_b))\n self.play(FadeIn(union_fill))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_005832", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ChemistryAnimation", "num_animations": 8, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_008309", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "MetalOxideFormation", "num_animations": 6, "num_rich_primitives": 2, "prompt": "I would like to create an animation that shows a chemical reaction where an electron and an oxygen molecule come together to form a metal oxide with the formula \\( \\text{Me}_2\\text{O}_3 \\). The electron and the oxygen molecule should appear on screen, move together, and then transform into the metal oxide on the right side of the screen. Can you design an animation that represents this chemical reaction process visually?", "code": "from manim import *\n\nclass MetalOxideFormation(Scene):\n def construct(self):\n # --- Configuration ---\n self.camera.background_color = \"#1a1a1a\"\n \n # --- 1. Initial State Objects ---\n # Electron: Small glowing cyan dot with a negative sign\n electron = Dot(color=CYAN, radius=0.15)\n electron_sign = MathTex(\"-\", color=WHITE, font_size=24).move_to(electron.get_center())\n electron_group = VGroup(electron, electron_sign).shift(LEFT * 4 + UP * 1)\n electron_label = MathTex(\"e^-\", color=CYAN, font_size=36).next_to(electron_group, DOWN, buff=0.3)\n \n # Oxygen Molecule: Two red spheres connected\n o_atom_1 = Dot(color=RED, radius=0.25).shift(LEFT * 0.3)\n o_atom_2 = Dot(color=RED, radius=0.25).shift(RIGHT * 0.3)\n o_bond = Line(LEFT * 0.3, RIGHT * 0.3, color=RED, stroke_width=4)\n o2_group = VGroup(o_atom_1, o_atom_2, o_bond).shift(LEFT * 4 + DOWN * 1)\n o2_label = MathTex(\"O_2\", color=RED, font_size=36).next_to(o2_group, DOWN, buff=0.3)\n \n # --- 3. Final Product Objects ---\n # Me2O3 Representation: 2 Metal (Gray), 3 Oxygen (Red)\n me_atom = Dot(color=GRAY_B, radius=0.4)\n o_atom = Dot(color=RED, radius=0.25)\n \n # Simple cluster arrangement for Me2O3 schematic\n me1 = me_atom.copy().shift(LEFT * 0.5 + DOWN * 0.2)\n me2 = me_atom.copy().shift(RIGHT * 0.5 + DOWN * 0.2)\n ox1 = o_atom.copy().shift(UP * 0.5)\n ox2 = o_atom.copy().shift(DOWN * 0.6 + LEFT * 0.2)\n ox3 = o_atom.copy().shift(DOWN * 0.6 + RIGHT * 0.2)\n \n # Bonds to represent ionic/covalent lattice\n bond1 = Line(me1.get_center(), ox1.get_center(), color=GRAY, stroke_width=4)\n bond2 = Line(me1.get_center(), ox2.get_center(), color=GRAY, stroke_width=4)\n bond3 = Line(me2.get_center(), ox3.get_center(), color=GRAY, stroke_width=4)\n bond4 = Line(me2.get_center(), ox1.get_center(), color=GRAY, stroke_width=4)\n \n product_cluster = VGroup(me1, me2, ox1, ox2, ox3, bond1, bond2, bond3, bond4)\n product_label = MathTex(\"Me_2O_3\", color=WHITE, font_size=48).next_to(product_cluster, DOWN, buff=0.3)\n \n full_product = VGroup(product_cluster, product_label).shift(RIGHT * 3)\n \n # --- Animation Sequence ---\n \n # 1. Initial State\n self.play(FadeIn(electron_group), Write(electron_label))\n self.play(FadeIn(o2_group), Write(o2_label))\n self.wait(1)\n \n # 2. Interaction (Moving toward center)\n convergence_point = ORIGIN\n self.play(\n electron_group.animate.move_to(convergence_point + UP * 0.5),\n o2_group.animate.move_to(convergence_point + DOWN * 0.5),\n FadeOut(electron_label),\n FadeOut(o2_label),\n run_time=2,\n rate_func=smooth\n )\n \n # Interaction Flash to signify reaction energy\n flash = Circle(radius=1.0, color=WHITE, stroke_width=8).move_to(convergence_point)\n self.play(Create(flash), run_time=0.2)\n self.play(\n FadeOut(flash), \n FadeOut(electron_group), \n FadeOut(o2_group), \n run_time=0.3\n )\n \n # 3. Transformation (Product appears on right)\n self.play(FadeIn(full_product, scale=0.8), run_time=1.5)\n \n # Final Hold\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an animation that shows a chemical reaction where an electron and an oxygen molecule come together to form a metal oxide with the formula \\( \\text{Me}_2\\text{O}_3 \\). The electron and the oxygen molecule should appear on screen, move together, and then transform into the metal oxide on the right side of the screen. Can you design an animation that represents this chemical reaction process visually?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass MetalOxideFormation(Scene):\n def construct(self):\n # --- Configuration ---\n self.camera.background_color = \"#1a1a1a\"\n \n # --- 1. Initial State Objects ---\n # Electron: Small glowing cyan dot with a negative sign\n electron = Dot(color=CYAN, radius=0.15)\n electron_sign = MathTex(\"-\", color=WHITE, font_size=24).move_to(electron.get_center())\n electron_group = VGroup(electron, electron_sign).shift(LEFT * 4 + UP * 1)\n electron_label = MathTex(\"e^-\", color=CYAN, font_size=36).next_to(electron_group, DOWN, buff=0.3)\n \n # Oxygen Molecule: Two red spheres connected\n o_atom_1 = Dot(color=RED, radius=0.25).shift(LEFT * 0.3)\n o_atom_2 = Dot(color=RED, radius=0.25).shift(RIGHT * 0.3)\n o_bond = Line(LEFT * 0.3, RIGHT * 0.3, color=RED, stroke_width=4)\n o2_group = VGroup(o_atom_1, o_atom_2, o_bond).shift(LEFT * 4 + DOWN * 1)\n o2_label = MathTex(\"O_2\", color=RED, font_size=36).next_to(o2_group, DOWN, buff=0.3)\n \n # --- 3. Final Product Objects ---\n # Me2O3 Representation: 2 Metal (Gray), 3 Oxygen (Red)\n me_atom = Dot(color=GRAY_B, radius=0.4)\n o_atom = Dot(color=RED, radius=0.25)\n \n # Simple cluster arrangement for Me2O3 schematic\n me1 = me_atom.copy().shift(LEFT * 0.5 + DOWN * 0.2)\n me2 = me_atom.copy().shift(RIGHT * 0.5 + DOWN * 0.2)\n ox1 = o_atom.copy().shift(UP * 0.5)\n ox2 = o_atom.copy().shift(DOWN * 0.6 + LEFT * 0.2)\n ox3 = o_atom.copy().shift(DOWN * 0.6 + RIGHT * 0.2)\n \n # Bonds to represent ionic/covalent lattice\n bond1 = Line(me1.get_center(), ox1.get_center(), color=GRAY, stroke_width=4)\n bond2 = Line(me1.get_center(), ox2.get_center(), color=GRAY, stroke_width=4)\n bond3 = Line(me2.get_center(), ox3.get_center(), color=GRAY, stroke_width=4)\n bond4 = Line(me2.get_center(), ox1.get_center(), color=GRAY, stroke_width=4)\n \n product_cluster = VGroup(me1, me2, ox1, ox2, ox3, bond1, bond2, bond3, bond4)\n product_label = MathTex(\"Me_2O_3\", color=WHITE, font_size=48).next_to(product_cluster, DOWN, buff=0.3)\n \n full_product = VGroup(product_cluster, product_label).shift(RIGHT * 3)\n \n # --- Animation Sequence ---\n \n # 1. Initial State\n self.play(FadeIn(electron_group), Write(electron_label))\n self.play(FadeIn(o2_group), Write(o2_label))\n self.wait(1)\n \n # 2. Interaction (Moving toward center)\n convergence_point = ORIGIN\n self.play(\n electron_group.animate.move_to(convergence_point + UP * 0.5),\n o2_group.animate.move_to(convergence_point + DOWN * 0.5),\n FadeOut(electron_label),\n FadeOut(o2_label),\n run_time=2,\n rate_func=smooth\n )\n \n # Interaction Flash to signify reaction energy\n flash = Circle(radius=1.0, color=WHITE, stroke_width=8).move_to(convergence_point)\n self.play(Create(flash), run_time=0.2)\n self.play(\n FadeOut(flash), \n FadeOut(electron_group), \n FadeOut(o2_group), \n run_time=0.3\n )\n \n # 3. Transformation (Product appears on right)\n self.play(FadeIn(full_product, scale=0.8), run_time=1.5)\n \n # Final Hold\n self.wait(2)\n```"}]}
{"id": "multi_act_v2_00770", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0770", "num_animations": 18, "prompt": "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: Can you create an animation where the word \"Broadcast\" appears and moves upward, followed by a triangle shape emanating some sort of broadcast signal and then the triangle disappearing?\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: Here is the enhanced animation description that builds upon the original while adding significant new features:", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0770(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_broadcastanimation()\n self.clear_stage()\n self.act_2_sentimentanalysisscene()\n self.clear_stage()\n self.act_3_lineartransformationscen()\n\n def act_1_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=48, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(\n text.animate.shift(UP * 3),\n run_time=1.2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # 3. Shape & Signal\n # Create a triangle to represent the broadcast source\n triangle = Triangle()\n triangle.set_stroke(BLUE, width=4)\n triangle.set_fill(BLUE, opacity=0.3)\n triangle.scale(0.8)\n self.play(Create(triangle), run_time=1)\n\n # Create concentric arcs for the signal wave effect\n waves = VGroup()\n num_waves = 3\n for i in range(1, num_waves + 1):\n arc = Arc(\n radius=i * 0.5,\n start_angle=30 * DEGREES,\n angle=120 * DEGREES,\n stroke_width=4,\n color=BLUE\n ).rotate(-90 * DEGREES, about_point=triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out to simulate signal emission\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(1.5)\n .set_stroke(opacity=0, width=1)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2\n )\n self.wait(0.5)\n\n # 4. Disappearance\n self.play(FadeOut(triangle), run_time=1)\n self.wait(0.5)\n\n def act_2_sentimentanalysisscene(self):\n context = Text('Word Vector Similarity Calculation > Applications of Semantic Analysis', font_size=20, color=LIGHT_GRAY).to_corner(UL)\n title = Text('Sentiment Analysis', font_size=44, color=BLUE, weight=BOLD).next_to(context, DOWN, buff=0.5).align_to(context, LEFT)\n subtitle = Text('The Role of Semantic Analysis in Sentiment Analysis', font_size=32, color=YELLOW).next_to(title, DOWN, buff=0.6).align_to(title, LEFT)\n bullet_1 = Text('• Understanding the semantic content of emotional expressions,\\n not only judging polarity but also analyzing the causes of emotions.', font_size=26, line_spacing=1.2)\n bullet_2 = Text('• Identifying the subject, object (Aspect), and degree of emotion\\n to achieve fine-grained emotional mining.', font_size=26, line_spacing=1.2)\n bullets = VGroup(bullet_1, bullet_2).arrange(DOWN, aligned_edge=LEFT, buff=0.6).next_to(subtitle, DOWN, buff=0.8).align_to(subtitle, LEFT).shift(RIGHT * 0.2)\n self.play(FadeIn(context, shift=DOWN * 0.2))\n self.wait(0.5)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(subtitle, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(bullet_1, shift=UP * 0.3))\n self.wait(1)\n self.play(FadeIn(bullet_2, shift=UP * 0.3))\n self.wait(2)\n\n def act_3_lineartransformationscen(self):\n line = Line(LEFT*3, RIGHT*3, color=PURPLE)\n equation = MathTex(\"y = 0\", color=PURPLE).next_to(line, DOWN)\n\n # Create axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-3, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n \n # Fade in coordinate system\n self.play(\n FadeIn(axes),\n Write(axes_labels),\n run_time=1\n )\n self.wait(0.5)\n \n # Transform line and equation\n new_line = line.copy().shift(UP*2)\n new_equation = MathTex(\"y = 2\", color=PURPLE).next_to(new_line, DOWN)\n dashed_line = DashedLine(LEFT*3, RIGHT*3, color=GRAY)\n vertical_line = Line(DOWN*2, UP*2, color=GREEN).shift(LEFT*3)\n \n self.play(\n Transform(line, new_line),\n Transform(equation, new_equation),\n Create(dashed_line),\n Create(vertical_line),\n run_time=2\n )\n self.wait()\n \n # Final pulse effect\n for mobj in [line, equation, axes, axes_labels, dashed_line, vertical_line]:\n self.play(\n mobj.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n mobj.animate.scale(1/1.1),\n run_time=0.5\n )\n \n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: Can you create an animation where the word \"Broadcast\" appears and moves upward, followed by a triangle shape emanating some sort of broadcast signal and then the triangle disappearing?\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: Here is the enhanced animation description that builds upon the original while adding significant new features:"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0770(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_broadcastanimation()\n self.clear_stage()\n self.act_2_sentimentanalysisscene()\n self.clear_stage()\n self.act_3_lineartransformationscen()\n\n def act_1_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=48, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(\n text.animate.shift(UP * 3),\n run_time=1.2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # 3. Shape & Signal\n # Create a triangle to represent the broadcast source\n triangle = Triangle()\n triangle.set_stroke(BLUE, width=4)\n triangle.set_fill(BLUE, opacity=0.3)\n triangle.scale(0.8)\n self.play(Create(triangle), run_time=1)\n\n # Create concentric arcs for the signal wave effect\n waves = VGroup()\n num_waves = 3\n for i in range(1, num_waves + 1):\n arc = Arc(\n radius=i * 0.5,\n start_angle=30 * DEGREES,\n angle=120 * DEGREES,\n stroke_width=4,\n color=BLUE\n ).rotate(-90 * DEGREES, about_point=triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out to simulate signal emission\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(1.5)\n .set_stroke(opacity=0, width=1)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2\n )\n self.wait(0.5)\n\n # 4. Disappearance\n self.play(FadeOut(triangle), run_time=1)\n self.wait(0.5)\n\n def act_2_sentimentanalysisscene(self):\n context = Text('Word Vector Similarity Calculation > Applications of Semantic Analysis', font_size=20, color=LIGHT_GRAY).to_corner(UL)\n title = Text('Sentiment Analysis', font_size=44, color=BLUE, weight=BOLD).next_to(context, DOWN, buff=0.5).align_to(context, LEFT)\n subtitle = Text('The Role of Semantic Analysis in Sentiment Analysis', font_size=32, color=YELLOW).next_to(title, DOWN, buff=0.6).align_to(title, LEFT)\n bullet_1 = Text('• Understanding the semantic content of emotional expressions,\\n not only judging polarity but also analyzing the causes of emotions.', font_size=26, line_spacing=1.2)\n bullet_2 = Text('• Identifying the subject, object (Aspect), and degree of emotion\\n to achieve fine-grained emotional mining.', font_size=26, line_spacing=1.2)\n bullets = VGroup(bullet_1, bullet_2).arrange(DOWN, aligned_edge=LEFT, buff=0.6).next_to(subtitle, DOWN, buff=0.8).align_to(subtitle, LEFT).shift(RIGHT * 0.2)\n self.play(FadeIn(context, shift=DOWN * 0.2))\n self.wait(0.5)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(subtitle, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(bullet_1, shift=UP * 0.3))\n self.wait(1)\n self.play(FadeIn(bullet_2, shift=UP * 0.3))\n self.wait(2)\n\n def act_3_lineartransformationscen(self):\n line = Line(LEFT*3, RIGHT*3, color=PURPLE)\n equation = MathTex(\"y = 0\", color=PURPLE).next_to(line, DOWN)\n\n # Create axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-3, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n \n # Fade in coordinate system\n self.play(\n FadeIn(axes),\n Write(axes_labels),\n run_time=1\n )\n self.wait(0.5)\n \n # Transform line and equation\n new_line = line.copy().shift(UP*2)\n new_equation = MathTex(\"y = 2\", color=PURPLE).next_to(new_line, DOWN)\n dashed_line = DashedLine(LEFT*3, RIGHT*3, color=GRAY)\n vertical_line = Line(DOWN*2, UP*2, color=GREEN).shift(LEFT*3)\n \n self.play(\n Transform(line, new_line),\n Transform(equation, new_equation),\n Create(dashed_line),\n Create(vertical_line),\n run_time=2\n )\n self.wait()\n \n # Final pulse effect\n for mobj in [line, equation, axes, axes_labels, dashed_line, vertical_line]:\n self.play(\n mobj.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n mobj.animate.scale(1/1.1),\n run_time=0.5\n )\n \n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_005242", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralCalculation", "num_animations": 14, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "ProtocolDesign", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "PythagoreanTheorem", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_000365", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaveEquationAnimation", "num_animations": 26, "num_rich_primitives": 3, "prompt": "How can I create an educational animation using a tool that illustrates the one-dimensional wave equation, its general solution, and briefly touches on particular solutions with accompanied explanations, pausing between each step to allow the content to be absorbed?", "code": "from manim import *\nimport numpy as np\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: The One-Dimensional Wave Equation\n # ------------------------------------------------------------------\n title = Text(\"The One-Dimensional Wave Equation\", font_size=40).to_edge(UP)\n \n wave_equation = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n ).next_to(title, DOWN, buff=0.5)\n \n eq_explanation = Text(\n \"This PDE describes how a disturbance evolves in space (x) and time (t).\",\n font_size=24,\n color=GRAY\n ).next_to(wave_equation, DOWN, buff=0.3)\n\n self.play(Write(title))\n self.wait(1)\n self.play(Write(wave_equation))\n self.play(FadeIn(eq_explanation))\n self.wait(2)\n \n self.play(FadeOut(title), FadeOut(wave_equation), FadeOut(eq_explanation))\n\n # ------------------------------------------------------------------\n # 2. General Solution (d'Alembert's Formula)\n # ------------------------------------------------------------------\n solution_title = Text(\"General Solution (d'Alembert)\", font_size=36).to_edge(UP)\n \n d_alembert = MathTex(\n r\"u(x,t) = f(x - ct) + g(x + ct)\",\n font_size=48,\n color=YELLOW\n ).next_to(solution_title, DOWN, buff=0.5)\n \n sol_explanation = Text(\n \"Superposition of a right-moving wave f and a left-moving wave g.\",\n font_size=24,\n color=GRAY\n ).next_to(d_alembert, DOWN, buff=0.3)\n\n self.play(Write(solution_title))\n self.play(Write(d_alembert))\n self.play(FadeIn(sol_explanation))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # 3. Visualization of Wave Components\n # ------------------------------------------------------------------\n self.play(FadeOut(solution_title), FadeOut(d_alembert), FadeOut(sol_explanation))\n\n # Setup Axes\n axes = Axes(\n x_range=[-8, 8, 2],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": True, \"include_numbers\": False},\n ).shift(DOWN * 0.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"u\")\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n\n # Time Tracker and Wave Speed\n t_tracker = ValueTracker(0)\n c = 1.5 \n\n # Define Wave Functions (Gaussian Pulses)\n def right_wave(x):\n return np.exp(-(x - c * t_tracker.get_value())**2)\n \n def left_wave(x):\n return np.exp(-(x + c * t_tracker.get_value())**2)\n \n def superposition_wave(x):\n return right_wave(x) + left_wave(x)\n\n # Create Dynamic Plots\n plot_right = always_redraw(lambda: axes.plot(right_wave, color=BLUE))\n plot_left = always_redraw(lambda: axes.plot(left_wave, color=GREEN))\n plot_sum = always_redraw(lambda: axes.plot(superposition_wave, color=YELLOW))\n\n # --- 3a. Right Moving Wave ---\n step_text = Text(\"1. Right-moving wave: f(x-ct)\", font_size=28).to_edge(UP)\n label_f = MathTex(r\"f(x-ct)\", color=BLUE, font_size=30).next_to(plot_right, UR, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_right), Write(label_f))\n self.play(t_tracker.animate.set_value(3), run_time=3, rate_func=linear)\n self.wait(1)\n \n t_tracker.set_value(0)\n self.play(FadeOut(plot_right), FadeOut(label_f), FadeOut(step_text))\n\n # --- 3b. Left Moving Wave ---\n step_text = Text(\"2. Left-moving wave: g(x+ct)\", font_size=28).to_edge(UP)\n label_g = MathTex(r\"g(x+ct)\", color=GREEN, font_size=30).next_to(plot_left, UL, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_left), Write(label_g))\n self.play(t_tracker.animate.set_value(3), run_time=3, rate_func=linear)\n self.wait(1)\n \n t_tracker.set_value(0)\n self.play(FadeOut(plot_left), FadeOut(label_g), FadeOut(step_text))\n\n # --- 3c. Superposition ---\n step_text = Text(\"3. Superposition: u(x,t) = f + g\", font_size=28).to_edge(UP)\n label_u = MathTex(r\"u(x,t)\", color=YELLOW, font_size=30).next_to(plot_sum, UP, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_sum), Write(label_u))\n self.play(t_tracker.animate.set_value(3), run_time=4, rate_func=linear)\n self.wait(2)\n \n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(plot_sum), FadeOut(label_u), FadeOut(step_text)\n )\n\n # ------------------------------------------------------------------\n # 4. Particular Solutions\n # ------------------------------------------------------------------\n particular_title = Text(\"Particular Solutions\", font_size=36).to_edge(UP)\n \n standing_wave_eq = MathTex(\n r\"u(x,t) = \\sin(x)\\cos(ct)\",\n font_size=40\n ).next_to(particular_title, DOWN, buff=0.5)\n \n particular_text = Text(\n \"Derived from specific initial/boundary conditions.\\nExample: Standing waves on a string.\",\n font_size=24,\n color=GRAY\n ).next_to(standing_wave_eq, DOWN, buff=0.5)\n\n self.play(Write(particular_title))\n self.play(Write(standing_wave_eq))\n self.play(FadeIn(particular_text))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # 5. Conclusion\n # ------------------------------------------------------------------\n conclusion = Text(\n \"Understanding wave behavior through decomposition.\",\n font_size=30\n ).to_edge(DOWN)\n \n self.play(FadeIn(conclusion))\n self.wait(2)\n \n self.play(\n FadeOut(particular_title), FadeOut(standing_wave_eq),\n FadeOut(particular_text), FadeOut(conclusion)\n )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "How can I create an educational animation using a tool that illustrates the one-dimensional wave equation, its general solution, and briefly touches on particular solutions with accompanied explanations, pausing between each step to allow the content to be absorbed?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: The One-Dimensional Wave Equation\n # ------------------------------------------------------------------\n title = Text(\"The One-Dimensional Wave Equation\", font_size=40).to_edge(UP)\n \n wave_equation = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n ).next_to(title, DOWN, buff=0.5)\n \n eq_explanation = Text(\n \"This PDE describes how a disturbance evolves in space (x) and time (t).\",\n font_size=24,\n color=GRAY\n ).next_to(wave_equation, DOWN, buff=0.3)\n\n self.play(Write(title))\n self.wait(1)\n self.play(Write(wave_equation))\n self.play(FadeIn(eq_explanation))\n self.wait(2)\n \n self.play(FadeOut(title), FadeOut(wave_equation), FadeOut(eq_explanation))\n\n # ------------------------------------------------------------------\n # 2. General Solution (d'Alembert's Formula)\n # ------------------------------------------------------------------\n solution_title = Text(\"General Solution (d'Alembert)\", font_size=36).to_edge(UP)\n \n d_alembert = MathTex(\n r\"u(x,t) = f(x - ct) + g(x + ct)\",\n font_size=48,\n color=YELLOW\n ).next_to(solution_title, DOWN, buff=0.5)\n \n sol_explanation = Text(\n \"Superposition of a right-moving wave f and a left-moving wave g.\",\n font_size=24,\n color=GRAY\n ).next_to(d_alembert, DOWN, buff=0.3)\n\n self.play(Write(solution_title))\n self.play(Write(d_alembert))\n self.play(FadeIn(sol_explanation))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # 3. Visualization of Wave Components\n # ------------------------------------------------------------------\n self.play(FadeOut(solution_title), FadeOut(d_alembert), FadeOut(sol_explanation))\n\n # Setup Axes\n axes = Axes(\n x_range=[-8, 8, 2],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": True, \"include_numbers\": False},\n ).shift(DOWN * 0.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"u\")\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n\n # Time Tracker and Wave Speed\n t_tracker = ValueTracker(0)\n c = 1.5 \n\n # Define Wave Functions (Gaussian Pulses)\n def right_wave(x):\n return np.exp(-(x - c * t_tracker.get_value())**2)\n \n def left_wave(x):\n return np.exp(-(x + c * t_tracker.get_value())**2)\n \n def superposition_wave(x):\n return right_wave(x) + left_wave(x)\n\n # Create Dynamic Plots\n plot_right = always_redraw(lambda: axes.plot(right_wave, color=BLUE))\n plot_left = always_redraw(lambda: axes.plot(left_wave, color=GREEN))\n plot_sum = always_redraw(lambda: axes.plot(superposition_wave, color=YELLOW))\n\n # --- 3a. Right Moving Wave ---\n step_text = Text(\"1. Right-moving wave: f(x-ct)\", font_size=28).to_edge(UP)\n label_f = MathTex(r\"f(x-ct)\", color=BLUE, font_size=30).next_to(plot_right, UR, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_right), Write(label_f))\n self.play(t_tracker.animate.set_value(3), run_time=3, rate_func=linear)\n self.wait(1)\n \n t_tracker.set_value(0)\n self.play(FadeOut(plot_right), FadeOut(label_f), FadeOut(step_text))\n\n # --- 3b. Left Moving Wave ---\n step_text = Text(\"2. Left-moving wave: g(x+ct)\", font_size=28).to_edge(UP)\n label_g = MathTex(r\"g(x+ct)\", color=GREEN, font_size=30).next_to(plot_left, UL, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_left), Write(label_g))\n self.play(t_tracker.animate.set_value(3), run_time=3, rate_func=linear)\n self.wait(1)\n \n t_tracker.set_value(0)\n self.play(FadeOut(plot_left), FadeOut(label_g), FadeOut(step_text))\n\n # --- 3c. Superposition ---\n step_text = Text(\"3. Superposition: u(x,t) = f + g\", font_size=28).to_edge(UP)\n label_u = MathTex(r\"u(x,t)\", color=YELLOW, font_size=30).next_to(plot_sum, UP, buff=0.2)\n \n self.play(Write(step_text))\n self.play(Create(plot_sum), Write(label_u))\n self.play(t_tracker.animate.set_value(3), run_time=4, rate_func=linear)\n self.wait(2)\n \n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(plot_sum), FadeOut(label_u), FadeOut(step_text)\n )\n\n # ------------------------------------------------------------------\n # 4. Particular Solutions\n # ------------------------------------------------------------------\n particular_title = Text(\"Particular Solutions\", font_size=36).to_edge(UP)\n \n standing_wave_eq = MathTex(\n r\"u(x,t) = \\sin(x)\\cos(ct)\",\n font_size=40\n ).next_to(particular_title, DOWN, buff=0.5)\n \n particular_text = Text(\n \"Derived from specific initial/boundary conditions.\\nExample: Standing waves on a string.\",\n font_size=24,\n color=GRAY\n ).next_to(standing_wave_eq, DOWN, buff=0.5)\n\n self.play(Write(particular_title))\n self.play(Write(standing_wave_eq))\n self.play(FadeIn(particular_text))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # 5. Conclusion\n # ------------------------------------------------------------------\n conclusion = Text(\n \"Understanding wave behavior through decomposition.\",\n font_size=30\n ).to_edge(DOWN)\n \n self.play(FadeIn(conclusion))\n self.wait(2)\n \n self.play(\n FadeOut(particular_title), FadeOut(standing_wave_eq),\n FadeOut(particular_text), FadeOut(conclusion)\n )\n```"}]}
{"id": "multi_act_v2_00108", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0108", "num_animations": 16, "prompt": "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 chemistry animation that visually represents an electrochemical concept. The animation should start with a 3x3 grid of lithium ions to demonstrate the initial state of a battery's el\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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0108(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_areaundercurveexample()\n self.clear_stage()\n self.act_2_govtexpendituremultiplie()\n\n def act_1_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n\n def act_2_govtexpendituremultiplie(self):\n self.camera.background_color = '#1e1e1e'\n title = Title('2. Government Expenditure Multiplier Formula', include_underline=True)\n title.set_color(YELLOW)\n self.play(Write(title))\n self.wait(0.5)\n text1 = Tex('Focus on fiscal policy: only consider changes in $G$.', font_size=36)\n text2 = Tex('$\\\\bullet$ Take the increment (or partial derivative) of the above equation:', font_size=36)\n eq1 = MathTex('\\\\Delta Y = \\\\frac{1}{1 - c} \\\\Delta G', font_size=48)\n eq1.set_color(TEAL)\n text3 = Tex('$\\\\bullet$ Therefore, the \\\\textbf{government expenditure multiplier} is:', font_size=36)\n eq2 = MathTex('k_G = \\\\frac{\\\\Delta Y}{\\\\Delta G} = \\\\frac{1}{1 - c}', font_size=48)\n eq2.set_color(GREEN_C)\n content_group = VGroup(text1, text2, eq1, text3, eq2)\n content_group.arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content_group.next_to(title, DOWN, buff=0.5)\n content_group.shift(RIGHT * 0.5)\n eq1.set_x(0)\n eq2.set_x(0)\n self.play(FadeIn(text1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(text2, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq1))\n self.wait(1.5)\n self.play(FadeIn(text3, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq2))\n self.wait(1)\n highlight_box = SurroundingRectangle(eq2, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(2)\n self.play(FadeOut(VGroup(title, content_group, highlight_box)))\n self.wait(0.5)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 chemistry animation that visually represents an electrochemical concept. The animation should start with a 3x3 grid of lithium ions to demonstrate the initial state of a battery's el\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_0108(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_areaundercurveexample()\n self.clear_stage()\n self.act_2_govtexpendituremultiplie()\n\n def act_1_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n\n def act_2_govtexpendituremultiplie(self):\n self.camera.background_color = '#1e1e1e'\n title = Title('2. Government Expenditure Multiplier Formula', include_underline=True)\n title.set_color(YELLOW)\n self.play(Write(title))\n self.wait(0.5)\n text1 = Tex('Focus on fiscal policy: only consider changes in $G$.', font_size=36)\n text2 = Tex('$\\\\bullet$ Take the increment (or partial derivative) of the above equation:', font_size=36)\n eq1 = MathTex('\\\\Delta Y = \\\\frac{1}{1 - c} \\\\Delta G', font_size=48)\n eq1.set_color(TEAL)\n text3 = Tex('$\\\\bullet$ Therefore, the \\\\textbf{government expenditure multiplier} is:', font_size=36)\n eq2 = MathTex('k_G = \\\\frac{\\\\Delta Y}{\\\\Delta G} = \\\\frac{1}{1 - c}', font_size=48)\n eq2.set_color(GREEN_C)\n content_group = VGroup(text1, text2, eq1, text3, eq2)\n content_group.arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content_group.next_to(title, DOWN, buff=0.5)\n content_group.shift(RIGHT * 0.5)\n eq1.set_x(0)\n eq2.set_x(0)\n self.play(FadeIn(text1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(text2, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq1))\n self.wait(1.5)\n self.play(FadeIn(text3, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq2))\n self.wait(1)\n highlight_box = SurroundingRectangle(eq2, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(2)\n self.play(FadeOut(VGroup(title, content_group, highlight_box)))\n self.wait(0.5)\n```"}]}
{"id": "adaption-unified-manim-instructions_007931", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "FundamentalTheoremOfCalculus", "num_animations": 11, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralSolution", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ChemicalBondingScene", "num_animations": 8, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "manim-sft-10k_004610", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "EnhancedIntegralAnimation", "num_animations": 17, "num_rich_primitives": 2, "prompt": "Here’s an enhanced version of the animation with additional features:\n\nThe animation begins by displaying the integral problem \\(\\int_1^3 \\sqrt{x}\\,dx\\) prominently on the screen. As the axes and labels appear, the graph of \\(y = \\sqrt{x}\\) is plotted smoothly, accompanied by a dynamic numerical counter that tracks the x-values in real-time. The area under the curve between \\(x = 1\\) and \\(x = 3\\) is highlighted with a gradient fill that transitions from blue to green, while a Riemann sum visualization appears briefly, showing rectangles converging to the exact area as their widths shrink. The integral solution is then derived step-by-step: the antiderivative \\(\\frac{2}{3}x^{3/2}\\) is displayed, followed by the evaluation at the bounds, which are highlighted on the graph with pulsating dots. The final calculation \\(2\\sqrt{3} - \\frac{2}{3}\\) is shown alongside an animated simplification process, where terms are color-coded for clarity. To reinforce understanding, a small info box appears at the bottom, explaining the Fundamental Theorem of Calculus, and the entire scene concludes with the final answer centered on a clean slate, slowly zooming in for emphasis. This enhanced version not only demonstrates the computation but also provides visual and textual context to deepen comprehension.", "code": "from manim import *\nimport math\n\nclass EnhancedIntegralAnimation(Scene):\n def construct(self):\n # Initial integral display\n integral = MathTex(r\"\\int_1^3 \\sqrt{x}\\,dx\").scale(2)\n self.play(Write(integral))\n self.wait(1)\n \n # Setup axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 2, 0.5],\n axis_config={\"color\": BLUE},\n x_axis_config={\n \"numbers_to_include\": [1, 2, 3],\n \"decimal_number_config\": {\"num_decimal_places\": 0},\n },\n y_axis_config={\n \"numbers_to_include\": [0.5, 1, 1.5, 2],\n },\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Transform integral to smaller size and move to top\n self.play(\n integral.animate.scale(0.5).to_edge(UP),\n Create(axes),\n Write(axes_labels),\n )\n self.wait(0.5)\n \n # Plot the function\n graph = axes.plot(lambda x: math.sqrt(x), color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=r\"y = \\sqrt{x}\")\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n \n # Highlight area under curve\n area = axes.get_area(graph, x_range=(1, 3), color=[BLUE, GREEN])\n self.play(FadeIn(area))\n self.wait(1)\n \n # Riemann sum visualization\n riemann_rects = axes.get_riemann_rectangles(\n graph, x_range=[1, 3], dx=0.5, input_sample_type=\"left\", color=BLUE, fill_opacity=0.6\n )\n self.play(FadeIn(riemann_rects))\n self.wait(0.5)\n \n for dx in [0.2, 0.1, 0.05]:\n new_rects = axes.get_riemann_rectangles(\n graph, x_range=[1, 3], dx=dx, input_sample_type=\"left\", color=BLUE, fill_opacity=0.6\n )\n self.play(Transform(riemann_rects, new_rects), run_time=0.5)\n \n self.play(FadeOut(riemann_rects))\n self.wait(0.5)\n \n # Solution steps\n antiderivative = MathTex(r\"\\frac{2}{3}x^{3/2}\").next_to(integral, DOWN)\n self.play(Write(antiderivative))\n self.wait(1)\n \n evaluated = MathTex(\n r\"\\left.\\frac{2}{3}x^{3/2}\\right|_1^3 = \",\n r\"\\frac{2}{3}(3)^{3/2} - \\frac{2}{3}(1)^{3/2}\"\n ).next_to(antiderivative, DOWN)\n self.play(Write(evaluated[0]))\n self.wait(0.5)\n self.play(Write(evaluated[1]))\n self.wait(1)\n \n simplified = MathTex(\n r\"= 2\\sqrt{3} - \\frac{2}{3}\"\n ).next_to(evaluated, DOWN)\n self.play(Write(simplified))\n self.wait(1)\n \n # Highlight bounds on graph\n dot1 = Dot(axes.c2p(1, math.sqrt(1)), color=RED)\n dot3 = Dot(axes.c2p(3, math.sqrt(3)), color=RED)\n self.play(FadeIn(dot1), FadeIn(dot3))\n self.play(\n dot1.animate.scale(1.5).set_opacity(0.5),\n dot3.animate.scale(1.5).set_opacity(0.5),\n run_time=0.5\n )\n self.play(\n dot1.animate.scale(1/1.5).set_opacity(1),\n dot3.animate.scale(1/1.5).set_opacity(1),\n run_time=0.5\n )\n self.wait(1)\n \n # Info box\n info_box = Rectangle(width=5, height=1.5, color=WHITE, fill_color=BLACK, fill_opacity=0.8)\n info_text = Text(\"Fundamental Theorem of Calculus:\\nThe integral equals the antiderivative\\nat the bounds.\", font_size=24)\n info_group = VGroup(info_box, info_text)\n info_group.to_edge(DOWN)\n self.play(FadeIn(info_box), Write(info_text))\n self.wait(2)\n \n # Final answer\n final_answer = MathTex(r\"\\int_1^3 \\sqrt{x}\\,dx = 2\\sqrt{3} - \\frac{2}{3}\").scale(1.5)\n self.play(\n FadeOut(VGroup(axes, axes_labels, graph, graph_label, area, dot1, dot3, integral, antiderivative, evaluated, simplified, info_group)),\n FadeIn(final_answer)\n )\n self.wait(1)\n self.play(final_answer.animate.scale(1.2))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Here’s an enhanced version of the animation with additional features:\n\nThe animation begins by displaying the integral problem \\(\\int_1^3 \\sqrt{x}\\,dx\\) prominently on the screen. As the axes and labels appear, the graph of \\(y = \\sqrt{x}\\) is plotted smoothly, accompanied by a dynamic numerical counter that tracks the x-values in real-time. The area under the curve between \\(x = 1\\) and \\(x = 3\\) is highlighted with a gradient fill that transitions from blue to green, while a Riemann sum visualization appears briefly, showing rectangles converging to the exact area as their widths shrink. The integral solution is then derived step-by-step: the antiderivative \\(\\frac{2}{3}x^{3/2}\\) is displayed, followed by the evaluation at the bounds, which are highlighted on the graph with pulsating dots. The final calculation \\(2\\sqrt{3} - \\frac{2}{3}\\) is shown alongside an animated simplification process, where terms are color-coded for clarity. To reinforce understanding, a small info box appears at the bottom, explaining the Fundamental Theorem of Calculus, and the entire scene concludes with the final answer centered on a clean slate, slowly zooming in for emphasis. This enhanced version not only demonstrates the computation but also provides visual and textual context to deepen comprehension."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport math\n\nclass EnhancedIntegralAnimation(Scene):\n def construct(self):\n # Initial integral display\n integral = MathTex(r\"\\int_1^3 \\sqrt{x}\\,dx\").scale(2)\n self.play(Write(integral))\n self.wait(1)\n \n # Setup axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 2, 0.5],\n axis_config={\"color\": BLUE},\n x_axis_config={\n \"numbers_to_include\": [1, 2, 3],\n \"decimal_number_config\": {\"num_decimal_places\": 0},\n },\n y_axis_config={\n \"numbers_to_include\": [0.5, 1, 1.5, 2],\n },\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Transform integral to smaller size and move to top\n self.play(\n integral.animate.scale(0.5).to_edge(UP),\n Create(axes),\n Write(axes_labels),\n )\n self.wait(0.5)\n \n # Plot the function\n graph = axes.plot(lambda x: math.sqrt(x), color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=r\"y = \\sqrt{x}\")\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n \n # Highlight area under curve\n area = axes.get_area(graph, x_range=(1, 3), color=[BLUE, GREEN])\n self.play(FadeIn(area))\n self.wait(1)\n \n # Riemann sum visualization\n riemann_rects = axes.get_riemann_rectangles(\n graph, x_range=[1, 3], dx=0.5, input_sample_type=\"left\", color=BLUE, fill_opacity=0.6\n )\n self.play(FadeIn(riemann_rects))\n self.wait(0.5)\n \n for dx in [0.2, 0.1, 0.05]:\n new_rects = axes.get_riemann_rectangles(\n graph, x_range=[1, 3], dx=dx, input_sample_type=\"left\", color=BLUE, fill_opacity=0.6\n )\n self.play(Transform(riemann_rects, new_rects), run_time=0.5)\n \n self.play(FadeOut(riemann_rects))\n self.wait(0.5)\n \n # Solution steps\n antiderivative = MathTex(r\"\\frac{2}{3}x^{3/2}\").next_to(integral, DOWN)\n self.play(Write(antiderivative))\n self.wait(1)\n \n evaluated = MathTex(\n r\"\\left.\\frac{2}{3}x^{3/2}\\right|_1^3 = \",\n r\"\\frac{2}{3}(3)^{3/2} - \\frac{2}{3}(1)^{3/2}\"\n ).next_to(antiderivative, DOWN)\n self.play(Write(evaluated[0]))\n self.wait(0.5)\n self.play(Write(evaluated[1]))\n self.wait(1)\n \n simplified = MathTex(\n r\"= 2\\sqrt{3} - \\frac{2}{3}\"\n ).next_to(evaluated, DOWN)\n self.play(Write(simplified))\n self.wait(1)\n \n # Highlight bounds on graph\n dot1 = Dot(axes.c2p(1, math.sqrt(1)), color=RED)\n dot3 = Dot(axes.c2p(3, math.sqrt(3)), color=RED)\n self.play(FadeIn(dot1), FadeIn(dot3))\n self.play(\n dot1.animate.scale(1.5).set_opacity(0.5),\n dot3.animate.scale(1.5).set_opacity(0.5),\n run_time=0.5\n )\n self.play(\n dot1.animate.scale(1/1.5).set_opacity(1),\n dot3.animate.scale(1/1.5).set_opacity(1),\n run_time=0.5\n )\n self.wait(1)\n \n # Info box\n info_box = Rectangle(width=5, height=1.5, color=WHITE, fill_color=BLACK, fill_opacity=0.8)\n info_text = Text(\"Fundamental Theorem of Calculus:\\nThe integral equals the antiderivative\\nat the bounds.\", font_size=24)\n info_group = VGroup(info_box, info_text)\n info_group.to_edge(DOWN)\n self.play(FadeIn(info_box), Write(info_text))\n self.wait(2)\n \n # Final answer\n final_answer = MathTex(r\"\\int_1^3 \\sqrt{x}\\,dx = 2\\sqrt{3} - \\frac{2}{3}\").scale(1.5)\n self.play(\n FadeOut(VGroup(axes, axes_labels, graph, graph_label, area, dot1, dot3, integral, antiderivative, evaluated, simplified, info_group)),\n FadeIn(final_answer)\n )\n self.wait(1)\n self.play(final_answer.animate.scale(1.2))\n self.wait(2)\n```"}]}
{"id": "multi_act_v2_00579", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0579", "num_animations": 16, "prompt": "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: 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 2: Could you create an educational animation that visually demonstrates how the sine wave is generated from the movement of a point along the real axis on the complex plane? Include these specifics:", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0579(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_propertiesofcfls()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_propertiesofcfls(self):\n title = Title('Properties of Context-Free Languages')\n self.play(Write(title))\n self.wait(0.5)\n section = Text('Introduction and Learning Objectives', font_size=36, color=BLUE)\n section.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(section, shift=UP))\n self.wait(0.5)\n topic_title = Text('Topic:', font_size=30, color=YELLOW)\n topic_desc = Text('Analyzing the Capability Boundaries and\\nStructural Characteristics of Context-Free Languages', font_size=28, line_spacing=1.2, t2c={'Context-Free Languages': TEAL})\n topic_group = VGroup(topic_title, topic_desc).arrange(RIGHT, aligned_edge=UP, buff=0.4)\n topic_box = SurroundingRectangle(topic_group, color=YELLOW, buff=0.3)\n topic_full = VGroup(topic_box, topic_group)\n topic_full.next_to(section, DOWN, buff=0.8)\n self.play(Create(topic_box))\n self.play(Write(topic_title), FadeIn(topic_desc))\n self.wait(1)\n desc_text = Text('This lesson shifts from \"construction\" to \"analysis\":', font_size=28, t2c={'\"construction\"': RED_B, '\"analysis\"': GREEN_B})\n bullet_1 = Text('• Closure properties of CFLs under mathematical operations.', font_size=26, color=LIGHT_GREY)\n bullet_2 = Text('• How to prove that certain languages are not CFLs.', font_size=26, color=LIGHT_GREY)\n bullets = VGroup(desc_text, bullet_1, bullet_2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bullet_1.shift(RIGHT * 0.5)\n bullet_2.shift(RIGHT * 0.5)\n bullets.next_to(topic_full, DOWN, buff=0.8)\n self.play(Write(desc_text))\n self.wait(0.5)\n self.play(FadeIn(bullet_1, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(bullet_2, shift=RIGHT))\n self.wait(2)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n area = Area(\n axes=Axes(x_range=[0, 3], y_range=[0, 9]),\n graph=ParametricFunction(func, t_range=[0, 3]),\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n\n # Displaying the function and the area under the curve\n self.play(Write(area.axes), Write(area.graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Displaying the integral notation\n integral_text = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n integral_text.next_to(area, UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # Explanation for the area under the curve\n explanation = Text(\"This shaded area represents the definite integral\", font_size=24)\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Solving the integral\n solution = MathTex(r\"= [\\frac{1}{3}x^3]_0^2\", r\"= \\frac{1}{3}(2^3) - \\frac{1}{3}(0^3)\", r\"= \\frac{8}{3}\")\n solution.next_to(integral_text, DOWN)\n self.play(ReplacementTransform(integral_text, solution))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The value of the definite integral is 8/3.\", font_size=24)\n conclusion.to_edge(DOWN + RIGHT)\n self.play(Transform(explanation, conclusion))\n self.wait(2)\n\n # Clear the scene and end\n self.clear()\n self.wait(1)\n self.play(Write(solution))\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 2: Could you create an educational animation that visually demonstrates how the sine wave is generated from the movement of a point along the real axis on the complex plane? Include these specifics:"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0579(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_propertiesofcfls()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_propertiesofcfls(self):\n title = Title('Properties of Context-Free Languages')\n self.play(Write(title))\n self.wait(0.5)\n section = Text('Introduction and Learning Objectives', font_size=36, color=BLUE)\n section.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(section, shift=UP))\n self.wait(0.5)\n topic_title = Text('Topic:', font_size=30, color=YELLOW)\n topic_desc = Text('Analyzing the Capability Boundaries and\\nStructural Characteristics of Context-Free Languages', font_size=28, line_spacing=1.2, t2c={'Context-Free Languages': TEAL})\n topic_group = VGroup(topic_title, topic_desc).arrange(RIGHT, aligned_edge=UP, buff=0.4)\n topic_box = SurroundingRectangle(topic_group, color=YELLOW, buff=0.3)\n topic_full = VGroup(topic_box, topic_group)\n topic_full.next_to(section, DOWN, buff=0.8)\n self.play(Create(topic_box))\n self.play(Write(topic_title), FadeIn(topic_desc))\n self.wait(1)\n desc_text = Text('This lesson shifts from \"construction\" to \"analysis\":', font_size=28, t2c={'\"construction\"': RED_B, '\"analysis\"': GREEN_B})\n bullet_1 = Text('• Closure properties of CFLs under mathematical operations.', font_size=26, color=LIGHT_GREY)\n bullet_2 = Text('• How to prove that certain languages are not CFLs.', font_size=26, color=LIGHT_GREY)\n bullets = VGroup(desc_text, bullet_1, bullet_2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bullet_1.shift(RIGHT * 0.5)\n bullet_2.shift(RIGHT * 0.5)\n bullets.next_to(topic_full, DOWN, buff=0.8)\n self.play(Write(desc_text))\n self.wait(0.5)\n self.play(FadeIn(bullet_1, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(bullet_2, shift=RIGHT))\n self.wait(2)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n area = Area(\n axes=Axes(x_range=[0, 3], y_range=[0, 9]),\n graph=ParametricFunction(func, t_range=[0, 3]),\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n\n # Displaying the function and the area under the curve\n self.play(Write(area.axes), Write(area.graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Displaying the integral notation\n integral_text = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n integral_text.next_to(area, UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # Explanation for the area under the curve\n explanation = Text(\"This shaded area represents the definite integral\", font_size=24)\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Solving the integral\n solution = MathTex(r\"= [\\frac{1}{3}x^3]_0^2\", r\"= \\frac{1}{3}(2^3) - \\frac{1}{3}(0^3)\", r\"= \\frac{8}{3}\")\n solution.next_to(integral_text, DOWN)\n self.play(ReplacementTransform(integral_text, solution))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The value of the definite integral is 8/3.\", font_size=24)\n conclusion.to_edge(DOWN + RIGHT)\n self.play(Transform(explanation, conclusion))\n self.wait(2)\n\n # Clear the scene and end\n self.clear()\n self.wait(1)\n self.play(Write(solution))\n self.wait(1)\n```"}]}
{"id": "multi_act_v2_00409", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0409", "num_animations": 21, "prompt": "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: 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 2: Here’s the enhanced animation instruction, which retains the original red circle while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n- Act 3: Create a 12-second Manim scene that explains consumer surplus on a demand curve. Show a downward-sloping demand line, a market price line, the traded quantity, and shade the triangle between willingness to pay and the ac", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0409(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_hermitianoperators()\n self.clear_stage()\n self.act_2_circletosquarewithmath()\n self.clear_stage()\n self.act_3_consumersurplusstory()\n\n def act_1_hermitianoperators(self):\n context = Text('Fundamentals of Quantum Mechanics (I) > Operator Theory', font_size=16, color=GRAY).to_corner(UL)\n title = Text('Hermitian Operators and Observable Quantities', font_size=36, color=BLUE)\n title.next_to(context, DOWN, buff=0.5).set_x(0)\n underline = Line(LEFT, RIGHT).match_width(title).next_to(title, DOWN, buff=0.1).set_color(BLUE)\n desc = Text('Hermitian operators ensure that the results of physical measurements\\nare real numbers, serving as the mathematical counterparts of\\nobservable quantities in quantum mechanics.', font_size=28, line_spacing=1.2, t2c={'real numbers': YELLOW, 'observable quantities': GREEN})\n def_title = Text('Definition', font_size=32, color=YELLOW)\n eq = MathTex('A^\\\\dagger = A', font_size=60)\n box = SurroundingRectangle(eq, color=YELLOW, buff=0.25)\n eq_group = VGroup(eq, box)\n eq_desc = Text('Meaning its matrix representation is equal to its conjugate transpose matrix.', font_size=24, t2c={'conjugate transpose': ORANGE})\n content_group = VGroup(desc, def_title, eq_group, eq_desc).arrange(DOWN, buff=0.7)\n content_group.next_to(underline, DOWN, buff=0.7)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.play(Create(underline))\n self.wait(0.5)\n self.play(FadeIn(desc, shift=UP * 0.3))\n self.wait(2)\n self.play(Write(def_title))\n self.wait(0.5)\n self.play(Write(eq))\n self.play(Create(box))\n self.wait(1)\n self.play(FadeIn(eq_desc, shift=UP * 0.2))\n self.wait(3)\n\n def act_2_circletosquarewithmath(self):\n circle = Circle(radius=2, color=RED, fill_opacity=0.5)\n circle_label = Tex(\"Unit Circle (r = 2)\", color=BLUE).next_to(circle, DOWN)\n\n # Show circle and label\n self.play(Create(circle), Write(circle_label))\n self.wait(1)\n\n # Prepare the area formulas\n formula1 = MathTex(\"A = \\\\pi r^2 = \\\\pi (2)^2 = 4\\\\pi\").to_edge(UP)\n formula2 = MathTex(\"\\\\text{For equal area: } s^2 = 4\\\\pi \\\\rightarrow s = 2\\\\sqrt{\\\\pi}\").next_to(formula1, DOWN)\n\n # Show formulas\n self.play(Write(formula1))\n self.wait(0.5)\n self.play(Write(formula2))\n self.wait(1)\n\n # Create the square with equal area\n side_length = 2 * np.sqrt(PI)\n square = Square(side_length=side_length, color=GREEN, fill_opacity=0.5)\n square.move_to(circle.get_center())\n\n # Transform circle to square\n self.play(Transform(circle, square), circle.animate.set_color(GREEN))\n self.wait(1)\n\n # Show side length measurement\n measurement = DoubleArrow(\n start=square.get_corner(DL),\n end=square.get_corner(DR),\n buff=0,\n color=YELLOW\n )\n side_label = MathTex(\"2\\\\sqrt{\\\\pi}\", color=YELLOW).next_to(measurement, DOWN)\n\n self.play(Create(measurement), Write(side_label))\n self.wait(2)\n\n # Move both shapes and formulas to final positions\n circle_copy = Circle(radius=2, color=RED, fill_opacity=0.5).shift(LEFT*3)\n square_copy = Square(side_length=side_length, color=GREEN, fill_opacity=0.5).shift(RIGHT*3)\n formulas = VGroup(formula1, formula2).to_edge(DOWN)\n\n self.play(\n Transform(circle, circle_copy),\n Transform(square, square_copy),\n FadeOut(measurement),\n FadeOut(side_label),\n FadeOut(circle_label),\n formulas.animate.to_edge(DOWN)\n )\n self.wait(2)\n\n def act_3_consumersurplusstory(self):\n title = Text('Consumer Surplus Is Value Above The Market Price', font_size=29).to_edge(UP)\n axes = Axes(x_range=[0, 10, 1], y_range=[0, 10, 1], x_length=6.7, y_length=4.6, tips=False).shift(LEFT * 0.9 + DOWN * 0.1)\n demand = axes.plot(lambda x: 9 - 0.65 * x, x_range=[0.8, 9.0], color=BLUE_D)\n price_y = 4.6\n q_star = (9 - price_y) / 0.65\n price_line = Line(axes.c2p(0.8, price_y), axes.c2p(q_star, price_y), color=ORANGE, stroke_width=5)\n quantity_line = DashedLine(axes.c2p(q_star, 0), axes.c2p(q_star, price_y), color=GRAY_B)\n surplus = Polygon(axes.c2p(0.8, price_y), axes.c2p(q_star, price_y), axes.c2p(0.8, 9 - 0.65 * 0.8), color=GREEN_D, fill_opacity=0.3, stroke_width=0)\n labels = VGroup(Text('demand', font_size=20, color=BLUE_D).next_to(demand, UP, buff=0.12), Text('market price', font_size=20, color=ORANGE).next_to(price_line, DOWN, buff=0.15), Text('consumer surplus', font_size=20, color=GREEN_D).next_to(surplus, RIGHT, buff=0.15))\n caption = Text('Buyers up to the traded quantity would have paid more than the price they actually pay, and that gap becomes surplus.', font_size=20, color=WHITE).to_edge(DOWN)\n caption_group = VGroup(BackgroundRectangle(caption, fill_opacity=0.88, buff=0.14), caption)\n\n self.play(FadeIn(title), Create(axes), Create(demand), run_time=2.0)\n self.play(Create(price_line), Create(quantity_line), FadeIn(labels[0]), FadeIn(labels[1]), run_time=1.8)\n self.play(FadeIn(surplus), FadeIn(labels[2]), run_time=1.5)\n self.play(FadeIn(caption_group), Indicate(surplus, color=YELLOW_A), run_time=1.5)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 2: Here’s the enhanced animation instruction, which retains the original red circle while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n- Act 3: Create a 12-second Manim scene that explains consumer surplus on a demand curve. Show a downward-sloping demand line, a market price line, the traded quantity, and shade the triangle between willingness to pay and the ac"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0409(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_hermitianoperators()\n self.clear_stage()\n self.act_2_circletosquarewithmath()\n self.clear_stage()\n self.act_3_consumersurplusstory()\n\n def act_1_hermitianoperators(self):\n context = Text('Fundamentals of Quantum Mechanics (I) > Operator Theory', font_size=16, color=GRAY).to_corner(UL)\n title = Text('Hermitian Operators and Observable Quantities', font_size=36, color=BLUE)\n title.next_to(context, DOWN, buff=0.5).set_x(0)\n underline = Line(LEFT, RIGHT).match_width(title).next_to(title, DOWN, buff=0.1).set_color(BLUE)\n desc = Text('Hermitian operators ensure that the results of physical measurements\\nare real numbers, serving as the mathematical counterparts of\\nobservable quantities in quantum mechanics.', font_size=28, line_spacing=1.2, t2c={'real numbers': YELLOW, 'observable quantities': GREEN})\n def_title = Text('Definition', font_size=32, color=YELLOW)\n eq = MathTex('A^\\\\dagger = A', font_size=60)\n box = SurroundingRectangle(eq, color=YELLOW, buff=0.25)\n eq_group = VGroup(eq, box)\n eq_desc = Text('Meaning its matrix representation is equal to its conjugate transpose matrix.', font_size=24, t2c={'conjugate transpose': ORANGE})\n content_group = VGroup(desc, def_title, eq_group, eq_desc).arrange(DOWN, buff=0.7)\n content_group.next_to(underline, DOWN, buff=0.7)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.play(Create(underline))\n self.wait(0.5)\n self.play(FadeIn(desc, shift=UP * 0.3))\n self.wait(2)\n self.play(Write(def_title))\n self.wait(0.5)\n self.play(Write(eq))\n self.play(Create(box))\n self.wait(1)\n self.play(FadeIn(eq_desc, shift=UP * 0.2))\n self.wait(3)\n\n def act_2_circletosquarewithmath(self):\n circle = Circle(radius=2, color=RED, fill_opacity=0.5)\n circle_label = Tex(\"Unit Circle (r = 2)\", color=BLUE).next_to(circle, DOWN)\n\n # Show circle and label\n self.play(Create(circle), Write(circle_label))\n self.wait(1)\n\n # Prepare the area formulas\n formula1 = MathTex(\"A = \\\\pi r^2 = \\\\pi (2)^2 = 4\\\\pi\").to_edge(UP)\n formula2 = MathTex(\"\\\\text{For equal area: } s^2 = 4\\\\pi \\\\rightarrow s = 2\\\\sqrt{\\\\pi}\").next_to(formula1, DOWN)\n\n # Show formulas\n self.play(Write(formula1))\n self.wait(0.5)\n self.play(Write(formula2))\n self.wait(1)\n\n # Create the square with equal area\n side_length = 2 * np.sqrt(PI)\n square = Square(side_length=side_length, color=GREEN, fill_opacity=0.5)\n square.move_to(circle.get_center())\n\n # Transform circle to square\n self.play(Transform(circle, square), circle.animate.set_color(GREEN))\n self.wait(1)\n\n # Show side length measurement\n measurement = DoubleArrow(\n start=square.get_corner(DL),\n end=square.get_corner(DR),\n buff=0,\n color=YELLOW\n )\n side_label = MathTex(\"2\\\\sqrt{\\\\pi}\", color=YELLOW).next_to(measurement, DOWN)\n\n self.play(Create(measurement), Write(side_label))\n self.wait(2)\n\n # Move both shapes and formulas to final positions\n circle_copy = Circle(radius=2, color=RED, fill_opacity=0.5).shift(LEFT*3)\n square_copy = Square(side_length=side_length, color=GREEN, fill_opacity=0.5).shift(RIGHT*3)\n formulas = VGroup(formula1, formula2).to_edge(DOWN)\n\n self.play(\n Transform(circle, circle_copy),\n Transform(square, square_copy),\n FadeOut(measurement),\n FadeOut(side_label),\n FadeOut(circle_label),\n formulas.animate.to_edge(DOWN)\n )\n self.wait(2)\n\n def act_3_consumersurplusstory(self):\n title = Text('Consumer Surplus Is Value Above The Market Price', font_size=29).to_edge(UP)\n axes = Axes(x_range=[0, 10, 1], y_range=[0, 10, 1], x_length=6.7, y_length=4.6, tips=False).shift(LEFT * 0.9 + DOWN * 0.1)\n demand = axes.plot(lambda x: 9 - 0.65 * x, x_range=[0.8, 9.0], color=BLUE_D)\n price_y = 4.6\n q_star = (9 - price_y) / 0.65\n price_line = Line(axes.c2p(0.8, price_y), axes.c2p(q_star, price_y), color=ORANGE, stroke_width=5)\n quantity_line = DashedLine(axes.c2p(q_star, 0), axes.c2p(q_star, price_y), color=GRAY_B)\n surplus = Polygon(axes.c2p(0.8, price_y), axes.c2p(q_star, price_y), axes.c2p(0.8, 9 - 0.65 * 0.8), color=GREEN_D, fill_opacity=0.3, stroke_width=0)\n labels = VGroup(Text('demand', font_size=20, color=BLUE_D).next_to(demand, UP, buff=0.12), Text('market price', font_size=20, color=ORANGE).next_to(price_line, DOWN, buff=0.15), Text('consumer surplus', font_size=20, color=GREEN_D).next_to(surplus, RIGHT, buff=0.15))\n caption = Text('Buyers up to the traded quantity would have paid more than the price they actually pay, and that gap becomes surplus.', font_size=20, color=WHITE).to_edge(DOWN)\n caption_group = VGroup(BackgroundRectangle(caption, fill_opacity=0.88, buff=0.14), caption)\n\n self.play(FadeIn(title), Create(axes), Create(demand), run_time=2.0)\n self.play(Create(price_line), Create(quantity_line), FadeIn(labels[0]), FadeIn(labels[1]), run_time=1.8)\n self.play(FadeIn(surplus), FadeIn(labels[2]), run_time=1.5)\n self.play(FadeIn(caption_group), Indicate(surplus, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_006472", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaterFormation", "num_animations": 8, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_004716", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 13, "num_rich_primitives": 3, "prompt": "Create an educational animation that explains how to calculate the area under the curve of the function f(x) = x^2 from x=1 to x=2. Start by displaying the function and then introduce the concept of the definite integral to find the area. Step by step, write out the integral sign with limits a and b, specify the bounds as a=1 and b=2, and then replace a and b with the actual values in the integral. Show the intermediate steps of solving the integral, including evaluating from the lower to the upper limit, and then simplify the result to find the numerical value of the area. Conclude by presenting the final area value clearly and labeling the resulting area under the curve as 7/3 on the screen, with a written conclusion that appears at the bottom. Ensure the animation includes appropriate pauses between steps to allow the viewer to follow along.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Introduction: Display Axes, Curve, and Function ---\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).scale(0.8).to_edge(LEFT, buff=1)\n\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.2])\n graph_label = axes.get_graph_label(graph, label=MathTex(\"f(x) = x^2\"), x_val=2.1, direction=UR)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --- 2. Concept Introduction: Definite Integral ---\n eq_pos = RIGHT * 3 + UP * 1.5\n \n intro_text = Text(\"To find the area under the curve,\", font_size=24).shift(eq_pos + DOWN * 1.5)\n method_text = Text(\"we use the definite integral.\", font_size=24).next_to(intro_text, DOWN, buff=0.3)\n \n self.play(Write(intro_text), Write(method_text))\n self.wait(2)\n self.play(FadeOut(intro_text), FadeOut(method_text))\n\n # --- 3. Symbolic Setup ---\n # Generic integral with 'a' and 'b'\n integral_generic = MathTex(\n r\"\\text{Area} = \\int_{a}^{b}\", \"f(x)\", \"\\\\,dx\",\n color=YELLOW\n ).shift(eq_pos)\n \n self.play(Write(integral_generic))\n self.wait(1)\n\n # Explicitly specify the bounds\n bounds_text = MathTex(\"a = 1, \\\\quad b = 2\", font_size=36).next_to(integral_generic, DOWN, buff=0.5)\n self.play(Write(bounds_text))\n self.wait(2)\n\n # Replace 'a' and 'b' with actual values\n integral_specific = MathTex(\n r\"\\text{Area} = \\int_{1}^{2}\", \"x^2\", \"\\\\,dx\",\n color=YELLOW\n ).shift(eq_pos)\n\n self.play(\n TransformMatchingTex(integral_generic, integral_specific),\n FadeOut(bounds_text)\n )\n self.wait(1)\n\n # --- 4. Calculation Steps ---\n # Antiderivative\n step_antiderivative = MathTex(\n r\"= \\\\left[ \\\\frac{x^3}{3} \\\\right]_{1}^{2}\",\n color=YELLOW\n ).next_to(integral_specific, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(Write(step_antiderivative))\n self.wait(1)\n\n # Evaluation (Upper - Lower)\n step_evaluation = MathTex(\n r\"= \\\\frac{2^3}{3}\", \"-\", r\"\\\\frac{1^3}{3}\",\n color=YELLOW\n ).next_to(step_antiderivative, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_antiderivative.copy(), step_evaluation))\n self.wait(1)\n\n # Simplification\n step_simplify = MathTex(\n r\"= \\\\frac{8}{3}\", \"-\", r\"\\\\frac{1}{3}\",\n color=YELLOW\n ).next_to(step_evaluation, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_evaluation.copy(), step_simplify))\n self.wait(1)\n\n # Final Numerical Value\n final_result = MathTex(\n r\"= \\\\frac{7}{3}\",\n color=YELLOW\n ).next_to(step_simplify, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_simplify.copy(), final_result))\n self.wait(1)\n\n # --- 5. Conclusion ---\n # Shade the area under the curve from 1 to 2\n area = axes.get_area(graph, x_range=[1, 2], color=GREEN, opacity=0.5)\n \n # Label the resulting area on the graph\n area_label = MathTex(r\"\\frac{7}{3}\", color=BLACK).move_to(\n axes.c2p(1.5, 1.2) # Positioned roughly in the center of the shaded area\n )\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # Display written conclusion at the bottom\n conclusion_text = Text(\n \"The area under f(x) = x^2 from x=1 to x=2 is 7/3 square units.\",\n font_size=24\n ).to_edge(DOWN, buff=0.5)\n \n self.play(Write(conclusion_text))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Create an educational animation that explains how to calculate the area under the curve of the function f(x) = x^2 from x=1 to x=2. Start by displaying the function and then introduce the concept of the definite integral to find the area. Step by step, write out the integral sign with limits a and b, specify the bounds as a=1 and b=2, and then replace a and b with the actual values in the integral. Show the intermediate steps of solving the integral, including evaluating from the lower to the upper limit, and then simplify the result to find the numerical value of the area. Conclude by presenting the final area value clearly and labeling the resulting area under the curve as 7/3 on the screen, with a written conclusion that appears at the bottom. Ensure the animation includes appropriate pauses between steps to allow the viewer to follow along."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Introduction: Display Axes, Curve, and Function ---\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).scale(0.8).to_edge(LEFT, buff=1)\n\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.2])\n graph_label = axes.get_graph_label(graph, label=MathTex(\"f(x) = x^2\"), x_val=2.1, direction=UR)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --- 2. Concept Introduction: Definite Integral ---\n eq_pos = RIGHT * 3 + UP * 1.5\n \n intro_text = Text(\"To find the area under the curve,\", font_size=24).shift(eq_pos + DOWN * 1.5)\n method_text = Text(\"we use the definite integral.\", font_size=24).next_to(intro_text, DOWN, buff=0.3)\n \n self.play(Write(intro_text), Write(method_text))\n self.wait(2)\n self.play(FadeOut(intro_text), FadeOut(method_text))\n\n # --- 3. Symbolic Setup ---\n # Generic integral with 'a' and 'b'\n integral_generic = MathTex(\n r\"\\text{Area} = \\int_{a}^{b}\", \"f(x)\", \"\\\\,dx\",\n color=YELLOW\n ).shift(eq_pos)\n \n self.play(Write(integral_generic))\n self.wait(1)\n\n # Explicitly specify the bounds\n bounds_text = MathTex(\"a = 1, \\\\quad b = 2\", font_size=36).next_to(integral_generic, DOWN, buff=0.5)\n self.play(Write(bounds_text))\n self.wait(2)\n\n # Replace 'a' and 'b' with actual values\n integral_specific = MathTex(\n r\"\\text{Area} = \\int_{1}^{2}\", \"x^2\", \"\\\\,dx\",\n color=YELLOW\n ).shift(eq_pos)\n\n self.play(\n TransformMatchingTex(integral_generic, integral_specific),\n FadeOut(bounds_text)\n )\n self.wait(1)\n\n # --- 4. Calculation Steps ---\n # Antiderivative\n step_antiderivative = MathTex(\n r\"= \\\\left[ \\\\frac{x^3}{3} \\\\right]_{1}^{2}\",\n color=YELLOW\n ).next_to(integral_specific, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(Write(step_antiderivative))\n self.wait(1)\n\n # Evaluation (Upper - Lower)\n step_evaluation = MathTex(\n r\"= \\\\frac{2^3}{3}\", \"-\", r\"\\\\frac{1^3}{3}\",\n color=YELLOW\n ).next_to(step_antiderivative, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_antiderivative.copy(), step_evaluation))\n self.wait(1)\n\n # Simplification\n step_simplify = MathTex(\n r\"= \\\\frac{8}{3}\", \"-\", r\"\\\\frac{1}{3}\",\n color=YELLOW\n ).next_to(step_evaluation, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_evaluation.copy(), step_simplify))\n self.wait(1)\n\n # Final Numerical Value\n final_result = MathTex(\n r\"= \\\\frac{7}{3}\",\n color=YELLOW\n ).next_to(step_simplify, DOWN, buff=0.5, align_to=LEFT)\n\n self.play(ReplacementTransform(step_simplify.copy(), final_result))\n self.wait(1)\n\n # --- 5. Conclusion ---\n # Shade the area under the curve from 1 to 2\n area = axes.get_area(graph, x_range=[1, 2], color=GREEN, opacity=0.5)\n \n # Label the resulting area on the graph\n area_label = MathTex(r\"\\frac{7}{3}\", color=BLACK).move_to(\n axes.c2p(1.5, 1.2) # Positioned roughly in the center of the shaded area\n )\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # Display written conclusion at the bottom\n conclusion_text = Text(\n \"The area under f(x) = x^2 from x=1 to x=2 is 7/3 square units.\",\n font_size=24\n ).to_edge(DOWN, buff=0.5)\n \n self.play(Write(conclusion_text))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_001644", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolynomialApproximation", "num_animations": 7, "num_rich_primitives": 2, "prompt": "Can you create an educational animation that visually illustrates the process of approximating a cubic function using different polynomial degrees, starting with a linear function and progressing through to a cubic one? The animation should begin by displaying a set of axes and plotting the original cubic function x^3 in green. Afterward, it should graph a linear approximation 3x-2 in red, followed by a quadratic approximation x^2-2x+1 in orange, and finally a more accurate cubic approximation 0.1x^3+0.2x^2-0.5x-1 in purple. Each new approximation should replace the previous one, and all functions should be accurately labeled. At the end of the animation, I'd like to briefly clear the screen before concluding with just the most accurate cubic approximation displayed. Please ensure each step is paced for clear comprehension and visual appeal.", "code": "from manim import *\n\nclass PolynomialApproximation(Scene):\n def construct(self):\n # 1. Setup: Display axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n axis_config={\"include_tip\": True},\n tips=False\n ).add_coordinates()\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n self.play(Create(axes), Write(axis_labels), run_time=2)\n self.wait(0.5)\n\n # 2. Original Function: x^3 in Green\n original_func = axes.plot(lambda x: x**3, color=GREEN)\n original_label = MathTex(\"f(x) = x^3\", color=GREEN).scale(0.8).to_corner(UR)\n \n self.play(Create(original_func), Write(original_label), run_time=2)\n self.wait(1)\n\n # 3. Approximation Sequence\n approximations = [\n (lambda x: 3*x - 2, RED, \"P_1(x) = 3x - 2\"),\n (lambda x: x**2 - 2*x + 1, ORANGE, \"P_2(x) = x^2 - 2x + 1\"),\n (lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1, PURPLE, \"P_3(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\"),\n ]\n\n prev_graph = None\n prev_label = None\n\n for func, color, text in approximations:\n current_graph = axes.plot(func, color=color)\n current_label = MathTex(text, color=color).scale(0.7).to_corner(UR)\n\n if prev_graph is None:\n # First approximation (Linear)\n self.play(Create(current_graph), Write(current_label), run_time=2)\n else:\n # Replace previous approximation with the current one\n self.play(\n ReplacementTransform(prev_graph, current_graph),\n ReplacementTransform(prev_label, current_label),\n run_time=2\n )\n \n self.wait(2)\n prev_graph = current_graph\n prev_label = current_label\n\n self.wait(1)\n\n # 4. Conclusion: Briefly clear the screen\n self.play(\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(original_func),\n FadeOut(original_label),\n FadeOut(prev_graph),\n FadeOut(prev_label),\n run_time=1\n )\n self.wait(0.5)\n\n # 5. Conclude by displaying only the most accurate cubic approximation\n final_axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n axis_config={\"include_tip\": True},\n tips=False\n ).add_coordinates()\n \n final_labels = final_axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n final_graph = final_axes.plot(lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1, color=PURPLE)\n final_label = MathTex(\"P_3(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\", color=PURPLE).scale(0.7).to_corner(UR)\n\n self.play(Create(final_axes), Write(final_labels), run_time=2)\n self.play(Create(final_graph), Write(final_label), run_time=2)\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually illustrates the process of approximating a cubic function using different polynomial degrees, starting with a linear function and progressing through to a cubic one? The animation should begin by displaying a set of axes and plotting the original cubic function x^3 in green. Afterward, it should graph a linear approximation 3x-2 in red, followed by a quadratic approximation x^2-2x+1 in orange, and finally a more accurate cubic approximation 0.1x^3+0.2x^2-0.5x-1 in purple. Each new approximation should replace the previous one, and all functions should be accurately labeled. At the end of the animation, I'd like to briefly clear the screen before concluding with just the most accurate cubic approximation displayed. Please ensure each step is paced for clear comprehension and visual appeal."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolynomialApproximation(Scene):\n def construct(self):\n # 1. Setup: Display axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n axis_config={\"include_tip\": True},\n tips=False\n ).add_coordinates()\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n self.play(Create(axes), Write(axis_labels), run_time=2)\n self.wait(0.5)\n\n # 2. Original Function: x^3 in Green\n original_func = axes.plot(lambda x: x**3, color=GREEN)\n original_label = MathTex(\"f(x) = x^3\", color=GREEN).scale(0.8).to_corner(UR)\n \n self.play(Create(original_func), Write(original_label), run_time=2)\n self.wait(1)\n\n # 3. Approximation Sequence\n approximations = [\n (lambda x: 3*x - 2, RED, \"P_1(x) = 3x - 2\"),\n (lambda x: x**2 - 2*x + 1, ORANGE, \"P_2(x) = x^2 - 2x + 1\"),\n (lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1, PURPLE, \"P_3(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\"),\n ]\n\n prev_graph = None\n prev_label = None\n\n for func, color, text in approximations:\n current_graph = axes.plot(func, color=color)\n current_label = MathTex(text, color=color).scale(0.7).to_corner(UR)\n\n if prev_graph is None:\n # First approximation (Linear)\n self.play(Create(current_graph), Write(current_label), run_time=2)\n else:\n # Replace previous approximation with the current one\n self.play(\n ReplacementTransform(prev_graph, current_graph),\n ReplacementTransform(prev_label, current_label),\n run_time=2\n )\n \n self.wait(2)\n prev_graph = current_graph\n prev_label = current_label\n\n self.wait(1)\n\n # 4. Conclusion: Briefly clear the screen\n self.play(\n FadeOut(axes),\n FadeOut(axis_labels),\n FadeOut(original_func),\n FadeOut(original_label),\n FadeOut(prev_graph),\n FadeOut(prev_label),\n run_time=1\n )\n self.wait(0.5)\n\n # 5. Conclude by displaying only the most accurate cubic approximation\n final_axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n axis_config={\"include_tip\": True},\n tips=False\n ).add_coordinates()\n \n final_labels = final_axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n final_graph = final_axes.plot(lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1, color=PURPLE)\n final_label = MathTex(\"P_3(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\", color=PURPLE).scale(0.7).to_corner(UR)\n\n self.play(Create(final_axes), Write(final_labels), run_time=2)\n self.play(Create(final_graph), Write(final_label), run_time=2)\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_001532", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralCalculation", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderParabola", "num_animations": 10, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "RY7Games/ry_manim_codegen", "tier": 1, "scene_name": "HyperbolicGeodesics", "num_animations": 15, "num_rich_primitives": 2, "prompt": "Why do geodesics on a hyperbolic surface diverge exponentially from each other, and how can this phenomenon be visualized?", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_006738", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 13, "num_rich_primitives": 2, "prompt": "I would like to create an animated educational video that explains the concept of finding the area under the curve of the function f(x) = x^2 from x=0 to x=2. The video should start by displaying the integral problem, then show a graphical representation of this function on a set of axes, and proceed to approximate the area under the curve using the method of rectangles. After the approximation, it should transition to explaining the actual integration process followed by showing the final solution of the integral. Each step should be displayed with clear visual and textual explanations, and there should be pauses between each step to ensure the viewer can follow along. Can you please create a scene that accomplishes this?", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Problem Statement ---\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\")\n problem.scale(1.5)\n problem.to_edge(UP)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Graph Visualization ---\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=4,\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [0, 2, 4]},\n ).shift(DOWN * 0.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"f(x)\")\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(graph_label))\n self.wait(2)\n\n # --- Step 3: Riemann Sum Approximation ---\n approx_text = Text(\"Approximation using Rectangles\", font_size=30).next_to(axes, DOWN, buff=0.5)\n self.play(Write(approx_text))\n \n # Animate 4 rectangles first\n rects_4 = axes.get_riemann_rectangles(\n graph, \n x_range=[0, 2], \n dx=0.5, \n input_sample_type=\"left\",\n color=GREEN, \n fill_opacity=0.5\n )\n self.play(Create(rects_4), run_time=2)\n self.wait(1)\n\n # Transition to 10 rectangles for a better approximation\n rects_10 = axes.get_riemann_rectangles(\n graph, \n x_range=[0, 2], \n dx=0.2, \n input_sample_type=\"left\",\n color=GREEN, \n fill_opacity=0.5\n )\n self.play(FadeOut(rects_4), FadeIn(rects_10), run_time=1)\n self.wait(2)\n\n # Clean up to transition to the analytical part\n self.play(\n FadeOut(rects_10), \n FadeOut(approx_text), \n FadeOut(graph_label), \n FadeOut(graph), \n FadeOut(axes), \n FadeOut(x_label), \n FadeOut(y_label),\n FadeOut(problem)\n )\n self.wait(1)\n\n # --- Step 4: Integration Explanation ---\n step1 = MathTex(r\"\\int x^2 \\, dx = \\frac{x^3}{3} + C\")\n step1.scale(1.2)\n step1.to_edge(UP)\n \n self.play(Write(step1))\n self.wait(2)\n\n step2 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.75)\n \n self.play(Write(step2))\n self.wait(2)\n\n # --- Step 5: Final Solution ---\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n step3.next_to(step2, DOWN, buff=0.75)\n \n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n step4.next_to(step3, DOWN, buff=0.75)\n \n self.play(Write(step3))\n self.wait(1)\n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n final_box = SurroundingRectangle(step4, color=YELLOW)\n self.play(Create(final_box))\n self.wait(3)\n\n # Fade everything out to end\n self.play(FadeOut(Group(*self.mobjects)))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an animated educational video that explains the concept of finding the area under the curve of the function f(x) = x^2 from x=0 to x=2. The video should start by displaying the integral problem, then show a graphical representation of this function on a set of axes, and proceed to approximate the area under the curve using the method of rectangles. After the approximation, it should transition to explaining the actual integration process followed by showing the final solution of the integral. Each step should be displayed with clear visual and textual explanations, and there should be pauses between each step to ensure the viewer can follow along. Can you please create a scene that accomplishes this?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Problem Statement ---\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\")\n problem.scale(1.5)\n problem.to_edge(UP)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Graph Visualization ---\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=4,\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [0, 2, 4]},\n ).shift(DOWN * 0.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"f(x)\")\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(graph_label))\n self.wait(2)\n\n # --- Step 3: Riemann Sum Approximation ---\n approx_text = Text(\"Approximation using Rectangles\", font_size=30).next_to(axes, DOWN, buff=0.5)\n self.play(Write(approx_text))\n \n # Animate 4 rectangles first\n rects_4 = axes.get_riemann_rectangles(\n graph, \n x_range=[0, 2], \n dx=0.5, \n input_sample_type=\"left\",\n color=GREEN, \n fill_opacity=0.5\n )\n self.play(Create(rects_4), run_time=2)\n self.wait(1)\n\n # Transition to 10 rectangles for a better approximation\n rects_10 = axes.get_riemann_rectangles(\n graph, \n x_range=[0, 2], \n dx=0.2, \n input_sample_type=\"left\",\n color=GREEN, \n fill_opacity=0.5\n )\n self.play(FadeOut(rects_4), FadeIn(rects_10), run_time=1)\n self.wait(2)\n\n # Clean up to transition to the analytical part\n self.play(\n FadeOut(rects_10), \n FadeOut(approx_text), \n FadeOut(graph_label), \n FadeOut(graph), \n FadeOut(axes), \n FadeOut(x_label), \n FadeOut(y_label),\n FadeOut(problem)\n )\n self.wait(1)\n\n # --- Step 4: Integration Explanation ---\n step1 = MathTex(r\"\\int x^2 \\, dx = \\frac{x^3}{3} + C\")\n step1.scale(1.2)\n step1.to_edge(UP)\n \n self.play(Write(step1))\n self.wait(2)\n\n step2 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.75)\n \n self.play(Write(step2))\n self.wait(2)\n\n # --- Step 5: Final Solution ---\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n step3.next_to(step2, DOWN, buff=0.75)\n \n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n step4.next_to(step3, DOWN, buff=0.75)\n \n self.play(Write(step3))\n self.wait(1)\n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n final_box = SurroundingRectangle(step4, color=YELLOW)\n self.play(Create(final_box))\n self.wait(3)\n\n # Fade everything out to end\n self.play(FadeOut(Group(*self.mobjects)))\n```"}]}
{"id": "manim-sft-10k_002774", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "UncertaintyInGameTheory", "num_animations": 21, "num_rich_primitives": 2, "prompt": "What is the impact of introducing uncertainty in payoff values on Nash equilibria in mixed strategy games?", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000458", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "HierarchicalAttentionScene", "num_animations": 4, "num_rich_primitives": 4, "prompt": "I'm learning about hierarchical attention and want a visualization that builds intuition from words to sentences to documents.\nShow tokens grouped into sentences, with local attention within a sentence and global attention across sentences, plus weight heatmaps.\nAnimate the flow of information through multi-level attention, including position encodings and token representations evolving through layers.\nProvide a small running example, perhaps question answering, to illustrate how hierarchy improves context understanding.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass HierarchicalAttentionScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: WORDS]\n with self.voiceover(text=\"Hierarchical attention models process text at multiple levels. First, word-level attention identifies the most important words within each individual sentence, assigning them higher weights.\") as tracker:\n title = Text(\"Hierarchical Attention\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n sent1_words = VGroup(*[Text(w, font_size=20) for w in [\"The\", \"movie\", \"was\", \"great\"]]).arrange(RIGHT, buff=0.2)\n sent1_box = SurroundingRectangle(sent1_words, color=BLUE, buff=0.1)\n sent1 = VGroup(sent1_words, sent1_box).shift(UP * 1.5)\n \n sent2_words = VGroup(*[Text(w, font_size=20) for w in [\"but\", \"ending\", \"bad\"]]).arrange(RIGHT, buff=0.2)\n sent2_box = SurroundingRectangle(sent2_words, color=GREEN, buff=0.1)\n sent2 = VGroup(sent2_words, sent2_box).shift(DOWN * 1.5)\n \n highlights1 = VGroup(\n SurroundingRectangle(sent1_words[1], color=YELLOW, buff=0.05),\n SurroundingRectangle(sent1_words[3], color=YELLOW, buff=0.05)\n )\n \n self.wait_until_bookmark(\"WORDS\")\n self.play(Write(title), Create(sent1), Create(sent2), Create(highlights1), run_time=tracker.duration)\n\n with self.voiceover(text=\"Next, each sentence is condensed into a single embedding vector. Sentence-level attention then determines which sentences are most critical to the overall meaning of the document.\") as tracker:\n self.play(FadeOut(highlights1), run_time=0.5)\n \n emb1 = Rectangle(width=1.5, height=0.6, color=BLUE, fill_opacity=0.4)\n emb1_label = Text(\"h₁\", font_size=20, color=BLUE).move_to(emb1)\n emb1_group = VGroup(emb1, emb1_label).next_to(sent1, RIGHT, buff=1)\n \n emb2 = Rectangle(width=1.5, height=0.6, color=GREEN, fill_opacity=0.4)\n emb2_label = Text(\"h₂\", font_size=20, color=GREEN).move_to(emb2)\n emb2_group = VGroup(emb2, emb2_label).next_to(sent2, RIGHT, buff=1)\n \n arrows = VGroup(\n Arrow(sent1.get_right(), emb1.get_left()),\n Arrow(sent2.get_right(), emb2.get_left())\n )\n \n self.wait_until_bookmark(\"SENTS\")\n self.play(Create(arrows), Create(emb1_group), Create(emb2_group), run_time=tracker.duration)\n\n with self.voiceover(text=\"Finally, these weighted sentence embeddings are combined into a single document vector. This rich representation captures the full context, enabling highly accurate document classification.\") as tracker:\n doc_vec = Rectangle(width=2, height=0.8, color=PURPLE, fill_opacity=0.5)\n doc_vec_label = Text(\"Doc Vector\", font_size=18, color=PURPLE).move_to(doc_vec)\n doc_vec_group = VGroup(doc_vec, doc_vec_label).shift(RIGHT * 5)\n \n doc_arrows = VGroup(\n Arrow(emb1.get_right(), doc_vec.get_left() + UP * 0.2),\n Arrow(emb2.get_right(), doc_vec.get_left() + DOWN * 0.2)\n )\n \n self.wait_until_bookmark(\"DOC\")\n self.play(Create(doc_arrows), Create(doc_vec_group), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm learning about hierarchical attention and want a visualization that builds intuition from words to sentences to documents.\nShow tokens grouped into sentences, with local attention within a sentence and global attention across sentences, plus weight heatmaps.\nAnimate the flow of information through multi-level attention, including position encodings and token representations evolving through layers.\nProvide a small running example, perhaps question answering, to illustrate how hierarchy improves context understanding."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass HierarchicalAttentionScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: WORDS]\n with self.voiceover(text=\"Hierarchical attention models process text at multiple levels. First, word-level attention identifies the most important words within each individual sentence, assigning them higher weights.\") as tracker:\n title = Text(\"Hierarchical Attention\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n sent1_words = VGroup(*[Text(w, font_size=20) for w in [\"The\", \"movie\", \"was\", \"great\"]]).arrange(RIGHT, buff=0.2)\n sent1_box = SurroundingRectangle(sent1_words, color=BLUE, buff=0.1)\n sent1 = VGroup(sent1_words, sent1_box).shift(UP * 1.5)\n \n sent2_words = VGroup(*[Text(w, font_size=20) for w in [\"but\", \"ending\", \"bad\"]]).arrange(RIGHT, buff=0.2)\n sent2_box = SurroundingRectangle(sent2_words, color=GREEN, buff=0.1)\n sent2 = VGroup(sent2_words, sent2_box).shift(DOWN * 1.5)\n \n highlights1 = VGroup(\n SurroundingRectangle(sent1_words[1], color=YELLOW, buff=0.05),\n SurroundingRectangle(sent1_words[3], color=YELLOW, buff=0.05)\n )\n \n self.wait_until_bookmark(\"WORDS\")\n self.play(Write(title), Create(sent1), Create(sent2), Create(highlights1), run_time=tracker.duration)\n\n with self.voiceover(text=\"Next, each sentence is condensed into a single embedding vector. Sentence-level attention then determines which sentences are most critical to the overall meaning of the document.\") as tracker:\n self.play(FadeOut(highlights1), run_time=0.5)\n \n emb1 = Rectangle(width=1.5, height=0.6, color=BLUE, fill_opacity=0.4)\n emb1_label = Text(\"h₁\", font_size=20, color=BLUE).move_to(emb1)\n emb1_group = VGroup(emb1, emb1_label).next_to(sent1, RIGHT, buff=1)\n \n emb2 = Rectangle(width=1.5, height=0.6, color=GREEN, fill_opacity=0.4)\n emb2_label = Text(\"h₂\", font_size=20, color=GREEN).move_to(emb2)\n emb2_group = VGroup(emb2, emb2_label).next_to(sent2, RIGHT, buff=1)\n \n arrows = VGroup(\n Arrow(sent1.get_right(), emb1.get_left()),\n Arrow(sent2.get_right(), emb2.get_left())\n )\n \n self.wait_until_bookmark(\"SENTS\")\n self.play(Create(arrows), Create(emb1_group), Create(emb2_group), run_time=tracker.duration)\n\n with self.voiceover(text=\"Finally, these weighted sentence embeddings are combined into a single document vector. This rich representation captures the full context, enabling highly accurate document classification.\") as tracker:\n doc_vec = Rectangle(width=2, height=0.8, color=PURPLE, fill_opacity=0.5)\n doc_vec_label = Text(\"Doc Vector\", font_size=18, color=PURPLE).move_to(doc_vec)\n doc_vec_group = VGroup(doc_vec, doc_vec_label).shift(RIGHT * 5)\n \n doc_arrows = VGroup(\n Arrow(emb1.get_right(), doc_vec.get_left() + UP * 0.2),\n Arrow(emb2.get_right(), doc_vec.get_left() + DOWN * 0.2)\n )\n \n self.wait_until_bookmark(\"DOC\")\n self.play(Create(doc_arrows), Create(doc_vec_group), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_007091", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SolveLinearODE", "num_animations": 14, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_000757", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralXCubed", "num_animations": 11, "num_rich_primitives": 2, "prompt": "Could you create an educational animation that visually explains how to compute the definite integral of x cubed from 0 to 2 using the power rule for integration, including the step-by-step calculation and ending with the presentation of the final result as the area under the curve?", "code": "from manim import *\n\nclass DefiniteIntegralXCubed(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ------------------------------------------------------------------\n # Define axes suitable for x^3 on [0, 2] (y reaches 8)\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=5,\n y_length=6,\n axis_config={\"include_tip\": True},\n tips=True\n ).to_edge(LEFT, buff=1)\n \n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Plot the curve f(x) = x^3\n graph = axes.plot(lambda x: x**3, x_range=[0, 2.2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=MathTex(\"f(x) = x^3\"), x_val=2, direction=UR)\n \n # Introduction: Draw the coordinate system and the function curve\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Display the Definite Integral Expression\n # ------------------------------------------------------------------\n # Position the math on the right side of the screen\n integral_expr = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=42)\n integral_expr.to_edge(RIGHT, buff=1.5).shift(UP * 2)\n \n self.play(Write(integral_expr))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 3. Apply the Power Rule for Integration\n # ------------------------------------------------------------------\n # Highlight the general rule before applying it\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=YELLOW)\n power_rule.next_to(integral_expr, DOWN, buff=0.8).align_to(integral_expr, LEFT)\n \n self.play(Write(power_rule))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 4. Step-by-Step Symbolic Calculation\n # ------------------------------------------------------------------\n # Step A: Applying the rule\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_0^2\", font_size=42)\n step1.next_to(power_rule, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step B: Simplifying the fraction\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=42)\n step2.next_to(step1, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step C: Fundamental Theorem of Calculus (Evaluation)\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42)\n step3.next_to(step2, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step D: Final Numerical Result\n step4 = MathTex(r\"= \\frac{16}{4} - 0 = 4\", font_size=42, color=GREEN)\n step4.next_to(step3, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Animate the calculation sequence\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(1)\n self.play(Write(step4))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 5. Visualize the Area Under the Curve\n # ------------------------------------------------------------------\n # Create the area object 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 # Highlight the bounds on the x-axis\n bound_line = Line(axes.c2p(0, 0), axes.c2p(2, 0), color=YELLOW)\n bound_label = MathTex(\"2\", font_size=30).next_to(bound_line, DOWN, buff=0.1)\n \n # Animate the filling of the area to represent the integral value\n self.play(Create(bound_line), Write(bound_label))\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 6. Final Conclusion\n # ------------------------------------------------------------------\n # Create a final summary box to connect the calculation and the area\n final_text = Tex(\"The area under the curve from 0 to 2 is 4\", font_size=36, color=GREEN)\n final_text.to_edge(BOTTOM, buff=1)\n \n box = SurroundingRectangle(final_text, color=WHITE, buff=0.3)\n \n self.play(Write(final_text), Create(box))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that visually explains how to compute the definite integral of x cubed from 0 to 2 using the power rule for integration, including the step-by-step calculation and ending with the presentation of the final result as the area under the curve?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralXCubed(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ------------------------------------------------------------------\n # Define axes suitable for x^3 on [0, 2] (y reaches 8)\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=5,\n y_length=6,\n axis_config={\"include_tip\": True},\n tips=True\n ).to_edge(LEFT, buff=1)\n \n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Plot the curve f(x) = x^3\n graph = axes.plot(lambda x: x**3, x_range=[0, 2.2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=MathTex(\"f(x) = x^3\"), x_val=2, direction=UR)\n \n # Introduction: Draw the coordinate system and the function curve\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Display the Definite Integral Expression\n # ------------------------------------------------------------------\n # Position the math on the right side of the screen\n integral_expr = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=42)\n integral_expr.to_edge(RIGHT, buff=1.5).shift(UP * 2)\n \n self.play(Write(integral_expr))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 3. Apply the Power Rule for Integration\n # ------------------------------------------------------------------\n # Highlight the general rule before applying it\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=YELLOW)\n power_rule.next_to(integral_expr, DOWN, buff=0.8).align_to(integral_expr, LEFT)\n \n self.play(Write(power_rule))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 4. Step-by-Step Symbolic Calculation\n # ------------------------------------------------------------------\n # Step A: Applying the rule\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_0^2\", font_size=42)\n step1.next_to(power_rule, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step B: Simplifying the fraction\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=42)\n step2.next_to(step1, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step C: Fundamental Theorem of Calculus (Evaluation)\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42)\n step3.next_to(step2, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Step D: Final Numerical Result\n step4 = MathTex(r\"= \\frac{16}{4} - 0 = 4\", font_size=42, color=GREEN)\n step4.next_to(step3, DOWN, buff=0.5).align_to(integral_expr, LEFT)\n \n # Animate the calculation sequence\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(1)\n self.play(Write(step4))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 5. Visualize the Area Under the Curve\n # ------------------------------------------------------------------\n # Create the area object 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 # Highlight the bounds on the x-axis\n bound_line = Line(axes.c2p(0, 0), axes.c2p(2, 0), color=YELLOW)\n bound_label = MathTex(\"2\", font_size=30).next_to(bound_line, DOWN, buff=0.1)\n \n # Animate the filling of the area to represent the integral value\n self.play(Create(bound_line), Write(bound_label))\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 6. Final Conclusion\n # ------------------------------------------------------------------\n # Create a final summary box to connect the calculation and the area\n final_text = Tex(\"The area under the curve from 0 to 2 is 4\", font_size=36, color=GREEN)\n final_text.to_edge(BOTTOM, buff=1)\n \n box = SurroundingRectangle(final_text, color=WHITE, buff=0.3)\n \n self.play(Write(final_text), Create(box))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_002384", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "FourierSeriesExplanation", "num_animations": 18, "num_rich_primitives": 4, "prompt": "Can you create an educational animation that first displays the general equation for a Fourier series, then explains it as a concept that decomposes periodic functions into constituent frequencies, and finally shows a simple example of a Fourier series with just two terms, all while smoothly transitioning between the stages of the explanation?", "code": "from manim import *\nimport numpy as np\n\nclass FourierSeriesExplanation(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # Stage 1: General Equation\n # ---------------------------------------------------------\n # Display the standard trigonometric form of the Fourier Series\n fourier_eq = MathTex(\n r\"f(x) = \\frac{a_0}{2} + \\sum_{n=1}^{\\infty} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=42\n ).shift(UP * 2)\n \n eq_title = Text(\"General Fourier Series\", font_size=30, color=BLUE).next_to(fourier_eq, UP)\n \n self.play(Write(eq_title))\n self.play(Write(fourier_eq))\n self.wait(1)\n \n # Highlight the summation part to emphasize constituent frequencies\n sum_part = VGroup(\n fourier_eq[0][5], # Sigma\n fourier_eq[0][6], # Left Paren\n fourier_eq[0][7], # a_n\n fourier_eq[0][8], # cos\n fourier_eq[0][9], # +\n fourier_eq[0][10], # b_n\n fourier_eq[0][11], # sin\n fourier_eq[0][12] # Right Paren\n )\n self.play(sum_part.animate.set_color(YELLOW))\n self.wait(2)\n\n # Transition: Fade out title and move equation to the top\n self.play(FadeOut(eq_title), fourier_eq.animate.scale(0.8).to_edge(UP))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # Stage 2: Conceptual Explanation (Decomposition)\n # ---------------------------------------------------------\n axes = Axes(\n x_range=[-TAU, TAU, TAU / 2],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False},\n ).shift(DOWN * 0.5)\n \n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n self.play(Create(axes), Write(axes_labels))\n \n concept_title = Text(\"Decomposition Concept\", font_size=36).next_to(axes, UP)\n self.play(Write(concept_title))\n \n # 1. Show a complex periodic function (Target)\n target_func = axes.plot(lambda x: np.sin(x) + 0.5 * np.sin(3 * x), color=WHITE)\n target_label = Text(\"Complex Periodic Function\", font_size=24, color=WHITE).next_to(axes, UP).shift(DOWN * 1.5)\n \n self.play(Create(target_func), Write(target_label))\n self.wait(1)\n \n # 2. Fade target and decompose visually into components\n self.play(\n target_func.animate.set_opacity(0.3),\n target_label.animate.set_opacity(0.3)\n )\n \n # Component 1: Fundamental Frequency\n wave1 = axes.plot(lambda x: np.sin(x), color=BLUE)\n label1 = MathTex(r\"\\sin(x)\", color=BLUE).next_to(axes, UP).shift(RIGHT * 2)\n \n # Component 2: Harmonic Frequency\n wave2 = axes.plot(lambda x: 0.5 * np.sin(3 * x), color=GREEN)\n label2 = MathTex(r\"+ 0.5\\sin(3x)\", color=GREEN).next_to(label1, RIGHT)\n \n self.play(Create(wave1), Write(label1))\n self.play(Create(wave2), Write(label2))\n self.wait(1)\n \n # 3. Show Reconstruction\n recon_text = Text(\"Superposition = Original Function\", font_size=24).next_to(axes, DOWN)\n self.play(Write(recon_text))\n self.play(target_func.animate.set_opacity(1.0))\n self.wait(2)\n \n # Clear for Specific Example\n self.play(FadeOut(VGroup(\n axes, axes_labels, target_func, wave1, wave2, \n label1, label2, recon_text, concept_title\n )))\n \n # ---------------------------------------------------------\n # Stage 3: Specific Example (Square Wave, 2 Terms)\n # ---------------------------------------------------------\n example_title = Text(\"Example: Square Wave Approximation (2 Terms)\", font_size=36).to_edge(UP)\n self.play(Write(example_title))\n \n new_axes = Axes(\n x_range=[-TAU, TAU, TAU / 2],\n y_range=[-1.5, 1.5, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False}\n ).shift(DOWN * 0.5)\n \n new_labels = new_axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(new_axes), Write(new_labels))\n \n # Fourier Series for Square Wave: 4/pi * (sin(x) + 1/3 sin(3x) + ...)\n scalar = 4 / PI\n \n # Term 1\n term1 = new_axes.plot(lambda x: scalar * np.sin(x), color=BLUE)\n t1_eq = MathTex(r\"S_1(x) = \\frac{4}{\\pi}\\sin(x)\", color=BLUE, font_size=32).to_edge(DOWN).shift(RIGHT * 3)\n \n self.play(Create(term1), Write(t1_eq))\n self.wait(1)\n \n # Term 2 (Sum of Term 1 and Term 2)\n term2 = new_axes.plot(\n lambda x: scalar * (np.sin(x) + (1 / 3) * np.sin(3 * x)), \n color=YELLOW\n )\n t2_eq = MathTex(r\"S_2(x) = \\frac{4}{\\pi}\\sin(x) + \\frac{4}{3\\pi}\\sin(3x)\", color=YELLOW, font_size=32).to_edge(DOWN).shift(LEFT * 2)\n \n self.play(ReplacementTransform(term1, term2), ReplacementTransform(t1_eq, t2_eq))\n self.wait(1)\n \n # Highlight the final approximation\n self.play(Indicate(term2, color=YELLOW, scale_factor=1.05))\n \n # Final pause to view the result\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that first displays the general equation for a Fourier series, then explains it as a concept that decomposes periodic functions into constituent frequencies, and finally shows a simple example of a Fourier series with just two terms, all while smoothly transitioning between the stages of the explanation?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass FourierSeriesExplanation(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # Stage 1: General Equation\n # ---------------------------------------------------------\n # Display the standard trigonometric form of the Fourier Series\n fourier_eq = MathTex(\n r\"f(x) = \\frac{a_0}{2} + \\sum_{n=1}^{\\infty} \\left( a_n \\cos(nx) + b_n \\sin(nx) \\right)\",\n font_size=42\n ).shift(UP * 2)\n \n eq_title = Text(\"General Fourier Series\", font_size=30, color=BLUE).next_to(fourier_eq, UP)\n \n self.play(Write(eq_title))\n self.play(Write(fourier_eq))\n self.wait(1)\n \n # Highlight the summation part to emphasize constituent frequencies\n sum_part = VGroup(\n fourier_eq[0][5], # Sigma\n fourier_eq[0][6], # Left Paren\n fourier_eq[0][7], # a_n\n fourier_eq[0][8], # cos\n fourier_eq[0][9], # +\n fourier_eq[0][10], # b_n\n fourier_eq[0][11], # sin\n fourier_eq[0][12] # Right Paren\n )\n self.play(sum_part.animate.set_color(YELLOW))\n self.wait(2)\n\n # Transition: Fade out title and move equation to the top\n self.play(FadeOut(eq_title), fourier_eq.animate.scale(0.8).to_edge(UP))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # Stage 2: Conceptual Explanation (Decomposition)\n # ---------------------------------------------------------\n axes = Axes(\n x_range=[-TAU, TAU, TAU / 2],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False},\n ).shift(DOWN * 0.5)\n \n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n self.play(Create(axes), Write(axes_labels))\n \n concept_title = Text(\"Decomposition Concept\", font_size=36).next_to(axes, UP)\n self.play(Write(concept_title))\n \n # 1. Show a complex periodic function (Target)\n target_func = axes.plot(lambda x: np.sin(x) + 0.5 * np.sin(3 * x), color=WHITE)\n target_label = Text(\"Complex Periodic Function\", font_size=24, color=WHITE).next_to(axes, UP).shift(DOWN * 1.5)\n \n self.play(Create(target_func), Write(target_label))\n self.wait(1)\n \n # 2. Fade target and decompose visually into components\n self.play(\n target_func.animate.set_opacity(0.3),\n target_label.animate.set_opacity(0.3)\n )\n \n # Component 1: Fundamental Frequency\n wave1 = axes.plot(lambda x: np.sin(x), color=BLUE)\n label1 = MathTex(r\"\\sin(x)\", color=BLUE).next_to(axes, UP).shift(RIGHT * 2)\n \n # Component 2: Harmonic Frequency\n wave2 = axes.plot(lambda x: 0.5 * np.sin(3 * x), color=GREEN)\n label2 = MathTex(r\"+ 0.5\\sin(3x)\", color=GREEN).next_to(label1, RIGHT)\n \n self.play(Create(wave1), Write(label1))\n self.play(Create(wave2), Write(label2))\n self.wait(1)\n \n # 3. Show Reconstruction\n recon_text = Text(\"Superposition = Original Function\", font_size=24).next_to(axes, DOWN)\n self.play(Write(recon_text))\n self.play(target_func.animate.set_opacity(1.0))\n self.wait(2)\n \n # Clear for Specific Example\n self.play(FadeOut(VGroup(\n axes, axes_labels, target_func, wave1, wave2, \n label1, label2, recon_text, concept_title\n )))\n \n # ---------------------------------------------------------\n # Stage 3: Specific Example (Square Wave, 2 Terms)\n # ---------------------------------------------------------\n example_title = Text(\"Example: Square Wave Approximation (2 Terms)\", font_size=36).to_edge(UP)\n self.play(Write(example_title))\n \n new_axes = Axes(\n x_range=[-TAU, TAU, TAU / 2],\n y_range=[-1.5, 1.5, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False}\n ).shift(DOWN * 0.5)\n \n new_labels = new_axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(new_axes), Write(new_labels))\n \n # Fourier Series for Square Wave: 4/pi * (sin(x) + 1/3 sin(3x) + ...)\n scalar = 4 / PI\n \n # Term 1\n term1 = new_axes.plot(lambda x: scalar * np.sin(x), color=BLUE)\n t1_eq = MathTex(r\"S_1(x) = \\frac{4}{\\pi}\\sin(x)\", color=BLUE, font_size=32).to_edge(DOWN).shift(RIGHT * 3)\n \n self.play(Create(term1), Write(t1_eq))\n self.wait(1)\n \n # Term 2 (Sum of Term 1 and Term 2)\n term2 = new_axes.plot(\n lambda x: scalar * (np.sin(x) + (1 / 3) * np.sin(3 * x)), \n color=YELLOW\n )\n t2_eq = MathTex(r\"S_2(x) = \\frac{4}{\\pi}\\sin(x) + \\frac{4}{3\\pi}\\sin(3x)\", color=YELLOW, font_size=32).to_edge(DOWN).shift(LEFT * 2)\n \n self.play(ReplacementTransform(term1, term2), ReplacementTransform(t1_eq, t2_eq))\n self.wait(1)\n \n # Highlight the final approximation\n self.play(Indicate(term2, color=YELLOW, scale_factor=1.05))\n \n # Final pause to view the result\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_000060", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderParabola", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000046", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "TaylorSeriesExpansion", "num_animations": 5, "num_rich_primitives": 1, "prompt": "Create a step-by-step educational Manim CE lecture scene explaining: Taylor Series Expansion of exp(x).", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nMARGIN = 0.5\n\nclass TaylorSeriesExpansion(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [LAYOUT]\n title = Title(r\"Taylor Series of $e^x$ around $x=0$\")\n self.fit_in_frame(title, w_frac=0.95)\n \n # Position axes on the left side\n ax = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 2],\n x_length=5,\n y_length=3.5,\n tips=True,\n axis_config={\"include_numbers\": True}\n ).shift(LEFT * 2.5 + DOWN * 0.5)\n \n exp_curve = ax.plot(lambda x: np.exp(x), color=WHITE, x_range=[-2.5, 2.2])\n exp_label = MathTex(r\"e^x\").scale(0.8).next_to(ax.c2p(1.8, np.exp(1.8)), UR, buff=0.1)\n \n # Taylor approximation curves\n t1 = ax.plot(lambda x: 1 + x, color=BLUE, x_range=[-2.5, 2.5])\n t2 = ax.plot(lambda x: 1 + x + 0.5 * x**2, color=GREEN, x_range=[-2.5, 2.5])\n t3 = ax.plot(lambda x: 1 + x + 0.5 * x**2 + (1/6) * x**3, color=YELLOW, x_range=[-2.5, 2.5])\n \n # Formula display on the right\n formula_base = MathTex(\n r\"e^x = \\sum_{n=0}^{\\infty} \\frac{x^n}{n!}\",\n font_size=36\n ).to_edge(RIGHT, buff=MARGIN).shift(UP * 1.5)\n self.fit_in_frame(formula_base, w_frac=0.95)\n \n term1 = MathTex(r\"T_1(x) = 1 + x\", color=BLUE, font_size=32).next_to(formula_base, DOWN, buff=0.5, aligned_edge=LEFT)\n term2 = MathTex(r\"T_2(x) = 1 + x + \\frac{x^2}{2}\", color=GREEN, font_size=32).next_to(term1, DOWN, buff=0.3, aligned_edge=LEFT)\n term3 = MathTex(r\"T_3(x) = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6}\", color=YELLOW, font_size=32).next_to(term2, DOWN, buff=0.3, aligned_edge=LEFT)\n \n # [BEAT 1 | sync: intro]\n with self.voiceover(text=\"\"\"\n Let's explore the Taylor series expansion of e to the x around x equals zero.\n \n The exponential function can be approximated by a polynomial series.\n \"\"\") as tracker:\n self.play(Write(title))\n self.wait_until_bookmark(\"intro\")\n self.play(Create(ax), Create(exp_curve), Write(exp_label), Write(formula_base))\n \n # [BEAT 2 | sync: linear]\n with self.voiceover(text=\"\"\"\n The first order approximation is simply one plus x, which gives us a straight line.\n \n Notice how it matches the exponential near x equals zero, but diverges quickly.\n \"\"\") as tracker:\n self.play(Create(t1), Write(term1), run_time=1.5)\n self.wait_until_bookmark(\"linear\")\n self.wait(0.5)\n \n # [BEAT 3 | sync: quad]\n with self.voiceover(text=\"\"\"\n Adding the quadratic term, x squared over two factorial, improves the fit.\n \n The second order approximation follows the curve more closely.\n \"\"\") as tracker:\n self.play(Transform(t1, t2), Write(term2), run_time=1.5)\n self.wait_until_bookmark(\"quad\")\n self.wait(0.5)\n \n # [BEAT 4 | sync: cubic]\n with self.voiceover(text=\"\"\"\n With the cubic term, x cubed over six, we get an even better approximation.\n \n Each additional term extends the range where our polynomial matches the exponential.\n \"\"\") as tracker:\n self.play(Transform(t1, t3), Write(term3), run_time=1.5)\n self.wait_until_bookmark(\"cubic\")\n self.wait(0.5)\n \n # [BEAT 5 | sync: end]\n with self.voiceover(text=\"\"\"\n As we add more terms, the Taylor series converges to the true exponential function.\n \n This is the power of series approximations in mathematics.\n \"\"\") as tracker:\n self.wait_until_bookmark(\"end\")\n self.wait(1)\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Create a step-by-step educational Manim CE lecture scene explaining: Taylor Series Expansion of exp(x)."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nMARGIN = 0.5\n\nclass TaylorSeriesExpansion(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [LAYOUT]\n title = Title(r\"Taylor Series of $e^x$ around $x=0$\")\n self.fit_in_frame(title, w_frac=0.95)\n \n # Position axes on the left side\n ax = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 2],\n x_length=5,\n y_length=3.5,\n tips=True,\n axis_config={\"include_numbers\": True}\n ).shift(LEFT * 2.5 + DOWN * 0.5)\n \n exp_curve = ax.plot(lambda x: np.exp(x), color=WHITE, x_range=[-2.5, 2.2])\n exp_label = MathTex(r\"e^x\").scale(0.8).next_to(ax.c2p(1.8, np.exp(1.8)), UR, buff=0.1)\n \n # Taylor approximation curves\n t1 = ax.plot(lambda x: 1 + x, color=BLUE, x_range=[-2.5, 2.5])\n t2 = ax.plot(lambda x: 1 + x + 0.5 * x**2, color=GREEN, x_range=[-2.5, 2.5])\n t3 = ax.plot(lambda x: 1 + x + 0.5 * x**2 + (1/6) * x**3, color=YELLOW, x_range=[-2.5, 2.5])\n \n # Formula display on the right\n formula_base = MathTex(\n r\"e^x = \\sum_{n=0}^{\\infty} \\frac{x^n}{n!}\",\n font_size=36\n ).to_edge(RIGHT, buff=MARGIN).shift(UP * 1.5)\n self.fit_in_frame(formula_base, w_frac=0.95)\n \n term1 = MathTex(r\"T_1(x) = 1 + x\", color=BLUE, font_size=32).next_to(formula_base, DOWN, buff=0.5, aligned_edge=LEFT)\n term2 = MathTex(r\"T_2(x) = 1 + x + \\frac{x^2}{2}\", color=GREEN, font_size=32).next_to(term1, DOWN, buff=0.3, aligned_edge=LEFT)\n term3 = MathTex(r\"T_3(x) = 1 + x + \\frac{x^2}{2} + \\frac{x^3}{6}\", color=YELLOW, font_size=32).next_to(term2, DOWN, buff=0.3, aligned_edge=LEFT)\n \n # [BEAT 1 | sync: intro]\n with self.voiceover(text=\"\"\"\n Let's explore the Taylor series expansion of e to the x around x equals zero.\n \n The exponential function can be approximated by a polynomial series.\n \"\"\") as tracker:\n self.play(Write(title))\n self.wait_until_bookmark(\"intro\")\n self.play(Create(ax), Create(exp_curve), Write(exp_label), Write(formula_base))\n \n # [BEAT 2 | sync: linear]\n with self.voiceover(text=\"\"\"\n The first order approximation is simply one plus x, which gives us a straight line.\n \n Notice how it matches the exponential near x equals zero, but diverges quickly.\n \"\"\") as tracker:\n self.play(Create(t1), Write(term1), run_time=1.5)\n self.wait_until_bookmark(\"linear\")\n self.wait(0.5)\n \n # [BEAT 3 | sync: quad]\n with self.voiceover(text=\"\"\"\n Adding the quadratic term, x squared over two factorial, improves the fit.\n \n The second order approximation follows the curve more closely.\n \"\"\") as tracker:\n self.play(Transform(t1, t2), Write(term2), run_time=1.5)\n self.wait_until_bookmark(\"quad\")\n self.wait(0.5)\n \n # [BEAT 4 | sync: cubic]\n with self.voiceover(text=\"\"\"\n With the cubic term, x cubed over six, we get an even better approximation.\n \n Each additional term extends the range where our polynomial matches the exponential.\n \"\"\") as tracker:\n self.play(Transform(t1, t3), Write(term3), run_time=1.5)\n self.wait_until_bookmark(\"cubic\")\n self.wait(0.5)\n \n # [BEAT 5 | sync: end]\n with self.voiceover(text=\"\"\"\n As we add more terms, the Taylor series converges to the true exponential function.\n \n This is the power of series approximations in mathematics.\n \"\"\") as tracker:\n self.wait_until_bookmark(\"end\")\n self.wait(1)\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000638", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "GradientAccumulationScene", "num_animations": 5, "num_rich_primitives": 1, "prompt": "I'm learning how gradient contributions accumulate when the same index appears multiple times in a batch.\nVisualize a tiny batch with repeated indices and show how each occurrence adds to the gradient, with a running total and final update.\nInclude a side-by-side comparison with unique indices to highlight the difference, and use a running-accumulator animation on the gradient vector.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass GradientAccumulationScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: REPEAT]\n with self.voiceover(text=\"When the same index appears multiple times in a batch, its gradient contribution is computed for each occurrence and then summed.\") as tracker:\n title = Text(\"Gradient Accumulation in Batches\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n batch = VGroup(\n Text(\"Index 0\", font_size=20),\n Text(\"Index 2\", font_size=20),\n Text(\"Index 0\", font_size=20),\n Text(\"Index 1\", font_size=20)\n ).arrange(DOWN, buff=0.3)\n \n self.wait_until_bookmark(\"REPEAT\")\n self.play(Write(title), Write(batch), run_time=tracker.duration)\n \n with self.voiceover(text=\"As we process the batch, each time Index 0 appears, its gradient is computed and added to a running total in the accumulator.\") as tracker:\n accum = Rectangle(width=2, height=1, color=GREEN, fill_opacity=0.2)\n accum_label = Text(\"Grad Accumulator\", font_size=16).move_to(accum)\n accum_group = VGroup(accum, accum_label).shift(RIGHT * 3)\n \n running_total = MathTex(\"\\\\nabla_0 = 0.0\", font_size=24)\n running_total.next_to(accum_group, DOWN, buff=0.3)\n \n self.wait_until_bookmark(\"ACCUM\")\n self.play(Create(accum_group), Write(running_total), run_time=tracker.duration * 0.3)\n self.play(\n running_total.animate.become(MathTex(\"\\\\nabla_0 = 0.0 + 0.3 = 0.3\", font_size=24)),\n run_time=tracker.duration * 0.35\n )\n self.play(\n running_total.animate.become(MathTex(\"\\\\nabla_0 = 0.3 + 0.5 = 0.8\", font_size=24)),\n run_time=tracker.duration * 0.35\n )\n \n with self.voiceover(text=\"Compared to unique indices, this accumulation ensures the final weight update correctly reflects the total error signal for that specific parameter.\") as tracker:\n compare_text = Text(\"Unique: Update once\\nRepeated: Sum then update\", font_size=20, color=GREEN)\n compare_text.to_edge(DOWN)\n \n self.wait_until_bookmark(\"COMPARE\")\n self.play(Write(compare_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm learning how gradient contributions accumulate when the same index appears multiple times in a batch.\nVisualize a tiny batch with repeated indices and show how each occurrence adds to the gradient, with a running total and final update.\nInclude a side-by-side comparison with unique indices to highlight the difference, and use a running-accumulator animation on the gradient vector."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass GradientAccumulationScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: REPEAT]\n with self.voiceover(text=\"When the same index appears multiple times in a batch, its gradient contribution is computed for each occurrence and then summed.\") as tracker:\n title = Text(\"Gradient Accumulation in Batches\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n batch = VGroup(\n Text(\"Index 0\", font_size=20),\n Text(\"Index 2\", font_size=20),\n Text(\"Index 0\", font_size=20),\n Text(\"Index 1\", font_size=20)\n ).arrange(DOWN, buff=0.3)\n \n self.wait_until_bookmark(\"REPEAT\")\n self.play(Write(title), Write(batch), run_time=tracker.duration)\n \n with self.voiceover(text=\"As we process the batch, each time Index 0 appears, its gradient is computed and added to a running total in the accumulator.\") as tracker:\n accum = Rectangle(width=2, height=1, color=GREEN, fill_opacity=0.2)\n accum_label = Text(\"Grad Accumulator\", font_size=16).move_to(accum)\n accum_group = VGroup(accum, accum_label).shift(RIGHT * 3)\n \n running_total = MathTex(\"\\\\nabla_0 = 0.0\", font_size=24)\n running_total.next_to(accum_group, DOWN, buff=0.3)\n \n self.wait_until_bookmark(\"ACCUM\")\n self.play(Create(accum_group), Write(running_total), run_time=tracker.duration * 0.3)\n self.play(\n running_total.animate.become(MathTex(\"\\\\nabla_0 = 0.0 + 0.3 = 0.3\", font_size=24)),\n run_time=tracker.duration * 0.35\n )\n self.play(\n running_total.animate.become(MathTex(\"\\\\nabla_0 = 0.3 + 0.5 = 0.8\", font_size=24)),\n run_time=tracker.duration * 0.35\n )\n \n with self.voiceover(text=\"Compared to unique indices, this accumulation ensures the final weight update correctly reflects the total error signal for that specific parameter.\") as tracker:\n compare_text = Text(\"Unique: Update once\\nRepeated: Sum then update\", font_size=20, color=GREEN)\n compare_text.to_edge(DOWN)\n \n self.wait_until_bookmark(\"COMPARE\")\n self.play(Write(compare_text), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "AOS-Manim-SFT_000180", "source": "nabin2004/AOS-Manim-SFT", "tier": 1, "scene_name": "IntroRegressionUnderfittingVisualization", "num_animations": 17, "num_rich_primitives": 4, "prompt": "I'm teaching an intro regression unit and want to visualize underfitting as a high-bias scenario. Show a sinusoidal data set with a straight-line model that cannot fit well, plus residuals heatmap highlighting systematic error. Animate the attempt to fit with a low-complexity model, then zoom into the bias-dominated region. Conclude with intuition about model capacity and feature engineering.", "code": "from manim import *\n\nclass IntroRegressionUnderfittingVisualization(Scene):\n\n def construct(self):\n title = Text('Regression Underfitting Visualization', font_size=36, color=BLUE)\n title.to_edge(UP)\n self.play(Write(title), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(title))\n axes = Axes(x_range=[-1, 10, 1], y_range=[-1, 8, 1], axis_config={'include_numbers': True, 'font_size': 20}, x_length=8, y_length=5)\n axes_labels = axes.get_axis_labels(x_label='x', y_label='y')\n self.play(Create(axes), Write(axes_labels), run_time=2.0)\n data_x = [1, 2, 3, 4, 5, 6, 7, 8]\n data_y = [1.5, 1.8, 2.8, 4.5, 5.2, 4.8, 3.5, 2.2]\n dots = VGroup(*[Dot(axes.c2p(x, y), color=BLUE, radius=0.08) for x, y in zip(data_x, data_y)])\n self.play(AnimationGroup(*[Create(dot) for dot in dots], lag_ratio=0.1), run_time=2.0)\n underfit_line = axes.plot(lambda x: 3.2, x_range=[0.5, 8.5], color=RED)\n underfit_label = MathTex('y = 3.2', color=RED, font_size=28)\n underfit_label.next_to(underfit_line, UP, buff=0.3)\n self.play(Create(underfit_line), Write(underfit_label), run_time=2.0)\n residual_lines = VGroup(*[DashedLine(start=axes.c2p(x, y), end=axes.c2p(x, 3.2), color=RED_E, stroke_width=1.5) for x, y in zip(data_x, data_y)])\n self.play(Create(residual_lines), run_time=2.0)\n underfit_text = Text('UNDERFITTING', font_size=28, color=RED, weight=BOLD)\n underfit_desc = Text('Model too simple\\nHigh bias', font_size=20, color=RED_D)\n underfit_box = VGroup(underfit_text, underfit_desc).arrange(DOWN, buff=0.2)\n underfit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(underfit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(underfit_line), FadeOut(underfit_label), FadeOut(residual_lines), FadeOut(underfit_box), run_time=2.0)\n good_fit = axes.plot(lambda x: -0.15 * (x - 5) ** 2 + 5.5, x_range=[0.5, 8.5], color=GREEN)\n good_label = Text('Good Fit', font_size=24, color=GREEN)\n good_label.next_to(good_fit, UP, buff=0.1).shift(RIGHT * 2)\n self.play(Create(good_fit), Write(good_label), run_time=2.0)\n good_residuals = VGroup(*[DashedLine(start=axes.c2p(x, y), end=axes.c2p(x, -0.15 * (x - 5) ** 2 + 5.5), color=GREEN_E, stroke_width=1.5) for x, y in zip(data_x, data_y)])\n self.play(Create(good_residuals), run_time=2.0)\n good_fit_box = VGroup(Text('BALANCED', font_size=28, color=GREEN, weight=BOLD), Text('Good generalization', font_size=20, color=GREEN_D)).arrange(DOWN, buff=0.2)\n good_fit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(good_fit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(good_fit), FadeOut(good_label), FadeOut(good_residuals), FadeOut(good_fit_box), run_time=2.0)\n overfit_curve = VMobject(color=PURPLE)\n overfit_points = [axes.c2p(x, y) for x, y in zip(data_x, data_y)]\n overfit_curve.set_points_smoothly([axes.c2p(0.5, 1.8), axes.c2p(1, 1.5), axes.c2p(1.5, 2.5), axes.c2p(2, 1.8), axes.c2p(2.5, 2.5), axes.c2p(3, 2.8), axes.c2p(3.5, 3.8), axes.c2p(4, 4.5), axes.c2p(4.5, 5.0), axes.c2p(5, 5.2), axes.c2p(5.5, 5.0), axes.c2p(6, 4.8), axes.c2p(6.5, 4.0), axes.c2p(7, 3.5), axes.c2p(7.5, 2.8), axes.c2p(8, 2.2), axes.c2p(8.5, 2.0)])\n overfit_label = Text('Overfit', font_size=24, color=PURPLE)\n overfit_label.to_corner(UR, buff=0.5)\n self.play(Create(overfit_curve), Write(overfit_label), run_time=2.0)\n overfit_box = VGroup(Text('OVERFITTING', font_size=28, color=PURPLE, weight=BOLD), Text('Model too complex\\nHigh variance', font_size=20, color=PURPLE_D)).arrange(DOWN, buff=0.2)\n overfit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(overfit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(overfit_curve), FadeOut(overfit_label), FadeOut(overfit_box), run_time=2.0 * 0.5)\n underfit_line2 = axes.plot(lambda x: 3.2, x_range=[0.5, 8.5], color=RED)\n good_fit2 = axes.plot(lambda x: -0.15 * (x - 5) ** 2 + 5.5, x_range=[0.5, 8.5], color=GREEN)\n underfit_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=RED), Text('Underfit', font_size=20, color=RED)).arrange(RIGHT, buff=0.2)\n good_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=GREEN), Text('Good Fit', font_size=20, color=GREEN)).arrange(RIGHT, buff=0.2)\n overfit_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=PURPLE), Text('Overfit', font_size=20, color=PURPLE)).arrange(RIGHT, buff=0.2)\n legend = VGroup(underfit_legend, good_legend, overfit_legend).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n legend.to_corner(DR, buff=0.5)\n self.play(Create(underfit_line2), Create(good_fit2), Create(overfit_curve), FadeIn(legend), run_time=2.0)\n takeaway = Text('Key: Match model complexity to data complexity!', font_size=28, color=YELLOW)\n takeaway.to_edge(DOWN, buff=0.8)\n self.play(Write(takeaway), run_time=2.0)\n self.wait(1)\n self.wait(2.0)\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an intro regression unit and want to visualize underfitting as a high-bias scenario. Show a sinusoidal data set with a straight-line model that cannot fit well, plus residuals heatmap highlighting systematic error. Animate the attempt to fit with a low-complexity model, then zoom into the bias-dominated region. Conclude with intuition about model capacity and feature engineering."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntroRegressionUnderfittingVisualization(Scene):\n\n def construct(self):\n title = Text('Regression Underfitting Visualization', font_size=36, color=BLUE)\n title.to_edge(UP)\n self.play(Write(title), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(title))\n axes = Axes(x_range=[-1, 10, 1], y_range=[-1, 8, 1], axis_config={'include_numbers': True, 'font_size': 20}, x_length=8, y_length=5)\n axes_labels = axes.get_axis_labels(x_label='x', y_label='y')\n self.play(Create(axes), Write(axes_labels), run_time=2.0)\n data_x = [1, 2, 3, 4, 5, 6, 7, 8]\n data_y = [1.5, 1.8, 2.8, 4.5, 5.2, 4.8, 3.5, 2.2]\n dots = VGroup(*[Dot(axes.c2p(x, y), color=BLUE, radius=0.08) for x, y in zip(data_x, data_y)])\n self.play(AnimationGroup(*[Create(dot) for dot in dots], lag_ratio=0.1), run_time=2.0)\n underfit_line = axes.plot(lambda x: 3.2, x_range=[0.5, 8.5], color=RED)\n underfit_label = MathTex('y = 3.2', color=RED, font_size=28)\n underfit_label.next_to(underfit_line, UP, buff=0.3)\n self.play(Create(underfit_line), Write(underfit_label), run_time=2.0)\n residual_lines = VGroup(*[DashedLine(start=axes.c2p(x, y), end=axes.c2p(x, 3.2), color=RED_E, stroke_width=1.5) for x, y in zip(data_x, data_y)])\n self.play(Create(residual_lines), run_time=2.0)\n underfit_text = Text('UNDERFITTING', font_size=28, color=RED, weight=BOLD)\n underfit_desc = Text('Model too simple\\nHigh bias', font_size=20, color=RED_D)\n underfit_box = VGroup(underfit_text, underfit_desc).arrange(DOWN, buff=0.2)\n underfit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(underfit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(underfit_line), FadeOut(underfit_label), FadeOut(residual_lines), FadeOut(underfit_box), run_time=2.0)\n good_fit = axes.plot(lambda x: -0.15 * (x - 5) ** 2 + 5.5, x_range=[0.5, 8.5], color=GREEN)\n good_label = Text('Good Fit', font_size=24, color=GREEN)\n good_label.next_to(good_fit, UP, buff=0.1).shift(RIGHT * 2)\n self.play(Create(good_fit), Write(good_label), run_time=2.0)\n good_residuals = VGroup(*[DashedLine(start=axes.c2p(x, y), end=axes.c2p(x, -0.15 * (x - 5) ** 2 + 5.5), color=GREEN_E, stroke_width=1.5) for x, y in zip(data_x, data_y)])\n self.play(Create(good_residuals), run_time=2.0)\n good_fit_box = VGroup(Text('BALANCED', font_size=28, color=GREEN, weight=BOLD), Text('Good generalization', font_size=20, color=GREEN_D)).arrange(DOWN, buff=0.2)\n good_fit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(good_fit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(good_fit), FadeOut(good_label), FadeOut(good_residuals), FadeOut(good_fit_box), run_time=2.0)\n overfit_curve = VMobject(color=PURPLE)\n overfit_points = [axes.c2p(x, y) for x, y in zip(data_x, data_y)]\n overfit_curve.set_points_smoothly([axes.c2p(0.5, 1.8), axes.c2p(1, 1.5), axes.c2p(1.5, 2.5), axes.c2p(2, 1.8), axes.c2p(2.5, 2.5), axes.c2p(3, 2.8), axes.c2p(3.5, 3.8), axes.c2p(4, 4.5), axes.c2p(4.5, 5.0), axes.c2p(5, 5.2), axes.c2p(5.5, 5.0), axes.c2p(6, 4.8), axes.c2p(6.5, 4.0), axes.c2p(7, 3.5), axes.c2p(7.5, 2.8), axes.c2p(8, 2.2), axes.c2p(8.5, 2.0)])\n overfit_label = Text('Overfit', font_size=24, color=PURPLE)\n overfit_label.to_corner(UR, buff=0.5)\n self.play(Create(overfit_curve), Write(overfit_label), run_time=2.0)\n overfit_box = VGroup(Text('OVERFITTING', font_size=28, color=PURPLE, weight=BOLD), Text('Model too complex\\nHigh variance', font_size=20, color=PURPLE_D)).arrange(DOWN, buff=0.2)\n overfit_box.to_corner(DR, buff=0.5)\n self.play(FadeIn(overfit_box), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(overfit_curve), FadeOut(overfit_label), FadeOut(overfit_box), run_time=2.0 * 0.5)\n underfit_line2 = axes.plot(lambda x: 3.2, x_range=[0.5, 8.5], color=RED)\n good_fit2 = axes.plot(lambda x: -0.15 * (x - 5) ** 2 + 5.5, x_range=[0.5, 8.5], color=GREEN)\n underfit_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=RED), Text('Underfit', font_size=20, color=RED)).arrange(RIGHT, buff=0.2)\n good_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=GREEN), Text('Good Fit', font_size=20, color=GREEN)).arrange(RIGHT, buff=0.2)\n overfit_legend = VGroup(Line(LEFT * 0.3, RIGHT * 0.3, color=PURPLE), Text('Overfit', font_size=20, color=PURPLE)).arrange(RIGHT, buff=0.2)\n legend = VGroup(underfit_legend, good_legend, overfit_legend).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n legend.to_corner(DR, buff=0.5)\n self.play(Create(underfit_line2), Create(good_fit2), Create(overfit_curve), FadeIn(legend), run_time=2.0)\n takeaway = Text('Key: Match model complexity to data complexity!', font_size=28, color=YELLOW)\n takeaway.to_edge(DOWN, buff=0.8)\n self.play(Write(takeaway), run_time=2.0)\n self.wait(1)\n self.wait(2.0)\n self.wait(2)\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000456", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "BOinRLScene", "num_animations": 5, "num_rich_primitives": 2, "prompt": "I'm learning Bayesian optimization for RL in model-based settings and want to see how objectives and constraints interact.\nVisualize a surrogate model being updated as we collect samples, with multiple objectives and hard/soft constraints shaping the search.\nShow a few adaptive experiments, tradeoffs between exploration and exploitation, and a plot of the constraint satisfaction frontier over time.\nI'd like the animation to sweep through environments and include a comparison of sample efficiency with and without the constraints.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nclass BOinRLScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: GP]\n with self.voiceover(text=\"Bayesian Optimization uses a surrogate model to efficiently tune RL hyperparameters. A Gaussian Process not only predicts the objective function but also quantifies the uncertainty of that prediction.\") as tracker:\n title = Text(\"Bayesian Optimization in RL\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n axes = Axes(x_range=[0, 6, 1], y_range=[-2, 2.5, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n \n gp_mean = axes.plot(lambda x: 0.5 * np.sin(x), color=BLUE, stroke_width=2)\n \n band = VGroup()\n for x in np.linspace(0, 6, 40):\n y_center = 0.5 * np.sin(x)\n band.add(Line(\n axes.c2p(x, y_center - 0.8), \n axes.c2p(x, y_center + 0.8), \n stroke_width=1, color=BLUE\n ).set_opacity(0.15))\n \n self.wait_until_bookmark(\"GP\")\n self.play(Write(title), Create(axes), Create(band), Create(gp_mean), run_time=tracker.duration)\n\n with self.voiceover(text=\"To decide where to sample next, we use an acquisition function. It balances exploration of uncertain regions with exploitation of known good areas, guiding the search efficiently.\") as tracker:\n self.play(FadeOut(VGroup(band, gp_mean)), run_time=0.5)\n \n acq_title = Text(\"Acquisition Function\", font_size=24, color=PURPLE)\n acq_title.next_to(axes, UP, buff=0.2)\n \n acq_types = VGroup(\n Text(\"Expected Improvement (EI)\", font_size=16),\n Text(\"Upper Confidence Bound (UCB)\", font_size=16),\n Text(\"Probability of Improvement (PI)\", font_size=16)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(axes, RIGHT, buff=0.5)\n \n self.wait_until_bookmark(\"ACQ\")\n self.play(Write(acq_title), Write(acq_types), run_time=tracker.duration)\n\n with self.voiceover(text=\"The algorithm iterates this process. We fit the GP, maximize the acquisition function to find the next hyperparameter, evaluate the RL agent, and update our beliefs until we find the optimal policy.\") as tracker:\n self.play(FadeOut(VGroup(acq_title, acq_types)), run_time=0.5)\n \n steps = VGroup(\n Text(\"1. Initialize GP prior\", font_size=16, color=BLUE),\n Text(\"2. Fit GP to observed data\", font_size=16, color=GREEN),\n Text(\"3. Maximize acquisition function\", font_size=16, color=PURPLE),\n Text(\"4. Evaluate RL agent\", font_size=16, color=YELLOW),\n Text(\"5. Update posterior, repeat\", font_size=16, color=GRAY)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(axes, LEFT, buff=0.5)\n \n self.wait_until_bookmark(\"ALGO\")\n self.play(Write(steps), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm learning Bayesian optimization for RL in model-based settings and want to see how objectives and constraints interact.\nVisualize a surrogate model being updated as we collect samples, with multiple objectives and hard/soft constraints shaping the search.\nShow a few adaptive experiments, tradeoffs between exploration and exploitation, and a plot of the constraint satisfaction frontier over time.\nI'd like the animation to sweep through environments and include a comparison of sample efficiency with and without the constraints."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nclass BOinRLScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: GP]\n with self.voiceover(text=\"Bayesian Optimization uses a surrogate model to efficiently tune RL hyperparameters. A Gaussian Process not only predicts the objective function but also quantifies the uncertainty of that prediction.\") as tracker:\n title = Text(\"Bayesian Optimization in RL\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n axes = Axes(x_range=[0, 6, 1], y_range=[-2, 2.5, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n \n gp_mean = axes.plot(lambda x: 0.5 * np.sin(x), color=BLUE, stroke_width=2)\n \n band = VGroup()\n for x in np.linspace(0, 6, 40):\n y_center = 0.5 * np.sin(x)\n band.add(Line(\n axes.c2p(x, y_center - 0.8), \n axes.c2p(x, y_center + 0.8), \n stroke_width=1, color=BLUE\n ).set_opacity(0.15))\n \n self.wait_until_bookmark(\"GP\")\n self.play(Write(title), Create(axes), Create(band), Create(gp_mean), run_time=tracker.duration)\n\n with self.voiceover(text=\"To decide where to sample next, we use an acquisition function. It balances exploration of uncertain regions with exploitation of known good areas, guiding the search efficiently.\") as tracker:\n self.play(FadeOut(VGroup(band, gp_mean)), run_time=0.5)\n \n acq_title = Text(\"Acquisition Function\", font_size=24, color=PURPLE)\n acq_title.next_to(axes, UP, buff=0.2)\n \n acq_types = VGroup(\n Text(\"Expected Improvement (EI)\", font_size=16),\n Text(\"Upper Confidence Bound (UCB)\", font_size=16),\n Text(\"Probability of Improvement (PI)\", font_size=16)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(axes, RIGHT, buff=0.5)\n \n self.wait_until_bookmark(\"ACQ\")\n self.play(Write(acq_title), Write(acq_types), run_time=tracker.duration)\n\n with self.voiceover(text=\"The algorithm iterates this process. We fit the GP, maximize the acquisition function to find the next hyperparameter, evaluate the RL agent, and update our beliefs until we find the optimal policy.\") as tracker:\n self.play(FadeOut(VGroup(acq_title, acq_types)), run_time=0.5)\n \n steps = VGroup(\n Text(\"1. Initialize GP prior\", font_size=16, color=BLUE),\n Text(\"2. Fit GP to observed data\", font_size=16, color=GREEN),\n Text(\"3. Maximize acquisition function\", font_size=16, color=PURPLE),\n Text(\"4. Evaluate RL agent\", font_size=16, color=YELLOW),\n Text(\"5. Update posterior, repeat\", font_size=16, color=GRAY)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(axes, LEFT, buff=0.5)\n \n self.wait_until_bookmark(\"ALGO\")\n self.play(Write(steps), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_007443", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralSolution", "num_animations": 13, "num_rich_primitives": 2, "prompt": "Could you create an educational animation using ManimCE that visually demonstrates how to solve a triple integration problem step by step? Start by displaying the triple integral of the function xyz within the bounds z from 0 to 3, x from 0 to 2, and y from 0 to 1 on the screen. For each step, begin by integrating with respect to z, followed by x, and lastly y. Include written explanations above each mathematical step indicating which variable we are integrating with respect to next. After calculating each integral, show the resulting expression before moving on to the next. Once the final answer is found, clear the screen and display only the final numerical solution prominently.", "code": "from manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- 1. Initialization ---\n # Display the full triple integral with specified bounds.\n # Splitting into components allows for smoother visual transformations.\n initial_integral = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{2}\", r\"\\int_{0}^{3}\",\n r\"xyz\", r\"\\, dz \\, dx \\, dy\",\n font_size=40\n )\n \n # Color coding bounds and variables for pedagogical clarity\n for i in range(3):\n initial_integral[i].set_color(BLUE)\n initial_integral[3].set_color(YELLOW)\n \n title = Text(\"Triple Integration Problem\", font_size=36).to_edge(UP)\n initial_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title), Write(initial_integral))\n self.wait(1.5)\n\n # --- 2. Step-by-Step Integration ---\n \n # Step 1: Integration with respect to z\n step1_label = Text(\"Step 1: Integrate with respect to z\", font_size=28, color=BLUE)\n step1_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_z = MathTex(\n r\"\\int_{0}^{3} xyz \\, dz = xy \\left[ \\frac{z^2}{2} \\right]_{0}^{3} = \\frac{9}{2}xy\",\n font_size=32\n )\n calc_z.next_to(initial_integral, DOWN, buff=0.5)\n \n self.play(Transform(title, step1_label))\n self.play(Write(calc_z))\n self.wait(1.5)\n \n # Transform the main integral to reflect the result of the z-integration\n integral_step1 = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{2}\", \n r\"\\frac{9}{2}xy\", r\"\\, dx\", r\"\\, dy\",\n font_size=40\n )\n integral_step1[0].set_color(BLUE)\n integral_step1[1].set_color(BLUE)\n integral_step1[2].set_color(YELLOW)\n integral_step1.move_to(initial_integral)\n \n self.play(ReplacementTransform(initial_integral, integral_step1), FadeOut(calc_z))\n self.wait(1)\n\n # Step 2: Integration with respect to x\n step2_label = Text(\"Step 2: Integrate with respect to x\", font_size=28, color=GREEN)\n step2_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_x = MathTex(\n r\"\\int_{0}^{2} \\frac{9}{2}xy \\, dx = \\frac{9}{2}y \\left[ \\frac{x^2}{2} \\right]_{0}^{2} = 9y\",\n font_size=32\n )\n calc_x.next_to(integral_step1, DOWN, buff=0.5)\n \n self.play(Transform(step1_label, step2_label))\n self.play(Write(calc_x))\n self.wait(1.5)\n \n # Transform the main integral\n integral_step2 = MathTex(\n r\"\\int_{0}^{1}\", r\"9y\", r\"\\, dy\",\n font_size=40\n )\n integral_step2[0].set_color(BLUE)\n integral_step2[1].set_color(YELLOW)\n integral_step2.move_to(integral_step1)\n \n self.play(ReplacementTransform(integral_step1, integral_step2), FadeOut(calc_x))\n self.wait(1)\n\n # Step 3: Integration with respect to y\n step3_label = Text(\"Step 3: Integrate with respect to y\", font_size=28, color=YELLOW)\n step3_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_y = MathTex(\n r\"\\int_{0}^{1} 9y \\, dy = 9 \\left[ \\frac{y^2}{2} \\right]_{0}^{1} = \\frac{9}{2}\",\n font_size=32\n )\n calc_y.next_to(integral_step2, DOWN, buff=0.5)\n \n self.play(Transform(step2_label, step3_label))\n self.play(Write(calc_y))\n self.wait(1.5)\n \n # Transform to final result within the equation context\n final_result_eq = MathTex(r\"\\frac{9}{2}\", font_size=40)\n final_result_eq.move_to(integral_step2)\n \n self.play(ReplacementTransform(integral_step2, final_result_eq), FadeOut(calc_y))\n self.wait(1)\n\n # --- 3. Conclusion ---\n # Clear the screen\n self.play(FadeOut(step3_label), FadeOut(final_result_eq))\n \n # Display only the final numerical solution prominently\n final_answer = MathTex(r\"4.5\", font_size=80, color=GOLD)\n final_answer.move_to(ORIGIN)\n \n self.play(Write(final_answer))\n self.play(Indicate(final_answer))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation using ManimCE that visually demonstrates how to solve a triple integration problem step by step? Start by displaying the triple integral of the function xyz within the bounds z from 0 to 3, x from 0 to 2, and y from 0 to 1 on the screen. For each step, begin by integrating with respect to z, followed by x, and lastly y. Include written explanations above each mathematical step indicating which variable we are integrating with respect to next. After calculating each integral, show the resulting expression before moving on to the next. Once the final answer is found, clear the screen and display only the final numerical solution prominently."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- 1. Initialization ---\n # Display the full triple integral with specified bounds.\n # Splitting into components allows for smoother visual transformations.\n initial_integral = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{2}\", r\"\\int_{0}^{3}\",\n r\"xyz\", r\"\\, dz \\, dx \\, dy\",\n font_size=40\n )\n \n # Color coding bounds and variables for pedagogical clarity\n for i in range(3):\n initial_integral[i].set_color(BLUE)\n initial_integral[3].set_color(YELLOW)\n \n title = Text(\"Triple Integration Problem\", font_size=36).to_edge(UP)\n initial_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title), Write(initial_integral))\n self.wait(1.5)\n\n # --- 2. Step-by-Step Integration ---\n \n # Step 1: Integration with respect to z\n step1_label = Text(\"Step 1: Integrate with respect to z\", font_size=28, color=BLUE)\n step1_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_z = MathTex(\n r\"\\int_{0}^{3} xyz \\, dz = xy \\left[ \\frac{z^2}{2} \\right]_{0}^{3} = \\frac{9}{2}xy\",\n font_size=32\n )\n calc_z.next_to(initial_integral, DOWN, buff=0.5)\n \n self.play(Transform(title, step1_label))\n self.play(Write(calc_z))\n self.wait(1.5)\n \n # Transform the main integral to reflect the result of the z-integration\n integral_step1 = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{2}\", \n r\"\\frac{9}{2}xy\", r\"\\, dx\", r\"\\, dy\",\n font_size=40\n )\n integral_step1[0].set_color(BLUE)\n integral_step1[1].set_color(BLUE)\n integral_step1[2].set_color(YELLOW)\n integral_step1.move_to(initial_integral)\n \n self.play(ReplacementTransform(initial_integral, integral_step1), FadeOut(calc_z))\n self.wait(1)\n\n # Step 2: Integration with respect to x\n step2_label = Text(\"Step 2: Integrate with respect to x\", font_size=28, color=GREEN)\n step2_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_x = MathTex(\n r\"\\int_{0}^{2} \\frac{9}{2}xy \\, dx = \\frac{9}{2}y \\left[ \\frac{x^2}{2} \\right]_{0}^{2} = 9y\",\n font_size=32\n )\n calc_x.next_to(integral_step1, DOWN, buff=0.5)\n \n self.play(Transform(step1_label, step2_label))\n self.play(Write(calc_x))\n self.wait(1.5)\n \n # Transform the main integral\n integral_step2 = MathTex(\n r\"\\int_{0}^{1}\", r\"9y\", r\"\\, dy\",\n font_size=40\n )\n integral_step2[0].set_color(BLUE)\n integral_step2[1].set_color(YELLOW)\n integral_step2.move_to(integral_step1)\n \n self.play(ReplacementTransform(integral_step1, integral_step2), FadeOut(calc_x))\n self.wait(1)\n\n # Step 3: Integration with respect to y\n step3_label = Text(\"Step 3: Integrate with respect to y\", font_size=28, color=YELLOW)\n step3_label.to_edge(UP, buff=1)\n \n # Show the intermediate calculation explicitly\n calc_y = MathTex(\n r\"\\int_{0}^{1} 9y \\, dy = 9 \\left[ \\frac{y^2}{2} \\right]_{0}^{1} = \\frac{9}{2}\",\n font_size=32\n )\n calc_y.next_to(integral_step2, DOWN, buff=0.5)\n \n self.play(Transform(step2_label, step3_label))\n self.play(Write(calc_y))\n self.wait(1.5)\n \n # Transform to final result within the equation context\n final_result_eq = MathTex(r\"\\frac{9}{2}\", font_size=40)\n final_result_eq.move_to(integral_step2)\n \n self.play(ReplacementTransform(integral_step2, final_result_eq), FadeOut(calc_y))\n self.wait(1)\n\n # --- 3. Conclusion ---\n # Clear the screen\n self.play(FadeOut(step3_label), FadeOut(final_result_eq))\n \n # Display only the final numerical solution prominently\n final_answer = MathTex(r\"4.5\", font_size=80, color=GOLD)\n final_answer.move_to(ORIGIN)\n \n self.play(Write(final_answer))\n self.play(Indicate(final_answer))\n self.wait(3)\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000031", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "ApiValidBarChart378", "num_animations": 4, "num_rich_primitives": 2, "prompt": "Construct a clean Manim CE scene initializing BarChart with verified keyword arguments. Ensure no deprecated ManimGL arguments (like element_color, max_value, or max_magnitude) are used.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nMARGIN = 0.5\n\nclass ApiValidBarChart378(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [LAYOUT]\n # Create title\n title = Text(\"BarChart: Valid API\", font_size=36).to_edge(UP, buff=MARGIN)\n \n # Create BarChart with valid keyword arguments (ManimCE v0.19+)\n chart = BarChart(\n values=[2, 4, 3, 5],\n bar_names=['A', 'B', 'C', 'D'],\n y_range=[0, 6, 2],\n y_length=4,\n x_length=6\n )\n chart.set_color(BLUE)\n \n # Fit chart in frame\n self.fit_in_frame(chart, w_frac=0.8, h_frac=0.6)\n chart.move_to(ORIGIN)\n \n # Parameter labels\n params = VGroup(\n Text(\"values=[2,4,3,5]\", font_size=20),\n Text(\"bar_names=['A','B','C','D']\", font_size=20),\n Text(\"y_range=[0,6,2]\", font_size=20),\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n params.next_to(chart, DOWN, buff=0.4)\n self.fit_in_frame(params, w_frac=0.9, h_frac=0.2)\n \n # [BEAT 1 | sync: create]\n with self.voiceover(text=\"\"\"\n Let's create a bar chart using Manim Community Edition's validated API.\n \n \"\"\") as t:\n self.play(Write(title))\n self.wait_until_bookmark(\"create\")\n self.play(Create(chart), run_time=2)\n \n # [BEAT 2 | sync: params]\n with self.voiceover(text=\"\"\"\n We use valid keyword arguments: values, bar names, y range, and chart dimensions.\n \n These are all documented parameters in the current Manim C E version.\n \n \"\"\") as t:\n self.wait_until_bookmark(\"params\")\n self.play(FadeIn(params, shift=UP))\n self.wait_until_bookmark(\"done\")\n self.wait(1)\n \n # Cleanup\n self.play(\n FadeOut(title),\n FadeOut(chart),\n FadeOut(params)\n )\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Construct a clean Manim CE scene initializing BarChart with verified keyword arguments. Ensure no deprecated ManimGL arguments (like element_color, max_value, or max_magnitude) are used."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nMARGIN = 0.5\n\nclass ApiValidBarChart378(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [LAYOUT]\n # Create title\n title = Text(\"BarChart: Valid API\", font_size=36).to_edge(UP, buff=MARGIN)\n \n # Create BarChart with valid keyword arguments (ManimCE v0.19+)\n chart = BarChart(\n values=[2, 4, 3, 5],\n bar_names=['A', 'B', 'C', 'D'],\n y_range=[0, 6, 2],\n y_length=4,\n x_length=6\n )\n chart.set_color(BLUE)\n \n # Fit chart in frame\n self.fit_in_frame(chart, w_frac=0.8, h_frac=0.6)\n chart.move_to(ORIGIN)\n \n # Parameter labels\n params = VGroup(\n Text(\"values=[2,4,3,5]\", font_size=20),\n Text(\"bar_names=['A','B','C','D']\", font_size=20),\n Text(\"y_range=[0,6,2]\", font_size=20),\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n params.next_to(chart, DOWN, buff=0.4)\n self.fit_in_frame(params, w_frac=0.9, h_frac=0.2)\n \n # [BEAT 1 | sync: create]\n with self.voiceover(text=\"\"\"\n Let's create a bar chart using Manim Community Edition's validated API.\n \n \"\"\") as t:\n self.play(Write(title))\n self.wait_until_bookmark(\"create\")\n self.play(Create(chart), run_time=2)\n \n # [BEAT 2 | sync: params]\n with self.voiceover(text=\"\"\"\n We use valid keyword arguments: values, bar names, y range, and chart dimensions.\n \n These are all documented parameters in the current Manim C E version.\n \n \"\"\") as t:\n self.wait_until_bookmark(\"params\")\n self.play(FadeIn(params, shift=UP))\n self.wait_until_bookmark(\"done\")\n self.wait(1)\n \n # Cleanup\n self.play(\n FadeOut(title),\n FadeOut(chart),\n FadeOut(params)\n )\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_008233", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralSpherical", "num_animations": 18, "num_rich_primitives": 2, "prompt": "I would like to create an educational animation that visually explains the steps to solve a triple integral using spherical coordinates. Specifically, I want to solve the triple integral of ρ^2 sin φ with respect to ρ, then θ, and finally φ, over the ranges of 0 to 1 for ρ, 0 to 2π for θ, and 0 to π for φ. The animation should include the written integral problem, and step-by-step animations showcasing each stage of the integration process, complete with textual explanations guiding through the integration with respect to ρ, then θ, then φ, and finally evaluating the integral to find the numerical result. Can you create this animated visualization to help students understand the concept and steps of evaluating triple integrals in spherical coordinates?", "code": "from manim import *\n\nclass TripleIntegralSpherical(Scene):\n def construct(self):\n # --- Colors ---\n COLOR_RHO = YELLOW\n COLOR_THETA = BLUE\n COLOR_PHI = GREEN\n \n # --- 1. Problem Statement ---\n title = Text(\"Evaluating a Triple Integral in Spherical Coordinates\", font_size=36).to_edge(UP)\n \n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\int_{0}^{1} \\rho^2 \\sin \\phi \\, d\\rho \\, d\\theta \\, d\\phi\",\n font_size=42\n ).shift(UP * 1.5)\n\n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Setup for Step-by-Step ---\n guide_text = Tex(\n \"Step 1: Integrate with respect to $\\\\rho$\", \n font_size=32, \n color=COLOR_RHO\n ).next_to(title, DOWN, buff=0.5)\n\n # --- 2. Step 1: Integration w.r.t rho ---\n self.play(Write(guide_text))\n self.wait(1)\n\n # Antiderivative\n step1_antideriv = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\left[ \\frac{\\rho^3}{3} \\sin \\phi \\right]_{0}^{1} \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(initial_integral, step1_antideriv))\n self.wait(2)\n\n # Substitution\n step1_sub = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\left( \\frac{1^3}{3} - \\frac{0^3}{3} \\right) \\sin \\phi \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_antideriv, step1_sub))\n self.wait(2)\n\n # Simplify\n step1_final = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\frac{1}{3} \\sin \\phi \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_sub, step1_final))\n self.wait(2)\n\n # --- 3. Step 2: Integration w.r.t theta ---\n new_guide_text = Tex(\n \"Step 2: Integrate with respect to $\\\\theta$\", \n font_size=32, \n color=COLOR_THETA\n ).next_to(title, DOWN, buff=0.5)\n\n self.play(Transform(guide_text, new_guide_text))\n self.wait(1)\n\n # Antiderivative\n step2_antideriv = MathTex(\n r\"\\frac{1}{3} \\int_{0}^{\\pi} \\left[ \\theta \\sin \\phi \\right]_{0}^{2\\pi} \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_final, step2_antideriv))\n self.wait(2)\n\n # Substitution\n step2_sub = MathTex(\n r\"\\frac{1}{3} \\int_{0}^{\\pi} \\left( 2\\pi \\sin \\phi - 0 \\right) \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_antideriv, step2_sub))\n self.wait(2)\n\n # Simplify\n step2_final = MathTex(\n r\"\\frac{2\\pi}{3} \\int_{0}^{\\pi} \\sin \\phi \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_sub, step2_final))\n self.wait(2)\n\n # --- 4. Step 3: Integration w.r.t phi ---\n final_guide_text = Tex(\n \"Step 3: Integrate with respect to $\\\\phi$\", \n font_size=32, \n color=COLOR_PHI\n ).next_to(title, DOWN, buff=0.5)\n\n self.play(Transform(guide_text, final_guide_text))\n self.wait(1)\n\n # Antiderivative\n step3_antideriv = MathTex(\n r\"\\frac{2\\pi}{3} \\left[ -\\cos \\phi \\right]_{0}^{\\pi}\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_final, step3_antideriv))\n self.wait(2)\n\n # Substitution\n step3_sub = MathTex(\n r\"\\frac{2\\pi}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step3_antideriv, step3_sub))\n self.wait(2)\n\n # Arithmetic\n step3_arith = MathTex(\n r\"\\frac{2\\pi}{3} \\left( 1 + 1 \\right)\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step3_sub, step3_arith))\n self.wait(2)\n\n # --- 5. Final Result ---\n final_result = MathTex(\n r\"=\\frac{4\\pi}{3}\",\n font_size=54,\n color=YELLOW\n ).move_to(initial_integral)\n\n self.play(FadeOut(guide_text))\n self.play(FadeTransform(step3_arith, final_result))\n \n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n \n conclusion = Tex(\n \"Volume of the Unit Sphere: $\\\\frac{4\\pi}{3}$\", \n font_size=36\n ).next_to(box, DOWN, buff=0.5)\n \n self.play(Write(conclusion))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that visually explains the steps to solve a triple integral using spherical coordinates. Specifically, I want to solve the triple integral of ρ^2 sin φ with respect to ρ, then θ, and finally φ, over the ranges of 0 to 1 for ρ, 0 to 2π for θ, and 0 to π for φ. The animation should include the written integral problem, and step-by-step animations showcasing each stage of the integration process, complete with textual explanations guiding through the integration with respect to ρ, then θ, then φ, and finally evaluating the integral to find the numerical result. Can you create this animated visualization to help students understand the concept and steps of evaluating triple integrals in spherical coordinates?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralSpherical(Scene):\n def construct(self):\n # --- Colors ---\n COLOR_RHO = YELLOW\n COLOR_THETA = BLUE\n COLOR_PHI = GREEN\n \n # --- 1. Problem Statement ---\n title = Text(\"Evaluating a Triple Integral in Spherical Coordinates\", font_size=36).to_edge(UP)\n \n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\int_{0}^{1} \\rho^2 \\sin \\phi \\, d\\rho \\, d\\theta \\, d\\phi\",\n font_size=42\n ).shift(UP * 1.5)\n\n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Setup for Step-by-Step ---\n guide_text = Tex(\n \"Step 1: Integrate with respect to $\\\\rho$\", \n font_size=32, \n color=COLOR_RHO\n ).next_to(title, DOWN, buff=0.5)\n\n # --- 2. Step 1: Integration w.r.t rho ---\n self.play(Write(guide_text))\n self.wait(1)\n\n # Antiderivative\n step1_antideriv = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\left[ \\frac{\\rho^3}{3} \\sin \\phi \\right]_{0}^{1} \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(initial_integral, step1_antideriv))\n self.wait(2)\n\n # Substitution\n step1_sub = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\left( \\frac{1^3}{3} - \\frac{0^3}{3} \\right) \\sin \\phi \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_antideriv, step1_sub))\n self.wait(2)\n\n # Simplify\n step1_final = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{2\\pi} \\frac{1}{3} \\sin \\phi \\, d\\theta \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_sub, step1_final))\n self.wait(2)\n\n # --- 3. Step 2: Integration w.r.t theta ---\n new_guide_text = Tex(\n \"Step 2: Integrate with respect to $\\\\theta$\", \n font_size=32, \n color=COLOR_THETA\n ).next_to(title, DOWN, buff=0.5)\n\n self.play(Transform(guide_text, new_guide_text))\n self.wait(1)\n\n # Antiderivative\n step2_antideriv = MathTex(\n r\"\\frac{1}{3} \\int_{0}^{\\pi} \\left[ \\theta \\sin \\phi \\right]_{0}^{2\\pi} \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step1_final, step2_antideriv))\n self.wait(2)\n\n # Substitution\n step2_sub = MathTex(\n r\"\\frac{1}{3} \\int_{0}^{\\pi} \\left( 2\\pi \\sin \\phi - 0 \\right) \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_antideriv, step2_sub))\n self.wait(2)\n\n # Simplify\n step2_final = MathTex(\n r\"\\frac{2\\pi}{3} \\int_{0}^{\\pi} \\sin \\phi \\, d\\phi\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_sub, step2_final))\n self.wait(2)\n\n # --- 4. Step 3: Integration w.r.t phi ---\n final_guide_text = Tex(\n \"Step 3: Integrate with respect to $\\\\phi$\", \n font_size=32, \n color=COLOR_PHI\n ).next_to(title, DOWN, buff=0.5)\n\n self.play(Transform(guide_text, final_guide_text))\n self.wait(1)\n\n # Antiderivative\n step3_antideriv = MathTex(\n r\"\\frac{2\\pi}{3} \\left[ -\\cos \\phi \\right]_{0}^{\\pi}\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step2_final, step3_antideriv))\n self.wait(2)\n\n # Substitution\n step3_sub = MathTex(\n r\"\\frac{2\\pi}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step3_antideriv, step3_sub))\n self.wait(2)\n\n # Arithmetic\n step3_arith = MathTex(\n r\"\\frac{2\\pi}{3} \\left( 1 + 1 \\right)\",\n font_size=42\n ).move_to(initial_integral)\n\n self.play(FadeTransform(step3_sub, step3_arith))\n self.wait(2)\n\n # --- 5. Final Result ---\n final_result = MathTex(\n r\"=\\frac{4\\pi}{3}\",\n font_size=54,\n color=YELLOW\n ).move_to(initial_integral)\n\n self.play(FadeOut(guide_text))\n self.play(FadeTransform(step3_arith, final_result))\n \n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n \n conclusion = Tex(\n \"Volume of the Unit Sphere: $\\\\frac{4\\pi}{3}$\", \n font_size=36\n ).next_to(box, DOWN, buff=0.5)\n \n self.play(Write(conclusion))\n self.wait(3)\n```"}]}
{"id": "multi_act_v2_00062", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0062", "num_animations": 28, "prompt": "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 with additional features: \n- Act 2: Here is the enhanced animation description with additional features:\n- Act 3: 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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0062(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_enhancedshapetransformat()\n self.clear_stage()\n self.act_2_shapetransformationwitha()\n self.clear_stage()\n self.act_3_lineartransformation()\n\n def act_1_enhancedshapetransformat(self):\n circle = Circle(color=YELLOW, fill_opacity=0.8).rotate(-45 * DEGREES)\n triangle = Triangle(color=GREEN, fill_opacity=0.8).rotate(-45 * DEGREES)\n \n # Position shapes\n circle.move_to(LEFT * 2)\n triangle.move_to(RIGHT * 2)\n \n # Group shapes\n shapes = VGroup(circle, triangle)\n \n # Add shapes to scene\n self.play(Create(circle), Create(triangle))\n self.wait(0.5)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.8).move_to(circle.get_center())\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.8).move_to(triangle.get_center())\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Add equation\n equation = MathTex(r\"\\text{Area} = \\pi r^2\").next_to(shapes, DOWN, buff=1)\n equation.scale(0.01) # Start small\n \n self.play(\n equation.animate.scale(1.2),\n FadeIn(equation),\n run_time=1\n )\n self.wait(0.5)\n \n # Rotate shapes and pulse equation\n self.play(\n Rotate(shapes, angle=2 * PI, about_point=ORIGIN),\n equation.animate.scale(1.1).set_color_by_gradient(BLUE, WHITE),\n run_time=2\n )\n self.play(equation.animate.scale(1 / 1.1))\n self.wait(0.5)\n \n # Add title and zoom out\n title = Text(\"Shapes and Their Areas\", font_size=24).to_edge(UP)\n grid = NumberPlane()\n \n self.play(\n FadeIn(title, shift=DOWN),\n Create(grid, run_time=2, lag_ratio=0.1),\n shapes.animate.scale(0.8),\n equation.animate.scale(0.8).shift(UP * 0.5),\n run_time=2\n )\n self.wait(2)\n\n def act_2_shapetransformationwitha(self):\n circle = Circle(radius=2, color=PINK)\n formula_text = MathTex(\"\\\\pi r^2 = \", \"s^2\").to_edge(UP)\n explanation = Text(\"A circle transforms into a square while preserving \", font_size=24).to_edge(DOWN)\n area_word = Text(\"area\", color=BLUE, font_size=24).next_to(explanation, RIGHT, buff=0.1)\n \n # Animation sequence\n self.play(Create(circle), run_time=1.5)\n self.play(circle.animate.scale(1.1), run_time=0.5)\n self.play(circle.animate.scale(1/1.1), run_time=0.5)\n \n # Show formula and explanation\n self.play(Write(formula_text[0]), run_time=1)\n self.play(Write(explanation), FadeIn(area_word, shift=UP*0.2), run_time=1)\n \n # Transform circle to square\n side_length = np.sqrt(np.pi * 2**2)\n square = Square(side_length=side_length, color=YELLOW)\n self.play(Transform(circle, square), Write(formula_text[1]), run_time=2)\n \n # Show coordinate system briefly\n axes = Axes()\n self.play(FadeIn(axes), run_time=0.5)\n self.play(FadeOut(axes), run_time=0.5)\n \n # Divide square into smaller squares\n small_squares = VGroup(*[\n Square(side_length=side_length/2, color=YELLOW).move_to(\n square.get_center() + np.array([x, y, 0]) * side_length/2\n )\n for x in [-0.5, 0.5] for y in [-0.5, 0.5]\n ])\n \n self.play(Transform(square, small_squares), run_time=1.5)\n \n # Fade out all elements\n self.play(\n FadeOut(square),\n FadeOut(formula_text),\n FadeOut(explanation),\n FadeOut(area_word),\n run_time=1\n )\n \n # Show ghosted circle\n ghost_circle = Circle(radius=2, color=PINK, fill_opacity=0.2, stroke_opacity=0.5)\n self.play(FadeIn(ghost_circle), run_time=0.5)\n self.play(FadeOut(ghost_circle), run_time=0.5)\n\n def act_3_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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 with additional features: \n- Act 2: Here is the enhanced animation description with additional features:\n- Act 3: 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"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0062(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_enhancedshapetransformat()\n self.clear_stage()\n self.act_2_shapetransformationwitha()\n self.clear_stage()\n self.act_3_lineartransformation()\n\n def act_1_enhancedshapetransformat(self):\n circle = Circle(color=YELLOW, fill_opacity=0.8).rotate(-45 * DEGREES)\n triangle = Triangle(color=GREEN, fill_opacity=0.8).rotate(-45 * DEGREES)\n \n # Position shapes\n circle.move_to(LEFT * 2)\n triangle.move_to(RIGHT * 2)\n \n # Group shapes\n shapes = VGroup(circle, triangle)\n \n # Add shapes to scene\n self.play(Create(circle), Create(triangle))\n self.wait(0.5)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.8).move_to(circle.get_center())\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.8).move_to(triangle.get_center())\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Add equation\n equation = MathTex(r\"\\text{Area} = \\pi r^2\").next_to(shapes, DOWN, buff=1)\n equation.scale(0.01) # Start small\n \n self.play(\n equation.animate.scale(1.2),\n FadeIn(equation),\n run_time=1\n )\n self.wait(0.5)\n \n # Rotate shapes and pulse equation\n self.play(\n Rotate(shapes, angle=2 * PI, about_point=ORIGIN),\n equation.animate.scale(1.1).set_color_by_gradient(BLUE, WHITE),\n run_time=2\n )\n self.play(equation.animate.scale(1 / 1.1))\n self.wait(0.5)\n \n # Add title and zoom out\n title = Text(\"Shapes and Their Areas\", font_size=24).to_edge(UP)\n grid = NumberPlane()\n \n self.play(\n FadeIn(title, shift=DOWN),\n Create(grid, run_time=2, lag_ratio=0.1),\n shapes.animate.scale(0.8),\n equation.animate.scale(0.8).shift(UP * 0.5),\n run_time=2\n )\n self.wait(2)\n\n def act_2_shapetransformationwitha(self):\n circle = Circle(radius=2, color=PINK)\n formula_text = MathTex(\"\\\\pi r^2 = \", \"s^2\").to_edge(UP)\n explanation = Text(\"A circle transforms into a square while preserving \", font_size=24).to_edge(DOWN)\n area_word = Text(\"area\", color=BLUE, font_size=24).next_to(explanation, RIGHT, buff=0.1)\n \n # Animation sequence\n self.play(Create(circle), run_time=1.5)\n self.play(circle.animate.scale(1.1), run_time=0.5)\n self.play(circle.animate.scale(1/1.1), run_time=0.5)\n \n # Show formula and explanation\n self.play(Write(formula_text[0]), run_time=1)\n self.play(Write(explanation), FadeIn(area_word, shift=UP*0.2), run_time=1)\n \n # Transform circle to square\n side_length = np.sqrt(np.pi * 2**2)\n square = Square(side_length=side_length, color=YELLOW)\n self.play(Transform(circle, square), Write(formula_text[1]), run_time=2)\n \n # Show coordinate system briefly\n axes = Axes()\n self.play(FadeIn(axes), run_time=0.5)\n self.play(FadeOut(axes), run_time=0.5)\n \n # Divide square into smaller squares\n small_squares = VGroup(*[\n Square(side_length=side_length/2, color=YELLOW).move_to(\n square.get_center() + np.array([x, y, 0]) * side_length/2\n )\n for x in [-0.5, 0.5] for y in [-0.5, 0.5]\n ])\n \n self.play(Transform(square, small_squares), run_time=1.5)\n \n # Fade out all elements\n self.play(\n FadeOut(square),\n FadeOut(formula_text),\n FadeOut(explanation),\n FadeOut(area_word),\n run_time=1\n )\n \n # Show ghosted circle\n ghost_circle = Circle(radius=2, color=PINK, fill_opacity=0.2, stroke_opacity=0.5)\n self.play(FadeIn(ghost_circle), run_time=0.5)\n self.play(FadeOut(ghost_circle), run_time=0.5)\n\n def act_3_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```"}]}
{"id": "adaption-unified-manim-instructions_003020", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "CNNDataFlow", "num_animations": 6, "num_rich_primitives": 2, "prompt": "\"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.\"", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralAnimation", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000703", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "LayerActivationsScene", "num_animations": 3, "num_rich_primitives": 1, "prompt": "I'm teaching undergrads in a DL visualization course and want a sequence that tracks layer activations from epoch 1 to 100. Visualize them with a violin plot that widens or narrows to reflect distribution changes, with smooth transitions between epochs. Include separate scenes for early, mid, and late training, with axes and a legend for density. I’d like a caption-style explanation and a quick intuition on what the widening means.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass LayerActivationsScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: EARLY]\n with self.voiceover(text=\"During training, the distribution of layer activations evolves significantly. In early epochs, activations are often narrow and concentrated, reflecting limited feature extraction.\") as tracker:\n title = Text(\"Layer Activation Distributions\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n axes = Axes(x_range=[-3, 3], y_range=[0, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n early_dist = axes.plot(lambda x: 0.8 * np.exp(-2 * x**2), color=BLUE)\n self.wait_until_bookmark(\"EARLY\")\n self.play(Write(title), Create(axes), Create(early_dist), run_time=tracker.duration)\n \n with self.voiceover(text=\"As training progresses, the distribution widens, indicating that the neurons are learning to represent a richer, more diverse set of features.\") as tracker:\n late_dist = axes.plot(lambda x: 0.4 * np.exp(-0.5 * x**2), color=GREEN)\n self.wait_until_bookmark(\"LATE\")\n self.play(Transform(early_dist, late_dist), run_time=tracker.duration)\n \n with self.voiceover(text=\"We can visualize this evolution using a violin plot. The width of the violin represents the density of activations, providing an intuitive view of the feature distribution.\") as tracker:\n violin_label = Text(\"Violin Plot: Activation Density\", font_size=24, color=GREEN)\n violin_label.to_edge(DOWN)\n self.wait_until_bookmark(\"VIOLIN\")\n self.play(Write(violin_label), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching undergrads in a DL visualization course and want a sequence that tracks layer activations from epoch 1 to 100. Visualize them with a violin plot that widens or narrows to reflect distribution changes, with smooth transitions between epochs. Include separate scenes for early, mid, and late training, with axes and a legend for density. I’d like a caption-style explanation and a quick intuition on what the widening means."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass LayerActivationsScene(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: EARLY]\n with self.voiceover(text=\"During training, the distribution of layer activations evolves significantly. In early epochs, activations are often narrow and concentrated, reflecting limited feature extraction.\") as tracker:\n title = Text(\"Layer Activation Distributions\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n axes = Axes(x_range=[-3, 3], y_range=[0, 1], x_length=8, y_length=4)\n axes.shift(DOWN * 0.5)\n early_dist = axes.plot(lambda x: 0.8 * np.exp(-2 * x**2), color=BLUE)\n self.wait_until_bookmark(\"EARLY\")\n self.play(Write(title), Create(axes), Create(early_dist), run_time=tracker.duration)\n \n with self.voiceover(text=\"As training progresses, the distribution widens, indicating that the neurons are learning to represent a richer, more diverse set of features.\") as tracker:\n late_dist = axes.plot(lambda x: 0.4 * np.exp(-0.5 * x**2), color=GREEN)\n self.wait_until_bookmark(\"LATE\")\n self.play(Transform(early_dist, late_dist), run_time=tracker.duration)\n \n with self.voiceover(text=\"We can visualize this evolution using a violin plot. The width of the violin represents the density of activations, providing an intuitive view of the feature distribution.\") as tracker:\n violin_label = Text(\"Violin Plot: Activation Density\", font_size=24, color=GREEN)\n violin_label.to_edge(DOWN)\n self.wait_until_bookmark(\"VIOLIN\")\n self.play(Write(violin_label), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000576", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "TrainingDashboard", "num_animations": 3, "num_rich_primitives": 1, "prompt": "I'm teaching undergrads and want a vivid visualization of a live training dashboard. Show four panels: Loss (top-left), LR (top-right), Accuracy (bottom-left), and Gradient Norms (bottom-right), updating in real time. Use smooth transitions, synchronized time axis, and color cues to highlight spikes or trends. Include concise captions explaining what each metric indicates and let the camera slowly pan to the current point when a loss spike occurs.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass TrainingDashboard(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: DASHBOARD]\n with self.voiceover(text=\"A live training dashboard provides four key panels: Loss, Learning Rate, Accuracy, and Gradient Norms. These metrics update in real time to monitor the training process.\") as tracker:\n title = Text(\"Live Training Dashboard\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n panels = VGroup(\n Rectangle(width=3, height=2, color=BLUE, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=GREEN, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=RED, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=YELLOW, fill_opacity=0.2)\n ).arrange_in_grid(rows=2, cols=2, buff=0.5)\n \n labels = VGroup(Text(\"Loss\"), Text(\"LR\"), Text(\"Acc\"), Text(\"Grad Norms\"))\n for p, l in zip(panels, labels):\n l.move_to(p)\n \n self.wait_until_bookmark(\"DASHBOARD\")\n self.play(Write(title), Create(panels), Write(labels), run_time=tracker.duration)\n \n with self.voiceover(text=\"When a loss spike occurs, the camera can slowly pan to the current point, allowing us to inspect the anomaly closely.\") as tracker:\n spike_dot = Dot(panels[0].get_center() + UP*0.5 + RIGHT*0.5, color=RED)\n \n self.wait_until_bookmark(\"SPIKE\")\n self.play(Create(spike_dot), run_time=tracker.duration)\n \n with self.voiceover(text=\"Color cues highlight trends, and concise captions explain what each metric indicates about the model's learning dynamics.\") as tracker:\n caption = Text(\"Spike indicates instability\", font_size=20, color=RED)\n caption.next_to(panels, DOWN)\n \n self.wait_until_bookmark(\"METRICS\")\n self.play(Write(caption), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching undergrads and want a vivid visualization of a live training dashboard. Show four panels: Loss (top-left), LR (top-right), Accuracy (bottom-left), and Gradient Norms (bottom-right), updating in real time. Use smooth transitions, synchronized time axis, and color cues to highlight spikes or trends. Include concise captions explaining what each metric indicates and let the camera slowly pan to the current point when a loss spike occurs."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass TrainingDashboard(VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # [BEAT 1 | sync: DASHBOARD]\n with self.voiceover(text=\"A live training dashboard provides four key panels: Loss, Learning Rate, Accuracy, and Gradient Norms. These metrics update in real time to monitor the training process.\") as tracker:\n title = Text(\"Live Training Dashboard\", font_size=36, color=BLUE)\n self.fit_in_frame(title)\n title.to_edge(UP)\n \n panels = VGroup(\n Rectangle(width=3, height=2, color=BLUE, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=GREEN, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=RED, fill_opacity=0.2),\n Rectangle(width=3, height=2, color=YELLOW, fill_opacity=0.2)\n ).arrange_in_grid(rows=2, cols=2, buff=0.5)\n \n labels = VGroup(Text(\"Loss\"), Text(\"LR\"), Text(\"Acc\"), Text(\"Grad Norms\"))\n for p, l in zip(panels, labels):\n l.move_to(p)\n \n self.wait_until_bookmark(\"DASHBOARD\")\n self.play(Write(title), Create(panels), Write(labels), run_time=tracker.duration)\n \n with self.voiceover(text=\"When a loss spike occurs, the camera can slowly pan to the current point, allowing us to inspect the anomaly closely.\") as tracker:\n spike_dot = Dot(panels[0].get_center() + UP*0.5 + RIGHT*0.5, color=RED)\n \n self.wait_until_bookmark(\"SPIKE\")\n self.play(Create(spike_dot), run_time=tracker.duration)\n \n with self.voiceover(text=\"Color cues highlight trends, and concise captions explain what each metric indicates about the model's learning dynamics.\") as tracker:\n caption = Text(\"Spike indicates instability\", font_size=20, color=RED)\n caption.next_to(panels, DOWN)\n \n self.wait_until_bookmark(\"METRICS\")\n self.play(Write(caption), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "manim-sft-10k_002364", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "EnhancedDodecagon", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSinCos", "num_animations": 12, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00143", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0143", "num_animations": 23, "prompt": "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: 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 2: Can you create an animation using simple geometric shapes that starts with a text message moving upwards, then a circle appearing on the screen, which transforms into a red square that moves downwards and to the right, t\n- Act 3: Manim is an animation engine for creating precise programmatic animations, primarily designed for explanatory math videos. It allows users to generate animations using Python code, enabling the creation of visually appea", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0143(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_intuitivecharacteristics()\n self.clear_stage()\n self.act_2_fastsequencescene()\n self.clear_stage()\n self.act_3_derivativevisualization()\n\n def act_1_intuitivecharacteristics(self):\n title = Title('Intuitive Characteristics of Problems in P', font_size=40)\n self.play(Write(title))\n self.wait(0.5)\n desc_1 = Text('Typically solved by directly constructing a solution', font_size=36)\n desc_2 = Text('through some deterministic steps.', font_size=36, color=YELLOW)\n desc_3 = Text('(such as loops, recursion)', font_size=32, color=LIGHT_GREY, slant=ITALIC)\n description = VGroup(desc_1, desc_2, desc_3).arrange(DOWN, buff=0.25)\n ex_title = Text('For example:', font_size=36, color=BLUE_C)\n ex_1 = Text('• Connected graph determination', font_size=32)\n ex_2 = Text('• Greatest common divisor calculation', font_size=32)\n ex_3 = Text('• Sorting', font_size=32)\n examples = VGroup(ex_title, ex_1, ex_2, ex_3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n content = VGroup(description, examples).arrange(DOWN, buff=1.0)\n content.next_to(title, DOWN, buff=0.6)\n self.play(FadeIn(desc_1, shift=DOWN * 0.2))\n self.wait(0.3)\n self.play(FadeIn(desc_2, shift=DOWN * 0.2))\n self.wait(0.3)\n self.play(FadeIn(desc_3, shift=DOWN * 0.2))\n self.wait(0.8)\n self.play(Write(ex_title))\n self.wait(0.3)\n for ex in [ex_1, ex_2, ex_3]:\n self.play(FadeIn(ex, shift=RIGHT * 0.2))\n self.wait(0.3)\n else:\n pass\n box = SurroundingRectangle(examples, color=BLUE_C, corner_radius=0.2, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_fastsequencescene(self):\n text = Text(\"Moving Upwards\")\n self.play(Write(text), text.animate.shift(UP * 2), run_time=0.6)\n\n # 2. Shape Appearance: A circle appears on the screen\n circle = Circle()\n original_pos = circle.get_center()\n self.play(Create(circle), run_time=0.4)\n\n # 3. Pause: Insert a brief pause immediately after the circle appears\n self.wait(0.2)\n\n # 4. Transformation: The circle transforms into a red square\n square = Square(color=RED)\n self.play(ReplacementTransform(circle, square), run_time=0.4)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN + RIGHT), run_time=0.4)\n\n # 6. Shift: The square shifts further to the right\n self.play(square.animate.shift(RIGHT), run_time=0.3)\n\n # 7. Rotation: The square rotates slightly\n self.play(Rotate(square, angle=PI / 6), run_time=0.3)\n\n # 8. Pause: Insert a brief pause immediately after the rotation\n self.wait(0.2)\n\n # 9. Reversion: The square reverts back to a circle\n final_circle = Circle()\n final_circle.move_to(square)\n self.play(ReplacementTransform(square, final_circle), run_time=0.4)\n\n # 10. Return: The circle returns to its original position\n self.play(final_circle.animate.move_to(original_pos), run_time=0.4)\n\n def act_3_derivativevisualization(self):\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n \n # 2. Define the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=r\"f(x) = x^2\")\n\n # 3. Define the moving point and dynamic tangent line\n dot = Dot(color=YELLOW)\n \n # always_redraw re-evaluates the tangent line each frame based on the dot's position\n tangent_line = always_redraw(lambda: \n axes.get_tangent_line(\n x=dot.get_center()[0] - axes.get_x0()[0],\n graph=graph, \n length=3, \n color=RED\n )\n )\n\n # 4. Mathematical expression\n formula = MathTex(r\"f'(x) = 2x\", color=RED).to_edge(UP)\n\n # 5. Animation sequence\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.play(Write(formula))\n self.add(dot, tangent_line)\n\n # Animate the point along the curve\n self.play(dot.animate.move_to(axes.c2p(1, 1)), run_time=2)\n self.play(dot.animate.move_to(axes.c2p(2, 4)), run_time=2)\n self.play(dot.animate.move_to(axes.c2p(0, 0)), run_time=2)\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 2: Can you create an animation using simple geometric shapes that starts with a text message moving upwards, then a circle appearing on the screen, which transforms into a red square that moves downwards and to the right, t\n- Act 3: Manim is an animation engine for creating precise programmatic animations, primarily designed for explanatory math videos. It allows users to generate animations using Python code, enabling the creation of visually appea"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0143(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_intuitivecharacteristics()\n self.clear_stage()\n self.act_2_fastsequencescene()\n self.clear_stage()\n self.act_3_derivativevisualization()\n\n def act_1_intuitivecharacteristics(self):\n title = Title('Intuitive Characteristics of Problems in P', font_size=40)\n self.play(Write(title))\n self.wait(0.5)\n desc_1 = Text('Typically solved by directly constructing a solution', font_size=36)\n desc_2 = Text('through some deterministic steps.', font_size=36, color=YELLOW)\n desc_3 = Text('(such as loops, recursion)', font_size=32, color=LIGHT_GREY, slant=ITALIC)\n description = VGroup(desc_1, desc_2, desc_3).arrange(DOWN, buff=0.25)\n ex_title = Text('For example:', font_size=36, color=BLUE_C)\n ex_1 = Text('• Connected graph determination', font_size=32)\n ex_2 = Text('• Greatest common divisor calculation', font_size=32)\n ex_3 = Text('• Sorting', font_size=32)\n examples = VGroup(ex_title, ex_1, ex_2, ex_3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n content = VGroup(description, examples).arrange(DOWN, buff=1.0)\n content.next_to(title, DOWN, buff=0.6)\n self.play(FadeIn(desc_1, shift=DOWN * 0.2))\n self.wait(0.3)\n self.play(FadeIn(desc_2, shift=DOWN * 0.2))\n self.wait(0.3)\n self.play(FadeIn(desc_3, shift=DOWN * 0.2))\n self.wait(0.8)\n self.play(Write(ex_title))\n self.wait(0.3)\n for ex in [ex_1, ex_2, ex_3]:\n self.play(FadeIn(ex, shift=RIGHT * 0.2))\n self.wait(0.3)\n else:\n pass\n box = SurroundingRectangle(examples, color=BLUE_C, corner_radius=0.2, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_fastsequencescene(self):\n text = Text(\"Moving Upwards\")\n self.play(Write(text), text.animate.shift(UP * 2), run_time=0.6)\n\n # 2. Shape Appearance: A circle appears on the screen\n circle = Circle()\n original_pos = circle.get_center()\n self.play(Create(circle), run_time=0.4)\n\n # 3. Pause: Insert a brief pause immediately after the circle appears\n self.wait(0.2)\n\n # 4. Transformation: The circle transforms into a red square\n square = Square(color=RED)\n self.play(ReplacementTransform(circle, square), run_time=0.4)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN + RIGHT), run_time=0.4)\n\n # 6. Shift: The square shifts further to the right\n self.play(square.animate.shift(RIGHT), run_time=0.3)\n\n # 7. Rotation: The square rotates slightly\n self.play(Rotate(square, angle=PI / 6), run_time=0.3)\n\n # 8. Pause: Insert a brief pause immediately after the rotation\n self.wait(0.2)\n\n # 9. Reversion: The square reverts back to a circle\n final_circle = Circle()\n final_circle.move_to(square)\n self.play(ReplacementTransform(square, final_circle), run_time=0.4)\n\n # 10. Return: The circle returns to its original position\n self.play(final_circle.animate.move_to(original_pos), run_time=0.4)\n\n def act_3_derivativevisualization(self):\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n \n # 2. Define the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=r\"f(x) = x^2\")\n\n # 3. Define the moving point and dynamic tangent line\n dot = Dot(color=YELLOW)\n \n # always_redraw re-evaluates the tangent line each frame based on the dot's position\n tangent_line = always_redraw(lambda: \n axes.get_tangent_line(\n x=dot.get_center()[0] - axes.get_x0()[0],\n graph=graph, \n length=3, \n color=RED\n )\n )\n\n # 4. Mathematical expression\n formula = MathTex(r\"f'(x) = 2x\", color=RED).to_edge(UP)\n\n # 5. Animation sequence\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.play(Write(formula))\n self.add(dot, tangent_line)\n\n # Animate the point along the curve\n self.play(dot.animate.move_to(axes.c2p(1, 1)), run_time=2)\n self.play(dot.animate.move_to(axes.c2p(2, 4)), run_time=2)\n self.play(dot.animate.move_to(axes.c2p(0, 0)), run_time=2)\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_006838", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 12, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "AOS-Manim-SFT_000119", "source": "nabin2004/AOS-Manim-SFT", "tier": 1, "scene_name": "CausalMaskScene", "num_animations": 10, "num_rich_primitives": 5, "prompt": "I'm teaching an NLP course and want to illustrate a causal mask matrix used in Transformers. Visualize a square attention mask where the upper triangle is filled with -inf and the lower triangle with 0. Animate the mask being applied to an attention score matrix, show how logits are masked, and highlight the effect on subsequent token predictions. Include a transition that sweeps from no mask to full causal mask, with labeled diagonals and a color legend.", "code": "from manim import *\n\nclass CausalMaskScene(Scene):\n\n def construct(self):\n title = Text('Causal Mask Matrix in Transformers', font_size=38)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title), run_time=2.0)\n words = ['The', 'cat', 'sat', 'down']\n tokens = VGroup(*[Text(f'\"{w}\"', font_size=26) for w in words])\n tokens.arrange(RIGHT, buff=0.6)\n tokens.next_to(title, DOWN, buff=0.4)\n self.play(FadeIn(tokens), run_time=2.0)\n score_entries = [['2.0', '1.0', '0.5', '1.2'], ['0.8', '3.0', '1.5', '0.2'], ['1.1', '0.3', '2.5', '1.8'], ['0.2', '1.0', '0.4', '3.2']]\n score_matrix = Matrix(score_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_scores = MathTex('\\\\text{Scores} = QK^T', font_size=30)\n group_scores = VGroup(label_scores, score_matrix).arrange(DOWN, buff=0.25)\n group_scores.next_to(tokens, DOWN, buff=0.3)\n self.play(Create(score_matrix), Write(label_scores), run_time=2.0)\n mask_entries = [['1', '0', '0', '0'], ['1', '1', '0', '0'], ['1', '1', '1', '0'], ['1', '1', '1', '1']]\n mask_matrix = Matrix(mask_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_mask = MathTex('\\\\text{Causal Mask}', font_size=30)\n group_mask = VGroup(label_mask, mask_matrix).arrange(DOWN, buff=0.25)\n group_mask.next_to(group_scores, RIGHT, buff=0.9)\n self.play(Create(mask_matrix), Write(label_mask), run_time=2.0)\n arrow = Arrow(group_scores.get_right(), group_mask.get_left(), buff=0.1, stroke_width=2, tip_length=0.2)\n op_text = MathTex('\\\\times', font_size=34)\n op_text.move_to(arrow.get_center())\n self.play(GrowArrow(arrow), Write(op_text), run_time=2.0)\n masked_entries = [['2.0', '-\\\\infty', '-\\\\infty', '-\\\\infty'], ['0.8', '3.0', '-\\\\infty', '-\\\\infty'], ['1.1', '0.3', '2.5', '-\\\\infty'], ['0.2', '1.0', '0.4', '3.2']]\n masked_matrix = Matrix(masked_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_masked = MathTex('\\\\text{Masked Scores}', font_size=30)\n group_masked = VGroup(label_masked, masked_matrix).arrange(DOWN, buff=0.25)\n group_masked.move_to(group_scores.get_center())\n self.play(ReplacementTransform(score_matrix, masked_matrix), Transform(label_scores, label_masked), FadeOut(group_mask, arrow, op_text), run_time=2.0)\n softmax_formula = MathTex('\\\\text{Softmax}(x_i) = \\\\frac{e^{x_i}}{\\\\sum_j e^{x_j}}', font_size=32)\n softmax_formula.next_to(group_masked, RIGHT, buff=0.7)\n self.play(Write(softmax_formula), run_time=2.0)\n weight_entries = [['1.00', '0', '0', '0'], ['0.10', '0.90', '0', '0'], ['0.20', '0.05', '0.75', '0'], ['0.06', '0.08', '0.05', '0.81']]\n weight_matrix = Matrix(weight_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_weight = MathTex('\\\\text{Attention Weights}', font_size=30)\n group_weight = VGroup(label_weight, weight_matrix).arrange(DOWN, buff=0.25)\n group_weight.move_to(group_masked.get_center())\n self.play(ReplacementTransform(masked_matrix, weight_matrix), Transform(label_masked, label_weight), FadeOut(softmax_formula), run_time=2.0)\n summary_title = Text('Key Takeaways', font_size=28, color=YELLOW)\n summary_title.next_to(group_weight, DOWN, buff=0.4)\n pt1 = MathTex('\\\\bullet\\\\ \\\\text{Causal mask: lower-triangular matrix}', font_size=24)\n pt2 = MathTex('\\\\bullet\\\\ \\\\text{Blocks future-token leakage}', font_size=24)\n pt3 = MathTex('\\\\bullet\\\\ \\\\text{Vital for autoregressive models like GPT}', font_size=24)\n summary_pts = VGroup(pt1, pt2, pt3).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n summary_pts.next_to(summary_title, DOWN, buff=0.25)\n self.play(Write(summary_title), run_time=0.5)\n self.play(LaggedStart(*[Write(p) for p in [pt1, pt2, pt3]], lag_ratio=0.3), run_time=2.0 - 0.5)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching an NLP course and want to illustrate a causal mask matrix used in Transformers. Visualize a square attention mask where the upper triangle is filled with -inf and the lower triangle with 0. Animate the mask being applied to an attention score matrix, show how logits are masked, and highlight the effect on subsequent token predictions. Include a transition that sweeps from no mask to full causal mask, with labeled diagonals and a color legend."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass CausalMaskScene(Scene):\n\n def construct(self):\n title = Text('Causal Mask Matrix in Transformers', font_size=38)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title), run_time=2.0)\n words = ['The', 'cat', 'sat', 'down']\n tokens = VGroup(*[Text(f'\"{w}\"', font_size=26) for w in words])\n tokens.arrange(RIGHT, buff=0.6)\n tokens.next_to(title, DOWN, buff=0.4)\n self.play(FadeIn(tokens), run_time=2.0)\n score_entries = [['2.0', '1.0', '0.5', '1.2'], ['0.8', '3.0', '1.5', '0.2'], ['1.1', '0.3', '2.5', '1.8'], ['0.2', '1.0', '0.4', '3.2']]\n score_matrix = Matrix(score_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_scores = MathTex('\\\\text{Scores} = QK^T', font_size=30)\n group_scores = VGroup(label_scores, score_matrix).arrange(DOWN, buff=0.25)\n group_scores.next_to(tokens, DOWN, buff=0.3)\n self.play(Create(score_matrix), Write(label_scores), run_time=2.0)\n mask_entries = [['1', '0', '0', '0'], ['1', '1', '0', '0'], ['1', '1', '1', '0'], ['1', '1', '1', '1']]\n mask_matrix = Matrix(mask_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_mask = MathTex('\\\\text{Causal Mask}', font_size=30)\n group_mask = VGroup(label_mask, mask_matrix).arrange(DOWN, buff=0.25)\n group_mask.next_to(group_scores, RIGHT, buff=0.9)\n self.play(Create(mask_matrix), Write(label_mask), run_time=2.0)\n arrow = Arrow(group_scores.get_right(), group_mask.get_left(), buff=0.1, stroke_width=2, tip_length=0.2)\n op_text = MathTex('\\\\times', font_size=34)\n op_text.move_to(arrow.get_center())\n self.play(GrowArrow(arrow), Write(op_text), run_time=2.0)\n masked_entries = [['2.0', '-\\\\infty', '-\\\\infty', '-\\\\infty'], ['0.8', '3.0', '-\\\\infty', '-\\\\infty'], ['1.1', '0.3', '2.5', '-\\\\infty'], ['0.2', '1.0', '0.4', '3.2']]\n masked_matrix = Matrix(masked_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_masked = MathTex('\\\\text{Masked Scores}', font_size=30)\n group_masked = VGroup(label_masked, masked_matrix).arrange(DOWN, buff=0.25)\n group_masked.move_to(group_scores.get_center())\n self.play(ReplacementTransform(score_matrix, masked_matrix), Transform(label_scores, label_masked), FadeOut(group_mask, arrow, op_text), run_time=2.0)\n softmax_formula = MathTex('\\\\text{Softmax}(x_i) = \\\\frac{e^{x_i}}{\\\\sum_j e^{x_j}}', font_size=32)\n softmax_formula.next_to(group_masked, RIGHT, buff=0.7)\n self.play(Write(softmax_formula), run_time=2.0)\n weight_entries = [['1.00', '0', '0', '0'], ['0.10', '0.90', '0', '0'], ['0.20', '0.05', '0.75', '0'], ['0.06', '0.08', '0.05', '0.81']]\n weight_matrix = Matrix(weight_entries, element_to_mobject_config={'font_size': 26}, h_buff=1.0, v_buff=0.6).scale(0.75)\n label_weight = MathTex('\\\\text{Attention Weights}', font_size=30)\n group_weight = VGroup(label_weight, weight_matrix).arrange(DOWN, buff=0.25)\n group_weight.move_to(group_masked.get_center())\n self.play(ReplacementTransform(masked_matrix, weight_matrix), Transform(label_masked, label_weight), FadeOut(softmax_formula), run_time=2.0)\n summary_title = Text('Key Takeaways', font_size=28, color=YELLOW)\n summary_title.next_to(group_weight, DOWN, buff=0.4)\n pt1 = MathTex('\\\\bullet\\\\ \\\\text{Causal mask: lower-triangular matrix}', font_size=24)\n pt2 = MathTex('\\\\bullet\\\\ \\\\text{Blocks future-token leakage}', font_size=24)\n pt3 = MathTex('\\\\bullet\\\\ \\\\text{Vital for autoregressive models like GPT}', font_size=24)\n summary_pts = VGroup(pt1, pt2, pt3).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n summary_pts.next_to(summary_title, DOWN, buff=0.25)\n self.play(Write(summary_title), run_time=0.5)\n self.play(LaggedStart(*[Write(p) for p in [pt1, pt2, pt3]], lag_ratio=0.3), run_time=2.0 - 0.5)\n self.wait(1)\n```"}]}
{"id": "manim-sft-10k_001706", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "SchwartzFourierTransform", "num_animations": 18, "num_rich_primitives": 2, "prompt": "How do we represent the transformation of a Schwartz function under the Fourier transform?", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DivisorsOfTen", "num_animations": 5, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "KleeneStar", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_005563", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DoubleIntegralPolar", "num_animations": 16, "num_rich_primitives": 2, "prompt": "Could you please create an animated video that explains step by step how to solve the double integral problem in polar coordinates, specifically the integral from 0 to pi of the integral from 0 to 1 of r squared times sine theta with respect to r and theta? I would like each step of the problem solving process to be written out and displayed, along with verbal descriptions of what to integrate first. Additionally, show the antiderivative as it is being calculated for each integral, with a final display of the computed numerical value of the entire integral.", "code": "from manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # Color configuration\n explanation_color = BLUE_B\n math_color = WHITE\n highlight_color = YELLOW\n\n # --- Step 1: Title and Problem Statement ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36).to_edge(UP)\n \n problem = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=48,\n color=math_color\n ).shift(UP * 1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Inner Integration (with respect to r) ---\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$\",\n font_size=32,\n color=explanation_color\n ).next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(step1_text))\n self.wait(1)\n\n # Display the antiderivative for the inner integral\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{r=0}^{r=1} d\\theta\",\n font_size=48,\n color=math_color\n ).move_to(problem)\n\n self.play(ReplacementTransform(problem, inner_antiderivative))\n self.wait(2)\n\n # Evaluate the inner limits\n inner_evaluated = MathTex(\n r\"\\int_{0}^{\\pi} \\left( \\frac{1^3}{3}\\sin(\\theta) - \\frac{0^3}{3}\\sin(\\theta) \\right) d\\theta\",\n font_size=42,\n color=math_color\n ).move_to(inner_antiderivative)\n\n self.play(ReplacementTransform(inner_antiderivative, inner_evaluated))\n self.wait(2)\n\n # Simplify the inner evaluation\n inner_simplified = MathTex(\n r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=48,\n color=math_color\n ).move_to(inner_evaluated)\n\n self.play(ReplacementTransform(inner_evaluated, inner_simplified))\n self.wait(2)\n\n # --- Step 3: Outer Integration (with respect to \\theta ) ---\n self.play(FadeOut(step1_text))\n\n step2_text = Tex(\n \"Step 2: Integrate with respect to $\\\\theta$\",\n font_size=32,\n color=explanation_color\n ).next_to(inner_simplified, DOWN, buff=0.8)\n\n self.play(Write(step2_text))\n self.wait(1)\n\n # Display the antiderivative for the outer integral\n outer_antiderivative = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi}\",\n font_size=48,\n color=math_color\n ).move_to(inner_simplified)\n\n self.play(ReplacementTransform(inner_simplified, outer_antiderivative))\n self.wait(2)\n\n # --- Step 4: Final Evaluation ---\n self.play(FadeOut(step2_text))\n\n eval_text = Tex(\n \"Evaluate the definite integral:\",\n font_size=32,\n color=explanation_color\n ).next_to(outer_antiderivative, DOWN, buff=0.8)\n\n self.play(Write(eval_text))\n self.wait(1)\n\n # Substitute the limits\n calc_step1 = MathTex(\n r\"-\\frac{1}{3} \\cos(\\pi) - \\left( -\\frac{1}{3} \\cos(0) \\right)\",\n font_size=42,\n color=math_color\n ).move_to(outer_antiderivative)\n\n self.play(ReplacementTransform(outer_antiderivative, calc_step1))\n self.wait(2)\n\n # Calculate cosine values\n calc_step2 = MathTex(\n r\"-\\frac{1}{3} (-1) + \\frac{1}{3} (1)\",\n font_size=42,\n color=math_color\n ).move_to(calc_step1)\n\n self.play(ReplacementTransform(calc_step1, calc_step2))\n self.wait(2)\n\n # Final Result\n final_result = MathTex(\n r\"\\frac{2}{3}\",\n font_size=48,\n color=highlight_color\n ).move_to(calc_step2)\n\n self.play(ReplacementTransform(calc_step2, final_result))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(final_result, color=highlight_color, buff=0.3)\n final_label = Text(\"Final Result\", font_size=24, color=highlight_color).next_to(box, UP)\n\n self.play(Create(box), Write(final_label))\n self.wait(2)\n\n # Center and scale the final answer for emphasis\n self.play(\n FadeOut(title),\n FadeOut(eval_text),\n FadeOut(box),\n FadeOut(final_label),\n final_result.animate.scale(1.5).move_to(ORIGIN)\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you please create an animated video that explains step by step how to solve the double integral problem in polar coordinates, specifically the integral from 0 to pi of the integral from 0 to 1 of r squared times sine theta with respect to r and theta? I would like each step of the problem solving process to be written out and displayed, along with verbal descriptions of what to integrate first. Additionally, show the antiderivative as it is being calculated for each integral, with a final display of the computed numerical value of the entire integral."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # Color configuration\n explanation_color = BLUE_B\n math_color = WHITE\n highlight_color = YELLOW\n\n # --- Step 1: Title and Problem Statement ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36).to_edge(UP)\n \n problem = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=48,\n color=math_color\n ).shift(UP * 1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Inner Integration (with respect to r) ---\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$\",\n font_size=32,\n color=explanation_color\n ).next_to(problem, DOWN, buff=0.8)\n\n self.play(Write(step1_text))\n self.wait(1)\n\n # Display the antiderivative for the inner integral\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{r=0}^{r=1} d\\theta\",\n font_size=48,\n color=math_color\n ).move_to(problem)\n\n self.play(ReplacementTransform(problem, inner_antiderivative))\n self.wait(2)\n\n # Evaluate the inner limits\n inner_evaluated = MathTex(\n r\"\\int_{0}^{\\pi} \\left( \\frac{1^3}{3}\\sin(\\theta) - \\frac{0^3}{3}\\sin(\\theta) \\right) d\\theta\",\n font_size=42,\n color=math_color\n ).move_to(inner_antiderivative)\n\n self.play(ReplacementTransform(inner_antiderivative, inner_evaluated))\n self.wait(2)\n\n # Simplify the inner evaluation\n inner_simplified = MathTex(\n r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=48,\n color=math_color\n ).move_to(inner_evaluated)\n\n self.play(ReplacementTransform(inner_evaluated, inner_simplified))\n self.wait(2)\n\n # --- Step 3: Outer Integration (with respect to \\theta ) ---\n self.play(FadeOut(step1_text))\n\n step2_text = Tex(\n \"Step 2: Integrate with respect to $\\\\theta$\",\n font_size=32,\n color=explanation_color\n ).next_to(inner_simplified, DOWN, buff=0.8)\n\n self.play(Write(step2_text))\n self.wait(1)\n\n # Display the antiderivative for the outer integral\n outer_antiderivative = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi}\",\n font_size=48,\n color=math_color\n ).move_to(inner_simplified)\n\n self.play(ReplacementTransform(inner_simplified, outer_antiderivative))\n self.wait(2)\n\n # --- Step 4: Final Evaluation ---\n self.play(FadeOut(step2_text))\n\n eval_text = Tex(\n \"Evaluate the definite integral:\",\n font_size=32,\n color=explanation_color\n ).next_to(outer_antiderivative, DOWN, buff=0.8)\n\n self.play(Write(eval_text))\n self.wait(1)\n\n # Substitute the limits\n calc_step1 = MathTex(\n r\"-\\frac{1}{3} \\cos(\\pi) - \\left( -\\frac{1}{3} \\cos(0) \\right)\",\n font_size=42,\n color=math_color\n ).move_to(outer_antiderivative)\n\n self.play(ReplacementTransform(outer_antiderivative, calc_step1))\n self.wait(2)\n\n # Calculate cosine values\n calc_step2 = MathTex(\n r\"-\\frac{1}{3} (-1) + \\frac{1}{3} (1)\",\n font_size=42,\n color=math_color\n ).move_to(calc_step1)\n\n self.play(ReplacementTransform(calc_step1, calc_step2))\n self.wait(2)\n\n # Final Result\n final_result = MathTex(\n r\"\\frac{2}{3}\",\n font_size=48,\n color=highlight_color\n ).move_to(calc_step2)\n\n self.play(ReplacementTransform(calc_step2, final_result))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(final_result, color=highlight_color, buff=0.3)\n final_label = Text(\"Final Result\", font_size=24, color=highlight_color).next_to(box, UP)\n\n self.play(Create(box), Write(final_label))\n self.wait(2)\n\n # Center and scale the final answer for emphasis\n self.play(\n FadeOut(title),\n FadeOut(eval_text),\n FadeOut(box),\n FadeOut(final_label),\n final_result.animate.scale(1.5).move_to(ORIGIN)\n )\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_008130", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TransformationSequence", "num_animations": 6, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_003839", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "MonthlyProfitGraph", "num_animations": 7, "num_rich_primitives": 2, "prompt": "I would like to create an animated video graph that displays monthly profits in Brazilian reais for the first half of the year. The graph should have a vertical axis ranging from 0 to 9000 with 1000 unit increments, and a horizontal axis representing the months from January to June. Each month should have a labeled point indicating the profit for that month, and these points should be connected with lines. For a visual emphasis, I wish to sequentially highlight the points and lines between January to February, February to April, and April to June with a different color, making the dots and lines temporarily larger during the highlight. The animated sequence should start with the title \"Lucro mensal em reais\" fading in along with the axes, followed by the points appearing one after another, with auxiliary lines across the graph at each 1000 unit interval on the vertical axis. After the monthly profits for June are shown, and after the last highlight sequence, I would like all the graph contents to fade out gracefully. For design, I prefer a light background and dark axes, with clear but not overly bright colors for the data points and highlights.", "code": "from manim import *\n\nclass MonthlyProfitGraph(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n self.camera.background_color = \"#F5F5F5\" # Light background\n \n COLOR_AXIS = \"#333333\" # Dark axes\n COLOR_DATA = \"#2E86AB\" # Clear, distinct blue for data\n COLOR_HIGHLIGHT = \"#C1666B\" # Muted red for highlights\n COLOR_TEXT = \"#333333\" # Dark text\n COLOR_GRID = \"#ADB5BD\" # Soft gray for auxiliary lines\n \n # --- Data Setup ---\n months = [\"Jan\", \"Fev\", \"Mar\", \"Abr\", \"Mai\", \"Jun\"]\n profits = [2000, 4500, 3000, 6000, 5500, 8000]\n x_values = list(range(1, 7)) # 1 to 6\n \n # --- Axes Creation ---\n axes = Axes(\n x_range=[0, 7, 1],\n y_range=[0, 9000, 1000],\n x_length=10,\n y_length=6,\n axis_config={\n \"color\": COLOR_AXIS,\n \"include_numbers\": False,\n \"include_tip\": True,\n },\n y_axis_config={\n \"include_numbers\": True,\n \"number_config\": {\"color\": COLOR_TEXT, \"font_size\": 24},\n },\n )\n \n # --- Title & X-axis Labels ---\n title = Text(\"Lucro mensal em reais\", font_size=36, color=COLOR_TEXT)\n title.to_edge(UP)\n \n x_labels = VGroup()\n for i, month in enumerate(months):\n label = Text(month, font_size=24, color=COLOR_TEXT)\n label.next_to(axes.c2p(i + 1, 0), DOWN, buff=0.2)\n x_labels.add(label)\n \n # --- Auxiliary Lines (Grid) ---\n grid_lines = VGroup()\n for y_val in range(1000, 9001, 1000):\n line = Line(\n start=axes.c2p(0, y_val),\n end=axes.c2p(7, y_val),\n color=COLOR_GRID,\n stroke_width=1,\n stroke_opacity=0.5\n )\n grid_lines.add(line)\n \n # --- Data Points & Connecting Lines ---\n dots = VGroup()\n dot_labels = VGroup()\n coordinates = []\n \n for i, profit in enumerate(profits):\n coord = axes.c2p(x_values[i], profit)\n coordinates.append(coord)\n \n dot = Dot(coord, color=COLOR_DATA, radius=0.08)\n dots.add(dot)\n \n # Value label near dot\n d_label = Text(f\"R$ {profit}\", font_size=20, color=COLOR_TEXT)\n d_label.next_to(dot, UP, buff=0.1)\n dot_labels.add(d_label)\n \n # Connecting lines between points\n graph_lines = VGroup()\n for i in range(len(coordinates) - 1):\n line = Line(coordinates[i], coordinates[i+1], color=COLOR_DATA, stroke_width=3)\n graph_lines.add(line)\n \n # --- Animation Sequence ---\n \n # 1. Intro: Fade in title and axes simultaneously\n self.play(FadeIn(title), Create(axes), run_time=1.5)\n \n # 2. Auxiliary Lines & X-axis labels\n self.play(Create(grid_lines), FadeIn(x_labels), run_time=1)\n \n # 3. Data Appearance: Points and connecting lines sequentially\n for i in range(len(dots)):\n if i > 0:\n self.play(Create(graph_lines[i-1]), run_time=0.3)\n self.play(FadeIn(dots[i]), FadeIn(dot_labels[i]), run_time=0.4)\n \n self.wait(0.5)\n \n # 4. Highlight Phase\n # Segments: (Start Index, End Index)\n highlight_segments = [(0, 1), (1, 3), (3, 5)]\n \n for start, end in highlight_segments:\n seg_dots = dots[start : end + 1]\n seg_lines = graph_lines[start : end]\n \n # Animation: Scale up and change color\n self.play(\n seg_dots.animate.set_color(COLOR_HIGHLIGHT).scale(1.5),\n seg_lines.animate.set_color(COLOR_HIGHLIGHT).set_stroke(width=6),\n run_time=0.6\n )\n self.wait(0.4)\n # Animation: Return to normal\n self.play(\n seg_dots.animate.set_color(COLOR_DATA).scale(1/1.5),\n seg_lines.animate.set_color(COLOR_DATA).set_stroke(width=3),\n run_time=0.6\n )\n \n self.wait(1)\n \n # 5. Outro: Gracefully fade out all graph contents\n all_contents = VGroup(\n title, axes, grid_lines, x_labels, \n dots, dot_labels, graph_lines\n )\n \n self.play(FadeOut(all_contents), run_time=1.5)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an animated video graph that displays monthly profits in Brazilian reais for the first half of the year. The graph should have a vertical axis ranging from 0 to 9000 with 1000 unit increments, and a horizontal axis representing the months from January to June. Each month should have a labeled point indicating the profit for that month, and these points should be connected with lines. For a visual emphasis, I wish to sequentially highlight the points and lines between January to February, February to April, and April to June with a different color, making the dots and lines temporarily larger during the highlight. The animated sequence should start with the title \"Lucro mensal em reais\" fading in along with the axes, followed by the points appearing one after another, with auxiliary lines across the graph at each 1000 unit interval on the vertical axis. After the monthly profits for June are shown, and after the last highlight sequence, I would like all the graph contents to fade out gracefully. For design, I prefer a light background and dark axes, with clear but not overly bright colors for the data points and highlights."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass MonthlyProfitGraph(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n self.camera.background_color = \"#F5F5F5\" # Light background\n \n COLOR_AXIS = \"#333333\" # Dark axes\n COLOR_DATA = \"#2E86AB\" # Clear, distinct blue for data\n COLOR_HIGHLIGHT = \"#C1666B\" # Muted red for highlights\n COLOR_TEXT = \"#333333\" # Dark text\n COLOR_GRID = \"#ADB5BD\" # Soft gray for auxiliary lines\n \n # --- Data Setup ---\n months = [\"Jan\", \"Fev\", \"Mar\", \"Abr\", \"Mai\", \"Jun\"]\n profits = [2000, 4500, 3000, 6000, 5500, 8000]\n x_values = list(range(1, 7)) # 1 to 6\n \n # --- Axes Creation ---\n axes = Axes(\n x_range=[0, 7, 1],\n y_range=[0, 9000, 1000],\n x_length=10,\n y_length=6,\n axis_config={\n \"color\": COLOR_AXIS,\n \"include_numbers\": False,\n \"include_tip\": True,\n },\n y_axis_config={\n \"include_numbers\": True,\n \"number_config\": {\"color\": COLOR_TEXT, \"font_size\": 24},\n },\n )\n \n # --- Title & X-axis Labels ---\n title = Text(\"Lucro mensal em reais\", font_size=36, color=COLOR_TEXT)\n title.to_edge(UP)\n \n x_labels = VGroup()\n for i, month in enumerate(months):\n label = Text(month, font_size=24, color=COLOR_TEXT)\n label.next_to(axes.c2p(i + 1, 0), DOWN, buff=0.2)\n x_labels.add(label)\n \n # --- Auxiliary Lines (Grid) ---\n grid_lines = VGroup()\n for y_val in range(1000, 9001, 1000):\n line = Line(\n start=axes.c2p(0, y_val),\n end=axes.c2p(7, y_val),\n color=COLOR_GRID,\n stroke_width=1,\n stroke_opacity=0.5\n )\n grid_lines.add(line)\n \n # --- Data Points & Connecting Lines ---\n dots = VGroup()\n dot_labels = VGroup()\n coordinates = []\n \n for i, profit in enumerate(profits):\n coord = axes.c2p(x_values[i], profit)\n coordinates.append(coord)\n \n dot = Dot(coord, color=COLOR_DATA, radius=0.08)\n dots.add(dot)\n \n # Value label near dot\n d_label = Text(f\"R$ {profit}\", font_size=20, color=COLOR_TEXT)\n d_label.next_to(dot, UP, buff=0.1)\n dot_labels.add(d_label)\n \n # Connecting lines between points\n graph_lines = VGroup()\n for i in range(len(coordinates) - 1):\n line = Line(coordinates[i], coordinates[i+1], color=COLOR_DATA, stroke_width=3)\n graph_lines.add(line)\n \n # --- Animation Sequence ---\n \n # 1. Intro: Fade in title and axes simultaneously\n self.play(FadeIn(title), Create(axes), run_time=1.5)\n \n # 2. Auxiliary Lines & X-axis labels\n self.play(Create(grid_lines), FadeIn(x_labels), run_time=1)\n \n # 3. Data Appearance: Points and connecting lines sequentially\n for i in range(len(dots)):\n if i > 0:\n self.play(Create(graph_lines[i-1]), run_time=0.3)\n self.play(FadeIn(dots[i]), FadeIn(dot_labels[i]), run_time=0.4)\n \n self.wait(0.5)\n \n # 4. Highlight Phase\n # Segments: (Start Index, End Index)\n highlight_segments = [(0, 1), (1, 3), (3, 5)]\n \n for start, end in highlight_segments:\n seg_dots = dots[start : end + 1]\n seg_lines = graph_lines[start : end]\n \n # Animation: Scale up and change color\n self.play(\n seg_dots.animate.set_color(COLOR_HIGHLIGHT).scale(1.5),\n seg_lines.animate.set_color(COLOR_HIGHLIGHT).set_stroke(width=6),\n run_time=0.6\n )\n self.wait(0.4)\n # Animation: Return to normal\n self.play(\n seg_dots.animate.set_color(COLOR_DATA).scale(1/1.5),\n seg_lines.animate.set_color(COLOR_DATA).set_stroke(width=3),\n run_time=0.6\n )\n \n self.wait(1)\n \n # 5. Outro: Gracefully fade out all graph contents\n all_contents = VGroup(\n title, axes, grid_lines, x_labels, \n dots, dot_labels, graph_lines\n )\n \n self.play(FadeOut(all_contents), run_time=1.5)\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_000515", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralUSubstitution", "num_animations": 10, "num_rich_primitives": 3, "prompt": "How would you create a step-by-step animated explanation of solving the integral of e^(2x) using u-substitution, with text instructions and the final solution, utilizing a mathematical animation tool?", "code": "from manim import *\n\nclass IntegralUSubstitution(Scene):\n def construct(self):\n # Color configuration for pedagogical emphasis\n COLOR_U = BLUE\n COLOR_DX = YELLOW\n COLOR_DU = GREEN\n COLOR_TEXT = GREY_A\n\n # --- Step 1: Display the Original Integral ---\n intro_text = Tex(\"Evaluate the integral:\", color=COLOR_TEXT).to_edge(UP)\n original_integral = MathTex(\n r\"\\int\", \"e^{2x}\", \"dx\"\n ).scale(1.5).next_to(intro_text, DOWN, buff=0.5)\n \n # Highlight specific parts for substitution context\n original_integral[1].set_color(COLOR_U) # 2x\n original_integral[2].set_color(COLOR_DX) # dx\n\n self.play(Write(intro_text))\n self.play(Write(original_integral))\n self.wait(1)\n\n # --- Step 2: Define u ---\n step1_text = Tex(\"Step 1: Choose substitution variable\", color=COLOR_TEXT).to_edge(UP)\n u_def = MathTex(\"u\", \"=\", \"2x\").scale(1.2).next_to(intro_text, DOWN, buff=0.5)\n u_def[0].set_color(COLOR_U) # u\n u_def[2].set_color(COLOR_U) # 2x\n \n self.play(\n FadeOut(intro_text),\n Write(step1_text),\n FadeTransform(original_integral, u_def)\n )\n self.wait(1)\n\n # --- Step 3: Calculate du ---\n step2_text = Tex(\"Step 2: Differentiate to find du\", color=COLOR_TEXT).to_edge(UP)\n du_def = MathTex(\"du\", \"=\", \"2\", \"dx\").scale(1.2).next_to(step1_text, DOWN, buff=0.5)\n du_def[0].set_color(COLOR_DU) # du\n du_def[3].set_color(COLOR_DX) # dx\n \n # Solve for dx\n dx_sol = MathTex(\"dx\", \"=\", r\"\\frac{1}{2}\", \"du\").scale(1.2).next_to(step2_text, DOWN, buff=0.5)\n dx_sol[0].set_color(COLOR_DX) # dx\n dx_sol[3].set_color(COLOR_DU) # du\n\n self.play(\n FadeOut(step1_text),\n Write(step2_text),\n ReplacementTransform(u_def, du_def)\n )\n self.wait(1)\n \n # Show rearrangement for dx\n self.play(ReplacementTransform(du_def, dx_sol))\n self.wait(1)\n\n # --- Step 4: Perform Substitution ---\n step3_text = Tex(\"Step 3: Substitute into the integral\", color=COLOR_TEXT).to_edge(UP)\n \n substituted_integral = MathTex(\n r\"\\int\", \"e^{u}\", r\"\\cdot\", r\"\\frac{1}{2}\", \"du\"\n ).scale(1.5).move_to(dx_sol)\n substituted_integral[1].set_color(COLOR_U) # e^u\n substituted_integral[4].set_color(COLOR_DU) # du\n\n self.play(\n FadeOut(step2_text),\n Write(step3_text),\n FadeTransform(dx_sol, substituted_integral)\n )\n self.wait(1)\n\n # Rearrange constant for clarity\n integrated_form = MathTex(\n r\"\\frac{1}{2}\", r\"\\int\", \"e^{u}\", \"du\"\n ).scale(1.5).move_to(substituted_integral)\n integrated_form[0].set_color(WHITE)\n integrated_form[2].set_color(COLOR_U)\n integrated_form[3].set_color(COLOR_DU)\n\n self.play(ReplacementTransform(substituted_integral, integrated_form))\n self.wait(1)\n\n # --- Step 5: Integrate ---\n step4_text = Tex(\"Step 4: Integrate with respect to u\", color=COLOR_TEXT).to_edge(UP)\n result_u = MathTex(\n r\"\\frac{1}{2}\", \"e^{u}\", \"+\", \"C\"\n ).scale(1.5).move_to(integrated_form)\n result_u[0].set_color(WHITE)\n result_u[1].set_color(COLOR_U)\n\n self.play(\n FadeOut(step3_text),\n Write(step4_text),\n ReplacementTransform(integrated_form, result_u)\n )\n self.wait(1)\n\n # --- Step 6: Back-Substitution ---\n step5_text = Tex(\"Step 5: Back-substitute u = 2x\", color=COLOR_TEXT).to_edge(UP)\n final_solution = MathTex(\n r\"\\frac{1}{2}\", \"e^{2x}\", \"+\", \"C\"\n ).scale(1.5).move_to(result_u)\n final_solution[0].set_color(WHITE)\n final_solution[1].set_color(WHITE) # Back to standard color\n\n self.play(\n FadeOut(step4_text),\n Write(step5_text),\n ReplacementTransform(result_u, final_solution)\n )\n self.wait(1)\n\n # --- Final Display ---\n final_text = Tex(\"Final Solution\", color=COLOR_TEXT).to_edge(UP)\n box = SurroundingRectangle(final_solution, color=YELLOW, buff=0.3)\n \n self.play(\n FadeOut(step5_text),\n Write(final_text),\n Create(box)\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "How would you create a step-by-step animated explanation of solving the integral of e^(2x) using u-substitution, with text instructions and the final solution, utilizing a mathematical animation tool?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralUSubstitution(Scene):\n def construct(self):\n # Color configuration for pedagogical emphasis\n COLOR_U = BLUE\n COLOR_DX = YELLOW\n COLOR_DU = GREEN\n COLOR_TEXT = GREY_A\n\n # --- Step 1: Display the Original Integral ---\n intro_text = Tex(\"Evaluate the integral:\", color=COLOR_TEXT).to_edge(UP)\n original_integral = MathTex(\n r\"\\int\", \"e^{2x}\", \"dx\"\n ).scale(1.5).next_to(intro_text, DOWN, buff=0.5)\n \n # Highlight specific parts for substitution context\n original_integral[1].set_color(COLOR_U) # 2x\n original_integral[2].set_color(COLOR_DX) # dx\n\n self.play(Write(intro_text))\n self.play(Write(original_integral))\n self.wait(1)\n\n # --- Step 2: Define u ---\n step1_text = Tex(\"Step 1: Choose substitution variable\", color=COLOR_TEXT).to_edge(UP)\n u_def = MathTex(\"u\", \"=\", \"2x\").scale(1.2).next_to(intro_text, DOWN, buff=0.5)\n u_def[0].set_color(COLOR_U) # u\n u_def[2].set_color(COLOR_U) # 2x\n \n self.play(\n FadeOut(intro_text),\n Write(step1_text),\n FadeTransform(original_integral, u_def)\n )\n self.wait(1)\n\n # --- Step 3: Calculate du ---\n step2_text = Tex(\"Step 2: Differentiate to find du\", color=COLOR_TEXT).to_edge(UP)\n du_def = MathTex(\"du\", \"=\", \"2\", \"dx\").scale(1.2).next_to(step1_text, DOWN, buff=0.5)\n du_def[0].set_color(COLOR_DU) # du\n du_def[3].set_color(COLOR_DX) # dx\n \n # Solve for dx\n dx_sol = MathTex(\"dx\", \"=\", r\"\\frac{1}{2}\", \"du\").scale(1.2).next_to(step2_text, DOWN, buff=0.5)\n dx_sol[0].set_color(COLOR_DX) # dx\n dx_sol[3].set_color(COLOR_DU) # du\n\n self.play(\n FadeOut(step1_text),\n Write(step2_text),\n ReplacementTransform(u_def, du_def)\n )\n self.wait(1)\n \n # Show rearrangement for dx\n self.play(ReplacementTransform(du_def, dx_sol))\n self.wait(1)\n\n # --- Step 4: Perform Substitution ---\n step3_text = Tex(\"Step 3: Substitute into the integral\", color=COLOR_TEXT).to_edge(UP)\n \n substituted_integral = MathTex(\n r\"\\int\", \"e^{u}\", r\"\\cdot\", r\"\\frac{1}{2}\", \"du\"\n ).scale(1.5).move_to(dx_sol)\n substituted_integral[1].set_color(COLOR_U) # e^u\n substituted_integral[4].set_color(COLOR_DU) # du\n\n self.play(\n FadeOut(step2_text),\n Write(step3_text),\n FadeTransform(dx_sol, substituted_integral)\n )\n self.wait(1)\n\n # Rearrange constant for clarity\n integrated_form = MathTex(\n r\"\\frac{1}{2}\", r\"\\int\", \"e^{u}\", \"du\"\n ).scale(1.5).move_to(substituted_integral)\n integrated_form[0].set_color(WHITE)\n integrated_form[2].set_color(COLOR_U)\n integrated_form[3].set_color(COLOR_DU)\n\n self.play(ReplacementTransform(substituted_integral, integrated_form))\n self.wait(1)\n\n # --- Step 5: Integrate ---\n step4_text = Tex(\"Step 4: Integrate with respect to u\", color=COLOR_TEXT).to_edge(UP)\n result_u = MathTex(\n r\"\\frac{1}{2}\", \"e^{u}\", \"+\", \"C\"\n ).scale(1.5).move_to(integrated_form)\n result_u[0].set_color(WHITE)\n result_u[1].set_color(COLOR_U)\n\n self.play(\n FadeOut(step3_text),\n Write(step4_text),\n ReplacementTransform(integrated_form, result_u)\n )\n self.wait(1)\n\n # --- Step 6: Back-Substitution ---\n step5_text = Tex(\"Step 5: Back-substitute u = 2x\", color=COLOR_TEXT).to_edge(UP)\n final_solution = MathTex(\n r\"\\frac{1}{2}\", \"e^{2x}\", \"+\", \"C\"\n ).scale(1.5).move_to(result_u)\n final_solution[0].set_color(WHITE)\n final_solution[1].set_color(WHITE) # Back to standard color\n\n self.play(\n FadeOut(step4_text),\n Write(step5_text),\n ReplacementTransform(result_u, final_solution)\n )\n self.wait(1)\n\n # --- Final Display ---\n final_text = Tex(\"Final Solution\", color=COLOR_TEXT).to_edge(UP)\n box = SurroundingRectangle(final_solution, color=YELLOW, buff=0.3)\n \n self.play(\n FadeOut(step5_text),\n Write(final_text),\n Create(box)\n )\n self.wait(2)\n```"}]}
{"id": "ry_manim_codegen_000013", "source": "RY7Games/ry_manim_codegen", "tier": 1, "scene_name": "KLDivergenceScene", "num_animations": 16, "num_rich_primitives": 2, "prompt": "How does the Kullback-Leibler Divergence distinguish between two normal distributions with varying means and identical variances?", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0448", "num_animations": 22, "prompt": "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:** ", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000003", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "SciComputeScene1248", "num_animations": 5, "num_rich_primitives": 4, "prompt": "Write a Manim CE visualization using scientific Python libraries (numpy, scipy, sympy) for: Linear Algebra 2D Matrix Eigenvector Transformation.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nMARGIN = 0.5\n\nclass SciComputeScene1248(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # Matrix and eigendecomposition\n A = np.array([[2.0, 1.0], [1.0, 2.0]])\n eigenvalues, eigenvectors = np.linalg.eig(A)\n \n # Sort by eigenvalue (descending)\n idx = eigenvalues.argsort()[::-1]\n eigenvalues = eigenvalues[idx]\n eigenvectors = eigenvectors[:, idx]\n \n v1 = eigenvectors[:, 0] # \\lambda =3\n v2 = eigenvectors[:, 1] # \\lambda =1\n \n # [LAYOUT]\n plane = NumberPlane(\n x_range=[-4, 4, 1], \n y_range=[-3, 3, 1],\n background_line_style={\"stroke_opacity\": 0.4}\n )\n self.fit_in_frame(plane, w_frac=0.85, h_frac=0.85)\n \n # Matrix display\n matrix_tex = MathTex(\n r\"A = \\begin{bmatrix} 2 & 1 \\\\ 1 & 2 \\end{bmatrix}\"\n ).scale(0.7).to_corner(UL, buff=MARGIN)\n \n # Eigenvectors as arrows (scaled for visibility)\n scale_factor = 1.5\n vec1 = Arrow(\n ORIGIN, \n plane.c2p(v1[0] * scale_factor, v1[1] * scale_factor), \n color=RED, \n buff=0,\n stroke_width=6\n )\n vec2 = Arrow(\n ORIGIN, \n plane.c2p(v2[0] * scale_factor, v2[1] * scale_factor), \n color=GREEN, \n buff=0,\n stroke_width=6\n )\n \n # Labels\n label_v1 = MathTex(r\"\\mathbf{v}_1\", color=RED).scale(0.8).next_to(vec1.get_end(), UR, buff=0.15)\n label_v2 = MathTex(r\"\\mathbf{v}_2\", color=GREEN).scale(0.8).next_to(vec2.get_end(), UL, buff=0.15)\n \n # Eigenvalue labels\n eig_label_1 = MathTex(r\"\\lambda_1 = 3\", color=RED).scale(0.6)\n eig_label_2 = MathTex(r\"\\lambda_2 = 1\", color=GREEN).scale(0.6)\n eig_labels = VGroup(eig_label_1, eig_label_2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n eig_labels.to_corner(UR, buff=MARGIN)\n \n # [BEAT 1 | sync: intro]\n with self.voiceover(\n text=\"We have matrix A with elements 2, 1, 1, 2.\"\n ) as tracker:\n self.play(Create(plane), run_time=1)\n self.play(Write(matrix_tex), run_time=1)\n self.wait_until_bookmark(\"intro\")\n \n # [BEAT 2 | sync: show_evecs]\n with self.voiceover(\n text=\"Computing eigenvalues gives us lambda 1 equals 3 and lambda 2 equals 1, with corresponding eigenvectors shown in red and green.\"\n ) as tracker:\n self.wait_until_bookmark(\"show_evecs\")\n self.play(\n Create(vec1),\n Create(vec2),\n Write(label_v1),\n Write(label_v2),\n run_time=1.5\n )\n self.play(FadeIn(eig_labels), run_time=0.8)\n \n # [BEAT 3 | sync: transform]\n with self.voiceover(\n text=\"Watch as we apply the transformation. Notice how each eigenvector scales by its eigenvalue, staying on its original direction.\"\n ) as tracker:\n self.wait_until_bookmark(\"transform\")\n \n # Transformed eigenvectors\n v1_transformed = A @ v1\n v2_transformed = A @ v2\n \n self.play(\n plane.animate.apply_matrix(A),\n vec1.animate.put_start_and_end_on(\n ORIGIN, \n plane.c2p(v1_transformed[0] * scale_factor, v1_transformed[1] * scale_factor)\n ),\n vec2.animate.put_start_and_end_on(\n ORIGIN, \n plane.c2p(v2_transformed[0] * scale_factor, v2_transformed[1] * scale_factor)\n ),\n label_v1.animate.next_to(\n plane.c2p(v1_transformed[0] * scale_factor, v1_transformed[1] * scale_factor), \n UR, \n buff=0.15\n ),\n label_v2.animate.next_to(\n plane.c2p(v2_transformed[0] * scale_factor, v2_transformed[1] * scale_factor), \n UL, \n buff=0.15\n ),\n run_time=3\n )\n \n # [BEAT 4 | sync: end]\n with self.voiceover(\n text=\"This is the defining property of eigenvectors.\"\n ) as tracker:\n self.wait_until_bookmark(\"end\")\n self.wait(1)\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Write a Manim CE visualization using scientific Python libraries (numpy, scipy, sympy) for: Linear Algebra 2D Matrix Eigenvector Transformation."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\nimport numpy as np\n\nMARGIN = 0.5\n\nclass SciComputeScene1248(VoiceoverScene):\n def construct(self):\n # [SETUP]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n \n # Matrix and eigendecomposition\n A = np.array([[2.0, 1.0], [1.0, 2.0]])\n eigenvalues, eigenvectors = np.linalg.eig(A)\n \n # Sort by eigenvalue (descending)\n idx = eigenvalues.argsort()[::-1]\n eigenvalues = eigenvalues[idx]\n eigenvectors = eigenvectors[:, idx]\n \n v1 = eigenvectors[:, 0] # \\lambda =3\n v2 = eigenvectors[:, 1] # \\lambda =1\n \n # [LAYOUT]\n plane = NumberPlane(\n x_range=[-4, 4, 1], \n y_range=[-3, 3, 1],\n background_line_style={\"stroke_opacity\": 0.4}\n )\n self.fit_in_frame(plane, w_frac=0.85, h_frac=0.85)\n \n # Matrix display\n matrix_tex = MathTex(\n r\"A = \\begin{bmatrix} 2 & 1 \\\\ 1 & 2 \\end{bmatrix}\"\n ).scale(0.7).to_corner(UL, buff=MARGIN)\n \n # Eigenvectors as arrows (scaled for visibility)\n scale_factor = 1.5\n vec1 = Arrow(\n ORIGIN, \n plane.c2p(v1[0] * scale_factor, v1[1] * scale_factor), \n color=RED, \n buff=0,\n stroke_width=6\n )\n vec2 = Arrow(\n ORIGIN, \n plane.c2p(v2[0] * scale_factor, v2[1] * scale_factor), \n color=GREEN, \n buff=0,\n stroke_width=6\n )\n \n # Labels\n label_v1 = MathTex(r\"\\mathbf{v}_1\", color=RED).scale(0.8).next_to(vec1.get_end(), UR, buff=0.15)\n label_v2 = MathTex(r\"\\mathbf{v}_2\", color=GREEN).scale(0.8).next_to(vec2.get_end(), UL, buff=0.15)\n \n # Eigenvalue labels\n eig_label_1 = MathTex(r\"\\lambda_1 = 3\", color=RED).scale(0.6)\n eig_label_2 = MathTex(r\"\\lambda_2 = 1\", color=GREEN).scale(0.6)\n eig_labels = VGroup(eig_label_1, eig_label_2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n eig_labels.to_corner(UR, buff=MARGIN)\n \n # [BEAT 1 | sync: intro]\n with self.voiceover(\n text=\"We have matrix A with elements 2, 1, 1, 2.\"\n ) as tracker:\n self.play(Create(plane), run_time=1)\n self.play(Write(matrix_tex), run_time=1)\n self.wait_until_bookmark(\"intro\")\n \n # [BEAT 2 | sync: show_evecs]\n with self.voiceover(\n text=\"Computing eigenvalues gives us lambda 1 equals 3 and lambda 2 equals 1, with corresponding eigenvectors shown in red and green.\"\n ) as tracker:\n self.wait_until_bookmark(\"show_evecs\")\n self.play(\n Create(vec1),\n Create(vec2),\n Write(label_v1),\n Write(label_v2),\n run_time=1.5\n )\n self.play(FadeIn(eig_labels), run_time=0.8)\n \n # [BEAT 3 | sync: transform]\n with self.voiceover(\n text=\"Watch as we apply the transformation. Notice how each eigenvector scales by its eigenvalue, staying on its original direction.\"\n ) as tracker:\n self.wait_until_bookmark(\"transform\")\n \n # Transformed eigenvectors\n v1_transformed = A @ v1\n v2_transformed = A @ v2\n \n self.play(\n plane.animate.apply_matrix(A),\n vec1.animate.put_start_and_end_on(\n ORIGIN, \n plane.c2p(v1_transformed[0] * scale_factor, v1_transformed[1] * scale_factor)\n ),\n vec2.animate.put_start_and_end_on(\n ORIGIN, \n plane.c2p(v2_transformed[0] * scale_factor, v2_transformed[1] * scale_factor)\n ),\n label_v1.animate.next_to(\n plane.c2p(v1_transformed[0] * scale_factor, v1_transformed[1] * scale_factor), \n UR, \n buff=0.15\n ),\n label_v2.animate.next_to(\n plane.c2p(v2_transformed[0] * scale_factor, v2_transformed[1] * scale_factor), \n UL, \n buff=0.15\n ),\n run_time=3\n )\n \n # [BEAT 4 | sync: end]\n with self.voiceover(\n text=\"This is the defining property of eigenvectors.\"\n ) as tracker:\n self.wait_until_bookmark(\"end\")\n self.wait(1)\n \n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "adaption-unified-manim-instructions_006288", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "NeuralNetworkTraining", "num_animations": 10, "num_rich_primitives": 4, "prompt": "How do I create an animation that shows the training of a simple feedforward neural network using Manim, with specific layers and different colors for the input and output layers?", "code": "from manim import *\nimport numpy as np\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Configuration for the network architecture\n layer_sizes = [3, 4, 2] # Input, Hidden, Output\n layer_colors = [BLUE, GREY, RED] # Distinct colors for input and output layers\n layer_labels = [\"Input Layer\", \"Hidden Layer\", \"Output Layer\"]\n \n # Positioning constants\n layer_spacing = 3.0\n node_radius = 0.25\n \n # --- Create Layers ---\n layers = []\n neurons = []\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n neuron_layer = []\n for j in range(size):\n neuron = Circle(\n radius=node_radius, \n color=layer_colors[i], \n fill_opacity=1\n )\n neuron.shift(UP * (j - (size - 1) / 2) * 1.2)\n layer_group.add(neuron)\n neuron_layer.append(neuron)\n layer_group.shift(RIGHT * (i - (len(layer_sizes) - 1) / 2) * layer_spacing)\n layers.append(layer_group)\n neurons.append(neuron_layer)\n \n network_nodes = VGroup(*layers)\n \n # --- Create Edges (Weights) ---\n edges = VGroup()\n edge_groups = [] # Track edge groups for forward/backward pass visualization\n \n for i in range(len(neurons) - 1):\n current_layer = neurons[i]\n next_layer = neurons[i + 1]\n edge_group = VGroup()\n for n1 in current_layer:\n for n2 in next_layer:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n stroke_width=1.5, \n stroke_opacity=0.4, \n color=WHITE\n )\n edges.add(line)\n edge_group.add(line)\n edge_groups.append(edge_group)\n \n network = VGroup(edges, network_nodes)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, layer_group in enumerate(layers):\n label = Text(layer_labels[i], font_size=20, color=layer_colors[i])\n label.next_to(layer_group, DOWN, buff=0.5)\n labels.add(label)\n \n # --- Create Loss Graph ---\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 1, 0.2],\n x_length=4,\n y_length=2.5,\n axis_config={\"include_tip\": False, \"include_numbers\": True},\n ).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n axes_labels = VGroup(\n Text(\"Epoch\", font_size=18).next_to(axes.get_x_axis(), DOWN),\n Text(\"Loss\", font_size=18).next_to(axes.get_y_axis(), LEFT)\n )\n \n loss_text = Text(\"Loss: 1.00\", font_size=22, color=YELLOW).next_to(axes, UP, buff=0.3)\n \n # --- Animation Sequence ---\n \n # 1. Introduce Network Structure and Labels\n self.play(Create(network), Write(labels), run_time=2)\n self.wait(0.5)\n \n # 2. Introduce Loss Monitoring\n self.play(Create(axes), Write(axes_labels), Write(loss_text), run_time=2)\n self.wait(0.5)\n \n # 3. Simulate Training Loop\n loss_curve = VMobject(color=YELLOW)\n loss_curve.set_points_as_corners([axes.c2p(0, 1), axes.c2p(0, 1)])\n self.add(loss_curve)\n \n current_loss = 1.0\n epochs = 5\n \n for epoch in range(1, epochs + 1):\n epoch_text = Text(f\"Epoch {epoch}\", font_size=24).to_edge(UL)\n self.play(FadeIn(epoch_text))\n \n # Simulate Forward Pass (Left to Right)\n for edge_group in edge_groups:\n self.play(\n edge_group.animate.set_stroke(color=YELLOW, opacity=1, width=3),\n run_time=0.3\n )\n self.play(\n edge_group.animate.set_stroke(color=WHITE, opacity=0.4, width=1.5),\n run_time=0.3\n )\n \n # Simulate Backward Pass / Weight Update (Right to Left)\n for edge_group in reversed(edge_groups):\n # Vary stroke width to simulate weight adjustments\n for edge in edge_group:\n new_width = np.random.uniform(1.0, 3.5)\n edge.set_stroke(width=new_width)\n \n self.play(\n edge_group.animate.set_stroke(color=RED, opacity=0.8, width=3),\n run_time=0.3\n )\n self.play(\n edge_group.animate.set_stroke(color=WHITE, opacity=0.4, width=1.5),\n run_time=0.3\n )\n \n # Update Loss Curve\n new_loss = max(0.1, current_loss * np.random.uniform(0.7, 0.9))\n current_loss = new_loss\n \n new_point = axes.c2p(epoch, current_loss)\n loss_curve.add_line_to(new_point)\n \n # Update Text\n new_loss_text = Text(f\"Loss: {current_loss:.2f}\", font_size=22, color=YELLOW).next_to(axes, UP, buff=0.3)\n self.play(\n ReplacementTransform(loss_text, new_loss_text),\n FadeOut(epoch_text),\n run_time=0.5\n )\n loss_text = new_loss_text\n \n # 4. Conclusion\n self.play(\n Indicate(loss_text, scale_factor=1.2, color=GREEN),\n run_time=1\n )\n \n final_label = Text(\"Training Complete\", color=GREEN, font_size=36).to_edge(UP)\n self.play(Write(final_label))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "How do I create an animation that shows the training of a simple feedforward neural network using Manim, with specific layers and different colors for the input and output layers?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Configuration for the network architecture\n layer_sizes = [3, 4, 2] # Input, Hidden, Output\n layer_colors = [BLUE, GREY, RED] # Distinct colors for input and output layers\n layer_labels = [\"Input Layer\", \"Hidden Layer\", \"Output Layer\"]\n \n # Positioning constants\n layer_spacing = 3.0\n node_radius = 0.25\n \n # --- Create Layers ---\n layers = []\n neurons = []\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n neuron_layer = []\n for j in range(size):\n neuron = Circle(\n radius=node_radius, \n color=layer_colors[i], \n fill_opacity=1\n )\n neuron.shift(UP * (j - (size - 1) / 2) * 1.2)\n layer_group.add(neuron)\n neuron_layer.append(neuron)\n layer_group.shift(RIGHT * (i - (len(layer_sizes) - 1) / 2) * layer_spacing)\n layers.append(layer_group)\n neurons.append(neuron_layer)\n \n network_nodes = VGroup(*layers)\n \n # --- Create Edges (Weights) ---\n edges = VGroup()\n edge_groups = [] # Track edge groups for forward/backward pass visualization\n \n for i in range(len(neurons) - 1):\n current_layer = neurons[i]\n next_layer = neurons[i + 1]\n edge_group = VGroup()\n for n1 in current_layer:\n for n2 in next_layer:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n stroke_width=1.5, \n stroke_opacity=0.4, \n color=WHITE\n )\n edges.add(line)\n edge_group.add(line)\n edge_groups.append(edge_group)\n \n network = VGroup(edges, network_nodes)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, layer_group in enumerate(layers):\n label = Text(layer_labels[i], font_size=20, color=layer_colors[i])\n label.next_to(layer_group, DOWN, buff=0.5)\n labels.add(label)\n \n # --- Create Loss Graph ---\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 1, 0.2],\n x_length=4,\n y_length=2.5,\n axis_config={\"include_tip\": False, \"include_numbers\": True},\n ).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n axes_labels = VGroup(\n Text(\"Epoch\", font_size=18).next_to(axes.get_x_axis(), DOWN),\n Text(\"Loss\", font_size=18).next_to(axes.get_y_axis(), LEFT)\n )\n \n loss_text = Text(\"Loss: 1.00\", font_size=22, color=YELLOW).next_to(axes, UP, buff=0.3)\n \n # --- Animation Sequence ---\n \n # 1. Introduce Network Structure and Labels\n self.play(Create(network), Write(labels), run_time=2)\n self.wait(0.5)\n \n # 2. Introduce Loss Monitoring\n self.play(Create(axes), Write(axes_labels), Write(loss_text), run_time=2)\n self.wait(0.5)\n \n # 3. Simulate Training Loop\n loss_curve = VMobject(color=YELLOW)\n loss_curve.set_points_as_corners([axes.c2p(0, 1), axes.c2p(0, 1)])\n self.add(loss_curve)\n \n current_loss = 1.0\n epochs = 5\n \n for epoch in range(1, epochs + 1):\n epoch_text = Text(f\"Epoch {epoch}\", font_size=24).to_edge(UL)\n self.play(FadeIn(epoch_text))\n \n # Simulate Forward Pass (Left to Right)\n for edge_group in edge_groups:\n self.play(\n edge_group.animate.set_stroke(color=YELLOW, opacity=1, width=3),\n run_time=0.3\n )\n self.play(\n edge_group.animate.set_stroke(color=WHITE, opacity=0.4, width=1.5),\n run_time=0.3\n )\n \n # Simulate Backward Pass / Weight Update (Right to Left)\n for edge_group in reversed(edge_groups):\n # Vary stroke width to simulate weight adjustments\n for edge in edge_group:\n new_width = np.random.uniform(1.0, 3.5)\n edge.set_stroke(width=new_width)\n \n self.play(\n edge_group.animate.set_stroke(color=RED, opacity=0.8, width=3),\n run_time=0.3\n )\n self.play(\n edge_group.animate.set_stroke(color=WHITE, opacity=0.4, width=1.5),\n run_time=0.3\n )\n \n # Update Loss Curve\n new_loss = max(0.1, current_loss * np.random.uniform(0.7, 0.9))\n current_loss = new_loss\n \n new_point = axes.c2p(epoch, current_loss)\n loss_curve.add_line_to(new_point)\n \n # Update Text\n new_loss_text = Text(f\"Loss: {current_loss:.2f}\", font_size=22, color=YELLOW).next_to(axes, UP, buff=0.3)\n self.play(\n ReplacementTransform(loss_text, new_loss_text),\n FadeOut(epoch_text),\n run_time=0.5\n )\n loss_text = new_loss_text\n \n # 4. Conclusion\n self.play(\n Indicate(loss_text, scale_factor=1.2, color=GREEN),\n run_time=1\n )\n \n final_label = Text(\"Training Complete\", color=GREEN, font_size=36).to_edge(UP)\n self.play(Write(final_label))\n self.wait(2)\n```"}]}
{"id": "manim-sft-10k_005936", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "EnhancedNeuralNetworkAnimation", "num_animations": 18, "num_rich_primitives": 6, "prompt": "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.", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SolveLinearODE", "num_animations": 12, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_007496", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "OxygenMoleculeFormation", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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?", "code": "from manim import *\n\nclass OxygenMoleculeFormation(Scene):\n def construct(self):\n # --- 1. Initialization ---\n # Define Oxygen atoms using standard CPK coloring (Red) with labels\n atom_color = RED\n electron_color = YELLOW\n \n atom_left = VGroup(\n Circle(radius=0.6, color=atom_color, fill_opacity=0.8),\n Text(\"O\", font_size=36, color=WHITE)\n ).move_to(LEFT * 3)\n \n atom_right = VGroup(\n Circle(radius=0.6, color=atom_color, fill_opacity=0.8),\n Text(\"O\", font_size=36, color=WHITE)\n ).move_to(RIGHT * 3)\n \n # Define Valence Electrons (Yellow dots)\n # Representing the outer shell electrons that will participate in bonding\n electrons_left = VGroup(\n Dot(color=electron_color, radius=0.1).move_to(atom_left.get_center() + RIGHT * 0.8),\n Dot(color=electron_color, radius=0.1).move_to(atom_left.get_center() + RIGHT * 0.5 + UP * 0.5)\n )\n \n electrons_right = VGroup(\n Dot(color=electron_color, radius=0.1).move_to(atom_right.get_center() + LEFT * 0.8),\n Dot(color=electron_color, radius=0.1).move_to(atom_right.get_center() + LEFT * 0.5 + UP * 0.5)\n )\n \n # Add a title for context\n title = Text(\"Two Oxygen Atoms\", font_size=24).to_edge(UP)\n \n self.play(Write(title))\n self.play(\n Create(atom_left), Create(atom_right),\n Create(electrons_left), Create(electrons_right),\n run_time=2\n )\n self.wait(0.5)\n \n # --- 2. Approach ---\n # Move atoms toward each other\n self.play(\n title.animate.fade_out(),\n atom_left.animate.shift(RIGHT * 2),\n atom_right.animate.shift(LEFT * 2),\n electrons_left.animate.shift(RIGHT * 2),\n electrons_right.animate.shift(LEFT * 2),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n \n # --- 3. Bond Formation ---\n # Visualize electron sharing (Covalent Double Bond)\n # Move the electrons to the center overlap region between the nuclei\n midpoint = (atom_left.get_center() + atom_right.get_center()) / 2\n \n self.play(\n electrons_left[0].animate.move_to(midpoint + DOWN * 0.15),\n electrons_right[0].animate.move_to(midpoint + DOWN * 0.15),\n electrons_left[1].animate.move_to(midpoint + UP * 0.15),\n electrons_right[1].animate.move_to(midpoint + UP * 0.15),\n run_time=1.5\n )\n \n # Draw bond lines to emphasize the double covalent bond\n bond_line_top = Line(\n start=atom_left.get_right(), \n end=atom_right.get_left(), \n color=WHITE, \n stroke_width=4\n ).shift(UP * 0.1)\n \n bond_line_bottom = Line(\n start=atom_left.get_right(), \n end=atom_right.get_left(), \n color=WHITE, \n stroke_width=4\n ).shift(DOWN * 0.1)\n \n self.play(Create(bond_line_top), Create(bond_line_bottom), run_time=1)\n self.wait(0.5)\n \n # Group all components into a single molecule object for subsequent transformations\n molecule = VGroup(\n atom_left, atom_right, \n electrons_left, electrons_right, \n bond_line_top, bond_line_bottom\n )\n \n # --- 4. Transformation Sequence ---\n \n # Step 4a: Shift the entire molecule upwards\n self.play(\n molecule.animate.shift(UP * 2),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4b: Shrink the molecule in size\n self.play(\n molecule.animate.scale(0.5),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4c: Rotate the molecule\n self.play(\n molecule.animate.rotate(PI / 3),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4d: Fade the molecule out until it disappears\n self.play(\n FadeOut(molecule),\n run_time=1.5\n )\n \n self.wait(0.5)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 OxygenMoleculeFormation(Scene):\n def construct(self):\n # --- 1. Initialization ---\n # Define Oxygen atoms using standard CPK coloring (Red) with labels\n atom_color = RED\n electron_color = YELLOW\n \n atom_left = VGroup(\n Circle(radius=0.6, color=atom_color, fill_opacity=0.8),\n Text(\"O\", font_size=36, color=WHITE)\n ).move_to(LEFT * 3)\n \n atom_right = VGroup(\n Circle(radius=0.6, color=atom_color, fill_opacity=0.8),\n Text(\"O\", font_size=36, color=WHITE)\n ).move_to(RIGHT * 3)\n \n # Define Valence Electrons (Yellow dots)\n # Representing the outer shell electrons that will participate in bonding\n electrons_left = VGroup(\n Dot(color=electron_color, radius=0.1).move_to(atom_left.get_center() + RIGHT * 0.8),\n Dot(color=electron_color, radius=0.1).move_to(atom_left.get_center() + RIGHT * 0.5 + UP * 0.5)\n )\n \n electrons_right = VGroup(\n Dot(color=electron_color, radius=0.1).move_to(atom_right.get_center() + LEFT * 0.8),\n Dot(color=electron_color, radius=0.1).move_to(atom_right.get_center() + LEFT * 0.5 + UP * 0.5)\n )\n \n # Add a title for context\n title = Text(\"Two Oxygen Atoms\", font_size=24).to_edge(UP)\n \n self.play(Write(title))\n self.play(\n Create(atom_left), Create(atom_right),\n Create(electrons_left), Create(electrons_right),\n run_time=2\n )\n self.wait(0.5)\n \n # --- 2. Approach ---\n # Move atoms toward each other\n self.play(\n title.animate.fade_out(),\n atom_left.animate.shift(RIGHT * 2),\n atom_right.animate.shift(LEFT * 2),\n electrons_left.animate.shift(RIGHT * 2),\n electrons_right.animate.shift(LEFT * 2),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n \n # --- 3. Bond Formation ---\n # Visualize electron sharing (Covalent Double Bond)\n # Move the electrons to the center overlap region between the nuclei\n midpoint = (atom_left.get_center() + atom_right.get_center()) / 2\n \n self.play(\n electrons_left[0].animate.move_to(midpoint + DOWN * 0.15),\n electrons_right[0].animate.move_to(midpoint + DOWN * 0.15),\n electrons_left[1].animate.move_to(midpoint + UP * 0.15),\n electrons_right[1].animate.move_to(midpoint + UP * 0.15),\n run_time=1.5\n )\n \n # Draw bond lines to emphasize the double covalent bond\n bond_line_top = Line(\n start=atom_left.get_right(), \n end=atom_right.get_left(), \n color=WHITE, \n stroke_width=4\n ).shift(UP * 0.1)\n \n bond_line_bottom = Line(\n start=atom_left.get_right(), \n end=atom_right.get_left(), \n color=WHITE, \n stroke_width=4\n ).shift(DOWN * 0.1)\n \n self.play(Create(bond_line_top), Create(bond_line_bottom), run_time=1)\n self.wait(0.5)\n \n # Group all components into a single molecule object for subsequent transformations\n molecule = VGroup(\n atom_left, atom_right, \n electrons_left, electrons_right, \n bond_line_top, bond_line_bottom\n )\n \n # --- 4. Transformation Sequence ---\n \n # Step 4a: Shift the entire molecule upwards\n self.play(\n molecule.animate.shift(UP * 2),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4b: Shrink the molecule in size\n self.play(\n molecule.animate.scale(0.5),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4c: Rotate the molecule\n self.play(\n molecule.animate.rotate(PI / 3),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Step 4d: Fade the molecule out until it disappears\n self.play(\n FadeOut(molecule),\n run_time=1.5\n )\n \n self.wait(0.5)\n```"}]}
{"id": "adaption-unified-manim-instructions_008112", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SimpleHarmonicMotion", "num_animations": 10, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "qwen3-8b-manimator-gold-sft_000440", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "SpectralTheoremTour", "num_animations": 7, "num_rich_primitives": 3, "prompt": "Target audience: first-year undergrads in linear algebra; prerequisites: vectors, eigenvalues, and basic matrix multiplication.\nCreate a visual tour of the spectral theorem for real symmetric matrices: start with a 2D scene showing eigenvectors as principal axes, then a 3D ellipsoid deformation demonstrating how A maps along those axes.\nShow the decomposition A = Q Λ Q^T, with animated eigenvalues sweeping and a moving vector decomposed into the eigenbasis and scaled by Λ, highlighting intuition before the algebra.\nInclude clean transitions, color coding for eigenvectors and eigenvalues, and a short interactive thought experiment about what happens when the matrix changes while preserving symmetry.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass SpectralTheoremTour(ThreeDScene, VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: SYMMETRIC]\n with self.voiceover(text=\"The spectral theorem is one of the most beautiful results in linear algebra. It applies to symmetric matrices, where A equals A transpose.\") as tracker:\n title = Text(\"Spectral Theorem for Symmetric Matrices\", font_size=36)\n self.fit_in_frame(title)\n self.add_fixed_in_frame_mobjects(title)\n title.to_edge(UP)\n self.wait_until_bookmark(\"SYMMETRIC\")\n self.play(Write(title), run_time=tracker.duration * 0.5)\n \n sym_eq = MathTex(\"A = A^\\\\top\", font_size=40)\n sym_mat = Matrix([[2, 1], [1, 2]], h_buff=1.2, v_buff=0.6).scale(0.6)\n sym_group = VGroup(sym_eq, sym_mat).arrange(RIGHT, buff=1)\n self.add_fixed_in_frame_mobjects(sym_group)\n sym_group.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(sym_group), run_time=tracker.duration * 0.5)\n\n with self.voiceover(text=\"The theorem states that any symmetric matrix can be decomposed as A equals Q Lambda Q transpose, where Q is orthogonal and Lambda is diagonal.\") as tracker:\n self.play(FadeOut(sym_group), run_time=0.5)\n decomp = MathTex(\"A = Q\", \"\\\\Lambda\", \"Q^\\\\top\", font_size=44)\n decomp.set_color_by_tex(\"\\\\Lambda\", RED)\n self.add_fixed_in_frame_mobjects(decomp)\n decomp.move_to(ORIGIN)\n self.wait_until_bookmark(\"DECOMP\")\n self.play(Write(decomp), run_time=tracker.duration)\n\n with self.voiceover(text=\"Geometrically, this means the matrix stretches space along the eigenvector axes by the eigenvalues, transforming a sphere into an ellipsoid.\") as tracker:\n self.play(FadeOut(decomp), run_time=0.5)\n axes = ThreeDAxes(x_range=[-3, 3], y_range=[-3, 3], z_range=[-3, 3])\n sphere = Sphere(radius=1, color=BLUE, fill_opacity=0.3)\n self.wait_until_bookmark(\"ELLIPSOID\")\n self.play(Create(axes), Create(sphere), run_time=tracker.duration * 0.5)\n \n ellipsoid = sphere.copy().stretch(2.5, dim=0).stretch(1.5, dim=1).stretch(0.8, dim=2).set_color(GREEN)\n self.play(Transform(sphere, ellipsoid), run_time=tracker.duration * 0.5)\n self.begin_ambient_camera_rotation(rate=0.1)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Target audience: first-year undergrads in linear algebra; prerequisites: vectors, eigenvalues, and basic matrix multiplication.\nCreate a visual tour of the spectral theorem for real symmetric matrices: start with a 2D scene showing eigenvectors as principal axes, then a 3D ellipsoid deformation demonstrating how A maps along those axes.\nShow the decomposition A = Q Λ Q^T, with animated eigenvalues sweeping and a moving vector decomposed into the eigenbasis and scaled by Λ, highlighting intuition before the algebra.\nInclude clean transitions, color coding for eigenvectors and eigenvalues, and a short interactive thought experiment about what happens when the matrix changes while preserving symmetry."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass SpectralTheoremTour(ThreeDScene, VoiceoverScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n\n # [BEAT 1 | sync: SYMMETRIC]\n with self.voiceover(text=\"The spectral theorem is one of the most beautiful results in linear algebra. It applies to symmetric matrices, where A equals A transpose.\") as tracker:\n title = Text(\"Spectral Theorem for Symmetric Matrices\", font_size=36)\n self.fit_in_frame(title)\n self.add_fixed_in_frame_mobjects(title)\n title.to_edge(UP)\n self.wait_until_bookmark(\"SYMMETRIC\")\n self.play(Write(title), run_time=tracker.duration * 0.5)\n \n sym_eq = MathTex(\"A = A^\\\\top\", font_size=40)\n sym_mat = Matrix([[2, 1], [1, 2]], h_buff=1.2, v_buff=0.6).scale(0.6)\n sym_group = VGroup(sym_eq, sym_mat).arrange(RIGHT, buff=1)\n self.add_fixed_in_frame_mobjects(sym_group)\n sym_group.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(sym_group), run_time=tracker.duration * 0.5)\n\n with self.voiceover(text=\"The theorem states that any symmetric matrix can be decomposed as A equals Q Lambda Q transpose, where Q is orthogonal and Lambda is diagonal.\") as tracker:\n self.play(FadeOut(sym_group), run_time=0.5)\n decomp = MathTex(\"A = Q\", \"\\\\Lambda\", \"Q^\\\\top\", font_size=44)\n decomp.set_color_by_tex(\"\\\\Lambda\", RED)\n self.add_fixed_in_frame_mobjects(decomp)\n decomp.move_to(ORIGIN)\n self.wait_until_bookmark(\"DECOMP\")\n self.play(Write(decomp), run_time=tracker.duration)\n\n with self.voiceover(text=\"Geometrically, this means the matrix stretches space along the eigenvector axes by the eigenvalues, transforming a sphere into an ellipsoid.\") as tracker:\n self.play(FadeOut(decomp), run_time=0.5)\n axes = ThreeDAxes(x_range=[-3, 3], y_range=[-3, 3], z_range=[-3, 3])\n sphere = Sphere(radius=1, color=BLUE, fill_opacity=0.3)\n self.wait_until_bookmark(\"ELLIPSOID\")\n self.play(Create(axes), Create(sphere), run_time=tracker.duration * 0.5)\n \n ellipsoid = sphere.copy().stretch(2.5, dim=0).stretch(1.5, dim=1).stretch(0.8, dim=2).set_color(GREEN)\n self.play(Transform(sphere, ellipsoid), run_time=tracker.duration * 0.5)\n self.begin_ambient_camera_rotation(rate=0.1)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "multi_act_v2_00629", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0629", "num_animations": 19, "prompt": "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: How can I create an animation where text changes to the word \"Circumscribe\" and moves upwards, followed by new text appearing saying \"Look Here\" which then gets highlighted with animation, first with the default shape an\n- Act 2: Display a square by fading it in. Then, rotate the square 45 degrees. Finally, fade the square out and pause for one second.\n- Act 3: I would like to create an educational animation that visually demonstrates the concept of finding the area under a curve on a graph. Specifically, I want to illustrate the area under the curve of the function f(x) = x^2 ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0629(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_circumscribeanimation()\n self.clear_stage()\n self.act_2_someanimations()\n self.clear_stage()\n self.act_3_areaundercurve()\n\n def act_1_circumscribeanimation(self):\n initial_text = Text(\"Start\", font_size=48)\n target_text = Text(\"Circumscribe\", font_size=48)\n \n # Ensure the target starts at the same position as the initial text\n target_text.move_to(initial_text)\n \n # Animate the transformation of content while shifting upwards\n self.play(\n ReplacementTransform(initial_text, target_text),\n initial_text.animate.shift(UP * 2),\n run_time=2\n )\n self.wait(0.5)\n\n # 2. Sequential Text Appearance\n look_here_text = Text(\"Look Here\", font_size=48)\n look_here_text.next_to(target_text, DOWN, buff=1.5)\n \n self.play(Write(look_here_text), run_time=1.5)\n self.wait(0.5)\n\n # 3. Highlighting Sequence\n # First: Default highlight shape\n self.play(Highlight(look_here_text), run_time=1)\n self.wait(0.5)\n\n # Second: Circular highlight shape using Circumscribe\n self.play(\n Circumscribe(look_here_text, Circle, fade_out=True, color=YELLOW), \n run_time=1.5\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Fade out all text elements from the scene\n self.play(FadeOut(target_text), FadeOut(look_here_text), run_time=1)\n self.wait(1)\n\n def act_2_someanimations(self):\n square = Square()\n\n # some animations display mobjects, ...\n self.play(FadeIn(square))\n\n # ... some move or rotate mobjects around...\n self.play(Rotate(square, PI/4))\n\n # some animations remove mobjects from the screen\n self.play(FadeOut(square))\n\n self.wait(1)\n\n def act_3_areaundercurve(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).to_edge(LEFT, buff=1.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n func_label = MathTex(r\"f(x) = x^2\").next_to(curve, UR, buff=0.2)\n\n # 2. Visual Highlight\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # 3. Mathematical Derivation Steps\n step1 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=40)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\", font_size=40)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\", font_size=40)\n step4 = MathTex(r\"= \\frac{8}{3}\", font_size=40, color=YELLOW)\n\n equations = VGroup(step1, step2, step3, step4).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 0.5)\n\n # 4. Animation Sequence\n\n # Introduce the graph and function\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n self.play(Create(curve), Write(func_label))\n self.wait(1)\n\n # Shade the area under the curve\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n\n # Systematically display the calculation steps\n self.play(Write(step1))\n self.wait(1)\n\n self.play(Write(step2))\n self.wait(1)\n\n self.play(Write(step3))\n self.wait(1)\n\n self.play(Write(step4))\n self.wait(1.5)\n\n # Conclude by highlighting the final value\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: How can I create an animation where text changes to the word \"Circumscribe\" and moves upwards, followed by new text appearing saying \"Look Here\" which then gets highlighted with animation, first with the default shape an\n- Act 2: Display a square by fading it in. Then, rotate the square 45 degrees. Finally, fade the square out and pause for one second.\n- Act 3: I would like to create an educational animation that visually demonstrates the concept of finding the area under a curve on a graph. Specifically, I want to illustrate the area under the curve of the function f(x) = x^2 "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0629(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_circumscribeanimation()\n self.clear_stage()\n self.act_2_someanimations()\n self.clear_stage()\n self.act_3_areaundercurve()\n\n def act_1_circumscribeanimation(self):\n initial_text = Text(\"Start\", font_size=48)\n target_text = Text(\"Circumscribe\", font_size=48)\n \n # Ensure the target starts at the same position as the initial text\n target_text.move_to(initial_text)\n \n # Animate the transformation of content while shifting upwards\n self.play(\n ReplacementTransform(initial_text, target_text),\n initial_text.animate.shift(UP * 2),\n run_time=2\n )\n self.wait(0.5)\n\n # 2. Sequential Text Appearance\n look_here_text = Text(\"Look Here\", font_size=48)\n look_here_text.next_to(target_text, DOWN, buff=1.5)\n \n self.play(Write(look_here_text), run_time=1.5)\n self.wait(0.5)\n\n # 3. Highlighting Sequence\n # First: Default highlight shape\n self.play(Highlight(look_here_text), run_time=1)\n self.wait(0.5)\n\n # Second: Circular highlight shape using Circumscribe\n self.play(\n Circumscribe(look_here_text, Circle, fade_out=True, color=YELLOW), \n run_time=1.5\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Fade out all text elements from the scene\n self.play(FadeOut(target_text), FadeOut(look_here_text), run_time=1)\n self.wait(1)\n\n def act_2_someanimations(self):\n square = Square()\n\n # some animations display mobjects, ...\n self.play(FadeIn(square))\n\n # ... some move or rotate mobjects around...\n self.play(Rotate(square, PI/4))\n\n # some animations remove mobjects from the screen\n self.play(FadeOut(square))\n\n self.wait(1)\n\n def act_3_areaundercurve(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).to_edge(LEFT, buff=1.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n func_label = MathTex(r\"f(x) = x^2\").next_to(curve, UR, buff=0.2)\n\n # 2. Visual Highlight\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # 3. Mathematical Derivation Steps\n step1 = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=40)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\", font_size=40)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\", font_size=40)\n step4 = MathTex(r\"= \\frac{8}{3}\", font_size=40, color=YELLOW)\n\n equations = VGroup(step1, step2, step3, step4).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 0.5)\n\n # 4. Animation Sequence\n\n # Introduce the graph and function\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n self.play(Create(curve), Write(func_label))\n self.wait(1)\n\n # Shade the area under the curve\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n\n # Systematically display the calculation steps\n self.play(Write(step1))\n self.wait(1)\n\n self.play(Write(step2))\n self.wait(1)\n\n self.play(Write(step3))\n self.wait(1)\n\n self.play(Write(step4))\n self.wait(1.5)\n\n # Conclude by highlighting the final value\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_003950", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "FourierSeriesAnimation", "num_animations": 16, "num_rich_primitives": 4, "prompt": "Can you create an educational animation that first displays the general equation for a Fourier series, then explains it as a concept that decomposes periodic functions into constituent frequencies, and finally shows a simple example of a Fourier series with just two terms, all while smoothly transitioning between the stages of the explanation?", "code": "from manim import *\nimport numpy as np\n\nclass FourierSeriesAnimation(Scene):\n def construct(self):\n # ==========================================\n # Stage 1: General Equation\n # ==========================================\n title = Text(\"Fourier Series\", font_size=48).to_edge(UP)\n \n fourier_eq = MathTex(\n \"f(x) = \", \"\\\\frac{a_0}{2}\", \" + \", \n \"\\\\sum_{n=1}^{\\\\infty}\", \n \"\\\\left( \", \"a_n\", \"\\\\cos(nx)\", \" + \", \"b_n\", \"\\\\sin(nx)\", \" \\\\right)\",\n font_size=42\n )\n fourier_eq.next_to(title, DOWN, buff=0.8)\n\n self.play(Write(title), run_time=1.5)\n self.play(Write(fourier_eq), run_time=3)\n self.wait(1)\n\n # ==========================================\n # Stage 2: Conceptual Explanation\n # ==========================================\n # Highlight the summation part to explain decomposition\n sum_part = fourier_eq[3:]\n box = SurroundingRectangle(sum_part, color=YELLOW, buff=0.1)\n \n concept_text = Text(\n \"Decomposes periodic functions\\ninto constituent frequencies\",\n font_size=32,\n line_spacing=1.5\n ).next_to(fourier_eq, DOWN, buff=1)\n \n self.play(Create(box))\n self.play(FadeIn(concept_text))\n \n # Highlight coefficients to imply frequency components\n an_term = fourier_eq[5] # a_n\n bn_term = fourier_eq[8] # b_n\n self.play(\n an_term.animate.set_color(RED),\n bn_term.animate.set_color(GREEN),\n )\n self.wait(1)\n\n # Transition: Move title and fade out equation elements\n self.play(\n FadeOut(box),\n FadeOut(concept_text),\n FadeOut(fourier_eq),\n title.animate.scale(0.7).to_corner(UL)\n )\n\n # Visualizing decomposition with constituent waves\n axes = Axes(\n x_range=[0, 2 * PI, 1],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": False}\n ).shift(DOWN * 0.5)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(axis_labels))\n\n # A complex wave (sum of 3 frequencies)\n complex_func = lambda x: np.sin(x) + 0.5 * np.sin(3 * x) + 0.2 * np.sin(5 * x)\n complex_graph = axes.plot(complex_func, color=WHITE)\n complex_label = MathTex(\"\\\\text{Complex Periodic Wave}\").next_to(axes, UP)\n \n self.play(Create(complex_graph), Write(complex_label))\n self.wait(1)\n\n # Decompose into constituent waves\n wave1 = axes.plot(lambda x: np.sin(x), color=RED)\n wave2 = axes.plot(lambda x: 0.5 * np.sin(3 * x), color=GREEN)\n wave3 = axes.plot(lambda x: 0.2 * np.sin(5 * x), color=BLUE)\n \n labels_waves = VGroup(\n MathTex(\"\\\\sin(x)\", color=RED).scale(0.7),\n MathTex(\"0.5\\\\sin(3x)\", color=GREEN).scale(0.7),\n MathTex(\"0.2\\\\sin(5x)\", color=BLUE).scale(0.7)\n ).arrange(RIGHT, buff=1).to_edge(UP).shift(RIGHT * 2)\n\n self.play(\n FadeOut(complex_graph),\n FadeOut(complex_label),\n Create(wave1),\n Create(wave2),\n Create(wave3),\n Write(labels_waves)\n )\n self.wait(2)\n\n # ==========================================\n # Stage 3: Specific Example (Two Terms)\n # ==========================================\n # Clear the conceptual part to show the 2-term approximation\n self.play(\n FadeOut(wave1), FadeOut(wave2), FadeOut(wave3), \n FadeOut(labels_waves),\n title.animate.set_text(\"Two-Term Approximation\").scale(1.2).move_to(UP * 2)\n )\n\n # Define a simple 2-term example: f(x) = sin(x) + 0.5*sin(2x)\n example_eq = MathTex(\n \"S_2(x) = \", \"\\\\sin(x)\", \" + \", \"0.5\", \"\\\\sin(2x)\"\n ).next_to(title, DOWN, buff=0.5)\n \n # Color match the terms for visual consistency\n example_eq[1].set_color(RED)\n example_eq[4].set_color(GREEN)\n\n self.play(Write(example_eq), run_time=2)\n self.wait(1)\n\n # Plot individual terms and their sum\n graph1 = axes.plot(lambda x: np.sin(x), color=RED)\n graph2 = axes.plot(lambda x: 0.5 * np.sin(2 * x), color=GREEN)\n graph_sum = axes.plot(lambda x: np.sin(x) + 0.5 * np.sin(2 * x), color=YELLOW)\n\n label1 = MathTex(\"\\\\sin(x)\", color=RED).scale(0.6).next_to(graph1, UR, buff=0.2)\n label2 = MathTex(\"0.5\\\\sin(2x)\", color=GREEN).scale(0.6).next_to(graph2, DR, buff=0.2)\n label_sum = MathTex(\"S_2(x)\", color=YELLOW).scale(0.8).to_edge(DOWN).shift(UP)\n\n # Animation sequence for the example\n self.play(Create(graph1), Write(label1))\n self.wait(1)\n self.play(Create(graph2), Write(label2))\n self.wait(1)\n \n # Show the superposition (Sum) and fade individual components slightly\n self.play(\n Create(graph_sum),\n Write(label_sum),\n graph1.animate.set_opacity(0.3),\n label1.animate.set_opacity(0.3),\n graph2.animate.set_opacity(0.3),\n label2.animate.set_opacity(0.3),\n run_time=2\n )\n \n # Final Highlight\n self.play(Indicate(label_sum, color=YELLOW, scale_factor=1.2))\n self.wait(2)\n\n # Final cleanup\n self.play(FadeOut(Group(*self.mobjects)))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that first displays the general equation for a Fourier series, then explains it as a concept that decomposes periodic functions into constituent frequencies, and finally shows a simple example of a Fourier series with just two terms, all while smoothly transitioning between the stages of the explanation?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass FourierSeriesAnimation(Scene):\n def construct(self):\n # ==========================================\n # Stage 1: General Equation\n # ==========================================\n title = Text(\"Fourier Series\", font_size=48).to_edge(UP)\n \n fourier_eq = MathTex(\n \"f(x) = \", \"\\\\frac{a_0}{2}\", \" + \", \n \"\\\\sum_{n=1}^{\\\\infty}\", \n \"\\\\left( \", \"a_n\", \"\\\\cos(nx)\", \" + \", \"b_n\", \"\\\\sin(nx)\", \" \\\\right)\",\n font_size=42\n )\n fourier_eq.next_to(title, DOWN, buff=0.8)\n\n self.play(Write(title), run_time=1.5)\n self.play(Write(fourier_eq), run_time=3)\n self.wait(1)\n\n # ==========================================\n # Stage 2: Conceptual Explanation\n # ==========================================\n # Highlight the summation part to explain decomposition\n sum_part = fourier_eq[3:]\n box = SurroundingRectangle(sum_part, color=YELLOW, buff=0.1)\n \n concept_text = Text(\n \"Decomposes periodic functions\\ninto constituent frequencies\",\n font_size=32,\n line_spacing=1.5\n ).next_to(fourier_eq, DOWN, buff=1)\n \n self.play(Create(box))\n self.play(FadeIn(concept_text))\n \n # Highlight coefficients to imply frequency components\n an_term = fourier_eq[5] # a_n\n bn_term = fourier_eq[8] # b_n\n self.play(\n an_term.animate.set_color(RED),\n bn_term.animate.set_color(GREEN),\n )\n self.wait(1)\n\n # Transition: Move title and fade out equation elements\n self.play(\n FadeOut(box),\n FadeOut(concept_text),\n FadeOut(fourier_eq),\n title.animate.scale(0.7).to_corner(UL)\n )\n\n # Visualizing decomposition with constituent waves\n axes = Axes(\n x_range=[0, 2 * PI, 1],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": False}\n ).shift(DOWN * 0.5)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(axis_labels))\n\n # A complex wave (sum of 3 frequencies)\n complex_func = lambda x: np.sin(x) + 0.5 * np.sin(3 * x) + 0.2 * np.sin(5 * x)\n complex_graph = axes.plot(complex_func, color=WHITE)\n complex_label = MathTex(\"\\\\text{Complex Periodic Wave}\").next_to(axes, UP)\n \n self.play(Create(complex_graph), Write(complex_label))\n self.wait(1)\n\n # Decompose into constituent waves\n wave1 = axes.plot(lambda x: np.sin(x), color=RED)\n wave2 = axes.plot(lambda x: 0.5 * np.sin(3 * x), color=GREEN)\n wave3 = axes.plot(lambda x: 0.2 * np.sin(5 * x), color=BLUE)\n \n labels_waves = VGroup(\n MathTex(\"\\\\sin(x)\", color=RED).scale(0.7),\n MathTex(\"0.5\\\\sin(3x)\", color=GREEN).scale(0.7),\n MathTex(\"0.2\\\\sin(5x)\", color=BLUE).scale(0.7)\n ).arrange(RIGHT, buff=1).to_edge(UP).shift(RIGHT * 2)\n\n self.play(\n FadeOut(complex_graph),\n FadeOut(complex_label),\n Create(wave1),\n Create(wave2),\n Create(wave3),\n Write(labels_waves)\n )\n self.wait(2)\n\n # ==========================================\n # Stage 3: Specific Example (Two Terms)\n # ==========================================\n # Clear the conceptual part to show the 2-term approximation\n self.play(\n FadeOut(wave1), FadeOut(wave2), FadeOut(wave3), \n FadeOut(labels_waves),\n title.animate.set_text(\"Two-Term Approximation\").scale(1.2).move_to(UP * 2)\n )\n\n # Define a simple 2-term example: f(x) = sin(x) + 0.5*sin(2x)\n example_eq = MathTex(\n \"S_2(x) = \", \"\\\\sin(x)\", \" + \", \"0.5\", \"\\\\sin(2x)\"\n ).next_to(title, DOWN, buff=0.5)\n \n # Color match the terms for visual consistency\n example_eq[1].set_color(RED)\n example_eq[4].set_color(GREEN)\n\n self.play(Write(example_eq), run_time=2)\n self.wait(1)\n\n # Plot individual terms and their sum\n graph1 = axes.plot(lambda x: np.sin(x), color=RED)\n graph2 = axes.plot(lambda x: 0.5 * np.sin(2 * x), color=GREEN)\n graph_sum = axes.plot(lambda x: np.sin(x) + 0.5 * np.sin(2 * x), color=YELLOW)\n\n label1 = MathTex(\"\\\\sin(x)\", color=RED).scale(0.6).next_to(graph1, UR, buff=0.2)\n label2 = MathTex(\"0.5\\\\sin(2x)\", color=GREEN).scale(0.6).next_to(graph2, DR, buff=0.2)\n label_sum = MathTex(\"S_2(x)\", color=YELLOW).scale(0.8).to_edge(DOWN).shift(UP)\n\n # Animation sequence for the example\n self.play(Create(graph1), Write(label1))\n self.wait(1)\n self.play(Create(graph2), Write(label2))\n self.wait(1)\n \n # Show the superposition (Sum) and fade individual components slightly\n self.play(\n Create(graph_sum),\n Write(label_sum),\n graph1.animate.set_opacity(0.3),\n label1.animate.set_opacity(0.3),\n graph2.animate.set_opacity(0.3),\n label2.animate.set_opacity(0.3),\n run_time=2\n )\n \n # Final Highlight\n self.play(Indicate(label_sum, color=YELLOW, scale_factor=1.2))\n self.wait(2)\n\n # Final cleanup\n self.play(FadeOut(Group(*self.mobjects)))\n```"}]}
{"id": "adaption-unified-manim-instructions_007066", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolynomialApproximation", "num_animations": 8, "num_rich_primitives": 3, "prompt": "Can you create an educational animation that visually illustrates the process of approximating a cubic function using different polynomial degrees, starting with a linear function and progressing through to a cubic one? The animation should begin by displaying a set of axes and plotting the original cubic function x^3 in green. Afterward, it should graph a linear approximation 3x-2 in red, followed by a quadratic approximation x^2-2x+1 in orange, and finally a more accurate cubic approximation 0.1x^3+0.2x^2-0.5x-1 in purple. Each new approximation should replace the previous one, and all functions should be accurately labeled. At the end of the animation, I'd like to briefly clear the screen before concluding with just the most accurate cubic approximation displayed. Please ensure each step is paced for clear comprehension and visual appeal.", "code": "from manim import *\n\nclass PolynomialApproximation(Scene):\n def construct(self):\n # 1. Setup: Create and display coordinate axes\n # Ranges are adjusted to comfortably fit x^3 and the approximations\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n x_length=10,\n y_length=6,\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n\n self.play(Create(axes), run_time=2)\n self.wait(1)\n\n # Define the functions as specified\n func_original = lambda x: x**3\n func_linear = lambda x: 3*x - 2\n func_quadratic = lambda x: x**2 - 2*x + 1\n func_cubic_approx = lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1\n\n # Create plot objects with specified colors\n plot_original = axes.plot(func_original, color=GREEN, x_range=[-2.15, 2.15])\n plot_linear = axes.plot(func_linear, color=RED, x_range=[-3, 3])\n plot_quadratic = axes.plot(func_quadratic, color=ORANGE, x_range=[-3, 3])\n plot_cubic_approx = axes.plot(func_cubic_approx, color=PURPLE, x_range=[-3, 3])\n\n # Create labels for each function using MathTex for clear equation rendering\n label_original = MathTex(\"f(x) = x^3\", color=GREEN).to_corner(UL)\n label_linear = MathTex(\"f(x) = 3x - 2\", color=RED).to_corner(UL)\n label_quadratic = MathTex(\"f(x) = x^2 - 2x + 1\", color=ORANGE).to_corner(UL)\n # Scale down slightly to fit the longer equation\n label_cubic_approx = MathTex(\"f(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\", color=PURPLE).scale(0.8).to_corner(UL)\n\n # 2. Original Function: Plot x^3 in green\n self.play(Create(plot_original), Write(label_original), run_time=2)\n self.wait(2)\n\n # 3. Sequential Approximations\n \n # Linear Approximation: 3x - 2 in Red (Replaces Original)\n self.play(\n ReplacementTransform(plot_original, plot_linear),\n ReplacementTransform(label_original, label_linear),\n run_time=2\n )\n self.wait(2)\n\n # Quadratic Approximation: x^2 - 2x + 1 in Orange (Replaces Linear)\n self.play(\n ReplacementTransform(plot_linear, plot_quadratic),\n ReplacementTransform(label_linear, label_quadratic),\n run_time=2\n )\n self.wait(2)\n\n # Cubic Approximation: 0.1x^3 + ... in Purple (Replaces Quadratic)\n self.play(\n ReplacementTransform(plot_quadratic, plot_cubic_approx),\n ReplacementTransform(label_quadratic, label_cubic_approx),\n run_time=2\n )\n self.wait(2)\n\n # 4. Conclusion: Briefly clear the screen (fade out all elements)\n self.play(FadeOut(VGroup(axes, plot_cubic_approx, label_cubic_approx)), run_time=1.5)\n self.wait(1)\n\n # Display only the final, most accurate cubic approximation\n self.play(Create(axes), run_time=1)\n self.play(Create(plot_cubic_approx), Write(label_cubic_approx), run_time=2)\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually illustrates the process of approximating a cubic function using different polynomial degrees, starting with a linear function and progressing through to a cubic one? The animation should begin by displaying a set of axes and plotting the original cubic function x^3 in green. Afterward, it should graph a linear approximation 3x-2 in red, followed by a quadratic approximation x^2-2x+1 in orange, and finally a more accurate cubic approximation 0.1x^3+0.2x^2-0.5x-1 in purple. Each new approximation should replace the previous one, and all functions should be accurately labeled. At the end of the animation, I'd like to briefly clear the screen before concluding with just the most accurate cubic approximation displayed. Please ensure each step is paced for clear comprehension and visual appeal."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolynomialApproximation(Scene):\n def construct(self):\n # 1. Setup: Create and display coordinate axes\n # Ranges are adjusted to comfortably fit x^3 and the approximations\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-10, 10, 2],\n x_length=10,\n y_length=6,\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n\n self.play(Create(axes), run_time=2)\n self.wait(1)\n\n # Define the functions as specified\n func_original = lambda x: x**3\n func_linear = lambda x: 3*x - 2\n func_quadratic = lambda x: x**2 - 2*x + 1\n func_cubic_approx = lambda x: 0.1*x**3 + 0.2*x**2 - 0.5*x - 1\n\n # Create plot objects with specified colors\n plot_original = axes.plot(func_original, color=GREEN, x_range=[-2.15, 2.15])\n plot_linear = axes.plot(func_linear, color=RED, x_range=[-3, 3])\n plot_quadratic = axes.plot(func_quadratic, color=ORANGE, x_range=[-3, 3])\n plot_cubic_approx = axes.plot(func_cubic_approx, color=PURPLE, x_range=[-3, 3])\n\n # Create labels for each function using MathTex for clear equation rendering\n label_original = MathTex(\"f(x) = x^3\", color=GREEN).to_corner(UL)\n label_linear = MathTex(\"f(x) = 3x - 2\", color=RED).to_corner(UL)\n label_quadratic = MathTex(\"f(x) = x^2 - 2x + 1\", color=ORANGE).to_corner(UL)\n # Scale down slightly to fit the longer equation\n label_cubic_approx = MathTex(\"f(x) = 0.1x^3 + 0.2x^2 - 0.5x - 1\", color=PURPLE).scale(0.8).to_corner(UL)\n\n # 2. Original Function: Plot x^3 in green\n self.play(Create(plot_original), Write(label_original), run_time=2)\n self.wait(2)\n\n # 3. Sequential Approximations\n \n # Linear Approximation: 3x - 2 in Red (Replaces Original)\n self.play(\n ReplacementTransform(plot_original, plot_linear),\n ReplacementTransform(label_original, label_linear),\n run_time=2\n )\n self.wait(2)\n\n # Quadratic Approximation: x^2 - 2x + 1 in Orange (Replaces Linear)\n self.play(\n ReplacementTransform(plot_linear, plot_quadratic),\n ReplacementTransform(label_linear, label_quadratic),\n run_time=2\n )\n self.wait(2)\n\n # Cubic Approximation: 0.1x^3 + ... in Purple (Replaces Quadratic)\n self.play(\n ReplacementTransform(plot_quadratic, plot_cubic_approx),\n ReplacementTransform(label_quadratic, label_cubic_approx),\n run_time=2\n )\n self.wait(2)\n\n # 4. Conclusion: Briefly clear the screen (fade out all elements)\n self.play(FadeOut(VGroup(axes, plot_cubic_approx, label_cubic_approx)), run_time=1.5)\n self.wait(1)\n\n # Display only the final, most accurate cubic approximation\n self.play(Create(axes), run_time=1)\n self.play(Create(plot_cubic_approx), Write(label_cubic_approx), run_time=2)\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_003761", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ForwardPropagationScene", "num_animations": 11, "num_rich_primitives": 3, "prompt": "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?", "code": "from 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", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_001028", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PolarDoubleIntegral", "num_animations": 13, "num_rich_primitives": 2, "prompt": "Could you create an educational animation illustrating the steps to solve a double integral in polar coordinates, specifically the integral of r^2 sin(theta) with the limits for r going from 0 to 1 and for theta from 0 to pi/2? It should include the integration first with respect to r, showing the intermediate steps, and then integration with respect to theta, until reaching the final numeric solution. Also, include textual explanations for each step of the process.", "code": "from manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Configuration ---\n tex_font_size = 42\n explanation_color = BLUE_B\n highlight_color = YELLOW\n\n # --- Step 1: Problem Statement ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n problem = MathTex(\n r\"\\int_{0}^{\\pi/2} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(title, DOWN, buff=0.8)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Inner Integral (w.r.t r) ---\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$ (treat $\\\\theta$ as constant)\",\n color=explanation_color,\n font_size=30\n ).next_to(problem, DOWN, buff=0.8)\n\n # Antiderivative: \\int_{0}^{\\pi/2} [ r^3/3 sin(theta) ]_0^1 d\\theta\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi/2} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1} \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(step1_text, DOWN, buff=0.5)\n\n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(problem.copy(), inner_antiderivative))\n self.wait(2)\n\n # Evaluate limits for r\n eval_r_text = Text(\"Evaluate limits: r = 0 to 1\", font_size=24, color=GRAY)\n eval_r_text.next_to(inner_antiderivative, RIGHT, buff=0.5)\n self.play(Write(eval_r_text))\n self.wait(1)\n\n # Intermediate Result: \\int_{0}^{\\pi/2} (1/3) sin(theta) d\\theta\n intermediate_result = MathTex(\n r\"\\int_{0}^{\\pi/2} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(inner_antiderivative, DOWN, buff=0.5)\n\n self.play(\n Write(intermediate_result),\n inner_antiderivative.animate.set_opacity(0.4),\n FadeOut(eval_r_text)\n )\n self.wait(2)\n\n # --- Step 3: Outer Integral (w.r.t theta) ---\n # Clear previous step details, keep intermediate result for continuity\n self.play(\n FadeOut(title),\n FadeOut(step1_text), \n FadeOut(problem),\n FadeOut(inner_antiderivative)\n )\n self.play(intermediate_result.animate.to_edge(UP).shift(DOWN * 1.2))\n\n step2_text = Text(\n \"Step 2: Integrate with respect to \\theta \", \n font_size=30, \n color=explanation_color\n ).next_to(intermediate_result, DOWN, buff=0.8)\n\n self.play(Write(step2_text))\n self.wait(1)\n\n # Antiderivative: [ -(1/3) cos(theta) ]_0^{pi/2}\n outer_antiderivative = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi/2}\",\n font_size=tex_font_size\n ).next_to(step2_text, DOWN, buff=0.5)\n\n self.play(\n ReplacementTransform(intermediate_result.copy(), outer_antiderivative),\n intermediate_result.animate.set_opacity(0.4)\n )\n self.wait(2)\n\n # Evaluate limits for theta\n # -1/3 (cos(pi/2) - cos(0))\n outer_eval = MathTex(\n r\"-\\frac{1}{3} \\left( \\cos\\left(\\frac{\\pi}{2}\\right) - \\cos(0) \\right)\",\n font_size=tex_font_size\n ).next_to(outer_antiderivative, DOWN, buff=0.5)\n\n eval_theta_text = Text(\"Evaluate limits: \\theta = 0 to \\pi /2\", font_size=24, color=GRAY)\n eval_theta_text.next_to(outer_eval, RIGHT, buff=0.5)\n \n self.play(Write(outer_eval), Write(eval_theta_text))\n self.wait(2)\n\n # Final Calculation: -1/3 (0 - 1) = 1/3\n final_solution = MathTex(\n r\"-\\frac{1}{3} (0 - 1) = \\frac{1}{3}\",\n font_size=tex_font_size,\n color=highlight_color\n ).next_to(outer_eval, DOWN, buff=0.5)\n\n self.play(\n Write(final_solution),\n FadeOut(eval_theta_text)\n )\n self.wait(1)\n\n # Highlight Final Answer\n conclusion_text = Text(\"Final Solution\", font_size=28, color=highlight_color)\n conclusion_text.next_to(final_solution, DOWN, buff=0.5)\n \n box = SurroundingRectangle(final_solution, color=highlight_color, buff=0.2)\n self.play(Create(box), FadeIn(conclusion_text))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql script_name.py PolarDoubleIntegral", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation illustrating the steps to solve a double integral in polar coordinates, specifically the integral of r^2 sin(theta) with the limits for r going from 0 to 1 and for theta from 0 to pi/2? It should include the integration first with respect to r, showing the intermediate steps, and then integration with respect to theta, until reaching the final numeric solution. Also, include textual explanations for each step of the process."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Configuration ---\n tex_font_size = 42\n explanation_color = BLUE_B\n highlight_color = YELLOW\n\n # --- Step 1: Problem Statement ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n problem = MathTex(\n r\"\\int_{0}^{\\pi/2} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(title, DOWN, buff=0.8)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Inner Integral (w.r.t r) ---\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$ (treat $\\\\theta$ as constant)\",\n color=explanation_color,\n font_size=30\n ).next_to(problem, DOWN, buff=0.8)\n\n # Antiderivative: \\int_{0}^{\\pi/2} [ r^3/3 sin(theta) ]_0^1 d\\theta\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi/2} \\left[ \\frac{r^3}{3} \\sin(\\theta) \\right]_{0}^{1} \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(step1_text, DOWN, buff=0.5)\n\n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(problem.copy(), inner_antiderivative))\n self.wait(2)\n\n # Evaluate limits for r\n eval_r_text = Text(\"Evaluate limits: r = 0 to 1\", font_size=24, color=GRAY)\n eval_r_text.next_to(inner_antiderivative, RIGHT, buff=0.5)\n self.play(Write(eval_r_text))\n self.wait(1)\n\n # Intermediate Result: \\int_{0}^{\\pi/2} (1/3) sin(theta) d\\theta\n intermediate_result = MathTex(\n r\"\\int_{0}^{\\pi/2} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=tex_font_size\n ).next_to(inner_antiderivative, DOWN, buff=0.5)\n\n self.play(\n Write(intermediate_result),\n inner_antiderivative.animate.set_opacity(0.4),\n FadeOut(eval_r_text)\n )\n self.wait(2)\n\n # --- Step 3: Outer Integral (w.r.t theta) ---\n # Clear previous step details, keep intermediate result for continuity\n self.play(\n FadeOut(title),\n FadeOut(step1_text), \n FadeOut(problem),\n FadeOut(inner_antiderivative)\n )\n self.play(intermediate_result.animate.to_edge(UP).shift(DOWN * 1.2))\n\n step2_text = Text(\n \"Step 2: Integrate with respect to \\theta \", \n font_size=30, \n color=explanation_color\n ).next_to(intermediate_result, DOWN, buff=0.8)\n\n self.play(Write(step2_text))\n self.wait(1)\n\n # Antiderivative: [ -(1/3) cos(theta) ]_0^{pi/2}\n outer_antiderivative = MathTex(\n r\"\\left[ -\\frac{1}{3} \\cos(\\theta) \\right]_{0}^{\\pi/2}\",\n font_size=tex_font_size\n ).next_to(step2_text, DOWN, buff=0.5)\n\n self.play(\n ReplacementTransform(intermediate_result.copy(), outer_antiderivative),\n intermediate_result.animate.set_opacity(0.4)\n )\n self.wait(2)\n\n # Evaluate limits for theta\n # -1/3 (cos(pi/2) - cos(0))\n outer_eval = MathTex(\n r\"-\\frac{1}{3} \\left( \\cos\\left(\\frac{\\pi}{2}\\right) - \\cos(0) \\right)\",\n font_size=tex_font_size\n ).next_to(outer_antiderivative, DOWN, buff=0.5)\n\n eval_theta_text = Text(\"Evaluate limits: \\theta = 0 to \\pi /2\", font_size=24, color=GRAY)\n eval_theta_text.next_to(outer_eval, RIGHT, buff=0.5)\n \n self.play(Write(outer_eval), Write(eval_theta_text))\n self.wait(2)\n\n # Final Calculation: -1/3 (0 - 1) = 1/3\n final_solution = MathTex(\n r\"-\\frac{1}{3} (0 - 1) = \\frac{1}{3}\",\n font_size=tex_font_size,\n color=highlight_color\n ).next_to(outer_eval, DOWN, buff=0.5)\n\n self.play(\n Write(final_solution),\n FadeOut(eval_theta_text)\n )\n self.wait(1)\n\n # Highlight Final Answer\n conclusion_text = Text(\"Final Solution\", font_size=28, color=highlight_color)\n conclusion_text.next_to(final_solution, DOWN, buff=0.5)\n \n box = SurroundingRectangle(final_solution, color=highlight_color, buff=0.2)\n self.play(Create(box), FadeIn(conclusion_text))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql script_name.py PolarDoubleIntegral\n```"}]}
{"id": "adaption-unified-manim-instructions_000030", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralExample", "num_animations": 12, "num_rich_primitives": 2, "prompt": "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?", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_004317", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ProjectileMotion", "num_animations": 10, "num_rich_primitives": 7, "prompt": "I would like to create an educational animation that illustrates the concept of projectile motion. The animation should begin by introducing the formula for velocity as a function of time during projectile motion in a clear way. It should then show an object being launched at an initial velocity, following a trajectory that represents the projectile motion path, while the camera frame is focused on the action. The object's initial velocity vector should be visible and properly labeled. At the peak of the trajectory, I want a series of red sparks to explode outward in all directions as if the object is a firework. Can you create a dynamic and visually appealing animation that incorporates these features and helps to explain projectile motion?", "code": "from manim import *\nimport numpy as np\n\nclass ProjectileMotion(Scene):\n def construct(self):\n # --- Physics Constants ---\n # Scaled for visual clarity while maintaining mathematical correctness\n g = 4.0\n v0_mag = 6.0\n theta = 60 * DEGREES\n \n # Velocity components\n v0x = v0_mag * np.cos(theta)\n v0y = v0_mag * np.sin(theta)\n \n # Time calculations\n t_peak = v0y / g\n t_total = 2 * t_peak\n\n # --- 1. Formula Introduction ---\n formula = MathTex(\n r\"\\vec{v}(t) = \\langle v_0 \\cos\\theta, \\, v_0 \\sin\\theta - gt \\rangle\"\n ).scale(0.9).to_edge(UP).set_color(WHITE)\n \n formula_desc = Text(\n \"Velocity as a function of time\", font_size=24, color=GRAY_A\n ).next_to(formula, DOWN)\n \n self.play(Write(formula))\n self.play(FadeIn(formula_desc))\n self.wait(1.5)\n self.play(FadeOut(formula_desc), formula.animate.scale(0.8).to_corner(UL))\n\n # --- Setup Coordinate System ---\n axes = Axes(\n x_range=[0, 8, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(DOWN * 2.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n\n # --- 2. Vector Visualization ---\n start_pos = axes.c2p(0, 0)\n \n # Initial velocity vector\n v0_vector = Arrow(\n start=start_pos,\n end=start_pos + np.array([v0x, v0y, 0]) * 0.4,\n color=YELLOW,\n buff=0\n )\n v0_label = MathTex(\"v_0\", color=YELLOW).next_to(v0_vector, UR, buff=0.1)\n \n self.play(GrowArrow(v0_vector), Write(v0_label))\n self.wait(1)\n\n # --- 3. Launch and Trajectory ---\n projectile = Dot(color=BLUE, radius=0.15).move_to(start_pos)\n \n # Traced path for the parabola\n trail = TracedPath(projectile.get_center, stroke_color=BLUE, stroke_width=3)\n self.add(trail)\n \n # Use ValueTracker to smoothly animate time\n t_tracker = ValueTracker(0)\n \n # Updater for projectile position\n projectile.add_updater(lambda m: m.move_to(\n axes.c2p(v0x * t_tracker.get_value(), v0y * t_tracker.get_value() - 0.5 * g * t_tracker.get_value()**2)\n ))\n \n # Updater for current velocity vector\n current_v_vec = always_redraw(lambda: Arrow(\n start=projectile.get_center(),\n end=projectile.get_center() + np.array([v0x, v0y - g * t_tracker.get_value(), 0]) * 0.4,\n buff=0,\n color=YELLOW,\n stroke_width=3\n ))\n \n v_label = always_redraw(lambda: MathTex(\n \"v(t)\", color=YELLOW, font_size=24\n ).next_to(current_v_vec, RIGHT, buff=0.1))\n\n self.play(FadeIn(projectile), FadeIn(current_v_vec), FadeIn(v_label))\n \n # Animate launch to peak\n self.play(t_tracker.animate.set_value(t_peak), run_time=t_peak, rate_func=linear)\n\n # --- 4. Peak Effect (Firework Explosion) ---\n peak_pos = projectile.get_center()\n \n # Create red sparks radiating outward\n n_sparks = 40\n sparks = VGroup()\n for i in range(n_sparks):\n angle = (2 * np.pi / n_sparks) * i\n speed = np.random.uniform(1.5, 3.0) # Varied speeds for natural effect\n direction = np.array([np.cos(angle), np.sin(angle), 0])\n \n spark = Dot(radius=0.06, color=RED, fill_opacity=1).move_to(peak_pos)\n spark.direction = direction\n spark.speed = speed\n sparks.add(spark)\n \n self.add(sparks)\n \n def update_sparks(mob, dt):\n for s in mob:\n s.shift(s.direction * s.speed * dt)\n s.set_opacity(max(0, s.get_opacity() - dt * 1.5))\n \n sparks.add_updater(update_sparks)\n \n # Let explosion play out\n self.wait(1.2)\n sparks.clear_updaters()\n self.play(FadeOut(sparks), run_time=0.3)\n\n # Animate peak to ground\n self.play(t_tracker.animate.set_value(t_total), run_time=t_peak, rate_func=linear)\n\n # Final wrap-up\n self.play(\n FadeOut(VGroup(\n formula, axes, x_label, y_label, \n projectile, trail, v0_vector, v0_label, \n current_v_vec, v_label\n ))\n )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that illustrates the concept of projectile motion. The animation should begin by introducing the formula for velocity as a function of time during projectile motion in a clear way. It should then show an object being launched at an initial velocity, following a trajectory that represents the projectile motion path, while the camera frame is focused on the action. The object's initial velocity vector should be visible and properly labeled. At the peak of the trajectory, I want a series of red sparks to explode outward in all directions as if the object is a firework. Can you create a dynamic and visually appealing animation that incorporates these features and helps to explain projectile motion?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass ProjectileMotion(Scene):\n def construct(self):\n # --- Physics Constants ---\n # Scaled for visual clarity while maintaining mathematical correctness\n g = 4.0\n v0_mag = 6.0\n theta = 60 * DEGREES\n \n # Velocity components\n v0x = v0_mag * np.cos(theta)\n v0y = v0_mag * np.sin(theta)\n \n # Time calculations\n t_peak = v0y / g\n t_total = 2 * t_peak\n\n # --- 1. Formula Introduction ---\n formula = MathTex(\n r\"\\vec{v}(t) = \\langle v_0 \\cos\\theta, \\, v_0 \\sin\\theta - gt \\rangle\"\n ).scale(0.9).to_edge(UP).set_color(WHITE)\n \n formula_desc = Text(\n \"Velocity as a function of time\", font_size=24, color=GRAY_A\n ).next_to(formula, DOWN)\n \n self.play(Write(formula))\n self.play(FadeIn(formula_desc))\n self.wait(1.5)\n self.play(FadeOut(formula_desc), formula.animate.scale(0.8).to_corner(UL))\n\n # --- Setup Coordinate System ---\n axes = Axes(\n x_range=[0, 8, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(DOWN * 2.5)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n\n # --- 2. Vector Visualization ---\n start_pos = axes.c2p(0, 0)\n \n # Initial velocity vector\n v0_vector = Arrow(\n start=start_pos,\n end=start_pos + np.array([v0x, v0y, 0]) * 0.4,\n color=YELLOW,\n buff=0\n )\n v0_label = MathTex(\"v_0\", color=YELLOW).next_to(v0_vector, UR, buff=0.1)\n \n self.play(GrowArrow(v0_vector), Write(v0_label))\n self.wait(1)\n\n # --- 3. Launch and Trajectory ---\n projectile = Dot(color=BLUE, radius=0.15).move_to(start_pos)\n \n # Traced path for the parabola\n trail = TracedPath(projectile.get_center, stroke_color=BLUE, stroke_width=3)\n self.add(trail)\n \n # Use ValueTracker to smoothly animate time\n t_tracker = ValueTracker(0)\n \n # Updater for projectile position\n projectile.add_updater(lambda m: m.move_to(\n axes.c2p(v0x * t_tracker.get_value(), v0y * t_tracker.get_value() - 0.5 * g * t_tracker.get_value()**2)\n ))\n \n # Updater for current velocity vector\n current_v_vec = always_redraw(lambda: Arrow(\n start=projectile.get_center(),\n end=projectile.get_center() + np.array([v0x, v0y - g * t_tracker.get_value(), 0]) * 0.4,\n buff=0,\n color=YELLOW,\n stroke_width=3\n ))\n \n v_label = always_redraw(lambda: MathTex(\n \"v(t)\", color=YELLOW, font_size=24\n ).next_to(current_v_vec, RIGHT, buff=0.1))\n\n self.play(FadeIn(projectile), FadeIn(current_v_vec), FadeIn(v_label))\n \n # Animate launch to peak\n self.play(t_tracker.animate.set_value(t_peak), run_time=t_peak, rate_func=linear)\n\n # --- 4. Peak Effect (Firework Explosion) ---\n peak_pos = projectile.get_center()\n \n # Create red sparks radiating outward\n n_sparks = 40\n sparks = VGroup()\n for i in range(n_sparks):\n angle = (2 * np.pi / n_sparks) * i\n speed = np.random.uniform(1.5, 3.0) # Varied speeds for natural effect\n direction = np.array([np.cos(angle), np.sin(angle), 0])\n \n spark = Dot(radius=0.06, color=RED, fill_opacity=1).move_to(peak_pos)\n spark.direction = direction\n spark.speed = speed\n sparks.add(spark)\n \n self.add(sparks)\n \n def update_sparks(mob, dt):\n for s in mob:\n s.shift(s.direction * s.speed * dt)\n s.set_opacity(max(0, s.get_opacity() - dt * 1.5))\n \n sparks.add_updater(update_sparks)\n \n # Let explosion play out\n self.wait(1.2)\n sparks.clear_updaters()\n self.play(FadeOut(sparks), run_time=0.3)\n\n # Animate peak to ground\n self.play(t_tracker.animate.set_value(t_total), run_time=t_peak, rate_func=linear)\n\n # Final wrap-up\n self.play(\n FadeOut(VGroup(\n formula, axes, x_label, y_label, \n projectile, trail, v0_vector, v0_label, \n current_v_vec, v_label\n ))\n )\n```"}]}
{"id": "AOS-Manim-SFT_000189", "source": "nabin2004/AOS-Manim-SFT", "tier": 1, "scene_name": "NLPCharacterEmbeddingsVisualization", "num_animations": 9, "num_rich_primitives": 3, "prompt": "I’m studying NLP embeddings and want to visualize how discrete character IDs become dense vectors. Show an input sequence of characters mapped to embedding IDs, then transform to a sequence of dense vectors forming a contextualized representation. Include a montage of the embedding table rows being read and the resulting vector matrix, with color cues for magnitudes. Offer a quick note on why embeddings capture semantic similarity.", "code": "from manim import *\n\nclass NLPCharacterEmbeddingsVisualization(Scene, ThreeDScene):\n\n def construct(self):\n title = Text('NLP Character Embeddings Visualization', font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(title))\n axes = ThreeDAxes(x_range=[-2.5, 2.5, 1], y_range=[-2.5, 2.5, 1], z_range=[-2.5, 2.5, 1], x_length=5, y_length=5, z_length=5)\n axes.set_stroke(width=2)\n axes_labels = axes.get_axis_labels(x_label=Tex('dim 1', font_size=24), y_label=Tex('dim 2', font_size=24), z_label=Tex('dim 3', font_size=24))\n self.set_camera_orientation(phi=60 * DEGREES, theta=-45 * DEGREES, zoom=0.8)\n self.play(Create(axes), Write(axes_labels), run_time=2.0)\n char_embeddings = [('a', [0.8, 1.2, 0.5], RED), ('e', [1.0, 1.0, 0.7], RED), ('i', [0.9, 1.1, 0.6], RED), ('o', [1.1, 0.9, 0.8], RED), ('u', [0.7, 1.3, 0.4], RED), ('b', [-1.2, -0.5, 1.0], BLUE), ('c', [-1.0, -0.7, 1.1], BLUE), ('d', [-0.9, -0.4, 0.9], BLUE), ('t', [-1.1, -0.6, 1.2], BLUE), ('s', [0.2, -1.5, -0.8], GREEN), ('r', [0.1, -1.3, -0.7], GREEN), ('n', [0.3, -1.4, -0.9], GREEN)]\n dots = VGroup()\n text_labels = VGroup()\n for ch, pos, color in char_embeddings:\n point = axes.coords_to_point(*pos)\n dot = Dot3D(point=point, radius=0.08, color=color)\n dots.add(dot)\n lbl = Text(ch, font_size=28, color=color)\n lbl.move_to(point + 0.35 * (UP + RIGHT))\n text_labels.add(lbl)\n self.play(*[Create(dots[i]) for i in range(5)], *[Write(text_labels[i]) for i in range(5)], run_time=2.0)\n self.play(*[Create(dots[i]) for i in range(5, 9)], *[Write(text_labels[i]) for i in range(5, 9)], run_time=2.0)\n self.play(*[Create(dots[i]) for i in range(9, 12)], *[Write(text_labels[i]) for i in range(9, 12)], run_time=2.0)\n self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES, run_time=2.0)\n vowel_connections = VGroup()\n for i in range(4):\n start = axes.coords_to_point(*char_embeddings[i][1])\n end = axes.coords_to_point(*char_embeddings[i + 1][1])\n line = DashedLine(start, end, color=YELLOW, stroke_width=2)\n vowel_connections.add(line)\n self.play(Create(vowel_connections), run_time=2.0 * 0.6)\n self.wait(2.0 * 0.4)\n vectors = VGroup()\n for ch, pos, color in char_embeddings:\n start = axes.coords_to_point(0, 0, 0)\n end = axes.coords_to_point(*pos)\n arrow = Arrow3D(start=start, end=end, color=color, thickness=0.015)\n vectors.add(arrow)\n self.play(FadeOut(vowel_connections), run_time=0.5)\n self.play(*[Create(v) for v in vectors], run_time=2.0)\n self.wait(2.0)\n self.move_camera(phi=60 * DEGREES, theta=-45 * DEGREES, zoom=0.8, run_time=2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I’m studying NLP embeddings and want to visualize how discrete character IDs become dense vectors. Show an input sequence of characters mapped to embedding IDs, then transform to a sequence of dense vectors forming a contextualized representation. Include a montage of the embedding table rows being read and the resulting vector matrix, with color cues for magnitudes. Offer a quick note on why embeddings capture semantic similarity."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass NLPCharacterEmbeddingsVisualization(Scene, ThreeDScene):\n\n def construct(self):\n title = Text('NLP Character Embeddings Visualization', font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(title))\n axes = ThreeDAxes(x_range=[-2.5, 2.5, 1], y_range=[-2.5, 2.5, 1], z_range=[-2.5, 2.5, 1], x_length=5, y_length=5, z_length=5)\n axes.set_stroke(width=2)\n axes_labels = axes.get_axis_labels(x_label=Tex('dim 1', font_size=24), y_label=Tex('dim 2', font_size=24), z_label=Tex('dim 3', font_size=24))\n self.set_camera_orientation(phi=60 * DEGREES, theta=-45 * DEGREES, zoom=0.8)\n self.play(Create(axes), Write(axes_labels), run_time=2.0)\n char_embeddings = [('a', [0.8, 1.2, 0.5], RED), ('e', [1.0, 1.0, 0.7], RED), ('i', [0.9, 1.1, 0.6], RED), ('o', [1.1, 0.9, 0.8], RED), ('u', [0.7, 1.3, 0.4], RED), ('b', [-1.2, -0.5, 1.0], BLUE), ('c', [-1.0, -0.7, 1.1], BLUE), ('d', [-0.9, -0.4, 0.9], BLUE), ('t', [-1.1, -0.6, 1.2], BLUE), ('s', [0.2, -1.5, -0.8], GREEN), ('r', [0.1, -1.3, -0.7], GREEN), ('n', [0.3, -1.4, -0.9], GREEN)]\n dots = VGroup()\n text_labels = VGroup()\n for ch, pos, color in char_embeddings:\n point = axes.coords_to_point(*pos)\n dot = Dot3D(point=point, radius=0.08, color=color)\n dots.add(dot)\n lbl = Text(ch, font_size=28, color=color)\n lbl.move_to(point + 0.35 * (UP + RIGHT))\n text_labels.add(lbl)\n self.play(*[Create(dots[i]) for i in range(5)], *[Write(text_labels[i]) for i in range(5)], run_time=2.0)\n self.play(*[Create(dots[i]) for i in range(5, 9)], *[Write(text_labels[i]) for i in range(5, 9)], run_time=2.0)\n self.play(*[Create(dots[i]) for i in range(9, 12)], *[Write(text_labels[i]) for i in range(9, 12)], run_time=2.0)\n self.move_camera(phi=75 * DEGREES, theta=30 * DEGREES, run_time=2.0)\n vowel_connections = VGroup()\n for i in range(4):\n start = axes.coords_to_point(*char_embeddings[i][1])\n end = axes.coords_to_point(*char_embeddings[i + 1][1])\n line = DashedLine(start, end, color=YELLOW, stroke_width=2)\n vowel_connections.add(line)\n self.play(Create(vowel_connections), run_time=2.0 * 0.6)\n self.wait(2.0 * 0.4)\n vectors = VGroup()\n for ch, pos, color in char_embeddings:\n start = axes.coords_to_point(0, 0, 0)\n end = axes.coords_to_point(*pos)\n arrow = Arrow3D(start=start, end=end, color=color, thickness=0.015)\n vectors.add(arrow)\n self.play(FadeOut(vowel_connections), run_time=0.5)\n self.play(*[Create(v) for v in vectors], run_time=2.0)\n self.wait(2.0)\n self.move_camera(phi=60 * DEGREES, theta=-45 * DEGREES, zoom=0.8, run_time=2)\n```"}]}
{"id": "adaption-unified-manim-instructions_006198", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ConcaveMirrorAnimation", "num_animations": 13, "num_rich_primitives": 2, "prompt": "Can you create an educational animation that visually explains how image formation works with a concave mirror by showing light rays tracing from an object to the mirror and reflecting according to the rules of ray tracing? The animation should include a representation of a concave mirror with a principal axis, focal point, and center of curvature marked. An upright object in front of the mirror, and its inverted real image formed by the mirror should also be shown. Additionally, the animation should trace three specific light rays: one that travels parallel to the principal axis and then reflects through the focal point, another that travels towards the focal point and reflects parallel to the principal axis, and a third that travels toward the center of curvature and reflects back along the same path. At the end of the animation, all elements should fade out, leaving a blank screen.", "code": "from manim import *\n\nclass ConcaveMirrorAnimation(Scene):\n def construct(self):\n # Configuration\n config.background_color = \"#1a1a1a\"\n \n # Geometry Parameters\n R = 3.0 # Radius of curvature\n f = R / 2 # Focal length\n \n # Positions (Mirror at Origin, opening Left)\n # Object is beyond C (x = -5)\n obj_x = -5.0\n obj_h = 1.5\n \n # Image Calculation (1/f = 1/do + 1/di)\n # 1/1.5 = 1/5 + 1/di => di = 2.1428...\n img_x = -2.1428\n img_h = -0.6428 # Inverted and diminished\n\n # --- Scene Elements ---\n principal_axis = Line(LEFT * 7, RIGHT * 1, color=WHITE, stroke_width=2)\n \n # Mirror Arc (Center of circle is at C = -3, 0)\n mirror = Arc(radius=R, start_angle=PI/3, angle=-2*PI/3, color=WHITE, stroke_width=4)\n mirror.move_to(LEFT * R) # Align vertex to origin\n \n # Points\n point_f = Dot(LEFT * f, color=YELLOW)\n label_f = Text(\"F\", font_size=24, color=YELLOW).next_to(point_f, DOWN)\n \n point_c = Dot(LEFT * R, color=CYAN)\n label_c = Text(\"C\", font_size=24, color=CYAN).next_to(point_c, DOWN)\n \n # Object\n object_arrow = Arrow(LEFT * obj_x, LEFT * obj_x + UP * obj_h, color=GREEN, buff=0, stroke_width=6)\n \n # Image\n image_arrow = Arrow(LEFT * img_x, LEFT * img_x + UP * img_h, color=RED, buff=0, stroke_width=6)\n image_arrow.set_opacity(0)\n\n # --- Build Scene ---\n self.play(Create(principal_axis))\n self.play(Create(mirror))\n self.play(Create(point_f), Write(label_f), Create(point_c), Write(label_c))\n self.play(Create(object_arrow))\n self.wait(1)\n\n # --- Ray Tracing ---\n # Ray 1: Parallel -> Through F\n r1_start = object_arrow.get_end()\n r1_hit = ORIGIN + UP * obj_h # Hits mirror at y = obj_h\n r1_end = LEFT * f + DOWN * (obj_h / f) * f # Passes through F\n \n ray1_i = Line(r1_start, r1_hit, color=BLUE)\n ray1_r = Line(r1_hit, r1_end, color=BLUE)\n self.play(Create(ray1_i), run_time=1.5)\n self.play(Create(ray1_r), run_time=1.5)\n\n # Ray 2: Toward F -> Parallel\n r2_start = object_arrow.get_end()\n # Intersection of line (start to F) with mirror circle (x+3)^2 + y^2 = 9\n # Precalculated hit point for obj_h=1.5\n r2_hit = np.array([-0.08, -0.64, 0]) \n r2_end = LEFT * 7 + UP * r2_hit[1] # Horizontal reflection\n \n ray2_i = Line(r2_start, r2_hit, color=YELLOW)\n ray2_r = Line(r2_hit, r2_end, color=YELLOW)\n self.play(Create(ray2_i), run_time=1.5)\n self.play(Create(ray2_r), run_time=1.5)\n\n # Ray 3: Through C -> Back on itself\n r3_start = object_arrow.get_end()\n # Intersection of line (start to C) with mirror circle\n # Precalculated hit point for obj_h=1.5\n r3_hit = np.array([-0.6, -1.8, 0])\n \n ray3_i = Line(r3_start, r3_hit, color=MAGENTA)\n ray3_r = Line(r3_hit, r3_start, color=MAGENTA)\n self.play(Create(ray3_i), run_time=1.5)\n self.play(Create(ray3_r), run_time=1.5)\n\n # --- Image Formation ---\n intersection_point = LEFT * img_x + UP * img_h\n glow = Circle(radius=0.2, color=WHITE).move_to(intersection_point)\n \n self.play(Create(glow), run_time=0.5)\n self.play(FadeIn(image_arrow), FadeOut(glow), run_time=1.5)\n self.wait(2)\n\n # --- Conclusion: Fade Out ---\n all_elements = VGroup(\n principal_axis, mirror, \n point_f, label_f, point_c, label_c,\n object_arrow, image_arrow,\n ray1_i, ray1_r, ray2_i, ray2_r, ray3_i, ray3_r\n )\n \n self.play(FadeOut(all_elements), run_time=2)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually explains how image formation works with a concave mirror by showing light rays tracing from an object to the mirror and reflecting according to the rules of ray tracing? The animation should include a representation of a concave mirror with a principal axis, focal point, and center of curvature marked. An upright object in front of the mirror, and its inverted real image formed by the mirror should also be shown. Additionally, the animation should trace three specific light rays: one that travels parallel to the principal axis and then reflects through the focal point, another that travels towards the focal point and reflects parallel to the principal axis, and a third that travels toward the center of curvature and reflects back along the same path. At the end of the animation, all elements should fade out, leaving a blank screen."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass ConcaveMirrorAnimation(Scene):\n def construct(self):\n # Configuration\n config.background_color = \"#1a1a1a\"\n \n # Geometry Parameters\n R = 3.0 # Radius of curvature\n f = R / 2 # Focal length\n \n # Positions (Mirror at Origin, opening Left)\n # Object is beyond C (x = -5)\n obj_x = -5.0\n obj_h = 1.5\n \n # Image Calculation (1/f = 1/do + 1/di)\n # 1/1.5 = 1/5 + 1/di => di = 2.1428...\n img_x = -2.1428\n img_h = -0.6428 # Inverted and diminished\n\n # --- Scene Elements ---\n principal_axis = Line(LEFT * 7, RIGHT * 1, color=WHITE, stroke_width=2)\n \n # Mirror Arc (Center of circle is at C = -3, 0)\n mirror = Arc(radius=R, start_angle=PI/3, angle=-2*PI/3, color=WHITE, stroke_width=4)\n mirror.move_to(LEFT * R) # Align vertex to origin\n \n # Points\n point_f = Dot(LEFT * f, color=YELLOW)\n label_f = Text(\"F\", font_size=24, color=YELLOW).next_to(point_f, DOWN)\n \n point_c = Dot(LEFT * R, color=CYAN)\n label_c = Text(\"C\", font_size=24, color=CYAN).next_to(point_c, DOWN)\n \n # Object\n object_arrow = Arrow(LEFT * obj_x, LEFT * obj_x + UP * obj_h, color=GREEN, buff=0, stroke_width=6)\n \n # Image\n image_arrow = Arrow(LEFT * img_x, LEFT * img_x + UP * img_h, color=RED, buff=0, stroke_width=6)\n image_arrow.set_opacity(0)\n\n # --- Build Scene ---\n self.play(Create(principal_axis))\n self.play(Create(mirror))\n self.play(Create(point_f), Write(label_f), Create(point_c), Write(label_c))\n self.play(Create(object_arrow))\n self.wait(1)\n\n # --- Ray Tracing ---\n # Ray 1: Parallel -> Through F\n r1_start = object_arrow.get_end()\n r1_hit = ORIGIN + UP * obj_h # Hits mirror at y = obj_h\n r1_end = LEFT * f + DOWN * (obj_h / f) * f # Passes through F\n \n ray1_i = Line(r1_start, r1_hit, color=BLUE)\n ray1_r = Line(r1_hit, r1_end, color=BLUE)\n self.play(Create(ray1_i), run_time=1.5)\n self.play(Create(ray1_r), run_time=1.5)\n\n # Ray 2: Toward F -> Parallel\n r2_start = object_arrow.get_end()\n # Intersection of line (start to F) with mirror circle (x+3)^2 + y^2 = 9\n # Precalculated hit point for obj_h=1.5\n r2_hit = np.array([-0.08, -0.64, 0]) \n r2_end = LEFT * 7 + UP * r2_hit[1] # Horizontal reflection\n \n ray2_i = Line(r2_start, r2_hit, color=YELLOW)\n ray2_r = Line(r2_hit, r2_end, color=YELLOW)\n self.play(Create(ray2_i), run_time=1.5)\n self.play(Create(ray2_r), run_time=1.5)\n\n # Ray 3: Through C -> Back on itself\n r3_start = object_arrow.get_end()\n # Intersection of line (start to C) with mirror circle\n # Precalculated hit point for obj_h=1.5\n r3_hit = np.array([-0.6, -1.8, 0])\n \n ray3_i = Line(r3_start, r3_hit, color=MAGENTA)\n ray3_r = Line(r3_hit, r3_start, color=MAGENTA)\n self.play(Create(ray3_i), run_time=1.5)\n self.play(Create(ray3_r), run_time=1.5)\n\n # --- Image Formation ---\n intersection_point = LEFT * img_x + UP * img_h\n glow = Circle(radius=0.2, color=WHITE).move_to(intersection_point)\n \n self.play(Create(glow), run_time=0.5)\n self.play(FadeIn(image_arrow), FadeOut(glow), run_time=1.5)\n self.wait(2)\n\n # --- Conclusion: Fade Out ---\n all_elements = VGroup(\n principal_axis, mirror, \n point_f, label_f, point_c, label_c,\n object_arrow, image_arrow,\n ray1_i, ray1_r, ray2_i, ray2_r, ray3_i, ray3_r\n )\n \n self.play(FadeOut(all_elements), run_time=2)\n self.wait(1)\n```"}]}
{"id": "manim-sft-10k_003115", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "TrunkAccessConcepts", "num_animations": 11, "num_rich_primitives": 2, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00271", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0271", "num_animations": 21, "prompt": "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 educational animation that illustrates how to find the area under the curve of y = x^2 from x = 0 to x = 2, including both the visual representation of the graph and the integration steps to arrive at\n- Act 2: 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 3: I would like to create an educational math animation where we visualize the process of solving a double integral problem step-by-step. I want to start with the problem \"\\(\\int_{0}^{1} \\int_{0}^{1-x} e^{-(x+y)} dy\\,dx\\)\" ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0271(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_areaundercurve()\n self.clear_stage()\n self.act_2_matchwidthanimation()\n self.clear_stage()\n self.act_3_definiteintegral()\n\n def act_1_areaundercurve(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the Function y = x^2\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n func_label = axes.get_graph_label(curve, \"y = x^2\", x_val=1.5, direction=UR)\n\n # 3. Highlight the Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add a vertical line at x=2 to clearly mark the boundary\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n line_label = MathTex(\"x=2\").next_to(line_x2, DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\")\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT, buff=1)\n\n # 5. Animation Sequence\n # Draw axes and curve\n self.play(Create(axes), Create(curve), Write(func_label))\n self.wait(1)\n\n # Highlight the area and boundary\n self.play(FadeIn(area), Create(line_x2), Write(line_label))\n self.wait(1)\n\n # Display integration steps sequentially\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_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_3_definiteintegral(self):\n problem = MathTex(r\"\\int_{a}^{b} x dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explain the integral boundaries\n boundaries_explanation = Text(\"Evaluating from 'a' to 'b':\", font_size=24).to_edge(UP)\n self.play(Write(boundaries_explanation))\n self.wait(2)\n\n # Show fundamental theorem of calculus\n theorem = MathTex(r\"F(b) - F(a)\", \"=\", r\"\\left. \\frac{x^{n+1}}{n+1} \\right|_{a}^{b}\")\n self.play(Write(theorem))\n self.wait(2)\n\n # Perform the definite integral calculation\n solution = MathTex(r\"=\", r\"\\frac{b^2}{2}\", \"-\", r\"\\frac{a^2}{2}\")\n self.play(ReplacementTransform(problem.copy(), solution))\n self.wait(1)\n\n # Highlight the result\n highlight_box = SurroundingRectangle(solution[-2:], buff=.1)\n self.play(Create(highlight_box))\n self.wait(2)\n\n # Clear everything\n self.clear()\n self.wait(1)\n\n # Present the final result of the integral\n final_result = MathTex(r\"\\int_{a}^{b} x dx\", \"=\", r\"\\frac{b^2}{2} - \\frac{a^2}{2}\")\n self.play(Write(final_result))\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 educational animation that illustrates how to find the area under the curve of y = x^2 from x = 0 to x = 2, including both the visual representation of the graph and the integration steps to arrive at\n- Act 2: 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 3: I would like to create an educational math animation where we visualize the process of solving a double integral problem step-by-step. I want to start with the problem \"\\(\\int_{0}^{1} \\int_{0}^{1-x} e^{-(x+y)} dy\\,dx\\)\" "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0271(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_areaundercurve()\n self.clear_stage()\n self.act_2_matchwidthanimation()\n self.clear_stage()\n self.act_3_definiteintegral()\n\n def act_1_areaundercurve(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the Function y = x^2\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n func_label = axes.get_graph_label(curve, \"y = x^2\", x_val=1.5, direction=UR)\n\n # 3. Highlight the Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add a vertical line at x=2 to clearly mark the boundary\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n line_label = MathTex(\"x=2\").next_to(line_x2, DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\")\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT, buff=1)\n\n # 5. Animation Sequence\n # Draw axes and curve\n self.play(Create(axes), Create(curve), Write(func_label))\n self.wait(1)\n\n # Highlight the area and boundary\n self.play(FadeIn(area), Create(line_x2), Write(line_label))\n self.wait(1)\n\n # Display integration steps sequentially\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n def act_2_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_3_definiteintegral(self):\n problem = MathTex(r\"\\int_{a}^{b} x dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explain the integral boundaries\n boundaries_explanation = Text(\"Evaluating from 'a' to 'b':\", font_size=24).to_edge(UP)\n self.play(Write(boundaries_explanation))\n self.wait(2)\n\n # Show fundamental theorem of calculus\n theorem = MathTex(r\"F(b) - F(a)\", \"=\", r\"\\left. \\frac{x^{n+1}}{n+1} \\right|_{a}^{b}\")\n self.play(Write(theorem))\n self.wait(2)\n\n # Perform the definite integral calculation\n solution = MathTex(r\"=\", r\"\\frac{b^2}{2}\", \"-\", r\"\\frac{a^2}{2}\")\n self.play(ReplacementTransform(problem.copy(), solution))\n self.wait(1)\n\n # Highlight the result\n highlight_box = SurroundingRectangle(solution[-2:], buff=.1)\n self.play(Create(highlight_box))\n self.wait(2)\n\n # Clear everything\n self.clear()\n self.wait(1)\n\n # Present the final result of the integral\n final_result = MathTex(r\"\\int_{a}^{b} x dx\", \"=\", r\"\\frac{b^2}{2} - \\frac{a^2}{2}\")\n self.play(Write(final_result))\n self.wait(1)\n```"}]}
{"id": "bespoke-manim_000049", "source": "bespokelabs/bespoke-manim", "tier": 1, "scene_name": "GoldbachConjecture", "num_animations": 9, "num_rich_primitives": 1, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TaylorExpansionExp", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "QueueEmptyFullProblem", "num_animations": 6, "num_rich_primitives": 2, "prompt": "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", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_001259", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "ParametricSurfaceArea", "num_animations": 12, "num_rich_primitives": 3, "prompt": "Can you create an animated video that explains the process of finding the surface area of a parametric surface, including the formula for the surface integral and the steps to compute it?", "code": "from manim import *\nimport numpy as np\n\nclass ParametricSurfaceArea(ThreeDScene):\n def construct(self):\n # --- 1. Introduction and Formula ---\n title = Text(\"Surface Area of a Parametric Surface\", font_size=36)\n title.to_edge(UP)\n \n # Formula: A = \\iint_D || r_u x r_v || dA\n formula = MathTex(\n \"A\", \"=\", \"\\iint_D\", \"\\\\left\\\\|\", \n \"\\\\mathbf{r}_u\", \"\\\\times\", \"\\\\mathbf{r}_v\", \n \"\\\\right\\\\|\", \"\\\\,dA\"\n )\n formula.scale(1.2)\n formula.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.play(Write(formula))\n self.wait(2)\n\n # --- 2. Step-by-Step Procedure ---\n steps = VGroup(\n Text(\"1. Define Parametrization: $\\\\mathbf{r}(u, v)$\", font_size=24),\n Text(\"2. Compute Partial Derivatives: $\\\\mathbf{r}_u, \\\\mathbf{r}_v$\", font_size=24),\n Text(\"3. Calculate Cross Product: $\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v$\", font_size=24),\n Text(\"4. Find Magnitude: $\\\\|\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v\\\\|$\", font_size=24),\n Text(\"5. Evaluate Double Integral over Domain D\", font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n steps.to_edge(LEFT).shift(DOWN * 1.2)\n \n self.play(Write(steps))\n self.wait(2)\n \n # Transition to 3D\n self.play(FadeOut(title), FadeOut(formula), FadeOut(steps))\n self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)\n\n # --- 3. 3D Visualization Setup ---\n axes = ThreeDAxes(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n z_range=[0, 4, 1],\n x_length=4,\n y_length=4,\n z_length=3\n )\n \n # Define parametric surface: Paraboloid z = x^2 + y^2\n # r(u, v) = \n def surface_func(u, v):\n return np.array([u, v, u**2 + v**2])\n\n surface = Surface(\n surface_func,\n u_range=[-1.5, 1.5],\n v_range=[-1.5, 1.5],\n resolution=(25, 25),\n fill_opacity=0.5,\n fill_color=BLUE,\n stroke_width=1,\n stroke_color=BLUE_E\n )\n \n self.play(Create(axes), Create(surface))\n self.begin_ambient_camera_rotation(rate=0.15)\n self.wait(1)\n\n # --- 4. Geometric Intuition: Tangent Vectors ---\n # Pick a point (u, v) = (1, 1)\n u_val, v_val = 1, 1\n point = surface_func(u_val, v_val)\n dot = Dot3D(point, color=RED)\n \n # r_u = <1, 0, 2u>, r_v = <0, 1, 2v>\n ru = np.array([1, 0, 2 * u_val])\n rv = np.array([0, 1, 2 * v_val])\n \n vec_ru = Arrow3D(start=point, end=point + 0.5 * ru, color=GREEN)\n vec_rv = Arrow3D(start=point, end=point + 0.5 * rv, color=GOLD)\n \n label_ru = MathTex(\"\\\\mathbf{r}_u\").set_color(GREEN).next_to(vec_ru.get_end(), RIGHT)\n label_rv = MathTex(\"\\\\mathbf{r}_v\").set_color(GOLD).next_to(vec_rv.get_end(), UP)\n \n # Fix labels to camera frame so they are readable\n self.add_fixed_in_frame_mobjects(label_ru, label_rv)\n \n self.play(Create(dot))\n self.play(Create(vec_ru), Write(label_ru))\n self.play(Create(vec_rv), Write(label_rv))\n self.wait(1)\n\n # --- 5. Normal Vector (Cross Product) ---\n cross_prod = np.cross(ru, rv)\n vec_cross = Arrow3D(start=point, end=point + 0.3 * cross_prod, color=YELLOW)\n label_cross = MathTex(\"\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v\").set_color(YELLOW).next_to(vec_cross.get_end(), OUT)\n \n self.add_fixed_in_frame_mobjects(label_cross)\n self.play(Create(vec_cross), Write(label_cross))\n self.wait(1)\n\n # --- 6. Specific Mathematical Computation ---\n self.stop_ambient_camera_rotation()\n self.move_camera(phi=75 * DEGREES, theta=-45 * DEGREES)\n \n # Display the specific math for the paraboloid example\n example_math = VGroup(\n MathTex(\"\\\\mathbf{r}(u,v) = \\\\langle u, v, u^2 + v^2 \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_u = \\\\langle 1, 0, 2u \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_v = \\\\langle 0, 1, 2v \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v = \\\\langle -2u, -2v, 1 \\\\rangle\"),\n MathTex(\"\\\\| \\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v \\\\| = \\\\sqrt{4u^2 + 4v^2 + 1}\"),\n MathTex(\"A = \\\\iint_D \\\\sqrt{4u^2 + 4v^2 + 1} \\\\, du \\\\, dv\")\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n \n example_math.scale(0.7).to_corner(UR)\n \n # Fade 3D elements slightly to emphasize text\n self.play(\n surface.animate.set_opacity(0.2),\n axes.animate.set_opacity(0.2),\n dot.animate.set_opacity(0.2),\n vec_ru.animate.set_opacity(0.2),\n vec_rv.animate.set_opacity(0.2),\n vec_cross.animate.set_opacity(0.2)\n )\n \n self.add_fixed_in_frame_mobjects(example_math)\n self.play(Write(example_math))\n self.wait(3)\n\n # --- 7. Conclusion ---\n conclusion = Text(\"Surface Area Computed\", font_size=36, color=GREEN)\n conclusion.to_edge(DOWN)\n self.add_fixed_in_frame_mobjects(conclusion)\n self.play(Write(conclusion))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an animated video that explains the process of finding the surface area of a parametric surface, including the formula for the surface integral and the steps to compute it?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass ParametricSurfaceArea(ThreeDScene):\n def construct(self):\n # --- 1. Introduction and Formula ---\n title = Text(\"Surface Area of a Parametric Surface\", font_size=36)\n title.to_edge(UP)\n \n # Formula: A = \\iint_D || r_u x r_v || dA\n formula = MathTex(\n \"A\", \"=\", \"\\iint_D\", \"\\\\left\\\\|\", \n \"\\\\mathbf{r}_u\", \"\\\\times\", \"\\\\mathbf{r}_v\", \n \"\\\\right\\\\|\", \"\\\\,dA\"\n )\n formula.scale(1.2)\n formula.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.play(Write(formula))\n self.wait(2)\n\n # --- 2. Step-by-Step Procedure ---\n steps = VGroup(\n Text(\"1. Define Parametrization: $\\\\mathbf{r}(u, v)$\", font_size=24),\n Text(\"2. Compute Partial Derivatives: $\\\\mathbf{r}_u, \\\\mathbf{r}_v$\", font_size=24),\n Text(\"3. Calculate Cross Product: $\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v$\", font_size=24),\n Text(\"4. Find Magnitude: $\\\\|\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v\\\\|$\", font_size=24),\n Text(\"5. Evaluate Double Integral over Domain D\", font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n steps.to_edge(LEFT).shift(DOWN * 1.2)\n \n self.play(Write(steps))\n self.wait(2)\n \n # Transition to 3D\n self.play(FadeOut(title), FadeOut(formula), FadeOut(steps))\n self.set_camera_orientation(phi=75 * DEGREES, theta=-45 * DEGREES)\n\n # --- 3. 3D Visualization Setup ---\n axes = ThreeDAxes(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n z_range=[0, 4, 1],\n x_length=4,\n y_length=4,\n z_length=3\n )\n \n # Define parametric surface: Paraboloid z = x^2 + y^2\n # r(u, v) = \n def surface_func(u, v):\n return np.array([u, v, u**2 + v**2])\n\n surface = Surface(\n surface_func,\n u_range=[-1.5, 1.5],\n v_range=[-1.5, 1.5],\n resolution=(25, 25),\n fill_opacity=0.5,\n fill_color=BLUE,\n stroke_width=1,\n stroke_color=BLUE_E\n )\n \n self.play(Create(axes), Create(surface))\n self.begin_ambient_camera_rotation(rate=0.15)\n self.wait(1)\n\n # --- 4. Geometric Intuition: Tangent Vectors ---\n # Pick a point (u, v) = (1, 1)\n u_val, v_val = 1, 1\n point = surface_func(u_val, v_val)\n dot = Dot3D(point, color=RED)\n \n # r_u = <1, 0, 2u>, r_v = <0, 1, 2v>\n ru = np.array([1, 0, 2 * u_val])\n rv = np.array([0, 1, 2 * v_val])\n \n vec_ru = Arrow3D(start=point, end=point + 0.5 * ru, color=GREEN)\n vec_rv = Arrow3D(start=point, end=point + 0.5 * rv, color=GOLD)\n \n label_ru = MathTex(\"\\\\mathbf{r}_u\").set_color(GREEN).next_to(vec_ru.get_end(), RIGHT)\n label_rv = MathTex(\"\\\\mathbf{r}_v\").set_color(GOLD).next_to(vec_rv.get_end(), UP)\n \n # Fix labels to camera frame so they are readable\n self.add_fixed_in_frame_mobjects(label_ru, label_rv)\n \n self.play(Create(dot))\n self.play(Create(vec_ru), Write(label_ru))\n self.play(Create(vec_rv), Write(label_rv))\n self.wait(1)\n\n # --- 5. Normal Vector (Cross Product) ---\n cross_prod = np.cross(ru, rv)\n vec_cross = Arrow3D(start=point, end=point + 0.3 * cross_prod, color=YELLOW)\n label_cross = MathTex(\"\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v\").set_color(YELLOW).next_to(vec_cross.get_end(), OUT)\n \n self.add_fixed_in_frame_mobjects(label_cross)\n self.play(Create(vec_cross), Write(label_cross))\n self.wait(1)\n\n # --- 6. Specific Mathematical Computation ---\n self.stop_ambient_camera_rotation()\n self.move_camera(phi=75 * DEGREES, theta=-45 * DEGREES)\n \n # Display the specific math for the paraboloid example\n example_math = VGroup(\n MathTex(\"\\\\mathbf{r}(u,v) = \\\\langle u, v, u^2 + v^2 \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_u = \\\\langle 1, 0, 2u \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_v = \\\\langle 0, 1, 2v \\\\rangle\"),\n MathTex(\"\\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v = \\\\langle -2u, -2v, 1 \\\\rangle\"),\n MathTex(\"\\\\| \\\\mathbf{r}_u \\\\times \\\\mathbf{r}_v \\\\| = \\\\sqrt{4u^2 + 4v^2 + 1}\"),\n MathTex(\"A = \\\\iint_D \\\\sqrt{4u^2 + 4v^2 + 1} \\\\, du \\\\, dv\")\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n \n example_math.scale(0.7).to_corner(UR)\n \n # Fade 3D elements slightly to emphasize text\n self.play(\n surface.animate.set_opacity(0.2),\n axes.animate.set_opacity(0.2),\n dot.animate.set_opacity(0.2),\n vec_ru.animate.set_opacity(0.2),\n vec_rv.animate.set_opacity(0.2),\n vec_cross.animate.set_opacity(0.2)\n )\n \n self.add_fixed_in_frame_mobjects(example_math)\n self.play(Write(example_math))\n self.wait(3)\n\n # --- 7. Conclusion ---\n conclusion = Text(\"Surface Area Computed\", font_size=36, color=GREEN)\n conclusion.to_edge(DOWN)\n self.add_fixed_in_frame_mobjects(conclusion)\n self.play(Write(conclusion))\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_005418", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "TripleIntegralSolution", "num_animations": 12, "num_rich_primitives": 2, "prompt": "I would like an animated video that explains how to solve a triple integral, step by step, using a specific example of integrating the function xyz over the unit cube with bounds from 0 to 1. The animation should include on-screen text guiding through each step of the integration: first integrating with respect to z, then y, and finally x, showing the evaluated antiderivatives and results after each integration. After the calculation, display the final numerical answer clearly. The explanations should appear at the top of the screen and the mathematical steps should be shown in the center. Please ensure that each step is presented in a clear and easy-to-understand manner, and let there be pauses between steps so the viewer can follow along.", "code": "from manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Configuration\n text_font_size = 36\n math_font_size = 48\n wait_time = 2.0\n \n # --- Initial State ---\n header = Text(\"Evaluate: \\int \\int \\int xyz dV over Unit Cube [0,1]^3\", font_size=text_font_size)\n header.to_edge(UP)\n \n current_math = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Write(header), Write(current_math))\n self.wait(wait_time)\n \n # --- Step 1: Integrate with respect to z ---\n step1_header = Text(\"Step 1: Integrate with respect to z\", font_size=text_font_size, color=BLUE)\n step1_header.to_edge(UP)\n \n step1_antiderivative = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{xyz^2}{2} \\right]_{z=0}^{z=1} \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step1_header))\n self.play(TransformMatchingTex(current_math, step1_antiderivative))\n self.wait(wait_time)\n \n step1_result = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{xy}{2} \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step1_antiderivative, step1_result))\n self.wait(wait_time)\n \n current_math = step1_result\n \n # --- Step 2: Integrate with respect to y ---\n step2_header = Text(\"Step 2: Integrate with respect to y\", font_size=text_font_size, color=GREEN)\n step2_header.to_edge(UP)\n \n step2_antiderivative = MathTex(\n r\"\\int_0^1 \\left[ \\frac{xy^2}{4} \\right]_{y=0}^{y=1} \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step2_header))\n self.play(TransformMatchingTex(current_math, step2_antiderivative))\n self.wait(wait_time)\n \n step2_result = MathTex(\n r\"\\int_0^1 \\frac{x}{4} \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step2_antiderivative, step2_result))\n self.wait(wait_time)\n \n current_math = step2_result\n \n # --- Step 3: Integrate with respect to x ---\n step3_header = Text(\"Step 3: Integrate with respect to x\", font_size=text_font_size, color=YELLOW)\n step3_header.to_edge(UP)\n \n step3_antiderivative = MathTex(\n r\"\\left[ \\frac{x^2}{8} \\right]_{x=0}^{x=1}\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step3_header))\n self.play(TransformMatchingTex(current_math, step3_antiderivative))\n self.wait(wait_time)\n \n final_result = MathTex(\n r\"\\frac{1}{8}\",\n font_size=60,\n color=GOLD\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step3_antiderivative, final_result))\n self.wait(wait_time)\n \n # --- Final Summary ---\n summary_header = Text(\"Final Solution\", font_size=text_font_size, color=YELLOW)\n summary_header.to_edge(UP)\n \n summary_equation = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx = \\frac{1}{8}\",\n font_size=math_font_size,\n color=GREEN\n ).move_to(ORIGIN)\n \n self.play(Transform(header, summary_header))\n self.play(ReplacementTransform(final_result, summary_equation))\n self.wait(3.0)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like an animated video that explains how to solve a triple integral, step by step, using a specific example of integrating the function xyz over the unit cube with bounds from 0 to 1. The animation should include on-screen text guiding through each step of the integration: first integrating with respect to z, then y, and finally x, showing the evaluated antiderivatives and results after each integration. After the calculation, display the final numerical answer clearly. The explanations should appear at the top of the screen and the mathematical steps should be shown in the center. Please ensure that each step is presented in a clear and easy-to-understand manner, and let there be pauses between steps so the viewer can follow along."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Configuration\n text_font_size = 36\n math_font_size = 48\n wait_time = 2.0\n \n # --- Initial State ---\n header = Text(\"Evaluate: \\int \\int \\int xyz dV over Unit Cube [0,1]^3\", font_size=text_font_size)\n header.to_edge(UP)\n \n current_math = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Write(header), Write(current_math))\n self.wait(wait_time)\n \n # --- Step 1: Integrate with respect to z ---\n step1_header = Text(\"Step 1: Integrate with respect to z\", font_size=text_font_size, color=BLUE)\n step1_header.to_edge(UP)\n \n step1_antiderivative = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{xyz^2}{2} \\right]_{z=0}^{z=1} \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step1_header))\n self.play(TransformMatchingTex(current_math, step1_antiderivative))\n self.wait(wait_time)\n \n step1_result = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{xy}{2} \\, dy \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step1_antiderivative, step1_result))\n self.wait(wait_time)\n \n current_math = step1_result\n \n # --- Step 2: Integrate with respect to y ---\n step2_header = Text(\"Step 2: Integrate with respect to y\", font_size=text_font_size, color=GREEN)\n step2_header.to_edge(UP)\n \n step2_antiderivative = MathTex(\n r\"\\int_0^1 \\left[ \\frac{xy^2}{4} \\right]_{y=0}^{y=1} \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step2_header))\n self.play(TransformMatchingTex(current_math, step2_antiderivative))\n self.wait(wait_time)\n \n step2_result = MathTex(\n r\"\\int_0^1 \\frac{x}{4} \\, dx\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step2_antiderivative, step2_result))\n self.wait(wait_time)\n \n current_math = step2_result\n \n # --- Step 3: Integrate with respect to x ---\n step3_header = Text(\"Step 3: Integrate with respect to x\", font_size=text_font_size, color=YELLOW)\n step3_header.to_edge(UP)\n \n step3_antiderivative = MathTex(\n r\"\\left[ \\frac{x^2}{8} \\right]_{x=0}^{x=1}\",\n font_size=math_font_size\n ).move_to(ORIGIN)\n \n self.play(Transform(header, step3_header))\n self.play(TransformMatchingTex(current_math, step3_antiderivative))\n self.wait(wait_time)\n \n final_result = MathTex(\n r\"\\frac{1}{8}\",\n font_size=60,\n color=GOLD\n ).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(step3_antiderivative, final_result))\n self.wait(wait_time)\n \n # --- Final Summary ---\n summary_header = Text(\"Final Solution\", font_size=text_font_size, color=YELLOW)\n summary_header.to_edge(UP)\n \n summary_equation = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx = \\frac{1}{8}\",\n font_size=math_font_size,\n color=GREEN\n ).move_to(ORIGIN)\n \n self.play(Transform(header, summary_header))\n self.play(ReplacementTransform(final_result, summary_equation))\n self.wait(3.0)\n```"}]}
{"id": "adaption-unified-manim-instructions_000176", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSine", "num_animations": 16, "num_rich_primitives": 2, "prompt": "I would like an animated video that explains the process of integrating \\(\\sin(x)\\) from \\(0\\) to \\(\\pi\\), including the use of trigonometric identities and the evaluation of the definite integral, with the final answer displayed at the end. Can you create an animation that writes out the problem, provides a brief written explanation of the steps involved in solving it, shows the integration step where the trigonometric identity is used, and then evaluates the definite integral with the final solution appearing at the end? Please also make sure there is enough time for viewers to follow along with each step before moving on to the next.", "code": "from manim import *\n\nclass IntegrateSine(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Problem Statement\n # ------------------------------------------------------------------\n # Set up the title to frame the video\n title = Tex(\"Integrating $\\\\sin(x)$ from $0$ to $\\\\pi$\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(1)\n\n # Animate writing the integral problem\n problem = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\", font_size=60)\n problem.next_to(title, DOWN, buff=1)\n self.play(Write(problem), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 2. Step-by-Step Explanation: The Antiderivative\n # ------------------------------------------------------------------\n # Explain the rule used to integrate sine\n step1_text = Text(\"Step 1: Find the antiderivative\", color=BLUE)\n step1_text.next_to(problem, DOWN, buff=0.8)\n self.play(FadeIn(step1_text), run_time=1.5)\n self.wait(1)\n\n # Explicitly visualize the trigonometric identity / derivative rule\n identity = MathTex(r\"\\frac{d}{dx}(-\\cos(x)) = \\sin(x)\", color=GREEN)\n identity.next_to(step1_text, DOWN, buff=0.5)\n self.play(Write(identity), run_time=2)\n self.wait(3) # Pause for viewer to read the identity\n\n # ------------------------------------------------------------------\n # 3. Integration Step\n # ------------------------------------------------------------------\n # Clean up helper text to make room for the working steps\n self.play(FadeOut(step1_text), FadeOut(identity))\n\n # Show the application of the identity to the definite integral\n integration_step = MathTex(r\"= \\left[ -\\cos(x) \\right]_{0}^{\\pi}\", font_size=60)\n integration_step.next_to(problem, RIGHT, buff=0.5).align_to(problem, DOWN)\n self.play(Write(integration_step), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 4. Evaluation Step (Fundamental Theorem of Calculus)\n # ------------------------------------------------------------------\n step2_text = Text(\"Step 2: Evaluate using the Fundamental Theorem of Calculus\", color=YELLOW)\n step2_text.next_to(problem, DOWN, buff=0.8)\n self.play(FadeIn(step2_text), run_time=1.5)\n self.wait(2)\n\n # Show the substitution of limits: F(pi) - F(0)\n eval_step1 = MathTex(r\"= \\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\", font_size=60)\n eval_step1.next_to(integration_step, DOWN, buff=0.5).align_to(integration_step, LEFT)\n self.play(Write(eval_step1), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 5. Simplification\n # ------------------------------------------------------------------\n step3_text = Text(\"Step 3: Substitute trigonometric values\", color=BLUE)\n step3_text.next_to(step2_text, DOWN, buff=0.3)\n self.play(FadeIn(step3_text), run_time=1.5)\n self.wait(1)\n\n # Evaluating cos(pi) = -1 and cos(0) = 1\n eval_step2 = MathTex(r\"= -(-1) - (-1)\", font_size=60)\n eval_step2.next_to(eval_step1, DOWN, buff=0.5).align_to(eval_step1, LEFT)\n self.play(Write(eval_step2), run_time=2)\n self.wait(2)\n\n # Final arithmetic\n eval_step3 = MathTex(r\"= 1 + 1\", font_size=60)\n eval_step3.next_to(eval_step2, DOWN, buff=0.5).align_to(eval_step2, LEFT)\n self.play(Write(eval_step3), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Result\n # ------------------------------------------------------------------\n # Display the final answer clearly with emphasis\n final_answer = MathTex(r\"= 2\", font_size=80, color=GOLD)\n final_answer.next_to(eval_step3, DOWN, buff=0.5).align_to(eval_step3, LEFT)\n \n final_result_box = SurroundingRectangle(final_answer, color=YELLOW, buff=0.2)\n \n self.play(Write(final_answer), run_time=2)\n self.play(Create(final_result_box))\n self.wait(2)\n\n # Transition to a concluding summary screen\n summary = MathTex(\n r\"\\int_{0}^{\\pi} \\sin(x) \\, dx = 2\", \n font_size=70, \n color=YELLOW\n )\n \n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(integration_step),\n FadeOut(step2_text),\n FadeOut(step3_text),\n FadeOut(eval_step1),\n FadeOut(eval_step2),\n FadeOut(eval_step3),\n FadeOut(final_answer),\n FadeOut(final_result_box),\n run_time=2\n )\n \n self.play(Write(summary))\n self.play(Indicate(summary))\n self.wait(4)\n\n# To run this code:\n# 1. Install manim: pip install manim\n# 2. Run via command line: manim -pql script_name.py IntegrateSine", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like an animated video that explains the process of integrating \\(\\sin(x)\\) from \\(0\\) to \\(\\pi\\), including the use of trigonometric identities and the evaluation of the definite integral, with the final answer displayed at the end. Can you create an animation that writes out the problem, provides a brief written explanation of the steps involved in solving it, shows the integration step where the trigonometric identity is used, and then evaluates the definite integral with the final solution appearing at the end? Please also make sure there is enough time for viewers to follow along with each step before moving on to the next."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegrateSine(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Problem Statement\n # ------------------------------------------------------------------\n # Set up the title to frame the video\n title = Tex(\"Integrating $\\\\sin(x)$ from $0$ to $\\\\pi$\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(1)\n\n # Animate writing the integral problem\n problem = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\", font_size=60)\n problem.next_to(title, DOWN, buff=1)\n self.play(Write(problem), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 2. Step-by-Step Explanation: The Antiderivative\n # ------------------------------------------------------------------\n # Explain the rule used to integrate sine\n step1_text = Text(\"Step 1: Find the antiderivative\", color=BLUE)\n step1_text.next_to(problem, DOWN, buff=0.8)\n self.play(FadeIn(step1_text), run_time=1.5)\n self.wait(1)\n\n # Explicitly visualize the trigonometric identity / derivative rule\n identity = MathTex(r\"\\frac{d}{dx}(-\\cos(x)) = \\sin(x)\", color=GREEN)\n identity.next_to(step1_text, DOWN, buff=0.5)\n self.play(Write(identity), run_time=2)\n self.wait(3) # Pause for viewer to read the identity\n\n # ------------------------------------------------------------------\n # 3. Integration Step\n # ------------------------------------------------------------------\n # Clean up helper text to make room for the working steps\n self.play(FadeOut(step1_text), FadeOut(identity))\n\n # Show the application of the identity to the definite integral\n integration_step = MathTex(r\"= \\left[ -\\cos(x) \\right]_{0}^{\\pi}\", font_size=60)\n integration_step.next_to(problem, RIGHT, buff=0.5).align_to(problem, DOWN)\n self.play(Write(integration_step), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 4. Evaluation Step (Fundamental Theorem of Calculus)\n # ------------------------------------------------------------------\n step2_text = Text(\"Step 2: Evaluate using the Fundamental Theorem of Calculus\", color=YELLOW)\n step2_text.next_to(problem, DOWN, buff=0.8)\n self.play(FadeIn(step2_text), run_time=1.5)\n self.wait(2)\n\n # Show the substitution of limits: F(pi) - F(0)\n eval_step1 = MathTex(r\"= \\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\", font_size=60)\n eval_step1.next_to(integration_step, DOWN, buff=0.5).align_to(integration_step, LEFT)\n self.play(Write(eval_step1), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 5. Simplification\n # ------------------------------------------------------------------\n step3_text = Text(\"Step 3: Substitute trigonometric values\", color=BLUE)\n step3_text.next_to(step2_text, DOWN, buff=0.3)\n self.play(FadeIn(step3_text), run_time=1.5)\n self.wait(1)\n\n # Evaluating cos(pi) = -1 and cos(0) = 1\n eval_step2 = MathTex(r\"= -(-1) - (-1)\", font_size=60)\n eval_step2.next_to(eval_step1, DOWN, buff=0.5).align_to(eval_step1, LEFT)\n self.play(Write(eval_step2), run_time=2)\n self.wait(2)\n\n # Final arithmetic\n eval_step3 = MathTex(r\"= 1 + 1\", font_size=60)\n eval_step3.next_to(eval_step2, DOWN, buff=0.5).align_to(eval_step2, LEFT)\n self.play(Write(eval_step3), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Result\n # ------------------------------------------------------------------\n # Display the final answer clearly with emphasis\n final_answer = MathTex(r\"= 2\", font_size=80, color=GOLD)\n final_answer.next_to(eval_step3, DOWN, buff=0.5).align_to(eval_step3, LEFT)\n \n final_result_box = SurroundingRectangle(final_answer, color=YELLOW, buff=0.2)\n \n self.play(Write(final_answer), run_time=2)\n self.play(Create(final_result_box))\n self.wait(2)\n\n # Transition to a concluding summary screen\n summary = MathTex(\n r\"\\int_{0}^{\\pi} \\sin(x) \\, dx = 2\", \n font_size=70, \n color=YELLOW\n )\n \n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(integration_step),\n FadeOut(step2_text),\n FadeOut(step3_text),\n FadeOut(eval_step1),\n FadeOut(eval_step2),\n FadeOut(eval_step3),\n FadeOut(final_answer),\n FadeOut(final_result_box),\n run_time=2\n )\n \n self.play(Write(summary))\n self.play(Indicate(summary))\n self.wait(4)\n\n# To run this code:\n# 1. Install manim: pip install manim\n# 2. Run via command line: manim -pql script_name.py IntegrateSine\n```"}]}
{"id": "manim-sft-10k_003235", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "CombinedLossScene", "num_animations": 8, "num_rich_primitives": 4, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00479", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0479", "num_animations": 19, "prompt": "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 is the enhanced animation description that builds upon the original while adding significant new features:\n- Act 2: Create a 15-second materials-science scene explaining the difference between elastic and plastic deformation on a stress-strain curve. Reveal the linear elastic region, mark the yield point, continue into plastic deforma\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:", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0479(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_lineartransformationscen()\n self.clear_stage()\n self.act_2_stressstrainyield()\n self.clear_stage()\n self.act_3_enhancedgrowarrow()\n\n def act_1_lineartransformationscen(self):\n line = Line(LEFT*3, RIGHT*3, color=PURPLE)\n equation = MathTex(\"y = 0\", color=PURPLE).next_to(line, DOWN)\n\n # Create axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-3, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n \n # Fade in coordinate system\n self.play(\n FadeIn(axes),\n Write(axes_labels),\n run_time=1\n )\n self.wait(0.5)\n \n # Transform line and equation\n new_line = line.copy().shift(UP*2)\n new_equation = MathTex(\"y = 2\", color=PURPLE).next_to(new_line, DOWN)\n dashed_line = DashedLine(LEFT*3, RIGHT*3, color=GRAY)\n vertical_line = Line(DOWN*2, UP*2, color=GREEN).shift(LEFT*3)\n \n self.play(\n Transform(line, new_line),\n Transform(equation, new_equation),\n Create(dashed_line),\n Create(vertical_line),\n run_time=2\n )\n self.wait()\n \n # Final pulse effect\n for mobj in [line, equation, axes, axes_labels, dashed_line, vertical_line]:\n self.play(\n mobj.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n mobj.animate.scale(1/1.1),\n run_time=0.5\n )\n \n self.wait(2)\n\n def act_2_stressstrainyield(self):\n title = Text(\"Yield separates recoverable and permanent deformation\", font_size=35).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 6, 1], x_length=7.4, y_length=4.7, tips=False).shift(LEFT * 0.7 + DOWN * 0.2)\n labels = axes.get_axis_labels(Text(\"strain\", font_size=22), Text(\"stress\", font_size=22))\n elastic = Line(axes.c2p(0, 0), axes.c2p(2, 4), color=BLUE_B)\n plastic = VMobject(color=ORANGE).set_points_smoothly([\n axes.c2p(2, 4), axes.c2p(3, 4.8), axes.c2p(4.5, 5.2), axes.c2p(5.5, 5.35)\n ])\n yield_dot = Dot(axes.c2p(2, 4), color=YELLOW)\n yield_label = Text(\"yield\", font_size=22, color=YELLOW).next_to(yield_dot, UL)\n probe = Dot(axes.c2p(0, 0), color=WHITE)\n load_path = VMobject(stroke_opacity=0).set_points_as_corners([axes.c2p(0, 0), axes.c2p(2, 4), axes.c2p(4.5, 5.2)])\n unload = Arrow(axes.c2p(4.5, 5.2), axes.c2p(2.0, 0), color=TEAL_B, buff=0)\n residual = BraceBetweenPoints(axes.c2p(0, -0.3), axes.c2p(2.0, -0.3), color=TEAL_B)\n residual_label = Text(\"permanent strain\", font_size=21, color=TEAL_B).next_to(residual, UP, buff=0.05)\n caption = Text(\"Below yield: elastic return. Beyond yield: a residual strain remains.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(axes), FadeIn(labels))\n self.play(Create(elastic), MoveAlongPath(probe, elastic), run_time=2)\n self.play(FadeIn(yield_dot, yield_label), Flash(yield_dot, color=YELLOW))\n self.play(Create(plastic), MoveAlongPath(probe, plastic), run_time=2.5)\n self.play(GrowArrow(unload), probe.animate.move_to(axes.c2p(2.0, 0)), run_time=2)\n self.play(GrowFromCenter(residual), FadeIn(residual_label, caption))\n self.wait(2)\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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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 is the enhanced animation description that builds upon the original while adding significant new features:\n- Act 2: Create a 15-second materials-science scene explaining the difference between elastic and plastic deformation on a stress-strain curve. Reveal the linear elastic region, mark the yield point, continue into plastic deforma\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_0479(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_lineartransformationscen()\n self.clear_stage()\n self.act_2_stressstrainyield()\n self.clear_stage()\n self.act_3_enhancedgrowarrow()\n\n def act_1_lineartransformationscen(self):\n line = Line(LEFT*3, RIGHT*3, color=PURPLE)\n equation = MathTex(\"y = 0\", color=PURPLE).next_to(line, DOWN)\n\n # Create axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-3, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n \n # Fade in coordinate system\n self.play(\n FadeIn(axes),\n Write(axes_labels),\n run_time=1\n )\n self.wait(0.5)\n \n # Transform line and equation\n new_line = line.copy().shift(UP*2)\n new_equation = MathTex(\"y = 2\", color=PURPLE).next_to(new_line, DOWN)\n dashed_line = DashedLine(LEFT*3, RIGHT*3, color=GRAY)\n vertical_line = Line(DOWN*2, UP*2, color=GREEN).shift(LEFT*3)\n \n self.play(\n Transform(line, new_line),\n Transform(equation, new_equation),\n Create(dashed_line),\n Create(vertical_line),\n run_time=2\n )\n self.wait()\n \n # Final pulse effect\n for mobj in [line, equation, axes, axes_labels, dashed_line, vertical_line]:\n self.play(\n mobj.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n mobj.animate.scale(1/1.1),\n run_time=0.5\n )\n \n self.wait(2)\n\n def act_2_stressstrainyield(self):\n title = Text(\"Yield separates recoverable and permanent deformation\", font_size=35).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 6, 1], x_length=7.4, y_length=4.7, tips=False).shift(LEFT * 0.7 + DOWN * 0.2)\n labels = axes.get_axis_labels(Text(\"strain\", font_size=22), Text(\"stress\", font_size=22))\n elastic = Line(axes.c2p(0, 0), axes.c2p(2, 4), color=BLUE_B)\n plastic = VMobject(color=ORANGE).set_points_smoothly([\n axes.c2p(2, 4), axes.c2p(3, 4.8), axes.c2p(4.5, 5.2), axes.c2p(5.5, 5.35)\n ])\n yield_dot = Dot(axes.c2p(2, 4), color=YELLOW)\n yield_label = Text(\"yield\", font_size=22, color=YELLOW).next_to(yield_dot, UL)\n probe = Dot(axes.c2p(0, 0), color=WHITE)\n load_path = VMobject(stroke_opacity=0).set_points_as_corners([axes.c2p(0, 0), axes.c2p(2, 4), axes.c2p(4.5, 5.2)])\n unload = Arrow(axes.c2p(4.5, 5.2), axes.c2p(2.0, 0), color=TEAL_B, buff=0)\n residual = BraceBetweenPoints(axes.c2p(0, -0.3), axes.c2p(2.0, -0.3), color=TEAL_B)\n residual_label = Text(\"permanent strain\", font_size=21, color=TEAL_B).next_to(residual, UP, buff=0.05)\n caption = Text(\"Below yield: elastic return. Beyond yield: a residual strain remains.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(axes), FadeIn(labels))\n self.play(Create(elastic), MoveAlongPath(probe, elastic), run_time=2)\n self.play(FadeIn(yield_dot, yield_label), Flash(yield_dot, color=YELLOW))\n self.play(Create(plastic), MoveAlongPath(probe, plastic), run_time=2.5)\n self.play(GrowArrow(unload), probe.animate.move_to(axes.c2p(2.0, 0)), run_time=2)\n self.play(GrowFromCenter(residual), FadeIn(residual_label, caption))\n self.wait(2)\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": "adaption-unified-manim-instructions_001455", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "PowersOfTwo", "num_animations": 7, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_007828", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "AreaUnderCurve", "num_animations": 11, "num_rich_primitives": 3, "prompt": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene.", "code": "from manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Axes\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).add_coordinates()\n \n # Add axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # 2. Plot the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 2.5])\n func_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.5)\n\n # 3. Shade the region 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 area_label = MathTex(r\"\\text{Area}\", color=GREEN).next_to(area, RIGHT, buff=0.2)\n\n # 4. Prepare Calculation Steps\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").scale(1.1)\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").scale(1.1)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").scale(1.1)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\").scale(1.1)\n result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW).scale(1.1)\n\n # Group and align calculation steps to the right\n calculation_group = VGroup(integral_expr, step1, step2, step3, result)\n calculation_group.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n calculation_group.to_edge(RIGHT, buff=1.5).shift(UP * 1.5)\n\n # Group all visual elements for final fade out\n all_elements = VGroup(\n axes, labels, graph, func_label, area, area_label, calculation_group\n )\n\n # --- Animation Sequence ---\n\n # Introduce coordinate system and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(func_label))\n self.wait(0.5)\n\n # Reveal the shaded area under the curve\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # Display the integral notation\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Show the step-by-step calculation\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(1)\n\n # Highlight the final numerical result\n self.play(Write(result))\n self.play(Indicate(result))\n self.wait(1)\n\n # Clear statement of the final result\n conclusion = Text(\"The area under the curve is 8/3.\", font_size=36)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Fade out all elements from the scene\n self.play(FadeOut(all_elements), FadeOut(conclusion))\n self.wait(0.5)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that visually demonstrates the concept of finding the area under a curve, specifically the area under the graph of \\(x^2\\) from 0 to 2, and also show the calculation of the definite integral of \\(x^2\\) from 0 to 2 using ManimCE? The animation should include the graph of the function, the shaded area under the curve, the step-by-step integral calculation, and finally display the numerical value of the area. Also, ensure that the elements are introduced in a sequence that aids understanding and that there is a clear statement of the final result. After the conclusion, please fade out all elements from the scene."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Axes\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).add_coordinates()\n \n # Add axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # 2. Plot the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 2.5])\n func_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.5)\n\n # 3. Shade the region 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 area_label = MathTex(r\"\\text{Area}\", color=GREEN).next_to(area, RIGHT, buff=0.2)\n\n # 4. Prepare Calculation Steps\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").scale(1.1)\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").scale(1.1)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").scale(1.1)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\").scale(1.1)\n result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW).scale(1.1)\n\n # Group and align calculation steps to the right\n calculation_group = VGroup(integral_expr, step1, step2, step3, result)\n calculation_group.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n calculation_group.to_edge(RIGHT, buff=1.5).shift(UP * 1.5)\n\n # Group all visual elements for final fade out\n all_elements = VGroup(\n axes, labels, graph, func_label, area, area_label, calculation_group\n )\n\n # --- Animation Sequence ---\n\n # Introduce coordinate system and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(func_label))\n self.wait(0.5)\n\n # Reveal the shaded area under the curve\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # Display the integral notation\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Show the step-by-step calculation\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(1)\n\n # Highlight the final numerical result\n self.play(Write(result))\n self.play(Indicate(result))\n self.wait(1)\n\n # Clear statement of the final result\n conclusion = Text(\"The area under the curve is 8/3.\", font_size=36)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Fade out all elements from the scene\n self.play(FadeOut(all_elements), FadeOut(conclusion))\n self.wait(0.5)\n```"}]}
{"id": "manim-sft-10k_000337", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "PercentageScalingAnimation", "num_animations": 7, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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 )", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00741", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0741", "num_animations": 19, "prompt": "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: 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 2: Could you create an animated video that explains the process of solving the integral of sin(x) cos(x) with respect to x using the substitution method? In the video, first display the integral, then add text about using t", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0741(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_marxistphilosophy()\n self.clear_stage()\n self.act_2_integralsubstitution()\n\n def act_1_marxistphilosophy(self):\n title = Text('Revolutionary Transformation in Marxist Philosophy', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.8)\n title_underline = Underline(title, color=YELLOW)\n self.play(Write(title))\n self.play(Create(title_underline))\n self.wait(1)\n point1 = Text('1. Shift in Philosophical Subject:', font_size=36, color=BLUE_C)\n point1.next_to(title_underline, DOWN, buff=1.2)\n self.play(FadeIn(point1, shift=UP * 0.3))\n self.wait(1)\n abstract_man = Text('Abstract Man', font_size=36, color=RED_C)\n real_man = Text('Real Man', font_size=36, color=GREEN_C)\n abstract_man.move_to(LEFT * 3.5 + DOWN * 1)\n real_man.move_to(RIGHT * 3.5 + DOWN * 1)\n arrow = Arrow(start=abstract_man.get_right(), end=real_man.get_left(), color=WHITE, buff=0.3, stroke_width=6, max_tip_length_to_length_ratio=0.15)\n self.play(Write(abstract_man))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(real_man))\n self.wait(1)\n shift_group = VGroup(abstract_man, arrow, real_man)\n highlight_box = SurroundingRectangle(shift_group, color=YELLOW, buff=0.5, corner_radius=0.2)\n self.play(Create(highlight_box))\n self.wait(3)\n self.play(FadeOut(title), FadeOut(title_underline), FadeOut(point1), FadeOut(shift_group), FadeOut(highlight_box))\n self.wait(1)\n\n def act_2_integralsubstitution(self):\n original_integral = MathTex(r\"\\int \\sin(x)\\cos(x) \\, dx\")\n original_integral.scale(1.5)\n self.play(Write(original_integral))\n self.wait(1)\n\n # Step 2: Add text at the top of the screen stating: \"Using the Substitution Method\"\n title = Text(\"Using the Substitution Method\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # Step 3: Explicitly show the chosen substitution variables\n substitution = VGroup(\n MathTex(r\"u = \\sin(x)\"),\n MathTex(r\"du = \\cos(x) \\, dx\")\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n sub_box = SurroundingRectangle(substitution, color=BLUE, buff=0.3)\n \n self.play(Write(substitution), Create(sub_box))\n self.wait(2)\n\n # Step 4: Rewrite the integral entirely in terms of u\n integral_u = MathTex(r\"\\int u \\, du\")\n self.play(ReplacementTransform(original_integral, integral_u))\n self.wait(2)\n\n # Step 5: Solve the simplified integral\n solved_u = MathTex(r\"= \\frac{1}{2}u^2 + C\")\n solved_u.next_to(integral_u, RIGHT)\n self.play(Write(solved_u))\n self.wait(2)\n\n # Step 6: Perform back-substitution to express the final answer in terms of x\n solved_x = MathTex(r\"= \\frac{1}{2}\\sin^2(x) + C\")\n self.play(ReplacementTransform(solved_u, solved_x))\n self.wait(3)\n\n # Step 7: Clear the screen completely\n all_mobs = VGroup(title, substitution, sub_box, integral_u, solved_x)\n self.play(FadeOut(all_mobs))\n self.wait(1)\n\n # Step 8: Display only the final solved integral\n final_result = MathTex(\n r\"\\int \\sin(x)\\cos(x) \\, dx = \\frac{1}{2}\\sin^2(x) + C\",\n font_size=48\n )\n self.play(Write(final_result))\n self.play(final_result.animate.set_color(YELLOW))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 2: Could you create an animated video that explains the process of solving the integral of sin(x) cos(x) with respect to x using the substitution method? In the video, first display the integral, then add text about using t"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0741(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_marxistphilosophy()\n self.clear_stage()\n self.act_2_integralsubstitution()\n\n def act_1_marxistphilosophy(self):\n title = Text('Revolutionary Transformation in Marxist Philosophy', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.8)\n title_underline = Underline(title, color=YELLOW)\n self.play(Write(title))\n self.play(Create(title_underline))\n self.wait(1)\n point1 = Text('1. Shift in Philosophical Subject:', font_size=36, color=BLUE_C)\n point1.next_to(title_underline, DOWN, buff=1.2)\n self.play(FadeIn(point1, shift=UP * 0.3))\n self.wait(1)\n abstract_man = Text('Abstract Man', font_size=36, color=RED_C)\n real_man = Text('Real Man', font_size=36, color=GREEN_C)\n abstract_man.move_to(LEFT * 3.5 + DOWN * 1)\n real_man.move_to(RIGHT * 3.5 + DOWN * 1)\n arrow = Arrow(start=abstract_man.get_right(), end=real_man.get_left(), color=WHITE, buff=0.3, stroke_width=6, max_tip_length_to_length_ratio=0.15)\n self.play(Write(abstract_man))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(real_man))\n self.wait(1)\n shift_group = VGroup(abstract_man, arrow, real_man)\n highlight_box = SurroundingRectangle(shift_group, color=YELLOW, buff=0.5, corner_radius=0.2)\n self.play(Create(highlight_box))\n self.wait(3)\n self.play(FadeOut(title), FadeOut(title_underline), FadeOut(point1), FadeOut(shift_group), FadeOut(highlight_box))\n self.wait(1)\n\n def act_2_integralsubstitution(self):\n original_integral = MathTex(r\"\\int \\sin(x)\\cos(x) \\, dx\")\n original_integral.scale(1.5)\n self.play(Write(original_integral))\n self.wait(1)\n\n # Step 2: Add text at the top of the screen stating: \"Using the Substitution Method\"\n title = Text(\"Using the Substitution Method\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # Step 3: Explicitly show the chosen substitution variables\n substitution = VGroup(\n MathTex(r\"u = \\sin(x)\"),\n MathTex(r\"du = \\cos(x) \\, dx\")\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n sub_box = SurroundingRectangle(substitution, color=BLUE, buff=0.3)\n \n self.play(Write(substitution), Create(sub_box))\n self.wait(2)\n\n # Step 4: Rewrite the integral entirely in terms of u\n integral_u = MathTex(r\"\\int u \\, du\")\n self.play(ReplacementTransform(original_integral, integral_u))\n self.wait(2)\n\n # Step 5: Solve the simplified integral\n solved_u = MathTex(r\"= \\frac{1}{2}u^2 + C\")\n solved_u.next_to(integral_u, RIGHT)\n self.play(Write(solved_u))\n self.wait(2)\n\n # Step 6: Perform back-substitution to express the final answer in terms of x\n solved_x = MathTex(r\"= \\frac{1}{2}\\sin^2(x) + C\")\n self.play(ReplacementTransform(solved_u, solved_x))\n self.wait(3)\n\n # Step 7: Clear the screen completely\n all_mobs = VGroup(title, substitution, sub_box, integral_u, solved_x)\n self.play(FadeOut(all_mobs))\n self.wait(1)\n\n # Step 8: Display only the final solved integral\n final_result = MathTex(\n r\"\\int \\sin(x)\\cos(x) \\, dx = \\frac{1}{2}\\sin^2(x) + C\",\n font_size=48\n )\n self.play(Write(final_result))\n self.play(final_result.animate.set_color(YELLOW))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_003527", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "HarmonicOscillator", "num_animations": 15, "num_rich_primitives": 6, "prompt": "Can you create an educational animation that illustrates the dynamics of a harmonic oscillator, starting with the display of its differential equation on screen, then explaining the concept of angular frequency, followed by transforming the equation to include the angular frequency, and finally showing the general solution of the equation? Additionally, please visualize the harmonic motion by animating a dot moving along a circular path and conclude the animation with a recap text about harmonic oscillator dynamics.", "code": "from manim import *\nimport numpy as np\n\nclass HarmonicOscillator(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # Step 1: Display the Differential Equation\n # ---------------------------------------------------------\n eq_initial = MathTex(\n r\"m \\frac{d^2 x}{dt^2} = -k x\",\n font_size=40\n ).to_edge(UP)\n \n eq_label = Text(\n \"Differential Equation of a Harmonic Oscillator\",\n font_size=24\n ).next_to(eq_initial, UP, buff=0.2)\n \n self.play(Write(eq_label), Write(eq_initial))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 2: Explain Angular Frequency\n # ---------------------------------------------------------\n omega_def_text = Text(\"Define Angular Frequency:\", font_size=28)\n omega_def_eq = MathTex(r\"\\omega = \\sqrt{\\frac{k}{m}}\", font_size=40, color=YELLOW)\n \n omega_explanation = Text(\n \"ω represents how fast the system oscillates.\",\n font_size=22\n )\n \n omega_group = VGroup(omega_def_text, omega_def_eq, omega_explanation)\\\n .arrange(DOWN, buff=0.3)\\\n .next_to(eq_initial, DOWN, buff=0.8)\n \n self.play(Write(omega_def_text), Write(omega_def_eq))\n self.play(FadeIn(omega_explanation))\n self.wait(2)\n self.play(FadeOut(omega_explanation), FadeOut(omega_def_text), FadeOut(eq_label))\n\n # ---------------------------------------------------------\n # Step 3: Transform the Equation\n # ---------------------------------------------------------\n eq_intermediate = MathTex(\n r\"\\frac{d^2 x}{dt^2} = -\\frac{k}{m} x\",\n font_size=40\n ).move_to(eq_initial)\n \n eq_omega = MathTex(\n r\"\\frac{d^2 x}{dt^2} = -\\omega^2 x\",\n font_size=40\n ).move_to(eq_initial)\n \n eq_final = MathTex(\n r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\",\n font_size=40,\n color=GREEN\n ).move_to(eq_initial)\n\n self.play(TransformMatchingTex(eq_initial, eq_intermediate))\n self.wait(0.5)\n self.play(TransformMatchingTex(eq_intermediate, eq_omega))\n self.wait(0.5)\n self.play(TransformMatchingTex(eq_omega, eq_final))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 4: Show the General Solution\n # ---------------------------------------------------------\n solution_text = Text(\"General Solution:\", font_size=28)\n solution_eq = MathTex(\n r\"x(t) = A \\cos(\\omega t + \\phi)\",\n font_size=40,\n color=BLUE\n )\n \n solution_group = VGroup(solution_text, solution_eq)\\\n .arrange(DOWN, buff=0.3)\\\n .next_to(omega_def_eq, DOWN, buff=0.8)\n \n self.play(Write(solution_text), Write(solution_eq))\n self.wait(2)\n\n # Move equations to the top to make room for visualization\n top_group = VGroup(eq_final, omega_def_eq, solution_text, solution_eq)\n self.play(top_group.animate.scale(0.7).to_edge(UP))\n\n # ---------------------------------------------------------\n # Step 5: Visualize Harmonic Motion (Circular Projection)\n # ---------------------------------------------------------\n radius = 2.0\n omega_val = 2.0\n \n circle = Circle(radius=radius, color=BLUE)\n axis = Arrow(start=LEFT * 3.5, end=RIGHT * 3.5, color=WHITE)\n axis.shift(DOWN * 3)\n axis_label = MathTex(\"x(t)\", font_size=28).next_to(axis, RIGHT)\n \n viz_group = VGroup(circle, axis, axis_label).shift(DOWN * 0.5)\n \n theta_tracker = ValueTracker(0)\n\n # Dot moving on the circle\n circle_dot = Dot(color=YELLOW)\n circle_dot.add_updater(lambda d: d.move_to(\n circle.point_at_angle(theta_tracker.get_value())\n ))\n\n # Projected dot on the x-axis (Harmonic Oscillator)\n project_dot = Dot(color=RED)\n project_dot.add_updater(lambda d: d.move_to([\n circle.point_at_angle(theta_tracker.get_value())[0], \n axis.get_center()[1], \n 0\n ]))\n\n # Projection Line (dashed)\n proj_line = DashedLine(color=GRAY)\n proj_line.add_updater(lambda l: l.put_start_and_end_on(\n circle_dot.get_center(),\n project_dot.get_center()\n ))\n\n self.play(Create(circle), Create(axis), Write(axis_label))\n self.add(circle_dot, project_dot, proj_line)\n self.wait(0.5)\n\n # Animate the rotation\n self.play(\n theta_tracker.animate.set_value(2 * PI),\n run_time=4,\n rate_func=linear\n )\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 6: Conclude with Recap\n # ---------------------------------------------------------\n self.play(\n FadeOut(viz_group),\n FadeOut(circle_dot),\n FadeOut(project_dot),\n FadeOut(proj_line),\n FadeOut(top_group)\n )\n\n recap_title = Text(\n \"Summary: Harmonic Oscillator\",\n font_size=36,\n color=YELLOW\n ).to_edge(UP)\n \n recap_points = VGroup(\n Text(\"1. Restoring force is proportional to displacement\", font_size=24),\n Text(\"2. Motion is described by sinusoidal functions\", font_size=24),\n Text(\"3. Angular frequency ω determines oscillation rate\", font_size=24),\n Text(\"4. Equivalent to projection of uniform circular motion\", font_size=24),\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.4).next_to(recap_title, DOWN, buff=0.5)\n\n self.play(Write(recap_title))\n for point in recap_points:\n self.play(Write(point))\n self.wait(0.5)\n \n self.wait(2)\n self.play(FadeOut(recap_title), FadeOut(recap_points))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Can you create an educational animation that illustrates the dynamics of a harmonic oscillator, starting with the display of its differential equation on screen, then explaining the concept of angular frequency, followed by transforming the equation to include the angular frequency, and finally showing the general solution of the equation? Additionally, please visualize the harmonic motion by animating a dot moving along a circular path and conclude the animation with a recap text about harmonic oscillator dynamics."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass HarmonicOscillator(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # Step 1: Display the Differential Equation\n # ---------------------------------------------------------\n eq_initial = MathTex(\n r\"m \\frac{d^2 x}{dt^2} = -k x\",\n font_size=40\n ).to_edge(UP)\n \n eq_label = Text(\n \"Differential Equation of a Harmonic Oscillator\",\n font_size=24\n ).next_to(eq_initial, UP, buff=0.2)\n \n self.play(Write(eq_label), Write(eq_initial))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 2: Explain Angular Frequency\n # ---------------------------------------------------------\n omega_def_text = Text(\"Define Angular Frequency:\", font_size=28)\n omega_def_eq = MathTex(r\"\\omega = \\sqrt{\\frac{k}{m}}\", font_size=40, color=YELLOW)\n \n omega_explanation = Text(\n \"ω represents how fast the system oscillates.\",\n font_size=22\n )\n \n omega_group = VGroup(omega_def_text, omega_def_eq, omega_explanation)\\\n .arrange(DOWN, buff=0.3)\\\n .next_to(eq_initial, DOWN, buff=0.8)\n \n self.play(Write(omega_def_text), Write(omega_def_eq))\n self.play(FadeIn(omega_explanation))\n self.wait(2)\n self.play(FadeOut(omega_explanation), FadeOut(omega_def_text), FadeOut(eq_label))\n\n # ---------------------------------------------------------\n # Step 3: Transform the Equation\n # ---------------------------------------------------------\n eq_intermediate = MathTex(\n r\"\\frac{d^2 x}{dt^2} = -\\frac{k}{m} x\",\n font_size=40\n ).move_to(eq_initial)\n \n eq_omega = MathTex(\n r\"\\frac{d^2 x}{dt^2} = -\\omega^2 x\",\n font_size=40\n ).move_to(eq_initial)\n \n eq_final = MathTex(\n r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\",\n font_size=40,\n color=GREEN\n ).move_to(eq_initial)\n\n self.play(TransformMatchingTex(eq_initial, eq_intermediate))\n self.wait(0.5)\n self.play(TransformMatchingTex(eq_intermediate, eq_omega))\n self.wait(0.5)\n self.play(TransformMatchingTex(eq_omega, eq_final))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 4: Show the General Solution\n # ---------------------------------------------------------\n solution_text = Text(\"General Solution:\", font_size=28)\n solution_eq = MathTex(\n r\"x(t) = A \\cos(\\omega t + \\phi)\",\n font_size=40,\n color=BLUE\n )\n \n solution_group = VGroup(solution_text, solution_eq)\\\n .arrange(DOWN, buff=0.3)\\\n .next_to(omega_def_eq, DOWN, buff=0.8)\n \n self.play(Write(solution_text), Write(solution_eq))\n self.wait(2)\n\n # Move equations to the top to make room for visualization\n top_group = VGroup(eq_final, omega_def_eq, solution_text, solution_eq)\n self.play(top_group.animate.scale(0.7).to_edge(UP))\n\n # ---------------------------------------------------------\n # Step 5: Visualize Harmonic Motion (Circular Projection)\n # ---------------------------------------------------------\n radius = 2.0\n omega_val = 2.0\n \n circle = Circle(radius=radius, color=BLUE)\n axis = Arrow(start=LEFT * 3.5, end=RIGHT * 3.5, color=WHITE)\n axis.shift(DOWN * 3)\n axis_label = MathTex(\"x(t)\", font_size=28).next_to(axis, RIGHT)\n \n viz_group = VGroup(circle, axis, axis_label).shift(DOWN * 0.5)\n \n theta_tracker = ValueTracker(0)\n\n # Dot moving on the circle\n circle_dot = Dot(color=YELLOW)\n circle_dot.add_updater(lambda d: d.move_to(\n circle.point_at_angle(theta_tracker.get_value())\n ))\n\n # Projected dot on the x-axis (Harmonic Oscillator)\n project_dot = Dot(color=RED)\n project_dot.add_updater(lambda d: d.move_to([\n circle.point_at_angle(theta_tracker.get_value())[0], \n axis.get_center()[1], \n 0\n ]))\n\n # Projection Line (dashed)\n proj_line = DashedLine(color=GRAY)\n proj_line.add_updater(lambda l: l.put_start_and_end_on(\n circle_dot.get_center(),\n project_dot.get_center()\n ))\n\n self.play(Create(circle), Create(axis), Write(axis_label))\n self.add(circle_dot, project_dot, proj_line)\n self.wait(0.5)\n\n # Animate the rotation\n self.play(\n theta_tracker.animate.set_value(2 * PI),\n run_time=4,\n rate_func=linear\n )\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 6: Conclude with Recap\n # ---------------------------------------------------------\n self.play(\n FadeOut(viz_group),\n FadeOut(circle_dot),\n FadeOut(project_dot),\n FadeOut(proj_line),\n FadeOut(top_group)\n )\n\n recap_title = Text(\n \"Summary: Harmonic Oscillator\",\n font_size=36,\n color=YELLOW\n ).to_edge(UP)\n \n recap_points = VGroup(\n Text(\"1. Restoring force is proportional to displacement\", font_size=24),\n Text(\"2. Motion is described by sinusoidal functions\", font_size=24),\n Text(\"3. Angular frequency ω determines oscillation rate\", font_size=24),\n Text(\"4. Equivalent to projection of uniform circular motion\", font_size=24),\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.4).next_to(recap_title, DOWN, buff=0.5)\n\n self.play(Write(recap_title))\n for point in recap_points:\n self.play(Write(point))\n self.wait(0.5)\n \n self.wait(2)\n self.play(FadeOut(recap_title), FadeOut(recap_points))\n```"}]}
{"id": "adaption-unified-manim-instructions_007301", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "WaveEquationVisualization", "num_animations": 11, "num_rich_primitives": 3, "prompt": "I'd like to create an educational animation that first displays the partial differential equation known as the wave equation. Then, I want to show a brief text description explaining that this equation describes the propagation of waves. After this, I want to transition to showing the general solution of the wave equation using arbitrary functions. It should be followed by another text description that clarifies that these arbitrary functions represent the waveforms. Lastly, I'd like to see an example solution to the wave equation involving a sine function to represent a monochromatic plane wave, finishing with a brief descriptive text about this specific example. All of this should be animated with enough time between each part so that viewers can clearly understand the information presented. Can you help me make this educational animation using Manim?", "code": "from manim import *\nimport numpy as np\n\nclass WaveEquationVisualization(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Wave Equation\n # ------------------------------------------------------------------\n # The standard 1D wave equation relating second derivatives in time and space.\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \n r\"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n # Color coding for pedagogical clarity\n wave_eq[0].set_color(YELLOW) # u_tt\n wave_eq[2].set_color(BLUE) # c^2\n wave_eq[4].set_color(YELLOW) # u_xx\n \n self.play(Write(wave_eq), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Initial Explanation\n # ------------------------------------------------------------------\n explanation_1 = Tex(\n \"This partial differential equation describes the \\\\\\\\ propagation of waves through a medium.\", \n font_size=36, \n color=BLUE_B\n ).next_to(wave_eq, DOWN, buff=0.5)\n\n self.play(FadeIn(explanation_1, shift=UP), run_time=1.5)\n self.wait(3)\n \n # Transition: Clear the screen for the general solution\n self.play(FadeOut(wave_eq), FadeOut(explanation_1), run_time=1)\n\n # ------------------------------------------------------------------\n # Step 3: General Solution (d'Alembert's Solution)\n # ------------------------------------------------------------------\n general_sol = MathTex(\n r\"u(x, t)\", \"=\", \n r\"f(x - ct)\", \"+\", r\"g(x + ct)\",\n font_size=48\n )\n # Color coding to distinguish left and right traveling waves\n general_sol[0].set_color(YELLOW)\n general_sol[2].set_color(GREEN)\n general_sol[4].set_color(RED)\n \n self.play(Write(general_sol), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Function Clarification\n # ------------------------------------------------------------------\n explanation_2 = Tex(\n \"Here, $f$ and $g$ are arbitrary functions representing \\\\\\\\ waveforms traveling in opposite directions.\", \n font_size=36, \n color=BLUE_B\n ).next_to(general_sol, DOWN, buff=0.5)\n\n self.play(FadeIn(explanation_2, shift=UP), run_time=1.5)\n self.wait(4)\n\n # Transition: Move text to the top to make room for the plot\n self.play(\n general_sol.animate.to_edge(UP).scale(0.8),\n explanation_2.animate.next_to(general_sol, DOWN).scale(0.7),\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Specific Example (Monochromatic Plane Wave)\n # ------------------------------------------------------------------\n example_eq = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t)\", \n font_size=40, \n color=PURPLE\n ).next_to(explanation_2, DOWN, buff=0.5)\n\n self.play(Write(example_eq), run_time=2)\n self.wait(1)\n\n # Visualization of the sine wave\n axes = Axes(\n x_range=[0, 10, 1], \n y_range=[-1.5, 1.5, 1], \n axis_config={\"include_tip\": False},\n x_length=8, \n y_length=3\n ).shift(DOWN * 2)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n # We use a ValueTracker to animate time (t)\n time_tracker = ValueTracker(0)\n \n # The wave function: u(x, t) = sin(x - t)\n # k=1, omega=1 for simplicity in visualization\n wave = always_redraw(lambda: \n axes.plot(\n lambda x: np.sin(x - time_tracker.get_value()), \n color=YELLOW\n )\n )\n\n self.play(Create(axes), Write(labels))\n self.add(wave)\n \n # Animate the wave moving to the right\n self.play(time_tracker.animate.set_value(2 * PI), run_time=4, rate_func=linear)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Example Explanation\n # ------------------------------------------------------------------\n final_text = Tex(\n \"This represents a monochromatic plane wave \\\\\\\\ moving with a constant phase velocity.\", \n font_size=32, \n color=GRAY_A\n ).to_edge(DOWN, buff=0.5)\n\n self.play(FadeIn(final_text), run_time=1.5)\n self.wait(4)\n\n # Final fade out\n self.play(FadeOut(Group(*self.mobjects)))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'd like to create an educational animation that first displays the partial differential equation known as the wave equation. Then, I want to show a brief text description explaining that this equation describes the propagation of waves. After this, I want to transition to showing the general solution of the wave equation using arbitrary functions. It should be followed by another text description that clarifies that these arbitrary functions represent the waveforms. Lastly, I'd like to see an example solution to the wave equation involving a sine function to represent a monochromatic plane wave, finishing with a brief descriptive text about this specific example. All of this should be animated with enough time between each part so that viewers can clearly understand the information presented. Can you help me make this educational animation using Manim?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaveEquationVisualization(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Wave Equation\n # ------------------------------------------------------------------\n # The standard 1D wave equation relating second derivatives in time and space.\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \n r\"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n # Color coding for pedagogical clarity\n wave_eq[0].set_color(YELLOW) # u_tt\n wave_eq[2].set_color(BLUE) # c^2\n wave_eq[4].set_color(YELLOW) # u_xx\n \n self.play(Write(wave_eq), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Initial Explanation\n # ------------------------------------------------------------------\n explanation_1 = Tex(\n \"This partial differential equation describes the \\\\\\\\ propagation of waves through a medium.\", \n font_size=36, \n color=BLUE_B\n ).next_to(wave_eq, DOWN, buff=0.5)\n\n self.play(FadeIn(explanation_1, shift=UP), run_time=1.5)\n self.wait(3)\n \n # Transition: Clear the screen for the general solution\n self.play(FadeOut(wave_eq), FadeOut(explanation_1), run_time=1)\n\n # ------------------------------------------------------------------\n # Step 3: General Solution (d'Alembert's Solution)\n # ------------------------------------------------------------------\n general_sol = MathTex(\n r\"u(x, t)\", \"=\", \n r\"f(x - ct)\", \"+\", r\"g(x + ct)\",\n font_size=48\n )\n # Color coding to distinguish left and right traveling waves\n general_sol[0].set_color(YELLOW)\n general_sol[2].set_color(GREEN)\n general_sol[4].set_color(RED)\n \n self.play(Write(general_sol), run_time=2)\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Function Clarification\n # ------------------------------------------------------------------\n explanation_2 = Tex(\n \"Here, $f$ and $g$ are arbitrary functions representing \\\\\\\\ waveforms traveling in opposite directions.\", \n font_size=36, \n color=BLUE_B\n ).next_to(general_sol, DOWN, buff=0.5)\n\n self.play(FadeIn(explanation_2, shift=UP), run_time=1.5)\n self.wait(4)\n\n # Transition: Move text to the top to make room for the plot\n self.play(\n general_sol.animate.to_edge(UP).scale(0.8),\n explanation_2.animate.next_to(general_sol, DOWN).scale(0.7),\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Specific Example (Monochromatic Plane Wave)\n # ------------------------------------------------------------------\n example_eq = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t)\", \n font_size=40, \n color=PURPLE\n ).next_to(explanation_2, DOWN, buff=0.5)\n\n self.play(Write(example_eq), run_time=2)\n self.wait(1)\n\n # Visualization of the sine wave\n axes = Axes(\n x_range=[0, 10, 1], \n y_range=[-1.5, 1.5, 1], \n axis_config={\"include_tip\": False},\n x_length=8, \n y_length=3\n ).shift(DOWN * 2)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"u\")\n\n # We use a ValueTracker to animate time (t)\n time_tracker = ValueTracker(0)\n \n # The wave function: u(x, t) = sin(x - t)\n # k=1, omega=1 for simplicity in visualization\n wave = always_redraw(lambda: \n axes.plot(\n lambda x: np.sin(x - time_tracker.get_value()), \n color=YELLOW\n )\n )\n\n self.play(Create(axes), Write(labels))\n self.add(wave)\n \n # Animate the wave moving to the right\n self.play(time_tracker.animate.set_value(2 * PI), run_time=4, rate_func=linear)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Example Explanation\n # ------------------------------------------------------------------\n final_text = Tex(\n \"This represents a monochromatic plane wave \\\\\\\\ moving with a constant phase velocity.\", \n font_size=32, \n color=GRAY_A\n ).to_edge(DOWN, buff=0.5)\n\n self.play(FadeIn(final_text), run_time=1.5)\n self.wait(4)\n\n # Final fade out\n self.play(FadeOut(Group(*self.mobjects)))\n```"}]}
{"id": "autoresearch-manim_000034", "source": "sebastianboehler/autoresearch-manim", "tier": 1, "scene_name": "TransformReplacementComparison", "num_animations": 3, "num_rich_primitives": 1, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "multi_act_v2_00713", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0713", "num_animations": 21, "prompt": "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: **Enhanced Animation Instruction:** \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: Create a 10-second Manim scene that introduces a simplified benzene ring. Show a hexagonal carbon skeleton, alternating double bonds, and labels for several carbon and hydrogen positions.", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0713(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_hexagontocube()\n self.clear_stage()\n self.act_2_revolutionarytransformat()\n self.clear_stage()\n self.act_3_benzeneringlabels()\n\n def act_1_hexagontocube(self):\n hexagon = RegularPolygon(n=6, radius=2, color=YELLOW)\n self.play(Create(hexagon, run_time=3))\n self.wait(1)\n\n # Label the vertices\n labels = []\n vertices = hexagon.get_vertices()\n letters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"]\n for i, vertex in enumerate(vertices):\n label = Tex(letters[i], color=WHITE, font_size=36).move_to(vertex * 1.2)\n labels.append(label)\n self.play(Write(label), run_time=0.5)\n self.wait(1)\n\n # Draw triangles from center to vertices\n center = hexagon.get_center()\n triangles = VGroup()\n for i in range(6):\n next_i = (i + 1) % 6\n triangle = Polygon(center, vertices[i], vertices[next_i], color=BLUE, fill_opacity=0.5)\n triangles.add(triangle)\n \n for triangle in triangles:\n self.play(DrawBorderThenFill(triangle), run_time=0.5)\n self.wait(1)\n\n # Display the area formula\n formula = MathTex(r\"\\text{Area} = \\frac{3\\sqrt{3}}{2} \\times \\text{side}^2\", color=WHITE).to_edge(UP)\n self.play(FadeIn(formula))\n self.wait(2)\n\n # Transform hexagon into a cube\n cube = Cube(side_length=2, fill_opacity=0.8, fill_color=YELLOW, stroke_width=2)\n cube.move_to(hexagon.get_center())\n \n self.play(\n Rotate(hexagon, angle=PI/4, axis=OUT),\n Transform(hexagon, cube),\n run_time=3\n )\n self.wait(2)\n\n # Fade out all elements\n self.play(*[FadeOut(mob) for mob in self.mobjects], run_time=2)\n\n def act_2_revolutionarytransformat(self):\n title = Text('Revolutionary Transformation\\nof Marxist Philosophy', font_size=48, weight=BOLD, t2c={'Marxist Philosophy': YELLOW}, line_spacing=1.2)\n self.play(Write(title))\n self.wait(1.5)\n self.play(title.animate.to_edge(UP, buff=0.5).scale(0.7))\n self.wait(0.5)\n point1_title = Text('1. Shift in Philosophical Object:', font_size=36, color=BLUE_B)\n point1_title.next_to(title, DOWN, buff=1).to_edge(LEFT, buff=1)\n self.play(FadeIn(point1_title, shift=RIGHT))\n self.wait(0.5)\n abstract_man = Text('Abstract Man', font_size=42, color=LIGHT_GRAY)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, stroke_width=6, buff=0.2)\n real_man = Text('Real Man', font_size=42, color=GREEN_C, weight=BOLD)\n transformation_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.8)\n transformation_group.next_to(point1_title, DOWN, buff=1.5)\n self.play(Write(abstract_man))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(real_man))\n self.wait(1)\n highlight_box = SurroundingRectangle(real_man, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(3)\n self.play(FadeOut(title), FadeOut(point1_title), FadeOut(transformation_group), FadeOut(highlight_box))\n self.wait(1)\n\n def act_3_benzeneringlabels(self):\n title = Text(\"Benzene Ring\", font_size=36).to_edge(UP)\n hexagon = RegularPolygon(n=6, radius=1.6, color=BLUE_D)\n carbon_labels = VGroup(*[\n Text(\"C\", font_size=24).move_to(hexagon.point_from_proportion(i / 6) * 0.82)\n for i in range(6)\n ])\n bonds = VGroup()\n vertices = [hexagon.point_from_proportion(i / 6) for i in range(6)]\n for i in [0, 2, 4]:\n start = vertices[i]\n end = vertices[(i + 1) % 6]\n offset = 0.08 * normalize(rotate_vector(end - start, PI / 2))\n bonds.add(Line(start + offset, end + offset, color=YELLOW_D, stroke_width=4))\n hydrogen_labels = VGroup(*[\n Text(\"H\", font_size=22, color=GRAY_C).move_to(vertex * 1.28)\n for vertex in vertices\n ])\n note = Text(\"Alternating bonds capture the familiar benzene motif.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(hexagon), run_time=2)\n self.play(FadeIn(carbon_labels), FadeIn(hydrogen_labels), run_time=3)\n self.play(LaggedStart(*[Create(bond) for bond in bonds], lag_ratio=0.2), run_time=3)\n self.play(FadeIn(note), run_time=1)\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: **Enhanced Animation Instruction:** \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: Create a 10-second Manim scene that introduces a simplified benzene ring. Show a hexagonal carbon skeleton, alternating double bonds, and labels for several carbon and hydrogen positions."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0713(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_hexagontocube()\n self.clear_stage()\n self.act_2_revolutionarytransformat()\n self.clear_stage()\n self.act_3_benzeneringlabels()\n\n def act_1_hexagontocube(self):\n hexagon = RegularPolygon(n=6, radius=2, color=YELLOW)\n self.play(Create(hexagon, run_time=3))\n self.wait(1)\n\n # Label the vertices\n labels = []\n vertices = hexagon.get_vertices()\n letters = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\"]\n for i, vertex in enumerate(vertices):\n label = Tex(letters[i], color=WHITE, font_size=36).move_to(vertex * 1.2)\n labels.append(label)\n self.play(Write(label), run_time=0.5)\n self.wait(1)\n\n # Draw triangles from center to vertices\n center = hexagon.get_center()\n triangles = VGroup()\n for i in range(6):\n next_i = (i + 1) % 6\n triangle = Polygon(center, vertices[i], vertices[next_i], color=BLUE, fill_opacity=0.5)\n triangles.add(triangle)\n \n for triangle in triangles:\n self.play(DrawBorderThenFill(triangle), run_time=0.5)\n self.wait(1)\n\n # Display the area formula\n formula = MathTex(r\"\\text{Area} = \\frac{3\\sqrt{3}}{2} \\times \\text{side}^2\", color=WHITE).to_edge(UP)\n self.play(FadeIn(formula))\n self.wait(2)\n\n # Transform hexagon into a cube\n cube = Cube(side_length=2, fill_opacity=0.8, fill_color=YELLOW, stroke_width=2)\n cube.move_to(hexagon.get_center())\n \n self.play(\n Rotate(hexagon, angle=PI/4, axis=OUT),\n Transform(hexagon, cube),\n run_time=3\n )\n self.wait(2)\n\n # Fade out all elements\n self.play(*[FadeOut(mob) for mob in self.mobjects], run_time=2)\n\n def act_2_revolutionarytransformat(self):\n title = Text('Revolutionary Transformation\\nof Marxist Philosophy', font_size=48, weight=BOLD, t2c={'Marxist Philosophy': YELLOW}, line_spacing=1.2)\n self.play(Write(title))\n self.wait(1.5)\n self.play(title.animate.to_edge(UP, buff=0.5).scale(0.7))\n self.wait(0.5)\n point1_title = Text('1. Shift in Philosophical Object:', font_size=36, color=BLUE_B)\n point1_title.next_to(title, DOWN, buff=1).to_edge(LEFT, buff=1)\n self.play(FadeIn(point1_title, shift=RIGHT))\n self.wait(0.5)\n abstract_man = Text('Abstract Man', font_size=42, color=LIGHT_GRAY)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, stroke_width=6, buff=0.2)\n real_man = Text('Real Man', font_size=42, color=GREEN_C, weight=BOLD)\n transformation_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.8)\n transformation_group.next_to(point1_title, DOWN, buff=1.5)\n self.play(Write(abstract_man))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(real_man))\n self.wait(1)\n highlight_box = SurroundingRectangle(real_man, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(3)\n self.play(FadeOut(title), FadeOut(point1_title), FadeOut(transformation_group), FadeOut(highlight_box))\n self.wait(1)\n\n def act_3_benzeneringlabels(self):\n title = Text(\"Benzene Ring\", font_size=36).to_edge(UP)\n hexagon = RegularPolygon(n=6, radius=1.6, color=BLUE_D)\n carbon_labels = VGroup(*[\n Text(\"C\", font_size=24).move_to(hexagon.point_from_proportion(i / 6) * 0.82)\n for i in range(6)\n ])\n bonds = VGroup()\n vertices = [hexagon.point_from_proportion(i / 6) for i in range(6)]\n for i in [0, 2, 4]:\n start = vertices[i]\n end = vertices[(i + 1) % 6]\n offset = 0.08 * normalize(rotate_vector(end - start, PI / 2))\n bonds.add(Line(start + offset, end + offset, color=YELLOW_D, stroke_width=4))\n hydrogen_labels = VGroup(*[\n Text(\"H\", font_size=22, color=GRAY_C).move_to(vertex * 1.28)\n for vertex in vertices\n ])\n note = Text(\"Alternating bonds capture the familiar benzene motif.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(hexagon), run_time=2)\n self.play(FadeIn(carbon_labels), FadeIn(hydrogen_labels), run_time=3)\n self.play(LaggedStart(*[Create(bond) for bond in bonds], lag_ratio=0.2), run_time=3)\n self.play(FadeIn(note), run_time=1)\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_003821", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SimpleHarmonicMotion", "num_animations": 11, "num_rich_primitives": 4, "prompt": "Could you create an educational animation that illustrates the concept of Simple Harmonic Motion (SHM), starting with the display of its differential equation, followed by an explanation and introduction of angular frequency, and then showing how the equation is rewritten using angular frequency? Additionally, can you demonstrate the general solution of the equation involving cosine function, explain the meaning of phase difference within the context, and finally clear the scene to focus on the final solution?", "code": "from manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # --- Step 1: Display the Differential Equation ---\n eq_initial = MathTex(\n r\"\\frac{d^2x}{dt^2}\", \"=\", \"-\\frac{k}{m}\", \"x\"\n ).scale(1.2)\n eq_initial.to_edge(UP)\n \n eq_label = Text(\"Differential Equation for SHM\", font_size=24).next_to(eq_initial, UP, buff=0.3)\n \n self.play(Write(eq_label), Write(eq_initial))\n self.wait(2)\n\n # --- Step 2: Introduce Angular Frequency ---\n omega_def = MathTex(\n r\"\\omega\", \"=\", r\"\\sqrt{\\frac{k}{m}}\",\n color=YELLOW\n ).scale(1.2)\n omega_def.next_to(eq_initial, DOWN, buff=0.8)\n \n omega_text = Text(\"Angular Frequency (ω)\", font_size=24, color=YELLOW).next_to(omega_def, DOWN, buff=0.3)\n \n self.play(Write(omega_def), Write(omega_text))\n self.wait(2)\n\n # --- Step 3: Rewrite the Equation ---\n eq_omega = MathTex(\n r\"\\frac{d^2x}{dt^2}\", \"=\", \"-\\omega^2\", \"x\"\n ).scale(1.2)\n eq_omega.move_to(eq_initial)\n eq_omega.set_color_by_tex(r\"\\omega^2\", YELLOW)\n \n self.play(FadeOut(eq_label), TransformMatchingTex(eq_initial, eq_omega))\n self.play(Indicate(omega_def, color=YELLOW, scale_factor=1.2))\n self.wait(2)\n\n # --- Step 4: Present the General Solution ---\n # Construct solution with isolated phi for later highlighting\n sol_lhs = MathTex(r\"x(t)\", \"=\", font_size=48)\n sol_amp = MathTex(r\"A\", font_size=48)\n sol_cos = MathTex(r\"\\cos(\\omega t + \", font_size=48)\n sol_phi = MathTex(r\"\\phi\", font_size=48, color=GREEN)\n sol_close = MathTex(r\")\", font_size=48)\n \n solution_group = VGroup(sol_lhs, sol_amp, sol_cos, sol_phi, sol_close)\n solution_group.arrange(RIGHT, buff=0.1)\n solution_group.scale(1.3)\n solution_group.next_to(omega_def, DOWN, buff=1.0)\n \n sol_label = Text(\"General Solution\", font_size=24).next_to(solution_group, UP, buff=0.3)\n \n self.play(FadeOut(omega_text), Write(sol_label), Write(solution_group))\n self.wait(2)\n\n # --- Step 5: Explain Phase Difference ---\n # Visualize the effect of phi using graphs\n axes = Axes(\n x_range=[0, 4 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=6,\n y_length=2.5,\n axis_config={\"color\": WHITE},\n )\n axes.next_to(solution_group, DOWN, buff=0.5)\n \n graph_ref = axes.plot(lambda t: np.cos(t), color=WHITE)\n graph_shifted = axes.plot(lambda t: np.cos(t + PI / 3), color=GREEN)\n \n label_ref = MathTex(r\"\\phi = 0\", color=WHITE, font_size=24).next_to(graph_ref, RIGHT, buff=0.2)\n label_shift = MathTex(r\"\\phi > 0\", color=GREEN, font_size=24).next_to(graph_shifted, RIGHT, buff=0.2)\n \n phase_expl = Text(\n \"Phase Difference (φ): Determines the starting position\", \n font_size=20, \n color=GREEN\n ).next_to(axes, DOWN, buff=0.3)\n\n self.play(Create(axes))\n self.play(Create(graph_ref), Write(label_ref))\n self.play(Create(graph_shifted), Write(label_shift), Write(phase_expl))\n self.play(sol_phi.animate.scale(1.5).set_color(RED))\n self.wait(3)\n\n # --- Step 6: Final Focus ---\n # Clear intermediate steps to focus on the final derived solution\n self.play(\n FadeOut(omega_def),\n FadeOut(eq_omega),\n FadeOut(sol_label),\n FadeOut(axes),\n FadeOut(graph_ref),\n FadeOut(graph_shifted),\n FadeOut(label_ref),\n FadeOut(label_shift),\n FadeOut(phase_expl),\n sol_phi.animate.scale(1/1.5).set_color(WHITE)\n )\n \n # Consolidate into a single clean equation for the final frame\n final_eq = MathTex(r\"x(t) = A \\cos(\\omega t + \\phi)\").scale(1.5)\n final_eq.move_to(ORIGIN)\n \n final_label = Text(\"The Equation of Motion\", font_size=30).next_to(final_eq, UP, buff=1.0)\n \n self.play(FadeOut(solution_group), FadeIn(final_eq), Write(final_label))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that illustrates the concept of Simple Harmonic Motion (SHM), starting with the display of its differential equation, followed by an explanation and introduction of angular frequency, and then showing how the equation is rewritten using angular frequency? Additionally, can you demonstrate the general solution of the equation involving cosine function, explain the meaning of phase difference within the context, and finally clear the scene to focus on the final solution?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # --- Step 1: Display the Differential Equation ---\n eq_initial = MathTex(\n r\"\\frac{d^2x}{dt^2}\", \"=\", \"-\\frac{k}{m}\", \"x\"\n ).scale(1.2)\n eq_initial.to_edge(UP)\n \n eq_label = Text(\"Differential Equation for SHM\", font_size=24).next_to(eq_initial, UP, buff=0.3)\n \n self.play(Write(eq_label), Write(eq_initial))\n self.wait(2)\n\n # --- Step 2: Introduce Angular Frequency ---\n omega_def = MathTex(\n r\"\\omega\", \"=\", r\"\\sqrt{\\frac{k}{m}}\",\n color=YELLOW\n ).scale(1.2)\n omega_def.next_to(eq_initial, DOWN, buff=0.8)\n \n omega_text = Text(\"Angular Frequency (ω)\", font_size=24, color=YELLOW).next_to(omega_def, DOWN, buff=0.3)\n \n self.play(Write(omega_def), Write(omega_text))\n self.wait(2)\n\n # --- Step 3: Rewrite the Equation ---\n eq_omega = MathTex(\n r\"\\frac{d^2x}{dt^2}\", \"=\", \"-\\omega^2\", \"x\"\n ).scale(1.2)\n eq_omega.move_to(eq_initial)\n eq_omega.set_color_by_tex(r\"\\omega^2\", YELLOW)\n \n self.play(FadeOut(eq_label), TransformMatchingTex(eq_initial, eq_omega))\n self.play(Indicate(omega_def, color=YELLOW, scale_factor=1.2))\n self.wait(2)\n\n # --- Step 4: Present the General Solution ---\n # Construct solution with isolated phi for later highlighting\n sol_lhs = MathTex(r\"x(t)\", \"=\", font_size=48)\n sol_amp = MathTex(r\"A\", font_size=48)\n sol_cos = MathTex(r\"\\cos(\\omega t + \", font_size=48)\n sol_phi = MathTex(r\"\\phi\", font_size=48, color=GREEN)\n sol_close = MathTex(r\")\", font_size=48)\n \n solution_group = VGroup(sol_lhs, sol_amp, sol_cos, sol_phi, sol_close)\n solution_group.arrange(RIGHT, buff=0.1)\n solution_group.scale(1.3)\n solution_group.next_to(omega_def, DOWN, buff=1.0)\n \n sol_label = Text(\"General Solution\", font_size=24).next_to(solution_group, UP, buff=0.3)\n \n self.play(FadeOut(omega_text), Write(sol_label), Write(solution_group))\n self.wait(2)\n\n # --- Step 5: Explain Phase Difference ---\n # Visualize the effect of phi using graphs\n axes = Axes(\n x_range=[0, 4 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=6,\n y_length=2.5,\n axis_config={\"color\": WHITE},\n )\n axes.next_to(solution_group, DOWN, buff=0.5)\n \n graph_ref = axes.plot(lambda t: np.cos(t), color=WHITE)\n graph_shifted = axes.plot(lambda t: np.cos(t + PI / 3), color=GREEN)\n \n label_ref = MathTex(r\"\\phi = 0\", color=WHITE, font_size=24).next_to(graph_ref, RIGHT, buff=0.2)\n label_shift = MathTex(r\"\\phi > 0\", color=GREEN, font_size=24).next_to(graph_shifted, RIGHT, buff=0.2)\n \n phase_expl = Text(\n \"Phase Difference (φ): Determines the starting position\", \n font_size=20, \n color=GREEN\n ).next_to(axes, DOWN, buff=0.3)\n\n self.play(Create(axes))\n self.play(Create(graph_ref), Write(label_ref))\n self.play(Create(graph_shifted), Write(label_shift), Write(phase_expl))\n self.play(sol_phi.animate.scale(1.5).set_color(RED))\n self.wait(3)\n\n # --- Step 6: Final Focus ---\n # Clear intermediate steps to focus on the final derived solution\n self.play(\n FadeOut(omega_def),\n FadeOut(eq_omega),\n FadeOut(sol_label),\n FadeOut(axes),\n FadeOut(graph_ref),\n FadeOut(graph_shifted),\n FadeOut(label_ref),\n FadeOut(label_shift),\n FadeOut(phase_expl),\n sol_phi.animate.scale(1/1.5).set_color(WHITE)\n )\n \n # Consolidate into a single clean equation for the final frame\n final_eq = MathTex(r\"x(t) = A \\cos(\\omega t + \\phi)\").scale(1.5)\n final_eq.move_to(ORIGIN)\n \n final_label = Text(\"The Equation of Motion\", font_size=30).next_to(final_eq, UP, buff=1.0)\n \n self.play(FadeOut(solution_group), FadeIn(final_eq), Write(final_label))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_003040", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "MatrixDeterminantAndEigenvalues", "num_animations": 24, "num_rich_primitives": 5, "prompt": "Could you create an educational animation that demonstrates how to find the determinant and the eigenvalues of a 2x2 matrix using ManimCE? The matrix should be presented first, followed by an explanation of how to calculate its determinant, and then proceed to explain and calculate the eigenvalues. Additionally, can the animation include text explanations and the mathematical formulas for the calculations, concluding with the final eigenvalues highlighted on screen?", "code": "from manim import *\n\nclass MatrixDeterminantAndEigenvalues(Scene):\n def construct(self):\n # --- Step 1: Matrix Presentation ---\n # We use A = [[4, 1], [2, 3]] which yields integer eigenvalues (5 and 2) \n # for a clear educational demonstration.\n matrix = Matrix([[4, 1], [2, 3]])\n matrix_label = MathTex(\"A = \").next_to(matrix, LEFT)\n matrix_group = VGroup(matrix_label, matrix).shift(UP * 2.5)\n\n title = Text(\"Determinant & Eigenvalues\", font_size=40).to_edge(UP)\n self.play(Write(title))\n self.play(Write(matrix_label), Create(matrix))\n self.wait(1)\n\n # --- Step 2: Determinant Calculation ---\n det_title = Text(\"1. Determinant Calculation\", font_size=32, color=BLUE).next_to(title, DOWN, buff=0.4)\n self.play(Write(det_title))\n\n # General formula: det(A) = ad - bc\n det_formula = MathTex(\"\\\\det(A) = ad - bc\", font_size=32).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(det_formula))\n self.wait(0.5)\n\n # Specific substitution\n det_calc = MathTex(\"= (4)(3) - (1)(2)\", font_size=32).next_to(det_formula, DOWN, buff=0.3)\n self.play(Write(det_calc))\n\n # Highlight the diagonals visually\n rect_main = SurroundingRectangle(matrix.get_entries()[0], color=YELLOW)\n rect_main2 = SurroundingRectangle(matrix.get_entries()[3], color=YELLOW)\n self.play(Create(rect_main), Create(rect_main2))\n self.wait(0.5)\n self.play(FadeOut(rect_main), FadeOut(rect_main2))\n\n rect_off = SurroundingRectangle(matrix.get_entries()[1], color=RED)\n rect_off2 = SurroundingRectangle(matrix.get_entries()[2], color=RED)\n self.play(Create(rect_off), Create(rect_off2))\n self.wait(0.5)\n self.play(FadeOut(rect_off), FadeOut(rect_off2))\n\n # Final determinant result\n det_result = MathTex(\"= 12 - 2 = 10\", font_size=32, color=GREEN).next_to(det_calc, DOWN, buff=0.3)\n self.play(Write(det_result))\n self.wait(1)\n\n # Clean up determinant section\n self.play(\n FadeOut(det_title), FadeOut(det_formula), \n FadeOut(det_calc), FadeOut(det_result)\n )\n\n # --- Step 3: Eigenvalue Calculation ---\n eig_title = Text(\"2. Eigenvalue Calculation\", font_size=32, color=BLUE).next_to(title, DOWN, buff=0.4)\n self.play(Write(eig_title))\n\n # Characteristic equation concept\n eig_concept = MathTex(\"\\\\det(A - \\\\lambda I) = 0\", font_size=32).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(eig_concept))\n self.wait(0.5)\n\n # Show the matrix (A - \\lambda I)\n char_matrix = MathTex(\n \"\\\\det \\\\left( \\\\begin{bmatrix} 4-\\\\lambda & 1 \\\\\\\\ 2 & 3-\\\\lambda \\\\end{bmatrix} \\\\right) = 0\",\n font_size=28\n ).next_to(eig_concept, DOWN, buff=0.3)\n self.play(Write(char_matrix))\n self.wait(1)\n\n # Expand the determinant\n poly_step1 = MathTex(\"(4-\\\\lambda)(3-\\\\lambda) - (1)(2) = 0\", font_size=28).next_to(char_matrix, DOWN, buff=0.3)\n self.play(Write(poly_step1))\n self.wait(0.5)\n\n # Simplify to standard quadratic form\n poly_step2 = MathTex(\"\\\\lambda^2 - 7\\\\lambda + 12 - 2 = 0\", font_size=28).next_to(poly_step1, DOWN, buff=0.3)\n self.play(ReplacementTransform(poly_step1.copy(), poly_step2))\n self.wait(0.5)\n\n poly_step3 = MathTex(\"\\\\lambda^2 - 7\\\\lambda + 10 = 0\", font_size=28, color=TEAL).next_to(poly_step2, DOWN, buff=0.3)\n self.play(Write(poly_step3))\n self.wait(0.5)\n\n # Factor the quadratic equation\n factored = MathTex(\"(\\\\lambda - 5)(\\\\lambda - 2) = 0\", font_size=28).next_to(poly_step3, DOWN, buff=0.3)\n self.play(Write(factored))\n self.wait(1)\n\n # --- Step 4: Conclusion ---\n # Clear intermediate equations to highlight final results\n self.play(\n FadeOut(eig_title), FadeOut(eig_concept), FadeOut(char_matrix),\n FadeOut(poly_step1), FadeOut(poly_step2), FadeOut(poly_step3), FadeOut(factored)\n )\n\n conclusion_text = Text(\"The Eigenvalues are:\", font_size=36).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(conclusion_text))\n\n # Display final eigenvalues prominently\n final_eigenvalues = VGroup(\n MathTex(\"\\\\lambda_1 = 5\", font_size=44, color=YELLOW),\n MathTex(\"\\\\lambda_2 = 2\", font_size=44, color=YELLOW)\n ).arrange(RIGHT, buff=1.5).next_to(conclusion_text, DOWN, buff=0.5)\n\n self.play(Write(final_eigenvalues))\n \n # Add a surrounding box and pulse animation to emphasize the final answer\n box = SurroundingRectangle(final_eigenvalues, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.play(Indicate(final_eigenvalues, color=YELLOW, scale=1.1), run_time=2)\n \n self.wait(2)\n self.play(FadeOut(*self.mobjects))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Could you create an educational animation that demonstrates how to find the determinant and the eigenvalues of a 2x2 matrix using ManimCE? The matrix should be presented first, followed by an explanation of how to calculate its determinant, and then proceed to explain and calculate the eigenvalues. Additionally, can the animation include text explanations and the mathematical formulas for the calculations, concluding with the final eigenvalues highlighted on screen?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass MatrixDeterminantAndEigenvalues(Scene):\n def construct(self):\n # --- Step 1: Matrix Presentation ---\n # We use A = [[4, 1], [2, 3]] which yields integer eigenvalues (5 and 2) \n # for a clear educational demonstration.\n matrix = Matrix([[4, 1], [2, 3]])\n matrix_label = MathTex(\"A = \").next_to(matrix, LEFT)\n matrix_group = VGroup(matrix_label, matrix).shift(UP * 2.5)\n\n title = Text(\"Determinant & Eigenvalues\", font_size=40).to_edge(UP)\n self.play(Write(title))\n self.play(Write(matrix_label), Create(matrix))\n self.wait(1)\n\n # --- Step 2: Determinant Calculation ---\n det_title = Text(\"1. Determinant Calculation\", font_size=32, color=BLUE).next_to(title, DOWN, buff=0.4)\n self.play(Write(det_title))\n\n # General formula: det(A) = ad - bc\n det_formula = MathTex(\"\\\\det(A) = ad - bc\", font_size=32).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(det_formula))\n self.wait(0.5)\n\n # Specific substitution\n det_calc = MathTex(\"= (4)(3) - (1)(2)\", font_size=32).next_to(det_formula, DOWN, buff=0.3)\n self.play(Write(det_calc))\n\n # Highlight the diagonals visually\n rect_main = SurroundingRectangle(matrix.get_entries()[0], color=YELLOW)\n rect_main2 = SurroundingRectangle(matrix.get_entries()[3], color=YELLOW)\n self.play(Create(rect_main), Create(rect_main2))\n self.wait(0.5)\n self.play(FadeOut(rect_main), FadeOut(rect_main2))\n\n rect_off = SurroundingRectangle(matrix.get_entries()[1], color=RED)\n rect_off2 = SurroundingRectangle(matrix.get_entries()[2], color=RED)\n self.play(Create(rect_off), Create(rect_off2))\n self.wait(0.5)\n self.play(FadeOut(rect_off), FadeOut(rect_off2))\n\n # Final determinant result\n det_result = MathTex(\"= 12 - 2 = 10\", font_size=32, color=GREEN).next_to(det_calc, DOWN, buff=0.3)\n self.play(Write(det_result))\n self.wait(1)\n\n # Clean up determinant section\n self.play(\n FadeOut(det_title), FadeOut(det_formula), \n FadeOut(det_calc), FadeOut(det_result)\n )\n\n # --- Step 3: Eigenvalue Calculation ---\n eig_title = Text(\"2. Eigenvalue Calculation\", font_size=32, color=BLUE).next_to(title, DOWN, buff=0.4)\n self.play(Write(eig_title))\n\n # Characteristic equation concept\n eig_concept = MathTex(\"\\\\det(A - \\\\lambda I) = 0\", font_size=32).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(eig_concept))\n self.wait(0.5)\n\n # Show the matrix (A - \\lambda I)\n char_matrix = MathTex(\n \"\\\\det \\\\left( \\\\begin{bmatrix} 4-\\\\lambda & 1 \\\\\\\\ 2 & 3-\\\\lambda \\\\end{bmatrix} \\\\right) = 0\",\n font_size=28\n ).next_to(eig_concept, DOWN, buff=0.3)\n self.play(Write(char_matrix))\n self.wait(1)\n\n # Expand the determinant\n poly_step1 = MathTex(\"(4-\\\\lambda)(3-\\\\lambda) - (1)(2) = 0\", font_size=28).next_to(char_matrix, DOWN, buff=0.3)\n self.play(Write(poly_step1))\n self.wait(0.5)\n\n # Simplify to standard quadratic form\n poly_step2 = MathTex(\"\\\\lambda^2 - 7\\\\lambda + 12 - 2 = 0\", font_size=28).next_to(poly_step1, DOWN, buff=0.3)\n self.play(ReplacementTransform(poly_step1.copy(), poly_step2))\n self.wait(0.5)\n\n poly_step3 = MathTex(\"\\\\lambda^2 - 7\\\\lambda + 10 = 0\", font_size=28, color=TEAL).next_to(poly_step2, DOWN, buff=0.3)\n self.play(Write(poly_step3))\n self.wait(0.5)\n\n # Factor the quadratic equation\n factored = MathTex(\"(\\\\lambda - 5)(\\\\lambda - 2) = 0\", font_size=28).next_to(poly_step3, DOWN, buff=0.3)\n self.play(Write(factored))\n self.wait(1)\n\n # --- Step 4: Conclusion ---\n # Clear intermediate equations to highlight final results\n self.play(\n FadeOut(eig_title), FadeOut(eig_concept), FadeOut(char_matrix),\n FadeOut(poly_step1), FadeOut(poly_step2), FadeOut(poly_step3), FadeOut(factored)\n )\n\n conclusion_text = Text(\"The Eigenvalues are:\", font_size=36).next_to(matrix_group, DOWN, buff=0.5)\n self.play(Write(conclusion_text))\n\n # Display final eigenvalues prominently\n final_eigenvalues = VGroup(\n MathTex(\"\\\\lambda_1 = 5\", font_size=44, color=YELLOW),\n MathTex(\"\\\\lambda_2 = 2\", font_size=44, color=YELLOW)\n ).arrange(RIGHT, buff=1.5).next_to(conclusion_text, DOWN, buff=0.5)\n\n self.play(Write(final_eigenvalues))\n \n # Add a surrounding box and pulse animation to emphasize the final answer\n box = SurroundingRectangle(final_eigenvalues, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.play(Indicate(final_eigenvalues, color=YELLOW, scale=1.1), run_time=2)\n \n self.wait(2)\n self.play(FadeOut(*self.mobjects))\n```"}]}
{"id": "qwen3-8b-manimator-gold-sft_000673", "source": "nabin2004/qwen3-8b-manimator-gold-sft", "tier": 1, "scene_name": "SVDAndPCA", "num_animations": 3, "num_rich_primitives": 1, "prompt": "I'm learning linear algebra to undergraduates; can you visualize SVD with a 2D point cloud transformed by a matrix A, followed by its decomposition into U, Sigma, V^T?\nI want intuition first—show the ellipsoid that Ax maps the unit circle to, with the principal axes and the singular values as stretch factors.\nThen present the algebra with minimal clutter, and animate how U, Sigma, V^T reconstruct Ax; include multiple scenes: original cloud, transformed cloud, and the ellipsoid, plus a 3D camera orbit.\nAdd a parameter sweep of A to reveal how Sigma changes, tie the result to PCA intuition, and provide annotated diagrams and gradual pacing suitable for a 50-minute class.", "code": "from manim import *\nimport numpy as np\n\nclass SVDAndPCA(VoiceoverScene, ThreeDScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)\n \n # [BEAT 1 | sync: INTRO]\n with self.voiceover(text=\"Singular Value Decomposition, or SVD, is the Swiss Army knife of linear algebra. It decomposes any matrix A into three simpler transformations: a rotation, a scaling, and another rotation.\") as tracker:\n self.wait_until_bookmark(\"INTRO\")\n title = MathTex(\"A = U \\\\Sigma V^T\", font_size=48)\n self.fit_in_frame(title)\n self.add_fixed_in_frame_mobjects(title)\n self.play(Write(title), run_time=tracker.duration)\n \n with self.voiceover(text=\"Geometrically, imagine a unit sphere in 3D space. When we apply matrix A, the sphere stretches and rotates into an ellipsoid.\") as tracker:\n self.wait_until_bookmark(\"SPHERE\")\n self.play(FadeOut(title))\n axes = ThreeDAxes()\n sphere = Sphere(radius=1, resolution=(16, 16)).set_color(BLUE).set_opacity(0.5)\n self.add(axes, sphere)\n self.wait(tracker.duration)\n \n with self.voiceover(text=\"The principal axes of this ellipsoid are the left singular vectors, U. The lengths of these axes are the singular values, Sigma. This is exactly what Principal Component Analysis does: it finds the directions of maximum variance in your data.\") as tracker:\n self.wait_until_bookmark(\"PCA\")\n A = np.array([[2, 0, 0], [0, 1, 0], [0, 0, 0.5]])\n self.play(ApplyMatrix(A, sphere), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm learning linear algebra to undergraduates; can you visualize SVD with a 2D point cloud transformed by a matrix A, followed by its decomposition into U, Sigma, V^T?\nI want intuition first—show the ellipsoid that Ax maps the unit circle to, with the principal axes and the singular values as stretch factors.\nThen present the algebra with minimal clutter, and animate how U, Sigma, V^T reconstruct Ax; include multiple scenes: original cloud, transformed cloud, and the ellipsoid, plus a 3D camera orbit.\nAdd a parameter sweep of A to reveal how Sigma changes, tie the result to PCA intuition, and provide annotated diagrams and gradual pacing suitable for a 50-minute class."}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass SVDAndPCA(VoiceoverScene, ThreeDScene):\n def construct(self):\n # [SETUP]\n # [LAYOUT]\n self.set_speech_service(GTTSService(transcription_model=\"base\"))\n self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)\n \n # [BEAT 1 | sync: INTRO]\n with self.voiceover(text=\"Singular Value Decomposition, or SVD, is the Swiss Army knife of linear algebra. It decomposes any matrix A into three simpler transformations: a rotation, a scaling, and another rotation.\") as tracker:\n self.wait_until_bookmark(\"INTRO\")\n title = MathTex(\"A = U \\\\Sigma V^T\", font_size=48)\n self.fit_in_frame(title)\n self.add_fixed_in_frame_mobjects(title)\n self.play(Write(title), run_time=tracker.duration)\n \n with self.voiceover(text=\"Geometrically, imagine a unit sphere in 3D space. When we apply matrix A, the sphere stretches and rotates into an ellipsoid.\") as tracker:\n self.wait_until_bookmark(\"SPHERE\")\n self.play(FadeOut(title))\n axes = ThreeDAxes()\n sphere = Sphere(radius=1, resolution=(16, 16)).set_color(BLUE).set_opacity(0.5)\n self.add(axes, sphere)\n self.wait(tracker.duration)\n \n with self.voiceover(text=\"The principal axes of this ellipsoid are the left singular vectors, U. The lengths of these axes are the singular values, Sigma. This is exactly what Principal Component Analysis does: it finds the directions of maximum variance in your data.\") as tracker:\n self.wait_until_bookmark(\"PCA\")\n A = np.array([[2, 0, 0], [0, 1, 0], [0, 0, 0.5]])\n self.play(ApplyMatrix(A, sphere), run_time=tracker.duration)\n self.wait(1)\n\n def fit_in_frame(self, mob: Mobject, w_frac: float = 0.9, h_frac: float = 0.9) -> Mobject:\n max_w = config.frame_width * w_frac\n max_h = config.frame_height * h_frac\n if mob.width > max_w:\n mob.width = max_w\n if mob.height > max_h:\n mob.height = max_h\n return mob\n```"}]}
{"id": "multi_act_v2_00321", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0321", "num_animations": 14, "prompt": "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: 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 2: Here is the enhanced animation description: ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0321(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_symplecticinnerproduct()\n self.clear_stage()\n self.act_2_animatedheptagon()\n\n def act_1_symplecticinnerproduct(self):\n title = Text('Symplectic Inner Product & Commutativity', 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 intro_text = Text('Vectors u and v correspond to Pauli operators P and Q', font_size=26)\n intro_text.next_to(title_group, DOWN, buff=0.6)\n self.play(FadeIn(intro_text, shift=DOWN * 0.2), run_time=1)\n formula = MathTex('u \\\\odot v = \\\\sum_{i=1}^n (u_{x,i} v_{z,i} + u_{z,i} v_{x,i}) \\\\pmod{2}', font_size=38)\n formula.next_to(intro_text, DOWN, buff=0.5)\n formula_box = SurroundingRectangle(formula, color=YELLOW, buff=0.2)\n self.play(Write(formula), run_time=1.5)\n self.play(Create(formula_box), run_time=0.8)\n crit_title = Text('Commutativity Criterion:', font_size=28, color=BLUE)\n crit_title.next_to(formula_box, DOWN, buff=0.7)\n crit_1 = MathTex('u \\\\odot v = 0 \\\\implies P \\\\text{ and } Q \\\\text{ commute}', font_size=32)\n crit_2 = MathTex('u \\\\odot v = 1 \\\\implies P \\\\text{ and } Q \\\\text{ anti-commute}', font_size=32)\n crit_group = VGroup(crit_1, crit_2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n crit_group.next_to(crit_title, DOWN, buff=0.3)\n self.play(Write(crit_title), run_time=1)\n self.play(FadeIn(crit_group, shift=UP * 0.2), run_time=1.5)\n conc_text = Tex('Finding stabilizer subgroups $\\\\Rightarrow$ Finding isotropic subspaces in $\\\\mathbb{Z}_2^{2n}$', font_size=30, color=GREEN)\n conc_text.next_to(crit_group, DOWN, buff=0.7)\n self.play(Write(conc_text), run_time=1.5)\n self.wait(0.5)\n\n def act_2_animatedheptagon(self):\n heptagon = RegularPolygon(n=7, color=PURPLE, fill_opacity=0.5)\n heptagon.scale(2)\n \n # Animate drawing the heptagon\n self.play(Create(heptagon), run_time=2)\n \n # Pulsate the heptagon\n self.play(\n heptagon.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=1.5\n )\n \n # Split into smaller heptagons at vertices\n small_heptagons = VGroup(*[\n RegularPolygon(n=7, color=PURPLE, fill_opacity=0.3).scale(0.5).move_to(point)\n for point in heptagon.get_vertices()\n ])\n \n self.play(\n Transform(heptagon, small_heptagons),\n run_time=1.5\n )\n \n # Rotate small heptagons around center\n def update_rotate(mob, dt):\n mob.rotate(0.05, about_point=ORIGIN)\n \n small_heptagons.add_updater(update_rotate)\n self.add(small_heptagons)\n \n # Add trails\n trails = VGroup(*[\n TracedPath(hept.get_center, stroke_color=PURPLE, stroke_width=2)\n for hept in small_heptagons\n ])\n self.add(trails)\n \n # Show formula\n formula = MathTex(\n r\"\\text{Interior angle} = \\frac{5\\pi}{7} \\approx 128.57^\\circ\",\n color=YELLOW\n ).to_edge(UP)\n \n explanation = Text(\n \"For a regular heptagon (7 sides)\",\n font_size=24\n ).next_to(formula, DOWN)\n \n self.play(Write(formula), FadeIn(explanation), run_time=1.5)\n self.wait(2)\n \n # Reassemble the original heptagon\n small_heptagons.remove_updater(update_rotate)\n self.play(\n Transform(small_heptagons, heptagon),\n FadeOut(trails),\n FadeOut(formula),\n FadeOut(explanation),\n run_time=2\n )\n \n self.wait()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 2: Here is the enhanced animation description: "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0321(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_symplecticinnerproduct()\n self.clear_stage()\n self.act_2_animatedheptagon()\n\n def act_1_symplecticinnerproduct(self):\n title = Text('Symplectic Inner Product & Commutativity', 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 intro_text = Text('Vectors u and v correspond to Pauli operators P and Q', font_size=26)\n intro_text.next_to(title_group, DOWN, buff=0.6)\n self.play(FadeIn(intro_text, shift=DOWN * 0.2), run_time=1)\n formula = MathTex('u \\\\odot v = \\\\sum_{i=1}^n (u_{x,i} v_{z,i} + u_{z,i} v_{x,i}) \\\\pmod{2}', font_size=38)\n formula.next_to(intro_text, DOWN, buff=0.5)\n formula_box = SurroundingRectangle(formula, color=YELLOW, buff=0.2)\n self.play(Write(formula), run_time=1.5)\n self.play(Create(formula_box), run_time=0.8)\n crit_title = Text('Commutativity Criterion:', font_size=28, color=BLUE)\n crit_title.next_to(formula_box, DOWN, buff=0.7)\n crit_1 = MathTex('u \\\\odot v = 0 \\\\implies P \\\\text{ and } Q \\\\text{ commute}', font_size=32)\n crit_2 = MathTex('u \\\\odot v = 1 \\\\implies P \\\\text{ and } Q \\\\text{ anti-commute}', font_size=32)\n crit_group = VGroup(crit_1, crit_2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n crit_group.next_to(crit_title, DOWN, buff=0.3)\n self.play(Write(crit_title), run_time=1)\n self.play(FadeIn(crit_group, shift=UP * 0.2), run_time=1.5)\n conc_text = Tex('Finding stabilizer subgroups $\\\\Rightarrow$ Finding isotropic subspaces in $\\\\mathbb{Z}_2^{2n}$', font_size=30, color=GREEN)\n conc_text.next_to(crit_group, DOWN, buff=0.7)\n self.play(Write(conc_text), run_time=1.5)\n self.wait(0.5)\n\n def act_2_animatedheptagon(self):\n heptagon = RegularPolygon(n=7, color=PURPLE, fill_opacity=0.5)\n heptagon.scale(2)\n \n # Animate drawing the heptagon\n self.play(Create(heptagon), run_time=2)\n \n # Pulsate the heptagon\n self.play(\n heptagon.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=1.5\n )\n \n # Split into smaller heptagons at vertices\n small_heptagons = VGroup(*[\n RegularPolygon(n=7, color=PURPLE, fill_opacity=0.3).scale(0.5).move_to(point)\n for point in heptagon.get_vertices()\n ])\n \n self.play(\n Transform(heptagon, small_heptagons),\n run_time=1.5\n )\n \n # Rotate small heptagons around center\n def update_rotate(mob, dt):\n mob.rotate(0.05, about_point=ORIGIN)\n \n small_heptagons.add_updater(update_rotate)\n self.add(small_heptagons)\n \n # Add trails\n trails = VGroup(*[\n TracedPath(hept.get_center, stroke_color=PURPLE, stroke_width=2)\n for hept in small_heptagons\n ])\n self.add(trails)\n \n # Show formula\n formula = MathTex(\n r\"\\text{Interior angle} = \\frac{5\\pi}{7} \\approx 128.57^\\circ\",\n color=YELLOW\n ).to_edge(UP)\n \n explanation = Text(\n \"For a regular heptagon (7 sides)\",\n font_size=24\n ).next_to(formula, DOWN)\n \n self.play(Write(formula), FadeIn(explanation), run_time=1.5)\n self.wait(2)\n \n # Reassemble the original heptagon\n small_heptagons.remove_updater(update_rotate)\n self.play(\n Transform(small_heptagons, heptagon),\n FadeOut(trails),\n FadeOut(formula),\n FadeOut(explanation),\n run_time=2\n )\n \n self.wait()\n```"}]}
{"id": "manim-sft-10k_002899", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "DiscountFactorScene", "num_animations": 29, "num_rich_primitives": 2, "prompt": "In an infinitely repeated Prisoner's Dilemma with a discount factor less than 1, how does varying the discount rate influence the set of achievable payoffs?", "code": "from manim import *\n\nclass DiscountFactorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unpacking Repeated Games: The Mystery of Discount Factors\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Element 1: Prisoner's Dilemma Grid\n pd_title = Text(\"Prisoner's Dilemma\", font_size=28).to_edge(UP)\n \n # Create a simplified grid\n square = Square(side_length=4, color=WHITE)\n h_line = Line(square.get_left(), square.get_right(), color=WHITE)\n v_line = Line(square.get_top(), square.get_bottom(), color=WHITE)\n \n # Add payoff labels\n cc = Text(\"(3,3)\", font_size=24).move_to(square.get_corner(UL) + DOWN + RIGHT)\n cd = Text(\"(0,5)\", font_size=24).move_to(square.get_corner(UR) + DOWN + LEFT)\n dc = Text(\"(5,0)\", font_size=24).move_to(square.get_corner(DL) + UP + RIGHT)\n dd = Text(\"(1,1)\", font_size=24).move_to(square.get_corner(DR) + UP + LEFT)\n \n grid = VGroup(square, h_line, v_line, cc, cd, dc, dd)\n \n self.play(Write(pd_title))\n self.play(Create(grid))\n self.wait(1.5)\n self.play(FadeOut(pd_title), FadeOut(grid))\n \n # Element 2: Two players in repeated game\n players_title = Text(\"Repeated Interactions\", font_size=28).to_edge(UP)\n \n player1 = Circle(radius=0.5, color=BLUE).shift(LEFT * 2)\n player2 = Circle(radius=0.5, color=GREEN).shift(RIGHT * 2)\n p1_label = Text(\"Player 1\", font_size=20).next_to(player1, DOWN)\n p2_label = Text(\"Player 2\", font_size=20).next_to(player2, DOWN)\n \n # Arrow showing interaction\n arrow = Arrow(player1.get_right(), player2.get_left(), color=WHITE)\n \n self.play(Write(players_title))\n self.play(Create(player1), Create(player2))\n self.play(Write(p1_label), Write(p2_label))\n self.play(Create(arrow))\n self.wait(1)\n \n self.play(\n FadeOut(players_title), FadeOut(player1), FadeOut(player2), \n FadeOut(p1_label), FadeOut(p2_label), FadeOut(arrow)\n )\n \n # Element 3: Discount factor explanation\n discount_title = Text(\"Discount Factor (\\delta )\", font_size=28).to_edge(UP)\n discount_text = Text(\"How much we value future payoffs\", font_size=24).next_to(discount_title, DOWN)\n \n # Simple line showing discount factor range\n line = Line(LEFT * 3, RIGHT * 3, color=WHITE)\n zero = Text(\"0\", font_size=20).next_to(line.get_start(), DOWN)\n one = Text(\"1\", font_size=20).next_to(line.get_end(), DOWN)\n \n self.play(Write(discount_title))\n self.play(Write(discount_text))\n self.play(Create(line), Write(zero), Write(one))\n self.wait(1.5)\n \n self.play(\n FadeOut(discount_title), FadeOut(discount_text),\n FadeOut(line), FadeOut(zero), FadeOut(one)\n )\n \n # Element 4: First Equation\n eq1_title = Text(\"Present Value Formula\", font_size=28).to_edge(UP)\n \n equation1 = MathTex(\"V = \\\\frac{P}{1 - \\\\delta}\")\n eq1_explain = Text(\"V: total value, P: payoff per period\", font_size=24).next_to(equation1, DOWN)\n \n self.play(Write(eq1_title))\n self.play(Write(equation1))\n self.play(Write(eq1_explain))\n self.wait(1.5)\n \n self.play(FadeOut(eq1_title), FadeOut(equation1), FadeOut(eq1_explain))\n \n # Element 4b: Second Equation\n eq2_title = Text(\"Future Cooperation Utility\", font_size=28).to_edge(UP)\n \n equation2 = MathTex(\"u_2 = \\\\delta^2 \\\\cdot (c_1) + \\\\delta^1 \\\\cdot (c_2)\")\n eq2_explain = Text(\"Discounted future cooperation payoffs\", font_size=24).next_to(equation2, DOWN)\n \n self.play(Write(eq2_title))\n self.play(Write(equation2))\n self.play(Write(eq2_explain))\n self.wait(1.5)\n \n self.play(FadeOut(eq2_title), FadeOut(equation2), FadeOut(eq2_explain))\n \n # Element 5: Simplified payoff visualization\n payoff_title = Text(\"Achievable Payoffs\", font_size=28).to_edge(UP)\n \n # Simple circles to represent payoff spaces\n small_circle = Circle(radius=0.75, color=BLUE).shift(LEFT * 2)\n large_circle = Circle(radius=2, color=GREEN).shift(RIGHT * 2)\n small_circle.set_fill(BLUE, opacity=0.3)\n large_circle.set_fill(GREEN, opacity=0.3)\n \n low_delta = Text(\"Low \\delta \", font_size=20).next_to(small_circle, DOWN)\n high_delta = Text(\"High \\delta \", font_size=20).next_to(large_circle, DOWN)\n \n self.play(Write(payoff_title))\n self.play(Create(small_circle), Write(low_delta))\n self.play(Create(large_circle), Write(high_delta))\n \n explanation = Text(\"Higher \\delta \\rightarrow Larger set of achievable payoffs\", font_size=24).to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(1.5)\n \n self.play(\n FadeOut(payoff_title), FadeOut(small_circle), FadeOut(large_circle),\n FadeOut(low_delta), FadeOut(high_delta), FadeOut(explanation)\n )\n \n # Conclusion\n conclusion = Text(\"Higher discount factors enable\\nmore cooperative strategies\", font_size=28)\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "In an infinitely repeated Prisoner's Dilemma with a discount factor less than 1, how does varying the discount rate influence the set of achievable payoffs?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DiscountFactorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unpacking Repeated Games: The Mystery of Discount Factors\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Element 1: Prisoner's Dilemma Grid\n pd_title = Text(\"Prisoner's Dilemma\", font_size=28).to_edge(UP)\n \n # Create a simplified grid\n square = Square(side_length=4, color=WHITE)\n h_line = Line(square.get_left(), square.get_right(), color=WHITE)\n v_line = Line(square.get_top(), square.get_bottom(), color=WHITE)\n \n # Add payoff labels\n cc = Text(\"(3,3)\", font_size=24).move_to(square.get_corner(UL) + DOWN + RIGHT)\n cd = Text(\"(0,5)\", font_size=24).move_to(square.get_corner(UR) + DOWN + LEFT)\n dc = Text(\"(5,0)\", font_size=24).move_to(square.get_corner(DL) + UP + RIGHT)\n dd = Text(\"(1,1)\", font_size=24).move_to(square.get_corner(DR) + UP + LEFT)\n \n grid = VGroup(square, h_line, v_line, cc, cd, dc, dd)\n \n self.play(Write(pd_title))\n self.play(Create(grid))\n self.wait(1.5)\n self.play(FadeOut(pd_title), FadeOut(grid))\n \n # Element 2: Two players in repeated game\n players_title = Text(\"Repeated Interactions\", font_size=28).to_edge(UP)\n \n player1 = Circle(radius=0.5, color=BLUE).shift(LEFT * 2)\n player2 = Circle(radius=0.5, color=GREEN).shift(RIGHT * 2)\n p1_label = Text(\"Player 1\", font_size=20).next_to(player1, DOWN)\n p2_label = Text(\"Player 2\", font_size=20).next_to(player2, DOWN)\n \n # Arrow showing interaction\n arrow = Arrow(player1.get_right(), player2.get_left(), color=WHITE)\n \n self.play(Write(players_title))\n self.play(Create(player1), Create(player2))\n self.play(Write(p1_label), Write(p2_label))\n self.play(Create(arrow))\n self.wait(1)\n \n self.play(\n FadeOut(players_title), FadeOut(player1), FadeOut(player2), \n FadeOut(p1_label), FadeOut(p2_label), FadeOut(arrow)\n )\n \n # Element 3: Discount factor explanation\n discount_title = Text(\"Discount Factor (\\delta )\", font_size=28).to_edge(UP)\n discount_text = Text(\"How much we value future payoffs\", font_size=24).next_to(discount_title, DOWN)\n \n # Simple line showing discount factor range\n line = Line(LEFT * 3, RIGHT * 3, color=WHITE)\n zero = Text(\"0\", font_size=20).next_to(line.get_start(), DOWN)\n one = Text(\"1\", font_size=20).next_to(line.get_end(), DOWN)\n \n self.play(Write(discount_title))\n self.play(Write(discount_text))\n self.play(Create(line), Write(zero), Write(one))\n self.wait(1.5)\n \n self.play(\n FadeOut(discount_title), FadeOut(discount_text),\n FadeOut(line), FadeOut(zero), FadeOut(one)\n )\n \n # Element 4: First Equation\n eq1_title = Text(\"Present Value Formula\", font_size=28).to_edge(UP)\n \n equation1 = MathTex(\"V = \\\\frac{P}{1 - \\\\delta}\")\n eq1_explain = Text(\"V: total value, P: payoff per period\", font_size=24).next_to(equation1, DOWN)\n \n self.play(Write(eq1_title))\n self.play(Write(equation1))\n self.play(Write(eq1_explain))\n self.wait(1.5)\n \n self.play(FadeOut(eq1_title), FadeOut(equation1), FadeOut(eq1_explain))\n \n # Element 4b: Second Equation\n eq2_title = Text(\"Future Cooperation Utility\", font_size=28).to_edge(UP)\n \n equation2 = MathTex(\"u_2 = \\\\delta^2 \\\\cdot (c_1) + \\\\delta^1 \\\\cdot (c_2)\")\n eq2_explain = Text(\"Discounted future cooperation payoffs\", font_size=24).next_to(equation2, DOWN)\n \n self.play(Write(eq2_title))\n self.play(Write(equation2))\n self.play(Write(eq2_explain))\n self.wait(1.5)\n \n self.play(FadeOut(eq2_title), FadeOut(equation2), FadeOut(eq2_explain))\n \n # Element 5: Simplified payoff visualization\n payoff_title = Text(\"Achievable Payoffs\", font_size=28).to_edge(UP)\n \n # Simple circles to represent payoff spaces\n small_circle = Circle(radius=0.75, color=BLUE).shift(LEFT * 2)\n large_circle = Circle(radius=2, color=GREEN).shift(RIGHT * 2)\n small_circle.set_fill(BLUE, opacity=0.3)\n large_circle.set_fill(GREEN, opacity=0.3)\n \n low_delta = Text(\"Low \\delta \", font_size=20).next_to(small_circle, DOWN)\n high_delta = Text(\"High \\delta \", font_size=20).next_to(large_circle, DOWN)\n \n self.play(Write(payoff_title))\n self.play(Create(small_circle), Write(low_delta))\n self.play(Create(large_circle), Write(high_delta))\n \n explanation = Text(\"Higher \\delta \\rightarrow Larger set of achievable payoffs\", font_size=24).to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(1.5)\n \n self.play(\n FadeOut(payoff_title), FadeOut(small_circle), FadeOut(large_circle),\n FadeOut(low_delta), FadeOut(high_delta), FadeOut(explanation)\n )\n \n # Conclusion\n conclusion = Text(\"Higher discount factors enable\\nmore cooperative strategies\", font_size=28)\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```"}]}
{"id": "adaption-unified-manim-instructions_006874", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "NewYearRocketScene", "num_animations": 9, "num_rich_primitives": 4, "prompt": "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.", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0483", "num_animations": 13, "prompt": "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", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrateSinCos", "num_animations": 9, "num_rich_primitives": 3, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "AOS-Narrated-Manim-400_000269", "source": "nabin2004/AOS-Narrated-Manim-400", "tier": 1, "scene_name": "TrainingPipelinesVisualization", "num_animations": 10, "num_rich_primitives": 4, "prompt": "I'm teaching training pipelines and want real-time visibility of the loss printed to a console log as training progresses. Create a streaming log visualization with iter/epoch markers, a dynamic text console, and a live plot of loss vs time. Include highlights when the loss drops, and a small panel summarizing current learning rate and accuracy.", "code": "from manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass TrainingPipelinesVisualization(VoiceoverScene):\n def construct(self):\n self.set_speech_service(\n GTTSService(voice=\"alba\", cache_dir=\"voiceover_cache\")\n )\n\n # Title\n title = Text(\"AI Training Pipeline\", font_size=44)\n title.to_edge(UP, buff=0.5)\n\n with self.voiceover(text=\"Have you ever wondered how an AI model goes from raw data to a fully trained system? In today's session, we'll explore the fascinating journey that data takes in a training pipeline, shedding light on each crucial step in this transformative process!\") as tracker:\n self.play(Write(title), run_time=tracker.duration)\n\n # Pipeline stages\n stage_data = [\n (\"Data\", \"Collection\"),\n (\"Data\", \"Preprocessing\"),\n (\"Model\", \"Architecture\"),\n (\"Training\", \"Loop\"),\n (\"Evaluation\", \"\"),\n (\"Deployment\", \"\")\n ]\n\n stage_groups = VGroup()\n for main, sub in stage_data:\n box = Rectangle(width=1.6, height=0.9, color=BLUE, fill_opacity=0.2)\n if sub:\n label = VGroup(\n Text(main, font_size=16, weight=BOLD),\n Text(sub, font_size=14)\n ).arrange(DOWN, buff=0.06)\n else:\n label = Text(main, font_size=16, weight=BOLD)\n group = VGroup(box, label)\n stage_groups.add(group)\n\n stage_groups.arrange(RIGHT, buff=0.5)\n stage_groups.move_to(ORIGIN + DOWN * 0.2)\n\n if stage_groups.width > 12:\n stage_groups.scale_to_fit_width(11.5)\n\n # Arrows\n arrows = VGroup()\n for i in range(len(stage_groups) - 1):\n arrow = Arrow(\n start=stage_groups[i].get_right(),\n end=stage_groups[i+1].get_left(),\n buff=0.08,\n color=YELLOW,\n stroke_width=3,\n tip_length=0.15\n )\n arrows.add(arrow)\n\n with self.voiceover(text=\"A training pipeline consists of several key stages, each playing a vital role in transforming raw data into an intelligent system.\") as tracker:\n self.play(\n LaggedStart(*[FadeIn(g) for g in stage_groups], lag_ratio=0.15),\n run_time=tracker.duration\n )\n\n with self.voiceover(text=\"Data flows sequentially from one stage to the next. Let's trace this path together.\") as tracker:\n self.play(\n LaggedStart(*[GrowArrow(a) for a in arrows], lag_ratio=0.15),\n run_time=tracker.duration\n )\n\n explanations = [\n \"First, we collect raw data from various sources. This is the foundation of any AI system.\",\n \"Next, we preprocess the data — cleaning, normalizing, and formatting it for the model.\",\n \"Then we define the model architecture, choosing the right network structure for our task.\",\n \"The training loop is where the magic happens. The model learns patterns by adjusting its weights over many iterations.\",\n \"After training, we evaluate the model's performance on unseen data to ensure it generalizes well.\",\n \"Finally, we deploy the trained model so it can make real-world predictions and deliver value.\"\n ]\n\n for i, exp in enumerate(explanations):\n box = stage_groups[i][0]\n with self.voiceover(text=exp) as tracker:\n self.play(\n box.animate.set_fill(YELLOW, opacity=0.4).set_stroke(YELLOW, width=3),\n run_time=min(tracker.duration * 0.4, 1.0)\n )\n self.wait(max(tracker.duration - 1.0, 0.5))\n self.play(\n box.animate.set_fill(BLUE, opacity=0.2).set_stroke(BLUE, width=2),\n run_time=0.5\n )\n\n # Data flow dot\n data_dot = Dot(color=GREEN, radius=0.1)\n data_dot.move_to(stage_groups[0].get_center())\n\n with self.voiceover(text=\"Watch how a single data point travels through the entire pipeline, transforming at every stage until it helps produce a prediction.\") as tracker:\n self.play(FadeIn(data_dot), run_time=0.5)\n for i in range(len(stage_groups) - 1):\n mid_point = arrows[i].get_center()\n self.play(\n data_dot.animate.move_to(mid_point),\n run_time=0.4\n )\n self.play(\n data_dot.animate.move_to(stage_groups[i+1].get_center()),\n run_time=0.4\n )\n self.play(FadeOut(data_dot), run_time=0.5)\n\n # Summary\n summary_title = Text(\"Key Takeaways\", font_size=28, weight=BOLD, color=WHITE)\n takeaways = VGroup(\n Text(\"• Define the key components of a training pipeline\", font_size=20),\n Text(\"• Illustrate the data flow from input to output\", font_size=20),\n Text(\"• Explain the importance of each stage in model training\", font_size=20)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n\n summary_group = VGroup(summary_title, takeaways).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n summary_group.to_edge(DOWN, buff=0.4)\n summary_box = SurroundingRectangle(summary_group, color=GRAY, buff=0.3, corner_radius=0.1)\n\n with self.voiceover(text=\"To summarize: you should now be able to define the key components of a training pipeline, illustrate the data flow from input to output, and explain why each stage matters for successful model training.\") as tracker:\n self.play(\n Create(summary_box),\n FadeIn(summary_group),\n run_time=tracker.duration\n )\n\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'm teaching training pipelines and want real-time visibility of the loss printed to a console log as training progresses. Create a streaming log visualization with iter/epoch markers, a dynamic text console, and a live plot of loss vs time. Include highlights when the loss drops, and a small panel summarizing current learning rate and accuracy."}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim_voiceover import VoiceoverScene\nfrom manim_voiceover.services.gtts import GTTSService\n\nclass TrainingPipelinesVisualization(VoiceoverScene):\n def construct(self):\n self.set_speech_service(\n GTTSService(voice=\"alba\", cache_dir=\"voiceover_cache\")\n )\n\n # Title\n title = Text(\"AI Training Pipeline\", font_size=44)\n title.to_edge(UP, buff=0.5)\n\n with self.voiceover(text=\"Have you ever wondered how an AI model goes from raw data to a fully trained system? In today's session, we'll explore the fascinating journey that data takes in a training pipeline, shedding light on each crucial step in this transformative process!\") as tracker:\n self.play(Write(title), run_time=tracker.duration)\n\n # Pipeline stages\n stage_data = [\n (\"Data\", \"Collection\"),\n (\"Data\", \"Preprocessing\"),\n (\"Model\", \"Architecture\"),\n (\"Training\", \"Loop\"),\n (\"Evaluation\", \"\"),\n (\"Deployment\", \"\")\n ]\n\n stage_groups = VGroup()\n for main, sub in stage_data:\n box = Rectangle(width=1.6, height=0.9, color=BLUE, fill_opacity=0.2)\n if sub:\n label = VGroup(\n Text(main, font_size=16, weight=BOLD),\n Text(sub, font_size=14)\n ).arrange(DOWN, buff=0.06)\n else:\n label = Text(main, font_size=16, weight=BOLD)\n group = VGroup(box, label)\n stage_groups.add(group)\n\n stage_groups.arrange(RIGHT, buff=0.5)\n stage_groups.move_to(ORIGIN + DOWN * 0.2)\n\n if stage_groups.width > 12:\n stage_groups.scale_to_fit_width(11.5)\n\n # Arrows\n arrows = VGroup()\n for i in range(len(stage_groups) - 1):\n arrow = Arrow(\n start=stage_groups[i].get_right(),\n end=stage_groups[i+1].get_left(),\n buff=0.08,\n color=YELLOW,\n stroke_width=3,\n tip_length=0.15\n )\n arrows.add(arrow)\n\n with self.voiceover(text=\"A training pipeline consists of several key stages, each playing a vital role in transforming raw data into an intelligent system.\") as tracker:\n self.play(\n LaggedStart(*[FadeIn(g) for g in stage_groups], lag_ratio=0.15),\n run_time=tracker.duration\n )\n\n with self.voiceover(text=\"Data flows sequentially from one stage to the next. Let's trace this path together.\") as tracker:\n self.play(\n LaggedStart(*[GrowArrow(a) for a in arrows], lag_ratio=0.15),\n run_time=tracker.duration\n )\n\n explanations = [\n \"First, we collect raw data from various sources. This is the foundation of any AI system.\",\n \"Next, we preprocess the data — cleaning, normalizing, and formatting it for the model.\",\n \"Then we define the model architecture, choosing the right network structure for our task.\",\n \"The training loop is where the magic happens. The model learns patterns by adjusting its weights over many iterations.\",\n \"After training, we evaluate the model's performance on unseen data to ensure it generalizes well.\",\n \"Finally, we deploy the trained model so it can make real-world predictions and deliver value.\"\n ]\n\n for i, exp in enumerate(explanations):\n box = stage_groups[i][0]\n with self.voiceover(text=exp) as tracker:\n self.play(\n box.animate.set_fill(YELLOW, opacity=0.4).set_stroke(YELLOW, width=3),\n run_time=min(tracker.duration * 0.4, 1.0)\n )\n self.wait(max(tracker.duration - 1.0, 0.5))\n self.play(\n box.animate.set_fill(BLUE, opacity=0.2).set_stroke(BLUE, width=2),\n run_time=0.5\n )\n\n # Data flow dot\n data_dot = Dot(color=GREEN, radius=0.1)\n data_dot.move_to(stage_groups[0].get_center())\n\n with self.voiceover(text=\"Watch how a single data point travels through the entire pipeline, transforming at every stage until it helps produce a prediction.\") as tracker:\n self.play(FadeIn(data_dot), run_time=0.5)\n for i in range(len(stage_groups) - 1):\n mid_point = arrows[i].get_center()\n self.play(\n data_dot.animate.move_to(mid_point),\n run_time=0.4\n )\n self.play(\n data_dot.animate.move_to(stage_groups[i+1].get_center()),\n run_time=0.4\n )\n self.play(FadeOut(data_dot), run_time=0.5)\n\n # Summary\n summary_title = Text(\"Key Takeaways\", font_size=28, weight=BOLD, color=WHITE)\n takeaways = VGroup(\n Text(\"• Define the key components of a training pipeline\", font_size=20),\n Text(\"• Illustrate the data flow from input to output\", font_size=20),\n Text(\"• Explain the importance of each stage in model training\", font_size=20)\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n\n summary_group = VGroup(summary_title, takeaways).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n summary_group.to_edge(DOWN, buff=0.4)\n summary_box = SurroundingRectangle(summary_group, color=GRAY, buff=0.3, corner_radius=0.1)\n\n with self.voiceover(text=\"To summarize: you should now be able to define the key components of a training pipeline, illustrate the data flow from input to output, and explain why each stage matters for successful model training.\") as tracker:\n self.play(\n Create(summary_box),\n FadeIn(summary_group),\n run_time=tracker.duration\n )\n\n self.wait(1)\n```"}]}
{"id": "manim-sft-10k_003157", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "ErrorEstimationPINN", "num_animations": 9, "num_rich_primitives": 2, "prompt": "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### 4.2 Error Estimation Theorem for PINN\n\nError analysis provides a theoretical foundation for the PINN method, but also reveals its limitations.\n\n- **Theorem 1 (Dimension-Independent Error Bound)**\n - Conditions: Sample size \\(N,M = \\left( \\frac{|\\Omega|}{\\delta} \\right)^W (D + W)(2/\\epsilon)^W\\) (\\(\\delta\\) is an arbitrarily small number, \\(D, W\\) are network parameters, \\(B\\) is the boundary)\n - Conclusion: \\(\\mathbb{P}(E(a) \\leq \\epsilon)\\), where \\(E(a)\\) is the loss of PINN, and the error order is independent of the problem dimension \\(d\\), indicating that under certain conditions, PINN can overcome the curse of dimensionality\n\n\nThe context of this section (from highest to current level):\n# Neural Networks for Solving Differential Equations\n## 4. Error Analysis\n", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ErrorEstimationPINN(Scene):\n\n def construct(self):\n title = Title('4.2 Error Estimation Theorem for PINN', match_underline_width_to_text=True)\n self.play(Write(title))\n self.wait(0.5)\n intro_text = Text('Error analysis provides a theoretical foundation for the PINN method,\\nbut also reveals its limitations.', font_size=28, t2c={'theoretical foundation': BLUE_C, 'limitations': RED_C})\n intro_text.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(intro_text, shift=DOWN))\n self.wait(1)\n thm_title = Text('Theorem 1 (Dimension-Independent Error Bound)', font_size=30, color=YELLOW)\n thm_title.next_to(intro_text, DOWN, buff=0.8).to_edge(LEFT, buff=1)\n cond_label = Text('Conditions:', font_size=26, color=BLUE_B)\n cond_label.next_to(thm_title, DOWN, buff=0.5).align_to(thm_title, LEFT)\n cond_math = MathTex('\\\\text{Sample size } N, M = \\\\left( \\\\frac{|\\\\Omega|}{\\\\delta} \\\\right)^W (D + W)(2/\\\\epsilon)^W', font_size=32)\n cond_math.next_to(cond_label, RIGHT, buff=0.3)\n cond_desc = Tex('($\\\\delta$ is an arbitrarily small number, $D, W$ are network parameters, $B$ is the boundary)', font_size=26, color=LIGHT_GREY)\n cond_desc.next_to(cond_label, DOWN, buff=0.2).align_to(cond_label, LEFT).shift(RIGHT * 0.5)\n conc_label = Text('Conclusion:', font_size=26, color=GREEN_B)\n conc_label.next_to(cond_desc, DOWN, buff=0.6).align_to(thm_title, LEFT)\n conc_math = MathTex('\\\\mathbb{P}(E(a) \\\\leq \\\\epsilon)', font_size=32)\n conc_math.next_to(conc_label, RIGHT, buff=0.3)\n conc_desc = Tex('where $E(a)$ is the loss of PINN, and the error order is independent\\\\\\\\of the problem dimension $d$, indicating that under certain conditions,\\\\\\\\PINN can overcome the \\\\textbf{curse of dimensionality}.', font_size=26, color=LIGHT_GREY, tex_environment='flushleft')\n conc_desc.next_to(conc_label, DOWN, buff=0.2).align_to(conc_label, LEFT).shift(RIGHT * 0.5)\n theorem_group = VGroup(thm_title, cond_label, cond_math, cond_desc, conc_label, conc_math, conc_desc)\n box = SurroundingRectangle(theorem_group, color=YELLOW_A, buff=0.4, corner_radius=0.2)\n self.play(Write(thm_title))\n self.play(Create(box))\n self.wait(0.5)\n self.play(Write(cond_label), FadeIn(cond_math, shift=LEFT))\n self.play(FadeIn(cond_desc))\n self.wait(1)\n self.play(Write(conc_label), FadeIn(conc_math, shift=LEFT))\n self.play(FadeIn(conc_desc))\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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### 4.2 Error Estimation Theorem for PINN\n\nError analysis provides a theoretical foundation for the PINN method, but also reveals its limitations.\n\n- **Theorem 1 (Dimension-Independent Error Bound)**\n - Conditions: Sample size \\(N,M = \\left( \\frac{|\\Omega|}{\\delta} \\right)^W (D + W)(2/\\epsilon)^W\\) (\\(\\delta\\) is an arbitrarily small number, \\(D, W\\) are network parameters, \\(B\\) is the boundary)\n - Conclusion: \\(\\mathbb{P}(E(a) \\leq \\epsilon)\\), where \\(E(a)\\) is the loss of PINN, and the error order is independent of the problem dimension \\(d\\), indicating that under certain conditions, PINN can overcome the curse of dimensionality\n\n\nThe context of this section (from highest to current level):\n# Neural Networks for Solving Differential Equations\n## 4. Error Analysis\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ErrorEstimationPINN(Scene):\n\n def construct(self):\n title = Title('4.2 Error Estimation Theorem for PINN', match_underline_width_to_text=True)\n self.play(Write(title))\n self.wait(0.5)\n intro_text = Text('Error analysis provides a theoretical foundation for the PINN method,\\nbut also reveals its limitations.', font_size=28, t2c={'theoretical foundation': BLUE_C, 'limitations': RED_C})\n intro_text.next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(intro_text, shift=DOWN))\n self.wait(1)\n thm_title = Text('Theorem 1 (Dimension-Independent Error Bound)', font_size=30, color=YELLOW)\n thm_title.next_to(intro_text, DOWN, buff=0.8).to_edge(LEFT, buff=1)\n cond_label = Text('Conditions:', font_size=26, color=BLUE_B)\n cond_label.next_to(thm_title, DOWN, buff=0.5).align_to(thm_title, LEFT)\n cond_math = MathTex('\\\\text{Sample size } N, M = \\\\left( \\\\frac{|\\\\Omega|}{\\\\delta} \\\\right)^W (D + W)(2/\\\\epsilon)^W', font_size=32)\n cond_math.next_to(cond_label, RIGHT, buff=0.3)\n cond_desc = Tex('($\\\\delta$ is an arbitrarily small number, $D, W$ are network parameters, $B$ is the boundary)', font_size=26, color=LIGHT_GREY)\n cond_desc.next_to(cond_label, DOWN, buff=0.2).align_to(cond_label, LEFT).shift(RIGHT * 0.5)\n conc_label = Text('Conclusion:', font_size=26, color=GREEN_B)\n conc_label.next_to(cond_desc, DOWN, buff=0.6).align_to(thm_title, LEFT)\n conc_math = MathTex('\\\\mathbb{P}(E(a) \\\\leq \\\\epsilon)', font_size=32)\n conc_math.next_to(conc_label, RIGHT, buff=0.3)\n conc_desc = Tex('where $E(a)$ is the loss of PINN, and the error order is independent\\\\\\\\of the problem dimension $d$, indicating that under certain conditions,\\\\\\\\PINN can overcome the \\\\textbf{curse of dimensionality}.', font_size=26, color=LIGHT_GREY, tex_environment='flushleft')\n conc_desc.next_to(conc_label, DOWN, buff=0.2).align_to(conc_label, LEFT).shift(RIGHT * 0.5)\n theorem_group = VGroup(thm_title, cond_label, cond_math, cond_desc, conc_label, conc_math, conc_desc)\n box = SurroundingRectangle(theorem_group, color=YELLOW_A, buff=0.4, corner_radius=0.2)\n self.play(Write(thm_title))\n self.play(Create(box))\n self.wait(0.5)\n self.play(Write(cond_label), FadeIn(cond_math, shift=LEFT))\n self.play(FadeIn(cond_desc))\n self.wait(1)\n self.play(Write(conc_label), FadeIn(conc_math, shift=LEFT))\n self.play(FadeIn(conc_desc))\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))\n```"}]}
{"id": "multi_act_v2_00159", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0159", "num_animations": 12, "prompt": "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", "code": "from 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))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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_00617", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0617", "num_animations": 19, "prompt": "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: Write Manim code for a scene demonstrating the concept of eigenvalues and eigenvectors. Begin with a matrix transformation, show the corresponding eigenvectors, and explain their significance.\n- Act 2: Here’s an enhanced version of the animation that retains all the original features while adding a dynamic mathematical explanation and a transformation sequence: \n- Act 3: Can you create an animation showing the first ten terms of a Fourier series approximation of a square wave using Manim?", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0617(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_eigenvalueseigenvectors()\n self.clear_stage()\n self.act_2_enhancedhexagonanimation()\n self.clear_stage()\n self.act_3_neuralnetworkscene()\n\n def act_1_eigenvalueseigenvectors(self):\n matrix = Matrix([[1, 2], \n [0, 3]])\n \n # Show the matrix\n self.play(Write(matrix))\n \n # Calculate and show the eigenvalues\n eigenvalue1 = Text(\"\\lambda 1 = 1\")\n eigenvalue1.to_edge(UP) \n eigenvalue2 = Text(\"\\lambda 2 = 3\")\n eigenvalue2.next_to(eigenvalue1, DOWN)\n \n self.add(eigenvalue1, eigenvalue2)\n\n # Hide the matrix\n self.play(FadeOut(matrix))\n \n # Calculate and show the eigenvectors\n eigenvector1 = Arrow(LEFT, RIGHT).set_color(GREEN)\n eigenvector2 = Arrow(LEFT, RIGHT + DOWN).set_color(RED)\n \n self.play(Write(eigenvector1))\n self.play(Write(eigenvector2))\n \n # Explain eigenvectors\n explanation = Text(\"Eigenvectors define the principal axes \\nof the transformation.\")\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n \n # Apply the matrix transformation \n self.play(Transform(eigenvector1, eigenvector1.copy().scale(1)),\n Transform(eigenvector2, eigenvector2.copy().scale(3)))\n \n self.wait()\n\n def act_2_enhancedhexagonanimation(self):\n triangle = Triangle(color=RED, fill_opacity=0.7)\n triangle.scale(1.5)\n \n # Create the yellow hexagon\n hexagon = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.5)\n hexagon.scale(0.1).move_to(triangle.get_center())\n \n # Create the area formula\n area_formula = MathTex(\n r\"\\text{Area of Regular Hexagon} = \\frac{3\\sqrt{3}}{2} \\times \\text{side}^2\",\n font_size=36\n )\n area_formula.next_to(triangle, DOWN, buff=1)\n \n # Create the perimeter formula\n perimeter_formula = MathTex(\n r\"\\text{Perimeter} = 6 \\times \\text{side}\",\n font_size=36\n )\n perimeter_formula.move_to(area_formula.get_center())\n \n # Animate the triangle and hexagon\n self.play(FadeIn(triangle))\n self.play(\n GrowFromCenter(hexagon),\n Write(area_formula),\n run_time=2\n )\n self.wait(1)\n \n # Transform the hexagon and formula\n self.play(\n FadeOut(triangle),\n hexagon.animate.scale(0.5).shift(UP * 1.5),\n Transform(area_formula, perimeter_formula),\n run_time=2\n )\n self.wait(1)\n \n # Dissolve the formula and scatter hexagons\n self.play(FadeOut(hexagon))\n \n # Create multiple small hexagons\n small_hexagons = VGroup(*[\n RegularPolygon(n=6, color=YELLOW, fill_opacity=0.3).scale(0.2)\n for _ in range(12)\n ])\n \n # Position them randomly\n for hex in small_hexagons:\n hex.move_to(perimeter_formula.get_center())\n hex.shift(np.random.uniform(-3, 3) * RIGHT + np.random.uniform(-2, 2) * UP)\n \n self.play(\n FadeOut(perimeter_formula),\n LaggedStart(*[GrowFromCenter(hex) for hex in small_hexagons], lag_ratio=0.1),\n run_time=2\n )\n self.wait(1)\n\n def act_3_neuralnetworkscene(self):\n layers = VGroup(\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=BLUE, fill_opacity=0.5),\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=GREEN, fill_opacity=0.5),\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=RED, fill_opacity=0.5),\n )\n # Arrange layers vertically with a specified distance between them\n layers.arrange(DOWN, buff=0.5)\n\n # Add layer labels\n for i, layer in enumerate(layers):\n label = Text(f\"Layer {i+1}\", color=WHITE).scale(0.5)\n label.move_to(layer.get_center())\n layer.add(label)\n\n # Create arrows between layers\n arrows = VGroup()\n for i in range(len(layers) - 1):\n arrow = Arrow(start=layers[i].get_bottom(), end=layers[i+1].get_top(), buff=0.1)\n arrows.add(arrow)\n\n # Create the full neural network diagram and move it to the center\n neural_net = VGroup(layers, arrows)\n neural_net.move_to(ORIGIN)\n\n # Animation\n self.play(FadeIn(neural_net, shift=UP))\n self.wait(1)\n self.play(Transform(layers[0], layers[0].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n self.play(Transform(layers[1], layers[1].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n self.play(Transform(layers[2], layers[2].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n\n # Fade out animation\n self.play(FadeOut(neural_net, shift=DOWN))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: Write Manim code for a scene demonstrating the concept of eigenvalues and eigenvectors. Begin with a matrix transformation, show the corresponding eigenvectors, and explain their significance.\n- Act 2: Here’s an enhanced version of the animation that retains all the original features while adding a dynamic mathematical explanation and a transformation sequence: \n- Act 3: Can you create an animation showing the first ten terms of a Fourier series approximation of a square wave using Manim?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0617(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_eigenvalueseigenvectors()\n self.clear_stage()\n self.act_2_enhancedhexagonanimation()\n self.clear_stage()\n self.act_3_neuralnetworkscene()\n\n def act_1_eigenvalueseigenvectors(self):\n matrix = Matrix([[1, 2], \n [0, 3]])\n \n # Show the matrix\n self.play(Write(matrix))\n \n # Calculate and show the eigenvalues\n eigenvalue1 = Text(\"\\lambda 1 = 1\")\n eigenvalue1.to_edge(UP) \n eigenvalue2 = Text(\"\\lambda 2 = 3\")\n eigenvalue2.next_to(eigenvalue1, DOWN)\n \n self.add(eigenvalue1, eigenvalue2)\n\n # Hide the matrix\n self.play(FadeOut(matrix))\n \n # Calculate and show the eigenvectors\n eigenvector1 = Arrow(LEFT, RIGHT).set_color(GREEN)\n eigenvector2 = Arrow(LEFT, RIGHT + DOWN).set_color(RED)\n \n self.play(Write(eigenvector1))\n self.play(Write(eigenvector2))\n \n # Explain eigenvectors\n explanation = Text(\"Eigenvectors define the principal axes \\nof the transformation.\")\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n \n # Apply the matrix transformation \n self.play(Transform(eigenvector1, eigenvector1.copy().scale(1)),\n Transform(eigenvector2, eigenvector2.copy().scale(3)))\n \n self.wait()\n\n def act_2_enhancedhexagonanimation(self):\n triangle = Triangle(color=RED, fill_opacity=0.7)\n triangle.scale(1.5)\n \n # Create the yellow hexagon\n hexagon = RegularPolygon(n=6, color=YELLOW, fill_opacity=0.5)\n hexagon.scale(0.1).move_to(triangle.get_center())\n \n # Create the area formula\n area_formula = MathTex(\n r\"\\text{Area of Regular Hexagon} = \\frac{3\\sqrt{3}}{2} \\times \\text{side}^2\",\n font_size=36\n )\n area_formula.next_to(triangle, DOWN, buff=1)\n \n # Create the perimeter formula\n perimeter_formula = MathTex(\n r\"\\text{Perimeter} = 6 \\times \\text{side}\",\n font_size=36\n )\n perimeter_formula.move_to(area_formula.get_center())\n \n # Animate the triangle and hexagon\n self.play(FadeIn(triangle))\n self.play(\n GrowFromCenter(hexagon),\n Write(area_formula),\n run_time=2\n )\n self.wait(1)\n \n # Transform the hexagon and formula\n self.play(\n FadeOut(triangle),\n hexagon.animate.scale(0.5).shift(UP * 1.5),\n Transform(area_formula, perimeter_formula),\n run_time=2\n )\n self.wait(1)\n \n # Dissolve the formula and scatter hexagons\n self.play(FadeOut(hexagon))\n \n # Create multiple small hexagons\n small_hexagons = VGroup(*[\n RegularPolygon(n=6, color=YELLOW, fill_opacity=0.3).scale(0.2)\n for _ in range(12)\n ])\n \n # Position them randomly\n for hex in small_hexagons:\n hex.move_to(perimeter_formula.get_center())\n hex.shift(np.random.uniform(-3, 3) * RIGHT + np.random.uniform(-2, 2) * UP)\n \n self.play(\n FadeOut(perimeter_formula),\n LaggedStart(*[GrowFromCenter(hex) for hex in small_hexagons], lag_ratio=0.1),\n run_time=2\n )\n self.wait(1)\n\n def act_3_neuralnetworkscene(self):\n layers = VGroup(\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=BLUE, fill_opacity=0.5),\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=GREEN, fill_opacity=0.5),\n RoundedRectangle(cornerRadius=0.15, width=4, height=1, fill_color=RED, fill_opacity=0.5),\n )\n # Arrange layers vertically with a specified distance between them\n layers.arrange(DOWN, buff=0.5)\n\n # Add layer labels\n for i, layer in enumerate(layers):\n label = Text(f\"Layer {i+1}\", color=WHITE).scale(0.5)\n label.move_to(layer.get_center())\n layer.add(label)\n\n # Create arrows between layers\n arrows = VGroup()\n for i in range(len(layers) - 1):\n arrow = Arrow(start=layers[i].get_bottom(), end=layers[i+1].get_top(), buff=0.1)\n arrows.add(arrow)\n\n # Create the full neural network diagram and move it to the center\n neural_net = VGroup(layers, arrows)\n neural_net.move_to(ORIGIN)\n\n # Animation\n self.play(FadeIn(neural_net, shift=UP))\n self.wait(1)\n self.play(Transform(layers[0], layers[0].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n self.play(Transform(layers[1], layers[1].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n self.play(Transform(layers[2], layers[2].copy().set_fill(YELLOW, 0.5)))\n self.wait(1)\n\n # Fade out animation\n self.play(FadeOut(neural_net, shift=DOWN))\n```"}]}
{"id": "multi_act_v2_00491", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0491", "num_animations": 20, "prompt": "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: 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 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: I would like an animation that demonstrates the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the ", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0491(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_gradeprocessingencapsula()\n self.clear_stage()\n self.act_2_mapdefinition()\n self.clear_stage()\n self.act_3_sineapproximation()\n\n def act_1_gradeprocessingencapsula(self):\n title = Title('Process Encapsulation: Grade Processing Example', font_size=40)\n req_title = Text('Requirements:', font_size=36, weight=BOLD)\n req_title.next_to(title, DOWN, buff=0.6).to_edge(LEFT, buff=1.0)\n req_group = VGroup(Tex('$\\\\bullet$ Input the grades of $n$ students;', font_size=32), Tex('$\\\\bullet$ Calculate the average grade;', font_size=32), Tex('$\\\\bullet$ Find the highest grade;', font_size=32), Tex('$\\\\bullet$ Output the results.', font_size=32)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n req_group.next_to(req_title, DOWN, buff=0.4).align_to(req_title, LEFT).shift(RIGHT * 0.5)\n conclusion = Tex('These processes can be encapsulated\\\\\\\\[0.5em] into several independent functions.', font_size=36, color=YELLOW)\n conclusion_box = SurroundingRectangle(conclusion, color=BLUE, buff=0.4, corner_radius=0.2)\n conclusion_group = VGroup(conclusion_box, conclusion)\n conclusion_group.next_to(req_group, DOWN, buff=0.8)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(req_title, shift=RIGHT * 0.5))\n self.wait(0.5)\n for item in req_group:\n self.play(FadeIn(item, shift=RIGHT * 0.5), run_time=0.6)\n else:\n pass\n self.wait(1)\n self.play(Create(conclusion_box))\n self.play(Write(conclusion))\n self.wait(2)\n\n def act_2_mapdefinition(self):\n context_group = VGroup(Text('Introduction to Keypoints and Pose Estimation', font_size=24, color=GRAY), Text('Keypoint Evaluation Metrics', font_size=20, color=LIGHT_GRAY)).arrange(DOWN, buff=0.1)\n context_group.to_edge(UP)\n title = Text('Definition of mAP in Keypoint Tasks', font_size=36, color=BLUE)\n title.next_to(context_group, DOWN, buff=0.8)\n bullet = Paragraph('• The AP calculated at different thresholds based on OKS', ' (Object Keypoint Similarity) is a core metric for mainstream', ' datasets like COCO.', font_size=30, alignment='left')\n bullet.next_to(title, DOWN, buff=0.8)\n formula = MathTex('mAP = \\\\frac{1}{|T|} \\\\sum_{t \\\\in T} AP^{OKS=t}', font_size=44)\n formula.next_to(bullet, DOWN, buff=0.8)\n thresholds = MathTex('T = \\\\{0.50, 0.55, 0.60, \\\\dots, 0.95\\\\}', font_size=36, color=YELLOW)\n thresholds.next_to(formula, DOWN, buff=0.5)\n self.play(FadeIn(context_group, shift=DOWN * 0.5))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Write(formula))\n self.wait(0.5)\n self.play(FadeIn(thresholds, shift=UP * 0.5))\n coco_box = SurroundingRectangle(thresholds, color=GREEN, buff=0.2)\n coco_text = Text('COCO Standard', font_size=24, color=GREEN)\n coco_text.next_to(coco_box, RIGHT, buff=0.3)\n self.play(Create(coco_box), Write(coco_text))\n self.wait(3)\n\n def act_3_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n \n self.play(Create(axes))\n self.wait(1)\n\n # 2. Add Title\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # 3. Plot Sine Wave\n sine_wave = axes.plot(\n lambda x: np.sin(x), \n color=BLUE, \n x_range=[0, 10]\n )\n sine_label = axes.get_graph_label(sine_wave, label=\"\\\\sin(x)\")\n \n self.play(Create(sine_wave), Write(sine_label))\n self.wait(1)\n\n # 4. Plot Polynomial Approximation\n # Using the 5th-order Taylor polynomial: x - x^3/3! + x^5/5!\n # This provides a closer fit near the origin before diverging\n poly_wave = axes.plot(\n lambda x: x - (x**3 / 6) + (x**5 / 120), \n color=GREEN, \n x_range=[0, 4.5] \n )\n poly_label = axes.get_graph_label(poly_wave, label=\"P(x) = x - \\\\frac{x^3}{6} + \\\\frac{x^5}{120}\", x_val=3)\n poly_label.set_color(GREEN)\n\n self.play(Create(poly_wave), Write(poly_label))\n self.wait(1)\n\n # 5. Mark Specific Point\n # Point where angle is pi (x = PI, y = sin(PI) = 0)\n pi_val = np.pi\n dot = Dot(axes.c2p(pi_val, np.sin(pi_val)), color=RED)\n pi_label = MathTex(r\"\\pi\").next_to(dot, DOWN)\n\n self.play(FadeIn(dot), Write(pi_label))\n self.wait(1)\n\n # 6. Draw Projection Line\n # Dashed yellow vertical line from the red dot to the x-axis\n projection_line = DashedLine(\n start=dot.get_center(), \n end=axes.c2p(pi_val, 0), \n color=YELLOW\n )\n\n self.play(Create(projection_line))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: 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 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: I would like an animation that demonstrates the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the "}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0491(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_gradeprocessingencapsula()\n self.clear_stage()\n self.act_2_mapdefinition()\n self.clear_stage()\n self.act_3_sineapproximation()\n\n def act_1_gradeprocessingencapsula(self):\n title = Title('Process Encapsulation: Grade Processing Example', font_size=40)\n req_title = Text('Requirements:', font_size=36, weight=BOLD)\n req_title.next_to(title, DOWN, buff=0.6).to_edge(LEFT, buff=1.0)\n req_group = VGroup(Tex('$\\\\bullet$ Input the grades of $n$ students;', font_size=32), Tex('$\\\\bullet$ Calculate the average grade;', font_size=32), Tex('$\\\\bullet$ Find the highest grade;', font_size=32), Tex('$\\\\bullet$ Output the results.', font_size=32)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n req_group.next_to(req_title, DOWN, buff=0.4).align_to(req_title, LEFT).shift(RIGHT * 0.5)\n conclusion = Tex('These processes can be encapsulated\\\\\\\\[0.5em] into several independent functions.', font_size=36, color=YELLOW)\n conclusion_box = SurroundingRectangle(conclusion, color=BLUE, buff=0.4, corner_radius=0.2)\n conclusion_group = VGroup(conclusion_box, conclusion)\n conclusion_group.next_to(req_group, DOWN, buff=0.8)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(req_title, shift=RIGHT * 0.5))\n self.wait(0.5)\n for item in req_group:\n self.play(FadeIn(item, shift=RIGHT * 0.5), run_time=0.6)\n else:\n pass\n self.wait(1)\n self.play(Create(conclusion_box))\n self.play(Write(conclusion))\n self.wait(2)\n\n def act_2_mapdefinition(self):\n context_group = VGroup(Text('Introduction to Keypoints and Pose Estimation', font_size=24, color=GRAY), Text('Keypoint Evaluation Metrics', font_size=20, color=LIGHT_GRAY)).arrange(DOWN, buff=0.1)\n context_group.to_edge(UP)\n title = Text('Definition of mAP in Keypoint Tasks', font_size=36, color=BLUE)\n title.next_to(context_group, DOWN, buff=0.8)\n bullet = Paragraph('• The AP calculated at different thresholds based on OKS', ' (Object Keypoint Similarity) is a core metric for mainstream', ' datasets like COCO.', font_size=30, alignment='left')\n bullet.next_to(title, DOWN, buff=0.8)\n formula = MathTex('mAP = \\\\frac{1}{|T|} \\\\sum_{t \\\\in T} AP^{OKS=t}', font_size=44)\n formula.next_to(bullet, DOWN, buff=0.8)\n thresholds = MathTex('T = \\\\{0.50, 0.55, 0.60, \\\\dots, 0.95\\\\}', font_size=36, color=YELLOW)\n thresholds.next_to(formula, DOWN, buff=0.5)\n self.play(FadeIn(context_group, shift=DOWN * 0.5))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Write(formula))\n self.wait(0.5)\n self.play(FadeIn(thresholds, shift=UP * 0.5))\n coco_box = SurroundingRectangle(thresholds, color=GREEN, buff=0.2)\n coco_text = Text('COCO Standard', font_size=24, color=GREEN)\n coco_text.next_to(coco_box, RIGHT, buff=0.3)\n self.play(Create(coco_box), Write(coco_text))\n self.wait(3)\n\n def act_3_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n \n self.play(Create(axes))\n self.wait(1)\n\n # 2. Add Title\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # 3. Plot Sine Wave\n sine_wave = axes.plot(\n lambda x: np.sin(x), \n color=BLUE, \n x_range=[0, 10]\n )\n sine_label = axes.get_graph_label(sine_wave, label=\"\\\\sin(x)\")\n \n self.play(Create(sine_wave), Write(sine_label))\n self.wait(1)\n\n # 4. Plot Polynomial Approximation\n # Using the 5th-order Taylor polynomial: x - x^3/3! + x^5/5!\n # This provides a closer fit near the origin before diverging\n poly_wave = axes.plot(\n lambda x: x - (x**3 / 6) + (x**5 / 120), \n color=GREEN, \n x_range=[0, 4.5] \n )\n poly_label = axes.get_graph_label(poly_wave, label=\"P(x) = x - \\\\frac{x^3}{6} + \\\\frac{x^5}{120}\", x_val=3)\n poly_label.set_color(GREEN)\n\n self.play(Create(poly_wave), Write(poly_label))\n self.wait(1)\n\n # 5. Mark Specific Point\n # Point where angle is pi (x = PI, y = sin(PI) = 0)\n pi_val = np.pi\n dot = Dot(axes.c2p(pi_val, np.sin(pi_val)), color=RED)\n pi_label = MathTex(r\"\\pi\").next_to(dot, DOWN)\n\n self.play(FadeIn(dot), Write(pi_label))\n self.wait(1)\n\n # 6. Draw Projection Line\n # Dashed yellow vertical line from the red dot to the x-axis\n projection_line = DashedLine(\n start=dot.get_center(), \n end=axes.c2p(pi_val, 0), \n color=YELLOW\n )\n\n self.play(Create(projection_line))\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_004539", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DefiniteIntegralExplanation", "num_animations": 13, "num_rich_primitives": 3, "prompt": "I'd like an animated video that explains the process of evaluating a definite integral of a simple power function from two different points, a and b. The video should start by introducing the integral of x with respect to x between the limits a and b. I want it to then display a clear explanation of what the boundaries a and b mean, followed by a demonstration of the fundamental theorem of calculus in relation to this problem. The video should also include the steps taken to calculate the definite integral of x in this specific case, preferably showing the algebraic manipulation leading to the final answer. I would like the answer to be highlighted in some way to draw attention to it. Lastly, after clearing all prior details, the final simplified result of the integral should be revisited and displayed on its own for emphasis.", "code": "from manim import *\n\nclass DefiniteIntegralExplanation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Display the integral of x with respect to x\n # ------------------------------------------------------------------\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n integral = MathTex(r\"\\int_{a}^{b} x \\, dx\", font_size=60)\n integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title))\n self.play(Write(integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Concept Explanation: Explain the meaning of the boundaries a and b\n # ------------------------------------------------------------------\n # Color code and highlight the limits using braces\n part_a = integral.get_part_by_tex(\"a\")\n part_b = integral.get_part_by_tex(\"b\")\n \n brace_a = Brace(part_a, DOWN, color=BLUE)\n label_a = Text(\"Lower Limit\", font_size=24, color=BLUE).next_to(brace_a, DOWN)\n \n brace_b = Brace(part_b, UP, color=GREEN)\n label_b = Text(\"Upper Limit\", font_size=24, color=GREEN).next_to(brace_b, UP)\n \n self.play(\n GrowFromCenter(brace_a), Write(label_a),\n GrowFromCenter(brace_b), Write(label_b)\n )\n self.wait(2)\n \n # Clean up explanation elements\n self.play(FadeOut(brace_a), FadeOut(label_a), FadeOut(brace_b), FadeOut(label_b))\n\n # ------------------------------------------------------------------\n # 3. Theoretical Demonstration: Fundamental Theorem of Calculus\n # ------------------------------------------------------------------\n ftc_title = Text(\"Fundamental Theorem of Calculus\", font_size=40).to_edge(UP)\n ftc_formula = MathTex(r\"\\int_{a}^{b} f(x) \\, dx = F(b) - F(a)\", font_size=40)\n ftc_formula.next_to(ftc_title, DOWN, buff=0.5)\n \n self.play(Transform(title, ftc_title))\n self.play(Write(ftc_formula))\n self.wait(2)\n self.play(FadeOut(ftc_formula))\n\n # ------------------------------------------------------------------\n # 4. Step-by-Step Calculation: Algebraic manipulation steps\n # ------------------------------------------------------------------\n # Find antiderivative\n antiderivative = MathTex(r\"\\int_{a}^{b} x \\, dx = \\left[ \\frac{x^2}{2} \\right]_{a}^{b}\", font_size=50)\n antiderivative.next_to(ftc_title, DOWN, buff=1)\n \n self.play(ReplacementTransform(integral.copy(), antiderivative))\n self.wait(1)\n \n # Evaluate at boundaries\n evaluation_step = MathTex(r\"= \\frac{b^2}{2} - \\frac{a^2}{2}\", font_size=50)\n evaluation_step.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n \n self.play(Write(evaluation_step))\n self.wait(1)\n \n # Simplify\n final_form = MathTex(r\"= \\frac{b^2 - a^2}{2}\", font_size=50)\n final_form.next_to(evaluation_step, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_form))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Highlighting: Visually highlight the final answer\n # ------------------------------------------------------------------\n box = SurroundingRectangle(final_form, color=YELLOW, buff=0.2)\n self.play(Create(box), final_form.animate.set_color(YELLOW))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Final Emphasis: Clear all prior details, display final result\n # ------------------------------------------------------------------\n self.play(\n FadeOut(title), FadeOut(antiderivative),\n FadeOut(evaluation_step), FadeOut(final_form), FadeOut(box)\n )\n \n final_result = MathTex(r\"\\frac{b^2 - a^2}{2}\", font_size=80)\n final_result.set_color(YELLOW).move_to(ORIGIN)\n \n self.play(Write(final_result))\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'd like an animated video that explains the process of evaluating a definite integral of a simple power function from two different points, a and b. The video should start by introducing the integral of x with respect to x between the limits a and b. I want it to then display a clear explanation of what the boundaries a and b mean, followed by a demonstration of the fundamental theorem of calculus in relation to this problem. The video should also include the steps taken to calculate the definite integral of x in this specific case, preferably showing the algebraic manipulation leading to the final answer. I would like the answer to be highlighted in some way to draw attention to it. Lastly, after clearing all prior details, the final simplified result of the integral should be revisited and displayed on its own for emphasis."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DefiniteIntegralExplanation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Display the integral of x with respect to x\n # ------------------------------------------------------------------\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n integral = MathTex(r\"\\int_{a}^{b} x \\, dx\", font_size=60)\n integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title))\n self.play(Write(integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Concept Explanation: Explain the meaning of the boundaries a and b\n # ------------------------------------------------------------------\n # Color code and highlight the limits using braces\n part_a = integral.get_part_by_tex(\"a\")\n part_b = integral.get_part_by_tex(\"b\")\n \n brace_a = Brace(part_a, DOWN, color=BLUE)\n label_a = Text(\"Lower Limit\", font_size=24, color=BLUE).next_to(brace_a, DOWN)\n \n brace_b = Brace(part_b, UP, color=GREEN)\n label_b = Text(\"Upper Limit\", font_size=24, color=GREEN).next_to(brace_b, UP)\n \n self.play(\n GrowFromCenter(brace_a), Write(label_a),\n GrowFromCenter(brace_b), Write(label_b)\n )\n self.wait(2)\n \n # Clean up explanation elements\n self.play(FadeOut(brace_a), FadeOut(label_a), FadeOut(brace_b), FadeOut(label_b))\n\n # ------------------------------------------------------------------\n # 3. Theoretical Demonstration: Fundamental Theorem of Calculus\n # ------------------------------------------------------------------\n ftc_title = Text(\"Fundamental Theorem of Calculus\", font_size=40).to_edge(UP)\n ftc_formula = MathTex(r\"\\int_{a}^{b} f(x) \\, dx = F(b) - F(a)\", font_size=40)\n ftc_formula.next_to(ftc_title, DOWN, buff=0.5)\n \n self.play(Transform(title, ftc_title))\n self.play(Write(ftc_formula))\n self.wait(2)\n self.play(FadeOut(ftc_formula))\n\n # ------------------------------------------------------------------\n # 4. Step-by-Step Calculation: Algebraic manipulation steps\n # ------------------------------------------------------------------\n # Find antiderivative\n antiderivative = MathTex(r\"\\int_{a}^{b} x \\, dx = \\left[ \\frac{x^2}{2} \\right]_{a}^{b}\", font_size=50)\n antiderivative.next_to(ftc_title, DOWN, buff=1)\n \n self.play(ReplacementTransform(integral.copy(), antiderivative))\n self.wait(1)\n \n # Evaluate at boundaries\n evaluation_step = MathTex(r\"= \\frac{b^2}{2} - \\frac{a^2}{2}\", font_size=50)\n evaluation_step.next_to(antiderivative, DOWN, aligned_edge=LEFT)\n \n self.play(Write(evaluation_step))\n self.wait(1)\n \n # Simplify\n final_form = MathTex(r\"= \\frac{b^2 - a^2}{2}\", font_size=50)\n final_form.next_to(evaluation_step, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_form))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Highlighting: Visually highlight the final answer\n # ------------------------------------------------------------------\n box = SurroundingRectangle(final_form, color=YELLOW, buff=0.2)\n self.play(Create(box), final_form.animate.set_color(YELLOW))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Final Emphasis: Clear all prior details, display final result\n # ------------------------------------------------------------------\n self.play(\n FadeOut(title), FadeOut(antiderivative),\n FadeOut(evaluation_step), FadeOut(final_form), FadeOut(box)\n )\n \n final_result = MathTex(r\"\\frac{b^2 - a^2}{2}\", font_size=80)\n final_result.set_color(YELLOW).move_to(ORIGIN)\n \n self.play(Write(final_result))\n self.wait(2)\n```"}]}
{"id": "adaption-unified-manim-instructions_000578", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralAreaVisualization", "num_animations": 7, "num_rich_primitives": 2, "prompt": "I would like to see an animated video which starts with displaying the mathematical function f(x) = x^2, then transforms that into an integral problem showing the area under that curve between x=1 and x=3. After that, it should visually display the area under the curve on a set of axes, and color the area between 1 and 3. Following the visuals, I'd like the animation to demonstrate the integration process by showing how to evaluate the integral of x^2 from 1 to 3 step by step, ending with the exact value of the area. Finally, it should conclude with a statement that this shaded area is equal to the calculated value in square units.", "code": "from manim import *\n\nclass IntegralAreaVisualization(Scene):\n def construct(self):\n # --- 1. Function Display ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).shift(DOWN * 0.5 + LEFT * 2)\n\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.2])\n curve_label = MathTex(\"f(x) = x^2\").next_to(curve, UR)\n\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # --- 2. Problem Transformation ---\n bound_line_1 = axes.get_vertical_line(axes.i2gp(1, curve), color=YELLOW, stroke_width=2)\n bound_line_3 = axes.get_vertical_line(axes.i2gp(3, curve), color=YELLOW, stroke_width=2)\n \n bound_label_1 = MathTex(\"x=1\").next_to(axes.c2p(1, 0), DOWN)\n bound_label_3 = MathTex(\"x=3\").next_to(axes.c2p(3, 0), DOWN)\n\n problem_text = MathTex(r\"\\text{Find the area: } \\int_{1}^{3} x^2 \\, dx\", font_size=36).to_edge(UP)\n\n self.play(\n Create(bound_line_1), Create(bound_line_3),\n Write(bound_label_1), Write(bound_label_3),\n Transform(curve_label, problem_text)\n )\n self.wait(1)\n\n # --- 3. Area Visualization ---\n area = axes.get_area(curve, x_range=[1, 3], color=GREEN, opacity=0.5)\n area_label = Text(\"Area = ?\", font_size=24, color=GREEN).next_to(area, RIGHT, buff=0.3)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # --- 4. Step-by-Step Evaluation ---\n # Define the mathematical steps\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=36)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", font_size=36)\n step3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\", font_size=36)\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=36)\n step5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\", font_size=36, color=YELLOW)\n\n steps = VGroup(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT).shift(UP * 0.5)\n\n # Transition from visual question to mathematical solution\n self.play(FadeOut(area_label), Write(step1))\n self.wait(0.5)\n\n # Animate subsequent steps\n for i in range(1, len(steps)):\n self.play(Write(steps[i]))\n self.wait(0.5)\n \n self.wait(1)\n\n # --- 5. Conclusion ---\n conclusion = Text(\n \"The shaded area is equal to 26/3 square units.\", \n font_size=28, \n color=WHITE\n ).to_edge(DOWN)\n\n self.play(Write(conclusion))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to see an animated video which starts with displaying the mathematical function f(x) = x^2, then transforms that into an integral problem showing the area under that curve between x=1 and x=3. After that, it should visually display the area under the curve on a set of axes, and color the area between 1 and 3. Following the visuals, I'd like the animation to demonstrate the integration process by showing how to evaluate the integral of x^2 from 1 to 3 step by step, ending with the exact value of the area. Finally, it should conclude with a statement that this shaded area is equal to the calculated value in square units."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralAreaVisualization(Scene):\n def construct(self):\n # --- 1. Function Display ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).shift(DOWN * 0.5 + LEFT * 2)\n\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.2])\n curve_label = MathTex(\"f(x) = x^2\").next_to(curve, UR)\n\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # --- 2. Problem Transformation ---\n bound_line_1 = axes.get_vertical_line(axes.i2gp(1, curve), color=YELLOW, stroke_width=2)\n bound_line_3 = axes.get_vertical_line(axes.i2gp(3, curve), color=YELLOW, stroke_width=2)\n \n bound_label_1 = MathTex(\"x=1\").next_to(axes.c2p(1, 0), DOWN)\n bound_label_3 = MathTex(\"x=3\").next_to(axes.c2p(3, 0), DOWN)\n\n problem_text = MathTex(r\"\\text{Find the area: } \\int_{1}^{3} x^2 \\, dx\", font_size=36).to_edge(UP)\n\n self.play(\n Create(bound_line_1), Create(bound_line_3),\n Write(bound_label_1), Write(bound_label_3),\n Transform(curve_label, problem_text)\n )\n self.wait(1)\n\n # --- 3. Area Visualization ---\n area = axes.get_area(curve, x_range=[1, 3], color=GREEN, opacity=0.5)\n area_label = Text(\"Area = ?\", font_size=24, color=GREEN).next_to(area, RIGHT, buff=0.3)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n\n # --- 4. Step-by-Step Evaluation ---\n # Define the mathematical steps\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=36)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", font_size=36)\n step3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\", font_size=36)\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=36)\n step5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\", font_size=36, color=YELLOW)\n\n steps = VGroup(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT).shift(UP * 0.5)\n\n # Transition from visual question to mathematical solution\n self.play(FadeOut(area_label), Write(step1))\n self.wait(0.5)\n\n # Animate subsequent steps\n for i in range(1, len(steps)):\n self.play(Write(steps[i]))\n self.wait(0.5)\n \n self.wait(1)\n\n # --- 5. Conclusion ---\n conclusion = Text(\n \"The shaded area is equal to 26/3 square units.\", \n font_size=28, \n color=WHITE\n ).to_edge(DOWN)\n\n self.play(Write(conclusion))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_000939", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "MObjectShowcase", "num_animations": 5, "num_rich_primitives": 2, "prompt": "I'd like to create an animated video using a Python library that showcases various mathematical and text objects. The video should start by displaying the phrase \"A Showcase of MObjects\" at the top. Then I want to see a collection of different geometric shapes like squares, circles, triangles, annuluses, ellipses, dots, arrows, and stars. Below the shapes, there should be a line of different text and number-related objects including simple text, an integral formula, a rounded integer number, a decimal number, a bulleted list with three items, and a snippet of Python code that says 'Hello, World!'. \n\nThese collections of objects should be arranged in a grid layout with a nice visual spacing between them. Each object should fade into the scene starting from the top-left and moving to the bottom-right. After they all appear, I'd like the geometric shapes to have a wave-like effect applied one by one, and the text-based objects to be highlighted in sequence. This should be visually engaging showing a little bit of what can be done with objects in this library. \n\nFinally, all objects should fade out, including the title, to end the animation. Can you create something like that for me?", "code": "from manim import *\n\nclass MObjectShowcase(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Creation\n # ------------------------------------------------------------------\n title = Text(\"A Showcase of MObjects\", font_size=48)\n title.to_edge(UP)\n\n # ------------------------------------------------------------------\n # 2. Geometric Shapes Creation\n # ------------------------------------------------------------------\n # Creating a variety of geometric MObjects with distinct colors\n square = Square(side_length=1.0, color=BLUE)\n circle = Circle(radius=0.5, color=GREEN)\n triangle = Triangle(color=RED).scale(0.7)\n annulus = Annulus(inner_radius=0.3, outer_radius=0.5, color=PURPLE)\n ellipse = Ellipse(width=1.2, height=0.7, color=ORANGE)\n dot = Dot(color=YELLOW).scale(3) # Scale up dot for grid visibility\n arrow = Arrow(start=LEFT, end=RIGHT, color=TEAL).scale(0.5)\n star = Star(color=PINK).scale(0.5)\n\n shapes = [square, circle, triangle, annulus, ellipse, dot, arrow, star]\n\n # ------------------------------------------------------------------\n # 3. Text & Number Objects Creation\n # ------------------------------------------------------------------\n # Simple text\n simple_text = Text(\"Simple Text\", font_size=24)\n \n # Integral formula (using MathTex for proper rendering)\n integral = MathTex(r\"\\int_{a}^{b} x^2 \\, dx\", font_size=36)\n \n # Rounded integer (visually enclosed in a circle for the \"rounded\" aesthetic)\n int_num = Integer(42, font_size=36)\n int_bg = Circle(radius=0.4, color=GREY_A).set_fill(GREY_A, opacity=0.3)\n rounded_int = VGroup(int_bg, int_num)\n \n # Decimal number\n decimal = DecimalNumber(3.14159, num_decimal_places=5, font_size=36)\n \n # Bulleted list (3 items)\n bulleted_list = BulletedList(\"Item 1\", \"Item 2\", \"Item 3\", font_size=24).scale(0.6)\n \n # Python code snippet displaying exactly: 'Hello, World!'\n code_snippet = Code(\n code=\"Hello, World!\",\n language=\"python\",\n font_size=20,\n insert_line_no=False,\n background=\"rectangle\"\n ).scale(0.5)\n\n text_objects = [simple_text, integral, rounded_int, decimal, bulleted_list, code_snippet]\n\n # ------------------------------------------------------------------\n # 4. Grid Arrangement\n # ------------------------------------------------------------------\n # Combine all objects into a single VGroup for layout\n # Total objects: 8 shapes + 6 text/num = 14 objects\n all_objects = VGroup(*shapes, *text_objects)\n \n # Arrange in a grid with consistent visual spacing\n all_objects.arrange_in_grid(rows=2, cols=7, buff=0.6)\n \n # Position the grid below the title\n all_objects.next_to(title, DOWN, buff=1)\n\n # ------------------------------------------------------------------\n # 5. Entrance Animation\n # ------------------------------------------------------------------\n # Animate the title first\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # Fade in objects sequentially from top-left to bottom-right\n # Using shift creates a subtle movement effect during the fade-in\n for obj in all_objects:\n self.play(FadeIn(obj, shift=DOWN + RIGHT), run_time=0.3)\n\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Effect Phase\n # ------------------------------------------------------------------\n # Apply a wave-like effect to geometric shapes one by one\n for shape in shapes:\n self.play(\n ApplyWave(shape, direction=RIGHT, amplitude=0.2),\n run_time=0.5\n )\n\n # Apply a highlight effect to text-based objects in sequence\n # ShowPassingFlash on a copied outline simulates a highlighter sweep\n for text_obj in text_objects:\n highlight = text_obj.copy()\n highlight.set_stroke(YELLOW, width=10)\n highlight.set_fill(opacity=0)\n self.play(ShowPassingFlash(highlight, time_width=0.5), run_time=0.5)\n\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 7. Exit Animation\n # ------------------------------------------------------------------\n # Fade out all objects including the title\n self.play(FadeOut(VGroup(title, *all_objects)), run_time=1.5)\n self.wait(0.5)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I'd like to create an animated video using a Python library that showcases various mathematical and text objects. The video should start by displaying the phrase \"A Showcase of MObjects\" at the top. Then I want to see a collection of different geometric shapes like squares, circles, triangles, annuluses, ellipses, dots, arrows, and stars. Below the shapes, there should be a line of different text and number-related objects including simple text, an integral formula, a rounded integer number, a decimal number, a bulleted list with three items, and a snippet of Python code that says 'Hello, World!'. \n\nThese collections of objects should be arranged in a grid layout with a nice visual spacing between them. Each object should fade into the scene starting from the top-left and moving to the bottom-right. After they all appear, I'd like the geometric shapes to have a wave-like effect applied one by one, and the text-based objects to be highlighted in sequence. This should be visually engaging showing a little bit of what can be done with objects in this library. \n\nFinally, all objects should fade out, including the title, to end the animation. Can you create something like that for me?"}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass MObjectShowcase(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Creation\n # ------------------------------------------------------------------\n title = Text(\"A Showcase of MObjects\", font_size=48)\n title.to_edge(UP)\n\n # ------------------------------------------------------------------\n # 2. Geometric Shapes Creation\n # ------------------------------------------------------------------\n # Creating a variety of geometric MObjects with distinct colors\n square = Square(side_length=1.0, color=BLUE)\n circle = Circle(radius=0.5, color=GREEN)\n triangle = Triangle(color=RED).scale(0.7)\n annulus = Annulus(inner_radius=0.3, outer_radius=0.5, color=PURPLE)\n ellipse = Ellipse(width=1.2, height=0.7, color=ORANGE)\n dot = Dot(color=YELLOW).scale(3) # Scale up dot for grid visibility\n arrow = Arrow(start=LEFT, end=RIGHT, color=TEAL).scale(0.5)\n star = Star(color=PINK).scale(0.5)\n\n shapes = [square, circle, triangle, annulus, ellipse, dot, arrow, star]\n\n # ------------------------------------------------------------------\n # 3. Text & Number Objects Creation\n # ------------------------------------------------------------------\n # Simple text\n simple_text = Text(\"Simple Text\", font_size=24)\n \n # Integral formula (using MathTex for proper rendering)\n integral = MathTex(r\"\\int_{a}^{b} x^2 \\, dx\", font_size=36)\n \n # Rounded integer (visually enclosed in a circle for the \"rounded\" aesthetic)\n int_num = Integer(42, font_size=36)\n int_bg = Circle(radius=0.4, color=GREY_A).set_fill(GREY_A, opacity=0.3)\n rounded_int = VGroup(int_bg, int_num)\n \n # Decimal number\n decimal = DecimalNumber(3.14159, num_decimal_places=5, font_size=36)\n \n # Bulleted list (3 items)\n bulleted_list = BulletedList(\"Item 1\", \"Item 2\", \"Item 3\", font_size=24).scale(0.6)\n \n # Python code snippet displaying exactly: 'Hello, World!'\n code_snippet = Code(\n code=\"Hello, World!\",\n language=\"python\",\n font_size=20,\n insert_line_no=False,\n background=\"rectangle\"\n ).scale(0.5)\n\n text_objects = [simple_text, integral, rounded_int, decimal, bulleted_list, code_snippet]\n\n # ------------------------------------------------------------------\n # 4. Grid Arrangement\n # ------------------------------------------------------------------\n # Combine all objects into a single VGroup for layout\n # Total objects: 8 shapes + 6 text/num = 14 objects\n all_objects = VGroup(*shapes, *text_objects)\n \n # Arrange in a grid with consistent visual spacing\n all_objects.arrange_in_grid(rows=2, cols=7, buff=0.6)\n \n # Position the grid below the title\n all_objects.next_to(title, DOWN, buff=1)\n\n # ------------------------------------------------------------------\n # 5. Entrance Animation\n # ------------------------------------------------------------------\n # Animate the title first\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # Fade in objects sequentially from top-left to bottom-right\n # Using shift creates a subtle movement effect during the fade-in\n for obj in all_objects:\n self.play(FadeIn(obj, shift=DOWN + RIGHT), run_time=0.3)\n\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Effect Phase\n # ------------------------------------------------------------------\n # Apply a wave-like effect to geometric shapes one by one\n for shape in shapes:\n self.play(\n ApplyWave(shape, direction=RIGHT, amplitude=0.2),\n run_time=0.5\n )\n\n # Apply a highlight effect to text-based objects in sequence\n # ShowPassingFlash on a copied outline simulates a highlighter sweep\n for text_obj in text_objects:\n highlight = text_obj.copy()\n highlight.set_stroke(YELLOW, width=10)\n highlight.set_fill(opacity=0)\n self.play(ShowPassingFlash(highlight, time_width=0.5), run_time=0.5)\n\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 7. Exit Animation\n # ------------------------------------------------------------------\n # Fade out all objects including the title\n self.play(FadeOut(VGroup(title, *all_objects)), run_time=1.5)\n self.wait(0.5)\n```"}]}
{"id": "multi_act_v2_00381", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0381", "num_animations": 14, "prompt": "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: ", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "manim-sft-10k_001802", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "AsynchronousExecution", "num_animations": 14, "num_rich_primitives": 3, "prompt": "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### Asynchronicity is Common in Engineering\nDue to clock drift and processing speed differences, time $t$ for agent A may correspond to time $t-1$ or $t+1$ for agent B.\n\n### Inconsistency in States Caused by Asynchronicity\nAgents may make decisions based on outdated neighbor information, leading to failed collaboration.\n\n\nThe context of this section (from highest to current level):\n# Engineering and Real-world Applications of Multi-agent Systems\n## Issues with Synchronous and Asynchronous Execution\n", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AsynchronousExecution(Scene):\n\n def construct(self):\n title = Title('Issues with Asynchronous Execution', font_size=40)\n self.play(Write(title))\n h1 = Text('1. Asynchronicity is Common in Engineering', font_size=32, color=BLUE)\n h1.to_edge(LEFT).shift(UP * 2)\n t1 = Tex('Due to clock drift and processing speed differences,\\\\\\\\time $t$ for agent A may correspond to time $t-1$ or $t+1$ for agent B.', font_size=28)\n t1.next_to(h1, DOWN, aligned_edge=LEFT, buff=0.3)\n self.play(Write(h1))\n self.play(FadeIn(t1))\n v1_group = VGroup()\n line_a = NumberLine(x_range=[-1, 1, 1], length=6, include_numbers=False)\n line_a.shift(RIGHT * 1.5 + UP * 0.2)\n line_b = NumberLine(x_range=[-2, 0, 1], length=6, include_numbers=False)\n line_b.shift(RIGHT * 1.5 + DOWN * 1.8)\n label_a = Text('Agent A (Fast)', font_size=24, color=TEAL).next_to(line_a, LEFT, buff=0.5)\n label_b = Text('Agent B (Slow)', font_size=24, color=PURPLE).next_to(line_b, LEFT, buff=0.5)\n labels_a = VGroup(MathTex('t-1', font_size=28).next_to(line_a.n2p(-1), UP), MathTex('t', font_size=28).next_to(line_a.n2p(0), UP), MathTex('t+1', font_size=28).next_to(line_a.n2p(1), UP))\n labels_b = VGroup(MathTex('t-2', font_size=28).next_to(line_b.n2p(-2), DOWN), MathTex('t-1', font_size=28).next_to(line_b.n2p(-1), DOWN), MathTex('t', font_size=28).next_to(line_b.n2p(0), DOWN))\n dots_a = VGroup(*[Dot(line_a.n2p(i), color=TEAL) for i in [-1, 0, 1]])\n dots_b = VGroup(*[Dot(line_b.n2p(i), color=PURPLE) for i in [-2, -1, 0]])\n v1_group.add(line_a, line_b, label_a, label_b, labels_a, labels_b, dots_a, dots_b)\n self.play(FadeIn(v1_group, shift=UP * 0.5))\n box_a = SurroundingRectangle(labels_a[1], color=YELLOW, buff=0.1)\n box_b = SurroundingRectangle(labels_b[1], color=YELLOW, buff=0.1)\n arrow_sync = DashedLine(box_a.get_bottom(), box_b.get_top(), color=YELLOW).add_tip()\n sync_text = Text('Simultaneous in real time', font_size=20, color=YELLOW).next_to(arrow_sync, RIGHT)\n self.play(Create(box_a), Create(box_b))\n self.play(Create(arrow_sync), Write(sync_text))\n self.wait(2)\n self.play(*[FadeOut(m) for m in self.mobjects if m != title])\n h2 = Text('2. Inconsistency in States Caused by Asynchronicity', font_size=32, color=RED)\n h2.to_edge(LEFT).shift(UP * 2)\n t2 = Tex('Agents may make decisions based on outdated neighbor\\\\\\\\information, leading to failed collaboration.', font_size=28)\n t2.next_to(h2, DOWN, aligned_edge=LEFT, buff=0.3)\n self.play(Write(h2))\n self.play(FadeIn(t2))\n agent_a = Circle(radius=0.8, color=TEAL, fill_opacity=0.3).shift(LEFT * 3 + DOWN * 1.5)\n agent_b = Circle(radius=0.8, color=PURPLE, fill_opacity=0.3).shift(RIGHT * 3 + DOWN * 1.5)\n name_a = Text('Agent A', font_size=24).move_to(agent_a)\n name_b = Text('Agent B', font_size=24).move_to(agent_b)\n state_a = MathTex('\\\\text{State}_A(t)', font_size=24, color=TEAL).next_to(agent_a, DOWN)\n state_b = MathTex('\\\\text{State}_B(t-1)', font_size=24, color=PURPLE).next_to(agent_b, DOWN)\n self.play(FadeIn(agent_a, name_a, state_a), FadeIn(agent_b, name_b, state_b))\n msg = Rectangle(width=1.0, height=0.6, color=YELLOW, fill_opacity=0.8)\n msg_text = Text('Info', font_size=16, color=BLACK).move_to(msg)\n msg_group = VGroup(msg, msg_text).next_to(agent_b, LEFT)\n self.play(FadeIn(msg_group, shift=LEFT))\n self.play(msg_group.animate.next_to(agent_a, RIGHT), run_time=2)\n thought_bubble = Ellipse(width=3.0, height=1.5, color=LIGHT_GREY, fill_opacity=0.2)\n thought_bubble.next_to(agent_a, UP, buff=0.2)\n thought_text = Tex('Decision based on\\\\\\\\$\\\\text{State}_B(t-1)$', font_size=20).move_to(thought_bubble)\n thought_group = VGroup(thought_bubble, thought_text)\n self.play(FadeIn(thought_group, shift=UP))\n cross = Cross(stroke_width=6).scale(0.8).move_to(ORIGIN + DOWN * 1.5)\n fail_text = Text('Failed Collaboration!', font_size=28, color=RED).next_to(cross, UP)\n self.play(Create(cross), Write(fail_text))\n self.wait(3)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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### Asynchronicity is Common in Engineering\nDue to clock drift and processing speed differences, time $t$ for agent A may correspond to time $t-1$ or $t+1$ for agent B.\n\n### Inconsistency in States Caused by Asynchronicity\nAgents may make decisions based on outdated neighbor information, leading to failed collaboration.\n\n\nThe context of this section (from highest to current level):\n# Engineering and Real-world Applications of Multi-agent Systems\n## Issues with Synchronous and Asynchronous Execution\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AsynchronousExecution(Scene):\n\n def construct(self):\n title = Title('Issues with Asynchronous Execution', font_size=40)\n self.play(Write(title))\n h1 = Text('1. Asynchronicity is Common in Engineering', font_size=32, color=BLUE)\n h1.to_edge(LEFT).shift(UP * 2)\n t1 = Tex('Due to clock drift and processing speed differences,\\\\\\\\time $t$ for agent A may correspond to time $t-1$ or $t+1$ for agent B.', font_size=28)\n t1.next_to(h1, DOWN, aligned_edge=LEFT, buff=0.3)\n self.play(Write(h1))\n self.play(FadeIn(t1))\n v1_group = VGroup()\n line_a = NumberLine(x_range=[-1, 1, 1], length=6, include_numbers=False)\n line_a.shift(RIGHT * 1.5 + UP * 0.2)\n line_b = NumberLine(x_range=[-2, 0, 1], length=6, include_numbers=False)\n line_b.shift(RIGHT * 1.5 + DOWN * 1.8)\n label_a = Text('Agent A (Fast)', font_size=24, color=TEAL).next_to(line_a, LEFT, buff=0.5)\n label_b = Text('Agent B (Slow)', font_size=24, color=PURPLE).next_to(line_b, LEFT, buff=0.5)\n labels_a = VGroup(MathTex('t-1', font_size=28).next_to(line_a.n2p(-1), UP), MathTex('t', font_size=28).next_to(line_a.n2p(0), UP), MathTex('t+1', font_size=28).next_to(line_a.n2p(1), UP))\n labels_b = VGroup(MathTex('t-2', font_size=28).next_to(line_b.n2p(-2), DOWN), MathTex('t-1', font_size=28).next_to(line_b.n2p(-1), DOWN), MathTex('t', font_size=28).next_to(line_b.n2p(0), DOWN))\n dots_a = VGroup(*[Dot(line_a.n2p(i), color=TEAL) for i in [-1, 0, 1]])\n dots_b = VGroup(*[Dot(line_b.n2p(i), color=PURPLE) for i in [-2, -1, 0]])\n v1_group.add(line_a, line_b, label_a, label_b, labels_a, labels_b, dots_a, dots_b)\n self.play(FadeIn(v1_group, shift=UP * 0.5))\n box_a = SurroundingRectangle(labels_a[1], color=YELLOW, buff=0.1)\n box_b = SurroundingRectangle(labels_b[1], color=YELLOW, buff=0.1)\n arrow_sync = DashedLine(box_a.get_bottom(), box_b.get_top(), color=YELLOW).add_tip()\n sync_text = Text('Simultaneous in real time', font_size=20, color=YELLOW).next_to(arrow_sync, RIGHT)\n self.play(Create(box_a), Create(box_b))\n self.play(Create(arrow_sync), Write(sync_text))\n self.wait(2)\n self.play(*[FadeOut(m) for m in self.mobjects if m != title])\n h2 = Text('2. Inconsistency in States Caused by Asynchronicity', font_size=32, color=RED)\n h2.to_edge(LEFT).shift(UP * 2)\n t2 = Tex('Agents may make decisions based on outdated neighbor\\\\\\\\information, leading to failed collaboration.', font_size=28)\n t2.next_to(h2, DOWN, aligned_edge=LEFT, buff=0.3)\n self.play(Write(h2))\n self.play(FadeIn(t2))\n agent_a = Circle(radius=0.8, color=TEAL, fill_opacity=0.3).shift(LEFT * 3 + DOWN * 1.5)\n agent_b = Circle(radius=0.8, color=PURPLE, fill_opacity=0.3).shift(RIGHT * 3 + DOWN * 1.5)\n name_a = Text('Agent A', font_size=24).move_to(agent_a)\n name_b = Text('Agent B', font_size=24).move_to(agent_b)\n state_a = MathTex('\\\\text{State}_A(t)', font_size=24, color=TEAL).next_to(agent_a, DOWN)\n state_b = MathTex('\\\\text{State}_B(t-1)', font_size=24, color=PURPLE).next_to(agent_b, DOWN)\n self.play(FadeIn(agent_a, name_a, state_a), FadeIn(agent_b, name_b, state_b))\n msg = Rectangle(width=1.0, height=0.6, color=YELLOW, fill_opacity=0.8)\n msg_text = Text('Info', font_size=16, color=BLACK).move_to(msg)\n msg_group = VGroup(msg, msg_text).next_to(agent_b, LEFT)\n self.play(FadeIn(msg_group, shift=LEFT))\n self.play(msg_group.animate.next_to(agent_a, RIGHT), run_time=2)\n thought_bubble = Ellipse(width=3.0, height=1.5, color=LIGHT_GREY, fill_opacity=0.2)\n thought_bubble.next_to(agent_a, UP, buff=0.2)\n thought_text = Tex('Decision based on\\\\\\\\$\\\\text{State}_B(t-1)$', font_size=20).move_to(thought_bubble)\n thought_group = VGroup(thought_bubble, thought_text)\n self.play(FadeIn(thought_group, shift=UP))\n cross = Cross(stroke_width=6).scale(0.8).move_to(ORIGIN + DOWN * 1.5)\n fail_text = Text('Failed Collaboration!', font_size=28, color=RED).next_to(cross, UP)\n self.play(Create(cross), Write(fail_text))\n self.wait(3)\n```"}]}
{"id": "adaption-unified-manim-instructions_006233", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegralAreaAnimation", "num_animations": 10, "num_rich_primitives": 4, "prompt": "I would like to see an animated video which starts with displaying the mathematical function f(x) = x^2, then transforms that into an integral problem showing the area under that curve between x=1 and x=3. After that, it should visually display the area under the curve on a set of axes, and color the area between 1 and 3. Following the visuals, I'd like the animation to demonstrate the integration process by showing how to evaluate the integral of x^2 from 1 to 3 step by step, ending with the exact value of the area. Finally, it should conclude with a statement that this shaded area is equal to the calculated value in square units.", "code": "from manim import *\n\nclass IntegralAreaAnimation(Scene):\n def construct(self):\n # --- 1. Display the mathematical function ---\n func_text = MathTex(r\"f(x) = x^2\", font_size=48)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Transform into an integral problem ---\n integral_problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=48)\n self.play(ReplacementTransform(func_text, integral_problem))\n self.wait(1)\n self.play(integral_problem.animate.to_edge(UP))\n\n # --- 3. Setup Axes and Visually Display Area ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True},\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n graph_label = axes.get_graph_label(graph, label=r\"x^2\", x_val=3.2, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Shading the area between x=1 and x=3\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n # Vertical boundary lines\n line_1 = axes.get_vertical_line(axes.input_to_graph_point(1, graph), color=YELLOW)\n line_3 = axes.get_vertical_line(axes.input_to_graph_point(3, graph), color=YELLOW)\n \n # Boundary labels\n label_1 = MathTex(\"1\", font_size=36).next_to(axes.c2p(1, 0), DOWN, buff=0.2)\n label_3 = MathTex(\"3\", font_size=36).next_to(axes.c2p(3, 0), DOWN, buff=0.2)\n\n self.play(FadeIn(line_1), FadeIn(line_3), Write(label_1), Write(label_3))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 4. Step-by-step integration process ---\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=36)\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_1^3\", font_size=36)\n step3 = MathTex(r\"= \\frac{1}{3}(3)^3 - \\frac{1}{3}(1)^3\", font_size=36)\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=36)\n step5 = MathTex(r\"= \\frac{26}{3}\", font_size=36)\n step6 = MathTex(r\"\\approx 8.67\", font_size=36)\n\n # Arrange and position steps\n steps = VGroup(step1, step2, step3, step4, step5, step6)\n steps.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n steps.next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # Transform the top integral into the first step of the calculation\n self.play(ReplacementTransform(integral_problem, steps[0]))\n self.wait(0.5)\n\n # Animate each subsequent step\n for i in range(1, len(steps)):\n self.play(Write(steps[i]))\n self.wait(0.5)\n\n # --- 5. Conclusion Statement ---\n conclusion = Tex(\n r\"The shaded area is equal to $\\frac{26}{3}$ square units.\",\n font_size=36,\n color=YELLOW\n ).to_edge(DOWN, buff=0.8)\n\n # Highlight the final result and the area simultaneously\n self.play(\n Indicate(steps[4]),\n area.animate.set_color(YELLOW),\n Write(conclusion)\n )\n self.wait(2)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to see an animated video which starts with displaying the mathematical function f(x) = x^2, then transforms that into an integral problem showing the area under that curve between x=1 and x=3. After that, it should visually display the area under the curve on a set of axes, and color the area between 1 and 3. Following the visuals, I'd like the animation to demonstrate the integration process by showing how to evaluate the integral of x^2 from 1 to 3 step by step, ending with the exact value of the area. Finally, it should conclude with a statement that this shaded area is equal to the calculated value in square units."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass IntegralAreaAnimation(Scene):\n def construct(self):\n # --- 1. Display the mathematical function ---\n func_text = MathTex(r\"f(x) = x^2\", font_size=48)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Transform into an integral problem ---\n integral_problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=48)\n self.play(ReplacementTransform(func_text, integral_problem))\n self.wait(1)\n self.play(integral_problem.animate.to_edge(UP))\n\n # --- 3. Setup Axes and Visually Display Area ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True},\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 3.5])\n graph_label = axes.get_graph_label(graph, label=r\"x^2\", x_val=3.2, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Shading the area between x=1 and x=3\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n # Vertical boundary lines\n line_1 = axes.get_vertical_line(axes.input_to_graph_point(1, graph), color=YELLOW)\n line_3 = axes.get_vertical_line(axes.input_to_graph_point(3, graph), color=YELLOW)\n \n # Boundary labels\n label_1 = MathTex(\"1\", font_size=36).next_to(axes.c2p(1, 0), DOWN, buff=0.2)\n label_3 = MathTex(\"3\", font_size=36).next_to(axes.c2p(3, 0), DOWN, buff=0.2)\n\n self.play(FadeIn(line_1), FadeIn(line_3), Write(label_1), Write(label_3))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 4. Step-by-step integration process ---\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=36)\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_1^3\", font_size=36)\n step3 = MathTex(r\"= \\frac{1}{3}(3)^3 - \\frac{1}{3}(1)^3\", font_size=36)\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=36)\n step5 = MathTex(r\"= \\frac{26}{3}\", font_size=36)\n step6 = MathTex(r\"\\approx 8.67\", font_size=36)\n\n # Arrange and position steps\n steps = VGroup(step1, step2, step3, step4, step5, step6)\n steps.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n steps.next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # Transform the top integral into the first step of the calculation\n self.play(ReplacementTransform(integral_problem, steps[0]))\n self.wait(0.5)\n\n # Animate each subsequent step\n for i in range(1, len(steps)):\n self.play(Write(steps[i]))\n self.wait(0.5)\n\n # --- 5. Conclusion Statement ---\n conclusion = Tex(\n r\"The shaded area is equal to $\\frac{26}{3}$ square units.\",\n font_size=36,\n color=YELLOW\n ).to_edge(DOWN, buff=0.8)\n\n # Highlight the final result and the area simultaneously\n self.play(\n Indicate(steps[4]),\n area.animate.set_color(YELLOW),\n Write(conclusion)\n )\n self.wait(2)\n```"}]}
{"id": "multi_act_v2_00313", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0313", "num_animations": 16, "prompt": "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: How can I create an animation where text changes to the word \"Circumscribe\" and moves upwards, followed by new text appearing saying \"Look Here\" which then gets highlighted with animation, first with the default shape an\n- Act 2: 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.\n- Act 3: 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", "code": "from manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0313(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_circumscribeanimation()\n self.clear_stage()\n self.act_2_economicssupplydemandshi()\n self.clear_stage()\n self.act_3_frameboxanimation()\n\n def act_1_circumscribeanimation(self):\n initial_text = Text(\"Start\", font_size=48)\n target_text = Text(\"Circumscribe\", font_size=48)\n \n # Ensure the target starts at the same position as the initial text\n target_text.move_to(initial_text)\n \n # Animate the transformation of content while shifting upwards\n self.play(\n ReplacementTransform(initial_text, target_text),\n initial_text.animate.shift(UP * 2),\n run_time=2\n )\n self.wait(0.5)\n\n # 2. Sequential Text Appearance\n look_here_text = Text(\"Look Here\", font_size=48)\n look_here_text.next_to(target_text, DOWN, buff=1.5)\n \n self.play(Write(look_here_text), run_time=1.5)\n self.wait(0.5)\n\n # 3. Highlighting Sequence\n # First: Default highlight shape\n self.play(Highlight(look_here_text), run_time=1)\n self.wait(0.5)\n\n # Second: Circular highlight shape using Circumscribe\n self.play(\n Circumscribe(look_here_text, Circle, fade_out=True, color=YELLOW), \n run_time=1.5\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Fade out all text elements from the scene\n self.play(FadeOut(target_text), FadeOut(look_here_text), run_time=1)\n self.wait(1)\n\n def act_2_economicssupplydemandshi(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\n def act_3_frameboxanimation(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange them vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n # Create surrounding rectangles for each text with specified colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initial State: Display texts and highlight the first text with a blue rectangle\n self.play(Write(texts))\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Transition 1: Replace blue rectangle with green rectangle highlighting the second text\n self.play(Transform(rect1, rect2))\n self.wait(0.5)\n\n # Transition 2: Replace green rectangle with red rectangle highlighting the third text\n self.play(Transform(rect1, rect3))\n self.wait(0.5)\n\n # Final Movement: Red rectangle moves upwards, following the text \"FrameBoxes\"\n # Define an updater to ensure the rectangle tracks the text's position precisely\n def follow_text(mob):\n mob.move_to(text3)\n\n rect1.add_updater(follow_text)\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=2)\n \n # Clean up updater\n rect1.remove_updater(follow_text)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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: How can I create an animation where text changes to the word \"Circumscribe\" and moves upwards, followed by new text appearing saying \"Look Here\" which then gets highlighted with animation, first with the default shape an\n- Act 2: 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.\n- Act 3: 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"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0313(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_circumscribeanimation()\n self.clear_stage()\n self.act_2_economicssupplydemandshi()\n self.clear_stage()\n self.act_3_frameboxanimation()\n\n def act_1_circumscribeanimation(self):\n initial_text = Text(\"Start\", font_size=48)\n target_text = Text(\"Circumscribe\", font_size=48)\n \n # Ensure the target starts at the same position as the initial text\n target_text.move_to(initial_text)\n \n # Animate the transformation of content while shifting upwards\n self.play(\n ReplacementTransform(initial_text, target_text),\n initial_text.animate.shift(UP * 2),\n run_time=2\n )\n self.wait(0.5)\n\n # 2. Sequential Text Appearance\n look_here_text = Text(\"Look Here\", font_size=48)\n look_here_text.next_to(target_text, DOWN, buff=1.5)\n \n self.play(Write(look_here_text), run_time=1.5)\n self.wait(0.5)\n\n # 3. Highlighting Sequence\n # First: Default highlight shape\n self.play(Highlight(look_here_text), run_time=1)\n self.wait(0.5)\n\n # Second: Circular highlight shape using Circumscribe\n self.play(\n Circumscribe(look_here_text, Circle, fade_out=True, color=YELLOW), \n run_time=1.5\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Fade out all text elements from the scene\n self.play(FadeOut(target_text), FadeOut(look_here_text), run_time=1)\n self.wait(1)\n\n def act_2_economicssupplydemandshi(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\n def act_3_frameboxanimation(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange them vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n # Create surrounding rectangles for each text with specified colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initial State: Display texts and highlight the first text with a blue rectangle\n self.play(Write(texts))\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Transition 1: Replace blue rectangle with green rectangle highlighting the second text\n self.play(Transform(rect1, rect2))\n self.wait(0.5)\n\n # Transition 2: Replace green rectangle with red rectangle highlighting the third text\n self.play(Transform(rect1, rect3))\n self.wait(0.5)\n\n # Final Movement: Red rectangle moves upwards, following the text \"FrameBoxes\"\n # Define an updater to ensure the rectangle tracks the text's position precisely\n def follow_text(mob):\n mob.move_to(text3)\n\n rect1.add_updater(follow_text)\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=2)\n \n # Clean up updater\n rect1.remove_updater(follow_text)\n```"}]}
{"id": "manim-sft-10k_000137", "source": "nabin2004/manim-sft-10k", "tier": 1, "scene_name": "TuringMachineLecture", "num_animations": 18, "num_rich_primitives": 2, "prompt": "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### Learning Objectives: Understanding the Turing Machine Model and Its Implications for Computability\nMaster the formal definition of the Turing machine, its operational mechanism, and how it precisely captures the intuitive concept of an \"algorithm.\"\n\n## Why a Stronger Model than PDA is Needed\n\n### The Limitation of PDA Having Only One Stack\nPushdown automata (PDA) rely on a \"last-in, first-out\" stack structure, which lacks random access capabilities and struggles to handle non-nested dependencies.\n\n\nContext of this section (from highest to current level):\n# Turing Machines and the Foundations of Computability\n## Course Introduction and Learning Objectives\n", "code": "from manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TuringMachineLecture(Scene):\n\n def construct(self):\n title = Title('Turing Machines and the Foundations of Computability', font_size=36)\n self.play(Write(title))\n obj_heading = Text('Learning Objectives:', color=BLUE, font_size=32)\n obj_sub = Text('Understanding the Turing Machine Model and Its Implications for Computability', font_size=24, slant=ITALIC, color=LIGHT_GREY)\n obj_body = Text(\"• Master the formal definition of the Turing machine,\\n its operational mechanism, and how it precisely\\n captures the intuitive concept of an 'algorithm'.\", font_size=24, line_spacing=1.2)\n slide1_group = VGroup(obj_heading, obj_sub, obj_body).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n slide1_group.next_to(title, DOWN, buff=1.0).shift(LEFT * 0.5)\n self.play(FadeIn(obj_heading, shift=RIGHT))\n self.play(FadeIn(obj_sub, shift=UP))\n self.play(Write(obj_body))\n self.wait(3)\n self.play(FadeOut(slide1_group))\n pda_heading = Text('Why a Stronger Model than PDA is Needed', color=RED, font_size=32)\n pda_sub = Text('The Limitation of PDA Having Only One Stack', color=YELLOW, font_size=28)\n pda_body = Text(\"• Pushdown automata (PDA) rely on a 'last-in, first-out' (LIFO)\\n stack structure, which lacks random access capabilities\\n and struggles to handle non-nested dependencies.\", font_size=24, line_spacing=1.2)\n slide2_text_group = VGroup(pda_heading, pda_sub, pda_body).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n slide2_text_group.next_to(title, DOWN, buff=0.5).shift(LEFT * 0.5)\n self.play(FadeIn(pda_heading, shift=RIGHT))\n self.play(FadeIn(pda_sub, shift=UP))\n self.play(Write(pda_body))\n self.wait(1)\n left_wall = Line(UP * 1.0, DOWN * 1.0)\n right_wall = Line(UP * 1.0, DOWN * 1.0)\n bottom_wall = Line(LEFT * 0.6, RIGHT * 0.6)\n left_wall.shift(LEFT * 0.6)\n right_wall.shift(RIGHT * 0.6)\n bottom_wall.shift(DOWN * 1.0)\n pda_container = VGroup(left_wall, right_wall, bottom_wall).set_color(WHITE)\n\n def create_stack_element(text_str, color=BLUE):\n rect = Rectangle(width=1.2, height=0.5, color=color, fill_opacity=0.5)\n text = Text(text_str, font_size=14)\n return VGroup(rect, text)\n elem1 = create_stack_element('Data 1')\n elem2 = create_stack_element('Data 2')\n elem3 = create_stack_element('Data 3')\n elem1.next_to(bottom_wall, UP, buff=0)\n elem2.next_to(elem1, UP, buff=0)\n elem3.next_to(elem2, UP, buff=0)\n pda_stack = VGroup(pda_container, elem1, elem2, elem3)\n pda_label = Text('PDA: LIFO Stack', font_size=18, color=YELLOW).next_to(pda_stack, DOWN, buff=0.3)\n pda_group = VGroup(pda_stack, pda_label).move_to(DOWN * 2 + LEFT * 3.5)\n self.play(Create(pda_container), Write(pda_label))\n self.play(FadeIn(elem1, shift=DOWN), FadeIn(elem2, shift=DOWN), FadeIn(elem3, shift=DOWN))\n cross = Cross(elem1, stroke_color=RED, stroke_width=6)\n no_access_label = Text('No Access', font_size=16, color=RED).next_to(cross, LEFT, buff=0.2)\n self.play(Create(cross), Write(no_access_label))\n tm_cells = VGroup(*[Rectangle(width=0.8, height=0.8, color=WHITE).set_fill(DARK_GRAY, opacity=0.5) for _ in range(7)]).arrange(RIGHT, buff=0)\n tm_texts = VGroup(*[Text(f'D{i}', font_size=16) for i in range(1, 8)])\n for cell, txt in zip(tm_cells, tm_texts):\n txt.move_to(cell.get_center())\n else:\n pass\n tm_tape = VGroup(tm_cells, tm_texts)\n head = Polygon(LEFT * 0.3 + UP * 0.3, RIGHT * 0.3 + UP * 0.3, DOWN * 0.3, color=GREEN, fill_opacity=0.8)\n head.next_to(tm_cells[3], UP, buff=0.1)\n head_label = Text('R/W Head', font_size=14, color=GREEN).next_to(head, UP, buff=0.1)\n head_label.add_updater(lambda m: m.next_to(head, UP, buff=0.1))\n tm_head = VGroup(head, head_label)\n tm_label = Text('Turing Machine: Random Access', font_size=18, color=GREEN).next_to(tm_tape, DOWN, buff=0.3)\n tm_group = VGroup(tm_tape, tm_head, tm_label).move_to(DOWN * 2 + RIGHT * 2.5)\n self.play(Create(tm_cells), Write(tm_label))\n self.play(Write(tm_texts))\n self.play(FadeIn(head, shift=DOWN), FadeIn(head_label, shift=DOWN))\n self.play(head.animate.next_to(tm_cells[1], UP, buff=0.1), run_time=1)\n self.play(head.animate.next_to(tm_cells[5], UP, buff=0.1), run_time=1)\n self.play(head.animate.next_to(tm_cells[2], UP, buff=0.1), run_time=1)\n head_label.clear_updaters()\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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### Learning Objectives: Understanding the Turing Machine Model and Its Implications for Computability\nMaster the formal definition of the Turing machine, its operational mechanism, and how it precisely captures the intuitive concept of an \"algorithm.\"\n\n## Why a Stronger Model than PDA is Needed\n\n### The Limitation of PDA Having Only One Stack\nPushdown automata (PDA) rely on a \"last-in, first-out\" stack structure, which lacks random access capabilities and struggles to handle non-nested dependencies.\n\n\nContext of this section (from highest to current level):\n# Turing Machines and the Foundations of Computability\n## Course Introduction and Learning Objectives\n"}, {"role": "assistant", "content": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TuringMachineLecture(Scene):\n\n def construct(self):\n title = Title('Turing Machines and the Foundations of Computability', font_size=36)\n self.play(Write(title))\n obj_heading = Text('Learning Objectives:', color=BLUE, font_size=32)\n obj_sub = Text('Understanding the Turing Machine Model and Its Implications for Computability', font_size=24, slant=ITALIC, color=LIGHT_GREY)\n obj_body = Text(\"• Master the formal definition of the Turing machine,\\n its operational mechanism, and how it precisely\\n captures the intuitive concept of an 'algorithm'.\", font_size=24, line_spacing=1.2)\n slide1_group = VGroup(obj_heading, obj_sub, obj_body).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n slide1_group.next_to(title, DOWN, buff=1.0).shift(LEFT * 0.5)\n self.play(FadeIn(obj_heading, shift=RIGHT))\n self.play(FadeIn(obj_sub, shift=UP))\n self.play(Write(obj_body))\n self.wait(3)\n self.play(FadeOut(slide1_group))\n pda_heading = Text('Why a Stronger Model than PDA is Needed', color=RED, font_size=32)\n pda_sub = Text('The Limitation of PDA Having Only One Stack', color=YELLOW, font_size=28)\n pda_body = Text(\"• Pushdown automata (PDA) rely on a 'last-in, first-out' (LIFO)\\n stack structure, which lacks random access capabilities\\n and struggles to handle non-nested dependencies.\", font_size=24, line_spacing=1.2)\n slide2_text_group = VGroup(pda_heading, pda_sub, pda_body).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n slide2_text_group.next_to(title, DOWN, buff=0.5).shift(LEFT * 0.5)\n self.play(FadeIn(pda_heading, shift=RIGHT))\n self.play(FadeIn(pda_sub, shift=UP))\n self.play(Write(pda_body))\n self.wait(1)\n left_wall = Line(UP * 1.0, DOWN * 1.0)\n right_wall = Line(UP * 1.0, DOWN * 1.0)\n bottom_wall = Line(LEFT * 0.6, RIGHT * 0.6)\n left_wall.shift(LEFT * 0.6)\n right_wall.shift(RIGHT * 0.6)\n bottom_wall.shift(DOWN * 1.0)\n pda_container = VGroup(left_wall, right_wall, bottom_wall).set_color(WHITE)\n\n def create_stack_element(text_str, color=BLUE):\n rect = Rectangle(width=1.2, height=0.5, color=color, fill_opacity=0.5)\n text = Text(text_str, font_size=14)\n return VGroup(rect, text)\n elem1 = create_stack_element('Data 1')\n elem2 = create_stack_element('Data 2')\n elem3 = create_stack_element('Data 3')\n elem1.next_to(bottom_wall, UP, buff=0)\n elem2.next_to(elem1, UP, buff=0)\n elem3.next_to(elem2, UP, buff=0)\n pda_stack = VGroup(pda_container, elem1, elem2, elem3)\n pda_label = Text('PDA: LIFO Stack', font_size=18, color=YELLOW).next_to(pda_stack, DOWN, buff=0.3)\n pda_group = VGroup(pda_stack, pda_label).move_to(DOWN * 2 + LEFT * 3.5)\n self.play(Create(pda_container), Write(pda_label))\n self.play(FadeIn(elem1, shift=DOWN), FadeIn(elem2, shift=DOWN), FadeIn(elem3, shift=DOWN))\n cross = Cross(elem1, stroke_color=RED, stroke_width=6)\n no_access_label = Text('No Access', font_size=16, color=RED).next_to(cross, LEFT, buff=0.2)\n self.play(Create(cross), Write(no_access_label))\n tm_cells = VGroup(*[Rectangle(width=0.8, height=0.8, color=WHITE).set_fill(DARK_GRAY, opacity=0.5) for _ in range(7)]).arrange(RIGHT, buff=0)\n tm_texts = VGroup(*[Text(f'D{i}', font_size=16) for i in range(1, 8)])\n for cell, txt in zip(tm_cells, tm_texts):\n txt.move_to(cell.get_center())\n else:\n pass\n tm_tape = VGroup(tm_cells, tm_texts)\n head = Polygon(LEFT * 0.3 + UP * 0.3, RIGHT * 0.3 + UP * 0.3, DOWN * 0.3, color=GREEN, fill_opacity=0.8)\n head.next_to(tm_cells[3], UP, buff=0.1)\n head_label = Text('R/W Head', font_size=14, color=GREEN).next_to(head, UP, buff=0.1)\n head_label.add_updater(lambda m: m.next_to(head, UP, buff=0.1))\n tm_head = VGroup(head, head_label)\n tm_label = Text('Turing Machine: Random Access', font_size=18, color=GREEN).next_to(tm_tape, DOWN, buff=0.3)\n tm_group = VGroup(tm_tape, tm_head, tm_label).move_to(DOWN * 2 + RIGHT * 2.5)\n self.play(Create(tm_cells), Write(tm_label))\n self.play(Write(tm_texts))\n self.play(FadeIn(head, shift=DOWN), FadeIn(head_label, shift=DOWN))\n self.play(head.animate.next_to(tm_cells[1], UP, buff=0.1), run_time=1)\n self.play(head.animate.next_to(tm_cells[5], UP, buff=0.1), run_time=1)\n self.play(head.animate.next_to(tm_cells[2], UP, buff=0.1), run_time=1)\n head_label.clear_updaters()\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))\n```"}]}
{"id": "adaption-unified-manim-instructions_005942", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "DoubleIntegralPolar", "num_animations": 17, "num_rich_primitives": 2, "prompt": "Create an animated video using a Python library that visually explains the steps to solve a double integral in polar coordinates, where the integral is from 0 to π for φ (phi) and from 0 to 2 for ρ (rho) of the function ρ^3 sinφ. Display the mathematical problem on the screen, then show the process of integrating ρ first while explaining that step through text on the screen, and simplify the resulting expression. Next, switch the explanation to integrate with respect to φ, perform the integration, and show each simplification step. Finally, evaluate the definite integral, simplify the answer, and present the final numerical solution. Each step should be written out and transitions should be smooth to help viewers follow along with the calculation. Include pauses between each step to give viewers time to understand the information before moving on to the next part.", "code": "from manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # --- Configuration ---\n highlight_color = YELLOW\n text_color = WHITE\n \n # --- Introduction ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n # Initial Integral: \\int (0 to \\pi ) \\int (0 to 2) ρ^3 sin(φ) dρ dφ\n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi}\", r\"\\int_{0}^{2}\", r\"\\rho^3 \\sin(\\phi)\", r\"\\, d\\rho\", r\"\\, d\\phi\",\n font_size=44\n )\n initial_integral.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title), Write(initial_integral))\n self.wait(2)\n \n # Move the initial problem up to make room for the steps\n self.play(initial_integral.animate.shift(UP * 1.5))\n \n # --- Step 1: Inner Integral (with respect to ρ) ---\n step1_text = Text(\"Step 1: Integrate with respect to ρ\", font_size=30, color=BLUE)\n step1_text.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Show the antiderivative of ρ^3 which is ρ^4/4\n inner_integration = MathTex(\n r\"= \\int_{0}^{\\pi} \\left[ \\frac{\\rho^4}{4} \\sin(\\phi) \\right]_{0}^{2} \\, d\\phi\",\n font_size=42\n )\n inner_integration.next_to(step1_text, DOWN, buff=0.5)\n \n self.play(Write(inner_integration))\n self.wait(2)\n \n # Simplify the inner integral result: (2^4/4 - 0^4/4) = 4\n simplification_text = Text(\"Simplify: (2⁴/4) - 0 = 4\", font_size=28, color=GREEN)\n simplification_text.next_to(inner_integration, DOWN, buff=0.3)\n \n self.play(Write(simplification_text))\n self.wait(1)\n \n inner_result = MathTex(\n r\"= \\int_{0}^{\\pi} 4 \\sin(\\phi) \\, d\\phi\",\n font_size=42\n )\n inner_result.move_to(inner_integration)\n \n self.play(\n ReplacementTransform(inner_integration, inner_result),\n FadeOut(simplification_text)\n )\n self.wait(2)\n \n # --- Step 2: Outer Integral (with respect to φ) ---\n self.play(FadeOut(step1_text), inner_result.animate.shift(UP * 1))\n \n step2_text = Text(\"Step 2: Integrate with respect to φ\", font_size=30, color=GREEN)\n step2_text.next_to(inner_result, DOWN, buff=0.8)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Show antiderivative of sin(φ) which is -cos(φ)\n outer_integration = MathTex(\n r\"= \\left[ -4 \\cos(\\phi) \\right]_{0}^{\\pi}\",\n font_size=42\n )\n outer_integration.next_to(step2_text, DOWN, buff=0.5)\n \n self.play(ReplacementTransform(inner_result, outer_integration))\n self.wait(2)\n \n # --- Step 3: Evaluate Definite Integral ---\n evaluate_text = Text(\"Substitute bounds: φ = \\pi and φ = 0\", font_size=28, color=BLUE)\n evaluate_text.next_to(outer_integration, DOWN, buff=0.5)\n \n self.play(Write(evaluate_text))\n self.wait(1)\n \n # Show substitution: -4(cos(\\pi ) - cos(0))\n substitution = MathTex(\n r\"= -4 \\left( \\cos(\\pi) - \\cos(0) \\right)\",\n font_size=42\n )\n substitution.move_to(outer_integration)\n \n self.play(\n ReplacementTransform(outer_integration, substitution),\n FadeOut(evaluate_text)\n )\n self.wait(2)\n \n # Show trig values: cos(\\pi ) = -1, cos(0) = 1\n trig_explanation = Text(\"cos(\\pi ) = -1, cos(0) = 1\", font_size=28, color=GREEN)\n trig_explanation.next_to(substitution, DOWN, buff=0.3)\n \n self.play(Write(trig_explanation))\n self.wait(1)\n \n trig_values = MathTex(\n r\"= -4 (-1 - 1)\",\n font_size=42\n )\n trig_values.move_to(substitution)\n \n self.play(\n ReplacementTransform(substitution, trig_values),\n FadeOut(trig_explanation)\n )\n self.wait(2)\n \n # --- Conclusion: Final Result ---\n final_result = MathTex(\n r\"= -4(-2) = 8\",\n font_size=50,\n color=highlight_color\n )\n final_result.move_to(trig_values)\n \n self.play(ReplacementTransform(trig_values, final_result))\n self.wait(1)\n \n # Clean up intermediate text\n self.play(FadeOut(step2_text))\n \n # Center the final result and make it prominent\n final_result.generate_target()\n final_result.target.move_to(ORIGIN)\n final_result.target.scale(1.2)\n \n final_box = SurroundingRectangle(final_result.target, color=highlight_color, buff=0.3)\n final_label = Text(\"Final Solution\", font_size=36).next_to(final_box, UP, buff=0.3)\n \n self.play(\n MoveToTarget(final_result),\n Create(final_box),\n Write(final_label)\n )\n \n self.wait(3)\n \n # Fade out everything for a clean end\n self.play(\n FadeOut(final_result),\n FadeOut(final_box),\n FadeOut(final_label),\n FadeOut(title)\n )\n self.wait(1)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "Create an animated video using a Python library that visually explains the steps to solve a double integral in polar coordinates, where the integral is from 0 to π for φ (phi) and from 0 to 2 for ρ (rho) of the function ρ^3 sinφ. Display the mathematical problem on the screen, then show the process of integrating ρ first while explaining that step through text on the screen, and simplify the resulting expression. Next, switch the explanation to integrate with respect to φ, perform the integration, and show each simplification step. Finally, evaluate the definite integral, simplify the answer, and present the final numerical solution. Each step should be written out and transitions should be smooth to help viewers follow along with the calculation. Include pauses between each step to give viewers time to understand the information before moving on to the next part."}, {"role": "assistant", "content": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # --- Configuration ---\n highlight_color = YELLOW\n text_color = WHITE\n \n # --- Introduction ---\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n # Initial Integral: \\int (0 to \\pi ) \\int (0 to 2) ρ^3 sin(φ) dρ dφ\n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi}\", r\"\\int_{0}^{2}\", r\"\\rho^3 \\sin(\\phi)\", r\"\\, d\\rho\", r\"\\, d\\phi\",\n font_size=44\n )\n initial_integral.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title), Write(initial_integral))\n self.wait(2)\n \n # Move the initial problem up to make room for the steps\n self.play(initial_integral.animate.shift(UP * 1.5))\n \n # --- Step 1: Inner Integral (with respect to ρ) ---\n step1_text = Text(\"Step 1: Integrate with respect to ρ\", font_size=30, color=BLUE)\n step1_text.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Show the antiderivative of ρ^3 which is ρ^4/4\n inner_integration = MathTex(\n r\"= \\int_{0}^{\\pi} \\left[ \\frac{\\rho^4}{4} \\sin(\\phi) \\right]_{0}^{2} \\, d\\phi\",\n font_size=42\n )\n inner_integration.next_to(step1_text, DOWN, buff=0.5)\n \n self.play(Write(inner_integration))\n self.wait(2)\n \n # Simplify the inner integral result: (2^4/4 - 0^4/4) = 4\n simplification_text = Text(\"Simplify: (2⁴/4) - 0 = 4\", font_size=28, color=GREEN)\n simplification_text.next_to(inner_integration, DOWN, buff=0.3)\n \n self.play(Write(simplification_text))\n self.wait(1)\n \n inner_result = MathTex(\n r\"= \\int_{0}^{\\pi} 4 \\sin(\\phi) \\, d\\phi\",\n font_size=42\n )\n inner_result.move_to(inner_integration)\n \n self.play(\n ReplacementTransform(inner_integration, inner_result),\n FadeOut(simplification_text)\n )\n self.wait(2)\n \n # --- Step 2: Outer Integral (with respect to φ) ---\n self.play(FadeOut(step1_text), inner_result.animate.shift(UP * 1))\n \n step2_text = Text(\"Step 2: Integrate with respect to φ\", font_size=30, color=GREEN)\n step2_text.next_to(inner_result, DOWN, buff=0.8)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Show antiderivative of sin(φ) which is -cos(φ)\n outer_integration = MathTex(\n r\"= \\left[ -4 \\cos(\\phi) \\right]_{0}^{\\pi}\",\n font_size=42\n )\n outer_integration.next_to(step2_text, DOWN, buff=0.5)\n \n self.play(ReplacementTransform(inner_result, outer_integration))\n self.wait(2)\n \n # --- Step 3: Evaluate Definite Integral ---\n evaluate_text = Text(\"Substitute bounds: φ = \\pi and φ = 0\", font_size=28, color=BLUE)\n evaluate_text.next_to(outer_integration, DOWN, buff=0.5)\n \n self.play(Write(evaluate_text))\n self.wait(1)\n \n # Show substitution: -4(cos(\\pi ) - cos(0))\n substitution = MathTex(\n r\"= -4 \\left( \\cos(\\pi) - \\cos(0) \\right)\",\n font_size=42\n )\n substitution.move_to(outer_integration)\n \n self.play(\n ReplacementTransform(outer_integration, substitution),\n FadeOut(evaluate_text)\n )\n self.wait(2)\n \n # Show trig values: cos(\\pi ) = -1, cos(0) = 1\n trig_explanation = Text(\"cos(\\pi ) = -1, cos(0) = 1\", font_size=28, color=GREEN)\n trig_explanation.next_to(substitution, DOWN, buff=0.3)\n \n self.play(Write(trig_explanation))\n self.wait(1)\n \n trig_values = MathTex(\n r\"= -4 (-1 - 1)\",\n font_size=42\n )\n trig_values.move_to(substitution)\n \n self.play(\n ReplacementTransform(substitution, trig_values),\n FadeOut(trig_explanation)\n )\n self.wait(2)\n \n # --- Conclusion: Final Result ---\n final_result = MathTex(\n r\"= -4(-2) = 8\",\n font_size=50,\n color=highlight_color\n )\n final_result.move_to(trig_values)\n \n self.play(ReplacementTransform(trig_values, final_result))\n self.wait(1)\n \n # Clean up intermediate text\n self.play(FadeOut(step2_text))\n \n # Center the final result and make it prominent\n final_result.generate_target()\n final_result.target.move_to(ORIGIN)\n final_result.target.scale(1.2)\n \n final_box = SurroundingRectangle(final_result.target, color=highlight_color, buff=0.3)\n final_label = Text(\"Final Solution\", font_size=36).next_to(final_box, UP, buff=0.3)\n \n self.play(\n MoveToTarget(final_result),\n Create(final_box),\n Write(final_label)\n )\n \n self.wait(3)\n \n # Fade out everything for a clean end\n self.play(\n FadeOut(final_result),\n FadeOut(final_box),\n FadeOut(final_label),\n FadeOut(title)\n )\n self.wait(1)\n```"}]}
{"id": "adaption-unified-manim-instructions_001944", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "IntegrationByParts", "num_animations": 14, "num_rich_primitives": 2, "prompt": "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.", "code": "from 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)", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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": "adaption-unified-manim-instructions_005928", "source": "priyanshutomar2024/adaption-unified-manim-instructions", "tier": 1, "scene_name": "SimpleHarmonicMotion", "num_animations": 18, "num_rich_primitives": 4, "prompt": "I would like to create an educational animation that explains Simple Harmonic Motion (SHM) in physics. It should begin by displaying the differential equation for SHM on screen and then introduce the concept of angular frequency with an explanation. It should also show the transformation of the original SHM equation with the introduction of angular frequency. Next, can you illustrate the general solution of the SHM equation, and mention how initial conditions can determine the constants in the solution? Finally, I’d love to see a visual example of SHM, such as a dot moving back and forth in simple harmonic motion, and end with a closing statement that signifies the end of the demonstration. The entire explanation throughout the animation should be both visual and text-based for clarity. Can you do something like that?", "code": "from manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # 1. Introduction of the Differential Equation\n # ---------------------------------------------------------\n title = Text(\"Simple Harmonic Motion (SHM)\", font_size=40).to_edge(UP)\n \n # Start with the physical law derived from Hooke's Law and Newton's Second Law\n eq_physical = MathTex(r\"m\", r\"\\frac{d^2 x}{dt^2}\", \"=\", \"-\", r\"k\", \"x\", font_size=42)\n eq_physical.next_to(title, DOWN, buff=0.8)\n \n self.play(Write(title))\n self.play(Write(eq_physical))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Angular Frequency Concept\n # ---------------------------------------------------------\n omega_text = Text(\n \"We define the angular frequency ω as:\", \n font_size=28, \n color=BLUE\n ).next_to(eq_physical, DOWN, buff=0.6)\n \n omega_def = MathTex(r\"\\omega^2 = \\frac{k}{m}\", font_size=42, color=BLUE)\n omega_def.next_to(omega_text, DOWN, buff=0.3)\n \n omega_explanation = Text(\n \"Angular frequency determines how fast the oscillation occurs.\",\n font_size=24, color=GRAY\n ).next_to(omega_def, DOWN, buff=0.4)\n\n self.play(Write(omega_text), Write(omega_def))\n self.play(Write(omega_explanation))\n self.wait(2)\n\n # ---------------------------------------------------------\n # 3. Equation Transformation\n # ---------------------------------------------------------\n # Transform the physical equation into the standard SHM differential equation\n eq_standard = MathTex(\n r\"\\frac{d^2 x}{dt^2}\", \"+\", r\"\\omega^2\", \"x\", \"=\", \"0\", font_size=42\n )\n eq_standard.move_to(eq_physical)\n \n prop_text = Text(\n \"Acceleration is proportional to displacement (opposite direction)\",\n font_size=24, color=GRAY\n ).next_to(eq_standard, DOWN, buff=0.8)\n\n self.play(\n Transform(eq_physical, eq_standard),\n FadeOut(omega_text),\n FadeOut(omega_def),\n FadeOut(omega_explanation)\n )\n self.play(Write(prop_text))\n self.wait(2)\n self.play(FadeOut(prop_text))\n\n # ---------------------------------------------------------\n # 4. General Solution\n # ---------------------------------------------------------\n sol_text = Text(\"General Solution:\", font_size=30)\n sol_text.next_to(eq_physical, DOWN, buff=0.8)\n \n general_sol = MathTex(\n \"x(t)\", \"=\", \"A\", r\"\\cos(\", r\"\\omega t\", \"+\", r\"\\phi\", \")\",\n font_size=48, color=YELLOW\n )\n general_sol.next_to(sol_text, DOWN, buff=0.5)\n\n self.play(Write(sol_text))\n self.play(Write(general_sol))\n self.wait(2)\n\n # ---------------------------------------------------------\n # 5. Initial Conditions\n # ---------------------------------------------------------\n # Highlight constants A and phi\n self.play(\n general_sol.set_color_by_tex(\"A\", GREEN),\n general_sol.set_color_by_tex(r\"\\phi\", RED)\n )\n \n constants_exp = VGroup(\n MathTex(r\"A : \\text{Amplitude}\", font_size=28, color=GREEN),\n MathTex(r\"\\phi : \\text{Phase Constant}\", font_size=28, color=RED)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(general_sol, DOWN, buff=0.8)\n \n init_text = Text(\n \"These constants are determined by\\nthe initial conditions x(0) and v(0).\",\n font_size=24, color=GRAY\n ).next_to(constants_exp, DOWN, buff=0.4)\n\n self.play(Write(constants_exp))\n self.play(Write(init_text))\n self.wait(2)\n\n # Clean up for visual demonstration\n self.play(\n FadeOut(title), FadeOut(eq_physical), FadeOut(sol_text),\n FadeOut(general_sol), FadeOut(constants_exp), FadeOut(init_text)\n )\n\n # ---------------------------------------------------------\n # 6. Visual Demonstration\n # ---------------------------------------------------------\n # Create axes representing the path of motion\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_numbers\": True, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-3, -2, -1, 0, 1, 2, 3]},\n y_axis_config={\"visible\": False} # Hide y-axis for 1D motion clarity\n ).scale(0.8).shift(DOWN * 0.5)\n \n x_label = MathTex(\"x\").next_to(axes.x_axis.get_end(), RIGHT)\n eq_visual = MathTex(r\"x(t) = A \\cos(\\omega t)\", font_size=30).to_edge(UP)\n\n self.play(Create(axes), Write(x_label), Write(eq_visual))\n \n # Oscillating dot\n A_val = 3.0\n omega_val = 2.0\n dot = Dot(color=RED, radius=0.1).move_to(axes.c2p(A_val, 0))\n \n # Trace path for visual clarity\n trace = TracedPath(dot.get_center, stroke_color=RED, stroke_width=2)\n \n # Time tracker and updater\n t_tracker = ValueTracker(0)\n \n def update_dot(mob):\n t = t_tracker.get_value()\n x_pos = A_val * np.cos(omega_val * t)\n mob.move_to(axes.c2p(x_pos, 0))\n \n dot.add_updater(update_dot)\n \n self.add(dot, trace)\n \n # Animate the motion for 2 full cycles\n self.play(t_tracker.animate.set_value(4 * PI), run_time=4, rate_func=linear)\n self.wait(1)\n \n dot.remove_updater(update_dot)\n\n # ---------------------------------------------------------\n # 7. Conclusion\n # ---------------------------------------------------------\n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(eq_visual),\n FadeOut(dot), FadeOut(trace)\n )\n \n conclusion = Text(\"End of Demonstration\", font_size=42, color=GREEN)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"role": "user", "content": "I would like to create an educational animation that explains Simple Harmonic Motion (SHM) in physics. It should begin by displaying the differential equation for SHM on screen and then introduce the concept of angular frequency with an explanation. It should also show the transformation of the original SHM equation with the introduction of angular frequency. Next, can you illustrate the general solution of the SHM equation, and mention how initial conditions can determine the constants in the solution? Finally, I’d love to see a visual example of SHM, such as a dot moving back and forth in simple harmonic motion, and end with a closing statement that signifies the end of the demonstration. The entire explanation throughout the animation should be both visual and text-based for clarity. Can you do something like that?"}, {"role": "assistant", "content": "```python\nfrom manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # 1. Introduction of the Differential Equation\n # ---------------------------------------------------------\n title = Text(\"Simple Harmonic Motion (SHM)\", font_size=40).to_edge(UP)\n \n # Start with the physical law derived from Hooke's Law and Newton's Second Law\n eq_physical = MathTex(r\"m\", r\"\\frac{d^2 x}{dt^2}\", \"=\", \"-\", r\"k\", \"x\", font_size=42)\n eq_physical.next_to(title, DOWN, buff=0.8)\n \n self.play(Write(title))\n self.play(Write(eq_physical))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Angular Frequency Concept\n # ---------------------------------------------------------\n omega_text = Text(\n \"We define the angular frequency ω as:\", \n font_size=28, \n color=BLUE\n ).next_to(eq_physical, DOWN, buff=0.6)\n \n omega_def = MathTex(r\"\\omega^2 = \\frac{k}{m}\", font_size=42, color=BLUE)\n omega_def.next_to(omega_text, DOWN, buff=0.3)\n \n omega_explanation = Text(\n \"Angular frequency determines how fast the oscillation occurs.\",\n font_size=24, color=GRAY\n ).next_to(omega_def, DOWN, buff=0.4)\n\n self.play(Write(omega_text), Write(omega_def))\n self.play(Write(omega_explanation))\n self.wait(2)\n\n # ---------------------------------------------------------\n # 3. Equation Transformation\n # ---------------------------------------------------------\n # Transform the physical equation into the standard SHM differential equation\n eq_standard = MathTex(\n r\"\\frac{d^2 x}{dt^2}\", \"+\", r\"\\omega^2\", \"x\", \"=\", \"0\", font_size=42\n )\n eq_standard.move_to(eq_physical)\n \n prop_text = Text(\n \"Acceleration is proportional to displacement (opposite direction)\",\n font_size=24, color=GRAY\n ).next_to(eq_standard, DOWN, buff=0.8)\n\n self.play(\n Transform(eq_physical, eq_standard),\n FadeOut(omega_text),\n FadeOut(omega_def),\n FadeOut(omega_explanation)\n )\n self.play(Write(prop_text))\n self.wait(2)\n self.play(FadeOut(prop_text))\n\n # ---------------------------------------------------------\n # 4. General Solution\n # ---------------------------------------------------------\n sol_text = Text(\"General Solution:\", font_size=30)\n sol_text.next_to(eq_physical, DOWN, buff=0.8)\n \n general_sol = MathTex(\n \"x(t)\", \"=\", \"A\", r\"\\cos(\", r\"\\omega t\", \"+\", r\"\\phi\", \")\",\n font_size=48, color=YELLOW\n )\n general_sol.next_to(sol_text, DOWN, buff=0.5)\n\n self.play(Write(sol_text))\n self.play(Write(general_sol))\n self.wait(2)\n\n # ---------------------------------------------------------\n # 5. Initial Conditions\n # ---------------------------------------------------------\n # Highlight constants A and phi\n self.play(\n general_sol.set_color_by_tex(\"A\", GREEN),\n general_sol.set_color_by_tex(r\"\\phi\", RED)\n )\n \n constants_exp = VGroup(\n MathTex(r\"A : \\text{Amplitude}\", font_size=28, color=GREEN),\n MathTex(r\"\\phi : \\text{Phase Constant}\", font_size=28, color=RED)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(general_sol, DOWN, buff=0.8)\n \n init_text = Text(\n \"These constants are determined by\\nthe initial conditions x(0) and v(0).\",\n font_size=24, color=GRAY\n ).next_to(constants_exp, DOWN, buff=0.4)\n\n self.play(Write(constants_exp))\n self.play(Write(init_text))\n self.wait(2)\n\n # Clean up for visual demonstration\n self.play(\n FadeOut(title), FadeOut(eq_physical), FadeOut(sol_text),\n FadeOut(general_sol), FadeOut(constants_exp), FadeOut(init_text)\n )\n\n # ---------------------------------------------------------\n # 6. Visual Demonstration\n # ---------------------------------------------------------\n # Create axes representing the path of motion\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_numbers\": True, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-3, -2, -1, 0, 1, 2, 3]},\n y_axis_config={\"visible\": False} # Hide y-axis for 1D motion clarity\n ).scale(0.8).shift(DOWN * 0.5)\n \n x_label = MathTex(\"x\").next_to(axes.x_axis.get_end(), RIGHT)\n eq_visual = MathTex(r\"x(t) = A \\cos(\\omega t)\", font_size=30).to_edge(UP)\n\n self.play(Create(axes), Write(x_label), Write(eq_visual))\n \n # Oscillating dot\n A_val = 3.0\n omega_val = 2.0\n dot = Dot(color=RED, radius=0.1).move_to(axes.c2p(A_val, 0))\n \n # Trace path for visual clarity\n trace = TracedPath(dot.get_center, stroke_color=RED, stroke_width=2)\n \n # Time tracker and updater\n t_tracker = ValueTracker(0)\n \n def update_dot(mob):\n t = t_tracker.get_value()\n x_pos = A_val * np.cos(omega_val * t)\n mob.move_to(axes.c2p(x_pos, 0))\n \n dot.add_updater(update_dot)\n \n self.add(dot, trace)\n \n # Animate the motion for 2 full cycles\n self.play(t_tracker.animate.set_value(4 * PI), run_time=4, rate_func=linear)\n self.wait(1)\n \n dot.remove_updater(update_dot)\n\n # ---------------------------------------------------------\n # 7. Conclusion\n # ---------------------------------------------------------\n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(eq_visual),\n FadeOut(dot), FadeOut(trace)\n )\n \n conclusion = Text(\"End of Demonstration\", font_size=42, color=GREEN)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```"}]}
{"id": "multi_act_v2_00180", "source": "synthesized_modular_multi_act_v2", "tier": 1, "scene_name": "MultiActMasterpiece_0180", "num_animations": 14, "prompt": "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", "code": "from 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()", "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. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n3. 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 (`self.play(*[FadeOut(m) for m in self.mobjects])`) before starting the next act so text and graphics NEVER overlap.\n4. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+` inside `MathTex` and never use unescaped `%`."}, {"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```"}]}