{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### LSD-SLAM\n\n**LSD-SLAM (Large-Scale Direct SLAM):**\n\n#### Monocular SLAM Based on Semi-Dense Direct Method\n\n#### Proposed by TUM in 2014\n* A milestone in direct methods, demonstrating SLAM can be done without feature points.\n\n**Key Features:**\n\n#### **Semi-Dense Depth Estimation**\n\n##### Depth Estimation in Regions with High Gradients\n\n##### Depth Filter Update\n* Continuously converges the depth value of each pixel using Bayesian estimation.\n\n#### **Direct Image Alignment**\n\n##### Minimizing Photometric Error\n\n##### Sim(3) Pose Graph Optimization\n* Explicitly handles scale factors in the optimization to correct scale drift.\n\n#### **Scale Drift Awareness**\n\n##### Detects and Corrects Scale Drift\n\n\nThe context of this section (from highest to current level):\n# Embodied Intelligence: Visual Perception and SLAM\n## Classical SLAM Systems\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass LsdSlamScene(Scene):\n\n def construct(self):\n title = Text(\"Monocular SLAM Based on Semi-Dense Direct Method\", font_size=36)\n subtitle = Text(\"Proposed by TUM in 2014\", font_size=28, color=GRAY).next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n bullet_list = BulletedList(\n \"A milestone in direct methods, demonstrating SLAM can be done without feature points.\",\n font_size=28\n )\n features_title = Text(\"Key Features:\", font_size=36, weight=BOLD).to_edge(UP, buff=0.5)\n self.play(Write(features_title))\n semi_dense_text = Text(\"- Semi-Dense Depth Estimation\\n- Depth Estimation in Regions with High Gradients\\n- Depth Filter Update:\\n • Continuous convergence via Bayesian estimation.\", font_size=28, line_spacing=1.2)\n sim3_text = Text(\"- Direct Image Alignment\\n- Minimizing photometric error\\n- Sim(3) Pose Graph Optimization:\\n • Handles scale factors explicitly for scale drift correction.\", font_size=28, line_spacing=1.2)\n semi_dense_box = RoundedRectangle(corner_radius=0.2, width=7.2, height=2.8, fill_color=BLUE_D, fill_opacity=0.1)\n semidense_label = Text(\"Semi-\\nDense\\ndepth\\nest.\\nmethod\", font_size=24, color=YELLOW).move_to(RIGHT * 4 + UP * 1.2)\n semi_denselist_group = VGroup(semi_dense_box, semidense_label, semi_dense_text).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n sim3box = RoundedRectangle(corner_radius=0.2, width=6.2, height=2.2, fill_color=GREEN_C, fill_opacity=0.1)\n sim3label = Text(\"Sim(3)\\npose graph\\noptimization\", font_size=24, color=ORANGE).move_to(LEFT * 4 + UP * 0.8)\n sim3listgroup = VGroup(sim3box, sim3label, sim3_text).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n boxes = VGroup(semi_denselist_group, sim3listgroup).arrange(RIGHT, buff=2.0).shift(UP * 0.8)\n arrows = VGroup(Arrow(start=boxes.get_left() + RIGHT * 1.2 + DOWN * 0.5, end=semi_denselist_group.get_right(), stroke_width=2), Arrow(start=boxes.get_left() + RIGHT * 1.2 + DOWN * 0.5, end=sim3listgroup.get_left(), stroke_width=2)).set_stroke(WHITE, opacity=0.8)\n self.play(Write(bullet_list))\n self.play(Create(arrows), FadeIn(semi_denselist_group), FadeIn(sim3listgroup))\n conclusion_text = Text(\"• Enables high-resolution maps\\n• Handles large-scale scenes\\n• Robust against scale changes\", font_size=28, t2c={\"high-resolution\": YELLOW})\n conclusion_box = SurroundingRectangle(conclusion_text, corner_radius=0.2, color=WHITE, buff=0.2)\n conclusion_group = VGroup(conclusion_box, conclusion_text).to_edge(DOWN, buff=1.0)\n self.play(FadeIn(conclusion_group))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass LsdSlam(Scene):\n\n def construct(self):\n title = Text(\"LSD-SLAM\", font_size=72).to_edge(UP)\n subtitle = Text(\n \"Monocular SLAM Based on Semi-Dense Direct Method\",\n font_size=36,\n color=BLUE_C\n ).next_to(title, DOWN, buff=0.8)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n author_text = Text(\"- TUM, 2014\", font_size=24, color=GRAY)\n author_box = SurroundingRectangle(author_text, color=WHITE, fill_opacity=0.1, buff=0.15)\n author_group = VGroup(author_box, author_text).align_to([0, -3, 0], UP)\n self.play(Write(author_group))\n features_title = Text(\"Key Features:\", font_size=32, weight=BOLD)\n semidense_depth = Text(\"• Semi-dense depth estimation\", font_size=24)\n semidense_filter = Text(\"• Continuous depth filter update\\nusing Bayesian estimation\", font_size=20, t2c={\"Bayesian\": BLUE})\n image_align = Text(\"\\n• Direct image alignment\\nMinimizing photometric error\", font_size=24)\n sim3_opt = Text(\"Sim(3) Pose Graph Optimization\\nExplicitly handling scale factors\\nto correct scale drift\", font_size=20, t2c={\"Sim(3)\": YELLOW})\n semidense_rect = RoundedRectangle(width=4, height=2.5, corner_radius=0.3)\n semidense_rect.move_to([-4, -1.2, 0])\n semidense_box = SurroundingRectangle(semi_dense_depth, color=YELLOW, buff=0.3)\n filter_rect = RoundedRectangle(width=3.5, height=2.0, corner_radius=0.3)\n filter_rect.next_to(semidense_rect, RIGHT, buff=0.8)\n filter_box = SurroundingRectangle(semi_dense_filter, color=GREEN, buff=0.3)\n align_rect = RoundedRectangle(width=4.5, height=2.5, corner_radius=0.3)\n align_rect.to_edge(RIGHT, buff=1.0)\n align_box = SurroundingRectangle(image_align, color=ORANGE, buff=0.3)\n sim3_rect = RoundedRectangle(width=4.5, height=2.5, corner_radius=0.3)\n sim3_rect.shift(DOWN * 0.5)\n sim3_rect.next_to(filter_rect, DOWN, buff=0.8)\n sim3_box = SurroundingRectangle(sim3_opt, color=PURPLE, buff=0.3)\n diagram_group = VGroup(semidense_rect, filter_rect, align_rect, sim3_rect)\n diagram_group.arrange(RIGHT, buff=0.8).shift(LEFT * 1.5 + DOWN * 0.8)\n for rect in [semidense_rect, filter_rect, align_rect, sim3_rect]:\n rect.set_fill(opacity=0.2)\n else:\n pass\n self.play(Write(features_title))\n self.play(Create(semidense_rect), Write(semi_dense_depth), Create(semidense_box))\n self.play(Create(filter_rect), Write(semi_dense_filter), Create(filter_box))\n self.play(Create(align_rect), Write(image_align), Create(align_box))\n self.play(Create(sim3_rect), Write(sim3_opt), Create(sim3_box))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # --- Step 1: Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n self.play(Write(title))\n \n # Fade out the title so we can work cleanly with axes/graphs later\n self.play(FadeOut(title))\n\n # --- Step 2: Axes Setup ---\n # Create axes with ranges (-3, 8) and color Blue\n # Using logarithmic scaling helps visualize the rapid increase of exponential functions\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[0, 8, 1],\n x_length=7,\n y_length=5,\n tips=False,\n axis_config={\"color\": BLUE},\n ).shift(DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n self.play(Create(axes), Write(labels))\n self.wait()\n\n # --- Step 3: Plot e^x ---\n exp_func_e = MathTex(r\"f(x)\", \"=\", r\"\\text{e}^x\")\n exp_graph_e = axes.plot(lambda x: np.exp(x), color=GREEN)\n exp_label_e = MathTex(r\"\\text{e}^x\").next_to(exp_graph_e, UR, buff=0.2).set_color(GREEN)\n\n self.play(Create(exp_graph_e), Write(exp_label_e), Write(exp_func_e))\n self.wait(1)\n\n # Move the original equation to make room for the second function\n self.play(MoveAlongPath(exp_func_e.copy(), exp_graph_e), run_time=2)\n self.wait(1)\n\n # --- Step 4: Introduce 2^x ---\n exp_func_2 = MathTex(r\"g(x)\", \"=\", r\"2^x\")\n exp_graph_2 = axes.plot(lambda x: 2**x, color=RED)\n exp_label_2 = MathTex(r\"2^x\").move_to(exp_label_e.get_center()).set_color(RED).shift(UP * 0.5)\n\n # Animate the transformation of e^x to 2^x\n self.play(\n ReplacementTransform(exp_graph_e, exp_graph_2),\n ReplacementTransform(exp_label_e, exp_label_2),\n ReplacementTransform(exp_func_e, exp_func_2)\n )\n self.wait(1)\n\n # --- Step 5: Show both functions simultaneously ---\n # Reposition the equations to the left and right for comparison\n eq_left = VGroup(MathTex(\"\\\\text{Initial: } f(x) =\", r\"\\\\ \\text{Current: } g(x) =\"), MathTex(\"\\\\text{e}^x\", \"\\\\quad\", r\"2^x\")).arrange(DOWN, aligned_edge=LEFT)\n eq_right = VGroup(MathTex(\"\\\\text{Current: } g(x) = \"), MathTex(\"2^x\")).arrange(DOWN, aligned_edge=RIGHT)\n\n eq_left.to_edge(LEFT).scale(0.8)\n eq_right.next_to(eq_left, RIGHT, buff=1).scale(0.8)\n\n # Shift existing curves to make space for the labels\n self.play(\n exp_graph_2.animate.shift(LEFT * 0.5 + UP * 0.5),\n exp_label_2.animate.move_to(ORIGIN + LEFT * 0.5 + UP * 0.5).shift(LEFT * 0.5 + DOWN * 0.5),\n exp_graph_e.animate.shift(RIGHT * 0.5 + UP * 0.5),\n exp_label_e.animate.move_to(ORIGIN + RIGHT * 0.5 + UP * 0.5).shift(RIGHT * 0.5 + DOWN * 0.5),\n Write(eq_left),\n Write(eq_right)\n )\n\n self.wait(2)\n\n # End of Animation\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # Title\n title = Text(\"Exponential Function Graph\", font_size=36).to_edge(UP)\n \n # Axes configuration\n axis_config = {\n 'x_range': [-3, 3, 1],\n 'y_range': [0, 8, 1],\n 'x_length': config.frame_width - 2,\n 'y_length': config.frame_height - 2,\n 'axis_color': BLUE,\n 'numbers_to_exclude': [0]\n }\n axes = Axes(**axis_config).shift(DOWN * 0.5)\n\n # Plotting e^x initially\n exp_e_label = MathTex(\"e^x\").scale(0.7).next_to(axes, UP, buff=0.5)\n exp_curve_e = axes.plot(lambda x: np.exp(x), color=GREEN)\n \n self.play(Write(title))\n self.play(Create(axes))\n self.play(Create(exp_curve_e), Write(exp_e_label))\n self.wait(1) # Display graph briefly\n\n # Transition to 2^x\n exp_new_label = MathTex(\"2^x\").scale(0.7).next_to(axes, UP, buff=1.0)\n exp_curve_new = axes.plot(lambda x: 2**x, color=RED)\n \n self.play(\n ReplacementTransform(exp_curve_e, exp_curve_new),\n ReplacementTransform(exp_e_label, exp_new_label),\n run_time=2\n )\n self.wait(1)\n\n # Comparison view\n exp_curve_old = axes.plot(lambda x: np.exp(x), color=GREEN)\n exp_old_label = MathTex(\"e^x\").scale(0.7).move_to(exp_new_label.get_center())\n \n self.play(FadeIn(exp_old_label), Create(exp_curve_old))\n self.wait(2)\n \n # Final state\n final_text = Tex(\"End of Animation\").scale(0.8).to_edge(DOWN)\n self.play(Write(final_text))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that explains how to evaluate the definite integral of x^3 from 0 to 2 using the power rule for integration, including the simplification of the final expression?", "chosen": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n \"\"\"\n Animates the step-by-step evaluation of the definite integral \n of x^3 from 0 to 2 using the power rule for integration.\n \"\"\"\n \n # Title for context\n title = Tex(\"Evaluating a Definite Integral\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 1: Display the initial integral expression\n # ------------------------------------------------------------------\n # Define the initial integral expression: integral of x^3 from 0 to 2\n initial_integral = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n initial_integral.scale(1.5) # Scale up for better visibility\n \n self.play(Write(initial_integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 2: Apply the Power Rule for Integration\n # ------------------------------------------------------------------\n # Power Rule: integral(x^n) = x^(n+1) / (n+1)\n # Here n=3, so the antiderivative is x^4 / 4\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.scale(1.5)\n antiderivative.move_to(initial_integral)\n \n self.play(ReplacementTransform(initial_integral, antiderivative))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 3: Substitute the Limits of Integration\n # ------------------------------------------------------------------\n # Evaluate the antiderivative at the upper limit (2) and lower limit (0)\n substitution = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\")\n substitution.scale(1.5)\n substitution.move_to(antiderivative)\n \n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 4: Simplify the Exponents\n # ------------------------------------------------------------------\n # Calculate the powers: 2^4 = 16 and 0^4 = 0\n simplified_powers = MathTex(r\"\\frac{16}{4} - 0\")\n simplified_powers.scale(1.5)\n simplified_powers.move_to(substitution)\n \n self.play(ReplacementTransform(substitution, simplified_powers))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 5: Final Arithmetic and Result\n # ------------------------------------------------------------------\n # Perform the division: 16 / 4 = 4\n final_result = MathTex(r\"4\")\n final_result.scale(1.5)\n final_result.move_to(simplified_powers)\n \n self.play(ReplacementTransform(simplified_powers, final_result))\n \n # Highlight the final answer with a color change and a surrounding box\n self.play(final_result.animate.set_color(GREEN))\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Cleanup/Outro\n self.play(FadeOut(final_result), FadeOut(box), FadeOut(title))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n \"\"\"\n Animates the step-by-step evaluation of the definite integral \n of x^3 from 0 to 2 using the power rule for integration.\n \"\"\"\n \n # Title for context\n title = Tex(\"Evaluating a Definite Integral\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 1: Display the initial integral expression\n # ------------------------------------------------------------------\n # Define the initial integral expression: integral of x^3 from 0 to 2\n initial_integral = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n initial_integral.scale(1.5) # Scale up for better visibility\n \n self.play(Write(initial_integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 2: Apply the Power Rule for Integration\n # ------------------------------------------------------------------\n # Power Rule: integral(x^n) = x^(n+1) / (n+1)\n # Here n=3, so the antiderivative is x^4 / 4\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.scale(1.5)\n antiderivative.move_to(initial_integral)\n \n self.play(ReplacementTransform(target_position=ORIGIN, initial_integral, antiderivative))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 3: Substitute the Limits of Integration\n # ------------------------------------------------------------------\n # Evaluate the antiderivative at the upper limit (2) and lower limit (0)\n substitution = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\")\n substitution.scale(1.5)\n substitution.move_to(antiderivative)\n \n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 4: Simplify the Exponents\n # ------------------------------------------------------------------\n # Calculate the powers: 2^4 = 16 and 0^4 = 0\n simplified_powers = MathTex(r\"\\frac{16}{4} - 0\")\n simplified_powers.scale(1.5)\n simplified_powers.move_to(substitution)\n \n self.play(ReplacementTransform(substitution, simplified_powers))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 5: Final Arithmetic and Result\n # ------------------------------------------------------------------\n # Perform the division: 16 / 4 = 4\n final_result = MathTex(r\"4\")\n final_result.scale(1.5)\n final_result.move_to(simplified_powers)\n \n self.play(ReplacementTransform(simplified_powers, final_result))\n \n # Highlight the final answer with a color change and a surrounding box\n self.play(final_result.animate.set_color(GREEN))\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Cleanup/Outro\n self.play(FadeOut(final_result), FadeOut(box), FadeOut(title))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: **Enhanced Animation Instruction:** \n- Act 2: Here’s an enhanced version of the animation with additional features: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0405(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_triangletocirclewitharea()\n self.clear_stage()\n self.act_2_enhancedrotationscene()\n\n def act_1_triangletocirclewitharea(self):\n triangle = Polygon(\n [-2, -1, 0], [2, -1, 0], [0, 1, 0],\n color=BLUE, fill_opacity=0.5\n )\n triangle_area_text = MathTex(r\"\\text{Area} = \\frac{\\text{base} \\times \\text{height}}{2}\").next_to(triangle, DOWN)\n \n # Show initial elements\n self.play(Create(triangle), Write(triangle_area_text))\n self.wait(1)\n \n # Create circle (initially hidden)\n circle = Circle(radius=1, color=RED, fill_opacity=0.5).move_to(triangle.get_center())\n circle_area_text = MathTex(r\"\\text{Area} = \\pi r^2\").move_to(triangle_area_text)\n radius_line = Line(circle.get_center(), circle.get_right(), color=YELLOW)\n radius_label = MathTex(\"r\").next_to(radius_line, UP)\n \n # Animate transformation\n self.play(\n Rotate(triangle, angle=PI/2, about_point=triangle.get_center()),\n Transform(triangle, circle),\n Transform(triangle_area_text, circle_area_text),\n run_time=2\n )\n \n # Show radius and label\n self.play(Create(radius_line), Write(radius_label))\n self.wait(0.5)\n \n # Highlight formulas\n self.play(\n triangle_area_text.animate.set_color(YELLOW),\n Flash(triangle_area_text, color=YELLOW, line_length=0.3),\n run_time=1\n )\n self.play(triangle_area_text.animate.set_color(WHITE))\n self.wait(0.5)\n \n # Pulse circle\n self.play(\n circle.animate.scale(1.2),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show conclusion text\n conclusion = Tex(\"A triangle can be smoothly deformed into a circle while preserving area.\").to_edge(DOWN)\n self.play(FadeIn(conclusion))\n self.wait(2)\n\n def act_2_enhancedrotationscene(self):\n circle = Circle(color=BLUE, fill_opacity=0.5)\n triangle = Triangle(color=RED, fill_opacity=0.5)\n shapes = VGroup(circle, triangle)\n shapes.arrange(RIGHT, buff=1)\n \n # Display shapes\n self.play(\n Create(circle),\n Create(triangle),\n run_time=2\n )\n self.wait(1)\n \n # Rotate the group\n self.play(\n Rotate(shapes, angle=-45 * DEGREES, about_point=shapes.get_center()),\n run_time=2\n )\n self.wait(1)\n \n # Morph circle into triangle\n self.play(\n Transform(circle, triangle.copy().set_color(BLUE)),\n run_time=2\n )\n self.wait(1)\n \n # Morph triangle back into circle\n self.play(\n Transform(circle, Circle(color=BLUE, fill_opacity=0.5)),\n run_time=2\n )\n self.wait(1)\n \n # Display rotation formula\n formula = MathTex(r\"\\theta = -\\frac{\\pi}{4}\").next_to(shapes, DOWN, buff=1)\n self.play(\n Write(formula),\n Flash(shapes, color=YELLOW, flash_radius=1.5),\n run_time=2\n )\n self.wait(1)\n \n # Add explanatory text\n label = Text(\"Rotation of -45°\").to_edge(UP)\n self.play(\n Write(label),\n shapes.animate.scale(1.2),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0405(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_triangletocirclewitharea()\n self.clear_stage()\n self.act_2_enhancedrotationscene()\n\n def act_1_triangletocirclewitharea(self):\n triangle = Polygon(\n [-2, -1, 0], [2, -1, 0], [0, 1, 0],\n color=BLUE, fill_opacity=0.5\n )\n triangle_area_text = MathTex(r\"\\text{Area} = \\frac{\\text{base} \\times \\text{height}}{2}\").next_to(triangle, DOWN)\n \n # Show initial elements\n self.play(Create(triangle), Write(triangle_area_text))\n self.wait(1)\n \n # Create circle (initially hidden)\n circle = Circle(radius=1, color=RED, fill_opacity=0.5).move_to(triangle.get_center())\n circle_area_text = MathTex(r\"\\text{Area} = \\pi r^2\").move_to(triangle_area_text)\n radius_line = Line(circle.get_center(), circle.get_right(), color=YELLOW)\n radius_label = MathTex(\"r\").next_to(radius_line, UP)\n \n # Animate transformation\n self.play(\n Rotate(triangle, angle=PI/2, about_point=triangle.get_center()),\n Transform(triangle, circle),\n Transform(triangle_area_text, circle_area_text),\n run_time=2\n )\n \n # Show radius and label\n self.play(Create(radius_line), Write(radius_label))\n self.wait(0.5)\n \n # Highlight formulas\n self.play(\n triangle_area_text.animate.set_color(YELLOW),\n Flash(triangle_area_text, color=YELLOW, line_length=0.3),\n run_time=1\n )\n self.play(triangle_area_text.animate.set_color(WHITE))\n self.wait(0.5)\n \n # Pulse circle\n self.play(\n circle.animate.scale(1.2),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show conclusion text\n conclusion = Tex(\"A triangle can be smoothly deformed into a circle while preserving area.\").to_edge(DOWN)\n self.play(FadeIn(conclusion))\n self.wait(2)\n\n def act_2_enhancedrotationscene(self):\n circle = Circle(color=BLUE, fill_opacity=0.5)\n triangle = Triangle(color=RED, fill_opacity=0.5)\n shapes = VGroup(circle, triangle)\n shapes.arrange(RIGHT, buff=1)\n \n # Display shapes\n self.play(\n Create(circle),\n Create(triangle),\n run_time=2\n )\n self.wait(1)\n \n # Rotate the group\n self.play(\n Rotate(shapes, angle=-45 * DEGREES, about_point=shapes.get_center()),\n run_time=2\n )\n self.wait(1)\n \n # Morph circle into triangle\n self.play(\n Transform(circle, triangle.copy().set_color(BLUE)),\n run_time=2\n )\n self.wait(1)\n \n # Morph triangle back into circle\n self.play(\n Transform(circle, Circle(color=BLUE, fill_opacity=0.5)),\n run_time=2\n )\n self.wait(1)\n \n # Display rotation formula\n formula = MathTex(r\"\\theta = -\\frac{\\pi}{4}\").next_to(shapes, DOWN, buff=1)\n self.play(\n Write(formula),\n Flash(shapes, color=YELLOW, flash_radius=1.5),\n run_time=2\n )\n self.wait(1)\n \n # Add explanatory text\n label = Text(\"Rotation of -45°\").to_edge(UP)\n self.play(\n Write(label),\n shapes.animate.scale(1.2),\n run_time=2\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Classification Rule\n\\[\n\\hat{y}=\\arg\\max_y \\Big(\\log P(y)+\\sum_{j=1}^d \\log P(x_j\\mid y)\\Big)\n\\]\n- Actual calculations typically use the logarithmic form to convert products into sums, thereby avoiding numerical underflow.\n\n\nThe context of this section (from highest to current level):\n# Machine Learning Course — Detailed Outline for Lecture 8 (Probabilistic Generative Models, 90 minutes)\n## Naive Bayes (25 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass NaiveBayesRule(Scene):\n\n def construct(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```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass NaiveBayesRule(Scene):\n\n def construct(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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # --- Step 1: Setup ---\n # Display the initial integral expression\n setup_label = Text(\"Calculate the Definite Integral:\", font_size=36).to_edge(UP)\n integral_expr = MathTex(r\"\\int_{0}^{2}\", \"x^3\", \"dx\", font_size=72)\n \n self.play(Write(setup_label))\n self.play(Write(integral_expr))\n self.wait(2)\n\n # --- Step 2: Power Rule Application ---\n # Display the power rule formula for reference\n rule_label = Text(\"Applying the Power Rule:\", font_size=30, color=BLUE).shift(UP * 2 + LEFT * 3)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40, color=BLUE).next_to(rule_label, RIGHT)\n rule_group = VGroup(rule_label, power_rule).arrange(RIGHT).to_edge(UP, buff=1.5)\n\n self.play(FadeIn(rule_group))\n self.wait(1)\n\n # Transform the integral into the antiderivative with boundaries\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=72)\n \n self.play(Transform(integral_expr, antiderivative))\n self.wait(2)\n\n # Clear the rule now that it's applied\n self.play(FadeOut(rule_group))\n\n # --- Step 3: Boundary Evaluation ---\n # Label for substitution\n sub_label = Text(\"Substitute Boundaries:\", font_size=30, color=YELLOW).to_edge(UP)\n \n # The expression showing (Upper Bound) - (Lower Bound)\n evaluation = MathTex(r\"\\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=72)\n\n self.play(Write(sub_label))\n self.play(Transform(integral_expr, evaluation))\n self.wait(2)\n\n # --- Step 4: Final Calculation ---\n # Label for simplification\n calc_label = Text(\"Simplify and Solve:\", font_size=30, color=GREEN).to_edge(UP)\n \n # Step-by-step simplification\n simplification = MathTex(r\"\\frac{16}{4} - 0\", font_size=72)\n final_answer = MathTex(r\"\\frac{16}{4} - 0 = 4\", font_size=72, color=GREEN)\n\n self.play(ReplacementTransform(sub_label, calc_label))\n self.play(Transform(integral_expr, simplification))\n self.wait(1)\n \n self.play(Transform(integral_expr, final_answer))\n self.wait(3)\n\n # Final Wrap-up: Highlight the result\n box = SurroundingRectangle(integral_expr, color=WHITE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # --- Step 1: Setup ---\n # Display the initial integral expression\n setup_label = Text(\"Calculate the Definite Integral:\", font_size=36).to_edge(UP)\n integral_expr = MathTex(r\"\\int_{0}^{2}\" + \" = x\", \"x^3\", \"dx\", font_size=72)\n \n self.play(Write(setup_label))\n self.play(Write(integral_expr))\n self.wait(2)\n\n # --- Step 2: Power Rule Application ---\n # Display the power rule formula for reference\n rule_label = Text(\"Applying the Power Rule:\", font_size=30, color=BLUE).shift(UP * 2 + LEFT * 3)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40, color=BLUE).next_to(rule_label, RIGHT)\n rule_group = VGroup(rule_label, power_rule).arrange(RIGHT).to_edge(UP, buff=1.5)\n\n self.play(FadeIn(rule_group))\n self.wait(1)\n\n # Transform the integral into the antiderivative with boundaries\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=72)\n \n self.play(Transform(integral_expr, antiderivative))\n self.wait(2)\n\n # Clear the rule now that it's applied\n self.play(FadeOut(rule_group))\n\n # --- Step 3: Boundary Evaluation ---\n # Label for substitution\n sub_label = Text(\"Substitute Boundaries:\", font_size=30, color=YELLOW).to_edge(UP)\n \n # The expression showing (Upper Bound) - (Lower Bound)\n evaluation = MathTex(r\"\\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=72)\n\n self.play(Write(sub_label))\n self.play(Transform(integral_expr, evaluation))\n self.wait(2)\n\n # --- Step 4: Final Calculation ---\n # Label for simplification\n calc_label = Text(\"Simplify and Solve:\", font_size=30, color=GREEN).to_edge(UP)\n \n # Step-by-step simplification\n simplification = MathTex(r\"\\frac{16}{4} - 0\", font_size=72)\n final_answer = MathTex(r\"\\frac{16}{4} - 0 = 4\", font_size=72, color=GREEN)\n\n self.play(ReplacementTransform(sub_label, calc_label))\n self.play(Transform(integral_expr, simplification))\n self.wait(1)\n \n self.play(Transform(integral_expr, final_answer))\n self.wait(3)\n\n # Final Wrap-up: Highlight the result\n box = SurroundingRectangle(integral_expr, color=WHITE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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- **Calculation Example**:\n\n - Xiaoming's Data: Weight 70kg, Height 1.75m\n - Calculation Process: $70 \\div (1.75 \\times 1.75) \\approx 22.9$\n\n\nThe context location of this section (from highest to current level):\n# The Science Behind Weight - BMI and Health\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BMICalculationExample(Scene):\n\n def construct(self):\n title = Text('The Science Behind Weight - BMI and Health', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('Calculation Example', font_size=30, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n data_title = Text(\"Xiaoming's Data:\", font_size=28, color=YELLOW)\n weight_text = Text('• Weight: 70 kg', font_size=28)\n height_text = Text('• Height: 1.75 m', font_size=28)\n data_group = VGroup(data_title, weight_text, height_text)\n data_group.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n data_group.next_to(subtitle, DOWN, buff=0.8).to_edge(LEFT, buff=2)\n self.play(Write(data_title))\n self.play(FadeIn(weight_text, shift=RIGHT * 0.3))\n self.play(FadeIn(height_text, shift=RIGHT * 0.3))\n self.wait(1)\n calc_title = Text('Calculation Process:', font_size=28, color=YELLOW)\n calc_title.next_to(data_group, DOWN, buff=0.8, aligned_edge=LEFT)\n self.play(Write(calc_title))\n self.wait(0.5)\n formula = MathTex('\\\\text{BMI}', '=', '70 \\\\div (1.75 \\\\times 1.75)', '\\\\approx', '22.9', font_size=44)\n formula.next_to(calc_title, DOWN, buff=0.6)\n formula.set_x(0)\n self.play(Write(formula[0:2]))\n self.wait(0.2)\n self.play(Write(formula[2]))\n self.wait(1)\n self.play(Write(formula[3:]))\n self.wait(0.5)\n result_box = SurroundingRectangle(formula[4], color=GREEN, buff=0.15)\n self.play(Create(result_box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BMICalculationExample(Scene):\n\n def construct(self):\n title = Text('The Science Behind Weight - BMI and Health', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('Calculation Example', font_size=30, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n data_title = Text(\"Xiaoming's Data:\", font_size=28, color=YELLOW)\n weight_text = Text('• Weight: 70 kg', font_size=28)\n height_text = Text('• Height: 1.75 m', font_size=28)\n data_group = VGroup(data_title, weight_text, height_text)\n data_group.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n data_group.next_to(subtitle, DOWN, buff=0.8).to_edge(LEFT, buff=2)\n self.play(Write(data_title))\n self.play(FadeIn(weight_text, shift=RIGHT * 0.3))\n self.play(FadeIn(height_text, shift=RIGHT * 0.3))\n self.wait(1)\n calc_title = Text('Calculation Process:', font_size=28, color=YELLOW)\n calc_title.next_to(data_group, DOWN, buff=0.8, aligned_edge=LEFT)\n self.play(Write(calc_title))\n self.wait(0.5)\n formula = MathTex('\\\\text{BMI}', '=', '70 \\\\div (1.75 \\\\times 1.75)', '\\\\approx', '22.9', font_size=44)\n formula.next_to(calc_title, DOWN, buff=0.6)\n formula.set_x(0)\n self.play(Write(formula[0:2]))\n self.wait(0.2)\n self.play(Write(formula[2]))\n self.wait(1)\n self.play(Write(formula[3:]))\n self.wait(0.5)\n result_box = SurroundingRectangle(formula[4], color=GREEN, buff=0.15)\n self.play(Create(result_box))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational math animation that shows visually how to find the area under the curve of the function y = x^2, specifically between the x-values of 1 and 3. Start the animation by displaying the equation of the curve, then present the goal of calculating the definite integral of this function from 1 to 3 to find the area underneath. I want the animation to then show the integral symbol with the limits of integration, followed by the steps of integration, including evaluating the integrated function at the bounds. Finally, display the result of the area calculation and then clear all the elements from the screen.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Introduction: Display the equation of the curve\n title = Text(\"Area Under the Curve\", font_size=40)\n equation = MathTex(\"y = x^2\", font_size=60)\n equation.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(equation))\n\n # 2. Goal Statement: Present the objective\n goal_text = Text(\n \"Goal: Calculate the definite integral\\nfrom x = 1 to x = 3\",\n font_size=36\n )\n self.play(Write(goal_text))\n self.wait(2)\n self.play(FadeOut(goal_text))\n\n # 3. Mathematical Setup: Graph and integral notation\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True},\n ).shift(LEFT * 3)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n curve = axes.plot(lambda x: x**2, color=YELLOW)\n curve_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.2)\n \n area = axes.get_area(curve, x_range=[1, 3], color=BLUE, opacity=0.5)\n line_1 = axes.get_vertical_line(axes.input_to_graph_point(1, curve), color=WHITE)\n line_3 = axes.get_vertical_line(axes.input_to_graph_point(3, curve), color=WHITE)\n \n integral_expr = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=50).to_edge(UP)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(curve_label))\n self.play(Write(integral_expr))\n self.play(FadeIn(area), Create(line_1), Create(line_3))\n self.wait(2)\n\n # 4. Integration Steps\n # Move integral to the side to make room for steps\n integral_expr.generate_target()\n integral_expr.target.scale(0.8).to_corner(UL)\n self.play(MoveToTarget(integral_expr))\n \n # Step 4a: Finding the antiderivative\n antiderivative = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\",\n font_size=50\n ).next_to(integral_expr, RIGHT, buff=0.3)\n \n self.play(Write(antiderivative))\n self.wait(1)\n \n # Step 4b: Evaluating the integrated function at the bounds\n evaluation = MathTex(\n r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\",\n font_size=50\n ).next_to(antiderivative, DOWN, aligned_edge=LEFT)\n \n self.play(Write(evaluation))\n self.wait(1)\n \n # Step 4c: Simplifying\n simplification = MathTex(\n r\"= \\frac{27}{3} - \\frac{1}{3}\",\n font_size=50\n ).next_to(evaluation, DOWN, aligned_edge=LEFT)\n \n self.play(Write(simplification))\n self.wait(1)\n\n # 5. Result: Display the final calculated area value\n final_result = MathTex(\n r\"= \\frac{26}{3} \\approx 8.67\",\n font_size=60,\n color=YELLOW\n ).next_to(simplification, DOWN, aligned_edge=LEFT)\n \n result_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.1)\n \n self.play(Write(final_result))\n self.play(Create(result_box))\n self.wait(3)\n\n # 6. Cleanup: Clear all elements from the screen\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Introduction: Display the equation of the curve\n title = Text(\"Area Under the Curve\", font_size=40)\n equation = MathTex(\"y = x^2\", font_size=60)\n equation.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(equation))\n\n # 2. Goal Statement: Present the objective\n goal_text = Text(\n \"Goal: Calculate the definite integral\\nfrom x = 1 to x = 3\",\n font_size=36\n )\n self.play(Write(goal_text))\n self.wait(2)\n self.play(FadeOut(goal_text))\n\n # 3. Mathematical Setup: Graph and integral notation\n axes = Axes(label_font_size=24, \n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True},\n ).shift(LEFT * 3)\n \n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n \n curve = axes.plot(lambda x: x**2, color=YELLOW)\n curve_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.2)\n \n area = axes.get_area(curve, x_range=[1, 3], color=BLUE, opacity=0.5)\n line_1 = axes.get_vertical_line(axes.input_to_graph_point(1, curve), color=WHITE)\n line_3 = axes.get_vertical_line(axes.input_to_graph_point(3, curve), color=WHITE)\n \n integral_expr = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=50).to_edge(UP)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(curve_label))\n self.play(Write(integral_expr))\n self.play(FadeIn(area), Create(line_1), Create(line_3))\n self.wait(2)\n\n # 4. Integration Steps\n # Move integral to the side to make room for steps\n integral_expr.generate_target()\n integral_expr.target.scale(0.8).to_corner(UL)\n self.play(MoveToTarget(integral_expr))\n \n # Step 4a: Finding the antiderivative\n antiderivative = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\",\n font_size=50\n ).next_to(integral_expr, RIGHT, buff=0.3)\n \n self.play(Write(antiderivative))\n self.wait(1)\n \n # Step 4b: Evaluating the integrated function at the bounds\n evaluation = MathTex(\n r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\",\n font_size=50\n ).next_to(antiderivative, DOWN, aligned_edge=LEFT)\n \n self.play(Write(evaluation))\n self.wait(1)\n \n # Step 4c: Simplifying\n simplification = MathTex(\n r\"= \\frac{27}{3} - \\frac{1}{3}\",\n font_size=50\n ).next_to(evaluation, DOWN, aligned_edge=LEFT)\n \n self.play(Write(simplification))\n self.wait(1)\n\n # 5. Result: Display the final calculated area value\n final_result = MathTex(\n r\"= \\frac{26}{3} \\approx 8.67\",\n font_size=60,\n color=YELLOW\n ).next_to(simplification, DOWN, aligned_edge=LEFT)\n \n result_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.1)\n \n self.play(Write(final_result))\n self.play(Create(result_box))\n self.wait(3)\n\n # 6. Cleanup: Clear all elements from the screen\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to see an educational animation that visually explains how to evaluate the definite integral of x cubed from 0 to 1. The video should start by displaying the integral problem, and then go step by step through the process of solving it using the power rule for integration. After that, it should show how to apply the bounds of the integral and simplify the final answer. Finally, it should conclude by showing the simplified solution on a clear screen. Can you create such an animation that is easy to understand, possibly for use in a math classroom?", "chosen": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n # --- 1. Introduction ---\n # Display the definite integral problem\n problem = MathTex(r\"\\int_0^1 x^3 \\, dx\", font_size=72)\n self.play(Write(problem))\n self.wait(2)\n self.play(problem.animate.to_edge(UP))\n\n # --- 2. Step-by-Step Solution: Power Rule ---\n # State the general Power Rule for integration\n power_rule_label = Text(\"Power Rule for Integration:\", font_size=32, color=BLUE)\n power_rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=48, \n color=BLUE\n )\n power_rule_group = VGroup(power_rule_label, power_rule).arrange(DOWN, buff=0.2)\n power_rule_group.next_to(problem, DOWN, buff=1)\n \n self.play(Write(power_rule_group))\n self.wait(2)\n\n # Apply the rule to x^3\n application = MathTex(\n r\"n=3 \\implies \\frac{x^{3+1}}{3+1} = \\frac{x^4}{4}\", \n font_size=48\n ).next_to(power_rule_group, DOWN, buff=0.5)\n \n self.play(Write(application))\n self.wait(2)\n\n # Transition to the antiderivative notation\n antiderivative = MathTex(\n r\"\\left[ \\frac{x^4}{4} \\right]_0^1\", \n font_size=72\n ).move_to(ORIGIN)\n \n self.play(\n FadeOut(power_rule_group), \n FadeOut(application),\n Transform(problem, antiderivative)\n )\n self.wait(2)\n\n # --- 3. Evaluation: Substituting Bounds ---\n # Show the substitution of upper and lower bounds\n substitution = MathTex(\n r\"= \\left( \\frac{1^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=72\n ).next_to(problem, DOWN, buff=0.8)\n \n self.play(Write(substitution))\n self.wait(2)\n\n # --- 4. Simplification ---\n # Simplify the arithmetic\n simplification = MathTex(\n r\"= \\frac{1}{4} - 0\", \n font_size=72\n ).next_to(substitution, DOWN, buff=0.8)\n \n self.play(Write(simplification))\n self.wait(2)\n\n final_step = MathTex(\n r\"= \\frac{1}{4}\", \n font_size=80, \n color=YELLOW\n ).next_to(simplification, DOWN, buff=0.8)\n \n self.play(Write(final_step))\n self.wait(3)\n\n # --- 5. Conclusion ---\n # Clear the screen for the final answer\n self.play(\n FadeOut(problem), \n FadeOut(substitution), \n FadeOut(simplification), \n FadeOut(final_step)\n )\n \n final_result = MathTex(\n r\"\\int_0^1 x^3 \\, dx = \\frac{1}{4}\", \n font_size=90\n )\n \n box = SurroundingRectangle(final_result, color=BLUE, buff=0.3)\n \n self.play(Write(final_result))\n self.play(Create(box))\n self.play(final_result.animate.scale(1.1))\n self.wait(4)\n```", "rejected": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n # --- 1. Introduction ---\n # Display the definite integral problem\n problem = MathTex(r\"\\int_0^1 x^3 \\, dx\" + \" = x\", font_size=72)\n self.play(Write(problem))\n self.wait(2)\n self.play(problem.animate.to_edge(UP))\n\n # --- 2. Step-by-Step Solution: Power Rule ---\n # State the general Power Rule for integration\n power_rule_label = Text(\"Power Rule for Integration:\", font_size=32, color=BLUE)\n power_rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=48, \n color=BLUE\n )\n power_rule_group = VGroup(power_rule_label, power_rule).arrange(DOWN, buff=0.2)\n power_rule_group.next_to(problem, DOWN, buff=1)\n \n self.play(Write(power_rule_group))\n self.wait(2)\n\n # Apply the rule to x^3\n application = MathTex(\n r\"n=3 \\implies \\frac{x^{3+1}}{3+1} = \\frac{x^4}{4}\", \n font_size=48\n ).next_to(power_rule_group, DOWN, buff=0.5)\n \n self.play(Write(application))\n self.wait(2)\n\n # Transition to the antiderivative notation\n antiderivative = MathTex(\n r\"\\left[ \\frac{x^4}{4} \\right]_0^1\", \n font_size=72\n ).move_to(ORIGIN)\n \n self.play(\n FadeOut(power_rule_group), \n FadeOut(application),\n Transform(problem, antiderivative)\n )\n self.wait(2)\n\n # --- 3. Evaluation: Substituting Bounds ---\n # Show the substitution of upper and lower bounds\n substitution = MathTex(\n r\"= \\left( \\frac{1^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=72\n ).next_to(problem, DOWN, buff=0.8)\n \n self.play(Write(substitution))\n self.wait(2)\n\n # --- 4. Simplification ---\n # Simplify the arithmetic\n simplification = MathTex(\n r\"= \\frac{1}{4} - 0\", \n font_size=72\n ).next_to(substitution, DOWN, buff=0.8)\n \n self.play(Write(simplification))\n self.wait(2)\n\n final_step = MathTex(\n r\"= \\frac{1}{4}\", \n font_size=80, \n color=YELLOW\n ).next_to(simplification, DOWN, buff=0.8)\n \n self.play(Write(final_step))\n self.wait(3)\n\n # --- 5. Conclusion ---\n # Clear the screen for the final answer\n self.play(\n FadeOut(problem), \n FadeOut(substitution), \n FadeOut(simplification), \n FadeOut(final_step)\n )\n \n final_result = MathTex(\n r\"\\int_0^1 x^3 \\, dx = \\frac{1}{4}\", \n font_size=90\n )\n \n box = SurroundingRectangle(final_result, color=BLUE, buff=0.3)\n \n self.play(Write(final_result))\n self.play(Create(box))\n self.play(final_result.animate.scale(1.1))\n self.wait(4)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows the process of calculating the definite integral of the function x cubed from 0 to 2? Start by displaying the integral problem, then explain the use of the power rule for integration, followed by demonstrating it. Subsequently, perform the integration step by step. Finally, reveal the numerical result after evaluating at the boundaries, and conclude the animation with the final answer to the integral.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # --- 1. Problem Display ---\n # Initialize and display the definite integral problem\n title = Text(\"Definite Integral Calculation\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n \n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.8)\n self.play(Write(problem))\n self.wait(1)\n\n # Move problem up to make room for explanation\n problem.generate_target()\n problem.target.shift(UP * 1.5)\n self.play(MoveToTarget(problem))\n\n # --- 2. Concept Explanation ---\n # Visually present the Power Rule for Integration\n rule_title = Text(\"Power Rule for Integration\", font_size=28)\n rule_title.next_to(problem, DOWN, buff=0.8)\n \n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n power_rule.next_to(rule_title, DOWN, buff=0.3)\n power_rule.set_color(BLUE)\n \n # Highlight the specific application for this problem\n hint = Text(\"Apply rule: n = 3 \\rightarrow n + 1 = 4\", font_size=24)\n hint.next_to(power_rule, DOWN, buff=0.3)\n hint.set_color(YELLOW)\n\n self.play(FadeIn(rule_title), Write(power_rule), Write(hint))\n self.wait(2)\n\n # --- 3. Step-by-Step Execution ---\n # Show the antiderivative with boundary notation\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.scale(1.8)\n antiderivative.move_to(problem)\n \n # Smoothly transition from the problem to the antiderivative\n self.play(ReplacementTransform(problem, antiderivative))\n # Clean up explanation text\n self.play(FadeOut(rule_title), FadeOut(power_rule), FadeOut(hint))\n self.wait(1)\n\n # --- 4. Evaluation ---\n # Demonstrate the evaluation of the antiderivative at the boundaries\n eval_label = Text(\"Evaluate at boundaries:\", font_size=24)\n eval_label.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(eval_label))\n\n evaluation = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n evaluation.scale(1.5)\n evaluation.next_to(eval_label, DOWN, buff=0.5)\n \n self.play(Write(evaluation))\n self.wait(1)\n\n # --- 5. Numerical Calculation ---\n # Simplify the expression to show the arithmetic\n simplification = MathTex(r\"= \\frac{16}{4} - 0\")\n simplification.scale(1.5)\n simplification.move_to(evaluation)\n \n self.play(ReplacementTransform(evaluation, simplification))\n self.wait(1)\n\n # --- 6. Final Result ---\n # Reveal the calculated numerical result\n final_result = MathTex(r\"= 4\")\n final_result.scale(2)\n final_result.move_to(simplification)\n final_result.set_color(GREEN)\n \n self.play(ReplacementTransform(simplification, final_result))\n self.wait(1)\n\n # Conclude the animation with the final answer clearly displayed\n box = SurroundingRectangle(final_result, color=GREEN, buff=0.3)\n label = Text(\"Final Answer\", font_size=24)\n label.next_to(box, DOWN, buff=0.2)\n \n self.play(Create(box), FadeIn(label))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # --- 1. Problem Display ---\n # Initialize and display the definite integral problem\n title = Text(\"Definite Integral Calculation\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n \n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.8)\n self.play(Write(problem))\n self.wait(1)\n\n # Move problem up to make room for explanation\n problem.generate_target()\n problem.target.shift(UP * 1.5)\n self.play(MoveToTarget(problem))\n\n # --- 2. Concept Explanation ---\n # Visually present the Power Rule for Integration\n rule_title = Text(\"Power Rule for Integration\", font_size=28)\n rule_title.next_to(problem, DOWN, buff=0.8)\n \n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n power_rule.next_to(rule_title, DOWN, buff=0.3)\n power_rule.set_color(BBLUE)\n \n # Highlight the specific application for this problem\n hint = Text(\"Apply rule: n = 3 \\rightarrow n + 1 = 4\", font_size=24)\n hint.next_to(power_rule, DOWN, buff=0.3)\n hint.set_color(YELLOW)\n\n self.play(FadeIn(rule_title), Write(power_rule), Write(hint))\n self.wait(2)\n\n # --- 3. Step-by-Step Execution ---\n # Show the antiderivative with boundary notation\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.scale(1.8)\n antiderivative.move_to(problem)\n \n # Smoothly transition from the problem to the antiderivative\n self.play(ReplacementTransform(problem, antiderivative))\n # Clean up explanation text\n self.play(FadeOut(rule_title), FadeOut(power_rule), FadeOut(hint))\n self.wait(1)\n\n # --- 4. Evaluation ---\n # Demonstrate the evaluation of the antiderivative at the boundaries\n eval_label = Text(\"Evaluate at boundaries:\", font_size=24)\n eval_label.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(eval_label))\n\n evaluation = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n evaluation.scale(1.5)\n evaluation.next_to(eval_label, DOWN, buff=0.5)\n \n self.play(Write(evaluation))\n self.wait(1)\n\n # --- 5. Numerical Calculation ---\n # Simplify the expression to show the arithmetic\n simplification = MathTex(r\"= \\frac{16}{4} - 0\")\n simplification.scale(1.5)\n simplification.move_to(evaluation)\n \n self.play(ReplacementTransform(evaluation, simplification))\n self.wait(1)\n\n # --- 6. Final Result ---\n # Reveal the calculated numerical result\n final_result = MathTex(r\"= 4\")\n final_result.scale(2)\n final_result.move_to(simplification)\n final_result.set_color(GREEN)\n \n self.play(ReplacementTransform(simplification, final_result))\n self.wait(1)\n\n # Conclude the animation with the final answer clearly displayed\n box = SurroundingRectangle(final_result, color=GREEN, buff=0.3)\n label = Text(\"Final Answer\", font_size=24)\n label.next_to(box, DOWN, buff=0.2)\n \n self.play(Create(box), FadeIn(label))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass FourierSeriesExplanation(Scene):\n def construct(self):\n # --- Stage 1: General Equation Display ---\n title = Text(\"The Fourier Series\", font_size=48).to_edge(UP)\n \n # Split the equation to allow highlighting of the summation term\n lhs = MathTex(\"f(x)\")\n rhs_part1 = MathTex(\"= \\\\frac{a_0}{2} + \\\\sum_{n=1}^{\\\\infty}\")\n rhs_part2 = MathTex(\"\\\\left[ a_n \\\\cos(n \\\\omega x) + b_n \\\\sin(n \\\\omega x) \\\\right]\")\n \n rhs = VGroup(rhs_part1, rhs_part2).arrange(RIGHT, buff=0.1)\n general_eq = VGroup(lhs, rhs).arrange(RIGHT, buff=0.1).scale(1.2)\n \n self.play(Write(title), run_time=1)\n self.play(Write(general_eq), run_time=2)\n self.wait(1)\n\n # --- Stage 2: Conceptual Explanation ---\n concept_text = Text(\n \"Any periodic function can be decomposed\\ninto a sum of simple sine and cosine waves.\",\n font_size=30,\n line_spacing=1.5,\n color=BLUE_B\n ).next_to(general_eq, DOWN, buff=1)\n \n self.play(FadeIn(concept_text, shift=UP), run_time=1.5)\n self.wait(1)\n \n # Highlight the constituent frequencies part of the formula\n sum_box = SurroundingRectangle(rhs_part2, color=YELLOW, buff=0.15)\n self.play(Create(sum_box), run_time=1)\n self.wait(1)\n \n # Transition: Move equation to the corner and prepare for the example\n self.play(\n FadeOut(title),\n FadeOut(concept_text),\n FadeOut(sum_box),\n general_eq.animate.scale(0.6).to_corner(UL),\n run_time=1.5\n )\n\n # --- Stage 3: Specific Example (Two Terms) ---\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\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 labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(labels), run_time=1.5)\n\n # Define the components: f(x) = sin(x) + 0.5*sin(2x)\n term1_func = lambda x: np.sin(x)\n term2_func = lambda x: 0.5 * np.sin(2 * x)\n combined_func = lambda x: term1_func(x) + term2_func(x)\n\n graph1 = axes.plot(term1_func, color=BLUE)\n graph2 = axes.plot(term2_func, color=GREEN)\n graph_sum = axes.plot(combined_func, color=YELLOW)\n\n # Splitting the example equation allows for individual term coloring\n eq_example = MathTex(\"f(x) \\\\approx\", \"\\\\sin(x)\", \"+\", \"0.5\\\\sin(2x)\", font_size=36)\n eq_example.next_to(axes, UP, buff=0.2)\n\n # Animate First Term (Fundamental Frequency)\n self.play(Create(graph1), eq_example[1].animate.set_color(BLUE), run_time=2)\n self.wait(0.5)\n\n # Animate Second Term (Harmonic)\n self.play(Create(graph2), eq_example[3].animate.set_color(GREEN), run_time=2)\n self.wait(0.5)\n\n # Animate the Superposition (The Sum)\n self.play(\n Create(graph_sum),\n graph1.animate.set_stroke(opacity=0.3),\n graph2.animate.set_stroke(opacity=0.3),\n run_time=2\n )\n self.wait(0.5)\n \n # Highlight the resulting combined wave\n self.play(Indicate(graph_sum), run_time=1)\n self.wait(2)\n\n # --- Stage 4: Conclusion & Fade Out ---\n conclusion = Text(\n \"Complex Wave = Sum of Simple Frequencies\",\n font_size=30,\n color=WHITE\n ).to_edge(DOWN)\n \n self.play(FadeIn(conclusion), run_time=1)\n self.wait(2)\n \n self.play(\n FadeOut(general_eq),\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(graph1),\n FadeOut(graph2),\n FadeOut(graph_sum),\n FadeOut(eq_example),\n FadeOut(conclusion),\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass FourierSeriesExplanation(Scene):\n def construct(self):\n # --- Stage 1: General Equation Display ---\n title = Text(\"The Fourier Series\", font_size=48).to_edge(UP)\n \n # Split the equation to allow highlighting of the summation term\n lhs = MathTex(r\"f(x)\" + \" = x\")\n rhs_part1 = MathTex(\"= \\\\frac{a_0}{2} + \\\\sum_{n=1}^{\\\\infty}\")\n rhs_part2 = MathTex(\"\\\\left[ a_n \\\\cos(n \\\\omega x) + b_n \\\\sin(n \\\\omega x) \\\\right]\")\n \n rhs = VGroup(rhs_part1, rhs_part2).arrange(RIGHT, buff=0.1)\n general_eq = VGroup(lhs, rhs).arrange(RIGHT, buff=0.1).scale(1.2)\n \n self.play(Write(title), run_time=1)\n self.play(Write(general_eq), run_time=2)\n self.wait(1)\n\n # --- Stage 2: Conceptual Explanation ---\n concept_text = Text(\n \"Any periodic function can be decomposed\\ninto a sum of simple sine and cosine waves.\",\n font_size=30,\n line_spacing=1.5,\n color=BLUE_B\n ).next_to(general_eq, DOWN, buff=1)\n \n self.play(FadeIn(concept_text, shift=UP), run_time=1.5)\n self.wait(1)\n \n # Highlight the constituent frequencies part of the formula\n sum_box = SurroundingRectangle(rhs_part2, color=YELLOW, buff=0.15)\n self.play(Create(sum_box), run_time=1)\n self.wait(1)\n \n # Transition: Move equation to the corner and prepare for the example\n self.play(\n FadeOut(title),\n FadeOut(concept_text),\n FadeOut(sum_box),\n general_eq.animate.scale(0.6).to_corner(UL),\n run_time=1.5\n )\n\n # --- Stage 3: Specific Example (Two Terms) ---\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\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 labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(labels), run_time=1.5)\n\n # Define the components: f(x) = sin(x) + 0.5*sin(2x)\n term1_func = lambda x: np.sin(x)\n term2_func = lambda x: 0.5 * np.sin(2 * x)\n combined_func = lambda x: term1_func(x) + term2_func(x)\n\n graph1 = axes.plot(term1_func, color=BLUE)\n graph2 = axes.plot(term2_func, color=GREEN)\n graph_sum = axes.plot(combined_func, color=YELLOW)\n\n # Splitting the example equation allows for individual term coloring\n eq_example = MathTex(\"f(x) \\\\approx\", \"\\\\sin(x)\", \"+\", \"0.5\\\\sin(2x)\", font_size=36)\n eq_example.next_to(axes, UP, buff=0.2)\n\n # Animate First Term (Fundamental Frequency)\n self.play(Create(graph1), eq_example[1].animate.set_color(BLUE), run_time=2)\n self.wait(0.5)\n\n # Animate Second Term (Harmonic)\n self.play(Create(graph2), eq_example[3].animate.set_color(GREEN), run_time=2)\n self.wait(0.5)\n\n # Animate the Superposition (The Sum)\n self.play(\n Create(graph_sum),\n graph1.animate.set_stroke(opacity=0.3),\n graph2.animate.set_stroke(opacity=0.3),\n run_time=2\n )\n self.wait(0.5)\n \n # Highlight the resulting combined wave\n self.play(Indicate(graph_sum), run_time=1)\n self.wait(2)\n\n # --- Stage 4: Conclusion & Fade Out ---\n conclusion = Text(\n \"Complex Wave = Sum of Simple Frequencies\",\n font_size=30,\n color=WHITE\n ).to_edge(DOWN)\n \n self.play(FadeIn(conclusion), run_time=1)\n self.wait(2)\n \n self.play(\n FadeOut(general_eq),\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(graph1),\n FadeOut(graph2),\n FadeOut(graph_sum),\n FadeOut(eq_example),\n FadeOut(conclusion),\n run_time=1\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Demonstrate the concept of torque and rotational motion.", "chosen": "```python\nfrom manim import *\n\nclass TorqueAndRotationalMotion(Scene):\n def construct(self):\n # Title and explanation\n title = Text(\"Torque and Rotational Motion\", font_size=36).to_edge(UP)\n explanation = Text(\n \"Torque causes an object to rotate about an axis.\",\n font_size=24\n ).next_to(title, DOWN)\n\n # Pivot point representing the axis\n pivot = Dot().set_color(YELLOW).shift(LEFT * 3 + DOWN)\n\n # Rod representing the object\n rod = Line(start=pivot.get_center(), end=pivot.get_center() + UP * 2)\n rod.set_stroke(width=10)\n\n # Force acting on the rod creating torque\n force = Arrow(start=pivot.get_center(), end=pivot.get_center() + RIGHT * 2)\n force.set_color(RED)\n\n # Label for the force\n force_label = Text(\"Force\", font_size=18).next_to(force, RIGHT)\n\n # Label for the rod\n rod_label = Text(\"Rod\", font_size=18).next_to(rod, UP)\n\n # Torque formula\n torque_formula = MathTex(\n r\"\\tau = r \\times F\",\n tex_to_color_map={r\"\\tau\": YELLOW, \"r\": BLUE, \"F\": RED}\n ).scale(1.2).to_edge(DOWN, buff=1)\n\n # Create animations\n self.play(Write(title), Write(explanation))\n self.play(Create(pivot), Write(rod_label))\n self.play(Create(rod))\n self.play(Create(force), Write(force_label))\n self.play(Write(torque_formula))\n\n # Apply rotation to the rod due to torque\n self.play(Rotate(rod, angle=PI/3, axis=OUT), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass TorqueAndRotationalMotion(Scene):\n def construct(self):\n # Title and explanation\n title = Text(\"Torque and Rotational Motion\", font_size=36).to_edge(UP)\n explanation = Text(\n \"Torque causes an object to rotate about an axis.\",\n font_size=24\n ).next_to(title, DOWN)\n\n # Pivot point representing the axis\n pivot = Dot().set_color(YELLOW).shift(LEFT * 3 + DOWN)\n\n # Rod representing the object\n rod = Line(start=pivot.get_center(), end=pivot.get_center() + UP * 2)\n rod.set_stroke(width=10)\n\n # Force acting on the rod creating torque\n force = Arrow(start=pivot.get_center(), end=pivot.get_center() + RIGHT * 2)\n force.set_color(RED)\n\n # Label for the force\n force_label = Text(\"Force\", font_size=18).next_to(force, RIGHT)\n\n # Label for the rod\n rod_label = Text(\"Rod\", font_size=18).next_to(rod, UP)\n\n # Torque formula\n torque_formula = MathTex(r\"\\tau = r \\times F\" + \" = x\",\n tex_to_color_map={r\"\\tau\": YELLOW, \"r\": BLUE, \"F\": RED}\n ).scale(1.2).to_edge(DOWN, buff=1)\n\n # Create animations\n self.play(Write(title), Write(explanation))\n self.play(Create(pivot), Write(rod_label))\n self.play(Create(rod))\n self.play(Create(force), Write(force_label))\n self.play(Write(torque_formula))\n\n # Apply rotation to the rod due to torque\n self.play(Rotate(rod, angle=PI/3, axis=OUT), run_time=2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated visualization of the bubble sort algorithm using colored bars where the height of each bar represents a different value in an array? The animation should show the swapping process of the bars as they are being sorted in ascending order.", "chosen": "```python\nfrom manim import *\n\nclass HarmonicOscillatorScene(Scene):\n def construct(self):\n # Displaying the ODE\n ode = MathTex(r\"m \\frac{d^2x}{dt^2} + b \\frac{dx}{dt} + kx = 0\")\n self.play(Write(ode))\n self.wait(1)\n\n # Explanation of the physical context\n explanation1 = Text(\"Damped Harmonic Oscillator\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Explanation for the associate characteristic equation\n explanation2 = Text(\"Associated characteristic equation\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(1)\n\n # Writing the characteristic equation\n char_eq = MathTex(r\"mr^2 + br + k = 0\")\n self.play(ReplacementTransform(ode.copy(), char_eq))\n self.wait(2)\n\n # Calculate the roots of the characteristic equation\n roots_title = Text(\"Roots of the characteristic equation\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, roots_title))\n roots = MathTex(r\"r = \\frac{-b \\pm \\sqrt{b^2 - 4mk}}{2m}\")\n self.play(ReplacementTransform(char_eq, roots))\n self.wait(2)\n\n # Display the general solution depending on the discriminant\n solution_title = Text(\"General solution depends on the discriminant\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, solution_title))\n different_cases = VGroup(\n MathTex(r\"\\text{If } \\Delta > 0: x(t) = C_1 e^{r_1 t} + C_2 e^{r_2 t}\"),\n MathTex(r\"\\text{If } \\Delta = 0: x(t) = (C_1 + C_2 t) e^{-bt / 2m}\"),\n MathTex(r\"\\text{If } \\Delta < 0: x(t) = e^{-bt / 2m}(C_1 \\cos{\\omega t} + C_2 \\sin{\\omega t})\")\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n\n self.play(Write(different_cases))\n self.wait(2)\n\n # Clear scene and conclude with the case of critical damping\n self.clear()\n self.wait(1)\n crit_damping = Text(\"Case of critical damping (\\\\(\\\\Delta = 0\\\\))\", font_size=24)\n crit_solution = MathTex(r\"x(t) = (C_1 + C_2 t) e^{-bt / 2m}\")\n self.play(Write(crit_damping))\n self.wait(1)\n self.play(Write(crit_solution))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass HarmonicOscillatorScene(Scene):\n def construct(self):\n # Displaying the ODE\n ode = MathTex(r\"m \\frac{d^2x}{dt^2} + b \\frac{dx}{dt} + kx = 0\")\n self.play(Write(ode))\n self.wait(1)\n\n # Explanation of the physical context\n explanation1 = Text(\"Damped Harmonic Oscillator\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Explanation for the associate characteristic equation\n explanation2 = Text(\"Associated characteristic equation\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(1)\n\n # Writing the characteristic equation\n char_eq = MathTex(r\"mr^2 + br + k = 0\")\n self.play(ReplacementTransform(target_position=ORIGIN, ode.copy(), char_eq))\n self.wait(2)\n\n # Calculate the roots of the characteristic equation\n roots_title = Text(\"Roots of the characteristic equation\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, roots_title))\n roots = MathTex(r\"r = \\frac{-b \\pm \\sqrt{b^2 - 4mk}}{2m}\")\n self.play(ReplacementTransform(char_eq, roots))\n self.wait(2)\n\n # Display the general solution depending on the discriminant\n solution_title = Text(\"General solution depends on the discriminant\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, solution_title))\n different_cases = VGroup(\n MathTex(r\"\\text{If } \\Delta > 0: x(t) = C_1 e^{r_1 t} + C_2 e^{r_2 t}\"),\n MathTex(r\"\\text{If } \\Delta = 0: x(t) = (C_1 + C_2 t) e^{-bt / 2m}\"),\n MathTex(r\"\\text{If } \\Delta < 0: x(t) = e^{-bt / 2m}(C_1 \\cos{\\omega t} + C_2 \\sin{\\omega t})\")\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n\n self.play(Write(different_cases))\n self.wait(2)\n\n # Clear scene and conclude with the case of critical damping\n self.clear()\n self.wait(1)\n crit_damping = Text(\"Case of critical damping (\\\\(\\\\Delta = 0\\\\))\", font_size=24)\n crit_solution = MathTex(r\"x(t) = (C_1 + C_2 t) e^{-bt / 2m}\")\n self.play(Write(crit_damping))\n self.wait(1)\n self.play(Write(crit_solution))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second logic scene explaining necessary and sufficient conditions with nested sets. Put set A entirely inside set B, animate examples inside and outside A, and label that A is sufficient for B while B is necessary for A. Avoid implying the converse.", "chosen": "```python\nfrom manim import *\n\nclass SufficientNecessaryScene(Scene):\n def construct(self):\n title = Text(\"Sufficient vs Necessary Conditions\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Draw Venn Diagram\n circle_A = Circle(radius=2.0, color=BLUE, fill_opacity=0.15).shift(LEFT*2)\n text_A = MathTex(\"A\").next_to(circle_A, DOWN)\n \n circle_B = Circle(radius=3.0, color=GREEN, fill_opacity=0.15).move_to(RIGHT*2)\n text_B = MathTex(\"B\").next_to(circle_B, UP)\n \n self.add(text_A, text_B)\n self.play(Create(circle_A), Create(circle_B))\n\n # Show elements in A but not in B\n element_in_A_not_in_B = Dot(point=circle_A.point_at_angle(TAU/4) + RIGHT*1.5, color=YELLOW).scale(1.5)\n label_outside = MathTex(\"\\\\text{Not in } B\\\\ \\\\Rightarrow \\\\text{Possible}\").next_to(element_in_A_not_in_B, DOWN)\n \n self.play(FadeIn(element_in_A_not_in_B), Write(label_outside))\n\n # Show elements in both A and B\n shared_element = Dot(point=ORIGIN, color=WHITE).scale(1.5)\n label_inside = MathTex(\"\\\\text{Both in } A\\\\ \\\\wedge \\\\text{in } B\").next_to(shared_element, DOWN)\n\n self.play(Transform(element_in_A_not_in_B, shared_element), FadeOut(label_outside), Write(label_inside))\n\n # Show elements only in B\n element_only_in_B = Dot(point=circle_B.get_right(), color=RED).scale(1.5)\n label_only_in_B = MathTex(\"\\\\text{Only in } B\\\\ \\\\nrightarrow \\\\text{Required by } A\").next_to(element_only_in_B, UP)\n\n self.play(FadeIn(element_only_in_B), Write(label_only_in_B))\n\n # Add labels for condition statements\n statement_sufficient = MathTex(\"\\\\text{If } A \\\\text{ then } B\", color=BLUE).to_edge(DOWN).shift(LEFT*2)\n statement_necessary = MathTex(\"\\\\text{If } B \\\\text{ then } A\", color=GREEN).to_edge(DOWN).shift(RIGHT*2)\n\n self.play(Write(statement_sufficient), Write(statement_necessary))\n \n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass SetNecessarySufficient(Scene):\n def construct(self):\n # Create sets on axes\n axes = Axes(\n x_min=-3,\n x_max=3,\n y_min=-1,\n y_max=7,\n axis_config={\"include_tip\": False},\n ).shift(LEFT * 2 + DOWN * 0)\n \n circle_A = Circle(radius=1.5, color=GREEN).shift(RIGHT * 2.8 + UP * 0.5) \n label_A = MathTex(\"A\", font_size=42).move_to(circle_A.get_center())\n \n circle_B = Circle(radius=2.5, color=BLUE).shift(RIGHT * 2.8 + UP * 0.5) \n label_B = MathTex(\"B\", font_size=42).move_to(circle_B.get_center()) \n\n self.play(Create(axes))\n self.play(FadeIn(label_A, shift=UP))\n self.play(Create(circle_A)) \n \n # Show elements within both sets\n point_in_A_outside_B = Dot([2.8, 0.5, 0], color=YELLOW) \n dot_label = MathTex(\"\\\\text{Example } \\\\in A \\\\setminus B\").scale(0.6).next_to(point_in_A_outside_B, RIGHT, buff=0.3)\n\n self.play(Write(dot_label))\n self.play(Flash(point_in_A_outside_B, color=YELLOW))\n\n # Animate necessary condition text moving above set B\n n_text = Text(\"necessary\", font_size=32, color=RED).to_edge(UP)\n s_text = Text(\"sufficient\", font_size=32, color=GREEN).to_edge(DOWN)\n\n self.play(Write(n_text), FadeIn(label_B, shift=DOWN))\n self.play(Create(circle_B), Indicate(circle_B, color=BLUE))\n self.wait(1)\n\n # Highlight element in B but not in A\n point_in_B_outside_A = Dot([3.3, 2.5, 0], color=ORANGE)\n outside_label = MathTex(\"\\\\text{Example } \\\\in B \\\\setminus A\").scale(0.6).next_to(point_in_B_outside_A, LEFT, buff=0.3)\n\n self.play(Write(outside_label))\n self.play(Flash(point_in_B_outside_A, color=ORANGE))\n\n # Display relationship equations\n eq_nec = MathTex(\"A \\\\subseteq B\", \"\\\\implies \", \"B \\\\nrightarrow \", \"A\")\n eq_suf = MathTex(\"A \\\\subsetneq B\", \"\\\\implies \", \"B \\\\leftarrow \", \"A\")\n\n eq_group = VGroup(eq_nec, eq_suf).arrange(DOWN, aligned_edge=LEFT)\n eq_group.scale(0.8)\n eq_group.to_edge(RIGHT, buff=1.5).shift(UP * 1.0)\n \n box_nec = SurroundingRectangle(eq_nec[0], color=WHITE)\n box_suf = SurroundingRectangle(eq_suf[0], color=WHITE)\n\n self.play(Write(eq_group))\n self.play(Create(box_nec))\n self.wait(1)\n\n # Clear screen and show equation groups separately\n self.play(\n FadeOut(axes),\n FadeOut(circle_A),\n FadeOut(circle_B),\n FadeOut(label_A),\n FadeOut(label_B),\n FadeOut(point_in_A_outside_B),\n FadeOut(dot_label),\n FadeOut(point_in_B_outside_A),\n FadeOut(outside_label),\n FadeOut(n_text),\n FadeOut(s_text),\n FadeOut(box_nec),\n )\n\n self.play(ReplaceWithBuff(eq_nec[0], eq_nec[2]))\n self.play(ReArrange(eq_nec, [eq_nec[0], eq_nec[1], eq_nec[3]]))\n self.wait(1)\n\n # Add arrow to explain implication flow from equation\n arr_left = Arrow(start=LEFT * 3, end=RIGHT * 3, color=BLUE)\n arr_right = Arrow(start=RIGHT * 3, end=LEFT * 3, color=GREEN)\n\n self.play(GrowArrow(arr_left), GrowArrow(arr_right))\n self.wait(1)\n\n self.play(\n ReplaceWithBuff(eq_suf[0], eq_suf[2]),\n ReArrange(eq_suf, [eq_suf[0], eq_suf[1], eq_suf[3]])\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Function Definition & Initial Scene ---\n # Define quadratic function f(x) = 0.5x^2\n func = lambda x: 0.5 * x**2\n\n # Setup coordinate axes\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [2, 4, 6, 8]},\n ).add_coordinates()\n\n # Plot the quadratic curve\n curve = axes.plot(func, color=BLUE, x_range=[-1, 5])\n\n # Display axes and curve\n self.play(Create(axes), run_time=1.5)\n self.play(Create(curve), run_time=1.5)\n self.wait(1)\n\n # --- 2. Labeling ---\n # Position the equation of the curve near the graph\n equation = MathTex(r\"f(x) = \\frac{1}{2}x^2\", font_size=36)\n equation.to_corner(UR).shift(DOWN * 0.5 + LEFT * 0.5)\n \n self.play(FadeIn(equation), run_time=1)\n self.wait(1)\n\n # --- 3. Shading ---\n # Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=YELLOW, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # --- 4. Explanation ---\n # Display text stating the shaded area represents the integral\n explanation = Text(\n \"The shaded area represents\\nthe integral from 0 to 4\",\n font_size=24,\n color=YELLOW\n )\n explanation.next_to(axes, DOWN, buff=0.5)\n \n self.play(FadeIn(explanation), run_time=1)\n self.wait(1.5)\n\n # --- 5. Formula Transition ---\n # Animate the integral formula replacing the equation label\n integral_formula = MathTex(\n r\"\\int_{0}^{4} \\frac{1}{2}x^2 \\, dx\", font_size=36\n )\n integral_formula.move_to(equation.get_center())\n \n self.play(ReplacementTransform(equation, integral_formula), run_time=2)\n self.wait(1)\n\n # --- 6. Calculation ---\n # Compute and display the actual numerical value of the area\n # Integral of (1/2)x^2 is x^3/6. Evaluated from 0 to 4: 64/6 = 32/3 approx 10.67\n result = MathTex(\n r\"= \\left[ \\frac{x^3}{6} \\right]_{0}^{4} = \\frac{32}{3} \\approx 10.67\",\n font_size=36,\n color=GOLD\n )\n result.next_to(integral_formula, DOWN, buff=0.3)\n \n self.play(Write(result), run_time=1.5)\n self.wait(2)\n\n # --- 7. Final Scene ---\n # Clear all other elements, leaving only the final solution visible\n final_solution = VGroup(integral_formula, result)\n everything_else = VGroup(axes, curve, area, explanation)\n \n self.play(FadeOut(everything_else), run_time=1.5)\n \n # Center the final solution for emphasis\n self.play(\n final_solution.animate.arrange(RIGHT, buff=0.2).scale(1.5).move_to(ORIGIN),\n run_time=1\n )\n \n # --- 8. Pacing ---\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Function Definition & Initial Scene ---\n # Define quadratic function f(x) = 0.5x^2\n func = lambda x: 0.5 * x**2\n\n # Setup coordinate axes\n axes = Axes(label_font_size=24, \n x_range=[-1, 5, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [2, 4, 6, 8]},\n ).add_coordinates()\n\n # Plot the quadratic curve\n curve = axes.plot(func, color=BLUE, x_range=[-1, 5])\n\n # Display axes and curve\n self.play(Create(axes), run_time=1.5)\n self.play(Create(curve), run_time=1.5)\n self.wait(1)\n\n # --- 2. Labeling ---\n # Position the equation of the curve near the graph\n equation = MathTex(r\"f(x) = \\frac{1}{2}x^2\", font_size=36)\n equation.to_corner(UR).shift(DOWN * 0.5 + LEFT * 0.5)\n \n self.play(FadeIn(equation), run_time=1)\n self.wait(1)\n\n # --- 3. Shading ---\n # Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=YELLOW, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # --- 4. Explanation ---\n # Display text stating the shaded area represents the integral\n explanation = Text(\n \"The shaded area represents\\nthe integral from 0 to 4\",\n font_size=24,\n color=YELLOW\n )\n explanation.next_to(axes, DOWN, buff=0.5)\n \n self.play(FadeIn(explanation), run_time=1)\n self.wait(1.5)\n\n # --- 5. Formula Transition ---\n # Animate the integral formula replacing the equation label\n integral_formula = MathTex(\n r\"\\int_{0}^{4} \\frac{1}{2}x^2 \\, dx\", font_size=36\n )\n integral_formula.move_to(equation.get_center())\n \n self.play(ReplacementTransform(equation, integral_formula), run_time=2)\n self.wait(1)\n\n # --- 6. Calculation ---\n # Compute and display the actual numerical value of the area\n # Integral of (1/2)x^2 is x^3/6. Evaluated from 0 to 4: 64/6 = 32/3 approx 10.67\n result = MathTex(\n r\"= \\left[ \\frac{x^3}{6} \\right]_{0}^{4} = \\frac{32}{3} \\approx 10.67\",\n font_size=36,\n color=GOLD\n )\n result.next_to(integral_formula, DOWN, buff=0.3)\n \n self.play(Write(result), run_time=1.5)\n self.wait(2)\n\n # --- 7. Final Scene ---\n # Clear all other elements, leaving only the final solution visible\n final_solution = VGroup(integral_formula, result)\n everything_else = VGroup(axes, curve, area, explanation)\n \n self.play(FadeOut(everything_else), run_time=1.5)\n \n # Center the final solution for emphasis\n self.play(\n final_solution.animate.arrange(RIGHT, buff=0.2).scale(1.5).move_to(ORIGIN),\n run_time=1\n )\n \n # --- 8. Pacing ---\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can the Argument Principle be used to determine the nature of the singularities (simple, double, etc.) of a function contained within a contour?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n title = Text(\"The Argument Principle\", font_size=36)\n subtitle = Text(\n \"Determines singularity types inside contours\",\n font_size=28,\n color=BLUE_C\n )\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.5))\n self.wait(1)\n\n # Create a circle representing the contour\n curve = Circle(radius=2, color=YELLOW)\n curve_label = MathTex(\"C\").next_to(curve, UR, buff=-0.3)\n self.play(Create(curve), Write(curve_label))\n\n # Display the formula for the argument principle\n formula1 = MathTex(\n r\"n(f) = \\frac{1}{2\\pi i} \\int_{C} \\frac{f'(z)}{f(z)} \\\\ dz\"\n ).to_edge(DOWN).scale(0.7)\n \n formula2 = MathTex(\n r\"\\text{(where } n(\\cdot) \\text{ counts zeros minus poles})\"\n ).next_to(formula1, DOWN)\n \n self.play(Write(formula1))\n self.play(Write(formula2))\n self.wait(1)\n\n # Demonstrate different types of singularities\n point_simple = Dot(np.array([0.5, 1.5, 0]), radius=0.1, color=GREEN)\n label_simple = Tex(\"Simple\", font_size=18, color=GREEN).next_to(point_simple, UP)\n self.play(FadeIn(point_simple), FadeIn(label_simple))\n self.wait(0.5)\n\n point_double = Dot(np.array([-1, -1, 0]), radius=0.1, color=RED)\n label_double = Tex(\"Double\", font_size=18, color=RED).next_to(point_double, LEFT)\n self.play(FadeIn(point_double), FadeIn(label_double))\n self.wait(0.5)\n\n point_pole = Dot(np.array([1.5, -1.5, 0]), radius=0.1, color=PURPLE)\n label_pole = Tex(\"Pole\", font_size=18, color=PURPLE).next_to(point_pole, RIGHT)\n self.play(FadeIn(point_pole), FadeIn(label_pole))\n self.wait(1)\n\n # Clear everything except the title\n self.play(\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(point_simple),\n FadeOut(label_simple),\n FadeOut(point_double),\n FadeOut(label_double),\n FadeOut(point_pole),\n FadeOut(label_pole),\n FadeOut(formula1),\n FadeOut(formula2),\n run_time=1.5\n )\n\n conclusion = Text(\n \"Argument Principle allows us to count\\nand classify singularities simply.\",\n font_size=24\n )\n box = SurroundingRectangle(conclusion, color=WHITE, fill_opacity=0.1)\n self.play(Write(conclusion), Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n # Introduction\n title = Text(\"The Argument Principle\", font_size=48)\n subtitle = Text(\n \"Exploring Singularities through Contour Integration\",\n font_size=36,\n color=GRAY\n )\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN * 0.5))\n self.wait(2)\n\n self.play(FadeOut(title), FadeOut(subtitle))\n\n # Display the formula for the argument principle\n arg_princ = MathTex(\n r\"n(z) = \\frac{1}{2\\pi i} \\int_{\\gamma} \\frac{f'(z)}{f(z)} \\, dz\"\n ).scale(0.7).to_edge(UP)\n\n self.play(Write(arg_princ))\n \n # Explain what n(z) represents\n explanation_text = Text(\n \"Where $n(z)$ counts zeros minus poles within the closed curve.\",\n font_size=24,\n color=YELLOW\n )\n\n explanation_text.next_to(arg_princ, DOWN, buff=1.0)\n self.play(Write(explanation_text))\n self.wait(2)\n\n # Clear screen and reset text position\n self.clear()\n self.wait()\n\n # Show a simple function f(z) = z^3 - 1\n func_title = Text(\"Consider the Function:\", font_size=36)\n func_title.to_edge(DOWN)\n\n func_math = MathTex(r\"f(z) = z^3 - 1\")\n func_group = VGroup(func_title, func_math).arrange(RIGHT, buff=1.0)\n func_group.scale(0.8).move_to(ORIGIN)\n\n self.play(Write(func_group))\n self.wait(2)\n\n # Draw the unit circle containing the roots at 1, exp(i*2*pi/3), exp(-i*2*pi/3)\n circle = Circle(radius=1, color=BLUE).shift(LEFT * 3)\n root_circle = Circle(radius=0.1, color=RED)\n root_center = Dot(circle.get_left(), color=WHITE)\n root_a = Dot(root_circle.shift(UP + RIGHT).get_center())\n root_b = Dot(root_circle.shift(UP * math.sin(2 * PI / 3)).get_center())\n\n self.add(circle, root_center, root_a, root_b)\n self.wait(2)\n\n # Connect the center dot to the roots to show where they lie on the complex plane\n connections = VGroup(\n Line(root_center.get_center(), root_a.get_center()),\n Line(root_center.get_center(), root_b.get_center())\n )\n connection_labels = VGroup(\n Tex(\"$\\\\omega$\", color=GREEN).next_to(connections[0], UP),\n Tex(\"$\\\\overline{\\\\omega}$\", color=GREEN).next_to(connections[1], UP)\n )\n\n self.play(Create(connections), Write(connection_labels))\n self.wait(2)\n\n # Calculate n(z) using the argument principle\n calc_title = Text(\"Calculate the Integral along the Unit Circle:\", font_size=24)\n calc_title.to_edge(UP)\n\n integral_expr = MathTex(r\"\\frac{1}{2\\pi i}\", \"\\\\int_\", \"_C\", r\"\\frac{f'(z)}{f(z)} \\\\,\", \"dz\").scale(0.8)\n integral_group = VGroup(calc_title, integral_expr).arrange(DOWN, aligned_edge=LEFT)\n integral_group.move_to(ORIGIN)\n\n self.play(Write(integral_group))\n self.wait(2)\n\n # Simplify the derivative and simplify the fraction\n deriv_simplification = MathTex(r\"= \", r\"\\frac{1}{2\\pi i}\", \"\\\\int_\", \"_C\", r\"\\frac{3z^{2}}{z^3-1} \\\\,\", \"dz\")\n simplified_integral = MathTex(r\"= \", r\"\\frac{1}{2\\pi i}\", \"\\\\left[ \\\\log|z^3-1| \\\\right]\", r\"_C\")\n\n simplifications = VGroup(deriv_simplification, simplified_integral).arrange(DOWN, aligned_edge=RIGHT)\n simplifications.scale(0.8).next_to(integral_group, DOWN, buff=0.5)\n\n self.play(Write(simplifications[0]))\n self.wait(1)\n\n # Evaluate the antiderivative along the boundary of the unit disk\n evaluated_antideriv = MathTex(\n r\"= \", r\"\\frac{1}{2\\pi i}\", r\"(0)\", r\"-\", r\"\\frac{1}{2\\pi i}\",\n r\"(\\\\ln |1^3 - 1|)\", r\"-\", r\"\\frac{1}{2\\pi i}\"\n ).scale(0.8)\n \n evaluated_antideriv.next_to(simplifications[0], DOWN, buff=0.2)\n\n self.play(Write(evaluated_antideriv))\n self.wait(2)\n\n # Final Result\n final_result = MathTex(r\"= \", \"-1\").scale(1.2)\n final_result.next_to(evaluated_antideriv, DOWN, buff=0.2)\n\n self.play(Write(final_result))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\n \"The result tells us there is exactly one zero and two poles.\",\n font_size=28\n )\n conclusion.to_edge(DOWN)\n\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clean up\n self.play(FadeOut(VGroup(\n func_group, \n circle, \n root_center, \n root_a, \n root_b, \n connections, \n connection_labels,\n integral_group,\n simplifications,\n evaluated_antideriv,\n final_result,\n conclusion\n )))\n\n# To run this code, save it as filename.py and execute 'manim filename.py ArgumentPrinciple'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the animation that maintains all original features while adding significant new elements: \n\nThe enhanced animation begins by constructing the original **MathOperationLayer**, displaying a mathematical operation (+, -, *, /) within a blue-stroked circle, which highlights in orange during activation. To this, we introduce a **dynamic input-output visualization**: as the operation activates, two animated input values (represented as labeled circles) flow into the operation node, while the result emerges as an output circle, with the calculation displayed as a formula (e.g., \"3 + 5 = 8\") above the node. Additionally, we include an **interactive activation function plot**—when the operation executes, the corresponding activation function (e.g., ReLU, Sigmoid) animates alongside the result, showing how the output is transformed. The animation concludes with the operation node fading back to its default state while the formula and activation plot linger briefly for clarity, reinforcing the mathematical relationship between inputs, operation, and activation. This enhancement makes the layer’s function more intuitive by visualizing both the arithmetic process and its subsequent nonlinear transformation.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass MathOperationLayerWithActivation(Scene):\n def construct(self):\n # Create operation node\n operation_node = Circle(radius=0.8, color=BLUE, stroke_width=4)\n operation_node.set_fill(BLUE_E, opacity=0.5)\n operation_text = MathTex(\"+\").scale(1.5)\n operation_group = VGroup(operation_node, operation_text)\n operation_group.move_to(ORIGIN)\n\n # Create input nodes\n input1 = Circle(radius=0.6, color=GREEN, stroke_width=3)\n input1.set_fill(GREEN_E, opacity=0.5)\n input1_text = MathTex(\"3\").scale(1.2)\n input1_group = VGroup(input1, input1_text)\n input1_group.move_to(LEFT * 3 + UP * 1)\n\n input2 = Circle(radius=0.6, color=GREEN, stroke_width=3)\n input2.set_fill(GREEN_E, opacity=0.5)\n input2_text = MathTex(\"5\").scale(1.2)\n input2_group = VGroup(input2, input2_text)\n input2_group.move_to(LEFT * 3 + DOWN * 1)\n\n # Create output node\n output_node = Circle(radius=0.6, color=RED, stroke_width=3)\n output_node.set_fill(RED_E, opacity=0.5)\n output_text = MathTex(\"8\").scale(1.2)\n output_group = VGroup(output_node, output_text)\n output_group.move_to(RIGHT * 3)\n\n # Create formula text\n formula = MathTex(\"3 + 5 = 8\").scale(1.2)\n formula.next_to(operation_group, UP, buff=1)\n\n # Create activation function plot\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[0, 1, 0.5],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": [-2, 0, 2]},\n y_axis_config={\"numbers_to_include\": [0.5, 1]},\n )\n axes.scale(0.5)\n axes.next_to(operation_group, DOWN, buff=1)\n\n sigmoid = axes.plot(lambda x: 1 / (1 + np.exp(-x)), color=YELLOW)\n sigmoid_label = axes.get_graph_label(sigmoid, \"Sigmoid\", x_val=-2.5)\n\n # Animation sequence\n self.play(Create(input1_group), Create(input2_group))\n self.wait(0.5)\n self.play(Create(operation_group))\n self.wait(0.5)\n\n # Highlight operation node\n self.play(\n operation_node.animate.set_stroke(ORANGE, width=6),\n operation_text.animate.set_color(ORANGE)\n )\n self.wait(0.5)\n\n # Animate inputs moving to operation\n self.play(\n input1_group.animate.move_to(operation_group.get_center() + LEFT * 0.5 + UP * 0.3),\n input2_group.animate.move_to(operation_group.get_center() + LEFT * 0.5 + DOWN * 0.3),\n run_time=1.5\n )\n self.wait(0.5)\n\n # Show formula\n self.play(Write(formula))\n self.wait(0.5)\n\n # Animate output appearing\n self.play(FadeIn(output_group, shift=RIGHT))\n self.wait(0.5)\n\n # Show activation function\n self.play(\n Create(axes),\n Create(sigmoid),\n Write(sigmoid_label)\n )\n self.wait(1)\n\n # Fade back to original state\n self.play(\n operation_node.animate.set_stroke(BLUE, width=4),\n operation_text.animate.set_color(WHITE),\n FadeOut(input1_group),\n FadeOut(input2_group),\n FadeOut(formula),\n FadeOut(axes),\n FadeOut(sigmoid),\n FadeOut(sigmoid_label),\n run_time=1.5\n )\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass MathOperationLayerWithActivation(Scene):\n def construct(self):\n # Create operation node\n operation_node = Circle(radius=0.8, color=BLUE, stroke_width=4)\n operation_node.set_fill(BLUE_E, opacity=0.5)\n operation_text = MathTex(\"+\").scale(1.5)\n operation_group = VGroup(operation_node, operation_text)\n operation_group.move_to(ORIGIN)\n\n # Create input nodes\n input1 = Circle(radius=0.6, color=GREEN, stroke_width=3)\n input1.set_fill(GREEN_E, opacity=0.5)\n input1_text = MathTex(\"3\").scale(1.2)\n input1_group = VGroup(input1, input1_text)\n input1_group.move_to(LEFT * 3 + UP * 1)\n\n input2 = Circle(radius=0.6, color=GREEN, stroke_width=3)\n input2.set_fill(GREEN_E, opacity=0.5)\n input2_text = MathTex(\"5\").scale(1.2)\n input2_group = VGroup(input2, input2_text)\n input2_group.move_to(LEFT * 3 + DOWN * 1)\n\n # Create output node\n output_node = Circle(radius=0.6, color=RED, stroke_width=3)\n output_node.set_fill(RED_E, opacity=0.5)\n output_text = MathTex(\"8\").scale(1.2)\n output_group = VGroup(output_node, output_text)\n output_group.move_to(RIGHT * 3)\n\n # Create formula text\n formula = MathTex(\"3 + 5 = 8\").scale(1.2)\n formula.next_to(operation_group, UP, buff=1)\n\n # Create activation function plot\n axes = Axes(label_font_size=24, \n x_range=[-3, 3, 1],\n y_range=[0, 1, 0.5],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": [-2, 0, 2]},\n y_axis_config={\"numbers_to_include\": [0.5, 1]},\n )\n axes.scale(0.5)\n axes.next_to(operation_group, DOWN, buff=1)\n\n sigmoid = axes.plot(lambda x: 1 / (1 + np.exp(-x)), color=YELLOW)\n sigmoid_label = axes.get_graph_label(sigmoid, \"Sigmoid\", x_val=-2.5)\n\n # Animation sequence\n self.play(Create(input1_group), Create(input2_group))\n self.wait(0.5)\n self.play(Create(operation_group))\n self.wait(0.5)\n\n # Highlight operation node\n self.play(\n operation_node.animate.set_stroke(ORANGE, width=6),\n operation_text.animate.set_color(ORANGE)\n )\n self.wait(0.5)\n\n # Animate inputs moving to operation\n self.play(\n input1_group.animate.move_to(operation_group.get_center() + LEFT * 0.5 + UP * 0.3),\n input2_group.animate.move_to(operation_group.get_center() + LEFT * 0.5 + DOWN * 0.3),\n run_time=1.5\n )\n self.wait(0.5)\n\n # Show formula\n self.play(Write(formula))\n self.wait(0.5)\n\n # Animate output appearing\n self.play(FadeIn(output_group, shift=RIGHT))\n self.wait(0.5)\n\n # Show activation function\n self.play(\n Create(axes),\n Create(sigmoid),\n Write(sigmoid_label)\n )\n self.wait(1)\n\n # Fade back to original state\n self.play(\n operation_node.animate.set_stroke(BLUE, width=4),\n operation_text.animate.set_color(WHITE),\n FadeOut(input1_group),\n FadeOut(input2_group),\n FadeOut(formula),\n FadeOut(axes),\n FadeOut(sigmoid),\n FadeOut(sigmoid_label),\n run_time=1.5\n )\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all original features while adding significant new elements: \n\nThe animation begins by constructing the coordinate axes with a blue color scheme, ranging from 0 to 4 on the x-axis and 0 to 8 on the y-axis. The function *f(x) = x²* is plotted in white, accompanied by a label reading *x²* for clarity. After displaying the axes and graph sequentially, the area under the curve from *x = 0* to *x = 2* is filled with a gradient from blue to green at 50% opacity. To deepen understanding, a new feature is introduced: a dynamic Riemann sum approximation that visually decomposes the area into rectangular partitions, which then smoothly transform into the exact integral area. Simultaneously, the integral formula *∫₀² x² dx = 8/3* appears below the graph, with each component (integral symbol, bounds, and result) animating in sequentially. Finally, a text box fades in, explaining the connection between Riemann sums and definite integrals, reinforcing the visual demonstration with a conceptual summary. The entire sequence is timed to ensure clarity, with pauses between key transitions for emphasis.", "chosen": "```python\nfrom manim import *\n\nclass RiemannSumToIntegral(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 8, 2],\n x_length=6,\n y_length=6,\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot the function x^2\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label=\"x^2\", direction=UP)\n\n # Display axes and graph\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Fill area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Riemann sum approximation\n riemann_rects = axes.get_riemann_rectangles(\n graph, x_range=[0, 2], dx=0.5, color=BLUE, fill_opacity=0.7\n )\n self.play(Create(riemann_rects))\n self.wait(1)\n\n # Transform Riemann sum into exact area\n self.play(Transform(riemann_rects, area))\n self.wait(1)\n\n # Display integral formula\n integral_text = MathTex(r\"\\int_0^2 x^2 \\, dx = \\frac{8}{3}\")\n integral_text.next_to(axes, DOWN)\n \n # Animate integral parts sequentially\n self.play(Write(integral_text[0][0:3])) # \\int ₀^2\n self.play(Write(integral_text[0][3:7])) # x^2 dx\n self.play(Write(integral_text[0][7:])) # = 8/3\n self.wait(1)\n\n # Add explanatory text box\n explanation = Text(\n \"Riemann sums approximate the area\\nunder a curve using rectangles.\\nThe exact area is given by the definite integral.\",\n font_size=24,\n )\n explanation.next_to(integral_text, DOWN, buff=0.5)\n box = SurroundingRectangle(explanation, buff=0.2, color=YELLOW)\n \n self.play(Create(box), Write(explanation))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass RiemannSumToIntegral(Scene):\n def construct(self):\n # Create axes\n axes = Axes(label_font_size=24, \n x_range=[0, 4, 1],\n y_range=[0, 8, 2],\n x_length=6,\n y_length=6,\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot the function x^2\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label=\"x^2\", direction=UP)\n\n # Display axes and graph\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Fill area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Riemann sum approximation\n riemann_rects = axes.get_riemann_rectangles(\n graph, x_range=[0, 2], dx=0.5, color=BLUE, fill_opacity=0.7\n )\n self.play(Create(riemann_rects))\n self.wait(1)\n\n # Transform Riemann sum into exact area\n self.play(Transform(riemann_rects, area))\n self.wait(1)\n\n # Display integral formula\n integral_text = MathTex(r\"\\int_0^2 x^2 \\, dx = \\frac{8}{3}\")\n integral_text.next_to(axes, DOWN)\n \n # Animate integral parts sequentially\n self.play(Write(integral_text[0][0:3])) # \\int ₀^2\n self.play(Write(integral_text[0][3:7])) # x^2 dx\n self.play(Write(integral_text[0][7:])) # = 8/3\n self.wait(1)\n\n # Add explanatory text box\n explanation = Text(\n \"Riemann sums approximate the area\\nunder a curve using rectangles.\\nThe exact area is given by the definite integral.\",\n font_size=24,\n )\n explanation.next_to(integral_text, DOWN, buff=0.5)\n box = SurroundingRectangle(explanation, buff=0.2, color=YELLOW)\n \n self.play(Create(box), Write(explanation))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 15-second networking scene explaining TCP additive increase and multiplicative decrease. Draw a congestion-window sawtooth over time, reveal linear growth and sharp drops step by step, and explain that the sender probes capacity rather than knowing it in advance.", "chosen": "```python\nfrom manim import *\n\nclass TcpAddIncMulDec(Scene):\n def construct(self):\n # Title\n title = Text(\"TCP Adds Capacity on Success, Multiplies on Loss\", font_size=36).to_edge(UP)\n \n # Initial Window Size\n initial_window = VGroup(\n Rectangle(width=0.8, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.15, color=WHITE)\n ).shift(RIGHT*2 + UP*0.7)\n \n text_initial = Text(\"Initial window size of 1\", font_size=24).next_to(initial_window, DOWN)\n\n self.play(Write(title))\n self.play(Create(initial_window), Write(text_initial))\n self.wait(1)\n\n # First Increase (Linear Growth)\n window_after_first_inc = VGroup(\n Rectangle(width=1.6, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.2, color=WHITE)\n )\n \n text_incremented = Text(\"+1 after success\", font_size=24).move_to(text_initial.get_center())\n\n self.play(Transform(initial_window, window_after_first_inc), Transform(text_initial, text_incremented))\n self.wait(0.5)\n\n # Second Increase (Linear Growth)\n window_after_second_inc = VGroup(\n Rectangle(width=2.4, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.25, color=WHITE)\n )\n\n self.play(Transform(initial_window, window_after_second_inc))\n self.wait(0.5)\n\n # Drop (Multiplicative Decrease)\n drop_area = RoundedRectangle(corner_radius=0.1, width=0.8, height=0.2, color=RED, fill_color=RED, fill_opacity=0.3)\n drop_label = Text(\"-1/2 due to loss\", font_size=24).move_to(window_after_second_inc.get_bottom())\n \n self.play(FadeIn(drop_area), FadeIn(drop_label))\n self.wait(1)\n\n # Final State\n final_state_rect = VGroup(\n Rectangle(width=1.2, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.2, color=WHITE)\n ).move_to(window_after_second_inc.get_top())\n\n final_text = Text(\"Final state post-drop\", font_size=24).move_to(final_state_rect.get_bottom())\n\n self.play(\n Transform(initial_window, final_state_rect),\n Transform(text_initial, final_text),\n FadeOut(drop_area),\n FadeOut(drop_label)\n )\n\n # Explanation Box\n explanation_box = RoundedRectangle(corner_radius=0.3, width=5.5, height=2.5, color=YELLOW, fill_color=YELLOW, fill_opacity=0.2)\n explanation_title = Text(\"Exploration vs Exploitation\", font_size=24, weight=BOLD).move_to(explanation_box.get_top() + DOWN*0.3)\n exploration_text = Text(\"Sender probes capacity\\nrather than knowing it in advance.\", font_size=20, line_spacing=1.2).move_to(explanation_box.get_center()).set_x(-1.2)\n expl_queue = VGroup(Text(\"Queue\"), Circle(radius=0.15, stroke_width=2, stroke_color=WHITE), Text(\"Server\")).arrange(RIGHT, buff=0.1).scale(0.8).next_to(expl_queue_start := Point().shift(DOWN*1.5 + LEFT*2.8), RIGHT, buff=-0.1)\n\n self.play(Write(explanation_box), Write(explanation_title))\n\n for i, txt in enumerate([\"Sent:\", \"Received:\"], start=1):\n sent_recv_txt = Text(txt, font_size=20).next_to(expl_queue_start, DOWN*i, buff=0.1)\n dot = Dot(color=BLUE if txt == \"Sent:\" else GREEN, radius=i*0.15).move_to(sent_recv_txt.get_right() + RIGHT*(i-1)*0.2)\n self.add(dot, sent_recv_txt)\n\n self.play(Write(exploration_text), Create(expl_queue))\n self.wait(1)\n\n # Highlight the core concept briefly at the end\n highlight_rect = SurroundingRectangle(VGroup(initial_window, text_initial), color=ORANGE, buff=0.15, corner_radius=0.1)\n highlight_text = Text(\"Adding on success, reducing quickly\\non loss ---\\nExploratory and adaptive\", font_size=20, t2c={\"adding\": ORANGE}).next_to(highlight_rect, DOWN, buff=0.3)\n\n self.play(Create(highlight_rect), Write(highlight_text))\n self.wait(2)\n\n# To render this animation, save the file as tcp_add_inc_mul_dec.py and run:\n# manim -pql tcp_add_inc_mul_dec.py TcpAddIncMulDec\n```", "rejected": "```python\nfrom manim import *\n\nclass TcpWindowScene(Scene):\n def construct(self):\n # Title\n title = Text(\"TCP Window Capacity\", font_size=36)\n self.play(Write(title))\n \n # Create axes for the graph\n axes = Axes(\n x_range=[0, 8, 1],\n y_range=[0, 8, 1],\n axis_config={\"color\": BLUE},\n ).shift(DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"Time\", y_label=\"Congestion Window\")\n\n # Plot the sawtooth pattern of the window size changing\n data = [\n [0, 0], [1, 1], [2, 2], [3, 3], \n [4, 7], [5, 1], [6, 2], [7, 7]\n ]\n line = VMobject(color=YELLOW)\n points = VGroup()\n for x, y in data:\n point = Dot(axes.c2p(x, y), color=WHITE)\n points.add(point)\n \n line.set_points_as_corners([axes.c2p(0, 0)] + [point.get_center() for point in points])\n\n # Add text explanation below the diagram\n explanation_text = Text(\n \"Sender probes network capacity through\\nlinear growth and sharp drops.\",\n font_size=24,\n t2c={'probe': YELLOW}\n )\n explanation_text.to_edge(DOWN)\n\n # Animate creation of the graph components\n self.play(Create(axes), Write(labels))\n self.play(LaggedStartMap(FadeIn, points))\n self.play(Create(line))\n\n # Highlight the probing mechanism\n probe_box = SurroundingRectangle(points[3].get_center(), buff=0.2)\n probe_box.set_color(GREEN)\n self.play(ShowPassingFlash(probe_box, time_width=0.1))\n \n self.play(Write(explanation_text))\n\n # Pause at the end\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an educational animation using ManimCE that illustrates how light rays interact with a pair of lenses? The lenses should be displayed as blue and semi-transparent, and there should be one on the left and o\n- Act 2: 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:", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0633(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_enhancedhexagonscene()\n\n def act_1_areaundercurveexample(self):\n axes = Axes(x_range=[-1, 5], y_range=[-1, 6], axis_config={\"color\": BLUE})\n graph = axes.plot(lambda x: 0.1 * (x - 2)**2 + 1, color=GREEN)\n area = axes.get_area(graph, x_range=(0,4), color=GREY, opacity=0.5)\n label = MathTex(r\"f(x) = 0.1(x-2)^2 + 1\").next_to(graph, UP)\n\n self.play(Create(axes), Create(graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.play(Write(label))\n self.wait(2)\n\n # Explanation of the area calculation\n explanation = Text(\"This shaded area represents the integral from 0 to 4\",\n font_size=24).to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Calculation of the area\n calculation = MathTex(r\"\\int_0^4 0.1(x-2)^2 + 1 \\,dx\")\n self.play(ReplacementTransform(label.copy(), calculation), FadeOut(explanation))\n self.wait(1)\n\n # Solution\n solution = MathTex(r\"A = \\frac{8}{3} + 4\")\n self.play(ReplacementTransform(calculation, solution))\n self.wait(2)\n\n # Clear the scene and show only the solution\n self.clear()\n self.play(Write(solution))\n self.wait(1)\n\n def act_2_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0633(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_enhancedhexagonscene()\n\n def act_1_areaundercurveexample(self):\n axes = Axes(x_range=[-1, 5], y_range=[-1, 6], axis_config={\"color\": BLUE})\n graph = axes.plot(lambda x: 0.1 * (x - 2)**2 + 1, color=GREEN)\n area = axes.get_area(graph, x_range=(0,4), color=GREY, opacity=0.5)\n label = MathTex(r\"f(x) = 0.1(x-2)^2 + 1\").next_to(graph, UP)\n\n self.play(Create(axes), Create(graph))\n self.wait(1)\n self.play(FadeIn(area))\n self.play(Write(label))\n self.wait(2)\n\n # Explanation of the area calculation\n explanation = Text(\"This shaded area represents the integral from 0 to 4\",\n font_size=24).to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Calculation of the area\n calculation = MathTex(r\"\\int_0^4 0.1(x-2)^2 + 1 \\,dx\")\n self.play(ReplacementTransform(label.copy(), calculation), FadeOut(explanation))\n self.wait(1)\n\n # Solution\n solution = MathTex(r\"A = \\frac{8}{3} + 4\" + \" = x\")\n self.play(ReplacementTransform(calculation, solution))\n self.wait(2)\n\n # Clear the scene and show only the solution\n self.clear()\n self.play(Write(solution))\n self.wait(1)\n\n def act_2_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation using ManimCE that visualizes a simple convolutional neural network with alternating convolutional layers and pooling layers? The network should start with a convolutional layer that has 6 feature maps and a 3x3 kernel, then a pooling layer, followed by another convolutional layer with 16 feature maps and a 3x3 kernel, and ending with a final pooling layer. The animation should show the construction of this neural network.", "chosen": "```python\nfrom manim import *\n\nclass ConvolutionNetwork(Scene):\n def construct(self):\n title = Text(\"A Simple CNN\", font_size=36)\n self.play(Write(title))\n conv_layer1 = RoundedRectangle(width=7, height=2.8, corner_radius=0.1, color=BLUE).shift(LEFT*3 + DOWN*1)\n pool_layer1 = RoundedRectangle(width=7, height=1.5, corner_radius=0.1, color=YELLOW).next_to(conv_layer1, DOWN, buff=0.5)\n \n # Create grid for the first convolutional layer\n filters1 = VGroup()\n for i in range(6):\n filter_rect = Rectangle(height=1.5, width=2, fill_opacity=0.8, color=WHITE, fill_color=GREEN).shift(RIGHT*(i%3-1) + UP*(1-(i//3)))\n labels = VGroup(Text(f\"F{i}\", font_size=20, color=BLACK)).move_to(filter_rect.get_center())\n filters1.add(VGroup(filter_rect, labels))\n\n text1 = Tex(\"$\\\\text{Conv}(F=6, K=3 \\\\times 3)$\", font_size=24).to_edge(UP)\n\n self.play(Create(text1))\n self.play(FadeIn(filters1, shift=RIGHT))\n self.play(Create(conv_layer1), FadeIn(pool_layer1, shift=DOWN))\n \n conv_layer2 = RoundedRectangle(width=7, height=3.8, corner_radius=0.1, color=BLUE).shift(RIGHT*3 + DOWN*1)\n pool_layer2 = RoundedRectangle(width=7, height=2.5, corner_radius=0.1, color=YELLOW).next_to(conv_layer2, DOWN, buff=0.5)\n \n # Create grid for the second convolutional layer\n filters2 = VGroup()\n for i in range(16):\n filter_rect = Rectangle(height=1.5, width=2, fill_opacity=0.8, color=WHITE, fill_color=RED).shift(RIGHT*((i%4)-1) + UP*(1-(i//4)*2))\n labels = VGroup(Text(f\"K{i}\", font_size=18, color=BLACK)).move_to(filter_rect.get_bottom())\n filters2.add(VGroup(filter_rect, labels))\n\n text2 = Tex(\"$\\\\text{Conv}(F=16, K=3 \\\\times 3)$\", font_size=24).to_edge(UP)\n\n self.play(Transform(text1, text2))\n self.play(FadeIn(filters2, scale=0.8))\n self.play(Create(conv_layer2), FadeIn(pool_layer2, shift=DOWN))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ConvolutionNetworkScene(Scene):\n def construct(self):\n # Title for the visualization\n title = Text(\"Visualizing Convolutional Layers\", font_size=34)\n self.play(Write(title))\n self.wait(1)\n\n # --- Layer 1: Input Image ---\n input_label = Text(\"Input Image\", font_size=28).to_edge(UP)\n image_shape = RoundedRectangle(corner_radius=0.15, width=7, height=3.5, color=BLUE_B, fill_opacity=0.1)\n \n # Create grid points representing pixel values\n pixels = VGroup()\n cell_width = 0.5\n cell_height = 0.5\n \n for x in range(int(image_shape.width/cell_width)):\n row = []\n for y in range(int(image_shape.height/cell_height)):\n dot = Dot(radius=cell_width/2, color=BLUE_D).move_to(\n image_shape.get_corner(DOWN + LEFT) \n + UP*(y*cell_height + cell_height/2)\n + RIGHT*(x*cell_width + cell_width/2)\n )\n row.append(dot)\n pixels.add(VGroup(*row))\n\n input_group = VGroup(input_label, image_shape, pixels).arrange(RIGHT, buff=1.5)\n input_group.shift(LEFT*3.5 + DOWN*1)\n \n # Animate creation of input elements\n self.play(FadeIn(input_label), Create(image_shape), FadeIn(pixels), run_time=2)\n self.wait(0.5)\n\n # --- Layer 2A: Conv1 Feature Maps ---\n conv1_title = Text(\"+ Filter Group 1\", font_size=22).next_to(image_shape, UP, buff=0.5)\n filter_map_labels = [\n MathTex(\"\\\\text{Filter } F_{1}\").scale(0.6),\n MathTex(\"\\\\text{Filter } F_{2}\"),\n MathTex(\"\\\\text{Filter } F_{3}\")\n ]\n filters_g1 = VGroup(*filter_map_labels)\n \n # Position filters vertically within their own group\n g1_filters = VGroup(*filters_g1).arrange(DOWN, buff=0.2).shift(UP*1.2)\n self.play(Write(conv1_title), Write(g1_filters), run_time=1.5)\n self.wait(0.5)\n \n # Show how each map is created from the input data\n maps_g1 = VGroup()\n for i in range(len(filters_g1)):\n map_rect = Rectangle(width=image_shape.width-0.5, height=image_shape.height-0.5, color=GREEN_A, stroke_width=2)\n text = Text(f\"Map {i+1}\", font_size=20).next_to(map_rect, DOWN)\n maps_g1.add(VGroup(map_rect, text).set_color(GREEN_C))\n\n maps_group1 = VGroup(*maps_g1).arrange(RIGHT, buff=0.5).next_to(filter_map_labels[-1], DOWN, buff=1).align_to(g1_filters, LEFT).shift(RIGHT*1.5)\n \n # Animation: Morph the input dots into mapped areas\n morphed_input_dots = VGroup()\n for i, dot in enumerate(pixels.submobjects):\n rect_pos = maps_group1[i].get_center()\n \n # Map area is slightly smaller than input shape\n rect = Rectangle(\n width=max(maps_group1[i].width, 0.4), \n height=max(maps_group1[i].height, 0.3), \n color=WHITE,\n fill_opacity=0.2, \n stroke_width=1\n ).move_to(rect_pos)\n \n morphed_input_dots.add(Rectangle(\n width=max(cell_width*1.5, 0.4), \n height=max(cell_height*1.5, 0.3), \n color=BLUE_D, \n fill_opacity=0.1, \n stroke_width=1\n ).move_to(dot.get_center()))\n \n else:\n pass\n\n # Move labels up to make room for outputs\n self.play(\n FadeOut(g1_filters), \n move_into_view=morphed_input_dots, \n run_time=2\n )\n\n # Display individual maps with labels\n self.play(Create(maps_group1), run_time=2)\n self.wait(0.5)\n\n # --- Layer 2B: Pooling Layer ---\n pool_layer_text = Text(\"\\nPooling\\nLayer\", font_size=22, line_spacing=1.2)\n pool_filter_rects = VGroup()\n for _ in range(4): # Simulate 4 max-pool regions\n pool_rect = Rectangle(width=1.5, height=1.5, color=YELLOW, fill_opacity=0.2)\n pool_rect.shift(LEFT*1.5 + DOWN*0.5)\n pool_filter_rects.add(pool_rect)\n\n pool_groups = VGroup()\n for mrect in maps_group1:\n small_rect = Rect(\n width=mrect.width / 2.5, \n height=mrect.height / 2.5, \n color=ORANGE, \n fill_opacity=0.1\n )\n small_rect.move_to(mrect.get_center())\n pool_groups.add(small_rect)\n\n pools_group = VGroup(pool_filter_rects, pool_groups)\n pools_group.next_to(maps_group1, DOWN, buff=1).align_to(maps_group1, LEFT).shift(RIGHT*1.5)\n \n self.play(Write(pool_layer_text), Create(pool_filter_rects), run_time=1.5)\n self.play(LaggedStart(*[\n TransformFromCopy(mrect.copy(), pgroup) for mrect, pgroup in zip(maps_group1, pool_groups)\n ], lag_ratio=0.5), run_time=2)\n self.wait(0.5)\n\n # --- Transition to Second Set of Filters ---\n second_conv_label = Text(\"+ Filter Group 2\", font_size=22).next_to(images_group, UP, buff=0.5)\n filters_g2 = VGroup(MathTex(\"\\\\text{Filter } G_{1}\"), MathTex(\"\\\\text{Filter } G_{2}\"))\n g2_filters = VGroup(*filters_g2).arrange(DOWN, buff=0.2).shift(UP*1.2)\n self.play(Write(second_conv_label), Write(g2_filters), run_time=1.5)\n self.wait(0.5)\n\n images_group = VGroup()\n for i in range(len(filters_g2)):\n img_rect = Rectangle(width=image_shape.width-0.5, height=image_shape.height-0.5, color=TEAL_A, stroke_width=2)\n text = Text(f\"Image {i+1}\", font_size=20).next_to(img_rect, DOWN)\n images_group.add(VGroup(img_rect, text).set_color(TEAL_C))\n\n images_group.arrange(RIGHT, buff=0.5).next_to(filter_map_labels[-1], DOWN, buff=1).align_to(g2_filters, LEFT).shift(LEFT*3.5)\n \n # Merge the two groups of maps horizontally to simulate stacking\n merged_maps = VGroup()\n for i in range(len(images_group)):\n combined_rect = Rectangle(\n width=(images_group[i][0].width + maps_group1[i][0].width)/2, \n height=max(images_group[i][0].height, maps_group1[i][0].height), \n color=LIGHT_GRAY, \n stroke_width=2\n ).move_to((images_group[i].get_center()[0], images_group[i].get_center()[1], 0))\n combined_text = Text(f\"Merged Map {i+1}\", font_size=20).next_to(combined_rect, DOWN, buff=-0.2)\n merged_maps.add(VGroup(combined_rect, combined_text).set_color(YELLOW_A))\n\n self.play(TransformFromCopy(maps_group1, merged_maps), run_time=2)\n self.wait(0.5)\n\n # --- Final State: Flat Structure ---\n flat_structure = VGroup()\n for i in range(len(filtered_merges)):\n box = Square(side_length=1.2, color=BLUE_E, fill_opacity=i/len(filtered_merges))\n label = Text(str(i+1), font_size=20).move_to(box.get_center()).set_fill(WHITE)\n flat_structure.add(VGroup(box, label).shift(LEFT*i*1.8))\n else:\n pass\n \n final_image = VGroup().add(Square(side_length=3.5, color=BLUE_D)).center()\n\n # Move everything to center and animate transformation\n self.play(\n FadeOut(inputs), \n FadeOut(pool_layers), \n FadeOut(all_filters), \n FadeIn(final_image), \n run_time=2\n )\n self.wait(1)\n\n# To run this animation, save it to a file named 'conv_network.py' and execute:\n# manim -pql conv_network.py ConvolutionNetworkScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that shows a simple feedforward neural network with three layers, where the first layer has 4 neurons, the second layer has 6 neurons with a ReLU activation function, and the third layer has 3 neurons with a Softmax activation function, and then demonstrate a data point passing through this network?", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkFlow(Scene):\n def construct(self):\n # --- Configuration ---\n num_input_nodes = 4\n num_hidden_nodes = 6\n num_output_nodes = 3\n \n input_layer_label = \"Input Layer\"\n hidden_layer_label = \"Hidden Layer\\n(ReLU)\"\n output_layer_label = \"Output Layer\\n(Softmax)\"\n\n node_color = BLUE\n edge_color = WHITE\n\n # Create nodes for each layer\n input_nodes = VGroup()\n hidden_nodes = VGroup()\n output_nodes = VGroup()\n\n for i in range(num_input_nodes):\n dot = Dot(radius=0.18)\n input_nodes.add(dot)\n\n for i in range(num_hidden_nodes):\n rect = Rectangle(width=1.2, height=0.5, color=node_color).shift(DOWN * i*0.7 - DOWN * (num_hidden_nodes-1)/2 )\n \n label = Text(\"h\", font_size=22).move_to(rect.get_center())\n group = VGroup(label,rect)\n hidden_nodes.add(group)\n\n for i in range(num_output_nodes):\n circle = Circle(radius=0.25, color=node_color).shift(DOWN * i*0.7 - DOWN * (num_output_nodes-1)/2 )\n text = MathTex(\"\\\\sigma(x_i)\", font_size=20).next_to(circle, UP, buff=0.2)\n group = VGroup(text,circle)\n output_nodes.add(group)\n\n # Position nodes by their corresponding labels\n input_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (input_nodes.get_width()/2) , height=0.5*(num_input_nodes))\n input_text = Text(input_layer_label, font_size=20, weight=BOLD).next_to(input_rect, DOWN, buff=0.3)\n \n hidden_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (hidden_nodes.get_width()/2) , height=0.5*(num_hidden_nodes))\n hidden_text = Text(hidden_layer_label, font_size=20, weight=BOLD, t2c={\"ReLU\": YELLOW}).next_to(hidden_rect, DOWN, buff=0.3)\n hidden_text.shift(RIGHT * 0.15)\n \n output_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (output_nodes.get_width()), height=0.5*(num_output_nodes)*1.2 )\n output_text = Text(output_layer_label, font_size=20, weight=BOLD, t2c={\"Softmax\": GREEN}).next_to(output_rect, DOWN, buff=0.3)\n \n \n inputs_group = VGroup(\n input_rect,\n input_text,\n input_nodes\n ).arrange(RIGHT, buff=0.3)\n\n hidden_group = VGroup(\n hidden_rect,\n hidden_text,\n hidden_nodes\n ).arrange(RIGHT, buff=0.3)\n\n output_group = VGroup(\n output_rect,\n output_text,\n output_nodes\n )\n\n # Arrange groups horizontally\n main_structure = VGroup(inputs_group, hidden_group, output_group).arrange(RIGHT, buff=1.5)\n \n\n # Add edges between layers\n connections = []\n\n for i in range(len(input_nodes)):\n for j in range(len(hidden_nodes)):\n line_start = input_nodes[i].get_right() + RIGHT * 0.3\n line_end = hidden_nodes[j][0].get_left() + LEFT * 0.3\n \n if i == len(input_nodes)-1 and j != 0:\n line_start += UP * (j-i)*0.1\n line_end += UP * (j-i)*0.1\n \n \n connection = Line(line_start, line_end, stroke_width=1.5, color=edge_color)\n connections.append(connection)\n\n for i in range(len(hidden_nodes)):\n for j in range(len(output_nodes)):\n line_start = hidden_nodes[i][0].get_bottom() + DOWN * 0.2\n line_end = output_nodes[j][0].get_top() + UP * 0.2\n \n if i != len(hidden_nodes)-1 and j != 0:\n line_start += RIGHT * (j-i)*0.1\n line_end += RIGHT * (j-i)*0.1\n \n connection = Line(line_start, line_end, stroke_width=1.5, color=edge_color)\n connections.append(connection)\n\n # --- Animation Sequence ---\n\n self.play(Create(main_structure), run_time=2)\n self.wait(0.5)\n\n # Animate data points moving from Input -> Hidden (Left-to-Right)\n input_dots = [\n Dot(point=node.get_center(), radius=0.18, color=YELLOW).set_opacity(0)\n for node in input_nodes\n ]\n\n # Fade dots in sequentially\n for dot in input_dots:\n self.add(dot)\n self.play(FadeIn(dot, scale=1.5), run_time=0.5)\n\n # Show weights/connectors\n for conn in connections:\n self.play(Create(conn), run_time=0.1)\n\n # Forward signal animation through Hidden Layer\n hidden_inputs = []\n for h_node in hidden_nodes:\n hidden_dot = Dot(h_node[0].get_center(), color=ORANGE).scale(0)\n self.play(TransformFromCopy(hidden_dot, h_node[1]), run_time=0.2)\n self.wait(0.2)\n\n # Forward signal animation through Output Layer\n output_inputs = []\n for o_node in output_nodes:\n output_dot = Dot(o_node[0].get_center(), color=GREEN).scale(0)\n self.play(TransformFromCopy(output_dot, o_node[1]), run_time=0.2)\n self.wait(0.2)\n\n # Highlight Activation Functions\n relu_box = SurroundingRectangle(hidden_nodes, corner_radius=0.15, color=RED, fill_opacity=0.1, buff=0.1)\n softbox = SurroundingRectangle(output_nodes, corner_radius=0.15, color=GREEN, fill_opacity=0.1, buff=0.1)\n relu_text = Tex(\"$\\\\text{ReLU}$\").to_edge(UP).shift(RIGHT * 1.5)\n soft_text = Tex(\"$\\\\text{Softmax}$\").to_edge(UP).shift(RIGHT * 2.5)\n \n self.play(Create(relu_box), Write(relu_text), run_time=1)\n self.wait(0.5)\n self.play(Circumscribe(hidden_nodes, color=RED), Indicate(hidden_nodes, color=RED), run_time=1)\n self.wait(1)\n\n # Final state highlighting output predictions\n final_boxes = [SurroundingRectangle(node, corner_radius=0.15, color=GREEN, fill_opacity=0.1, buff=0.1) for node in output_nodes]\n final_labels = [Text(f\"Predicted Class {i}\", font_size=16).next_to(box, DOWN, buff=-0.2) for box, node in zip(final_boxes, output_nodes)]\n\n self.play(LaggedStart(*[Create(box) for box in final_boxes], lag_ratio=0.3), run_time=1.5)\n self.wait(1)\n self.play(LaggedStart(*[Write(label) for label in final_labels], lag_ratio=0.3), run_time=1.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkScene(Scene):\n def construct(self):\n # --- Configuration ---\n neuron_radius = 0.25\n layer_spacing = 3.5\n neuron_spacing = 1.5\n\n # Colors for visual differentiation\n color_input = BLUE_E\n color_hidden = YELLOW_D\n color_output = GREEN_C\n \n text_color = WHITE\n title_text = \"A Simple Feedforward Neural Network\"\n\n # Create Layer Groups\n input_layer = VGroup()\n hidden_layer = VGroup()\n output_layer = VGroup()\n\n # Input Layer: 4 Neurons\n for i in range(4):\n neuron = Circle(radius=neuron_radius, stroke_width=2, fill_opacity=0)\n neuron.set_stroke(color=color_input, width=2)\n neuron.move_to([layer_spacing + neuron_spacing * i, 1.8, 0])\n \n label = Text(\"Input\", font_size=18).next_to(neuron, UP, buff=0.1)\n label.set_color(text_color)\n\n input_layer.add(VGroup(neuron, label))\n\n # Hidden Layer: 6 Neurons (ReLU Activation)\n for i in range(6):\n neuron = Circle(radius=neuron_radius, stroke_width=2, fill_opacity=0)\n neuron.set_stroke(color=color_hidden, width=2)\n neuron.move_to([0, 0.8 - i * neuron_spacing, 0])\n \n label = MathTex(\"\\\\text{ReLU}\", font_size=20).move_to(neuron.get_center())\n label.set_color(TEXT_COLOR)\n \n hidden_layer.add(VGroup(neuron, label))\n \n # Output Layer: 3 Neurons (Softmax Activation)\n for i in range(3):\n neuron = Circle(radius=neuron_radius, stroke_width=2, fill_opacity=0.1)\n neuron.set_fill(color_output, opacity=1)\n neuron.set_stroke(color=output_layer[-1].get_stroke_color(), width=2) \n neuron.move_to([-layer_spacing - neuron_spacing * i, -0.8 + i * neuron_spacing, 0])\n\n label = MathTex(\"\\\\text{Softmax}\", font_size=20).move_to(neuron.get_center())\n label.set_color(TEXT_COLOR)\n \n output_layer.add(VGroup(neuron, label))\n\n # Connect Layers with Lines\n connections = []\n arrow_style = {\"stroke_width\": 1, \"color\": GREY_A}\n\n # Connections from Input -> Hidden\n for input_neuron in input_layer:\n for hidden_neuron in hidden_layer:\n line = Line(\n start=input_neuron.get_right(),\n end=hidden_neuron.get_left(),\n **arrow_style,\n stroke_opacity=0.2\n )\n \n connections.append(line)\n\n # Connections from Hidden -> Output\n for hidden_neuron in hidden_layer:\n for output_neuron in output_layer:\n line = Line(\n start=hidden_neuron.get_right(),\n end=output_neuron.get_left(),\n **arrow_style,\n stroke_opacity=0.2\n )\n\n connections.append(line)\n\n # Group everything for easy transformation later on\n network_group = VGroup(input_layer, hidden_layer, output_layer, VGroup(*connections)).center()\n\n # Animate Title\n title = Text(title_text, font_size=36, weight=BOLD).to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # Display the full architecture\n self.play(Create(network_group), run_time=2.0)\n self.wait(1.0)\n\n # Data Point Animation\n # Show a small dot representing our input data moving along the connection lines\n data_point = Dot(point=[1.75, 1.8, 0], radius=0.08, color=WHITE)\n self.play(FadeIn(data_point, scale=0.5), run_time=0.5)\n\n # Move the dot forward along the path of the connection lines\n target_pos = [0, 0.8, 0]\n self.play(MoveAlongPath(data_point, Line(start=data_point.get_center(), end=target_pos)), run_time=1.5)\n\n # Highlight the hidden layer nodes briefly\n for n in hidden_layer:\n self.play(n.animate.scale(1.2), runtime=0.3)\n self.play(n.animate.scale(1/1.2), runtime=0.2)\n \n # Repeat for the output layer\n for n in output_layer:\n self.play(n.animate.scale(1.2), runtime=0.3)\n self.play(n.animate.scale(1/1.2), runtime=0.2)\n\n # FinalfadeOut\n self.wait(1)\n self.play(FadeOut(all_mobs=True))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding new elements for clarity and engagement:\n\nThe enhanced animation begins by drawing the axes and plotting the quadratic curve \\( y = x^2 \\) in green, as in the original. However, it now includes a dynamic grid that fades in to emphasize the coordinate system. As the area under the curve from \\( x = 0 \\) to \\( x = 2 \\) is filled in grey, the integral notation \\( \\int_0^2 x^2 \\,dx \\) appears at the top, followed by a step-by-step evaluation: first transforming into the antiderivative \\( \\frac{1}{3}x^3 \\), then calculating the definite integral \\( \\frac{8}{3} \\). New to this version, a Riemann sum approximation animates alongside the area, with rectangles shrinking in width to visually converge to the exact area, reinforcing the connection between discrete sums and integration. Additionally, a brief pause highlights the Fundamental Theorem of Calculus with a flashing arrow linking the antiderivative to the area. Finally, the scene clears, leaving only the result \\( \\frac{8}{3} \\), which pulses to draw attention, while a subtle watermark of the function \\( x^2 \\) remains in the background for context. This enriched animation not only demonstrates the computation but also deepens understanding through visual metaphors and interactive elements.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedQuadraticIntegral(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create grid\n grid = NumberPlane(\n x_range=[0, 3, 0.5],\n y_range=[0, 5, 0.5],\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n\n # Create quadratic curve\n curve = axes.plot(lambda x: x**2, color=GREEN)\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\")\n\n # Add grid and axes\n self.play(Create(grid), run_time=1.5)\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n\n # Draw curve\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # Show area under curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREY, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Integral notation\n integral = MathTex(r\"\\int_0^2 x^2 \\,dx\").to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Step 1: Antiderivative\n antiderivative = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_0^2\").next_to(integral, DOWN)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 2: Evaluation\n evaluation = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\").next_to(antiderivative, DOWN)\n self.play(Write(evaluation))\n self.wait(1)\n\n # Final result\n result = MathTex(r\"= \\frac{8}{3}\").next_to(evaluation, DOWN)\n self.play(Write(result))\n self.wait(1)\n\n # Riemann sum visualization\n riemann_rects = axes.get_riemann_rectangles(\n curve, x_range=[0, 2], dx=0.5, input_sample_type=\"right\", color=BLUE, fill_opacity=0.3\n )\n self.play(Create(riemann_rects))\n self.wait(0.5)\n\n for n in [10, 20, 50]:\n new_riemann = axes.get_riemann_rectangles(\n curve, x_range=[0, 2], dx=2/n, input_sample_type=\"right\", color=BLUE, fill_opacity=0.3\n )\n self.play(Transform(riemann_rects, new_riemann), run_time=0.5)\n self.wait(0.2)\n\n self.wait(1)\n\n # Fundamental Theorem highlight\n ftc_arrow = Arrow(\n antiderivative.get_bottom(),\n area.get_center(),\n buff=0.1,\n color=YELLOW\n )\n ftc_label = Tex(\"Fundamental Theorem of Calculus\").next_to(ftc_arrow, RIGHT)\n self.play(\n Create(ftc_arrow),\n Write(ftc_label),\n Flash(ftc_arrow, color=YELLOW, line_length=0.5)\n )\n self.wait(2)\n\n # Clear scene except result\n self.play(\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(area),\n FadeOut(integral),\n FadeOut(antiderivative),\n FadeOut(evaluation),\n FadeOut(riemann_rects),\n FadeOut(ftc_arrow),\n FadeOut(ftc_label),\n FadeOut(grid)\n )\n self.play(result.animate.move_to(ORIGIN).scale(2))\n self.wait(1)\n\n # Add watermark\n watermark = curve_label.copy().scale(0.5).to_corner(DR, buff=0.5).set_opacity(0.3)\n self.play(FadeIn(watermark))\n self.wait(2)\n\n # Pulse final result\n self.play(\n result.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedQuadraticIntegral(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create grid\n grid = NumberPlane(\n x_range=[0, 3, 0.5],\n y_range=[0, 5, 0.5],\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n\n # Create quadratic curve\n curve = axes.plot(lambda x: x**2, color=GREEN)\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\")\n\n # Add grid and axes\n self.play(Create(grid), run_time=1.5)\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n\n # Draw curve\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # Show area under curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREY, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Integral notation\n integral = MathTex(r\"\\int_0^2 x^2 \\,dx\" + \" = x\").to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Step 1: Antiderivative\n antiderivative = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_0^2\").next_to(integral, DOWN)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 2: Evaluation\n evaluation = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\").next_to(antiderivative, DOWN)\n self.play(Write(evaluation))\n self.wait(1)\n\n # Final result\n result = MathTex(r\"= \\frac{8}{3}\").next_to(evaluation, DOWN)\n self.play(Write(result))\n self.wait(1)\n\n # Riemann sum visualization\n riemann_rects = axes.get_riemann_rectangles(\n curve, x_range=[0, 2], dx=0.5, input_sample_type=\"right\", color=BLUE, fill_opacity=0.3\n )\n self.play(Create(riemann_rects))\n self.wait(0.5)\n\n for n in [10, 20, 50]:\n new_riemann = axes.get_riemann_rectangles(\n curve, x_range=[0, 2], dx=2/n, input_sample_type=\"right\", color=BLUE, fill_opacity=0.3\n )\n self.play(Transform(riemann_rects, new_riemann), run_time=0.5)\n self.wait(0.2)\n\n self.wait(1)\n\n # Fundamental Theorem highlight\n ftc_arrow = Arrow(\n antiderivative.get_bottom(),\n area.get_center(),\n buff=0.1,\n color=YELLOW\n )\n ftc_label = Tex(\"Fundamental Theorem of Calculus\").next_to(ftc_arrow, RIGHT)\n self.play(\n Create(ftc_arrow),\n Write(ftc_label),\n Flash(ftc_arrow, color=YELLOW, line_length=0.5)\n )\n self.wait(2)\n\n # Clear scene except result\n self.play(\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(area),\n FadeOut(integral),\n FadeOut(antiderivative),\n FadeOut(evaluation),\n FadeOut(riemann_rects),\n FadeOut(ftc_arrow),\n FadeOut(ftc_label),\n FadeOut(grid)\n )\n self.play(result.animate.move_to(ORIGIN).scale(2))\n self.wait(1)\n\n # Add watermark\n watermark = curve_label.copy().scale(0.5).to_corner(DR, buff=0.5).set_opacity(0.3)\n self.play(FadeIn(watermark))\n self.wait(2)\n\n # Pulse final result\n self.play(\n result.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=2\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that visually demonstrates the Pythagorean theorem? It should include the equation \"a^2 + b^2 = c^2\" written out, followed by a right triangle appearing on the screen. Next, can you show squares being formed on each side of the triangle to represent \"a^2\", \"b^2\", and \"c^2\" respectively? I'd also like two separate pieces of text that explain the concept: one that says \"Consider squares on each side\" and another that changes to say \"Area of c^2 is equal to sum of a^2 and b^2\". To conclude, can you transform the original equation into a final statement at the bottom of the screen, clear everything else, and then rewrite the equation one more time to emphasize the conclusion? Include pauses in the animation to allow the viewer to understand each step.", "chosen": "```python\nfrom manim import *\n\n# From manim import *\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display Equation ---\n equation = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n self.play(Write(equation))\n self.wait(2)\n\n # --- Step 2: Create Triangle ---\n # Define vertices for a 3-4-5 right triangle\n vertex_a = ORIGIN\n vertex_b = RIGHT * 3\n vertex_c = UP * 4\n \n triangle = Polygon(vertex_a, vertex_b, vertex_c)\n \n # Add labels to sides opposite angles A, B, C where angle C is the right angle\n label_c = MathTex(\"c\").next_to(triangle.get_edge_center(UP), DOWN, buff=0.1)\n label_a = MathTex(\"a\").next_to(triangle.get_vertices()[0], LEFT, buff=0.1).shift(DOWN * 0.3)\n label_b = MathTex(\"b\").next_to(triangle.get_vertices()[0], DOWN, buff=0.1).shift(RIGHT * 0.3)\n \n self.play(Create(triangle), Write(label_c), Write(label_a), Write(label_b))\n self.wait(2)\n\n # --- Step 3: Form Squares ---\n # Square A^2\n square_a = RoundedRectangle(width=3, height=3, corner_radius=0.1)\n square_a.move_to([vertex_a[0], vertex_a[1], 0])\n \n # Square B^2\n square_b = RoundedRectangle(width=4, height=4, corner_radius=0.1)\n square_b.move_to([vertex_a[0], vertex_a[1], 0]) # Position relative to the right-angle vertex\n \n # Square C^2\n square_c = Rectangle(height=5, width=5) # Width matches c length exactly \n square_c.next_to(square_a, UR, buff=0) # Aligns perfectly since a=3,b=4,c=5\n\n self.play(\n TransformFromCopy(triangle, square_a),\n TransformFromCopy(triangle, square_b),\n TransformFromCopy(triangle, square_c),\n )\n self.wait(2)\n\n # --- Step 4: Explain Concept ---\n explanation_text1 = Text(\"Consider squares on each side\", font_size=28).to_edge(UP)\n explanation_text2 = Text(\"Area of c^2 equals sum of a^2 and b^2\", font_size=28).to_edge(UP)\n \n self.play(Write(explanation_text1))\n self.wait(1)\n self.play(Transform(explanation_text1, explanation_text2))\n self.wait(2)\n\n # Clear intermediate elements from screen\n self.play(FadeOut(triangle), FadeOut(label_c), FadeOut(label_a), FadeOut(label_b))\n\n # --- Step 6: Final Transformation ---\n final_statement = MathTex(\"\\\\text{Area of } c^2 \\\\rightarrow \\\\sum\\\\limits_{i=a}^{b}\")\n final_statement.to_edge(DOWN, buff=1)\n \n # Animate transformation of the initial equation to the final statement\n self.play(ReplacementTransform(equation.copy(), final_statement))\n \n # Emphasize the conclusion by changing color and scaling up\n self.play(final_statement.animate.scale(1.5).set_color(YELLOW))\n \n # Hold the final state briefly\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Equation Display ---\n eq_initial = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n eq_initial.scale(1.5)\n self.play(Write(eq_initial))\n self.wait(2)\n\n # Shift initial equation up for visual spacing later\n self.play(eq_initial.animate.shift(UP * 2))\n\n # --- Step 2: Triangle Appearance ---\n # Create vertices\n A = ORIGIN\n B = RIGHT * 4\n C = UP * 3\n \n # Draw sides\n side_a = Line(A, C)\n side_b = Line(C, B)\n hypotenuse = Line(B, A)\n \n triangle = Polygon(\n A, \n C, \n B,\n color=WHITE,\n fill_opacity=0.8,\n stroke_width=6\n )\n self.add(triangle)\n \n # Add labels for sides\n label_c = MathTex(\"c\").next_to(hypotenuse, DOWN)\n label_a = MathTex(\"a\").rotate(-PI/4).move_to((A+C)/2)\n label_b = MathTex(\"b\").rotate(-PI/4).shift(RIGHT*1.5 + UP*1)\n \n self.play(Create(side_a), Write(label_a))\n self.play(Create(side_b), Write(label_b))\n self.play(Create(hypotenuse), Write(label_c))\n self.wait(2)\n\n # Animate squares forming on sides\n square_a = Square(side_length=A.distance_to(C), color=RED)\n square_b = Square(side_length=C.distance_to(B), color=BLUE)\n square_c = Square(side_length=B.distance_to(A), color=YELLOW)\n \n # Position squares exactly covering the triangles' areas\n square_a.move_to(((A+A+C) / 2)).set_fill(RED, opacity=0.7)\n square_b.move_to((C+(C+B)) / 2).rotate(PI/2).set_fill(BLUE, opacity=0.7)\n square_c.move_to((B+(B+A)) / 2).rotate(PI/2).set_fill(YELLOW, opacity=0.7)\n \n self.play(FadeIn(square_a), FadeIn(square_b), FadeIn(square_c))\n self.wait(2)\n\n # --- Step 3: Text Explanations ---\n\n # Explanation 1: Consider squares on each side\n text_explanation1 = Tex(\n r\"\\text{Consider squares constructed on each side of the right triangle}\",\n font_size=36\n ).to_edge(UP)\n self.play(Write(text_explanation1))\n self.wait(2)\n self.play(FadeOut(text_explanation1))\n\n # Explanation 2: Area relationship\n text_explanation2 = Tex(\n r\"$\\text{Area of } c^2 \\text{ is equal to the sum of areas of } a^2 \\text{ and } b^2$\",\n font_size=36\n ).to_edge(UP)\n self.play(Write(text_explanation2))\n self.wait(2)\n self.play(ReplaceScene(text_explanation2, Eq(a_squared_plus_b_squared_equals_c_squared)))\n\n # --- Step 4: Final Transformation ---\n\n # Move equations down to make room for the final emphasis\n self.play(\n eq_initial.animate.to_edge(DOWN),\n Eq(a_squared_plus_b_squared_equals_c_squared).animate.to_edge(UP)\n )\n\n # Emphasize the final conclusion with a large box around it\n box = SurroundingRectangle(Eq(a_squared_plus_b_squared_equals_c_squared), buff=0.2)\n box.set_stroke(width=3)\n self.play(Create(box))\n \n # Re-render the final equation to ensure it scales well across the full width\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n final_eq.scale(2)\n self.play(TransformFromCopy(Eq(a_squared_plus_b_squared_equals_c_squared), final_eq))\n self.wait(3)\n\n# To run this script:\n# 1. Save it as pyth_theo.py\n# 2. Run 'manim -pql pyth_theo.py PythagoreanTheorem'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass IntegrationVisualization(Scene):\n def construct(self):\n # --- 1. Setup Axes and Function ---\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # --- 2. Represent the Area Under the Curve ---\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.4)\n\n # --- 3. Mathematical Expressions ---\n # Problem statement\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42)\n \n # Step 1: Antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n \n # Step 2: Evaluate at bounds\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n \n # Step 3: Final solution\n final_answer = MathTex(r\"= \\frac{8}{3}\", font_size=48, color=YELLOW)\n\n # Arrange equations vertically on the right side\n equations = VGroup(problem, step1, step2, final_answer).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n equations.next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # --- 4. Animation Sequence ---\n \n # Introduce the coordinate system, graph, and area\n self.play(Create(axes), Write(labels), Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # Display the integral problem\n self.play(Write(problem))\n self.wait(1)\n\n # Animate the step-by-step solution\n self.play(Write(step1))\n self.wait(1)\n self.play(Write(step2))\n self.wait(1)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- 5. Final Transition ---\n # Group all elements to be faded out\n elements_to_remove = VGroup(\n axes, labels, graph, graph_label, area, problem, step1, step2\n )\n\n # Fade out the graph and intermediate steps, moving the final answer to the center\n self.play(\n FadeOut(elements_to_remove),\n final_answer.animate.move_to(ORIGIN).scale(1.5)\n )\n \n self.wait(2)\n\n# To run this animation, use the command:\n# manim -pql scene_file.py IntegrationVisualization\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrationVisualization(Scene):\n def construct(self):\n # --- 1. Setup Axes and Function ---\n axes = Axes(font_size=24, \n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # --- 2. Represent the Area Under the Curve ---\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.4)\n\n # --- 3. Mathematical Expressions ---\n # Problem statement\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42)\n \n # Step 1: Antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n \n # Step 2: Evaluate at bounds\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n \n # Step 3: Final solution\n final_answer = MathTex(r\"= \\frac{8}{3}\", font_size=48, color=YELLOW)\n\n # Arrange equations vertically on the right side\n equations = VGroup(problem, step1, step2, final_answer).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n equations.next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # --- 4. Animation Sequence ---\n \n # Introduce the coordinate system, graph, and area\n self.play(Create(axes), Write(labels), Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # Display the integral problem\n self.play(Write(problem))\n self.wait(1)\n\n # Animate the step-by-step solution\n self.play(Write(step1))\n self.wait(1)\n self.play(Write(step2))\n self.wait(1)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- 5. Final Transition ---\n # Group all elements to be faded out\n elements_to_remove = VGroup(\n axes, labels, graph, graph_label, area, problem, step1, step2\n )\n\n # Fade out the graph and intermediate steps, moving the final answer to the center\n self.play(\n FadeOut(elements_to_remove),\n final_answer.animate.move_to(ORIGIN).scale(1.5)\n )\n \n self.wait(2)\n\n# To run this animation, use the command:\n# manim -pql scene_file.py IntegrationVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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\nCan be represented using a \"pseudocode template\" as follows:\n\n```text\nSolve(problem P of size n):\n if n is small enough:\n solve directly and return\n divide P into several subproblems P1, P2, ..., Pa\n recursively solve each subproblem to get solutions S1, S2, ..., Sa\n combine these subproblem solutions Si into the solution S for P\n return S\n```\n\nThis template highlights two things:\n\n- **Control of Scale**: Each recursive call must reduce the size of the subproblems strictly to ensure the algorithm converges.\n- **Structural Similarity**: The subproblems must be of the same type as the original problem, allowing the same process `Solve` to be repeatedly called.\n\n\nThe context of this section (from highest to current level):\n# Recursion and Divide-and-Conquer Strategy — Course Notes\n## General Structure of Divide-and-Conquer Algorithms\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DivideAndConquerStructure(Scene):\n\n def construct(self):\n title = Title('General Structure of Divide-and-Conquer')\n self.play(Write(title))\n lines = ['Solve(problem P of size n):', ' if n is small enough:', ' solve directly and return', ' divide P into several subproblems P1, P2, ..., Pa', ' recursively solve each subproblem to get solutions S1, S2, ..., Sa', ' combine these subproblem solutions Si into the solution S for P', ' return S']\n t2c = {'Solve': YELLOW, 'solve': YELLOW, 'if': ORANGE, 'return': ORANGE, 'divide': TEAL, 'recursively': TEAL, 'combine': TEAL, 'P1, P2, ..., Pa': BLUE, 'S1, S2, ..., Sa': GREEN}\n code_group = VGroup(*[Text(line, font='monospace', font_size=20, t2c=t2c) for line in lines])\n code_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n code_rect = SurroundingRectangle(code_group, color=BLUE, fill_opacity=0.05, buff=0.3)\n pseudo_code = VGroup(code_rect, code_group)\n b1_title = Text('• Control of Scale:', font_size=22, color=YELLOW)\n b1_desc = Text('Each recursive call must strictly reduce the size of the\\nsubproblems to ensure the algorithm converges.', font_size=20, color=LIGHT_GRAY)\n b1_desc.next_to(b1_title, DOWN, aligned_edge=LEFT, buff=0.1)\n b1 = VGroup(b1_title, b1_desc)\n b2_title = Text('• Structural Similarity:', font_size=22, color=YELLOW)\n b2_desc = Text(\"The subproblems must be of the same type as the original problem,\\nallowing the same process 'Solve' to be repeatedly called.\", font_size=20, color=LIGHT_GRAY)\n b2_desc.next_to(b2_title, DOWN, aligned_edge=LEFT, buff=0.1)\n b2 = VGroup(b2_title, b2_desc)\n bullets = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n content_group = VGroup(pseudo_code, bullets).arrange(DOWN, buff=0.5)\n content_group.next_to(title, DOWN, buff=0.4)\n if content_group.height > 6.5:\n content_group.scale_to_fit_height(6.5)\n content_group.next_to(title, DOWN, buff=0.4)\n else:\n pass\n self.play(FadeIn(code_rect))\n for line in code_group:\n self.play(Write(line), run_time=0.4)\n else:\n pass\n self.wait(0.5)\n self.play(FadeIn(b1_title, shift=RIGHT * 0.5))\n self.play(Write(b1_desc))\n self.wait(0.5)\n self.play(FadeIn(b2_title, shift=RIGHT * 0.5))\n self.play(Write(b2_desc))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DivideAndConquerStructure(Scene):\n\n def construct(self):\n title = Title('General Structure of Divide-and-Conquer')\n self.play(Write(title))\n lines = ['Solve(problem P of size n):', ' if n is small enough:', ' solve directly and return', ' divide P into several subproblems P1, P2, ..., Pa', ' recursively solve each subproblem to get solutions S1, S2, ..., Sa', ' combine these subproblem solutions Si into the solution S for P', ' return S']\n t2c = {'Solve': YELLOW, 'solve': YELLOW, 'if': ORANGE, 'return': ORANGE, 'divide': TEAL, 'recursively': TEAL, 'combine': TEAL, 'P1, P2, ..., Pa': BBLUE, 'S1, S2, ..., Sa': GREEN}\n code_group = VGroup(*[Text(line, font='monospace', font_size=20, t2c=t2c) for line in lines])\n code_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n code_rect = SurroundingRectangle(code_group, color=BLUE, fill_opacity=0.05, buff=0.3)\n pseudo_code = VGroup(code_rect, code_group)\n b1_title = Text('• Control of Scale:', font_size=22, color=YELLOW)\n b1_desc = Text('Each recursive call must strictly reduce the size of the\\nsubproblems to ensure the algorithm converges.', font_size=20, color=LIGHT_GRAY)\n b1_desc.next_to(b1_title, DOWN, aligned_edge=LEFT, buff=0.1)\n b1 = VGroup(b1_title, b1_desc)\n b2_title = Text('• Structural Similarity:', font_size=22, color=YELLOW)\n b2_desc = Text(\"The subproblems must be of the same type as the original problem,\\nallowing the same process 'Solve' to be repeatedly called.\", font_size=20, color=LIGHT_GRAY)\n b2_desc.next_to(b2_title, DOWN, aligned_edge=LEFT, buff=0.1)\n b2 = VGroup(b2_title, b2_desc)\n bullets = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n content_group = VGroup(pseudo_code, bullets).arrange(DOWN, buff=0.5)\n content_group.next_to(title, DOWN, buff=0.4)\n if content_group.height > 6.5:\n content_group.scale_to_fit_height(6.5)\n content_group.next_to(title, DOWN, buff=0.4)\n else:\n pass\n self.play(FadeIn(code_rect))\n for line in code_group:\n self.play(Write(line), run_time=0.4)\n else:\n pass\n self.wait(0.5)\n self.play(FadeIn(b1_title, shift=RIGHT * 0.5))\n self.play(Write(b1_desc))\n self.wait(0.5)\n self.play(FadeIn(b2_title, shift=RIGHT * 0.5))\n self.play(Write(b2_desc))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an animation that walks through the process of solving a double integral in polar coordinates. Start by displaying the double integral symbolically on the screen. Then add a text explanation that we will first integrate with respect to the radius (r). Show the result of that inner integration and display the intermediate integral with respect to the angle (theta). Replace the explanation text with one that says we will now integrate with respect to theta. Complete the process by computing the final value and make sure each step transitions smoothly to the next, so it's easy to follow. Can you also include brief pauses between steps to allow viewers to understand each phase of the integration?", "chosen": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Initial Display\n # ------------------------------------------------------------------\n # Define the initial double integral in polar coordinates.\n # Example: Integral of r*sin(theta) over a quarter circle\n initial_integral = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} \\int_{0}^{2} r \\sin(\\theta) \\, dr \\, d\\theta\"\n ).scale(1.2)\n\n self.play(Write(initial_integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: First Integration Phase (with respect to r)\n # ------------------------------------------------------------------\n explanation_1 = Text(\n \"First, integrate with respect to the radius (r).\",\n font_size=36\n ).to_edge(UP)\n\n self.play(Write(explanation_1))\n self.wait(2)\n\n # Show the antiderivative of the inner integral\n inner_step_1 = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} \\left[ \\frac{1}{2}r^2 \\sin(\\theta) \\right]_{0}^{2} d\\theta\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(initial_integral, inner_step_1))\n self.wait(2)\n\n # Display the intermediate integral after evaluating the limits for r\n # [1/2 * 2^2 * sin(theta)] - [0] = 2*sin(theta)\n inner_step_2 = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} 2 \\sin(\\theta) \\, d\\theta\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(inner_step_1, inner_step_2))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Second Integration Phase (with respect to theta)\n # ------------------------------------------------------------------\n explanation_2 = Text(\n \"Now, integrate with respect to theta.\",\n font_size=36\n ).to_edge(UP)\n\n # Replace the previous text explanation\n self.play(ReplacementTransform(explanation_1, explanation_2))\n self.wait(1)\n\n # Animate the solution of the outer integral\n outer_step = MathTex(\n r\"\\left[ -2 \\cos(\\theta) \\right]_{0}^{\\frac{\\pi}{2}}\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(inner_step_2, outer_step))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Final Result\n # ------------------------------------------------------------------\n # Compute and display the final value\n # -2(cos(pi/2) - cos(0)) = -2(0 - 1) = 2\n final_result = MathTex(\n r\"-2(0 - 1) = 2\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(outer_step, final_result))\n \n # Final visual polish: highlight the result\n box = SurroundingRectangle(final_result, color=YELLOW)\n self.play(Create(box))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Initial Display\n # ------------------------------------------------------------------\n # Define the initial double integral in polar coordinates.\n # Example: Integral of r*sin(theta) over a quarter circle\n initial_integral = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} \\int_{0}^{2} r \\sin(\\theta) \\, dr \\, d\\theta\"\n ).scale(1.2)\n\n self.play(Write(initial_integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: First Integration Phase (with respect to r)\n # ------------------------------------------------------------------\n explanation_1 = Text(\n \"First, integrate with respect to the radius (r).\",\n font_size=36\n ).to_edge(UP)\n\n self.play(Write(explanation_1))\n self.wait(2)\n\n # Show the antiderivative of the inner integral\n inner_step_1 = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} \\left[ \\frac{1}{2}r^2 \\sin(\\theta) \\right]_{0}^{2} d\\theta\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(target_position=ORIGIN, initial_integral, inner_step_1))\n self.wait(2)\n\n # Display the intermediate integral after evaluating the limits for r\n # [1/2 * 2^2 * sin(theta)] - [0] = 2*sin(theta)\n inner_step_2 = MathTex(\n r\"\\int_{0}^{\\frac{\\pi}{2}} 2 \\sin(\\theta) \\, d\\theta\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(inner_step_1, inner_step_2))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Second Integration Phase (with respect to theta)\n # ------------------------------------------------------------------\n explanation_2 = Text(\n \"Now, integrate with respect to theta.\",\n font_size=36\n ).to_edge(UP)\n\n # Replace the previous text explanation\n self.play(ReplacementTransform(explanation_1, explanation_2))\n self.wait(1)\n\n # Animate the solution of the outer integral\n outer_step = MathTex(\n r\"\\left[ -2 \\cos(\\theta) \\right]_{0}^{\\frac{\\pi}{2}}\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(inner_step_2, outer_step))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Final Result\n # ------------------------------------------------------------------\n # Compute and display the final value\n # -2(cos(pi/2) - cos(0)) = -2(0 - 1) = 2\n final_result = MathTex(\n r\"-2(0 - 1) = 2\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(outer_step, final_result))\n \n # Final visual polish: highlight the result\n box = SurroundingRectangle(final_result, color=YELLOW)\n self.play(Create(box))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## 3. Deriving Equilibrium Income and the Government Spending Multiplier\n\n### 1. Solving for Equilibrium Income \\(Y\\) (Board Work)\n\nFrom:\n\\[\nY = C_0 + cY + I + G\n\\]\n\nRearrange:\n\\[\nY - cY = C_0 + I + G\n\\]\n\n\\[\n(1 - c)Y = C_0 + I + G\n\\]\n\nThus:\n\\[\nY = \\frac{1}{1 - c}(C_0 + I + G)\n\\]\n\n\nContextual location of this section: None\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass DeriveEquilibriumIncome(Scene):\n def construct(self):\n title = Text(\"Deriving Equilibrium Income\", font_size=36).to_edge(UP)\n context_text = Text(\n \"Where:\\n$C_{0}$ = autonomous consumption\\n$c$ = marginal propensity to consume\",\n font_size=24,\n ).next_to(title, DOWN, buff=0.5)\n \n equation_initial = MathTex(\"Y = C_0 + cy + I + G\").scale(1.2).shift(DOWN * 1.8)\n \n step_rearrange = MathTex(\"Y - cy = C_0 + I + G\").scale(1.2).shift(UP * 0.7)\n \n step_factor = MathTex(\"(1 - c)Y = C_0 + I + G\").scale(1.2).shift(DOWN * 0.8)\n \n final_equation = MathTex(\"Y = \\\\frac{1}{1-c} (C_0 + I + G)\").scale(1.2).move_to(ORIGIN)\n \n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(context_text, shift=DOWN * 0.5))\n self.wait(1)\n self.play(Write(equation_initial))\n self.wait(1)\n self.play(TransformMatchingTex(equation_initial.copy(), step_rearrange))\n self.wait(1)\n self.play(TransformMatchingTex(step_rearrange.copy(), step_factor))\n self.wait(1)\n self.play(Write(final_equation))\n self.wait(1)\n self.play(FadeOut(VGroup(title, context_text, equation_initial, step_rearrange, step_factor)))\n box = SurroundingRectangle(final_equation, color=BLUE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass BoardWorkScene(Scene):\n def construct(self):\n title_text = Text(\"Solving for Equilibrium Income Y\", font_size=36, weight=BOLD).to_edge(UP)\n \n from_eq = MathTex(r\"Y =\", \"C_{0}\", \"+ \", r\"cY\", \"+ \", \"I\", \"+ \", \"G\").scale(1.2).next_to(title_text, DOWN, buff=0.8)\n \n rearrange_step1 = MathTex(r\"Y - cY =\", \"C_{0} + I + G\").scale(1.2).next_to(from_eq, DOWN, aligned_edge=LEFT)\n rearrange_step2 = MathTex(r\"(1 - c)Y =\", \"C_{0} + I + G\").scale(1.2).move_to(rearrange_step1.get_center())\n \n solution_step = MathTex(r\"Y =\", r\"\\frac{1}{1-c}\", r\"\\left(C_{0} + I + G\\\\right)\", font_size=30).scale(1.2).next_to(rearrange_step2, DOWN, aligned_edge=LEFT).shift(RIGHT * 0.5)\n \n # Highlight each part of the derivation step by step\n self.play(Write(title_text))\n self.play(Write(from_eq))\n self.wait(1.5)\n\n highlight_box_from = SurroundingRectangle(from_eq[0], color=BLUE, buff=0.1)\n highlight_box_c1 = SurroundingRectangle(from_eq[1], color=YELLOW, buff=0.1)\n highlight_box_ci = SurroundingRectangle(from_eq[3], color=GREEN, buff=0.1)\n highlight_box_i = SurroundingRectangle(from_eq[-2], color=ORANGE, buff=0.1)\n highlight_box_g = SurroundingRectangle(from_eq[-1], color=PURPLE, buff=0.1)\n\n self.play(Create(highlight_box_from), Write(rearrange_step1))\n self.wait(1)\n self.play(Transform(from_eq[3:], from_eq[3:].copy().set_color(GREEN)), Transform(rearrange_step1[1:], rearrange_step1[1:].copy().set_color(GREEN)))\n self.wait(1)\n\n self.play(\n Create(highlight_box_ci),\n Write(rearrange_step1[2]),\n Transform(from_eq[3:], from_eq[3:].copy().set_color(YELLOW)),\n Transform(rearrange_step1[3:], rearrange_step1[3:].copy().set_color(YELLOW))\n )\n self.wait(1)\n\n self.play(\n Create(highlight_box_i),\n Write(rearrange_step1[5])\n )\n self.wait(1)\n\n self.play(\n Create(highlight_box_g),\n Write(rearrange_step1[7])\n )\n\n self.wait(1)\n self.play(FadeIn(highlight_box_from, shift=DOWN * 0.5))\n\n self.play(Write(rearrange_step2))\n self.wait(1)\n\n box_equation = SurroundingRectangle(rearrange_step2, color=WHITE, buff=0.1)\n self.play(Create(box_equation))\n self.wait(1.5)\n\n self.play(Write(solution_step))\n self.wait(1)\n\n arrow_next = Arrow(solution_step[0].get_bottom(), solution_step[1].get_top()).set_color(RED)\n self.play(GrowArrow(arrow_next))\n formula_value = MathTex(r\"\\text{Total } Y = \\\\ \\frac{\\sum(\\text{Income Sources})}{1-\\text{marginal propensity to consume}}\")\n formula_group = VGroup(formula_value).scale(0.8).next_to(solution_step, DOWN, buff=0.8)\n self.play(Write(formula_group))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## Basic Concepts of Variables and Constants\n\n- Variable:\n - A storage unit in memory with a specific type and name;\n - The value of a variable can be changed during program execution (Reassigned).\n - The type determines the bit width (Bit width) and interpretation method (such as two's complement or floating-point format) of the variable.\n\n\nContext location of this section (from highest level to current):\n# Basic Components of a Program\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ConceptVariablesAndConstants(Scene):\n\n def construct(self):\n title = Text('Basic Concepts of Variables and Constants', font_size=36).to_edge(UP)\n header_var = Text('Variable:', color=BLUE, weight=BOLD).next_to(title, DOWN, buff=0.7).align_to(title, LEFT)\n desc_var1 = Text('- Storage unit in memory\\n with a specific type and name;\\n Reassignable.', t2c={'Storage': BLUE, 'specific': YELLOW}).scale(0.8).next_to(header_var, DOWN, buff=0.4).shift(RIGHT * 0.1)\n desc_var2 = MathTex('\\\\text{Type} \\\\rightarrow \\\\text{Bit Width}', '\\\\qquad', '\\\\text{\"Two\\'s Complement\"}').scale(0.7).arrange(DOWN, aligned_edge=LEFT).next_to(desc_var1, DOWN, buff=0.5).shift(RIGHT * 0.1)\n dot_type = Dot(color=YELLOW).move_to(desc_var2.get_center() + RIGHT * 3.0)\n rect_bitwidth = RoundedRectangle(corner_radius=0.1, height=0.4, width=2.2, color=GREEN).move_to(dot_type.get_right())\n label_bw = Tex('$\\\\times$ Bit Width').scale(0.6).next_to(rect_bitwidth, UP, buff=0.2)\n var_type_label = Text('\"Integer\"', font_size=24, color=WHITE).rotate(-PI/2).next_to(rect_bitwidth, LEFT, buff=0.2)\n \n self.play(FadeIn(title))\n self.play(Write(header_var))\n self.play(FadeIn(desc_var1, shift=RIGHT))\n self.wait(1)\n self.play(Write(desc_var2))\n self.wait(0.5)\n self.play(Create(dot_type), FadeIn(var_type_label))\n self.play(GrowFromCenter(rect_bitwidth), Write(label_bw))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ProgrammingConcepts(Scene):\n\n def construct(self):\n title = Text(\"Basic Concepts of Variables and Constants\", font_size=36)\n subtitle = Text(\"Program Structure\", font_color=TEAL_D).scale(0.7)\n \n # Group title components for proper alignment later on\n main_title = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n self.play(Write(main_title))\n self.wait(0.5)\n\n var_box = RoundedRectangle(corner_radius=0.15, height=1.8, width=2.8, color=YELLOW)\n const_text = MathTex(\"\\\\text{const } x \\\\text{ : int} = 10\")\n \n var_group = VGroup(var_box, const_text).arrange(RIGHT, buff=0.5)\n var_label = Tex(\"Variable Storage Unit\").next_to(var_group, DOWN, buff=0.5)\n \n reassign_arrow = Arrow(start=var_group.get_bottom(), end=var_group.get_bottom() + UP * 1.8, buff=0.1, color=ORANGE)\n reassign_txt = Text(\"- Can be reassigned\\n- Type defines bit-width\\nand interpretation\", t2c={\"reassigned\": ORANGE}).to_edge(LEFT, buff=1.5)\n \n self.play(Create(var_group), Write(reassign_arrow), FadeIn(var_label))\n self.play(FadeIn(const_text), Write(reassign_txt))\n self.wait()\n\n bitbox1 = Rectangle(height=0.6, width=1, fill_opacity=0.1, stroke_width=2)\n bitbox2 = Rectangle(height=0.6, width=1, fill_opacity=0.1, stroke_width=2)\n bits = VGroup(bitbox1, bitbox2).arrange(RIGHT, buff=0.2)\n bits.next_to(reassign_txt, RIGHT, buff=1.2)\n \n types = [\"int\", \"float\"]\n labels = [Text(t, font_size=22, color=BLUE_B) for t in types]\n \n label_groups = VGroup()\n for i, box in enumerate([bitbox1, bitbox2]):\n label = labels[i].move_to(box.get_center())\n group = VGroup(box, label)\n label_groups.add(group)\n \n self.play(\n Create(bits),\n *[Write(label) for label in labels],\n Indicate(bitbox1, scale_factor=1.3, color=GREEN_A),\n Indicate(bitbox2, scale_factor=1.3, color=RED_A)\n )\n self.wait(0.5)\n \n bit_desc = Text(\"Type specifies bit-width and\\ninterpretation format\", font_size=20, line_spacing=1.2)\n bit_desc.to_edge(DOWN, buff=1.0)\n bit_desc.next_to(labels, DOWN, buff=0.2)\n self.play(Write(bit_desc))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'm learning an undergrad course on numerical linear algebra and want a visual explanation of SVD.\nShow geometrically how a matrix A transforms the unit circle into an ellipse, with singular vectors as axes and Σ as scaling.\nThen decompose A as UΣV^T and illustrate the transformation step by step, including a noisy perturbation to show conditioning.\nInclude multiple scenes: constructing the ellipse, applying A to the circle, and a real-world data example to motivate use.\nI’d like the animation to have clear pacing, smooth transitions, and both intuition and rigorous definitions.", "chosen": "```python\nfrom manim import *\n\nclass SVDScene(Scene):\n\n def construct(self):\n title = Text('Geometric Interpretation of SVD', font_size=36)\n title.to_edge(UP, buff=0.5)\n formula = MathTex('A = U', '\\\\Sigma', 'V^T', font_size=32)\n formula.next_to(title, DOWN, buff=0.3)\n formula[0][2:].set_color(BLUE)\n formula[1].set_color(RED)\n formula[2].set_color(GREEN)\n self.play(Write(title), run_time=2.0 * 0.5)\n self.play(Write(formula), run_time=2.0 * 0.5)\n self.wait(0.5)\n circle = Circle(radius=1.5, color=WHITE)\n circle.shift(LEFT * 3.5)\n e1 = Arrow(circle.get_center(), circle.get_center() + RIGHT * 1.5, buff=0, color=YELLOW)\n e2 = Arrow(circle.get_center(), circle.get_center() + UP * 1.5, buff=0, color=YELLOW)\n e1_label = MathTex('\\\\mathbf{e}_1', font_size=24, color=YELLOW)\n e1_label.next_to(e1.get_end(), RIGHT, buff=0.1)\n e2_label = MathTex('\\\\mathbf{e}_2', font_size=24, color=YELLOW)\n e2_label.next_to(e2.get_end(), UP, buff=0.1)\n unit_group = VGroup(circle, e1, e2, e1_label, e2_label)\n self.play(Create(circle), run_time=2.0 * 0.4)\n self.play(Create(e1), Create(e2), run_time=2.0 * 0.3)\n self.play(Write(e1_label), Write(e2_label), run_time=2.0 * 0.3)\n A = np.array([[2, 1], [1, 3]])\n angle_vt = -np.arctan2(2, 1) * 0.5\n circle_vt = circle.copy()\n e1_vt = e1.copy()\n e2_vt = e2.copy()\n e1_label_vt = e1_label.copy()\n e2_label_vt = e2_label.copy()\n vt_group = VGroup(circle_vt, e1_vt, e2_vt, e1_label_vt, e2_label_vt)\n vt_group.shift(RIGHT * 4)\n vt_label = Text('V^T: Rotation', font_size=20, color=GREEN)\n vt_label.next_to(vt_group, UP, buff=0.3)\n self.play(TransformFromCopy(unit_group, vt_group), Write(vt_label), run_time=2.0)\n self.wait(0.3)\n sigma_1 = 3.6\n sigma_2 = 1.4\n circle_sigma = Ellipse(width=3, height=1.2, color=WHITE)\n circle_sigma.move_to(vt_group.get_center())\n e1_sigma = Arrow(circle_sigma.get_center(), circle_sigma.get_center() + RIGHT * 1.5, buff=0, color=ORANGE)\n e2_sigma = Arrow(circle_sigma.get_center(), circle_sigma.get_center() + UP * 0.6, buff=0, color=ORANGE)\n sigma_label = Text('\\sum : Scaling', font_size=20, color=RED)\n sigma_label.next_to(circle_sigma, UP, buff=0.3)\n sigma_values = MathTex('\\\\sigma_1 = 3.6, \\\\sigma_2 = 1.4', font_size=18, color=RED)\n sigma_values.next_to(sigma_label, DOWN, buff=0.1)\n sigma_group = VGroup(circle_sigma, e1_sigma, e2_sigma, sigma_label, sigma_values)\n self.play(Transform(circle_vt, circle_sigma), Transform(e1_vt, e1_sigma), Transform(e2_vt, e2_sigma), FadeOut(e1_label_vt), FadeOut(e2_label_vt), Transform(vt_label, sigma_label), FadeIn(sigma_values), run_time=2.0)\n self.wait(0.3)\n circle_u = Ellipse(width=3.2, height=1.0, color=WHITE)\n circle_u.move_to(vt_group.get_center())\n circle_u.rotate(PI / 6)\n e1_u = Arrow(circle_u.get_center(), circle_u.get_center() + np.array([1.4, 0.8, 0]), buff=0, color=BLUE)\n e2_u = Arrow(circle_u.get_center(), circle_u.get_center() + np.array([-0.4, 0.5, 0]), buff=0, color=BLUE)\n u_label = Text('U: Rotation', font_size=20, color=BLUE)\n u_label.next_to(circle_u, UP, buff=0.3)\n self.play(Transform(circle_vt, circle_u), Transform(e1_vt, e1_u), Transform(e2_vt, e2_u), Transform(vt_label, u_label), FadeOut(sigma_values), run_time=2.0)\n self.wait(0.3)\n summary_title = Text('SVD = Rotate · Scale · Rotate', font_size=28)\n summary_title.to_edge(DOWN, buff=0.5)\n summary_formula = MathTex('A = U', '\\\\Sigma', 'V^T', font_size=30)\n summary_formula.next_to(summary_title, UP, buff=0.3)\n summary_formula[0][2:].set_color(BLUE)\n summary_formula[1].set_color(RED)\n summary_formula[2].set_color(GREEN)\n self.play(Write(summary_title), Write(summary_formula), run_time=2.0)\n self.wait(1)\n self.play(FadeOut(vt_group), FadeOut(vt_label), FadeOut(unit_group), FadeOut(title), FadeOut(formula), run_time=1)\n takeaway_box = Rectangle(width=10, height=3.5, color=WHITE)\n takeaway_box.to_edge(DOWN, buff=0.8)\n takeaway_title = Text('Key Takeaways', font_size=28, weight=BOLD)\n takeaway_title.next_to(takeaway_box.get_top(), DOWN, buff=0.3)\n takeaways = VGroup(Text('• V^T: Rotates input space to align with principal axes', font_size=20), Text('• \\sum : Scales along each principal axis (singular values)', font_size=20), Text('• U: Rotates to final output orientation', font_size=20), Text('• The circle becomes an ellipse: this is the geometric essence of SVD', font_size=20)).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n takeaways.next_to(takeaway_title, DOWN, buff=0.3)\n self.play(Create(takeaway_box), run_time=2.0 * 0.3)\n self.play(Write(takeaway_title), run_time=2.0 * 0.2)\n self.play(Write(takeaways), run_time=2.0 * 0.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass SVDScene(Scene):\n\n def construct(self):\n title = Text('Geometric Interpretation of SVD', font_size=36)\n title.to_edge(UP, buff=0.5)\n formula = MathTex('A = U', '\\\\Sigma', 'V^T', font_size=32)\n formula.next_to(title, DOWN, buff=0.3)\n formula[0][2:].set_color(BLUE)\n formula[1].set_color(RED)\n formula[2].set_color(GREEN)\n self.play(Write(title), run_time=2.0 * 0.5)\n self.play(Write(formula), run_time=2.0 * 0.5)\n self.wait(0.5)\n circle = Circle(radius=1.5, color=WHITE)\n circle.shift(LEFT * 3.5)\n e1 = Arrow(circle.get_center(), circle.get_center() + RIGHT * 1.5, buff=0, color=YELLOW)\n e2 = Arrow(circle.get_center(), circle.get_center() + UP * 1.5, buff=0, color=YELLOW)\n e1_label = MathTex('\\\\mathbf{e}_1', font_size=24, color=YELLOW)\n e1_label.next_to(e1.get_end(), RIGHT, buff=0.1)\n e2_label = MathTex('\\\\mathbf{e}_2', font_size=24, color=YELLOW)\n e2_label.next_to(e2.get_end(), UP, buff=0.1)\n unit_group = VGroup(circle, e1, e2, e1_label, e2_label)\n self.play(Create(circle), run_time=2.0 * 0.4)\n self.play(Create(e1), Create(e2), run_time=2.0 * 0.3)\n self.play(Write(e1_label), Write(e2_label), run_time=2.0 * 0.3)\n A = np.array([[2, 1], [1, 3]])\n angle_vt = -np.arctan2(2, 1) * 0.5\n circle_vt = circle.copy()\n e1_vt = e1.copy()\n e2_vt = e2.copy()\n e1_label_vt = e1_label.copy()\n e2_label_vt = e2_label.copy()\n vt_group = VGroup(circle_vt, e1_vt, e2_vt, e1_label_vt, e2_label_vt)\n vt_group.shift(RIGHT * 4)\n vt_label = Text('V^T: Rotation', font_size=20, color=GREEN)\n vt_label.next_to(vt_group, UP, buff=0.3)\n self.play(TransformFromCopy(unit_group, vt_group), Write(vt_label), run_time=2.0)\n self.wait(0.3)\n sigma_1 = 3.6\n sigma_2 = 1.4\n circle_sigma = Ellipse(width=3, height=1.2, color=WHITE)\n circle_sigma.move_to(vt_group.get_center())\n e1_sigma = Arrow(circle_sigma.get_center(), circle_sigma.get_center() + RIGHT * 1.5, buff=0, color=ORANGE)\n e2_sigma = Arrow(circle_sigma.get_center(), circle_sigma.get_center() + UP * 0.6, buff=0, color=ORANGE)\n sigma_label = Text('\\sum : Scaling', font_size=20, color=RED)\n sigma_label.next_to(circle_sigma, UP, buff=0.3)\n sigma_values = MathTex('\\\\sigma_1 = 3.6, \\\\sigma_2 = 1.4', font_size=18, color=RED)\n sigma_values.next_to(sigma_label, DOWN, buff=0.1)\n sigma_group = VGroup(circle_sigma, e1_sigma, e2_sigma, sigma_label, sigma_values)\n self.play(Transform(circle_vt, circle_sigma), Transform(e1_vt, e1_sigma), Transform(e2_vt, e2_sigma), FadeOut(e1_label_vt), FadeOut(e2_label_vt), Transform(vt_label, sigma_label), FadeIn(sigma_values), run_time=2.0)\n self.wait(0.3)\n circle_u = Ellipse(width=3.2, height=1.0, color=WHITE)\n circle_u.move_to(vt_group.get_center())\n circle_u.rotate(PI / 6)\n e1_u = Arrow(circle_u.get_center(), circle_u.get_center() + np.array([1.4, 0.8, 0]), buff=0, color=BLUE)\n e2_u = Arrow(circle_u.get_center(), circle_u.get_center() + np.array([-0.4, 0.5, 0]), buff=0, color=BLUE)\n u_label = Text('U: Rotation', font_size=20, color=BLUE)\n u_label.next_to(circle_u, UP, buff=0.3)\n self.play(Transform(circle_vt, circle_u), Transform(e1_vt, e1_u), Transform(e2_vt, e2_u), Transform(vt_label, u_label), FadeOut(sigma_values), run_time=2.0)\n self.wait(0.3)\n summary_title = Text('SVD = Rotate · Scale · Rotate', font_size=28)\n summary_title.to_edge(DOWN, buff=0.5)\n summary_formula = MathTex('A = U', '\\\\Sigma', 'V^T', font_size=30)\n summary_formula.next_to(summary_title, UP, buff=0.3)\n summary_formula[0][2:].set_color(BLUE)\n summary_formula[1].set_color(RED)\n summary_formula[2].set_color(GREEN)\n self.play(Write(summary_title), Write(summary_formula), run_time=2.0)\n self.wait(1)\n self.play(FadeOut(vt_group), FadeOut(vt_label), FadeOut(unit_group), FadeOut(title), FadeOut(formula), run_time=1)\n takeaway_box = Rectangle(width=10, height=3.5, color=WHITE)\n takeaway_box.to_edge(DOWN, buff=0.8)\n takeaway_title = Text('Key Takeaways', font_size=28, weight=BOLD)\n takeaway_title.next_to(takeaway_box.get_top(), DOWN, buff=0.3)\n takeaways = VGroup(Text('• V^T: Rotates input space to align with principal axes', font_size=20), Text('• \\sum : Scales along each principal axis (singular values)', font_size=20), Text('• U: Rotates to final output orientation', font_size=20), Text('• The circle becomes an ellipse: this is the geometric essence of SVD', font_size=20)).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n takeaways.next_to(takeaway_title, DOWN, buff=0.3)\n self.play(Create(takeaway_box), run_time=2.0 * 0.3)\n self.play(Write(takeaway_title), run_time=2.0 * 0.2)\n self.play(Write(takeaways), run_time=2.0 * 0.5)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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 2: Here is the enhanced animation instruction that includes all original features plus significant new elements:", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0075(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_textshapeanimation()\n self.clear_stage()\n self.act_2_enhancedheptagonanimatio()\n\n def act_1_textshapeanimation(self):\n initial_text = Text(\"Initial Message\", font_size=36)\n new_text = Text(\"New Message\", font_size=36).shift(UP * 2)\n\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # Transition to the new message with an upward shift animation\n self.play(ReplacementTransform(initial_text, new_text))\n self.wait(0.5)\n\n # Clear the text from the screen to prepare for the shapes\n self.play(FadeOut(new_text))\n\n # Step 2: Shape Expansion\n # Create a circle and a star. The star is slightly offset from the center \n # so that scaling the group visually pushes it away from the center.\n circle = Circle(radius=1.5, color=BLUE, fill_opacity=0.2)\n star = Star(n=5, outer_radius=0.4, inner_radius=0.2, color=YELLOW, fill_opacity=1).shift(UR * 0.3)\n\n # Group them together to apply transformations simultaneously\n shape_group = VGroup(circle, star)\n\n self.play(FadeIn(shape_group))\n self.wait(0.5)\n\n # Expand the group. Because the star is offset, scaling the group moves it outward.\n self.play(\n shape_group.animate.scale(2.5),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # Step 3: Disappearance\n # Animate both the circle and the star disappearing from the screen\n self.play(FadeOut(shape_group))\n self.wait(0.5)\n\n def act_2_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0075(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_textshapeanimation()\n self.clear_stage()\n self.act_2_enhancedheptagonanimatio()\n\n def act_1_textshapeanimation(self):\n initial_text = Text(\"Initial Message\", font_size=36)\n new_text = Text(\"New Message\", font_size=36).shift(UP * 2)\n\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # Transition to the new message with an upward shift animation\n self.play(ReplacementTransform(initial_text, new_text))\n self.wait(0.5)\n\n # Clear the text from the screen to prepare for the shapes\n self.play(FadeOut(new_text))\n\n # Step 2: Shape Expansion\n # Create a circle and a star. The star is slightly offset from the center \n # so that scaling the group visually pushes it away from the center.\n circle = Circle(radius=1.5, color=BLUE, fill_opacity=0.2)\n star = Star(n=5, outer_radius=0.4, inner_radius=0.2, color=YELLOW, fill_opacity=1).shift(UR * 0.3)\n\n # Group them together to apply transformations simultaneously\n shape_group = VGroup(circle, star)\n\n self.play(FadeIn(shape_group))\n self.wait(0.5)\n\n # Expand the group. Because the star is offset, scaling the group moves it outward.\n self.play(\n shape_group.animate.scale(2.5),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # Step 3: Disappearance\n # Animate both the circle and the star disappearing from the screen\n self.play(FadeOut(shape_group))\n self.wait(0.5)\n\n def act_2_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the documentation configuration with additional features and explanations:\n\nThe enhanced documentation configuration builds upon the original by adding comprehensive documentation features while maintaining all existing settings. It now includes intersphinx mapping for linking to Python standard library documentation, automatic API documentation generation through autosummary, improved theme customization with logo and favicon support, and version-specific documentation using the releases extension. The configuration also enables SVG image support through sphinx.ext.imgconverter and adds MathJax for mathematical notation. The HTML output is further enhanced with custom CSS in the _static directory and sidebar customization through html_theme_options. The build process now automatically generates API documentation for all modules while excluding test files, and includes improved search functionality through the html_search_options setting. The documentation version is dynamically set from the package version, and the configuration includes comprehensive settings for PDF output through LaTeX customization. All original paths and exclusions are preserved while adding these new capabilities to create a more robust and feature-rich documentation system.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedDocumentationScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Enhanced Documentation\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Main features\n features = VGroup(\n Text(\"• Intersphinx mapping\", font_size=30),\n Text(\"• Autosummary API docs\", font_size=30),\n Text(\"• Theme customization\", font_size=30),\n Text(\"• Version-specific docs\", font_size=30),\n Text(\"• SVG/MathJax support\", font_size=30),\n Text(\"• Custom CSS/JS\", font_size=30),\n Text(\"• Improved search\", font_size=30),\n Text(\"• PDF output options\", font_size=30)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(title, DOWN, buff=0.5)\n \n self.play(LaggedStart(*[Write(f) for f in features], lag_ratio=0.2))\n self.wait(2)\n \n # Highlight key features\n boxes = VGroup(*[SurroundingRectangle(f, color=YELLOW) for f in features])\n self.play(LaggedStart(*[Create(b) for b in boxes], lag_ratio=0.3))\n self.wait(1)\n self.play(FadeOut(boxes))\n \n # Configuration diagram\n config = Text(\"docs/conf.py\", font=\"Monospace\", font_size=30)\n config_box = SurroundingRectangle(config, color=BLUE, buff=0.3)\n \n options = VGroup(\n Text(\"extensions = [\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.autodoc',\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.intersphinx',\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.mathjax',\", font=\"Monospace\", font_size=24),\n Text(\"]\", font=\"Monospace\", font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT)\n \n group = VGroup(config, config_box, options).arrange(DOWN, buff=0.5)\n group.next_to(features, DOWN, buff=0.7)\n \n self.play(FadeIn(config), Create(config_box))\n self.wait(0.5)\n self.play(Write(options))\n self.wait(2)\n \n # Final animation\n self.play(\n FadeOut(title),\n FadeOut(features),\n group.animate.scale(1.2).move_to(ORIGIN)\n )\n self.wait(1)\n \n self.play(FadeOut(group))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedDocumentationScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Enhanced Documentation\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Main features\n features = VGroup(\n Text(\"• Intersphinx mapping\", font_size=30),\n Text(\"• Autosummary API docs\", font_size=30),\n Text(\"• Theme customization\", font_size=30),\n Text(\"• Version-specific docs\", font_size=30),\n Text(\"• SVG/MathJax support\", font_size=30),\n Text(\"• Custom CSS/JS\", font_size=30),\n Text(\"• Improved search\", font_size=30),\n Text(\"• PDF output options\", font_size=30)\n ).arrange(DOWN, aligned_edge=LEFT).next_to(title, DOWN, buff=0.5)\n \n self.play(LaggedStart(*[Write(f) for f in features], lag_ratio=0.2))\n self.wait(2)\n \n # Highlight key features\n boxes = VGroup(*[SurroundingRectangle(f, color=YELLOW) for f in features])\n self.play(LaggedStart(*[Create(b) for b in boxes], lag_ratio=0.3))\n self.wait(1)\n self.play(FadeOut(boxes))\n \n # Configuration diagram\n config = Text(\"docs/conf.py\", font=\"Monospace\", font_size=30)\n config_box = SurroundingRectangle(config, color=BBLUE, buff=0.3)\n \n options = VGroup(\n Text(\"extensions = [\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.autodoc',\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.intersphinx',\", font=\"Monospace\", font_size=24),\n Text(\" 'sphinx.ext.mathjax',\", font=\"Monospace\", font_size=24),\n Text(\"]\", font=\"Monospace\", font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT)\n \n group = VGroup(config, config_box, options).arrange(DOWN, buff=0.5)\n group.next_to(features, DOWN, buff=0.7)\n \n self.play(FadeIn(config), Create(config_box))\n self.wait(0.5)\n self.play(Write(options))\n self.wait(2)\n \n # Final animation\n self.play(\n FadeOut(title),\n FadeOut(features),\n group.animate.scale(1.2).move_to(ORIGIN)\n )\n self.wait(1)\n \n self.play(FadeOut(group))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Shader Example\n**Vertex Shader Core Functionality:**\n- Receives vertex attributes (position, normal, texture coordinates)\n- Applies transformation matrices to compute the position in clip space\n- Outputs transformed attributes for use by the fragment shader\n\n**Fragment Shader Core Functionality:**\n- Receives interpolated vertex attributes\n- Performs texture sampling\n- Computes lighting (e.g., Blinn-Phong model)\n- Outputs the final pixel color\n\n**[Suggested Diagram: Data flow diagram for vertex and fragment shaders]**\n\n\nContext location within the document (from highest to current level):\n# Computer Graphics and Virtual Reality: Graphics Rendering Pipeline\n## Introduction to Shader Programming\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShaderExampleScene(Scene):\n\n def construct(self):\n title = Text('Shader Programming: Core Functionality', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title))\n vs_box = RoundedRectangle(width=4.8, height=1.5, corner_radius=0.2, color=BLUE)\n vs_title = Text('Vertex Shader', font_size=28, color=BLUE).move_to(vs_box.get_center())\n vs_group = VGroup(vs_box, vs_title).move_to(LEFT * 3.6 + UP * 1.5)\n vs_items = ['• Receives vertex attributes\\n (position, normal, UVs)', '• Applies transformation matrices\\n to compute clip space position', '• Outputs transformed attributes']\n vs_list = VGroup(*[Text(item, font_size=20, line_spacing=1.2) for item in vs_items])\n vs_list.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n vs_list.next_to(vs_group, DOWN, buff=0.5)\n vs_list.align_to(vs_group, LEFT).shift(RIGHT * 0.2)\n fs_box = RoundedRectangle(width=4.8, height=1.5, corner_radius=0.2, color=GREEN)\n fs_title = Text('Fragment Shader', font_size=28, color=GREEN).move_to(fs_box.get_center())\n fs_group = VGroup(fs_box, fs_title).move_to(RIGHT * 3.6 + UP * 1.5)\n fs_items = ['• Receives interpolated\\n vertex attributes', '• Performs texture sampling', '• Computes lighting\\n (e.g., Blinn-Phong model)', '• Outputs the final pixel color']\n fs_list = VGroup(*[Text(item, font_size=20, line_spacing=1.2) for item in fs_items])\n fs_list.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n fs_list.next_to(fs_group, DOWN, buff=0.5)\n fs_list.align_to(fs_group, LEFT).shift(RIGHT * 0.2)\n arrow_in = Arrow(LEFT * 7.1, vs_box.get_left(), buff=0.2, color=WHITE)\n text_in = Text('Vertex\\nAttributes', font_size=18).next_to(arrow_in, UP, buff=0.1)\n arrow_mid = Arrow(vs_box.get_right(), fs_box.get_left(), buff=0.2, color=YELLOW)\n text_mid = Text('Transformed\\nAttributes', font_size=18, color=YELLOW).next_to(arrow_mid, UP, buff=0.1)\n arrow_out = Arrow(fs_box.get_right(), RIGHT * 7.1, buff=0.2, color=WHITE)\n text_out = Text('Final\\nPixel Color', font_size=18).next_to(arrow_out, UP, buff=0.1)\n self.play(GrowArrow(arrow_in), FadeIn(text_in))\n self.play(Create(vs_box), Write(vs_title))\n for item in vs_list:\n self.play(FadeIn(item, shift=RIGHT * 0.3), run_time=0.7)\n else:\n pass\n self.play(GrowArrow(arrow_mid), FadeIn(text_mid))\n self.play(Create(fs_box), Write(fs_title))\n for item in fs_list:\n self.play(FadeIn(item, shift=RIGHT * 0.3), run_time=0.7)\n else:\n pass\n self.play(GrowArrow(arrow_out), FadeIn(text_out))\n flow_dot = Dot(color=RED, radius=0.08)\n self.play(FadeIn(flow_dot.move_to(arrow_in.get_start())))\n self.play(MoveAlongPath(flow_dot, Line(arrow_in.get_start(), arrow_in.get_end())), run_time=0.6)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.play(vs_box.animate.set_fill(BLUE, opacity=0.3), run_time=0.3)\n self.play(vs_box.animate.set_fill(BLUE, opacity=0), run_time=0.3)\n flow_dot.move_to(arrow_mid.get_start())\n self.play(FadeIn(flow_dot), run_time=0.2)\n self.play(MoveAlongPath(flow_dot, Line(arrow_mid.get_start(), arrow_mid.get_end())), run_time=0.8)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.play(fs_box.animate.set_fill(GREEN, opacity=0.3), run_time=0.3)\n self.play(fs_box.animate.set_fill(GREEN, opacity=0), run_time=0.3)\n flow_dot.move_to(arrow_out.get_start())\n self.play(FadeIn(flow_dot), run_time=0.2)\n self.play(MoveAlongPath(flow_dot, Line(arrow_out.get_start(), arrow_out.get_end())), run_time=0.6)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShaderExampleScene(Scene):\n\n def construct(self):\n title = Text('Shader Programming: Core Functionality', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title))\n vs_box = RoundedRectangle(width=4.8, height=1.5, corner_radius=0.2, color=BBLUE)\n vs_title = Text('Vertex Shader', font_size=28, color=BLUE).move_to(vs_box.get_center())\n vs_group = VGroup(vs_box, vs_title).move_to(LEFT * 3.6 + UP * 1.5)\n vs_items = ['• Receives vertex attributes\\n (position, normal, UVs)', '• Applies transformation matrices\\n to compute clip space position', '• Outputs transformed attributes']\n vs_list = VGroup(*[Text(item, font_size=20, line_spacing=1.2) for item in vs_items])\n vs_list.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n vs_list.next_to(vs_group, DOWN, buff=0.5)\n vs_list.align_to(vs_group, LEFT).shift(RIGHT * 0.2)\n fs_box = RoundedRectangle(width=4.8, height=1.5, corner_radius=0.2, color=GREEN)\n fs_title = Text('Fragment Shader', font_size=28, color=GREEN).move_to(fs_box.get_center())\n fs_group = VGroup(fs_box, fs_title).move_to(RIGHT * 3.6 + UP * 1.5)\n fs_items = ['• Receives interpolated\\n vertex attributes', '• Performs texture sampling', '• Computes lighting\\n (e.g., Blinn-Phong model)', '• Outputs the final pixel color']\n fs_list = VGroup(*[Text(item, font_size=20, line_spacing=1.2) for item in fs_items])\n fs_list.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n fs_list.next_to(fs_group, DOWN, buff=0.5)\n fs_list.align_to(fs_group, LEFT).shift(RIGHT * 0.2)\n arrow_in = Arrow(LEFT * 7.1, vs_box.get_left(), buff=0.2, color=WHITE)\n text_in = Text('Vertex\\nAttributes', font_size=18).next_to(arrow_in, UP, buff=0.1)\n arrow_mid = Arrow(vs_box.get_right(), fs_box.get_left(), buff=0.2, color=YELLOW)\n text_mid = Text('Transformed\\nAttributes', font_size=18, color=YELLOW).next_to(arrow_mid, UP, buff=0.1)\n arrow_out = Arrow(fs_box.get_right(), RIGHT * 7.1, buff=0.2, color=WHITE)\n text_out = Text('Final\\nPixel Color', font_size=18).next_to(arrow_out, UP, buff=0.1)\n self.play(GrowArrow(arrow_in), FadeIn(text_in))\n self.play(Create(vs_box), Write(vs_title))\n for item in vs_list:\n self.play(FadeIn(item, shift=RIGHT * 0.3), run_time=0.7)\n else:\n pass\n self.play(GrowArrow(arrow_mid), FadeIn(text_mid))\n self.play(Create(fs_box), Write(fs_title))\n for item in fs_list:\n self.play(FadeIn(item, shift=RIGHT * 0.3), run_time=0.7)\n else:\n pass\n self.play(GrowArrow(arrow_out), FadeIn(text_out))\n flow_dot = Dot(color=RED, radius=0.08)\n self.play(FadeIn(flow_dot.move_to(arrow_in.get_start())))\n self.play(MoveAlongPath(flow_dot, Line(arrow_in.get_start(), arrow_in.get_end())), run_time=0.6)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.play(vs_box.animate.set_fill(BLUE, opacity=0.3), run_time=0.3)\n self.play(vs_box.animate.set_fill(BLUE, opacity=0), run_time=0.3)\n flow_dot.move_to(arrow_mid.get_start())\n self.play(FadeIn(flow_dot), run_time=0.2)\n self.play(MoveAlongPath(flow_dot, Line(arrow_mid.get_start(), arrow_mid.get_end())), run_time=0.8)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.play(fs_box.animate.set_fill(GREEN, opacity=0.3), run_time=0.3)\n self.play(fs_box.animate.set_fill(GREEN, opacity=0), run_time=0.3)\n flow_dot.move_to(arrow_out.get_start())\n self.play(FadeIn(flow_dot), run_time=0.2)\n self.play(MoveAlongPath(flow_dot, Line(arrow_out.get_start(), arrow_out.get_end())), run_time=0.6)\n self.play(FadeOut(flow_dot), run_time=0.2)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe animation begins by simultaneously fading in a **circle** and a **triangle** (positioned as in the original script). After a brief pause, the circle smoothly transforms into a **square** while the triangle morphs into a **pentagon**, demonstrating shape-shifting capabilities. As this transformation occurs, a **mathematical formula** (e.g., Euler’s formula, *V - E + F = 2*) appears below the shapes, explaining the topological relationship between vertices (*V*), edges (*E*), and faces (*F*). The shapes then rotate in opposite directions (the square clockwise, the pentagon counterclockwise) while a **dynamic counter** tracks the rotation angle in real time. Finally, the shapes merge into a single **hexagon**, which pulses with a color gradient before fading out, leaving only the formula on screen. Throughout the animation, **explanatory text** appears at key moments, guiding the viewer through the geometric transformations and their mathematical significance. \n\nThis enhanced version retains the original elements (circle and triangle) while adding shape morphing, mathematical context, rotational animation, real-time angle tracking, and explanatory text—making it both visually engaging and educational.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial objects\n circle = Circle(radius=1)\n triangle = Triangle()\n \n # Arrange them side-by-side for symmetry\n shapes_group = VGroup(circle, triangle).arrange(RIGHT)\n \n # Fade in the shapes\n self.play(FadeIn(shapes_group))\n self.wait(1)\n\n # Define target shapes\n square = Square(side_length=2)\n pentagon = RegularPolygon(n=5, radius=2)\n \n # Animate the transition from circle to square and triangle to pentagon\n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=2,\n rate_func=smooth\n )\n \n # Add mathematical formula\n math_text = MathTex(\"V - E + F = 2\")\n math_text.next_to(shapes_group, DOWN, buff=1.5)\n self.play(Write(math_text))\n\n # Rotate shapes in opposite directions\n square_anim = Rotate(square, angle=TAU, about_point=square.get_center(), run_time=8, rate_func=linear)\n pentagon_anim = Rotate(pentagon, angle=-TAU, about_point=pentagon.get_center(), run_time=8, rate_func=linear)\n\n # Track rotation angles\n angle_tracker_square = ValueTracker(0)\n angle_tracker_pentagon = ValueTracker(0)\n \n # Display real-time rotation angles\n display_angle_square = Text(f\"Angle: {angle_tracker_square.get_value():.2f} rad\", font_size=36).to_edge(DOWN)\n display_angle_pentagon = Text(f\"Angle: {angle_tracker_pentagon.get_value():.2f} rad\", font_size=36).to_edge(DOWN)\n display_angle_pentagon.shift(UP * 0.5)\n \n self.add(display_angle_square, display_angle_pentagon)\n \n def update_display_shape1(mob):\n mob.text_string = f\"Angle: {angle_tracker_square.get_value():.2f} rad\"\n \n def update_display_shape2(mob):\n mob.text_string = f\"Angle: {angle_tracker_pentagon.get_value():.2f} rad\"\n\n display_angle_square.add_updater(update_display_shape1)\n display_angle_pentagon.add_updater(update_display_shape2)\n\n self.add(angle_tracker_square, angle_tracker_pentagon)\n \n self.play(\n square_anim,\n pentagon_anim,\n rate_func=linear,\n run_time=7\n )\n\n # Merge shapes into hexagon\n hexagon = RegularPolygon(n=6, radius=2)\n hexagon.move_to(shape_center := shapes_group.get_center())\n\n self.play(\n Transform(VGroup(circle, triangle, square, pentagon), hexagon),\n run_time=2\n )\n self.remove(angle_tracker_square, angle_tracker_pentagon)\n self.wait()\n\n # Pulse hexagon with color gradient\n colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE]\n for i in range(len(colors)):\n hexagon.set_color(colors[i])\n self.play(hexagon.animate.scale(1.1), run_time=0.1)\n self.play(hexagon.animate.scale(1/1.1), run_time=0.1)\n \n self.wait(1)\n\n # Remove hexagon and show formula\n self.play(FadeOut(hexagon))\n self.wait(2)\n self.play(FadeOut(display_angle_square, display_angle_pentagon), Write(MathTex(\"\\\\text{Educational Animation}\", \"\\\\text{Demonstrating Shape Morphism}\", font_size=36)))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial shapes: Circle and Triangle\n circle = Circle(radius=1.5)\n triangle = Polygon([2, 0, 0], [1, 2, 0], [-1, 2, 0])\n\n # Animate the appearance of the shapes\n self.play(FadeIn(circle), FadeIn(triangle))\n \n # Pause briefly after appearance\n self.wait(1)\n\n # Define formulas for explanation\n vertex_formula = MathTex(\"V\", \"-\", \"E\", \"+\", \"F\", \"=\", \"2\")\n edge_formula = MathTex(\"\\\\text{Edges} \\\\rightarrow \\\\text{Triangle}\", \"\\\\rightarrow\", \"\\\\text{Pentagon}\")\n hex_formula = MathTex(\"6\", \"-\", \"5\", \"+\", \"2\", \"=\", \"3\")\n\n # Position math formulas below shapes\n vertex_formula.next_to(VGroup(circle, triangle), DOWN, buff=1)\n edge_formula.move_to(vertex_formula.get_center())\n hex_formula.move_to(vertex_formula.get_center())\n\n # Show V-E+F=2 initially\n self.play(Write(vertex_formula))\n\n # Morph the circle into a square and the triangle into a pentagon\n square = Square(side_length=3, fill_opacity=0.8, stroke_width=1)\n pentagon = RegularPolygon(n=5, radius=1.5, fill_opacity=0.8, stroke_width=1)\n\n self.play(\n TransformFromCopy(circle, square),\n TransformFromCopy(triangle, pentagon)\n )\n self.wait(1)\n\n # Rotate squares and pentagons in opposite directions\n # Add a ValueTracker to track rotation angles dynamically\n square_tracker = ValueTracker(0)\n pentagon_tracker = ValueTracker(0)\n\n square_addition = MathTex(\"+\", r\"\\frac{\\pi}{2}\").next_to(square, RIGHT)\n pent_addition = MathTex(\"+\", r\"\\frac{\\pi}{2}\").next_to(pentagon, LEFT)\n\n def update_square(mob):\n rot_angle = square_tracker.get_value()\n mob.become(Square(side_length=3, fill_opacity=0.8, stroke_width=1))\n mob.rotate(-rot_angle, about_point=mob.get_center())\n return mob\n\n def update_pentagon(mob):\n rot_angle = pentagon_tracker.get_value()\n mob.become(RegularPolygon(n=5, radius=1.5, fill_opacity=0.8, stroke_width=1))\n mob.rotate(rot_angle, about_point=mob.get_center())\n return mob\n \n def update_rotations():\n square_tracker.increment_by(0.05)\n pentagon_tracker.increment_by(-0.05)\n \n if abs(square_tracker.get_value()) > TAU:\n square_tracker.set_value(0)\n if abs(pentagon_tracker.get_value()) > TAU:\n pentagon_tracker.set_value(0)\n\n square_group = VGroup(square, square_addition)\n pent_group = VGroup(pentagon, pent_addition)\n rotations = AlwaysRedraw(update_rotations)\n\n self.add_updater(rotations)\n self.play(\n UpdateFromFunc(square_group, update_square),\n UpdateFromFunc(pent_group, update_pentagon)\n )\n\n # Track and display rotation angles\n angle_text = Text(\"Angle Tracking\", font_size=24).to_edge(DOWN)\n self.play(Write(angle_text))\n \n # Pulse effect for Hexagon\n hexagon = RegularPolygon(n=6, side_length=3, fill_opacity=0.8, stroke_width=2)\n hexagon_set = VGroup(hexagon)\n \n # Merge shapes into Hexagon\n self.play(\n Transform(square_group, hexagon_set),\n Transform(pent_group, hexagon_set),\n Write(hex_formula)\n )\n self.remove(updates=[rotations])\n \n # Apply pulse animation with color gradients\n colors = [\"red\", \"#FFA726\", \"green\"]\n for i in range(5):\n hexagon.set_fill(colors[i % len(colors)], opacity=i/(i+1))\n self.wait(0.1)\n \n # Final fade out sequence\n self.play(\n FadeOut(hexagon),\n FadeOut(vertex_formula),\n FadeOut(edge_formula),\n FadeOut(hex_formula),\n FadeOut(angle_text)\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an animation that walks through the process of solving a double integral in polar coordinates. Start by displaying the double integral symbolically on the screen. Then add a text explanation that we will first integrate with respect to the radius (r). Show the result of that inner integration and display the intermediate integral with respect to the angle (theta). Replace the explanation text with one that says we will now integrate with respect to theta. Complete the process by computing the final value and make sure each step transitions smoothly to the next, so it's easy to follow. Can you also include brief pauses between steps to allow viewers to understand each phase of the integration?", "chosen": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n \"\"\"\n Animation demonstrating the step-by-step solution of a double integral \n in polar coordinates: Integral from 0 to 2pi and 0 to 1 of (r dr dtheta).\n This represents the area of a unit circle.\n \"\"\"\n def construct(self):\n # --- Configuration & Colors ---\n COLOR_R = YELLOW\n COLOR_THETA = BLUE\n COLOR_RESULT = GREEN\n\n # 1. Initial Display\n # Define components for the initial integral to allow smooth part-wise transformations\n left_1 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_1 = MathTex(r\"\\int_{0}^{1} r \\,dr\")\n right_1 = MathTex(r\"\\,d\\theta\")\n eq_1 = VGroup(left_1, mid_1, right_1).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(Write(eq_1))\n self.wait(1)\n\n # 2. First Integration Step (with respect to r)\n # Display explanation text\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$ first\", \n color=COLOR_R, \n font_size=36\n ).to_edge(UP)\n self.play(Write(step1_text))\n self.wait(1)\n\n # Animate calculation of the inner integration (antiderivative)\n left_2 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_2 = MathTex(r\"\\left[ \\frac{1}{2}r^2 \\right]_{0}^{1}\")\n right_2 = MathTex(r\"\\,d\\theta\")\n eq_2 = VGroup(left_2, mid_2, right_2).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(ReplacementTransform(eq_1, eq_2))\n self.wait(1)\n\n # Display resulting intermediate integral (evaluated inner bounds)\n left_3 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_3 = MathTex(r\"\\frac{1}{2}\")\n right_3 = MathTex(r\"\\,d\\theta\")\n eq_3 = VGroup(left_3, mid_3, right_3).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(ReplacementTransform(eq_2, eq_3))\n self.wait(1)\n\n # 3. Second Integration Step (with respect to theta)\n # Replace explanation text\n step2_text = Tex(\n \"Step 2: Now integrate with respect to $\\\\theta$\", \n color=COLOR_THETA, \n font_size=36\n ).to_edge(UP)\n self.play(ReplacementTransform(step1_text, step2_text))\n self.wait(1)\n\n # Animate calculation of the final integration\n # The integral symbols are absorbed into the evaluation brackets\n eq_4 = MathTex(r\"\\left[ \\frac{1}{2}\\theta \\right]_{0}^{2\\pi}\").scale(1.4)\n \n self.play(ReplacementTransform(eq_3, eq_4))\n self.wait(1)\n\n # 4. Final Result\n # Compute and display the final numerical/symbolic value\n final_result = MathTex(r\"\\pi\", color=COLOR_RESULT).scale(2.0)\n \n self.play(ReplacementTransform(eq_4, final_result))\n self.wait(1)\n\n # Box the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n\n# To run this code, use:\n# manim -pql polar_integral.py PolarDoubleIntegral\n```", "rejected": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n \"\"\"\n Animation demonstrating the step-by-step solution of a double integral \n in polar coordinates: Integral from 0 to 2pi and 0 to 1 of (r dr dtheta).\n This represents the area of a unit circle.\n \"\"\"\n def construct(self):\n # --- Configuration & Colors ---\n COLOR_R = YELLOW\n COLOR_THETA = BLUE\n COLOR_RESULT = GREEN\n\n # 1. Initial Display\n # Define components for the initial integral to allow smooth part-wise transformations\n left_1 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_1 = MathTex(r\"\\int_{0}^{1} r \\,dr\")\n right_1 = MathTex(r\"\\,d\\theta\")\n eq_1 = VGroup(left_1, mid_1, right_1).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(Write(eq_1))\n self.wait(1)\n\n # 2. First Integration Step (with respect to r)\n # Display explanation text\n step1_text = Tex(\n \"Step 1: Integrate with respect to $r$ first\", \n color=COLOR_R, \n font_size=36\n ).to_edge(UP)\n self.play(Write(step1_text))\n self.wait(1)\n\n # Animate calculation of the inner integration (antiderivative)\n left_2 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_2 = MathTex(r\"\\left[ \\frac{1}{2}r^2 \\right]_{0}^{1}\")\n right_2 = MathTex(r\"\\,d\\theta\")\n eq_2 = VGroup(left_2, mid_2, right_2).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(ReplacementTransform(target_position=ORIGIN, eq_1, eq_2))\n self.wait(1)\n\n # Display resulting intermediate integral (evaluated inner bounds)\n left_3 = MathTex(r\"\\int_{0}^{2\\pi}\")\n mid_3 = MathTex(r\"\\frac{1}{2}\")\n right_3 = MathTex(r\"\\,d\\theta\")\n eq_3 = VGroup(left_3, mid_3, right_3).arrange(RIGHT, buff=0.15).scale(1.4)\n \n self.play(ReplacementTransform(eq_2, eq_3))\n self.wait(1)\n\n # 3. Second Integration Step (with respect to theta)\n # Replace explanation text\n step2_text = Tex(\n \"Step 2: Now integrate with respect to $\\\\theta$\", \n color=COLOR_THETA, \n font_size=36\n ).to_edge(UP)\n self.play(ReplacementTransform(step1_text, step2_text))\n self.wait(1)\n\n # Animate calculation of the final integration\n # The integral symbols are absorbed into the evaluation brackets\n eq_4 = MathTex(r\"\\left[ \\frac{1}{2}\\theta \\right]_{0}^{2\\pi}\").scale(1.4)\n \n self.play(ReplacementTransform(eq_3, eq_4))\n self.wait(1)\n\n # 4. Final Result\n # Compute and display the final numerical/symbolic value\n final_result = MathTex(r\"\\pi\", color=COLOR_RESULT).scale(2.0)\n \n self.play(ReplacementTransform(eq_4, final_result))\n self.wait(1)\n\n # Box the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n\n# To run this code, use:\n# manim -pql polar_integral.py PolarDoubleIntegral\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # 1. Setup Axes and Plot\n # Shift axes to the left to make room for equations on the right\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=4,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n axes.add_coordinates()\n\n # Plot the function y = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.2], color=BLUE)\n curve_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 2. Shade the Area Under the Curve (x=0 to x=2)\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.5)\n\n # 3. Prepare the Mathematical Steps\n # Step 1: The Definite Integral\n step1 = MathTex(r\"\\int_{0}^{2}\", \"x^2\", \"\\\\,dx\", font_size=40)\n \n # Step 2: Antiderivative\n step2 = MathTex(r\"=\", r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=40)\n \n # Step 3: Substitution of limits\n step3 = MathTex(r\"=\", r\"\\frac{2^3}{3}\", \"-\", r\"\\frac{0^3}{3}\", font_size=40)\n \n # Step 4: Final Numerical Result (Highlighted)\n step4 = MathTex(r\"=\", r\"\\frac{8}{3}\", r\"\\approx\", r\"2.67\", font_size=40, color=YELLOW)\n\n # Arrange steps vertically on the right side of the screen\n calculation_group = VGroup(step1, step2, step3, step4).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n ).to_edge(RIGHT, buff=1).shift(UP * 1.5)\n\n # --- Animation Sequence ---\n\n # Draw the coordinate system and function curve\n self.play(Create(axes), Create(graph), Write(curve_label))\n self.wait(0.5)\n\n # Highlight the area representing the integral\n self.play(FadeIn(area))\n self.wait(1)\n\n # Display the integral expression\n self.play(Write(step1))\n self.wait(0.5)\n\n # Demonstrate step-by-step calculation\n self.play(Write(step2))\n self.wait(0.5)\n \n self.play(Write(step3))\n self.wait(0.5)\n\n # Reveal the final result\n self.play(Write(step4))\n self.wait(1)\n \n # Briefly emphasize the result before clearing\n self.play(Indicate(step4))\n self.wait(1)\n\n # 4. Cleanup: Animate clearing all elements from the screen\n self.play(FadeOut(*self.mobjects), run_time=1.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # 1. Setup Axes and Plot\n # Shift axes to the left to make room for equations on the right\n axes = Axes(font_size=24, \n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=4,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n axes.add_coordinates()\n\n # Plot the function y = x^2\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.2], color=BLUE)\n curve_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 2. Shade the Area Under the Curve (x=0 to x=2)\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.5)\n\n # 3. Prepare the Mathematical Steps\n # Step 1: The Definite Integral\n step1 = MathTex(r\"\\int_{0}^{2}\", \"x^2\", \"\\\\,dx\", font_size=40)\n \n # Step 2: Antiderivative\n step2 = MathTex(r\"=\", r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=40)\n \n # Step 3: Substitution of limits\n step3 = MathTex(r\"=\", r\"\\frac{2^3}{3}\", \"-\", r\"\\frac{0^3}{3}\", font_size=40)\n \n # Step 4: Final Numerical Result (Highlighted)\n step4 = MathTex(r\"=\", r\"\\frac{8}{3}\", r\"\\approx\", r\"2.67\", font_size=40, color=YELLOW)\n\n # Arrange steps vertically on the right side of the screen\n calculation_group = VGroup(step1, step2, step3, step4).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n ).to_edge(RIGHT, buff=1).shift(UP * 1.5)\n\n # --- Animation Sequence ---\n\n # Draw the coordinate system and function curve\n self.play(Create(axes), Create(graph), Write(curve_label))\n self.wait(0.5)\n\n # Highlight the area representing the integral\n self.play(FadeIn(area))\n self.wait(1)\n\n # Display the integral expression\n self.play(Write(step1))\n self.wait(0.5)\n\n # Demonstrate step-by-step calculation\n self.play(Write(step2))\n self.wait(0.5)\n \n self.play(Write(step3))\n self.wait(0.5)\n\n # Reveal the final result\n self.play(Write(step4))\n self.wait(1)\n \n # Briefly emphasize the result before clearing\n self.play(Indicate(step4))\n self.wait(1)\n\n # 4. Cleanup: Animate clearing all elements from the screen\n self.play(FadeOut(*self.mobjects), run_time=1.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that demonstrates how to evaluate the definite integral of x squared from 0 to 2, including the step-by-step process from stating the problem to showing the calculation of the indefinite integral, applying the bounds, evaluating at the bounds, and then presenting the final solution? Also, can you include a brief pause after each step so that the viewer has time to understand what's happening?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # Step 1: State the Problem\n problem_label = Text(\"Problem: Evaluate the definite integral\", font_size=36).to_edge(UP)\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\")\n \n self.play(Write(problem_label), Write(problem))\n self.wait(2)\n\n # Step 2: Find the Indefinite Integral\n step1_label = Text(\"Step 1: Find the antiderivative\", font_size=36, color=BLUE).to_edge(UP)\n antiderivative = MathTex(r\"\\int x^2 \\, dx = \\frac{x^3}{3}\").move_to(problem)\n \n self.play(ReplacementTransform(problem_label, step1_label))\n self.play(ReplacementTransform(problem, antiderivative))\n self.wait(2)\n\n # Step 3: Apply Bounds\n step2_label = Text(\"Step 2: Apply the bounds\", font_size=36, color=BLUE).to_edge(UP)\n bounds = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").move_to(antiderivative)\n \n self.play(ReplacementTransform(step1_label, step2_label))\n self.play(ReplacementTransform(antiderivative, bounds))\n self.wait(2)\n\n # Step 4: Evaluate\n step3_label = Text(\"Step 3: Evaluate at the bounds\", font_size=36, color=BLUE).to_edge(UP)\n substitution = MathTex(r\"\\frac{2^3}{3} - \\frac{0^3}{3}\").move_to(bounds)\n arithmetic = MathTex(r\"\\frac{8}{3} - 0\").move_to(substitution)\n \n self.play(ReplacementTransform(step2_label, step3_label))\n self.play(ReplacementTransform(bounds, substitution))\n self.wait(1)\n self.play(ReplacementTransform(substitution, arithmetic))\n self.wait(2)\n\n # Step 5: Present Solution\n final_label = Text(\"Final Result\", font_size=36, color=YELLOW).to_edge(UP)\n solution = MathTex(r\"\\frac{8}{3}\").move_to(arithmetic)\n solution_box = SurroundingRectangle(solution, color=YELLOW, buff=0.2)\n \n self.play(ReplacementTransform(step3_label, final_label))\n self.play(ReplacementTransform(arithmetic, solution))\n self.play(solution.animate.scale(1.5).set_color(YELLOW), Create(solution_box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # Step 1: State the Problem\n problem_label = Text(\"Problem: Evaluate the definite integral\", font_size=36).to_edge(UP)\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\")\n \n self.play(Write(problem_label), Write(problem))\n self.wait(2)\n\n # Step 2: Find the Indefinite Integral\n step1_label = Text(\"Step 1: Find the antiderivative\", font_size=36, color=BLUE).to_edge(UP)\n antiderivative = MathTex(r\"\\int x^2 \\, dx = \\frac{x^3}{3}\").move_to(problem)\n \n self.play(ReplacementTransform(problem_label, step1_label))\n self.play(ReplacementTransform(problem, antiderivative))\n self.wait(2)\n\n # Step 3: Apply Bounds\n step2_label = Text(\"Step 2: Apply the bounds\", font_size=36, color=BLUE).to_edge(UP)\n bounds = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").move_to(antiderivative)\n \n self.play(ReplacementTransform(step1_label, step2_label))\n self.play(ReplacementTransform(antiderivative, bounds))\n self.wait(2)\n\n # Step 4: Evaluate\n step3_label = Text(\"Step 3: Evaluate at the bounds\", font_size=36, color=BLUE).to_edge(UP)\n substitution = MathTex(r\"\\frac{2^3}{3} - \\frac{0^3}{3}\").move_to(bounds)\n arithmetic = MathTex(r\"\\frac{8}{3} - 0\" + \" = x\").move_to(substitution)\n \n self.play(ReplacementTransform(step2_label, step3_label))\n self.play(ReplacementTransform(bounds, substitution))\n self.wait(1)\n self.play(ReplacementTransform(substitution, arithmetic))\n self.wait(2)\n\n # Step 5: Present Solution\n final_label = Text(\"Final Result\", font_size=36, color=YELLOW).to_edge(UP)\n solution = MathTex(r\"\\frac{8}{3}\").move_to(arithmetic)\n solution_box = SurroundingRectangle(solution, color=YELLOW, buff=0.2)\n \n self.play(ReplacementTransform(step3_label, final_label))\n self.play(ReplacementTransform(arithmetic, solution))\n self.play(solution.animate.scale(1.5).set_color(YELLOW), Create(solution_box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Next Steps\n\n#### Clustering: How to Discover the Intrinsic Cluster Structure in the Reduced-Dimension Space\n- Dimensionality reduction is often a prerequisite step for clustering and can significantly enhance the performance of algorithms like K-Means.\n\n\nContextual location of this section (from highest to current level):\n# Machine Learning Course - Outline for the Fourth Class (Dimensionality Reduction, 90 minutes)\n## Summary and Comparison (10 minutes)\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClusteringScene(Scene):\n\n def construct(self):\n title = Text(\"Clustering\", font_size=60).to_edge(UP)\n subtitle = Text(\"How to discover intrinsic cluster structures\\nin reduced-dimension space\", font_size=36).next_to(title, DOWN, buff=0.5).set_color(YELLOW)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n context_text = Text(\"\\nMachine Learning Course > Class 4 | Dimensionality Reduction \\nSummary and Comparison :: Dimensional Space vs. High-Dimensional Spaces\", font_size=22, color=GRAY).to_corner(DL, buff=0.5)\n self.play(Write(context_text))\n \n # Step 2: Problem Statement\n problem_title = Text(\"Problem: Finding clusters in high-dimensional data\", font_size=32, color=RED)\n problem_desc = Text(\"- Dimensionality reduction helps visualize and analyze complex datasets\", font_size=28)\n problem_group = VGroup(problem_title, problem_desc).arrange(DOWN, aligned_edge=LEFT).shift(RIGHT * 0.5 + UP * 0.5)\n self.play(Write(problem_group))\n\n # Create a simple scatter plot representing high dimensional data points\n dot_radius = 0.15\n dots_high_dim = VGroup()\n colors = [BLUE, GREEN, ORANGE]\n for i in range(len(colors)):\n group_dots = VGroup()\n for _ in range(10): # Number of dots per cluster\n x = np.random.uniform(-2, 2)\n y = np.random.uniform(-2, 2)\n point = Dot(radius=dot_radius, color=colors[i]).move_to([x, y, 0])\n group_dots.add(point)\n dots_high_dim.add(group_dots)\n\n low_dot_radius = 0.15\n dots_low_dim = VGroup()\n for i in range(len(colors)):\n group_dots = VGroup()\n for j in range(3): # Simplified lower dimension representation\n angle = j * PI / 3\n radius = 1.5\n x = radius * np.cos(angle) + dots_high_dim[i][j].get_center()[0]\n y = radius * np.sin(angle) + dots_high_dim[i][j].get_center()[1]\n point = Dot(radius=low_dot_radius, color=colors[i], fill_opacity=0.7).move_to(np.array([x, y, 0]))\n group_dots.add(point)\n dots_low_dim.add(group_dots)\n\n # Step 3: Solution Visualization\n solution_title = Text(\"Solution: Apply Dimensionality Reduction then Clustering\", font_size=32, color=GREEN).to_edge(DOWN)\n self.play(Write(solution_title))\n self.play(Create(dots_high_dim))\n self.wait(1)\n self.play(Transform(dots_high_dim, dots_low_dim))\n self.wait(1)\n\n # Step 4: Conclusion\n conclusion = Text(\"Key Takeaway:\\nDimensionality reduction enhances clustering by simplifying high-dimensional spaces.\", font_size=28, color=YELLOW)\n conclusion_box = SurroundingRectangle(conclusion, corner_radius=0.2, color=WHITE)\n conclusion_group = VGroup(conclusion_box, conclusion).to_edge(DOWN, buff=1.0)\n self.play(Write(conclusion_box), Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClusteringScene(Scene):\n\n def construct(self):\n title = Text('Clustering: Revealing Hidden Patterns', font_size=36).to_edge(UP)\n subtitle = Text(\"Discover intrinsic cluster structures\", color=BLUE_C).next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN * 0.5))\n self.wait(2)\n\n # Create data points\n dots = VGroup()\n colors = [RED, GREEN, BLUE]\n labels = ['Cluster A', 'Cluster B', 'Cluster C']\n clusters = [[-2, 0], [2, 0]], [[-1, 1], [-1, -1]], [[3, 1], [3, -1]]\n\n for i in range(len(clusters)):\n for j in range(2):\n dot = Dot(radius=0.08, color=colors[i]).shift(np.array(clusters[i][j]))\n label = MathTex(labels[i]).scale(0.7).next_to(dot, UP, buff=0.15)\n dots.add(VGroup(dot, label))\n\n data_group = VGroup(dots).arrange(RIGHT, buff=1)\n data_label = Text(\"Data Points\", font_size=24, color=GRAY).next_to(data_group, DOWN, buff=0.3)\n\n # Show data visualization\n self.play(Create(dots), Write(data_label), run_time=3)\n self.wait(1)\n\n # Show reduced dimension space\n axes = Axes(\n x_range=[-3, 5],\n y_range=[-2, 3],\n x_length=4,\n y_length=3\n ).shift(DOWN * 1)\n\n reduced_dots = VGroup()\n axes_labels = []\n\n for i in range(len(clusters)):\n for j in range(2):\n new_point = axes.c2p(clusters[i][j][0] + 2, clusters[i][j][1])\n dot = Dot(point=new_point, radius=0.1, color=colors[i])\n label = MathTex(f\"P_{i*2+j}\").scale(0.7).move_to(new_point)\n \n if len(reduced_dots) == 0:\n axes_labels.append(Text(f\"Reduced-\\nSpace\", color=YELLOW).next_to(axes, UP, buff=0.3))\n \n reduced_dots.add(VGroup(dot, label))\n\n reduced_label = Text(\"Revised Coordinates\", font_size=24, color=GREEN).next_to(reduced_dots, UP, buff=0.3)\n\n self.play(TransformFromCopy(data_group, reduced_dots), FadeIn(axes), FadeIn(reduced_label), *[FadeIn(label) for label in axes_labels], run_time=3)\n \n # Highlight clusters\n groups = []\n for i in range(3):\n group = VGroup(*[dot[0] for dot in reduced_dots[i*2:i*2+2]])\n groups.append(group)\n\n for g in groups:\n box = SurroundingRectangle(g, color=WHITE, stroke_width=2, buff=0.1)\n \n self.play(Create(box), Indicate(g, color=colors[i], scale_factor=1.1))\n self.wait(0.5)\n\n conclusion_text = Text(\"By reducing dimensions, we reveal hidden patterns.\", font_size=32).to_edge(DOWN)\n self.play(Write(conclusion_text), run_time=2)\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n # Define the quadratic function: f(x) = (3/8)x^2\n # This coefficient is chosen so the area from 0 to 4 is exactly 8,\n # avoiding visual clutter from complex fractions during the solution reveal.\n func = lambda x: (3/8) * x**2\n \n # Color Palette\n axis_color = LIGHT_GREY\n curve_color = BLUE\n area_color = BLUE\n text_color = WHITE\n\n # --- Step 1: Initial Setup ---\n # Create axes and plot the curve\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 10, 2],\n axis_config={\"color\": axis_color, \"include_tip\": True},\n )\n \n graph = axes.plot(func, x_range=[0, 4], color=curve_color)\n \n # Equation Label positioned near the graph\n equation_label = MathTex(r\"f(x) = \\frac{3}{8}x^2\", font_size=36).to_corner(UR)\n \n # Animate initial elements\n self.play(Create(axes), Create(graph), Write(equation_label), run_time=2)\n self.wait(2) # Pause for viewer to recognize the function\n\n # --- Step 2: Shading the Area ---\n # Shade the region under the curve from x=0 to x=4\n area = axes.get_area(graph, x_range=[0, 4], color=area_color, opacity=0.4)\n \n self.play(FadeIn(area), run_time=1.5)\n self.wait(2) # Emphasize the bounded region\n\n # --- Step 3: Conceptual Explanation ---\n # Display text explaining the definite integral concept\n concept_text = Text(\n \"The shaded region represents the\\ndefinite integral from 0 to 4.\",\n font_size=28,\n color=text_color\n ).to_edge(DOWN)\n \n self.play(Write(concept_text), run_time=2)\n self.wait(3) # Allow time to read the conceptual link\n self.play(FadeOut(concept_text), run_time=1)\n\n # --- Step 4: Formula Transition ---\n # Transform the equation label into the integral formula\n integral_label = MathTex(r\"\\int_{0}^{4} \\frac{3}{8}x^2 \\, dx\", font_size=36)\n integral_label.move_to(equation_label.get_center())\n \n # ReplacementTransform visually \"morphs\" the function equation into the integral notation,\n # illustrating that the integral is an operation performed on that specific function.\n self.play(ReplacementTransform(equation_label, integral_label), run_time=2)\n self.wait(2) # Pause to let the new notation sink in\n\n # --- Step 5: Solution Reveal ---\n # Calculate and display the exact numerical value\n # Integral of (3/8)x^2 is (1/8)x^3. Evaluated 0 to 4 -> (1/8)*64 = 8.\n solution_label = MathTex(\"= 8\", font_size=48, color=YELLOW)\n solution_label.next_to(integral_label, RIGHT)\n \n self.play(Write(solution_label), run_time=1.5)\n self.wait(2) # Emphasize the result\n\n # --- Step 6: Final Focus ---\n # Clear all visual elements except the final solution\n # Group everything except the solution for fading out\n elements_to_remove = VGroup(axes, graph, area, integral_label)\n \n self.play(\n FadeOut(elements_to_remove, shift=UP),\n solution_label.animate.move_to(ORIGIN).scale(1.5).set_color(WHITE),\n run_time=2\n )\n self.wait(3) # Hold on final result for emphasis\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n # Define the quadratic function: f(x) = (3/8)x^2\n # This coefficient is chosen so the area from 0 to 4 is exactly 8,\n # avoiding visual clutter from complex fractions during the solution reveal.\n func = lambda x: (3/8) * x**2\n \n # Color Palette\n axis_color = LIGHT_GREY\n curve_color = BLUE\n area_color = BLUE\n text_color = WHITE\n\n # --- Step 1: Initial Setup ---\n # Create axes and plot the curve\n axes = Axes(label_font_size=24, \n x_range=[0, 5, 1],\n y_range=[0, 10, 2],\n axis_config={\"color\": axis_color, \"include_tip\": True},\n )\n \n graph = axes.plot(func, x_range=[0, 4], color=curve_color)\n \n # Equation Label positioned near the graph\n equation_label = MathTex(r\"f(x) = \\frac{3}{8}x^2\", font_size=36).to_corner(UR)\n \n # Animate initial elements\n self.play(Create(axes), Create(graph), Write(equation_label), run_time=2)\n self.wait(2) # Pause for viewer to recognize the function\n\n # --- Step 2: Shading the Area ---\n # Shade the region under the curve from x=0 to x=4\n area = axes.get_area(graph, x_range=[0, 4], color=area_color, opacity=0.4)\n \n self.play(FadeIn(area), run_time=1.5)\n self.wait(2) # Emphasize the bounded region\n\n # --- Step 3: Conceptual Explanation ---\n # Display text explaining the definite integral concept\n concept_text = Text(\n \"The shaded region represents the\\ndefinite integral from 0 to 4.\",\n font_size=28,\n color=text_color\n ).to_edge(DOWN)\n \n self.play(Write(concept_text), run_time=2)\n self.wait(3) # Allow time to read the conceptual link\n self.play(FadeOut(concept_text), run_time=1)\n\n # --- Step 4: Formula Transition ---\n # Transform the equation label into the integral formula\n integral_label = MathTex(r\"\\int_{0}^{4} \\frac{3}{8}x^2 \\, dx\", font_size=36)\n integral_label.move_to(equation_label.get_center())\n \n # ReplacementTransform visually \"morphs\" the function equation into the integral notation,\n # illustrating that the integral is an operation performed on that specific function.\n self.play(ReplacementTransform(equation_label, integral_label), run_time=2)\n self.wait(2) # Pause to let the new notation sink in\n\n # --- Step 5: Solution Reveal ---\n # Calculate and display the exact numerical value\n # Integral of (3/8)x^2 is (1/8)x^3. Evaluated 0 to 4 -> (1/8)*64 = 8.\n solution_label = MathTex(\"= 8\", font_size=48, color=YELLOW)\n solution_label.next_to(integral_label, RIGHT)\n \n self.play(Write(solution_label), run_time=1.5)\n self.wait(2) # Emphasize the result\n\n # --- Step 6: Final Focus ---\n # Clear all visual elements except the final solution\n # Group everything except the solution for fading out\n elements_to_remove = VGroup(axes, graph, area, integral_label)\n \n self.play(\n FadeOut(elements_to_remove, shift=UP),\n solution_label.animate.move_to(ORIGIN).scale(1.5).set_color(WHITE),\n run_time=2\n )\n self.wait(3) # Hold on final result for emphasis\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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:\n\nThe animation begins by transforming the existing text into the word \"GrowArrow\" positioned at the top of the screen, just as in the original. Then, an arrow grows smoothly from nothing, emphasizing the `GrowArrow` effect. However, the enhanced version introduces a labeled coordinate system in the background to contextualize the arrow's direction, along with a floating text box that explains, \"The arrow represents a vector in 2D space.\" Simultaneously, the Pythagorean theorem formula \\( \\|\\vec{v}\\| = \\sqrt{x^2 + y^2} \\) fades in below the arrow, dynamically updating its values as the arrow lengthens. After the arrow reaches full size, it transforms into a dashed line to demonstrate its path, and the original arrow is removed. Finally, the formula and explanatory text dissolve away, leaving only the transformed dashed line as a visual reminder of the arrow's trajectory. This version adds educational depth and visual polish while preserving the original's simplicity.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedGrowArrow(Scene):\n def construct(self):\n # Create and transform text\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```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedGrowArrow(Scene):\n def construct(self):\n # Create and transform text\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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation using ManimCE that visualizes a simple convolutional neural network with alternating convolutional layers and pooling layers? The network should start with a convolutional layer that has 6 feature maps and a 3x3 kernel, then a pooling layer, followed by another convolutional layer with 16 feature maps and a 3x3 kernel, and ending with a final pooling layer. The animation should show the construction of this neural network.", "chosen": "```python\nfrom manim import *\n\nclass CNNConstruction(Scene):\n def construct(self):\n # Title\n title = Text(\"Convolutional Neural Network Architecture\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n def create_feature_volume(num_maps, square_size, color, stack_offset=0.04):\n volume = VGroup()\n if num_maps > 8:\n # Arrange 16 maps in a 4x4 grid for visual clarity\n cols = 4\n grid = VGroup()\n for i in range(num_maps):\n square = Square(side_length=square_size, fill_color=color, fill_opacity=0.5, stroke_width=1)\n r = i // cols\n c = i % cols\n square.move_to([c * (square_size + 0.05), -r * (square_size + 0.05), 0])\n grid.add(square)\n grid.center()\n shadow = Square(side_length=square_size * cols + 0.2, fill_color=BLACK, fill_opacity=0.3, stroke_width=0)\n shadow.move_to(grid.get_center() + UP * 0.05 + RIGHT * 0.05)\n volume.add(shadow, grid)\n else:\n # Stack maps with a 3D offset\n for i in range(num_maps):\n square = Square(side_length=square_size, fill_color=color, fill_opacity=0.5, stroke_width=1)\n square.shift(i * stack_offset * UP + i * stack_offset * RIGHT)\n volume.add(square)\n volume.center()\n return volume\n\n def create_kernel(size, color):\n kernel = VGroup()\n single_size = size / 3\n for r in range(3):\n for c in range(3):\n sq = Square(side_length=single_size, stroke_color=color, stroke_width=2, fill_opacity=0)\n sq.move_to([(c - 1) * single_size, (1 - r) * single_size, 0])\n kernel.add(sq)\n return kernel\n\n # Layer configurations\n input_vol = create_feature_volume(1, 1.6, GREY)\n conv1_vol = create_feature_volume(6, 1.4, BLUE)\n pool1_vol = create_feature_volume(6, 0.8, GREEN)\n conv2_vol = create_feature_volume(16, 0.35, BLUE)\n pool2_vol = create_feature_volume(16, 0.2, GREEN)\n\n layers = [input_vol, conv1_vol, pool1_vol, conv2_vol, pool2_vol]\n labels_text = [\n \"Input\\n32x32x1\",\n \"Conv1\\n6 Maps, 3x3\\n30x30x6\",\n \"Pool1\\n15x15x6\",\n \"Conv2\\n16 Maps, 3x3\\n13x13x16\",\n \"Pool2\\n6x6x16\"\n ]\n \n labels = VGroup()\n for text in labels_text:\n labels.add(Text(text, font_size=18, line_spacing=1.1))\n\n # Positioning\n start_x = -5.5\n spacing = 2.5\n for i, layer in enumerate(layers):\n layer.move_to([start_x + i * spacing, 0.5, 0])\n labels[i].next_to(layer, DOWN, buff=0.4)\n\n # 1. Animate Input\n self.play(FadeIn(input_vol), Write(labels[0]))\n self.wait(0.5)\n\n # 2. Animate Conv1 with sliding kernel\n self.play(input_vol.animate.shift(LEFT * 0.5), labels[0].animate.shift(LEFT * 0.5))\n \n kernel1 = create_kernel(0.6, RED)\n kernel1.move_to(input_vol.get_center())\n kernel1_label = Text(\"3x3 Kernel\", font_size=16, color=RED).next_to(kernel1, UP, buff=0.1)\n \n self.play(FadeIn(kernel1), Write(kernel1_label))\n self.play(kernel1.animate.shift(RIGHT * 0.4 + UP * 0.4), run_time=0.5)\n self.play(kernel1.animate.shift(DOWN * 0.4), run_time=0.3)\n self.play(kernel1.animate.move_to(input_vol.get_center()), run_time=0.3)\n\n arrow1 = Arrow(input_vol.get_right(), conv1_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow1), FadeOut(kernel1), FadeOut(kernel1_label))\n self.play(GrowFromCenter(conv1_vol), Write(labels[1]))\n self.wait(0.5)\n\n # 3. Animate Pool1\n arrow2 = Arrow(conv1_vol.get_right(), pool1_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow2))\n self.play(Transform(conv1_vol.copy(), pool1_vol), Write(labels[2]))\n self.add(pool1_vol) # Ensure final state is present\n self.wait(0.5)\n\n # 4. Animate Conv2 with sliding kernel\n kernel2 = create_kernel(0.3, YELLOW)\n kernel2.move_to(pool1_vol.get_center())\n kernel2_label = Text(\"3x3 Kernel\", font_size=16, color=YELLOW).next_to(kernel2, UP, buff=0.1)\n \n self.play(FadeIn(kernel2), Write(kernel2_label))\n self.play(kernel2.animate.shift(RIGHT * 0.2 + UP * 0.2), run_time=0.4)\n self.play(kernel2.animate.move_to(pool1_vol.get_center()), run_time=0.3)\n\n arrow3 = Arrow(pool1_vol.get_right(), conv2_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow3), FadeOut(kernel2), FadeOut(kernel2_label))\n self.play(GrowFromCenter(conv2_vol), Write(labels[3]))\n self.wait(0.5)\n\n # 5. Animate Pool2\n arrow4 = Arrow(conv2_vol.get_right(), pool2_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow4))\n self.play(Transform(conv2_vol.copy(), pool2_vol), Write(labels[4]))\n self.add(pool2_vol)\n self.wait(1)\n\n # Final Highlight\n all_elements = VGroup(input_vol, conv1_vol, pool1_vol, conv2_vol, pool2_vol, *labels)\n summary_box = SurroundingRectangle(all_elements, color=YELLOW, buff=0.5)\n summary_text = Text(\"CNN Construction Complete\", font_size=28, color=YELLOW).to_edge(DOWN)\n \n self.play(Create(summary_box), Write(summary_text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CNNConstruction(Scene):\n def construct(self):\n # Title\n title = Text(\"Convolutional Neural Network Architecture\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n def create_feature_volume(num_maps, square_size, color, stack_offset=0.04):\n volume = VGroup()\n if num_maps > 8:\n # Arrange 16 maps in a 4x4 grid for visual clarity\n cols = 4\n grid = VGroup()\n for i in range(num_maps):\n square = Square(side_length=square_size, fill_color=color, fill_opacity=0.5, stroke_width=1)\n r = i // cols\n c = i % cols\n square.move_to([c * (square_size + 0.05), -r * (square_size + 0.05), 0])\n grid.add(square)\n grid.center()\n shadow = Square(side_length=square_size * cols + 0.2, fill_color=BLACK, fill_opacity=0.3, stroke_width=0)\n shadow.move_to(grid.get_center() + UP * 0.05 + RIGHT * 0.05)\n volume.add(shadow, grid)\n else:\n # Stack maps with a 3D offset\n for i in range(num_maps):\n square = Square(side_length=square_size, fill_color=color, fill_opacity=0.5, stroke_width=1)\n square.shift(i * stack_offset * UP + i * stack_offset * RIGHT)\n volume.add(square)\n volume.center()\n return volume\n\n def create_kernel(size, color):\n kernel = VGroup()\n single_size = size / 3\n for r in range(3):\n for c in range(3):\n sq = Square(side_length=single_size, stroke_color=color, stroke_width=2, fill_opacity=0)\n sq.move_to([(c - 1) * single_size, (1 - r) * single_size, 0])\n kernel.add(sq)\n return kernel\n\n # Layer configurations\n input_vol = create_feature_volume(1, 1.6, GREY)\n conv1_vol = create_feature_volume(6, 1.4, BBLUE)\n pool1_vol = create_feature_volume(6, 0.8, GREEN)\n conv2_vol = create_feature_volume(16, 0.35, BLUE)\n pool2_vol = create_feature_volume(16, 0.2, GREEN)\n\n layers = [input_vol, conv1_vol, pool1_vol, conv2_vol, pool2_vol]\n labels_text = [\n \"Input\\n32x32x1\",\n \"Conv1\\n6 Maps, 3x3\\n30x30x6\",\n \"Pool1\\n15x15x6\",\n \"Conv2\\n16 Maps, 3x3\\n13x13x16\",\n \"Pool2\\n6x6x16\"\n ]\n \n labels = VGroup()\n for text in labels_text:\n labels.add(Text(text, font_size=18, line_spacing=1.1))\n\n # Positioning\n start_x = -5.5\n spacing = 2.5\n for i, layer in enumerate(layers):\n layer.move_to([start_x + i * spacing, 0.5, 0])\n labels[i].next_to(layer, DOWN, buff=0.4)\n\n # 1. Animate Input\n self.play(FadeIn(input_vol), Write(labels[0]))\n self.wait(0.5)\n\n # 2. Animate Conv1 with sliding kernel\n self.play(input_vol.animate.shift(LEFT * 0.5), labels[0].animate.shift(LEFT * 0.5))\n \n kernel1 = create_kernel(0.6, RED)\n kernel1.move_to(input_vol.get_center())\n kernel1_label = Text(\"3x3 Kernel\", font_size=16, color=RED).next_to(kernel1, UP, buff=0.1)\n \n self.play(FadeIn(kernel1), Write(kernel1_label))\n self.play(kernel1.animate.shift(RIGHT * 0.4 + UP * 0.4), run_time=0.5)\n self.play(kernel1.animate.shift(DOWN * 0.4), run_time=0.3)\n self.play(kernel1.animate.move_to(input_vol.get_center()), run_time=0.3)\n\n arrow1 = Arrow(input_vol.get_right(), conv1_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow1), FadeOut(kernel1), FadeOut(kernel1_label))\n self.play(GrowFromCenter(conv1_vol), Write(labels[1]))\n self.wait(0.5)\n\n # 3. Animate Pool1\n arrow2 = Arrow(conv1_vol.get_right(), pool1_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow2))\n self.play(Transform(conv1_vol.copy(), pool1_vol), Write(labels[2]))\n self.add(pool1_vol) # Ensure final state is present\n self.wait(0.5)\n\n # 4. Animate Conv2 with sliding kernel\n kernel2 = create_kernel(0.3, YELLOW)\n kernel2.move_to(pool1_vol.get_center())\n kernel2_label = Text(\"3x3 Kernel\", font_size=16, color=YELLOW).next_to(kernel2, UP, buff=0.1)\n \n self.play(FadeIn(kernel2), Write(kernel2_label))\n self.play(kernel2.animate.shift(RIGHT * 0.2 + UP * 0.2), run_time=0.4)\n self.play(kernel2.animate.move_to(pool1_vol.get_center()), run_time=0.3)\n\n arrow3 = Arrow(pool1_vol.get_right(), conv2_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow3), FadeOut(kernel2), FadeOut(kernel2_label))\n self.play(GrowFromCenter(conv2_vol), Write(labels[3]))\n self.wait(0.5)\n\n # 5. Animate Pool2\n arrow4 = Arrow(conv2_vol.get_right(), pool2_vol.get_left(), buff=0.15, color=WHITE)\n self.play(GrowArrow(arrow4))\n self.play(Transform(conv2_vol.copy(), pool2_vol), Write(labels[4]))\n self.add(pool2_vol)\n self.wait(1)\n\n # Final Highlight\n all_elements = VGroup(input_vol, conv1_vol, pool1_vol, conv2_vol, pool2_vol, *labels)\n summary_box = SurroundingRectangle(all_elements, color=YELLOW, buff=0.5)\n summary_text = Text(\"CNN Construction Complete\", font_size=28, color=YELLOW).to_edge(DOWN)\n \n self.play(Create(summary_box), Write(summary_text))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated explanation of how to evaluate the double integral of r^2 in polar coordinates over a unit circle from 0 to 2π in the angle θ and from 0 to 1 in the radius r. The animation should start by displaying the mathematical problem, then step by step show the solution. Begin by integrating with respect to r, explaining that we do the inner integral first, followed by a transformation to the next step which evaluates the result of this inner integral. Then, it should indicate transitioning to integrate with respect to θ now and proceed to evaluate the outer integral. Finally, the animation should show the result of the outer integral, simplify it, and then display the simplified final solution.", "chosen": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # Configure colors for clarity\n color_r = YELLOW\n color_theta = BLUE\n color_result = GOLD\n\n # --- Step 1: Setup and Problem Statement ---\n problem_title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n problem_title.to_edge(UP)\n \n # Initial Integral: I = \\int_{0}^{2\\pi} \\int_{0}^{1} r^2 dr d\\theta\n initial_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\int_{0}^{1}\", r\"r^2\", r\"\\, dr \\, d\\theta\",\n font_size=48\n )\n initial_integral.next_to(problem_title, DOWN, buff=0.5)\n initial_integral.set_color_by_tex(\"r\", color_r)\n initial_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n \n self.play(Write(problem_title))\n self.play(Write(initial_integral))\n self.wait(1)\n \n # --- Step 2: Inner Integral (r) ---\n explanation_inner = Text(\n \"Step 1: Evaluate the inner integral with respect to r\",\n font_size=24, color=WHITE\n )\n explanation_inner.next_to(initial_integral, DOWN, buff=0.5)\n self.play(FadeIn(explanation_inner))\n \n # Highlight the inner integral part\n box = SurroundingRectangle(VGroup(initial_integral[2], initial_integral[3], initial_integral[4][:3]), color=color_r, buff=0.1)\n self.play(Create(box))\n self.wait(1)\n \n # Transform to show antiderivative of r^2\n step2_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\left[ \\frac{r^3}{3} \\right]_{0}^{1}\", r\"\\, d\\theta\",\n font_size=48\n )\n step2_integral.set_color_by_tex(\"r\", color_r)\n step2_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step2_integral.move_to(initial_integral)\n \n self.play(TransformMatchingTex(initial_integral, step2_integral))\n self.wait(1)\n \n # Evaluate the bounds for r (1^3/3 - 0^3/3 = 1/3)\n step3_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\frac{1}{3}\", r\"\\, d\\theta\",\n font_size=48\n )\n step3_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step3_integral.move_to(step2_integral)\n \n eval_text = Text(\"Evaluate bounds: 1/3 - 0 = 1/3\", font_size=24, color=WHITE)\n eval_text.next_to(explanation_inner, DOWN, buff=0.3)\n \n self.play(TransformMatchingTex(step2_integral, step3_integral), FadeIn(eval_text))\n self.wait(1)\n self.play(FadeOut(eval_text), FadeOut(explanation_inner), FadeOut(box))\n \n # --- Step 3: Transition to Outer Integral ---\n transition_text = Text(\n \"Step 2: Transition to outer integral with respect to \\theta \",\n font_size=24, color=WHITE\n )\n transition_text.next_to(step3_integral, DOWN, buff=0.5)\n \n self.play(FadeIn(transition_text))\n self.wait(1)\n \n # --- Step 4: Outer Integral (\\theta ) ---\n # Show antiderivative with respect to theta\n step4_integral = MathTex(\n r\"I =\", r\"\\left[ \\frac{\\theta}{3} \\right]_{0}^{2\\pi}\",\n font_size=48\n )\n step4_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step4_integral.move_to(step3_integral)\n \n self.play(TransformMatchingTex(step3_integral, step4_integral))\n self.wait(1)\n \n # --- Step 5: Final Result and Simplification ---\n # Show raw substitution\n step5_raw = MathTex(\n r\"I =\", r\"\\frac{2\\pi}{3} - \\frac{0}{3}\",\n font_size=48\n )\n step5_raw.move_to(step4_integral)\n \n self.play(TransformMatchingTex(step4_integral, step5_raw))\n self.wait(0.5)\n \n # Show simplified final solution\n final_result = MathTex(\n r\"I =\", r\"\\frac{2\\pi}{3}\",\n font_size=60\n )\n final_result.set_color(color_result)\n final_result.move_to(step5_raw)\n \n simplify_text = Text(\"Simplify\", font_size=24, color=WHITE)\n simplify_text.next_to(step5_raw, DOWN, buff=0.3)\n \n self.play(FadeIn(simplify_text))\n self.play(TransformMatchingTex(step5_raw, final_result))\n self.wait(1)\n \n # Final Display\n final_box = SurroundingRectangle(final_result, color=color_result, buff=0.2)\n self.play(Create(final_box))\n \n conclusion_text = Text(\"Solution Complete\", font_size=36)\n conclusion_text.to_edge(DOWN)\n self.play(FadeIn(conclusion_text))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # Configure colors for clarity\n color_r = YELLOW\n color_theta = BBLUE\n color_result = GOLD\n\n # --- Step 1: Setup and Problem Statement ---\n problem_title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n problem_title.to_edge(UP)\n \n # Initial Integral: I = \\int_{0}^{2\\pi} \\int_{0}^{1} r^2 dr d\\theta\n initial_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\int_{0}^{1}\", r\"r^2\", r\"\\, dr \\, d\\theta\",\n font_size=48\n )\n initial_integral.next_to(problem_title, DOWN, buff=0.5)\n initial_integral.set_color_by_tex(\"r\", color_r)\n initial_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n \n self.play(Write(problem_title))\n self.play(Write(initial_integral))\n self.wait(1)\n \n # --- Step 2: Inner Integral (r) ---\n explanation_inner = Text(\n \"Step 1: Evaluate the inner integral with respect to r\",\n font_size=24, color=WHITE\n )\n explanation_inner.next_to(initial_integral, DOWN, buff=0.5)\n self.play(FadeIn(explanation_inner))\n \n # Highlight the inner integral part\n box = SurroundingRectangle(VGroup(initial_integral[2], initial_integral[3], initial_integral[4][:3]), color=color_r, buff=0.1)\n self.play(Create(box))\n self.wait(1)\n \n # Transform to show antiderivative of r^2\n step2_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\left[ \\frac{r^3}{3} \\right]_{0}^{1}\", r\"\\, d\\theta\",\n font_size=48\n )\n step2_integral.set_color_by_tex(\"r\", color_r)\n step2_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step2_integral.move_to(initial_integral)\n \n self.play(TransformMatchingTex(initial_integral, step2_integral))\n self.wait(1)\n \n # Evaluate the bounds for r (1^3/3 - 0^3/3 = 1/3)\n step3_integral = MathTex(\n r\"I =\", r\"\\int_{0}^{2\\pi}\", r\"\\frac{1}{3}\", r\"\\, d\\theta\",\n font_size=48\n )\n step3_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step3_integral.move_to(step2_integral)\n \n eval_text = Text(\"Evaluate bounds: 1/3 - 0 = 1/3\", font_size=24, color=WHITE)\n eval_text.next_to(explanation_inner, DOWN, buff=0.3)\n \n self.play(TransformMatchingTex(step2_integral, step3_integral), FadeIn(eval_text))\n self.wait(1)\n self.play(FadeOut(eval_text), FadeOut(explanation_inner), FadeOut(box))\n \n # --- Step 3: Transition to Outer Integral ---\n transition_text = Text(\n \"Step 2: Transition to outer integral with respect to \\theta \",\n font_size=24, color=WHITE\n )\n transition_text.next_to(step3_integral, DOWN, buff=0.5)\n \n self.play(FadeIn(transition_text))\n self.wait(1)\n \n # --- Step 4: Outer Integral (\\theta ) ---\n # Show antiderivative with respect to theta\n step4_integral = MathTex(\n r\"I =\", r\"\\left[ \\frac{\\theta}{3} \\right]_{0}^{2\\pi}\",\n font_size=48\n )\n step4_integral.set_color_by_tex(\"\\\\theta\", color_theta)\n step4_integral.move_to(step3_integral)\n \n self.play(TransformMatchingTex(step3_integral, step4_integral))\n self.wait(1)\n \n # --- Step 5: Final Result and Simplification ---\n # Show raw substitution\n step5_raw = MathTex(\n r\"I =\", r\"\\frac{2\\pi}{3} - \\frac{0}{3}\",\n font_size=48\n )\n step5_raw.move_to(step4_integral)\n \n self.play(TransformMatchingTex(step4_integral, step5_raw))\n self.wait(0.5)\n \n # Show simplified final solution\n final_result = MathTex(\n r\"I =\", r\"\\frac{2\\pi}{3}\",\n font_size=60\n )\n final_result.set_color(color_result)\n final_result.move_to(step5_raw)\n \n simplify_text = Text(\"Simplify\", font_size=24, color=WHITE)\n simplify_text.next_to(step5_raw, DOWN, buff=0.3)\n \n self.play(FadeIn(simplify_text))\n self.play(TransformMatchingTex(step5_raw, final_result))\n self.wait(1)\n \n # Final Display\n final_box = SurroundingRectangle(final_result, color=color_result, buff=0.2)\n self.play(Create(final_box))\n \n conclusion_text = Text(\"Solution Complete\", font_size=36)\n conclusion_text.to_edge(DOWN)\n self.play(FadeIn(conclusion_text))\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated Valentine's Day card that has a mathematical theme. The animation should start with a white background and black axes drawn in the middle of the screen, with the axes labeled with tick marks at the pi over 2 intervals. The graph should feature animations of the sine function and its inverse, as well as circles that transition into heart shapes. Specifically, I want the positive sine function and its reflection across the y-axis to be drawn and labeled, turning gradually into a red color, followed by two circles that also fill with red color while being traced. Then, I'd like to rotate these graphs and their labels about the line y=x to turn them into their inverse functions. Finally, all the red parts should come together to form a complete heart shape, which then gets filled with solid red, that is then minimized to make room for a special Valentine's Day message that reads \"With love from\" next to a small heart icon. In the end, I want the Manim Community logo to be displayed at the bottom. All of this should be accompanied by smooth transitions and appropriate pauses to ensure a visually appealing presentation.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ValentinesMathCard(Scene):\n def construct(self):\n # --- 1. Scene Setup ---\n self.camera.background_color = WHITE\n\n # Create black axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BLACK, \"include_tip\": False},\n x_length=7,\n y_length=5\n )\n\n # Add tick marks and labels at intervals of pi/2\n x_labels = VGroup()\n tick_values = [-PI, -PI/2, PI/2, PI]\n tick_tex = [r\"-\\pi\", r\"-\\frac{\\pi}{2}\", r\"\\frac{\\pi}{2}\", r\"\\pi\"]\n\n for val, tex in zip(tick_values, tick_tex):\n pos = axes.c2p(val, 0)\n tick = Line(pos + DOWN * 0.1, pos + UP * 0.1, color=BLACK)\n lbl = MathTex(tex, color=BLACK, font_size=24)\n lbl.next_to(tick, DOWN, buff=0.15)\n x_labels.add(tick, lbl)\n\n axes_group = VGroup(axes, x_labels)\n self.play(Create(axes_group), run_time=2)\n self.wait(0.5)\n\n # --- 2. Function Animation ---\n # Animate positive sine function and its reflection across the y-axis\n sine_right = axes.plot(lambda x: np.sin(x), x_range=[0, PI], color=BLACK)\n sine_left = axes.plot(lambda x: np.sin(-x), x_range=[-PI, 0], color=BLACK)\n\n label_right = MathTex(r\"y = \\sin(x)\", color=BLACK, font_size=30).next_to(sine_right, UP, buff=0.2)\n label_left = MathTex(r\"y = \\sin(-x)\", color=BLACK, font_size=30).next_to(sine_left, UP, buff=0.2)\n\n self.play(Create(sine_right), Create(sine_left), Write(label_right), Write(label_left), run_time=2)\n self.wait(0.5)\n\n # Gradually turn graphs and labels red\n self.play(\n sine_right.animate.set_color(RED),\n sine_left.animate.set_color(RED),\n label_right.animate.set_color(RED),\n label_left.animate.set_color(RED),\n run_time=1.5\n )\n self.wait(0.5)\n\n # --- 3. Circle to Heart Transition ---\n # Introduce two circles positioned above the sine humps\n circle_left = Circle(radius=0.8, color=RED).move_to(axes.c2p(-PI/2, 1.5))\n circle_right = Circle(radius=0.8, color=RED).move_to(axes.c2p(PI/2, 1.5))\n\n # Trace the circles and fill them with red\n self.play(Create(circle_left), Create(circle_right), run_time=1.5)\n self.play(\n circle_left.animate.set_fill(RED, opacity=0.5),\n circle_right.animate.set_fill(RED, opacity=0.5),\n run_time=1\n )\n\n # Group all red components\n math_components = VGroup(\n sine_left, sine_right,\n label_left, label_right,\n circle_left, circle_right\n )\n\n # Transformation: Rotate about the line y=x (Swap x and y coordinates)\n # This visually represents transforming them into their inverse functions\n def swap_coords(point):\n x, y, z = point\n return [y, x, z]\n\n self.play(\n ApplyPointwiseFunction(swap_coords, math_components),\n run_time=2\n )\n self.wait(0.5)\n\n # --- 4. Final Heart Formation ---\n # Define a standard parametric heart shape for the final merge\n heart_curve = ParametricFunction(\n lambda t: np.array([\n 16 * np.sin(t)**3,\n 13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t),\n 0\n ]),\n t_range=[0, TAU],\n color=RED\n ).scale(0.25).shift(UP * 0.5)\n\n # Merge all components into the heart shape\n self.play(\n ReplacementTransform(math_components, heart_curve),\n FadeOut(axes_group),\n run_time=2\n )\n self.wait(0.5)\n\n # Fill the resulting heart with solid red\n self.play(\n heart_curve.animate.set_fill(RED, opacity=1),\n heart_curve.animate.set_stroke(width=0),\n run_time=1.5\n )\n\n # Minimization: Shrink the heart to create space for text\n self.play(heart_curve.animate.scale(0.6).shift(UP * 1.5), run_time=1.5)\n self.wait(0.5)\n\n # --- 5. Message & Branding ---\n # Display the message \"With love from\" next to a small heart icon\n message_text = Text(\"With love from\", font_size=36, color=BLACK)\n small_heart = Tex(r\"$\\heartsuit$\", color=RED, font_size=40)\n message_group = VGroup(message_text, small_heart).arrange(RIGHT, buff=0.2)\n message_group.next_to(heart_curve, DOWN, buff=0.8)\n\n self.play(Write(message_text), FadeIn(small_heart), run_time=1.5)\n self.wait(0.5)\n\n # Display the Manim Community logo (Stylized for standalone compatibility)\n logo_square = Square(side_length=0.8, fill_color=\"#3879A9\", fill_opacity=1, stroke_color=WHITE, stroke_width=2)\n logo_text = Text(\"M\", font_size=24, color=WHITE).move_to(logo_square)\n logo_label = Text(\"Manim Community\", font_size=20, color=\"#3879A9\").next_to(logo_square, DOWN, buff=0.15)\n logo_group = VGroup(logo_square, logo_text, logo_label)\n logo_group.to_edge(DOWN, buff=0.5)\n\n self.play(FadeIn(logo_group), run_time=1.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ValentinesMathCard(Scene):\n def construct(self):\n # --- 1. Scene Setup ---\n self.camera.background_color = WHITE\n\n # Create black axes\n axes = Axes(font_size=24, \n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BLACK, \"include_tip\": False},\n x_length=7,\n y_length=5\n )\n\n # Add tick marks and labels at intervals of pi/2\n x_labels = VGroup()\n tick_values = [-PI, -PI/2, PI/2, PI]\n tick_tex = [r\"-\\pi\", r\"-\\frac{\\pi}{2}\", r\"\\frac{\\pi}{2}\", r\"\\pi\"]\n\n for val, tex in zip(tick_values, tick_tex):\n pos = axes.c2p(val, 0)\n tick = Line(pos + DOWN * 0.1, pos + UP * 0.1, color=BLACK)\n lbl = MathTex(tex, color=BLACK, font_size=24)\n lbl.next_to(tick, DOWN, buff=0.15)\n x_labels.add(tick, lbl)\n\n axes_group = VGroup(axes, x_labels)\n self.play(Create(axes_group), run_time=2)\n self.wait(0.5)\n\n # --- 2. Function Animation ---\n # Animate positive sine function and its reflection across the y-axis\n sine_right = axes.plot(lambda x: np.sin(x), x_range=[0, PI], color=BLACK)\n sine_left = axes.plot(lambda x: np.sin(-x), x_range=[-PI, 0], color=BLACK)\n\n label_right = MathTex(r\"y = \\sin(x)\", color=BLACK, font_size=30).next_to(sine_right, UP, buff=0.2)\n label_left = MathTex(r\"y = \\sin(-x)\", color=BLACK, font_size=30).next_to(sine_left, UP, buff=0.2)\n\n self.play(Create(sine_right), Create(sine_left), Write(label_right), Write(label_left), run_time=2)\n self.wait(0.5)\n\n # Gradually turn graphs and labels red\n self.play(\n sine_right.animate.set_color(RED),\n sine_left.animate.set_color(RED),\n label_right.animate.set_color(RED),\n label_left.animate.set_color(RED),\n run_time=1.5\n )\n self.wait(0.5)\n\n # --- 3. Circle to Heart Transition ---\n # Introduce two circles positioned above the sine humps\n circle_left = Circle(radius=0.8, color=RED).move_to(axes.c2p(-PI/2, 1.5))\n circle_right = Circle(radius=0.8, color=RED).move_to(axes.c2p(PI/2, 1.5))\n\n # Trace the circles and fill them with red\n self.play(Create(circle_left), Create(circle_right), run_time=1.5)\n self.play(\n circle_left.animate.set_fill(RED, opacity=0.5),\n circle_right.animate.set_fill(RED, opacity=0.5),\n run_time=1\n )\n\n # Group all red components\n math_components = VGroup(\n sine_left, sine_right,\n label_left, label_right,\n circle_left, circle_right\n )\n\n # Transformation: Rotate about the line y=x (Swap x and y coordinates)\n # This visually represents transforming them into their inverse functions\n def swap_coords(point):\n x, y, z = point\n return [y, x, z]\n\n self.play(\n ApplyPointwiseFunction(swap_coords, math_components),\n run_time=2\n )\n self.wait(0.5)\n\n # --- 4. Final Heart Formation ---\n # Define a standard parametric heart shape for the final merge\n heart_curve = ParametricFunction(\n lambda t: np.array([\n 16 * np.sin(t)**3,\n 13 * np.cos(t) - 5 * np.cos(2*t) - 2 * np.cos(3*t) - np.cos(4*t),\n 0\n ]),\n t_range=[0, TAU],\n color=RED\n ).scale(0.25).shift(UP * 0.5)\n\n # Merge all components into the heart shape\n self.play(\n ReplacementTransform(math_components, heart_curve),\n FadeOut(axes_group),\n run_time=2\n )\n self.wait(0.5)\n\n # Fill the resulting heart with solid red\n self.play(\n heart_curve.animate.set_fill(RED, opacity=1),\n heart_curve.animate.set_stroke(width=0),\n run_time=1.5\n )\n\n # Minimization: Shrink the heart to create space for text\n self.play(heart_curve.animate.scale(0.6).shift(UP * 1.5), run_time=1.5)\n self.wait(0.5)\n\n # --- 5. Message & Branding ---\n # Display the message \"With love from\" next to a small heart icon\n message_text = Text(\"With love from\", font_size=36, color=BLACK)\n small_heart = Tex(r\"$\\heartsuit$\", color=RED, font_size=40)\n message_group = VGroup(message_text, small_heart).arrange(RIGHT, buff=0.2)\n message_group.next_to(heart_curve, DOWN, buff=0.8)\n\n self.play(Write(message_text), FadeIn(small_heart), run_time=1.5)\n self.wait(0.5)\n\n # Display the Manim Community logo (Stylized for standalone compatibility)\n logo_square = Square(side_length=0.8, fill_color=\"#3879A9\", fill_opacity=1, stroke_color=WHITE, stroke_width=2)\n logo_text = Text(\"M\", font_size=24, color=WHITE).move_to(logo_square)\n logo_label = Text(\"Manim Community\", font_size=20, color=\"#3879A9\").next_to(logo_square, DOWN, buff=0.15)\n logo_group = VGroup(logo_square, logo_text, logo_label)\n logo_group.to_edge(DOWN, buff=0.5)\n\n self.play(FadeIn(logo_group), run_time=1.5)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an animation that visually explains how to solve a triple integral, specifically the integral of the function xyz from z=0 to z=2, x=-1 to x=1, and y=0 to y=1? The animation should first display the integral problem, then step-by-step walk through the integration process by first integrating with respect to z, then x, and finally y. For each integration step, I would like a brief explanatory text that appears stating which variable is being integrated, followed by the updated integral expression. The final frame should show the evaluated result of the integral. Can this all be done with smooth transitions between steps and pauses that allow time for each part to be understood?", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n text_color = BLUE_B\n math_color = WHITE\n result_color = YELLOW\n\n # 1. Intro: Display the original unsolved integral\n # Integral of xyz from z=0 to 2, x=-1 to 1, y=0 to 1\n title = Text(\"Evaluating a Triple Integral\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n original_integral = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} \\int_{0}^{2} xyz \\, dz \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n \n self.play(Write(original_integral))\n self.wait(2)\n\n # 2. Step 1: Integration with respect to z\n step1_text = Text(\"Integrating with respect to z:\", color=text_color, font_size=30)\n step1_text.next_to(original_integral, UP, buff=1)\n \n # Intermediate step showing the antiderivative for z\n step1_eval = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} \\left[ xy \\frac{z^2}{2} \\right]_{0}^{2} \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n \n # Result after evaluating z limits: (xy * 2^2 / 2) - 0 = 2xy\n step1_result = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} 2xy \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n\n self.play(FadeIn(step1_text))\n self.play(ReplacementTransform(original_integral, step1_eval))\n self.wait(2)\n self.play(ReplacementTransform(step1_eval, step1_result))\n self.wait(2)\n self.play(FadeOut(step1_text))\n\n # 3. Step 2: Integration with respect to x\n step2_text = Text(\"Integrating with respect to x:\", color=text_color, font_size=30)\n step2_text.next_to(step1_result, UP, buff=1)\n \n # Intermediate step showing the antiderivative for x\n step2_eval = MathTex(\n r\"\\int_{0}^{1} \\left[ 2y \\frac{x^2}{2} \\right]_{-1}^{1} \\, dy\", \n color=math_color\n ).scale(1.2)\n \n # Result after evaluating x limits: y * (1^2 - (-1)^2) = y * (1 - 1) = 0\n step2_result = MathTex(\n r\"\\int_{0}^{1} 0 \\, dy\", \n color=math_color\n ).scale(1.2)\n\n self.play(FadeIn(step2_text))\n self.play(ReplacementTransform(step1_result, step2_eval))\n self.wait(2)\n self.play(ReplacementTransform(step2_eval, step2_result))\n self.wait(2)\n self.play(FadeOut(step2_text))\n\n # 4. Step 3: Integration with respect to y\n step3_text = Text(\"Integrating with respect to y:\", color=text_color, font_size=30)\n step3_text.next_to(step2_result, UP, buff=1)\n \n # Final evaluation\n final_eval = MathTex(\n r\"[0]_{0}^{1}\", \n color=math_color\n ).scale(1.2)\n \n final_result = MathTex(\n r\"0\", \n color=result_color\n ).scale(1.5)\n\n self.play(FadeIn(step3_text))\n self.play(ReplacementTransform(step2_result, final_eval))\n self.wait(2)\n self.play(ReplacementTransform(final_eval, final_result))\n self.wait(2)\n self.play(FadeOut(step3_text), FadeOut(title))\n \n # Conclusion\n conclusion = Text(\"Final Result: 0\", font_size=36, color=GREEN)\n conclusion.next_to(final_result, DOWN, buff=0.5)\n \n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box), Write(conclusion))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n text_color = BLUE_B\n math_color = WHITE\n result_color = YELLOW\n\n # 1. Intro: Display the original unsolved integral\n # Integral of xyz from z=0 to 2, x=-1 to 1, y=0 to 1\n title = Text(\"Evaluating a Triple Integral\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n original_integral = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} \\int_{0}^{2} xyz \\, dz \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n \n self.play(Write(original_integral))\n self.wait(2)\n\n # 2. Step 1: Integration with respect to z\n step1_text = Text(\"Integrating with respect to z:\", color=text_color, font_size=30)\n step1_text.next_to(original_integral, UP, buff=1)\n \n # Intermediate step showing the antiderivative for z\n step1_eval = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} \\left[ xy \\frac{z^2}{2} \\right]_{0}^{2} \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n \n # Result after evaluating z limits: (xy * 2^2 / 2) - 0 = 2xy\n step1_result = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} 2xy \\, dx \\, dy\", \n color=math_color\n ).scale(1.2)\n\n self.play(FadeIn(step1_text))\n self.play(ReplacementTransform(target_position=ORIGIN, original_integral, step1_eval))\n self.wait(2)\n self.play(ReplacementTransform(step1_eval, step1_result))\n self.wait(2)\n self.play(FadeOut(step1_text))\n\n # 3. Step 2: Integration with respect to x\n step2_text = Text(\"Integrating with respect to x:\", color=text_color, font_size=30)\n step2_text.next_to(step1_result, UP, buff=1)\n \n # Intermediate step showing the antiderivative for x\n step2_eval = MathTex(\n r\"\\int_{0}^{1} \\left[ 2y \\frac{x^2}{2} \\right]_{-1}^{1} \\, dy\", \n color=math_color\n ).scale(1.2)\n \n # Result after evaluating x limits: y * (1^2 - (-1)^2) = y * (1 - 1) = 0\n step2_result = MathTex(\n r\"\\int_{0}^{1} 0 \\, dy\", \n color=math_color\n ).scale(1.2)\n\n self.play(FadeIn(step2_text))\n self.play(ReplacementTransform(step1_result, step2_eval))\n self.wait(2)\n self.play(ReplacementTransform(step2_eval, step2_result))\n self.wait(2)\n self.play(FadeOut(step2_text))\n\n # 4. Step 3: Integration with respect to y\n step3_text = Text(\"Integrating with respect to y:\", color=text_color, font_size=30)\n step3_text.next_to(step2_result, UP, buff=1)\n \n # Final evaluation\n final_eval = MathTex(\n r\"[0]_{0}^{1}\", \n color=math_color\n ).scale(1.2)\n \n final_result = MathTex(\n r\"0\", \n color=result_color\n ).scale(1.5)\n\n self.play(FadeIn(step3_text))\n self.play(ReplacementTransform(step2_result, final_eval))\n self.wait(2)\n self.play(ReplacementTransform(final_eval, final_result))\n self.wait(2)\n self.play(FadeOut(step3_text), FadeOut(title))\n \n # Conclusion\n conclusion = Text(\"Final Result: 0\", font_size=36, color=GREEN)\n conclusion.next_to(final_result, DOWN, buff=0.5)\n \n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box), Write(conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation demonstrating the calculation of the area under a quadratic curve. First, display the function f(x) = x^2. Then show the formula for the area A as the definite integral of x^2 from a to b. Next, visually represent the area under the curve between x = 0 and x = 2. After that, illustrate the integration process by transforming the area formula to the antiderivative form A = 1/3 x^3 evaluated from a to b. Subsequently, show the substitution of the limits into the antiderivative, which simplifies to A = 1/3 (b^3 - a^3). End the animation with a clear and final display of the simplified area formula. Afterward, clear the animation and show the final answer alone for emphasis.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- Configuration ---\n func = lambda x: x**2\n a_val, b_val = 0, 2\n\n # --- Step 1: Display Function ---\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 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 ).shift(LEFT * 3)\n\n graph = axes.plot(func, color=BLUE, x_range=[-0.5, 3])\n graph_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Create(graph), Write(graph_label), run_time=2)\n self.wait(0.5)\n\n # --- Step 2: Show Integral Formula ---\n integral_formula = MathTex(\n \"A\", \"=\", \"\\\\int_{a}^{b}\", \"x^2\", \"\\\\,dx\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(Write(integral_formula), run_time=2)\n self.wait(0.5)\n\n # --- Step 3: Visualize Area ---\n area = axes.get_area(\n graph,\n x_range=(a_val, b_val),\n color=GREEN,\n opacity=0.5\n )\n\n line_a = axes.get_vertical_line(axes.i2gp(a_val, graph), color=YELLOW)\n line_b = axes.get_vertical_line(axes.i2gp(b_val, graph), color=YELLOW)\n a_label = MathTex(\"a=0\").next_to(axes.x_axis.n2p(a_val), DOWN, buff=0.2)\n b_label = MathTex(\"b=2\").next_to(axes.x_axis.n2p(b_val), DOWN, buff=0.2)\n\n self.play(\n FadeIn(area), Create(line_a), Create(line_b), \n Write(a_label), Write(b_label), run_time=2\n )\n self.wait(0.5)\n\n # --- Step 4: Illustrate Antiderivative ---\n antiderivative_formula = MathTex(\n \"A\", \"=\", \"\\\\left[\", \"\\\\frac{1}{3}\", \"x^3\", \"\\\\right]_{a}^{b}\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(\n TransformMatchingTex(integral_formula, antiderivative_formula),\n run_time=2\n )\n self.wait(0.5)\n\n # --- Step 5: Substitute Limits ---\n simplified_formula = MathTex(\n \"A\", \"=\", \"\\\\frac{1}{3}\", \"(\", \"b^3\", \"-\", \"a^3\", \")\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(\n TransformMatchingTex(antiderivative_formula, simplified_formula),\n run_time=2\n )\n self.wait(0.5)\n\n # --- Step 6: Final Formula Display ---\n self.wait(1.5)\n\n # --- Step 7: Emphasis Phase ---\n numerical_result = MathTex(\"A = \\\\frac{8}{3}\", font_size=72, color=YELLOW)\n\n # Clear all previous elements\n self.play(\n FadeOut(axes), FadeOut(graph), FadeOut(graph_label),\n FadeOut(area), FadeOut(line_a), FadeOut(line_b),\n FadeOut(a_label), FadeOut(b_label), FadeOut(simplified_formula),\n run_time=1.5\n )\n\n # Display final numerical answer prominently\n self.play(Write(numerical_result), run_time=2)\n self.play(numerical_result.animate.scale(1.2), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- Configuration ---\n func = lambda x: x**2\n a_val, b_val = 0, 2\n\n # --- Step 1: Display Function ---\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 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 ).shift(LEFT * 3)\n\n graph = axes.plot(func, color=BLUE, x_range=[-0.5, 3])\n graph_label = MathTex(r\"f(x) = x^2\" + \" = x\", color=BLUE).next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Create(graph), Write(graph_label), run_time=2)\n self.wait(0.5)\n\n # --- Step 2: Show Integral Formula ---\n integral_formula = MathTex(\n \"A\", \"=\", \"\\\\int_{a}^{b}\", \"x^2\", \"\\\\,dx\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(Write(integral_formula), run_time=2)\n self.wait(0.5)\n\n # --- Step 3: Visualize Area ---\n area = axes.get_area(\n graph,\n x_range=(a_val, b_val),\n color=GREEN,\n opacity=0.5\n )\n\n line_a = axes.get_vertical_line(axes.i2gp(a_val, graph), color=YELLOW)\n line_b = axes.get_vertical_line(axes.i2gp(b_val, graph), color=YELLOW)\n a_label = MathTex(\"a=0\").next_to(axes.x_axis.n2p(a_val), DOWN, buff=0.2)\n b_label = MathTex(\"b=2\").next_to(axes.x_axis.n2p(b_val), DOWN, buff=0.2)\n\n self.play(\n FadeIn(area), Create(line_a), Create(line_b), \n Write(a_label), Write(b_label), run_time=2\n )\n self.wait(0.5)\n\n # --- Step 4: Illustrate Antiderivative ---\n antiderivative_formula = MathTex(\n \"A\", \"=\", \"\\\\left[\", \"\\\\frac{1}{3}\", \"x^3\", \"\\\\right]_{a}^{b}\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(\n TransformMatchingTex(integral_formula, antiderivative_formula),\n run_time=2\n )\n self.wait(0.5)\n\n # --- Step 5: Substitute Limits ---\n simplified_formula = MathTex(\n \"A\", \"=\", \"\\\\frac{1}{3}\", \"(\", \"b^3\", \"-\", \"a^3\", \")\"\n ).to_edge(RIGHT).shift(UP * 2)\n\n self.play(\n TransformMatchingTex(antiderivative_formula, simplified_formula),\n run_time=2\n )\n self.wait(0.5)\n\n # --- Step 6: Final Formula Display ---\n self.wait(1.5)\n\n # --- Step 7: Emphasis Phase ---\n numerical_result = MathTex(\"A = \\\\frac{8}{3}\", font_size=72, color=YELLOW)\n\n # Clear all previous elements\n self.play(\n FadeOut(axes), FadeOut(graph), FadeOut(graph_label),\n FadeOut(area), FadeOut(line_a), FadeOut(line_b),\n FadeOut(a_label), FadeOut(b_label), FadeOut(simplified_formula),\n run_time=1.5\n )\n\n # Display final numerical answer prominently\n self.play(Write(numerical_result), run_time=2)\n self.play(numerical_result.animate.scale(1.2), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Derivation of Transformation Matrix\n\n**Transformation Steps**:\n1. Translate the bottom-left corner of the window to the origin: $T(-x_{wmin}, -y_{wmin})$\n2. Scale to the viewport size (normalize and then enlarge): $S(s_x, s_y)$\n3. Translate to the bottom-left corner of the viewport: $T(x_{vmin}, y_{vmin})$\n\n**Scaling Factors**:\n$$\ns_x = \\frac{x_{vmax} - x_{vmin}}{x_{wmax} - x_{wmin}}, \\quad\ns_y = \\frac{y_{vmax} - y_{vmin}}{y_{wmax} - y_{wmin}}\n$$\n\n\nContextual location of this section (from highest to current level):\n# Computer Graphics and Virtual Reality: 2D Transformations and Clipping\n## Window-Viewport Transformation\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TransformationMatrixDerivation(Scene):\n\n def construct(self):\n title = Text('Window-Viewport Transformation', font_size=40, weight=BOLD)\n subtitle = Text('Derivation of Transformation Matrix', font_size=32, color=BLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2).to_edge(UP)\n self.play(Write(header))\n self.wait(0.5)\n steps_title = Text('Transformation Steps:', font_size=28, weight=BOLD)\n steps_title.to_edge(LEFT, buff=1.0).shift(UP * 1.5)\n step1 = Tex('1. Translate the bottom-left corner of the window to the origin: ', '$T(-x_{wmin}, -y_{wmin})$', font_size=30)\n step1[1].set_color(YELLOW)\n step2 = Tex('2. Scale to the viewport size (normalize and then enlarge): ', '$S(s_x, s_y)$', font_size=30)\n step2[1].set_color(YELLOW)\n step3 = Tex('3. Translate to the bottom-left corner of the viewport: ', '$T(x_{vmin}, y_{vmin})$', font_size=30)\n step3[1].set_color(YELLOW)\n steps = VGroup(step1, step2, step3).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.next_to(steps_title, DOWN, aligned_edge=LEFT, buff=0.4).shift(RIGHT * 0.5)\n self.play(FadeIn(steps_title, shift=RIGHT * 0.5))\n for step in steps:\n self.play(Write(step), run_time=1.5)\n self.wait(0.3)\n else:\n pass\n factors_title = Text('Scaling Factors:', font_size=28, weight=BOLD)\n factors_title.next_to(steps, DOWN, aligned_edge=LEFT, buff=0.8).shift(LEFT * 0.5)\n math_eq = MathTex('s_x = \\\\frac{x_{vmax} - x_{vmin}}{x_{wmax} - x_{wmin}}, \\\\quad s_y = \\\\frac{y_{vmax} - y_{vmin}}{y_{wmax} - y_{wmin}}', font_size=38)\n math_eq.next_to(factors_title, DOWN, buff=0.5)\n math_eq.set_x(0)\n self.play(FadeIn(factors_title, shift=RIGHT * 0.5))\n self.play(Write(math_eq), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TransformationMatrixDerivation(Scene):\n\n def construct(self):\n title = Text('Window-Viewport Transformation', font_size=40, weight=BOLD)\n subtitle = Text('Derivation of Transformation Matrix', font_size=32, color=BLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2).to_edge(UP)\n self.play(Write(header))\n self.wait(0.5)\n steps_title = Text('Transformation Steps:', font_size=28, weight=BOLD)\n steps_title.to_edge(LEFT, buff=1.0).shift(UP * 1.5)\n step1 = Tex('1. Translate the bottom-left corner of the window to the origin: ', '$T(-x_{wmin}, -y_{wmin})$', font_size=30)\n step1[1].set_color(YELLOW)\n step2 = Tex('2. Scale to the viewport size (normalize and then enlarge): ', '$S(s_x, s_y)$', font_size=30)\n step2[1].set_color(YELLOW)\n step3 = Tex('3. Translate to the bottom-left corner of the viewport: ', '$T(x_{vmin}, y_{vmin})$', font_size=30)\n step3[1].set_color(YELLOW)\n steps = VGroup(step1, step2, step3).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.next_to(steps_title, DOWN, aligned_edge=LEFT, buff=0.4).shift(RIGHT * 0.5)\n self.play(FadeIn(steps_title, shift=RIGHT * 0.5))\n for step in steps:\n self.play(Write(step), run_time=1.5)\n self.wait(0.3)\n else:\n pass\n factors_title = Text('Scaling Factors:', font_size=28, weight=BOLD)\n factors_title.next_to(steps, DOWN, aligned_edge=LEFT, buff=0.8).shift(LEFT * 0.5)\n math_eq = MathTex('s_x = \\\\frac{x_{vmax} - x_{vmin}}{x_{wmax} - x_{wmin}}, \\\\quad s_y = \\\\frac{y_{vmax} - y_{vmin}}{y_{wmax} - y_{wmin}}', font_size=38)\n math_eq.next_to(factors_title, DOWN, buff=0.5)\n math_eq.set_x(0)\n self.play(FadeIn(factors_title, shift=RIGHT * 0.5))\n self.play(Write(math_eq), run_time=2)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can the Argument Principle be used to determine the nature of the singularities (simple, double, etc.) of a function contained within a contour?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n title = Text(\"The Argument Principle\", font_size=36)\n subtitle = Text(\n \"Determines singularity types inside contours\",\n font_size=28,\n color=BLUE_C\n )\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.5))\n self.wait(1)\n\n # Create a circle representing the contour\n curve = Circle(radius=2, color=YELLOW)\n curve_label = MathTex(\"C\").next_to(curve, UR, buff=-0.3)\n self.play(Create(curve), Write(curve_label))\n\n # Display the formula for the argument principle\n formula1 = MathTex(\n r\"n(f) = \\frac{1}{2\\pi i} \\int_{C} \\frac{f'(z)}{f(z)} \\\\ dz\"\n ).to_edge(DOWN).scale(0.7)\n \n formula2 = MathTex(\n r\"\\text{(where } n(\\cdot) \\text{ counts zeros minus poles})\"\n ).next_to(formula1, DOWN)\n \n self.play(Write(formula1))\n self.play(Write(formula2))\n self.wait(1)\n\n # Demonstrate different types of singularities\n point_simple = Dot(np.array([0.5, 1.5, 0]), radius=0.1, color=GREEN)\n label_simple = Tex(\"Simple\", font_size=18, color=GREEN).next_to(point_simple, UP)\n self.play(FadeIn(point_simple), FadeIn(label_simple))\n self.wait(0.5)\n\n point_double = Dot(np.array([-1, -1, 0]), radius=0.1, color=RED)\n label_double = Tex(\"Double\", font_size=18, color=RED).next_to(point_double, LEFT)\n self.play(FadeIn(point_double), FadeIn(label_double))\n self.wait(0.5)\n\n point_pole = Dot(np.array([1.5, -1.5, 0]), radius=0.1, color=PURPLE)\n label_pole = Tex(\"Pole\", font_size=18, color=PURPLE).next_to(point_pole, RIGHT)\n self.play(FadeIn(point_pole), FadeIn(label_pole))\n self.wait(1)\n\n # Clear everything except the title\n self.play(\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(point_simple),\n FadeOut(label_simple),\n FadeOut(point_double),\n FadeOut(label_double),\n FadeOut(point_pole),\n FadeOut(label_pole),\n FadeOut(formula1),\n FadeOut(formula2),\n run_time=1.5\n )\n\n conclusion = Text(\n \"Argument Principle allows us to count\\nand classify singularities simply.\",\n font_size=24\n )\n box = SurroundingRectangle(conclusion, color=WHITE, fill_opacity=0.1)\n self.play(Write(conclusion), Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n title = Text(\"The Argument Principle\", font_size=36)\n subtitle = Text(\n \"Unveiling Singularities Within Contours\",\n font_size=28,\n color=GRAY\n )\n \n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n\n # --- Step 1: Define the Function ---\n func_text = MathTex(\"f(z) =\", r\"\\frac{(z-2)(z+1)}{z^2 + z}\", font_size=40)\n func_title = Text(\"Given Function:\", font_size=28, color=YELLOW)\n \n func_group = VGroup(func_title, func_text).arrange(RIGHT, buff=0.5).shift(UP * 2)\n self.play(Write(func_group))\n\n # Highlight the numerator and denominator for clarity\n num_rect = SurroundingRectangle(VGroup(func_text[1][0], func_text[1][1]), color=BLUE, buff=0.15)\n den_rect = SurroundingRectangle(func_text[1][2], color=RED, buff=0.15)\n \n self.play(Create(num_rect), Create(den_rect))\n self.wait(1)\n\n # --- Step 2: State the Theorem ---\n theorem_text = Text(\n \"Argument Principle:\\nLet f be analytic on a simple,\\nclosed curve C except at finitely many points.\",\n font_size=24,\n line_spacing=1.1\n ).to_edge(LEFT).shift(UP * 1)\n\n equation = MathTex(\"\\\\Delta \\\\theta = \", \"\\\\int_C\", r\"\\\\frac{f'(z)}{f(z)}\", \"\\\\,dz\")\n equation[1].set_color(YELLOW)\n equation[2].set_color(GREEN)\n \n eq_group = VGroup(theorem_text, equation).arrange(DOWN, aligned_edge=RIGHT, buff=0.4)\n \n self.play(Write(eq_group))\n self.wait(2)\n\n # --- Step 3: Analyze the Integral ---\n integral_text = Text(\n \"As we traverse C, the integrand tracks\\nthe change in the argument along C.\",\n font_size=28\n ).next_to(eq_group, DOWN, buff=0.7)\n \n self.play(Write(integral_text))\n self.wait(1)\n\n # --- Step 4: Connect to Zeros/Poles ---\n zero_pole_text = Text(\n \"Zeros contribute positive angles,\\nPoles contribute negative angles.\",\n font_size=28\n ).next_to(integral_text, DOWN, buff=0.7)\n \n self.play(Write(zero_pole_text))\n self.wait(1)\n\n # --- Final Summary ---\n final_text = Text(\n \"The total angle change equals $2\\pi$ times \\nthe difference between zeros and poles.\",\n font_size=28\n ).to_edge(LEFT).shift(UP * 2.5)\n \n formula = MathTex(\"\\\\Delta \\\\theta = 2\\\\pi(n_z - n_p)\")\n formula[0][8:].set_color(YELLO)\n formula[0][12:].set_color(PURPLE)\n \n summary_group = VGroup(final_text, formula).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n \n self.play(FadeOut(integral_text), FadeOut(zero_pole_text))\n self.play(Write(summary_group))\n self.wait(2)\n\n # Clean up and conclude\n self.play(\n FadeOut(func_group),\n FadeOut(eq_group),\n FadeOut(summary_group),\n FadeOut(theorem_text)\n )\n\n conclusion = Text(\n \"Exploring Functions throughContours\",\n font_size=32,\n color=GREEN\n )\n \n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'm teaching sequence modeling and want a clear confusion-matrix-style visualization for next-character predictions. Show predicted probability slices vs. actual next-character labels on the validation set, with a big heatmap comparing probabilities to true counts. Annotate typical mispredictions and emphasize per-character precision-recall style metrics. Add a timeline of model accuracy as the dataset advances to connect confusion to overall performance.", "chosen": "```python\nfrom manim import *\n\nclass SequenceModelingConfusionMatrixVisualization(Scene):\n\n def construct(self):\n title = Text('Sequence Modeling: Confusion Matrix', font_size=36)\n subtitle = Text('Visualizing Model Performance', font_size=24, color=BLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n header.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0 * 0.6)\n self.play(FadeIn(subtitle), run_time=2.0 * 0.4)\n context = VGroup(Text('Context: \"The cat ...\"', font_size=22), Text('Prediction: \"sat\"', font_size=22, color=GREEN)).arrange(DOWN, buff=0.2)\n context.next_to(header, DOWN, buff=0.5)\n self.play(FadeIn(context), run_time=2.0)\n classes = ['the', 'cat', 'sat']\n n = len(classes)\n cell_size = 0.9\n values = [[8, 1, 1], [2, 7, 0], [0, 1, 9]]\n matrix_group = VGroup()\n top_labels = VGroup(*[Text(c, font_size=20) for c in classes])\n for j, lbl in enumerate(top_labels):\n lbl.move_to(np.array([(j - 1) * cell_size, cell_size + 0.35, 0]))\n matrix_group.add(top_labels)\n pred_label = Text('Predicted', font_size=20)\n pred_label.next_to(top_labels, UP, buff=0.2)\n matrix_group.add(pred_label)\n left_labels = VGroup(*[Text(c, font_size=20) for c in classes])\n for i, lbl in enumerate(left_labels):\n lbl.move_to(np.array([-cell_size - 0.4, -(i - 1) * cell_size, 0]))\n matrix_group.add(left_labels)\n act_label = Text('Actual', font_size=20)\n act_label.next_to(left_labels, LEFT, buff=0.3)\n matrix_group.add(act_label)\n cells = VGroup()\n numbers = VGroup()\n for i in range(n):\n for j in range(n):\n sq = Square(side_length=cell_size, stroke_width=2)\n sq.move_to(np.array([(j - 1) * cell_size, -(i - 1) * cell_size, 0]))\n if i == j:\n sq.set_fill(GREEN, opacity=0.15)\n else:\n sq.set_fill(RED, opacity=0.08)\n cells.add(sq)\n num = Text(str(values[i][j]), font_size=22)\n num.move_to(sq.get_center())\n numbers.add(num)\n matrix_group.add(cells, numbers)\n matrix_group.next_to(context, DOWN, buff=0.5)\n self.play(FadeIn(matrix_group), run_time=2.0)\n diag_boxes = VGroup()\n for i in range(n):\n box = SurroundingRectangle(cells[i * n + i], color=GREEN, buff=0.05, stroke_width=3)\n diag_boxes.add(box)\n self.play(Create(diag_boxes), run_time=2.0)\n error_boxes = VGroup()\n for i in range(n):\n for j in range(n):\n if i != j and values[i][j] > 0:\n box = SurroundingRectangle(cells[i * n + j], color=RED, buff=0.05, stroke_width=3)\n error_boxes.add(box)\n self.play(Create(error_boxes), run_time=2.0)\n self.play(FadeOut(header), FadeOut(context), FadeOut(matrix_group), FadeOut(diag_boxes), FadeOut(error_boxes))\n summary_title = Text('Key Takeaways', font_size=32, color=BLUE)\n summary_title.to_edge(UP, buff=0.5)\n bullets = VGroup(Text('• Rows = Actual labels', font_size=24), Text('• Columns = Predicted labels', font_size=24), Text('• Diagonal = High accuracy', font_size=24), Text('• Off-diagonal = Model confusion', font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.35)\n bullets.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeIn(summary_title), run_time=2.0 * 0.2)\n self.play(FadeIn(bullets), run_time=2.0 * 0.8)\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass SequenceModelingConfusionMatrixVisualization(Scene):\n\n def construct(self):\n title = Text('Sequence Modeling: Confusion Matrix', font_size=36)\n subtitle = Text('Visualizing Model Performance', font_size=24, color=BBLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n header.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0 * 0.6)\n self.play(FadeIn(subtitle), run_time=2.0 * 0.4)\n context = VGroup(Text('Context: \"The cat ...\"', font_size=22), Text('Prediction: \"sat\"', font_size=22, color=GREEN)).arrange(DOWN, buff=0.2)\n context.next_to(header, DOWN, buff=0.5)\n self.play(FadeIn(context), run_time=2.0)\n classes = ['the', 'cat', 'sat']\n n = len(classes)\n cell_size = 0.9\n values = [[8, 1, 1], [2, 7, 0], [0, 1, 9]]\n matrix_group = VGroup()\n top_labels = VGroup(*[Text(c, font_size=20) for c in classes])\n for j, lbl in enumerate(top_labels):\n lbl.move_to(np.array([(j - 1) * cell_size, cell_size + 0.35, 0]))\n matrix_group.add(top_labels)\n pred_label = Text('Predicted', font_size=20)\n pred_label.next_to(top_labels, UP, buff=0.2)\n matrix_group.add(pred_label)\n left_labels = VGroup(*[Text(c, font_size=20) for c in classes])\n for i, lbl in enumerate(left_labels):\n lbl.move_to(np.array([-cell_size - 0.4, -(i - 1) * cell_size, 0]))\n matrix_group.add(left_labels)\n act_label = Text('Actual', font_size=20)\n act_label.next_to(left_labels, LEFT, buff=0.3)\n matrix_group.add(act_label)\n cells = VGroup()\n numbers = VGroup()\n for i in range(n):\n for j in range(n):\n sq = Square(side_length=cell_size, stroke_width=2)\n sq.move_to(np.array([(j - 1) * cell_size, -(i - 1) * cell_size, 0]))\n if i == j:\n sq.set_fill(GREEN, opacity=0.15)\n else:\n sq.set_fill(RED, opacity=0.08)\n cells.add(sq)\n num = Text(str(values[i][j]), font_size=22)\n num.move_to(sq.get_center())\n numbers.add(num)\n matrix_group.add(cells, numbers)\n matrix_group.next_to(context, DOWN, buff=0.5)\n self.play(FadeIn(matrix_group), run_time=2.0)\n diag_boxes = VGroup()\n for i in range(n):\n box = SurroundingRectangle(cells[i * n + i], color=GREEN, buff=0.05, stroke_width=3)\n diag_boxes.add(box)\n self.play(Create(diag_boxes), run_time=2.0)\n error_boxes = VGroup()\n for i in range(n):\n for j in range(n):\n if i != j and values[i][j] > 0:\n box = SurroundingRectangle(cells[i * n + j], color=RED, buff=0.05, stroke_width=3)\n error_boxes.add(box)\n self.play(Create(error_boxes), run_time=2.0)\n self.play(FadeOut(header), FadeOut(context), FadeOut(matrix_group), FadeOut(diag_boxes), FadeOut(error_boxes))\n summary_title = Text('Key Takeaways', font_size=32, color=BLUE)\n summary_title.to_edge(UP, buff=0.5)\n bullets = VGroup(Text('• Rows = Actual labels', font_size=24), Text('• Columns = Predicted labels', font_size=24), Text('• Diagonal = High accuracy', font_size=24), Text('• Off-diagonal = Model confusion', font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.35)\n bullets.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeIn(summary_title), run_time=2.0 * 0.2)\n self.play(FadeIn(bullets), run_time=2.0 * 0.8)\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Perceived Loudness and Logarithmic Compression\n\n#### Weber-Fechner Law\n- Describes the nonlinear relationship between psychological quantities and physical quantities: the magnitude of the perceived quantity is proportional to the logarithm of the stimulus intensity.\n- In hearing, this manifests as: the human ear perceives loudness corresponding to logarithmic changes in sound pressure level, rather than linear amplitude changes.\n- Empirical rule: When sound intensity increases by a factor of 10 (i.e., 10 dB), the subjective perception of loudness only approximately doubles.\n\n\nContextual location of this section (from highest to current level):\n# Intelligent Voice Technology Course - Detailed Outline for Lecture 3 (Auditory Perception and Classical Acoustic Features, 90 minutes)\n## Nonlinear Characteristics of the Human Auditory System (30 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\nimport numpy as np\n\nclass WeberFechnerLaw(Scene):\n\n def construct(self):\n title = Text('Perceived Loudness & Logarithmic Compression', font_size=36, color=BLUE)\n title.to_edge(UP, buff=0.4)\n subtitle = Text('Weber-Fechner Law', font_size=28, color=YELLOW)\n subtitle.next_to(title, DOWN, buff=0.2)\n item1 = Tex('$\\\\bullet$ Nonlinear relationship: perceived quantity $\\\\propto \\\\log(\\\\text{stimulus intensity})$', font_size=28)\n item2 = Tex('$\\\\bullet$ Hearing: Loudness corresponds to logarithmic sound pressure changes', font_size=28)\n item3 = Tex('$\\\\bullet$ Empirical rule: $10\\\\times$ intensity (+10 dB) $\\\\rightarrow$ $2\\\\times$ subjective loudness', font_size=28)\n bullets = VGroup(item1, item2, item3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n bullets.next_to(subtitle, DOWN, buff=0.4)\n axes = Axes(x_range=[0, 110, 10], y_range=[0, 2.5, 1], x_length=8, y_length=3.2, axis_config={'include_numbers': False})\n axes.to_edge(DOWN, buff=0.4)\n x_label = Text('Physical Intensity', font_size=18).next_to(axes.x_axis, DOWN, buff=0.2)\n y_label = Text('Perceived Loudness', font_size=18).next_to(axes.y_axis, LEFT, buff=0.2).rotate(PI / 2)\n axes.x_axis.add_numbers([10, 100], font_size=18)\n axes.y_axis.add_numbers([1, 2], font_size=18)\n curve = axes.plot(lambda x: np.log10(x), x_range=[1, 100], color=GREEN)\n math_label = MathTex('P = k \\\\log_{10}(S)', font_size=24, color=GREEN).next_to(curve.point_from_proportion(0.7), UP, buff=0.3)\n p10 = axes.c2p(10, 1)\n p100 = axes.c2p(100, 2)\n lines_10 = VGroup(DashedLine(axes.c2p(10, 0), p10, color=YELLOW), DashedLine(axes.c2p(0, 1), p10, color=YELLOW))\n lines_100 = VGroup(DashedLine(axes.c2p(100, 0), p100, color=YELLOW), DashedLine(axes.c2p(0, 2), p100, color=YELLOW))\n dot_10 = Dot(p10, color=YELLOW)\n dot_100 = Dot(p100, color=YELLOW)\n arrow_x = DoubleArrow(axes.c2p(10, 0.15), axes.c2p(100, 0.15), tip_length=0.15, color=ORANGE)\n arrow_y = DoubleArrow(axes.c2p(4, 1), axes.c2p(4, 2), tip_length=0.15, color=ORANGE)\n text_x = Text('10x Intensity (+10 dB)', font_size=16, color=ORANGE).next_to(arrow_x, UP, buff=0.1)\n text_y = Text('2x Loudness', font_size=16, color=ORANGE).next_to(arrow_y, RIGHT, buff=0.1)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n for item in bullets:\n self.play(FadeIn(item, shift=RIGHT * 0.2))\n self.wait(0.4)\n else:\n pass\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(math_label))\n self.wait(0.5)\n self.play(Create(lines_10), FadeIn(dot_10))\n self.wait(0.3)\n self.play(Create(lines_100), FadeIn(dot_100))\n self.wait(0.5)\n self.play(GrowArrow(arrow_x), Write(text_x))\n self.play(GrowArrow(arrow_y), Write(text_y))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\nimport numpy as np\n\nclass WeberFechnerLaw(Scene):\n\n def construct(self):\n title = Text('Perceived Loudness & Logarithmic Compression', font_size=36, color=BLUE)\n title.to_edge(UP, buff=0.4)\n subtitle = Text('Weber-Fechner Law', font_size=28, color=YELLOW)\n subtitle.next_to(title, DOWN, buff=0.2)\n item1 = Tex('$\\\\bullet$ Nonlinear relationship: perceived quantity $\\\\propto \\\\log(\\\\text{stimulus intensity})$', font_size=28)\n item2 = Tex('$\\\\bullet$ Hearing: Loudness corresponds to logarithmic sound pressure changes', font_size=28)\n item3 = Tex('$\\\\bullet$ Empirical rule: $10\\\\times$ intensity (+10 dB) $\\\\rightarrow$ $2\\\\times$ subjective loudness', font_size=28)\n bullets = VGroup(item1, item2, item3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n bullets.next_to(subtitle, DOWN, buff=0.4)\n axes = Axes(x_range=[0, 110, 10], y_range=[0, 2.5, 1], x_length=8, y_length=3.2, axis_config={'include_numbers': False})\n axes.to_edge(DOWN, buff=0.4)\n x_label = Text('Physical Intensity', font_size=18).next_to(axes.x_axis, DOWN, buff=0.2)\n y_label = Text('Perceived Loudness', font_size=18).next_to(axes.y_axis, LEFT, buff=0.2).rotate(PI / 2)\n axes.x_axis.add_numbers([10, 100], font_size=18)\n axes.y_axis.add_numbers([1, 2], font_size=18)\n curve = axes.plot(lambda x: np.log10(x), x_range=[1, 100], color=GREEN)\n math_label = MathTex('P = k \\\\log_{10}(S)', font_size=24, color=GREEN).next_to(curve.point_from_proportion(0.7), UP, buff=0.3)\n p10 = axes.c2p(10, 1)\n p100 = axes.c2p(100, 2)\n lines_10 = VGroup(DashedLine(axes.c2p(10, 0), p10, color=YELLOW), DashedLine(axes.c2p(0, 1), p10, color=YELLOW))\n lines_100 = VGroup(DashedLine(axes.c2p(100, 0), p100, color=YELLOW), DashedLine(axes.c2p(0, 2), p100, color=YELLOW))\n dot_10 = Dot(p10, color=YELLOW)\n dot_100 = Dot(p100, color=YELLOW)\n arrow_x = DoubleArrow(axes.c2p(10, 0.15), axes.c2p(100, 0.15), tip_length=0.15, color=ORANGE)\n arrow_y = DoubleArrow(axes.c2p(4, 1), axes.c2p(4, 2), tip_length=0.15, color=ORANGE)\n text_x = Text('10x Intensity (+10 dB)', font_size=16, color=ORANGE).next_to(arrow_x, UP, buff=0.1)\n text_y = Text('2x Loudness', font_size=16, color=ORANGE).next_to(arrow_y, RIGHT, buff=0.1)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n for item in bullets:\n self.play(FadeIn(item, shift=RIGHT * 0.2))\n self.wait(0.4)\n else:\n pass\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(curve), Write(math_label))\n self.wait(0.5)\n self.play(Create(lines_10), FadeIn(dot_10))\n self.wait(0.3)\n self.play(Create(lines_100), FadeIn(dot_100))\n self.wait(0.5)\n self.play(GrowArrow(arrow_x), Write(text_x))\n self.play(GrowArrow(arrow_y), Write(text_y))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the effect of adding and removing elements on the levels of the cumulative hierarchy?", "chosen": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Set background color to dark blue\n # For older Manim versions:\n self.camera.background_color = \"#0C2D48\"\n # For ManimCE, uncomment the line below:\n # config.background_color = \"#0C2D48\"\n \n # Title\n title = Text(\"Navigating the Cumulative Hierarchy\", color=WHITE)\n subtitle = Text(\"Adding and Removing Sets\", color=WHITE, font_size=24)\n subtitle.next_to(title, DOWN)\n \n # Introduction\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Empty set and hierarchy visualization\n empty_set = MathTex(r\"\\emptyset\", color=WHITE)\n self.play(FadeIn(empty_set), run_time=1)\n self.wait(0.5)\n \n # Simple hierarchy with three nested circles\n circles = VGroup()\n for i in range(3):\n circle = Circle(radius=0.5 + i*0.5, color=BLUE_C, fill_opacity=0.2)\n circles.add(circle)\n \n self.play(Transform(empty_set, circles), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(empty_set))\n \n # Key concept 1: Adding a set\n concept1 = Text(\"Key concept 1: Adding sets\", color=WHITE, font_size=28)\n concept1.to_edge(UP)\n self.play(Write(concept1), run_time=1)\n \n # Simple power set representation\n base_set = Circle(radius=0.8, color=RED, fill_opacity=0.3)\n base_set.shift(LEFT*2)\n base_label = Text(\"S\", font_size=24, color=WHITE).move_to(base_set)\n \n power_set = Circle(radius=1.2, color=BLUE, fill_opacity=0.3)\n power_set.shift(RIGHT*2)\n power_label = MathTex(r\"\\mathcal{P}(S)\", color=WHITE).move_to(power_set)\n \n arrow = Arrow(base_set.get_right(), power_set.get_left(), color=WHITE)\n \n self.play(Create(base_set), Write(base_label), run_time=1)\n self.play(Create(arrow), run_time=0.8)\n self.play(Create(power_set), Write(power_label), run_time=1)\n \n # Power set equation\n equation1 = MathTex(r\"\\mathcal{P}(S) = \\{ X \\mid X \\subseteq S \\}\", color=WHITE)\n equation1.to_edge(DOWN, buff=1)\n \n self.play(Write(equation1), run_time=1.5)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept1), \n FadeOut(base_set), \n FadeOut(base_label),\n FadeOut(power_set), \n FadeOut(power_label),\n FadeOut(arrow), \n FadeOut(equation1)\n )\n \n # Key concept 2: Removing a set\n concept2 = Text(\"Key concept 2: Removing sets\", color=WHITE, font_size=28)\n concept2.to_edge(UP)\n self.play(Write(concept2), run_time=1)\n \n # Visualization of set removal\n elements = VGroup()\n for i in range(3):\n elem = Circle(radius=0.4, color=RED, fill_opacity=0.3)\n elem.shift(DOWN + (i-1)*RIGHT*1.5)\n elements.add(elem)\n \n combined_set = Circle(radius=1.2, color=BLUE, fill_opacity=0.3)\n combined_set.shift(UP*1.5)\n \n arrows = VGroup()\n for elem in elements:\n arrow = Arrow(elem.get_top(), combined_set.get_bottom(), color=WHITE)\n arrows.add(arrow)\n \n self.play(Create(elements), Create(combined_set), run_time=1.5)\n self.play(Create(arrows), run_time=1)\n self.wait(0.5)\n \n # Remove middle element\n self.play(\n FadeOut(elements[1]), \n FadeOut(arrows[1]), \n run_time=0.8\n )\n \n # Show impact on the combined set\n new_combined = Circle(radius=0.9, color=GREEN_C, fill_opacity=0.3).move_to(combined_set.get_center())\n self.play(Transform(combined_set, new_combined), run_time=1)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept2), \n FadeOut(elements[0]),\n FadeOut(elements[2]), \n FadeOut(combined_set), \n FadeOut(arrows[0]),\n FadeOut(arrows[2])\n )\n \n # Key concept 3: Glass layers\n concept3 = Text(\"Key concept 3: Layered Structure\", color=WHITE, font_size=28)\n concept3.to_edge(UP)\n self.play(Write(concept3), run_time=1)\n \n # Glass layers visualization (simplified to rectangles)\n layers = VGroup()\n for i in range(3):\n layer = Rectangle(height=0.3, width=4, fill_opacity=(i+1)*0.15, color=BLUE_C)\n layer.shift(UP*(i*0.4 - 0.4))\n layers.add(layer)\n \n self.play(Create(layers), run_time=1.2)\n \n # Adding a layer\n new_layer = Rectangle(height=0.3, width=4, fill_opacity=0.6, color=BLUE_C)\n new_layer.next_to(layers, UP, buff=0)\n \n self.play(Create(new_layer), run_time=0.8)\n self.wait(0.5)\n \n # Removing a layer\n self.play(FadeOut(layers[1]), run_time=0.8)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept3), \n FadeOut(layers[0]),\n FadeOut(layers[2]),\n FadeOut(new_layer)\n )\n \n # Key insight\n insight = Text(\"Key Insight\", color=WHITE, font_size=28)\n insight.to_edge(UP)\n \n equation2 = MathTex(r\"V_{\\alpha + 1} = \\mathcal{P}(V_{\\alpha})\", color=WHITE)\n \n self.play(Write(insight), run_time=0.8)\n self.play(Write(equation2), run_time=1.2)\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"The elegant dynamics of set theory\", color=WHITE, font_size=24)\n conclusion.next_to(equation2, DOWN, buff=1)\n \n self.play(Write(conclusion), run_time=1.2)\n self.wait(1.5)\n \n # Final fade out\n self.play(\n FadeOut(insight), \n FadeOut(equation2), \n FadeOut(conclusion), \n run_time=1.2\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Set background color to dark blue\n # For older Manim versions:\n self.camera.background_color = \"#0C2D48\"\n # For ManimCE, uncomment the line below:\n # config.background_color = \"#0C2D48\"\n \n # Title\n title = Text(\"Navigating the Cumulative Hierarchy\", color=WHITE)\n subtitle = Text(\"Adding and Removing Sets\", color=WHITE, font_size=24)\n subtitle.next_to(title, DOWN)\n \n # Introduction\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Empty set and hierarchy visualization\n empty_set = MathTex(r\"\\emptyset\" + \" = x\", color=WHITE)\n self.play(FadeIn(empty_set), run_time=1)\n self.wait(0.5)\n \n # Simple hierarchy with three nested circles\n circles = VGroup()\n for i in range(3):\n circle = Circle(radius=0.5 + i*0.5, color=BLUE_C, fill_opacity=0.2)\n circles.add(circle)\n \n self.play(Transform(empty_set, circles), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(empty_set))\n \n # Key concept 1: Adding a set\n concept1 = Text(\"Key concept 1: Adding sets\", color=WHITE, font_size=28)\n concept1.to_edge(UP)\n self.play(Write(concept1), run_time=1)\n \n # Simple power set representation\n base_set = Circle(radius=0.8, color=RED, fill_opacity=0.3)\n base_set.shift(LEFT*2)\n base_label = Text(\"S\", font_size=24, color=WHITE).move_to(base_set)\n \n power_set = Circle(radius=1.2, color=BLUE, fill_opacity=0.3)\n power_set.shift(RIGHT*2)\n power_label = MathTex(r\"\\mathcal{P}(S)\", color=WHITE).move_to(power_set)\n \n arrow = Arrow(base_set.get_right(), power_set.get_left(), color=WHITE)\n \n self.play(Create(base_set), Write(base_label), run_time=1)\n self.play(Create(arrow), run_time=0.8)\n self.play(Create(power_set), Write(power_label), run_time=1)\n \n # Power set equation\n equation1 = MathTex(r\"\\mathcal{P}(S) = \\{ X \\mid X \\subseteq S \\}\", color=WHITE)\n equation1.to_edge(DOWN, buff=1)\n \n self.play(Write(equation1), run_time=1.5)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept1), \n FadeOut(base_set), \n FadeOut(base_label),\n FadeOut(power_set), \n FadeOut(power_label),\n FadeOut(arrow), \n FadeOut(equation1)\n )\n \n # Key concept 2: Removing a set\n concept2 = Text(\"Key concept 2: Removing sets\", color=WHITE, font_size=28)\n concept2.to_edge(UP)\n self.play(Write(concept2), run_time=1)\n \n # Visualization of set removal\n elements = VGroup()\n for i in range(3):\n elem = Circle(radius=0.4, color=RED, fill_opacity=0.3)\n elem.shift(DOWN + (i-1)*RIGHT*1.5)\n elements.add(elem)\n \n combined_set = Circle(radius=1.2, color=BLUE, fill_opacity=0.3)\n combined_set.shift(UP*1.5)\n \n arrows = VGroup()\n for elem in elements:\n arrow = Arrow(elem.get_top(), combined_set.get_bottom(), color=WHITE)\n arrows.add(arrow)\n \n self.play(Create(elements), Create(combined_set), run_time=1.5)\n self.play(Create(arrows), run_time=1)\n self.wait(0.5)\n \n # Remove middle element\n self.play(\n FadeOut(elements[1]), \n FadeOut(arrows[1]), \n run_time=0.8\n )\n \n # Show impact on the combined set\n new_combined = Circle(radius=0.9, color=GREEN_C, fill_opacity=0.3).move_to(combined_set.get_center())\n self.play(Transform(combined_set, new_combined), run_time=1)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept2), \n FadeOut(elements[0]),\n FadeOut(elements[2]), \n FadeOut(combined_set), \n FadeOut(arrows[0]),\n FadeOut(arrows[2])\n )\n \n # Key concept 3: Glass layers\n concept3 = Text(\"Key concept 3: Layered Structure\", color=WHITE, font_size=28)\n concept3.to_edge(UP)\n self.play(Write(concept3), run_time=1)\n \n # Glass layers visualization (simplified to rectangles)\n layers = VGroup()\n for i in range(3):\n layer = Rectangle(height=0.3, width=4, fill_opacity=(i+1)*0.15, color=BLUE_C)\n layer.shift(UP*(i*0.4 - 0.4))\n layers.add(layer)\n \n self.play(Create(layers), run_time=1.2)\n \n # Adding a layer\n new_layer = Rectangle(height=0.3, width=4, fill_opacity=0.6, color=BLUE_C)\n new_layer.next_to(layers, UP, buff=0)\n \n self.play(Create(new_layer), run_time=0.8)\n self.wait(0.5)\n \n # Removing a layer\n self.play(FadeOut(layers[1]), run_time=0.8)\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(concept3), \n FadeOut(layers[0]),\n FadeOut(layers[2]),\n FadeOut(new_layer)\n )\n \n # Key insight\n insight = Text(\"Key Insight\", color=WHITE, font_size=28)\n insight.to_edge(UP)\n \n equation2 = MathTex(r\"V_{\\alpha + 1} = \\mathcal{P}(V_{\\alpha})\", color=WHITE)\n \n self.play(Write(insight), run_time=0.8)\n self.play(Write(equation2), run_time=1.2)\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"The elegant dynamics of set theory\", color=WHITE, font_size=24)\n conclusion.next_to(equation2, DOWN, buff=1)\n \n self.play(Write(conclusion), run_time=1.2)\n self.wait(1.5)\n \n # Final fade out\n self.play(\n FadeOut(insight), \n FadeOut(equation2), \n FadeOut(conclusion), \n run_time=1.2\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s the enhanced animation description: \n\nThe scene begins by creating a VGroup of three circles arranged in a grid, which are drawn sequentially with smooth animations. As the circles appear, a transformation matrix [[1, 2], [0, 1]] is applied, stretching them horizontally in a shear-like motion. Simultaneously, the x and y axes fade in, providing a reference frame for the transformation. To deepen understanding, a LaTeX formula appears above the circles, dynamically rendering the matrix equation \\( \\begin{pmatrix} x' \\\\ y' \\end{pmatrix} = \\begin{pmatrix} 1 & 2 \\\\ 0 & 1 \\end{pmatrix} \\begin{pmatrix} x \\\\ y \\end{pmatrix} \\) alongside an explanatory label (\"Horizontal Shear\"). As the transformation completes, the original and transformed positions of the circles are briefly connected with dashed lines to visualize the movement. Finally, the axes, formula, and circles fade out gracefully, leaving a clean slate. This enhanced version not only demonstrates the linear transformation but also reinforces the underlying mathematical concept with visual and textual cues.", "chosen": "```python\nfrom manim import *\n\nclass LinearTransformationScene(Scene):\n def construct(self):\n # Create circles arranged in a grid\n circles = VGroup(\n Circle(radius=0.5, color=BLUE).shift(LEFT + UP),\n Circle(radius=0.5, color=GREEN).shift(LEFT + DOWN),\n Circle(radius=0.5, color=RED).shift(RIGHT + UP)\n )\n \n # Draw circles sequentially\n for circle in circles:\n self.play(Create(circle), run_time=0.5)\n \n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE}\n )\n \n # Fade in axes\n self.play(FadeIn(axes), run_time=1)\n \n # Create matrix equation\n matrix_tex = MathTex(\n r\"\\begin{pmatrix} x' \\\\ y' \\end{pmatrix} = \"\n r\"\\begin{pmatrix} 1 & 2 \\\\ 0 & 1 \\end{pmatrix} \"\n r\"\\begin{pmatrix} x \\\\ y \\end{pmatrix}\",\n color=YELLOW\n ).to_edge(UP)\n \n label = Text(\"Horizontal Shear\", color=WHITE).next_to(matrix_tex, DOWN)\n \n # Show equation and label\n self.play(Write(matrix_tex), Write(label), run_time=1.5)\n \n # Apply transformation matrix\n transformed_circles = circles.copy()\n matrix = [[1, 2], [0, 1]]\n transformed_circles.apply_matrix(matrix)\n \n # Animate transformation\n self.play(\n Transform(circles, transformed_circles),\n run_time=2\n )\n \n # Connect original and transformed positions with dashed lines\n for original, transformed in zip(circles.copy(), transformed_circles):\n line = DashedLine(original.get_center(), transformed.get_center(), color=WHITE)\n self.play(Create(line), run_time=0.5)\n \n # Fade out everything\n self.play(\n FadeOut(circles),\n FadeOut(axes),\n FadeOut(matrix_tex),\n FadeOut(label),\n *[FadeOut(mob) for mob in self.mobjects if isinstance(mob, DashedLine)],\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass LinearTransformationScene(Scene):\n def construct(self):\n # Create circles arranged in a grid\n circles = VGroup(\n Circle(radius=0.5, color=BBLUE).shift(LEFT + UP),\n Circle(radius=0.5, color=GREEN).shift(LEFT + DOWN),\n Circle(radius=0.5, color=RED).shift(RIGHT + UP)\n )\n \n # Draw circles sequentially\n for circle in circles:\n self.play(Create(circle), run_time=0.5)\n \n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": WHITE}\n )\n \n # Fade in axes\n self.play(FadeIn(axes), run_time=1)\n \n # Create matrix equation\n matrix_tex = MathTex(\n r\"\\begin{pmatrix} x' \\\\ y' \\end{pmatrix} = \"\n r\"\\begin{pmatrix} 1 & 2 \\\\ 0 & 1 \\end{pmatrix} \"\n r\"\\begin{pmatrix} x \\\\ y \\end{pmatrix}\",\n color=YELLOW\n ).to_edge(UP)\n \n label = Text(\"Horizontal Shear\", color=WHITE).next_to(matrix_tex, DOWN)\n \n # Show equation and label\n self.play(Write(matrix_tex), Write(label), run_time=1.5)\n \n # Apply transformation matrix\n transformed_circles = circles.copy()\n matrix = [[1, 2], [0, 1]]\n transformed_circles.apply_matrix(matrix)\n \n # Animate transformation\n self.play(\n Transform(circles, transformed_circles),\n run_time=2\n )\n \n # Connect original and transformed positions with dashed lines\n for original, transformed in zip(circles.copy(), transformed_circles):\n line = DashedLine(original.get_center(), transformed.get_center(), color=WHITE)\n self.play(Create(line), run_time=0.5)\n \n # Fade out everything\n self.play(\n FadeOut(circles),\n FadeOut(axes),\n FadeOut(matrix_tex),\n FadeOut(label),\n *[FadeOut(mob) for mob in self.mobjects if isinstance(mob, DashedLine)],\n run_time=1\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that visually demonstrates the Pythagorean theorem? It should include the equation \"a^2 + b^2 = c^2\" written out, followed by a right triangle appearing on the screen. Next, can you show squares being formed on each side of the triangle to represent \"a^2\", \"b^2\", and \"c^2\" respectively? I'd also like two separate pieces of text that explain the concept: one that says \"Consider squares on each side\" and another that changes to say \"Area of c^2 is equal to sum of a^2 and b^2\". To conclude, can you transform the original equation into a final statement at the bottom of the screen, clear everything else, and then rewrite the equation one more time to emphasize the conclusion? Include pauses in the animation to allow the viewer to understand each step.", "chosen": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\n title = MathTex(\"a^2 + b^2 = c^2\").scale(1.5)\n self.play(Write(title))\n self.wait(2)\n\n # Clear the title for the next steps\n self.play(FadeOut(title))\n\n # --- Step 2: Create Triangle ---\n triangle = Polygon(\n ORIGIN, \n RIGHT*2, \n UP*1.732, \n color=BLUE, \n fill_opacity=0.5\n )\n \n # Add labels for sides\n label_a = Text(\"a\", font_size=28).next_to(RIGHT*2, DOWN, buff=0.1)\n label_b = Text(\"b\", font_size=28).move_to(triangle.get_vertices()[0])\n label_c = Text(\"c\", font_size=28).rotate(-PI/6).move_to(triangle.get_center())\n \n # Animate the creation of the triangle and its labels\n self.play(Create(triangle), Write(label_a), Write(label_b), Write(label_c))\n self.wait(2)\n\n # --- Step 3: Form Squares ---\n square_a = Square(side_length=2, color=RED, fill_opacity=0.3)\n square_b = Square(side_length=1.732, color=GREEN, fill_opacity=0.3)\n square_c = Square(side_length=2.236, color=YELLOW, fill_opacity=0.3) \n \n # Position squares such that their areas match the sides of the triangle\n square_a.next_to(triangle.get_vertices()[0], LEFT, buff=-1)\n square_b.move_to(triangle.get_vertices()[1])\n square_c.move_to(triangle.get_vertices()[2])\n\n # Group squares for transformation later\n squares_group = VGroup(square_a.copy(), square_b.copy(), square_c.copy())\n\n # Draw the squares\n self.play(Create(square_a), Create(square_b), Create(square_c))\n self.wait(2)\n\n # --- Step 4: Explanatory Text ---\n explanation1 = Text(\"Consider squares on each side\", font_size=24)\n explanation1.to_edge(UP)\n explanation2 = Text(\"Area of c^2 is equal to sum of a^2 and b^2\", font_size=24)\n explanation2.next_to(explanation1, DOWN, buff=0.5)\n \n self.play(Write(explanation1))\n self.wait(1)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Move explanations up to make room for equations at the bottom\n self.play(\n FadeOut(triangle),\n FadeOut(squares_group),\n FadeOut(label_a),\n FadeOut(label_b),\n FadeOut(label_c),\n explanation1.animate.shift(UP*2)\n )\n\n # --- Conclusion Steps ---\n\n # Transform original equation into final statement\n final_statement = MathTex(\"\\\\text{Final Result: } c^2 \\\\stackrel{\\\\triangle}{=} a^2 + b^2\")\n final_statement.scale(1.2)\n final_statement.to_edge(DOWN)\n \n self.play(Write(final_statement))\n self.wait(2)\n\n # Clear everything except the final equation\n self.play(\n FadeOut(squares_group),\n FadeOut(triangle),\n FadeOut(label_a),\n FadeOut(label_b),\n FadeOut(label_c),\n FadeOut(explanation1),\n )\n self.wait(1)\n\n # Rewrite the equation once more to emphasize the conclusion\n emphasized_eq = MathTex(\"c^2 \\\\stackrel{\\\\triangle}{=} a^2 + b^2\")\n emphasized_eq.scale(1.5)\n emphasized_eq.to_edge(DOWN)\n \n self.play(Write(emphasized_eq))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\n title_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.5)\n self.play(Write(title_eq))\n self.wait(2)\n\n # --- Step 2: Create Triangle ---\n # Right angle triangle with sides labeled for clarity\n triangle_vertices = [\n ORIGIN,\n RIGHT * 4,\n UP * 3 + RIGHT * 4,\n ]\n triangle = Polygon(\n *triangle_vertices,\n color=BLUE,\n fill_opacity=0.3\n )\n \n # Label the sides based on their lengths\n labels = VGroup()\n for i, start_point in enumerate(triangle_vertices[:-1]):\n end_point = triangle_vertices[i+1]\n \n # Calculate direction vector and rotate it 90 degrees counter-clockwise for labeling position\n direction_vector = (end_point - start_point).normalize()\n label_pos = start_point + direction_vector.rotate(-PI/2) * 0.8\n \n if i == 2:\n # Hypotenuse: C\n label_text = MathTex(\"c\")\n elif i == 0:\n # Side adjacent to hypotenuse (A)\n label_text = MathTex(\"a\")\n else:\n # Side opposite to A (B)\n label_text = MathTex(\"b\")\n \n label_text.next_to(label_pos, LEFT, buff=0.1)\n labels.add(label_text)\n \n # Animate the creation of both the triangle and its labels\n self.play(Create(triangle), Write(labels))\n self.wait(2)\n\n # --- Step 3: Form Squares on Each Side ---\n # Square on 'a' side (adjacent to hypotenuse)\n square_a = Square(side_length=4, color=GREEN)\n square_a.move_to([4, 1.5, 0])\n \n # Square on 'b' side (opposite to 'a')\n square_b = Square(side_length=3, color=YELLOW)\n square_b.move_to([1.5, 2.5, 0])\n\n # Area representation for 'c'\n area_c = Rectangle(width=7.6, height=6.1, color=RED)\n area_c.move_to([2.3, 0.8, 0]) \n area_c.shift(RIGHT*0.3)\n \n self.play(FadeIn(square_a), FadeIn(square_b), FadeIn(area_c))\n self.wait(2)\n\n # --- Step 4: Add Explanatory Text ---\n text_explain = Text(\"Consider squares on each side\", font_size=28).to_edge(UP)\n self.play(Write(text_explain))\n\n self.wait(2)\n\n # Change text to second explanation\n text_change = Text(\"Area of $c^2$ is equal to sum of $a^2$ and $b^2$\", font_size=28).to_edge(UP)\n self.play(Transform(text_explain, text_change))\n\n # Move equations up to make room for the conclusion\n self.play(\n title_eq.animate.to_edge(DOWN),\n text_explain.animate.to_edge(UP)\n )\n\n self.wait(2)\n\n # --- Step 5: Transform Original Equation and Emphasize Conclusion ---\n # Clear intermediate shapes to make space for the final result\n self.play(\n FadeOut(triangle), \n FadeOut(labels), \n FadeOut(square_a), \n FadeOut(square_b), \n FadeOut(area_c),\n )\n \n # Prepare final emphasis\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.8)\n final_box = SurroundingRectangle(final_eq, color=WHITE, buff=0.2)\n final_title = Text(\"Pythagorean Theorem Proved Visually\", font_size=30).next_to(final_eq, DOWN)\n \n self.play(Write(final_eq), run_time=1.5)\n self.play(Create(final_box), write(final_title), run_time=1.5)\n self.wait(3)\n\n# To render this animation, save the file as pyth_theo.py and run:\n# manim -pql pyth_theo.py PythagoreanTheorem\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Absorption Laws\n\nThe absorption laws are used to simplify expressions that contain repeated variables in conjunction with disjunction operations, greatly simplifying the formula structure:\n1. $P \\lor (P \\land Q) \\equiv P$\n2. $P \\land (P \\lor Q) \\equiv P$\n\n*Intuitive understanding: Taking the first example, if $P$ is true, the entire expression is true; if $P$ is false, then $P \\land Q$ is also false, making the entire expression false. The result depends entirely on $P$.*\n\n\nThe context of this section (from highest to current level):\n# Discrete Mathematics: Propositional Logic, Logical Equivalence, and Implication\n## Logical Equivalence (Logical Equivalence)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AbsorptionLaws(Scene):\n\n def construct(self):\n title = Text('Absorption Laws', 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('Simplifies expressions with repeated variables in conjunction and disjunction.', font_size=24)\n intro_text.next_to(title_group, DOWN, buff=0.5)\n self.play(FadeIn(intro_text, shift=UP * 0.2), run_time=1.2)\n law1 = MathTex('1.\\\\; P \\\\lor (P \\\\land Q) \\\\equiv P', font_size=40)\n law2 = MathTex('2.\\\\; P \\\\land (P \\\\lor Q) \\\\equiv P', font_size=40)\n laws_group = VGroup(law1, law2).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n laws_group.next_to(intro_text, DOWN, buff=0.6)\n self.play(Write(law1), run_time=1)\n self.play(Write(law2), run_time=1)\n highlight_box = SurroundingRectangle(law1, color=YELLOW, buff=0.15)\n self.play(Create(highlight_box), run_time=0.8)\n intuition_title = Text('Intuitive understanding for Law 1:', font_size=28, color=YELLOW)\n case1 = MathTex('\\\\text{If } P \\\\text{ is True:} \\\\implies \\\\text{True} \\\\lor (\\\\text{True} \\\\land Q) \\\\equiv \\\\text{True}', font_size=32)\n case2 = MathTex('\\\\text{If } P \\\\text{ is False:} \\\\implies \\\\text{False} \\\\lor (\\\\text{False} \\\\land Q) \\\\equiv \\\\text{False} \\\\lor \\\\text{False} \\\\equiv \\\\text{False}', font_size=32)\n conclusion = Text('The result depends entirely on P.', font_size=28, color=GREEN)\n intuition_group = VGroup(intuition_title, case1, case2, conclusion).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n intuition_group.next_to(laws_group, DOWN, buff=0.6)\n self.play(Write(intuition_title), run_time=1)\n self.play(FadeIn(case1, shift=RIGHT * 0.3), run_time=1.2)\n self.play(FadeIn(case2, shift=RIGHT * 0.3), run_time=1.2)\n self.play(Write(conclusion), run_time=1)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AbsorptionLaws(Scene):\n\n def construct(self):\n title = Text('Absorption Laws', 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('Simplifies expressions with repeated variables in conjunction and disjunction.', font_size=24)\n intro_text.next_to(title_group, DOWN, buff=0.5)\n self.play(FadeIn(intro_text, shift=UP * 0.2), run_time=1.2)\n law1 = MathTex('1.\\\\; P \\\\lor (P \\\\land Q) \\\\equiv P', font_size=40)\n law2 = MathTex('2.\\\\; P \\\\land (P \\\\lor Q) \\\\equiv P', font_size=40)\n laws_group = VGroup(law1, law2).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n laws_group.next_to(intro_text, DOWN, buff=0.6)\n self.play(Write(law1), run_time=1)\n self.play(Write(law2), run_time=1)\n highlight_box = SurroundingRectangle(law1, color=YELLOW, buff=0.15)\n self.play(Create(highlight_box), run_time=0.8)\n intuition_title = Text('Intuitive understanding for Law 1:', font_size=28, color=YELLOW)\n case1 = MathTex('\\\\text{If } P \\\\text{ is True:} \\\\implies \\\\text{True} \\\\lor (\\\\text{True} \\\\land Q) \\\\equiv \\\\text{True}', font_size=32)\n case2 = MathTex('\\\\text{If } P \\\\text{ is False:} \\\\implies \\\\text{False} \\\\lor (\\\\text{False} \\\\land Q) \\\\equiv \\\\text{False} \\\\lor \\\\text{False} \\\\equiv \\\\text{False}', font_size=32)\n conclusion = Text('The result depends entirely on P.', font_size=28, color=GREEN)\n intuition_group = VGroup(intuition_title, case1, case2, conclusion).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n intuition_group.next_to(laws_group, DOWN, buff=0.6)\n self.play(Write(intuition_title), run_time=1)\n self.play(FadeIn(case1, shift=RIGHT * 0.3), run_time=1.2)\n self.play(FadeIn(case2, shift=RIGHT * 0.3), run_time=1.2)\n self.play(Write(conclusion), run_time=1)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that visualizes the formation of an ionic compound for my chemistry class? Start by showing separate representations of an oxygen molecule, a metal atom, and an electron. These should appear in a row, with some space between them. Then, have a positively charged ion fade in above this group, and a negatively charged ion fade in below the group. After that, I'd like the oxygen, metal, and electron to transform into the ionic compound, consisting of the positive and negative ions placed side by side. Next, let the ionic compound move in a zigzag motion across the screen, as if it's showing the random movement of ions in a solution. Finish the animation by fading out the ionic compound at the end. Can the whole sequence last about 12 seconds?", "chosen": "```python\nfrom manim import *\n\nclass IonicCompoundFormation(Scene):\n def construct(self):\n # 1. Initial State: Oxygen Molecule, Metal Atom, Electron\n o2 = MathTex(\"O_2\", color=RED).scale(1.5)\n metal = MathTex(\"Na\", color=GRAY).scale(1.5)\n \n # Electron represented as a small charged particle\n electron_dot = Circle(radius=0.15, color=BLUE, fill_opacity=1)\n electron_sign = MathTex(\"-\", font_size=24, color=WHITE).move_to(electron_dot.get_center())\n electron = VGroup(electron_dot, electron_sign)\n \n # Group the initial components and arrange them horizontally\n initial_group = VGroup(o2, metal, electron).arrange(RIGHT, buff=1.5).move_to(ORIGIN)\n \n # 2. Ion Appearance: Positive above, Negative below\n pos_ion_template = MathTex(\"Na^+\", color=BLUE).scale(1.5).next_to(initial_group, UP, buff=1.5)\n neg_ion_template = MathTex(\"O^{2-}\", color=RED).scale(1.5).next_to(initial_group, DOWN, buff=1.5)\n \n # The final ionic compound (Cation and Anion side-by-side)\n final_pos = MathTex(\"Na^+\", color=BLUE).scale(1.5)\n final_neg = MathTex(\"O^{2-}\", color=RED).scale(1.5)\n compound = VGroup(final_pos, final_neg).arrange(RIGHT, buff=0.5).move_to(ORIGIN)\n\n # --- Animation Sequence (Total ~12 Seconds) ---\n \n # Step 1: Show separate representations (2 seconds)\n self.play(FadeIn(initial_group), run_time=2)\n \n # Step 2: Ions fade in above and below (2 seconds)\n self.play(FadeIn(pos_ion_template), FadeIn(neg_ion_template), run_time=2)\n \n # Step 3: Transform initial entities into the ionic compound (2 seconds)\n # Metal becomes cation, oxygen becomes anion, electron is transferred (fades out)\n self.play(\n ReplacementTransform(metal, final_pos),\n ReplacementTransform(o2, final_neg),\n FadeOut(electron),\n FadeOut(pos_ion_template),\n FadeOut(neg_ion_template),\n run_time=2\n )\n \n # Step 4: Zigzag motion simulating random movement in solution (4 seconds)\n # Define a series of coordinates to create a zigzag path across the screen\n start_x = compound.get_x()\n zigzag_points = [\n [start_x + 1.0, 0.5, 0],\n [start_x + 2.0, -0.5, 0],\n [start_x + 3.0, 0.5, 0],\n [start_x + 4.0, -0.5, 0],\n [start_x + 5.0, 0, 0]\n ]\n \n # Animate the compound moving to each point in the sequence\n for point in zigzag_points:\n self.play(\n compound.animate.move_to(point), \n run_time=0.8, \n rate_func=linear\n )\n \n # Step 5: Fade out the ionic compound to end the scene (2 seconds)\n self.play(FadeOut(compound), run_time=2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IonicCompoundFormation(Scene):\n def construct(self):\n # 1. Initial State: Oxygen Molecule, Metal Atom, Electron\n o2 = MathTex(\"O_2\", color=RED).scale(1.5)\n metal = MathTex(\"Na\", color=GRAY).scale(1.5)\n \n # Electron represented as a small charged particle\n electron_dot = Circle(radius=0.15, color=BLUE, fill_opacity=1)\n electron_sign = MathTex(\"-\", font_size=24, color=WHITE).move_to(electron_dot.get_center())\n electron = VGroup(electron_dot, electron_sign)\n \n # Group the initial components and arrange them horizontally\n initial_group = VGroup(o2, metal, electron).arrange(RIGHT, buff=1.5).move_to(ORIGIN)\n \n # 2. Ion Appearance: Positive above, Negative below\n pos_ion_template = MathTex(\"Na^+\", color=BLUE).scale(1.5).next_to(initial_group, UP, buff=1.5)\n neg_ion_template = MathTex(\"O^{2-}\", color=RED).scale(1.5).next_to(initial_group, DOWN, buff=1.5)\n \n # The final ionic compound (Cation and Anion side-by-side)\n final_pos = MathTex(\"Na^+\", color=BLUE).scale(1.5)\n final_neg = MathTex(\"O^{2-}\", color=RED).scale(1.5)\n compound = VGroup(final_pos, final_neg).arrange(RIGHT, buff=0.5).move_to(ORIGIN)\n\n # --- Animation Sequence (Total ~12 Seconds) ---\n \n # Step 1: Show separate representations (2 seconds)\n self.play(FadeIn(initial_group), run_time=2)\n \n # Step 2: Ions fade in above and below (2 seconds)\n self.play(FadeIn(pos_ion_template), FadeIn(neg_ion_template), run_time=2)\n \n # Step 3: Transform initial entities into the ionic compound (2 seconds)\n # Metal becomes cation, oxygen becomes anion, electron is transferred (fades out)\n self.play(\n ReplacementTransform(target_position=ORIGIN, metal, final_pos),\n ReplacementTransform(o2, final_neg),\n FadeOut(electron),\n FadeOut(pos_ion_template),\n FadeOut(neg_ion_template),\n run_time=2\n )\n \n # Step 4: Zigzag motion simulating random movement in solution (4 seconds)\n # Define a series of coordinates to create a zigzag path across the screen\n start_x = compound.get_x()\n zigzag_points = [\n [start_x + 1.0, 0.5, 0],\n [start_x + 2.0, -0.5, 0],\n [start_x + 3.0, 0.5, 0],\n [start_x + 4.0, -0.5, 0],\n [start_x + 5.0, 0, 0]\n ]\n \n # Animate the compound moving to each point in the sequence\n for point in zigzag_points:\n self.play(\n compound.animate.move_to(point), \n run_time=0.8, \n rate_func=linear\n )\n \n # Step 5: Fade out the ionic compound to end the scene (2 seconds)\n self.play(FadeOut(compound), run_time=2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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\nKey Points Review:\n\n- Dijkstra Algorithm: Efficient, based on greedy approach, only applicable to **non-negative weight graphs**, commonly uses heap optimization;\n- Bellman-Ford Algorithm: Stronger generality, can handle **negative weight edges** and detect negative cycles, but is less efficient;\n- Algorithm Selection: In practical applications, one should first check the edge weights and the size of the graph.\n\n\nThe context location of this section (from highest to current level):\n# Shortest Path Algorithms - Course Notes\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShortestPathSummary(Scene):\n\n def construct(self):\n title = Text('Shortest Path Algorithms Summary', 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 self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n d_title = Text('Dijkstra Algorithm', font_size=28, color=BLUE)\n bf_title = Text('Bellman-Ford Algorithm', font_size=28, color=RED)\n d_title.move_to(LEFT * 3.5 + UP * 1.5)\n bf_title.move_to(RIGHT * 3.5 + UP * 1.5)\n d_line = Line(LEFT, RIGHT, color=BLUE).match_width(d_title).next_to(d_title, DOWN, buff=0.1)\n bf_line = Line(LEFT, RIGHT, color=RED).match_width(bf_title).next_to(bf_title, DOWN, buff=0.1)\n self.play(FadeIn(d_title, shift=UP * 0.2), FadeIn(bf_title, shift=UP * 0.2), Create(d_line), Create(bf_line), run_time=1)\n d_p1 = Text('- Greedy approach', font_size=24)\n d_p2 = Text('- Non-negative weights only', font_size=24, color=YELLOW)\n d_p3 = Text('- Heap optimization (Fast)', font_size=24)\n d_points = VGroup(d_p1, d_p2, d_p3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n d_points.next_to(d_line, DOWN, buff=0.4).align_to(d_line, LEFT)\n self.play(Write(d_points, run_time=2))\n bf_p1 = Text('- High generality', font_size=24)\n bf_p2 = Text('- Handles negative weights', font_size=24, color=YELLOW)\n bf_p3 = Text('- Detects negative cycles', font_size=24, color=YELLOW)\n bf_p4 = Text('- Less efficient (Slow)', font_size=24)\n bf_points = VGroup(bf_p1, bf_p2, bf_p3, bf_p4).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bf_points.next_to(bf_line, DOWN, buff=0.4).align_to(bf_line, LEFT)\n self.play(Write(bf_points, run_time=2))\n rule_title = Text('Algorithm Selection Rule', font_size=26, color=GREEN, weight=BOLD)\n rule_desc = Text('First check edge weights and the size of the graph', font_size=24)\n rule_group = VGroup(rule_title, rule_desc).arrange(DOWN, buff=0.2)\n rule_group.move_to(DOWN * 2.5)\n rule_box = SurroundingRectangle(rule_group, color=GREEN, buff=0.3)\n self.play(FadeIn(rule_group, shift=UP * 0.2), Create(rule_box), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShortestPathSummary(Scene):\n\n def construct(self):\n title = Text('Shortest Path Algorithms Summary', 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 self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n d_title = Text('Dijkstra Algorithm', font_size=28, color=BBLUE)\n bf_title = Text('Bellman-Ford Algorithm', font_size=28, color=RED)\n d_title.move_to(LEFT * 3.5 + UP * 1.5)\n bf_title.move_to(RIGHT * 3.5 + UP * 1.5)\n d_line = Line(LEFT, RIGHT, color=BLUE).match_width(d_title).next_to(d_title, DOWN, buff=0.1)\n bf_line = Line(LEFT, RIGHT, color=RED).match_width(bf_title).next_to(bf_title, DOWN, buff=0.1)\n self.play(FadeIn(d_title, shift=UP * 0.2), FadeIn(bf_title, shift=UP * 0.2), Create(d_line), Create(bf_line), run_time=1)\n d_p1 = Text('- Greedy approach', font_size=24)\n d_p2 = Text('- Non-negative weights only', font_size=24, color=YELLOW)\n d_p3 = Text('- Heap optimization (Fast)', font_size=24)\n d_points = VGroup(d_p1, d_p2, d_p3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n d_points.next_to(d_line, DOWN, buff=0.4).align_to(d_line, LEFT)\n self.play(Write(d_points, run_time=2))\n bf_p1 = Text('- High generality', font_size=24)\n bf_p2 = Text('- Handles negative weights', font_size=24, color=YELLOW)\n bf_p3 = Text('- Detects negative cycles', font_size=24, color=YELLOW)\n bf_p4 = Text('- Less efficient (Slow)', font_size=24)\n bf_points = VGroup(bf_p1, bf_p2, bf_p3, bf_p4).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n bf_points.next_to(bf_line, DOWN, buff=0.4).align_to(bf_line, LEFT)\n self.play(Write(bf_points, run_time=2))\n rule_title = Text('Algorithm Selection Rule', font_size=26, color=GREEN, weight=BOLD)\n rule_desc = Text('First check edge weights and the size of the graph', font_size=24)\n rule_group = VGroup(rule_title, rule_desc).arrange(DOWN, buff=0.2)\n rule_group.move_to(DOWN * 2.5)\n rule_box = SurroundingRectangle(rule_group, color=GREEN, buff=0.3)\n self.play(FadeIn(rule_group, shift=UP * 0.2), Create(rule_box), run_time=2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can we model the probability distribution of extreme weather events using the GEV distribution?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass GEVDistribution(Scene):\n def construct(self):\n # Title\n title = Text(\"Forecasting Extremes: GEV Distribution\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple coordinate system\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Create data points representing temperature maxima\n dots = VGroup(\n Dot(axes.c2p(1, 5), color=RED),\n Dot(axes.c2p(2, 6), color=RED),\n Dot(axes.c2p(3, 4), color=RED),\n Dot(axes.c2p(4, 7), color=RED),\n Dot(axes.c2p(5, 5), color=RED),\n Dot(axes.c2p(6, 8), color=RED),\n Dot(axes.c2p(7, 6), color=RED),\n Dot(axes.c2p(8, 9), color=RED),\n Dot(axes.c2p(9, 7), color=RED),\n )\n \n data_label = Text(\"Annual Temperature Maxima\", font_size=24).next_to(axes, UP, buff=0.5)\n \n self.play(Create(axes))\n self.play(Create(dots), Write(data_label))\n self.wait(1)\n \n # GEV curve (simple bell-shaped curve)\n curve = ParametricFunction(\n lambda t: axes.c2p(t, 3 + 5 * np.exp(-((t-5)/2)**2)),\n t_range=[0, 10],\n color=GREEN\n )\n \n gev_label = Text(\"GEV Distribution Curve\", font_size=24).next_to(axes, UP, buff=0.5)\n \n self.play(FadeOut(data_label))\n self.play(Write(gev_label), Create(curve))\n self.wait(1)\n \n # Simple GEV equation\n eq = Text(\"GEV(x) = exp(-(1 + ξ(x-μ)/\\sigma )^(-1/ξ))\", font_size=24).next_to(axes, DOWN, buff=0.5)\n self.play(Write(eq))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Predicting extreme weather with GEV\", font_size=28)\n self.play(FadeOut(axes), FadeOut(dots), FadeOut(curve), \n FadeOut(eq), FadeOut(gev_label), FadeOut(title))\n self.play(Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass GEVDistribution(Scene):\n def construct(self):\n # Title\n title = Text(\"Forecasting Extremes: GEV Distribution\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple coordinate system\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BBLUE},\n )\n \n # Create data points representing temperature maxima\n dots = VGroup(\n Dot(axes.c2p(1, 5), color=RED),\n Dot(axes.c2p(2, 6), color=RED),\n Dot(axes.c2p(3, 4), color=RED),\n Dot(axes.c2p(4, 7), color=RED),\n Dot(axes.c2p(5, 5), color=RED),\n Dot(axes.c2p(6, 8), color=RED),\n Dot(axes.c2p(7, 6), color=RED),\n Dot(axes.c2p(8, 9), color=RED),\n Dot(axes.c2p(9, 7), color=RED),\n )\n \n data_label = Text(\"Annual Temperature Maxima\", font_size=24).next_to(axes, UP, buff=0.5)\n \n self.play(Create(axes))\n self.play(Create(dots), Write(data_label))\n self.wait(1)\n \n # GEV curve (simple bell-shaped curve)\n curve = ParametricFunction(\n lambda t: axes.c2p(t, 3 + 5 * np.exp(-((t-5)/2)**2)),\n t_range=[0, 10],\n color=GREEN\n )\n \n gev_label = Text(\"GEV Distribution Curve\", font_size=24).next_to(axes, UP, buff=0.5)\n \n self.play(FadeOut(data_label))\n self.play(Write(gev_label), Create(curve))\n self.wait(1)\n \n # Simple GEV equation\n eq = Text(\"GEV(x) = exp(-(1 + ξ(x-μ)/\\sigma )^(-1/ξ))\", font_size=24).next_to(axes, DOWN, buff=0.5)\n self.play(Write(eq))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Predicting extreme weather with GEV\", font_size=28)\n self.play(FadeOut(axes), FadeOut(dots), FadeOut(curve), \n FadeOut(eq), FadeOut(gev_label), FadeOut(title))\n self.play(Write(conclusion))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an animation that visually represents a neural network with three layers: the first layer having 20 neurons, the second layer 10 neurons, and the third layer 5 neurons. Each neuron should be relatively small with a clear outline. The neurons should appear one layer at a time, each layer coming from above and then settling into position. After all layers are displayed, I want to see an animation that represents the forward pass of data through this network, going from the first layer to the last. The animation should be clear and hold on the final frame for a short moment before ending. Can you design something like this?", "chosen": "```python\n# Import required classes from Manim\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # Configuration settings\n layer_sizes = [20, 10, 5]\n layer_positions = [-3.0, 0.0, 3.0]\n neuron_radius = 0.1\n neuron_spacing = 0.8\n \n # --- Helper Functions ---\n \n def create_layer(neuron_count, x_pos=0, y_start=-1.5):\n \"\"\"Creates a vertical stack of neurons aligned horizontally.\"\"\"\n \n # Create individual dots representing neurons\n neurons = VGroup()\n for i in range(neuron_count):\n dot = Dot(\n radius=neuron_radius,\n color=BLUE,\n stroke_color=WHITE,\n fill_opacity=1\n )\n \n # Position vertically relative to start point\n offset_y = i * neuron_spacing\n \n # Center horizontally by default\n center_x = 0\n \n # Arrange left/right based on index modulo 2\n if neuron_count % 2 == 0:\n # Even indices (first half) go left\n if i < neuron_count // 2:\n center_x -= neuron_spacing * (i + 1)\n else:\n center_x += neuron_spacing * (i - neuron_count//2)\n else:\n # Odd indices (middle stays centered)\n if i <= neuron_count // 2:\n center_x -= neuron_spacing * i\n else:\n center_x += neuron_spacing * (i - neuron_count//2 - 1)\n\n # Apply offsets and add to group\n dot.move_to([center_x + x_pos, offset_y + y_start, 0])\n neurons.add(dot)\n \n return neurons\n\n def connect_layers(layer_a, layer_b):\n connections = []\n for n_a in layer_a:\n for n_b in layer_b:\n line = Line(\n n_a.get_center(),\n n_b.get_center(),\n stroke_width=2,\n stroke_opacity=0.3\n ).set_z_index(-1)\n \n connections.append(line)\n return VGroup(*connections)\n\n # --- Step 1: Layer Creation ---\n layers = VGroup()\n for size, pos in zip(layer_sizes, layer_positions):\n layer = create_layer(size, x_pos=pos)\n layers.add(layer)\n\n self.play(Create(layers))\n self.wait(1)\n\n # Animate each layer appearing sequentially from top to bottom\n for idx in range(len(layers)):\n layer_group = layers[:idx+1]\n self.play(FadeIn(layer_group, shift=UP))\n self.wait(0.5)\n\n self.wait(1)\n\n # --- Step 2: Forward Pass Animation ---\n \n # Connect adjacent layers with transparent lines\n connection_groups = [\n connect_layers(l1, l2).animate.set_stroke(opacity=0.2)\n for l1, l2 in zip(layers[:-1], layers[1:])\n ]\n \n # Display connections briefly\n self.play(LaggedStart(*connection_groups, lag_ratio=0.2))\n self.wait(0.5)\n \n # Simulate signal flow from input to output\n # Pulse each neuron up to the next layer sequentially\n for src_idx in range(len(layers)-1):\n src_layer = layers[src_idx]\n dest_layer = layers[src_idx+1]\n\n # Create pulse effect\n pulses = VGroup()\n for s_neuron in src_layer:\n pulse = Circle(radius=0.6, color=YELLOW, fill_opacity=0.3, stroke_width=0)\n pulse.move_to(s_neuron.get_center())\n pulses.add(pulse)\n\n self.play(LaggedStart(*[\n FadeIn(pulse) for pulse in pulses\n ], lag_ratio=0.1))\n\n # Send signals along connections\n signal_lines = VGroup()\n for s_dot, d_dots in zip(src_layer, [dest_layer]):\n for d_dot in d_dots:\n line = Line(\n s_dot.get_center(), \n d_dot.get_center(), \n stroke_color=ORANGE,\n stroke_width=2\n ).add_updater(lambda m: m.become(Line(\n s_dot.get_center(), \n d_dot.get_center(), \n stroke_color=ORANGE,\n stroke_width=2\n ))\n )\n signal_lines.add(line)\n\n self.add(signal_lines)\n\n # Allow signals to travel simultaneously\n self.play(\n *[UpdateFromFunc(line, lambda m:m) for line in signal_lines],\n run_time=0.7,\n rate_func=rush_into\n )\n\n self.remove(*signal_lines)\n self.wait(0.2)\n\n # Hold final state briefly before ending\n self.wait(1)\n\n# To render this animation:\n# manim -pql filename.py NeuralNetworkForwardPass\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n LAYER_COUNT = 3\n NEURON_PER_LAYER = [20, 10, 5]\n \n # Layer positions along Y-axis\n START_Y = -2\n SPACING_Y = 0.6\n \n # Neuron sizes\n RADIUS_SMALL = 0.28\n\n # Colors\n COLOR_INPUT = BLUE_D\n COLOR_HIDDEN = TEAL_D\n COLOR_OUTPUT = GREEN_D\n\n # Animation durations\n ANIM_DURATION_LAYER = 0.7\n ANIM_SPEED_FORWARD_PASS = 0.6\n HOLD_FRAME_SECONDS = 2\n\n # Create Network Layers\n layers = VGroup()\n node_positions = []\n\n for i in range(LAYER_COUNT):\n y_pos = START_Y + i * SPACING_Y\n \n # Arrange nodes vertically within their layer\n layer_group = VGroup()\n\n for j in range(NEURON_PER_LAYER[i]):\n pos_y = y_pos + (j - (NEURON_PER_LAYER[i]-1) / 2) * 0.5\n dot = Circle(radius=RADIUS_SMALL, color=WHITE)\n \n if i == 0:\n dot.set_color(COLOR_INPUT)\n elif i == 1:\n dot.set_color(COLOR_HIDDEN)\n else: # Last layer is output layer\n dot.set_color(COLOR_OUTPUT)\n\n layer_group.add(dot.move_to([i*SPACING_Y, pos_y, 0]))\n \n layer_group.shift(RIGHT * (i-1)*SPACING_Y * 1.5)\n layers.add(layer_group)\n \n # Store center positions by index\n node_positions.append(\n np.array([\n [dot.get_center()[0], pos_y, dot.get_center()[2]] \n for dot in layer_group\n ])\n )\n\n self.play(FadeIn(layers[0]), run_time=ANIM_DURATION_LAYER)\n self.play(FadeIn(layers[1]), run_time=ANIM_DURATION_LAYER)\n self.play(FadeIn(layers[2]), run_time=ANIM_DURATION_LAYER)\n \n self.wait(0.5)\n\n # Forward Pass Animations\n arrows = []\n \n for l_idx in range(len(node_positions)-1): # Connect only between adjacent layers\n start_nodes = VGroup(*[Dot(pos, radius=0.02, color=BLACK).set_opacity(0.1) for pos in node_positions[l_idx]])\n end_nodes = VGroup(*[Dot(pos, radius=0.02, color=COLOR_BLUE).set_opacity(0.1) for pos in node_positions[l_idx+1]])\n \n arrow = Arrow(start_nodes.get_center(), end_nodes.get_center(),\n buff=0, stroke_width=4, color=GRAY_A,\n max_tip_length_to_length_ratio=0.1)\n arrow.set_z_index(-1)\n self.play(Create(arrow), run_time=0.3, rate_func=linear)\n arrows.append((start_nodes, end_nodes, arrow))\n \n self.wait(0.5)\n\n # Animate connections passing signals across layers\n for src, dest, conn in arrows:\n dots = VGroup(*[\n Dot(src.get_center(), radius=0.03, color=WHITE).move_to(dest.get_center())\n for _ in range(max(int(len(src)/10), 1)) # Scale number of pulses based on signal density\n ])\n \n self.play(\n LaggedStartMap(\n FadeIn, dots, lag_ratio=0.1, run_time=0.8, rate_func=rush_into),\n *[Write(conn.copy()) for _ in range(dots[0].get_opacity())],\n run_speed=ANIM_SPEED_FORWARD_PASS\n )\n self.wait(0.5)\n self.play(FadeOut(dots, run_time=0.6))\n\n # Final Hold\n self.wait(HOLD_FRAME_SECONDS)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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 2: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0678(Scene):\n def clear_stage(self):\n if self.mobjects:\n FadeOut(*self.mobjects).set_run_time(0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_textcirclestaranimation()\n self.clear_stage()\n self.act_2_fxsquaringgraphanimation()\n\n def act_1_textcirclestaranimation(self):\n # --- Step 1: Text Transition ---\n initial_text = Text(\"Initial Message\", font_size=48)\n final_text = Text(\"New Upward Shifted Message\", font_size=48)\n\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # Animate transition to the second text with an upward shift effect\n self.play(\n ReplacementTransform(initial_text, final_text),\n final_text.animate.shift(UP * 2),\n run_time=1.5,\n rate_func=smooth\n )\n \n self.wait(0.5)\n self.play(FadeOut(final_text))\n\n # --- Step 2: Shape Sequence ---\n # Create a Circle containing a Star centered within it\n inner_star = Star(n=5, outer_radius=1.2, color=YELLOW)\n outer_circle = Circle(radius=1.8, stroke_color=RED, fill_opacity=0.2)\n\n combined_shape = VGroup(inner_star, outer_circle)\n combined_shape.move_to(ORIGIN)\n\n self.add(combined_shape)\n self.wait(0.5)\n\n # Expand the entire shape group simultaneously while moving the star outward\n self.play(\n combined_shape.animate.scale(2),\n inner_star.animate.shift(RIGHT * 1.5 + UP * 0.5),\n run_time=2,\n rate_func=smooth\n )\n\n self.wait(0.5)\n\n # --- Final Step: Disappearance ---\n # Smoothly remove both elements from the scene\n self.play(FadeOut(combined_shape), run_time=1.5)\n self.wait(1)\n\n def act_2_fxsquaringgraphanimation(self):\n func_expr = MathTex(\"f(x)\", \"=\", \"x^2\")\n func_expr.to_edge(UP)\n self.play(Write(func_expr))\n\n axes = Axes(\n x_range=[-2.5, 2.5],\n y_range=[-1, 5]\n ).scale(1.2).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(\"y\"))\n self.play(Create(axes), Write(labels))\n\n points = [\n (-2, 4), (-1.5, 2.25), (-1, 1), (-0.5, 0.25), (0, 0),\n (0.5, 0.25), (1, 1), (1.5, 2.25), (2, 4)\n ]\n curve = VMobject(color=GREEN)\n curve.set_points_as_corners([axes.c2p(x, y) for x, y in points])\n\n self.play(LaggedStart(*[\n Create(curve.copy().set_stroke(width=i*2))\n for i in range(1, 4)\n ], lag_ratio=0.2))\n \n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0867(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects), run_time=0.8)\n \n def construct(self):\n # --- First Act ---\n \n # Step 1: Text Transition\n initial_text = Text(\"Initial Message\", font_size=48).to_edge(UP)\n final_text = Text(\"Final Shifted Message\", font_size=48).shift(UP * 2)\n\n self.add(initial_text)\n self.wait(0.5)\n self.play(Transform(initial_text, final_text))\n self.wait(1)\n\n # Step 2: Shape Animation\n # Create Circle containing Star (Star is initially hidden)\n circle = Circle(radius=1.5, color=BLUE, fill_opacity=0.1)\n star = Star(n=5, outer_radius=0.8, inner_radius=0.4, color=YELLOW)\n shape_group = VGroup(circle, star).move_to(ORIGIN)\n \n self.play(Create(shape_group))\n self.wait(0.5)\n\n # Expand Circle while moving Star outward simultaneously\n self.play(\n circle.animate.scale(2),\n star.animate.shift(RIGHT * 2).rotate(-PI/4),\n rate_func=smooth,\n run_time=2\n )\n\n # Final Disappearance\n self.wait(0.5)\n self.play(FadeOut(shape_group))\n\n # Clear the first act content before entering the second act\n self.clear()\n self.wait(0.5)\n\n # --- Second Act ---\n\n func_text = MathTex(\"f(x)\", \"=\", \"x^2\").scale(1.5).to_edge(UP)\n self.play(Write(func_text))\n self.wait()\n\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-1, 5, 1]\n ).shift(DOWN*1.5 + LEFT*1.5).scale(1.2)\n axis_labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(\"f(x)\"))\n self.play(Create(axes), Write(axis_labels))\n self.wait(0.5)\n\n # Plotting the curve\n curve = axes.plot(lambda x: x**2, color=GREEN)\n self.play(Create(curve))\n self.wait(1)\n\n # Add area under the curve from -2 to 2\n area = axes.get_area(curve, x_range=(-2, 2), color=RED, opacity=0.3)\n self.play(FillBetween(curve, axes.get_y_axis(), x_range=(2, 2), color=RED, opacity=0.3))\n integral_expr = MathTex(\"\\\\int_{-2}^{2}\", \"x^2\", \"\\\\,dx\")\n integral_expr.next_to(area, DOWN, buff=0.5).set_color(YELLOW)\n self.play(Write(integral_expr))\n self.wait(2)\n\n # Display the evaluated result\n result_val = MathTex(\"\\\\frac{8}{3}\")\n result_val.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, result_val))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Develop a Manim animation explaining the concept of orthogonality in linear algebra. Visualize orthogonal vectors, subspaces, and projections, step by step.\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: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0687(Scene):\n def clear_stage(self):\n if self.mobjects:\n return FadeOut(*self.mobjects)\n else:\n return Wait(0)\n\n def construct(self):\n self.act_1_orthogonalvectors()\n self.play(self.clear_stage())\n self.act_2_simpleshapeanimation()\n self.play(self.clear_stage())\n self.act_3_plotgraph()\n\n def act_1_orthogonalvectors(self):\n title = Text(\"Orthogonality\", font_size=40).to_edge(UP)\n dot_a = Dot(RIGHT*2 + UP*1, color=BLUE)\n label_a = MathTex(\"\\\\vec{a}\", color=WHITE).next_to(dot_a, UR)\n \n vector_b_start = RIGHT*2 + DOWN*1\n vector_b_end = RIGHT*1 + DOWN*1\n arrow_b = Arrow(vector_b_start, vector_b_end, buff=0, color=GREEN)\n \n # Step 1: Define Orthogonal Vectors\n line_label = Text(\"Orthogonal Vectors form 90 degree angles\", font_size=24).to_edge(DOWN)\n \n # Animate the creation of vectors\n self.add(title, dot_a, label_a, arrow_b)\n self.wait(1)\n self.play(Write(line_label))\n self.wait(1)\n \n # Rotate the second vector to demonstrate orthogonality\n arrow_b_rotated = Arrow(\n vector_b_start,\n vector_b_start + RIGHT*1.5 + UP*1.5,\n buff=0,\n color=GREEN\n )\n rotation_animation = Transform(arrow_b.copy(), arrow_b_rotated)\n angle_indication = Arc(radius=1, start_angle=PI/4, angle=-PI/4, color=YELLOW)\n \n self.play(rotation_animation)\n self.play(Create(angle_indication))\n self.wait(1)\n \n # Clear intermediate elements to prepare for Subspace explanation\n \n self.play(FadeOut(VGroup(dot_a, label_a, arrow_b, line_label)))\n subspace_text = Text(\"Subspaces contain only orthogonal vectors\", font_size=24).to_edge(DOWN)\n \n # Create two sets of orthogonal vectors representing subspaces\n subspace_set1 = VGroup(\n Dot(RIGHT*3, color=RED),\n Dot(LEFT*3, color=RED)\n ).arrange(RIGHT, buff=1)\n subspace_set2 = VGroup(\n Dot(UP*3, color=RED),\n Dot(DOWN*3, color=RED)\n ).arrange(UP, buff=1)\n \n self.play(Write(subspace_text))\n self.play(Create(subspace_set1))\n self.play(Create(subspace_set2))\n self.wait(1)\n \n # Add projection formula\n projection_formula = MathTex(\n r\"\\text{proj}_{\\mathbf{b}} \\mathbf{a} = \\frac{\\mathbf{a}\\cdot\\mathbf{b}}{\\mathbf{b}\\cdot\\mathbf{b}} \\mathbf{b}\"\n ).scale(0.7).to_edge(UP)\n self.play(Transform(title, projection_formula))\n self.wait(1)\n self.play(FadeOut(VGroup(subspace_set1, subspace_set2, subspace_text)))\n\n def act_2_simpleshapeanimation(self):\n text = Tex(\"Hello, World!\").shift(UP * 2)\n self.play(Write(text))\n\n circle = Circle(color=BLUE)\n self.play(Write(circle))\n\n square = Square(side_length=1, color=RED)\n self.play(Transform(circle, square))\n\n self.play(square.animate.shift(DOWN * 2).rotate(-45 * DEGREES))\n\n def act_3_plotgraph(self):\n func = lambda x: x**2\n\n # --- Stage 1: Display Function ---\n func_tex = MathTex(\"f(x)\", \"=\", \"x^2\").scale(1.5)\n func_tex.to_edge(UP)\n self.play(Write(func_tex))\n self.wait(1)\n\n # --- Stage 2: Plot Graph ---\n axes = Axes(\n x_range=[-3, 3],\n y_range=[0, 6],\n axis_config={\"color\": BLUE}\n ).shift(DOWN * 0.5)\n\n labels = axes.get_axis_labels(Text(\"X\"), Text(\"Y\"))\n graph = axes.plot(func, color=RED, stroke_width=2)\n graph_label = MathTex(\"y=x^2\", color=RED).next_to(graph, UR, buff=0.1)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --- Stage 3: Animation Sequence ---\n points = [np.array([i, func(i), 0]) for i in [-2, -1, 0, 1, 2]]\n dots = VGroup(*[Dot(point, color=YELLOW) for point in points])\n lines = VGroup()\n for i in range(len(points)):\n if i > 0:\n line = Line(points[i-1], points[i], color=GREEN, stroke_opacity=i/len(points))\n lines.add(line)\n \n # Highlight each part sequentially\n for dot in dots:\n self.play(FadeIn(dot, scale=0.5))\n \n for line in lines:\n self.play(Create(line, run_time=0.5, rate_func=rush_into))\n \n self.wait(1)\n```", "rejected": "```python\n\"\"\"\nMulti-Act Masterpiece\n\nThis masterwork combines three distinct scenes into a seamless multi-part narrative.\nEach part stands alone while flowing smoothly into the next via FadeOut animations.\n\nRun this full file to render all parts sequentially.\n\"\"\"\n\nfrom manim import *\n\nclass MultiPartMasterpiece(Scene):\n def construct(self):\n # Part 1: Orthogonal Projection Animation\n self.part_one()\n\n def clear_scene(self):\n if self.mobjects:\n self.fade_out(*self.mobjects)\n self.wait(0.5)\n\n def part_one(self):\n title = Text(\"Orthogonal Projections\", font_size=36).to_edge(UP)\n \n vec_u = Arrow(start=ORIGIN, end=3*RIGHT + 2*UP, color=BLUE)\n vec_v = Arrow(start=ORIGIN, end=-2*LEFT + 3*DOWN, color=RED)\n proj_u_on_v = Line(ORIGIN, ORIGIN + np.dot(vec_u.get_end(), unit_vector(vec_v.get_end())) * unit_vector(vec_v.get_end()), color=YELLOW)\n\n u_label = MathTex(\"\\\\vec{u}\").next_to(vec_u, RIGHT)\n v_label = MathTex(\"\\\\vec{v}\").next_to(vec_v, DOWN)\n p_label = MathTex(\"\\\\text{Proj}_{\\\\vec{v}} \\\\vec{u}\").next_to(proj_u_on_v, UP)\n \n self.play(Write(title))\n self.play(Create(vec_u), Create(vec_v))\n self.play(GrowArrow(proj_u_on_v))\n self.play(Write(u_label), Write(v_label), Write(p_label))\n\n self.wait(2)\n\n # Step 2: Subspace Concept\n subspace_text = Text(\"Subspace formed by multiples of \\\\\\\\ vector \\\\vec{v}\", font_size=24).to_edge(DOWN)\n \n self.play(FadeIn(subspace_text))\n self.wait(1.5)\n self.play(FadeOut(subspace_text))\n\n # Clear first section\n self.play(\n FadeOut(title),\n FadeOut(vec_u), FadeOut(vec_v), FadeOut(proj_u_on_v),\n FadeOut(u_label), FadeOut(v_label), FadeOut(p_label)\n )\n\n # Step 3: Linear Combination Demonstration\n comb_title = Text(\"Linear Combinations\", font_size=36).to_edge(UP)\n line_u = DashedLine(ORIGIN, 3*RIGHT, color=BLUE)\n line_w = DashedLine(ORIGIN, -2*LEFT, color=GREEN)\n \n self.play(Write(comb_title))\n self.play(Create(line_u), Create(line_w))\n self.wait(2)\n\n # Clear second section\n self.play(\n FadeOut(combo_group),\n FadeOut(comb_title),\n FadeOut(line_u), FadeOut(line_w)\n )\n \n # Final Cleanup\n self.wait(1)\n\n# To run this entire multi-part storybook sequence:\n# manim -pql filename.py MultiPartMasterpiece\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'm learning robustness to misspecification and want to animate sensitivity analysis: perturb priors/likelihoods, display how outputs shift, and plot robustness measures across a parameter grid with quick scenario comparisons.", "chosen": "```python\nfrom manim import *\n\nclass SensitivityAnalysis(Scene):\n def construct(self):\n # Title\n title = Text(\"Sensitivity Analysis\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n\n # Clear title for main content\n self.play(FadeOut(title))\n\n # Model Parameters\n params_text = Text(\"Model Parameters:\", font_size=36).to_edge(UP)\n \n prior_tex = MathTex(\"\\\\text{Prior} \\\\sim N(\\\\mu_{prior}, \\\\sigma^2)\")\n like_tex = MathTex(\"\\\\text{Like} \\\\sim N(\\\\mu_{like}, \\\\sigma^2)\")\n\n model_params = VGroup(prior_tex, like_tex).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n model_group = VGroup(params_text, model_params).scale(0.7).shift(UP * 2 + LEFT * 3)\n\n # Observations\n obs_text = Text(\"Observations:\", font_size=36).next_to(model_group, DOWN, buff=1)\n obs_rect = RoundedRectangle(corner_radius=0.2, width=3, height=1, color=BLUE)\n obs_label = Text(\"+ Data Points\", font_size=24).move_to(obs_rect.get_center())\n\n observation = VGroup(obs_rect, obs_label).scale(0.5).shift(RIGHT * 3)\n\n # Shift of Results\n shift_text = Text(\"Shift in Outputs:\", font_size=36).next_to(observation, DOWN, buff=1)\n\n up_arrow = Arrow(start=DOWN, end=UP, color=RED, max_tip_length_to_length_ratio=0.2)\n down_arrow = Arrow(start=UP, end=DOWN, color=GREEN, max_tip_length_to_length_ratio=0.2)\n arrows = VGroup(up_arrow, down_arrow).arrange(RIGHT, buff=1)\n\n results_shift = VGroup(shift_text, arrows).scale(0.7).shift(RIGHT * 3 + UP * 1.5)\n\n # Display Components\n components = VGroup(\n model_group,\n obs_text,\n observation,\n shift_text,\n arrows\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n\n self.play(Write(components))\n self.wait(2)\n\n # Highlight Changes\n self.play(\n Indicate(obs_rect),\n Indicate(arrows[0], color=RED),\n Write(MathTex(\"\\\\Delta f < 0\").next_to(arrows[0], RIGHT)),\n run_time=2\n )\n self.play(\n Indicate(arrows[1]),\n Write(MathTex(\"\\\\Delta f > 0\").next_to(arrows[1], RIGHT)),\n run_time=2\n )\n\n # Conclusion\n conclusion = Text(\"Robust Models require stability under\\nparameter changes.\", font_size=32).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(3)\n\n# To run this animation:\n# manim -pql filename.py SensitivityAnalysis\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SensitivityAnalysisScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Sensitivity Analysis of Robust Models\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create a simple model equation\n equation = MathTex(\n r\"P(\\theta) \\propto L(x|\\theta)\\pi(\\theta)\"\n ).scale_to_fit_width(config.frame_width - 1).shift(UP * 2)\n \n self.play(Write(equation))\n self.wait(2)\n\n # Introduce prior and likelihood functions\n prior_text = Text(\"Prior Priors\", font_size=24).to_edge(LEFT).shift(DOWN * 0.8)\n likelihood_text = Text(\"Likelihood Functions\", font_size=24).next_to(prior_text, DOWN)\n \n prior_graph = VGroup()\n for i in range(-3, 4): \n line = Line(start=[i, 0, 0], end=[i, 0.5, 0], color=BLUE).set_stroke(width=2)\n prior_graph.add(line)\n \n likelihood_group = VGroup()\n for i in range(-3, 4): \n curve = ParametricFunction(lambda t: [t + i, 0.7 * np.sin(t*2), 0], t_range=[-np.pi, np.pi]).set_color(YELLOW).scale(1.5)\n likelihood_group.add(curve)\n \n self.play(FadeIn(prior_text), FadeIn(likelihood_group))\n self.wait(2)\n\n # Show parameters\n param_label = Text(\"Parameter Space:\", font_size=24).to_edge(RIGHT).shift(UP * 0.8)\n params = VGroup(*[\n Dot([i, 0, 0], radius=0.1) for i in [-3, -2, -1, 0, 1, 2]\n ]).arrange(RIGHT, buff=0.5)\n \n self.play(FadeIn(param_label), FadeIn(params))\n self.wait(1)\n\n # Animate changing values\n changes = [\n [(0, 1), (-1, 0.2)],\n ([1, 1.5], [2, 0]),\n ]\n \n for orig_pos, change_vals in changes:\n dots = [params[i] for i in orig_pos]\n\n new_dots = []\n for pos, val in zip(dots, change_vals):\n x_val = pos.get_center()[0] + val\n dot = Dot([x_val, 0, 0], radius=0.1, color=RED)\n new_dots.append(dot)\n \n self.play(\n Transform(pos, dot),\n run_time=0.3,\n rate_func=rush_into\n )\n\n self.wait(0.5)\n\n # Display results\n result_text = Text(\"Impact on Model Outputs\", font_size=24).next_to(likelihood_group, UP, buff=0.5)\n self.play(Write(result_text))\n\n # Draw arrows showing effect direction\n arrows = []\n for d1, d2 in zip(params[:-1], params[1:]):\n arrow = Arrow(d1.get_right(), d2.get_left(), stroke_width=2, color=GREEN)\n arrows.append(arrow)\n \n else:\n pass\n \n self.play(Create(VGroup(*arrows)))\n \n # Conclusion\n conclusion = Text(\"Robust models adapt efficiently\\nunder varying conditions.\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Function of the Target Network\n\nThis is an auxiliary network with temporarily fixed parameters, specifically used to calculate the TD target values. By severing the real-time connection between the target values and the current network parameters, it avoids training instability caused by \"chasing a moving target.\"\n\n\nThe context location of this section (from highest to current level):\n# Advanced Techniques in DQN\n## Key Improvement Ideas in DQN\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkScene(Scene):\n\n def construct(self):\n title = Text('Advanced Techniques in Deep Q-Networks', font_size=28).to_edge(UP)\n \n subtitle = Text('Key Improvement Idea: Target Network for Stabilized Training', font_size=26, color=BLUE_C).next_to(title, DOWN, buff=0.2)\n \n bullet_text = '• Severs real-time connection between target value predictions and current network parameters.'\n point = BulletedList(bullet_text, font_size=24).shift(DOWN * 0.5)\n \n explanation = Text('\"Chasing a moving target\" refers to instability due to changing targets while weights are still being updated.', font_size=22, line_spacing=1.2).shift(DOWN * 1.5)\n highlight_box = SurroundingRectangle(explanation, color=YELLOW, buff=0.25)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN * 0.2))\n self.wait(1)\n self.play(FadeIn(point, shift=RIGHT * 1))\n self.wait(1)\n \n # Visual representation\n main_net_label = Tex('$Q(s,a)$', font_size=36).set_color_by_tex('$Q$', BLUE_C)\n main_dot = Dot(color=BLUE_C).scale(1.2)\n target_net_label = Tex('$\\\\tilde{Q}(s,a)$', font_size=36, color=GREEN_C).move_to(main_dot.get_center())\n arrow = Arrow(start=main_dot.get_center(), end=target_net_label.get_center(), color=WHITE, stroke_width=2, max_tip_length_to_length_ratio=0.1)\n \n self.play(Create(main_dot), Write(main_net_label))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(target_net_label))\n self.wait(1)\n self.play(\n FadeIn(highlight_box),\n Indicate(explanation, color=YELLOW, scale_factor=1.1)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkExplanation(Scene):\n\n def construct(self):\n title = Text(\"Target Network for Stability\", font_size=36)\n \n # Create boxes and labels for the main components\n box_main = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=WHITE).shift(UP*1.8 + LEFT*2)\n label_main = Tex(\"$Q$-network\\n(real-time)\", font_size=16).move_to(box_main.get_center())\n \n box_target_fixed = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=ORANGE).next_to(title, DOWN, buff=1)\n label_fixed = Tex(\"\\\\textbf{Fixed} \\\\\\\\\\\\small\\\\textit{(parameters updated periodically)}\", font_size=18).move_to(box_target_fixed.get_center()).set_opacity(0.7)\n arrow_update = Arrow(start=box_target_fixed.get_top(), end=box_target_fixed.get_bottom() + UP*0.2, stroke_width=2, max_tip_length_to_length_ratio=0.1)\n update_text = Text(\"Update Periodically\", font_size=12, t2c={\"Periodically\": BLUE}).next_to(arrow_update, UP, buff=-0.2)\n \n box_agent = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=GREEN).to_edge(RIGHT, buff=2)\n label_agent = Tex(\"$s_{t}$\\n(state $t$)\", font_size=16).move_to(box_agent.get_center())\n line_arrow = Line(end=box_main.get_left()+RIGHT*0.1, start=box_agent.get_right()-LEFT*0.1)\n arc_arrow = Arc(radius=0.3, angle=PI/2).rotate(-PI/4).move_to(line_arrow.get_end())\n td_error_box = RoundedRectangle(width=2.2, height=1.2, corner_radius=0.2, color=YELLOW).next_to(arc_arrow, RIGHT, buff=0.1)\n td_label = MathTex(\"\\Delta E\").scale(0.75).move_to(td_error_box.get_center())\n error_flow = VGroup(Line(start=arc_arrow.get_end(), end=td_error_box.get_corner(DOWN+LEFT)), \n Arrow(start=td_error_box.get_corner(DOWN+LEFT)+RIGHT*0.1, end=box_main.get_right()-LEFT*0.1, buff=0.1))\n \n UILabel = Tex(\"Training Instability:\", font_size=24, color=RED).next_to(error_flow, DOWN, buff=0.3)\n UText = Tex(\"'Chasing a moving target'\", font_style=ITALIC, font_size=18).next_to(UILabel, DOWN, buff=0.2)\n\n self.play(Write(title), FadeIn(box_main), Write(label_main), run_time=2)\n self.wait(1)\n self.play(FadeIn(box_agent), Write(label_agent), RunTime(0.5))\n self.play(GrowArrow(line_arrow), GrowArrow(arc_arrow), run_time=1)\n self.play(Create(td_error_box), Write(td_label), run_time=1)\n self.play(LaggedStart(*[GrowArrow(i) for i in error_flow], lag_ratio=0.2), run_time=1.5)\n self.wait(1)\n self.play(FadeIn(box_target_fixed), Write(label_fixed), GrowArrow(arrow_update), Write(update_text), run_time=2)\n self.play(Write(UILabel), Write(UText), Indicate(box_target_fixed, color=ORANGE), Indicate(box_main, color=WHITE), run_time=3)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that illustrates how the sum of the harmonic series diverges as n approaches infinity? Start by displaying the formula for the partial sum of the series, proceed with a visual narration explaining that we're considering the limit as n goes to infinity, then show the mathematical expression of the limit of the series, followed by a text explanation that this series is known as the harmonic series and it diverges. Conclude by showing the mathematical result that the limit of the series equals infinity.", "chosen": "```python\nfrom manim import *\n\nclass HarmonicSeriesDivergence(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Formula Display: Render the formula for the partial sum.\n # ------------------------------------------------------------------\n partial_sum = MathTex(\n r\"S_n\", \"=\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\",\n font_size=48\n )\n self.play(Write(partial_sum))\n self.wait(1)\n\n # Move the formula up to make room for upcoming elements\n self.play(partial_sum.animate.to_edge(UP))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Visual Narration: Animate explanation about the limit.\n # ------------------------------------------------------------------\n narration = Text(\n \"Consider the limit as n approaches infinity.\",\n font_size=32,\n t2c={\"infinity\": YELLOW}\n ).next_to(partial_sum, DOWN, buff=0.8)\n \n self.play(FadeIn(narration, shift=UP))\n self.wait(2)\n self.play(FadeOut(narration))\n\n # ------------------------------------------------------------------\n # 3. Limit Expression: Display the mathematical expression for the limit.\n # ------------------------------------------------------------------\n limit_expr = MathTex(\n r\"\\lim_{n \\to \\infty}\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\",\n font_size=48\n )\n limit_expr.move_to(ORIGIN)\n\n # Transform the partial sum into the limit expression\n self.play(ReplacementTransform(partial_sum, limit_expr))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 4. Text Explanation: Identify series and behavior.\n # ------------------------------------------------------------------\n explanation = VGroup(\n Text(\"This is the Harmonic Series.\", font_size=36, t2c={\"Harmonic Series\": BLUE}),\n Text(\"Despite terms shrinking, it diverges.\", font_size=36, t2c={\"diverges\": RED})\n ).arrange(DOWN, aligned_edge=LEFT).next_to(limit_expr, DOWN, buff=0.8)\n \n self.play(Write(explanation))\n self.wait(2.5)\n \n # Clear explanation to prepare for the final result\n self.play(FadeOut(explanation))\n\n # ------------------------------------------------------------------\n # 5. Conclusion: Show the final mathematical result.\n # ------------------------------------------------------------------\n final_result = MathTex(\n r\"\\lim_{n \\to \\infty}\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\", \"=\", r\"\\infty\",\n font_size=48\n )\n final_result.set_color_by_tex(r\"\\infty\", RED)\n \n # Transform the limit expression into the full expanded result\n self.play(ReplacementTransform(limit_expr, final_result))\n \n # Add a surrounding rectangle for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=MED_LARGE_BUFF)\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass HarmonicSeriesDivergence(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Formula Display: Render the formula for the partial sum.\n # ------------------------------------------------------------------\n partial_sum = MathTex(\n r\"S_n\", \"=\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\",\n font_size=48\n )\n self.play(Write(partial_sum))\n self.wait(1)\n\n # Move the formula up to make room for upcoming elements\n self.play(partial_sum.animate.to_edge(UP))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Visual Narration: Animate explanation about the limit.\n # ------------------------------------------------------------------\n narration = Text(\n \"Consider the limit as n approaches infinity.\",\n font_size=32,\n t2c={\"infinity\": YELLOW}\n ).next_to(partial_sum, DOWN, buff=0.8)\n \n self.play(FadeIn(narration, shift=UP))\n self.wait(2)\n self.play(FadeOut(narration))\n\n # ------------------------------------------------------------------\n # 3. Limit Expression: Display the mathematical expression for the limit.\n # ------------------------------------------------------------------\n limit_expr = MathTex(\n r\"\\lim_{n \\to \\infty}\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\",\n font_size=48\n )\n limit_expr.move_to(ORIGIN)\n\n # Transform the partial sum into the limit expression\n self.play(ReplacementTransform(target_position=ORIGIN, partial_sum, limit_expr))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 4. Text Explanation: Identify series and behavior.\n # ------------------------------------------------------------------\n explanation = VGroup(\n Text(\"This is the Harmonic Series.\", font_size=36, t2c={\"Harmonic Series\": BLUE}),\n Text(\"Despite terms shrinking, it diverges.\", font_size=36, t2c={\"diverges\": RED})\n ).arrange(DOWN, aligned_edge=LEFT).next_to(limit_expr, DOWN, buff=0.8)\n \n self.play(Write(explanation))\n self.wait(2.5)\n \n # Clear explanation to prepare for the final result\n self.play(FadeOut(explanation))\n\n # ------------------------------------------------------------------\n # 5. Conclusion: Show the final mathematical result.\n # ------------------------------------------------------------------\n final_result = MathTex(\n r\"\\lim_{n \\to \\infty}\", r\"\\sum_{k=1}^{n}\", r\"\\frac{1}{k}\", \"=\", r\"\\infty\",\n font_size=48\n )\n final_result.set_color_by_tex(r\"\\infty\", RED)\n \n # Transform the limit expression into the full expanded result\n self.play(ReplacementTransform(limit_expr, final_result))\n \n # Add a surrounding rectangle for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=MED_LARGE_BUFF)\n self.play(Create(box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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#### Teacher Forcing Training\n- **Training Strategy**: During training, the model does not use its own previous prediction as input for the current step, but instead forces the use of the previous frame of the true data (Ground Truth).\n- **Advantages**: It greatly accelerates the convergence speed of model training and avoids cascading failures caused by early training errors.\n- **Costs**: It causes a mismatch in the data distribution between the training and inference phases, known as exposure bias, *which may lead to a decline in model performance when inferring long sentences*.\n\n\nThe context of this section (from highest to current level):\n# Intelligent Speech Technology Course - Detailed Outline of Lesson 11 (Tacotron and Autoregressive Acoustic Models, 90 minutes)\n## Analysis of Characteristics of Autoregressive Decoding (30 minutes)\n### Autoregressive Generation Mechanism\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TeacherForcing(Scene):\n\n def construct(self):\n title = Text('Teacher Forcing Training', 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 self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n m1_text = Text('Model', font_size=26)\n m1_box = SurroundingRectangle(m1_text, color=BLUE, buff=0.25)\n m1 = VGroup(m1_text, m1_box).move_to(LEFT * 3.5 + UP * 1.5)\n gt1 = MathTex('GT_{t-1}').next_to(m1, LEFT, buff=0.8)\n arr_gt1 = Arrow(gt1.get_right(), m1.get_left(), buff=0.1)\n y1 = MathTex('y_{t-1}').next_to(m1, RIGHT, buff=0.8)\n arr_y1 = Arrow(m1.get_right(), y1.get_left(), buff=0.1)\n self.play(Write(gt1), GrowArrow(arr_gt1), run_time=0.8)\n self.play(FadeIn(m1), run_time=0.6)\n self.play(GrowArrow(arr_y1), Write(y1), run_time=0.8)\n m2_text = Text('Model', font_size=26)\n m2_box = SurroundingRectangle(m2_text, color=BLUE, buff=0.25)\n m2 = VGroup(m2_text, m2_box).move_to(RIGHT * 2.5 + UP * 1.5)\n y2 = MathTex('y_t').next_to(m2, RIGHT, buff=0.8)\n arr_y2 = Arrow(m2.get_right(), y2.get_left(), buff=0.1)\n self.play(FadeIn(m2), run_time=0.6)\n arr_std = Arrow(y1.get_right(), m2.get_left(), buff=0.1, color=GRAY)\n std_label = Text('Standard', font_size=16, color=GRAY).next_to(arr_std, UP, buff=0.1)\n self.play(GrowArrow(arr_std), Write(std_label), run_time=0.8)\n cross1 = Line(LEFT * 0.2 + UP * 0.2, RIGHT * 0.2 + DOWN * 0.2, color=RED, stroke_width=4)\n cross2 = Line(LEFT * 0.2 + DOWN * 0.2, RIGHT * 0.2 + UP * 0.2, color=RED, stroke_width=4)\n cross = VGroup(cross1, cross2).move_to(arr_std.get_center())\n self.play(Create(cross), run_time=0.5)\n gt2 = MathTex('GT_t', color=GREEN).next_to(m2, DOWN, buff=1.0)\n arr_gt2 = Arrow(gt2.get_top(), m2.get_bottom(), buff=0.1, color=GREEN)\n tf_label = Text('Teacher Forcing', font_size=16, color=GREEN).next_to(arr_gt2, RIGHT, buff=0.1)\n self.play(Write(gt2), GrowArrow(arr_gt2), Write(tf_label), run_time=1)\n self.play(GrowArrow(arr_y2), Write(y2), run_time=0.8)\n t1 = Text('- Strategy: Force use of true data (GT) instead of previous prediction.', font_size=22)\n t2 = Text('- Advantage: Accelerates convergence, avoids cascading errors.', font_size=22, color=YELLOW)\n t3 = Text('- Cost: Exposure bias (training/inference distribution mismatch).', font_size=22, color=RED)\n t4 = Text('- Result: May lead to performance decline on long sequences.', font_size=22, color=RED)\n texts = VGroup(t1, t2, t3, t4).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n texts.to_edge(LEFT, buff=1).set_y(-2.2)\n for t in texts:\n self.play(Write(t), run_time=0.9)\n else:\n pass\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TeacherForcing(Scene):\n\n def construct(self):\n title = Text('Teacher Forcing Training', 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 self.play(Write(title, run_time=1.5), GrowFromCenter(title_line, run_time=0.8))\n m1_text = Text('Model', font_size=26)\n m1_box = SurroundingRectangle(m1_text, color=BBLUE, buff=0.25)\n m1 = VGroup(m1_text, m1_box).move_to(LEFT * 3.5 + UP * 1.5)\n gt1 = MathTex('GT_{t-1}').next_to(m1, LEFT, buff=0.8)\n arr_gt1 = Arrow(gt1.get_right(), m1.get_left(), buff=0.1)\n y1 = MathTex('y_{t-1}').next_to(m1, RIGHT, buff=0.8)\n arr_y1 = Arrow(m1.get_right(), y1.get_left(), buff=0.1)\n self.play(Write(gt1), GrowArrow(arr_gt1), run_time=0.8)\n self.play(FadeIn(m1), run_time=0.6)\n self.play(GrowArrow(arr_y1), Write(y1), run_time=0.8)\n m2_text = Text('Model', font_size=26)\n m2_box = SurroundingRectangle(m2_text, color=BLUE, buff=0.25)\n m2 = VGroup(m2_text, m2_box).move_to(RIGHT * 2.5 + UP * 1.5)\n y2 = MathTex('y_t').next_to(m2, RIGHT, buff=0.8)\n arr_y2 = Arrow(m2.get_right(), y2.get_left(), buff=0.1)\n self.play(FadeIn(m2), run_time=0.6)\n arr_std = Arrow(y1.get_right(), m2.get_left(), buff=0.1, color=GRAY)\n std_label = Text('Standard', font_size=16, color=GRAY).next_to(arr_std, UP, buff=0.1)\n self.play(GrowArrow(arr_std), Write(std_label), run_time=0.8)\n cross1 = Line(LEFT * 0.2 + UP * 0.2, RIGHT * 0.2 + DOWN * 0.2, color=RED, stroke_width=4)\n cross2 = Line(LEFT * 0.2 + DOWN * 0.2, RIGHT * 0.2 + UP * 0.2, color=RED, stroke_width=4)\n cross = VGroup(cross1, cross2).move_to(arr_std.get_center())\n self.play(Create(cross), run_time=0.5)\n gt2 = MathTex('GT_t', color=GREEN).next_to(m2, DOWN, buff=1.0)\n arr_gt2 = Arrow(gt2.get_top(), m2.get_bottom(), buff=0.1, color=GREEN)\n tf_label = Text('Teacher Forcing', font_size=16, color=GREEN).next_to(arr_gt2, RIGHT, buff=0.1)\n self.play(Write(gt2), GrowArrow(arr_gt2), Write(tf_label), run_time=1)\n self.play(GrowArrow(arr_y2), Write(y2), run_time=0.8)\n t1 = Text('- Strategy: Force use of true data (GT) instead of previous prediction.', font_size=22)\n t2 = Text('- Advantage: Accelerates convergence, avoids cascading errors.', font_size=22, color=YELLOW)\n t3 = Text('- Cost: Exposure bias (training/inference distribution mismatch).', font_size=22, color=RED)\n t4 = Text('- Result: May lead to performance decline on long sequences.', font_size=22, color=RED)\n texts = VGroup(t1, t2, t3, t4).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n texts.to_edge(LEFT, buff=1).set_y(-2.2)\n for t in texts:\n self.play(Write(t), run_time=0.9)\n else:\n pass\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "**Enhanced Animation Instruction:** \n\nBegin by creating a `Circle` and a `Triangle` positioned at the center of the screen, then group them into a `VGroup` and rotate them by **-45 degrees** as in the original script. Next, introduce a dynamic transformation: animate the `Circle` morphing smoothly into the `Triangle` (and vice versa) using `Transform`, while simultaneously displaying a mathematical formula (`A = πr²` for the circle and `A = ½bh` for the triangle) that fades in below the shapes. After the transformation completes, add a labeled coordinate system in the background with axes and grid lines to contextualize the rotation. Finally, animate the entire group scaling up and down rhythmically to emphasize the geometric relationship between the two shapes, concluding with a fade-out effect. The enhanced animation will not only demonstrate the rotation but also visually connect the shapes to their respective area formulas while providing spatial reference through the coordinate grid.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create shapes and group them\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)\n shapes.move_to(ORIGIN)\n \n # Rotate the group\n rotated_shapes = shapes.copy()\n rotated_shapes.rotate(-45 * DEGREES)\n \n # Create area formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n triangle_formula = MathTex(\"A = \\\\frac{1}{2} b h\").next_to(triangle, DOWN)\n \n # Add coordinate system\n axes = Axes(\n x_range=[-5, 5, 1],\n y_range=[-4, 4, 1],\n x_length=10,\n y_length=8,\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": np.arange(-5, 6, 1)},\n y_axis_config={\"numbers_to_include\": np.arange(-4, 5, 1)},\n )\n axes.add_coordinates()\n grid = NumberPlane(\n x_range=[-5, 5, 1],\n y_range=[-4, 4, 1],\n background_line_style={\n \"stroke_color\": BLUE_D,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n \n # Animation sequence\n self.play(Create(shapes))\n self.wait(0.5)\n self.play(Write(circle_formula), Write(triangle_formula))\n self.wait(1)\n self.play(Transform(shapes, rotated_shapes))\n self.wait(0.5)\n self.play(Transform(circle, triangle.copy()), Transform(triangle, circle.copy()))\n self.wait(1)\n self.play(FadeIn(grid), FadeIn(axes))\n self.wait(1)\n \n # Rhythmic scaling\n for _ in range(2):\n self.play(shapes.animate.scale(1.2), run_time=0.5)\n self.play(shapes.animate.scale(1/1.2), run_time=0.5)\n \n # Fade out\n self.play(FadeOut(shapes), FadeOut(circle_formula), FadeOut(triangle_formula), FadeOut(grid), FadeOut(axes))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create shapes and group them\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)\n shapes.move_to(ORIGIN)\n \n # Rotate the group\n rotated_shapes = shapes.copy()\n rotated_shapes.rotate(-45 * DEGREES)\n \n # Create area formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n triangle_formula = MathTex(\"A = \\\\frac{1}{2} b h\").next_to(triangle, DOWN)\n \n # Add coordinate system\n axes = Axes(label_font_size=24, \n x_range=[-5, 5, 1],\n y_range=[-4, 4, 1],\n x_length=10,\n y_length=8,\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": np.arange(-5, 6, 1)},\n y_axis_config={\"numbers_to_include\": np.arange(-4, 5, 1)},\n )\n axes.add_coordinates()\n grid = NumberPlane(\n x_range=[-5, 5, 1],\n y_range=[-4, 4, 1],\n background_line_style={\n \"stroke_color\": BLUE_D,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n \n # Animation sequence\n self.play(Create(shapes))\n self.wait(0.5)\n self.play(Write(circle_formula), Write(triangle_formula))\n self.wait(1)\n self.play(Transform(shapes, rotated_shapes))\n self.wait(0.5)\n self.play(Transform(circle, triangle.copy()), Transform(triangle, circle.copy()))\n self.wait(1)\n self.play(FadeIn(grid), FadeIn(axes))\n self.wait(1)\n \n # Rhythmic scaling\n for _ in range(2):\n self.play(shapes.animate.scale(1.2), run_time=0.5)\n self.play(shapes.animate.scale(1/1.2), run_time=0.5)\n \n # Fade out\n self.play(FadeOut(shapes), FadeOut(circle_formula), FadeOut(triangle_formula), FadeOut(grid), FadeOut(axes))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an animated video that shows the steps to solve the definite integral of x cubed from 0 to 2, including the application of the Fundamental Theorem of Calculus and the evaluation of the integral at the give\n- Act 2: Create a 12-second logic scene explaining necessary and sufficient conditions with nested sets. Put set A entirely inside set B, animate examples inside and outside A, and label that A is sufficient for B while B is nece", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0438(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_solvedefiniteintegral()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n\n def act_1_solvedefiniteintegral(self):\n integral = MathTex(r\"\\int_0^2 x^3 \\, dx\")\n \n # Step 2: Apply the Fundamental Theorem of Calculus (Antiderivative process)\n antiderivative = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\")\n \n # Step 3: Evaluate the antiderivative at the upper bound (2) and the lower bound (0)\n evaluation = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n \n # Step 4: Calculate the difference to simplify\n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n \n # Step 5: Conclude with the final numerical answer\n result = MathTex(r\"= 4\", color=YELLOW)\n\n # Group the expressions and arrange them vertically, aligned by the equals sign\n steps = VGroup(\n integral, antiderivative, evaluation, calculation, result\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n \n # Center the entire derivation on screen\n steps.center()\n\n # --- Animation Sequence ---\n\n # 1. Display the initial integral\n self.play(Write(integral), run_time=1.5)\n self.wait(1)\n\n # 2. Show the antiderivative process\n self.play(Write(antiderivative), run_time=1.5)\n self.wait(1)\n\n # 3. Show the evaluation at the upper and lower bounds\n self.play(Write(evaluation), run_time=1.5)\n self.wait(1)\n\n # 4. Calculate the difference\n self.play(Write(calculation), run_time=1.5)\n self.wait(1)\n\n # 5. Display the final numerical answer\n self.play(Write(result), run_time=1.5)\n self.wait(1)\n\n # Add a surrounding rectangle to emphasize the final result\n box = SurroundingRectangle(result, color=GREEN, buff=0.15)\n self.play(Create(box))\n self.wait(3)\n\n def act_2_necessarysufficientsets(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0438(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_solvedefiniteintegral()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n\n def act_1_solvedefiniteintegral(self):\n integral = MathTex(r\"\\int_0^2 x^3 \\, dx\")\n \n # Step 2: Apply the Fundamental Theorem of Calculus (Antiderivative process)\n antiderivative = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\")\n \n # Step 3: Evaluate the antiderivative at the upper bound (2) and the lower bound (0)\n evaluation = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n \n # Step 4: Calculate the difference to simplify\n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n \n # Step 5: Conclude with the final numerical answer\n result = MathTex(r\"= 4\", color=YELLOW)\n\n # Group the expressions and arrange them vertically, aligned by the equals sign\n steps = VGroup(\n integral, antiderivative, evaluation, calculation, result\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n \n # Center the entire derivation on screen\n steps.center()\n\n # --- Animation Sequence ---\n\n # 1. Display the initial integral\n self.play(Write(integral), run_time=1.5)\n self.wait(1)\n\n # 2. Show the antiderivative process\n self.play(Write(antiderivative), run_time=1.5)\n self.wait(1)\n\n # 3. Show the evaluation at the upper and lower bounds\n self.play(Write(evaluation), run_time=1.5)\n self.wait(1)\n\n # 4. Calculate the difference\n self.play(Write(calculation), run_time=1.5)\n self.wait(1)\n\n # 5. Display the final numerical answer\n self.play(Write(result), run_time=1.5)\n self.wait(1)\n\n # Add a surrounding rectangle to emphasize the final result\n box = SurroundingRectangle(result, color=GREEN, buff=0.15)\n self.play(Create(box))\n self.wait(3)\n\n def act_2_necessarysufficientsets(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(target_position=ORIGIN, sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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\nTherefore, the pipeline mainly improves the **number of instructions completed per unit of time**, rather than the processing speed of individual tasks.\n\n## Relationship Between Pipeline Depth and Benefits\n\nIncreasing the number of pipeline stages (deepening the pipeline, i.e., Superpipelining) theoretically can:\n\n- Further divide the logic delay of each stage, shortening the clock cycle;\n- Increase the potential maximum clock frequency.\n\n\nThe context location of this section (from highest level to current):\n# Instruction Pipeline Basics - Course Notes\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass PipelineDepthScene(Scene):\n\n def construct(self):\n title = Text('Pipeline Depth', font_size=36)\n subtitle = Text('Relationship between Depth and Performance', font_size=28)\n group = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n self.play(Write(group))\n box = RoundedRectangle(width=7, height=1.5, corner_radius=0.3)\n arrow = Arrow(box.get_right(), box.get_left())\n label_box = Text('Pipelined Execution\\n(per instruction)', font_size=20)\n label_arrow = MathTex('\\\\rightarrow', font_size=36)\n labels = VGroup(label_box, label_arrow).arrange(RIGHT, buff=0.2)\n labels.next_to(arrow, UP, buff=-0.2)\n self.play(Create(box), GrowArrow(arrow), FadeIn(labels))\n bullet1 = Text('- Logic Delay Division', color=GREEN)\n bullet2 = Text('- Clock Cycle Shortening')\n bullet3 = Text('- Maximum Frequency Gain')\n bullets = VGroup(bullet1, bullet2, bullet3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n for b in bullets:\n b.to_edge(UP, buff=1.5)\n b.shift((box.get_center()[0] + b.get_width()) * RIGHT)\n else:\n None\n desc1 = Text('Deepening the pipeline divides stage delays,\\nreducing overall clock cycles.')\n desc2 = Text('With shorter cycles, we can achieve higher frequencies.\\nThis enables more instructions per second.')\n descs = VGroup(desc1, desc2).arrange(DOWN, aligned_edge=RIGHT, buff=0.2)\n for d in descs:\n d.to_edge(DOWN, buff=1)\n d.shift((-box.get_center()[0] - d.get_width()) * LEFT)\n else:\n None\n for item, desc in zip([bullet2, bullet3], [desc1, desc2]):\n rect = SurroundingRectangle(item, color=YELLOW, buff=0.15)\n self.play(Create(rect), Write(desc))\n else:\n pass\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass InstructionPipelineScene(Scene):\n\n def construct(self):\n title = Text('Instruction Pipelines', font_size=36)\n title.to_edge(UP, buff=0.3)\n self.play(Write(title))\n main_text = Text(\"There is no free lunch.\\nImproving one metric usually\\nlimits another.\", \n t2c={'free': YELLOW}, font_size=28).to_edge(DOWN, buff=1.5)\n bullet_point = Tex(\"\\\\bullet\", \"Superpipelining increases depth by adding stages.\")\n point_desc = Text(\"(Adding more stages divides logical delays)\", font_size=24).next_to(bullet_point, RIGHT, buff=0.2)\n items = VGroup(Text(\"- Divides each stage's logic delay\"), Text(\"- Shortens the clock cycle\"), Text(\"- Increases the maximum clock frequency\"))\n for item in items:\n item.next_to(point_desc, DOWN, aligned_edge=LEFT, buff=0.3)\n else:\n None\n box = SurroundingRectangle(VGroup(main_text, bullet_point, point_desc, *items), color=WHITE, buff=0.2)\n group = VGroup(main_text, bullet_point, point_desc, *items, box).arrange(RIGHT, buff=1.5)\n group.move_to(ORIGIN)\n \n # Animation sequence\n self.play(Write(main_text))\n self.wait(1)\n self.play(FadeIn(bullet_point))\n self.wait(1)\n self.play(Write(item.copy()), Write(item.copy()))\n self.wait(1)\n self.play(Create(box))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Analyzing the Security of the Kerberos Protocol\nWrite a short essay analyzing the specific security threats to the system if an attacker obtains the session key generated by the AS, or if the attacker obtains the long-term key of the TGS.\n\n\nThe context of this section (from highest to current level):\n# Authentication Protocols\n## Homework\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass KerberosSecurityAnalysis(Scene):\n\n def construct(self):\n context_title = Text('Authentication Protocols: Homework', font_size=32, color=BLUE)\n context_title.to_edge(UP, buff=0.4)\n main_title = Text('Analyzing the Security of the Kerberos Protocol', font_size=28, color=YELLOW)\n main_title.next_to(context_title, DOWN, buff=0.3)\n question_text = VGroup(Text('Write a short essay analyzing the specific security threats', font_size=24), Text('to the system if an attacker obtains:', font_size=24), Text('1) The session key generated by the AS', font_size=24, color=GREEN_C), Text('2) The long-term key of the TGS', font_size=24, color=ORANGE)).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n question_text.next_to(main_title, DOWN, buff=0.5)\n as_box = RoundedRectangle(height=1, width=2.5, corner_radius=0.2, color=GREEN_C)\n as_text = Text('AS', font_size=24).move_to(as_box.get_center())\n as_node = VGroup(as_box, as_text).move_to(LEFT * 3.5 + DOWN * 0.5)\n tgs_box = RoundedRectangle(height=1, width=2.5, corner_radius=0.2, color=ORANGE)\n tgs_text = Text('TGS', font_size=24).move_to(tgs_box.get_center())\n tgs_node = VGroup(tgs_box, tgs_text).move_to(RIGHT * 3.5 + DOWN * 0.5)\n attacker_box = RoundedRectangle(height=1, width=2.5, corner_radius=0.2, color=RED)\n attacker_text = Text('Attacker', font_size=24, color=RED).move_to(attacker_box.get_center())\n attacker_node = VGroup(attacker_box, attacker_text).move_to(DOWN * 3)\n arrow1 = Arrow(start=as_node.get_bottom(), end=attacker_node.get_top() + LEFT * 0.5, color=RED, buff=0.1)\n label1 = Tex('Session Key ($K_{C,TGS}$)', font_size=22, color=RED)\n label1.next_to(arrow1, LEFT, buff=0.2).shift(UP * 0.3)\n arrow2 = Arrow(start=tgs_node.get_bottom(), end=attacker_node.get_top() + RIGHT * 0.5, color=RED, buff=0.1)\n label2 = Tex('Long-term Key ($K_{TGS}$)', font_size=22, color=RED)\n label2.next_to(arrow2, RIGHT, buff=0.2).shift(UP * 0.3)\n self.play(Write(context_title))\n self.play(FadeIn(main_title, shift=DOWN))\n self.wait(0.5)\n self.play(Write(question_text[0:2]))\n self.play(FadeIn(question_text[2], shift=RIGHT))\n self.play(FadeIn(question_text[3], shift=RIGHT))\n self.wait(1)\n self.play(Create(as_node), Create(tgs_node))\n self.play(Create(attacker_node))\n self.wait(0.5)\n self.play(GrowArrow(arrow1), Write(label1))\n self.wait(1)\n self.play(GrowArrow(arrow2), Write(label2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass KerberosSecurityAnalysis(Scene):\n\n def construct(self):\n context_title = Text('Authentication Protocols: Homework', font_size=32, color=BLUE)\n context_title.to_edge(UP, buff=0.4)\n main_title = Text('Analyzing the Security of the Kerberos Protocol', font_size=28, color=YELLOW)\n main_title.next_to(context_title, DOWN, buff=0.3)\n question_text = VGroup(Text('Write a short essay analyzing the specific security threats', font_size=24), Text('to the system if an attacker obtains:', font_size=24), Text('1) The session key generated by the AS', font_size=24, color=GREEN_C), Text('2) The long-term key of the TGS', font_size=24, color=ORANGE)).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n question_text.next_to(main_title, DOWN, buff=0.5)\n as_box = RoundRect(height=1, width=2.5, corner_radius=0.2, color=GREEN_C)\n as_text = Text('AS', font_size=24).move_to(as_box.get_center())\n as_node = VGroup(as_box, as_text).move_to(LEFT * 3.5 + DOWN * 0.5)\n tgs_box = RoundedRectangle(height=1, width=2.5, corner_radius=0.2, color=ORANGE)\n tgs_text = Text('TGS', font_size=24).move_to(tgs_box.get_center())\n tgs_node = VGroup(tgs_box, tgs_text).move_to(RIGHT * 3.5 + DOWN * 0.5)\n attacker_box = RoundedRectangle(height=1, width=2.5, corner_radius=0.2, color=RED)\n attacker_text = Text('Attacker', font_size=24, color=RED).move_to(attacker_box.get_center())\n attacker_node = VGroup(attacker_box, attacker_text).move_to(DOWN * 3)\n arrow1 = Arrow(start=as_node.get_bottom(), end=attacker_node.get_top() + LEFT * 0.5, color=RED, buff=0.1)\n label1 = Tex('Session Key ($K_{C,TGS}$)', font_size=22, color=RED)\n label1.next_to(arrow1, LEFT, buff=0.2).shift(UP * 0.3)\n arrow2 = Arrow(start=tgs_node.get_bottom(), end=attacker_node.get_top() + RIGHT * 0.5, color=RED, buff=0.1)\n label2 = Tex('Long-term Key ($K_{TGS}$)', font_size=22, color=RED)\n label2.next_to(arrow2, RIGHT, buff=0.2).shift(UP * 0.3)\n self.play(Write(context_title))\n self.play(FadeIn(main_title, shift=DOWN))\n self.wait(0.5)\n self.play(Write(question_text[0:2]))\n self.play(FadeIn(question_text[2], shift=RIGHT))\n self.play(FadeIn(question_text[3], shift=RIGHT))\n self.wait(1)\n self.play(Create(as_node), Create(tgs_node))\n self.play(Create(attacker_node))\n self.wait(0.5)\n self.play(GrowArrow(arrow1), Write(label1))\n self.wait(1)\n self.play(GrowArrow(arrow2), Write(label2))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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 2: Can you create a custom animation using Python and Manim where a square first dissolves into numerous small dots and then those dots come together to form the square again, but it should happen smoothly over a duration w\n- Act 3: Display three colored circles: red on the left, green in the center, and blue on the right. Initially, the red and green circles are grouped together, and the blue circle is in a separate group. After a pause, the blue c", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0470(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_someanimations()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_addtovgroup()\n\n def act_1_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_2_areaundercurve(self):\n axes = Axes(\n x_range=[0, 5],\n y_range=[0, 10],\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=WHITE)\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.3)\n \n self.play(Create(axes), Create(graph))\n self.wait(1)\n \n # Show the area under the curve\n area_label = MathTex(r\"\\text{Area} = \\int_0^2 x^2 \\,dx\").next_to(area, DOWN)\n self.play(FadeIn(area), Write(area_label))\n self.wait(2)\n\n # Calculate the area under the curve\n area_calculation = MathTex(r\"= \\left[\\frac{1}{3}x^3\\right]_0^2\")\n self.play(ReplacementTransform(area_label, area_calculation))\n self.wait(1)\n\n # Final area\n final_area = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\", r\"= \\frac{8}{3}\")\n self.play(ReplacementTransform(area_calculation, final_area))\n self.wait(2)\n\n # Clear the scene\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(area), FadeOut(final_area))\n self.wait(1)\n\n def act_3_addtovgroup(self):\n circle_red = Circle(color=RED)\n circle_green = Circle(color=GREEN)\n circle_blue = Circle(color=BLUE)\n circle_red.shift(LEFT)\n circle_blue.shift(RIGHT)\n gr = VGroup(circle_red, circle_green)\n gr2 = VGroup(circle_blue) # Constructor uses add directly\n self.add(gr,gr2)\n self.wait()\n gr += gr2 # Add group to another\n self.play(\n gr.animate.shift(DOWN),\n )\n gr -= gr2 # Remove group\n self.play( # Animate groups separately\n gr.animate.shift(LEFT),\n gr2.animate.shift(UP),\n )\n self.play( #Animate groups without modification\n (gr+gr2).animate.shift(RIGHT)\n )\n self.play( # Animate group without component\n (gr-circle_red).animate.shift(RIGHT)\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0470(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_someanimations()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_addtovgroup()\n\n def act_1_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_2_areaundercurve(self):\n axes = Axes(font_size=24, \n x_range=[0, 5],\n y_range=[0, 10],\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=WHITE)\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.3)\n \n self.play(Create(axes), Create(graph))\n self.wait(1)\n \n # Show the area under the curve\n area_label = MathTex(r\"\\text{Area} = \\int_0^2 x^2 \\,dx\").next_to(area, DOWN)\n self.play(FadeIn(area), Write(area_label))\n self.wait(2)\n\n # Calculate the area under the curve\n area_calculation = MathTex(r\"= \\left[\\frac{1}{3}x^3\\right]_0^2\")\n self.play(ReplacementTransform(area_label, area_calculation))\n self.wait(1)\n\n # Final area\n final_area = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\", r\"= \\frac{8}{3}\")\n self.play(ReplacementTransform(area_calculation, final_area))\n self.wait(2)\n\n # Clear the scene\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(area), FadeOut(final_area))\n self.wait(1)\n\n def act_3_addtovgroup(self):\n circle_red = Circle(color=RED)\n circle_green = Circle(color=GREEN)\n circle_blue = Circle(color=BLUE)\n circle_red.shift(LEFT)\n circle_blue.shift(RIGHT)\n gr = VGroup(circle_red, circle_green)\n gr2 = VGroup(circle_blue) # Constructor uses add directly\n self.add(gr,gr2)\n self.wait()\n gr += gr2 # Add group to another\n self.play(\n gr.animate.shift(DOWN),\n )\n gr -= gr2 # Remove group\n self.play( # Animate groups separately\n gr.animate.shift(LEFT),\n gr2.animate.shift(UP),\n )\n self.play( #Animate groups without modification\n (gr+gr2).animate.shift(RIGHT)\n )\n self.play( # Animate group without component\n (gr-circle_red).animate.shift(RIGHT)\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I want an educational animation showing the area under the curve of the function y = 0.25x^2 from x=0 to x=2 on graph axes labeled with 'x' and 'y'. Also, let the graph and axes be created with an animation effect. After showing the area under the curve highlighted in yellow with 50% opacity, display text \"Area under curve\" beside the highlighted area. Then, transform the \"Area under curve\" label into the integral notation for the area calculation, which is an integral from 0 to 2 of 0.25x^2 dx and place it at the top of the screen. Finally, reveal the calculation process and result of the integral below the integral notation, show the final numerical value for the area, and then clear everything else off the screen, leaving only the final area value shown at the end. Make sure the color of the axes is blue, the function graph is green, and use an appropriate animation to transition between each of these visual elements.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveScene(Scene):\n def construct(self):\n # 1. Setup: Axes and Function Graph\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 2, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n func = lambda x: 0.25 * x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=GREEN)\n \n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph))\n self.wait(0.5)\n\n # 2. Highlight Area\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n self.play(DrawBorderThenFill(area))\n self.wait(0.5)\n\n # 3. Initial Label\n label_text = Text(\"Area under curve\", font_size=28).next_to(area, RIGHT, buff=0.3)\n self.play(Write(label_text))\n self.wait(0.5)\n\n # 4. Transformation to Integral Notation\n integral = MathTex(r\"\\int_{0}^{2} 0.25x^2 \\, dx\", font_size=40)\n self.play(ReplacementTransform(label_text, integral))\n self.play(integral.animate.to_edge(UP))\n self.wait(0.5)\n\n # 5. Calculation Steps\n step1 = MathTex(r\"= \\left[ 0.25 \\cdot \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=36)\n step1.next_to(integral, DOWN, aligned_edge=LEFT)\n \n step2 = MathTex(r\"= \\frac{0.25 \\cdot 2^3}{3} - 0\", font_size=36)\n step2.next_to(step1, DOWN, aligned_edge=LEFT)\n \n step3 = MathTex(r\"= \\frac{0.25 \\cdot 8}{3} = \\frac{2}{3}\", font_size=36)\n step3.next_to(step2, DOWN, aligned_edge=LEFT)\n\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 # 6. Final Result\n final_result = MathTex(r\"\\frac{2}{3}\", font_size=48, color=YELLOW)\n final_result.next_to(step3, DOWN, buff=0.5)\n self.play(Write(final_result))\n self.wait(1)\n\n # 7. Cleanup\n elements_to_remove = VGroup(\n axes, axis_labels, graph, area, integral, step1, step2, step3\n )\n self.play(FadeOut(elements_to_remove))\n \n self.play(final_result.animate.move_to(ORIGIN).scale(1.5))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveScene(Scene):\n def construct(self):\n # 1. Setup: Axes and Function Graph\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 2, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n func = lambda x: 0.25 * x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=GREEN)\n \n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph))\n self.wait(0.5)\n\n # 2. Highlight Area\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n self.play(DrawBorderThenFill(area))\n self.wait(0.5)\n\n # 3. Initial Label\n label_text = Text(\"Area under curve\", font_size=28).next_to(area, RIGHT, buff=0.3)\n self.play(Write(label_text))\n self.wait(0.5)\n\n # 4. Transformation to Integral Notation\n integral = MathTex(r\"\\int_{0}^{2} 0.25x^2 \\, dx\", font_size=40)\n self.play(ReplacementTransform(target_position=ORIGIN, label_text, integral))\n self.play(integral.animate.to_edge(UP))\n self.wait(0.5)\n\n # 5. Calculation Steps\n step1 = MathTex(r\"= \\left[ 0.25 \\cdot \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=36)\n step1.next_to(integral, DOWN, aligned_edge=LEFT)\n \n step2 = MathTex(r\"= \\frac{0.25 \\cdot 2^3}{3} - 0\", font_size=36)\n step2.next_to(step1, DOWN, aligned_edge=LEFT)\n \n step3 = MathTex(r\"= \\frac{0.25 \\cdot 8}{3} = \\frac{2}{3}\", font_size=36)\n step3.next_to(step2, DOWN, aligned_edge=LEFT)\n\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 # 6. Final Result\n final_result = MathTex(r\"\\frac{2}{3}\", font_size=48, color=YELLOW)\n final_result.next_to(step3, DOWN, buff=0.5)\n self.play(Write(final_result))\n self.wait(1)\n\n # 7. Cleanup\n elements_to_remove = VGroup(\n axes, axis_labels, graph, area, integral, step1, step2, step3\n )\n self.play(FadeOut(elements_to_remove))\n \n self.play(final_result.animate.move_to(ORIGIN).scale(1.5))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 oxides and a separate set of carbon grids at the top of the screen. There should also be a lithium ion and an electron positioned together with the lithium ion below the carbon grids. I want the lithium ion to move smoothly across the screen from left to right and then down, tracing a specific path, while an electron follows it along a similar but slightly different path that mimics the main movements of the lithium ion but is offset a bit downward. The electron's path should have it move there and back with a noticeable pause in the middle of its journey to signify it’s interacting with the metal oxides. Can we have the entire movement of both the lithium ion and the electron synchronized and animated in such a way that it's visually pleasing, with a slight delay between their movements?", "chosen": "```python\nfrom manim import *\n\nclass BatteryIonTransport(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n COLOR_CARBON = GREY_B\n COLOR_METAL = RED_B\n COLOR_OXIDE = WHITE\n COLOR_LI = PURPLE\n COLOR_ELECTRON = BLUE_C\n \n GRID_HEIGHT = 3.0\n START_HEIGHT = 1.0\n MOVE_DISTANCE = 5.0\n DROP_DISTANCE = 1.5\n ELECTRON_OFFSET = 0.6\n SYNC_DELAY = 0.2\n \n # --- 1. Initial Scene Setup ---\n # Carbon Grids (Anode) - Top Left\n carbon_grid = VGroup()\n for i in range(5):\n for j in range(3):\n dot = Dot(radius=0.15, color=COLOR_CARBON)\n dot.move_to([-4.5 + i * 0.8, GRID_HEIGHT + j * 0.8, 0])\n carbon_grid.add(dot)\n carbon_label = Text(\"Carbon Anode\", font_size=24).next_to(carbon_grid, UP, buff=0.2)\n carbon_group = VGroup(carbon_grid, carbon_label)\n \n # Metal Oxide Grid (Cathode) - Top Right\n metal_oxide_grid = VGroup()\n for i in range(5):\n for j in range(3):\n metal = Dot(radius=0.15, color=COLOR_METAL)\n metal.move_to([1.0 + i * 1.0, GRID_HEIGHT + j * 0.8, 0])\n oxide = Dot(radius=0.08, color=COLOR_OXIDE)\n oxide.move_to(metal.get_center() + RIGHT * 0.5)\n metal_oxide_grid.add(VGroup(metal, oxide))\n metal_label = Text(\"Metal Oxide Cathode\", font_size=24).next_to(metal_oxide_grid, UP, buff=0.2)\n metal_group = VGroup(metal_oxide_grid, metal_label)\n\n # --- 2. Particles Setup ---\n # Lithium Ion (Li+)\n li_ion = Circle(radius=0.3, color=COLOR_LI, fill_opacity=1.0)\n li_label = Tex(\"Li$^+$\", font_size=24, color=WHITE).move_to(li_ion.get_center())\n li_group = VGroup(li_ion, li_label)\n \n # Electron (e-)\n electron = Circle(radius=0.15, color=COLOR_ELECTRON, fill_opacity=1.0)\n e_label = Tex(\"e$^-$\", font_size=18, color=WHITE).move_to(electron.get_center())\n electron_group = VGroup(electron, e_label)\n\n # Initial Position: Below Carbon Grids\n start_pos = [-4.0, START_HEIGHT, 0]\n li_group.move_to(start_pos)\n electron_group.move_to([start_pos[0], start_pos[1] - ELECTRON_OFFSET, start_pos[2]])\n\n # --- 3. Define Paths ---\n # Li+ Path: Left -> Right -> Down (L-Shape)\n li_path_start = start_pos\n li_path_mid = [start_pos[0] + MOVE_DISTANCE, start_pos[1], 0]\n li_path_end = [li_path_mid[0], start_pos[1] - DROP_DISTANCE, 0]\n \n li_path_horiz = VMobject().set_points_as_corners([li_path_start, li_path_mid])\n li_path_vert = VMobject().set_points_as_corners([li_path_mid, li_path_end])\n \n # Electron Path: Mimics Li+ but offset downward\n el_path_start = [start_pos[0], start_pos[1] - ELECTRON_OFFSET, 0]\n el_path_mid = [start_pos[0] + MOVE_DISTANCE, start_pos[1] - ELECTRON_OFFSET, 0]\n el_path_end = [el_path_mid[0], start_pos[1] - ELECTRON_OFFSET - DROP_DISTANCE, 0]\n \n el_path_horiz = VMobject().set_points_as_corners([el_path_start, el_path_mid])\n el_path_vert = VMobject().set_points_as_corners([el_path_mid, el_path_end])\n \n # Reverse path for electron return journey (there and back)\n electron_path_backward = VMobject().set_points_as_corners([el_path_end, el_path_mid, el_path_start])\n\n # --- 4. Animation Execution ---\n self.play(\n Create(carbon_group),\n Create(metal_group),\n run_time=1.5\n )\n \n self.play(\n FadeIn(li_group),\n FadeIn(electron_group),\n run_time=1.0\n )\n \n self.wait(0.5)\n\n # Phase 1: Horizontal Movement\n # Li+ and e- move right. lag_ratio introduces a slight delay for the electron.\n self.play(\n MoveAlongPath(li_group, li_path_horiz),\n MoveAlongPath(electron_group, el_path_horiz),\n run_time=2.5,\n lag_ratio=SYNC_DELAY,\n rate_func=smooth\n )\n\n # Phase 2: Li+ Vertical Movement & Electron Interaction Pause\n # Li+ moves down into the lattice. Electron pauses to signify interaction with metal oxides.\n self.play(\n MoveAlongPath(li_group, li_path_vert),\n run_time=2.0,\n rate_func=smooth\n )\n \n # Noticeable pause in the middle of the electron's journey\n self.wait(1.5)\n\n # Phase 3: Electron Return Journey (There and Back)\n # Electron traces its path back to the start while Li+ remains embedded\n self.play(\n MoveAlongPath(electron_group, electron_path_backward),\n run_time=3.0,\n rate_func=smooth\n )\n\n self.wait(1.0)\n```", "rejected": "```python\nfrom manim import *\n\nclass BatteryIonTransport(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n COLOR_CARBON = GREY_B\n COLOR_METAL = RED_B\n COLOR_OXIDE = WHITE\n COLOR_LI = PURPLE\n COLOR_ELECTRON = BLUE_C\n \n GRID_HEIGHT = 3.0\n START_HEIGHT = 1.0\n MOVE_DISTANCE = 5.0\n DROP_DISTANCE = 1.5\n ELECTRON_OFFSET = 0.6\n SYNC_DELAY = 0.2\n \n # --- 1. Initial Scene Setup ---\n # Carbon Grids (Anode) - Top Left\n carbon_grid = VGroup()\n for i in range(5):\n for j in range(3):\n dot = Dot(radius=0.15, color=COLOR_CARBON)\n dot.move_to([-4.5 + i * 0.8, GRID_HEIGHT + j * 0.8, 0])\n carbon_grid.add(dot)\n carbon_label = Text(\"Carbon Anode\", font_size=24).next_to(carbon_grid, UP, buff=0.2)\n carbon_group = VGroup(carbon_grid, carbon_label)\n \n # Metal Oxide Grid (Cathode) - Top Right\n metal_oxide_grid = VGroup()\n for i in range(5):\n for j in range(3):\n metal = Dot(radius=0.15, color=COLOR_METAL)\n metal.move_to([1.0 + i * 1.0, GRID_HEIGHT + j * 0.8, 0])\n oxide = Dot(radius=0.08, color=COLOR_OXIDE)\n oxide.move_to(metal.get_center() + RIGHT * 0.5)\n metal_oxide_grid.add(VGroup(metal, oxide))\n metal_label = Text(\"Metal Oxide Cathode\", font_size=24).next_to(metal_oxide_grid, UP, buff=0.2)\n metal_group = VGroup(metal_oxide_grid, metal_label)\n\n # --- 2. Particles Setup ---\n # Lithium Ion (Li+)\n li_ion = Circle(radius=0.3, color=COLOR_LI, fill_opacity=1.0)\n li_label = Tex(\"Li$^+$\", font_size=24, color=WHITE).move_to(li_ion.get_center())\n li_group = VGroup(li_ion, li_label)\n \n # Electron (e-)\n electron = Circle(radius=0.15, color=COLOR_ELECTRON, fill_opacity=1.0)\n e_label = Tex(\"e$^-$\", font_size=18, color=WHITE).move_to(electron.get_center())\n electron_group = VGroup(electron, e_label)\n\n # Initial Position: Below Carbon Grids\n start_pos = [-4.0, START_HEIGHT, 0]\n li_group.move_to(start_pos)\n electron_group.move_to([start_pos[0], start_pos[1] - ELECTRON_OFFSET, start_pos[2]])\n\n # --- 3. Define Paths ---\n # Li+ Path: Left -> Right -> Down (L-Shape)\n li_path_start = start_pos\n li_path_mid = [start_pos[0] + MOVE_DISTANCE, start_pos[1], 0]\n li_path_end = [li_path_mid[0], start_pos[1] - DROP_DISTANCE, 0]\n \n li_path_horiz = VMob().set_points_as_corners([li_path_start, li_path_mid])\n li_path_vert = VMobject().set_points_as_corners([li_path_mid, li_path_end])\n \n # Electron Path: Mimics Li+ but offset downward\n el_path_start = [start_pos[0], start_pos[1] - ELECTRON_OFFSET, 0]\n el_path_mid = [start_pos[0] + MOVE_DISTANCE, start_pos[1] - ELECTRON_OFFSET, 0]\n el_path_end = [el_path_mid[0], start_pos[1] - ELECTRON_OFFSET - DROP_DISTANCE, 0]\n \n el_path_horiz = VMobject().set_points_as_corners([el_path_start, el_path_mid])\n el_path_vert = VMobject().set_points_as_corners([el_path_mid, el_path_end])\n \n # Reverse path for electron return journey (there and back)\n electron_path_backward = VMobject().set_points_as_corners([el_path_end, el_path_mid, el_path_start])\n\n # --- 4. Animation Execution ---\n self.play(\n Create(carbon_group),\n Create(metal_group),\n run_time=1.5\n )\n \n self.play(\n FadeIn(li_group),\n FadeIn(electron_group),\n run_time=1.0\n )\n \n self.wait(0.5)\n\n # Phase 1: Horizontal Movement\n # Li+ and e- move right. lag_ratio introduces a slight delay for the electron.\n self.play(\n MoveAlongPath(li_group, li_path_horiz),\n MoveAlongPath(electron_group, el_path_horiz),\n run_time=2.5,\n lag_ratio=SYNC_DELAY,\n rate_func=smooth\n )\n\n # Phase 2: Li+ Vertical Movement & Electron Interaction Pause\n # Li+ moves down into the lattice. Electron pauses to signify interaction with metal oxides.\n self.play(\n MoveAlongPath(li_group, li_path_vert),\n run_time=2.0,\n rate_func=smooth\n )\n \n # Noticeable pause in the middle of the electron's journey\n self.wait(1.5)\n\n # Phase 3: Electron Return Journey (There and Back)\n # Electron traces its path back to the start while Li+ remains embedded\n self.play(\n MoveAlongPath(electron_group, electron_path_backward),\n run_time=3.0,\n rate_func=smooth\n )\n\n self.wait(1.0)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass CircleConcepts(Scene):\n def construct(self):\n # --- Step 1: Circle and Radius ---\n circle = Circle(radius=2, color=BLUE)\n center = circle.get_center()\n edge = circle.get_right()\n \n radius_line = Line(center, edge, color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n \n self.play(Create(circle))\n self.play(Create(radius_line), Write(radius_label))\n self.wait(2)\n \n # --- Step 2: Area Explanation ---\n area_explanation = Text(\n \"Area of a circle is given by the formula 'Area = \\pi r^2'\",\n font_size=28\n ).to_edge(UP)\n \n self.play(Write(area_explanation))\n self.wait(3)\n \n # --- Step 3: Transform to Area Formula ---\n area_formula = MathTex(\"A = \\\\pi r^2\", font_size=48, color=YELLOW)\n \n self.play(ReplacementTransform(area_explanation, area_formula))\n self.play(area_formula.animate.to_edge(DOWN, buff=1.0))\n self.wait(2)\n \n # --- Step 4: Circumference Visualization ---\n dot = Dot(color=RED).move_to(edge)\n \n self.play(FadeIn(dot))\n self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)\n self.wait(1)\n \n # --- Step 5: Circumference Formula ---\n circ_formula = MathTex(\"C = 2\\\\pi r\", font_size=48, color=RED)\n circ_formula.next_to(circle, DOWN, buff=0.5)\n \n self.play(Write(circ_formula))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass CircleConcepts(Scene):\n def construct(self):\n # --- Step 1: Circle and Radius ---\n circle = Circle(radius=2, color=BLUE)\n center = circle.get_center()\n edge = circle.get_right()\n \n radius_line = Line(center, edge, color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n \n self.play(Create(circle))\n self.play(Create(radius_line), Write(radius_label))\n self.wait(2)\n \n # --- Step 2: Area Explanation ---\n area_explanation = Text(\n \"Area of a circle is given by the formula 'Area = \\pi r^2'\",\n font_size=28\n ).to_edge(UP)\n \n self.play(Write(area_explanation))\n self.wait(3)\n \n # --- Step 3: Transform to Area Formula ---\n area_formula = MathTex(r\"A = \\\\pi r^2\" + \" = x\", font_size=48, color=YELLOW)\n \n self.play(ReplacementTransform(area_explanation, area_formula))\n self.play(area_formula.animate.to_edge(DOWN, buff=1.0))\n self.wait(2)\n \n # --- Step 4: Circumference Visualization ---\n dot = Dot(color=RED).move_to(edge)\n \n self.play(FadeIn(dot))\n self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)\n self.wait(1)\n \n # --- Step 5: Circumference Formula ---\n circ_formula = MathTex(\"C = 2\\\\pi r\", font_size=48, color=RED)\n circ_formula.next_to(circle, DOWN, buff=0.5)\n \n self.play(Write(circ_formula))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Classification Rule\n\\[\n\\hat{y}=\\arg\\max_y \\Big(\\log P(y)+\\sum_{j=1}^d \\log P(x_j\\mid y)\\Big)\n\\]\n- Actual calculations typically use the logarithmic form to convert products into sums, thereby avoiding numerical underflow.\n\n\nThe context of this section (from highest to current level):\n# Machine Learning Course — Detailed Outline for Lecture 8 (Probabilistic Generative Models, 90 minutes)\n## Naive Bayes (25 minutes)\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClassificationRule(Scene):\n\n def construct(self):\n title = Text('Classification Rule', font_size=36).to_edge(UP)\n rule_tex = MathTex('\\\\hat{y}', '=', '\\\\arg\\\\max_y \\\\left(\\\\log P(y) + \\\\sum_{j=1}^{d} \\\\log P(x_j|y)\\\\right)', font_size=40).next_to(title, DOWN, buff=0.5)\n self.play(Write(rule_tex))\n self.wait(1.5)\n \n explanation_text = Tex('- Calculations often utilize log-form for multiplication-to-addition conversion\\n- This helps avoid numerical underflow during probability computations', font_size=26).next_to(rule_tex, DOWN, buff=1)\n box = SurroundingRectangle(explanation_text, color=YELLOW, buff=0.2)\n self.play(FadeIn(explanation_text, shift=DOWN * 0.2), Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ClassificationRule(Scene):\n\n def construct(self):\n # --- Configuration ---\n \n # Colors for consistent theming\n COLOR_TEXT = WHITE\n COLOR_MATH = YELLOW\n \n # Position offsets for sequential display without overlap\n OFFSET_FIRST_LINE = DOWN * 1.5 + LEFT * 2.5\n OFFSET_SECOND_LINE = UP * 1.5 + RIGHT * 0.5\n \n # --- Step 1: Display Mathematical Expression ---\n\n # Create the classification rule equation using MathTex\n math_rule = MathTex(\n r\"\\hat{y}\", \"=\", \n r\"\\arg\\max_y\", \" \", \n r\"\\left( \\\\log P(y) + \\\\sum_{j=1}^{d} \\\\log P(x_j \\\\mid y)\\\\right)\", \n font_size=48,\n color=COLOR_MATH\n )\n \n math_rule.move_to(OFFSET_FIRST_LINE)\n\n # Highlight specific parts of the formula\n highlight_box = SurroundingRectangle(math_rule[2], buff=0.1, color=YELLOW)\n sum_highlight_box = SurroundingRectangle(VGroup(math_rule[4][6], math_rule[4][7]), buff=0.1, color=ORANGE)\n \n # Animate the creation of the rule\n self.play(Write(MathTex(\"\\\\hat{y}=\\\\text{Classification Result}\").to_edge(UP)))\n self.play(Write(math_rule))\n self.play(Create(highlight_box), Create(sum_highlight_box))\n\n # Add explanation text below the equation\n explanation_text = Text(\"Actual calculations avoid underflow by using logs.\", font_size=24).next_to(math_rule, DOWN, buff=0.5)\n self.play(Write(explanation_text))\n \n # Pause briefly at the end of visual presentation\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated educational video that illustrates the concept of finding the area under a curve using integrals. The animation should include a blue-colored set of axes and a green parabolic function graph. I want to display the area under the curve between the points 0.3 and 4.5 on the x-axis, highlighted with a gradient of red to green with a semi-transparent effect. Also, animate the addition of x-axis labels at the points 0.3 and 4.5. Next, show the corresponding integral notation above this area and then transform it to display the exact algebraic calculation of the integral. Once that's done, demonstrate the final result of the definite integral just below the calculation steps. Finally, clear the other elements away to leave just the highlighted area and the result visible. Make sure each step is clearly shown with sufficient time for a viewer to follow, pausing for a couple of seconds between steps.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Setup Axes ---\n # Create blue axes spanning from [-1, 6] on X-axis and [-1, 20] on Y-axis.\n axes = Axes(\n x_range=[-1, 7, 1],\n y_range=[-1, 22, 2],\n x_length=8,\n y_length=7,\n axis_config={\"color\": BLUE},\n )\n \n # Add labels to the axes\n x_label = MathTex(\"x\").next_to(axes.get_x_axis(), DOWN)\n y_label = MathTex(\"y\").next_to(axes.get_y_axis(), LEFT)\n\n self.play(Create(axes))\n self.play(Write(x_label), Write(y_label))\n\n # Pause briefly after setup\n self.wait(2)\n\n # --- Step 2: Plot Function ---\n # Define the Green Parabola f(x) = (1/2)x^2 shifted up by 1 unit.\n # This ensures positive values within the interval [0.3, 4.5].\n func = lambda x: 0.5*x**2 + 1\n \n # Draw the curve specifically over our required range (0.3 to 4.5)\n graph = axes.plot(func, color=GREEN, x_range=[0.3, 4.5])\n self.play(Create(graph))\n\n # Display integer tick marks along both axes for clarity\n integers = VGroup()\n for i in range(-1, 7): \n if i != 0:\n line = Line(UP*0.1, UP*-0.1).shift(RIGHT*i)\n label = Integer(i).scale(0.6).next_to(line, RIGHT, buff=-0.1)\n \n integers.add(VGroup(line, label)) \n \n self.play(FadeIn(integers), run_time=1.5)\n\n # Pause briefly after plotting\n self.wait(2)\n\n # --- Step 3: Highlight Region ---\n # Shade the region bounded by the curve and x-axis from 0.3 to 4.5\n shaded_area = axes.get_area(\n graph, \n x_range=(0.3, 4.5),\n color=RED, fill_opacity=0.6\n )\n\n # Animate the shading appearing with a semi-transparent red-to-green gradient\n self.play(FadeIn(shaded_area), run_time=2)\n self.wait(2)\n\n # --- Step 4: Add Labels ---\n # Place specific labels exactly at x=0.3 and x=4.5\n point_left = Dot(axes.c2p(0.3, func(0.3)), color=YELLOW)\n point_right = Dot(axes.c2p(4.5, func(4.5)), color=YELLOW)\n \n left_text = Text(\"0.3\", font_size=24).next_to(point_left, DOWN)\n right_text = Text(\"4.5\", font_size=24).next_to(point_right, DOWN)\n \n self.play(FadeIn(point_left, left_text), FadeIn(point_right, right_text), run_time=1.5)\n self.wait(2)\n\n # --- Step 5: Integral Notation ---\n # Position text just above the shaded region\n integral_notation = MathTex(\n r\"\\int_{0.3}^{4.5}\", \"(1/2)x^2 \", \"+ 1 \\\\, dx\"\n ).to_edge(UP, buff=0.5)\n \n self.play(Write(integral_notation))\n self.wait(2)\n\n # --- Step 6: Algebra Transformation ---\n # Transform the notational representation into its algebraically simplified form\n algebra_step = MathTex(\n r\"=\\left[ \\frac{1}{2}\\cdot\\frac{x^3}{3} + x \\right] _{0.3} ^{4.5}\"\n ).move_to(integral_notation)\n \n self.play(TransformMatchingTex(integral_notation, algebra_step))\n self.wait(2)\n\n # Calculate the numeric value explicitly for accuracy\n calc_value = MathTex(r\"=\", \"64.4\")\n calc_value.next_to(algebra_step, DOWN, aligned_edge=LEFT).align_to(algebra_step, LEFT).set_color(YELLOW)\n\n self.play(Write(calc_value))\n self.wait(3)\n\n # --- Step 7: Final Result ---\n # Clear intermediate elements while retaining only the shaded region and final answer\n self.play(\n FadeOut(axes), FadeOut(graph), FadeOut(integers),\n FadeOut(left_text), FadeOut(right_text), FadeOut(point_left), FadeOut(point_right),\n FadeOut(integral_notation)\n )\n self.wait(1)\n\n # Move final equation down slightly so it stands alone prominently\n self.play(\n algebra_step.animate.shift(DOWN * 2.0),\n calc_value.animate.move_to(ORIGIN).shift(DOWN * 2.0)\n )\n self.wait(3)\n\n# To render this animation, use the command:\n# manim -pql filename.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_AXES = BLUE\n COLOR_FUNCTION = GREEN\n COLOR_AREA = color_gradient(RED, GREEN)\n COLOR_LABELS = WHITE\n \n # Display Blue Axes\n axes = Axes(\n x_range=[-0.5, 5, 1],\n y_range=[-0.5, 8, 1],\n tips=False,\n x_length=7,\n y_length=6,\n x_axis_config={\"color\": COLOR_AXES},\n y_axis_config={\"color\": COLOR_AXES}\n )\n \n self.play(Create(axes))\n self.wait(2)\n\n # Plot Green Parabola Function f(x) = 0.1*x^2\n func = lambda x: 0.1 * x**2\n graph = axes.plot(func, color=COLOR_FUNCTION)\n \n self.play(Create(graph))\n self.wait(2)\n\n # Highlight Area Under Curve from x = 0.3 to x = 4.5 with Red-Green Gradient\n area = axes.get_area(graph, x_range=(0.3, 4.5), color=COLOR_AREA, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait(2)\n\n # Add X-Axis Labels at Points 0.3 and 4.5\n label_start = MathTex(\"0.3\").next_to(axes.n2p([0.3, 0]), DOWN, buff=-0.2).set_color(COLOR_LABELS)\n line_start = Line(start=axes.c2p(0.3, 0), end=axes.c2p(0.3, 1.5)).set_stroke(width=1, color=WHITE)\n \n label_end = MathTex(\"4.5\").next_to(axes.n2p([4.5, 0]), DOWN, buff=0.2).set_color(COLOR_LABELS)\n line_end = Line(start=axes.c2p(4.5, 0), end=axes.c2p(4.5, 1.5)).set_stroke(width=1, color=WHITE)\n \n self.play(\n Write(label_start),\n Create(line_start),\n Write(label_end),\n Create(line_end)\n )\n self.wait(2)\n\n # Animate Integration Notation Above the Area\n notations = [\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"f(x)\", \"\\\\, dx\", font_size=42),\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"(0.1 x^2)\", \"\\\\, dx\", font_size=42)\n ]\n \n math_notation = VGroup(notations[0]).to_edge(UP, buff=1)\n \n self.play(Write(math_notation))\n self.wait(2)\n self.play(ReplacementTransform(notations[0], notations[1]))\n self.wait(2)\n\n # Transform Notation to Exact Algebra Calculation\n calc_step1 = MathTex(\"\\\\left[ \\\\frac{0.1}{3} x^3 \\\\right]\", \"_{0.3}^{4.5}\", font_size=42)\n calc_step1.move_to(math_notation.get_center())\n \n self.play(Transform(match_target_data=True, math_notation, calc_step1))\n self.wait(2)\n\n # Final Result Just Below the Calculation Steps\n final_result = MathTex(\"\\\\approx\", \"{\\\\small 17.68}\", font_size=42)\n final_box = SurroundingRectangle(final_result, color=YELLOW, fill_opacity=0.1)\n \n final_group = VGroup(calc_step1.copy(), final_box, final_result)\n final_group.arrange(DOWN, aligned_edge=LEFT, buff=1).move_to(MathTex(\"A\").get_center())\n\n self.play(Write(final_group[:2]))\n self.play(Write(final_group[2]))\n self.wait(2)\n\n # Clear All Elements Except Area and Result\n remaining_elements = VGroup(axes, graph, area, label_start, line_start, label_end, line_end)\n self.play(FadeOut(remaining_elements, shift=DOWN))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralScene(Scene):\n def construct(self):\n # --- Step 1: Display Problem ---\n problem = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\, dx\",\n font_size=72,\n color=BLUE\n )\n \n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Explanation Text (TextObject) ---\n text_explanation_1 = Text(\"Evaluating this definite integral appears:\", font_size=36)\n box_text_explanation = SurroundingRectangle(text_explanation_1, buff=0.2, color=YELLOW)\n \n self.play(Write(text_explanation_1))\n self.play(Create(box_text_explanation))\n self.wait(2)\n\n # Clear intermediate elements\n self.play(FadeOut(text_explanation_1), FadeOut(box_text_explanation))\n\n # --- Step 3: Rule Display (Power Rule Formula) ---\n power_rule = MathTex(\n r\"\\int\", \"x^n\", \"\\, dx =\", \"\\\\frac{x^{n+1}}{n+1}\",\n font_size=54,\n color=GREEN\n ).to_edge(UP)\n rule_label = Text(\"General Power Rule:\", font_size=32).next_to(power_rule, UP)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(1)\n\n # Apply the rule specifically for n=2\n app_rule_step = MathTex(\n r\"=\", \"\\\\left.\", \"\\\\frac{x^{2+1}}{2+1}\", r\"\\right|_{0}^{1}\"\n ).set_color(GREEN).scale(1.2)\n app_rule_step.next_to(power_rule, DOWN, buff=1)\n \n self.play(Write(app_rule_step))\n self.wait(1)\n\n # --- Step 4: Calculation Steps ---\n calc_step1 = MathTex(\n r\"=\", \"\\\\left.\", \"\\\\frac{x^3}{3}\", r\"\\right|_{0}^{1}\"\n ).set_color(YELLOW).scale(1.2)\n calc_step2_sub = MathTex(\n r\"=\", r\"\\frac{1^3}{3}\" ,\"-\", r\"\\frac{0^3}{3}\"\n ).set_color(ORANGE).scale(1.2)\n \n calc_group = VGroup(calc_step1, calc_step2_sub)\n calc_group.arrange(DOWN, aligned_edge=LEFT).next_to(app_rule_step, DOWN, buff=0.8)\n \n self.play(Write(calc_step1))\n self.wait(1)\n self.play(Write(calc_step2_sub))\n self.wait(2)\n\n # --- Step 5: Solution Transformation ---\n sol_transform = MathTex(\n r\"=\", r\"\\frac{1}{3}\", \"-\", r\"\\frac{0}{3}\"\n ).scale(1.2).move_to(calc_step2_sub.get_center())\n \n self.play(TransformMatchingTex(calc_step2_sub, sol_transform))\n self.wait(1)\n\n # Final Result Box\n result_box = RoundedRectangle(width=2.5, height=0.8, corner_radius=0.3)\n result_box.move_to(sol_transform.get_center()).shift(RIGHT * 0.5 + UP * 0.2)\n final_answer = MathTex(\"\\\\approx 0.33\", color=RED).scale(2).move_to(result_box.get_center())\n\n self.play(Create(result_box), Write(final_answer))\n self.wait(1)\n\n # --- Step 6: Area Explanation ---\n explain_area = Text(\n \"This value represents the area under the curve\\nbetween 0 and 1.\",\n font_size=28,\n line_spacing=1.2\n ).to_edge(DOWN)\n\n self.play(Write(explain_area))\n self.wait(2)\n\n # --- Step 7: Conclusion Sequence ---\n self.play(\n FadeOut(problem),\n FadeOut(rule_label),\n FadeOut(power_rule),\n FadeOut(app_rule_step),\n FadeOut(calc_group),\n FadeOut(result_box),\n FadeOut(final_answer),\n FadeOut(explain_area)\n )\n\n # Re-present only final solution and its explanation\n final_solution = MathTex(\"\\\\frac{1}{3}\", color=RED).scale(4)\n final_text = Text(\"Area Under Curve\", font_size=36).next_to(final_solution, DOWN, buff=0.5)\n\n self.play(Write(final_solution))\n self.play(Write(final_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Integral ---\n integral_expr = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\\\, dx\"\n ).scale(1.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # --- Step 2: Explanation Text ---\n text_explanation1 = Tex(\"Evaluating this definite integral appears\").to_edge(DOWN).shift(UP*0.5)\n text_rule = Tex(\"\\\\text{General Power Rule: } \\\\int x^n\\\\, dx = \\\\frac{x^{n+1}}{n+1}\").next_to(text_explanation1, DOWN, buff=0.3)\n \n self.play(Write(text_explanation1))\n self.wait(1)\n self.play(FadeIn(text_rule, shift=DOWN))\n self.wait(2)\n\n # Fade out the rule text so it doesn't clutter the screen during calculations\n self.play(FadeOut(text_rule))\n\n # --- Step 3: Show Calculations ---\n calc_step1 = MathTex(\n r\"=\", \"[\", \"(1)^{2+1}\", \"/\", \"(2+1)\", \"]\",\n \"-\", \"[\", \"(0)^{2+1}\", \"/\", \"(2+1)\", \"]\"\n ).next_to(integral_expr, RIGHT, buff=0.5).set_color(YELLOW)\n \n self.play(Write(calc_step1))\n self.wait(1)\n\n # Simplify the exponentials\n calc_simplified = MathTex(\n r\"=\", \"[\", \"1^3\", \"/\", \"3\", \"]\",\n \"- [\", \"0^3\", \"/\", \"3\", \"]\"\n ).move_to(calc_step1)\n \n self.play(ReplacementTransform(calc_step1, calc_simplified))\n self.wait(1)\n\n # Final Substitution Values\n calc_substituted = MathTex(\n r\"=\", \"[\", \"1\", \"/\", \"3\", \"]\",\n \"- [\", \"0\", \"/\", \"3\", \"]\"\n ).move_to(calc_simplified)\n \n self.play(ReplacementTransform(calc_simplified, calc_substituted))\n self.wait(1)\n\n # --- Step 4: Transform to Solution ---\n calc_solution = MathTex(\n r\"=\", r\"\\frac{1}{3}\", \"-\", r\"\\frac{0}{3}\"\n ).move_to(calc_substituted)\n \n self.play(TransformMatchingTex(calc_substituted, calc_solution))\n self.wait(1)\n\n # Calculate Arithmetic Result\n calc_result = MathTex(\n r\"=\", r\"\\frac{1}{3}\" \n ).move_to(calc_solution)\n self.play(ReplacementTransform(calc_solution, calc_result))\n self.wait(1)\n\n # --- Step 5: Present Final Answer ---\n final_answer_text = Tex(\"$A$ represents the Area under the Curve\")\n final_group = VGroup(calc_result, final_answer_text).arrange(RIGHT, buff=0.6)\n box = SurroundingRectangle(final_group, color=YELLOW, buff=0.3)\n \n self.play(\n FadeOut(integral_expr),\n FadeOut(text_explanation1),\n FadeOut(box)\n )\n self.play(Write(final_answer_text))\n self.play(Create(box))\n self.wait(2)\n\n # Clear Everything Before Conclusion\n self.play(FadeOut(VGroup(*all_mobs)))\n\n # --- Step 6: Strong Conclusion ---\n final_conclusion = MathTex(\n r\"A\", \"=\", r\"\\frac{1}{3}\",\n tex_to_color_map={\"A\": BLUE}\n ).scale(1.8).center()\n final_label = Tex(\"Area Under the Curve from $x=0$ to $x=1$\")\n \n self.play(Write(final_conclusion))\n self.play(Write(final_label.next_to(final_conclusion, DOWN)))\n self.wait(3)\n\n# To run this code, save it as a .py file and execute via 'manim filename.py DefiniteIntegralSolution'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an educational animation that walks through the steps of solving a first-order linear ordinary differential equation, specifically y' - 3y = 0, by separating variables, integrating both sides, and then exp\n- Act 3: Create a Manim animation scene that includes the following visual elements and transformations step-by-step: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0641(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_areaundercurveexample()\n self.clear_stage()\n self.act_3_sequentialanimationscene()\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 vertically with consistent spacing\n texts = VGroup(text1, text2, text3)\n texts.arrange(DOWN, buff=1.0)\n\n # Create rectangular highlight boxes for each text\n box1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n box2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n box3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Display all text objects initially\n self.play(Write(texts))\n\n # --- Animation Sequence ---\n\n # 1. Initial State: Highlight the first text with a blue rectangle\n self.play(Create(box1))\n self.wait(0.5)\n\n # 2. Transition 1: Replace blue rectangle with a green rectangle highlighting the second text\n self.play(ReplacementTransform(box1, box2))\n self.wait(0.5)\n\n # 3. Transition 2: Replace green rectangle with a red rectangle highlighting the third text\n self.play(ReplacementTransform(box2, box3))\n self.wait(0.5)\n\n # 4. Final Movement: Animate the red rectangle moving upwards while strictly following the text\n # Add an updater to box3 so it strictly tracks the position of text3 during movement\n box3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n\n # Animate the text moving upwards for a few seconds\n self.play(text3.animate.shift(UP * 2), run_time=2)\n\n # Remove the updater to freeze the box in its final state\n box3.clear_updaters()\n self.wait(1)\n\n def act_2_areaundercurveexample(self):\n curve = MathTex(r\"f(x) = 3 - \\frac{x^3}{3}\", font_size=24).to_edge(UP)\n axes = Axes(\n x_range=[0, 2],\n y_range=[0, 3],\n axis_config={\"color\": BLUE},\n )\n f = lambda x: 3 - (x**3)/3\n graph = axes.plot(f, color=WHITE, x_range=[0, 2])\n\n self.play(Write(curve))\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.5)\n self.wait(1)\n\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n self.play(FadeIn(area))\n self.wait(1)\n\n integral = MathTex(r\"\\int_0^2 (3 - \\frac{x^3}{3}) \\,dx\")\n self.play(ReplacementTransform(curve, integral))\n self.wait(1)\n\n result = MathTex(r\"= [3x - \\frac{x^4}{12}]_0^2\", font_size=24)\n result.to_edge(DOWN)\n self.play(Transform(integral, result))\n self.wait(1)\n\n final_value = MathTex(r\"= (3(2) - \\frac{2^4}{12}) - (3(0) - \\frac{0^4}{12})\", r\"= 6 - \\frac{16}{12}\", r\"= 6 - \\frac{4}{3}\", r\"= \\frac{18}{3} - \\frac{4}{3}\", r\"= \\frac{14}{3}\", font_size=24)\n final_value.next_to(result, DOWN)\n self.play(Write(final_value))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Area under the curve from 0 to 2\", font_size=24).to_edge(DOWN)\n self.play(ReplacementTransform(final_value, conclusion))\n self.wait(2)\n\n def act_3_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0641(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_areaundercurveexample()\n self.clear_stage()\n self.act_3_sequentialanimationscene()\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 vertically with consistent spacing\n texts = VGroup(text1, text2, text3)\n texts.arrange(DOWN, buff=1.0)\n\n # Create rectangular highlight boxes for each text\n box1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n box2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n box3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Display all text objects initially\n self.play(Write(texts))\n\n # --- Animation Sequence ---\n\n # 1. Initial State: Highlight the first text with a blue rectangle\n self.play(Create(box1))\n self.wait(0.5)\n\n # 2. Transition 1: Replace blue rectangle with a green rectangle highlighting the second text\n self.play(ReplacementTransform(target_position=ORIGIN, box1, box2))\n self.wait(0.5)\n\n # 3. Transition 2: Replace green rectangle with a red rectangle highlighting the third text\n self.play(ReplacementTransform(box2, box3))\n self.wait(0.5)\n\n # 4. Final Movement: Animate the red rectangle moving upwards while strictly following the text\n # Add an updater to box3 so it strictly tracks the position of text3 during movement\n box3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n\n # Animate the text moving upwards for a few seconds\n self.play(text3.animate.shift(UP * 2), run_time=2)\n\n # Remove the updater to freeze the box in its final state\n box3.clear_updaters()\n self.wait(1)\n\n def act_2_areaundercurveexample(self):\n curve = MathTex(r\"f(x) = 3 - \\frac{x^3}{3}\", font_size=24).to_edge(UP)\n axes = Axes(\n x_range=[0, 2],\n y_range=[0, 3],\n axis_config={\"color\": BLUE},\n )\n f = lambda x: 3 - (x**3)/3\n graph = axes.plot(f, color=WHITE, x_range=[0, 2])\n\n self.play(Write(curve))\n area = axes.get_area(graph, x_range=(0, 2), color=[BLUE, GREEN], opacity=0.5)\n self.wait(1)\n\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n self.play(FadeIn(area))\n self.wait(1)\n\n integral = MathTex(r\"\\int_0^2 (3 - \\frac{x^3}{3}) \\,dx\")\n self.play(ReplacementTransform(curve, integral))\n self.wait(1)\n\n result = MathTex(r\"= [3x - \\frac{x^4}{12}]_0^2\", font_size=24)\n result.to_edge(DOWN)\n self.play(Transform(integral, result))\n self.wait(1)\n\n final_value = MathTex(r\"= (3(2) - \\frac{2^4}{12}) - (3(0) - \\frac{0^4}{12})\", r\"= 6 - \\frac{16}{12}\", r\"= 6 - \\frac{4}{3}\", r\"= \\frac{18}{3} - \\frac{4}{3}\", r\"= \\frac{14}{3}\", font_size=24)\n final_value.next_to(result, DOWN)\n self.play(Write(final_value))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Area under the curve from 0 to 2\", font_size=24).to_edge(DOWN)\n self.play(ReplacementTransform(final_value, conclusion))\n self.wait(2)\n\n def act_3_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## Basic Concepts of Variables and Constants\n\n- Variable:\n - A storage unit in memory with a specific type and name;\n - The value of a variable can be changed during program execution (Reassigned).\n - The type determines the bit width (Bit width) and interpretation method (such as two's complement or floating-point format) of the variable.\n\n\nContext location of this section (from highest level to current):\n# Basic Components of a Program\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ConceptVariablesAndConstants(Scene):\n\n def construct(self):\n title = Text('Basic Concepts of Variables and Constants', font_size=36).to_edge(UP)\n header_var = Text('Variable:', color=BLUE, weight=BOLD).next_to(title, DOWN, buff=0.7).align_to(title, LEFT)\n desc_var1 = Text('- Storage unit in memory\\n with a specific type and name;\\n Reassignable.', t2c={'Storage': BLUE, 'specific': YELLOW}).scale(0.8).next_to(header_var, DOWN, buff=0.4).shift(RIGHT * 0.1)\n desc_var2 = MathTex('\\\\text{Type} \\\\rightarrow \\\\text{Bit Width}', '\\\\qquad', '\\\\text{\"Two\\'s Complement\"}').scale(0.7).arrange(DOWN, aligned_edge=LEFT).next_to(desc_var1, DOWN, buff=0.5).shift(RIGHT * 0.1)\n dot_type = Dot(color=YELLOW).move_to(desc_var2.get_center() + RIGHT * 3.0)\n rect_bitwidth = RoundedRectangle(corner_radius=0.1, height=0.4, width=2.2, color=GREEN).move_to(dot_type.get_right())\n label_bw = Tex('$\\\\times$ Bit Width').scale(0.6).next_to(rect_bitwidth, UP, buff=0.2)\n var_type_label = Text('\"Integer\"', font_size=24, color=WHITE).rotate(-PI/2).next_to(rect_bitwidth, LEFT, buff=0.2)\n \n self.play(FadeIn(title))\n self.play(Write(header_var))\n self.play(FadeIn(desc_var1, shift=RIGHT))\n self.wait(1)\n self.play(Write(desc_var2))\n self.wait(0.5)\n self.play(Create(dot_type), FadeIn(var_type_label))\n self.play(GrowFromCenter(rect_bitwidth), Write(label_bw))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass VariablesAndConstants(Scene):\n\n def construct(self):\n title = Text('Basic Concepts of Variables and Constants', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title))\n var_title = Text('Variable:', font_size=28)\n var_text1 = Text('- Storage Unit in Memory\\nwith Specific Type and Name', font_size=20, line_spacing=1.5).next_to(var_title, DOWN, buff=0.4)\n var_box = RoundedRectangle(width=2, height=0.8, corner_radius=0.15, color=BLUE)\n var_label = Text('name', font_size=20, color=WHITE).move_to(var_box.get_center())\n var_group = VGroup(var_box, var_label).shift(RIGHT * 4 + UP * 1.7)\n var_text2 = Text(\"The Value Can Be Changed During Execution\", font_size=20, color=YELLOW).next_to(var_group, DOWN, buff=0.4)\n var_type_label = Text('Type determines Bit Width and Interpretation Method.', font_size=20, line_spacing=1.3).to_edge(DOWN, buff=1.0)\n const_title = Text('\\nConstant:', font_size=28)\n const_desc = Text(\"- Immutable Data Represented by Literal Values\\nor Expressions That Do Not Change.\", font_size=20, line_spacing=1.5).next_to(const_title, DOWN, buff=0.4)\n const_example = MathTex('\\\\text{const } MAX_VALUE = \\\\text{\"255\"}').scale(0.8).next_to(const_desc, DOWN, buff=0.2)\n const_block = VGroup(Text('const MAX_VALUE = \"255\"', font_size=16, weight=BOLD), Rectangle(height=1.5, width=4.5, stroke_color=GREEN)).arrange(DOWN, aligned_edge=LEFT, buff=0.2).shift(RIGHT * 4 + DOWN * 1.8)\n self.play(FadeIn(var_title, shift=RIGHT))\n self.play(Write(var_text1))\n self.play(Create(var_group[0]), Write(var_group[1]))\n self.play(Write(var_text2))\n self.play(Write(var_type_label))\n self.play(Write(const_title, shift=DOWN))\n self.play(Write(const_desc))\n self.play(Write(const_example))\n self.play(Create(const_block[1]), FadeIn(const_block[0], scale=0.5))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains the original rotation while adding explanatory text, a coordinate system for context, and a transformation into a square to demonstrate geometric relationships: \n\nThe animation begins by displaying a right-angled triangle with vertices at (-1, 0), (1, 0), and (0, 2) on a coordinate plane with labeled x and y axes. As the triangle rotates 90 degrees clockwise, a dynamic equation appears below it, showing the rotation transformation matrix: \n\\[ \\begin{pmatrix} \\cos(90°) & -\\sin(90°) \\\\ \\sin(90°) & \\cos(90°) \\end{pmatrix} \\] \nAfter the rotation completes, the triangle smoothly morphs into a square centered at the origin, with side length equal to the original triangle’s base (2 units), while text fades in explaining how both shapes share rotational symmetry. The animation concludes with the square fading out, leaving only the rotated triangle and the equation for emphasis. This version not only demonstrates rotation but also connects it to linear algebra and symmetry in a visually engaging way.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRotationScene(Scene):\n def construct(self):\n # Create coordinate axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n x_length=6,\n y_length=6,\n axis_config={\"color\": BLUE},\n )\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n\n # Create triangle\n triangle = Polygon(\n [-1, 0, 0], [1, 0, 0], [0, 2, 0],\n color=GREEN,\n fill_opacity=0.5\n )\n triangle_label = Tex(\"Original Triangle\").next_to(triangle, DOWN)\n\n # Create rotation matrix equation\n rotation_matrix = MathTex(\n r\"\\begin{pmatrix} \\cos(90^\\circ) & -\\sin(90^\\circ) \\\\ \\sin(90^\\circ) & \\cos(90^\\circ) \\end{pmatrix}\",\n color=YELLOW\n ).to_edge(DOWN)\n\n # Create square (for later transformation)\n square = Square(side_length=2, color=RED, fill_opacity=0.5)\n square_text = Tex(\"Square with rotational symmetry\").next_to(square, UP)\n\n # Animation sequence\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(triangle), Write(triangle_label))\n self.wait(1)\n \n # Rotate triangle and show matrix\n self.play(\n Rotate(triangle, angle=PI/2, about_point=ORIGIN),\n Write(rotation_matrix),\n run_time=2\n )\n self.wait(1)\n \n # Transform to square and show symmetry text\n self.play(\n Transform(triangle, square),\n FadeIn(square_text),\n run_time=2\n )\n self.wait(2)\n \n # Fade out square and text, leave rotated triangle and matrix\n self.play(\n FadeOut(square_text),\n triangle.animate.become(\n Polygon(\n [0, -1, 0], [0, 1, 0], [-2, 0, 0],\n color=GREEN,\n fill_opacity=0.5\n )\n ),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRotationScene(Scene):\n def construct(self):\n # Create coordinate axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n x_length=6,\n y_length=6,\n axis_config={\"color\": BBLUE},\n )\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n\n # Create triangle\n triangle = Polygon(\n [-1, 0, 0], [1, 0, 0], [0, 2, 0],\n color=GREEN,\n fill_opacity=0.5\n )\n triangle_label = Tex(\"Original Triangle\").next_to(triangle, DOWN)\n\n # Create rotation matrix equation\n rotation_matrix = MathTex(\n r\"\\begin{pmatrix} \\cos(90^\\circ) & -\\sin(90^\\circ) \\\\ \\sin(90^\\circ) & \\cos(90^\\circ) \\end{pmatrix}\",\n color=YELLOW\n ).to_edge(DOWN)\n\n # Create square (for later transformation)\n square = Square(side_length=2, color=RED, fill_opacity=0.5)\n square_text = Tex(\"Square with rotational symmetry\").next_to(square, UP)\n\n # Animation sequence\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(triangle), Write(triangle_label))\n self.wait(1)\n \n # Rotate triangle and show matrix\n self.play(\n Rotate(triangle, angle=PI/2, about_point=ORIGIN),\n Write(rotation_matrix),\n run_time=2\n )\n self.wait(1)\n \n # Transform to square and show symmetry text\n self.play(\n Transform(triangle, square),\n FadeIn(square_text),\n run_time=2\n )\n self.wait(2)\n \n # Fade out square and text, leave rotated triangle and matrix\n self.play(\n FadeOut(square_text),\n triangle.animate.become(\n Polygon(\n [0, -1, 0], [0, 1, 0], [-2, 0, 0],\n color=GREEN,\n fill_opacity=0.5\n )\n ),\n run_time=2\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational animation that visually explains the process of solving a triple integral problem step by step. Start with the triple integral of the function xyz over the cube defined by 0 to 1 on all axes. First, display the integral formula on the screen. Then, guide me through each integration step one at a time, integrating first with respect to x, then y, and finally z, using text explanations placed at the top of the screen before each step. At each step, replace the previous mathematical step with the new integral expression that results from performing the integration. After completing all integration steps, show the final numerical answer. Clear the screen before showing me the concluding answer again to reinforce it. Make sure to pause briefly after introducing new information so I can follow along with the computation.", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Step 0: Display the initial integral formula ---\n initial_integral = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=32).to_edge(UP)\n # \\int x dx from 0 to 1 = 1/2, so the expression becomes \\int \\int (1/2)yz dy dz\n integral_after_x = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(initial_integral, integral_after_x))\n self.wait(2)\n self.play(FadeOut(step1_text))\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y\", font_size=32).to_edge(UP)\n # \\int y dy from 0 to 1 = 1/2, so the constant becomes 1/2 * 1/2 = 1/4\n # The expression becomes \\int (1/4)z dz\n integral_after_y = MathTex(\n r\"\\int_0^1 \\frac{1}{4}z \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(step2_text))\n self.wait(1)\n self.play(ReplacementTransform(integral_after_x, integral_after_y))\n self.wait(2)\n self.play(FadeOut(step2_text))\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", font_size=32).to_edge(UP)\n # \\int z dz from 0 to 1 = 1/2, so the constant becomes 1/4 * 1/2 = 1/8\n final_result = MathTex(\n r\"\\frac{1}{8}\",\n font_size=60\n ).move_to(ORIGIN)\n \n self.play(Write(step3_text))\n self.wait(1)\n self.play(ReplacementTransform(integral_after_y, final_result))\n self.wait(2)\n self.play(FadeOut(step3_text))\n \n # Pause to show the result of the computation\n self.wait(1)\n\n # --- Clear the screen and reinforce the final answer ---\n self.clear()\n self.wait(1)\n \n # Display the concluding answer prominently\n concluding_answer = MathTex(\n r\"\\iiint_V xyz \\, dV = \\frac{1}{8} = 0.125\",\n font_size=54,\n color=YELLOW\n ).move_to(ORIGIN)\n \n self.play(Write(concluding_answer))\n self.play(Indicate(concluding_answer))\n self.wait(3)\n self.play(FadeOut(concluding_answer))\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Step 0: Display the initial integral formula ---\n initial_integral = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=32).to_edge(UP)\n # \\int x dx from 0 to 1 = 1/2, so the expression becomes \\int \\int (1/2)yz dy dz\n integral_after_x = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(initial_integral, integral_after_x))\n self.wait(2)\n self.play(FadeOut(step1_text))\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y\", font_size=32).to_edge(UP)\n # \\int y dy from 0 to 1 = 1/2, so the constant becomes 1/2 * 1/2 = 1/4\n # The expression becomes \\int (1/4)z dz\n integral_after_y = MathTex(\n r\"\\int_0^1 \\frac{1}{4}z \\, dz\",\n font_size=48\n ).move_to(ORIGIN)\n \n self.play(Write(step2_text))\n self.wait(1)\n self.play(ReplacementTransform(integral_after_x, integral_after_y))\n self.wait(2)\n self.play(FadeOut(step2_text))\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", font_size=32).to_edge(UP)\n # \\int z dz from 0 to 1 = 1/2, so the constant becomes 1/4 * 1/2 = 1/8\n final_result = MathTex(r\"\\frac{1}{8}\" + \" = x\",\n font_size=60\n ).move_to(ORIGIN)\n \n self.play(Write(step3_text))\n self.wait(1)\n self.play(ReplacementTransform(integral_after_y, final_result))\n self.wait(2)\n self.play(FadeOut(step3_text))\n \n # Pause to show the result of the computation\n self.wait(1)\n\n # --- Clear the screen and reinforce the final answer ---\n self.clear()\n self.wait(1)\n \n # Display the concluding answer prominently\n concluding_answer = MathTex(\n r\"\\iiint_V xyz \\, dV = \\frac{1}{8} = 0.125\",\n font_size=54,\n color=YELLOW\n ).move_to(ORIGIN)\n \n self.play(Write(concluding_answer))\n self.play(Indicate(concluding_answer))\n self.wait(3)\n self.play(FadeOut(concluding_answer))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can adaptive quadrature accurately integrate discontinuous functions, and how does it handle points of discontinuity?", "chosen": "```python\nfrom manim import *\n\nclass AdaptiveQuadratureScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Adapting to Discontinuity: The Magic of Adaptive Quadrature\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-2, 3, 1],\n axis_config={\"color\": BLUE}\n )\n self.play(Create(axes))\n \n # Create a discontinuous function\n def f(x):\n if abs(x) < 0.1: # Avoid division by zero\n return 0\n elif x < 0:\n return -1/x if x > -2 else 1\n else:\n return 1/x if x < 2 else 1\n \n # Plot the function\n left_curve = axes.plot(lambda x: f(x), x_range=[-3, -0.1], color=RED)\n right_curve = axes.plot(lambda x: f(x), x_range=[0.1, 3], color=RED)\n \n function_label = MathTex(r\"f(x) = \\begin{cases} \\frac{1}{x}, & x \\neq 0 \\\\ 0, & x = 0 \\end{cases}\")\n function_label.scale(0.7).next_to(axes, DOWN)\n \n self.play(Create(left_curve), Create(right_curve), Write(function_label))\n self.wait(1)\n \n # Highlight the discontinuity\n highlight = Circle(radius=0.3, color=YELLOW).move_to(axes.c2p(0, 0))\n self.play(Create(highlight))\n self.wait(1)\n \n # Regular quadrature - uniform intervals\n regular_rects = VGroup()\n step = 0.5\n \n for x in np.arange(-2.75, 2.8, step):\n if -0.25 < x < 0.25: # Skip near discontinuity\n continue\n \n height = f(x)\n if abs(height) > 3: # Cap very tall rectangles \n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=step,\n height=abs(height),\n stroke_width=1,\n fill_color=BLUE,\n fill_opacity=0.5\n )\n \n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n regular_rects.add(rect)\n \n regular_text = Text(\"Regular Quadrature\", font_size=20).next_to(function_label, DOWN)\n self.play(Write(regular_text))\n self.play(Create(regular_rects))\n self.wait(1)\n \n # Adaptive quadrature - variable intervals\n adaptive_rects = VGroup()\n \n # Wider steps for smooth regions\n wide_step = 0.5\n for x in np.arange(-2.75, -1.0, wide_step):\n height = f(x)\n rect = Rectangle(\n width=wide_step,\n height=abs(height),\n stroke_width=1,\n fill_color=GREEN,\n fill_opacity=0.5\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n for x in np.arange(1.0, 2.8, wide_step):\n height = f(x)\n rect = Rectangle(\n width=wide_step,\n height=abs(height),\n stroke_width=1,\n fill_color=GREEN,\n fill_opacity=0.5\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n # Finer steps near discontinuity\n fine_step = 0.1\n for x in np.arange(-1.0, -0.1, fine_step):\n height = f(x)\n if abs(height) > 3:\n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=fine_step,\n height=abs(height),\n stroke_width=1,\n fill_color=YELLOW,\n fill_opacity=0.7\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n for x in np.arange(0.1, 1.0, fine_step):\n height = f(x)\n if abs(height) > 3:\n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=fine_step,\n height=abs(height),\n stroke_width=1,\n fill_color=YELLOW,\n fill_opacity=0.7\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n adaptive_text = Text(\"Adaptive Quadrature\", font_size=20, color=GREEN).next_to(function_label, DOWN)\n self.play(ReplacementTransform(regular_text, adaptive_text))\n self.play(ReplacementTransform(regular_rects, adaptive_rects))\n self.wait(1)\n \n # Formula\n formula = MathTex(r\"\\int_a^b f(x) \\, dx \\approx \\sum_{i=1}^{n} w_i f(x_i)\")\n formula.scale(0.7).next_to(adaptive_text, DOWN)\n self.play(Write(formula))\n self.wait(1)\n \n # Key insight\n insight_text = Text(\"Smaller steps near discontinuities\", font_size=24, color=YELLOW)\n insight_text.next_to(formula, DOWN)\n self.play(Write(insight_text))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Adaptive quadrature accurately integrates discontinuous functions\", font_size=24)\n self.play(\n FadeOut(adaptive_rects),\n FadeOut(highlight),\n FadeOut(left_curve),\n FadeOut(right_curve),\n FadeOut(axes),\n FadeOut(function_label),\n FadeOut(adaptive_text),\n FadeOut(formula),\n FadeOut(insight_text),\n FadeOut(title),\n Write(conclusion)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AdaptiveQuadratureScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Adapting to Discontinuity: The Magic of Adaptive Quadrature\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-2, 3, 1],\n axis_config={\"color\": BLUE}\n )\n self.play(Create(axes))\n \n # Create a discontinuous function\n def f(x):\n if abs(x) < 0.1: # Avoid division by zero\n return 0\n elif x < 0:\n return -1/x if x > -2 else 1\n else:\n return 1/x if x < 2 else 1\n \n # Plot the function\n left_curve = axes.plot(lambda x: f(x), x_range=[-3, -0.1], color=RED)\n right_curve = axes.plot(lambda x: f(x), x_range=[0.1, 3], color=RED)\n \n function_label = MathTex(r\"f(x) = \\begin{cases} \\frac{1}{x}, & x \\neq 0 \\\\ 0, & x = 0 \\end{cases}\")\n function_label.scale(0.7).next_to(axes, DOWN)\n \n self.play(Create(left_curve), Create(right_curve), Write(function_label))\n self.wait(1)\n \n # Highlight the discontinuity\n highlight = Circle(radius=0.3, color=YELLOW).move_to(axes.c2p(0, 0))\n self.play(Create(highlight))\n self.wait(1)\n \n # Regular quadrature - uniform intervals\n regular_rects = VGroup()\n step = 0.5\n \n for x in np.arange(-2.75, 2.8, step):\n if -0.25 < x < 0.25: # Skip near discontinuity\n continue\n \n height = f(x)\n if abs(height) > 3: # Cap very tall rectangles \n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=step,\n height=abs(height),\n stroke_width=1,\n fill_color=BLUE,\n fill_opacity=0.5\n )\n \n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n regular_rects.add(rect)\n \n regular_text = Text(\"Regular Quadrature\", font_size=20).next_to(function_label, DOWN)\n self.play(Write(regular_text))\n self.play(Create(regular_rects))\n self.wait(1)\n \n # Adaptive quadrature - variable intervals\n adaptive_rects = VGroup()\n \n # Wider steps for smooth regions\n wide_step = 0.5\n for x in np.arange(-2.75, -1.0, wide_step):\n height = f(x)\n rect = Rectangle(\n width=wide_step,\n height=abs(height),\n stroke_width=1,\n fill_color=GREEN,\n fill_opacity=0.5\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n for x in np.arange(1.0, 2.8, wide_step):\n height = f(x)\n rect = Rectangle(\n width=wide_step,\n height=abs(height),\n stroke_width=1,\n fill_color=GREEN,\n fill_opacity=0.5\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n # Finer steps near discontinuity\n fine_step = 0.1\n for x in np.arange(-1.0, -0.1, fine_step):\n height = f(x)\n if abs(height) > 3:\n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=fine_step,\n height=abs(height),\n stroke_width=1,\n fill_color=YELLOW,\n fill_opacity=0.7\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n for x in np.arange(0.1, 1.0, fine_step):\n height = f(x)\n if abs(height) > 3:\n height = 3 * (1 if height > 0 else -1)\n \n rect = Rectangle(\n width=fine_step,\n height=abs(height),\n stroke_width=1,\n fill_color=YELLOW,\n fill_opacity=0.7\n )\n y_pos = height/2 if height > 0 else height/2\n rect.move_to(axes.c2p(x, y_pos))\n adaptive_rects.add(rect)\n \n adaptive_text = Text(\"Adaptive Quadrature\", font_size=20, color=GREEN).next_to(function_label, DOWN)\n self.play(ReplacementTransform(regular_text, adaptive_text))\n self.play(ReplacementTransform(regular_rects, adaptive_rects))\n self.wait(1)\n \n # Formula\n formula = MathTex(r\"\\int_a^b f(x) \\, dx \\approx \\sum_{i=1}^{n} w_i f(x_i)\")\n formula.scale(0.7).next_to(adaptive_text, DOWN)\n self.play(Write(formula))\n self.wait(1)\n \n # Key insight\n insight_text = Text(\"Smaller steps near discontinuities\", font_size=24, color=YELLOW)\n insight_text.next_to(formula, DOWN)\n self.play(Write(insight_text))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Adaptive quadrature accurately integrates discontinuous functions\", font_size=24)\n self.play(\n FadeOut(adaptive_rects),\n FadeOut(highlight),\n FadeOut(left_curve),\n FadeOut(right_curve),\n FadeOut(axes),\n FadeOut(function_label),\n FadeOut(adaptive_text),\n FadeOut(formula),\n FadeOut(insight_text),\n FadeOut(title),\n Write(conclusion)\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows a math student thoughtfully considering the greatest common divisor (GCD) of two numbers, 48 and 64, and then display the answer? I would like a pensive imagery with thought bubbles, and after a short pause, the answer should be revealed clearly. Can the overall color theme be soft with a background that is easy on the eyes?", "chosen": "```python\nfrom manim import *\n\nclass GCDThoughtScene(Scene):\n def construct(self):\n # --- Color Palette ---\n # Soft, muted colors for a pensive and easy-on-the-eyes aesthetic\n BG_COLOR = \"#F0F4F8\" # Soft light blue-grey background\n STUDENT_COLOR = \"#78909C\" # Muted slate blue\n BUBBLE_COLOR = \"#FFFFFF\" # Pure white for bubbles\n BUBBLE_STROKE = \"#A0AEC0\" # Light gray stroke for bubbles\n TEXT_COLOR = \"#455A64\" # Dark slate grey for text\n HIGHLIGHT_COLOR = \"#81C784\" # Soft green for the final answer\n BOX_COLOR = \"#F9E79F\" # Soft yellow for the answer highlight box\n \n self.camera.background_color = BG_COLOR\n\n # --- Student Representation ---\n # Creating a stylized, minimalist student figure\n head = Circle(radius=0.5, color=STUDENT_COLOR, fill_opacity=1, stroke_width=0)\n body = RoundedRectangle(corner_radius=0.2, height=1.5, width=1.2, \n color=STUDENT_COLOR, fill_opacity=1, stroke_width=0)\n body.next_to(head, DOWN, buff=0)\n \n # Eyes to convey thoughtfulness\n eye_left = Circle(radius=0.08, color=TEXT_COLOR, fill_opacity=1, stroke_width=0)\n eye_right = Circle(radius=0.08, color=TEXT_COLOR, fill_opacity=1, stroke_width=0)\n eyes = VGroup(eye_left, eye_right).arrange(RIGHT, buff=0.15)\n eyes.move_to(head.get_center() + UP * 0.1)\n \n student = VGroup(head, body, eyes)\n student.shift(LEFT * 3.5 + DOWN * 0.5)\n\n # --- Thought Bubble Components ---\n # Main bubble\n main_bubble = Ellipse(width=2.5, height=1.5, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n main_bubble.next_to(head, UR, buff=0.8)\n \n # Small bubbles leading to the main one\n small_bubble_1 = Circle(radius=0.2, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n small_bubble_1.next_to(main_bubble, DL, buff=-0.1)\n \n small_bubble_2 = Circle(radius=0.12, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n small_bubble_2.next_to(small_bubble_1, DL, buff=-0.05)\n \n thought_cloud = VGroup(main_bubble, small_bubble_1, small_bubble_2)\n\n # --- Text Elements ---\n # The numbers the student is considering\n numbers = MathTex(\"48\", \",\", \"64\", font_size=48, color=TEXT_COLOR)\n numbers.move_to(main_bubble.get_center())\n \n # The GCD question\n question = MathTex(r\"\\text{GCD}(48, 64) = \\text{?}\", font_size=40, color=TEXT_COLOR)\n question.move_to(main_bubble.get_center())\n \n # The answer revealed inside the bubble\n answer_in_bubble = MathTex(\"16\", font_size=48, color=HIGHLIGHT_COLOR)\n answer_in_bubble.move_to(main_bubble.get_center())\n\n # --- Final Equation & Highlight Box ---\n gcd_label = MathTex(r\"\\text{GCD}(48, 64) =\", font_size=50, color=TEXT_COLOR)\n gcd_val = MathTex(\"16\", font_size=50, color=HIGHLIGHT_COLOR)\n gcd_group = VGroup(gcd_label, gcd_val).arrange(RIGHT, buff=0.2)\n gcd_group.next_to(student, RIGHT, buff=2.5).shift(DOWN * 0.5)\n \n # Highlight Box for the answer\n answer_box = SurroundingRectangle(gcd_val, color=BOX_COLOR, buff=0.2, corner_radius=0.2)\n answer_box.set_fill(BOX_COLOR, opacity=0.3)\n\n # --- Animation Sequence ---\n \n # 1. Introduce the student\n self.play(FadeIn(student, shift=UP), run_time=1)\n self.wait(0.5)\n\n # 2. Thought bubbles appear gradually\n self.play(FadeIn(small_bubble_2), run_time=0.4)\n self.play(FadeIn(small_bubble_1), run_time=0.4)\n self.play(FadeIn(main_bubble), run_time=0.8)\n\n # 3. Display the numbers and transition to the GCD question\n self.play(Write(numbers), run_time=1)\n self.wait(1)\n self.play(Transform(numbers, question), run_time=1)\n \n # 4. Pensive Pause\n # The \"thinking\" phase where the student considers the answer\n self.wait(2.5) \n\n # 5. Reveal the answer clearly inside the bubble\n self.play(Transform(numbers, answer_in_bubble), run_time=1.2)\n self.wait(1.0)\n \n # 6. Reveal Full Equation Below with Highlight\n self.play(FadeIn(gcd_group), FadeIn(answer_box), run_time=1.0)\n \n # Emphasize the result\n self.play(Indicate(gcd_val, color=HIGHLIGHT_COLOR, scale_factor=1.2), run_time=1.5)\n \n self.wait(2.0)\n```", "rejected": "```python\nfrom manim import *\n\nclass GCDThoughtScene(Scene):\n def construct(self):\n # --- Color Palette ---\n # Soft, muted colors for a pensive and easy-on-the-eyes aesthetic\n BG_COLOR = \"#F0F4F8\" # Soft light blue-grey background\n STUDENT_COLOR = \"#78909C\" # Muted slate blue\n BUBBLE_COLOR = \"#FFFFFF\" # Pure white for bubbles\n BUBBLE_STROKE = \"#A0AEC0\" # Light gray stroke for bubbles\n TEXT_COLOR = \"#455A64\" # Dark slate grey for text\n HIGHLIGHT_COLOR = \"#81C784\" # Soft green for the final answer\n BOX_COLOR = \"#F9E79F\" # Soft yellow for the answer highlight box\n \n self.camera.background_color = BG_COLOR\n\n # --- Student Representation ---\n # Creating a stylized, minimalist student figure\n head = Circle(radius=0.5, color=STUDENT_COLOR, fill_opacity=1, stroke_width=0)\n body = RoundedRectangle(corner_radius=0.2, height=1.5, width=1.2, \n color=STUDENT_COLOR, fill_opacity=1, stroke_width=0)\n body.next_to(head, DOWN, buff=0)\n \n # Eyes to convey thoughtfulness\n eye_left = Circle(radius=0.08, color=TEXT_COLOR, fill_opacity=1, stroke_width=0)\n eye_right = Circle(radius=0.08, color=TEXT_COLOR, fill_opacity=1, stroke_width=0)\n eyes = VGroup(eye_left, eye_right).arrange(RIGHT, buff=0.15)\n eyes.move_to(head.get_center() + UP * 0.1)\n \n student = VGroup(head, body, eyes)\n student.shift(LEFT * 3.5 + DOWN * 0.5)\n\n # --- Thought Bubble Components ---\n # Main bubble\n main_bubble = Ellipse(width=2.5, height=1.5, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n main_bubble.next_to(head, UR, buff=0.8)\n \n # Small bubbles leading to the main one\n small_bubble_1 = Circle(radius=0.2, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n small_bubble_1.next_to(main_bubble, DL, buff=-0.1)\n \n small_bubble_2 = Circle(radius=0.12, color=BUBBLE_STROKE, fill_opacity=1, fill_color=BUBBLE_COLOR, stroke_width=2)\n small_bubble_2.next_to(small_bubble_1, DL, buff=-0.05)\n \n thought_cloud = VGroup(main_bubble, small_bubble_1, small_bubble_2)\n\n # --- Text Elements ---\n # The numbers the student is considering\n numbers = MathTex(\"48\", \",\", \"64\", font_size=48, color=TEXT_COLOR)\n numbers.move_to(main_bubble.get_center())\n \n # The GCD question\n question = MathTex(r\"\\text{GCD}(48, 64) = \\text{?}\", font_size=40, color=TEXT_COLOR)\n question.move_to(main_bubble.get_center())\n \n # The answer revealed inside the bubble\n answer_in_bubble = MathTex(\"16\", font_size=48, color=HIGHLIGHT_COLOR)\n answer_in_bubble.move_to(main_bubble.get_center())\n\n # --- Final Equation & Highlight Box ---\n gcd_label = MathTex(r\"\\text{GCD}(48, 64) =\" + \" = x\", font_size=50, color=TEXT_COLOR)\n gcd_val = MathTex(\"16\", font_size=50, color=HIGHLIGHT_COLOR)\n gcd_group = VGroup(gcd_label, gcd_val).arrange(RIGHT, buff=0.2)\n gcd_group.next_to(student, RIGHT, buff=2.5).shift(DOWN * 0.5)\n \n # Highlight Box for the answer\n answer_box = SurroundingRectangle(gcd_val, color=BOX_COLOR, buff=0.2, corner_radius=0.2)\n answer_box.set_fill(BOX_COLOR, opacity=0.3)\n\n # --- Animation Sequence ---\n \n # 1. Introduce the student\n self.play(FadeIn(student, shift=UP), run_time=1)\n self.wait(0.5)\n\n # 2. Thought bubbles appear gradually\n self.play(FadeIn(small_bubble_2), run_time=0.4)\n self.play(FadeIn(small_bubble_1), run_time=0.4)\n self.play(FadeIn(main_bubble), run_time=0.8)\n\n # 3. Display the numbers and transition to the GCD question\n self.play(Write(numbers), run_time=1)\n self.wait(1)\n self.play(Transform(numbers, question), run_time=1)\n \n # 4. Pensive Pause\n # The \"thinking\" phase where the student considers the answer\n self.wait(2.5) \n\n # 5. Reveal the answer clearly inside the bubble\n self.play(Transform(numbers, answer_in_bubble), run_time=1.2)\n self.wait(1.0)\n \n # 6. Reveal Full Equation Below with Highlight\n self.play(FadeIn(gcd_group), FadeIn(answer_box), run_time=1.0)\n \n # Emphasize the result\n self.play(Indicate(gcd_val, color=HIGHLIGHT_COLOR, scale_factor=1.2), run_time=1.5)\n \n self.wait(2.0)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to see an animation that explains the concept of a derivative using a visual representation. Can you create an animation where a graph is shown on a set of axes with both the original function and its derivative? The function should be something simple, like f(x) = x^2, and its derivative should also be shown on the graph. Also, I would like to see a tangent line drawn at the point where x equals 1 on the original function's graph to illustrate the slope of the tangent, which represents the value of the derivative at that point. Additionally, include some text in the animation that explains that the tangent line represents the derivative of the function. The text should be clearly visible and placed appropriately in relation to the tangent line. Can you ensure that each element of the animation is presented one after the other with some pauses in between to give viewers a moment to process the information?", "chosen": "```python\nfrom manim import *\n\nclass DerivativeConcept(Scene):\n def construct(self):\n # --- STEP 1: SETUP ---\n # Create axes and the original function f(x) = 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_include\": [1, 2]},\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, stroke_width=3)\n func_label = MathTex(\"f(x) = x^2\").to_corner(UL).set_color(BLUE)\n \n # Animate Setup\n self.play(Create(axes), Write(labels), run_time=1.5)\n self.play(Create(graph), run_time=1.5)\n self.play(Write(func_label), run_time=1)\n self.wait(2) # Pause for viewer processing\n\n # --- STEP 2: DERIVATIVE GRAPH ---\n # Add the graph of the derivative function f'(x) = 2x to the same axes\n deriv_func = lambda x: 2*x\n deriv_graph = axes.plot(deriv_func, color=RED, stroke_width=3)\n deriv_label = MathTex(\"f'(x) = 2x\").next_to(func_label, DOWN).set_color(RED)\n \n # Animate Derivative Graph\n self.play(Create(deriv_graph), run_time=1.5)\n self.play(Write(deriv_label), run_time=1)\n self.wait(2) # Pause for viewer processing\n\n # --- STEP 3: TANGENT LINE ---\n # Draw tangent at x = 1 and visually illustrate slope = derivative value\n x_val = 1\n y_val = func(x_val)\n point = axes.coords_to_point(x_val, y_val)\n \n # Create the dot on the original function\n dot = Dot(point, color=YELLOW)\n \n # Calculate tangent line equation: y - 1 = 2(x - 1) => y = 2x - 1\n tangent_line = axes.plot(lambda x: 2*x - 1, x_range=[0, 2], color=YELLOW, stroke_width=3)\n \n # Visual aid: Show the value on the derivative graph corresponds to the slope\n deriv_point = axes.coords_to_point(x_val, deriv_func(x_val))\n deriv_dot = Dot(deriv_point, color=RED)\n slope_label = MathTex(\"m = 2\").next_to(dot, UR, buff=0.2).set_color(YELLOW)\n deriv_value_label = MathTex(\"f'(1) = 2\").next_to(deriv_dot, RIGHT, buff=0.2).set_color(RED)\n \n # Connect the concepts visually with a dashed line\n connection_line = DashedLine(\n start=axes.coords_to_point(x_val, 0),\n end=deriv_point,\n color=WHITE,\n stroke_width=1\n )\n\n # Animate Tangent and Connection\n self.play(Create(dot), run_time=0.5)\n self.play(Create(tangent_line), run_time=1.5)\n self.play(Write(slope_label), run_time=0.5)\n self.wait(0.5)\n # Highlight the connection to the derivative graph\n self.play(Create(deriv_dot), Create(connection_line), run_time=1)\n self.play(Write(deriv_value_label), run_time=0.5)\n self.wait(2.5) # Extended pause to allow connection of concepts\n\n # --- STEP 4: EXPLANATORY TEXT ---\n # Display clearly visible text near the tangent line\n explanation = Text(\n \"The tangent line represents\\nthe derivative of the function.\",\n font_size=28,\n color=WHITE\n )\n # Position near the tangent line but not obscuring key features\n background_box = SurroundingRectangle(explanation, color=BLACK, fill_opacity=0.8)\n explanation.next_to(tangent_line, UR).shift(DOWN * 0.5)\n background_box.move_to(explanation)\n \n # Animate Text\n self.play(Create(background_box), Write(explanation), run_time=2)\n self.wait(3) # Final pause for reading\n```", "rejected": "```python\nfrom manim import *\n\nclass DerivativeConcept(Scene):\n def construct(self):\n # --- STEP 1: SETUP ---\n # Create axes and the original function f(x) = x^2\n axes = Axes(label_font_size=24, \n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_include\": [1, 2]},\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = x^2\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, stroke_width=3)\n func_label = MathTex(\"f(x) = x^2\").to_corner(UL).set_color(BLUE)\n \n # Animate Setup\n self.play(Create(axes), Write(labels), run_time=1.5)\n self.play(Create(graph), run_time=1.5)\n self.play(Write(func_label), run_time=1)\n self.wait(2) # Pause for viewer processing\n\n # --- STEP 2: DERIVATIVE GRAPH ---\n # Add the graph of the derivative function f'(x) = 2x to the same axes\n deriv_func = lambda x: 2*x\n deriv_graph = axes.plot(deriv_func, color=RED, stroke_width=3)\n deriv_label = MathTex(\"f'(x) = 2x\").next_to(func_label, DOWN).set_color(RED)\n \n # Animate Derivative Graph\n self.play(Create(deriv_graph), run_time=1.5)\n self.play(Write(deriv_label), run_time=1)\n self.wait(2) # Pause for viewer processing\n\n # --- STEP 3: TANGENT LINE ---\n # Draw tangent at x = 1 and visually illustrate slope = derivative value\n x_val = 1\n y_val = func(x_val)\n point = axes.coords_to_point(x_val, y_val)\n \n # Create the dot on the original function\n dot = Dot(point, color=YELLOW)\n \n # Calculate tangent line equation: y - 1 = 2(x - 1) => y = 2x - 1\n tangent_line = axes.plot(lambda x: 2*x - 1, x_range=[0, 2], color=YELLOW, stroke_width=3)\n \n # Visual aid: Show the value on the derivative graph corresponds to the slope\n deriv_point = axes.coords_to_point(x_val, deriv_func(x_val))\n deriv_dot = Dot(deriv_point, color=RED)\n slope_label = MathTex(\"m = 2\").next_to(dot, UR, buff=0.2).set_color(YELLOW)\n deriv_value_label = MathTex(\"f'(1) = 2\").next_to(deriv_dot, RIGHT, buff=0.2).set_color(RED)\n \n # Connect the concepts visually with a dashed line\n connection_line = DashedLine(\n start=axes.coords_to_point(x_val, 0),\n end=deriv_point,\n color=WHITE,\n stroke_width=1\n )\n\n # Animate Tangent and Connection\n self.play(Create(dot), run_time=0.5)\n self.play(Create(tangent_line), run_time=1.5)\n self.play(Write(slope_label), run_time=0.5)\n self.wait(0.5)\n # Highlight the connection to the derivative graph\n self.play(Create(deriv_dot), Create(connection_line), run_time=1)\n self.play(Write(deriv_value_label), run_time=0.5)\n self.wait(2.5) # Extended pause to allow connection of concepts\n\n # --- STEP 4: EXPLANATORY TEXT ---\n # Display clearly visible text near the tangent line\n explanation = Text(\n \"The tangent line represents\\nthe derivative of the function.\",\n font_size=28,\n color=WHITE\n )\n # Position near the tangent line but not obscuring key features\n background_box = SurroundingRectangle(explanation, color=BLACK, fill_opacity=0.8)\n explanation.next_to(tangent_line, UR).shift(DOWN * 0.5)\n background_box.move_to(explanation)\n \n # Animate Text\n self.play(Create(background_box), Write(explanation), run_time=2)\n self.wait(3) # Final pause for reading\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 15-second physiology scene explaining the sigmoidal oxygen-hemoglobin binding curve. Move a probe from the low plateau through the steep middle to the high plateau, and explain how the steep region supports unlo\n- Act 2: I'd like to create an animation where a green square appears on the screen by first drawing its border and then filling in its color. Once the square is visible, it should transform into a blue circle. After the transfor\n- Act 3: Here’s an enhanced version of the animation with additional features: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0505(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_oxygenbindingcurve()\n self.clear_stage()\n self.act_2_shapetransformation()\n self.clear_stage()\n self.act_3_enhancedrectangleanimati()\n\n def act_1_oxygenbindingcurve(self):\n self.camera.background_color = \"#F7F8FA\"\n ink = \"#202124\"\n title = Text(\"A sigmoid supports loading and unloading in different ranges\", font_size=34, color=ink).to_edge(UP)\n axes = Axes(x_range=[0, 100, 20], y_range=[0, 1.1, 0.2], x_length=8.5, y_length=4.5, tips=False, axis_config={\"color\": ink}).shift(DOWN * 0.2)\n labels = axes.get_axis_labels(Text(\"oxygen pressure\", font_size=21, color=ink), Text(\"fraction bound\", font_size=21, color=ink))\n curve = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[0.1, 100], color=RED_D)\n probe = Dot(axes.i2gp(5, curve), color=BLUE_D)\n low_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[5, 20], stroke_opacity=0)\n mid_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[20, 50], stroke_opacity=0)\n high_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[50, 95], stroke_opacity=0)\n low = Text(\"low range\", font_size=22, color=BLUE_D).to_edge(DOWN)\n middle = Text(\"steep middle: binding changes readily\", font_size=23, color=ORANGE).to_edge(DOWN)\n high = Text(\"upper plateau: binding stays high\", font_size=23, color=GREEN_D).to_edge(DOWN)\n caveat = Text(\"Conceptual curve; physiology also depends on local conditions.\", font_size=22, color=ink).to_edge(DOWN)\n\n self.play(FadeIn(title, axes, labels), Create(curve), FadeIn(probe, low))\n self.play(MoveAlongPath(probe, low_path), run_time=1.5)\n self.play(MoveAlongPath(probe, mid_path), ReplacementTransform(low, middle), run_time=2.5)\n self.play(Indicate(curve, color=ORANGE))\n self.play(MoveAlongPath(probe, high_path), ReplacementTransform(middle, high), run_time=2.5)\n self.play(ReplacementTransform(high, caveat))\n self.wait(2)\n\n def act_2_shapetransformation(self):\n opacity_val = 0.5\n\n # 1. Define the green square with semi-transparent stroke and no initial fill\n square = Square(\n side_length=2,\n color=GREEN,\n stroke_opacity=opacity_val,\n fill_opacity=0\n )\n\n # Animate drawing the border\n self.play(Create(square), run_time=1.5)\n self.wait(0.5)\n\n # 2. Animate the filling of the square with semi-transparent green\n self.play(square.animate.set_fill(GREEN, opacity=opacity_val), run_time=1)\n self.wait(0.5)\n\n # 3. Prepare the blue circle with semi-transparent fill and stroke\n circle = Circle(\n radius=1.2,\n color=BLUE,\n fill_opacity=opacity_val,\n stroke_opacity=opacity_val\n )\n\n # Transform the square into the circle\n self.play(ReplacementTransform(square, circle), run_time=1.5)\n self.wait(0.5)\n\n # 4. Highlight the blue circle using a surrounding ring and a flash\n highlight_ring = Circle(\n radius=1.4,\n color=WHITE,\n fill_opacity=0,\n stroke_opacity=0.8\n )\n self.play(Create(highlight_ring), Flash(circle, color=WHITE, line_length=0.3, num_lines=12), run_time=1)\n self.play(FadeOut(highlight_ring))\n self.wait(0.5)\n\n # 5. Fade out the blue circle, leaving a blank screen\n self.play(FadeOut(circle), run_time=1)\n self.wait(1)\n\n def act_3_enhancedrectangleanimati(self):\n rectangle = Rectangle(width=4, height=2, color=BLUE)\n rectangle.move_to(ORIGIN)\n \n # Add rectangle to scene\n self.play(Create(rectangle))\n self.wait(0.5)\n \n # Create formula\n formula = MathTex(\"A = width \\\\times height = 4 \\\\times 2 = 8\")\n formula.next_to(rectangle, DOWN, buff=0.5)\n \n # Animate rectangle moving and changing color\n self.play(\n rectangle.animate.move_to([1, 1, 0]).set_color(RED),\n Write(formula),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate rectangle\n self.play(Rotate(rectangle, angle=PI/2), run_time=1)\n \n # Add glowing border effect\n glow = SurroundingRectangle(rectangle, color=YELLOW, buff=0.1, fill_opacity=0.1)\n self.play(Create(glow), run_time=0.5)\n self.wait(0.5)\n \n # Add title text\n title = Text(\"Rectangle Transformation\", font_size=24)\n title.to_edge(UP)\n self.play(Write(title), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0505(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_oxygenbindingcurve()\n self.clear_stage()\n self.act_2_shapetransformation()\n self.clear_stage()\n self.act_3_enhancedrectangleanimati()\n\n def act_1_oxygenbindingcurve(self):\n self.camera.background_color = \"#F7F8FA\"\n ink = \"#202124\"\n title = Text(\"A sigmoid supports loading and unloading in different ranges\", font_size=34, color=ink).to_edge(UP)\n axes = Axes(label_font_size=24, x_range=[0, 100, 20], y_range=[0, 1.1, 0.2], x_length=8.5, y_length=4.5, tips=False, axis_config={\"color\": ink}).shift(DOWN * 0.2)\n labels = axes.get_axis_labels(Text(\"oxygen pressure\", font_size=21, color=ink), Text(\"fraction bound\", font_size=21, color=ink))\n curve = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[0.1, 100], color=RED_D)\n probe = Dot(axes.i2gp(5, curve), color=BLUE_D)\n low_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[5, 20], stroke_opacity=0)\n mid_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[20, 50], stroke_opacity=0)\n high_path = axes.plot(lambda x: x**2.8 / (26**2.8 + x**2.8), x_range=[50, 95], stroke_opacity=0)\n low = Text(\"low range\", font_size=22, color=BLUE_D).to_edge(DOWN)\n middle = Text(\"steep middle: binding changes readily\", font_size=23, color=ORANGE).to_edge(DOWN)\n high = Text(\"upper plateau: binding stays high\", font_size=23, color=GREEN_D).to_edge(DOWN)\n caveat = Text(\"Conceptual curve; physiology also depends on local conditions.\", font_size=22, color=ink).to_edge(DOWN)\n\n self.play(FadeIn(title, axes, labels), Create(curve), FadeIn(probe, low))\n self.play(MoveAlongPath(probe, low_path), run_time=1.5)\n self.play(MoveAlongPath(probe, mid_path), ReplacementTransform(low, middle), run_time=2.5)\n self.play(Indicate(curve, color=ORANGE))\n self.play(MoveAlongPath(probe, high_path), ReplacementTransform(middle, high), run_time=2.5)\n self.play(ReplacementTransform(high, caveat))\n self.wait(2)\n\n def act_2_shapetransformation(self):\n opacity_val = 0.5\n\n # 1. Define the green square with semi-transparent stroke and no initial fill\n square = Square(\n side_length=2,\n color=GREEN,\n stroke_opacity=opacity_val,\n fill_opacity=0\n )\n\n # Animate drawing the border\n self.play(Create(square), run_time=1.5)\n self.wait(0.5)\n\n # 2. Animate the filling of the square with semi-transparent green\n self.play(square.animate.set_fill(GREEN, opacity=opacity_val), run_time=1)\n self.wait(0.5)\n\n # 3. Prepare the blue circle with semi-transparent fill and stroke\n circle = Circle(\n radius=1.2,\n color=BLUE,\n fill_opacity=opacity_val,\n stroke_opacity=opacity_val\n )\n\n # Transform the square into the circle\n self.play(ReplacementTransform(square, circle), run_time=1.5)\n self.wait(0.5)\n\n # 4. Highlight the blue circle using a surrounding ring and a flash\n highlight_ring = Circle(\n radius=1.4,\n color=WHITE,\n fill_opacity=0,\n stroke_opacity=0.8\n )\n self.play(Create(highlight_ring), Flash(circle, color=WHITE, line_length=0.3, num_lines=12), run_time=1)\n self.play(FadeOut(highlight_ring))\n self.wait(0.5)\n\n # 5. Fade out the blue circle, leaving a blank screen\n self.play(FadeOut(circle), run_time=1)\n self.wait(1)\n\n def act_3_enhancedrectangleanimati(self):\n rectangle = Rectangle(width=4, height=2, color=BLUE)\n rectangle.move_to(ORIGIN)\n \n # Add rectangle to scene\n self.play(Create(rectangle))\n self.wait(0.5)\n \n # Create formula\n formula = MathTex(\"A = width \\\\times height = 4 \\\\times 2 = 8\")\n formula.next_to(rectangle, DOWN, buff=0.5)\n \n # Animate rectangle moving and changing color\n self.play(\n rectangle.animate.move_to([1, 1, 0]).set_color(RED),\n Write(formula),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate rectangle\n self.play(Rotate(rectangle, angle=PI/2), run_time=1)\n \n # Add glowing border effect\n glow = SurroundingRectangle(rectangle, color=YELLOW, buff=0.1, fill_opacity=0.1)\n self.play(Create(glow), run_time=0.5)\n self.wait(0.5)\n \n # Add title text\n title = Text(\"Rectangle Transformation\", font_size=24)\n title.to_edge(UP)\n self.play(Write(title), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that visually demonstrates the Pythagorean theorem? It should include the equation \"a^2 + b^2 = c^2\" written out, followed by a right triangle appearing on the screen. Next, can you show squares being formed on each side of the triangle to represent \"a^2\", \"b^2\", and \"c^2\" respectively? I'd also like two separate pieces of text that explain the concept: one that says \"Consider squares on each side\" and another that changes to say \"Area of c^2 is equal to sum of a^2 and b^2\". To conclude, can you transform the original equation into a final statement at the bottom of the screen, clear everything else, and then rewrite the equation one more time to emphasize the conclusion? Include pauses in the animation to allow the viewer to understand each step.", "chosen": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\n title = MathTex(\"a^2 + b^2 = c^2\").scale(1.5)\n self.play(Write(title))\n self.wait(2)\n\n # Clear the title for the next steps\n self.play(FadeOut(title))\n\n # --- Step 2: Create Triangle ---\n triangle = Polygon(\n ORIGIN, \n RIGHT*2, \n UP*1.732, \n color=BLUE, \n fill_opacity=0.5\n )\n \n # Add labels for sides\n label_a = Text(\"a\", font_size=28).next_to(RIGHT*2, DOWN, buff=0.1)\n label_b = Text(\"b\", font_size=28).move_to(triangle.get_vertices()[0])\n label_c = Text(\"c\", font_size=28).rotate(-PI/6).move_to(triangle.get_center())\n \n # Animate the creation of the triangle and its labels\n self.play(Create(triangle), Write(label_a), Write(label_b), Write(label_c))\n self.wait(2)\n\n # --- Step 3: Form Squares ---\n square_a = Square(side_length=2, color=RED, fill_opacity=0.3)\n square_b = Square(side_length=1.732, color=GREEN, fill_opacity=0.3)\n square_c = Square(side_length=2.236, color=YELLOW, fill_opacity=0.3) \n \n # Position squares such that their areas match the sides of the triangle\n square_a.next_to(triangle.get_vertices()[0], LEFT, buff=-1)\n square_b.move_to(triangle.get_vertices()[1])\n square_c.move_to(triangle.get_vertices()[2])\n\n # Group squares for transformation later\n squares_group = VGroup(square_a.copy(), square_b.copy(), square_c.copy())\n\n # Draw the squares\n self.play(Create(square_a), Create(square_b), Create(square_c))\n self.wait(2)\n\n # --- Step 4: Explanatory Text ---\n explanation1 = Text(\"Consider squares on each side\", font_size=24)\n explanation1.to_edge(UP)\n explanation2 = Text(\"Area of c^2 is equal to sum of a^2 and b^2\", font_size=24)\n explanation2.next_to(explanation1, DOWN, buff=0.5)\n \n self.play(Write(explanation1))\n self.wait(1)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Move explanations up to make room for equations at the bottom\n self.play(\n FadeOut(triangle),\n FadeOut(squares_group),\n FadeOut(label_a),\n FadeOut(label_b),\n FadeOut(label_c),\n explanation1.animate.shift(UP*2)\n )\n\n # --- Conclusion Steps ---\n\n # Transform original equation into final statement\n final_statement = MathTex(\"\\\\text{Final Result: } c^2 \\\\stackrel{\\\\triangle}{=} a^2 + b^2\")\n final_statement.scale(1.2)\n final_statement.to_edge(DOWN)\n \n self.play(Write(final_statement))\n self.wait(2)\n\n # Clear everything except the final equation\n self.play(\n FadeOut(squares_group),\n FadeOut(triangle),\n FadeOut(label_a),\n FadeOut(label_b),\n FadeOut(label_c),\n FadeOut(explanation1),\n )\n self.wait(1)\n\n # Rewrite the equation once more to emphasize the conclusion\n emphasized_eq = MathTex(\"c^2 \\\\stackrel{\\\\triangle}{=} a^2 + b^2\")\n emphasized_eq.scale(1.5)\n emphasized_eq.to_edge(DOWN)\n \n self.play(Write(emphasized_eq))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Equation Display ---\n eq_initial = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n eq_initial.scale(1.5)\n self.play(Write(eq_initial))\n self.wait(2)\n\n # Shift initial equation up for visual spacing later\n self.play(eq_initial.animate.shift(UP * 2))\n\n # --- Step 2: Triangle Appearance ---\n # Create vertices\n A = ORIGIN\n B = RIGHT * 4\n C = UP * 3\n \n # Draw sides\n side_a = Line(A, C)\n side_b = Line(C, B)\n hypotenuse = Line(B, A)\n \n triangle = Polygon(\n A, \n C, \n B,\n color=WHITE,\n fill_opacity=0.8,\n stroke_width=6\n )\n self.add(triangle)\n \n # Add labels for sides\n label_c = MathTex(\"c\").next_to(hypotenuse, DOWN)\n label_a = MathTex(\"a\").rotate(-PI/4).move_to((A+C)/2)\n label_b = MathTex(\"b\").rotate(-PI/4).shift(RIGHT*1.5 + UP*1)\n \n self.play(Create(side_a), Write(label_a))\n self.play(Create(side_b), Write(label_b))\n self.play(Create(hypotenuse), Write(label_c))\n self.wait(2)\n\n # Animate squares forming on sides\n square_a = Square(side_length=A.distance_to(C), color=RED)\n square_b = Square(side_length=C.distance_to(B), color=BLUE)\n square_c = Square(side_length=B.distance_to(A), color=YELLOW)\n \n # Position squares exactly covering the triangles' areas\n square_a.move_to(((A+A+C) / 2)).set_fill(RED, opacity=0.7)\n square_b.move_to((C+(C+B)) / 2).rotate(PI/2).set_fill(BLUE, opacity=0.7)\n square_c.move_to((B+(B+A)) / 2).rotate(PI/2).set_fill(YELLOW, opacity=0.7)\n \n self.play(FadeIn(square_a), FadeIn(square_b), FadeIn(square_c))\n self.wait(2)\n\n # --- Step 3: Text Explanations ---\n\n # Explanation 1: Consider squares on each side\n text_explanation1 = Tex(\n r\"\\text{Consider squares constructed on each side of the right triangle}\",\n font_size=36\n ).to_edge(UP)\n self.play(Write(text_explanation1))\n self.wait(2)\n self.play(FadeOut(text_explanation1))\n\n # Explanation 2: Area relationship\n text_explanation2 = Tex(\n r\"$\\text{Area of } c^2 \\text{ is equal to the sum of areas of } a^2 \\text{ and } b^2$\",\n font_size=36\n ).to_edge(UP)\n self.play(Write(text_explanation2))\n self.wait(2)\n self.play(ReplaceScene(text_explanation2, Eq(a_squared_plus_b_squared_equals_c_squared)))\n\n # --- Step 4: Final Transformation ---\n\n # Move equations down to make room for the final emphasis\n self.play(\n eq_initial.animate.to_edge(DOWN),\n Eq(a_squared_plus_b_squared_equals_c_squared).animate.to_edge(UP)\n )\n\n # Emphasize the final conclusion with a large box around it\n box = SurroundingRectangle(Eq(a_squared_plus_b_squared_equals_c_squared), buff=0.2)\n box.set_stroke(width=3)\n self.play(Create(box))\n \n # Re-render the final equation to ensure it scales well across the full width\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n final_eq.scale(2)\n self.play(TransformFromCopy(Eq(a_squared_plus_b_squared_equals_c_squared), final_eq))\n self.wait(3)\n\n# To run this script:\n# 1. Save it as pyth_theo.py\n# 2. Run 'manim -pql pyth_theo.py PythagoreanTheorem'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that demonstrates how to evaluate the definite integral of x squared from 0 to 2, including the step-by-step process from stating the problem to showing the calculation of the indefinite integral, applying the bounds, evaluating at the bounds, and then presenting the final solution? Also, can you include a brief pause after each step so that the viewer has time to understand what's happening?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- Configuration ---\n step_color = BLUE_B\n math_color = YELLOW\n result_color = GREEN\n\n # --- Step 1: State the Problem ---\n step1_label = Text(\"1. State the Problem\", font_size=30, color=step_color).to_edge(UP)\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=60, color=math_color)\n \n self.play(Write(step1_label))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Find the Indefinite Integral ---\n step2_label = Text(\"2. Find the Indefinite Integral\", font_size=30, color=step_color).to_edge(UP)\n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=60, color=math_color)\n \n self.play(Transform(step1_label, step2_label))\n self.play(TransformMatchingTex(problem, antiderivative))\n self.wait(2)\n\n # --- Step 3: Apply Bounds ---\n step3_label = Text(\"3. Apply Bounds\", font_size=30, color=step_color).to_edge(UP)\n bounds_substitution = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=60, color=math_color)\n \n self.play(Transform(step2_label, step3_label))\n self.play(TransformMatchingTex(antiderivative, bounds_substitution))\n self.wait(2)\n\n # --- Step 4: Evaluate ---\n step4_label = Text(\"4. Evaluate\", font_size=30, color=step_color).to_edge(UP)\n evaluation = MathTex(r\"= \\frac{8}{3} - 0\", font_size=60, color=math_color)\n \n self.play(Transform(step3_label, step4_label))\n self.play(TransformMatchingTex(bounds_substitution, evaluation))\n self.wait(2)\n\n # --- Step 5: Present Solution ---\n step5_label = Text(\"5. Present Solution\", font_size=30, color=step_color).to_edge(UP)\n final_result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=72, color=result_color)\n \n # Box the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.2)\n \n self.play(Transform(step4_label, step5_label))\n self.play(TransformMatchingTex(evaluation, final_result))\n self.play(Create(box))\n self.wait(3)\n\n# To render this animation, use the following command in your terminal:\n# manim -pql scene_file_name.py DefiniteIntegralEvaluation\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- Configuration ---\n step_color = BLUE_B\n math_color = YELLOW\n result_color = GREEN\n\n # --- Step 1: State the Problem ---\n step1_label = Text(\"1. State the Problem\", font_size=30, color=step_color).to_edge(UP)\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=60, color=math_color)\n \n self.play(Write(step1_label))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Find the Indefinite Integral ---\n step2_label = Text(\"2. Find the Indefinite Integral\", font_size=30, color=step_color).to_edge(UP)\n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=60, color=math_color)\n \n self.play(Transform(step1_label, step2_label))\n self.play(TransformMatchingTex(problem, antiderivative))\n self.wait(2)\n\n # --- Step 3: Apply Bounds ---\n step3_label = Text(\"3. Apply Bounds\", font_size=30, color=step_color).to_edge(UP)\n bounds_substitution = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=60, color=math_color)\n \n self.play(Transform(step2_label, step3_label))\n self.play(TransformMatchingTex(antiderivative, bounds_substitution))\n self.wait(2)\n\n # --- Step 4: Evaluate ---\n step4_label = Text(\"4. Evaluate\", font_size=30, color=step_color).to_edge(UP)\n evaluation = MathTex(r\"= \\frac{8}{3} - 0\" + \" = x\", font_size=60, color=math_color)\n \n self.play(Transform(step3_label, step4_label))\n self.play(TransformMatchingTex(bounds_substitution, evaluation))\n self.wait(2)\n\n # --- Step 5: Present Solution ---\n step5_label = Text(\"5. Present Solution\", font_size=30, color=step_color).to_edge(UP)\n final_result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=72, color=result_color)\n \n # Box the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.2)\n \n self.play(Transform(step4_label, step5_label))\n self.play(TransformMatchingTex(evaluation, final_result))\n self.play(Create(box))\n self.wait(3)\n\n# To render this animation, use the following command in your terminal:\n# manim -pql scene_file_name.py DefiniteIntegralEvaluation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational ManimCE animation on 'Euler's Totient Function' (Unveiling Patterns: Euler's Totient Function): What patterns emerge in the Euler's Totient Function when plotted for the sequence of natural numbers?\nVisual style guidance: A harmonious blend of dark blues and bright oranges, contrast creates an engaging and clear depiction, with fluid animations drawing attention to key concepts and mathematical beauty.", "chosen": "```python\nfrom manim import *\n\nclass EulersTotientFunction(Scene):\n def construct(self):\n # Color Definitions\n DARK_BLUE = \"#1874CD\"\n BRIGHT_ORANGE = \"#FFA600\"\n\n # Title\n title = Text(\n \"Unveiling Patterns:\\nEuler's Totient Function\",\n font_size=36,\n color=WHITE\n ).to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # Explanation text\n explanation_text = Tex(\"The function $\\\\phi(n)$ represents the number\", \n \"of integers up to n that are coprime to n.\")\n explanation_text.to_edge(DOWN).set_color(WHITE)\n explanation_text.scale(0.8)\n self.play(Write(explanation_text))\n\n # Create axes\n axes = Axes(\n x_range=[1, 10, 1],\n y_range=[0, 10, 1],\n x_length=8,\n y_length=6,\n tips=False\n )\n axes.set_colors(YELLOW)\n axes.shift(LEFT * 2 + DOWN * 1)\n\n labels = axes.get_axis_labels(Text(\"n\"), Text(\"$\\\\phi(n)$\"))\n self.add(axes, labels)\n \n phi_values = [1, 1, 2, 2, 4, 2, 6, 4, 6]\n \n dots = []\n for i, val in enumerate(phi_values):\n dot = Dot(axes.c2p(i+1, val), radius=0.15, color=ORANGE)\n dots.append(dot)\n\n # Plot points sequentially while highlighting the current value\n for i in range(len(dots)):\n self.play(Create(dots[i]))\n \n if i != len(dots) - 1:\n line_start = axes.c2p(i+1, phi_values[i])\n line_end = axes.c2p((i+1)+1, phi_values[i+1])\n \n # Draw lines between data points to show pattern progression\n line = Line(line_start, line_end, stroke_width=2)\n line.set_stroke(color=DARK_BLUE, opacity=0.7)\n self.play(Create(line), run_time=0.5)\n \n # Highlight the current point briefly during transition\n self.play(\n dots[i].animate.set_fill(PURPLE, opacity=0.8),\n rate_func=there_and_back,\n run_time=0.3\n )\n\n else:\n # Final highlight for clarity at end\n self.play(\n dots[i].animate.set_fill(PURPLE, opacity=0.8),\n run_time=0.8\n )\n\n self.wait(2)\n self.play(FadeOut(VGroup(*dots)), FadeOut(axes), FadeOut(labels), FadeOut(explanation_text), FadeOut(title))\n self.wait()\n```", "rejected": "```python\n\"\"\"\nTitle: \"Unveiling Patterns: Euler's Totient Function\"\nScene Description: \nThis educational animation explores how Euler's Totient Function emerges visually across sequences of integers using a color-coded grid. The visual style employs a harmonious blend of dark blues and bright oranges, enhancing engagement while clearly depicting mathematical concepts through fluid, animated transitions.\nKey Visual Elements: \n- Color-Coding by Modulo Groups\n- Smooth Animations\n- Mathematical Notation\n\"\"\"\n\n# Import necessary classes from ManimCommunity\nfrom manim import *\nimport numpy as np\n\n\nclass EulersTotientFunction(Scene):\n def construct(self):\n # Set background color to a dark blue\n self.camera.background_color = \"#1e1f28\"\n\n title = Text(\"Unveiling Patterns: Euler's Totient \\nFunction\", font_size=36)\n subtitle = Text(\n \"How colors reveal mathematical beauty\",\n font_size=24,\n color=ORANGE,\n )\n subtitle.next_to(title, DOWN)\n\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n\n self.play(FadeOut(title, subtitle))\n\n phi_text = MathText(\"\\\\phi(n)\", font_size=72).to_edge(LEFT, buff=1)\n \n # Create a grid of dots representing integers\n dots_group = VGroup()\n dot_radius = 0.08\n \n for n in range(1, 10):\n x_pos = (n - 1) * 0.5 + 1.0\n y_pos = -(n // 2) * 0.5 - 1.5\n \n inner_dots = VGroup()\n for i in range(1, n + 1):\n angle = i * TAU / n\n if math.gcd(i, n) == 1:\n color = YELLOW\n else:\n color = BLUE\n dot = Dot(radius=dot_radius, color=color).rotate(angle, about_point=ORIGIN)\n dot.shift(RIGHT * x_pos + UP * y_pos)\n inner_dots.add(dot)\n \n dots_group.add(inner_dots)\n\n self.play(Create(phi_text))\n self.wait(0.5)\n self.play(Create(dots_group))\n self.wait()\n\n # Display the formula for Euler's totient function\n formula = MathTex(\n r\"\\phi(n) = n \\prod_{p | n} \\left(1 - \\frac{1}{p}\\right)\",\n tex_to_color_map={\n \"\\\\phi\": ORANGE,\n \"n\": BLUE,\n \"p\": GREEN,\n },\n ).next_to(dots_group, RIGHT, buff=1)\n\n self.play(Write(formula))\n self.wait(2)\n\n # Clear the screen and show only the formula\n self.clear()\n self.wait(0.5)\n self.play(Write(formula))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass CircleConcept(Scene):\n def construct(self):\n # 1. Initial Scene: Animate the drawing of a circle and a line segment representing the radius\n circle = Circle(radius=2, color=BLUE)\n center = circle.get_center()\n radius_line = Line(start=center, end=center + RIGHT * 2, color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n\n self.play(Create(circle), run_time=2)\n self.play(Create(radius_line), Write(radius_label), run_time=1.5)\n self.wait(2)\n\n # 2. Area Explanation: Display text explaining the area formula\n area_explanation = Tex(\n \"The area of a circle is given by the formula: $\\\\text{Area} = \\\\pi r^2$\",\n font_size=36\n ).to_edge(UP)\n\n self.play(Write(area_explanation))\n self.wait(3)\n\n # 3. Formula Transformation: Transform the explanation text into the mathematical formula at the bottom\n area_formula = MathTex(\"\\\\text{Area} = \\\\pi r^2\", font_size=48).to_edge(DOWN, buff=1.0)\n\n self.play(ReplacementTransform(area_explanation, area_formula), run_time=1.5)\n self.wait(2)\n\n # 4. Circumference Illustration: Animate a dot moving along the circumference\n dot = Dot(color=RED).move_to(circle.get_right())\n\n self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)\n self.wait(1)\n self.play(FadeOut(dot))\n\n # 5. Final Formula: Display the Circumference formula below the circle\n circ_formula = MathTex(\"\\\\text{Circumference} = 2\\\\pi r\", font_size=48).next_to(area_formula, UP, buff=0.5)\n\n self.play(Write(circ_formula))\n self.wait(4)\n```", "rejected": "```python\nfrom manim import *\n\nclass CircleConcept(Scene):\n def construct(self):\n # 1. Initial Scene: Animate the drawing of a circle and a line segment representing the radius\n circle = Circle(radius=2, color=BLUE)\n center = circle.get_center()\n radius_line = Line(start=center, end=center + RIGHT * 2, color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n\n self.play(Create(circle), run_time=2)\n self.play(Create(radius_line), Write(radius_label), run_time=1.5)\n self.wait(2)\n\n # 2. Area Explanation: Display text explaining the area formula\n area_explanation = Tex(\n \"The area of a circle is given by the formula: $\\\\text{Area} = \\\\pi r^2$\",\n font_size=36\n ).to_edge(UP)\n\n self.play(Write(area_explanation))\n self.wait(3)\n\n # 3. Formula Transformation: Transform the explanation text into the mathematical formula at the bottom\n area_formula = MathTex(\"\\\\text{Area} = \\\\pi r^2\", font_size=48).to_edge(DOWN, buff=1.0)\n\n self.play(ReplacementTransform(target_position=ORIGIN, area_explanation, area_formula), run_time=1.5)\n self.wait(2)\n\n # 4. Circumference Illustration: Animate a dot moving along the circumference\n dot = Dot(color=RED).move_to(circle.get_right())\n\n self.play(MoveAlongPath(dot, circle), run_time=4, rate_func=linear)\n self.wait(1)\n self.play(FadeOut(dot))\n\n # 5. Final Formula: Display the Circumference formula below the circle\n circ_formula = MathTex(\"\\\\text{Circumference} = 2\\\\pi r\", font_size=48).next_to(area_formula, UP, buff=0.5)\n\n self.play(Write(circ_formula))\n self.wait(4)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a Manim scene that demonstrates basic mobject placement using various alignment methods.", "chosen": "```python\nfrom manim import *\n\nclass AlignmentDemo(Scene):\n \"\"\"\n A demonstration of basic mobject placement and alignment methods in Manim.\n Showcases move_to, next_to, shift, and align_to with clear visual labels.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup & Reference Object\n # ------------------------------------------------------------------\n title = Text(\"Mobject Alignment Methods\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create a central anchor object for relative positioning\n anchor = Square(side_length=2, color=WHITE, fill_opacity=0.2)\n anchor_label = Text(\"Reference\", font_size=24).next_to(anchor, UP)\n \n self.play(Create(anchor), Write(anchor_label))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Demonstrate .move_to() - Absolute Positioning\n # ------------------------------------------------------------------\n method_text = Text(\"1. .move_to() - Absolute Position\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n circle = Circle(radius=0.5, color=BLUE, fill_opacity=0.5)\n # Position explicitly at absolute coordinates [3, -2, 0]\n circle.move_to([3, -2, 0])\n \n circle_label = Text(\".move_to([3, -2, 0])\", font_size=20, color=BLUE)\n circle_label.next_to(circle, DOWN, buff=0.2)\n\n self.play(Write(method_text), FadeIn(circle), Write(circle_label))\n self.wait(1)\n\n self.play(FadeOut(method_text), FadeOut(circle), FadeOut(circle_label))\n\n # ------------------------------------------------------------------\n # 3. Demonstrate .next_to() - Relative Positioning\n # ------------------------------------------------------------------\n method_text = Text(\"2. .next_to() - Relative Direction\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n triangle = Triangle(color=RED, fill_opacity=0.5).scale(0.5)\n # Place relative to the anchor square with a small buffer\n triangle.next_to(anchor, RIGHT, buff=0.3)\n \n triangle_label = Text(\".next_to(ref, RIGHT)\", font_size=20, color=RED)\n triangle_label.next_to(triangle, DOWN, buff=0.2)\n\n self.play(Write(method_text), FadeIn(triangle), Write(triangle_label))\n self.wait(1)\n\n self.play(FadeOut(method_text), FadeOut(triangle), FadeOut(triangle_label))\n\n # ------------------------------------------------------------------\n # 4. Demonstrate .shift() - Relative Movement Vector\n # ------------------------------------------------------------------\n method_text = Text(\"3. .shift() - Relative Offset\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n square_small = Square(side_length=0.5, color=GREEN, fill_opacity=0.5)\n square_small.move_to(anchor.get_center())\n \n self.play(Write(method_text), Create(square_small))\n \n # Animate the shift to demonstrate displacement\n shift_vector = UP * 2 + LEFT * 3\n self.play(square_small.animate.shift(shift_vector), run_time=1.5)\n \n square_label = Text(\".shift(UP * 2 + LEFT * 3)\", font_size=20, color=GREEN)\n square_label.next_to(square_small, UP, buff=0.2)\n self.play(Write(square_label))\n self.wait(1)\n\n self.play(\n FadeOut(method_text), \n FadeOut(square_small), \n FadeOut(square_label)\n )\n\n # ------------------------------------------------------------------\n # 5. Demonstrate .align_to() - Edge/Center Coordination\n # ------------------------------------------------------------------\n method_text = Text(\"4. .align_to() - Edge Alignment\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n rect = Rectangle(width=3, height=1, color=YELLOW, fill_opacity=0.5)\n # Start at an arbitrary position\n rect.move_to(DOWN * 2 + LEFT * 3)\n \n self.play(Write(method_text), Create(rect))\n \n # Animate the alignment of the LEFT edge of the rect to the LEFT edge of the anchor\n self.play(rect.animate.align_to(anchor, LEFT), run_time=1.5)\n \n rect_label = Text(\".align_to(ref, LEFT)\", font_size=20, color=YELLOW)\n rect_label.next_to(rect, DOWN, buff=0.2)\n self.play(Write(rect_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Cleanup\n # ------------------------------------------------------------------\n all_mobjects = VGroup(\n title, anchor, anchor_label, \n method_text, rect, rect_label\n )\n self.play(FadeOut(all_mobjects))\n self.wait(1)\n\n# To run this script, use the command:\n# manim -pql script_name.py AlignmentDemo\n```", "rejected": "```python\nfrom manim import *\n\nclass AlignmentDemo(Scene):\n \"\"\"\n A demonstration of basic mobject placement and alignment methods in Manim.\n Showcases move_to, next_to, shift, and align_to with clear visual labels.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup & Reference Object\n # ------------------------------------------------------------------\n title = Text(\"Mobject Alignment Methods\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create a central anchor object for relative positioning\n anchor = Square(side_length=2, color=WHITE, fill_opacity=0.2)\n anchor_label = Text(\"Reference\", font_size=24).next_to(anchor, UP)\n \n self.play(Create(anchor), Write(anchor_label))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Demonstrate .move_to() - Absolute Positioning\n # ------------------------------------------------------------------\n method_text = Text(\"1. .move_to() - Absolute Position\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n circle = Circle(radius=0.5, color=BBLUE, fill_opacity=0.5)\n # Position explicitly at absolute coordinates [3, -2, 0]\n circle.move_to([3, -2, 0])\n \n circle_label = Text(\".move_to([3, -2, 0])\", font_size=20, color=BLUE)\n circle_label.next_to(circle, DOWN, buff=0.2)\n\n self.play(Write(method_text), FadeIn(circle), Write(circle_label))\n self.wait(1)\n\n self.play(FadeOut(method_text), FadeOut(circle), FadeOut(circle_label))\n\n # ------------------------------------------------------------------\n # 3. Demonstrate .next_to() - Relative Positioning\n # ------------------------------------------------------------------\n method_text = Text(\"2. .next_to() - Relative Direction\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n triangle = Triangle(color=RED, fill_opacity=0.5).scale(0.5)\n # Place relative to the anchor square with a small buffer\n triangle.next_to(anchor, RIGHT, buff=0.3)\n \n triangle_label = Text(\".next_to(ref, RIGHT)\", font_size=20, color=RED)\n triangle_label.next_to(triangle, DOWN, buff=0.2)\n\n self.play(Write(method_text), FadeIn(triangle), Write(triangle_label))\n self.wait(1)\n\n self.play(FadeOut(method_text), FadeOut(triangle), FadeOut(triangle_label))\n\n # ------------------------------------------------------------------\n # 4. Demonstrate .shift() - Relative Movement Vector\n # ------------------------------------------------------------------\n method_text = Text(\"3. .shift() - Relative Offset\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n square_small = Square(side_length=0.5, color=GREEN, fill_opacity=0.5)\n square_small.move_to(anchor.get_center())\n \n self.play(Write(method_text), Create(square_small))\n \n # Animate the shift to demonstrate displacement\n shift_vector = UP * 2 + LEFT * 3\n self.play(square_small.animate.shift(shift_vector), run_time=1.5)\n \n square_label = Text(\".shift(UP * 2 + LEFT * 3)\", font_size=20, color=GREEN)\n square_label.next_to(square_small, UP, buff=0.2)\n self.play(Write(square_label))\n self.wait(1)\n\n self.play(\n FadeOut(method_text), \n FadeOut(square_small), \n FadeOut(square_label)\n )\n\n # ------------------------------------------------------------------\n # 5. Demonstrate .align_to() - Edge/Center Coordination\n # ------------------------------------------------------------------\n method_text = Text(\"4. .align_to() - Edge Alignment\", font_size=28)\n method_text.next_to(title, DOWN, buff=0.5)\n\n rect = Rectangle(width=3, height=1, color=YELLOW, fill_opacity=0.5)\n # Start at an arbitrary position\n rect.move_to(DOWN * 2 + LEFT * 3)\n \n self.play(Write(method_text), Create(rect))\n \n # Animate the alignment of the LEFT edge of the rect to the LEFT edge of the anchor\n self.play(rect.animate.align_to(anchor, LEFT), run_time=1.5)\n \n rect_label = Text(\".align_to(ref, LEFT)\", font_size=20, color=YELLOW)\n rect_label.next_to(rect, DOWN, buff=0.2)\n self.play(Write(rect_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Cleanup\n # ------------------------------------------------------------------\n all_mobjects = VGroup(\n title, anchor, anchor_label, \n method_text, rect, rect_label\n )\n self.play(FadeOut(all_mobjects))\n self.wait(1)\n\n# To run this script, use the command:\n# manim -pql script_name.py AlignmentDemo\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation using Manim that shows an oxygen molecule with electrons moving along a complex path around it, including the appearance and disappearance of the molecule and the electron?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass OxygenElectronAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n # CPK coloring convention: Oxygen is Red\n O_COLOR = RED\n ELECTRON_COLOR = YELLOW\n ATOM_RADIUS = 0.5\n BOND_LENGTH = 1.2\n \n # --- 1. Molecule Visualization (O₂) ---\n # Create two oxygen atoms represented as shaded circles\n atom_left = Circle(radius=ATOM_RADIUS, color=O_COLOR, fill_opacity=0.8)\n atom_right = Circle(radius=ATOM_RADIUS, color=O_COLOR, fill_opacity=0.8)\n \n # Position atoms to form O2 molecule centered at the origin\n atom_left.move_to(LEFT * BOND_LENGTH / 2)\n atom_right.move_to(RIGHT * BOND_LENGTH / 2)\n \n # Visual double bond between atoms\n bond = VGroup(\n Line(start=atom_left.get_center() + UP * 0.1, end=atom_right.get_center() + UP * 0.1, color=O_COLOR, stroke_width=4),\n Line(start=atom_left.get_center() + DOWN * 0.1, end=atom_right.get_center() + DOWN * 0.1, color=O_COLOR, stroke_width=4)\n )\n \n # Group molecule components and add educational label\n oxygen_molecule = VGroup(atom_left, atom_right, bond)\n label = Text(\"O₂\", font_size=36).next_to(oxygen_molecule, DOWN, buff=0.5)\n \n # --- 2. Electron Path Definition ---\n # Define a complex parametric path (Lissajous-like curve) to simulate \n # a complex orbital trajectory around the molecule center\n def electron_path(t):\n # Superposition of circular motions to create a precessing orbit effect\n x = 2.5 * np.cos(t) + 0.5 * np.cos(5 * t)\n y = 2.5 * np.sin(t) + 0.5 * np.sin(5 * t)\n z = 0\n return np.array([x, y, z])\n\n # Create the visual path object (faint line to indicate trajectory)\n path = ParametricFunction(\n electron_path,\n t_range=[0, TAU],\n color=BLUE_E,\n stroke_opacity=0.3,\n stroke_width=2\n )\n path.scale(0.8) # Scale path to fit screen relative to molecule\n\n # --- 3. Electron Visualization ---\n electron = Dot(color=ELECTRON_COLOR, radius=0.15)\n # Initialize electron at the start of the path\n electron.move_to(path.get_start())\n\n # --- Animation Sequence ---\n \n # Step 1: Appearance (Fade In)\n # Molecule appears first to establish context\n self.play(FadeIn(oxygen_molecule), Write(label), run_time=1.5)\n self.wait(0.5)\n \n # Electron and its trajectory path appear\n self.play(FadeIn(path), FadeIn(electron), run_time=1.0)\n self.wait(0.5)\n\n # Step 2: Electron Animation\n # Move electron along the complex path\n # rate_func=linear ensures constant speed along the parametric curve\n self.play(\n MoveAlongPath(electron, path),\n run_time=6,\n rate_func=linear\n )\n self.wait(0.5)\n\n # Step 3: Disappearance (Fade Out)\n # Electron disappears first, then the molecule\n self.play(FadeOut(electron), FadeOut(path), run_time=1.0)\n self.wait(0.5)\n self.play(FadeOut(oxygen_molecule), FadeOut(label), run_time=1.5)\n \n # Final buffer\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass OxygenElectronAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n # CPK coloring convention: Oxygen is Red\n O_COLOR = RED\n ELECTRON_COLOR = YELLOW\n ATOM_RADIUS = 0.5\n BOND_LENGTH = 1.2\n \n # --- 1. Molecule Visualization (O₂) ---\n # Create two oxygen atoms represented as shaded circles\n atom_left = Circle(radius=ATOM_RADIUS, color=O_COLOR, fill_opacity=0.8)\n atom_right = Circle(radius=ATOM_RADIUS, color=O_COLOR, fill_opacity=0.8)\n \n # Position atoms to form O2 molecule centered at the origin\n atom_left.move_to(LEFT * BOND_LENGTH / 2)\n atom_right.move_to(RIGHT * BOND_LENGTH / 2)\n \n # Visual double bond between atoms\n bond = VGroup(\n Line(start=atom_left.get_center() + UP * 0.1, end=atom_right.get_center() + UP * 0.1, color=O_COLOR, stroke_width=4),\n Line(start=atom_left.get_center() + DOWN * 0.1, end=atom_right.get_center() + DOWN * 0.1, color=O_COLOR, stroke_width=4)\n )\n \n # Group molecule components and add educational label\n oxygen_molecule = VGroup(atom_left, atom_right, bond)\n label = Text(\"O₂\", font_size=36).next_to(oxygen_molecule, DOWN, buff=0.5)\n \n # --- 2. Electron Path Definition ---\n # Define a complex parametric path (Lissajous-like curve) to simulate \n # a complex orbital trajectory around the molecule center\n def electron_path(t):\n # Superposition of circular motions to create a precessing orbit effect\n x = 2.5 * np.cos(t) + 0.5 * np.cos(5 * t)\n y = 2.5 * np.sin(t) + 0.5 * np.sin(5 * t)\n z = 0\n return np.array([x, y, z])\n\n # Create the visual path object (faint line to indicate trajectory)\n path = ParametricFunction(\n electron_path,\n t_range=[0, TAU],\n color=BBLUE_E,\n stroke_opacity=0.3,\n stroke_width=2\n )\n path.scale(0.8) # Scale path to fit screen relative to molecule\n\n # --- 3. Electron Visualization ---\n electron = Dot(color=ELECTRON_COLOR, radius=0.15)\n # Initialize electron at the start of the path\n electron.move_to(path.get_start())\n\n # --- Animation Sequence ---\n \n # Step 1: Appearance (Fade In)\n # Molecule appears first to establish context\n self.play(FadeIn(oxygen_molecule), Write(label), run_time=1.5)\n self.wait(0.5)\n \n # Electron and its trajectory path appear\n self.play(FadeIn(path), FadeIn(electron), run_time=1.0)\n self.wait(0.5)\n\n # Step 2: Electron Animation\n # Move electron along the complex path\n # rate_func=linear ensures constant speed along the parametric curve\n self.play(\n MoveAlongPath(electron, path),\n run_time=6,\n rate_func=linear\n )\n self.wait(0.5)\n\n # Step 3: Disappearance (Fade Out)\n # Electron disappears first, then the molecule\n self.play(FadeOut(electron), FadeOut(path), run_time=1.0)\n self.wait(0.5)\n self.play(FadeOut(oxygen_molecule), FadeOut(label), run_time=1.5)\n \n # Final buffer\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Write Manim code for a scene illustrating the concept of cross products in vector calculus. Visualize the geometric interpretation and properties of cross products, step by step.", "chosen": "```python\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"The Geometric Power of Cross Products\", font_size=36).to_edge(UP)\n intro_text = Tex(\n \"Cross product combines vectors $\\\\vec{a}$ and $\\\\vec{b}$.\",\n \"$$ \\\\vec{c} = \\\\vec{a} \\\\times \\\\vec{b} $$\"\n ).scale(0.8).next_to(title, DOWN)\n\n self.play(Write(title))\n self.play(FadeIn(intro_text))\n\n # Create vectors a and b\n vec_a = Arrow(start=LEFT*2, end=RIGHT*2, color=RED)\n vec_b_start = LEFT*2 + UP*1\n vec_b_end = RIGHT*2 + DOWN*1\n vec_b = Arrow(vec_b_start, vec_b_end, color=BLUE)\n \n self.play(Create(vec_a), Create(vec_b))\n\n # Animate vectors moving up slightly to create depth\n self.play(\n vec_a.animate.shift(UP*0.3),\n vec_b.animate.shift(UP*0.3),\n run_time=1,\n rate_func=there_and_back\n )\n\n self.wait(1)\n\n # Show the resulting vector c orthogonal to both a and b\n vec_c_start = ORIGIN\n vec_c_end = RIGHT*2 + UP*1\n vec_c = Arrow(vec_c_start, vec_c_end, color=GREEN, buff=0)\n \n self.play(Create(vec_c))\n \n self.wait(1)\n\n # Add a plane to represent the 2D space\n plane = NumberPlane(x_range=[-2.5, 2.5], y_range=[-2.5, 2.5])\n plane.scale(0.7).shift(DOWN*0.5) # Scaled down to fit within frame\n\n # Display the equation using MathTex for better formatting\n math_eq = MathTex(\n r\"\\vec{c}\", \"=\", r\"\\vec{a}\", r\" \\times \", r\"\\vec{b}\",\n font_size=40\n ).move_to(ORIGIN)\n self.play(Write(math_eq))\n\n self.wait(1)\n\n # --- Step 2: Properties ---\n\n # Clear screen for property explanation\n self.clear()\n self.add(plane)\n\n prop_title = Text(\"Properties of Cross Product\", font_size=36).to_edge(UP)\n self.play(Write(prop_title))\n\n # Property 1: Anticommutativity\n anticommutative = MathTex(\n r\"\\vec{a}\", r\" \\times \", r\"\\vec{b}\", r\"=\", r\"-(\", r\"\\vec{b}\", r\" \\times \", r\"\\vec{a}\", r\")\"\n )\n anticommutative.to_edge(DOWN)\n \n self.play(Write(MathTex(\"\\\\text{Anticommutativity}:\")))\n self.play(Write(anticommutative))\n\n self.wait(1)\n\n # Property 2: Scalar Triple Product\n scalar_triple_product = MathTex(\n \"\\left(\\\\begin{vmatrix} \\\\mathbf{i} & \\\\mathbf{j} & \\\\mathbf{k} \\\\\\\\ \",\n \"\\\\vec{a}_1 & \\\\vec{a}_2 & \\\\vec{a}_3 \\\\\\\\ \", \n \"\\\\vec{b}_1 & \\\\vec{b}_2 & \\\\vec{b}_3 \\\\end{vmatrix}\\\\right)\"\n ).to_edge(DOWN)\n\n self.play(Write(MathTex(\"\\\\text{Scalar Triple Product}:\")))\n self.play(Write(scalar_triple_product))\n\n self.wait(1)\n\n # Property 3: Area of Parallelogram\n area_formula = MathTex(\n \"\\text{Area } A =\", r\"|\\vec{a}| |\\vec{b}| \\sin(\\\\theta)\",\n font_size=36\n )\n area_formula.next_to(prop_title, DOWN, aligned_edge=LEFT)\n\n self.play(Write(area_formula))\n\n # Highlight the triangle formed by vectors\n tri_vertices = [vec_a.get_end(), vec_b.get_end(), ORIGIN]\n polygon = Polygon(*tri_vertices, color=YELLOW)\n \n # Calculate angle between vectors a and b\n angle_ab = np.arccos(np.dot([vec_a.get_end()[0], vec_a.get_end()[1]], [-vec_b_start[0], -vec_b_start[1]]) /\n (np.linalg.norm(vec_a.get_end()) * np.linalg.norm(-vec_b_start)))\n \n # Rotate polygon around origin based on calculated angle\n polygon.rotate(angle_ab, about_point=ORIGIN)\n \n # Scale polygon to match magnitude of vectors\n scale_factor = max(abs(val) for val in [-vec_b_start[0], -vec_b_start[1]])\n polygon.scale(scale_factor)\n\n self.play(Create(polygon))\n self.wait(2)\n\n # Final cleanup\n self.clear()\n\n# To render this animation, save it as 'crossproductscene.py' then execute:\n# manim -pql crossproductscene.py CrossProductScene\n```", "rejected": "```python\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"The Geometric Power of Cross Products\", font_size=36).to_edge(UP)\n intro_text = Tex(\n \"Cross product combines vectors into a new one,\\nperpendicular to both original vectors.\"\n ).next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(FadeIn(intro_text))\n self.wait(2)\n\n # Clear screen to prepare for visualizations\n self.clear()\n self.add(title)\n\n # Create two perpendicular vectors\n vec_a = Arrow(start=LEFT*2, end=RIGHT*2, color=RED)\n vec_b = Arrow(start=DOWN*2, end=UP*2, color=BLUE)\n \n labels_a = MathTex(\"\\\\mathbf{a}\", color=WHITE).move_to(vec_a.get_end())\n labels_b = MathTex(\"\\\\mathbf{b}\", color=WHITE).move_to(vec_b.get_start())\n\n # Show vectors and their components\n self.play(Create(vec_a), Write(labels_a))\n self.play(Create(vec_b), Write(labels_b))\n\n # Animate cross product formula\n cross_formula = MathTex(\n \"\\\\mathbf{c} = \\\\mathbf{a} \\\\times \\\\mathbf{b}\",\n r\"\\\\ \\text{where } c = ab\\sin(\\theta)\",\n tex_to_color_map={\"\\\\mathbf{a}\": RED, \"\\\\mathbf{b}\": BLUE}\n ).scale(0.8).shift(DOWN * 2.5 + RIGHT * 2)\n\n self.play(Write(cross_formula[0]))\n self.wait(1)\n self.play(Write(cross_formula[1]))\n\n # Define the resulting cross product vector perpendicularly\n result_vec = Arrow(start=ORIGIN, end=UP*1.5 + LEFT*1.5, color=YELLOW)\n label_c = MathTex(\"\\\\mathbf{c}\", color=WHITE).move_to(result_vec.get_end())\n\n # Highlight that it's perpendicular using a blue circle\n plane = NumberPlane(x_range=(-3, 3), y_range=(-3, 3)).set_opacity(0.1)\n perp_circle = Circle(radius=0.7, color=GREEN).shift(UP*1.5 + LEFT*1.5)\n\n # Animation sequence showing construction of perpendicular component\n self.wait(1)\n self.play(Create(perp_circle))\n self.play(TransformFromCopy(vec_a.copy(), result_vec), TransformFromCopy(vec_b.copy(), perp_angle=result_vec.copy().rotate(-PI/2)))\n self.play(Write(label_c))\n\n # Explain direction via right-hand rule\n rh_rule = Tex(\"Right-hand Rule:\\\\ Up if $\\\\theta$ is acute, Down if obtuse\").to_edge(DOWN)\n self.play(Write(rh_rule))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Mastering cross products opens up powerful tools\\nfor physics, engineering, and math.\", font_size=24).to_edge(DOWN)\n \n # Fade out everything except vectors and formulas, then show final text\n self.play(\n FadeOut(perp_circle),\n FadeOut(plane),\n FadeOut(rh_rule),\n FadeOut(vec_a),\n FadeOut(vec_b),\n FadeOut(labels_a),\n FadeOut(labels_b),\n FadeOut(label_c),\n )\n self.play(Write(conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 15-second networking scene explaining TCP additive increase and multiplicative decrease. Draw a congestion-window sawtooth over time, reveal linear growth and sharp drops step by step, and explain that the sender probes capacity rather than knowing it in advance.", "chosen": "```python\nfrom manim import *\n\nclass TcpAddIncMulDec(Scene):\n def construct(self):\n # Title\n title = Text(\"TCP Adds Capacity on Success, Multiplies on Loss\", font_size=36).to_edge(UP)\n \n # Initial Window Size\n initial_window = VGroup(\n Rectangle(width=0.8, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.15, color=WHITE)\n ).shift(RIGHT*2 + UP*0.7)\n \n text_initial = Text(\"Initial window size of 1\", font_size=24).next_to(initial_window, DOWN)\n\n self.play(Write(title))\n self.play(Create(initial_window), Write(text_initial))\n self.wait(1)\n\n # First Increase (Linear Growth)\n window_after_first_inc = VGroup(\n Rectangle(width=1.6, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.2, color=WHITE)\n )\n \n text_incremented = Text(\"+1 after success\", font_size=24).move_to(text_initial.get_center())\n\n self.play(Transform(initial_window, window_after_first_inc), Transform(text_initial, text_incremented))\n self.wait(0.5)\n\n # Second Increase (Linear Growth)\n window_after_second_inc = VGroup(\n Rectangle(width=2.4, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.25, color=WHITE)\n )\n\n self.play(Transform(initial_window, window_after_second_inc))\n self.wait(0.5)\n\n # Drop (Multiplicative Decrease)\n drop_area = RoundedRectangle(corner_radius=0.1, width=0.8, height=0.2, color=RED, fill_color=RED, fill_opacity=0.3)\n drop_label = Text(\"-1/2 due to loss\", font_size=24).move_to(window_after_second_inc.get_bottom())\n \n self.play(FadeIn(drop_area), FadeIn(drop_label))\n self.wait(1)\n\n # Final State\n final_state_rect = VGroup(\n Rectangle(width=1.2, height=0.4, color=GREEN, fill_opacity=0),\n Dot(radius=0.2, color=WHITE)\n ).move_to(window_after_second_inc.get_top())\n\n final_text = Text(\"Final state post-drop\", font_size=24).move_to(final_state_rect.get_bottom())\n\n self.play(\n Transform(initial_window, final_state_rect),\n Transform(text_initial, final_text),\n FadeOut(drop_area),\n FadeOut(drop_label)\n )\n\n # Explanation Box\n explanation_box = RoundedRectangle(corner_radius=0.3, width=5.5, height=2.5, color=YELLOW, fill_color=YELLOW, fill_opacity=0.2)\n explanation_title = Text(\"Exploration vs Exploitation\", font_size=24, weight=BOLD).move_to(explanation_box.get_top() + DOWN*0.3)\n exploration_text = Text(\"Sender probes capacity\\nrather than knowing it in advance.\", font_size=20, line_spacing=1.2).move_to(explanation_box.get_center()).set_x(-1.2)\n expl_queue = VGroup(Text(\"Queue\"), Circle(radius=0.15, stroke_width=2, stroke_color=WHITE), Text(\"Server\")).arrange(RIGHT, buff=0.1).scale(0.8).next_to(expl_queue_start := Point().shift(DOWN*1.5 + LEFT*2.8), RIGHT, buff=-0.1)\n\n self.play(Write(explanation_box), Write(explanation_title))\n\n for i, txt in enumerate([\"Sent:\", \"Received:\"], start=1):\n sent_recv_txt = Text(txt, font_size=20).next_to(expl_queue_start, DOWN*i, buff=0.1)\n dot = Dot(color=BLUE if txt == \"Sent:\" else GREEN, radius=i*0.15).move_to(sent_recv_txt.get_right() + RIGHT*(i-1)*0.2)\n self.add(dot, sent_recv_txt)\n\n self.play(Write(exploration_text), Create(expl_queue))\n self.wait(1)\n\n # Highlight the core concept briefly at the end\n highlight_rect = SurroundingRectangle(VGroup(initial_window, text_initial), color=ORANGE, buff=0.15, corner_radius=0.1)\n highlight_text = Text(\"Adding on success, reducing quickly\\non loss ---\\nExploratory and adaptive\", font_size=20, t2c={\"adding\": ORANGE}).next_to(highlight_rect, DOWN, buff=0.3)\n\n self.play(Create(highlight_rect), Write(highlight_text))\n self.wait(2)\n\n# To render this animation, save the file as tcp_add_inc_mul_dec.py and run:\n# manim -pql tcp_add_inc_mul_dec.py TcpAddIncMulDec\n```", "rejected": "```python\nfrom manim import *\n\nclass TcpSawtoothScene(Scene):\n def construct(self):\n title = Text(\"TCP Congestion Control\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create axes for the graph\n axes = Axes(\n x_range=[0, 8, 1],\n y_range=[0, 10, 1],\n x_length=7,\n y_length=4,\n tips=False,\n ).shift(DOWN * 0.5).set_color(WHITE)\n\n labels = axes.get_axis_labels(x_label=\"Time\", y_label=\"Congestion Window\")\n\n # Additive Increase/Multiplicative Decrease\n ai_md_title = Tex(\n r\"$\\bullet$ Additive Increase / Multiplicative Decrease\",\n color=GREEN,\n )\n \n ai_md_text = Tex(\n \"Linear growth during probe phase.\",\n \"\\\\\\\\Sharp drop on loss detection.\"\n ).scale_to_fit_width(6.5).next_to(ai_md_md_title, DOWN, buff=0.5)\n \n\n self.add(axes, labels, ai_md_title, ai_md_text)\n self.wait(2)\n\n # Plot the first part of the curve\n # Start at window size 1, then add 1 per second up to 5\n plot_data1 = [[i, min(i + 1, 5)] for i in range(10)]\n path1 = VMobject()\n points1 = [axes.c2p(t, w) for t, w in plot_data1]\n path1.set_points_as_corners([ORIGIN, ORIGIN])\n path1.set_points_smoothly(points1)\n path1.set_stroke(color=YELLOW, width=5)\n self.play(Create(path1), run_time=2)\n self.wait(1)\n\n # Transition to the second part where we subtract twice the previous value\n # Start back at window size 5, then subtract half each cycle until below threshold\n\n # Define data for the transition period\n # We want to show two cycles where the rate decreases sharply after a small jump\n # First cycle jumps from 5 to 4 (subtract 1)\n # Second cycle jumps from 4 to 3 (subtract 1 again)\n # Then falls quickly to 1 (subtract ~1.5)\n transition_data = [\n [0, 5], # Start at 5\n [1, 5], # Hold at 5 for initial addition\n [2, 6], # Jump briefly to 6 (Add 1 immediately)\n [3, 5], # Drop back slightly\n [4, 4], # Subtract half the last increment (1)\n \n [5, 5], # Hold at 5 for initial subtraction\n [6, 6], # Jump briefly to 6 \n [7, 5], # Subtract half again\n [8, 3], # Quick drop to 3\n [9, 1], # Final rapid fall to 1\n ]\n\n # Clear the old line and prepare new coordinates\n path1.clear_points()\n new_points = []\n for t, w in transition_data:\n if not new_points:\n # Starting point is origin so arrow looks good from zero\n new_points.append(axes.c2p(-0.5, 0)) \n else:\n prev_t, _ = transition_data[t-1]\n new_points.append(axes.c2p(prev_t, w))\n\n # Append end position for final frame consistency\n end_point = axes.c2p(transition_data[-1][0], transition_data[-1][1]) \n new_points.append(end_point)\n\n # Set new coordinate set smoothly across the remaining animation duration\n path1.set_points_smoothly(new_points)\n path1.set_stroke(color=RED, width=5)\n\n self.play(\n FadeIn(VGroup(*ai_md_md_title, ai_md_text)),\n ReplacementTransform(path1.copy(), path1),\n run_time=4\n )\n\n # Label the graph elements clearly\n win_start_label = MathTex(\"W_{start}\").next_to(axes.c2p(0, 5), LEFT)\n win_end_label = MathTex(\"W_{end}\").next_to(axes.c2p(1, 5), RIGHT)\n \n self.play(FadeIn(win_start_label), FadeIn(win_end_label), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that shows a simple feedforward neural network with three layers, where the first layer has 4 neurons, the second layer has 6 neurons with a ReLU activation function, and the third layer has 3 neurons with a Softmax activation function, and then demonstrate a data point passing through this network?", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkFlow(Scene):\n def construct(self):\n # --- Configuration ---\n num_input_nodes = 4\n num_hidden_nodes = 6\n num_output_nodes = 3\n \n input_layer_label = \"Input Layer\"\n hidden_layer_label = \"Hidden Layer\\n(ReLU)\"\n output_layer_label = \"Output Layer\\n(Softmax)\"\n\n node_color = BLUE\n edge_color = WHITE\n\n # Create nodes for each layer\n input_nodes = VGroup()\n hidden_nodes = VGroup()\n output_nodes = VGroup()\n\n for i in range(num_input_nodes):\n dot = Dot(radius=0.18)\n input_nodes.add(dot)\n\n for i in range(num_hidden_nodes):\n rect = Rectangle(width=1.2, height=0.5, color=node_color).shift(DOWN * i*0.7 - DOWN * (num_hidden_nodes-1)/2 )\n \n label = Text(\"h\", font_size=22).move_to(rect.get_center())\n group = VGroup(label,rect)\n hidden_nodes.add(group)\n\n for i in range(num_output_nodes):\n circle = Circle(radius=0.25, color=node_color).shift(DOWN * i*0.7 - DOWN * (num_output_nodes-1)/2 )\n text = MathTex(\"\\\\sigma(x_i)\", font_size=20).next_to(circle, UP, buff=0.2)\n group = VGroup(text,circle)\n output_nodes.add(group)\n\n # Position nodes by their corresponding labels\n input_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (input_nodes.get_width()/2) , height=0.5*(num_input_nodes))\n input_text = Text(input_layer_label, font_size=20, weight=BOLD).next_to(input_rect, DOWN, buff=0.3)\n \n hidden_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (hidden_nodes.get_width()/2) , height=0.5*(num_hidden_nodes))\n hidden_text = Text(hidden_layer_label, font_size=20, weight=BOLD, t2c={\"ReLU\": YELLOW}).next_to(hidden_rect, DOWN, buff=0.3)\n hidden_text.shift(RIGHT * 0.15)\n \n output_rect = RoundedRectangle(corner_radius=0.2, width=1.5 + (output_nodes.get_width()), height=0.5*(num_output_nodes)*1.2 )\n output_text = Text(output_layer_label, font_size=20, weight=BOLD, t2c={\"Softmax\": GREEN}).next_to(output_rect, DOWN, buff=0.3)\n \n \n inputs_group = VGroup(\n input_rect,\n input_text,\n input_nodes\n ).arrange(RIGHT, buff=0.3)\n\n hidden_group = VGroup(\n hidden_rect,\n hidden_text,\n hidden_nodes\n ).arrange(RIGHT, buff=0.3)\n\n output_group = VGroup(\n output_rect,\n output_text,\n output_nodes\n )\n\n # Arrange groups horizontally\n main_structure = VGroup(inputs_group, hidden_group, output_group).arrange(RIGHT, buff=1.5)\n \n\n # Add edges between layers\n connections = []\n\n for i in range(len(input_nodes)):\n for j in range(len(hidden_nodes)):\n line_start = input_nodes[i].get_right() + RIGHT * 0.3\n line_end = hidden_nodes[j][0].get_left() + LEFT * 0.3\n \n if i == len(input_nodes)-1 and j != 0:\n line_start += UP * (j-i)*0.1\n line_end += UP * (j-i)*0.1\n \n \n connection = Line(line_start, line_end, stroke_width=1.5, color=edge_color)\n connections.append(connection)\n\n for i in range(len(hidden_nodes)):\n for j in range(len(output_nodes)):\n line_start = hidden_nodes[i][0].get_bottom() + DOWN * 0.2\n line_end = output_nodes[j][0].get_top() + UP * 0.2\n \n if i != len(hidden_nodes)-1 and j != 0:\n line_start += RIGHT * (j-i)*0.1\n line_end += RIGHT * (j-i)*0.1\n \n connection = Line(line_start, line_end, stroke_width=1.5, color=edge_color)\n connections.append(connection)\n\n # --- Animation Sequence ---\n\n self.play(Create(main_structure), run_time=2)\n self.wait(0.5)\n\n # Animate data points moving from Input -> Hidden (Left-to-Right)\n input_dots = [\n Dot(point=node.get_center(), radius=0.18, color=YELLOW).set_opacity(0)\n for node in input_nodes\n ]\n\n # Fade dots in sequentially\n for dot in input_dots:\n self.add(dot)\n self.play(FadeIn(dot, scale=1.5), run_time=0.5)\n\n # Show weights/connectors\n for conn in connections:\n self.play(Create(conn), run_time=0.1)\n\n # Forward signal animation through Hidden Layer\n hidden_inputs = []\n for h_node in hidden_nodes:\n hidden_dot = Dot(h_node[0].get_center(), color=ORANGE).scale(0)\n self.play(TransformFromCopy(hidden_dot, h_node[1]), run_time=0.2)\n self.wait(0.2)\n\n # Forward signal animation through Output Layer\n output_inputs = []\n for o_node in output_nodes:\n output_dot = Dot(o_node[0].get_center(), color=GREEN).scale(0)\n self.play(TransformFromCopy(output_dot, o_node[1]), run_time=0.2)\n self.wait(0.2)\n\n # Highlight Activation Functions\n relu_box = SurroundingRectangle(hidden_nodes, corner_radius=0.15, color=RED, fill_opacity=0.1, buff=0.1)\n softbox = SurroundingRectangle(output_nodes, corner_radius=0.15, color=GREEN, fill_opacity=0.1, buff=0.1)\n relu_text = Tex(\"$\\\\text{ReLU}$\").to_edge(UP).shift(RIGHT * 1.5)\n soft_text = Tex(\"$\\\\text{Softmax}$\").to_edge(UP).shift(RIGHT * 2.5)\n \n self.play(Create(relu_box), Write(relu_text), run_time=1)\n self.wait(0.5)\n self.play(Circumscribe(hidden_nodes, color=RED), Indicate(hidden_nodes, color=RED), run_time=1)\n self.wait(1)\n\n # Final state highlighting output predictions\n final_boxes = [SurroundingRectangle(node, corner_radius=0.15, color=GREEN, fill_opacity=0.1, buff=0.1) for node in output_nodes]\n final_labels = [Text(f\"Predicted Class {i}\", font_size=16).next_to(box, DOWN, buff=-0.2) for box, node in zip(final_boxes, output_nodes)]\n\n self.play(LaggedStart(*[Create(box) for box in final_boxes], lag_ratio=0.3), run_time=1.5)\n self.wait(1)\n self.play(LaggedStart(*[Write(label) for label in final_labels], lag_ratio=0.3), run_time=1.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkScene(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Layer Sizes\n INPUT_SIZE = 4\n HIDDEN_SIZE = 6\n OUTPUT_SIZE = 3\n \n # Colors for visual differentiation\n COLOR_INPUT = BLUE_E\n COLOR_HIDDEN = GREEN_C\n COLOR_OUTPUT = GOLD_D\n \n # Text labels configuration\n LABEL_COLOR = WHITE\n LABEL_FONT_SIZE = 28\n\n # Node sizes and spacing\n NODE_RADIUS = 0.2\n LAYER_SPACING = 4.0\n NEURON_SPACING = 1.0\n \n # Connection styles\n CONNECTION_STROKE_WIDTH = 2\n ACTIVE_CONNECTION_COLOR = YELLOW\n INACTIVE_CONNECTION_COLOR = GREY_A\n \n\n # --- Build Network Structure ---\n\n # Create Nodes for each layer\n input_layer_nodes = VGroup()\n hidden_layer_nodes = VGroup()\n output_layer_nodes = VGroup()\n\n # Input Layer (Left)\n for i in range(INPUT_SIZE):\n node = Circle(radius=NODE_RADIUS, color=COLOR_INPUT, fill_opacity=0.3)\n label_text = MathTex(\"I\", str(i + 1), color=LABEL_COLOR).scale(0.7)\n label_group = VGroup(node, label_text).arrange(DOWN, buff=0.1)\n input_layer_nodes.add(label_group)\n\n # Hidden Layer (Middle) - Position shifted slightly up/down to avoid overlap\n for i in range(HIDDEN_SIZE):\n x_offset = random.uniform(-0.1, 0.1) * 1.5\n y_shift = (-i * 0.45 if i < HIDDEN_SIZE // 2 else i * 0.45)\n \n node = Rectangle(\n width=NODE_RADIUS*2.5, \n height=NODE_RADIUS*1.8, \n color=COLOR_HIDDEN, \n fill_color=COLOR_HIDDEN,\n stroke_width=3, \n fill_opacity=0.4\n )\n node.shift(RIGHT*LAYER_SPACING/2.2 + UP*y_shift + LEFT*x_offset)\n label_text = MathTex(\"\\\\text{ReLU}\", font_size=26, color=WHITE).move_to(node.get_center())\n label_group = VGroup(node, label_text).arrange(DOWN, buff=0.1)\n hidden_layer_nodes.add(label_group)\n\n # Output Layer (Right)\n for i in range(OUTPUT_SIZE):\n x_offset = random.uniform(-0.1, 0.1) * 1.5\n y_shift = (-i * 0.45 if i < OUTPUT_SIZE // 2 else i * 0.45)\n \n node_rect = RoundedRectangle(corner_radius=0.2, width=NODE_RADIUS*2.5, height=NODE_RADIUS*1.8, color=COLOR_OUTPUT, fill_color=COLOR_OUTPUT, stroke_width=3, fill_opacity=0.5)\n node_circle = Circle(radius=(NODE_RADIUS)*0.8, color=WHITE, fill_color=BLACK, stroke_width=2, fill_opacity=0.7)\n node_rect.move_to(RIGHT*LAYER_SPACING/2.1 + UP*y_shift + LEFT*x_offset)\n node_circle.move_to(node_rect.get_center())\n\n label_text = MathTex(\"\\\\sigma(x)\", r\"=\\frac{1}{1+\\exp(-x)}\", font_size=20, color=WHITE).move_to(node_rect.get_center())\n label_group = VGroup(node_rect, node_circle, label_text).arrange(DOWN, buff=0.1)\n output_layer_nodes.add(VGroup(label_group))\n\n # Arrange nodes vertically within their group so they can be moved uniformly together later\n input_layer_nodes.arrange(DOWN, buff=NEURON_SPACING, aligned_edge=LEFT).shift(LEFT*LAYER_SPACING/2)\n hidden_layer_nodes.arrange(DOWN, buff=NEURON_SPACING, aligned_edge=RIGHT).shift(RIGHT*LAYER_SPACING/2)\n output_layer_nodes.arrange(DOWN, buff=NEURON_SPACING, aligned_edge=RIGHT).shift(RIGHT*LAYER_SPACING/2)\n\n\n # Add connection lines between layers\n connections_input_hidden = []\n connections_hidden_output = []\n\n # Draw connections from Input -> Hidden Layer\n for i in range(INPUT_SIZE):\n for j in range(HIDDEN_SIZE):\n start_pos = input_layer_nodes[i].get_right()\n end_pos = hidden_layer_nodes[j].get_left()\n \n line = Line(start=start_pos, end=end_pos, color=INACTIVE_CONNECTION_COLOR, stroke_width=CONNECTION_STROKE_WIDTH)\n connections_input_hidden.append(line)\n \n # Draw connections from Hidden -> Output Layer\n for i in range(HIDDEN_SIZE):\n for j in range(OUTPUT_SIZE):\n start_pos = hidden_layer_nodes[i].get_right()\n end_pos = output_layer_nodes[j].get_left()\n \n line = Line(start=start_pos, end=end_pos, color=INACTIVE_CONNECTION_COLOR, stroke_width=CONNECTION_STROKE_WIDTH)\n connections_hidden_output.append(line)\n\n connections_group = VGroup(*connections_input_hidden, *connections_hidden_output)\n\n\n # --- Animation Sequence ---\n\n # Step 1: Visualize Architecture\n self.play(Create(input_layer_nodes))\n self.play(Create(hidden_layer_nodes))\n self.play(Create(output_layer_nodes))\n \n # Animate connections forming smoothly from left to right\n self.play(LaggedStartMap(Create, connections_group, lag_ratio=0.02), run_time=2)\n \n self.wait(1)\n\n # Step 2: Simulate Data Point Flow\n # Highlight specific neuron indexes in order of processing\n DATA_POINT_SEQUENCE = [1, 0, 2, 3, 0, 1, 2]\n INDEX_MAP = {\n 'Input': [[0], [1], [2], [3]],\n 'Hidden': [[1], [0], [2]], # Using indices from RELU equation logic\n 'Output': [[1]] # Only index 1 is active at the end\n }\n ANIMATION_SPEED = 0.3\n DELAY_INTERVAL = 0.2\n \n # Function to highlight and animate activation paths sequentially\n def animate_activation(layer_index, target_indices, parent_connections, child_connections, delay_start=DELAY_INTERVAL):\n for idx in target_indices:\n current_node = None\n if layer_index == \"Input\":\n current_node = input_layer_nodes[idx][0]\n elif layer_index == \"Hidden\":\n current_node = hidden_layer_nodes[idx][0]\n else: # Output\n current_node = output_layer_nodes[idx][0]\n\n # Flash the current neuron/node briefly\n flash_animation = current_node.animate.scale(1.2)\n self.play(flash_animation, run_time=ANIMATION_SPEED)\n self.play(FadeOut(current_node), run_time=0.1)\n\n # Connect to parent/current layer nodes with temporary color\n for p_conn in parent_connections:\n p_conn.set_stroke(color=ACTIVE_CONNECTION_COLOR)\n \n # Connect to child/output layer nodes with temporary color\n for c_conn in child_connections:\n c_conn.set_stroke(color=ACTIVATE_CONNECTION_COLOR)\n \n # Show forward signal flow animation\n for p_conn in parent_connections:\n if layer_index != \"Output\": # Exclude final step since it connects internally only\n self.play(p_conn.animate.set_stroke(width=CONNECTION_STROKE_WIDTH*2), run_time=0.1)\n \n for c_conn in child_connections:\n self.play(c_conn.animate.set_stroke(width=CONNECTION_STROKE_WIDTH*2), run_time=0.1)\n \n # Reset colors after brief pulse\n self.play(\n *[p_conn.animate.set_stroke(color=INACTIVE_CONNECTION_COLOR) for p_conn in parent_connections],\n *[c_conn.animate.set_stroke(color=INACTIVE_CONNECTION_COLOR) for c_conn in child_connections],\n run_time=0.1\n )\n\n # Process sequence based on defined mapping\n for seq_idx, layer_key in enumerate(DATA_POINT_SEQUENCE):\n layer_name = [\"Input\", \"Hidden\"][layer_key] # Map integer key to layer name\n \n # Identify which nodes to activate from the map\n target_neurons = INDEX_MAP[layer_name][seq_idx % len(INDEX_MAP[layer_name])]\n \n # Determine parent/connection groups based on layer type\n prev_parents = connections_input_hidden if layer_name==\"Hidden\" else connections_hidden_output\n next_children = connections_hidden_output if layer_name==\"Hidden\" else []\n \n # Activate selected neurons in sequential pattern\n animate_activation(layer_name, target_neurons, prev_parents, next_children)\n\n # Final State Highlight\n self.play(\n FadeIn(output_layer_nodes[INDEX_MAP['Output'][len(DATA_POINT_SEQUENCE)-1]][0]),\n run_time=0.5\n )\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Setup: Create Axes ---\n axes = Axes(\n x_range=[-2, 3, 1],\n y_range=[-2, 4, 1],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # --- 2. Function Visualization ---\n func = lambda x: 3 - x**2\n graph = axes.plot(func, color=BLUE, x_range=[-2, 3])\n func_label = axes.get_graph_label(\n graph, label=MathTex(r\"f(x) = 3 - x^2\").set_color(BLUE), x_val=2, direction=UR\n )\n\n # --- 3. Area Highlighting ---\n area = axes.get_area(graph, x_range=[-1, 2], color=GREEN, opacity=0.5)\n\n # --- 4. Mathematical Steps ---\n # Position math equations on the right side of the screen\n integral_text = MathTex(r\"\\int_{-1}^{2} (3 - x^2) \\, dx\").to_edge(RIGHT).shift(UP * 2.5)\n \n antiderivative_text = MathTex(\n r\"=\\left[ 3x - \\frac{x^3}{3} \\right]_{-1}^{2}\"\n ).next_to(integral_text, DOWN, buff=0.5)\n \n substitution_text = MathTex(\n r\"=\\left( 3(2) - \\frac{2^3}{3} \\right) - \\left( 3(-1) - \\frac{(-1)^3}{3} \\right)\"\n ).scale(0.8).next_to(antiderivative_text, DOWN, buff=0.5)\n \n calculation_text = MathTex(\n r\"=\\left( 6 - \\frac{8}{3} \\right) - \\left( -3 + \\frac{1}{3} \\right)\"\n ).scale(0.8).next_to(substitution_text, DOWN, buff=0.5)\n \n simplification_text = MathTex(\n r\"=\\frac{10}{3} + \\frac{8}{3} = \\frac{18}{3}\"\n ).next_to(calculation_text, DOWN, buff=0.5)\n\n # --- Animation Sequence ---\n \n # Show the function itself\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), Write(func_label))\n self.wait(1)\n\n # Display the integral of the function within the given bounds\n self.play(Write(integral_text))\n self.wait(1)\n\n # Plot the function's graph and highlight the area under the curve\n self.play(FadeIn(area))\n self.wait(1)\n\n # Show the antiderivative of the function\n self.play(Write(antiderivative_text))\n self.wait(1)\n\n # Demonstrate how to evaluate the definite integral by substituting the bounds\n self.play(Write(substitution_text))\n self.wait(1)\n \n self.play(Write(calculation_text))\n self.wait(1)\n \n self.play(Write(simplification_text))\n self.wait(1)\n\n # --- 5. Result: Calculate and display the final numerical value ---\n result_text = MathTex(\"= 6\").set_color(YELLOW).scale(1.5).next_to(simplification_text, DOWN, buff=0.5)\n self.play(Write(result_text))\n self.wait(2)\n\n # --- 6. Conclusion: End the animation with only the final numerical result visible ---\n all_mobjects = VGroup(\n axes, axis_labels, graph, func_label, area, \n integral_text, antiderivative_text, substitution_text, \n calculation_text, simplification_text, result_text\n )\n \n final_result = MathTex(\"6\").scale(3).move_to(ORIGIN).set_color(YELLOW)\n \n self.play(\n FadeOut(all_mobjects),\n FadeIn(final_result)\n )\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Setup: Create Axes ---\n axes = Axes(\n x_range=[-2, 3, 1],\n y_range=[-2, 4, 1],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # --- 2. Function Visualization ---\n func = lambda x: 3 - x**2\n graph = axes.plot(func, color=BBLUE, x_range=[-2, 3])\n func_label = axes.get_graph_label(\n graph, label=MathTex(r\"f(x) = 3 - x^2\").set_color(BLUE), x_val=2, direction=UR\n )\n\n # --- 3. Area Highlighting ---\n area = axes.get_area(graph, x_range=[-1, 2], color=GREEN, opacity=0.5)\n\n # --- 4. Mathematical Steps ---\n # Position math equations on the right side of the screen\n integral_text = MathTex(r\"\\int_{-1}^{2} (3 - x^2) \\, dx\").to_edge(RIGHT).shift(UP * 2.5)\n \n antiderivative_text = MathTex(\n r\"=\\left[ 3x - \\frac{x^3}{3} \\right]_{-1}^{2}\"\n ).next_to(integral_text, DOWN, buff=0.5)\n \n substitution_text = MathTex(\n r\"=\\left( 3(2) - \\frac{2^3}{3} \\right) - \\left( 3(-1) - \\frac{(-1)^3}{3} \\right)\"\n ).scale(0.8).next_to(antiderivative_text, DOWN, buff=0.5)\n \n calculation_text = MathTex(\n r\"=\\left( 6 - \\frac{8}{3} \\right) - \\left( -3 + \\frac{1}{3} \\right)\"\n ).scale(0.8).next_to(substitution_text, DOWN, buff=0.5)\n \n simplification_text = MathTex(\n r\"=\\frac{10}{3} + \\frac{8}{3} = \\frac{18}{3}\"\n ).next_to(calculation_text, DOWN, buff=0.5)\n\n # --- Animation Sequence ---\n \n # Show the function itself\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(graph), Write(func_label))\n self.wait(1)\n\n # Display the integral of the function within the given bounds\n self.play(Write(integral_text))\n self.wait(1)\n\n # Plot the function's graph and highlight the area under the curve\n self.play(FadeIn(area))\n self.wait(1)\n\n # Show the antiderivative of the function\n self.play(Write(antiderivative_text))\n self.wait(1)\n\n # Demonstrate how to evaluate the definite integral by substituting the bounds\n self.play(Write(substitution_text))\n self.wait(1)\n \n self.play(Write(calculation_text))\n self.wait(1)\n \n self.play(Write(simplification_text))\n self.wait(1)\n\n # --- 5. Result: Calculate and display the final numerical value ---\n result_text = MathTex(\"= 6\").set_color(YELLOW).scale(1.5).next_to(simplification_text, DOWN, buff=0.5)\n self.play(Write(result_text))\n self.wait(2)\n\n # --- 6. Conclusion: End the animation with only the final numerical result visible ---\n all_mobjects = VGroup(\n axes, axis_labels, graph, func_label, area, \n integral_text, antiderivative_text, substitution_text, \n calculation_text, simplification_text, result_text\n )\n \n final_result = MathTex(\"6\").scale(3).move_to(ORIGIN).set_color(YELLOW)\n \n self.play(\n FadeOut(all_mobjects),\n FadeIn(final_result)\n )\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 linear transformation\" to explain the purpose of the animation. Next, please create a grid representing the 2D plane and place a yellow arrow labeled with \"v\" on it, representing a vector from the origin to the point (1, 2). After setting up the grid and vector, I want to animate the effect of applying the matrix A to the plane and the vector \"v\", showing how both the grid and the vector are transformed according to the matrix. The transformed vector should be labeled with \"Av\". To finish the animation, clear everything off the screen, and then redraw the same matrix A to reinforce what was presented. The animation should have pauses and play at a speed that allows the viewers to follow along easily.", "chosen": "```python\nfrom manim import *\n\nclass LinearTransformationVisualization(Scene):\n def construct(self):\n # 1. Matrix Display\n # Define the matrix A = [[2, 1], [1, 3]]\n matrix_values = [[2, 1], [1, 3]]\n matrix_a = Matrix(matrix_values)\n matrix_label = MathTex(\"A = \")\n matrix_group = VGroup(matrix_label, matrix_a).arrange(RIGHT)\n \n self.play(Write(matrix_group), run_time=2)\n self.wait(1)\n\n # 2. Explanatory Text\n explanation_text = Text(\"Visualize a linear transformation\", font_size=36)\n explanation_text.next_to(matrix_group, UP, buff=0.5)\n \n self.play(Write(explanation_text), run_time=2)\n self.wait(1)\n\n # Transition: Fade out introductory elements to make room for the grid\n self.play(FadeOut(matrix_group), FadeOut(explanation_text), run_time=1)\n self.wait(0.5)\n\n # 3. Grid and Vector Setup\n # Create a grid with expanded range to ensure the transformed vector (4, 7) remains visible\n plane = NumberPlane(\n x_range=(-10, 10, 1),\n y_range=(-10, 10, 1),\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.6\n }\n )\n \n # Place a yellow arrow labeled \"v\" from origin (0,0) to (1, 2)\n vec_v = Arrow(ORIGIN, [1, 2, 0], color=YELLOW, buff=0)\n label_v = MathTex(\"v\").next_to(vec_v.get_end(), UR, buff=0.1)\n \n self.play(Create(plane), run_time=2)\n self.play(GrowArrow(vec_v), Write(label_v), run_time=2)\n self.wait(1)\n\n # 4. Transformation Animation\n # Calculate the transformed vector endpoint: A * [1, 2] = [2*1 + 1*2, 1*1 + 3*2] = [4, 7]\n Av_end = [4, 7, 0]\n \n # Prepare the new label \"Av\" at the new tip position\n label_av = MathTex(\"Av\").next_to(Av_end, UR, buff=0.1)\n \n # Animate the application of matrix A to the grid and vector\n # The label smoothly transforms and moves to the new position simultaneously\n self.play(\n plane.animate.apply_matrix(matrix_values),\n vec_v.animate.apply_matrix(matrix_values),\n Transform(label_v, label_av),\n run_time=3\n )\n self.wait(2)\n\n # 5. Conclusion Sequence\n # Clear all elements from the screen\n self.play(FadeOut(plane), FadeOut(vec_v), FadeOut(label_v), run_time=1)\n self.clear()\n self.wait(0.5)\n \n # Redraw the original matrix A to reinforce the concept\n final_matrix = Matrix(matrix_values)\n final_label = MathTex(\"A = \")\n final_group = VGroup(final_label, final_matrix).arrange(RIGHT)\n \n self.play(Write(final_group), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass LinearTransformationVisualization(Scene):\n def construct(self):\n # 1. Matrix Display\n # Define the matrix A = [[2, 1], [1, 3]]\n matrix_values = [[2, 1], [1, 3]]\n matrix_a = Matrix(matrix_values)\n matrix_label = MathTex(r\"A = \" + \" = x\")\n matrix_group = VGroup(matrix_label, matrix_a).arrange(RIGHT)\n \n self.play(Write(matrix_group), run_time=2)\n self.wait(1)\n\n # 2. Explanatory Text\n explanation_text = Text(\"Visualize a linear transformation\", font_size=36)\n explanation_text.next_to(matrix_group, UP, buff=0.5)\n \n self.play(Write(explanation_text), run_time=2)\n self.wait(1)\n\n # Transition: Fade out introductory elements to make room for the grid\n self.play(FadeOut(matrix_group), FadeOut(explanation_text), run_time=1)\n self.wait(0.5)\n\n # 3. Grid and Vector Setup\n # Create a grid with expanded range to ensure the transformed vector (4, 7) remains visible\n plane = NumberPlane(\n x_range=(-10, 10, 1),\n y_range=(-10, 10, 1),\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.6\n }\n )\n \n # Place a yellow arrow labeled \"v\" from origin (0,0) to (1, 2)\n vec_v = Arrow(ORIGIN, [1, 2, 0], color=YELLOW, buff=0)\n label_v = MathTex(\"v\").next_to(vec_v.get_end(), UR, buff=0.1)\n \n self.play(Create(plane), run_time=2)\n self.play(GrowArrow(vec_v), Write(label_v), run_time=2)\n self.wait(1)\n\n # 4. Transformation Animation\n # Calculate the transformed vector endpoint: A * [1, 2] = [2*1 + 1*2, 1*1 + 3*2] = [4, 7]\n Av_end = [4, 7, 0]\n \n # Prepare the new label \"Av\" at the new tip position\n label_av = MathTex(\"Av\").next_to(Av_end, UR, buff=0.1)\n \n # Animate the application of matrix A to the grid and vector\n # The label smoothly transforms and moves to the new position simultaneously\n self.play(\n plane.animate.apply_matrix(matrix_values),\n vec_v.animate.apply_matrix(matrix_values),\n Transform(label_v, label_av),\n run_time=3\n )\n self.wait(2)\n\n # 5. Conclusion Sequence\n # Clear all elements from the screen\n self.play(FadeOut(plane), FadeOut(vec_v), FadeOut(label_v), run_time=1)\n self.clear()\n self.wait(0.5)\n \n # Redraw the original matrix A to reinforce the concept\n final_matrix = Matrix(matrix_values)\n final_label = MathTex(\"A = \")\n final_group = VGroup(final_label, final_matrix).arrange(RIGHT)\n \n self.play(Write(final_group), run_time=2)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an educational animation that visually explains how to evaluate the definite integral of x cubed from 0 to 2 using the power rule for integration. The animation should include the following steps: display the problem, write an explanation of applying the power rule, demonstrate the power rule itself, perform the integration step by step, evaluate the integral with the given bounds, show the final solution, and finally, conclude by clearly presenting the final numerical result. Can you make this animation engaging, with each step appearing in sequence and with appropriate pauses to allow viewers to follow along?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- Step 1: Problem Display ---\n title = Text(\"Evaluating a Definite Integral Using Power Rule\", font_size=36)\n title.to_edge(UP)\n\n problem = MathTex(\n r\"\\int_{0}^{2}\", \"x^3\", \"\\, dx\"\n ).scale(1.5).next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # Move the equation up slightly to make room for explanations\n self.play(FadeIn(problem.copy().shift(UP*0.8)))\n\n # Clear screen for explanations\n self.clear()\n self.wait(0.5)\n\n # --- Step 2: Explanation ---\n explanation_text = Text(\n \"Apply the Power Rule for Integration:\",\n font_size=32,\n color=BLUE\n )\n \n # Power Rule formula displayed separately so it scales smoothly during transformation\n power_rule_formula = MathTex(\n r\"\\text{If } f(x) = x^n \\Rightarrow F(x) = \\frac{x^{n+1}}{n+1}\"\n ).scale(0.7).to_edge(DOWN)\n\n self.play(Write(explanation_text))\n self.play(Write(power_rule_formula))\n\n # Animate the rule scaling down while moving it below the text\n self.play(\n power_rule_formula.animate.scale(0.5).move_to(ORIGIN).shift(DOWN*2),\n run_time=1.5\n )\n\n self.wait(2)\n\n # Fade out explanations for calculation steps\n self.play(FadeOut(explanation_text), FadeOut(power_rule_formula))\n self.wait(0.5)\n\n # --- Steps 3-5: Calculation ---\n # Antiderivative step\n antideriv_step = MathTex(\n r\"=\\left[ \\frac{x^{3+1}}{3+1}\\right]_{0}^{2}\",\n r\"=\", \n r\"\\left[ \\frac{x^4}{4}\\right]_{0}^{2}\",\n font_size=40\n ).next_to(problem, DOWN, buff=0.8)\n\n # Substitution of bounds step\n eval_bounds = MathTex(\n r\"=\\left( \\frac{2^4}{4}\\right)\", \"-\", \"(0)\"\n ).scale(0.9).next_to(antideriv_step, RIGHT, buff=0.5)\n\n self.play(Write(antideriv_step))\n self.wait(1)\n \n # Show substitution explicitly\n self.play(Write(eval_bounds))\n self.wait(1)\n\n # Simplification step\n simplification = MathTex(\n r\"=\", r\"\\frac{16}{4}\", r\"- 0\",\n font_size=40\n ).scale(0.9).next_to(eval_bounds, DOWN, aligned_edge=LEFT)\n\n self.play(Write(simplification))\n self.wait(1)\n\n # Final arithmetic step\n final_arithmetic = MathTex(\n r\"=\", r\"4\", font_size=40\n ).scale(1.5).next_to(simplification, DOWN, aligned_edge=LEFT)\n box = SurroundingRectangle(final_arithmetic, color=YELLOW, buff=MED_LARGE_BUFF)\n \n self.play(Write(final_arithmetic))\n self.play(Create(box))\n self.wait(2)\n\n # --- Step 6: Conclusion ---\n conclusion_title = Text(\"Final Solution:\", font_size=36, color=GREEN).to_edge(DOWN)\n self.play(Write(conclusion_title))\n self.wait(1)\n \n # Center the final result prominently at the bottom\n final_result = MathTex(\"4\").scale(2).set_color(GREEN)\n final_box = SurroundingRectangle(final_result, color=GOLD, buff=LARGE_BUFF)\n\n self.play(\n final_arithmetic.animate.move_to(ORIGIN).scale(1.5),\n box.animate.move_to(ORIGIN).scale(1.5),\n Write(conclusion_title),\n RunTime=2\n )\n \n # Add background box for emphasis\n full_group = VGroup(final_box, final_result, conclusion_title)\n self.play(FadeIn(full_group, shift=DOWN))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display Problem\n # Visually present the definite integral expression on screen.\n # ------------------------------------------------------------------\n\n # Create the integral notation specifically styled for MathJax rendering\n integral_expr = MathTex(\n r\"\\int_{0}^{2}\", \"x^\", \"{\\\\color{blue}{3}}\", \"\\\\,\", \"dx\",\n font_size=72,\n color=WHITE\n )\n\n # Position it at the top of the screen\n integral_expr.to_edge(UP)\n\n self.play(Write(integral_expr))\n self.wait(1) # Allow time to read\n\n # ------------------------------------------------------------------\n # Step 2: Explanation of Power Rule Application\n # Provide a brief textual context explaining the method used to solve.\n # This helps viewers understand why we're integrating powers.\n # ------------------------------------------------------------------\n\n explanation_text = Text(\"Apply the Power Rule:\", font_size=36)\n explanation_box = SurroundingRectangle(explanation_text, buff=0.2)\n \n explanation_group = VGroup(explanation_text, explanation_box).to_edge(DOWN, buff=0.8)\n\n self.play(Write(explanation_text), Create(explanation_box))\n\n # Animate the appearance of a simple equation showing the general formula\n rule_eq = MathTex(\n r\"\\\\left[ \\\\frac{x^{n+1}}{n+1} \\right]\", \"_{a}^{b}\",\n font_size=54\n ).next_to(explanation_group, UP, buff=0.8)\n\n self.play(Write(rule_eq))\n self.wait(2)\n\n # Fade out the rule briefly so we can transition cleanly to the specific case\n self.play(FadeOut(rule_eq))\n\n # Move explanation up slightly to make room for subsequent steps\n self.play(MoveAlongPath(explanation_group, Line(ORIGIN, DOWN*1.5)))\n\n # ------------------------------------------------------------------\n # Step 3: Demonstrate the General Power Rule Formula\n # Show the mathematical form of the power rule explicitly.\n # Highlight the exponent adding one divided by the new exponent.\n # ------------------------------------------------------------------\n\n power_rule_title = Text(\"The Power Rule for Integration:\", font_size=36)\n power_rule_form = MathTex(\n r\"\\int\", \"x^n\", \"\\\\,\", \"dx =\", \"\\\\frac{1}{n+1}\", \"x^{n+1}\"\n ).scale(1.2).shift(DOWN * 1)\n\n # Color coding for clarity\n highlight_color = YELLOW\n power_rule_form[0].set_color(GREEN)\n power_rule_form[1][1:-1].set_color(highlight_color) # n part\n power_rule_form[-2][1:].set_color(highlight_color) # n+1 part\n \n power_rule_group = VGroup(power_rule_title, power_rule_form)\n\n self.play(Write(power_rule_title), Write(power_rule_form))\n self.wait(2)\n\n # Emphasize the division step specifically\n box_for_division = SurroundingRectangle(VGroup(power_rule_form[2], power_rule_form[3]))\n self.play(Create(box_for_division))\n self.wait(2)\n\n # Clean up the rule demonstration to prepare for substitution\n self.play(\n FadeOut(power_rule_title),\n FadeOut(power_rule_form),\n FadeOut(box_for_division)\n )\n\n # -------------------------------------------------------------\n # Step 4: Perform Integration Steps (Substitution & Antiderivative)\n # Substituting n = 3 into the antiderivative formula.\n # -------------------------------------------------------------\n\n # Re-display the original problem to maintain reference point\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Prepare the antiderivative representation\n antideriv_step = MathTex(\n r\"=\", r\"\\\\left[ \", \"\\frac{x^{4}}{4}\", \"\\\\right]\", \"_{0}^{2}\",\n font_size=60\n )\n antideriv_step.next_to(integral_expr, RIGHT, buff=0.5)\n\n # Color code parts for visual emphasis\n antideriv_step[2].set_color(YELLOW)\n antideriv_step[3].set_color(WHITE)\n\n self.play(Write(antideriv_step))\n self.wait(2)\n\n # ---------------------------------------------------------------------------------\n # Step 5: Evaluate Bounds (Calculate Specific Values within Limits)\n # Substitute the upper bound (2) and subtract the lower bound (0) calculations.\n # -------------------------------------------------------------------------------------------------------------------\n\n eval_bounds = MathTex(\n r\"=\", r\"\\\\left(\", \"\\frac{2^{4}}{4}\", \"\\\\right)\", \"-\", r\"\\\\left(\", \"\\frac{0^{4}}{4}\", \"\\\\right)\",\n font_size=60\n ).next_to(antideriv_step, RIGHT, buff=0.5)\n\n # Color code differences between evaluation points for clarity\n eval_bounds[2].set_color(RED)\n eval_bounds[6].set_color(RED)\n\n # Clear old antideriv text to focus only on evaluation process\n self.play(\n FadeOut(antideriv_step),\n FadeIn(eval_bounds, shift=RIGHT * 0.5)\n )\n\n self.wait(1)\n\n # --------------------------------------------\n # Step 6: Final Solution (Arithmetic Calculation Result)\n # Execute the arithmetic operations to find the value.\n # ------------------------------------------------------------------------------\n\n # Simplify exponents first then subtraction of zero\n simplify_exps = MathTex(\n r\"=\", r\"\\\\left(\", \"16\", \"\\\\right)\", \"- 0\",\n font_size=60\n ).move_to(eval_bounds.get_center())\n \n self.play(TransformMatchingTex(eval_bounds, simplify_exps))\n self.wait(1)\n\n # Subtract zero explicitly to clear the minus sign\n finalize_calc = MathTex(\n r\"=\", 16,\n font_size=60,\n color=YELLOW\n ).move_to(simplify_exps.get_center())\n\n self.play(TransformMatchingTex(simplify_exps, finalize_calc))\n self.wait(2)\n\n # -----------------------------------------------\n # Step 7: Conclusion (Present Final Numerical Result)\n # Clearly present the computed answer at the center of the screen.\n # Include a large circle surrounding the final number for emphasis.\n # ----------------------------------------------------------------------------------------------------\n\n final_circle = Circle(radius=1, color=GREEN).center()\n final_result = Integer(finalize_calc[1]).scale(2.5).move_to(ORIGINATION_POINT)\n\n self.play(\n TransformFromCopy(finalize_calc, final_result),\n Create(final_circle)\n )\n\n # Hold the conclusion for viewing\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an educational animation that visually walks through the steps of solving a double integral in polar coordinates. Start by displaying the double integral of r^2 * sin(theta) with respect to r from 0 to 1 and theta from 0 to pi. Follow that by a step-by-step integration process. First, calculate the inner integral with respect to r and display the intermediate result. Then, explain that the next step is to integrate with respect to theta and show this calculation, leading to the final result. Finally, evaluate the integral and simplify the expression to get the numerical answer. Make sure that each step is clearly written out and that there are brief pauses between steps for viewers to follow along.", "chosen": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- 1. Initial Display ---\n # Render the full double integral expression\n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=48\n )\n \n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- 2. Inner Integration ---\n # Animate the antiderivative with respect to r\n inner_antideriv = 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 )\n \n self.play(ReplacementTransform(initial_integral, inner_antideriv))\n self.wait(2)\n\n # Substitute the limits for r\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=48\n )\n \n self.play(ReplacementTransform(inner_antideriv, inner_evaluated))\n self.wait(2)\n\n # Simplify the inner result\n inner_simplified = MathTex(\n r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=48\n )\n \n self.play(ReplacementTransform(inner_evaluated, inner_simplified))\n self.wait(2)\n\n # --- 3. Transition ---\n # Text explanation for the next step\n transition_text = Text(\n \"Next, integrate with respect to $\\\\theta$\", \n font_size=32, \n color=YELLOW\n ).next_to(inner_simplified, DOWN, buff=0.5)\n \n self.play(FadeIn(transition_text))\n self.wait(2)\n self.play(FadeOut(transition_text))\n self.wait(1)\n\n # --- 4. Outer Integration ---\n # Find the antiderivative of sin(theta)\n outer_antideriv = MathTex(\n r\"\\frac{1}{3} \\left[ -\\cos(\\theta) \\right]_{0}^{\\pi}\",\n font_size=48\n )\n \n self.play(ReplacementTransform(inner_simplified, outer_antideriv))\n self.wait(2)\n\n # Substitute the limits for theta\n outer_evaluated = MathTex(\n r\"\\frac{1}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\",\n font_size=48\n )\n \n self.play(ReplacementTransform(outer_antideriv, outer_evaluated))\n self.wait(2)\n\n # --- 5. Final Evaluation ---\n # Evaluate trigonometric functions\n final_calc = MathTex(\n r\"\\frac{1}{3} \\left( -(-1) + 1 \\right) = \\frac{1}{3}(2)\",\n font_size=48\n )\n \n self.play(ReplacementTransform(outer_evaluated, final_calc))\n self.wait(2)\n\n # Simplify to the final numerical answer\n final_result = MathTex(\n r\"= \\frac{2}{3}\",\n font_size=60,\n color=GREEN\n )\n \n self.play(ReplacementTransform(final_calc, final_result))\n \n # Add a surrounding box for prominence\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n\n# To run this script:\n# manim -pql polar_integral.py PolarDoubleIntegral\n```", "rejected": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- 1. Initial Display ---\n # Render the full double integral expression\n initial_integral = MathTex(\n r\"\\int_{0}^{\\pi} \\int_{0}^{1} r^2 \\sin(\\theta) \\, dr \\, d\\theta\",\n font_size=48\n )\n \n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- 2. Inner Integration ---\n # Animate the antiderivative with respect to r\n inner_antideriv = 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 )\n \n self.play(ReplacementTransform(target_position=ORIGIN, initial_integral, inner_antideriv))\n self.wait(2)\n\n # Substitute the limits for r\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=48\n )\n \n self.play(ReplacementTransform(inner_antideriv, inner_evaluated))\n self.wait(2)\n\n # Simplify the inner result\n inner_simplified = MathTex(\n r\"\\int_{0}^{\\pi} \\frac{1}{3} \\sin(\\theta) \\, d\\theta\",\n font_size=48\n )\n \n self.play(ReplacementTransform(inner_evaluated, inner_simplified))\n self.wait(2)\n\n # --- 3. Transition ---\n # Text explanation for the next step\n transition_text = Text(\n \"Next, integrate with respect to $\\\\theta$\", \n font_size=32, \n color=YELLOW\n ).next_to(inner_simplified, DOWN, buff=0.5)\n \n self.play(FadeIn(transition_text))\n self.wait(2)\n self.play(FadeOut(transition_text))\n self.wait(1)\n\n # --- 4. Outer Integration ---\n # Find the antiderivative of sin(theta)\n outer_antideriv = MathTex(\n r\"\\frac{1}{3} \\left[ -\\cos(\\theta) \\right]_{0}^{\\pi}\",\n font_size=48\n )\n \n self.play(ReplacementTransform(inner_simplified, outer_antideriv))\n self.wait(2)\n\n # Substitute the limits for theta\n outer_evaluated = MathTex(\n r\"\\frac{1}{3} \\left( -\\cos(\\pi) - (-\\cos(0)) \\right)\",\n font_size=48\n )\n \n self.play(ReplacementTransform(outer_antideriv, outer_evaluated))\n self.wait(2)\n\n # --- 5. Final Evaluation ---\n # Evaluate trigonometric functions\n final_calc = MathTex(\n r\"\\frac{1}{3} \\left( -(-1) + 1 \\right) = \\frac{1}{3}(2)\",\n font_size=48\n )\n \n self.play(ReplacementTransform(outer_evaluated, final_calc))\n self.wait(2)\n\n # Simplify to the final numerical answer\n final_result = MathTex(\n r\"= \\frac{2}{3}\",\n font_size=60,\n color=GREEN\n )\n \n self.play(ReplacementTransform(final_calc, final_result))\n \n # Add a surrounding box for prominence\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n\n# To run this script:\n# manim -pql polar_integral.py PolarDoubleIntegral\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_A = BLUE\n COLOR_B = GREEN\n COLOR_C = RED\n \n # Define triangle dimensions (3-4-5 right triangle)\n point_A = ORIGIN\n point_B = np.array([3, 0, 0])\n point_C = np.array([0, 4, 0])\n \n # --- Step 1: Initial Display ---\n initial_equation = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=48)\n initial_equation.to_edge(UP)\n \n self.play(Write(initial_equation))\n self.wait(1)\n self.play(FadeOut(initial_equation))\n \n # --- Step 2: Triangle Construction ---\n triangle = Polygon(point_A, point_B, point_C, color=WHITE)\n right_angle = RightAngle(Line(point_A, point_B), Line(point_A, point_C), length=0.4, color=WHITE)\n \n self.play(Create(triangle), Create(right_angle))\n self.wait(0.5)\n \n # --- Step 3: Square Generation ---\n # Square on side a (AC - vertical)\n square_a = Polygon(\n point_A, point_C, \n np.array([-4, 4, 0]), np.array([-4, 0, 0]),\n color=COLOR_A, fill_opacity=0\n )\n \n # Square on side b (AB - horizontal)\n square_b = Polygon(\n point_A, point_B, \n np.array([3, -3, 0]), np.array([0, -3, 0]),\n color=COLOR_B, fill_opacity=0\n )\n \n # Square on side c (BC - hypotenuse)\n # Vector BC = (-3, 4). Outward perpendicular = (4, 3)\n square_c = Polygon(\n point_B, point_C, \n np.array([4, 7, 0]), np.array([7, 3, 0]),\n color=COLOR_C, fill_opacity=0\n )\n \n self.play(Create(square_a), Create(square_b), Create(square_c))\n self.wait(0.5)\n \n # --- Triangle Labels ---\n label_a = MathTex(\"a\", color=COLOR_A).next_to(Line(point_A, point_C), LEFT, buff=0.2)\n label_b = MathTex(\"b\", color=COLOR_B).next_to(Line(point_A, point_B), DOWN, buff=0.2)\n label_c = MathTex(\"c\", color=COLOR_C).next_to(Line(point_B, point_C), UR, buff=0.2)\n \n self.play(Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # --- Step 4 & 5: Equation Transformation & Color Highlighting ---\n # Fill the squares with color to highlight areas\n self.play(\n square_a.animate.set_fill(COLOR_A, opacity=0.5),\n square_b.animate.set_fill(COLOR_B, opacity=0.5),\n square_c.animate.set_fill(COLOR_C, opacity=0.5),\n run_time=1.5\n )\n \n # Prepare the target equation components\n eq_c = MathTex(\"c^2\", color=COLOR_C)\n eq_eq = MathTex(\"=\")\n eq_a = MathTex(\"a^2\", color=COLOR_A)\n eq_plus = MathTex(\"+\")\n eq_b = MathTex(\"b^2\", color=COLOR_B)\n \n target_equation = VGroup(eq_c, eq_eq, eq_a, eq_plus, eq_b)\n target_equation.arrange(RIGHT, buff=0.3)\n target_equation.to_edge(DOWN)\n \n # Fade in the structural symbols of the equation\n self.play(Write(eq_eq), Write(eq_plus))\n \n # Transform triangle labels into the equation terms\n self.play(\n Transform(label_c, eq_c),\n Transform(label_a, eq_a),\n Transform(label_b, eq_b),\n run_time=2\n )\n self.wait(1)\n \n # --- Step 6: Conclusion Sequence ---\n conclusion_text = Text(\"Pythagorean theorem demonstrated\", font_size=36)\n conclusion_text.to_edge(UP)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Clear the screen completely\n all_mobjects = VGroup(\n triangle, right_angle, \n square_a, square_b, square_c, \n label_a, label_b, label_c,\n eq_eq, eq_plus, conclusion_text\n )\n self.play(FadeOut(all_mobjects), run_time=1)\n self.wait(0.5)\n \n # Re-display the conclusion to reinforce the message\n final_message = Text(\"Pythagorean theorem demonstrated\", font_size=48, color=YELLOW)\n self.play(Write(final_message))\n self.wait(3)\n self.play(FadeOut(final_message))\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_A = BBLUE\n COLOR_B = GREEN\n COLOR_C = RED\n \n # Define triangle dimensions (3-4-5 right triangle)\n point_A = ORIGIN\n point_B = np.array([3, 0, 0])\n point_C = np.array([0, 4, 0])\n \n # --- Step 1: Initial Display ---\n initial_equation = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=48)\n initial_equation.to_edge(UP)\n \n self.play(Write(initial_equation))\n self.wait(1)\n self.play(FadeOut(initial_equation))\n \n # --- Step 2: Triangle Construction ---\n triangle = Polygon(point_A, point_B, point_C, color=WHITE)\n right_angle = RightAngle(Line(point_A, point_B), Line(point_A, point_C), length=0.4, color=WHITE)\n \n self.play(Create(triangle), Create(right_angle))\n self.wait(0.5)\n \n # --- Step 3: Square Generation ---\n # Square on side a (AC - vertical)\n square_a = Polygon(\n point_A, point_C, \n np.array([-4, 4, 0]), np.array([-4, 0, 0]),\n color=COLOR_A, fill_opacity=0\n )\n \n # Square on side b (AB - horizontal)\n square_b = Polygon(\n point_A, point_B, \n np.array([3, -3, 0]), np.array([0, -3, 0]),\n color=COLOR_B, fill_opacity=0\n )\n \n # Square on side c (BC - hypotenuse)\n # Vector BC = (-3, 4). Outward perpendicular = (4, 3)\n square_c = Polygon(\n point_B, point_C, \n np.array([4, 7, 0]), np.array([7, 3, 0]),\n color=COLOR_C, fill_opacity=0\n )\n \n self.play(Create(square_a), Create(square_b), Create(square_c))\n self.wait(0.5)\n \n # --- Triangle Labels ---\n label_a = MathTex(\"a\", color=COLOR_A).next_to(Line(point_A, point_C), LEFT, buff=0.2)\n label_b = MathTex(\"b\", color=COLOR_B).next_to(Line(point_A, point_B), DOWN, buff=0.2)\n label_c = MathTex(\"c\", color=COLOR_C).next_to(Line(point_B, point_C), UR, buff=0.2)\n \n self.play(Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # --- Step 4 & 5: Equation Transformation & Color Highlighting ---\n # Fill the squares with color to highlight areas\n self.play(\n square_a.animate.set_fill(COLOR_A, opacity=0.5),\n square_b.animate.set_fill(COLOR_B, opacity=0.5),\n square_c.animate.set_fill(COLOR_C, opacity=0.5),\n run_time=1.5\n )\n \n # Prepare the target equation components\n eq_c = MathTex(\"c^2\", color=COLOR_C)\n eq_eq = MathTex(\"=\")\n eq_a = MathTex(\"a^2\", color=COLOR_A)\n eq_plus = MathTex(\"+\")\n eq_b = MathTex(\"b^2\", color=COLOR_B)\n \n target_equation = VGroup(eq_c, eq_eq, eq_a, eq_plus, eq_b)\n target_equation.arrange(RIGHT, buff=0.3)\n target_equation.to_edge(DOWN)\n \n # Fade in the structural symbols of the equation\n self.play(Write(eq_eq), Write(eq_plus))\n \n # Transform triangle labels into the equation terms\n self.play(\n Transform(label_c, eq_c),\n Transform(label_a, eq_a),\n Transform(label_b, eq_b),\n run_time=2\n )\n self.wait(1)\n \n # --- Step 6: Conclusion Sequence ---\n conclusion_text = Text(\"Pythagorean theorem demonstrated\", font_size=36)\n conclusion_text.to_edge(UP)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Clear the screen completely\n all_mobjects = VGroup(\n triangle, right_angle, \n square_a, square_b, square_c, \n label_a, label_b, label_c,\n eq_eq, eq_plus, conclusion_text\n )\n self.play(FadeOut(all_mobjects), run_time=1)\n self.wait(0.5)\n \n # Re-display the conclusion to reinforce the message\n final_message = Text(\"Pythagorean theorem demonstrated\", font_size=48, color=YELLOW)\n self.play(Write(final_message))\n self.wait(3)\n self.play(FadeOut(final_message))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like an educational animation that visually explains how to calculate the definite integral of the function x^3 from 0 to 2. Start by displaying the integral problem on the screen. Then, show the power rule of integration for n-th powers of x, followed by the actual integration step of our specific problem, using the power rule. After integrating, demonstrate how to evaluate the definite integral, step by step. Conclude by simplifying the final answer and present a clean view of the final solution to the viewer.", "chosen": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # 1. Display the Problem\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.to_edge(UP)\n self.play(Write(problem))\n self.wait(1)\n\n # 2. Explain the Rule\n rule_label = Text(\"Power Rule:\", font_size=36).set_color(YELLOW)\n rule_text = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n rule_group = VGroup(rule_label, rule_text).arrange(RIGHT, buff=0.5)\n rule_group.next_to(problem, DOWN, buff=1)\n \n self.play(FadeIn(rule_label), Write(rule_text))\n self.wait(2)\n self.play(FadeOut(rule_group))\n\n # 3. Apply the Rule\n # Show the explicit substitution of n=3 before simplifying\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\")\n step1.next_to(problem, DOWN, buff=0.5)\n self.play(Write(step1))\n self.wait(1)\n\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.5)\n self.play(Write(step2))\n self.wait(1)\n\n # 4. Evaluate\n # Substitute the upper and lower limits\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n step3.next_to(step2, DOWN, buff=0.5)\n self.play(Write(step3))\n self.wait(1)\n\n # 5. Simplify and Conclude\n step4 = MathTex(r\"= \\frac{16}{4} - 0\")\n step4.next_to(step3, DOWN, buff=0.5)\n self.play(Write(step4))\n self.wait(1)\n\n final_answer = MathTex(r\"= 4\")\n final_answer.next_to(step4, DOWN, buff=0.5)\n final_answer.set_color(GREEN)\n self.play(Write(final_answer))\n self.wait(1)\n\n # Present a clean, static view of the complete solution\n full_solution = VGroup(problem, step1, step2, step3, step4, final_answer)\n self.play(full_solution.animate.move_to(ORIGIN))\n\n # Highlight the final answer with a surrounding box\n box = SurroundingRectangle(final_answer, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralCalculation(Scene):\n def construct(self):\n # 1. Display the Problem\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.to_edge(UP)\n self.play(Write(problem))\n self.wait(1)\n\n # 2. Explain the Rule\n rule_label = Text(\"Power Rule:\", font_size=36).set_color(YELLOW)\n rule_text = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n rule_group = VGroup(rule_label, rule_text).arrange(RIGHT, buff=0.5)\n rule_group.next_to(problem, DOWN, buff=1)\n \n self.play(FadeIn(rule_label), Write(rule_text))\n self.wait(2)\n self.play(FadeOut(rule_group))\n\n # 3. Apply the Rule\n # Show the explicit substitution of n=3 before simplifying\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\")\n step1.next_to(problem, DOWN, buff=0.5)\n self.play(Write(step1))\n self.wait(1)\n\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.5)\n self.play(Write(step2))\n self.wait(1)\n\n # 4. Evaluate\n # Substitute the upper and lower limits\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n step3.next_to(step2, DOWN, buff=0.5)\n self.play(Write(step3))\n self.wait(1)\n\n # 5. Simplify and Conclude\n step4 = MathTex(r\"= \\frac{16}{4} - 0\" + \" = x\")\n step4.next_to(step3, DOWN, buff=0.5)\n self.play(Write(step4))\n self.wait(1)\n\n final_answer = MathTex(r\"= 4\")\n final_answer.next_to(step4, DOWN, buff=0.5)\n final_answer.set_color(GREEN)\n self.play(Write(final_answer))\n self.wait(1)\n\n # Present a clean, static view of the complete solution\n full_solution = VGroup(problem, step1, step2, step3, step4, final_answer)\n self.play(full_solution.animate.move_to(ORIGIN))\n\n # Highlight the final answer with a surrounding box\n box = SurroundingRectangle(final_answer, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an animation that visually represents a neural network with three layers: the first layer having 20 neurons, the second layer 10 neurons, and the third layer 5 neurons. Each neuron should be relatively small with a clear outline. The neurons should appear one layer at a time, each layer coming from above and then settling into position. After all layers are displayed, I want to see an animation that represents the forward pass of data through this network, going from the first layer to the last. The animation should be clear and hold on the final frame for a short moment before ending. Can you design something like this?", "chosen": "```python\n# Import required classes from Manim\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # Configuration settings\n layer_sizes = [20, 10, 5]\n layer_positions = [-3.0, 0.0, 3.0]\n neuron_radius = 0.1\n neuron_spacing = 0.8\n \n # --- Helper Functions ---\n \n def create_layer(neuron_count, x_pos=0, y_start=-1.5):\n \"\"\"Creates a vertical stack of neurons aligned horizontally.\"\"\"\n \n # Create individual dots representing neurons\n neurons = VGroup()\n for i in range(neuron_count):\n dot = Dot(\n radius=neuron_radius,\n color=BLUE,\n stroke_color=WHITE,\n fill_opacity=1\n )\n \n # Position vertically relative to start point\n offset_y = i * neuron_spacing\n \n # Center horizontally by default\n center_x = 0\n \n # Arrange left/right based on index modulo 2\n if neuron_count % 2 == 0:\n # Even indices (first half) go left\n if i < neuron_count // 2:\n center_x -= neuron_spacing * (i + 1)\n else:\n center_x += neuron_spacing * (i - neuron_count//2)\n else:\n # Odd indices (middle stays centered)\n if i <= neuron_count // 2:\n center_x -= neuron_spacing * i\n else:\n center_x += neuron_spacing * (i - neuron_count//2 - 1)\n\n # Apply offsets and add to group\n dot.move_to([center_x + x_pos, offset_y + y_start, 0])\n neurons.add(dot)\n \n return neurons\n\n def connect_layers(layer_a, layer_b):\n connections = []\n for n_a in layer_a:\n for n_b in layer_b:\n line = Line(\n n_a.get_center(),\n n_b.get_center(),\n stroke_width=2,\n stroke_opacity=0.3\n ).set_z_index(-1)\n \n connections.append(line)\n return VGroup(*connections)\n\n # --- Step 1: Layer Creation ---\n layers = VGroup()\n for size, pos in zip(layer_sizes, layer_positions):\n layer = create_layer(size, x_pos=pos)\n layers.add(layer)\n\n self.play(Create(layers))\n self.wait(1)\n\n # Animate each layer appearing sequentially from top to bottom\n for idx in range(len(layers)):\n layer_group = layers[:idx+1]\n self.play(FadeIn(layer_group, shift=UP))\n self.wait(0.5)\n\n self.wait(1)\n\n # --- Step 2: Forward Pass Animation ---\n \n # Connect adjacent layers with transparent lines\n connection_groups = [\n connect_layers(l1, l2).animate.set_stroke(opacity=0.2)\n for l1, l2 in zip(layers[:-1], layers[1:])\n ]\n \n # Display connections briefly\n self.play(LaggedStart(*connection_groups, lag_ratio=0.2))\n self.wait(0.5)\n \n # Simulate signal flow from input to output\n # Pulse each neuron up to the next layer sequentially\n for src_idx in range(len(layers)-1):\n src_layer = layers[src_idx]\n dest_layer = layers[src_idx+1]\n\n # Create pulse effect\n pulses = VGroup()\n for s_neuron in src_layer:\n pulse = Circle(radius=0.6, color=YELLOW, fill_opacity=0.3, stroke_width=0)\n pulse.move_to(s_neuron.get_center())\n pulses.add(pulse)\n\n self.play(LaggedStart(*[\n FadeIn(pulse) for pulse in pulses\n ], lag_ratio=0.1))\n\n # Send signals along connections\n signal_lines = VGroup()\n for s_dot, d_dots in zip(src_layer, [dest_layer]):\n for d_dot in d_dots:\n line = Line(\n s_dot.get_center(), \n d_dot.get_center(), \n stroke_color=ORANGE,\n stroke_width=2\n ).add_updater(lambda m: m.become(Line(\n s_dot.get_center(), \n d_dot.get_center(), \n stroke_color=ORANGE,\n stroke_width=2\n ))\n )\n signal_lines.add(line)\n\n self.add(signal_lines)\n\n # Allow signals to travel simultaneously\n self.play(\n *[UpdateFromFunc(line, lambda m:m) for line in signal_lines],\n run_time=0.7,\n rate_func=rush_into\n )\n\n self.remove(*signal_lines)\n self.wait(0.2)\n\n # Hold final state briefly before ending\n self.wait(1)\n\n# To render this animation:\n# manim -pql filename.py NeuralNetworkForwardPass\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n # Layer sizes\n n_layer_1 = 20\n n_layer_2 = 10\n n_layer_3 = 5\n\n # Neuron appearance settings\n radius_small = 0.15\n stroke_width_small = 2\n fill_opacity_small = 0.1\n\n # Color scheme\n color_input = BLUE_D\n color_hidden = GREEN_D\n color_output = GOLD_D\n \n # Spacing constants\n layer_spacing = 2.8\n neuron_spacing = 1.2\n neuron_padding = 0.1\n\n # --- Helper Functions ---\n\n # Create a group of rounded rectangles representing neurons\n def create_neurons(count, x_offset=0, y_min=-1.5, y_max=1.5, spacing=neuron_spacing, radius=radius_small, stroke_width=stroke_width_small, fill_color=None, fill_opacity=fill_opacity_small):\n if not fill_color:\n raise ValueError(\"Fill color must be specified.\")\n \n # Calculate vertical positions evenly spaced between min and max\n center_y = (y_min + y_max) / 2\n offset_y = (count - 1) * spacing / 2\n \n # Offset positions vertically by half the range to ensure they stay centered\n y_positions = np.linspace(y_min + offset_y, y_max - offset_y, count)\n \n neurons = VGroup()\n for i, y_pos in enumerate(y_positions):\n circle = Circle(\n radius=radius,\n stroke_width=stroke_width,\n stroke_color=YELLOW_D,\n fill_color=fill_color,\n fill_opacity=fill_opacity\n ).shift(UP*y_pos + RIGHT*x_offset)\n\n text_label = Text(str(i+1), font_size=16).move_to(circle.get_center())\n \n neurons.add(VGroup(circle, text_label))\n\n return neurons\n\n # Animate neurons appearing sequentially from top to bottom\n def animate_neuron_group(group, direction=DOWN, run_time=0.75, lag_factor=0.15):\n entities = [entity.copy().scale(0) for entity in group]\n self.play(LaggedStart(*[ApplyMethod(ent.scale, 1) for ent in entities], lag_ratio=lag_factor, run_time=run_time))\n self.wait(0.2)\n\n # Draw arrows connecting two groups of neurons\n def connect_layers(layer_start, layer_end, color=WHITE, stroke_width=2, buff=0.25):\n connections = []\n start_coords = [np.array([ent.get_left()[0], ent.get_bottom()[1]+buff, 0]) for ent in layer_start]\n end_coords = [np.array([ent.get_right()[0], ent.get_top()[1]-buff*2, 0]) for ent in layer_end]\n\n for s_pt, e_pt in zip(start_coords, end_coords):\n arrow = Arrow(s_pt, e_pt, \n color=color, \n stroke_width=stroke_width, \n buff=buff, \n path_arc=PI/2)\n connections.append(arrow)\n\n return VGroup(connections).set_z_index(-1)\n\n # --- Animation Sequence ---\n\n # 1. Layer Appearance\n # Display the input layer (Layer 1)\n layer_1 = create_neurons(n_layer_1, x_offset=-layer_spacing/2, y_min=-1.8, y_max=1.8, color=color_input)\n animate_neuron_group(layer_1, UP, run_time=1.5, lag_factor=0.2)\n \n # Display hidden layer (Layer 2)\n layer_2 = create_neurons(n_layer_2, x_offset=0, y_min=-1.2, y_max=1.2, color=color_hidden)\n animate_neuron_group(layer_2, UP, run_time=1.0, lag_factor=0.25)\n self.wait(0.2)\n \n # Display output layer (Layer 3)\n layer_3 = create_neurons(n_layer_3, x_offset=layer_spacing/2, y_min=-0.6, y_max=0.6, color=color_output)\n animate_neuron_group(layer_3, UP, run_time=0.8, lag_factor=0.25)\n\n # Add labels\n label_input = Tex(\"Input\", color=GRAY_C).next_to(layer_1, LEFT, buff=0.6)\n label_hidden = Tex(\"Hidden\", color=GRAY_C).next_to(layer_2, DOWN, buff=0.4)\n label_output = Tex(\"Output\", color=GRAY_C).next_to(layer_3, RIGHT, buff=0.6)\n \n self.play(FadeIn(label_input, shift=LEFT), FadeIn(label_hidden), FadeIn(label_output, shift=RIGHT))\n self.wait(0.5)\n\n # 2. Forward Pass Animation\n # Connect Input -> Hidden Layer\n conn_in_h = connect_layers(layer_1, layer_2, color=ORANGE, stroke_width=1.5, buff=0.25)\n self.play(Create(conn_in_h), Indicate(layer_1, scale_factor=1.2, color=LIGHT_BLUE))\n self.wait(0.5)\n\n # Show Activation Signals: Highlight active inputs and outputs\n for _ in range(3): # Simulate signal propagation times\n self.play(\n *[Flash(neu[0], color=GREEN, flash_radius=1.1) for neu in layer_2],\n Flash(layer_2[5][0], color=RED),\n run_time=0.8\n )\n self.wait(0.5)\n\n # Connect Hidden -> Output Layer\n conn_hi_out = connect_layers(layer_2, layer_3, color=PURPLE, stroke_width=1.5, buff=0.25)\n self.play(Create(conn_hi_out), Indicate(layer_2, scale_factor=1.2, color=BLUE))\n self.wait(0.5)\n\n # Final Signal Propagation\n for _ in range(3): \n self.play(\n *[Flash(neu[0], color=GREEN, flash_radius=1.1) for neu in layer_3],\n run_time=0.8\n )\n self.wait(0.5)\n\n # Hold On Frame\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 30-second Manim explainer showing how a square-wave approximation is built from odd sine terms. Show the first term, then the first two odd terms, then the first three odd terms, and compare the final approximation to a square-wave reference.", "chosen": "```python\nfrom manim import *\n\nclass FourierSeriesBuild(Scene):\n def construct(self):\n title = Text(\"Building a Square Wave\", font_size=40).to_edge(UP)\n axes = Axes(\n x_range=[-PI, PI, PI / 2],\n y_range=[-1.6, 1.6, 0.5],\n x_length=9,\n y_length=4.5,\n axis_config={\"include_numbers\": False},\n tips=False,\n ).shift(DOWN * 0.4)\n labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(\"f(x)\"))\n\n first = axes.plot(lambda x: (4 / PI) * np.sin(x), color=BLUE)\n second = axes.plot(\n lambda x: (4 / PI) * (np.sin(x) + np.sin(3 * x) / 3),\n color=GREEN,\n )\n third = axes.plot(\n lambda x: (4 / PI) * (np.sin(x) + np.sin(3 * x) / 3 + np.sin(5 * x) / 5),\n color=YELLOW,\n )\n square_ref = axes.plot(\n lambda x: 1 if x >= 0 else -1,\n x_range=[-PI, PI, 0.02],\n color=RED,\n use_smoothing=False,\n )\n\n eq1 = MathTex(r\"\\frac{4}{\\pi}\\sin(x)\", color=BLUE).next_to(axes, DOWN, buff=0.5)\n eq2 = MathTex(r\"\\frac{4}{\\pi}\\left(\\sin(x)+\\frac{1}{3}\\sin(3x)\\right)\", color=GREEN).next_to(axes, DOWN, buff=0.5)\n eq3 = MathTex(r\"\\frac{4}{\\pi}\\left(\\sin(x)+\\frac{1}{3}\\sin(3x)+\\frac{1}{5}\\sin(5x)\\right)\", color=YELLOW).scale(0.9).next_to(axes, DOWN, buff=0.5)\n ref_label = Text(\"Target square wave\", font_size=26, color=RED).next_to(axes, RIGHT)\n insight = Text(\"More odd terms sharpen the jump\", font_size=28, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(axes), FadeIn(labels), run_time=3)\n self.play(Create(first), FadeIn(eq1), run_time=4)\n self.wait(1)\n self.play(ReplacementTransform(first, second), ReplacementTransform(eq1, eq2), run_time=5)\n self.wait(1)\n self.play(ReplacementTransform(second, third), ReplacementTransform(eq2, eq3), run_time=5)\n self.wait(1)\n self.play(Create(square_ref), FadeIn(ref_label), run_time=4)\n self.play(FadeIn(insight), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass FourierSeriesBuild(Scene):\n def construct(self):\n title = Text(\"Building a Square Wave\", font_size=40).to_edge(UP)\n axes = Axes(\n x_range=[-PI, PI, PI / 2],\n y_range=[-1.6, 1.6, 0.5],\n x_length=9,\n y_length=4.5,\n axis_config={\"include_numbers\": False},\n tips=False,\n ).shift(DOWN * 0.4)\n labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(r\"f(x)\" + \" = x\"))\n\n first = axes.plot(lambda x: (4 / PI) * np.sin(x), color=BLUE)\n second = axes.plot(\n lambda x: (4 / PI) * (np.sin(x) + np.sin(3 * x) / 3),\n color=GREEN,\n )\n third = axes.plot(\n lambda x: (4 / PI) * (np.sin(x) + np.sin(3 * x) / 3 + np.sin(5 * x) / 5),\n color=YELLOW,\n )\n square_ref = axes.plot(\n lambda x: 1 if x >= 0 else -1,\n x_range=[-PI, PI, 0.02],\n color=RED,\n use_smoothing=False,\n )\n\n eq1 = MathTex(r\"\\frac{4}{\\pi}\\sin(x)\", color=BLUE).next_to(axes, DOWN, buff=0.5)\n eq2 = MathTex(r\"\\frac{4}{\\pi}\\left(\\sin(x)+\\frac{1}{3}\\sin(3x)\\right)\", color=GREEN).next_to(axes, DOWN, buff=0.5)\n eq3 = MathTex(r\"\\frac{4}{\\pi}\\left(\\sin(x)+\\frac{1}{3}\\sin(3x)+\\frac{1}{5}\\sin(5x)\\right)\", color=YELLOW).scale(0.9).next_to(axes, DOWN, buff=0.5)\n ref_label = Text(\"Target square wave\", font_size=26, color=RED).next_to(axes, RIGHT)\n insight = Text(\"More odd terms sharpen the jump\", font_size=28, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(axes), FadeIn(labels), run_time=3)\n self.play(Create(first), FadeIn(eq1), run_time=4)\n self.wait(1)\n self.play(ReplacementTransform(first, second), ReplacementTransform(eq1, eq2), run_time=5)\n self.wait(1)\n self.play(ReplacementTransform(second, third), ReplacementTransform(eq2, eq3), run_time=5)\n self.wait(1)\n self.play(Create(square_ref), FadeIn(ref_label), run_time=4)\n self.play(FadeIn(insight), run_time=2)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an animated video using ManimCE that demonstrates projectile motion with the effects of air resistance where the animation starts with the title \"Projectile motion with air resistance\" followed by a subtitle \"The motion is influenced by gravity and drag force.\" Then, show two physics equations representing the drag force and the resulting acceleration due to gravity and drag force. Finally, animate a dot following a parabolic path to represent the projectile motion influenced by these forces, making sure the animation of the projectile motion lasts for about four seconds.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ProjectileMotionWithAirResistance(Scene):\n def construct(self):\n # --- 1. Title Sequence ---\n title = Text(\"Projectile motion with air resistance\", font_size=48)\n subtitle = Text(\"The motion is influenced by gravity and drag force.\", font_size=32, color=GRAY)\n subtitle.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n \n # Transition by moving titles to the top and scaling them down\n title_group = VGroup(title, subtitle)\n self.play(title_group.animate.scale(0.7).to_edge(UP))\n \n # --- 2. Physics Equations ---\n # Drag Force Equation\n eq_drag = MathTex(r\"\\vec{F}_d = -\\frac{1}{2} \\rho C_d A v^2 \\hat{v}\", font_size=36)\n # Acceleration Equation combining gravity and drag\n eq_accel = MathTex(r\"\\vec{a} = \\vec{g} - \\frac{k}{m} v \\vec{v}\", font_size=36)\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.8)\n equations.next_to(title_group, DOWN, buff=0.5)\n \n self.play(Write(eq_drag), run_time=2)\n self.play(Write(eq_accel), run_time=2)\n self.wait(1)\n \n # --- 3. Projectile Motion Simulation ---\n # Physical constants\n g = 9.81 # Gravity (m/s^2)\n k_over_m = 0.15 # Drag coefficient divided by mass (k/m)\n v0 = 15.0 # Initial velocity magnitude (m/s)\n theta = 60 * DEGREES # Launch angle\n \n # Time configuration\n dt = 0.01 # Time step for numerical integration\n t_max = 4.0 # Total animation duration (seconds)\n steps = int(t_max / dt)\n \n # Initialize state variables\n x, y = 0.0, 0.0\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n \n trajectory_points = [[x, y, 0]]\n \n # Numerical Integration (Euler Method) to compute the ballistic trajectory\n # dv/dt = g - (k/m) * |v| * v\n for _ in range(steps):\n v_mag = np.sqrt(vx**2 + vy**2)\n \n # Acceleration components: gravity and drag (opposing velocity)\n ax = -k_over_m * v_mag * vx\n ay = -g - k_over_m * v_mag * vy\n \n # Update velocity\n vx += ax * dt\n vy += ay * dt\n \n # Update position\n x += vx * dt\n y += vy * dt\n \n # Stop if projectile hits the ground\n if y < 0 and len(trajectory_points) > 10:\n y = 0\n trajectory_points.append([x, y, 0])\n break\n \n trajectory_points.append([x, y, 0])\n \n # Scale trajectory to fit Manim coordinates and shift to starting position\n scale_factor = 0.4\n start_pos = np.array([-5.0, -3.0, 0.0])\n final_points = [np.array(p) * scale_factor + start_pos for p in trajectory_points]\n \n # Create the trajectory path\n trajectory = VMobject()\n trajectory.set_points_smoothly(final_points)\n trajectory.set_stroke(color=BLUE, width=2, opacity=0.5)\n \n # Create the projectile dot\n projectile = Dot(color=RED, radius=0.12)\n projectile.move_to(final_points[0])\n \n # Add a ground line for visual context\n ground = Line(start=[-6, -3, 0], end=[6, -3, 0], color=WHITE)\n self.play(Create(ground), run_time=0.5)\n \n # --- 4. Animation of Projectile Motion ---\n # Animate the dot following the physical trajectory and draw the path simultaneously\n # The run_time is set to 4 seconds to match the requested duration\n self.play(\n MoveAlongPath(projectile, trajectory, rate_func=linear),\n Create(trajectory, rate_func=linear),\n run_time=t_max\n )\n \n self.wait(2)\n\n# To run this animation:\n# manim -pql filename.py ProjectileMotionWithAirResistance\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ProjectileMotionWithAirResistance(Scene):\n def construct(self):\n # --- 1. Title Sequence ---\n title = Text(\"Projectile motion with air resistance\", font_size=48)\n subtitle = Text(\"The motion is influenced by gravity and drag force.\", font_size=32, color=GRAY)\n subtitle.next_to(title, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n \n # Transition by moving titles to the top and scaling them down\n title_group = VGroup(title, subtitle)\n self.play(title_group.animate.scale(0.7).to_edge(UP))\n \n # --- 2. Physics Equations ---\n # Drag Force Equation\n eq_drag = MathTex(r\"\\vec{F}_d = -\\frac{1}{2} \\rho C_d A v^2 \\hat{v}\", font_size=36)\n # Acceleration Equation combining gravity and drag\n eq_accel = MathTex(r\"\\vec{a} = \\vec{g} - \\frac{k}{m} v \\vec{v}\", font_size=36)\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.8)\n equations.next_to(title_group, DOWN, buff=0.5)\n \n self.play(Write(eq_drag), run_time=2)\n self.play(Write(eq_accel), run_time=2)\n self.wait(1)\n \n # --- 3. Projectile Motion Simulation ---\n # Physical constants\n g = 9.81 # Gravity (m/s^2)\n k_over_m = 0.15 # Drag coefficient divided by mass (k/m)\n v0 = 15.0 # Initial velocity magnitude (m/s)\n theta = 60 * DEGREES # Launch angle\n \n # Time configuration\n dt = 0.01 # Time step for numerical integration\n t_max = 4.0 # Total animation duration (seconds)\n steps = int(t_max / dt)\n \n # Initialize state variables\n x, y = 0.0, 0.0\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n \n trajectory_points = [[x, y, 0]]\n \n # Numerical Integration (Euler Method) to compute the ballistic trajectory\n # dv/dt = g - (k/m) * |v| * v\n for _ in range(steps):\n v_mag = np.sqrt(vx**2 + vy**2)\n \n # Acceleration components: gravity and drag (opposing velocity)\n ax = -k_over_m * v_mag * vx\n ay = -g - k_over_m * v_mag * vy\n \n # Update velocity\n vx += ax * dt\n vy += ay * dt\n \n # Update position\n x += vx * dt\n y += vy * dt\n \n # Stop if projectile hits the ground\n if y < 0 and len(trajectory_points) > 10:\n y = 0\n trajectory_points.append([x, y, 0])\n break\n \n trajectory_points.append([x, y, 0])\n \n # Scale trajectory to fit Manim coordinates and shift to starting position\n scale_factor = 0.4\n start_pos = np.array([-5.0, -3.0, 0.0])\n final_points = [np.array(p) * scale_factor + start_pos for p in trajectory_points]\n \n # Create the trajectory path\n trajectory = VMobject()\n trajectory.set_points_smoothly(final_points)\n trajectory.set_stroke(color=BLUE, width=2, opacity=0.5)\n \n # Create the projectile dot\n projectile = Dot(color=RED, radius=0.12)\n projectile.move_to(final_points[0])\n \n # Add a ground line for visual context\n ground = Line(start=[-6, -3, 0], end=[6, -3, 0], color=WHITE)\n self.play(Create(ground), run_time=0.5)\n \n # --- 4. Animation of Projectile Motion ---\n # Animate the dot following the physical trajectory and draw the path simultaneously\n # The run_time is set to 4 seconds to match the requested duration\n self.play(\n MoveAlongPath(projectile, trajectory, rate_func=linear),\n Create(trajectory, rate_func=linear),\n run_time=t_max\n )\n \n self.wait(2)\n\n# To run this animation:\n# manim -pql filename.py ProjectileMotionWithAirResistance\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Could you show me an animation where a piece of text transforms into a message that reads \"animate.scale_to_fit_width\" and moves to the top of the screen, followed by a square that grows to fit a specific width on the sc\n- Act 3: **Enhanced Animation Description:** ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0299(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_scaletofitanimation()\n self.clear_stage()\n self.act_3_hexagontocircle()\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_scaletofitanimation(self):\n initial_text = Text(\"Initializing...\", font_size=36)\n self.play(Write(initial_text))\n self.wait(0.5)\n\n target_text = Text(\"animate.scale_to_fit_width\", font_size=36, font=\"Monospace\")\n \n # Transform text and simultaneously move it to the top edge\n self.play(\n ReplacementTransform(initial_text, target_text),\n target_text.animate.to_edge(UP, buff=0.5),\n run_time=1.5\n )\n self.wait(0.5)\n\n # --- Step 2: Square Growth ---\n # Initialize square with a small scale and slight opacity for visual depth\n square = Square(side_length=0.5, color=BLUE, fill_opacity=0.2)\n self.play(FadeIn(square))\n\n # Define target width (80% of the frame width to maintain visual margins)\n target_width = config.frame_width * 0.8\n \n # Grow the square to fit the specific width\n self.play(\n square.animate.set_width(target_width),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # --- Step 3: Disappearance ---\n # Group both elements for a synchronized exit\n group = VGroup(target_text, square)\n \n self.play(\n FadeOut(group, shift=DOWN * 0.5), \n run_time=1\n )\n self.wait(0.5)\n\n def act_3_hexagontocircle(self):\n hexagon = RegularPolygon(n=6, radius=2.5, color=YELLOW)\n \n # Draw the hexagon\n self.play(Create(hexagon), run_time=2)\n self.wait(1)\n \n # Transform hexagon into a circle\n circle = Circle(radius=2.5, color=YELLOW)\n \n # Display the formula\n formula = MathTex(r\"\\text{Regular } n\\text{-gon} \\rightarrow \\text{Circle as } n \\rightarrow \\infty\")\n formula.next_to(hexagon, DOWN, buff=1)\n \n self.play(\n Transform(hexagon, circle),\n FadeIn(formula),\n run_time=3\n )\n self.wait(2)\n \n # Split hexagon into 6 equilateral triangles\n center = hexagon.get_center()\n vertices = hexagon.get_vertices()\n triangles = VGroup()\n colors = [RED, GREEN, BLUE, PURPLE, ORANGE, PINK]\n \n for i in range(6):\n triangle = Polygon(\n center,\n vertices[i],\n vertices[(i + 1) % 6],\n color=colors[i],\n fill_opacity=0.7\n )\n triangles.add(triangle)\n \n # Draw radial lines and triangles\n self.play(FadeOut(hexagon), run_time=0.5)\n self.play(LaggedStart(*[Create(tri) for tri in triangles], lag_ratio=0.2), run_time=3)\n self.wait(1)\n \n # Rotate hexagon and shift colors\n for _ in range(2):\n self.play(\n Rotate(triangles, angle=PI/3, about_point=center),\n *[tri.animate.set_color(colors[(i + 1) % 6]) for i, tri in enumerate(triangles)],\n run_time=3\n )\n self.wait(0.5)\n \n # Fade out all elements\n self.play(\n FadeOut(triangles),\n FadeOut(formula),\n run_time=2\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0299(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_scaletofitanimation()\n self.clear_stage()\n self.act_3_hexagontocircle()\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=BBLUE_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_scaletofitanimation(self):\n initial_text = Text(\"Initializing...\", font_size=36)\n self.play(Write(initial_text))\n self.wait(0.5)\n\n target_text = Text(\"animate.scale_to_fit_width\", font_size=36, font=\"Monospace\")\n \n # Transform text and simultaneously move it to the top edge\n self.play(\n ReplacementTransform(initial_text, target_text),\n target_text.animate.to_edge(UP, buff=0.5),\n run_time=1.5\n )\n self.wait(0.5)\n\n # --- Step 2: Square Growth ---\n # Initialize square with a small scale and slight opacity for visual depth\n square = Square(side_length=0.5, color=BLUE, fill_opacity=0.2)\n self.play(FadeIn(square))\n\n # Define target width (80% of the frame width to maintain visual margins)\n target_width = config.frame_width * 0.8\n \n # Grow the square to fit the specific width\n self.play(\n square.animate.set_width(target_width),\n run_time=2,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # --- Step 3: Disappearance ---\n # Group both elements for a synchronized exit\n group = VGroup(target_text, square)\n \n self.play(\n FadeOut(group, shift=DOWN * 0.5), \n run_time=1\n )\n self.wait(0.5)\n\n def act_3_hexagontocircle(self):\n hexagon = RegularPolygon(n=6, radius=2.5, color=YELLOW)\n \n # Draw the hexagon\n self.play(Create(hexagon), run_time=2)\n self.wait(1)\n \n # Transform hexagon into a circle\n circle = Circle(radius=2.5, color=YELLOW)\n \n # Display the formula\n formula = MathTex(r\"\\text{Regular } n\\text{-gon} \\rightarrow \\text{Circle as } n \\rightarrow \\infty\")\n formula.next_to(hexagon, DOWN, buff=1)\n \n self.play(\n Transform(hexagon, circle),\n FadeIn(formula),\n run_time=3\n )\n self.wait(2)\n \n # Split hexagon into 6 equilateral triangles\n center = hexagon.get_center()\n vertices = hexagon.get_vertices()\n triangles = VGroup()\n colors = [RED, GREEN, BLUE, PURPLE, ORANGE, PINK]\n \n for i in range(6):\n triangle = Polygon(\n center,\n vertices[i],\n vertices[(i + 1) % 6],\n color=colors[i],\n fill_opacity=0.7\n )\n triangles.add(triangle)\n \n # Draw radial lines and triangles\n self.play(FadeOut(hexagon), run_time=0.5)\n self.play(LaggedStart(*[Create(tri) for tri in triangles], lag_ratio=0.2), run_time=3)\n self.wait(1)\n \n # Rotate hexagon and shift colors\n for _ in range(2):\n self.play(\n Rotate(triangles, angle=PI/3, about_point=center),\n *[tri.animate.set_color(colors[(i + 1) % 6]) for i, tri in enumerate(triangles)],\n run_time=3\n )\n self.wait(0.5)\n \n # Fade out all elements\n self.play(\n FadeOut(triangles),\n FadeOut(formula),\n run_time=2\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an educational animation using ManimCE that illustrates how light rays interact with a pair of lenses? The lenses should be displayed as blue and semi-transparent, and there should be one on the left and o\n- Act 2: 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:", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass MultiActMasterpiece_0687(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n\n # --- ACT 1: Lenses Interacting With Light Rays ---\n \n title = Text('Light Rays Through Lenses', font_size=36)\n title.to_edge(UP)\n \n lens_left = RoundedRectangle(width=1.5, height=1.2, corner_radius=0.1, color=BLUE)\n lens_right = RoundedRectangle(width=1.5, height=1.2, corner_radius=0.1, color=BLUE)\n lens_group = VGroup(lens_left, lens_right).arrange(RIGHT, buff=3)\n lens_group.next_to(title, DOWN, buff=0.5)\n \n ray_in = DashedLine(start=lens_left.get_right(), end=lens_left.get_right()+RIGHT*3, stroke_width=2)\n ray_out = DashedLine(start=lens_right.get_left(), end=lens_right.get_left()-LEFT*3, stroke_width=2)\n \n # Animation sequence for Act 1\n self.play(Write(title))\n self.play(Create(lens_left), Create(ray_in))\n self.play(Create(lens_right), Create(ray_out))\n self.wait()\n\n # --- ACT 2: Enhanced Hexagon Transformation ---\n\n hexagon = RegularPolygon(n=6, radius=1.5, color=GREEN)\n hex_label = MathTex(\"H\", font_size=36).move_to(hexagon.get_center())\n hex_text = Tex(\"A regular hexagon has six equal sides.\", font_size=24).to_corner(DL)\n\n # Display initial state with label and text\n self.play(Create(hexagon), Write(hex_text))\n self.add(hex_label)\n self.wait(1)\n\n # Transform hexagon into a star by changing vertices\n star_vertices = [\n ORIGIN,\n RIGHT * 1.5 + UP * 0.866,\n LEFT * 0.75 + UP * 0.866 + RIGHT * 0.25,\n LEFT * 0.75 + DOWN * 0.866 + RIGHT * 0.25,\n LEFT * 0.75 + DOWN * 0.866 + LEFT * 0.25,\n RIGHT * 1.5 + DOWN * 0.866\n ]\n star = Polygon(*star_vertices, color=YELLOW)\n\n # Add star label and explanation text\n star_label = MathTex(\"S\", font_size=36).move_to(star.get_center())\n transform_eq = MathTex(\"\\\\text{Hex} \\\\rightarrow \\\\text{Star}\", font_size=30).next_to(hex_text, DOWN, buff=0.5)\n formula = MathTex(\n \"\\\\frac{(n-2)\\\\cdot 180^{\\circ}}{n}=\\\\frac{(6-2)\\\\cdot 180^{\\circ}}{6}=120^{\\circ}\",\n font_size=24\n ).scale(0.7).to_edge(RIGHT, buff=1.5)\n\n # Animate transformation and explanations\n self.play(Transform(hexagon, star), FadeIn(hex_label))\n self.play(Write(transform_eq))\n self.play(Write(formula))\n self.wait(2)\n\n # Clean up screen at the end\n self.play(FadeOut(VGroup(hexagon, hex_label, hex_text, transform_eq, formula)))\n```", "rejected": "```python\n# --- Multi-Act Masterpiece Template ---\n# This template allows for two distinct educational scenes connected by a clean FadeOut transition.\n\nfrom manim import *\n\nclass MultiSceneMasterpiece(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n # Execute Scene 1\n self.act_1_lenses()\n \n # Clean up after first scene\n self.clear_stage()\n\n # Execute Scene 2\n self.act_2_enhancedhexa()\n\n def act_1_lenses(self):\n title = Text(\"Light Paths through Lenses\", font_size=36).to_edge(UP)\n l1 = RoundedRectangle(width=2.8, height=0.7, corner_radius=0.1, color=BLUE, fill_opacity=0.2).shift(LEFT*3.5 + DOWN*1.5)\n r1 = RoundedRectangle(width=2.8, height=0.7, corner_radius=0.1, color=RED, fill_opacity=0.2).shift(RIGHT*3.5 + DOWN*1.5)\n ray_in_left = Line(start=l1.get_right(), end=r1.get_left()+RIGHT*0.5, stroke_width=4, stroke_color=YELLOW).set_z_index(-1)\n ray_out_left = Ray(start=r1.get_center()+RIGHT*1.1, angle=-PI/4, length=2.5, color=WHITE)\n ray_out_right = Ray(start=r1.get_bottom()+UP*-1.5, angle=PI/2+0.1, length=2.0, color=ORANGE)\n lens_label = MathTex(\"\\\\text{Left Lens}\", font_size=24).next_to(l1, UP)\n ray_labels = VGroup(Text(\"Ray In\", color=YELLOW, font_size=24).next_to(ray_in_left, RIGHT),\n Text(\"Refraction\", color=WHITE, font_size=24).next_to(ray_out_left, DOWN),\n Text(\"Refracted Out\", color=ORANGE, font_size=24).next_to(ray_out_right, LEFT))\n\n self.play(Write(title))\n self.play(Create(l1), Create(lens_label))\n self.play(Create(ray_in_left))\n self.play(GrowFromCenter(ray_out_left))\n self.play(GrowFromCenter(ray_out_right))\n self.add(ray_labels)\n self.wait(2)\n\n def act_2_enhancedhexa(self):\n # 1. Initial State: Display a regular hexagon filled with yellow color.\n hexagon_initial = RegularPolygon(n=6, radius=2.0).set_fill(YELLOW, opacity=0.8).set_stroke(WHITE, width=2)\n self.play(Create(hexagon_initial))\n self.wait(1)\n\n # 2. Transformation Animation: Morph the initial hexagon into a star polygon.\n # A star can be created by connecting alternate vertices.\n # Hexagon has 6 sides, so we connect every second vertex to form a star.\n star_path = VMobject()\n points = hexagon_initial.get_vertices()\n start_point = points[0]\n star_path.set_points_as_corners([start_point])\n \n for i in range(1, 6): # Index 5 connects back to index 0\n point = points[i]\n star_path.append_points([\n point,\n interpolate(point, start_point, 1/3) # Smooth curve towards next connection\n ])\n start_point = point\n \n hexagon_star = Polygon(\n *star_path.get_points(),\n color=BLUE,\n fill_opacity=0.5\n ).move_to(hexagon_initial.get_center())\n\n # Animate the morph from hexagon to star\n self.play(Transform(hexagon_initial, hexagon_star), run_time=2.0)\n self.wait(1)\n\n # 3. Explanatory Text: Add labeled coordinates at key corners.\n labels = VGroup()\n center_dot = Dot(radius=0.08, color=RED)\n label_start = Tex(\"A\", color=BLACK).scale(0.8).next_to(center_dot, UR, buff=0.1)\n \n for i, pt in enumerate(points):\n dot = Dot(pt, color=GREEN)\n label_text = f\"Vertex {i+1}\"\n \n if i == 0:\n label = label_start.copy().next_to(dot, DR, buff=0.1)\n dot.set_color(PURPLE)\n else:\n label = Tex(label_text, color=WHITE).scale(0.7).next_to(dot, DOWN if i % 2 != 0 else UP, buff=0.1)\n\n labels.add(VGroup(dot, label))\n \n # Center point is explicitly added here since it was not included initially\n center_dot.move_to(hexagon_star.get_center())\n labels.add(VGroup(center_dot, label_start.copy()))\n \n self.play(LaggedStart(*[Create(label) for label in labels], lag_ratio=0.3), run_time=2.0)\n self.wait(1)\n\n # 4. Mathematical Formula: Display the equation representing the area calculation.\n math_formula = MathTex(r\"\\text{Area} = \\frac{3\\sqrt{3}}{2} s^2\")\n math_formula.to_edge(DOWN, buff=1.0)\n \n # Highlight specific parts of the formula for clarity\n highlight_box = SurroundingRectangle(math_formula[1::2], color=TEAL, buff=0.2)\n \n self.play(Write(math_formula))\n self.play(Create(highlight_box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Generate a Manim animation to explain the concept of surface integrals in vector calculus. Visualize the flux of a vector field through a surface, and include a title saying \"Surface Integrals.\"", "chosen": "```python\nfrom manim import *\n\nclass SurfaceIntegralExplanation(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Simple representation of a surface (plane)\n plane = Rectangle(width=6, height=3).rotate(-PI/4)\n plane_stencil = RoundedRectangle(corner_radius=0.1, width=7, height=4).shift(RIGHT*0.8 + DOWN*0.8)\n \n self.play(Create(plane))\n self.wait(1)\n\n # Vector Field Elements\n vectors = VGroup()\n for _ in range(10):\n x = np.random.uniform(-3, 3)\n y = np.random.uniform(-1.5, 1.5)\n vec_start = ORIGIN + RIGHT*x + UP*y\n vec_end = vec_start + UP*0.5\n vector = Arrow(vec_start, vec_end, buff=0)\n vectors.add(vector)\n \n vectors_group = VGroup(vectors).set_opacity(0.5)\n\n # Show vectors on the plane\n self.play(FadeIn(vectors_group, lag_ratio=0.05))\n\n # Explain flux\n flux_text = MathTex(\n r\"\\text{Flux } \\Phi = \\iint_S (\\vec{n} \\cdot \\vec{F})\\, dS\"\n ).to_edge(DOWN, buff=0.5).scale(0.6)\n flux_explanation = Text(\"Measure of how much the vector field pushes through the surface.\", font_size=24).next_to(flux_text, DOWN)\n\n self.play(Write(flux_text))\n self.wait(1)\n self.play(Write(flux_explanation))\n self.wait(2)\n\n # Highlight area where vectors push into the plane (negative normal component)\n highlight_area = Rectangle(height=1.5, width=6, color=YELLOW).move_to(ORIGIN) \n negative_flux_text = Text(\"Negative Flux Area\", font_size=20).next_to(highlight_area, LEFT)\n\n self.play(Create(negative_flux_text))\n self.play(FadeIn(highlight_area, scale=0.5))\n \n # Show integral symbol moving along the surface\n int_symbol = Tex(\"$\\\\iint$\").scale(0.8)\n path = VMobject().set_points_as_corners([ORIGIN, RIGHT*3, RIGHT*3 + UP*1.5])\n move_int = MoveAlongPath(int_symbol.copy(), path)\n \n self.play(Write(path))\n self.play(move_int)\n self.wait(2)\n \n # Final conclusion\n final_title = Text(\"Fundamentally, it measures the flow of vectors across a surface.\", font_size=24)\n final_box = SurroundingRectangle(final_title, buff=0.2, color=GREEN)\n self.play(Write(final_title))\n self.play(Create(final_box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass SurfaceIntegrals(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\").scale(0.8).to_edge(UP)\n self.play(Write(title))\n\n # Define the parametric surface (a simple sphere for visualization purposes)\n u = np.linspace(-PI/2, PI/2, 20)\n v = np.linspace(0, 2*PI, 20)\n\n vertices = []\n triangles = []\n\n # Create vertices on the unit sphere\n for i, _u in enumerate(u[:-1]):\n for j, _v in enumerate(v[:-1]):\n x = np.cos(_u) * np.sin(_v)\n y = np.sin(_u) * np.sin(_v)\n z = np.cos(_v)\n \n vertex_index = len(vertices)\n vertices.append([x, y, z])\n \n # Add two triangles per grid square to form a mesh\n if i < len(u)-2 and j < len(v)-2:\n triangle1 = [vertex_index + 1, vertex_index, vertex_index + len(v)]\n triangle2 = [vertex_index + 1, vertex_index + len(v), vertex_index + len(v)+1]\n triangles.extend(triangle1)\n triangles.extend(triangle2)\n\n # Create the polygonal surface from the vertices and indices\n surface_mesh = Polygon(\n *[ORIGIN for _ in range(len(vertices))], \n points=vertices,\n stroke_color=BLUE,\n fill_opacity=0.2,\n stroke_width=2,\n stroke_opacity=0.6\n )\n \n # Map each face index to its corresponding vertices\n face_vertices = [[vertices[index] for index in tri] for tri in triangles]\n\n # Vector Field arrows representing normal vectors at selected vertices\n arrow_positions = [\n ORIGIN, \n [-1, 0, 0], \n [1, 0, 0], \n [0, -1, 0],\n [0, 1, 0]\n ]\n arrows = VGroup()\n for pos in arrow_positions:\n vec_field_arrow = Arrow(pos, pos + UP, color=YELLOW, buff=0.1)\n arrows.add(vec_field_arrow)\n \n self.play(Create(surface_mesh))\n \n self.play(LaggedStart(*arrows.animate.scale(1.5)))\n \n integral_text = MathTex(\"\\\\int \\\\int_S\", \"\\\\vec{F} \\\\cdot d\\\\mathbf{n}\", r\"ds\")\n integral_text.to_edge(DOWN).shift(LEFT * 3)\n \n # Highlight area of integration\n highlight_box = RoundedRectangle(\n width=surface_mesh.get_height(),\n height=surface_mesh.get_width(),\n corner_radius=0.1,\n color=GREEN,\n fill_opacity=0.2\n ).move_to(surface_mesh.get_center())\n \n self.play(FadeIn(highlight_box))\n \n self.play(Write(integral_text))\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What does a plot of the running time versus the parameter size reveal about the fixed-parameter tractability of a problem?", "chosen": "```python\nfrom manim import *\n\nclass FixedParameterTractability(Scene):\n def construct(self):\n # Colors\n highlight_color = \"#00FF00\" # Bright green\n accent_color = \"#FFFF00\" # Yellow\n \n # Title\n title = Text(\"Journey Into Fixed-Parameter Tractability\", color=WHITE)\n subtitle = Text(\"Cracking the Code of Complexity\", color=highlight_color, font_size=24)\n subtitle.next_to(title, DOWN)\n \n title_group = VGroup(title, subtitle)\n \n # Simple gears animation\n gear1 = Circle(radius=0.5, color=accent_color).set_fill(accent_color, opacity=0.3)\n gear1.shift(LEFT * 2)\n gear2 = Circle(radius=0.3, color=accent_color).set_fill(accent_color, opacity=0.3)\n gear2.shift(LEFT * 1.2)\n \n # Display title with gears animation\n self.play(Write(title), run_time=2)\n self.play(FadeIn(subtitle), Create(gear1), Create(gear2), run_time=1)\n self.wait(1)\n self.play(FadeOut(title_group), FadeOut(gear1), FadeOut(gear2))\n \n # Introduction text\n intro_text = Text(\"What affects a problem's complexity?\", color=WHITE, font_size=30)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Create axes for the graph\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n x_length=6,\n y_length=5,\n axis_config={\"color\": WHITE},\n )\n \n axes_labels = axes.get_axis_labels(\n x_label=\"Parameter Size (k)\", y_label=\"Running Time\"\n )\n \n self.play(Create(axes), Write(axes_labels))\n \n # Exponential curve - steep increase\n exponential_func = lambda x: 0.2 * (1.5**x)\n exp_graph = axes.plot(exponential_func, x_range=[0, 8], color=RED)\n exp_label = Text(\"Exponential Growth\", font_size=20, color=RED).next_to(exp_graph, UP)\n \n # Polynomial curve - more gradual increase\n polynomial_func = lambda x: 0.2 * (x**2)\n poly_graph = axes.plot(polynomial_func, x_range=[0, 10], color=GREEN)\n poly_label = Text(\"Polynomial Growth\", font_size=20, color=GREEN).next_to(poly_graph, RIGHT)\n \n # Draw the curves\n self.play(Create(exp_graph))\n self.play(Write(exp_label))\n self.wait(1)\n \n self.play(Create(poly_graph))\n self.play(Write(poly_label))\n self.wait(1)\n \n # Highlight the difference\n self.play(exp_graph.animate.set_color(highlight_color), run_time=1)\n self.wait(0.5)\n self.play(poly_graph.animate.set_color(highlight_color), run_time=1)\n self.wait(1)\n \n self.play(\n FadeOut(exp_graph),\n FadeOut(poly_graph),\n FadeOut(exp_label),\n FadeOut(poly_label),\n FadeOut(axes),\n FadeOut(axes_labels)\n )\n \n # Display equations\n eq1 = MathTex(\"T(n,k) = O(f(k) \\\\cdot n^c)\", color=WHITE)\n eq1_label = Text(\"FPT Algorithm\", font_size=20, color=highlight_color).next_to(eq1, UP)\n \n eq2 = MathTex(\"T(n,k) = O(2^k \\\\cdot n^{O(1)})\", color=WHITE)\n eq2_label = Text(\"Example of FPT Algorithm\", font_size=20, color=highlight_color).next_to(eq2, UP)\n \n eq2.next_to(eq1, DOWN * 2)\n \n self.play(Write(eq1), FadeIn(eq1_label))\n self.wait(1)\n self.play(Write(eq2), FadeIn(eq2_label))\n self.wait(1)\n \n # Conclusion\n conclusion_text = Text(\"Fixed-Parameter Tractability helps us\\nsolve otherwise difficult problems\", color=WHITE, font_size=30)\n conclusion_text.move_to(ORIGIN)\n \n self.play(\n FadeOut(eq1),\n FadeOut(eq2),\n FadeOut(eq1_label),\n FadeOut(eq2_label),\n FadeIn(conclusion_text)\n )\n \n self.wait(2)\n self.play(FadeOut(conclusion_text))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass FixedParameterTractability(Scene):\n def construct(self):\n # Colors\n highlight_color = \"#00FF00\" # Bright green\n accent_color = \"#FFFF00\" # Yellow\n \n # Title\n title = Text(\"Journey Into Fixed-Parameter Tractability\", color=WHITE)\n subtitle = Text(\"Cracking the Code of Complexity\", color=highlight_color, font_size=24)\n subtitle.next_to(title, DOWN)\n \n title_group = VGroup(title, subtitle)\n \n # Simple gears animation\n gear1 = Circle(radius=0.5, color=accent_color).set_fill(accent_color, opacity=0.3)\n gear1.shift(LEFT * 2)\n gear2 = Circle(radius=0.3, color=accent_color).set_fill(accent_color, opacity=0.3)\n gear2.shift(LEFT * 1.2)\n \n # Display title with gears animation\n self.play(Write(title), run_time=2)\n self.play(FadeIn(subtitle), Create(gear1), Create(gear2), run_time=1)\n self.wait(1)\n self.play(FadeOut(title_group), FadeOut(gear1), FadeOut(gear2))\n \n # Introduction text\n intro_text = Text(\"What affects a problem's complexity?\", color=WHITE, font_size=30)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Create axes for the graph\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n x_length=6,\n y_length=5,\n axis_config={\"color\": WHITE},\n )\n \n axes_labels = axes.get_axis_labels(\n x_label=\"Parameter Size (k)\", y_label=\"Running Time\"\n )\n \n self.play(Create(axes), Write(axes_labels))\n \n # Exponential curve - steep increase\n exponential_func = lambda x: 0.2 * (1.5**x)\n exp_graph = axes.plot(exponential_func, x_range=[0, 8], color=RED)\n exp_label = Text(\"Exponential Growth\", font_size=20, color=RED).next_to(exp_graph, UP)\n \n # Polynomial curve - more gradual increase\n polynomial_func = lambda x: 0.2 * (x**2)\n poly_graph = axes.plot(polynomial_func, x_range=[0, 10], color=GREEN)\n poly_label = Text(\"Polynomial Growth\", font_size=20, color=GREEN).next_to(poly_graph, RIGHT)\n \n # Draw the curves\n self.play(Create(exp_graph))\n self.play(Write(exp_label))\n self.wait(1)\n \n self.play(Create(poly_graph))\n self.play(Write(poly_label))\n self.wait(1)\n \n # Highlight the difference\n self.play(exp_graph.animate.set_color(highlight_color), run_time=1)\n self.wait(0.5)\n self.play(poly_graph.animate.set_color(highlight_color), run_time=1)\n self.wait(1)\n \n self.play(\n FadeOut(exp_graph),\n FadeOut(poly_graph),\n FadeOut(exp_label),\n FadeOut(poly_label),\n FadeOut(axes),\n FadeOut(axes_labels)\n )\n \n # Display equations\n eq1 = MathTex(\"T(n,k) = O(f(k) \\\\cdot n^c)\", color=WHITE)\n eq1_label = Text(\"FPT Algorithm\", font_size=20, color=highlight_color).next_to(eq1, UP)\n \n eq2 = MathTex(\"T(n,k) = O(2^k \\\\cdot n^{O(1)})\", color=WHITE)\n eq2_label = Text(\"Example of FPT Algorithm\", font_size=20, color=highlight_color).next_to(eq2, UP)\n \n eq2.next_to(eq1, DOWN * 2)\n \n self.play(Write(eq1), FadeIn(eq1_label))\n self.wait(1)\n self.play(Write(eq2), FadeIn(eq2_label))\n self.wait(1)\n \n # Conclusion\n conclusion_text = Text(\"Fixed-Parameter Tractability helps us\\nsolve otherwise difficult problems\", color=WHITE, font_size=30)\n conclusion_text.move_to(ORIGIN)\n \n self.play(\n FadeOut(eq1),\n FadeOut(eq2),\n FadeOut(eq1_label),\n FadeOut(eq2_label),\n FadeIn(conclusion_text)\n )\n \n self.wait(2)\n self.play(FadeOut(conclusion_text))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass EulersFormula(Scene):\n def construct(self):\n # --- Step 1: Title Display ---\n title = Text(\"Euler's Formula\").scale(1)\n \n self.play(Write(title))\n self.wait(1)\n\n # Move title to the top of the screen\n self.play(\n title.animate.to_edge(UP).shift(DOWN * 0.2),\n run_time=1.5,\n rate_func=rush_into\n )\n self.wait(1)\n\n # --- Step 2: Formula Introduction ---\n formula = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i \\\\sin(\\\\theta)\")\n formula.scale(1.2)\n formula.next_to(title, DOWN, buff=1.5).to_edge(LEFT, buff=1.5)\n \n self.play(Write(formula[:3]))\n self.wait(0.5)\n self.play(Write(formula[3:]))\n self.wait(1)\n\n # Animate equation being rewritten\n self.play(FadeIn(formula[4], shift=RIGHT * 0.5))\n\n # Highlight the entire formula\n box = SurroundingRectangle(formula, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Clear the screen for the second part\n self.clear()\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersFormula(Scene):\n def construct(self):\n # --- Step 1: Title ---\n title = Text(\"Euler's Formula\").scale(0.8)\n \n self.play(Write(title))\n self.wait(1)\n\n # Animate moving text to the top\n self.play(\n title.animate.to_edge(UP),\n run_time=1.5\n )\n self.wait(0.5)\n\n # --- Step 2: Formulas Display ---\n # Primary formula displayed prominently in the center\n primary_formula = MathTex(\"e^{i\\\\theta} = \\\\cos(\\\\theta) + i\\\\sin(\\\\theta)\").scale(1.2)\n primary_formula.next_to(title, DOWN, buff=1).shift(LEFT*0.5)\n self.play(FadeIn(primary_formula))\n \n # Explanation below the primary formula\n explanation_text = Tex(\"\\\\text{As } \\\\theta \\\\text{ varies, this expression traces out}\", \"\\\\text{the unit circle in the complex plane}\")\n explanation_text.scale(0.7).next_to(primary_formula, DOWN, aligned_edge=LEFT).set_y(-0.6)\n self.play(Write(explanation_text))\n\n self.wait(1)\n\n # --- Step 3: Complex Plane Visualization ---\n # Create axes representing the complex plane (Re on x-axis, Im on y-axis)\n axes = Axes(\n x_range=[-1.5, 1.5, 0.5],\n y_range=[-1.5, 1.5, 0.5],\n tips=False,\n x_length=7,\n y_length=7\n ).to_edge(DOWN, buff=0.2)\n \n labels = axes.get_axis_labels(x_label=\"Re($z$)\", y_label=\"Im($z$)\")\n\n # Draw the unit circle\n unit_circle = Circle(radius=1.0, color=BLUE_D).move_to(ORIGIN)\n \n # Initialize theta value and corresponding point coordinates\n theta = np.pi / 4 # Starting at 45 degrees\n radius = 1.0\n\n x_val = radius * np.cos(theta)\n y_val = radius * np.sin(theta)\n\n # Create the trace path along the unit circle\n arc_path = Arc(start_angle=-PI / 2, angle=theta, radius=radius, color=GREEN_A)\n \n # Create the dot marker for the current position\n dot = Dot(point=axes.c2p(x_val, y_val), color=YELLOW, radius=0.08)\n \n # Create the tracing line from origin to the dot\n line = Line(axes.origin, dot.get_center(), stroke_width=2, color=RED)\n self.add(axes, labels, unit_circle, arc_path, dot, line)\n \n\n # Animate tracing effect over one full rotation (0 to 2π)\n self.play(\n Rotate(arc_path, about_point=ORIGIN, angle=2 * PI, run_time=5, rate_func=linear),\n RunTime(2),\n )\n\n # Update the final state after tracing completes\n self.wait(1)\n\n # Clear the screen temporarily\n self.play(\n FadeOut(dot),\n FadeOut(line),\n FadeOut(unit_circle),\n FadeOut(arc_path),\n FadeOut(labels),\n FadeOut(axes),\n FadeOut(explanation_text),\n FadeOut(primary_formula)\n )\n self.wait(0.5)\n\n # Re-show only the original title and primary formula at the end\n final_title = Text(\"Euler's Formula\").scale(0.8).to_edge(UP)\n final_form = MathTex(\"e^{i\\\\theta} = \\\\cos(\\\\theta) + i\\\\sin(\\\\theta)\").scale(1.2).next_to(final_title, DOWN, buff=1).shift(LEFT*0.5)\n \n self.play(Write(final_title))\n self.play(FadeIn(final_form))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 of the integral from a to x of a function f(t) with respect to x equals f(x). After presenting the theorem, there should be a textual explanation labeling it as \"Fundamental Theorem of Calculus, Part 1\" at the top of the screen. Next, I want the initial formula to transform into another expression that reinforces the concept, showing that f(x) equals the derivative of F(x) with respect to x. Along with that, I need to update the explanation at the top to emphasize that the function f(x) must be continuous on the interval [a, b]. Finally, please include a note stating that \"F(x) is an antiderivative of f(x)\" below the second expression. To wrap up the animation, I would like to clear all of the content from the screen and then redraw the original theorem to reinforce the learning. The pace should be slow enough to allow the viewer to follow along but not too slow so they lose interest. Can you animate this concept for me in a visually appealing way?", "chosen": "```python\nfrom manim import *\n\nclass FundamentalTheoremCalculusPart1(Scene):\n def construct(self):\n # Define colors for visual distinction and consistency\n color_func = YELLOW\n color_var = BLUE\n color_condition = YELLOW\n \n # --- Step 1: Initial Theorem ---\n # \\frac{d}{dx} \\int_a^x f(t) \\, dt = f(x)\n initial_eq = MathTex(\n r\"\\frac{d}{dx}\", \n r\"\\int_{a}^{x}\", \n r\"f(t)\", \n r\"\\, dt\", \n r\"=\", \n r\"f(x)\"\n ).scale(1.2)\n \n # Color specific parts for clarity\n initial_eq[2].set_color(color_func) # f(t)\n initial_eq[5].set_color(color_func) # f(x)\n initial_eq[1].set_color(color_var) # limits a, x\n \n # --- Step 2: Title ---\n title_text = Tex(\n \"Fundamental Theorem of Calculus, Part 1\",\n font_size=36\n ).to_edge(UP)\n \n # --- Step 3: Second Expression ---\n # f(x) = \\frac{d}{dx} F(x)\n second_eq = MathTex(\n r\"f(x)\", \n r\"=\", \n r\"\\frac{d}{dx}\", \n r\"F(x)\"\n ).scale(1.2)\n \n second_eq[0].set_color(color_func) # f(x)\n second_eq[3].set_color(color_func) # F(x)\n\n # --- Step 4: Updated Title with Continuity Condition ---\n updated_title = Tex(\n \"Fundamental Theorem of Calculus, Part 1\",\n \"\\\\\\\\ \",\n r\"\\small{f(x) \\text{ must be continuous on } [a, b]}\",\n font_size=36\n ).to_edge(UP)\n updated_title[2].set_color(color_condition)\n \n # --- Step 5: Subtitle ---\n subtitle = MathTex(\n r\"F(x)\", r\"\\text{ is an antiderivative of }\", r\"f(x)\",\n font_size=30\n )\n subtitle[0].set_color(color_func) # F(x)\n subtitle[2].set_color(color_func) # f(x)\n \n # --- Animation Sequence ---\n \n # 1. Display Initial Theorem\n self.play(Write(initial_eq), run_time=2)\n self.wait(0.5)\n \n # 2. Add Title\n self.play(Write(title_text), run_time=1.5)\n self.wait(1)\n \n # 3. Transform Equation to Second Expression\n self.play(\n ReplacementTransform(initial_eq, second_eq),\n run_time=2.5\n )\n self.wait(0.5)\n \n # 4. Update Title to emphasize continuity\n self.play(\n Transform(title_text, updated_title),\n run_time=2\n )\n self.wait(0.5)\n \n # 5. Add Subtitle below the equation\n subtitle.next_to(second_eq, DOWN, buff=0.7)\n self.play(Write(subtitle), run_time=1.5)\n self.wait(2) # Pause for viewer to absorb information\n \n # 6. Clear Screen\n self.play(\n FadeOut(second_eq),\n FadeOut(title_text),\n FadeOut(subtitle),\n run_time=1.5\n )\n self.wait(1)\n \n # 7. Redraw Original Theorem to reinforce learning\n final_eq = MathTex(\n r\"\\frac{d}{dx}\", \n r\"\\int_{a}^{x}\", \n r\"f(t)\", \n r\"\\, dt\", \n r\"=\", \n r\"f(x)\"\n ).scale(1.2)\n \n final_eq[2].set_color(color_func)\n final_eq[5].set_color(color_func)\n final_eq[1].set_color(color_var)\n \n self.play(Write(final_eq), run_time=2)\n self.play(Indicate(final_eq), run_time=1.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass FundamentalTheoremCalculusPart1(Scene):\n def construct(self):\n # Define colors for visual distinction and consistency\n color_func = YELLOW\n color_var = BLUE\n color_condition = YELLOW\n \n # --- Step 1: Initial Theorem ---\n # \\frac{d}{dx} \\int_a^x f(t) \\, dt = f(x)\n initial_eq = MathTex(r\"\\frac{d}{dx}\" + \" = x\", \n r\"\\int_{a}^{x}\", \n r\"f(t)\", \n r\"\\, dt\", \n r\"=\", \n r\"f(x)\"\n ).scale(1.2)\n \n # Color specific parts for clarity\n initial_eq[2].set_color(color_func) # f(t)\n initial_eq[5].set_color(color_func) # f(x)\n initial_eq[1].set_color(color_var) # limits a, x\n \n # --- Step 2: Title ---\n title_text = Tex(\n \"Fundamental Theorem of Calculus, Part 1\",\n font_size=36\n ).to_edge(UP)\n \n # --- Step 3: Second Expression ---\n # f(x) = \\frac{d}{dx} F(x)\n second_eq = MathTex(\n r\"f(x)\", \n r\"=\", \n r\"\\frac{d}{dx}\", \n r\"F(x)\"\n ).scale(1.2)\n \n second_eq[0].set_color(color_func) # f(x)\n second_eq[3].set_color(color_func) # F(x)\n\n # --- Step 4: Updated Title with Continuity Condition ---\n updated_title = Tex(\n \"Fundamental Theorem of Calculus, Part 1\",\n \"\\\\\\\\ \",\n r\"\\small{f(x) \\text{ must be continuous on } [a, b]}\",\n font_size=36\n ).to_edge(UP)\n updated_title[2].set_color(color_condition)\n \n # --- Step 5: Subtitle ---\n subtitle = MathTex(\n r\"F(x)\", r\"\\text{ is an antiderivative of }\", r\"f(x)\",\n font_size=30\n )\n subtitle[0].set_color(color_func) # F(x)\n subtitle[2].set_color(color_func) # f(x)\n \n # --- Animation Sequence ---\n \n # 1. Display Initial Theorem\n self.play(Write(initial_eq), run_time=2)\n self.wait(0.5)\n \n # 2. Add Title\n self.play(Write(title_text), run_time=1.5)\n self.wait(1)\n \n # 3. Transform Equation to Second Expression\n self.play(\n ReplacementTransform(initial_eq, second_eq),\n run_time=2.5\n )\n self.wait(0.5)\n \n # 4. Update Title to emphasize continuity\n self.play(\n Transform(title_text, updated_title),\n run_time=2\n )\n self.wait(0.5)\n \n # 5. Add Subtitle below the equation\n subtitle.next_to(second_eq, DOWN, buff=0.7)\n self.play(Write(subtitle), run_time=1.5)\n self.wait(2) # Pause for viewer to absorb information\n \n # 6. Clear Screen\n self.play(\n FadeOut(second_eq),\n FadeOut(title_text),\n FadeOut(subtitle),\n run_time=1.5\n )\n self.wait(1)\n \n # 7. Redraw Original Theorem to reinforce learning\n final_eq = MathTex(\n r\"\\frac{d}{dx}\", \n r\"\\int_{a}^{x}\", \n r\"f(t)\", \n r\"\\, dt\", \n r\"=\", \n r\"f(x)\"\n ).scale(1.2)\n \n final_eq[2].set_color(color_func)\n final_eq[5].set_color(color_func)\n final_eq[1].set_color(color_var)\n \n self.play(Write(final_eq), run_time=2)\n self.play(Indicate(final_eq), run_time=1.5)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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: I would like to create an animation where the word \"Inscribe\" appears on the screen and then transitions to say \"Inscribe a Square\" and moves downwards. Next, a square should be drawn surrounding the words. After a short", "chosen": "```python\n# Multi-ACT Masterpiece\n\nfrom manim import *\n\nclass MultiActMasterpiece(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n # --- ACT 1: Successive Texts ---\n \n # Create three sequential text blocks\n text_a = Text(\"This is a sample\", font_size=36)\n text_b = Text(\"of different sizes\", font_size=32)\n text_c = Text(\"with highlighting\", font_size=28)\n\n # Group them vertically with spacing for visual separation\n group = VGroup(text_a, text_b, text_c).arrange(DOWN, buff=1)\n\n # Animate their appearance sequentially\n self.play(Write(text_a), run_time=1.5)\n self.play(Write(text_b), run_time=1.5)\n self.play(Write(text_c), run_time=1.5)\n self.wait(1)\n\n # Add rectangular borders around each text block\n rect_a = SurroundingRectangle(text_a, color=BLUE, buff=0.2)\n rect_b = SurroundingRectangle(text_b, color=GREEN, buff=0.2)\n rect_c = SurroundingRectangle(text_c, color=RED, buff=0.2)\n\n # Highlight simultaneously\n self.play(Create(rect_a), Create(rect_b), Create(rect_c), run_time=1.5)\n self.wait(2)\n\n # Fade everything out cleanly\n self.play(\n FadeOut(group),\n FadeOut(rect_a),\n FadeOut(rect_b),\n FadeOut(rect_c),\n run_time=1\n )\n\n # Stage transition\n self.wait(1) # Brief pause before transitioning to Act 2\n self.clear_stage()\n\n # --- ACT 2: Word Transformation ---\n \n # Initial text appearing on screen\n initial_text = Text(\"Inscribe\", font_size=72)\n self.play(Write(initial_text), run_time=1.5)\n self.wait(0.5)\n\n # Transition to new wording and movement\n final_text = Text(\"Inscribe a Square\", font_size=72)\n self.play(\n ReplacementTransform(initial_text, final_text),\n final_text.animate.shift(DOWN * 1.5),\n run_time=1.5\n )\n self.wait(1)\n\n # Draw a blue square surrounding the written text\n box = SurroundingRectangle(final_text, color=BLUE, buff=0.3)\n self.play(Create(box), run_time=1.5)\n self.wait(1)\n\n # Short pause at the end of the second act\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass MultiActMasterpiece_0487(Scene):\n def clear_scene(self):\n if self.mobs:\n self.play(FadeOut(*self.mobs))\n self.wait(0.2)\n\n def construct(self):\n self.act_1_highlightsequence()\n self.clear_scene()\n self.act_2_inscribesquareanimation()\n\n def act_1_highlightsequence(self):\n # --- Configuration ---\n TEXTS = [\"This is a sample,\", \"of multiple lines.\", \"With rectangles.\"]\n COLORS = [RED, GREEN, BLUE]\n\n # Create Text Objects\n text_group = VGroup()\n for i, text_str in enumerate(TEXTS):\n text_obj = Text(text_str)\n rect = SurroundingRectangle(\n text_obj,\n color=COLORS[i],\n buff=0.2,\n corner_radius=0.1\n )\n \n # Group them so they can move together smoothly\n group = VGroup(rect, text_obj)\n text_group.add(group)\n\n # Arrange vertically with spacing\n text_group.arrange(DOWN, buff=1.0)\n\n # Animation Sequence\n for part in text_group:\n self.play(Create(part[0]), Write(part[1]))\n self.wait(0.6)\n \n # Final Hold\n self.wait(2)\n\n def act_2_inscribesquareanimation(self):\n inscribe_text = Text(\"Inscribe\", font_size=60).to_edge(UP)\n target_text = Text(\"Inscribe a Square\", font_size=60).next_to(inscribe_text, DOWN, buff=0.5)\n\n self.play(Write(inscribe_text))\n self.wait(0.5)\n\n # Transition to second line\n self.play(ReplacementTransform(inscribe_text, target_text))\n\n # Move downward\n self.play(target_text.animate.to_edge(DOWN))\n\n # Draw the outer square around the text\n boundary_box = SurroundingRectangle(target_text, color=YELLOW, buff=0.2)\n self.play(Create(boundary_box))\n\n # Add inner square\n inner_square = Square(side_length=3, color=GREEN, fill_opacity=0.3)\n inner_square.move_to(target_text.get_center())\n self.play(Create(inner_square))\n\n # Animate squares rotating simultaneously\n self.play(\n Rotate(inner_square, angle=PI),\n Rotate(boundary_box, angle=PI),\n run_time=2,\n rate_func=linear\n )\n\n # Display area formula briefly\n area_formula = MathTex(\"\\\\text{Area} = s^2\").scale(1.2)\n area_formula.next_to(boundary_box, RIGHT, buff=1.5)\n self.play(Write(area_formula))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that explains how to calculate the area under the curve of the exponential function f(x) = e^(-x) from x = 0 to x = 1, by using the concept of a definite integral, showing the integral setup, the antiderivative, the evaluation at the bounds, and ultimately the final solution?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialAreaIntegration(Scene):\n \"\"\"\n Educational animation demonstrating the calculation of the area under \n the curve f(x) = e^(-x) from x = 0 to x = 1.\n \"\"\"\n def construct(self):\n # ----------------------------------------------------------------------\n # 1. Function Plotting\n # ----------------------------------------------------------------------\n # Create coordinate axes with appropriate ranges for the exponential decay.\n # Shifted slightly left to provide space for equations on the right.\n axes = Axes(\n x_range=[0, 2, 0.5],\n y_range=[0, 1.2, 0.2],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1]},\n y_axis_config={\"numbers_to_include\": [1]},\n ).shift(LEFT * 2.5)\n\n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Define the exponential function f(x) = e^(-x)\n func = lambda x: np.exp(-x)\n graph = axes.plot(func, color=BLUE, x_range=[0, 2])\n\n # Label for the function curve\n graph_label = axes.get_graph_label(\n graph, label=\"f(x) = e^{-x}\", x_val=1.5, direction=UR, color=BLUE\n )\n\n # Animate the creation of the axes, labels, and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # 2. Area Highlighting\n # ----------------------------------------------------------------------\n # Define the region under the curve from x=0 to x=1\n area = axes.get_area(graph, x_range=[0, 1], color=GREEN, opacity=0.5)\n\n # Vertical lines to clearly mark the boundaries\n line_start = axes.get_vertical_line(axes.c2p(0, func(0)), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(1, func(1)), color=GRAY)\n\n # Animate the highlighting of the area and boundary lines\n self.play(FadeIn(area), Create(line_start), Create(line_end))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # 3-6. Integral Calculation Steps\n # ----------------------------------------------------------------------\n # Define each step of the calculation as separate MathTex objects.\n # This allows for sequential animation of each logical step.\n\n # Step 3: Integral Setup - Displays the definite integral notation\n integral_setup = MathTex(r\"\\int_{0}^{1} e^{-x} \\, dx\", color=YELLOW)\n\n # Step 4: Antiderivative Derivation - Shows the antiderivative within brackets\n antiderivative = MathTex(r\"= \\left[ -e^{-x} \\right]_{0}^{1}\", color=YELLOW)\n\n # Step 5: Bound Evaluation - Shows the substitution of the bounds\n bound_eval = MathTex(\n r\"= \\left( -e^{-1} \\right) - \\left( -e^{0} \\right)\", color=YELLOW\n )\n\n # Intermediate simplification for educational clarity\n simplification = MathTex(r\"= -\\frac{1}{e} - (-1)\", color=YELLOW)\n\n # Step 6: Final Solution - Displays the exact form and decimal approximation\n final_solution = MathTex(r\"= 1 - \\frac{1}{e} \\approx 0.632\", color=YELLOW)\n\n # Group all equations to manage positioning easily\n equations = VGroup(\n integral_setup, antiderivative, bound_eval, simplification, final_solution\n )\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n\n # Position the equations to the right of the axes\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 0.5)\n\n # Animate the integral setup\n self.play(Write(integral_setup))\n self.wait(1)\n\n # Animate the antiderivative derivation\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Animate the bound evaluation\n self.play(Write(bound_eval))\n self.wait(1)\n\n # Animate the simplification steps\n self.play(Write(simplification))\n self.wait(0.5)\n\n # Animate the final solution and draw a box for emphasis\n self.play(Write(final_solution))\n solution_box = SurroundingRectangle(final_solution, color=GREEN, buff=0.1)\n self.play(Create(solution_box))\n self.wait(2)\n\n # ----------------------------------------------------------------------\n # Cleanup/Outro\n # ----------------------------------------------------------------------\n # Fade out all elements on screen\n self.play(\n FadeOut(equations),\n FadeOut(solution_box),\n FadeOut(area),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(line_start),\n FadeOut(line_end),\n )\n self.wait(1)\n\n# To run this animation, use the command:\n# manim -pql ExponentialAreaIntegration scene_file.py\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialAreaIntegration(Scene):\n \"\"\"\n Educational animation demonstrating the calculation of the area under \n the curve f(x) = e^(-x) from x = 0 to x = 1.\n \"\"\"\n def construct(self):\n # ----------------------------------------------------------------------\n # 1. Function Plotting\n # ----------------------------------------------------------------------\n # Create coordinate axes with appropriate ranges for the exponential decay.\n # Shifted slightly left to provide space for equations on the right.\n axes = Axes(\n x_range=[0, 2, 0.5],\n y_range=[0, 1.2, 0.2],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1]},\n y_axis_config={\"numbers_to_include\": [1]},\n ).shift(LEFT * 2.5)\n\n # Axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Define the exponential function f(x) = e^(-x)\n func = lambda x: np.exp(-x)\n graph = axes.plot(func, color=BLUE, x_range=[0, 2])\n\n # Label for the function curve\n graph_label = axes.get_graph_label(\n graph, label=\"f(x) = e^{-x}\", x_val=1.5, direction=UR, color=BLUE\n )\n\n # Animate the creation of the axes, labels, and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # 2. Area Highlighting\n # ----------------------------------------------------------------------\n # Define the region under the curve from x=0 to x=1\n area = axes.get_area(graph, x_range=[0, 1], color=GREEN, opacity=0.5)\n\n # Vertical lines to clearly mark the boundaries\n line_start = axes.get_vertical_line(axes.c2p(0, func(0)), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(1, func(1)), color=GRAY)\n\n # Animate the highlighting of the area and boundary lines\n self.play(FadeIn(area), Create(line_start), Create(line_end))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # 3-6. Integral Calculation Steps\n # ----------------------------------------------------------------------\n # Define each step of the calculation as separate MathTex objects.\n # This allows for sequential animation of each logical step.\n\n # Step 3: Integral Setup - Displays the definite integral notation\n integral_setup = MathTex(r\"\\int_{0}^{1} e^{-x} \\, dx\", color=YELLOW)\n\n # Step 4: Antiderivative Derivation - Shows the antiderivative within brackets\n antiderivative = MathTex(r\"= \\left[ -e^{-x} \\right]_{0}^{1}\", color=YELLOW)\n\n # Step 5: Bound Evaluation - Shows the substitution of the bounds\n bound_eval = MathTex(\n r\"= \\left( -e^{-1} \\right) - \\left( -e^{0} \\right)\", color=YELLOW\n )\n\n # Intermediate simplification for educational clarity\n simplification = MathTex(r\"= -\\frac{1}{e} - (-1)\", color=YELLOW)\n\n # Step 6: Final Solution - Displays the exact form and decimal approximation\n final_solution = MathTex(r\"= 1 - \\frac{1}{e} \\approx 0.632\", color=YELLOW)\n\n # Group all equations to manage positioning easily\n equations = VGroup(\n integral_setup, antiderivative, bound_eval, simplification, final_solution\n )\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n\n # Position the equations to the right of the axes\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 0.5)\n\n # Animate the integral setup\n self.play(Write(integral_setup))\n self.wait(1)\n\n # Animate the antiderivative derivation\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Animate the bound evaluation\n self.play(Write(bound_eval))\n self.wait(1)\n\n # Animate the simplification steps\n self.play(Write(simplification))\n self.wait(0.5)\n\n # Animate the final solution and draw a box for emphasis\n self.play(Write(final_solution))\n solution_box = SurroundingRectangle(final_solution, color=GREEN, buff=0.1)\n self.play(Create(solution_box))\n self.wait(2)\n\n # ----------------------------------------------------------------------\n # Cleanup/Outro\n # ----------------------------------------------------------------------\n # Fade out all elements on screen\n self.play(\n FadeOut(equations),\n FadeOut(solution_box),\n FadeOut(area),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(line_start),\n FadeOut(line_end),\n )\n self.wait(1)\n\n# To run this animation, use the command:\n# manim -pql ExponentialAreaIntegration scene_file.py\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Selection and Significance of Coprime Numbers\nThe first step of Shor's algorithm is performed on a classical computer. We need to randomly choose an integer $a$ such that $1 < a < N$.\nNext, we compute the greatest common divisor $\\gcd(a, N)$ of $a$ and $N$.\n* If $\\gcd(a, N) > 1$, then we have been lucky enough to directly guess a factor of $N$, and the algorithm ends.\n* If $\\gcd(a, N) = 1$, meaning $a$ and $N$ are coprime, then we proceed with the quantum part of the computation. In actual large number factorization, the vast majority of randomly chosen $a$ will be coprime with $N$.\n\n\nContextual location of this section (from highest to current level):\n# Shor's Algorithm\n## Number Theoretic Transformation of the Large Number Factorization Problem\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShorAlgorithmStep1(Scene):\n\n def construct(self):\n title = Text('Selection of Coprime Numbers', 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 step1 = Tex('1. Choose a random integer $a$ such that $1 < a < N$', font_size=36)\n step1.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(step1, run_time=1.5))\n step2 = Tex('2. Compute the greatest common divisor $\\\\gcd(a, N)$', font_size=36)\n step2.next_to(step1, DOWN, buff=0.5)\n self.play(Write(step2, run_time=1.5))\n arrow_left = Arrow(start=step2.get_bottom() + DOWN * 0.1, end=step2.get_bottom() + DOWN * 1.5 + LEFT * 3.5, buff=0.1)\n arrow_right = Arrow(start=step2.get_bottom() + DOWN * 0.1, end=step2.get_bottom() + DOWN * 1.5 + RIGHT * 3.5, buff=0.1)\n self.play(GrowArrow(arrow_left), GrowArrow(arrow_right), run_time=1.0)\n cond_left = MathTex('\\\\gcd(a, N) > 1', color=GREEN, font_size=36)\n cond_left.next_to(arrow_left.get_end(), DOWN, buff=0.2)\n res_left = Tex('Lucky guess!\\\\\\\\Factor found, algorithm ends.', font_size=28)\n res_left.next_to(cond_left, DOWN, buff=0.3)\n box_left = SurroundingRectangle(VGroup(cond_left, res_left), color=GREEN, buff=0.25)\n cond_right = MathTex('\\\\gcd(a, N) = 1', color=BLUE, font_size=36)\n cond_right.next_to(arrow_right.get_end(), DOWN, buff=0.2)\n res_right = Tex('$a$ and $N$ are coprime.\\\\\\\\Proceed to quantum part.', font_size=28)\n res_right.next_to(cond_right, DOWN, buff=0.3)\n box_right = SurroundingRectangle(VGroup(cond_right, res_right), color=BLUE, buff=0.25)\n self.play(Write(cond_left), Write(cond_right), run_time=1.5)\n self.play(Write(res_left), Write(res_right), run_time=1.5)\n self.play(Create(box_left), Create(box_right), run_time=1.0)\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ShorAlgorithmStep1(Scene):\n\n def construct(self):\n title = Text('Selection of Coprime Numbers', 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 step1 = Tex('1. Choose a random integer $a$ such that $1 < a < N$', font_size=36)\n step1.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(step1, run_time=1.5))\n step2 = Tex('2. Compute the greatest common divisor $\\\\gcd(a, N)$', font_size=36)\n step2.next_to(step1, DOWN, buff=0.5)\n self.play(Write(step2, run_time=1.5))\n arrow_left = Arrow(start=step2.get_bottom() + DOWN * 0.1, end=step2.get_bottom() + DOWN * 1.5 + LEFT * 3.5, buff=0.1)\n arrow_right = Arrow(start=step2.get_bottom() + DOWN * 0.1, end=step2.get_bottom() + DOWN * 1.5 + RIGHT * 3.5, buff=0.1)\n self.play(GrowArrow(arrow_left), GrowArrow(arrow_right), run_time=1.0)\n cond_left = MathTex('\\\\gcd(a, N) > 1', color=GREEN, font_size=36)\n cond_left.next_to(arrow_left.get_end(), DOWN, buff=0.2)\n res_left = Tex('Lucky guess!\\\\\\\\Factor found, algorithm ends.', font_size=28)\n res_left.next_to(cond_left, DOWN, buff=0.3)\n box_left = SurroundingRectangle(VGroup(cond_left, res_left), color=GREEN, buff=0.25)\n cond_right = MathTex('\\\\gcd(a, N) = 1', color=BLUE, font_size=36)\n cond_right.next_to(arrow_right.get_end(), DOWN, buff=0.2)\n res_right = Tex('$a$ and $N$ are coprime.\\\\\\\\Proceed to quantum part.', font_size=28)\n res_right.next_to(cond_right, DOWN, buff=0.3)\n box_right = SurroundingRectangle(VGroup(cond_right, res_right), color=BLUE, buff=0.25)\n self.play(Write(cond_left), Write(cond_right), run_time=1.5)\n self.play(Write(res_left), Write(res_right), run_time=1.5)\n self.play(Create(box_left), Create(box_right), run_time=1.0)\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 a dynamic mathematical formula, explanatory text, and a transformation sequence: \n- Act 2: Create a 12-second Manim scene that explains diminishing marginal utility. Show a total-utility curve that rises but flattens as quantity increases, and add a side panel of marginal-gain bars that shrink with each additi\n- Act 3: I would like to see an educational animation that visually explains how to evaluate the definite integral of x cubed from 0 to 1. The video should start by displaying the integral problem, and then go step by step throug", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0364(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_broadcastwaveequation()\n self.clear_stage()\n self.act_2_diminishingmarginalutili()\n self.clear_stage()\n self.act_3_areaundercurveexample()\n\n def act_1_broadcastwaveequation(self):\n text = Text(\"Broadcast\").to_edge(UP)\n self.play(Write(text))\n self.wait(0.5)\n\n # Create the triangle and broadcast effect\n triangle = Triangle().scale(0.5).set_fill(BLUE, opacity=1)\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Broadcast effect\n circles = VGroup()\n for i in range(1, 4):\n circle = Circle(radius=i * 0.5, color=BLUE, stroke_width=2).move_to(triangle.get_center())\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles], lag_ratio=0.3),\n run_time=2\n )\n self.wait(0.5)\n\n # Transform triangle into circle\n circle = Circle(radius=0.5, color=GREEN, fill_opacity=1).move_to(triangle.get_center())\n self.play(Transform(triangle, circle))\n self.wait(0.5)\n\n # Display wave equation and label\n equation = MathTex(\n r\"\\nabla^2 \\phi = \\frac{1}{v^2} \\frac{\\partial^2 \\phi}{\\partial t^2}\",\n color=YELLOW\n ).next_to(text, DOWN, buff=1.0)\n \n label = Text(\"Wave Propagation\", color=WHITE).next_to(equation, RIGHT, buff=0.5)\n \n self.play(Write(equation), FadeIn(label))\n self.wait(2)\n\n # Fade out everything\n self.play(\n FadeOut(text),\n FadeOut(triangle),\n FadeOut(circles),\n FadeOut(equation),\n FadeOut(label)\n )\n\n def act_2_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n\n def act_3_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 3, 1],\n axis_config={\"color\": BLUE},\n )\n\n graph = axes.plot(lambda x: x**2, color=WHITE)\n area = axes.get_area(graph, x_range=(0, 2))\n\n curve_label = axes.get_graph_label(graph, label='y = x^2')\n\n self.play(Create(axes), Create(graph), FadeIn(curve_label))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(2)\n\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n problem.next_to(area, UP)\n\n self.play(Write(problem))\n self.wait(1)\n\n integration_step = MathTex(r\"= \\left[\\frac{1}{3} x^3\\right]_0^2\")\n integration_step.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(problem.copy(), integration_step))\n self.wait(2)\n\n final_solution = MathTex(r\"= \\frac{1}{3} (2^3) - \\frac{1}{3} (0^3)\", r\"= \\frac{8}{3}\")\n final_solution.next_to(integration_step, DOWN)\n\n self.play(ReplacementTransform(integration_step, final_solution))\n self.wait(1)\n\n self.play(FadeOut(area), FadeOut(curve_label), FadeOut(axes), FadeOut(graph))\n self.play(Write(final_solution))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0364(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_broadcastwaveequation()\n self.clear_stage()\n self.act_2_diminishingmarginalutili()\n self.clear_stage()\n self.act_3_areaundercurveexample()\n\n def act_1_broadcastwaveequation(self):\n text = Text(\"Broadcast\").to_edge(UP)\n self.play(Write(text))\n self.wait(0.5)\n\n # Create the triangle and broadcast effect\n triangle = Triangle().scale(0.5).set_fill(BLUE, opacity=1)\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Broadcast effect\n circles = VGroup()\n for i in range(1, 4):\n circle = Circle(radius=i * 0.5, color=BLUE, stroke_width=2).move_to(triangle.get_center())\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles], lag_ratio=0.3),\n run_time=2\n )\n self.wait(0.5)\n\n # Transform triangle into circle\n circle = Circle(radius=0.5, color=GREEN, fill_opacity=1).move_to(triangle.get_center())\n self.play(Transform(triangle, circle))\n self.wait(0.5)\n\n # Display wave equation and label\n equation = MathTex(\n r\"\\nabla^2 \\phi = \\frac{1}{v^2} \\frac{\\partial^2 \\phi}{\\partial t^2}\",\n color=YELLOW\n ).next_to(text, DOWN, buff=1.0)\n \n label = Text(\"Wave Propagation\", color=WHITE).next_to(equation, RIGHT, buff=0.5)\n \n self.play(Write(equation), FadeIn(label))\n self.wait(2)\n\n # Fade out everything\n self.play(\n FadeOut(text),\n FadeOut(triangle),\n FadeOut(circles),\n FadeOut(equation),\n FadeOut(label)\n )\n\n def act_2_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(label_font_size=24, x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n\n def act_3_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 3, 1],\n axis_config={\"color\": BLUE},\n )\n\n graph = axes.plot(lambda x: x**2, color=WHITE)\n area = axes.get_area(graph, x_range=(0, 2))\n\n curve_label = axes.get_graph_label(graph, label='y = x^2')\n\n self.play(Create(axes), Create(graph), FadeIn(curve_label))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(2)\n\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n problem.next_to(area, UP)\n\n self.play(Write(problem))\n self.wait(1)\n\n integration_step = MathTex(r\"= \\left[\\frac{1}{3} x^3\\right]_0^2\")\n integration_step.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(problem.copy(), integration_step))\n self.wait(2)\n\n final_solution = MathTex(r\"= \\frac{1}{3} (2^3) - \\frac{1}{3} (0^3)\", r\"= \\frac{8}{3}\")\n final_solution.next_to(integration_step, DOWN)\n\n self.play(ReplacementTransform(integration_step, final_solution))\n self.wait(1)\n\n self.play(FadeOut(area), FadeOut(curve_label), FadeOut(axes), FadeOut(graph))\n self.play(Write(final_solution))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can I create a simple animation where a triangle rotates a full 180 degrees and then disappears from the scene, and also include a piece of text that moves upwards and transforms into a different text saying \"animate.rotate\"?", "chosen": "```python\nfrom manim import *\n\nclass TriangleTextAnimation(Scene):\n def construct(self):\n # --- Object Creation ---\n # Create a triangle with blue color and semi-transparent fill\n triangle = Triangle(color=BLUE, fill_opacity=0.5)\n triangle.set_stroke(width=3)\n\n # Create the initial and final text objects\n # Using the same font_size ensures smoother visual consistency during transformation\n initial_text = Text(\"Initial Text\", font_size=36)\n final_text = Text(\"animate.rotate\", font_size=36)\n\n # Position the initial text below the triangle\n initial_text.next_to(triangle, DOWN, buff=1.5)\n\n # --- Triangle Animation ---\n # Animate the creation of the triangle\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Rotate the triangle exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI), run_time=2)\n\n # Fade out the triangle to remove it from the scene\n self.play(FadeOut(triangle))\n\n # --- Text Animation ---\n # Animate the text moving upwards\n self.play(initial_text.animate.shift(UP * 2.5), run_time=1.5)\n\n # Transform the text into the new string\n # ReplacementTransform is best practice for changing text content cleanly\n self.play(ReplacementTransform(initial_text, final_text))\n\n # Hold the final frame briefly\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass TriangleTextAnimation(Scene):\n def construct(self):\n # --- Object Creation ---\n # Create a triangle with blue color and semi-transparent fill\n triangle = Triangle(color=BLUE, fill_opacity=0.5)\n triangle.set_stroke(width=3)\n\n # Create the initial and final text objects\n # Using the same font_size ensures smoother visual consistency during transformation\n initial_text = Text(\"Initial Text\", font_size=36)\n final_text = Text(\"animate.rotate\", font_size=36)\n\n # Position the initial text below the triangle\n initial_text.next_to(triangle, DOWN, buff=1.5)\n\n # --- Triangle Animation ---\n # Animate the creation of the triangle\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Rotate the triangle exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI), run_time=2)\n\n # Fade out the triangle to remove it from the scene\n self.play(FadeOut(triangle))\n\n # --- Text Animation ---\n # Animate the text moving upwards\n self.play(initial_text.animate.shift(UP * 2.5), run_time=1.5)\n\n # Transform the text into the new string\n # ReplacementTransform is best practice for changing text content cleanly\n self.play(ReplacementTransform(target_position=ORIGIN, initial_text, final_text))\n\n # Hold the final frame briefly\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a **Rectangle** (width=4, height=2) appearing at the center of the screen. Instead of simply moving to (1, 1), the rectangle now **animates smoothly** from the center to its target position while **changing color** from blue to red. As it moves, a **mathematical formula** (e.g., the area calculation `A = width × height = 4 × 2 = 8`) fades in below it, dynamically updating as the rectangle’s dimensions shift. Once the rectangle reaches (1, 1), it **rotates 90 degrees** clockwise, and a **highlighting effect** (a glowing border) emphasizes its final position. Finally, **explanatory text** (\"Rectangle Transformation\") appears at the top of the screen, tying together the visual and mathematical concepts. This enhanced version not only preserves the original movement but also incorporates **dynamic formulas, color transitions, rotational animation, and explanatory text** for a more engaging and educational presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle and Position Tracking\n rect = RoundedRectangle(\n width=4,\n height=2,\n corner_radius=0.1\n )\n \n # Initialize math labels for calculations\n calc_label_start = MathTex(\"A = w \\\\times h = 4 \\\\times 2 = 8\").to_edge(DOWN)\n calc_label_end = MathTex(\"Area = 8\", \"\\\\text{ units}^2\").next_to(rect, DOWN)\n\n # Animate Appearance and Movement\n self.play(Create(rect))\n self.wait(0.5)\n \n # Smoothly move to target position (1, 1)\n self.play(\n rect.animate.shift(RIGHT + UP).set_color(RED),\n Write(calc_label_start), \n run_time=2\n )\n\n # Rotate by 90 degrees clock-wise\n self.play(Rotate(rect, angle=-PI/2, about_point=rect.get_center()), run_time=1.5)\n self.wait(0.5)\n\n # Add highlighting effect\n highlight_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.1)\n self.play(Create(highlight_rect))\n\n # Display Explanatory Text\n title_text = Tex(\"Rectangle Transformation\", font_size=36).to_edge(UP)\n self.play(FadeIn(title_text))\n \n # Update math label to reflect new orientation/state\n self.play(Transform(calc_label_start, calc_label_end))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle\n rect = Rectangle(\n width=4, \n height=2, \n stroke_color=BLUE,\n fill_opacity=0.5\n )\n \n # Add Mathematical Formula\n math_text = MathTex(\"A =\", \"4\", \"\\\\times\", \"2\", \"=\", \"8\")\n math_group = VGroup(MathTex(\"A =\"), Rect(4, 2).next_to(MathTex(\"A =\"), RIGHT), MathTex(\"=\")).arrange(RIGHT)\n \n self.play(Create(rect))\n self.wait(0.5)\n\n # Move and Change Color\n self.play(\n rect.animate.move_to([1, 1, 0]),\n rect.animate.set_stroke(color=RED),\n run_time=2\n )\n self.wait()\n\n # Display Area Calculation\n self.play(FadeIn(math_group.to_edge(DOWN)))\n self.wait(2)\n \n # Rotate Rectangle\n self.play(rotating_rect.animate.rotate(-PI/2)) # Clockwise rotation by -90 degrees\n self.wait()\n \n # Highlight Final Position\n highlight_box = SurroundingRectangle(rotating_rect, color=YELLOW, buff=0.2)\n self.add(highlight_box)\n self.wait(1)\n self.remove(highlight_box)\n \n # Show Explanatory Text\n title = Tex(\"Rectangle Transformation\").to_edge(UP)\n self.play(Write(title))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational math animation that visually demonstrates the concept of limits in calculus using a graph? Specifically, I'd like to see a simple graph, like a parabola for the function y=x^2, where you show how the value of the function approaches a certain point as x approaches the value of 2. Also, include a text explanation stating \"As x approaches 2, the value of x^2 approaches 4.\" at the top of the screen and highlight the point on the graph (2,4) with a red dot and a dashed yellow line from the x-axis to this point to signify the approach.", "chosen": "```python\nfrom manim import *\n\nclass LimitConcept(Scene):\n def construct(self):\n # 1. Create Coordinate System\n axes = Axes(\n x_range=[-1, 4, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the function y = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-1, 3.1])\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 3. Display the exact text explanation at the top\n explanation_text = Text(\n \"As x approaches 2, the value of x^2 approaches 4.\",\n font_size=36\n ).to_edge(UP)\n\n # 4. Define the target coordinate (2, 4)\n target_coord = axes.c2p(2, 4)\n\n # 5. Create the red dot for the limit point\n target_dot = Dot(target_coord, color=RED, radius=0.1)\n\n # 6. Create the dashed yellow line from x-axis to the point\n dashed_line = DashedLine(\n start=axes.c2p(2, 0),\n end=target_coord,\n color=YELLOW\n )\n\n # 7. Create a tracer dot to demonstrate the approach behavior\n tracer = Dot(color=WHITE)\n x_tracker = ValueTracker(0)\n tracer.add_updater(\n lambda m: m.move_to(axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2))\n )\n\n # Animation Sequence\n self.play(Write(explanation_text))\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Animate x approaching 2 from the left\n self.play(FadeIn(tracer))\n self.play(x_tracker.animate.set_value(2), run_time=3, rate_func=slow_into)\n\n # Highlight the limit point and guide line\n self.play(Create(dashed_line), FadeIn(target_dot), FadeOut(tracer))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass LimitConcept(Scene):\n def construct(self):\n # 1. Create Coordinate System\n axes = Axes(\n x_range=[-1, 4, 1],\n y_range=[-1, 10, 2],\n axis_config={\"include_tip\": True}\n ).add_coordinates()\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the function y = x^2\n graph = axes.plot(lambda x: x**2, color=BBLUE, x_range=[-1, 3.1])\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 3. Display the exact text explanation at the top\n explanation_text = Text(\n \"As x approaches 2, the value of x^2 approaches 4.\",\n font_size=36\n ).to_edge(UP)\n\n # 4. Define the target coordinate (2, 4)\n target_coord = axes.c2p(2, 4)\n\n # 5. Create the red dot for the limit point\n target_dot = Dot(target_coord, color=RED, radius=0.1)\n\n # 6. Create the dashed yellow line from x-axis to the point\n dashed_line = DashedLine(\n start=axes.c2p(2, 0),\n end=target_coord,\n color=YELLOW\n )\n\n # 7. Create a tracer dot to demonstrate the approach behavior\n tracer = Dot(color=WHITE)\n x_tracker = ValueTracker(0)\n tracer.add_updater(\n lambda m: m.move_to(axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2))\n )\n\n # Animation Sequence\n self.play(Write(explanation_text))\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # Animate x approaching 2 from the left\n self.play(FadeIn(tracer))\n self.play(x_tracker.animate.set_value(2), run_time=3, rate_func=slow_into)\n\n # Highlight the limit point and guide line\n self.play(Create(dashed_line), FadeIn(target_dot), FadeOut(tracer))\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Displaying the problem\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explanation for the method of rectangles\n explanation1 = Text(\"Approximate area using rectangles\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Graph the function\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label='x^2')\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Display rectangles\n rects = axes.get_riemann_rectangles(graph, x_range=[0, 2], dx=0.25)\n self.play(Create(rects))\n self.wait(2)\n\n # Explanation for the actual integration\n explanation2 = Text(\"Calculate the exact area\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{2^3}{3} = \\frac{8}{3}\")\n self.play(ReplacementTransform(rects, final_solution))\n self.wait(1)\n\n # Clear the scene and conclude\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label), FadeOut(explanation1))\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Displaying the problem\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explanation for the method of rectangles\n explanation1 = Text(\"Approximate area using rectangles\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Graph the function\n axes = Axes(label_font_size=24, \n x_range=[0, 2.5, 0.5],\n y_range=[0, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label='x^2')\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Display rectangles\n rects = axes.get_riemann_rectangles(graph, x_range=[0, 2], dx=0.25)\n self.play(Create(rects))\n self.wait(2)\n\n # Explanation for the actual integration\n explanation2 = Text(\"Calculate the exact area\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{2^3}{3} = \\frac{8}{3}\")\n self.play(ReplacementTransform(rects, final_solution))\n self.wait(1)\n\n # Clear the scene and conclude\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label), FadeOut(explanation1))\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Develop a Manim animation explaining the concept of orthogonality in linear algebra. Visualize orthogonal vectors, subspaces, and projections, step by step.\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: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0768(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects), run_time=0.8)\n \n def construct(self):\n self.act_1_orthogonal()\n self.clear_stage()\n self.act_2_simplegeom()\n self.clear_stage()\n self.act_3_mathplot()\n\n def act_1_orthogonal(self):\n title = Text(\"Orthogonality Revealed\", font_size=40).to_edge(UP)\n dotA = Dot(RIGHT*2 + UP*1, color=YELLOW, radius=0.1)\n labelA = MathTex(\"\\\\mathbf{v}_1\").next_to(dotA, RIGHT, buff=-0.2)\n vectorA = Arrow(ORIGIN, dotA.get_center(), max_tip_length_to_length_ratio=0.2, color=YELLOW)\n \n # Show vectors\n self.play(Write(title))\n self.play(Create(vectorA), FadeIn(labelA), run_time=1.5)\n\n # Orthogonal vector\n dotO = Dot(LEFT*2 + DOWN*1, color=GREEN, radius=0.1)\n labelO = MathTex(\"\\\\perp \\\\quad \\\\mathbf{v}_2\").next_to(dotO, LEFT, buff=0.2)\n vectorO = Arrow(ORIGIN, dotO.get_center(), max_tip_length_to_length_ratio=0.2, color=GREEN)\n plane = Line(ORIGIN, ORIGIN+RIGHT).set_color(WHITE).rotate(-PI/4)\n \n # Animate projection formula\n proj_formula = MathTex(\n r\"\\text{Proj}_{\\mathbf{u}} \\mathbf{v} = \\frac{\\mathbf{v}\\cdot \\mathbf{u}}{\\mathbf{u}\\cdot \\mathbf{u}}\\\\\",\n r\"=\\frac{x_u y_v}{x_u^2+y_u^2}\"\n ).scale(0.7).to_corner(DOWN+LEFT)\n\n self.play(\n Create(plane),\n FadeIn(dotO, labelO, vectorO),\n Write(proj_formula)\n )\n self.wait(2)\n\n # Subspace explanation\n subspace_text = Text(\"Subspace Spanned by Orthogons\", font_size=24).to_edge(DOWN)\n self.play(Write(subspace_text))\n\n # Move vectors up briefly\n self.play(\n vectorA.animate.shift(UP*1.5), \n vectorO.animate.shift(UP*1.5), \n dotA.animate.shift(UP*1.5), \n dotO.animate.shift(UP*1.5)\n )\n\n # Shift vectors back down\n self.play(\n vectorA.animate.shift(DOWN*1.5), \n vectorO.animate.shift(DOWN*1.5), \n dotA.animate.shift(DOWN*1.5), \n dotO.animate.shift(DOWN*1.5)\n )\n self.wait(1)\n\n # Final transition\n self.play(\n FadeOut(title), \n FadeOut(subspace_text), \n FadeOut(vectorA), \n FadeOut(vectorO), \n FadeOut(dotA), \n FadeOut(dotO), \n FadeOut(labelA), \n FadeOut(labelO), \n FadeOut(proj_formula), \n FadeOut(plane)\n )\n self.wait(1)\n\n def act_2_simplegeom(self):\n # --- Configuration ---\n TEXT_START_POS = UP * 2\n CIRCLE_RADIUS = 1.5\n\n # Step 1: Display Title\n title = Tex(\"Simple Geometric Sequence\")\n title.to_edge(UP)\n self.play(Write(title))\n\n # Step 2: Create Moving Text\n moving_text = Tex(\"Moving Upwards\")\n moving_text.move_to(TEXT_START_POS)\n \n self.add(moving_text)\n self.play(\n moving_text.animate.shift(DOWN * 4),\n run_time=2,\n rate_func=linear\n )\n self.remove(moving_text)\n\n # Step 3: Create Circle\n circle = Circle(radius=CIRCLE_RADIUS, color=BLUE)\n self.play(Create(circle))\n\n # Step 4: Transform to Red Square\n square = Square(side_length=CIRCLE_RADIUS * 2, color=RED)\n \n self.play(Transform(circle, square))\n\n # Step 5: Animate Movement\n self.play(\n square.animate.shift(DOWN * 1.5 + RIGHT * 2),\n run_time=2,\n run_back=True,\n )\n\n # Step 6: Cleanup\n self.play(FadeOut(square))\n\n def act_3_mathplot(self):\n func_tex = MathTex(\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_tex))\n axes = Axes(\n x_range=[-2, 2],\n y_range=[-1, 4]\n ).shift(DOWN * 0.5)\n \n self.play(Create(axes))\n self.wait(0.5)\n\n # Plotting the function\n graph = axes.plot(lambda x: x**2, color=BLUE)\n self.play(Create(graph), run_time=2)\n self.wait(2)\n```", "rejected": "```python\n\"\"\"\nMulti-Act Masterpiece\n\nThis masterwork combines three distinct scenes into a seamless multi-part narrative.\nEach part stands alone while flowing smoothly into the next via FadeOut animations.\n\nRun this full file to render all parts sequentially.\n\"\"\"\n\nfrom manim import *\n\nclass MultiPartMasterpiece(Scene):\n def construct(self):\n # Part 1: Orthogonal Projection Animation\n self.part_one()\n\n def clear_scene(self):\n if self.mobjects:\n self.fade_out(*self.mobjects)\n self.wait(0.5)\n\n def part_one(self):\n title = Text(\"Orthogonal Projections\", font_size=36).to_edge(UP)\n \n vec_u = Arrow(start=ORIGIN, end=3*RIGHT + 2*UP, color=BLUE)\n vec_v = Arrow(start=ORIGIN, end=-2*LEFT + 3*DOWN, color=RED)\n proj_u_on_v = Line(ORIGIN, ORIGIN + np.dot(vec_u.get_end(), unit_vector(vec_v.get_end())) * unit_vector(vec_v.get_end()), color=YELLOW)\n\n u_label = MathTex(\"\\\\vec{u}\").next_to(vec_u, RIGHT)\n v_label = MathTex(\"\\\\vec{v}\").next_to(vec_v, DOWN)\n p_label = MathTex(\"\\\\text{Proj}_{\\\\vec{v}} \\\\vec{u}\").next_to(proj_u_on_v, UP)\n \n self.play(Write(title))\n self.play(Create(vec_u), Create(vec_v))\n self.play(GrowArrow(proj_u_on_v))\n self.play(Write(u_label), Write(v_label), Write(p_label))\n\n self.wait(2)\n\n # Step 2: Subspace Concept\n subspace_text = Text(\"Subspace formed by multiples of \\\\\\\\ vector \\\\vec{v}\", font_size=24).to_edge(DOWN)\n \n self.play(FadeIn(subspace_text))\n self.wait(1.5)\n self.play(FadeOut(subspace_text))\n\n # Clear first section\n self.play(\n FadeOut(title),\n FadeOut(vec_u), FadeOut(vec_v), FadeOut(proj_u_on_v),\n FadeOut(u_label), FadeOut(v_label), FadeOut(p_label)\n )\n\n # Step 3: Linear Combination Demonstration\n comb_title = Text(\"Linear Combinations\", font_size=36).to_edge(UP)\n line_u = DashedLine(ORIGIN, 3*RIGHT, color=BLUE)\n line_w = DashedLine(ORIGIN, -2*LEFT, color=GREEN)\n \n self.play(Write(comb_title))\n self.play(Create(line_u), Create(line_w))\n self.wait(2)\n\n # Clear second section\n self.play(\n FadeOut(combo_group),\n FadeOut(comb_title),\n FadeOut(line_u), FadeOut(line_w)\n )\n \n # Final Cleanup\n self.wait(1)\n\n# To run this entire multi-part storybook sequence:\n# manim -pql filename.py MultiPartMasterpiece\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that illustrates the concept of calculating the area under a quadratic curve between two points on the x-axis, showing the graph of the function, highlighting the specific area under consideration, presenting the integral formula, and then breaking down the calculation step by step until the final numerical answer is revealed?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup: Coordinate System\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 3.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2, 3]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).scale(0.7).to_edge(LEFT, buff=1)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # ------------------------------------------------------------------\n # 2. Function Visualization: Plot f(x) = x^2\n # ------------------------------------------------------------------\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 3])\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^2\", x_val=2.8, direction=UR)\n\n # ------------------------------------------------------------------\n # 3. Area Highlighting: Region under curve from x=0 to x=2\n # ------------------------------------------------------------------\n x_start, x_end = 0, 2\n \n # Create the area object\n area = axes.get_area(graph, x_range=[x_start, x_end], color=GREEN, opacity=0.5)\n \n # Add vertical lines to clearly bound the area\n line_start = axes.get_vertical_line(axes.i2gp(x_start, graph), color=WHITE)\n line_end = axes.get_vertical_line(axes.i2gp(x_end, graph), color=WHITE)\n\n # ------------------------------------------------------------------\n # 4. Formula Display & Step-by-Step Breakdown\n # ------------------------------------------------------------------\n # Define the steps of the calculation using MathTex\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} - 0\")\n step5 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW)\n\n # Arrange equations vertically on the right side of the screen\n equations = VGroup(step1, step2, step3, step4, step5)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.next_to(axes, RIGHT, buff=1.0).shift(UP * 0.5)\n\n # ------------------------------------------------------------------\n # 5. Animation Sequence\n # ------------------------------------------------------------------\n # Animate the creation of the coordinate system and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Highlight the area under the curve\n self.play(FadeIn(area), Create(line_start), Create(line_end))\n self.wait(1)\n\n # Introduce the integral formula\n self.play(Write(step1))\n self.wait(1)\n\n # Step-by-step transformation of the equation\n # Show Antiderivative\n self.play(ReplacementTransform(step1.copy(), step2))\n self.wait(1)\n\n # Show Substitution of Limits\n self.play(ReplacementTransform(step2.copy(), step3))\n self.wait(1)\n\n # Show Arithmetic Simplification\n self.play(ReplacementTransform(step3.copy(), step4))\n self.wait(1)\n\n # Reveal Final Result\n self.play(ReplacementTransform(step4.copy(), step5))\n self.wait(1)\n\n # Emphasize the final answer and the area\n box = SurroundingRectangle(step5, color=WHITE)\n self.play(Create(box), Indicate(area))\n \n self.wait(3)\n\n# To run this animation: manim -pql filename.py AreaUnderQuadratic\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup: Coordinate System\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 3.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2, 3]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).scale(0.7).to_edge(LEFT, buff=1)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # ------------------------------------------------------------------\n # 2. Function Visualization: Plot f(x) = x^2\n # ------------------------------------------------------------------\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[0, 3])\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^2\", x_val=2.8, direction=UR)\n\n # ------------------------------------------------------------------\n # 3. Area Highlighting: Region under curve from x=0 to x=2\n # ------------------------------------------------------------------\n x_start, x_end = 0, 2\n \n # Create the area object\n area = axes.get_area(graph, x_range=[x_start, x_end], color=GREEN, opacity=0.5)\n \n # Add vertical lines to clearly bound the area\n line_start = axes.get_vertical_line(axes.i2gp(x_start, graph), color=WHITE)\n line_end = axes.get_vertical_line(axes.i2gp(x_end, graph), color=WHITE)\n\n # ------------------------------------------------------------------\n # 4. Formula Display & Step-by-Step Breakdown\n # ------------------------------------------------------------------\n # Define the steps of the calculation using MathTex\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} - 0\")\n step5 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW)\n\n # Arrange equations vertically on the right side of the screen\n equations = VGroup(step1, step2, step3, step4, step5)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.next_to(axes, RIGHT, buff=1.0).shift(UP * 0.5)\n\n # ------------------------------------------------------------------\n # 5. Animation Sequence\n # ------------------------------------------------------------------\n # Animate the creation of the coordinate system and graph\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Highlight the area under the curve\n self.play(FadeIn(area), Create(line_start), Create(line_end))\n self.wait(1)\n\n # Introduce the integral formula\n self.play(Write(step1))\n self.wait(1)\n\n # Step-by-step transformation of the equation\n # Show Antiderivative\n self.play(ReplacementTransform(target_position=ORIGIN, step1.copy(), step2))\n self.wait(1)\n\n # Show Substitution of Limits\n self.play(ReplacementTransform(step2.copy(), step3))\n self.wait(1)\n\n # Show Arithmetic Simplification\n self.play(ReplacementTransform(step3.copy(), step4))\n self.wait(1)\n\n # Reveal Final Result\n self.play(ReplacementTransform(step4.copy(), step5))\n self.wait(1)\n\n # Emphasize the final answer and the area\n box = SurroundingRectangle(step5, color=WHITE)\n self.play(Create(box), Indicate(area))\n \n self.wait(3)\n\n# To run this animation: manim -pql filename.py AreaUnderQuadratic\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the effect of adding and removing elements on the levels of the cumulative hierarchy?", "chosen": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"The Effect of Adding Elements\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create set A\n circle_A = Circle(radius=1.0, color=BLUE).shift(LEFT*3 + DOWN*1)\n text_A = MathTex(\"\\\\text{Set } A\").next_to(circle_A, UP, buff=0.5)\n self.play(Create(circle_A), Write(text_A))\n\n # Add element x to Set A\n dot_x = Dot(color=RED).move_to(circle_A.get_center())\n text_add = Text(\"+ Element \\\\( x \\\\)\", font_size=28).to_edge(UP)\n \n self.play(FadeIn(dot_x), Write(text_add))\n self.wait(1)\n\n # Show H(A) level\n h_a_rect = RoundedRectangle(width=7, height=2, corner_radius=0.2, color=YELLOW).shift(RIGHT*3)\n h_a_text = MathTex(\"\\\\text{H}(A)\").next_to(h_a_rect, DOWN, buff=0.5)\n self.play(Create(h_a_rect), Write(h_a_text))\n self.wait(1)\n\n # Remove element x from Set A\n self.remove(dot_x, text_add)\n\n # Show H(A \\ {x}) level\n h_a_minus_rect = RoundedRectangle(width=7, height=2, corner_radius=0.2, color=GREEN).shift(DOWN*2)\n h_a_minus_text = MathTex(\"\\\\text{H}(A\\\\setminus\\\\{x\\\\})\").next_to(h_a_minus_rect, DOWN, buff=0.5)\n self.play(TransformFromCopy(h_a_rect, h_a_minus_rect), TransformFromCopy(h_a_text, h_a_minus_text))\n self.wait(1)\n\n # Compare both hierarchies\n arrow = Arrow(start=h_a_rect.get_right(), end=h_a_minus_rect.get_left(), buff=0.3)\n compare_text = Text(\"Adding/removing elements changes the hierarchy structure.\", font_size=24, color=WHITE).to_edge(DOWN)\n \n self.play(GrowArrow(arrow), Write(compare_text))\n self.wait(2)\n```", "rejected": "```python\n\"\"\"\nThe Cumulative Hierarchy Animation\n\nThis animation demonstrates how elements are added and removed from sets,\nand how this affects their level in the cumulative hierarchy.\n\nScene Structure:\n1. Introduction: Shows the initial empty set at Level 0.\n2. Addition Phase: Elements are introduced one by one.\n - Each element adds a new layer to the hierarchy.\n - The corresponding power set appears above the parent set.\n3. Removal Phase: Elements are removed sequentially.\n - As elements leave, the hierarchy collapses back to its original state.\n - Power sets disappear as they become redundant.\n\"\"\"\n\nimport os\nfrom manim import *\n\nclass HierarchicalStructure(Scene):\n def construct(self):\n # Title\n title = Text(\"Hierarchical Structures\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create two circles for nodes\n circle_a = Circle(radius=0.8).shift(LEFT * 3 + DOWN)\n label_a = MathText(\"A\").next_to(circle_a, UP)\n\n circle_b = Circle(radius=0.8).shift(RIGHT * 3 + DOWN)\n label_b = MathText(\"B\").next_to(circle_b, UP)\n\n # Add labels first so they appear behind the circles\n self.add(label_a, label_b)\n self.play(Create(circle_a), Create(circle_b))\n\n # Draw lines representing connections between nodes\n line_ab = Line(start=circle_a.get_right(), end=circle_b.get_left())\n \n connection_label = MathText(\"\\\\rightarrow \\\\left\\\\{ B \\\\right\\\\} \").next_to(line_ab, RIGHT)\n self.play(GrowArrow(line_ab))\n self.play(Write(connection_label))\n self.wait(2)\n\n # Clear the screen\n self.clear()\n self.wait(1)\n\n# To run this file:\n# python filename.py --renderer=svg\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 20-second Manim scene that explains convolutional feature maps. Start with an input image grid, then show several stacked feature maps, a pooling stage, and a final compressed representation with arrows and labels.", "chosen": "```python\nfrom manim import *\n\nclass FeatureMapStack(Scene):\n def construct(self):\n title = Text(\"Convolutional Feature Maps\", font_size=36).to_edge(UP)\n input_grid = VGroup(*[\n Square(side_length=0.22, stroke_width=1, fill_color=BLUE_B, fill_opacity=0.38)\n for _ in range(25)\n ]).arrange_in_grid(5, 5, buff=0.03).move_to(LEFT * 5)\n conv_stack = VGroup(*[\n Rectangle(width=1.1, height=1.7, stroke_color=TEAL_D, fill_color=TEAL_C, fill_opacity=0.18).shift(RIGHT * 0.14 * i + UP * 0.08 * i)\n for i in range(4)\n ]).move_to(LEFT * 1.8)\n pool_stack = VGroup(*[\n Rectangle(width=0.85, height=1.25, stroke_color=GREEN_D, fill_color=GREEN_C, fill_opacity=0.18).shift(RIGHT * 0.11 * i + UP * 0.07 * i)\n for i in range(3)\n ]).move_to(RIGHT * 1.0)\n embedding = VGroup(*[\n RoundedRectangle(corner_radius=0.08, width=0.55, height=0.28, color=PURPLE_D, fill_opacity=0.2).shift(DOWN * 0.34 * i)\n for i in range(5)\n ]).move_to(RIGHT * 4.3)\n labels = VGroup(\n Text(\"Input image\", font_size=24).next_to(input_grid, DOWN),\n Text(\"Conv features\", font_size=24).next_to(conv_stack, DOWN),\n Text(\"Pooling\", font_size=24).next_to(pool_stack, DOWN),\n Text(\"Embedding\", font_size=24).next_to(embedding, DOWN),\n )\n arrows = VGroup(\n Arrow(input_grid.get_right(), conv_stack.get_left(), buff=0.18, color=GRAY_B),\n Arrow(conv_stack.get_right(), pool_stack.get_left(), buff=0.18, color=GRAY_B),\n Arrow(pool_stack.get_right(), embedding.get_left(), buff=0.18, color=GRAY_B),\n )\n detail_box = SurroundingRectangle(conv_stack, color=YELLOW_D, buff=0.08)\n detail_text = Text(\"Each map responds to a different learned pattern.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), FadeIn(input_grid), FadeIn(labels[0]), run_time=2)\n self.play(GrowArrow(arrows[0]), FadeIn(conv_stack), FadeIn(labels[1]), run_time=3)\n self.play(GrowArrow(arrows[1]), FadeIn(pool_stack), FadeIn(labels[2]), run_time=2.5)\n self.play(GrowArrow(arrows[2]), FadeIn(embedding), FadeIn(labels[3]), run_time=2.5)\n self.play(Create(detail_box), run_time=1.5)\n self.play(FadeIn(detail_text), Indicate(conv_stack, color=TEAL_A), Indicate(pool_stack, color=GREEN_A), run_time=4)\n self.play(FadeOut(detail_box), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass FeatureMapStack(Scene):\n def construct(self):\n title = Text(\"Convolutional Feature Maps\", font_size=36).to_edge(UP)\n input_grid = VGroup(*[\n Square(side_length=0.22, stroke_width=1, fill_color=BBLUE_B, fill_opacity=0.38)\n for _ in range(25)\n ]).arrange_in_grid(5, 5, buff=0.03).move_to(LEFT * 5)\n conv_stack = VGroup(*[\n Rectangle(width=1.1, height=1.7, stroke_color=TEAL_D, fill_color=TEAL_C, fill_opacity=0.18).shift(RIGHT * 0.14 * i + UP * 0.08 * i)\n for i in range(4)\n ]).move_to(LEFT * 1.8)\n pool_stack = VGroup(*[\n Rectangle(width=0.85, height=1.25, stroke_color=GREEN_D, fill_color=GREEN_C, fill_opacity=0.18).shift(RIGHT * 0.11 * i + UP * 0.07 * i)\n for i in range(3)\n ]).move_to(RIGHT * 1.0)\n embedding = VGroup(*[\n RoundedRectangle(corner_radius=0.08, width=0.55, height=0.28, color=PURPLE_D, fill_opacity=0.2).shift(DOWN * 0.34 * i)\n for i in range(5)\n ]).move_to(RIGHT * 4.3)\n labels = VGroup(\n Text(\"Input image\", font_size=24).next_to(input_grid, DOWN),\n Text(\"Conv features\", font_size=24).next_to(conv_stack, DOWN),\n Text(\"Pooling\", font_size=24).next_to(pool_stack, DOWN),\n Text(\"Embedding\", font_size=24).next_to(embedding, DOWN),\n )\n arrows = VGroup(\n Arrow(input_grid.get_right(), conv_stack.get_left(), buff=0.18, color=GRAY_B),\n Arrow(conv_stack.get_right(), pool_stack.get_left(), buff=0.18, color=GRAY_B),\n Arrow(pool_stack.get_right(), embedding.get_left(), buff=0.18, color=GRAY_B),\n )\n detail_box = SurroundingRectangle(conv_stack, color=YELLOW_D, buff=0.08)\n detail_text = Text(\"Each map responds to a different learned pattern.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), FadeIn(input_grid), FadeIn(labels[0]), run_time=2)\n self.play(GrowArrow(arrows[0]), FadeIn(conv_stack), FadeIn(labels[1]), run_time=3)\n self.play(GrowArrow(arrows[1]), FadeIn(pool_stack), FadeIn(labels[2]), run_time=2.5)\n self.play(GrowArrow(arrows[2]), FadeIn(embedding), FadeIn(labels[3]), run_time=2.5)\n self.play(Create(detail_box), run_time=1.5)\n self.play(FadeIn(detail_text), Indicate(conv_stack, color=TEAL_A), Indicate(pool_stack, color=GREEN_A), run_time=4)\n self.play(FadeOut(detail_box), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Profile-Guided Optimization (PGO) Concept\n\n#### Run Sampling/Instrumentation First, Then Use Profiles to Guide Optimization\n\nUtilize actual branch probabilities and call frequencies during program execution to make more accurate optimization decisions (such as basic block reordering) than those made by static analysis.\n\n\nContextual location of this section (from highest to current level):\n# Compiler Principles Course - Detailed Outline for Lecture Sixteen (Modern Compilation Techniques and Course Summary: LLVM Ecosystem, JIT, and Engineering, 90 minutes)\n## JIT and Interpreters: Engineering Trade-offs in Runtime Compilation (20 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ProfileGuidedOptimization(Scene):\n\n def construct(self):\n title = Text('Profile-Guided Optimization (PGO)', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.3)\n subtitle = Text('Run Sampling/Instrumentation First, Then Use Profiles to Guide Optimization', font_size=24, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n box1 = VGroup(Text('1. Program Execution', font_size=20, color=YELLOW), Text('(Sampling/Instrumentation)', font_size=16)).arrange(DOWN, buff=0.1)\n rect1 = SurroundingRectangle(box1, color=YELLOW, buff=0.2, corner_radius=0.1)\n g1 = VGroup(rect1, box1)\n box2 = VGroup(Text('2. Profile Data', font_size=20, color=GREEN), Text('(Branch Probs, Call Freqs)', font_size=16)).arrange(DOWN, buff=0.1)\n rect2 = SurroundingRectangle(box2, color=GREEN, buff=0.2, corner_radius=0.1)\n g2 = VGroup(rect2, box2)\n box3 = VGroup(Text('3. Compiler Optimization', font_size=20, color=ORANGE), Text('(e.g., Basic Block Reordering)', font_size=16)).arrange(DOWN, buff=0.1)\n rect3 = SurroundingRectangle(box3, color=ORANGE, buff=0.2, corner_radius=0.1)\n g3 = VGroup(rect3, box3)\n flow = VGroup(g1, g2, g3).arrange(RIGHT, buff=1.2)\n flow.next_to(subtitle, DOWN, buff=0.6)\n a1 = Arrow(g1.get_right(), g2.get_left(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n a2 = Arrow(g2.get_right(), g3.get_left(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n self.play(Create(rect1), Write(box1))\n self.play(GrowArrow(a1))\n self.play(Create(rect2), Write(box2))\n self.play(GrowArrow(a2))\n self.play(Create(rect3), Write(box3))\n self.wait(1)\n cfg_title = Text('Control Flow Graph', font_size=22, color=WHITE)\n blk_a = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_a = Text('A', font_size=20).move_to(blk_a)\n grp_a = VGroup(blk_a, txt_a)\n blk_b = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_b = Text('B', font_size=20).move_to(blk_b)\n grp_b = VGroup(blk_b, txt_b)\n blk_c = Rectangle(width=0.8, height=0.5, color=RED)\n txt_c = Text('C', font_size=20).move_to(blk_c)\n grp_c = VGroup(blk_c, txt_c)\n grp_a.move_to(ORIGIN)\n grp_b.move_to(DOWN * 1.5 + LEFT * 1.0)\n grp_c.move_to(DOWN * 1.5 + RIGHT * 1.0)\n arr_ab = Arrow(grp_a.get_bottom(), grp_b.get_top(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n arr_ac = Arrow(grp_a.get_bottom(), grp_c.get_top(), buff=0.1, color=RED, max_tip_length_to_length_ratio=0.15)\n lbl_ab = Text('1%', font_size=16).next_to(arr_ab, LEFT, buff=0.1)\n lbl_ac = Text('99%', font_size=16, color=RED).next_to(arr_ac, RIGHT, buff=0.1)\n cfg_diagram = VGroup(grp_a, grp_b, grp_c, arr_ab, arr_ac, lbl_ab, lbl_ac)\n cfg_group = VGroup(cfg_title, cfg_diagram).arrange(DOWN, buff=0.4)\n layout_title = Text('Memory Layout', font_size=22, color=WHITE)\n layout_static_lbl = Text('Static Analysis:', font_size=18)\n box_sa = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_sb = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_sc = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_sa = Text('A', font_size=18).move_to(box_sa)\n txt_sb = Text('B', font_size=18).move_to(box_sb)\n txt_sc = Text('C', font_size=18).move_to(box_sc)\n v_static = VGroup(VGroup(box_sa, txt_sa), VGroup(box_sb, txt_sb), VGroup(box_sc, txt_sc)).arrange(RIGHT, buff=0)\n stat_group = VGroup(layout_static_lbl, v_static).arrange(RIGHT, buff=0.5)\n layout_pgo_lbl = Text('PGO (Hot Path):', font_size=18, color=RED)\n box_pa = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_pc = Rectangle(width=0.8, height=0.5, color=RED)\n box_pb = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_pa = Text('A', font_size=18).move_to(box_pa)\n txt_pc = Text('C', font_size=18).move_to(box_pc)\n txt_pb = Text('B', font_size=18).move_to(box_pb)\n v_pgo = VGroup(VGroup(box_pa, txt_pa), VGroup(box_pc, txt_pc), VGroup(box_pb, txt_pb)).arrange(RIGHT, buff=0)\n pgo_group = VGroup(layout_pgo_lbl, v_pgo).arrange(RIGHT, buff=0.5)\n note = Text('Hot path (A \\rightarrow C) becomes fall-through!', font_size=18, color=YELLOW)\n layout_static_lbl.align_to(layout_pgo_lbl, RIGHT)\n layout_diagram = VGroup(stat_group, pgo_group, note).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n layout_group = VGroup(layout_title, layout_diagram).arrange(DOWN, buff=0.4)\n bottom_section = VGroup(cfg_group, layout_group).arrange(RIGHT, buff=1.5)\n bottom_section.next_to(flow, DOWN, buff=0.8)\n self.play(FadeIn(cfg_title), FadeIn(layout_title))\n self.play(Create(grp_a), Create(grp_b), Create(grp_c))\n self.play(GrowArrow(arr_ab), Write(lbl_ab))\n self.play(GrowArrow(arr_ac), Write(lbl_ac))\n self.wait(0.5)\n self.play(FadeIn(stat_group, shift=LEFT * 0.2))\n self.wait(0.5)\n self.play(FadeIn(pgo_group, shift=LEFT * 0.2))\n self.play(Write(note))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ProfileGuidedOptimization(Scene):\n\n def construct(self):\n title = Text('Profile-Guided Optimization (PGO)', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.3)\n subtitle = Text('Run Sampling/Instrumentation First, Then Use Profiles to Guide Optimization', font_size=24, color=BBLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP * 0.2))\n self.wait(0.5)\n box1 = VGroup(Text('1. Program Execution', font_size=20, color=YELLOW), Text('(Sampling/Instrumentation)', font_size=16)).arrange(DOWN, buff=0.1)\n rect1 = SurroundingRectangle(box1, color=YELLOW, buff=0.2, corner_radius=0.1)\n g1 = VGroup(rect1, box1)\n box2 = VGroup(Text('2. Profile Data', font_size=20, color=GREEN), Text('(Branch Probs, Call Freqs)', font_size=16)).arrange(DOWN, buff=0.1)\n rect2 = SurroundingRectangle(box2, color=GREEN, buff=0.2, corner_radius=0.1)\n g2 = VGroup(rect2, box2)\n box3 = VGroup(Text('3. Compiler Optimization', font_size=20, color=ORANGE), Text('(e.g., Basic Block Reordering)', font_size=16)).arrange(DOWN, buff=0.1)\n rect3 = SurroundingRectangle(box3, color=ORANGE, buff=0.2, corner_radius=0.1)\n g3 = VGroup(rect3, box3)\n flow = VGroup(g1, g2, g3).arrange(RIGHT, buff=1.2)\n flow.next_to(subtitle, DOWN, buff=0.6)\n a1 = Arrow(g1.get_right(), g2.get_left(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n a2 = Arrow(g2.get_right(), g3.get_left(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n self.play(Create(rect1), Write(box1))\n self.play(GrowArrow(a1))\n self.play(Create(rect2), Write(box2))\n self.play(GrowArrow(a2))\n self.play(Create(rect3), Write(box3))\n self.wait(1)\n cfg_title = Text('Control Flow Graph', font_size=22, color=WHITE)\n blk_a = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_a = Text('A', font_size=20).move_to(blk_a)\n grp_a = VGroup(blk_a, txt_a)\n blk_b = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_b = Text('B', font_size=20).move_to(blk_b)\n grp_b = VGroup(blk_b, txt_b)\n blk_c = Rectangle(width=0.8, height=0.5, color=RED)\n txt_c = Text('C', font_size=20).move_to(blk_c)\n grp_c = VGroup(blk_c, txt_c)\n grp_a.move_to(ORIGIN)\n grp_b.move_to(DOWN * 1.5 + LEFT * 1.0)\n grp_c.move_to(DOWN * 1.5 + RIGHT * 1.0)\n arr_ab = Arrow(grp_a.get_bottom(), grp_b.get_top(), buff=0.1, max_tip_length_to_length_ratio=0.15)\n arr_ac = Arrow(grp_a.get_bottom(), grp_c.get_top(), buff=0.1, color=RED, max_tip_length_to_length_ratio=0.15)\n lbl_ab = Text('1%', font_size=16).next_to(arr_ab, LEFT, buff=0.1)\n lbl_ac = Text('99%', font_size=16, color=RED).next_to(arr_ac, RIGHT, buff=0.1)\n cfg_diagram = VGroup(grp_a, grp_b, grp_c, arr_ab, arr_ac, lbl_ab, lbl_ac)\n cfg_group = VGroup(cfg_title, cfg_diagram).arrange(DOWN, buff=0.4)\n layout_title = Text('Memory Layout', font_size=22, color=WHITE)\n layout_static_lbl = Text('Static Analysis:', font_size=18)\n box_sa = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_sb = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_sc = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_sa = Text('A', font_size=18).move_to(box_sa)\n txt_sb = Text('B', font_size=18).move_to(box_sb)\n txt_sc = Text('C', font_size=18).move_to(box_sc)\n v_static = VGroup(VGroup(box_sa, txt_sa), VGroup(box_sb, txt_sb), VGroup(box_sc, txt_sc)).arrange(RIGHT, buff=0)\n stat_group = VGroup(layout_static_lbl, v_static).arrange(RIGHT, buff=0.5)\n layout_pgo_lbl = Text('PGO (Hot Path):', font_size=18, color=RED)\n box_pa = Rectangle(width=0.8, height=0.5, color=WHITE)\n box_pc = Rectangle(width=0.8, height=0.5, color=RED)\n box_pb = Rectangle(width=0.8, height=0.5, color=WHITE)\n txt_pa = Text('A', font_size=18).move_to(box_pa)\n txt_pc = Text('C', font_size=18).move_to(box_pc)\n txt_pb = Text('B', font_size=18).move_to(box_pb)\n v_pgo = VGroup(VGroup(box_pa, txt_pa), VGroup(box_pc, txt_pc), VGroup(box_pb, txt_pb)).arrange(RIGHT, buff=0)\n pgo_group = VGroup(layout_pgo_lbl, v_pgo).arrange(RIGHT, buff=0.5)\n note = Text('Hot path (A \\rightarrow C) becomes fall-through!', font_size=18, color=YELLOW)\n layout_static_lbl.align_to(layout_pgo_lbl, RIGHT)\n layout_diagram = VGroup(stat_group, pgo_group, note).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n layout_group = VGroup(layout_title, layout_diagram).arrange(DOWN, buff=0.4)\n bottom_section = VGroup(cfg_group, layout_group).arrange(RIGHT, buff=1.5)\n bottom_section.next_to(flow, DOWN, buff=0.8)\n self.play(FadeIn(cfg_title), FadeIn(layout_title))\n self.play(Create(grp_a), Create(grp_b), Create(grp_c))\n self.play(GrowArrow(arr_ab), Write(lbl_ab))\n self.play(GrowArrow(arr_ac), Write(lbl_ac))\n self.wait(0.5)\n self.play(FadeIn(stat_group, shift=LEFT * 0.2))\n self.wait(0.5)\n self.play(FadeIn(pgo_group, shift=LEFT * 0.2))\n self.play(Write(note))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows how to find the derivative of the polynomial function x^2 + 3x + 2 using the power rule, with step-by-step visual and textual explanations, and then displays the final derivative formula, while finishing with a message that confirms \"That's the derivative!\"?", "chosen": "```python\nfrom manim import *\n\nclass DerivativePowerRule(Scene):\n def construct(self):\n # 1. Title and Original Function\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36)\n title.to_edge(UP)\n \n # Splitting MathTex into arguments allows TransformMatchingTex to work smoothly\n func = MathTex(\"f(x)\", \"=\", \"x^2\", \"+\", \"3x\", \"+\", \"2\").scale(1.5)\n \n self.play(Write(title))\n self.play(Write(func))\n self.wait(1)\n\n # 2. Power Rule Formula\n rule = MathTex(r\"\\frac{d}{dx}x^n = nx^{n-1}\", color=YELLOW).scale(1.2)\n rule_label = Text(\"Power Rule:\", font_size=28).next_to(rule, LEFT)\n rule_group = VGroup(rule_label, rule).next_to(func, DOWN, buff=0.8)\n \n self.play(FadeIn(rule_group))\n self.wait(2)\n\n # 3. Apply Derivative Operator\n step1 = MathTex(\"f'(x)\", \"=\", r\"\\frac{d}{dx}(x^2)\", \"+\", r\"\\frac{d}{dx}(3x)\", \"+\", r\"\\frac{d}{dx}(2)\").scale(1.5)\n self.play(TransformMatchingTex(func, step1))\n self.wait(1)\n\n # 4. Apply Rule to Each Term (Intermediate Step)\n step2 = MathTex(\"f'(x)\", \"=\", \"2x^{2-1}\", \"+\", \"3(1)x^{1-1}\", \"+\", \"0\").scale(1.5)\n \n explanation1 = Text(\n \"Apply rule: multiply by n, subtract 1 from power. Constant becomes 0.\", \n font_size=24\n ).next_to(step2, DOWN, buff=1)\n explanation1.set_color(GRAY)\n \n self.play(TransformMatchingTex(step1, step2))\n self.play(Write(explanation1))\n self.wait(2)\n\n # 5. Simplify Exponents\n step3 = MathTex(\"f'(x)\", \"=\", \"2x\", \"+\", \"3\", \"+\", \"0\").scale(1.5)\n \n explanation2 = Text(\"Simplify the exponents\", font_size=24).next_to(step3, DOWN, buff=1)\n explanation2.set_color(GRAY)\n \n self.play(TransformMatchingTex(step2, step3))\n self.play(FadeOut(explanation1), Write(explanation2))\n self.wait(1)\n\n # 6. Final Result\n step4 = MathTex(\"f'(x)\", \"=\", \"2x\", \"+\", \"3\").scale(1.5)\n self.play(TransformMatchingTex(step3, step4))\n self.play(FadeOut(explanation2), FadeOut(rule_group))\n self.wait(1)\n\n # 7. Emphasis and Conclusion\n box = SurroundingRectangle(step4, color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(1)\n\n conclusion = Text(\"That's the derivative!\", font_size=45, color=BLUE).next_to(box, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DerivativePowerRule(Scene):\n def construct(self):\n # 1. Title and Original Function\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36)\n title.to_edge(UP)\n \n # Splitting MathTex into arguments allows TransformMatchingTex to work smoothly\n func = MathTex(\"f(x)\", \"=\", \"x^2\", \"+\", \"3x\", \"+\", \"2\").scale(1.5)\n \n self.play(Write(title))\n self.play(Write(func))\n self.wait(1)\n\n # 2. Power Rule Formula\n rule = MathTex(r\"\\frac{d}{dx}x^n = nx^{n-1}\", color=YELLOW).scale(1.2)\n rule_label = Text(\"Power Rule:\", font_size=28).next_to(rule, LEFT)\n rule_group = VGroup(rule_label, rule).next_to(func, DOWN, buff=0.8)\n \n self.play(FadeIn(rule_group))\n self.wait(2)\n\n # 3. Apply Derivative Operator\n step1 = MathTex(\"f'(x)\", \"=\", r\"\\frac{d}{dx}(x^2)\", \"+\", r\"\\frac{d}{dx}(3x)\", \"+\", r\"\\frac{d}{dx}(2)\").scale(1.5)\n self.play(TransformMatchingTex(func, step1))\n self.wait(1)\n\n # 4. Apply Rule to Each Term (Intermediate Step)\n step2 = MathTex(\"f'(x)\", \"=\", \"2x^{2-1}\", \"+\", \"3(1)x^{1-1}\", \"+\", \"0\").scale(1.5)\n \n explanation1 = Text(\n \"Apply rule: multiply by n, subtract 1 from power. Constant becomes 0.\", \n font_size=24\n ).next_to(step2, DOWN, buff=1)\n explanation1.set_color(GRAY)\n \n self.play(TransformMatchingTex(step1, step2))\n self.play(Write(explanation1))\n self.wait(2)\n\n # 5. Simplify Exponents\n step3 = MathTex(\"f'(x)\", \"=\", \"2x\", \"+\", \"3\", \"+\", \"0\").scale(1.5)\n \n explanation2 = Text(\"Simplify the exponents\", font_size=24).next_to(step3, DOWN, buff=1)\n explanation2.set_color(GRAY)\n \n self.play(TransformMatchingTex(step2, step3))\n self.play(FadeOut(explanation1), Write(explanation2))\n self.wait(1)\n\n # 6. Final Result\n step4 = MathTex(\"f'(x)\", \"=\", \"2x\", \"+\", \"3\").scale(1.5)\n self.play(TransformMatchingTex(step3, step4))\n self.play(FadeOut(explanation2), FadeOut(rule_group))\n self.wait(1)\n\n # 7. Emphasis and Conclusion\n box = SurroundingRectangle(step4, color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(1)\n\n conclusion = Text(\"That's the derivative!\", font_size=45, color=BBLUE).next_to(box, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Function of the Target Network\n\nThis is an auxiliary network with temporarily fixed parameters, specifically used to calculate the TD target values. By severing the real-time connection between the target values and the current network parameters, it avoids training instability caused by \"chasing a moving target.\"\n\n\nThe context location of this section (from highest to current level):\n# Advanced Techniques in DQN\n## Key Improvement Ideas in DQN\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass FunctionOfTargetNetwork(Scene):\n\n def construct(self):\n title = Text('Function of the Target Network', font_size=36)\n title.to_edge(UP, buff=0.75)\n self.play(Write(title))\n context_text = Text('Key Improvement Idea\\nAdvanced Techniques in DQN > Key Improvements')\n context_box = SurroundingRectangle(context_text, color=BLUE_D, buff=0.2)\n context_group = VGroup(context_box, context_text).to_edge(DOWN, buff=0.8)\n self.add(context_group)\n desc1 = Text(\"Auxiliary network with temporarily fixed parameters\", font_size=24)\n desc1.next_to(title, DOWN, buff=1.2)\n box_target_net = RoundedRectangle(corner_radius=0.2, width=3.0, height=1.8, fill_opacity=0.1)\n label_tn = Text('Target Network', font_size=20, color=YELLOW)\n tnp = MathTex('\\\\theta^{\\\\text{t}}').next_to(label_tn, RIGHT, buff=0.2)\n label_fixed_params = Text('Fixed Parameters', font_size=20, color=ORANGE)\n param_block = VGroup(tnp, label_fixed_params).arrange(RIGHT, buff=0.2)\n param_rect = SurroundingRectangle(param_block, color=RED_D, stroke_width=2)\n param_group = VGroup(box_target_net, label_tn, param_rect, param_block)\n calc_label = Text('Calculate TD Target Values:', font_size=24, color=GREEN)\n arrow_calc = Arrow(start=LEFT, end=RIGHT, color=WHITE, max_tip_length_to_length_ratio=0.12)\n calc_group = VGroup(calc_label, arrow_calc).arrange(RIGHT, buff=0.5)\n calc_group.next_to(desc1, DOWN, buff=0.8).align_to(desc1, LEFT)\n eq_td = MathTex('T_{D} = r + \\\\gamma \\\\max_a Q(s', '\\\\rightarrow', 's\\' ,a | \\\\theta^{\\\\text{t}} }')\n eq_td[0].set_color(YELLOW)\n eq_td[2][1:].set_color(TEAL)\n eq_td[2][-1].set_color(GREEN)\n td_title = Text('\"Chasing\" a Moving Target', font_size=24, color=RED_A)\n td_desc = Text('Real-time connection between target values and current net params causes instability.', font_size=20)\n td_group = VGroup(td_title, td_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n td_group.next_to(eq_td, DOWN, buff=0.8).shift(LEFT * 0.5 + UP * 0.2)\n td_box = SurroundingRectangle(VGroup(td_title, td_desc), color=RED_D, buff=0.3)\n sd_txt = Text('Separate Data Flow:\\nReduce Instability', font_size=20, color=BLUE_B)\n sd_box = SurroundingRectangle(sd_txt, color=BLUE_E, stroke_width=3, corner_radius=0.2)\n sd_g = VGroup(sd_box, sd_txt).move_to([1.2, 0.2, 0])\n self.play(FadeIn(param_group, shift=DOWN))\n self.play(Write(calc_label), GrowArrow(arrow_calc))\n self.play(Write(eq_td))\n self.play(Write(td_box), Write(td_title), FadeIn(td_desc, shift=DOWN))\n self.play(Create(sd_box), Write(sd_txt))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkExplanation(Scene):\n\n def construct(self):\n title = Text(\"Target Network for Stability\", font_size=36)\n \n # Create boxes and labels for the main components\n box_main = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=WHITE).shift(UP*1.8 + LEFT*2)\n label_main = Tex(\"$Q$-network\\n(real-time)\", font_size=16).move_to(box_main.get_center())\n \n box_target_fixed = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=ORANGE).next_to(title, DOWN, buff=1)\n label_fixed = Tex(\"\\\\textbf{Fixed} \\\\\\\\\\\\small\\\\textit{(parameters updated periodically)}\", font_size=18).move_to(box_target_fixed.get_center()).set_opacity(0.7)\n arrow_update = Arrow(start=box_target_fixed.get_top(), end=box_target_fixed.get_bottom() + UP*0.2, stroke_width=2, max_tip_length_to_length_ratio=0.1)\n update_text = Text(\"Update Periodically\", font_size=12, t2c={\"Periodically\": BLUE}).next_to(arrow_update, UP, buff=-0.2)\n \n box_agent = RoundedRectangle(width=4, height=2, corner_radius=0.3, color=GREEN).to_edge(RIGHT, buff=2)\n label_agent = Tex(\"$s_{t}$\\n(state $t$)\", font_size=16).move_to(box_agent.get_center())\n line_arrow = Line(end=box_main.get_left()+RIGHT*0.1, start=box_agent.get_right()-LEFT*0.1)\n arc_arrow = Arc(radius=0.3, angle=PI/2).rotate(-PI/4).move_to(line_arrow.get_end())\n td_error_box = RoundedRectangle(width=2.2, height=1.2, corner_radius=0.2, color=YELLOW).next_to(arc_arrow, RIGHT, buff=0.1)\n td_label = MathTex(\"\\Delta E\").scale(0.75).move_to(td_error_box.get_center())\n error_flow = VGroup(Line(start=arc_arrow.get_end(), end=td_error_box.get_corner(DOWN+LEFT)), \n Arrow(start=td_error_box.get_corner(DOWN+LEFT)+RIGHT*0.1, end=box_main.get_right()-LEFT*0.1, buff=0.1))\n \n UILabel = Tex(\"Training Instability:\", font_size=24, color=RED).next_to(error_flow, DOWN, buff=0.3)\n UText = Tex(\"'Chasing a moving target'\", font_style=ITALIC, font_size=18).next_to(UILabel, DOWN, buff=0.2)\n\n self.play(Write(title), FadeIn(box_main), Write(label_main), run_time=2)\n self.wait(1)\n self.play(FadeIn(box_agent), Write(label_agent), RunTime(0.5))\n self.play(GrowArrow(line_arrow), GrowArrow(arc_arrow), run_time=1)\n self.play(Create(td_error_box), Write(td_label), run_time=1)\n self.play(LaggedStart(*[GrowArrow(i) for i in error_flow], lag_ratio=0.2), run_time=1.5)\n self.wait(1)\n self.play(FadeIn(box_target_fixed), Write(label_fixed), GrowArrow(arrow_update), Write(update_text), run_time=2)\n self.play(Write(UILabel), Write(UText), Indicate(box_target_fixed, color=ORANGE), Indicate(box_main, color=WHITE), run_time=3)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding explanatory text, a dynamic background grid, and a smooth transformation of the triangle into another shape: \n\nThe animation begins with the text \"animate.rotate\" appearing at the top of the screen, shifting upward for emphasis. Simultaneously, a bright blue triangle materializes at the center of the screen, rotating smoothly by 180 degrees (π radians) to demonstrate the rotation effect. As the rotation completes, a coordinate grid fades in behind the triangle, providing spatial context for the transformation. Text then appears below the triangle, explaining the rotation in mathematical terms: \"Rotation by π radians (180°) around the origin.\" Next, the triangle morphs seamlessly into a square, emphasizing how transformations can alter shapes while maintaining their properties. The square then rotates by π/2 radians (90°), further reinforcing the concept. Finally, the square and grid fade out, leaving only the original text, which pulses gently to draw attention before the scene concludes. This enhanced version not only demonstrates rotation but also educates the viewer with clear annotations and additional visual context.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRotationScene(Scene):\n def construct(self):\n # Create and animate the title text\n title = Text(\"animate.rotate\", font_size=48).to_edge(UP)\n self.play(Write(title))\n self.play(title.animate.shift(UP * 0.5), run_time=0.5)\n\n # Create and animate the triangle\n triangle = Triangle(color=BLUE, fill_opacity=0.8).scale(1.5)\n self.play(Create(triangle))\n self.play(Rotate(triangle, angle=PI, about_point=ORIGIN), run_time=2)\n\n # Fade in the grid\n grid = NumberPlane()\n self.play(FadeIn(grid), run_time=1)\n\n # Add explanation text\n explanation = Text(\n \"Rotation by \\pi radians (180°) around the origin\",\n font_size=24\n ).next_to(triangle, DOWN, buff=1)\n self.play(Write(explanation))\n self.wait(1)\n\n # Morph triangle into square\n square = Square(color=GREEN, fill_opacity=0.8).scale(1.5)\n self.play(Transform(triangle, square), run_time=1.5)\n self.wait(0.5)\n\n # Rotate the square\n self.play(Rotate(triangle, angle=PI/2, about_point=ORIGIN), run_time=1.5)\n self.wait(1)\n\n # Fade out the square and grid\n self.play(FadeOut(triangle), FadeOut(grid), run_time=1)\n\n # Pulse the title\n self.play(\n title.animate.scale(1.2),\n run_time=0.5,\n rate_func=there_and_back\n )\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRotationScene(Scene):\n def construct(self):\n # Create and animate the title text\n title = Text(\"animate.rotate\", font_size=48).to_edge(UP)\n self.play(Write(title))\n self.play(title.animate.shift(UP * 0.5), run_time=0.5)\n\n # Create and animate the triangle\n triangle = Triangle(color=BBLUE, fill_opacity=0.8).scale(1.5)\n self.play(Create(triangle))\n self.play(Rotate(triangle, angle=PI, about_point=ORIGIN), run_time=2)\n\n # Fade in the grid\n grid = NumberPlane()\n self.play(FadeIn(grid), run_time=1)\n\n # Add explanation text\n explanation = Text(\n \"Rotation by \\pi radians (180°) around the origin\",\n font_size=24\n ).next_to(triangle, DOWN, buff=1)\n self.play(Write(explanation))\n self.wait(1)\n\n # Morph triangle into square\n square = Square(color=GREEN, fill_opacity=0.8).scale(1.5)\n self.play(Transform(triangle, square), run_time=1.5)\n self.wait(0.5)\n\n # Rotate the square\n self.play(Rotate(triangle, angle=PI/2, about_point=ORIGIN), run_time=1.5)\n self.wait(1)\n\n # Fade out the square and grid\n self.play(FadeOut(triangle), FadeOut(grid), run_time=1)\n\n # Pulse the title\n self.play(\n title.animate.scale(1.2),\n run_time=0.5,\n rate_func=there_and_back\n )\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a Manim animation showcasing a mathematical equation, transforming text, a grid, and a non-linear grid transformation.", "chosen": "```python\nfrom manim import *\n\nclass OpeningManim(Scene):\n def construct(self):\n title = Tex(r\"This is some \\LaTeX\")\n basel = MathTex(r\"\\sum_{n=1}^\\infty \\frac{1}{n^2} = \\frac{\\pi^2}{6}\")\n VGroup(title, basel).arrange(DOWN)\n self.play(\n Write(title),\n FadeIn(basel, shift=DOWN),\n )\n self.wait()\n\n transform_title = Tex(\"That was a transform\")\n transform_title.to_corner(UP + LEFT)\n self.play(\n Transform(title, transform_title),\n LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),\n )\n self.wait()\n\n grid = NumberPlane()\n grid_title = Tex(\"This is a grid\", font_size=72)\n grid_title.move_to(transform_title)\n\n self.add(grid, grid_title) # Make sure title is on top of grid\n self.play(\n FadeOut(title),\n FadeIn(grid_title, shift=UP),\n Create(grid, run_time=3, lag_ratio=0.1),\n )\n self.wait()\n\n grid_transform_title = Tex(\n r\"That was a non-linear function \\\\ applied to the grid\"\n )\n grid_transform_title.move_to(grid_title, UL)\n grid.prepare_for_nonlinear_transform()\n self.play(\n grid.animate.apply_function(\n lambda p: p\n + np.array(\n [\\\n np.sin(p[1]),\\\n np.sin(p[0]),\\\n 0,\\\n ]\n )\n ),\n run_time=3,\n )\n self.wait()\n self.play(Transform(grid_title, grid_transform_title))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass OpeningManim(Scene):\n def construct(self):\n title = Tex(r\"This is some \\LaTeX\")\n basel = MathTex(r\"\\sum_{n=1}^\\infty \\frac{1}{n^2} = \\frac{\\pi^2}{6}\")\n VGroup(title, basel).arrange(DOWN)\n self.play(\n Write(title),\n FadeIn(basel, shift=DOWN),\n )\n self.wait()\n\n transform_title = Tex(\"That was a transform\")\n transform_title.to_corner(UP + LEFT)\n self.play(\n Transform(title, transform_title),\n LaggedStart(*[FadeOut(obj, shift=DOWN) for obj in basel]),\n )\n self.wait()\n\n grid = NumberPlane()\n grid_title = Tex(\"This is a grid\", font_size=72)\n grid_title.move_to(transform_title)\n\n self.add(grid, grid_title) # Make sure title is on top of grid\n self.play(\n FadeOut(title),\n FadeIn(grid_title, shift=UP),\n Create(grid, run_time=3, lag_ratio=0.1),\n )\n self.wait()\n\n grid_transform_title = Tex(\n r\"That was a non-linear function \\\\ applied to the grid\"\n )\n grid_transform_title.move_to(grid_title, UL)\n grid.prepare_for_nonlinear_transform()\n self.play(\n grid.animate.apply_function(\n lambda p: p\n + np.array(\n [\\\n np.sin(p[1]),\\\n np.sin(p[0]),\\\n 0,\\\n ]\n )\n ),\n run_time=3,\n )\n self.wait()\n self.play(Transform(grid_title, grid_transform_title))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Sentiment Analysis\n\n#### The Role of Semantic Analysis in Sentiment Analysis\n- Understanding the semantic content of emotional expressions, not only judging polarity but also analyzing the causes of emotions.\n- Identifying the subject, object (Aspect), and degree of emotion to achieve fine-grained emotional mining.\n\n\nThe context location of this section (from highest to current level):\n# Word Vector Similarity Calculation\n## Applications of Semantic Analysis\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SentimentAnalysisScene(Scene):\n\n def construct(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```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SentimentAnalysisScene(Scene):\n\n def construct(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=BBLUE, 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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a multi-act ManimCE scene (`AttentionGridScene`) showing 4 token `RoundedRectangle` boxes, `Arrow` Q/K/V projections, and a 4x4 attention `VGroup(*rows)` heatmap.", "chosen": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def clear_stage(self):\n if self.mobjects:\n for mobj in self.mobjects:\n mobj.animate.scale(0).shift(RIGHT*10 + DOWN*10)\n self.wait(0.1)\n\n def construct(self):\n # --- Act 1: Token Grid ---\n tokens = VGroup(\n RoundedRectangle(width=1.2, height=0.8, corner_radius=0.2) for _ in range(4)\n ).arrange(DOWN, buff=0.4).scale(0.75)\n\n labels = [\"Q\", \"K\", \"V\", \"\"]\n label_nodes = VGroup()\n for i, token in enumerate(tokens):\n node_label = Text(labels[i], font_size=24, color=WHITE)\n node_label.move_to(token.get_center())\n label_nodes.add(node_label)\n\n title_text = Tex(\"Token Sequence\").to_edge(UP, buff=0.5)\n title_box = SurroundingRectangle(title_text, color=BLUE, buff=0.2)\n\n self.play(FadeIn(title_text), Create(title_box))\n for box, label in zip(tokens, label_nodes):\n self.play(Create(box), Write(label))\n\n self.wait()\n\n # --- Transition to Attention Grid ---\n self.clear_stage()\n\n # --- Act 2: Matrix Representation of Attention ---\n matrix_grid = VGroup()\n rows = []\n colors = [RED, GREEN, YELLOW, BLUE]\n\n for row_idx in range(4):\n row = VGroup()\n for col_idx in range(4):\n cell = Square(side_length=0.6, color=colors[col_idx])\n cell.shift(LEFT*(col_idx - 1.5))\n text_value = MathTex(str(row_idx + 1)).move_to(cell)\n \n if row_idx == col_idx:\n highlight_rect = SurroundingRectangle(text_value, color=YELLOW, buff=0.05, stroke_width=2)\n \n else:\n highlight_rect = Rectangle(height=1.5, width=1, color=colors[col_idx])\n\n cell_group = VGroup(highlight_rect, cell, text_value)\n row.add(cell_group)\n \n cells_with_labels = VGroup(*row.arrange(RIGHT, buff=0.1))\n row_arrangement = cells_with_labels.arrange(DOWN, buff=0.3)\n rows.append(row_arrangement)\n \n matrix_grid.add(VGroup(*rows).arrange(RIGHT, buff=0.6).center())\n\n grid_title = Tex(\"Matrix Formulation of Attention\")\n grid_title.to_edge(UP, buff=0.5)\n\n self.play(Write(grid_title))\n self.wait(0.5)\n for row in rows:\n self.play(LaggedStartMap(Create, row, lag_ratio=0.2))\n self.wait(2)\n\n # Animate the transformation of the matrix elements into arrows\n arrow_groups = []\n for row_idx, row in enumerate(rows):\n arrows = VGroup()\n for col_idx, element in enumerate(row):\n if element[1].get_height(): # Check if it's not empty\n source = element[1].get_bottom()\n target = element[2].get_top()\n arrow = Arrow(source, target, buff=0.1, max_tip_length_to_length_ratio=0.2)\n arrows.add(arrow)\n arrow_groups.append(arrows)\n\n for arrows in arrow_groups:\n self.play(LaggedStartMap(GrowArrow, arrows, lag_ratio=0.3))\n\n self.wait(2)\n self.play(FadeOut(matrix_grid), FadeOut(grid_title))\n \n # --- End Scene ---\n\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n # --- Configuration ---\n NUM_TOKENS = 4\n TOKEN_SIZE = 1.0\n ATTENTION_COLOR = BLUE_D\n \n # Create Tokens\n tokens = VGroup()\n for i in range(NUM_TOKENS):\n box = RoundedRectangle(\n width=TOKEN_SIZE, \n height=TOKEN_SIZE, \n corner_radius=0.15,\n fill_color=GRAY_B, \n fill_opacity=0.7\n )\n label = Text(str(i), font_size=26).move_to(box.get_center())\n token_group = VGroup(box, label)\n tokens.add(token_group)\n\n # Position Tokens in a grid pattern\n row_spacing = TOKEN_SIZE + 0.8\n col_spacing = TOKEN_SIZE + 0.8\n start_pos = LEFT * 3.2 + DOWN * 1.5\n\n for i, token in enumerate(tokens):\n x = (i % 2) * col_spacing - TOKEN_SIZE - 0.2\n y = -(i // 2) * row_spacing + TOKEN_SIZE + 0.2\n pos = start_pos + np.array([x, y, 0])\n token.move_to(pos)\n\n self.play(Create(tokens))\n \n # Add Arrow Projections\n arrows = []\n labels = [\"Q\", \"K\", \"V\"]\n \n for index, token_label in enumerate(labels):\n arrow_start = tokens[index].get_bottom() + UP * 0.2\n \n arrow_end = tokens[(index + 1) % 4].get_top() + DOWN * 0.1\n arrow = Arrow(arrow_start, arrow_end, buff=0.1, color=YELLOW)\n \n text = MathTex(token_label).next_to(arrow, RIGHT, buff=-0.1)\n group = VGroup(arrow, text)\n arrows.append(group)\n \n self.play(GrowArrow(arrow), Write(text))\n\n self.wait(1)\n \n # Create Heatmap Grid\n heatmap_grid = VGroup()\n \n for r in range(NUM_TOKENS): # Rows\n row = VGroup()\n for c in range(NUM_TOKENS): # Columns\n cell_rect = Rectangle(\n width=TOKEN_SIZE, \n height=TOKEN_SIZE, \n stroke_width=1,\n stroke_color=WHITE,\n fill_opacity=0.1\n )\n \n if r == c:\n # Diagonal cells highlight active connections\n cell_rect.fill_color = YELLOW\n cell_rect.fill_opacity = 0.3\n \n else:\n # Off-diagonal cells show attention weights\n weight = np.random.uniform(0.1, 0.8) \n opacity = max(weight, 0.1) # Ensure at least some visibility\n cell_rect.fill_color = ATTENTION_COLOR\n cell_rect.fill_opacity = opacity\n \n cell_text = Text(str(round(opacity, 1)), font_size=20).move_to(cell_rect.get_center())\n cell_group = VGroup(cell_rect, cell_text)\n row.add(cell_group)\n heatmap_grid.add(row)\n \n # Arrange rows vertically, centered below the tokens\n heatmap_grid.arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n heat_start_y = tokens[-1].get_bottom()[1]\n target_y = heat_start_y -TOKEN_SIZE*NUM_TOKENS-0.5\n \n for row in heatmap_grid:\n row.shift(RIGHT * 4.2 + DOWN * (heat_start_y - row.get_center()[1]))\n \n # Animate creation of each column sequentially\n for col_idx in range(NUM_TOKENS):\n current_col = VGroup()\n for r in range(NUM_TOKENS):\n current_row = heatmap_grid[r]\n cell = current_row[col_idx]\n current_col.add(cell)\n \n # Highlight current position while building up the column\n if r < col_idx:\n current_col[0:r+1].set_fill(opacity=max(current_col[0:r+1][r].get_fill_opacity(), 0.1))\n \n self.play(FadeIn(current_col, shift=RIGHT * 0.3), run_time=0.8)\n \n # Update global state after animation completes\n for r in range(NUM_TOKENS):\n current_row = heatmap_grid[r]\n old_cell = current_row[col_idx]\n new_cell = old_cell.copy().shift(UP*(col_idx-r)*TOKEN_SIZE/NUM_TOKENS)\n current_row[col_idx] = new_cell\n\n self.wait(2)\n \n # Final Reveal: Move everything to center\n final_tokens = tokens.copy().arrange(RIGHT, buff=1.2).scale(1.0).to_edge(UP)\n final_heatmap = heatmap_grid.copy().arrange(RIGHT, buff=0.5).scale(0.9).to_edge(DOWN)\n final_arrows = VGroup(*arrows).arrange(RIGHT, buff=1.5).scale(0.8).to_edge(UP)\n \n \n self.play(\n FadeOut(final_arrows),\n FadeIn(final_tokens, scale=1.0),\n FadeIn(final_heatmap, scale=1.0),\n run_time=1.5\n )\n\n self.wait(3)\n \n self.clear()\n self.wait()\n\n# To render this scene, save it as 'attention_scene.py' and run:\n# manim -pql attention_scene.py AttentionGridScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Snapshot Isolation (快照隔离)\n- At the start of a transaction, a database snapshot is obtained, and subsequent operations are based on this snapshot.\n- This greatly improves the concurrency performance of read operations and is often used to achieve the effect of \"repeatable read\" level.\n\n\nThe context location of this section (from highest to current level):\n# Concurrency Control and Isolation Level Basics\n## Introduction to Multi-Version Concurrency Control (MVCC)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SnapshotIsolation(Scene):\n\n def construct(self):\n title = Text('Concurrency Control and Isolation Levels', font_size=32, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('MVCC: Snapshot Isolation', font_size=26, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(0.5)\n blist = BulletedList('At the start of a transaction, a database snapshot is obtained,\\nand subsequent operations are based on this snapshot.', 'This greatly improves the concurrency performance of read operations\\nand is often used to achieve the \"repeatable read\" level.', font_size=24, buff=0.5)\n blist.next_to(subtitle, DOWN, buff=0.6).to_edge(LEFT, buff=1)\n self.play(FadeIn(blist[0], shift=RIGHT))\n self.wait(1)\n diagram = VGroup()\n db_timeline = NumberLine(x_range=[0, 10, 1], length=8, include_numbers=False, include_tip=True)\n db_label = Text('Database State', font_size=20, color=BLUE).next_to(db_timeline, LEFT)\n tx_timeline = NumberLine(x_range=[0, 8, 1], length=6.4, include_numbers=False, include_tip=True)\n tx_timeline.align_to(db_timeline, LEFT).shift(RIGHT * 1.6 + DOWN * 1.5)\n tx_label = Text('Transaction', font_size=20, color=YELLOW).next_to(tx_timeline, LEFT)\n snapshot_dot = Dot(db_timeline.n2p(2), color=GREEN)\n snapshot_text = Text('Snapshot Obtained', font_size=16, color=GREEN).next_to(snapshot_dot, UP)\n tx_start_dot = Dot(tx_timeline.n2p(0), color=YELLOW)\n link_line = DashedLine(snapshot_dot.get_center(), tx_start_dot.get_center(), color=GREEN)\n read_dot = Dot(tx_timeline.n2p(3), color=WHITE)\n read_text = Text('Read Operation', font_size=16).next_to(read_dot, DOWN)\n read_arrow = Arrow(read_dot.get_center(), snapshot_dot.get_center(), buff=0.1, color=GREEN, max_tip_length_to_length_ratio=0.08)\n diagram.add(db_timeline, db_label, tx_timeline, tx_label, snapshot_dot, snapshot_text, tx_start_dot, link_line, read_dot, read_text, read_arrow)\n diagram.move_to(DOWN * 1.8)\n self.play(Create(db_timeline), Write(db_label))\n self.play(Create(tx_timeline), Write(tx_label))\n self.wait(0.5)\n self.play(FadeIn(snapshot_dot, scale=0.5), Write(snapshot_text))\n self.play(Create(link_line), FadeIn(tx_start_dot, scale=0.5))\n self.wait(1)\n self.play(FadeIn(read_dot, scale=0.5), Write(read_text))\n self.play(GrowArrow(read_arrow))\n self.wait(1)\n self.play(FadeIn(blist[1], shift=RIGHT))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SnapshotIsolation(Scene):\n\n def construct(self):\n title = Text('Concurrency Control and Isolation Levels', font_size=32, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('MVCC: Snapshot Isolation', font_size=26, color=BBLUE)\n subtitle.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(0.5)\n blist = BulletedList('At the start of a transaction, a database snapshot is obtained,\\nand subsequent operations are based on this snapshot.', 'This greatly improves the concurrency performance of read operations\\nand is often used to achieve the \"repeatable read\" level.', font_size=24, buff=0.5)\n blist.next_to(subtitle, DOWN, buff=0.6).to_edge(LEFT, buff=1)\n self.play(FadeIn(blist[0], shift=RIGHT))\n self.wait(1)\n diagram = VGroup()\n db_timeline = NumberLine(x_range=[0, 10, 1], length=8, include_numbers=False, include_tip=True)\n db_label = Text('Database State', font_size=20, color=BLUE).next_to(db_timeline, LEFT)\n tx_timeline = NumberLine(x_range=[0, 8, 1], length=6.4, include_numbers=False, include_tip=True)\n tx_timeline.align_to(db_timeline, LEFT).shift(RIGHT * 1.6 + DOWN * 1.5)\n tx_label = Text('Transaction', font_size=20, color=YELLOW).next_to(tx_timeline, LEFT)\n snapshot_dot = Dot(db_timeline.n2p(2), color=GREEN)\n snapshot_text = Text('Snapshot Obtained', font_size=16, color=GREEN).next_to(snapshot_dot, UP)\n tx_start_dot = Dot(tx_timeline.n2p(0), color=YELLOW)\n link_line = DashedLine(snapshot_dot.get_center(), tx_start_dot.get_center(), color=GREEN)\n read_dot = Dot(tx_timeline.n2p(3), color=WHITE)\n read_text = Text('Read Operation', font_size=16).next_to(read_dot, DOWN)\n read_arrow = Arrow(read_dot.get_center(), snapshot_dot.get_center(), buff=0.1, color=GREEN, max_tip_length_to_length_ratio=0.08)\n diagram.add(db_timeline, db_label, tx_timeline, tx_label, snapshot_dot, snapshot_text, tx_start_dot, link_line, read_dot, read_text, read_arrow)\n diagram.move_to(DOWN * 1.8)\n self.play(Create(db_timeline), Write(db_label))\n self.play(Create(tx_timeline), Write(tx_label))\n self.wait(0.5)\n self.play(FadeIn(snapshot_dot, scale=0.5), Write(snapshot_text))\n self.play(Create(link_line), FadeIn(tx_start_dot, scale=0.5))\n self.wait(1)\n self.play(FadeIn(read_dot, scale=0.5), Write(read_text))\n self.play(GrowArrow(read_arrow))\n self.wait(1)\n self.play(FadeIn(blist[1], shift=RIGHT))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here is the enhanced animation instruction that builds upon the original while adding significant new features:\n\nThe enhanced animation will begin by drawing the original green diagonal line from (1,1) to (-1,-1), but will now include a dynamic transformation sequence where the line first appears as a dot at the origin that grows outward in both directions simultaneously, accompanied by a glowing effect. As the line reaches its full length, the scene will reveal a coordinate system in the background with axes labels, and the equation y = -x will fade in above the line to mathematically represent its slope. The line will then transform into a rotating right triangle (with the hypotenuse being the original line) that demonstrates the Pythagorean theorem, showing how the sum of the squares of the legs equals the square of the hypotenuse through animated text and calculations that appear alongside the triangle. Finally, the triangle will morph back into the original line while the equation transforms into its parametric form (x(t), y(t)) = (t, -t), with t values from -1 to 1 appearing as moving points along the line to visualize the parameterization. Throughout the animation, smooth transitions and color gradients will be used to highlight the mathematical concepts being demonstrated.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedLineAnimation(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\n \"numbers_to_include\": [-1, 0, 1],\n \"numbers_with_elongated_ticks\": [-1, 0, 1],\n },\n y_axis_config={\n \"numbers_to_include\": [-1, 0, 1],\n \"numbers_with_elongated_ticks\": [-1, 0, 1],\n },\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create line that grows from dot\n line = Line(start=ORIGIN, end=ORIGIN, color=GREEN, stroke_width=8)\n growing_line = line.copy().set_points_as_corners([UP + LEFT, ORIGIN, DOWN + RIGHT])\n \n # Create equation\n equation = MathTex(\"y = -x\").to_edge(UP)\n parametric_eq = MathTex(r\"(x(t), y(t)) = (t, -t),\\ t \\in [-1,1]\").to_edge(UP)\n \n # Create dot that will move along the line\n dot = Dot(color=RED).move_to(line.get_start())\n \n # Create triangle\n triangle = Polygon(\n LEFT + UP, ORIGIN, RIGHT + DOWN,\n color=YELLOW, fill_opacity=0.5\n )\n a_label = MathTex(\"1\").next_to(Line(ORIGIN, LEFT + UP), LEFT, buff=0.1)\n b_label = MathTex(\"1\").next_to(Line(ORIGIN, RIGHT + DOWN), DOWN, buff=0.1)\n c_label = MathTex(r\"\\sqrt{2}\").move_to(UP * 0.3 + RIGHT * 0.3)\n pythagoras = MathTex(r\"1^2 + 1^2 = (\\sqrt{2})^2\").to_edge(DOWN)\n \n # Animation sequence\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n \n # Line growth animation\n self.play(\n GrowFromCenter(line),\n run_time=1.5,\n rate_func=rate_functions.ease_out_sine\n )\n self.play(\n Transform(line, growing_line),\n run_time=1.5,\n rate_func=rate_functions.ease_out_sine\n )\n self.play(\n line.animate.set_color(interpolate_color(GREEN, WHITE, 0.3)),\n Flash(line, color=GREEN, line_length=1, flash_radius=1.3),\n run_time=1\n )\n self.play(Write(equation))\n self.wait(1)\n \n # Transform to triangle\n self.play(\n Transform(line, triangle),\n FadeOut(equation),\n run_time=1.5\n )\n self.play(\n Write(a_label),\n Write(b_label),\n Write(c_label),\n run_time=1\n )\n self.play(Write(pythagoras))\n self.wait(2)\n \n # Transform back to line\n self.play(\n Transform(line, growing_line),\n FadeOut(a_label),\n FadeOut(b_label),\n FadeOut(c_label),\n FadeOut(pythagoras),\n run_time=1.5\n )\n self.play(Transform(equation, parametric_eq))\n \n # Animate moving dot\n self.play(\n MoveAlongPath(dot, line),\n run_time=3,\n rate_func=rate_functions.linear\n )\n self.wait(1)\n \n # Final fade out\n self.play(\n FadeOut(line),\n FadeOut(dot),\n FadeOut(equation),\n FadeOut(axes),\n FadeOut(axes_labels),\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedLineAnimation(Scene):\n def construct(self):\n # Create axes\n axes = Axes(font_size=24, \n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\n \"numbers_to_include\": [-1, 0, 1],\n \"numbers_with_elongated_ticks\": [-1, 0, 1],\n },\n y_axis_config={\n \"numbers_to_include\": [-1, 0, 1],\n \"numbers_with_elongated_ticks\": [-1, 0, 1],\n },\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create line that grows from dot\n line = Line(start=ORIGIN, end=ORIGIN, color=GREEN, stroke_width=8)\n growing_line = line.copy().set_points_as_corners([UP + LEFT, ORIGIN, DOWN + RIGHT])\n \n # Create equation\n equation = MathTex(\"y = -x\").to_edge(UP)\n parametric_eq = MathTex(r\"(x(t), y(t)) = (t, -t),\\ t \\in [-1,1]\").to_edge(UP)\n \n # Create dot that will move along the line\n dot = Dot(color=RED).move_to(line.get_start())\n \n # Create triangle\n triangle = Polygon(\n LEFT + UP, ORIGIN, RIGHT + DOWN,\n color=YELLOW, fill_opacity=0.5\n )\n a_label = MathTex(\"1\").next_to(Line(ORIGIN, LEFT + UP), LEFT, buff=0.1)\n b_label = MathTex(\"1\").next_to(Line(ORIGIN, RIGHT + DOWN), DOWN, buff=0.1)\n c_label = MathTex(r\"\\sqrt{2}\").move_to(UP * 0.3 + RIGHT * 0.3)\n pythagoras = MathTex(r\"1^2 + 1^2 = (\\sqrt{2})^2\").to_edge(DOWN)\n \n # Animation sequence\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n \n # Line growth animation\n self.play(\n GrowFromCenter(line),\n run_time=1.5,\n rate_func=rate_functions.ease_out_sine\n )\n self.play(\n Transform(line, growing_line),\n run_time=1.5,\n rate_func=rate_functions.ease_out_sine\n )\n self.play(\n line.animate.set_color(interpolate_color(GREEN, WHITE, 0.3)),\n Flash(line, color=GREEN, line_length=1, flash_radius=1.3),\n run_time=1\n )\n self.play(Write(equation))\n self.wait(1)\n \n # Transform to triangle\n self.play(\n Transform(line, triangle),\n FadeOut(equation),\n run_time=1.5\n )\n self.play(\n Write(a_label),\n Write(b_label),\n Write(c_label),\n run_time=1\n )\n self.play(Write(pythagoras))\n self.wait(2)\n \n # Transform back to line\n self.play(\n Transform(line, growing_line),\n FadeOut(a_label),\n FadeOut(b_label),\n FadeOut(c_label),\n FadeOut(pythagoras),\n run_time=1.5\n )\n self.play(Transform(equation, parametric_eq))\n \n # Animate moving dot\n self.play(\n MoveAlongPath(dot, line),\n run_time=3,\n rate_func=rate_functions.linear\n )\n self.wait(1)\n \n # Final fade out\n self.play(\n FadeOut(line),\n FadeOut(dot),\n FadeOut(equation),\n FadeOut(axes),\n FadeOut(axes_labels),\n run_time=1\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an animation that shows the wave equation for a vibrating string, followed by displaying the speed of light. Then, move the wave equation to the top of the screen and place the speed of light directly below it. Afterward, add a text explanation beneath them stating that the general solution to the wave equation involves sine and cosine functions, or exponentials with an imaginary argument. Next, transform the wave equation into an example solution involving a combination of cosine and sine functions, and replace the explanatory text with a new one that indicates the waves are traveling in the x direction. Finally, clear the screen by fading everything out.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationScene(Scene):\n def construct(self):\n # --- Step 1: Initial Display ---\n # Create the wave equation and display the speed of light\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n ).to_edge(LEFT).shift(DOWN * 1)\n\n speed_light = MathTex(\"c \\\\approx 3 \\\\times 10^8 \\\\text{ m/s}\", font_size=40).next_to(wave_eq, DOWN, buff=0.6)\n\n self.play(Write(wave_eq))\n self.play(Write(speed_light))\n\n # Wait briefly after initial display\n self.wait(1)\n\n # --- Step 2: Reorganization ---\n # Move the wave equation to the top and position the speed of light directly below it\n self.play(\n wave_eq.animate.to_edge(UP),\n speed_light.animate.next_to(wave_eq, DOWN, buff=1)\n )\n\n # Add the explanatory text below the equations\n explanation = Text(\n \"The general solution involves sine and cosine functions,\\nor exponentials with an imaginary argument.\",\n font_size=28,\n color=WHITE\n ).next_to(speed_light, DOWN, buff=0.7)\n\n self.play(Write(explanation))\n\n # Wait briefly after reorganization\n self.wait(1.5)\n\n # --- Step 3: Transformation & Replacement ---\n # Transform the wave equation into an example solution\n specific_solution = MathTex(\n r\"u(x,t) = A \\cos(kx - \\omega t)\",\n font_size=48\n ).move_to(wave_eq.get_center())\n\n self.play(Transform(wave_eq, specific_solution))\n\n # Replace the explanatory text with a new statement about travel direction\n travel_text = Text(\n \"This represents waves traveling in the positive x-direction.\",\n font_size=28,\n color=GREEN\n ).match_width(explanation).next_to(speed_light, DOWN, buff=0.7).center()\n\n self.play(ReplacementTransform(explanation, travel_text))\n\n # Wait briefly after transformation\n self.wait(2)\n\n # --- Step 4: Cleanup ---\n # Clear the screen by fading everything out simultaneously\n all_objects = VGroup(wave_eq, speed_light, travel_text)\n \n self.play(FadeOut(all_objects, shift=DOWN))\n \n # Final pause\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationScene(Scene):\n def construct(self):\n # --- Step 1: Display Initial Equations ---\n \n # Create the wave equation for a vibrating string\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c\", \"^2 \\\\nabla ^2 u\"\n )\n wave_eq.scale(0.8)\n \n # Create the constant representing the speed of light\n c_eq = MathTex(\"c\", \"=\", \"\\\\frac{\\\\lambda}{T}\")\n c_eq.next_to(wave_eq, DOWN, buff=0.6).scale(0.7)\n\n self.play(Write(wave_eq))\n self.play(Write(c_eq))\n self.wait(1)\n\n # Move equations to specified positions\n self.play(\n wave_eq.animate.to_edge(UP),\n c_eq.animate.next_to(wave_eq, DOWN, buff=0.6)\n )\n\n # Add explanation text\n exp_text = Text(\n \"The general solution involves sine and cosine functions,\\nor exponentials with an imaginary argument.\"\n ).to_edge(DOWN).set_color(YELLOW)\n \n self.play(Write(exp_text))\n self.wait(2)\n\n # Transform the wave equation into a specific solution\n sol_eq = MathTex(\n r\"u(x,t)\", \"=\", \"A\", \"\\\\cos(kx - \\omega t)\"\n )\n sol_eq.move_to(wave_eq) # Reuse the original position\n\n # Replace explanation text with new information about direction\n dir_text = Text(\n \"Waves are propagating in the positive x-direction.\",\n font_size=24,\n color=YELLOW\n ).next_to(sol_eq, DOWN, buff=0.5)\n\n # Animate transformations and replacements sequentially\n self.play(TransformMatchingTex(wave_eq, sol_eq)) # Morph the first equation\n self.play(FadeOut(exp_text))\n self.play(Write(dir_text))\n\n # --- Final Action: Clear Screen ---\n self.wait(1)\n all_objects = VGroup(wav_eq, c_eq, sol_eq, dir_text)\n self.fade_out(all_objects)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralFTC(Scene):\n \"\"\"\n Animation demonstrating the Fundamental Theorem of Calculus (FTC) \n by solving the definite integral of x^3 from 1 to 2.\n \"\"\"\n def construct(self):\n # =====================================================================\n # Step 1: Initial Display\n # Render the definite integral of x^3 with bounds from 1 to 2.\n # =====================================================================\n integral_expr = MathTex(r\"\\int_{1}^{2} x^3 \\, dx\")\n integral_expr.scale(1.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # =====================================================================\n # Step 2: Concept Introduction\n # Display a text explanation of the Fundamental Theorem of Calculus \n # at the top of the screen.\n # =====================================================================\n ftc_title = Text(\"Fundamental Theorem of Calculus\", font_size=32).to_edge(UP)\n ftc_title.set_color(BLUE)\n \n ftc_desc = MathTex(r\"\\int_{a}^{b} f(x) \\, dx = F(b) - F(a)\").next_to(ftc_title, DOWN, buff=0.3)\n \n header = VGroup(ftc_title, ftc_desc).arrange(DOWN, buff=0.3).to_edge(UP)\n \n # Move the integral down to make room for the theorem statement\n self.play(integral_expr.animate.shift(DOWN * 1.5))\n self.play(Write(ftc_title), FadeIn(ftc_desc, shift=DOWN * 0.3))\n self.wait(2)\n\n # =====================================================================\n # Step 3: Anti-derivative Visualization\n # Show the calculated anti-derivative of the function x^3.\n # =====================================================================\n antiderivative_text = Text(\"Find the anti-derivative F(x):\", font_size=24).next_to(integral_expr, DOWN, buff=0.5)\n antiderivative_val = MathTex(r\"F(x) = \\frac{x^4}{4}\").next_to(antiderivative_text, DOWN)\n \n self.play(Write(antiderivative_text))\n self.play(Write(antiderivative_val))\n self.wait(1)\n\n # =====================================================================\n # Step 4: Evaluation Step\n # Visually demonstrate evaluating the anti-derivative at the upper \n # bound (2) and lower bound (1), followed by displaying the subtraction.\n # =====================================================================\n eval_bracket = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{1}^{2}\").next_to(integral_expr, RIGHT, buff=0.5)\n \n # The subtraction operation F(2) - F(1)\n subtraction_step = MathTex(\n r\"= \\frac{2^4}{4} - \\frac{1^4}{4}\"\n ).next_to(eval_bracket, DOWN, aligned_edge=LEFT)\n \n self.play(Write(eval_bracket))\n self.wait(1)\n \n # Color code the bounds for clarity: green for upper, red for lower\n subtraction_step[0][1:2].set_color(GREEN) # Upper bound 2\n subtraction_step[0][5:6].set_color(RED) # Lower bound 1\n \n self.play(Write(subtraction_step))\n self.wait(2)\n\n # =====================================================================\n # Step 5: Emphasis\n # Add a specific text annotation highlighting the importance of the \n # subtraction step in finding the definite integral.\n # =====================================================================\n emphasis_text = Text(\n \"Subtract the evaluation of the lower bound from the upper bound.\", \n font_size=24, \n color=YELLOW\n ).to_edge(DOWN, buff=1)\n \n self.play(FadeIn(emphasis_text, shift=UP * 0.3))\n self.wait(3)\n\n # =====================================================================\n # Step 6: Final Solution\n # Calculate and display the simplified numeric result.\n # =====================================================================\n final_calc = MathTex(\n r\"= \\frac{16}{4} - \\frac{1}{4} = \\frac{15}{4} = 3.75\"\n ).next_to(subtraction_step, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_calc))\n self.wait(3)\n\n # =====================================================================\n # Step 7: Scene Cleanup\n # Clear all intermediate elements from the scene.\n # =====================================================================\n all_elements = VGroup(\n integral_expr, \n header, \n antiderivative_text, \n antiderivative_val, \n eval_bracket, \n subtraction_step, \n emphasis_text, \n final_calc\n )\n \n self.play(FadeOut(all_elements))\n self.wait(1)\n\n # =====================================================================\n # Step 8: Final Emphasis\n # Display only the final solution prominently.\n # =====================================================================\n final_solution = MathTex(r\"\\int_{1}^{2} x^3 \\, dx = \\frac{15}{4}\")\n final_solution.scale(2)\n final_solution.set_color(GOLD)\n \n self.play(Write(final_solution))\n self.play(Circumscribe(final_solution, color=YELLOW))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralFTC(Scene):\n \"\"\"\n Animation demonstrating the Fundamental Theorem of Calculus (FTC) \n by solving the definite integral of x^3 from 1 to 2.\n \"\"\"\n def construct(self):\n # =====================================================================\n # Step 1: Initial Display\n # Render the definite integral of x^3 with bounds from 1 to 2.\n # =====================================================================\n integral_expr = MathTex(r\"\\int_{1}^{2} x^3 \\, dx\")\n integral_expr.scale(1.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # =====================================================================\n # Step 2: Concept Introduction\n # Display a text explanation of the Fundamental Theorem of Calculus \n # at the top of the screen.\n # =====================================================================\n ftc_title = Text(\"Fundamental Theorem of Calculus\", font_size=32).to_edge(UP)\n ftc_title.set_color(BLUE)\n \n ftc_desc = MathTex(r\"\\int_{a}^{b} f(x) \\, dx = F(b) - F(a)\").next_to(ftc_title, DOWN, buff=0.3)\n \n header = VGroup(ftc_title, ftc_desc).arrange(DOWN, buff=0.3).to_edge(UP)\n \n # Move the integral down to make room for the theorem statement\n self.play(integral_expr.animate.shift(DOWN * 1.5))\n self.play(Write(ftc_title), FadeIn(ftc_desc, shift=DOWN * 0.3))\n self.wait(2)\n\n # =====================================================================\n # Step 3: Anti-derivative Visualization\n # Show the calculated anti-derivative of the function x^3.\n # =====================================================================\n antiderivative_text = Text(\"Find the anti-derivative F(x):\", font_size=24).next_to(integral_expr, DOWN, buff=0.5)\n antiderivative_val = MathTex(r\"F(x) = \\frac{x^4}{4}\" + \" = x\").next_to(antiderivative_text, DOWN)\n \n self.play(Write(antiderivative_text))\n self.play(Write(antiderivative_val))\n self.wait(1)\n\n # =====================================================================\n # Step 4: Evaluation Step\n # Visually demonstrate evaluating the anti-derivative at the upper \n # bound (2) and lower bound (1), followed by displaying the subtraction.\n # =====================================================================\n eval_bracket = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{1}^{2}\").next_to(integral_expr, RIGHT, buff=0.5)\n \n # The subtraction operation F(2) - F(1)\n subtraction_step = MathTex(\n r\"= \\frac{2^4}{4} - \\frac{1^4}{4}\"\n ).next_to(eval_bracket, DOWN, aligned_edge=LEFT)\n \n self.play(Write(eval_bracket))\n self.wait(1)\n \n # Color code the bounds for clarity: green for upper, red for lower\n subtraction_step[0][1:2].set_color(GREEN) # Upper bound 2\n subtraction_step[0][5:6].set_color(RED) # Lower bound 1\n \n self.play(Write(subtraction_step))\n self.wait(2)\n\n # =====================================================================\n # Step 5: Emphasis\n # Add a specific text annotation highlighting the importance of the \n # subtraction step in finding the definite integral.\n # =====================================================================\n emphasis_text = Text(\n \"Subtract the evaluation of the lower bound from the upper bound.\", \n font_size=24, \n color=YELLOW\n ).to_edge(DOWN, buff=1)\n \n self.play(FadeIn(emphasis_text, shift=UP * 0.3))\n self.wait(3)\n\n # =====================================================================\n # Step 6: Final Solution\n # Calculate and display the simplified numeric result.\n # =====================================================================\n final_calc = MathTex(\n r\"= \\frac{16}{4} - \\frac{1}{4} = \\frac{15}{4} = 3.75\"\n ).next_to(subtraction_step, DOWN, aligned_edge=LEFT)\n \n self.play(Write(final_calc))\n self.wait(3)\n\n # =====================================================================\n # Step 7: Scene Cleanup\n # Clear all intermediate elements from the scene.\n # =====================================================================\n all_elements = VGroup(\n integral_expr, \n header, \n antiderivative_text, \n antiderivative_val, \n eval_bracket, \n subtraction_step, \n emphasis_text, \n final_calc\n )\n \n self.play(FadeOut(all_elements))\n self.wait(1)\n\n # =====================================================================\n # Step 8: Final Emphasis\n # Display only the final solution prominently.\n # =====================================================================\n final_solution = MathTex(r\"\\int_{1}^{2} x^3 \\, dx = \\frac{15}{4}\")\n final_solution.scale(2)\n final_solution.set_color(GOLD)\n \n self.play(Write(final_solution))\n self.play(Circumscribe(final_solution, color=YELLOW))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass IntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n problem = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", r\" \\, dx\",\n font_size=60,\n color=WHITE\n )\n \n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Explanation Text ---\n explanation_text = Tex(\"Evaluating this definite integral gives us:\", \n tex_to_color_map={\"integral\": YELLOW})\n explanation_text.to_edge(DOWN)\n \n self.play(Write(explanation_text))\n self.wait(1)\n\n # --- Step 3: Power Rule Formula ---\n power_rule = MathTex(\n r\"\\int x^n \\, dx =\", r\"\\frac{x^{n+1}}{n+1}\",\n font_size=48,\n color=BLUE\n ).to_edge(UP)\n\n self.play(Write(power_rule))\n self.wait(1)\n\n # Highlight the specific case where n=2\n box = SurroundingRectangle(VGroup(power_rule[1][0], power_rule[1][2]), buff=0.1)\n self.play(Create(box))\n self.wait(2)\n\n # Clear the intermediate steps for clarity before moving on\n self.play(FadeOut(problem), FadeOut(explanation_text), FadeOut(power_rule))\n\n # Show the antiderivative explicitly\n antideriv = MathTex(\n r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{1}\",\n font_size=72\n )\n antideriv.move_to(ORIGIN)\n\n self.play(Write(antideriv))\n self.wait(1)\n\n # --- Step 4: Apply Limits (Substitution) ---\n substituted = MathTex(\n r\"\\frac{1^3}{3} - \\frac{0^3}{3}\",\n font_size=72\n )\n\n self.play(TransformMatchingTex(antideriv, substituted))\n self.wait(1)\n\n # --- Step 5: Solution Calculation ---\n calculated_value = MathTex(\n r\"\\frac{1}{3} - 0 = \\frac{1}{3}\",\n font_size=72\n )\n\n self.play(TransformMatchingTex(substituted, calculated_value))\n self.wait(2)\n\n # Final Answer Box\n result_box = RoundedRectangle(\n width=2.5, height=1.5, corner_radius=0.3,\n fill_opacity=0.2, stroke_width=2\n )\n result_box.center().shift(UP * 1.5 + LEFT * 3)\n\n final_answer = MathTex(\n r\"\\text{Final Area } A = \", r\"\\frac{1}{3}\",\n font_size=72, color=YELLOW\n )\n final_answer.next_to(result_box, DOWN, buff=0.3).align_to(final_answer[0], LEFT)\n\n self.add(result_box)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- Conclusion Sequence ---\n # Clear all intermediate steps\n intermediate_steps = VGroup(\n problem, explanation_text, power_rule,\n antideriv, substituted, calculated_value,\n result_box, final_answer\n )\n \n self.play(FadeOut(intermediate_steps))\n\n # Re-present only the final solution and explanation\n final_solution = MathTex(\n r\"A = \\frac{1}{3}\"\n ).scale(2).set_color(YELLOW)\n\n final_explanation = Tex(\n \"This numerical value represents the area under the curve $f(x)=x^2$ between $x=0$ and $x=1$.\"\n ).scale(0.7).next_to(final_solution, DOWN, buff=0.5)\n\n self.play(Write(final_solution))\n self.play(Write(final_explanation))\n\n # Hold at the conclusion for emphasis\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Initial Display ---\n title = Text(\"Evaluating the Integral\", font_size=36).to_edge(UP)\n \n initial_integral = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\\\, dx\"\n ).scale(1.8)\n\n self.play(Write(title))\n self.play(Write(initial_integral))\n\n # Pause briefly at the beginning\n self.wait(1.5)\n\n # --- Step 2: Explanation Phase ---\n evaluation_text = Text(\n \"We evaluate the definite integral using the Power Rule.\", \n font_size=28\n )\n evaluation_text.next_to(title, DOWN, buff=0.7)\n\n rule_title = Text(\"Power Rule:\", font_size=32).next_to(evaluation_text, DOWN, buff=0.5)\n power_rule = MathTex(\n r\"\\int u^n \\\\, du = \\frac{u^{n+1}}{n+1}\"\n ).scale(1.2).next_to(rule_title, DOWN, buff=0.3)\n\n self.play(Write(evaluation_text))\n self.play(Write(rule_title))\n self.play(Write(power_rule))\n\n self.wait(2)\n\n # Clear intermediate steps so they don't interfere with calculations\n self.play(FadeOut(evaluation_text), FadeOut(rule_title), FadeOut(power_rule))\n\n # --- Step 3: Calculation Phases ---\n # Apply Limits: Show the antiderivative with substituted upper limit (1) minus lower limit (0)\n calc_step1 = MathTex(\n r\"=\", \"[\", \"(1)^3 \", \"-\", \"(0)^3\", \"]\",\n ).scale(1.8)\n\n self.play(Write(calc_step1))\n\n # Simplify exponentiation results\n calc_simplified = MathTex(\n r\"=\", \"[\", \"1\", \"-\", \"0\", \"]\",\n ).scale(1.8).move_to(calc_step1.get_center())\n\n self.play(TransformMatchingTex(calc_step1, calc_simplified))\n\n # Subtraction step\n subtraction = MathTex(\n r\"=\", \"1\", \"-\",\n ).scale(1.8).move_to(calc_simplified.get_center())\n \n self.play(TransformMatchingTex(calc_simplified, subtraction))\n\n # Final Result: Area represented numerically\n result_final = MathTex(\n r\"=\", \"1\"\n ).scale(1.8).move_to(subtraction.get_center())\n\n self.play(TransformMatchTarget(subtraction, result_final))\n\n self.wait(1.5)\n\n # End state: All math elements displayed sequentially\n\n # --- Conclusion Sequence ---\n # Clear all visual components except the final numerical result and text\n to_clear = VGroup(title, evaluation_text, rule_title, power_rule, calc_step1, calc_simplified, subtraction)\n remaining_mobs = VGroup(result_final, title)\n\n self.play(FadeOut(to_clear), Circumscribe(remaining_mobs))\n\n # Re-present the key insight clearly with emphasis on physical interpretation\n conclusion_text = Text(\n \"This numeric result represents the exact area under the curve\\nbetween x=0 and x=1.\",\n t2c={\"area\": YELLOW},\n line_spacing=1.2,\n font_size=28\n ).to_edge(DOWN)\n\n box = SurroundingRectangle(conclusion_text, color=BLUE, buff=MED_LARGE_BUFF)\n \n self.play(Write(conclusion_text))\n self.play(Create(box))\n self.play(ConstrainPosition(conclusion_text, ORIGIN)) # Center without scaling\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an animation that visualizes the training process of a simple neural network with three layers, where the first layer has 4 neurons, the second layer has 7 neurons, and the third layer has 2 neurons? The neural network should be centered on the screen and the animation should clearly show some kind of training activity or process happening. Also, please ensure the animation ends with a pause so we can see the final state of the network.", "chosen": "```python\nfrom manim import *\nimport random\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Network Architecture Specifications\n layer_sizes = [4, 7, 2]\n layer_colors = [BLUE, GREEN, RED]\n layer_spacing = 3.5\n neuron_spacing = 0.9\n neuron_radius = 0.2\n \n node_layers = []\n nodes = VGroup()\n edges = VGroup()\n \n # Create Nodes for each layer\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_pos = i * layer_spacing\n # Center each layer vertically around y=0\n y_positions = [((size - 1) / 2 - j) * neuron_spacing for j in range(size)]\n for y in y_positions:\n neuron = Circle(radius=neuron_radius, color=layer_colors[i], fill_opacity=1)\n neuron.move_to([x_pos, y, 0])\n layer_group.add(neuron)\n node_layers.append(layer_group)\n nodes.add(layer_group)\n \n # Create Edges between adjacent layers\n for i in range(len(layer_sizes) - 1):\n current_layer = node_layers[i]\n next_layer = node_layers[i + 1]\n for n1 in current_layer:\n for n2 in next_layer:\n edge = Line(n1.get_center(), n2.get_center(), stroke_width=1, color=GRAY)\n edges.add(edge)\n \n # Group everything and center on the screen\n network_group = VGroup(nodes, edges).move_to(ORIGIN)\n \n # Animation: Network Structure Initialization\n self.play(Create(edges), FadeIn(nodes), run_time=2)\n self.wait(0.5)\n \n # Separate edges by layer transition for sequential animation\n edges_l1_l2 = edges[:layer_sizes[0] * layer_sizes[1]]\n edges_l2_l3 = edges[layer_sizes[0] * layer_sizes[1]:]\n \n # Simulate a few \"epochs\" of training: Forward Pass -> Backprop -> Weight Update\n for epoch in range(3):\n # --- Forward Pass (Data Flowing Left to Right) ---\n # Input to Hidden\n particles_1 = VGroup(*[Dot(radius=0.06, color=YELLOW).move_to(e.get_start()) for e in edges_l1_l2])\n self.add(particles_1)\n self.play(\n *[MoveAlongPath(p, e) for p, e in zip(particles_1, edges_l1_l2)],\n run_time=1.2\n )\n self.remove(particles_1)\n \n # Hidden to Output\n particles_2 = VGroup(*[Dot(radius=0.06, color=YELLOW).move_to(e.get_start()) for e in edges_l2_l3])\n self.add(particles_2)\n self.play(\n *[MoveAlongPath(p, e) for p, e in zip(particles_2, edges_l2_l3)],\n run_time=1.2\n )\n self.remove(particles_2)\n \n # --- Backpropagation (Error Flowing Right to Left) ---\n # Output to Hidden\n back_particles_2 = VGroup(*[Dot(radius=0.06, color=ORANGE).move_to(e.get_end()) for e in edges_l2_l3])\n self.add(back_particles_2)\n self.play(\n *[MoveAlongPath(p, Line(e.get_end(), e.get_start())) for p, e in zip(back_particles_2, edges_l2_l3)],\n run_time=1.2\n )\n self.remove(back_particles_2)\n \n # Hidden to Input\n back_particles_1 = VGroup(*[Dot(radius=0.06, color=ORANGE).move_to(e.get_end()) for e in edges_l1_l2])\n self.add(back_particles_1)\n self.play(\n *[MoveAlongPath(p, Line(e.get_end(), e.get_start())) for p, e in zip(back_particles_1, edges_l1_l2)],\n run_time=1.2\n )\n self.remove(back_particles_1)\n \n # --- Weight Update ---\n # Simulate weight updates by randomly changing line colors and thicknesses\n update_animations = []\n for edge in edges:\n new_color = interpolate_color(GRAY, BLUE, random.random())\n new_width = random.uniform(1, 3)\n update_animations.append(edge.animate.set_stroke(color=new_color, width=new_width))\n self.play(*update_animations, run_time=0.8)\n self.wait(0.5)\n \n # Conclusion: Highlight final network state and deliberate pause\n self.play(\n nodes.animate.set_fill(opacity=0.8),\n edges.animate.set_stroke(opacity=1),\n run_time=1\n )\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport random\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Network Architecture Specifications\n layer_sizes = [4, 7, 2]\n layer_colors = [BBLUE, GREEN, RED]\n layer_spacing = 3.5\n neuron_spacing = 0.9\n neuron_radius = 0.2\n \n node_layers = []\n nodes = VGroup()\n edges = VGroup()\n \n # Create Nodes for each layer\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_pos = i * layer_spacing\n # Center each layer vertically around y=0\n y_positions = [((size - 1) / 2 - j) * neuron_spacing for j in range(size)]\n for y in y_positions:\n neuron = Circle(radius=neuron_radius, color=layer_colors[i], fill_opacity=1)\n neuron.move_to([x_pos, y, 0])\n layer_group.add(neuron)\n node_layers.append(layer_group)\n nodes.add(layer_group)\n \n # Create Edges between adjacent layers\n for i in range(len(layer_sizes) - 1):\n current_layer = node_layers[i]\n next_layer = node_layers[i + 1]\n for n1 in current_layer:\n for n2 in next_layer:\n edge = Line(n1.get_center(), n2.get_center(), stroke_width=1, color=GRAY)\n edges.add(edge)\n \n # Group everything and center on the screen\n network_group = VGroup(nodes, edges).move_to(ORIGIN)\n \n # Animation: Network Structure Initialization\n self.play(Create(edges), FadeIn(nodes), run_time=2)\n self.wait(0.5)\n \n # Separate edges by layer transition for sequential animation\n edges_l1_l2 = edges[:layer_sizes[0] * layer_sizes[1]]\n edges_l2_l3 = edges[layer_sizes[0] * layer_sizes[1]:]\n \n # Simulate a few \"epochs\" of training: Forward Pass -> Backprop -> Weight Update\n for epoch in range(3):\n # --- Forward Pass (Data Flowing Left to Right) ---\n # Input to Hidden\n particles_1 = VGroup(*[Dot(radius=0.06, color=YELLOW).move_to(e.get_start()) for e in edges_l1_l2])\n self.add(particles_1)\n self.play(\n *[MoveAlongPath(p, e) for p, e in zip(particles_1, edges_l1_l2)],\n run_time=1.2\n )\n self.remove(particles_1)\n \n # Hidden to Output\n particles_2 = VGroup(*[Dot(radius=0.06, color=YELLOW).move_to(e.get_start()) for e in edges_l2_l3])\n self.add(particles_2)\n self.play(\n *[MoveAlongPath(p, e) for p, e in zip(particles_2, edges_l2_l3)],\n run_time=1.2\n )\n self.remove(particles_2)\n \n # --- Backpropagation (Error Flowing Right to Left) ---\n # Output to Hidden\n back_particles_2 = VGroup(*[Dot(radius=0.06, color=ORANGE).move_to(e.get_end()) for e in edges_l2_l3])\n self.add(back_particles_2)\n self.play(\n *[MoveAlongPath(p, Line(e.get_end(), e.get_start())) for p, e in zip(back_particles_2, edges_l2_l3)],\n run_time=1.2\n )\n self.remove(back_particles_2)\n \n # Hidden to Input\n back_particles_1 = VGroup(*[Dot(radius=0.06, color=ORANGE).move_to(e.get_end()) for e in edges_l1_l2])\n self.add(back_particles_1)\n self.play(\n *[MoveAlongPath(p, Line(e.get_end(), e.get_start())) for p, e in zip(back_particles_1, edges_l1_l2)],\n run_time=1.2\n )\n self.remove(back_particles_1)\n \n # --- Weight Update ---\n # Simulate weight updates by randomly changing line colors and thicknesses\n update_animations = []\n for edge in edges:\n new_color = interpolate_color(GRAY, BLUE, random.random())\n new_width = random.uniform(1, 3)\n update_animations.append(edge.animate.set_stroke(color=new_color, width=new_width))\n self.play(*update_animations, run_time=0.8)\n self.wait(0.5)\n \n # Conclusion: Highlight final network state and deliberate pause\n self.play(\n nodes.animate.set_fill(opacity=0.8),\n edges.animate.set_stroke(opacity=1),\n run_time=1\n )\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 30-second Manim scene that explains a simple receptive field on a grid. Highlight the center and surround regions, then animate how a bright spot in the center produces a different response than one in the surround.", "chosen": "```python\nfrom manim import *\n\nclass NeuroscienceReceptiveFieldStory(Scene):\n def construct(self):\n title = Text(\"Center-Surround Receptive Fields Compare Locations\", font_size=34).to_edge(UP)\n cells = VGroup(*[Square(side_length=0.5, stroke_color=GRAY_B, fill_opacity=0.0) for _ in range(25)]).arrange_in_grid(rows=5, cols=5, buff=0.03).shift(LEFT * 2.2)\n center = SurroundingRectangle(cells[12], color=ORANGE, buff=0.04)\n surround = SurroundingRectangle(VGroup(cells[6], cells[7], cells[8], cells[11], cells[13], cells[16], cells[17], cells[18]), color=BLUE_D, buff=0.06)\n spot_center = Square(side_length=0.42, stroke_width=0, fill_color=YELLOW_D, fill_opacity=0.85).move_to(cells[12])\n spot_surround = Square(side_length=0.42, stroke_width=0, fill_color=YELLOW_D, fill_opacity=0.85).move_to(cells[7])\n response = DecimalNumber(0.0, num_decimal_places=1, font_size=34, color=TEAL_D).to_edge(RIGHT).shift(UP * 0.6)\n response_label = Text(\"response\", font_size=22, color=GRAY_D).next_to(response, DOWN, buff=0.12)\n caption_a = Text(\"A receptive field often distinguishes center input from surround input.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_b = Text(\"A bright center can drive a stronger response than a bright surround.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_c = Text(\"Spatial location matters, not just the presence of light.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), FadeIn(cells), Create(center), Create(surround), FadeIn(response), FadeIn(response_label), FadeIn(caption_a), run_time=5)\n self.play(FadeIn(spot_center), response.animate.set_value(1.0), ReplacementTransform(caption_a, caption_b), run_time=4)\n self.play(ReplacementTransform(spot_center, spot_surround), response.animate.set_value(0.3), ReplacementTransform(caption_b, caption_c), run_time=4)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuroscienceReceptiveFieldStory(Scene):\n def construct(self):\n title = Text(\"Center-Surround Receptive Fields Compare Locations\", font_size=34).to_edge(UP)\n cells = VGroup(*[Square(side_length=0.5, stroke_color=GRAY_B, fill_opacity=0.0) for _ in range(25)]).arrange_in_grid(rows=5, cols=5, buff=0.03).shift(LEFT * 2.2)\n center = SurroundingRectangle(cells[12], color=ORANGE, buff=0.04)\n surround = SurroundingRectangle(VGroup(cells[6], cells[7], cells[8], cells[11], cells[13], cells[16], cells[17], cells[18]), color=BLUE_D, buff=0.06)\n spot_center = Square(side_length=0.42, stroke_width=0, fill_color=YELLOW_D, fill_opacity=0.85).move_to(cells[12])\n spot_surround = Square(side_length=0.42, stroke_width=0, fill_color=YELLOW_D, fill_opacity=0.85).move_to(cells[7])\n response = DecimalNumber(0.0, num_decimal_places=1, font_size=34, color=TEAL_D).to_edge(RIGHT).shift(UP * 0.6)\n response_label = Text(\"response\", font_size=22, color=GRAY_D).next_to(response, DOWN, buff=0.12)\n caption_a = Text(\"A receptive field often distinguishes center input from surround input.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_b = Text(\"A bright center can drive a stronger response than a bright surround.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_c = Text(\"Spatial location matters, not just the presence of light.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), FadeIn(cells), Create(center), Create(surround), FadeIn(response), FadeIn(response_label), FadeIn(caption_a), run_time=5)\n self.play(FadeIn(spot_center), response.animate.set_value(1.0), ReplacementTransform(target_position=ORIGIN, caption_a, caption_b), run_time=4)\n self.play(ReplacementTransform(spot_center, spot_surround), response.animate.set_value(0.3), ReplacementTransform(caption_b, caption_c), run_time=4)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # =====================================================================\n # Step 1: Introduction - Display the standard equation\n # =====================================================================\n intro_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=60)\n self.play(Write(intro_eq))\n self.wait(1)\n \n # Fade out the introduction to prepare for the geometric construction\n self.play(FadeOut(intro_eq))\n \n # =====================================================================\n # Step 2: Triangle Construction - Draw and label sides\n # =====================================================================\n # Define vertices for a 3-4-5 right triangle\n # Vertex A at origin, B on x-axis, C on y-axis\n point_A = ORIGIN\n point_B = RIGHT * 3\n point_C = UP * 4\n \n # Create the triangle polygon\n triangle = Polygon(point_A, point_B, point_C, color=WHITE, stroke_width=4)\n \n # Create labels for the sides\n label_a = MathTex(\"a\", font_size=36).next_to(Line(point_A, point_B), DOWN, buff=0.2)\n label_b = MathTex(\"b\", font_size=36).next_to(Line(point_A, point_C), LEFT, buff=0.2)\n label_c = MathTex(\"c\", font_size=36).next_to(Line(point_B, point_C), UR, buff=0.2)\n \n # Animate creation of triangle and labels\n self.play(Create(triangle))\n self.play(Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # =====================================================================\n # Step 3: Square Generation - Construct squares on each side\n # =====================================================================\n # Define distinct colors for each square corresponding to its side\n color_a = BLUE\n color_b = GREEN\n color_c = RED\n \n # Square on side 'a' (Horizontal leg, length 3)\n square_a = Polygon(\n point_A, point_B, \n point_B + DOWN * 3, \n point_A + DOWN * 3, \n color=color_a, stroke_width=2\n )\n \n # Square on side 'b' (Vertical leg, length 4)\n square_b = Polygon(\n point_A, point_C, \n point_C + LEFT * 4, \n point_A + LEFT * 4, \n color=color_b, stroke_width=2\n )\n \n # Square on side 'c' (Hypotenuse, length 5)\n # Vector BC = C - B = (-3, 4). Outward normal vector is (4, 3).\n outward_normal = np.array([4, 3, 0])\n square_c = Polygon(\n point_B, point_C, \n point_C + outward_normal, \n point_B + outward_normal, \n color=color_c, stroke_width=2\n )\n \n # Animate creation of squares\n self.play(Create(square_a), Create(square_b), Create(square_c))\n \n # Group all geometric elements to center them on screen\n all_geo = VGroup(triangle, label_a, label_b, label_c, square_a, square_b, square_c)\n self.play(all_geo.animate.center())\n self.wait(1)\n \n # =====================================================================\n # Step 4: Equation Transformation - Rearrange and move labels\n # =====================================================================\n # Create the rearranged equation: c^2 = a^2 + b^2\n final_eq = MathTex(\"c^2\", \"=\", \"a^2\", \"+\", \"b^2\", font_size=48)\n final_eq.to_edge(UP, buff=1)\n \n # Write the new equation\n self.play(Write(final_eq))\n \n # Animate the labels moving from the triangle sides to the equation positions\n # ReplacementTransform morphs the side labels into the full equation terms\n self.play(\n ReplacementTransform(label_c, final_eq[0]), # c -> c^2\n ReplacementTransform(label_a, final_eq[2]), # a -> a^2\n ReplacementTransform(label_b, final_eq[4]), # b -> b^2\n run_time=2\n )\n self.wait(1)\n \n # =====================================================================\n # Step 5: Area Highlighting - Color the squares to show relationship\n # =====================================================================\n # Fill the squares with distinct colors and opacity to represent their areas\n self.play(\n square_a.animate.set_fill(color_a, opacity=0.5),\n square_b.animate.set_fill(color_b, opacity=0.5),\n square_c.animate.set_fill(color_c, opacity=0.5),\n run_time=2\n )\n self.wait(2)\n \n # =====================================================================\n # Step 6: Conclusion Sequence\n # =====================================================================\n conclusion_text = Text(\"Pythagorean theorem demonstrated\", font_size=36)\n \n # Display conclusion text\n self.play(Write(conclusion_text))\n self.wait(1)\n \n # Clear the screen completely\n self.play(FadeOut(*self.mobjects))\n self.wait(1)\n \n # Display the conclusion text once more to reinforce the message\n self.play(Write(conclusion_text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # =====================================================================\n # Step 1: Introduction - Display the standard equation\n # =====================================================================\n intro_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=60)\n self.play(Write(intro_eq))\n self.wait(1)\n \n # Fade out the introduction to prepare for the geometric construction\n self.play(FadeOut(intro_eq))\n \n # =====================================================================\n # Step 2: Triangle Construction - Draw and label sides\n # =====================================================================\n # Define vertices for a 3-4-5 right triangle\n # Vertex A at origin, B on x-axis, C on y-axis\n point_A = ORIGIN\n point_B = RIGHT * 3\n point_C = UP * 4\n \n # Create the triangle polygon\n triangle = Polygon(point_A, point_B, point_C, color=WHITE, stroke_width=4)\n \n # Create labels for the sides\n label_a = MathTex(\"a\", font_size=36).next_to(Line(point_A, point_B), DOWN, buff=0.2)\n label_b = MathTex(\"b\", font_size=36).next_to(Line(point_A, point_C), LEFT, buff=0.2)\n label_c = MathTex(\"c\", font_size=36).next_to(Line(point_B, point_C), UR, buff=0.2)\n \n # Animate creation of triangle and labels\n self.play(Create(triangle))\n self.play(Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # =====================================================================\n # Step 3: Square Generation - Construct squares on each side\n # =====================================================================\n # Define distinct colors for each square corresponding to its side\n color_a = BLUE\n color_b = GREEN\n color_c = RED\n \n # Square on side 'a' (Horizontal leg, length 3)\n square_a = Polygon(\n point_A, point_B, \n point_B + DOWN * 3, \n point_A + DOWN * 3, \n color=color_a, stroke_width=2\n )\n \n # Square on side 'b' (Vertical leg, length 4)\n square_b = Polygon(\n point_A, point_C, \n point_C + LEFT * 4, \n point_A + LEFT * 4, \n color=color_b, stroke_width=2\n )\n \n # Square on side 'c' (Hypotenuse, length 5)\n # Vector BC = C - B = (-3, 4). Outward normal vector is (4, 3).\n outward_normal = np.array([4, 3, 0])\n square_c = Polygon(\n point_B, point_C, \n point_C + outward_normal, \n point_B + outward_normal, \n color=color_c, stroke_width=2\n )\n \n # Animate creation of squares\n self.play(Create(square_a), Create(square_b), Create(square_c))\n \n # Group all geometric elements to center them on screen\n all_geo = VGroup(triangle, label_a, label_b, label_c, square_a, square_b, square_c)\n self.play(all_geo.animate.center())\n self.wait(1)\n \n # =====================================================================\n # Step 4: Equation Transformation - Rearrange and move labels\n # =====================================================================\n # Create the rearranged equation: c^2 = a^2 + b^2\n final_eq = MathTex(\"c^2\", \"=\", \"a^2\", \"+\", \"b^2\", font_size=48)\n final_eq.to_edge(UP, buff=1)\n \n # Write the new equation\n self.play(Write(final_eq))\n \n # Animate the labels moving from the triangle sides to the equation positions\n # ReplacementTransform morphs the side labels into the full equation terms\n self.play(\n ReplacementTransform(target_position=ORIGIN, label_c, final_eq[0]), # c -> c^2\n ReplacementTransform(label_a, final_eq[2]), # a -> a^2\n ReplacementTransform(label_b, final_eq[4]), # b -> b^2\n run_time=2\n )\n self.wait(1)\n \n # =====================================================================\n # Step 5: Area Highlighting - Color the squares to show relationship\n # =====================================================================\n # Fill the squares with distinct colors and opacity to represent their areas\n self.play(\n square_a.animate.set_fill(color_a, opacity=0.5),\n square_b.animate.set_fill(color_b, opacity=0.5),\n square_c.animate.set_fill(color_c, opacity=0.5),\n run_time=2\n )\n self.wait(2)\n \n # =====================================================================\n # Step 6: Conclusion Sequence\n # =====================================================================\n conclusion_text = Text(\"Pythagorean theorem demonstrated\", font_size=36)\n \n # Display conclusion text\n self.play(Write(conclusion_text))\n self.wait(1)\n \n # Clear the screen completely\n self.play(FadeOut(*self.mobjects))\n self.wait(1)\n \n # Display the conclusion text once more to reinforce the message\n self.play(Write(conclusion_text))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding significant new elements: \n\nThe animation begins by drawing the central **start_node** at the origin, followed by the **end_nodes** arranged in a 2x2 grid below. The edges connecting them grow dynamically from the start node, each with a slight delay for clarity. As the tree structure forms, **event labels (HH, HT, TH, TT)** appear below the end nodes, and **probability labels (1/4)** are written along each edge. To enhance understanding, a **title (\"Probability Tree for Two Coin Flips\")** fades in at the top, and a **formula (P(Event) = 1/4 for each outcome)** appears beside the tree, explaining the uniform probability distribution. Additionally, **color-coded highlights** pulse along each branch (e.g., red for HH, blue for HT) to visually distinguish the paths. Finally, the **edges transform into arrows** to emphasize directionality, and a **summary box** listing all possible outcomes and their probabilities fades in at the bottom, reinforcing the concept before the scene holds for 2 seconds. This enriched version improves both visual appeal and educational value.", "chosen": "```python\nfrom manim import *\n\nclass ProbabilityTree(Scene):\n def construct(self):\n # Title\n title = Text(\"Probability Tree for Two Coin Flips\", font_size=24).to_edge(UP)\n self.play(FadeIn(title))\n self.wait(0.5)\n\n # Start node\n start_node = Circle(radius=0.3, color=WHITE, fill_opacity=1, fill_color=BLUE)\n start_label = Text(\"Start\", font_size=18).next_to(start_node, UP)\n self.play(Create(start_node), Write(start_label))\n self.wait(0.5)\n\n # End nodes in 2x2 grid\n end_nodes = VGroup(*[\n Circle(radius=0.2, color=WHITE, fill_opacity=1, fill_color=GREEN)\n for _ in range(4)\n ])\n end_nodes.arrange_in_grid(rows=2, cols=2, buff=1.5).shift(DOWN * 1.5)\n end_labels = VGroup(*[\n Text(label, font_size=16).next_to(node, DOWN)\n for label, node in zip([\"HH\", \"HT\", \"TH\", \"TT\"], end_nodes)\n ])\n self.play(\n LaggedStart(*[Create(node) for node in end_nodes], lag_ratio=0.2),\n LaggedStart(*[Write(label) for label in end_labels], lag_ratio=0.2),\n )\n self.wait(0.5)\n\n # Edges with probability labels\n edges = VGroup(*[\n Line(start_node.get_bottom(), node.get_top(), color=YELLOW)\n for node in end_nodes\n ])\n prob_labels = VGroup(*[\n Text(\"1/4\", font_size=16).move_to(\n edge.point_from_proportion(0.5) + UP * 0.2\n )\n for edge in edges\n ])\n for edge, label in zip(edges, prob_labels):\n self.play(Create(edge), Write(label), run_time=0.5)\n self.wait(0.2)\n\n # Color highlights\n colors = [RED, BLUE, PURPLE, ORANGE]\n for i, (node, label) in enumerate(zip(end_nodes, end_labels)):\n highlight = node.copy().set_color(colors[i]).set_stroke(width=5)\n self.play(\n node.animate.set_fill(colors[i], opacity=0.7),\n label.animate.set_color(colors[i]),\n Create(highlight),\n run_time=0.5,\n )\n self.play(FadeOut(highlight))\n self.wait(0.2)\n\n # Transform edges to arrows\n arrows = VGroup(*[\n Arrow(\n start_node.get_bottom(),\n node.get_top(),\n color=YELLOW,\n buff=0.1,\n tip_length=0.2,\n )\n for node in end_nodes\n ])\n self.play(\n *[ReplacementTransform(edge, arrow) for edge, arrow in zip(edges, arrows)]\n )\n self.wait(0.5)\n\n # Formula\n formula = MathTex(r\"P(\\text{Event}) = \\frac{1}{4} \\text{ for each outcome}\").next_to(\n end_nodes, RIGHT, buff=1.5\n )\n self.play(Write(formula))\n self.wait(0.5)\n\n # Summary box\n summary = VGroup(\n Text(\"Possible Outcomes:\", font_size=18),\n *[\n Text(f\"{label}: 1/4\", font_size=16)\n for label in [\"HH\", \"HT\", \"TH\", \"TT\"]\n ],\n )\n summary.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n box = SurroundingRectangle(\n summary, buff=0.5, color=WHITE, corner_radius=0.2\n )\n summary_group = VGroup(box, summary).to_edge(DOWN, buff=0.5)\n self.play(FadeIn(box), Write(summary))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ProbabilityTree(Scene):\n def construct(self):\n # Title\n title = Text(\"Probability Tree for Two Coin Flips\", font_size=24).to_edge(UP)\n self.play(FadeIn(title))\n self.wait(0.5)\n\n # Start node\n start_node = Circle(radius=0.3, color=WHITE, fill_opacity=1, fill_color=BBLUE)\n start_label = Text(\"Start\", font_size=18).next_to(start_node, UP)\n self.play(Create(start_node), Write(start_label))\n self.wait(0.5)\n\n # End nodes in 2x2 grid\n end_nodes = VGroup(*[\n Circle(radius=0.2, color=WHITE, fill_opacity=1, fill_color=GREEN)\n for _ in range(4)\n ])\n end_nodes.arrange_in_grid(rows=2, cols=2, buff=1.5).shift(DOWN * 1.5)\n end_labels = VGroup(*[\n Text(label, font_size=16).next_to(node, DOWN)\n for label, node in zip([\"HH\", \"HT\", \"TH\", \"TT\"], end_nodes)\n ])\n self.play(\n LaggedStart(*[Create(node) for node in end_nodes], lag_ratio=0.2),\n LaggedStart(*[Write(label) for label in end_labels], lag_ratio=0.2),\n )\n self.wait(0.5)\n\n # Edges with probability labels\n edges = VGroup(*[\n Line(start_node.get_bottom(), node.get_top(), color=YELLOW)\n for node in end_nodes\n ])\n prob_labels = VGroup(*[\n Text(\"1/4\", font_size=16).move_to(\n edge.point_from_proportion(0.5) + UP * 0.2\n )\n for edge in edges\n ])\n for edge, label in zip(edges, prob_labels):\n self.play(Create(edge), Write(label), run_time=0.5)\n self.wait(0.2)\n\n # Color highlights\n colors = [RED, BLUE, PURPLE, ORANGE]\n for i, (node, label) in enumerate(zip(end_nodes, end_labels)):\n highlight = node.copy().set_color(colors[i]).set_stroke(width=5)\n self.play(\n node.animate.set_fill(colors[i], opacity=0.7),\n label.animate.set_color(colors[i]),\n Create(highlight),\n run_time=0.5,\n )\n self.play(FadeOut(highlight))\n self.wait(0.2)\n\n # Transform edges to arrows\n arrows = VGroup(*[\n Arrow(\n start_node.get_bottom(),\n node.get_top(),\n color=YELLOW,\n buff=0.1,\n tip_length=0.2,\n )\n for node in end_nodes\n ])\n self.play(\n *[ReplacementTransform(edge, arrow) for edge, arrow in zip(edges, arrows)]\n )\n self.wait(0.5)\n\n # Formula\n formula = MathTex(r\"P(\\text{Event}) = \\frac{1}{4} \\text{ for each outcome}\").next_to(\n end_nodes, RIGHT, buff=1.5\n )\n self.play(Write(formula))\n self.wait(0.5)\n\n # Summary box\n summary = VGroup(\n Text(\"Possible Outcomes:\", font_size=18),\n *[\n Text(f\"{label}: 1/4\", font_size=16)\n for label in [\"HH\", \"HT\", \"TH\", \"TT\"]\n ],\n )\n summary.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n box = SurroundingRectangle(\n summary, buff=0.5, color=WHITE, corner_radius=0.2\n )\n summary_group = VGroup(box, summary).to_edge(DOWN, buff=0.5)\n self.play(FadeIn(box), Write(summary))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Why do spectral methods offer advantages over finite-difference methods for problems with smooth solutions?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SpectralFiniteDifferenceComparison(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Spectral Methods vs Finite-Difference Methods\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Explanation text about smooth solutions\n explanation = Text(\n \"For smooth solutions,\\nSpectral methods often converge faster\\nand require fewer points.\",\n font_size=28,\n t2c={\"smooth\": YELLOW}\n )\n explanation.next_to(title, DOWN, buff=1)\n self.play(FadeIn(explanation))\n \n # Draw equations on the right side\n eq_spectral = MathTex(r\"\\text{Error} \\propto N^{-\\alpha}\", color=GREEN).to_edge(RIGHT, buff=1.5).shift(UP * 1)\n eq_finite = MathTex(r\"\\text{Error} \\propto h^p\", color=RED).next_to(eq_spectral, DOWN, buff=0.5)\n \n # Create labels for each equation\n label_spectral = Text(\"Smooth Solution: High Convergence Rate\", font_size=20, color=GREEN).next_to(eq_spectral, LEFT, buff=0.5)\n label_finite = Text(\"Non-smooth Solutions: Polynomial Error\", font_size=20, color=RED).next_to(eq_finite, LEFT, buff=0.5)\n \n self.play(Write(label_spectral))\n self.play(Write(eq_spectral))\n self.play(Write(label_finite))\n self.play(Write(eq_finite))\n\n # Add dots to illustrate higher accuracy\n dot_high_accuracy = Dot(color=GREEN).move_to([1.2, 1.2, 0])\n dot_low_accuracy = Dot(color=RED).move_to([-1.2, -1.2, 0])\n\n self.add(dot_high_accuracy, dot_low_accuracy)\n\n # Highlight the relationship between high convergence rate and low number of points\n highlight_box = SurroundingRectangle(VGroup(eq_spectral, label_spectral), color=YELLOW, buff=0.2)\n self.play(Create(highlight_box))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Choose method based on solution characteristics.\", font_size=28)\n conclusion.to_edge(DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clean up\n self.play(\n FadeOut(title),\n FadeOut(explanation),\n FadeOut(eq_spectral),\n FadeOut(eq_finite),\n FadeOut(label_spectral),\n FadeOut(label_finite),\n FadeOut(highlight_box),\n FadeOut(conclusion),\n FadeOut(dot_high_accuracy),\n FadeOut(dot_low_accuracy)\n )\n\n# To run this code, save it to a file (e.g., spectral_vs_fd.py) \n# and execute it using the command: manim -pql filename.py ClassName\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SpectralMethods(Scene):\n def construct(self):\n # Title\n title = Text(\"Spectral Methods\", font_size=48)\n subtitle = Text(\n \"Advantages Over Finite-Difference Methods\\nfor Smooth Solutions\",\n font_size=36,\n t2c={\"Finite-Difference\": BLUE, \"Smooth Solutions\": GREEN}\n )\n \n self.play(Write(title))\n self.wait(1)\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n\n # Create a function graph using MathTex\n func_tex = MathTex(\"f(x) = \\\\sin(\\\\pi x)\", font_size=40)\n func_tex.to_edge(LEFT, buff=2).shift(DOWN * 0.5)\n\n axes = Axes(\n x_range=[-1, 1],\n y_range=[-1.5, 1.5]\n ).scale(0.7).to_edge(RIGHT, buff=1).shift(UP * 0.5 + DOWN * 0.5)\n\n curve = axes.plot(lambda x: np.sin(np.pi * x), color=GREEN)\n curve_label = MathTex(\"\\\\text{Exact Solution}\", color=GREEN).next_to(curve, UR, buff=0.2)\n\n # Display the math equation of the exact solution\n self.play(Write(func_tex))\n self.wait(1)\n\n # Draw the axes and the curve\n self.play(Create(axes), Create(curve), Write(curve_label))\n self.wait(1)\n\n # Show finite difference approximation\n fd_title = Tex(\"Finite Difference Approximation\").next_to(curve_label, UP, buff=0.5)\n self.play(Write(fd_title))\n\n # Place dots at discrete points on the axis\n n_dots = 5\n dot_positions = [np.array([i/n_dots*2-1, 0, 0]) for i in range(n_dots)]\n dots = VGroup()\n labels = VGroup()\n\n for pos in dot_positions:\n dots.add(Dot(pos, color=RED))\n label_text = f\"x_{int((pos[0]+1)/2*n_dots)}\"\n labels.add(Text(label_text, font_size=20).move_to(pos + LEFT * 1.2 + DOWN * 0.2))\n\n self.play(LaggedStart(*[GrowFromCenter(dot) for dot in dots], lag_ratio=0.3),\n LaggedStart(*[Write(label) for label in labels], lag_ratio=0.3))\n \n # Animate the approximation line connecting dots\n approx_curve = VMobject(color=YELLOW)\n approx_curve.set_points_as_corners(dots.get_center())\n approx_label = Text(\"Discrete Points\", font_size=20).to_edge(UP).set_color(YELLOW)\n \n self.play(Create(approx_curve), FadeIn(attributed_rect(), scale=0.6))\n \n # Highlight where the derivative is being computed\n highlight_box = SurroundingRectangle(labels[1].get_boundary_points(), color=ORANGE)\n diff_text = Text(\"Derivative Calculation\", font_size=20).to_edge(DOWN).set_color(ORANGE)\n \n self.play(Create(highlight_box), Write(diff_text))\n \n # Final message about spectral method advantage\n final_msg = Text(\n \"Spectral Methods leverage the power of polynomials\\nfor high accuracy and efficiency.\",\n font_size=24,\n t2c={\"polynomials\": PINK}\n ).to_corner(UL, buff=1.5)\n\n self.play(ReplacementTransform(fd_title, final_msg))\n self.wait(1)\n\n# Helper functions\ndef attributed_rect():\n rect = RoundedRectangle(width=4, height=2, corner_radius=0.3, stroke_width=2)\n text = Text(\"A simple rectangle\", font_size=20).move_to(rect.get_center())\n \n return Group(rect, text)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated visualization of the bubble sort algorithm using colored bars where the height of each bar represents a different value in an array? The animation should show the swapping process of the bars as they are being sorted in ascending order.", "chosen": "```python\nfrom manim import *\n\nclass BubbleSortVisualization(Scene):\n def construct(self):\n # 1. Define the sample array and configuration\n data = [6, 3, 8, 1, 5, 2, 7]\n n = len(data)\n \n # Visual configuration constants\n bar_width = 0.5\n bar_gap = 0.2\n max_height = 4.0\n max_value = max(data)\n \n # 2. Create Bars and Value Labels\n bars = VGroup()\n for value in data:\n # Calculate height proportional to value\n height = (value / max_value) * max_height\n \n # Create the rectangular bar\n rect = Rectangle(\n width=bar_width,\n height=height,\n stroke_width=2,\n stroke_color=WHITE,\n fill_color=BLUE,\n fill_opacity=0.8\n )\n \n # Create the number label\n label = Text(str(value), font_size=24)\n label.next_to(rect, UP, buff=0.1)\n \n # Group bar and label together for easier manipulation\n group = VGroup(rect, label)\n bars.add(group)\n \n # Arrange bars horizontally, aligned at the bottom\n bars.arrange(RIGHT, buff=bar_gap, aligned_edge=DOWN)\n bars.move_to(ORIGIN)\n \n # Animate the initial creation of bars\n self.play(Create(bars))\n self.wait(0.5)\n \n # 3. Bubble Sort Algorithm with Animation\n for i in range(n - 1):\n for j in range(0, n - i - 1):\n # Highlight bars being compared (YELLOW)\n self.play(\n bars[j][0].animate.set_color(YELLOW),\n bars[j+1][0].animate.set_color(YELLOW),\n run_time=0.2\n )\n \n # Check if swap is needed\n if data[j] > data[j+1]:\n # Change color to indicate swapping (RED)\n self.play(\n bars[j][0].animate.set_color(RED),\n bars[j+1][0].animate.set_color(RED),\n run_time=0.2\n )\n \n # Swap values in the data array\n data[j], data[j+1] = data[j+1], data[j]\n \n # Animate the visual swap of positions\n self.play(\n bars[j].animate.move_to(bars[j+1].get_center()),\n bars[j+1].animate.move_to(bars[j].get_center()),\n run_time=0.5\n )\n \n # Swap references in the bars list to maintain correct indexing\n bars[j], bars[j+1] = bars[j+1], bars[j]\n \n # Reset color to default (BLUE)\n self.play(\n bars[j][0].animate.set_color(BLUE),\n bars[j+1][0].animate.set_color(BLUE),\n run_time=0.1\n )\n else:\n # Indicate no swap needed (GREEN)\n self.play(\n bars[j][0].animate.set_color(GREEN),\n bars[j+1][0].animate.set_color(GREEN),\n run_time=0.2\n )\n # Reset color to default (BLUE)\n self.play(\n bars[j][0].animate.set_color(BLUE),\n bars[j+1][0].animate.set_color(BLUE),\n run_time=0.1\n )\n \n # After each pass, the largest element is at the end. Mark it sorted (GREEN).\n self.play(\n bars[n - i - 1][0].animate.set_color(GREEN),\n run_time=0.3\n )\n \n # Final animation to show all bars are sorted\n self.play(*[bar[0].animate.set_color(GREEN) for bar in bars])\n self.wait(1)\n\n# To run this code:\n# 1. Ensure Manim Community Edition is installed (pip install manim).\n# 2. Save the code in a file named bubble_sort.py.\n# 3. Run the command: manim -pql bubble_sort.py BubbleSortVisualization\n```", "rejected": "```python\nfrom manim import *\n\nclass BubbleSortVisualization(Scene):\n def construct(self):\n # 1. Define the sample array and configuration\n data = [6, 3, 8, 1, 5, 2, 7]\n n = len(data)\n \n # Visual configuration constants\n bar_width = 0.5\n bar_gap = 0.2\n max_height = 4.0\n max_value = max(data)\n \n # 2. Create Bars and Value Labels\n bars = VGroup()\n for value in data:\n # Calculate height proportional to value\n height = (value / max_value) * max_height\n \n # Create the rectangular bar\n rect = Rectangle(\n width=bar_width,\n height=height,\n stroke_width=2,\n stroke_color=WHITE,\n fill_color=BBLUE,\n fill_opacity=0.8\n )\n \n # Create the number label\n label = Text(str(value), font_size=24)\n label.next_to(rect, UP, buff=0.1)\n \n # Group bar and label together for easier manipulation\n group = VGroup(rect, label)\n bars.add(group)\n \n # Arrange bars horizontally, aligned at the bottom\n bars.arrange(RIGHT, buff=bar_gap, aligned_edge=DOWN)\n bars.move_to(ORIGIN)\n \n # Animate the initial creation of bars\n self.play(Create(bars))\n self.wait(0.5)\n \n # 3. Bubble Sort Algorithm with Animation\n for i in range(n - 1):\n for j in range(0, n - i - 1):\n # Highlight bars being compared (YELLOW)\n self.play(\n bars[j][0].animate.set_color(YELLOW),\n bars[j+1][0].animate.set_color(YELLOW),\n run_time=0.2\n )\n \n # Check if swap is needed\n if data[j] > data[j+1]:\n # Change color to indicate swapping (RED)\n self.play(\n bars[j][0].animate.set_color(RED),\n bars[j+1][0].animate.set_color(RED),\n run_time=0.2\n )\n \n # Swap values in the data array\n data[j], data[j+1] = data[j+1], data[j]\n \n # Animate the visual swap of positions\n self.play(\n bars[j].animate.move_to(bars[j+1].get_center()),\n bars[j+1].animate.move_to(bars[j].get_center()),\n run_time=0.5\n )\n \n # Swap references in the bars list to maintain correct indexing\n bars[j], bars[j+1] = bars[j+1], bars[j]\n \n # Reset color to default (BLUE)\n self.play(\n bars[j][0].animate.set_color(BLUE),\n bars[j+1][0].animate.set_color(BLUE),\n run_time=0.1\n )\n else:\n # Indicate no swap needed (GREEN)\n self.play(\n bars[j][0].animate.set_color(GREEN),\n bars[j+1][0].animate.set_color(GREEN),\n run_time=0.2\n )\n # Reset color to default (BLUE)\n self.play(\n bars[j][0].animate.set_color(BLUE),\n bars[j+1][0].animate.set_color(BLUE),\n run_time=0.1\n )\n \n # After each pass, the largest element is at the end. Mark it sorted (GREEN).\n self.play(\n bars[n - i - 1][0].animate.set_color(GREEN),\n run_time=0.3\n )\n \n # Final animation to show all bars are sorted\n self.play(*[bar[0].animate.set_color(GREEN) for bar in bars])\n self.wait(1)\n\n# To run this code:\n# 1. Ensure Manim Community Edition is installed (pip install manim).\n# 2. Save the code in a file named bubble_sort.py.\n# 3. Run the command: manim -pql bubble_sort.py BubbleSortVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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\n- Act 2: Write Manim code for a scene illustrating the properties of Laplace transforms. Show how the transform is applied to functions and their inverses, step by step.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0783(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_laplaceproperties()\n\n def act_1_areaundercurveexample(self):\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explanation for the method of rectangles\n explanation1 = Text(\"Approximate area using rectangles\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Graph the function\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label='x^2')\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Display rectangles\n rects = axes.get_riemann_rectangles(graph, x_range=[0, 2], dx=0.25)\n self.play(Create(rects))\n self.wait(2)\n\n # Explanation for the actual integration\n explanation2 = Text(\"Calculate the exact area\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{2^3}{3} = \\frac{8}{3}\")\n self.play(ReplacementTransform(rects, final_solution))\n self.wait(1)\n\n # Clear the scene and conclude\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label), FadeOut(explanation1))\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n\n def act_2_laplaceproperties(self):\n title = Text(\"Properties of Laplace Transforms\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n\n orig_func = MathTex(r\"f(t)\").next_to(title, DOWN).scale(0.8) \n self.play(FadeIn(orig_func))\n\n arrow1 = Arrow(start=orig_func.get_bottom(), end=orig_func.get_bottom()+DOWN) \n lt_text = Text(\"Laplace Transform\").next_to(arrow1, RIGHT).scale(0.6)\n trans_func = MathTex(r\"\\mathcal{L}\\{f(t)\\} = F(s)\").next_to(arrow1, DOWN).scale(0.8)\n self.play(GrowArrow(arrow1), FadeIn(trans_func), FadeIn(lt_text))\n \n linear_text = Text(\"Linearity\").next_to(trans_func, DOWN).scale(0.7)\n self.play(Write(linear_text))\n\n eq1 = MathTex(r\"\\mathcal{L}\\{af(t)\", \"+\", \"bg(t)\\}\", \"=\", \"a\", \n \"\\mathcal{L}\\{f(t)\\}\", \"+\", \"b\", \"\\mathcal{L}\\{g(t)\\}\").next_to(linear_text, DOWN).scale(0.8)\n self.play(Write(eq1))\n \n invlt_text = Text(\"Inverse Laplace \\n Transform\").next_to(eq1, DOWN).scale(0.6) \n self.play(Write(invlt_text))\n\n shift_text = Text(\"Time Shift\").next_to(invlt_text, DOWN).scale(0.7)\n self.play(ReplacementTransform(linear_text, shift_text)) \n \n eq2 = MathTex(r\"\\mathcal{L}\\{f(t-a)\\}\", \"=\", \"e^{-as}\", \n \"\\mathcal{L}\\{f(t)\\}\").next_to(shift_text, DOWN).scale(0.8)\n self.play(ReplacementTransform(eq1, eq2))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0783(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_laplaceproperties()\n\n def act_1_areaundercurveexample(self):\n problem = MathTex(r\"\\int_0^2 x^2 \\,dx\")\n self.play(Write(problem))\n self.wait(1)\n\n # Explanation for the method of rectangles\n explanation1 = Text(\"Approximate area using rectangles\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Graph the function\n axes = Axes(font_size=24, \n x_range=[0, 2.5, 0.5],\n y_range=[0, 4.5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"color\": BLUE},\n )\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label='x^2')\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Display rectangles\n rects = axes.get_riemann_rectangles(graph, x_range=[0, 2], dx=0.25)\n self.play(Create(rects))\n self.wait(2)\n\n # Explanation for the actual integration\n explanation2 = Text(\"Calculate the exact area\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{2^3}{3} = \\frac{8}{3}\")\n self.play(ReplacementTransform(rects, final_solution))\n self.wait(1)\n\n # Clear the scene and conclude\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label), FadeOut(explanation1))\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n\n def act_2_laplaceproperties(self):\n title = Text(\"Properties of Laplace Transforms\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n\n orig_func = MathTex(r\"f(t)\").next_to(title, DOWN).scale(0.8) \n self.play(FadeIn(orig_func))\n\n arrow1 = Arrow(start=orig_func.get_bottom(), end=orig_func.get_bottom()+DOWN) \n lt_text = Text(\"Laplace Transform\").next_to(arrow1, RIGHT).scale(0.6)\n trans_func = MathTex(r\"\\mathcal{L}\\{f(t)\\} = F(s)\").next_to(arrow1, DOWN).scale(0.8)\n self.play(GrowArrow(arrow1), FadeIn(trans_func), FadeIn(lt_text))\n \n linear_text = Text(\"Linearity\").next_to(trans_func, DOWN).scale(0.7)\n self.play(Write(linear_text))\n\n eq1 = MathTex(r\"\\mathcal{L}\\{af(t)\", \"+\", \"bg(t)\\}\", \"=\", \"a\", \n \"\\mathcal{L}\\{f(t)\\}\", \"+\", \"b\", \"\\mathcal{L}\\{g(t)\\}\").next_to(linear_text, DOWN).scale(0.8)\n self.play(Write(eq1))\n \n invlt_text = Text(\"Inverse Laplace \\n Transform\").next_to(eq1, DOWN).scale(0.6) \n self.play(Write(invlt_text))\n\n shift_text = Text(\"Time Shift\").next_to(invlt_text, DOWN).scale(0.7)\n self.play(ReplacementTransform(linear_text, shift_text)) \n \n eq2 = MathTex(r\"\\mathcal{L}\\{f(t-a)\\}\", \"=\", \"e^{-as}\", \n \"\\mathcal{L}\\{f(t)\\}\").next_to(shift_text, DOWN).scale(0.8)\n self.play(ReplacementTransform(eq1, eq2))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second geology scene explaining why P waves arrive before S waves at a seismic station. Show an earthquake source, two labeled wave pulses traveling along the same path at different speeds, and an arrival timeline. State that arrival-time separation helps estimate distance, not earthquake magnitude by itself.", "chosen": "```python\nfrom manim import *\n\nclass SeismicWaveArrivals(Scene):\n def construct(self):\n title = Text(\"P waves arrive before slower S waves\", font_size=38).to_edge(UP)\n ground = Line(LEFT * 5.5, RIGHT * 5.5, color=GRAY_B).shift(UP * 0.8)\n source = Star(n=7, outer_radius=0.35, color=ORANGE, fill_opacity=0.8).move_to(LEFT * 4 + UP * 0.8)\n station = VGroup(\n Rectangle(width=0.8, height=0.65, color=TEAL_B),\n Triangle(color=TEAL_B, fill_opacity=0.3).scale(0.45).shift(UP * 0.45),\n ).move_to(RIGHT * 4 + UP * 1.15)\n path = Line(source.get_center(), station.get_bottom(), stroke_opacity=0)\n p_pulse = Dot(source.get_center(), color=YELLOW, radius=0.12)\n s_pulse = Dot(source.get_center(), color=BLUE_B, radius=0.12)\n p_label = Text(\"P\", font_size=22, color=YELLOW).next_to(p_pulse, UP)\n s_label = Text(\"S\", font_size=22, color=BLUE_B).next_to(s_pulse, DOWN)\n timeline = NumberLine(x_range=[0, 6, 1], length=7, include_numbers=True).shift(DOWN * 1.4)\n p_mark = Triangle(color=YELLOW, fill_opacity=1).scale(0.16).rotate(PI).next_to(timeline.n2p(2), UP, buff=0.05)\n s_mark = Triangle(color=BLUE_B, fill_opacity=1).scale(0.16).rotate(PI).next_to(timeline.n2p(4), UP, buff=0.05)\n marks = VGroup(\n Text(\"P arrival\", font_size=20, color=YELLOW).next_to(p_mark, UP),\n Text(\"S arrival\", font_size=20, color=BLUE_B).next_to(s_mark, UP),\n )\n caption = Text(\"The P–S time gap estimates distance, not magnitude by itself.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(ground), FadeIn(source, station, p_pulse, s_pulse, p_label, s_label))\n self.play(Create(timeline))\n self.play(MoveAlongPath(p_pulse, path), p_label.animate.next_to(station, UP), run_time=2, rate_func=linear)\n self.play(FadeIn(p_mark, marks[0]), Flash(station, color=YELLOW))\n self.play(MoveAlongPath(s_pulse, path), s_label.animate.next_to(station, RIGHT), run_time=3, rate_func=linear)\n self.play(FadeIn(s_mark, marks[1]), Flash(station, color=BLUE_B))\n self.play(FadeIn(caption), Circumscribe(VGroup(p_mark, s_mark), color=ORANGE))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass SeismicWaveArrivals(Scene):\n def construct(self):\n title = Text(\"P waves arrive before slower S waves\", font_size=38).to_edge(UP)\n ground = Line(LEFT * 5.5, RIGHT * 5.5, color=GRAY_B).shift(UP * 0.8)\n source = Star(n=7, outer_radius=0.35, color=ORANGE, fill_opacity=0.8).move_to(LEFT * 4 + UP * 0.8)\n station = VGroup(\n Rectangle(width=0.8, height=0.65, color=TEAL_B),\n Triangle(color=TEAL_B, fill_opacity=0.3).scale(0.45).shift(UP * 0.45),\n ).move_to(RIGHT * 4 + UP * 1.15)\n path = Line(source.get_center(), station.get_bottom(), stroke_opacity=0)\n p_pulse = Dot(source.get_center(), color=YELLOW, radius=0.12)\n s_pulse = Dot(source.get_center(), color=BBLUE_B, radius=0.12)\n p_label = Text(\"P\", font_size=22, color=YELLOW).next_to(p_pulse, UP)\n s_label = Text(\"S\", font_size=22, color=BLUE_B).next_to(s_pulse, DOWN)\n timeline = NumberLine(x_range=[0, 6, 1], length=7, include_numbers=True).shift(DOWN * 1.4)\n p_mark = Triangle(color=YELLOW, fill_opacity=1).scale(0.16).rotate(PI).next_to(timeline.n2p(2), UP, buff=0.05)\n s_mark = Triangle(color=BLUE_B, fill_opacity=1).scale(0.16).rotate(PI).next_to(timeline.n2p(4), UP, buff=0.05)\n marks = VGroup(\n Text(\"P arrival\", font_size=20, color=YELLOW).next_to(p_mark, UP),\n Text(\"S arrival\", font_size=20, color=BLUE_B).next_to(s_mark, UP),\n )\n caption = Text(\"The P–S time gap estimates distance, not magnitude by itself.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(ground), FadeIn(source, station, p_pulse, s_pulse, p_label, s_label))\n self.play(Create(timeline))\n self.play(MoveAlongPath(p_pulse, path), p_label.animate.next_to(station, UP), run_time=2, rate_func=linear)\n self.play(FadeIn(p_mark, marks[0]), Flash(station, color=YELLOW))\n self.play(MoveAlongPath(s_pulse, path), s_label.animate.next_to(station, RIGHT), run_time=3, rate_func=linear)\n self.play(FadeIn(s_mark, marks[1]), Flash(station, color=BLUE_B))\n self.play(FadeIn(caption), Circumscribe(VGroup(p_mark, s_mark), color=ORANGE))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Classification Rule\n\\[\n\\hat{y}=\\arg\\max_y \\Big(\\log P(y)+\\sum_{j=1}^d \\log P(x_j\\mid y)\\Big)\n\\]\n- Actual calculations typically use the logarithmic form to convert products into sums, thereby avoiding numerical underflow.\n\n\nThe context of this section (from highest to current level):\n# Machine Learning Course — Detailed Outline for Lecture 8 (Probabilistic Generative Models, 90 minutes)\n## Naive Bayes (25 minutes)\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClassificationRule(Scene):\n\n def construct(self):\n title = Text('Classification Rule', font_size=36).to_edge(UP)\n rule_tex = MathTex('\\\\hat{y}', '=', '\\\\arg\\\\max_y \\\\left(\\\\log P(y) + \\\\sum_{j=1}^{d} \\\\log P(x_j|y)\\\\right)', font_size=40).next_to(title, DOWN, buff=0.5)\n self.play(Write(rule_tex))\n self.wait(1.5)\n \n explanation_text = Tex('- Calculations often utilize log-form for multiplication-to-addition conversion\\n- This helps avoid numerical underflow during probability computations', font_size=26).next_to(rule_tex, DOWN, buff=1)\n box = SurroundingRectangle(explanation_text, color=YELLOW, buff=0.2)\n self.play(FadeIn(explanation_text, shift=DOWN * 0.2), Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ClassificationRule(Scene):\n def construct(self):\n # Title\n title = Text(\"Classification Rule\", font_size=40).to_edge(UP)\n \n # Mathematical Expression\n formula = MathTex(\n r\"\\hat{y}\", \"=\", \"\\\\arg\\\\max_\", \"y\", \n r\"\\left( \\log P(y) + \\\\sum_{j=1}^{d} \\\\log P(x_{j}\\\\mid y) \\\\right)\"\n ).scale(0.7).next_to(title, DOWN, buff=0.5)\n\n # Highlight log terms\n box_log_p = SurroundingRectangle(formula[6], color=YELLOW, buff=MED_LARGE_BUFF)\n box_sum_logs = SurroundingRectangle(VGroup(formula[8], formula[9]), color=GREEN, buff=MED_SMALL_BUFF)\n\n # Explanation Text\n explanation = Text(\n \"Actual calculations typically use the logarithmic form\\n\"\n \"to avoid numerical underflow.\", \n font_size=24, t2c={\"numerical\": BLUE}\n )\n explanation.next_to(box_sum_logs, DOWN, buff=0.5).align_to(box_sum_logs, LEFT).shift(RIGHT * 0.2)\n\n # Animation Sequence\n self.play(Write(title))\n self.wait(0.5)\n self.play(Write(formula[0:5]))\n self.wait(0.5)\n self.play(Create(box_log_p))\n self.wait(1)\n self.play(Write(formula[6:10]))\n self.wait(0.5)\n self.play(Create(box_sum_logs))\n self.wait(1)\n self.play(FadeIn(explanation, shift=DOWN * 0.5))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I need an educational animation to explain the basics of an electrical generator. The animation should visually represent the main parts of a simple generator: a rotating armature and the magnetic field. To do this, create a grey circle to symbolize the base of the generator, with blue arcs around it to illustrate the coils of the magnetic field. Deploy a red double-sided arrow at the center to denote the armature. Additionally, include labeled arrows pointing to the relevant parts—blue for \"Magnetic Field\" pointing towards one of the coils, and red for \"Current\" pointing towards the top of the armature. Make sure the labels are clear and easy to read. Set the background to white to keep the focus on the components. Can you make this animation for a learning module on electricity and magnetism?", "chosen": "```python\nfrom manim import *\n\nclass ElectricalGeneratorScene(Scene):\n def construct(self):\n # 1. Background Configuration\n # Set the scene background to white to maintain focus on the components\n self.camera.background_color = WHITE\n\n # 2. Base of the Generator\n # Draw a grey circle to symbolize the base/stator frame\n base = Circle(radius=2.0, color=GRAY, fill_opacity=0.3)\n base.set_stroke(color=GRAY, width=2)\n\n # 3. Magnetic Field Coils\n # Render blue arcs around the grey circle to illustrate the coils\n coils = VGroup()\n coil_radius = 2.5\n # Create 4 arcs positioned around the base to represent field coils\n for i in range(4):\n start_angle = i * (PI / 2) + 0.1\n # Arc spans roughly 90 degrees minus a small gap for visual separation\n arc = Arc(\n radius=coil_radius, \n start_angle=start_angle, \n angle=PI / 2 - 0.2, \n color=BLUE, \n stroke_width=8\n )\n coils.add(arc)\n\n # 4. Armature\n # Place a red double-sided arrow at the center to denote the rotating armature\n armature = DoubleArrow(\n start=LEFT * 1.5, \n end=RIGHT * 1.5, \n color=RED, \n buff=0,\n stroke_width=6\n )\n\n # 5. Labels & Indicators\n \n # Magnetic Field Label (Blue arrow pointing towards one of the coils)\n mf_arrow = Arrow(\n start=UP * 3.5 + RIGHT * 3.5, \n end=UP * 2.6 + RIGHT * 2.6, \n color=BLUE, \n buff=0,\n max_tip_length_to_length_ratio=0.1,\n stroke_width=4\n )\n mf_text = Text(\"Magnetic Field\", color=BLUE, font_size=40)\n mf_text.next_to(mf_arrow, UR, buff=0.3)\n mf_label_group = VGroup(mf_arrow, mf_text)\n\n # Current Label (Red arrow pointing towards the top of the armature)\n curr_arrow = Arrow(\n start=UP * 2.5, \n end=UP * 0.5, \n color=RED, \n buff=0,\n max_tip_length_to_length_ratio=0.1,\n stroke_width=4\n )\n curr_text = Text(\"Current\", color=RED, font_size=40)\n curr_text.next_to(curr_arrow, UP, buff=0.3)\n curr_label_group = VGroup(curr_arrow, curr_text)\n\n # --- Animation Sequence ---\n\n # Step 1: Introduce the base structure and magnetic field coils\n self.play(Create(base), Create(coils), run_time=2)\n \n # Step 2: Insert the armature\n self.play(Create(armature), run_time=1)\n \n # Step 3: Display explanatory labels clearly\n self.play(GrowArrow(mf_arrow), Write(mf_text))\n self.play(GrowArrow(curr_arrow), Write(curr_text))\n \n # Pause to allow viewers to read the labels\n self.wait(1)\n\n # Step 4: Demonstrate generator function via rotation\n # Rotate the armature continuously to simulate operation\n self.play(\n Rotate(armature, angle=2 * PI, about_point=ORIGIN), \n run_time=3, \n rate_func=linear\n )\n self.play(\n Rotate(armature, angle=4 * PI, about_point=ORIGIN), \n run_time=4, \n rate_func=linear\n )\n \n # Final hold\n self.wait(2)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql your_filename.py ElectricalGeneratorScene\n```", "rejected": "```python\nfrom manim import *\n\nclass ElectricalGeneratorScene(Scene):\n def construct(self):\n # 1. Background Configuration\n # Set the scene background to white to maintain focus on the components\n self.camera.background_color = WHITE\n\n # 2. Base of the Generator\n # Draw a grey circle to symbolize the base/stator frame\n base = Circle(radius=2.0, color=GRAY, fill_opacity=0.3)\n base.set_stroke(color=GRAY, width=2)\n\n # 3. Magnetic Field Coils\n # Render blue arcs around the grey circle to illustrate the coils\n coils = VGroup()\n coil_radius = 2.5\n # Create 4 arcs positioned around the base to represent field coils\n for i in range(4):\n start_angle = i * (PI / 2) + 0.1\n # Arc spans roughly 90 degrees minus a small gap for visual separation\n arc = Arc(\n radius=coil_radius, \n start_angle=start_angle, \n angle=PI / 2 - 0.2, \n color=BBLUE, \n stroke_width=8\n )\n coils.add(arc)\n\n # 4. Armature\n # Place a red double-sided arrow at the center to denote the rotating armature\n armature = DoubleArrow(\n start=LEFT * 1.5, \n end=RIGHT * 1.5, \n color=RED, \n buff=0,\n stroke_width=6\n )\n\n # 5. Labels & Indicators\n \n # Magnetic Field Label (Blue arrow pointing towards one of the coils)\n mf_arrow = Arrow(\n start=UP * 3.5 + RIGHT * 3.5, \n end=UP * 2.6 + RIGHT * 2.6, \n color=BLUE, \n buff=0,\n max_tip_length_to_length_ratio=0.1,\n stroke_width=4\n )\n mf_text = Text(\"Magnetic Field\", color=BLUE, font_size=40)\n mf_text.next_to(mf_arrow, UR, buff=0.3)\n mf_label_group = VGroup(mf_arrow, mf_text)\n\n # Current Label (Red arrow pointing towards the top of the armature)\n curr_arrow = Arrow(\n start=UP * 2.5, \n end=UP * 0.5, \n color=RED, \n buff=0,\n max_tip_length_to_length_ratio=0.1,\n stroke_width=4\n )\n curr_text = Text(\"Current\", color=RED, font_size=40)\n curr_text.next_to(curr_arrow, UP, buff=0.3)\n curr_label_group = VGroup(curr_arrow, curr_text)\n\n # --- Animation Sequence ---\n\n # Step 1: Introduce the base structure and magnetic field coils\n self.play(Create(base), Create(coils), run_time=2)\n \n # Step 2: Insert the armature\n self.play(Create(armature), run_time=1)\n \n # Step 3: Display explanatory labels clearly\n self.play(GrowArrow(mf_arrow), Write(mf_text))\n self.play(GrowArrow(curr_arrow), Write(curr_text))\n \n # Pause to allow viewers to read the labels\n self.wait(1)\n\n # Step 4: Demonstrate generator function via rotation\n # Rotate the armature continuously to simulate operation\n self.play(\n Rotate(armature, angle=2 * PI, about_point=ORIGIN), \n run_time=3, \n rate_func=linear\n )\n self.play(\n Rotate(armature, angle=4 * PI, about_point=ORIGIN), \n run_time=4, \n rate_func=linear\n )\n \n # Final hold\n self.wait(2)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql your_filename.py ElectricalGeneratorScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Image Processing System Design\n#### System Architecture\n##### Image Acquisition Module\nSelect appropriate cameras (area scan/line scan), lenses, and lighting. Lighting design is key to obtaining high-quality images.\n\n##### Preprocessing Module\nNoise reduction, enhancement, and distortion correction, providing standardized input for subsequent algorithms.\n\n##### Processing Algorithm Module\nThe core of the system, containing specific logic such as feature extraction, segmentation, and recognition.\n\n##### Result Output Module\nDisplay images, output control signals (such as rejecting defective products), and save data logs.\n\n\nThe context location of this part (from highest level to current):\n# Comprehensive Application of Image Processing\n## Main Content\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ImageProcessingSystem(Scene):\n\n def construct(self):\n title = Text('Comprehensive Application of Image Processing', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.2)\n subtitle = Text('Image Processing System Design - System Architecture', font_size=24, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n self.wait(0.5)\n modules = [('Image Acquisition\\nModule', ['Select appropriate cameras (area scan/line scan),', 'lenses, and lighting. Lighting design is key', 'to obtaining high-quality images.']), ('Preprocessing\\nModule', ['Noise reduction, enhancement, and distortion', 'correction, providing standardized input', 'for subsequent algorithms.']), ('Processing Algorithm\\nModule', ['The core of the system, containing specific', 'logic such as feature extraction,', 'segmentation, and recognition.']), ('Result Output\\nModule', ['Display images, output control signals', '(such as rejecting defective products),', 'and save data logs.'])]\n boxes = VGroup()\n texts = VGroup()\n arrows = VGroup()\n for i, (mod_name, mod_lines) in enumerate(modules):\n box = Rectangle(width=3.6, height=0.9, color=TEAL, fill_opacity=0.15)\n box_text = Text(mod_name, font_size=20, weight=BOLD, line_spacing=1.2)\n box_text.move_to(box.get_center())\n box_group = VGroup(box, box_text)\n desc_lines = VGroup(*[Text(line, font_size=18, color=LIGHT_GREY) for line in mod_lines])\n desc_lines.arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n if i == 0:\n box_group.move_to(UP * 1.6 + LEFT * 3.0)\n else:\n box_group.next_to(boxes[-1], DOWN, buff=0.5)\n desc_lines.next_to(box_group, RIGHT, buff=0.6)\n boxes.add(box_group)\n texts.add(desc_lines)\n if i > 0:\n arrow = Arrow(start=boxes[i - 1].get_bottom(), end=box_group.get_top(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=GRAY)\n arrows.add(arrow)\n else:\n pass\n else:\n pass\n for i in range(len(modules)):\n self.play(Create(boxes[i][0]), Write(boxes[i][1]), run_time=0.8)\n self.play(FadeIn(texts[i], shift=LEFT), run_time=0.8)\n if i < len(modules) - 1:\n self.play(GrowArrow(arrows[i]), run_time=0.5)\n else:\n pass\n else:\n pass\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ImageProcessingSystem(Scene):\n\n def construct(self):\n title = Text('Comprehensive Application of Image Processing', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.2)\n subtitle = Text('Image Processing System Design - System Architecture', font_size=24, color=BBLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n self.wait(0.5)\n modules = [('Image Acquisition\\nModule', ['Select appropriate cameras (area scan/line scan),', 'lenses, and lighting. Lighting design is key', 'to obtaining high-quality images.']), ('Preprocessing\\nModule', ['Noise reduction, enhancement, and distortion', 'correction, providing standardized input', 'for subsequent algorithms.']), ('Processing Algorithm\\nModule', ['The core of the system, containing specific', 'logic such as feature extraction,', 'segmentation, and recognition.']), ('Result Output\\nModule', ['Display images, output control signals', '(such as rejecting defective products),', 'and save data logs.'])]\n boxes = VGroup()\n texts = VGroup()\n arrows = VGroup()\n for i, (mod_name, mod_lines) in enumerate(modules):\n box = Rectangle(width=3.6, height=0.9, color=TEAL, fill_opacity=0.15)\n box_text = Text(mod_name, font_size=20, weight=BOLD, line_spacing=1.2)\n box_text.move_to(box.get_center())\n box_group = VGroup(box, box_text)\n desc_lines = VGroup(*[Text(line, font_size=18, color=LIGHT_GREY) for line in mod_lines])\n desc_lines.arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n if i == 0:\n box_group.move_to(UP * 1.6 + LEFT * 3.0)\n else:\n box_group.next_to(boxes[-1], DOWN, buff=0.5)\n desc_lines.next_to(box_group, RIGHT, buff=0.6)\n boxes.add(box_group)\n texts.add(desc_lines)\n if i > 0:\n arrow = Arrow(start=boxes[i - 1].get_bottom(), end=box_group.get_top(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=GRAY)\n arrows.add(arrow)\n else:\n pass\n else:\n pass\n for i in range(len(modules)):\n self.play(Create(boxes[i][0]), Write(boxes[i][1]), run_time=0.8)\n self.play(FadeIn(texts[i], shift=LEFT), run_time=0.8)\n if i < len(modules) - 1:\n self.play(GrowArrow(arrows[i]), run_time=0.5)\n else:\n pass\n else:\n pass\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that visually explains how to calculate the area under a curve using a definite integral? Specifically, show the graph of the function f(x)=x^2, highlight the area under the curve between x=0 and x=2, and step by step, display the integration process to find the exact numerical value of this area.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Coordinate System\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the function f(x) = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n graph_label = axes.get_graph_label(graph, label=MathTex(\"f(x) = x^2\"), x_val=2.3, direction=UR)\n\n # 3. Highlight the 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 area_label = MathTex(r\"\\text{Area}\", color=GREEN).move_to(axes.c2p(1, 0.5))\n \n # Vertical line at x=2 for visual clarity\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=WHITE)\n label_x2 = MathTex(\"2\").next_to(axes.c2p(2, 0), DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\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} \\approx 2.67\")\n\n # Position steps to the right of the axes\n equation_group = VGroup(step1, step2, step3, step4)\n equation_group.arrange(DOWN, buff=0.8).next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # --- Animation Sequence ---\n\n # Introduction of Axes and Graph\n self.play(Create(axes), run_time=1.5)\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Highlighting the Region\n self.play(FadeIn(area), Create(line_x2), Write(label_x2), Write(area_label))\n self.wait(1)\n\n # Step 1: The Definite Integral Notation\n self.play(Write(step1))\n self.wait(1)\n\n # Step 2: The Antiderivative\n self.play(ReplacementTransform(step1.copy(), step2))\n self.wait(1)\n\n # Step 3: Substitution of limits\n self.play(ReplacementTransform(step2.copy(), step3))\n self.wait(1)\n\n # Step 4: Final Result\n step4.set_color(YELLOW)\n self.play(ReplacementTransform(step3.copy(), step4))\n self.wait(0.5)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=RED, buff=0.1)\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Coordinate System\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the function f(x) = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n graph_label = axes.get_graph_label(graph, label=MathTex(r\"f(x) = x^2\" + \" = x\"), x_val=2.3, direction=UR)\n\n # 3. Highlight the 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 area_label = MathTex(r\"\\text{Area}\", color=GREEN).move_to(axes.c2p(1, 0.5))\n \n # Vertical line at x=2 for visual clarity\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=WHITE)\n label_x2 = MathTex(\"2\").next_to(axes.c2p(2, 0), DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\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} \\approx 2.67\")\n\n # Position steps to the right of the axes\n equation_group = VGroup(step1, step2, step3, step4)\n equation_group.arrange(DOWN, buff=0.8).next_to(axes, RIGHT, buff=1).shift(UP * 0.5)\n\n # --- Animation Sequence ---\n\n # Introduction of Axes and Graph\n self.play(Create(axes), run_time=1.5)\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # Highlighting the Region\n self.play(FadeIn(area), Create(line_x2), Write(label_x2), Write(area_label))\n self.wait(1)\n\n # Step 1: The Definite Integral Notation\n self.play(Write(step1))\n self.wait(1)\n\n # Step 2: The Antiderivative\n self.play(ReplacementTransform(step1.copy(), step2))\n self.wait(1)\n\n # Step 3: Substitution of limits\n self.play(ReplacementTransform(step2.copy(), step3))\n self.wait(1)\n\n # Step 4: Final Result\n step4.set_color(YELLOW)\n self.play(ReplacementTransform(step3.copy(), step4))\n self.wait(0.5)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=RED, buff=0.1)\n self.play(Create(box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the animation that maintains all original features while adding significant new elements: \n\nThe enhanced animation begins by constructing the original **MathOperationLayer**, displaying a mathematical operation (+, -, *, /) within a blue-stroked circle, which highlights in orange during activation. To this, we introduce a **dynamic input-output visualization**: as the operation activates, two animated input values (represented as labeled circles) flow into the operation node, while the result emerges as an output circle, with the calculation displayed as a formula (e.g., \"3 + 5 = 8\") above the node. Additionally, we include an **interactive activation function plot**—when the operation executes, the corresponding activation function (e.g., ReLU, Sigmoid) animates alongside the result, showing how the output is transformed. The animation concludes with the operation node fading back to its default state while the formula and activation plot linger briefly for clarity, reinforcing the mathematical relationship between inputs, operation, and activation. This enhancement makes the layer’s function more intuitive by visualizing both the arithmetic process and its subsequent nonlinear transformation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedMathOperationLayer(Scene):\n def construct(self):\n # Create Math Operation Node\n math_node = Circle(radius=1, color=BLUE)\n math_text = Text(\"+\", font_size=60).move_to(math_node.get_center())\n \n self.play(Create(math_node), Write(math_text))\n self.wait(1)\n\n # Display Activation Function Plot\n axes = Axes(\n x_range=[-2, 2], y_range=[0, 1], \n x_length=7, y_length=5,\n tips=False\n ).shift(RIGHT*2)\n \n relu_curve = axes.plot(lambda x: np.maximum(x, 0), color=YELLOW)\n sigmoid_curve = axes.plot(lambda x: 1/(1 + np.exp(-x)), color=GREEN)\n \n self.play(Create(axes), Create(relu_curve))\n self.wait(1)\n\n # Animate Input Values Flowing In\n left_input_circle = Circle(radius=0.5, color=RED)\n right_input_circle = Circle(radius=0.5, color=RED)\n \n left_input_label = Text(\"Input A\", font_size=24).next_to(left_input_circle, DOWN)\n right_input_label = Text(\"Input B\", font_size=24).next_to(right_input_circle, DOWN)\n \n left_input_circle.move_to(LEFT*2)\n right_input_circle.next_to(left_input_circle, RIGHT)\n \n self.add(left_input_circle, right_input_circle, left_input_label, right_input_label)\n self.wait(0.5)\n\n self.play(\n MoveAlongPath(left_input_circle, Line(start=left_input_circle.get_center(), end=math_node.get_left())),\n MoveAlongPath(right_input_circle, Line(start=right_input_circle.get_center(), end=math_node.get_right()))\n )\n \n # Show Calculation Formula\n calc_formula = Tex(\"$A + B = C$\").to_edge(UP)\n \n self.play(Write(calc_formula))\n\n # Highlight Active State\n active_circle = math_node.copy()\n active_circle.set_stroke(ORANGE, width=2)\n \n self.play(Transform(math_node, active_circle))\n self.wait(1)\n\n # Activate Rectification (ReLU)\n rectified_output_circle = Circle(radius=0.5, color=GREEN)\n rectified_value = Text(\"C'\", font_size=24).next_to(rectified_output_circle, UP)\n rectified_output_circle.move_to(math_node.get_right())\n \n self.play(\n FadeIn(rectified_output_circle),\n Write(rectified_value)\n )\n\n self.play(\n Transform(relu_curve, sigmoid_curve, run_time=2)\n )\n self.wait(1)\n\n # Return to Default State\n self.play(\n FadeOut(left_input_circle), FadeOut(right_input_circle),\n FadeOut(left_input_label), FadeOut(right_input_label),\n FadeOut(calc_formula),\n Transform(active_circle, math_node)\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedMathOperationScene(Scene):\n def construct(self):\n # Create Math Operation Layer\n math_op_circle = Circle(radius=1.5, color=BLUE)\n plus_sign = MathTex(\"+\").scale(2).move_to(math_op_circle.get_center())\n \n self.play(Create(math_op_circle))\n self.play(Write(plus_sign))\n self.wait(1)\n\n # Highlight on Activation\n active_color = ORANGE\n highlight_path = VMobject()\n highlight_path.set_points_as_corners([math_op_circle.point_from_proportion(i/6) for i in range(7)])\n highlight_path.set_stroke(active_color, width=12, opacity=0.5)\n \n self.add(highlight_path)\n self.play(\n math_op_circle.animate.set_stroke(color=active_color),\n plus_sign.animate.set_color(active_color),\n run_time=1.5,\n )\n self.wait(0.5)\n self.play(\n math_op_circle.animate.set_stroke(width=4),\n plus_sign.animate.scale(0.7),\n run_time=0.5\n )\n\n # Dynamic Input-Output Visualization\n # Inputs\n left_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"3\", font_size=24)).arrange(DOWN)\n right_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"5\", font_size=24)).arrange(DOWN)\n inputs_group = VGroup(left_input.shift(LEFT*2.5), right_input.shift(RIGHT*2.5))\n\n # Result\n result_circle = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"8\", font_size=24, color=YELLOW)).arrange(DOWN)\n formula_text = MathTex(\"3 + 5 = 8\").to_edge(UP)\n\n # Animate inputs entering the operation and forming the result\n self.play(FadeIn(inputs_group), Write(formula_text), run_time=1.5)\n self.play(MoveAlongPath(left_input, Line(start=inputs_group[0].get_left(), end=math_op_circle.get_left())), \n MoveAlongPath(right_input, Line(start=inputs_group[1].get_right(), end=math_op_circle.get_right())),\n run_time=1.5)\n\n self.play(Transform(result_circle[0], math_op_circle.copy().set_fill(opacity=0)), \n Transform(result_circle[1], plus_sign.copy()),\n run_time=0.8)\n self.play(ShowPassingFlash(result_circle, time_width=0.2, flash_scale=1.5), run_time=1)\n\n # Interactive Activation Function Plot\n axes = Axes(x_range=[0, 10, 2], y_range=[0, 10, 2], x_length=8, y_length=6)\n relu_plot = axes.plot(lambda x: max(0, x), color=GREEN)\n sigmoid_curve = axes.plot(lambda x: 1/(1+np.exp(-x)), color=RED)\n \n # Show ReLU first since it maps positive numbers linearly\n self.play(Create(axes), Create(relu_plot), run_time=2)\n self.wait(1)\n\n # Switch to Sigmoid after the calculation shows non-linear behavior\n self.play(Transform(relu_plot, sigmoid_curve), run_time=2)\n self.wait(2)\n\n # Conclusion: Fade back to normal state, keep formulas visible\n self.play(\n math_op_circle.animate.set_stroke(color=BLUE, width=4),\n plus_sign.animate.scale(1.4),\n run_time=1.5\n )\n self.play(FadeOut(highlight_path))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated explanation video that shows how to integrate the sine function from 0 to pi, including the steps of integrating, evaluating the definite integral, and concluding with the result of the integration?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineIntegration(Scene):\n def construct(self):\n # --- 1. Setup Coordinate System ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 1.5, 0.5],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).to_edge(LEFT)\n \n # Custom x-axis labels for 0 and Pi\n x_labels = VGroup(\n MathTex(\"0\").next_to(axes.c2p(0, 0), DOWN, buff=0.2),\n MathTex(\"\\\\pi\").next_to(axes.c2p(np.pi, 0), DOWN, buff=0.2)\n )\n y_label = axes.get_y_axis_label(\"y\", edge=LEFT, buff=0.3)\n \n # --- 2. Plot the Function and Area ---\n sin_graph = axes.plot(lambda x: np.sin(x), x_range=[0, np.pi], color=BLUE)\n sin_label = axes.get_graph_label(sin_graph, \"\\\\sin(x)\", x_val=PI/2, direction=UP)\n \n # Area under the curve to visualize the definite integral\n area = axes.get_area(sin_graph, x_range=[0, np.pi], color=GREEN, opacity=0.5)\n \n # --- 3. Prepare Equation Steps ---\n # Step 1: The definite integral\n eq1 = MathTex(r\"\\int_{0}^{\\pi}\", r\"\\sin(x)\", r\"\\,dx\")\n \n # Step 2: The antiderivative\n eq2 = MathTex(r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\")\n \n # Step 3: Substitute limits via the Fundamental Theorem of Calculus\n eq3 = MathTex(r\"=\", r\"-\\cos(\\pi)\", r\"-\", r\"\\left(-\\cos(0)\\right)\")\n \n # Step 4: Evaluate trigonometric functions\n eq4 = MathTex(r\"=\", r\"-(-1)\", r\"-\", r\"(-1)\")\n \n # Step 5: Final arithmetic and result\n eq5 = MathTex(r\"=\", r\"1\", r\"+\", r\"1\", r\"=\", r\"2\")\n \n # Position equations on the right side of the screen\n equations = VGroup(eq1, eq2, eq3, eq4, eq5)\n equations.arrange(DOWN, buff=0.5, aligned_edge=LEFT)\n equations.to_edge(RIGHT).shift(UP * 0.5)\n \n # Title\n title = Text(\"Definite Integral of sin(x)\", font_size=36).to_edge(UP)\n \n # --- 4. Animation Sequence ---\n \n # Intro: Title, Axes, and Graph\n self.play(Write(title))\n self.play(Create(axes), Write(x_labels), Write(y_label))\n self.play(Create(sin_graph), Write(sin_label))\n self.wait(0.5)\n \n # Show Integral Formula and Area Visualization\n self.play(Write(eq1))\n self.play(FadeIn(area))\n self.wait(1)\n \n # Step 1 -> Step 2: Find Antiderivative\n self.play(Write(eq2))\n self.wait(1)\n \n # Step 2 -> Step 3: Apply Limits\n self.play(Write(eq3))\n self.wait(1)\n \n # Step 3 -> Step 4: Evaluate Cosine\n self.play(Write(eq4))\n self.wait(1)\n \n # Step 4 -> Step 5: Final Calculation\n self.play(Write(eq5))\n self.wait(1)\n \n # Highlight Final Result\n box = SurroundingRectangle(eq5, color=YELLOW, buff=0.2)\n result_text = Text(\"Final Result: 2\", font_size=30, color=YELLOW).next_to(box, DOWN, buff=0.4)\n self.play(Create(box), Write(result_text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineIntegration(Scene):\n def construct(self):\n # --- 1. Setup Coordinate System ---\n axes = Axes(font_size=24, \n x_range=[0, 4, 1],\n y_range=[0, 1.5, 0.5],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).to_edge(LEFT)\n \n # Custom x-axis labels for 0 and Pi\n x_labels = VGroup(\n MathTex(\"0\").next_to(axes.c2p(0, 0), DOWN, buff=0.2),\n MathTex(\"\\\\pi\").next_to(axes.c2p(np.pi, 0), DOWN, buff=0.2)\n )\n y_label = axes.get_y_axis_label(\"y\", edge=LEFT, buff=0.3)\n \n # --- 2. Plot the Function and Area ---\n sin_graph = axes.plot(lambda x: np.sin(x), x_range=[0, np.pi], color=BLUE)\n sin_label = axes.get_graph_label(sin_graph, \"\\\\sin(x)\", x_val=PI/2, direction=UP)\n \n # Area under the curve to visualize the definite integral\n area = axes.get_area(sin_graph, x_range=[0, np.pi], color=GREEN, opacity=0.5)\n \n # --- 3. Prepare Equation Steps ---\n # Step 1: The definite integral\n eq1 = MathTex(r\"\\int_{0}^{\\pi}\", r\"\\sin(x)\", r\"\\,dx\")\n \n # Step 2: The antiderivative\n eq2 = MathTex(r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\")\n \n # Step 3: Substitute limits via the Fundamental Theorem of Calculus\n eq3 = MathTex(r\"=\", r\"-\\cos(\\pi)\", r\"-\", r\"\\left(-\\cos(0)\\right)\")\n \n # Step 4: Evaluate trigonometric functions\n eq4 = MathTex(r\"=\", r\"-(-1)\", r\"-\", r\"(-1)\")\n \n # Step 5: Final arithmetic and result\n eq5 = MathTex(r\"=\", r\"1\", r\"+\", r\"1\", r\"=\", r\"2\")\n \n # Position equations on the right side of the screen\n equations = VGroup(eq1, eq2, eq3, eq4, eq5)\n equations.arrange(DOWN, buff=0.5, aligned_edge=LEFT)\n equations.to_edge(RIGHT).shift(UP * 0.5)\n \n # Title\n title = Text(\"Definite Integral of sin(x)\", font_size=36).to_edge(UP)\n \n # --- 4. Animation Sequence ---\n \n # Intro: Title, Axes, and Graph\n self.play(Write(title))\n self.play(Create(axes), Write(x_labels), Write(y_label))\n self.play(Create(sin_graph), Write(sin_label))\n self.wait(0.5)\n \n # Show Integral Formula and Area Visualization\n self.play(Write(eq1))\n self.play(FadeIn(area))\n self.wait(1)\n \n # Step 1 -> Step 2: Find Antiderivative\n self.play(Write(eq2))\n self.wait(1)\n \n # Step 2 -> Step 3: Apply Limits\n self.play(Write(eq3))\n self.wait(1)\n \n # Step 3 -> Step 4: Evaluate Cosine\n self.play(Write(eq4))\n self.wait(1)\n \n # Step 4 -> Step 5: Final Calculation\n self.play(Write(eq5))\n self.wait(1)\n \n # Highlight Final Result\n box = SurroundingRectangle(eq5, color=YELLOW, buff=0.2)\n result_text = Text(\"Final Result: 2\", font_size=30, color=YELLOW).next_to(box, DOWN, buff=0.4)\n self.play(Create(box), Write(result_text))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the effect of adding and removing elements on the levels of the cumulative hierarchy?", "chosen": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"Exploring Hierarchies\", font_size=48)\n subtitle = Text(\"Adding Elements Changes Levels\", font_size=36)\n \n self.play(Write(title))\n self.wait(1)\n self.play(Transform(title, subtitle))\n self.wait(1)\n\n # Create the first level\n level_0 = VGroup(Circle(radius=0.7)).shift(LEFT*2 + DOWN*2)\n label_0 = MathTex(\"\\\\mathcal{A}\").next_to(level_0, RIGHT)\n \n self.play(Create(level_0), Write(label_0))\n self.wait(1)\n\n # Add element to create second level\n level_1 = VGroup(Square(side_length=1.4).rotate(-PI/4)).move_to(level_0.get_center())\n label_1 = MathTex(\"\\\\mathcal{B} \\\\in \\\\mathcal{A}\").next_to(level_1, UP)\n \n self.play(Create(VGroup(level_1, label_1)))\n self.wait(1)\n\n # Remove element from second level back to first level\n self.play(FadeOut(VGroup(level_1, label_1)))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"Hierarchical structures change with additions/removals.\", font_size=32)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(VGroup(title, conclusion)))\n```", "rejected": "```python\n\"\"\"\nThe Cumulative Hierarchy Animation\n\nThis animation demonstrates how elements are added and removed from sets,\nand how this affects their level in the cumulative hierarchy.\n\nScene Structure:\n1. Introduction: Shows the initial empty set at Level 0.\n2. Addition Phase: Elements are introduced one by one.\n - Each element adds a new layer to the hierarchy.\n - The corresponding power set appears above the parent set.\n3. Removal Phase: Elements are removed sequentially.\n - As elements leave, the hierarchy collapses back to its original state.\n - Power sets disappear as they become redundant.\n\"\"\"\n\nimport os\nfrom manim import *\n\nclass HierarchicalStructure(Scene):\n def construct(self):\n # Title\n title = Text(\"Hierarchical Structures\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create two circles for nodes\n circle_a = Circle(radius=0.8).shift(LEFT * 3 + DOWN)\n label_a = MathText(\"A\").next_to(circle_a, UP)\n\n circle_b = Circle(radius=0.8).shift(RIGHT * 3 + DOWN)\n label_b = MathText(\"B\").next_to(circle_b, UP)\n\n # Add labels first so they appear behind the circles\n self.add(label_a, label_b)\n self.play(Create(circle_a), Create(circle_b))\n\n # Draw lines representing connections between nodes\n line_ab = Line(start=circle_a.get_right(), end=circle_b.get_left())\n \n connection_label = MathText(\"\\\\rightarrow \\\\left\\\\{ B \\\\right\\\\} \").next_to(line_ab, RIGHT)\n self.play(GrowArrow(line_ab))\n self.play(Write(connection_label))\n self.wait(2)\n\n # Clear the screen\n self.clear()\n self.wait(1)\n\n# To run this file:\n# python filename.py --renderer=svg\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation using ManimCE that visualizes a simple convolutional neural network with alternating convolutional layers and pooling layers? The network should start with a convolutional layer that has 6 feature maps and a 3x3 kernel, then a pooling layer, followed by another convolutional layer with 16 feature maps and a 3x3 kernel, and ending with a final pooling layer. The animation should show the construction of this neural network.", "chosen": "```python\nfrom manim import *\n\nclass ConvNetVisualization(Scene):\n def construct(self):\n # Title for the visualization\n title = Text(\"Simple CNN Architecture\", font_size=48).to_edge(UP)\n \n # --- Layer Configuration ---\n conv_layer_params_1 = {\"filters\": 6, \"kernel_size\": (3, 3), \"layer_type\": \"Conv\"}\n pool_layer_params = {\"stride\": 2}\n conv_layer_params_2 = {\"filters\": 16, \"kernel_size\": (3, 3), \"layer_type\": \"Conv\"}\n\n # Create nodes for each type of layer\n conv_nodes_1 = VGroup()\n for _ in range(conv_layer_params_1[\"filters\"]):\n box = RoundedRectangle(corner_radius=0.2, width=2.5, height=1.5, color=BLUE)\n text = MathTex(\"F\").scale(0.7).move_to(box.get_center())\n \n node_group = VGroup(text, box).set_color(YELLOW)\n conv_nodes_1.add(node_group)\n\n pool_node = Circle(radius=0.5, fill_opacity=0.5, stroke_width=2, color=GREEN)\n label_pool = Text(\"Pool\", font_size=18, color=WHITE).next_to(pool_node, DOWN)\n pool_group = VGroup(pool_node, label_pool)\n\n conv_nodes_2 = VGroup()\n for _ in range(conv_layer_params_2[\"filters\"]):\n box = RoundedRectangle(corner_radius=0.2, width=2.5, height=1.5, color=RED)\n text = MathTex(\"\\\\times\\\\times\\\\times\\\\times\").scale(0.7).move_to(box.get_center())\n \n node_group = VGroup(text, box).set_color(PURPLE)\n conv_nodes_2.add(node_group)\n\n # Arrange layers horizontally\n all_layers = VGroup(\n conv_nodes_1,\n pool_group,\n conv_nodes_2\n ).arrange(RIGHT, buff=2.5)\n\n # Animate the creation of each component sequentially\n \n self.play(Write(title))\n self.wait(0.5)\n\n # Show first convolutional layer\n self.play(Create(conv_nodes_1))\n self.wait(1)\n\n # Add Pooling layer\n self.play(FadeIn(pool_group, shift=DOWN * 0.5))\n self.wait(1)\n\n # Show second convolutional layer\n self.play(Create(conv_nodes_2))\n self.wait(1)\n\n# To run this script:\n# manim -pql filename.py ConvNetVisualization\n```", "rejected": "```python\nfrom manim import *\n\nclass ConvolutionNetworkScene(Scene):\n def construct(self):\n # Title for the visualization\n title = Text(\"Visualizing Convolutional Layers\", font_size=34)\n self.play(Write(title))\n self.wait(1)\n\n # --- Layer 1: Input Image ---\n input_label = Text(\"Input Image\", font_size=28).to_edge(UP)\n image_shape = RoundedRectangle(corner_radius=0.15, width=7, height=3.5, color=BLUE_B, fill_opacity=0.1)\n \n # Create grid points representing pixel values\n pixels = VGroup()\n cell_width = 0.5\n cell_height = 0.5\n \n for x in range(int(image_shape.width/cell_width)):\n row = []\n for y in range(int(image_shape.height/cell_height)):\n dot = Dot(radius=cell_width/2, color=BLUE_D).move_to(\n image_shape.get_corner(DOWN + LEFT) \n + UP*(y*cell_height + cell_height/2)\n + RIGHT*(x*cell_width + cell_width/2)\n )\n row.append(dot)\n pixels.add(VGroup(*row))\n\n input_group = VGroup(input_label, image_shape, pixels).arrange(RIGHT, buff=1.5)\n input_group.shift(LEFT*3.5 + DOWN*1)\n \n # Animate creation of input elements\n self.play(FadeIn(input_label), Create(image_shape), FadeIn(pixels), run_time=2)\n self.wait(0.5)\n\n # --- Layer 2A: Conv1 Feature Maps ---\n conv1_title = Text(\"+ Filter Group 1\", font_size=22).next_to(image_shape, UP, buff=0.5)\n filter_map_labels = [\n MathTex(\"\\\\text{Filter } F_{1}\").scale(0.6),\n MathTex(\"\\\\text{Filter } F_{2}\"),\n MathTex(\"\\\\text{Filter } F_{3}\")\n ]\n filters_g1 = VGroup(*filter_map_labels)\n \n # Position filters vertically within their own group\n g1_filters = VGroup(*filters_g1).arrange(DOWN, buff=0.2).shift(UP*1.2)\n self.play(Write(conv1_title), Write(g1_filters), run_time=1.5)\n self.wait(0.5)\n \n # Show how each map is created from the input data\n maps_g1 = VGroup()\n for i in range(len(filters_g1)):\n map_rect = Rectangle(width=image_shape.width-0.5, height=image_shape.height-0.5, color=GREEN_A, stroke_width=2)\n text = Text(f\"Map {i+1}\", font_size=20).next_to(map_rect, DOWN)\n maps_g1.add(VGroup(map_rect, text).set_color(GREEN_C))\n\n maps_group1 = VGroup(*maps_g1).arrange(RIGHT, buff=0.5).next_to(filter_map_labels[-1], DOWN, buff=1).align_to(g1_filters, LEFT).shift(RIGHT*1.5)\n \n # Animation: Morph the input dots into mapped areas\n morphed_input_dots = VGroup()\n for i, dot in enumerate(pixels.submobjects):\n rect_pos = maps_group1[i].get_center()\n \n # Map area is slightly smaller than input shape\n rect = Rectangle(\n width=max(maps_group1[i].width, 0.4), \n height=max(maps_group1[i].height, 0.3), \n color=WHITE,\n fill_opacity=0.2, \n stroke_width=1\n ).move_to(rect_pos)\n \n morphed_input_dots.add(Rectangle(\n width=max(cell_width*1.5, 0.4), \n height=max(cell_height*1.5, 0.3), \n color=BLUE_D, \n fill_opacity=0.1, \n stroke_width=1\n ).move_to(dot.get_center()))\n \n else:\n pass\n\n # Move labels up to make room for outputs\n self.play(\n FadeOut(g1_filters), \n move_into_view=morphed_input_dots, \n run_time=2\n )\n\n # Display individual maps with labels\n self.play(Create(maps_group1), run_time=2)\n self.wait(0.5)\n\n # --- Layer 2B: Pooling Layer ---\n pool_layer_text = Text(\"\\nPooling\\nLayer\", font_size=22, line_spacing=1.2)\n pool_filter_rects = VGroup()\n for _ in range(4): # Simulate 4 max-pool regions\n pool_rect = Rectangle(width=1.5, height=1.5, color=YELLOW, fill_opacity=0.2)\n pool_rect.shift(LEFT*1.5 + DOWN*0.5)\n pool_filter_rects.add(pool_rect)\n\n pool_groups = VGroup()\n for mrect in maps_group1:\n small_rect = Rect(\n width=mrect.width / 2.5, \n height=mrect.height / 2.5, \n color=ORANGE, \n fill_opacity=0.1\n )\n small_rect.move_to(mrect.get_center())\n pool_groups.add(small_rect)\n\n pools_group = VGroup(pool_filter_rects, pool_groups)\n pools_group.next_to(maps_group1, DOWN, buff=1).align_to(maps_group1, LEFT).shift(RIGHT*1.5)\n \n self.play(Write(pool_layer_text), Create(pool_filter_rects), run_time=1.5)\n self.play(LaggedStart(*[\n TransformFromCopy(mrect.copy(), pgroup) for mrect, pgroup in zip(maps_group1, pool_groups)\n ], lag_ratio=0.5), run_time=2)\n self.wait(0.5)\n\n # --- Transition to Second Set of Filters ---\n second_conv_label = Text(\"+ Filter Group 2\", font_size=22).next_to(images_group, UP, buff=0.5)\n filters_g2 = VGroup(MathTex(\"\\\\text{Filter } G_{1}\"), MathTex(\"\\\\text{Filter } G_{2}\"))\n g2_filters = VGroup(*filters_g2).arrange(DOWN, buff=0.2).shift(UP*1.2)\n self.play(Write(second_conv_label), Write(g2_filters), run_time=1.5)\n self.wait(0.5)\n\n images_group = VGroup()\n for i in range(len(filters_g2)):\n img_rect = Rectangle(width=image_shape.width-0.5, height=image_shape.height-0.5, color=TEAL_A, stroke_width=2)\n text = Text(f\"Image {i+1}\", font_size=20).next_to(img_rect, DOWN)\n images_group.add(VGroup(img_rect, text).set_color(TEAL_C))\n\n images_group.arrange(RIGHT, buff=0.5).next_to(filter_map_labels[-1], DOWN, buff=1).align_to(g2_filters, LEFT).shift(LEFT*3.5)\n \n # Merge the two groups of maps horizontally to simulate stacking\n merged_maps = VGroup()\n for i in range(len(images_group)):\n combined_rect = Rectangle(\n width=(images_group[i][0].width + maps_group1[i][0].width)/2, \n height=max(images_group[i][0].height, maps_group1[i][0].height), \n color=LIGHT_GRAY, \n stroke_width=2\n ).move_to((images_group[i].get_center()[0], images_group[i].get_center()[1], 0))\n combined_text = Text(f\"Merged Map {i+1}\", font_size=20).next_to(combined_rect, DOWN, buff=-0.2)\n merged_maps.add(VGroup(combined_rect, combined_text).set_color(YELLOW_A))\n\n self.play(TransformFromCopy(maps_group1, merged_maps), run_time=2)\n self.wait(0.5)\n\n # --- Final State: Flat Structure ---\n flat_structure = VGroup()\n for i in range(len(filtered_merges)):\n box = Square(side_length=1.2, color=BLUE_E, fill_opacity=i/len(filtered_merges))\n label = Text(str(i+1), font_size=20).move_to(box.get_center()).set_fill(WHITE)\n flat_structure.add(VGroup(box, label).shift(LEFT*i*1.8))\n else:\n pass\n \n final_image = VGroup().add(Square(side_length=3.5, color=BLUE_D)).center()\n\n # Move everything to center and animate transformation\n self.play(\n FadeOut(inputs), \n FadeOut(pool_layers), \n FadeOut(all_filters), \n FadeIn(final_image), \n run_time=2\n )\n self.wait(1)\n\n# To run this animation, save it to a file named 'conv_network.py' and execute:\n# manim -pql conv_network.py ConvolutionNetworkScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a multi-act ManimCE scene (`AttentionGridScene`) showing 4 token `RoundedRectangle` boxes, `Arrow` Q/K/V projections, and a 4x4 attention `VGroup(*rows)` heatmap.", "chosen": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def clear_stage(self):\n if self.mobjects:\n for mobj in self.mobjects:\n mobj.animate.scale(0).shift(RIGHT*10 + DOWN*10)\n self.wait(0.1)\n\n def construct(self):\n # --- Act 1: Token Grid ---\n tokens = VGroup(\n RoundedRectangle(width=1.2, height=0.8, corner_radius=0.2) for _ in range(4)\n ).arrange(DOWN, buff=0.4).scale(0.75)\n\n labels = [\"Q\", \"K\", \"V\", \"\"]\n label_nodes = VGroup()\n for i, token in enumerate(tokens):\n node_label = Text(labels[i], font_size=24, color=WHITE)\n node_label.move_to(token.get_center())\n label_nodes.add(node_label)\n\n title_text = Tex(\"Token Sequence\").to_edge(UP, buff=0.5)\n title_box = SurroundingRectangle(title_text, color=BLUE, buff=0.2)\n\n self.play(FadeIn(title_text), Create(title_box))\n for box, label in zip(tokens, label_nodes):\n self.play(Create(box), Write(label))\n\n self.wait()\n\n # --- Transition to Attention Grid ---\n self.clear_stage()\n\n # --- Act 2: Matrix Representation of Attention ---\n matrix_grid = VGroup()\n rows = []\n colors = [RED, GREEN, YELLOW, BLUE]\n\n for row_idx in range(4):\n row = VGroup()\n for col_idx in range(4):\n cell = Square(side_length=0.6, color=colors[col_idx])\n cell.shift(LEFT*(col_idx - 1.5))\n text_value = MathTex(str(row_idx + 1)).move_to(cell)\n \n if row_idx == col_idx:\n highlight_rect = SurroundingRectangle(text_value, color=YELLOW, buff=0.05, stroke_width=2)\n \n else:\n highlight_rect = Rectangle(height=1.5, width=1, color=colors[col_idx])\n\n cell_group = VGroup(highlight_rect, cell, text_value)\n row.add(cell_group)\n \n cells_with_labels = VGroup(*row.arrange(RIGHT, buff=0.1))\n row_arrangement = cells_with_labels.arrange(DOWN, buff=0.3)\n rows.append(row_arrangement)\n \n matrix_grid.add(VGroup(*rows).arrange(RIGHT, buff=0.6).center())\n\n grid_title = Tex(\"Matrix Formulation of Attention\")\n grid_title.to_edge(UP, buff=0.5)\n\n self.play(Write(grid_title))\n self.wait(0.5)\n for row in rows:\n self.play(LaggedStartMap(Create, row, lag_ratio=0.2))\n self.wait(2)\n\n # Animate the transformation of the matrix elements into arrows\n arrow_groups = []\n for row_idx, row in enumerate(rows):\n arrows = VGroup()\n for col_idx, element in enumerate(row):\n if element[1].get_height(): # Check if it's not empty\n source = element[1].get_bottom()\n target = element[2].get_top()\n arrow = Arrow(source, target, buff=0.1, max_tip_length_to_length_ratio=0.2)\n arrows.add(arrow)\n arrow_groups.append(arrows)\n\n for arrows in arrow_groups:\n self.play(LaggedStartMap(GrowArrow, arrows, lag_ratio=0.3))\n\n self.wait(2)\n self.play(FadeOut(matrix_grid), FadeOut(grid_title))\n \n # --- End Scene ---\n\n self.wait()\n```", "rejected": "```python\nimport numpy as np\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n self.token_grid()\n self.projections()\n self.attention_heatmap()\n\n def token_grid(self):\n tokens = VGroup(*[\n RoundedRectangle(\n width=2,\n height=1.5,\n corner_radius=0.2,\n fill_color=BLUE_D,\n fill_opacity=0.8\n ).shift(RIGHT * i + UP * j)\n for j in range(2) for i in range(2)\n ])\n \n labels = VGroup(*[\n MathTex(f\"t_{i+j*2}\").move_to(token.get_center())\n for j in range(2) for i in range(2)\n ])\n\n self.play(Create(tokens))\n self.add(labels)\n\n self.tokens = tokens\n\n def projections(self):\n tokens = self.tokens\n \n # Create projection arrows from each token box\n q_arrows = []\n k_arrows = []\n v_arrows = []\n\n for i, token in enumerate(tokens):\n pos = token.get_center()\n \n if i == 0: \n target_pos = ORIGIN\n elif i == 1: \n target_pos = RIGHT * 3\n else:\n continue\n\n arrow_style = Arrow(start=pos, end=target_pos, color=YELLOW, buff=0.1, max_tip_length_to_length_ratio=0.2)\n\n if i % 2 == 0:\n q_arrows.append(arrow_style.copy().set_stroke(opacity=i==0).scale(i==0))\n k_arrows.append(arrow_style.copy().rotate(-PI/2).set_stroke(color=GREEN_C, opacity=i==1))\n v_arrows.append(arrow_style.copy().rotate(PI/2).set_stroke(color=RED_C, opacity=i==1))\n else:\n pass\n \n self.play(GrowArrow(q_arrows[-1]), run_time=0.6)\n self.play(GrowArrows(k_arrows[-1], v_arrows[-1]), run_time=0.6)\n self.wait(0.2)\n\n self.arrows = [q_arrows, k_arrows, v_arrows]\n\n def attention_heatmap(self):\n rows = VGroup(*[\n VGroup(*[Square(side_length=1, stroke_width=1, color=WHITE, fill_opacity=1.0) for _ in range(4)])\n .arrange(DOWN, buff=0)\n .to_edge(UP, buff=0.5)\n .next_to(row_group, DOWN, buff=0.2)\n for row_group in [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 0], [0, 0, 0, 1]]\n ]).arrange(RIGHT, buff=0)\n\n # Animate grid appearing\n self.play(LaggedStartMap(FadeIn, rows, lag_ratio=0.1))\n self.wait(0.5)\n\n # Color cells based on values\n colors = [\n BLUE_D, GRAY_D, GREEN_D, RED_D\n ]\n\n # Fill matrix with different colors\n for r_idx, row in enumerate(rows):\n for c_idx, cell in enumerate([c for c in row]):\n val = colors[r_idx][c_idx]\n cell.set_fill(val, opacity=0.7)\n \n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features:\n\nThe animation begins by transforming the original text into the phrase \"animate.align_on_border\" at the top of the screen, just as in the original. Then, a square appears on the left side of the screen, but now it is accompanied by a labeled coordinate axis system to provide spatial context. As the square moves upward to align with the top border (along the y-axis direction [0,1,0]), a dynamic mathematical formula appears below it, displaying the vector transformation in real-time: `square.animate.align_on_border(direction=np.array([0,1,0]))`. Simultaneously, an explanatory text box fades in, briefly explaining the purpose of the `align_on_border` method. After the square reaches the top, it smoothly morphs into a circle, demonstrating how shapes can transform in Manim, and then fades out. The entire sequence is timed to emphasize clarity, with the formula and text persisting for a moment afterward to reinforce the learning point. This enhanced version not only preserves the original alignment animation but also adds educational context, visual aids, and a shape transformation to deepen understanding.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedAlignmentAnimation(Scene):\n def construct(self):\n # Create and transform the title text\n title = Text(\"animate.align_on_border\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create coordinate axes\n axes = Axes(\n x_range=[-7, 7, 1],\n y_range=[-4, 4, 1],\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels()\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n\n # Create square on the left\n square = Square(color=RED, fill_opacity=0.8).scale(0.5).shift(LEFT*3)\n self.play(DrawBorderThenFill(square))\n self.wait(0.5)\n\n # Create formula\n formula = MathTex(\n r\"\\text{square.animate.align\\_on\\_border(direction=np.array([0,1,0]))}\",\n font_size=24\n ).next_to(title, DOWN, buff=0.5)\n self.play(Write(formula))\n self.wait(0.5)\n\n # Create explanation text\n explanation = Text(\n \"Aligns the object to the specified screen border\",\n font_size=24,\n color=YELLOW\n ).next_to(formula, DOWN, buff=0.5)\n explanation_box = SurroundingRectangle(explanation, color=WHITE, buff=0.2)\n self.play(\n FadeIn(explanation),\n Create(explanation_box)\n )\n self.wait(0.5)\n\n # Animate square moving up\n self.play(\n square.animate.align_on_border(direction=np.array([0,1,0])),\n run_time=2\n )\n self.wait(1)\n\n # Transform square to circle\n circle = Circle(color=GREEN, fill_opacity=0.8).scale(0.5)\n circle.move_to(square)\n self.play(Transform(square, circle))\n self.wait(1)\n\n # Fade out everything\n self.play(\n FadeOut(square),\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(formula),\n FadeOut(explanation),\n FadeOut(explanation_box),\n run_time=1\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedAlignmentAnimation(Scene):\n def construct(self):\n # Create and transform the title text\n title = Text(\"animate.align_on_border\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create coordinate axes\n axes = Axes(\n x_range=[-7, 7, 1],\n y_range=[-4, 4, 1],\n axis_config={\"color\": BBLUE},\n )\n axes_labels = axes.get_axis_labels()\n self.play(Create(axes), Write(axes_labels))\n self.wait(0.5)\n\n # Create square on the left\n square = Square(color=RED, fill_opacity=0.8).scale(0.5).shift(LEFT*3)\n self.play(DrawBorderThenFill(square))\n self.wait(0.5)\n\n # Create formula\n formula = MathTex(\n r\"\\text{square.animate.align\\_on\\_border(direction=np.array([0,1,0]))}\",\n font_size=24\n ).next_to(title, DOWN, buff=0.5)\n self.play(Write(formula))\n self.wait(0.5)\n\n # Create explanation text\n explanation = Text(\n \"Aligns the object to the specified screen border\",\n font_size=24,\n color=YELLOW\n ).next_to(formula, DOWN, buff=0.5)\n explanation_box = SurroundingRectangle(explanation, color=WHITE, buff=0.2)\n self.play(\n FadeIn(explanation),\n Create(explanation_box)\n )\n self.wait(0.5)\n\n # Animate square moving up\n self.play(\n square.animate.align_on_border(direction=np.array([0,1,0])),\n run_time=2\n )\n self.wait(1)\n\n # Transform square to circle\n circle = Circle(color=GREEN, fill_opacity=0.8).scale(0.5)\n circle.move_to(square)\n self.play(Transform(square, circle))\n self.wait(1)\n\n # Fade out everything\n self.play(\n FadeOut(square),\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(formula),\n FadeOut(explanation),\n FadeOut(explanation_box),\n run_time=1\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an educational animation that visually explains step-by-step how to solve a triple integral math problem. Specifically, the problem should be the triple integral of the function xyz over the cube with sides from 0 to 1. I'd like the animation to proceed by first showing the triple integral equation, then sequentially explain how to integrate with respect to z, y, and x, displaying each step of the integration process clearly and pausing between steps. Each explanation should be accompanied by a text description that specifies which variable is being integrated over. After the final integration, display the complete solution to the triple integral. Can you make sure that the final result is showcased clearly at the end once the previous steps have been cleared from view?", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # 1. Initial Display\n initial_eq = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx\"\n ).scale(1.1)\n \n self.play(Write(initial_eq))\n self.wait(2)\n\n # 2. Step-by-Step Integration\n \n # --- Step 1: Integrate with respect to z ---\n label_z = Text(\"Integrate with respect to z\", font_size=32, color=BLUE).to_edge(UP)\n eq_z = MathTex(\n r\"= \\int_0^1 \\int_0^1 \\left[ \\frac{xyz^2}{2} \\right]_0^1 dy \\, dx\"\n ).scale(1.0)\n eq_z_simplified = MathTex(\n r\"= \\int_0^1 \\int_0^1 \\frac{xy}{2} \\, dy \\, dx\"\n ).scale(1.0)\n\n self.play(Write(label_z))\n self.play(ReplacementTransform(initial_eq, eq_z))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_z, eq_z_simplified))\n self.wait(2)\n self.play(FadeOut(label_z))\n\n # --- Step 2: Integrate with respect to y ---\n label_y = Text(\"Integrate with respect to y\", font_size=32, color=BLUE).to_edge(UP)\n eq_y = MathTex(\n r\"= \\int_0^1 \\left[ \\frac{xy^2}{4} \\right]_0^1 dx\"\n ).scale(1.0)\n eq_y_simplified = MathTex(\n r\"= \\int_0^1 \\frac{x}{4} \\, dx\"\n ).scale(1.0)\n\n self.play(Write(label_y))\n self.play(ReplacementTransform(eq_z_simplified, eq_y))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_y, eq_y_simplified))\n self.wait(2)\n self.play(FadeOut(label_y))\n\n # --- Step 3: Integrate with respect to x ---\n label_x = Text(\"Integrate with respect to x\", font_size=32, color=BLUE).to_edge(UP)\n eq_x = MathTex(\n r\"= \\left[ \\frac{x^2}{8} \\right]_0^1\"\n ).scale(1.0)\n eq_x_simplified = MathTex(\n r\"= \\frac{1}{8}\"\n ).scale(1.0)\n\n self.play(Write(label_x))\n self.play(ReplacementTransform(eq_y_simplified, eq_x))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_x, eq_x_simplified))\n self.wait(2)\n self.play(FadeOut(label_x))\n\n # 3. Final Solution\n # Clear the screen to make the final answer the sole focus\n self.play(FadeOut(eq_x_simplified))\n self.wait(1)\n\n # Showcase the final calculated result prominently\n final_result = MathTex(\n r\"\\frac{1}{8}\",\n color=YELLOW\n ).scale(2.0)\n \n self.play(Write(final_result))\n self.play(Circumscribe(final_result))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # 1. Initial Display\n initial_eq = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dz \\, dy \\, dx\"\n ).scale(1.1)\n \n self.play(Write(initial_eq))\n self.wait(2)\n\n # 2. Step-by-Step Integration\n \n # --- Step 1: Integrate with respect to z ---\n label_z = Text(\"Integrate with respect to z\", font_size=32, color=BLUE).to_edge(UP)\n eq_z = MathTex(\n r\"= \\int_0^1 \\int_0^1 \\left[ \\frac{xyz^2}{2} \\right]_0^1 dy \\, dx\"\n ).scale(1.0)\n eq_z_simplified = MathTex(\n r\"= \\int_0^1 \\int_0^1 \\frac{xy}{2} \\, dy \\, dx\"\n ).scale(1.0)\n\n self.play(Write(label_z))\n self.play(ReplacementTransform(target_position=ORIGIN, initial_eq, eq_z))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_z, eq_z_simplified))\n self.wait(2)\n self.play(FadeOut(label_z))\n\n # --- Step 2: Integrate with respect to y ---\n label_y = Text(\"Integrate with respect to y\", font_size=32, color=BLUE).to_edge(UP)\n eq_y = MathTex(\n r\"= \\int_0^1 \\left[ \\frac{xy^2}{4} \\right]_0^1 dx\"\n ).scale(1.0)\n eq_y_simplified = MathTex(\n r\"= \\int_0^1 \\frac{x}{4} \\, dx\"\n ).scale(1.0)\n\n self.play(Write(label_y))\n self.play(ReplacementTransform(eq_z_simplified, eq_y))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_y, eq_y_simplified))\n self.wait(2)\n self.play(FadeOut(label_y))\n\n # --- Step 3: Integrate with respect to x ---\n label_x = Text(\"Integrate with respect to x\", font_size=32, color=BLUE).to_edge(UP)\n eq_x = MathTex(\n r\"= \\left[ \\frac{x^2}{8} \\right]_0^1\"\n ).scale(1.0)\n eq_x_simplified = MathTex(\n r\"= \\frac{1}{8}\"\n ).scale(1.0)\n\n self.play(Write(label_x))\n self.play(ReplacementTransform(eq_y_simplified, eq_x))\n self.wait(1.5)\n self.play(ReplacementTransform(eq_x, eq_x_simplified))\n self.wait(2)\n self.play(FadeOut(label_x))\n\n # 3. Final Solution\n # Clear the screen to make the final answer the sole focus\n self.play(FadeOut(eq_x_simplified))\n self.wait(1)\n\n # Showcase the final calculated result prominently\n final_result = MathTex(\n r\"\\frac{1}{8}\",\n color=YELLOW\n ).scale(2.0)\n \n self.play(Write(final_result))\n self.play(Circumscribe(final_result))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an animated video that demonstrates different concepts in chemistry, starting with the formation of a simple molecule. The video should show the individual atoms or particles coming together to form a molecule, followed by the transformation of this molecule into a metal oxide grid. Afterward, I'd like to see this grid change into a carbon grid structure. Both grid transformations should be smoothly animated. Finally, the animation should show an electron moving in a complex path around the molecule or grid, mimicking the motion of electrons in an atomic structure. The entire sequence should be visually engaging and help illustrate the dynamic nature of chemical structures. Can you create such an animation for me?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryDynamics(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_OXYGEN = RED\n COLOR_HYDROGEN = WHITE\n COLOR_METAL = BLUE\n COLOR_CARBON = DARK_GRAY\n COLOR_ELECTRON = YELLOW\n ATOM_RADIUS = 0.25\n \n # ------------------------------------------------------------------\n # 1. Molecule Formation (H2O)\n # ------------------------------------------------------------------\n # Define atoms as dots\n oxygen = Dot(radius=ATOM_RADIUS, color=COLOR_OXYGEN)\n hydrogen1 = Dot(radius=ATOM_RADIUS * 0.8, color=COLOR_HYDROGEN)\n hydrogen2 = Dot(radius=ATOM_RADIUS * 0.8, color=COLOR_HYDROGEN)\n\n # Initial scattered positions\n oxygen.move_to(LEFT * 3 + UP * 1)\n hydrogen1.move_to(LEFT * 5 + UP * 2)\n hydrogen2.move_to(LEFT * 5 + DOWN * 2)\n\n self.play(Create(oxygen), Create(hydrogen1), Create(hydrogen2))\n \n molecule_label = Text(\"Molecular Formation\", font_size=36).to_edge(UP)\n self.play(Write(molecule_label))\n self.wait(0.5)\n\n # Target positions for H2O (Bent geometry)\n target_o = ORIGIN\n target_h1 = ORIGIN + np.array([1, 1, 0])\n target_h2 = ORIGIN + np.array([1, -1, 0])\n\n self.play(\n oxygen.animate.move_to(target_o),\n hydrogen1.animate.move_to(target_h1),\n hydrogen2.animate.move_to(target_h2),\n run_time=2,\n rate_func=smooth\n )\n \n # Add bonds\n bond1 = Line(target_o, target_h1, stroke_width=4, color=GREY)\n bond2 = Line(target_o, target_h2, stroke_width=4, color=GREY)\n self.play(Create(bond1), Create(bond2), run_time=1)\n \n molecule = VGroup(oxygen, hydrogen1, hydrogen2, bond1, bond2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Metal Oxide Grid Transformation\n # ------------------------------------------------------------------\n self.play(FadeOut(molecule_label))\n \n # Create a 4x4 alternating grid of Metal (MgO style)\n grid_size = 4\n spacing = 1.2\n metal_oxide_grid = VGroup()\n \n for i in range(grid_size):\n for j in range(grid_size):\n # Alternating colors for Ionic Lattice representation\n color = COLOR_METAL if (i + j) % 2 == 0 else COLOR_OXYGEN\n dot = Dot(radius=ATOM_RADIUS, color=color)\n x = (i - grid_size/2 + 0.5) * spacing\n y = (j - grid_size/2 + 0.5) * spacing\n dot.move_to(np.array([x, y, 0]))\n metal_oxide_grid.add(dot)\n\n # Transform the original molecule into part of the grid, create the rest\n self.play(\n Transform(molecule, metal_oxide_grid[:3]),\n Create(metal_oxide_grid[3:]),\n run_time=2.5\n )\n \n # Ensure all grid atoms are grouped and on screen\n current_grid = metal_oxide_grid\n self.add(current_grid)\n \n oxide_label = Text(\"Metal Oxide Lattice\", font_size=36).to_edge(UP)\n self.play(Write(oxide_label))\n self.wait(1.5)\n self.play(FadeOut(oxide_label))\n\n # ------------------------------------------------------------------\n # 3. Carbon Grid Transformation (Graphene-like Hexagonal)\n # ------------------------------------------------------------------\n carbon_grid = VGroup()\n hex_spacing = 1.0\n \n # Generate a hexagonal snippet\n rows = 5\n cols = 4\n for row in range(rows):\n offset = 0 if row % 2 == 0 else hex_spacing * np.cos(np.pi/6)\n y_pos = row * hex_spacing * np.sin(np.pi/6) * 2 - 3\n for col in range(cols):\n x_pos = col * hex_spacing * 1.5 + offset - 3\n pos = np.array([x_pos, y_pos, 0])\n atom = Dot(radius=ATOM_RADIUS, color=COLOR_CARBON)\n atom.move_to(pos)\n carbon_grid.add(atom)\n\n # Smoothly transform the square lattice to hexagonal\n self.play(\n ReplacementTransform(current_grid, carbon_grid),\n run_time=2.5\n )\n \n carbon_label = Text(\"Carbon Graphene Grid\", font_size=36).to_edge(UP)\n self.play(Write(carbon_label))\n self.wait(1.5)\n self.play(FadeOut(carbon_label))\n\n # ------------------------------------------------------------------\n # 4. Electron Motion\n # ------------------------------------------------------------------\n # Define a complex parametric path around the grid center\n # Combining circular motion with perturbation for a \"quantum\" feel\n electron_path = ParametricFunction(\n lambda t: np.array([\n 2.5 * np.cos(t) + 0.5 * np.cos(3 * t),\n 2.5 * np.sin(t) + 0.5 * np.sin(3 * t),\n 0\n ]),\n t_range=[0, 2 * PI],\n color=COLOR_ELECTRON\n )\n \n # Create the electron dot\n electron = Dot(radius=0.15, color=COLOR_ELECTRON)\n electron.set_glow_factor(2) # Adds a glow effect if supported by renderer\n \n # Add a trail to visualize the path history\n trail = VMobject(color=COLOR_ELECTRON, stroke_width=2)\n trail.set_points_as_corners([electron.get_center(), electron.get_center()])\n \n def update_trail(mob):\n mob.add_points_as_corners([electron.get_center()])\n if len(mob.points) > 100: # Limit trail length\n mob.set_points(mob.points[-100:])\n \n trail.add_updater(update_trail)\n self.add(trail)\n \n # Animate electron moving along the path\n self.play(\n MoveAlongPath(electron, electron_path),\n run_time=4,\n rate_func=linear\n )\n \n # Clean up trail updater\n trail.remove_updater(update_trail)\n \n # Final Fade Out\n self.play(\n FadeOut(carbon_grid),\n FadeOut(electron),\n FadeOut(trail),\n run_time=1\n )\n self.wait(1)\n\n# To run this: manim -pql script_name.py ChemistryDynamics\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryDynamics(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_OXYGEN = RED\n COLOR_HYDROGEN = WHITE\n COLOR_METAL = BLUE\n COLOR_CARBON = DARK_GRAY\n COLOR_ELECTRON = YELLOW\n ATOM_RADIUS = 0.25\n \n # ------------------------------------------------------------------\n # 1. Molecule Formation (H2O)\n # ------------------------------------------------------------------\n # Define atoms as dots\n oxygen = Dot(radius=ATOM_RADIUS, color=COLOR_OXYGEN)\n hydrogen1 = Dot(radius=ATOM_RADIUS * 0.8, color=COLOR_HYDROGEN)\n hydrogen2 = Dot(radius=ATOM_RADIUS * 0.8, color=COLOR_HYDROGEN)\n\n # Initial scattered positions\n oxygen.move_to(LEFT * 3 + UP * 1)\n hydrogen1.move_to(LEFT * 5 + UP * 2)\n hydrogen2.move_to(LEFT * 5 + DOWN * 2)\n\n self.play(Create(oxygen), Create(hydrogen1), Create(hydrogen2))\n \n molecule_label = Text(\"Molecular Formation\", font_size=36).to_edge(UP)\n self.play(Write(molecule_label))\n self.wait(0.5)\n\n # Target positions for H2O (Bent geometry)\n target_o = ORIGIN\n target_h1 = ORIGIN + np.array([1, 1, 0])\n target_h2 = ORIGIN + np.array([1, -1, 0])\n\n self.play(\n oxygen.animate.move_to(target_o),\n hydrogen1.animate.move_to(target_h1),\n hydrogen2.animate.move_to(target_h2),\n run_time=2,\n rate_func=smooth\n )\n \n # Add bonds\n bond1 = Line(target_o, target_h1, stroke_width=4, color=GREY)\n bond2 = Line(target_o, target_h2, stroke_width=4, color=GREY)\n self.play(Create(bond1), Create(bond2), run_time=1)\n \n molecule = VGroup(oxygen, hydrogen1, hydrogen2, bond1, bond2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Metal Oxide Grid Transformation\n # ------------------------------------------------------------------\n self.play(FadeOut(molecule_label))\n \n # Create a 4x4 alternating grid of Metal (MgO style)\n grid_size = 4\n spacing = 1.2\n metal_oxide_grid = VGroup()\n \n for i in range(grid_size):\n for j in range(grid_size):\n # Alternating colors for Ionic Lattice representation\n color = COLOR_METAL if (i + j) % 2 == 0 else COLOR_OXYGEN\n dot = Dot(radius=ATOM_RADIUS, color=color)\n x = (i - grid_size/2 + 0.5) * spacing\n y = (j - grid_size/2 + 0.5) * spacing\n dot.move_to(np.array([x, y, 0]))\n metal_oxide_grid.add(dot)\n\n # Transform the original molecule into part of the grid, create the rest\n self.play(\n Transform(molecule, metal_oxide_grid[:3]),\n Create(metal_oxide_grid[3:]),\n run_time=2.5\n )\n \n # Ensure all grid atoms are grouped and on screen\n current_grid = metal_oxide_grid\n self.add(current_grid)\n \n oxide_label = Text(\"Metal Oxide Lattice\", font_size=36).to_edge(UP)\n self.play(Write(oxide_label))\n self.wait(1.5)\n self.play(FadeOut(oxide_label))\n\n # ------------------------------------------------------------------\n # 3. Carbon Grid Transformation (Graphene-like Hexagonal)\n # ------------------------------------------------------------------\n carbon_grid = VGroup()\n hex_spacing = 1.0\n \n # Generate a hexagonal snippet\n rows = 5\n cols = 4\n for row in range(rows):\n offset = 0 if row % 2 == 0 else hex_spacing * np.cos(np.pi/6)\n y_pos = row * hex_spacing * np.sin(np.pi/6) * 2 - 3\n for col in range(cols):\n x_pos = col * hex_spacing * 1.5 + offset - 3\n pos = np.array([x_pos, y_pos, 0])\n atom = Dot(radius=ATOM_RADIUS, color=COLOR_CARBON)\n atom.move_to(pos)\n carbon_grid.add(atom)\n\n # Smoothly transform the square lattice to hexagonal\n self.play(\n ReplacementTransform(current_grid, carbon_grid),\n run_time=2.5\n )\n \n carbon_label = Text(\"Carbon Graphene Grid\", font_size=36).to_edge(UP)\n self.play(Write(carbon_label))\n self.wait(1.5)\n self.play(FadeOut(carbon_label))\n\n # ------------------------------------------------------------------\n # 4. Electron Motion\n # ------------------------------------------------------------------\n # Define a complex parametric path around the grid center\n # Combining circular motion with perturbation for a \"quantum\" feel\n electron_path = ParametricFunction(\n lambda t: np.array([\n 2.5 * np.cos(t) + 0.5 * np.cos(3 * t),\n 2.5 * np.sin(t) + 0.5 * np.sin(3 * t),\n 0\n ]),\n t_range=[0, 2 * PI],\n color=COLOR_ELECTRON\n )\n \n # Create the electron dot\n electron = Dot(radius=0.15, color=COLOR_ELECTRON)\n electron.set_glow_factor(2) # Adds a glow effect if supported by renderer\n \n # Add a trail to visualize the path history\n trail = VMob(color=COLOR_ELECTRON, stroke_width=2)\n trail.set_points_as_corners([electron.get_center(), electron.get_center()])\n \n def update_trail(mob):\n mob.add_points_as_corners([electron.get_center()])\n if len(mob.points) > 100: # Limit trail length\n mob.set_points(mob.points[-100:])\n \n trail.add_updater(update_trail)\n self.add(trail)\n \n # Animate electron moving along the path\n self.play(\n MoveAlongPath(electron, electron_path),\n run_time=4,\n rate_func=linear\n )\n \n # Clean up trail updater\n trail.remove_updater(update_trail)\n \n # Final Fade Out\n self.play(\n FadeOut(carbon_grid),\n FadeOut(electron),\n FadeOut(trail),\n run_time=1\n )\n self.wait(1)\n\n# To run this: manim -pql script_name.py ChemistryDynamics\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Develop a Manim animation explaining the concept of orthogonality in linear algebra. Visualize orthogonal vectors, subspaces, and projections, step by step.\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: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0687(Scene):\n def clear_stage(self):\n if self.mobjects:\n return FadeOut(*self.mobjects)\n else:\n return Wait(0)\n\n def construct(self):\n self.act_1_orthogonalvectors()\n self.play(self.clear_stage())\n self.act_2_simpleshapeanimation()\n self.play(self.clear_stage())\n self.act_3_plotgraph()\n\n def act_1_orthogonalvectors(self):\n title = Text(\"Orthogonality\", font_size=40).to_edge(UP)\n dot_a = Dot(RIGHT*2 + UP*1, color=BLUE)\n label_a = MathTex(\"\\\\vec{a}\", color=WHITE).next_to(dot_a, UR)\n \n vector_b_start = RIGHT*2 + DOWN*1\n vector_b_end = RIGHT*1 + DOWN*1\n arrow_b = Arrow(vector_b_start, vector_b_end, buff=0, color=GREEN)\n \n # Step 1: Define Orthogonal Vectors\n line_label = Text(\"Orthogonal Vectors form 90 degree angles\", font_size=24).to_edge(DOWN)\n \n # Animate the creation of vectors\n self.add(title, dot_a, label_a, arrow_b)\n self.wait(1)\n self.play(Write(line_label))\n self.wait(1)\n \n # Rotate the second vector to demonstrate orthogonality\n arrow_b_rotated = Arrow(\n vector_b_start,\n vector_b_start + RIGHT*1.5 + UP*1.5,\n buff=0,\n color=GREEN\n )\n rotation_animation = Transform(arrow_b.copy(), arrow_b_rotated)\n angle_indication = Arc(radius=1, start_angle=PI/4, angle=-PI/4, color=YELLOW)\n \n self.play(rotation_animation)\n self.play(Create(angle_indication))\n self.wait(1)\n \n # Clear intermediate elements to prepare for Subspace explanation\n \n self.play(FadeOut(VGroup(dot_a, label_a, arrow_b, line_label)))\n subspace_text = Text(\"Subspaces contain only orthogonal vectors\", font_size=24).to_edge(DOWN)\n \n # Create two sets of orthogonal vectors representing subspaces\n subspace_set1 = VGroup(\n Dot(RIGHT*3, color=RED),\n Dot(LEFT*3, color=RED)\n ).arrange(RIGHT, buff=1)\n subspace_set2 = VGroup(\n Dot(UP*3, color=RED),\n Dot(DOWN*3, color=RED)\n ).arrange(UP, buff=1)\n \n self.play(Write(subspace_text))\n self.play(Create(subspace_set1))\n self.play(Create(subspace_set2))\n self.wait(1)\n \n # Add projection formula\n projection_formula = MathTex(\n r\"\\text{proj}_{\\mathbf{b}} \\mathbf{a} = \\frac{\\mathbf{a}\\cdot\\mathbf{b}}{\\mathbf{b}\\cdot\\mathbf{b}} \\mathbf{b}\"\n ).scale(0.7).to_edge(UP)\n self.play(Transform(title, projection_formula))\n self.wait(1)\n self.play(FadeOut(VGroup(subspace_set1, subspace_set2, subspace_text)))\n\n def act_2_simpleshapeanimation(self):\n text = Tex(\"Hello, World!\").shift(UP * 2)\n self.play(Write(text))\n\n circle = Circle(color=BLUE)\n self.play(Write(circle))\n\n square = Square(side_length=1, color=RED)\n self.play(Transform(circle, square))\n\n self.play(square.animate.shift(DOWN * 2).rotate(-45 * DEGREES))\n\n def act_3_plotgraph(self):\n func = lambda x: x**2\n\n # --- Stage 1: Display Function ---\n func_tex = MathTex(\"f(x)\", \"=\", \"x^2\").scale(1.5)\n func_tex.to_edge(UP)\n self.play(Write(func_tex))\n self.wait(1)\n\n # --- Stage 2: Plot Graph ---\n axes = Axes(\n x_range=[-3, 3],\n y_range=[0, 6],\n axis_config={\"color\": BLUE}\n ).shift(DOWN * 0.5)\n\n labels = axes.get_axis_labels(Text(\"X\"), Text(\"Y\"))\n graph = axes.plot(func, color=RED, stroke_width=2)\n graph_label = MathTex(\"y=x^2\", color=RED).next_to(graph, UR, buff=0.1)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --- Stage 3: Animation Sequence ---\n points = [np.array([i, func(i), 0]) for i in [-2, -1, 0, 1, 2]]\n dots = VGroup(*[Dot(point, color=YELLOW) for point in points])\n lines = VGroup()\n for i in range(len(points)):\n if i > 0:\n line = Line(points[i-1], points[i], color=GREEN, stroke_opacity=i/len(points))\n lines.add(line)\n \n # Highlight each part sequentially\n for dot in dots:\n self.play(FadeIn(dot, scale=0.5))\n \n for line in lines:\n self.play(Create(line, run_time=0.5, rate_func=rush_into))\n \n self.wait(1)\n```", "rejected": "```python\n# --- Multi-Act Masterpiece: OrthoWalks ---\n# A three-part educational series showcasing linear algebra concepts through visual storytelling.\n\nfrom manim import *\n\nclass OrthoMasterPiece(Scene):\n def clear_stage(self):\n if self.mobs:\n FadeOut(*self.mobs, run_time=0.8)\n \n def construct(self):\n # Execute each act sequentially after clearing any prior content\n self.act_1_ortho_walk()\n self.clear_stage()\n self.act_2_simple_shape_tale()\n self.clear_stage()\n self.act_3_graphic_story()\n\n def act_1_ortho_walk(self):\n title = Text(\"Orthogonal Walks\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Step 2: Vector Visualization \n vector_a = Arrow(start=ORIGIN, end=RIGHT*2 + UP*1, color=BLUE)\n vector_b = Arrow(start=ORIGIN, end=LEFT*-1 + DOWN*-2, color=GREEN)\n \n self.play(Create(vector_a))\n self.play(GrowArrow(vector_b))\n \n label_a = MathText(\"\\\\vec{a}\", font_size=24).next_to(vector_a.get_end(), RIGHT)\n label_b = MathText(\"\\\\vec{b}\", font_size=24).next_to(vector_b.get_end(), LEFT)\n \n self.add(label_a, label_b)\n\n # Step 3: Projection Explanation \n proj_text = Tex(\"$P$ is the projection of $\\\\vec{v}$ onto $\\\\vec{u}$\").scale(0.7).shift(DOWN * 3)\n self.play(Write(proj_text))\n\n # Simple line representing u\n line_u = Line(START_POINT, END_POINT, stroke_color=YELLOW)\n u_label = Text('u', color=YELLOW).move_to(line_u.get_center())\n \n self.play(Create(line_u), Write(u_label))\n \n # Vector v\n vec_v = Arrow(start=ORIGIN, end=RIGHT*3 + UP*1, color=PURPLE)\n v_label = Text('v', color=PURPLE).next_to(vec_v.get_start(), DOWN)\n \n self.play(Create(vec_v), Write(v_label))\n\n # Step 4: Algebraic Equation\n eq = MathTex(\n \"P = \\\\frac{\\\\vec{v} \\\\cdot \\\\hat{u}}{\\\\hat{u} \\\\cdot \\\\hat{u}} \\\\hat{u}\"\n ).scale(0.7).to_edge(DOWN)\n\n self.play(Write(eq))\n\n # Final State\n final_title = Text(\"Orthogonality drives Linear Transformation\", font_size=30).to_edge(UP)\n self.play(Transform(title, final_title))\n\n self.wait(2)\n\n def act_2_simple_shape_tale(self):\n # 1. Initial Scene: Display a text message centered on-screen\n intro_text = Text(\"Welcome to Shape Animation!\", font_size=32).move_to(ORIGINA)\n self.play(Write(intro_text))\n self.wait(1)\n\n # Move the text upward\n self.play(FadeOut(intro_text, shift=UP))\n self.wait(0.5)\n\n # 2. Circle Appearance: Animate the appearance of a blue circle\n circle = Circle(radius=2, color=BLUE)\n self.play(Create(circle))\n self.wait(1)\n\n # Transform the circle into a red square\n square = Square(side_length=4, color=RED)\n self.transform_from_parts(square, circle)\n self.wait(1)\n\n # 3. Movement Sequence: The square should move downward and to the right simultaneously\n target_pos = RIGHT * 3 + DOWN * 3\n self.play(MoveAlongPath(square, Line(ORIGIN, target_pos)), run_time=2, rate_func=smooth)\n\n # 4. Conclusion: End the animation with the remaining elements fading out\n self.wait(1)\n self.fade_out(square)\n\n def act_3_graphic_story(self):\n func_text = MathTex(\"f(x) = x^2\")\n func_text.to_edge(UP)\n self.play(Write(func_text))\n\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-1, 9]\n )\n axes.shift(DOWN * 0.5)\n\n self.play(Create(axes))\n\n graph = axes.plot(lambda x: x**2, x_range=(-3, 3), color=WHITE)\n self.play(Create(graph))\n\n point_at_two = axes.input_to_graph_point(2, graph)\n dot_at_two = Dot(point_at_two, radius=0.1, color=BLUE)\n self.play(Create(dot_at_two))\n\n # Add vertical line\n vertical_line = DashedLine(\n start=axes.c2p(2, 0),\n end=point_at_two,\n color=GREY\n )\n\n self.play(Create(vertical_line))\n\n # Label the area under curve\n area = Polygon(\n axes.c2p(-2, 0),\n axes.c2p(2, 0),\n point_at_two\n )\n area_set = Area(area, color=BLUE, opacity=0.5)\n\n self.play(FadeIn(area_set))\n\n # Add integral notation\n integral_notation = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\")\n integral_notation.next_to(func_text, DOWN, buff=1)\n self.play(Write(integral_notation))\n\n result_text = MathTex(\"Area = 8\")\n result_text.move_to(integral_notation)\n self.play(ReplacementTransform(integral_notation, result_text))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an educational animation that explains the process of evaluating a basic definite integral in calculus. Start by showing the integral of x cubed from 0 to 2. Then, demonstrate step by step how to apply the power rule of integration. After that, show how to evaluate the integral from the lower limit to the upper limit, finishing by calculating the specific values at the bounds. Conclude by simplifying the results to display the final numerical answer. Include textual explanations for each step and ensure that the transition between each part of the solution is clear and easy to follow.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- 1. Introduction: Display the specific problem ---\n title = Text(\"Evaluating 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), Write(problem))\n self.wait(2)\n\n # --- 2. Integration Rule: Demonstrate step-by-step Power Rule ---\n step1_label = Text(\"Step 1: Apply the Power Rule\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step1_label))\n\n # Show the general Power Rule formula\n power_rule_formula = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=YELLOW\n ).shift(UP * 1.5)\n rule_desc = Text(\"Power Rule of Integration\", font_size=24).next_to(power_rule_formula, UP)\n \n self.play(Write(rule_desc), Write(power_rule_formula))\n self.wait(2)\n\n # Apply the rule to the specific problem: x^3 -> (x^(3+1))/(3+1) -> x^4 / 4\n application_step1 = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx = \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", \n font_size=50\n ).move_to(ORIGIN)\n \n application_step2 = MathTex(\n r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=50\n ).next_to(application_step1, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(problem, application_step1))\n self.wait(1)\n self.play(Write(application_step2))\n self.wait(2)\n\n # Clean up the rule display to make room for substitution\n self.play(FadeOut(rule_desc), FadeOut(power_rule_formula))\n\n # --- 3. Evaluation Setup: Show the process of evaluating at bounds ---\n step2_label = Text(\"Step 2: Evaluate at the Bounds\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step2_label))\n\n # Combine the previous two lines into one expression for clarity\n full_expression = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx = \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=50\n ).move_to(UP * 1)\n\n self.play(\n ReplacementTransform(application_step1, full_expression),\n FadeOut(application_step2)\n )\n self.wait(1)\n\n # --- 4. Substitution: Calculate and display specific values ---\n # Show the upper bound minus the lower bound\n substitution = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=50\n ).next_to(full_expression, DOWN, buff=0.8)\n\n self.play(Write(substitution))\n self.wait(2)\n\n # Calculate the values\n calculation = MathTex(\n r\"= \\frac{16}{4} - 0\", \n font_size=50\n ).next_to(substitution, DOWN, buff=0.8)\n\n self.play(Write(calculation))\n self.wait(2)\n\n # --- 5. Conclusion: Simplify results to reveal final answer ---\n step3_label = Text(\"Step 3: Final Simplification\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step3_label))\n\n final_answer = MathTex(\n r\"= 4\", \n font_size=60, \n color=GREEN\n ).next_to(calculation, DOWN, buff=0.8)\n\n # Highlight the final result with a box\n box = SurroundingRectangle(final_answer, color=GREEN, buff=0.2)\n\n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(3)\n\n # Final Outro\n conclusion_text = Text(\"The area under x^3 from 0 to 2 is 4\", font_size=35).to_edge(DOWN)\n self.play(Write(conclusion_text))\n self.wait(4)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- 1. Introduction: Display the specific problem ---\n title = Text(\"Evaluating 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), Write(problem))\n self.wait(2)\n\n # --- 2. Integration Rule: Demonstrate step-by-step Power Rule ---\n step1_label = Text(\"Step 1: Apply the Power Rule\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step1_label))\n\n # Show the general Power Rule formula\n power_rule_formula = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=YELLOW\n ).shift(UP * 1.5)\n rule_desc = Text(\"Power Rule of Integration\", font_size=24).next_to(power_rule_formula, UP)\n \n self.play(Write(rule_desc), Write(power_rule_formula))\n self.wait(2)\n\n # Apply the rule to the specific problem: x^3 -> (x^(3+1))/(3+1) -> x^4 / 4\n application_step1 = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx = \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", \n font_size=50\n ).move_to(ORIGIN)\n \n application_step2 = MathTex(\n r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=50\n ).next_to(application_step1, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(target_position=ORIGIN, problem, application_step1))\n self.wait(1)\n self.play(Write(application_step2))\n self.wait(2)\n\n # Clean up the rule display to make room for substitution\n self.play(FadeOut(rule_desc), FadeOut(power_rule_formula))\n\n # --- 3. Evaluation Setup: Show the process of evaluating at bounds ---\n step2_label = Text(\"Step 2: Evaluate at the Bounds\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step2_label))\n\n # Combine the previous two lines into one expression for clarity\n full_expression = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx = \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=50\n ).move_to(UP * 1)\n\n self.play(\n ReplacementTransform(application_step1, full_expression),\n FadeOut(application_step2)\n )\n self.wait(1)\n\n # --- 4. Substitution: Calculate and display specific values ---\n # Show the upper bound minus the lower bound\n substitution = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=50\n ).next_to(full_expression, DOWN, buff=0.8)\n\n self.play(Write(substitution))\n self.wait(2)\n\n # Calculate the values\n calculation = MathTex(\n r\"= \\frac{16}{4} - 0\", \n font_size=50\n ).next_to(substitution, DOWN, buff=0.8)\n\n self.play(Write(calculation))\n self.wait(2)\n\n # --- 5. Conclusion: Simplify results to reveal final answer ---\n step3_label = Text(\"Step 3: Final Simplification\", font_size=30, color=BLUE).to_edge(UP)\n self.play(Transform(title, step3_label))\n\n final_answer = MathTex(\n r\"= 4\", \n font_size=60, \n color=GREEN\n ).next_to(calculation, DOWN, buff=0.8)\n\n # Highlight the final result with a box\n box = SurroundingRectangle(final_answer, color=GREEN, buff=0.2)\n\n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(3)\n\n # Final Outro\n conclusion_text = Text(\"The area under x^3 from 0 to 2 is 4\", font_size=35).to_edge(DOWN)\n self.play(Write(conclusion_text))\n self.wait(4)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second Manim scene that explains income inequality with a Lorenz curve. Show the line of perfect equality, a bowed Lorenz curve beneath it, and shade the gap between them so the inequality idea is visible without relying on formulas.", "chosen": "```python\nfrom manim import *\n\nclass LorenzCurveInequalityStory(Scene):\n def construct(self):\n title = Text('A Lorenz Curve Shows How Unevenly Income Is Shared', font_size=27).to_edge(UP)\n axes = Axes(x_range=[0, 100, 20], y_range=[0, 100, 20], x_length=6.8, y_length=4.8, tips=False).shift(LEFT * 0.9 + DOWN * 0.1)\n equality = Line(axes.c2p(0, 0), axes.c2p(100, 100), color=GRAY_B, stroke_width=4)\n lorenz = axes.plot(lambda x: 100 * (x / 100) ** 1.9, x_range=[0, 100], color=BLUE_D)\n area = Polygon(axes.c2p(0, 0), axes.c2p(20, 20), axes.c2p(40, 40), axes.c2p(60, 60), axes.c2p(80, 80), axes.c2p(100, 100), axes.c2p(100, 100), axes.c2p(80, 65.6), axes.c2p(60, 37.9), axes.c2p(40, 17.5), axes.c2p(20, 4.7), axes.c2p(0, 0), color=ORANGE, fill_opacity=0.22, stroke_width=0)\n labels = VGroup(Text('perfect equality', font_size=18, color=GRAY_B).next_to(equality, UP, buff=0.12), Text('Lorenz curve', font_size=18, color=BLUE_D).next_to(axes.c2p(68, 47), RIGHT, buff=0.12), Text('inequality gap', font_size=18, color=ORANGE).next_to(axes.c2p(58, 66), RIGHT, buff=0.12))\n caption = Text('The farther the Lorenz curve bends away from the equality line, the more concentrated the income becomes.', 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(equality), FadeIn(labels[0]), run_time=2.0)\n self.play(Create(lorenz), FadeIn(labels[1]), run_time=1.6)\n self.play(FadeIn(area), FadeIn(labels[2]), run_time=1.5)\n self.play(FadeIn(caption_group), Indicate(area, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass LorenzCurveInequalityStory(Scene):\n def construct(self):\n title = Text('A Lorenz Curve Shows How Unevenly Income Is Shared', font_size=27).to_edge(UP)\n axes = Axes(font_size=24, x_range=[0, 100, 20], y_range=[0, 100, 20], x_length=6.8, y_length=4.8, tips=False).shift(LEFT * 0.9 + DOWN * 0.1)\n equality = Line(axes.c2p(0, 0), axes.c2p(100, 100), color=GRAY_B, stroke_width=4)\n lorenz = axes.plot(lambda x: 100 * (x / 100) ** 1.9, x_range=[0, 100], color=BLUE_D)\n area = Polygon(axes.c2p(0, 0), axes.c2p(20, 20), axes.c2p(40, 40), axes.c2p(60, 60), axes.c2p(80, 80), axes.c2p(100, 100), axes.c2p(100, 100), axes.c2p(80, 65.6), axes.c2p(60, 37.9), axes.c2p(40, 17.5), axes.c2p(20, 4.7), axes.c2p(0, 0), color=ORANGE, fill_opacity=0.22, stroke_width=0)\n labels = VGroup(Text('perfect equality', font_size=18, color=GRAY_B).next_to(equality, UP, buff=0.12), Text('Lorenz curve', font_size=18, color=BLUE_D).next_to(axes.c2p(68, 47), RIGHT, buff=0.12), Text('inequality gap', font_size=18, color=ORANGE).next_to(axes.c2p(58, 66), RIGHT, buff=0.12))\n caption = Text('The farther the Lorenz curve bends away from the equality line, the more concentrated the income becomes.', 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(equality), FadeIn(labels[0]), run_time=2.0)\n self.play(Create(lorenz), FadeIn(labels[1]), run_time=1.6)\n self.play(FadeIn(area), FadeIn(labels[2]), run_time=1.5)\n self.play(FadeIn(caption_group), Indicate(area, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 decreases so the viewer connects the improved shape to the training objective.", "chosen": "```python\nfrom manim import *\n\nclass FunctionApproximationStory(Scene):\n def construct(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```", "rejected": "```python\nfrom manim import *\n\nclass FunctionApproximationStory(Scene):\n def construct(self):\n title = Text('Training Improves The Function Approximation', font_size=28).to_edge(UP)\n axes = Axes(font_size=24, 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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that shows how to calculate the area under the curve of the function f(x) = x^2 between the points x=2 and x=3. The animation should start by showing the integral of x^2 from 2 to 3 and then proceed by illustrating the steps of the integration process. After finding the indefinite integral, it should demonstrate how to evaluate it at the boundaries 2 and 3. Once the evaluation is done, I want the animation to display the final numerical answer. To aid understanding, please include textual explanations above the mathematical steps that guide the viewer through setting up the integral, integrating, evaluating the boundaries, and concluding the result. The explanations should appear sequentially in simple language suitable for someone who is learning integration for the first time.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n TEXT_COLOR = WHITE\n MATH_COLOR = YELLOW\n HIGHLIGHT_COLOR = BLUE\n \n # ------------------------------------------------------------------\n # Step 1: Introduction\n # Display the definite integral problem statement\n # ------------------------------------------------------------------\n intro_text = Text(\"1. Set up the definite integral\", font_size=28, color=TEXT_COLOR)\n integral_expr = MathTex(r\"\\int_{2}^{3}\", \"x^2\", \"dx\", font_size=48, color=MATH_COLOR)\n \n # Position text above the math\n intro_text.next_to(integral_expr, UP, buff=0.5)\n intro_group = VGroup(intro_text, integral_expr).move_to(ORIGIN)\n \n self.play(Write(intro_text), Write(integral_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Integration Process\n # Show the indefinite integral (antiderivative)\n # ------------------------------------------------------------------\n step2_text = Text(\"2. Find the antiderivative using the power rule\", font_size=28, color=TEXT_COLOR)\n antiderivative_expr = MathTex(r\"=\", r\"\\left[\", r\"\\frac{x^3}{3}\", r\"\\right]_{2}^{3}\", font_size=48, color=MATH_COLOR)\n \n step2_text.next_to(antiderivative_expr, UP, buff=0.5)\n antiderivative_expr.next_to(integral_expr, DOWN, buff=0.8)\n step2_text.next_to(antiderivative_expr, UP, buff=0.5)\n \n self.play(FadeOut(intro_text), FadeIn(step2_text), Write(antiderivative_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Evaluation\n # Demonstrate evaluating the result at the boundaries (2 and 3)\n # ------------------------------------------------------------------\n step3_text = Text(\"3. Evaluate at the upper and lower limits\", font_size=28, color=TEXT_COLOR)\n evaluation_expr = MathTex(r\"=\", r\"\\left(\", r\"\\frac{3^3}{3}\", r\"\\right)\", r\"-\", r\"\\left(\", r\"\\frac{2^3}{3}\", r\"\\right)\", font_size=48, color=MATH_COLOR)\n \n evaluation_expr.next_to(antiderivative_expr, DOWN, buff=0.8)\n step3_text.next_to(antiderivative_expr, UP, buff=0.5)\n \n self.play(FadeOut(step2_text), FadeIn(step3_text), Write(evaluation_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Conclusion\n # Display the final numerical answer\n # ------------------------------------------------------------------\n step4_text = Text(\"4. Simplify to get the final area\", font_size=28, color=TEXT_COLOR)\n calc_step = MathTex(r\"=\", r\"\\frac{27}{3}\", r\"-\", r\"\\frac{8}{3}\", font_size=48, color=MATH_COLOR)\n final_answer = MathTex(r\"=\", r\"\\frac{19}{3}\", r\"\\approx\", r\"6.33\", font_size=48, color=HIGHLIGHT_COLOR)\n \n calc_step.next_to(evaluation_expr, DOWN, buff=0.8)\n final_answer.next_to(calc_step, DOWN, buff=0.5)\n \n self.play(FadeOut(step3_text), FadeIn(step4_text), Write(calc_step))\n self.wait(1)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- Final Visual Polish ---\n all_math = VGroup(integral_expr, antiderivative_expr, evaluation_expr, calc_step, final_answer)\n self.play(\n all_math.animate.shift(DOWN * 0.5),\n FadeOut(step4_text)\n )\n \n conclusion_box = SurroundingRectangle(final_answer, color=HIGHLIGHT_COLOR)\n self.play(Create(conclusion_box))\n self.wait(3)\n\n# To run this animation:\n# manim -pql scene_file_name.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n TEXT_COLOR = WHITE\n MATH_COLOR = YELLOW\n HIGHLIGHT_COLOR = BLUE\n \n # ------------------------------------------------------------------\n # Step 1: Introduction\n # Display the definite integral problem statement\n # ------------------------------------------------------------------\n intro_text = Text(\"1. Set up the definite integral\", font_size=28, color=TEXT_COLOR)\n integral_expr = MathTex(r\"\\int_{2}^{3}\" + \" = x\", \"x^2\", \"dx\", font_size=48, color=MATH_COLOR)\n \n # Position text above the math\n intro_text.next_to(integral_expr, UP, buff=0.5)\n intro_group = VGroup(intro_text, integral_expr).move_to(ORIGIN)\n \n self.play(Write(intro_text), Write(integral_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Integration Process\n # Show the indefinite integral (antiderivative)\n # ------------------------------------------------------------------\n step2_text = Text(\"2. Find the antiderivative using the power rule\", font_size=28, color=TEXT_COLOR)\n antiderivative_expr = MathTex(r\"=\", r\"\\left[\", r\"\\frac{x^3}{3}\", r\"\\right]_{2}^{3}\", font_size=48, color=MATH_COLOR)\n \n step2_text.next_to(antiderivative_expr, UP, buff=0.5)\n antiderivative_expr.next_to(integral_expr, DOWN, buff=0.8)\n step2_text.next_to(antiderivative_expr, UP, buff=0.5)\n \n self.play(FadeOut(intro_text), FadeIn(step2_text), Write(antiderivative_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Evaluation\n # Demonstrate evaluating the result at the boundaries (2 and 3)\n # ------------------------------------------------------------------\n step3_text = Text(\"3. Evaluate at the upper and lower limits\", font_size=28, color=TEXT_COLOR)\n evaluation_expr = MathTex(r\"=\", r\"\\left(\", r\"\\frac{3^3}{3}\", r\"\\right)\", r\"-\", r\"\\left(\", r\"\\frac{2^3}{3}\", r\"\\right)\", font_size=48, color=MATH_COLOR)\n \n evaluation_expr.next_to(antiderivative_expr, DOWN, buff=0.8)\n step3_text.next_to(antiderivative_expr, UP, buff=0.5)\n \n self.play(FadeOut(step2_text), FadeIn(step3_text), Write(evaluation_expr))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Conclusion\n # Display the final numerical answer\n # ------------------------------------------------------------------\n step4_text = Text(\"4. Simplify to get the final area\", font_size=28, color=TEXT_COLOR)\n calc_step = MathTex(r\"=\", r\"\\frac{27}{3}\", r\"-\", r\"\\frac{8}{3}\", font_size=48, color=MATH_COLOR)\n final_answer = MathTex(r\"=\", r\"\\frac{19}{3}\", r\"\\approx\", r\"6.33\", font_size=48, color=HIGHLIGHT_COLOR)\n \n calc_step.next_to(evaluation_expr, DOWN, buff=0.8)\n final_answer.next_to(calc_step, DOWN, buff=0.5)\n \n self.play(FadeOut(step3_text), FadeIn(step4_text), Write(calc_step))\n self.wait(1)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- Final Visual Polish ---\n all_math = VGroup(integral_expr, antiderivative_expr, evaluation_expr, calc_step, final_answer)\n self.play(\n all_math.animate.shift(DOWN * 0.5),\n FadeOut(step4_text)\n )\n \n conclusion_box = SurroundingRectangle(final_answer, color=HIGHLIGHT_COLOR)\n self.play(Create(conclusion_box))\n self.wait(3)\n\n# To run this animation:\n# manim -pql scene_file_name.py AreaUnderCurve\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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#### Web Authentication\n##### HTTP Authentication\nBasic Auth (Base64 encoding, insecure) and Digest Auth (digest authentication).\n\n##### Cookie Authentication\nTraditional Session-Cookie mechanism. The server stores the session, and the client's Cookie carries the Session ID.\n\n##### Token Authentication\nThe client stores the Token (e.g., in LocalStorage) and includes it in the request header for each request. Stateless, suitable for Apps.\n\n##### JWT Authentication\nJSON Web Token. A self-contained Token format that includes user claims and a signature, allowing the server to verify it without checking a database.\n\n\nThe context location of this section (from highest to current level):\n# Authentication Protocols\n## Main Content\n### Applications of Authentication Protocols\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass WebAuthentication(Scene):\n\n def construct(self):\n title = Text('Web Authentication Methods', 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\n def create_auth_block(title_str, line1_str, line2_str, color):\n header = Text(title_str, font_size=26, color=color, weight=BOLD)\n l1 = Text(line1_str, font_size=20, color=WHITE)\n l2 = Text(line2_str, font_size=20, color=WHITE)\n desc = VGroup(l1, l2).arrange(DOWN, buff=0.15)\n group = VGroup(header, desc).arrange(DOWN, buff=0.3)\n box = SurroundingRectangle(group, color=color, buff=0.4)\n return VGroup(box, group)\n block1 = create_auth_block('HTTP Authentication', 'Basic Base64 encoding', 'Digest authentication', BLUE)\n block2 = create_auth_block('Cookie Authentication', 'Traditional Session-Cookie', 'Server stores Session ID', GREEN)\n block3 = create_auth_block('Token Authentication', 'Stateless mechanism', 'Token in request header', YELLOW)\n block4 = create_auth_block('JWT Authentication', 'JSON Web Token', 'Self-contained and signed', PURPLE)\n row1 = VGroup(block1, block2).arrange(RIGHT, buff=1.0)\n row2 = VGroup(block3, block4).arrange(RIGHT, buff=1.0)\n all_blocks = VGroup(row1, row2).arrange(DOWN, buff=0.8)\n all_blocks.next_to(title_group, DOWN, buff=0.8)\n self.play(FadeIn(block1, shift=RIGHT * 0.5), run_time=1.2)\n self.play(FadeIn(block2, shift=LEFT * 0.5), run_time=1.2)\n self.play(FadeIn(block3, shift=RIGHT * 0.5), run_time=1.2)\n self.play(FadeIn(block4, shift=LEFT * 0.5), run_time=1.2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass WebAuthentication(Scene):\n\n def construct(self):\n title = Text('Web Authentication Methods', 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\n def create_auth_block(title_str, line1_str, line2_str, color):\n header = Text(title_str, font_size=26, color=color, weight=BOLD)\n l1 = Text(line1_str, font_size=20, color=WHITE)\n l2 = Text(line2_str, font_size=20, color=WHITE)\n desc = VGroup(l1, l2).arrange(DOWN, buff=0.15)\n group = VGroup(header, desc).arrange(DOWN, buff=0.3)\n box = SurroundingRectangle(group, color=color, buff=0.4)\n return VGroup(box, group)\n block1 = create_auth_block('HTTP Authentication', 'Basic Base64 encoding', 'Digest authentication', BBLUE)\n block2 = create_auth_block('Cookie Authentication', 'Traditional Session-Cookie', 'Server stores Session ID', GREEN)\n block3 = create_auth_block('Token Authentication', 'Stateless mechanism', 'Token in request header', YELLOW)\n block4 = create_auth_block('JWT Authentication', 'JSON Web Token', 'Self-contained and signed', PURPLE)\n row1 = VGroup(block1, block2).arrange(RIGHT, buff=1.0)\n row2 = VGroup(block3, block4).arrange(RIGHT, buff=1.0)\n all_blocks = VGroup(row1, row2).arrange(DOWN, buff=0.8)\n all_blocks.next_to(title_group, DOWN, buff=0.8)\n self.play(FadeIn(block1, shift=RIGHT * 0.5), run_time=1.2)\n self.play(FadeIn(block2, shift=LEFT * 0.5), run_time=1.2)\n self.play(FadeIn(block3, shift=RIGHT * 0.5), run_time=1.2)\n self.play(FadeIn(block4, shift=LEFT * 0.5), run_time=1.2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 before fading out. Also, I want the molecule to be shown with a double bond between the atoms.", "chosen": "```python\nfrom manim import *\n\nclass OxygenBondAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n atom_color = RED\n bond_color = WHITE\n \n # Create the oxygen atoms\n atom_left = Circle(radius=0.7, color=atom_color)\n atom_right = Circle(radius=0.7, color=atom_color)\n \n # Position them initially side-by-side for rotation effect\n atom_group = VGroup(atom_left, atom_right).arrange(RIGHT, buff=1)\n\n # Add bonds between corresponding parts of each circle\n bond1 = Line(\n start=atom_left.get_center() + UP * 0.3,\n end=atom_right.get_center() + DOWN * 0.6,\n stroke_width=6,\n stroke_color=bond_color\n )\n \n bond2 = Line(\n start=atom_left.get_center() + DOWN * 0.3,\n end=atom_right.get_center() + UP * 0.6,\n stroke_width=6,\n stroke_color=bond_color\n )\n\n # Group everything for atomic structure\n molecule = VGroup(bond1, bond2, atom_group)\n\n # --- Animation Sequence ---\n\n # Step 1: Fade In\n self.play(FadeIn(molecule))\n self.wait(0.5)\n\n # Step 2: Rotation\n self.play(\n Rotate(molecule, angle=TAU),\n run_time=3,\n rate_func=linear\n )\n self.wait(0.5)\n\n # Step 3: Scaling Up\n self.play(\n molecule.animate.scale(2),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(1)\n\n # Step 4: Fade Out\n self.play(FadeOut(molecule))\n\n# To render this animation, save it as 'oxygen_bond.py' and run:\n# manim -pql oxygen_bond.py OxygenBondAnimation\n```", "rejected": "```python\nfrom manim import *\n\nclass OxygenMoleculeFormation(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Colors for visual clarity\n atom_color = RED\n bond_color = WHITE\n \n # Initial sizes and positions\n initial_scale = 0.7\n final_scale = 2.0\n\n # Create the atomic structures\n # Simple circles represent the atoms\n atom_left = Circle(radius=0.8, color=atom_color).shift(LEFT*2)\n atom_right = Circle(radius=0.8, color=atom_color).shift(RIGHT*2)\n\n # Define the middle line of the bond\n bond_path = Line(start=-2.6, end=2.6)\n bond_path.set_stroke(color=bond_color, width=2)\n \n # Add bonds on both sides of the central path to simulate a double bond\n bond_left_up = DashedLine(\n start=Point(-2.6, 0.5),\n end=Point(-1.0, 0.5),\n stroke_width=2,\n dash_length=0.1\n )\n bond_left_down = DashedLine(\n start=Point(-2.6, -0.5),\n end=Point(-1.0, -0.5),\n stroke_width=2,\n dash_length=0.1\n )\n\n # Group everything so we can animate the entire unit at once\n molecule_group = VGroup(atom_left, atom_right, bond_path, bond_left_up, bond_left_down)\n\n # --- Step 1: Fade In ---\n self.play(FadeIn(molecule_group))\n self.wait(1)\n\n # --- Step 2: Rotation ---\n # Rotate the whole group around its center point\n self.play(Rotate(molecule_group, angle=PI, about_point=molecule_group.get_center()), run_time=1.5)\n self.wait(1)\n\n # --- Step 3: Scaling Up ---\n self.play(\n atom_left.animate.scale(final_scale / initial_scale).set_fill(opacity=0),\n atom_right.animate.scale(final_scale / initial_scale).set_fill(opacity=0),\n RunTime(1)\n )\n \n self.play(\n atom_left.animate.move_to(ORIGIN + LEFT * 2).scale(initial_scale),\n atom_right.animate.move_to(ORIGIN + RIGHT * 2).scale(initial_scale),\n RunTime(1)\n )\n \n self.wait(1)\n self.play(\n atom_left.animate.scale(2),\n atom_right.animate.scale(2),\n bond_path.animate.scale(2),\n bond_left_up.animate.scale(2),\n bond_left_down.animate.scale(2),\n run_time=1\n )\n self.wait(1)\n\n # --- Final Step: Fade Out ---\n # Animate the mobject disappearing from the screen\n self.play(FadeOut(molecule_group))\n\n# To render this animation, save it as 'oxygen_molecule.py' and run:\n# manim -pql oxygen_molecule.py OxygenMoleculeFormation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 oxides and a separate set of carbon grids at the top of the screen. There should also be a lithium ion and an electron positioned together with the lithium ion below the carbon grids. I want the lithium ion to move smoothly across the screen from left to right and then down, tracing a specific path, while an electron follows it along a similar but slightly different path that mimics the main movements of the lithium ion but is offset a bit downward. The electron's path should have it move there and back with a noticeable pause in the middle of its journey to signify it’s interacting with the metal oxides. Can we have the entire movement of both the lithium ion and the electron synchronized and animated in such a way that it's visually pleasing, with a slight delay between their movements?", "chosen": "```python\nfrom manim import *\n\nclass AreaBetweenCurves(Scene):\n def construct(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```", "rejected": "```python\nfrom manim import *\n\nclass AreaBetweenCurves(Scene):\n def construct(self):\n axes = Axes(label_font_size=24, \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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## 3. Deriving Equilibrium Income and the Government Spending Multiplier\n\n### 1. Solving for Equilibrium Income \\(Y\\) (Board Work)\n\nFrom:\n\\[\nY = C_0 + cY + I + G\n\\]\n\nRearrange:\n\\[\nY - cY = C_0 + I + G\n\\]\n\n\\[\n(1 - c)Y = C_0 + I + G\n\\]\n\nThus:\n\\[\nY = \\frac{1}{1 - c}(C_0 + I + G)\n\\]\n\n\nContextual location of this section: None\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass EquilibriumIncomeDerivation(Scene):\n\n def construct(self):\n title = Text('3. Deriving Equilibrium Income and the Government Spending Multiplier', font_size=28, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Tex('1. Solving for Equilibrium Income $Y$ (Board Work)', font_size=26, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.4)\n eq1 = MathTex('Y', '=', 'C_0 + cY + I + G')\n eq2 = MathTex('Y - cY', '=', 'C_0 + I + G')\n eq3 = MathTex('(1 - c)Y', '=', 'C_0 + I + G')\n eq4 = MathTex('Y', '=', '\\\\frac{1}{1 - c}(C_0 + I + G)')\n eqs = VGroup(eq1, eq2, eq3, eq4)\n eqs.arrange(DOWN, buff=0.8)\n for eq in eqs[1:]:\n eq.shift((eq1[1].get_center()[0] - eq[1].get_center()[0]) * RIGHT)\n else:\n pass\n eqs.next_to(subtitle, DOWN, buff=0.8)\n eqs.shift(-eq1[1].get_center()[0] * RIGHT)\n label1 = Text('From:', font_size=22, color=YELLOW)\n label2 = Text('Rearrange:', font_size=22, color=YELLOW)\n label4 = Text('Thus:', font_size=22, color=YELLOW)\n label1.next_to(eq1, LEFT, buff=1.0)\n label2.next_to(eq2, LEFT, buff=1.0)\n label4.next_to(eq4, LEFT, buff=1.0)\n left_x = min(label1.get_left()[0], label2.get_left()[0], label4.get_left()[0])\n label1.shift((left_x - label1.get_left()[0]) * RIGHT)\n label2.shift((left_x - label2.get_left()[0]) * RIGHT)\n label4.shift((left_x - label4.get_left()[0]) * RIGHT)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(0.5)\n self.play(FadeIn(label1, shift=RIGHT), Write(eq1))\n self.wait(1)\n self.play(FadeIn(label2, shift=RIGHT), Write(eq2))\n self.wait(1)\n self.play(Write(eq3))\n self.wait(1)\n self.play(FadeIn(label4, shift=RIGHT), Write(eq4))\n self.wait(1)\n box = SurroundingRectangle(eq4, color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass EquilibriumIncomeDerivation(Scene):\n\n def construct(self):\n title = Text('3. Deriving Equilibrium Income and the Government Spending Multiplier', font_size=28, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Tex('1. Solving for Equilibrium Income $Y$ (Board Work)', font_size=26, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.4)\n eq1 = MathTex('Y', '=', 'C_0 + cY + I + G')\n eq2 = MathTex('Y - cY', '=', 'C_0 + I + G')\n eq3 = MathTex('(1 - c)Y', '=', 'C_0 + I + G')\n eq4 = MathTex('Y', '=', '\\\\frac{1}{1 - c}(C_0 + I + G)')\n eqs = VGroup(eq1, eq2, eq3, eq4)\n eqs.arrange(DOWN, buff=0.8)\n for eq in eqs[1:]:\n eq.shift((eq1[1].get_center()[0] - eq[1].get_center()[0]) * RIGHT)\n else:\n pass\n eqs.next_to(subtitle, DOWN, buff=0.8)\n eqs.shift(-eq1[1].get_center()[0] * RIGHT)\n label1 = Text('From:', font_size=22, color=YELLOW)\n label2 = Text('Rearrange:', font_size=22, color=YELLOW)\n label4 = Text('Thus:', font_size=22, color=YELLOW)\n label1.next_to(eq1, LEFT, buff=1.0)\n label2.next_to(eq2, LEFT, buff=1.0)\n label4.next_to(eq4, LEFT, buff=1.0)\n left_x = min(label1.get_left()[0], label2.get_left()[0], label4.get_left()[0])\n label1.shift((left_x - label1.get_left()[0]) * RIGHT)\n label2.shift((left_x - label2.get_left()[0]) * RIGHT)\n label4.shift((left_x - label4.get_left()[0]) * RIGHT)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(0.5)\n self.play(FadeIn(label1, shift=RIGHT), Write(eq1))\n self.wait(1)\n self.play(FadeIn(label2, shift=RIGHT), Write(eq2))\n self.wait(1)\n self.play(Write(eq3))\n self.wait(1)\n self.play(FadeIn(label4, shift=RIGHT), Write(eq4))\n self.wait(1)\n box = SurroundingRectangle(eq4, color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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\n- Act 2: 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\n- Act 3: Could you create an educational animation that explains the concept of a harmonic oscillator using simple visuals? Start by showing the basic differential equation that governs the motion, then display the characteristic", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0151(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_quadraticderivative()\n self.clear_stage()\n self.act_3_harmonicoscillatorexplan()\n\n def act_1_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\n def act_2_quadraticderivative(self):\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=True\n )\n \n # Plot the function f(x) = x^2 as a green curve\n func = lambda x: x**2\n graph = axes.plot(func, color=GREEN)\n \n # Animate creation of axes and function\n self.play(Create(axes))\n self.play(Create(graph), run_time=2)\n self.wait(2)\n \n # Step 2: Annotations\n # Draw a yellow dashed vertical line at x=1 from x-axis to the graph\n start_point = axes.c2p(1, 0)\n end_point = axes.input_to_graph_point(1, graph)\n vertical_line = DashedLine(\n start=start_point,\n end=end_point,\n color=YELLOW\n )\n \n # Place a green label displaying the equation 'x^2' close to the graph\n label = MathTex(\"x^2\", color=GREEN)\n label.next_to(graph, UR, buff=0.5)\n \n # Animate creation of line and label\n self.play(Create(vertical_line))\n self.play(Write(label))\n self.wait(2)\n \n # Step 3: Derivative Visualization\n # Plot the derivative f'(x) = 2x as a purple curve\n deriv_func = lambda x: 2 * x\n deriv_graph = axes.plot(deriv_func, color=PURPLE)\n \n # Animate creation of the derivative curve\n self.play(Create(deriv_graph), run_time=2)\n self.wait(2)\n\n def act_3_harmonicoscillatorexplan(self):\n diff_eq = MathTex(r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\", font_size=60)\n self.play(Write(diff_eq))\n self.wait(2)\n\n # --- Step 2: Characteristic Equation ---\n char_eq = MathTex(r\"r^2 + \\omega^2 = 0\", font_size=60)\n self.play(ReplacementTransform(diff_eq, char_eq))\n self.wait(2)\n\n # --- Step 3: Solving for Roots ---\n roots = MathTex(r\"r = \\pm i\\omega\", font_size=60)\n self.play(ReplacementTransform(char_eq, roots))\n self.wait(2)\n\n # --- Step 4: General Solution ---\n general_sol = MathTex(r\"x(t) = C_1 \\cos(\\omega t) + C_2 \\sin(\\omega t)\", font_size=60)\n self.play(ReplacementTransform(roots, general_sol))\n self.wait(2)\n\n # --- Emphasis Finale ---\n # Clear the screen for a clean final highlight\n self.play(FadeOut(general_sol))\n self.wait(1)\n\n # Re-display the general solution with emphasis styling\n final_sol = MathTex(r\"x(t) = C_1 \\cos(\\omega t) + C_2 \\sin(\\omega t)\", font_size=70, color=YELLOW)\n \n self.play(Write(final_sol))\n self.play(final_sol.animate.scale(1.2))\n \n # Add a surrounding rectangle to emphasize the final result\n box = SurroundingRectangle(final_sol, color=BLUE, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0151(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_quadraticderivative()\n self.clear_stage()\n self.act_3_harmonicoscillatorexplan()\n\n def act_1_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\n def act_2_quadraticderivative(self):\n axes = Axes(label_font_size=24, \n x_range=[-3, 3, 1],\n y_range=[-5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=True\n )\n \n # Plot the function f(x) = x^2 as a green curve\n func = lambda x: x**2\n graph = axes.plot(func, color=GREEN)\n \n # Animate creation of axes and function\n self.play(Create(axes))\n self.play(Create(graph), run_time=2)\n self.wait(2)\n \n # Step 2: Annotations\n # Draw a yellow dashed vertical line at x=1 from x-axis to the graph\n start_point = axes.c2p(1, 0)\n end_point = axes.input_to_graph_point(1, graph)\n vertical_line = DashedLine(\n start=start_point,\n end=end_point,\n color=YELLOW\n )\n \n # Place a green label displaying the equation 'x^2' close to the graph\n label = MathTex(\"x^2\", color=GREEN)\n label.next_to(graph, UR, buff=0.5)\n \n # Animate creation of line and label\n self.play(Create(vertical_line))\n self.play(Write(label))\n self.wait(2)\n \n # Step 3: Derivative Visualization\n # Plot the derivative f'(x) = 2x as a purple curve\n deriv_func = lambda x: 2 * x\n deriv_graph = axes.plot(deriv_func, color=PURPLE)\n \n # Animate creation of the derivative curve\n self.play(Create(deriv_graph), run_time=2)\n self.wait(2)\n\n def act_3_harmonicoscillatorexplan(self):\n diff_eq = MathTex(r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\", font_size=60)\n self.play(Write(diff_eq))\n self.wait(2)\n\n # --- Step 2: Characteristic Equation ---\n char_eq = MathTex(r\"r^2 + \\omega^2 = 0\", font_size=60)\n self.play(ReplacementTransform(diff_eq, char_eq))\n self.wait(2)\n\n # --- Step 3: Solving for Roots ---\n roots = MathTex(r\"r = \\pm i\\omega\", font_size=60)\n self.play(ReplacementTransform(char_eq, roots))\n self.wait(2)\n\n # --- Step 4: General Solution ---\n general_sol = MathTex(r\"x(t) = C_1 \\cos(\\omega t) + C_2 \\sin(\\omega t)\", font_size=60)\n self.play(ReplacementTransform(roots, general_sol))\n self.wait(2)\n\n # --- Emphasis Finale ---\n # Clear the screen for a clean final highlight\n self.play(FadeOut(general_sol))\n self.wait(1)\n\n # Re-display the general solution with emphasis styling\n final_sol = MathTex(r\"x(t) = C_1 \\cos(\\omega t) + C_2 \\sin(\\omega t)\", font_size=70, color=YELLOW)\n \n self.play(Write(final_sol))\n self.play(final_sol.animate.scale(1.2))\n \n # Add a surrounding rectangle to emphasize the final result\n box = SurroundingRectangle(final_sol, color=BLUE, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here is the enhanced animation instruction that maintains all original features while adding significant new elements:\n\nThe enhanced animation begins by creating a feedforward neural network with three layers (4-input, 6-hidden with ReLU activation, and 3-output with Softmax), just like the original. As the network appears on screen, mathematical formulas for each activation function (ReLU and Softmax) materialize beside their respective layers, with the equations fading in synchronously with the layer creation. During the forward pass animation, we add a dynamic information panel at the bottom of the screen that displays real-time numerical values as the activation signals propagate through each layer, showing how inputs transform into outputs. The animation concludes with the network's final output probabilities visually represented as a color-coded bar chart that emerges from the output layer, with each bar growing proportionally to its probability value while the corresponding class label appears beneath it. Throughout the entire sequence, smooth transition effects connect each stage, and subtle glow effects highlight active neurons during the forward pass to better visualize information flow. This enhanced version maintains the original's educational value while providing deeper insight into the network's internal workings through multiple complementary visualizations.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedNeuralNetwork(Scene):\n def construct(self):\n # Colors\n NEURON_COLOR = BLUE\n CONNECTION_COLOR = GREY\n INPUT_COLOR = GREEN\n HIDDEN_COLOR = BLUE\n OUTPUT_COLOR = RED\n ACTIVATION_COLOR = YELLOW\n \n # Create network layers\n input_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(4)]).arrange(DOWN, buff=0.5)\n hidden_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(6)]).arrange(DOWN, buff=0.5)\n output_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(3)]).arrange(DOWN, buff=0.5)\n \n # Position layers\n hidden_layer.next_to(input_layer, RIGHT, buff=1.5)\n output_layer.next_to(hidden_layer, RIGHT, buff=1.5)\n \n # Add layer labels\n input_label = Text(\"Input Layer\").next_to(input_layer, UP)\n hidden_label = Text(\"Hidden Layer\").next_to(hidden_layer, UP)\n output_label = Text(\"Output Layer\").next_to(output_layer, UP)\n \n # Create connections\n connections = VGroup()\n for i in range(4):\n for j in range(6):\n connection = Line(\n input_layer[i].get_right(),\n hidden_layer[j].get_left(),\n color=CONNECTION_COLOR,\n stroke_width=1.5\n )\n connections.add(connection)\n \n for i in range(6):\n for j in range(3):\n connection = Line(\n hidden_layer[i].get_right(),\n output_layer[j].get_left(),\n color=CONNECTION_COLOR,\n stroke_width=1.5\n )\n connections.add(connection)\n \n # Create activation formulas\n relu_formula = MathTex(r\"ReLU(x) = \\max(0, x)\").next_to(hidden_layer, DOWN)\n softmax_formula = MathTex(r\"Softmax(x_i) = \\frac{e^{x_i}}{\\sum_j e^{x_j}}\").next_to(output_layer, DOWN)\n \n # Create information panel\n info_panel = Rectangle(width=12, height=2, color=WHITE, fill_opacity=0.2)\n info_panel.to_edge(DOWN)\n info_title = Text(\"Forward Pass Values\", font_size=24).next_to(info_panel.get_top(), DOWN, buff=0.1)\n \n # Create output visualization\n output_probs = [0.2, 0.5, 0.3] # Example probabilities\n bar_chart = VGroup()\n labels = [\"Class A\", \"Class B\", \"Class C\"]\n for i, prob in enumerate(output_probs):\n bar = Rectangle(\n width=0.8,\n height=prob * 3,\n color=OUTPUT_COLOR,\n fill_opacity=0.7\n )\n bar.next_to(output_layer[i], RIGHT, buff=0.5)\n label = Text(labels[i], font_size=20).next_to(bar, DOWN, buff=0.1)\n bar_chart.add(bar, label)\n \n # Animation sequence\n self.play(Write(input_label), Write(hidden_label), Write(output_label))\n self.play(LaggedStart(\n *[Create(neuron) for neuron in input_layer],\n *[Create(neuron) for neuron in hidden_layer],\n *[Create(neuron) for neuron in output_layer],\n lag_ratio=0.1\n ))\n self.wait(0.5)\n self.play(Create(connections), run_time=2)\n self.wait()\n \n # Show activation formulas\n self.play(Write(relu_formula), Write(softmax_formula))\n self.wait()\n \n # Create info panel\n self.play(Create(info_panel), Write(info_title))\n \n # Forward pass animation\n input_values = [0.8, 0.5, 0.3, 0.9] # Example inputs\n for i, value in enumerate(input_values):\n input_layer[i].set_fill(INPUT_COLOR)\n input_text = Text(f\"x{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(UP*0.3 + LEFT*(3 - i))\n self.play(\n input_layer[i].animate.set_fill(INPUT_COLOR, opacity=1),\n Write(input_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Hidden layer activation\n hidden_values = np.random.rand(6) # Random values for demo\n for i, value in enumerate(hidden_values):\n hidden_layer[i].set_fill(HIDDEN_COLOR)\n hidden_text = Text(f\"h{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(DOWN*0.3 + LEFT*(5 - i))\n self.play(\n hidden_layer[i].animate.set_fill(HIDDEN_COLOR, opacity=1),\n Write(hidden_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Output layer activation\n output_values = output_probs # Using our example probabilities\n for i, value in enumerate(output_values):\n output_layer[i].set_fill(OUTPUT_COLOR)\n output_text = Text(f\"o{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(DOWN*0.3 + RIGHT*(3 - i))\n self.play(\n output_layer[i].animate.set_fill(OUTPUT_COLOR, opacity=1),\n Write(output_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Show output visualization\n self.play(LaggedStart(\n *[GrowFromEdge(bar, DOWN) for bar in bar_chart[::2]],\n *[FadeIn(label) for label in bar_chart[1::2]],\n lag_ratio=0.2\n ))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedNeuralNetwork(Scene):\n def construct(self):\n # Colors\n NEURON_COLOR = BBLUE\n CONNECTION_COLOR = GREY\n INPUT_COLOR = GREEN\n HIDDEN_COLOR = BLUE\n OUTPUT_COLOR = RED\n ACTIVATION_COLOR = YELLOW\n \n # Create network layers\n input_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(4)]).arrange(DOWN, buff=0.5)\n hidden_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(6)]).arrange(DOWN, buff=0.5)\n output_layer = VGroup(*[Circle(radius=0.3, color=NEURON_COLOR, fill_opacity=0.8) \n for _ in range(3)]).arrange(DOWN, buff=0.5)\n \n # Position layers\n hidden_layer.next_to(input_layer, RIGHT, buff=1.5)\n output_layer.next_to(hidden_layer, RIGHT, buff=1.5)\n \n # Add layer labels\n input_label = Text(\"Input Layer\").next_to(input_layer, UP)\n hidden_label = Text(\"Hidden Layer\").next_to(hidden_layer, UP)\n output_label = Text(\"Output Layer\").next_to(output_layer, UP)\n \n # Create connections\n connections = VGroup()\n for i in range(4):\n for j in range(6):\n connection = Line(\n input_layer[i].get_right(),\n hidden_layer[j].get_left(),\n color=CONNECTION_COLOR,\n stroke_width=1.5\n )\n connections.add(connection)\n \n for i in range(6):\n for j in range(3):\n connection = Line(\n hidden_layer[i].get_right(),\n output_layer[j].get_left(),\n color=CONNECTION_COLOR,\n stroke_width=1.5\n )\n connections.add(connection)\n \n # Create activation formulas\n relu_formula = MathTex(r\"ReLU(x) = \\max(0, x)\").next_to(hidden_layer, DOWN)\n softmax_formula = MathTex(r\"Softmax(x_i) = \\frac{e^{x_i}}{\\sum_j e^{x_j}}\").next_to(output_layer, DOWN)\n \n # Create information panel\n info_panel = Rectangle(width=12, height=2, color=WHITE, fill_opacity=0.2)\n info_panel.to_edge(DOWN)\n info_title = Text(\"Forward Pass Values\", font_size=24).next_to(info_panel.get_top(), DOWN, buff=0.1)\n \n # Create output visualization\n output_probs = [0.2, 0.5, 0.3] # Example probabilities\n bar_chart = VGroup()\n labels = [\"Class A\", \"Class B\", \"Class C\"]\n for i, prob in enumerate(output_probs):\n bar = Rectangle(\n width=0.8,\n height=prob * 3,\n color=OUTPUT_COLOR,\n fill_opacity=0.7\n )\n bar.next_to(output_layer[i], RIGHT, buff=0.5)\n label = Text(labels[i], font_size=20).next_to(bar, DOWN, buff=0.1)\n bar_chart.add(bar, label)\n \n # Animation sequence\n self.play(Write(input_label), Write(hidden_label), Write(output_label))\n self.play(LaggedStart(\n *[Create(neuron) for neuron in input_layer],\n *[Create(neuron) for neuron in hidden_layer],\n *[Create(neuron) for neuron in output_layer],\n lag_ratio=0.1\n ))\n self.wait(0.5)\n self.play(Create(connections), run_time=2)\n self.wait()\n \n # Show activation formulas\n self.play(Write(relu_formula), Write(softmax_formula))\n self.wait()\n \n # Create info panel\n self.play(Create(info_panel), Write(info_title))\n \n # Forward pass animation\n input_values = [0.8, 0.5, 0.3, 0.9] # Example inputs\n for i, value in enumerate(input_values):\n input_layer[i].set_fill(INPUT_COLOR)\n input_text = Text(f\"x{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(UP*0.3 + LEFT*(3 - i))\n self.play(\n input_layer[i].animate.set_fill(INPUT_COLOR, opacity=1),\n Write(input_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Hidden layer activation\n hidden_values = np.random.rand(6) # Random values for demo\n for i, value in enumerate(hidden_values):\n hidden_layer[i].set_fill(HIDDEN_COLOR)\n hidden_text = Text(f\"h{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(DOWN*0.3 + LEFT*(5 - i))\n self.play(\n hidden_layer[i].animate.set_fill(HIDDEN_COLOR, opacity=1),\n Write(hidden_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Output layer activation\n output_values = output_probs # Using our example probabilities\n for i, value in enumerate(output_values):\n output_layer[i].set_fill(OUTPUT_COLOR)\n output_text = Text(f\"o{i+1}: {value:.2f}\", font_size=20).move_to(info_panel).shift(DOWN*0.3 + RIGHT*(3 - i))\n self.play(\n output_layer[i].animate.set_fill(OUTPUT_COLOR, opacity=1),\n Write(output_text),\n run_time=0.5\n )\n self.wait(0.3)\n \n # Show output visualization\n self.play(LaggedStart(\n *[GrowFromEdge(bar, DOWN) for bar in bar_chart[::2]],\n *[FadeIn(label) for label in bar_chart[1::2]],\n lag_ratio=0.2\n ))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Write Manim code for a scene illustrating the concept of cross products in vector calculus. Visualize the geometric interpretation and properties of cross products, step by step.", "chosen": "```python\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # --- Configuration ---\n VECTOR_LENGTH = 2.5\n \n # Color scheme for vectors A, B, C\n COLOR_A = BLUE\n COLOR_B = GREEN\n COLOR_C = YELLOW\n\n # Title text\n title = Text(\"The Power of Cross Products\", font_size=36)\n \n # Vector labels\n label_a = MathTex(\"\\\\mathbf{a}\").next_to(Vector([VECTOR_LENGTH, 0, 0]), UR, buff=0.1).set_color(COLOR_A)\n label_b = MathTex(\"\\\\mathbf{b}\").next_to(Vector([-VECTOR_LENGTH, VECTOR_LENGTH, 0]), UL, buff=0.1).set_color(COLOR_B)\n\n # Calculate the resulting vector direction using right-hand rule\n result_vector = np.cross([VECTOR_LENGTH, 0, 0], [-VECTOR_LENGTH, VECTOR_LENGTH, 0])\n magnitude = np.linalg.norm(result_vector)\n scale_factor = max(1.0, min(magnitude / 2, 2)) \n scaled_result_vec = [scale_factor * component for component in result_vector]\n label_c = MathTex(\"\\\\mathbf{c} = \\\\mathbf{a}\\\\times\\\\mathbf{b}\").move_to(RIGHT*3 + UP*0.8).set_color(COLOR_C)\n\n # Properties of cross product displayed on screen\n prop_cross_product = MathTex(\n \"\\\\text{Given } \\\\mathbf{u}, \\\\mathbf{v} \\\\in \\\\mathbb{R}^3:\\\\quad \",\n \"\\\\mathbf{u}\", r\"\\times \", r\"\\\\mathbf{v}\",\n \"= |\\\\mathbf{u}| |\\\\mathbf{v}| \\\\sin\\\\theta \\\\hat{n}\"\n ).to_edge(DOWN, buff=1.0).shift(LEFT*0.5).set_color_by_tex(\"\\\\mathbf{u}\", COLOR_A).set_color_by_tex(\"\\\\mathbf{v}\", COLOR_B)\n\n prop_anticommutativity = MathTex(\n \"\\\\mathbf{u}\", r\"\\times \", r\"\\\\mathbf{v}\", \"=-(\", r\"\\\\mathbf{v}\", r\"\\times \", r\"\\\\mathbf{u}\", \")\"\n ).next_to(prop_cross_product, DOWN, aligned_edge=LEFT, buff=0.7).set_color_by_tex(\"\\\\mathbf{u}\", COLOR_A).set_color_by_tex(\"\\\\mathbf{v}\", COLOR_B).set_color_by_tex(\"\\\\hat{n}\", COLOR_C)\n \n prop_scalar_triple = MathTex(\n \"|\\\\mathbf{a}\", r\"\\cdot \", \"(\\\\mathbf{b}\", r\"\\times \", r\"\\\\mathbf{c})\", \"= |\\\\mathbf{v}_1| |\\\\mathbf{v}_2| |\\\\mathbf{v}_3|\"\n ).next_to(prop_anticommutativity, DOWN, aligned_edge=LEFT, buff=0.7).set_color_by_tex(\"\\\\mathbf{a}\", COLOR_A).set_color_by_tex(\"\\\\mathbf{b}\", COLOR_B).set_color_by_tex(\"\\\\mathbf{c}\", COLOR_C)\n\n\n # Animation Sequence -------------------------------------------------------------------\n\n self.play(Write(title))\n self.play(Write(label_a))\n self.play(Create(Vector([VECTOR_LENGTH, 0, 0]).set_color(COLOR_A)))\n self.wait(1)\n\n self.play(Write(label_b))\n self.play(Create(Vector([-VECTOR_LENGTH, VECTOR_LENGTH, 0]).set_color(COLOR_B)))\n self.wait(1)\n\n # Show the formula for the cross product\n self.play(Write(prop_cross_product))\n\n # Animate anticommutativity property appearing\n self.play(Write(prop_anticommutativity))\n self.wait(1)\n\n # Display the scalar triple product\n self.play(Write(prop_scalar_triple))\n self.wait(2)\n\n # Perform visual transformation from vectors A and B to resulting vector C\n arrow_start = ORIGIN\n arrow_end = RIGHT * 2.5 \n \n start_point = Arrow(start=arrow_start, end=[-1, 1, 0], color=WHITE)\n end_point = Arrow(start=start_point.get_end(), end=arrow_end, color=WHITE)\n \n self.play(FadeIn(end_point, shift=RIGHT))\n self.wait(1)\n\n # Draw the resulting triangle representing the area spanned by vectors A and B\n triangle_vertices = [\n [VECTOR_LENGTH, 0, 0],\n [-VECTOR_LENGTH, VECTOR_LENGTH, 0],\n ORIGIN,\n ]\n triangle = Polygon(*triangle_vertices, color=GRAY, fill_opacity=0.1)\n self.add(triangle)\n\n # Reveal the resulting vector C\n self.play(Write(label_c))\n self.play(Create(Arrow(start=ORIGIN, end=scaled_result_vec, color=COLOR_C)))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"The Geometric Power of Cross Products\", font_size=36).to_edge(UP)\n intro_text = Tex(\n \"Cross product combines vectors into a new one,\\nperpendicular to both original vectors.\"\n ).next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(FadeIn(intro_text))\n self.wait(2)\n\n # Clear screen to prepare for visualizations\n self.clear()\n self.add(title)\n\n # Create two perpendicular vectors\n vec_a = Arrow(start=LEFT*2, end=RIGHT*2, color=RED)\n vec_b = Arrow(start=DOWN*2, end=UP*2, color=BLUE)\n \n labels_a = MathTex(\"\\\\mathbf{a}\", color=WHITE).move_to(vec_a.get_end())\n labels_b = MathTex(\"\\\\mathbf{b}\", color=WHITE).move_to(vec_b.get_start())\n\n # Show vectors and their components\n self.play(Create(vec_a), Write(labels_a))\n self.play(Create(vec_b), Write(labels_b))\n\n # Animate cross product formula\n cross_formula = MathTex(\n \"\\\\mathbf{c} = \\\\mathbf{a} \\\\times \\\\mathbf{b}\",\n r\"\\\\ \\text{where } c = ab\\sin(\\theta)\",\n tex_to_color_map={\"\\\\mathbf{a}\": RED, \"\\\\mathbf{b}\": BLUE}\n ).scale(0.8).shift(DOWN * 2.5 + RIGHT * 2)\n\n self.play(Write(cross_formula[0]))\n self.wait(1)\n self.play(Write(cross_formula[1]))\n\n # Define the resulting cross product vector perpendicularly\n result_vec = Arrow(start=ORIGIN, end=UP*1.5 + LEFT*1.5, color=YELLOW)\n label_c = MathTex(\"\\\\mathbf{c}\", color=WHITE).move_to(result_vec.get_end())\n\n # Highlight that it's perpendicular using a blue circle\n plane = NumberPlane(x_range=(-3, 3), y_range=(-3, 3)).set_opacity(0.1)\n perp_circle = Circle(radius=0.7, color=GREEN).shift(UP*1.5 + LEFT*1.5)\n\n # Animation sequence showing construction of perpendicular component\n self.wait(1)\n self.play(Create(perp_circle))\n self.play(TransformFromCopy(vec_a.copy(), result_vec), TransformFromCopy(vec_b.copy(), perp_angle=result_vec.copy().rotate(-PI/2)))\n self.play(Write(label_c))\n\n # Explain direction via right-hand rule\n rh_rule = Tex(\"Right-hand Rule:\\\\ Up if $\\\\theta$ is acute, Down if obtuse\").to_edge(DOWN)\n self.play(Write(rh_rule))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Mastering cross products opens up powerful tools\\nfor physics, engineering, and math.\", font_size=24).to_edge(DOWN)\n \n # Fade out everything except vectors and formulas, then show final text\n self.play(\n FadeOut(perp_circle),\n FadeOut(plane),\n FadeOut(rh_rule),\n FadeOut(vec_a),\n FadeOut(vec_b),\n FadeOut(labels_a),\n FadeOut(labels_b),\n FadeOut(label_c),\n )\n self.play(Write(conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 below it. Then, below the formula, can there be an arrow pointing downward to the expanded form of Euler's Formula, \"cos(x) = (e^(ix) + e^(-ix))/2\"? Afterward, I'd like all the elements on the screen to fade out and be replaced by the title \"Euler's Formula Transformation\" at the top of the screen in yellow. Finish up the animation by replacing the title with \"Euler's Identity\" and write out Euler’s famous identity \"e^(iπ) + 1 = 0\" below the title. Make sure each part of the animation is clear and give a brief pause between transitions so viewers can follow along.", "chosen": "```python\nfrom manim import *\n\nclass EulersFormulaScene(Scene):\n def construct(self):\n # --- 1. Opening Sequence ---\n # Create the phrase and the initial formula\n opening_text = Text(\"Euler's Formula:\")\n opening_formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\")\n \n # Group them and arrange vertically\n opening_group = VGroup(opening_text, opening_formula).arrange(DOWN, buff=0.5)\n \n # Animate the opening sequence\n self.play(Write(opening_text))\n self.wait(0.5)\n self.play(Write(opening_formula))\n self.wait(1.5)\n\n # --- 2. Transformation Step ---\n # Create an arrow pointing downward from the initial formula\n arrow = Arrow(\n start=opening_formula.get_bottom(), \n end=opening_formula.get_bottom() + DOWN * 1.5, \n buff=0.1\n )\n \n # Create the expanded form\n expanded_formula = MathTex(r\"\\cos(x) = \\frac{e^{ix} + e^{-ix}}{2}\")\n expanded_formula.next_to(arrow, DOWN, buff=0.2)\n \n # Animate the arrow and the new formula\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(expanded_formula))\n self.wait(2)\n\n # --- 3. Scene Transition ---\n # Fade out all current elements\n all_elements = VGroup(opening_text, opening_formula, arrow, expanded_formula)\n self.play(FadeOut(all_elements))\n self.wait(1)\n \n # Display the new title in yellow at the top\n transformation_title = Text(\"Euler's Formula Transformation\", color=YELLOW)\n transformation_title.to_edge(UP)\n \n self.play(Write(transformation_title))\n self.wait(2)\n\n # --- 4. Final Sequence ---\n # Create the new title to replace the yellow title\n identity_title = Text(\"Euler's Identity\")\n identity_title.to_edge(UP)\n \n # Animate the replacement of the title\n self.play(ReplacementTransform(transformation_title, identity_title))\n self.wait(0.5)\n \n # Write Euler's famous identity below the new title\n identity_formula = MathTex(r\"e^{i\\pi} + 1 = 0\")\n identity_formula.next_to(identity_title, DOWN, buff=1)\n \n self.play(Write(identity_formula))\n self.wait(3)\n \n # Final fade out for a clean finish\n self.play(FadeOut(identity_title), FadeOut(identity_formula))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersFormulaScene(Scene):\n def construct(self):\n # --- 1. Opening Sequence ---\n # Create the phrase and the initial formula\n opening_text = Text(\"Euler's Formula:\")\n opening_formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\")\n \n # Group them and arrange vertically\n opening_group = VGroup(opening_text, opening_formula).arrange(DOWN, buff=0.5)\n \n # Animate the opening sequence\n self.play(Write(opening_text))\n self.wait(0.5)\n self.play(Write(opening_formula))\n self.wait(1.5)\n\n # --- 2. Transformation Step ---\n # Create an arrow pointing downward from the initial formula\n arrow = Arrow(\n start=opening_formula.get_bottom(), \n end=opening_formula.get_bottom() + DOWN * 1.5, \n buff=0.1\n )\n \n # Create the expanded form\n expanded_formula = MathTex(r\"\\cos(x) = \\frac{e^{ix} + e^{-ix}}{2}\")\n expanded_formula.next_to(arrow, DOWN, buff=0.2)\n \n # Animate the arrow and the new formula\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(expanded_formula))\n self.wait(2)\n\n # --- 3. Scene Transition ---\n # Fade out all current elements\n all_elements = VGroup(opening_text, opening_formula, arrow, expanded_formula)\n self.play(FadeOut(all_elements))\n self.wait(1)\n \n # Display the new title in yellow at the top\n transformation_title = Text(\"Euler's Formula Transformation\", color=YELLOW)\n transformation_title.to_edge(UP)\n \n self.play(Write(transformation_title))\n self.wait(2)\n\n # --- 4. Final Sequence ---\n # Create the new title to replace the yellow title\n identity_title = Text(\"Euler's Identity\")\n identity_title.to_edge(UP)\n \n # Animate the replacement of the title\n self.play(ReplacementTransform(transformation_title, identity_title))\n self.wait(0.5)\n \n # Write Euler's famous identity below the new title\n identity_formula = MathTex(r\"e^{i\\pi} + 1 = 0\" + \" = x\")\n identity_formula.next_to(identity_title, DOWN, buff=1)\n \n self.play(Write(identity_formula))\n self.wait(3)\n \n # Final fade out for a clean finish\n self.play(FadeOut(identity_title), FadeOut(identity_formula))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Familiarize yourself with the general steps of a complete program development to lay the foundation for subsequent chapters.\n\n* Program development is not just about writing code; it encompasses the entire lifecycle from requirement analysis to maintenance.\n\n## The Essence of Program Design\n\n### Program design refers to the process of designing, writing, debugging, and maintaining computer programs based on given requirements.\n* It is an engineering activity that emphasizes the ability to solve practical problems within limited resources.\n\n\nThe context of this section (from highest to current level):\n# Introduction: Overview of the Basics of Program Design\n## Learning Objectives of This Section\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ProgrammingDevelopment(Scene):\n def construct(self):\n title = Text(\"Program Development: General Steps\", font_size=36)\n subtitle = Text(\n \"Requirement Analysis -> Implementation -> Testing -> Maintenance\",\n font_size=28,\n color=BLUE\n )\n \n # Create a visual flow chart using rounded rectangles\n step_labels = [\"Analysis\", \"Design\", \"Code\", \"Test\", \"Maintain\"]\n boxes = VGroup()\n arrows = VGroup()\n\n for i in range(5):\n box = RoundedRectangle(corner_radius=0.3, width=2.7, height=1.5, stroke_width=2)\n label_text = Text(step_labels[i], font_size=18).move_to(box.get_center())\n \n if i == 0:\n box.move_to(LEFT * 3 + UP * 0.5)\n labels_group = VGroup(label_text, box)\n self.play(FadeIn(labels_group))\n \n else:\n prev_box = boxes[-1]\n arrow = Arrow(prev_box.get_right(), box.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.1)\n arrows.add(arrow)\n box.shift(RIGHT * 3)\n \n labels_group = VGroup(label_text, box, arrow)\n self.play(FadeIn(labels_group))\n\n boxes.add(box)\n\n self.wait(1)\n summary_title = Title(\"Summary\")\n summary_list = BulletedList(\n \"Comprehensive life cycle covering requirements through maintenance.\",\n \"Emphasizes problem-solving capabilities under resource constraints.\"\n ).scale(0.8).to_edge(DOWN)\n\n self.play(Write(summary_title))\n self.play(Write(summary_list))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ProgrammingProcess(Scene):\n\n def construct(self):\n title = Text('Program Development Process', font_size=36)\n title.to_edge(UP, buff=0.5).set_color(YELLOW)\n \n items = ['Requirement Analysis',\n 'Design',\n 'Coding',\n 'Testing/QA',\n 'Deployment/Maintenance']\n colors = [RED, ORANGE, GREEN, BLUE, PURPLE]\n \n boxes = VGroup()\n arrows = VGroup()\n \n start_point = LEFT * 5 + UP * 0.5\n \n for i, item in enumerate(items):\n box = RoundedRectangle(corner_radius=0.2,\n width=2.8,\n height=0.75,\n color=colors[i],\n fill_opacity=i < len(colors) else 0.2)\n \n text = Tex(item, font_size=18).move_to(box.get_center())\n \n if i == 0:\n box.move_to(start_point)\n elif i > 0:\n prev_box = boxes[-1]\n \n arrow = Arrow(prev_box.get_right(), box.get_left(),\n stroke_width=3, max_tip_length_to_length_ratio=0.15)\n \n arrows.add(arrow)\n \n offset_y = (-i % 2) * 1.1\n \n box.next_to(arrows[-1], RIGHT, buff=0.5).shift(RIGHT * 0.1 + DOWN * offset_y)\n\n boxes.add(VGroup(box, text))\n \n self.play(FadeIn(title), FadeIn(boxes[0]), run_time=2)\n \n for i in range(len(boxes) - 1):\n self.play(GrowArrow(arrows[i]),\n FadeIn(boxes[i + 1][0], shift=RIGHT),\n Write(boxes[i + 1][1]),\n run_time=1.5, \n rate_func=smooth)\n \n self.wait(2)\n self.play(FadeOut(VGroup(title, *boxes, *arrows)))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Generate a Manim animation to explain the concept of surface integrals in vector calculus. Visualize the flux of a vector field through a surface, and include a title saying \"Surface Integrals.\"", "chosen": "```python\nfrom manim import *\n\nclass SurfaceIntegralExplanation(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Simple representation of a surface (plane)\n plane = Rectangle(width=6, height=3).rotate(-PI/4)\n plane_stencil = RoundedRectangle(corner_radius=0.1, width=7, height=4).shift(RIGHT*0.8 + DOWN*0.8)\n \n self.play(Create(plane))\n self.wait(1)\n\n # Vector Field Elements\n vectors = VGroup()\n for _ in range(10):\n x = np.random.uniform(-3, 3)\n y = np.random.uniform(-1.5, 1.5)\n vec_start = ORIGIN + RIGHT*x + UP*y\n vec_end = vec_start + UP*0.5\n vector = Arrow(vec_start, vec_end, buff=0)\n vectors.add(vector)\n \n vectors_group = VGroup(vectors).set_opacity(0.5)\n\n # Show vectors on the plane\n self.play(FadeIn(vectors_group, lag_ratio=0.05))\n\n # Explain flux\n flux_text = MathTex(\n r\"\\text{Flux } \\Phi = \\iint_S (\\vec{n} \\cdot \\vec{F})\\, dS\"\n ).to_edge(DOWN, buff=0.5).scale(0.6)\n flux_explanation = Text(\"Measure of how much the vector field pushes through the surface.\", font_size=24).next_to(flux_text, DOWN)\n\n self.play(Write(flux_text))\n self.wait(1)\n self.play(Write(flux_explanation))\n self.wait(2)\n\n # Highlight area where vectors push into the plane (negative normal component)\n highlight_area = Rectangle(height=1.5, width=6, color=YELLOW).move_to(ORIGIN) \n negative_flux_text = Text(\"Negative Flux Area\", font_size=20).next_to(highlight_area, LEFT)\n\n self.play(Create(negative_flux_text))\n self.play(FadeIn(highlight_area, scale=0.5))\n \n # Show integral symbol moving along the surface\n int_symbol = Tex(\"$\\\\iint$\").scale(0.8)\n path = VMobject().set_points_as_corners([ORIGIN, RIGHT*3, RIGHT*3 + UP*1.5])\n move_int = MoveAlongPath(int_symbol.copy(), path)\n \n self.play(Write(path))\n self.play(move_int)\n self.wait(2)\n \n # Final conclusion\n final_title = Text(\"Fundamentally, it measures the flow of vectors across a surface.\", font_size=24)\n final_box = SurroundingRectangle(final_title, buff=0.2, color=GREEN)\n self.play(Write(final_title))\n self.play(Create(final_box))\n self.wait(3)\n```", "rejected": "```python\n# Import necessary classes from ManimCommunityEdition\nfrom manim import *\n\nclass SurfaceIntegralsScene(Scene):\n def construct(self):\n # Display the title at the beginning\n title = Text(\"Surface Integrals\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n\n # Create a simple plane representing a surface\n plane = Plane()\n \n # Add grid lines for better visualization\n plane.add_coordinates(x_range=(-2, 2, 1), y_range=(-2, 2, 1))\n\n # Animate the creation of the plane\n self.play(Create(plane))\n self.wait(1)\n\n # Define a vector field represented by arrows on the plane\n vectors = VGroup(\n Arrow(start=plane.n2p([0, 0]), end=plane.n2p([0.5, 0.5])),\n Arrow(start=plane.n2p([-1, -1]), end=plane.n2p([0, 0]))\n )\n vectors.scale_to_fit_width(plane.width * 0.7)\n\n # Show the vectors on the plane\n self.play(Create(vectors))\n self.wait(1)\n\n # Explain the concept of flux\n flux_text = Tex(\"$\\\\text{Flux} = \\\\iint_S \\\\mathbf{n} \\\\cdot \\\\mathbf{F}$\")\n flux_text.to_edge(DOWN, buff=1.5)\n\n # Animate the explanation text appearing below the visual elements\n self.play(Write(flux_text))\n self.wait(2)\n\n # Clear the screen to demonstrate transformation\n self.play(FadeOut(VGroup(plane, vectors, flux_text)))\n\n # Transform the equation using ReplacementTransform to show substitution\n transformed_flux = MathTex(\"\\\\text{Flux} = \\\\frac{1}{2} \\\\times 1 \\\\times |\\\\mathbf{F}|\")\n transformed_flux.to_edge(DOWN, buff=1.5)\n\n # Perform the replacement transformation smoothly\n self.play(ReplacementTransform(flux_text, transformed_flux))\n self.wait(1)\n\n # Fade out everything to conclude the scene\n self.play(FadeOut(transformed_flux))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # 1. Title\n title = Text(\"Exponential Function Graph\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n\n # 2. Axes Configuration\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n )\n self.play(Create(axes))\n\n # 3. First Function Plot (e^x)\n graph_exp = axes.plot(lambda x: np.exp(x), color=GREEN)\n label_exp = MathTex(\"e^x\", color=GREEN)\n label_exp.move_to(axes.input_to_graph_point(2, graph_exp)).shift(RIGHT * 0.5 + UP * 0.2)\n\n self.play(Create(graph_exp), FadeIn(label_exp))\n self.wait(1)\n\n # 4. Transition to Second Function (2^x)\n graph_2 = axes.plot(lambda x: 2**x, color=RED)\n label_2 = MathTex(\"2^x\", color=RED)\n # Position label higher than the previous label to ensure upward movement animation\n label_2.move_to(axes.input_to_graph_point(2, graph_2)).shift(RIGHT * 0.5 + UP * 1.0)\n\n # Replace e^x graph with 2^x graph and animate label moving upward\n self.play(\n ReplacementTransform(graph_exp, graph_2),\n ReplacementTransform(label_exp, label_2),\n run_time=2\n )\n self.wait(1)\n\n # 5. Comparison View\n # Bring the initial e^x graph back onto the screen\n graph_exp_final = axes.plot(lambda x: np.exp(x), color=GREEN)\n label_exp_final = MathTex(\"e^x\", color=GREEN)\n label_exp_final.move_to(axes.input_to_graph_point(2, graph_exp_final)).shift(RIGHT * 0.5 + UP * 0.2)\n\n self.play(\n Create(graph_exp_final),\n FadeIn(label_exp_final),\n run_time=2\n )\n\n # 6. Conclusion\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # 1. Title\n title = Text(\"Exponential Function Graph\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n\n # 2. Axes Configuration\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n )\n self.play(Create(axes))\n\n # 3. First Function Plot (e^x)\n graph_exp = axes.plot(lambda x: np.exp(x), color=GREEN)\n label_exp = MathTex(\"e^x\", color=GREEN)\n label_exp.move_to(axes.input_to_graph_point(2, graph_exp)).shift(RIGHT * 0.5 + UP * 0.2)\n\n self.play(Create(graph_exp), FadeIn(label_exp))\n self.wait(1)\n\n # 4. Transition to Second Function (2^x)\n graph_2 = axes.plot(lambda x: 2**x, color=RED)\n label_2 = MathTex(\"2^x\", color=RED)\n # Position label higher than the previous label to ensure upward movement animation\n label_2.move_to(axes.input_to_graph_point(2, graph_2)).shift(RIGHT * 0.5 + UP * 1.0)\n\n # Replace e^x graph with 2^x graph and animate label moving upward\n self.play(\n ReplacementTransform(target_position=ORIGIN, graph_exp, graph_2),\n ReplacementTransform(label_exp, label_2),\n run_time=2\n )\n self.wait(1)\n\n # 5. Comparison View\n # Bring the initial e^x graph back onto the screen\n graph_exp_final = axes.plot(lambda x: np.exp(x), color=GREEN)\n label_exp_final = MathTex(\"e^x\", color=GREEN)\n label_exp_final.move_to(axes.input_to_graph_point(2, graph_exp_final)).shift(RIGHT * 0.5 + UP * 0.2)\n\n self.play(\n Create(graph_exp_final),\n FadeIn(label_exp_final),\n run_time=2\n )\n\n # 6. Conclusion\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a multi-act ManimCE scene (`AttentionGridScene`) showing 4 token `RoundedRectangle` boxes, `Arrow` Q/K/V projections, and a 4x4 attention `VGroup(*rows)` heatmap.", "chosen": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n self.show_tokens()\n self.show_projections()\n self.show_attention()\n\n def show_tokens(self):\n # Create four tokens as rounded rectangles arranged in a 2x2 grid\n tokens = VGroup(\n RoundedRectangle(width=1, height=1.5),\n RoundedRectangle(width=1, height=1.5).shift(RIGHT * 1.5 + UP * 1.5),\n RoundedRectangle(width=1, height=1.5).shift(LEFT * 1.5 + DOWN * 1.5),\n RoundedRectangle(width=1, height=1.5).shift(DOWN * 1.5)\n )\n \n for i, rect in enumerate(tokens):\n if i % 2 == 0:\n rect.set_color(GREEN)\n else:\n rect.set_color(YELLOW)\n\n labels = [\"Q\", \"K\", \"V\"] # First three will be labeled\n\n # Add text labels only to the first three tokens (excluding last one)\n for j in range(len(labels)):\n label_text = Text(labels[j], font_size=36).move_to(tokens[j])\n \n # Animate the creation of each rectangle followed by its corresponding text\n self.play(Create(tokens[j]))\n self.play(FadeIn(label_text))\n self.wait(0.3) # Pause briefly after displaying each element\n \n self.wait(1)\n\n def show_projections(self):\n # Define colors for arrows representing different paths (blue, green, yellow)\n arrow_colors = [BLUE, GREEN, YELLOW]\n \n # Position vectors defining the layout of projections from the center\n positions = [\n ORIGIN + RIGHT * 1.8 + UP * 0.7,\n ORIGIN + LEFT * 1.8 + UP * 0.7,\n ORIGIN + RIGHT * 1.8 + DOWN * 0.7\n ]\n \n # Create projection arrows from the center to specified end points\n arrows = []\n for pos, color in zip(positions, arrow_colors):\n arrow = Arrow(start=ORIGIN, end=pos, buff=0.1)\n arrow.set_color(color)\n arrow.scale(1.2)\n arrows.append(arrow)\n \n # Group all arrows and animate them appearing sequentially\n all_arrows = VGroup(*arrows)\n self.play(LaggedStart(*[Create(arrow) for arrow in all_arrows], lag_ratio=0.3))\n\n # Display labels indicating what is being projected where\n labels = [\"Query\", \"Key\", \"Value\"]\n label_positions = [\n ORIGIN + RIGHT * 1.8 + UP * 1.3,\n ORIGIN + LEFT * 1.8 + UP * 1.3,\n ORIGIN + RIGHT * 1.8 + DOWN * 1.3\n ]\n\n label_objs = []\n for i in range(len(arrows)):\n tex_label = MathTex(\"\\\\rightarrow \", labels[i]).next_to(arrows[i].get_end(), DOWN, buff=0.2)\n tex_label.to_edge(UP, buff=0.2).scale(0.8)\n label_objs.append(tex_label)\n\n for tex_label in label_objs:\n self.play(Write(tex_label))\n self.wait(0.5)\n \n self.wait(1)\n\n def show_attention(self):\n # Clear screen to make room for the large 4x4 matrix\n self.clear()\n \n # Generate random values between 0 and 1 to simulate attention scores\n data = [[np.random.rand() for _ in range(4)] for _ in range(4)]\n max_val = max(max(row) for row in data)\n\n # Configure axes limits based on the maximum value found\n x_min, y_min = 0, 0\n x_max = len(data) - 0.1\n y_max = len(data[0]) - 0.1\n \n # Initialize Axes object\n axes = Axes(\n x_range=[x_min, x_max],\n y_range=[y_min, y_max],\n x_length=7.5,\n y_length=5.5\n ).center()\n\n axis_labels = axes.get_axis_labels(x_label=\"Tokens\", y_label=\"Tokens\")\n\n # Create cells using Rectangles that scale their color intensity based on the score\n cells = VGroup()\n for i in range(len(data)):\n for j in range(len(data[0])):\n cell_rect = Rectangle(\n width=(data[i][j]/max_val)*1.5,\n height=1.5,\n stroke_width=0.5,\n fill_opacity=data[i][j]/max_val,\n stroke_opacity=0.1\n )\n \n # Adjust position so it aligns perfectly within the coordinate system\n offset_x = (-x_max / 2) + ((i+0.5)/len(data))*(x_max-x_min)-cell_rect.width/2\n offset_y = ((y_max-y_min)/2) - ((j+0.5)/len(data[0]))*(y_max-y_min)+cell_rect.height/2\n \n cell_rect.move_to([offset_x, offset_y, 0])\n\n # Highlight selected indices with a white border\n highlight_radius = 0.3\n highlight_circle = Circle(radius=highlight_radius, color=WHITE, stroke_width=2)\n highlight_circle.move_to(cell_rect.get_center())\n \n # Only add highlights for specific elements\n target_indices = [(0, 0), (0, 1), (1, 0), (2, 3)]\n if (i, j) in target_indices:\n cells.add(highlight_circle)\n\n cells.add(cell_rect)\n\n # Render the entire grid\n self.add(axes, axis_labels)\n self.add(cells)\n\n # Add titles above the grid\n title_query = Tex(\"Queries\").to_edge(UP, buff=1)\n title_key = Tex(\"Keys\").to_edge(UP, buff=1)\n \n self.add(title_query, title_key)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n # --- Configuration ---\n NUM_TOKENS = 4\n TOKEN_SIZE = 1.0\n ATTENTION_COLOR = BLUE_D\n \n # Create Tokens\n tokens = VGroup()\n for i in range(NUM_TOKENS):\n box = RoundedRectangle(\n width=TOKEN_SIZE, \n height=TOKEN_SIZE, \n corner_radius=0.15,\n fill_color=GRAY_B, \n fill_opacity=0.7\n )\n label = Text(str(i), font_size=26).move_to(box.get_center())\n token_group = VGroup(box, label)\n tokens.add(token_group)\n\n # Position Tokens in a grid pattern\n row_spacing = TOKEN_SIZE + 0.8\n col_spacing = TOKEN_SIZE + 0.8\n start_pos = LEFT * 3.2 + DOWN * 1.5\n\n for i, token in enumerate(tokens):\n x = (i % 2) * col_spacing - TOKEN_SIZE - 0.2\n y = -(i // 2) * row_spacing + TOKEN_SIZE + 0.2\n pos = start_pos + np.array([x, y, 0])\n token.move_to(pos)\n\n self.play(Create(tokens))\n \n # Add Arrow Projections\n arrows = []\n labels = [\"Q\", \"K\", \"V\"]\n \n for index, token_label in enumerate(labels):\n arrow_start = tokens[index].get_bottom() + UP * 0.2\n \n arrow_end = tokens[(index + 1) % 4].get_top() + DOWN * 0.1\n arrow = Arrow(arrow_start, arrow_end, buff=0.1, color=YELLOW)\n \n text = MathTex(token_label).next_to(arrow, RIGHT, buff=-0.1)\n group = VGroup(arrow, text)\n arrows.append(group)\n \n self.play(GrowArrow(arrow), Write(text))\n\n self.wait(1)\n \n # Create Heatmap Grid\n heatmap_grid = VGroup()\n \n for r in range(NUM_TOKENS): # Rows\n row = VGroup()\n for c in range(NUM_TOKENS): # Columns\n cell_rect = Rectangle(\n width=TOKEN_SIZE, \n height=TOKEN_SIZE, \n stroke_width=1,\n stroke_color=WHITE,\n fill_opacity=0.1\n )\n \n if r == c:\n # Diagonal cells highlight active connections\n cell_rect.fill_color = YELLOW\n cell_rect.fill_opacity = 0.3\n \n else:\n # Off-diagonal cells show attention weights\n weight = np.random.uniform(0.1, 0.8) \n opacity = max(weight, 0.1) # Ensure at least some visibility\n cell_rect.fill_color = ATTENTION_COLOR\n cell_rect.fill_opacity = opacity\n \n cell_text = Text(str(round(opacity, 1)), font_size=20).move_to(cell_rect.get_center())\n cell_group = VGroup(cell_rect, cell_text)\n row.add(cell_group)\n heatmap_grid.add(row)\n \n # Arrange rows vertically, centered below the tokens\n heatmap_grid.arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n heat_start_y = tokens[-1].get_bottom()[1]\n target_y = heat_start_y -TOKEN_SIZE*NUM_TOKENS-0.5\n \n for row in heatmap_grid:\n row.shift(RIGHT * 4.2 + DOWN * (heat_start_y - row.get_center()[1]))\n \n # Animate creation of each column sequentially\n for col_idx in range(NUM_TOKENS):\n current_col = VGroup()\n for r in range(NUM_TOKENS):\n current_row = heatmap_grid[r]\n cell = current_row[col_idx]\n current_col.add(cell)\n \n # Highlight current position while building up the column\n if r < col_idx:\n current_col[0:r+1].set_fill(opacity=max(current_col[0:r+1][r].get_fill_opacity(), 0.1))\n \n self.play(FadeIn(current_col, shift=RIGHT * 0.3), run_time=0.8)\n \n # Update global state after animation completes\n for r in range(NUM_TOKENS):\n current_row = heatmap_grid[r]\n old_cell = current_row[col_idx]\n new_cell = old_cell.copy().shift(UP*(col_idx-r)*TOKEN_SIZE/NUM_TOKENS)\n current_row[col_idx] = new_cell\n\n self.wait(2)\n \n # Final Reveal: Move everything to center\n final_tokens = tokens.copy().arrange(RIGHT, buff=1.2).scale(1.0).to_edge(UP)\n final_heatmap = heatmap_grid.copy().arrange(RIGHT, buff=0.5).scale(0.9).to_edge(DOWN)\n final_arrows = VGroup(*arrows).arrange(RIGHT, buff=1.5).scale(0.8).to_edge(UP)\n \n \n self.play(\n FadeOut(final_arrows),\n FadeIn(final_tokens, scale=1.0),\n FadeIn(final_heatmap, scale=1.0),\n run_time=1.5\n )\n\n self.wait(3)\n \n self.clear()\n self.wait()\n\n# To render this scene, save it as 'attention_scene.py' and run:\n# manim -pql attention_scene.py AttentionGridScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 a simple animation where a triangle rotates a full 180 degrees and then disappears from the scene, and also include a piece of text that moves upwards and transforms into a different text saying \"animate\n- Act 2: Create a 12-second mechanical-engineering scene comparing torque from the same force applied near and far from a pivot. Keep both levers visible, use equal-length force arrows, mark each lever arm, and show that the fart\n- Act 3: Here’s an enhanced version of the animation that retains the original features while adding new elements for clarity and visual appeal: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0661(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_triangletextanimation()\n self.clear_stage()\n self.act_2_torqueleverarm()\n self.clear_stage()\n self.act_3_enhancedoctagonrotation()\n\n def act_1_triangletextanimation(self):\n triangle = Triangle(color=BLUE)\n self.play(Create(triangle))\n \n # Animate a rotation of exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI))\n \n # Animate the triangle disappearing (fading out)\n self.play(FadeOut(triangle))\n \n # --- Text Animation ---\n # Create the initial text object positioned lower to allow upward movement\n initial_text = Text(\"Starting Text\", font_size=36)\n initial_text.shift(DOWN * 2)\n \n # Create the target text object positioned where the initial text will arrive\n final_text = Text(\"animate.rotate\", font_size=36)\n final_text.move_to(ORIGIN)\n \n # Add the initial text to the scene\n self.play(Write(initial_text))\n \n # Animate the text moving upwards\n self.play(initial_text.animate.shift(UP * 2))\n \n # Transform the moving text into the new text object\n self.play(ReplacementTransform(initial_text, final_text))\n \n # Hold the final frame briefly\n self.wait(1)\n\n def act_2_torqueleverarm(self):\n title = Text(\"The same force creates more torque farther from the pivot\", font_size=34).to_edge(UP)\n pivots = VGroup(\n Triangle(color=GRAY_B, fill_opacity=0.4).scale(0.35).shift(LEFT * 3 + DOWN * 1.1),\n Triangle(color=GRAY_B, fill_opacity=0.4).scale(0.35).shift(RIGHT * 3 + DOWN * 1.1),\n )\n beams = VGroup(*[\n Line(pivot.get_top(), pivot.get_top() + RIGHT * 3.0, color=BLUE_B, stroke_width=8)\n for pivot in pivots\n ])\n near_point = beams[0].point_from_proportion(0.35)\n far_point = beams[1].point_from_proportion(0.9)\n forces = VGroup(\n Arrow(near_point + UP * 1.2, near_point, color=RED, buff=0, stroke_width=7),\n Arrow(far_point + UP * 1.2, far_point, color=RED, buff=0, stroke_width=7),\n )\n arms = VGroup(\n BraceBetweenPoints(beams[0].get_start() + DOWN * 0.3, near_point + DOWN * 0.3, color=YELLOW),\n BraceBetweenPoints(beams[1].get_start() + DOWN * 0.3, far_point + DOWN * 0.3, color=YELLOW),\n )\n labels = VGroup(\n Text(\"short lever arm\", font_size=21, color=YELLOW).next_to(arms[0], DOWN),\n Text(\"long lever arm\", font_size=21, color=YELLOW).next_to(arms[1], DOWN),\n )\n torque = VGroup(\n Text(\"smaller torque\", font_size=24).next_to(beams[0], UP).shift(RIGHT * 0.65),\n Text(\"larger torque\", font_size=24, color=GREEN).next_to(beams[1], UP),\n )\n formula = Text(\"torque = force \\times perpendicular lever arm\", font_size=25).to_edge(DOWN)\n\n self.play(Write(title), FadeIn(pivots), Create(beams))\n self.play(GrowArrow(forces[0]), GrowArrow(forces[1]))\n self.play(GrowFromCenter(arms[0]), GrowFromCenter(arms[1]), FadeIn(labels))\n self.play(FadeIn(torque), Indicate(arms[1], color=GREEN))\n self.play(FadeIn(formula), Circumscribe(torque[1], color=GREEN))\n self.wait(3)\n\n def act_3_enhancedoctagonrotation(self):\n octagon = RegularPolygon(n=8, color=TEAL, fill_opacity=0.8)\n octagon.scale(1.5)\n \n # Add coordinate axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BLUE},\n )\n axes.set_opacity(0.5)\n \n # Create angle label\n angle_label = MathTex(r\"\\theta = -120^\\circ\", color=YELLOW)\n angle_label.next_to(octagon, UP)\n \n # Create transformation label\n transform_label = Tex(\"Regular Octagon $\\\\rightarrow$ Star Polygon\", color=WHITE)\n transform_label.next_to(octagon, DOWN)\n \n # Animation sequence\n self.play(DrawBorderThenFill(octagon))\n self.play(FadeIn(axes))\n self.play(\n Rotate(octagon, angle=-120 * DEGREES, about_point=ORIGIN),\n Write(angle_label),\n run_time=2\n )\n self.wait(0.5)\n \n # Transform octagon into star polygon\n star = Star(n=8, outer_radius=1.5, density=2, color=PURPLE, fill_opacity=0.8)\n self.play(\n ReplacementTransform(octagon, star),\n FadeTransform(angle_label, transform_label),\n run_time=1.5\n )\n \n # Pulse the star twice\n self.play(\n star.animate.scale(1.2).set_color(PINK),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1/1.2).set_color(PURPLE),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1.2).set_color(PINK),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1/1.2).set_color(PURPLE),\n run_time=0.5\n )\n \n self.wait(1)\n self.play(FadeOut(star), FadeOut(axes), FadeOut(transform_label))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0661(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_triangletextanimation()\n self.clear_stage()\n self.act_2_torqueleverarm()\n self.clear_stage()\n self.act_3_enhancedoctagonrotation()\n\n def act_1_triangletextanimation(self):\n triangle = Triangle(color=BLUE)\n self.play(Create(triangle))\n \n # Animate a rotation of exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI))\n \n # Animate the triangle disappearing (fading out)\n self.play(FadeOut(triangle))\n \n # --- Text Animation ---\n # Create the initial text object positioned lower to allow upward movement\n initial_text = Text(\"Starting Text\", font_size=36)\n initial_text.shift(DOWN * 2)\n \n # Create the target text object positioned where the initial text will arrive\n final_text = Text(\"animate.rotate\", font_size=36)\n final_text.move_to(ORIGIN)\n \n # Add the initial text to the scene\n self.play(Write(initial_text))\n \n # Animate the text moving upwards\n self.play(initial_text.animate.shift(UP * 2))\n \n # Transform the moving text into the new text object\n self.play(ReplacementTransform(initial_text, final_text))\n \n # Hold the final frame briefly\n self.wait(1)\n\n def act_2_torqueleverarm(self):\n title = Text(\"The same force creates more torque farther from the pivot\", font_size=34).to_edge(UP)\n pivots = VGroup(\n Triangle(color=GRAY_B, fill_opacity=0.4).scale(0.35).shift(LEFT * 3 + DOWN * 1.1),\n Triangle(color=GRAY_B, fill_opacity=0.4).scale(0.35).shift(RIGHT * 3 + DOWN * 1.1),\n )\n beams = VGroup(*[\n Line(pivot.get_top(), pivot.get_top() + RIGHT * 3.0, color=BLUE_B, stroke_width=8)\n for pivot in pivots\n ])\n near_point = beams[0].point_from_proportion(0.35)\n far_point = beams[1].point_from_proportion(0.9)\n forces = VGroup(\n Arrow(near_point + UP * 1.2, near_point, color=RED, buff=0, stroke_width=7),\n Arrow(far_point + UP * 1.2, far_point, color=RED, buff=0, stroke_width=7),\n )\n arms = VGroup(\n BraceBetweenPoints(beams[0].get_start() + DOWN * 0.3, near_point + DOWN * 0.3, color=YELLOW),\n BraceBetweenPoints(beams[1].get_start() + DOWN * 0.3, far_point + DOWN * 0.3, color=YELLOW),\n )\n labels = VGroup(\n Text(\"short lever arm\", font_size=21, color=YELLOW).next_to(arms[0], DOWN),\n Text(\"long lever arm\", font_size=21, color=YELLOW).next_to(arms[1], DOWN),\n )\n torque = VGroup(\n Text(\"smaller torque\", font_size=24).next_to(beams[0], UP).shift(RIGHT * 0.65),\n Text(\"larger torque\", font_size=24, color=GREEN).next_to(beams[1], UP),\n )\n formula = Text(\"torque = force \\times perpendicular lever arm\", font_size=25).to_edge(DOWN)\n\n self.play(Write(title), FadeIn(pivots), Create(beams))\n self.play(GrowArrow(forces[0]), GrowArrow(forces[1]))\n self.play(GrowFromCenter(arms[0]), GrowFromCenter(arms[1]), FadeIn(labels))\n self.play(FadeIn(torque), Indicate(arms[1], color=GREEN))\n self.play(FadeIn(formula), Circumscribe(torque[1], color=GREEN))\n self.wait(3)\n\n def act_3_enhancedoctagonrotation(self):\n octagon = RegularPolygon(n=8, color=TEAL, fill_opacity=0.8)\n octagon.scale(1.5)\n \n # Add coordinate axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BLUE},\n )\n axes.set_opacity(0.5)\n \n # Create angle label\n angle_label = MathTex(r\"\\theta = -120^\\circ\" + \" = x\", color=YELLOW)\n angle_label.next_to(octagon, UP)\n \n # Create transformation label\n transform_label = Tex(\"Regular Octagon $\\\\rightarrow$ Star Polygon\", color=WHITE)\n transform_label.next_to(octagon, DOWN)\n \n # Animation sequence\n self.play(DrawBorderThenFill(octagon))\n self.play(FadeIn(axes))\n self.play(\n Rotate(octagon, angle=-120 * DEGREES, about_point=ORIGIN),\n Write(angle_label),\n run_time=2\n )\n self.wait(0.5)\n \n # Transform octagon into star polygon\n star = Star(n=8, outer_radius=1.5, density=2, color=PURPLE, fill_opacity=0.8)\n self.play(\n ReplacementTransform(octagon, star),\n FadeTransform(angle_label, transform_label),\n run_time=1.5\n )\n \n # Pulse the star twice\n self.play(\n star.animate.scale(1.2).set_color(PINK),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1/1.2).set_color(PURPLE),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1.2).set_color(PINK),\n run_time=0.5\n )\n self.play(\n star.animate.scale(1/1.2).set_color(PURPLE),\n run_time=0.5\n )\n \n self.wait(1)\n self.play(FadeOut(star), FadeOut(axes), FadeOut(transform_label))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to see an animated video that introduces the exponential function, shows its formula, graphs it on a coordinate system, and then explains and displays its derivative. The video should include a title for each part, starting with the function itself and then the derivative. The graph should be clearly visible and colored blue, with the function being plotted across a reasonable range of x values. The video should also pause briefly after presenting each piece of information to give me time to understand what has been shown before moving on to the next part. Can you create that animation for me?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialIntroduction(Scene):\n def construct(self):\n # --- 1. Introduction & Formula ---\n title = Text(\"The Exponential Function\", font_size=48)\n title.to_edge(UP)\n \n formula = MathTex(\"f(x)\", \"=\", \"e^x\", font_size=60)\n formula.next_to(title, DOWN, buff=1.5)\n \n self.play(Write(title))\n self.play(Write(formula))\n self.wait(3) # Pause for comprehension\n \n self.play(FadeOut(title), FadeOut(formula))\n \n # --- 2. Graph Visualization ---\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n tips=False\n )\n \n # Define the exponential function in Blue\n exp_graph = axes.plot(lambda x: np.exp(x), color=BLUE, stroke_width=4, x_range=[-2, 2])\n \n self.play(Create(axes))\n self.play(Create(exp_graph), run_time=2)\n self.wait(3) # Pause after graph is rendered\n \n self.play(FadeOut(axes), FadeOut(exp_graph))\n \n # --- 3. Derivative Explanation ---\n deriv_title = Text(\"The Derivative\", font_size=48)\n deriv_title.to_edge(UP)\n \n deriv_formula = MathTex(r\"\\frac{d}{dx}\", \"e^x\", \"=\", \"e^x\", font_size=60)\n deriv_formula.next_to(deriv_title, DOWN, buff=1.0)\n \n explanation = Text(\"The rate of growth is equal to the value of the function.\", \n font_size=24, color=GRAY)\n explanation.next_to(deriv_formula, DOWN, buff=0.5)\n \n self.play(Write(deriv_title))\n self.play(Write(deriv_formula))\n self.play(FadeIn(explanation, shift=UP * 0.2))\n \n # Highlight the equality specifically\n self.play(\n Indicate(deriv_formula[1], color=BLUE), # Highlight first e^x\n Indicate(deriv_formula[3], color=BLUE), # Highlight second e^x\n run_time=1.5\n )\n \n self.wait(3) # Pause for understanding\n \n self.play(FadeOut(deriv_title), FadeOut(deriv_formula), FadeOut(explanation))\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialIntroduction(Scene):\n def construct(self):\n # --- 1. Introduction & Formula ---\n title = Text(\"The Exponential Function\", font_size=48)\n title.to_edge(UP)\n \n formula = MathTex(r\"f(x)\" + \" = x\", \"=\", \"e^x\", font_size=60)\n formula.next_to(title, DOWN, buff=1.5)\n \n self.play(Write(title))\n self.play(Write(formula))\n self.wait(3) # Pause for comprehension\n \n self.play(FadeOut(title), FadeOut(formula))\n \n # --- 2. Graph Visualization ---\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n tips=False\n )\n \n # Define the exponential function in Blue\n exp_graph = axes.plot(lambda x: np.exp(x), color=BLUE, stroke_width=4, x_range=[-2, 2])\n \n self.play(Create(axes))\n self.play(Create(exp_graph), run_time=2)\n self.wait(3) # Pause after graph is rendered\n \n self.play(FadeOut(axes), FadeOut(exp_graph))\n \n # --- 3. Derivative Explanation ---\n deriv_title = Text(\"The Derivative\", font_size=48)\n deriv_title.to_edge(UP)\n \n deriv_formula = MathTex(r\"\\frac{d}{dx}\", \"e^x\", \"=\", \"e^x\", font_size=60)\n deriv_formula.next_to(deriv_title, DOWN, buff=1.0)\n \n explanation = Text(\"The rate of growth is equal to the value of the function.\", \n font_size=24, color=GRAY)\n explanation.next_to(deriv_formula, DOWN, buff=0.5)\n \n self.play(Write(deriv_title))\n self.play(Write(deriv_formula))\n self.play(FadeIn(explanation, shift=UP * 0.2))\n \n # Highlight the equality specifically\n self.play(\n Indicate(deriv_formula[1], color=BLUE), # Highlight first e^x\n Indicate(deriv_formula[3], color=BLUE), # Highlight second e^x\n run_time=1.5\n )\n \n self.wait(3) # Pause for understanding\n \n self.play(FadeOut(deriv_title), FadeOut(deriv_formula), FadeOut(explanation))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Is it possible to construct a 3D model where each layer is a Latin square that maintains the properties in all three dimensions?", "chosen": "```python\nfrom manim import *\n\nclass LatinCubeExploration(Scene):\n def construct(self):\n # Title\n title = Text(\"Exploring Latin Squares in 3D\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # 1. Explain Latin Square\n subtitle = Text(\"Latin Square\", font_size=36)\n subtitle.to_edge(UP)\n self.play(Write(subtitle))\n \n # Create a 3x3 grid\n grid = VGroup()\n for i in range(4):\n h_line = Line(start=[-1.5, 1.5 - i, 0], end=[1.5, 1.5 - i, 0])\n v_line = Line(start=[-1.5 + i, 1.5, 0], end=[-1.5 + i, -1.5, 0])\n grid.add(h_line, v_line)\n \n self.play(Create(grid))\n \n # Add numbers to create a Latin square\n numbers = VGroup()\n values = [\n [1, 2, 3],\n [2, 3, 1],\n [3, 1, 2]\n ]\n \n for i in range(3):\n for j in range(3):\n num = Text(str(values[i][j]), font_size=36)\n num.move_to([-1 + j, 1 - i, 0])\n numbers.add(num)\n \n self.play(Write(numbers))\n self.wait(1)\n \n # Highlight a row and column\n row = Rectangle(width=3, height=0.8, color=YELLOW, fill_opacity=0.3)\n row.move_to([0, 1, 0])\n \n col = Rectangle(width=0.8, height=3, color=BLUE, fill_opacity=0.3)\n col.move_to([0, 0, 0])\n \n self.play(FadeIn(row))\n self.wait(0.5)\n self.play(FadeOut(row))\n \n self.play(FadeIn(col))\n self.wait(0.5)\n self.play(FadeOut(col))\n \n # Latin square equation\n eq1 = Text(\"L(S) = {L1, L2, ..., Ln} where each Li is a Latin square\", font_size=24)\n eq1.to_edge(DOWN)\n self.play(Write(eq1))\n self.wait(1)\n \n self.play(FadeOut(grid), FadeOut(numbers), FadeOut(eq1), FadeOut(subtitle))\n \n # 2. Extend to 3D\n subtitle = Text(\"3D Latin Cube\", font_size=36)\n subtitle.to_edge(UP)\n self.play(Write(subtitle))\n \n # Create a simplified 3D cube\n front = Square(side_length=3, color=WHITE)\n back = Square(side_length=3, color=WHITE)\n back.shift(RIGHT * 1 + UP * 1)\n \n connections = VGroup()\n for i in range(4):\n start = front.get_vertices()[i]\n end = back.get_vertices()[i]\n connection = DashedLine(start=start, end=end)\n connections.add(connection)\n \n cube = VGroup(front, back, connections)\n \n self.play(Create(cube))\n self.wait(1)\n \n # Explanation of 3D Latin cube\n insight = Text(\"Key Insight: Balance across all three dimensions\", font_size=28)\n insight.next_to(subtitle, DOWN, buff=0.5)\n self.play(Write(insight))\n self.wait(1)\n \n # 3D Latin cube equation\n eq2 = Text(\"L(i,j,k) = {1,2,...,n} without repetition in any dimension\", font_size=24)\n eq2.to_edge(DOWN)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(cube), FadeOut(insight), FadeOut(eq2), FadeOut(subtitle))\n \n conclusion = Text(\"3D Latin cubes: Mathematical elegance in three dimensions\", font_size=32)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass LatinCubeExploration(Scene):\n def construct(self):\n # Title\n title = Text(\"Exploring Latin Squares in 3D\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # 1. Explain Latin Square\n subtitle = Text(\"Latin Square\", font_size=36)\n subtitle.to_edge(UP)\n self.play(Write(subtitle))\n \n # Create a 3x3 grid\n grid = VGroup()\n for i in range(4):\n h_line = Line(start=[-1.5, 1.5 - i, 0], end=[1.5, 1.5 - i, 0])\n v_line = Line(start=[-1.5 + i, 1.5, 0], end=[-1.5 + i, -1.5, 0])\n grid.add(h_line, v_line)\n \n self.play(Create(grid))\n \n # Add numbers to create a Latin square\n numbers = VGroup()\n values = [\n [1, 2, 3],\n [2, 3, 1],\n [3, 1, 2]\n ]\n \n for i in range(3):\n for j in range(3):\n num = Text(str(values[i][j]), font_size=36)\n num.move_to([-1 + j, 1 - i, 0])\n numbers.add(num)\n \n self.play(Write(numbers))\n self.wait(1)\n \n # Highlight a row and column\n row = Rectangle(width=3, height=0.8, color=YELLOW, fill_opacity=0.3)\n row.move_to([0, 1, 0])\n \n col = Rectangle(width=0.8, height=3, color=BBLUE, fill_opacity=0.3)\n col.move_to([0, 0, 0])\n \n self.play(FadeIn(row))\n self.wait(0.5)\n self.play(FadeOut(row))\n \n self.play(FadeIn(col))\n self.wait(0.5)\n self.play(FadeOut(col))\n \n # Latin square equation\n eq1 = Text(\"L(S) = {L1, L2, ..., Ln} where each Li is a Latin square\", font_size=24)\n eq1.to_edge(DOWN)\n self.play(Write(eq1))\n self.wait(1)\n \n self.play(FadeOut(grid), FadeOut(numbers), FadeOut(eq1), FadeOut(subtitle))\n \n # 2. Extend to 3D\n subtitle = Text(\"3D Latin Cube\", font_size=36)\n subtitle.to_edge(UP)\n self.play(Write(subtitle))\n \n # Create a simplified 3D cube\n front = Square(side_length=3, color=WHITE)\n back = Square(side_length=3, color=WHITE)\n back.shift(RIGHT * 1 + UP * 1)\n \n connections = VGroup()\n for i in range(4):\n start = front.get_vertices()[i]\n end = back.get_vertices()[i]\n connection = DashedLine(start=start, end=end)\n connections.add(connection)\n \n cube = VGroup(front, back, connections)\n \n self.play(Create(cube))\n self.wait(1)\n \n # Explanation of 3D Latin cube\n insight = Text(\"Key Insight: Balance across all three dimensions\", font_size=28)\n insight.next_to(subtitle, DOWN, buff=0.5)\n self.play(Write(insight))\n self.wait(1)\n \n # 3D Latin cube equation\n eq2 = Text(\"L(i,j,k) = {1,2,...,n} without repetition in any dimension\", font_size=24)\n eq2.to_edge(DOWN)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(cube), FadeOut(insight), FadeOut(eq2), FadeOut(subtitle))\n \n conclusion = Text(\"3D Latin cubes: Mathematical elegance in three dimensions\", font_size=32)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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?", "chosen": "```python\nfrom manim import *\n\nclass BroadcastAnimation(Scene):\n def construct(self):\n # 1. Text Appearance\n text = Text(\"Broadcast\", font_size=72, color=BLUE)\n self.play(Write(text))\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(text.animate.shift(UP * 2.5))\n self.wait(0.5)\n\n # 3. Signal Emission\n # Create the triangle (antenna/transmitter)\n triangle = Triangle(color=YELLOW, fill_opacity=0.8, stroke_width=2)\n triangle.scale(0.6).move_to(ORIGIN)\n self.play(DrawBorderThenFill(triangle))\n\n # Create concentric arcs for the broadcast signal\n waves = VGroup()\n for i in range(4):\n arc = Arc(\n radius=0.3, \n start_angle=0, \n angle=PI, \n color=WHITE, \n stroke_width=4\n )\n arc.move_to(triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out sequentially for a pulsing effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(4).set_opacity(0)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2.0,\n rate_func=smooth\n )\n\n # 4. Disappearance\n self.play(FadeOut(triangle))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass BroadcastAnimation(Scene):\n def construct(self):\n # 1. Text Appearance\n text = Text(\"Broadcast\", font_size=72, color=BBLUE)\n self.play(Write(text))\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(text.animate.shift(UP * 2.5))\n self.wait(0.5)\n\n # 3. Signal Emission\n # Create the triangle (antenna/transmitter)\n triangle = Triangle(color=YELLOW, fill_opacity=0.8, stroke_width=2)\n triangle.scale(0.6).move_to(ORIGIN)\n self.play(DrawBorderThenFill(triangle))\n\n # Create concentric arcs for the broadcast signal\n waves = VGroup()\n for i in range(4):\n arc = Arc(\n radius=0.3, \n start_angle=0, \n angle=PI, \n color=WHITE, \n stroke_width=4\n )\n arc.move_to(triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out sequentially for a pulsing effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(4).set_opacity(0)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2.0,\n rate_func=smooth\n )\n\n # 4. Disappearance\n self.play(FadeOut(triangle))\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass EulersFormula(Scene):\n def construct(self):\n # --- Step 1: Title Display ---\n title = Text(\"Euler's Formula\").scale(1)\n \n self.play(Write(title))\n self.wait(1)\n\n # Move title to the top of the screen\n self.play(\n title.animate.to_edge(UP).shift(DOWN * 0.2),\n run_time=1.5,\n rate_func=rush_into\n )\n self.wait(1)\n\n # --- Step 2: Formula Introduction ---\n formula = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i \\\\sin(\\\\theta)\")\n formula.scale(1.2)\n formula.next_to(title, DOWN, buff=1.5).to_edge(LEFT, buff=1.5)\n \n self.play(Write(formula[:3]))\n self.wait(0.5)\n self.play(Write(formula[3:]))\n self.wait(1)\n\n # Animate equation being rewritten\n self.play(FadeIn(formula[4], shift=RIGHT * 0.5))\n\n # Highlight the entire formula\n box = SurroundingRectangle(formula, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Clear the screen for the second part\n self.clear()\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersFormulaVisualization(Scene):\n def construct(self):\n # --- Step 1: Title Animation ---\n title = Text(\"Euler's Formula\").scale(1)\n \n self.play(Write(title))\n self.wait(1)\n\n # Move title to the top of the screen\n self.play(\n title.animate.to_edge(UP).shift(DOWN * 0.5),\n run_time=1.5\n )\n self.wait(0.5)\n\n # Display the formula in the center\n formula = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i\\\\sin(\\\\theta)\").scale(1.2)\n formula.next_to(title, DOWN, buff=0.8)\n \n self.play(Write(formula))\n self.wait(2)\n\n # --- Step 2: Complex Plane Setup ---\n axes = Axes(\n x_range=[-1.5, 1.5, 1],\n y_range=[-1.5, 1.5, 1],\n tips=False,\n axis_config={\"include_numbers\": False}\n ).center()\n \n labels = NumberPlane().set_opacity(0.3).center()\n\n self.add(labels, axes)\n \n # Create radius line tracing theta\n initial_radius = Line(ORIGIN, UP, color=BLUE, stroke_width=4)\n angle_tracker = ValueTracker(PI/6)\n\n arc = Arc(radius=0.75, start_angle=0, angle=-angle_tracker.get_value(), color=YELLOW)\n \n dot = Dot(point=initial_radius.get_end(), color=RED)\n \n self.play(Create(initial_radius), Write(arc), FadeIn(dot))\n\n self.wait(0.5)\n\n # Animate the radius moving along the unit circle\n self.add(angle_tracker)\n self.add_updater(lambda mobj: mobj.become(Line(ORIGIN, [np.cos(angle_tracker.get_value()), np.sin(angle_tracker.get_value()), 0], color=BLUE)))\n self.add_updater(lambda mobj: mobj.become(Arc(radius=0.75, start_angle=0, angle=-angle_tracker.get_value(), color=YELLOW)))\n self.add_updater(lambda mobj: mobj.move_to([np.cos(angle_tracker.get_value()), np.sin(angle_tracker.get_value()), 0]))\n\n # Update the angle tracker smoothly\n for _ in range(4): # Complete two rotations\n self.play(angle_tracker.animate.increment_value(-TWO_PI), run_time=2)\n\n self.remove(updaters=True)\n \n # Clear up the remaining objects after completion\n self.play(FadeOut(axes), FadeOut(labels), FadeOut(arc), FadeOut(dot), FadeOut(initial_radius))\n self.wait(0.5)\n\n # --- Step 3: Conclusion Sequence ---\n final_formula = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i\\\\sin(\\\\theta)\")\n \n # Center the formula again on screen\n final_formula.scale(1.2).move_to(ORIGIN)\n \n self.play(Write(final_formula))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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 2: Can you create an educational animation that illustrates the principles of circular motion and tension involved, starting with the general equation of motion under gravity, explaining the relevant terms, then transformin\n- Act 3: I'd like to create an animation that visually represents a neural network with three layers: the first layer having 20 neurons, the second layer 10 neurons, and the third layer 5 neurons. Each neuron should be relatively", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0619(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_fastsequencescene()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_simpleharmonicmotionscen()\n\n def act_1_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_2_areaundercurve(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n\n def act_3_simpleharmonicmotionscen(self):\n equation = MathTex(r\"m\\frac{d^2 x}{dt^2} = -kx\")\n self.play(Write(equation))\n self.wait(1)\n\n # Explain what each term represents\n terms_explanation = Text(\n \"Represents mass, spring constant, and position (m, k, x)\",\n font_size=24\n ).to_edge(UP)\n self.play(Write(terms_explanation))\n self.wait(2)\n\n # Show the form of the solution\n solution_form = MathTex(r\"x(t) = A \\cos(\\omega t - \\phi)\")\n self.play(ReplacementTransform(equation, solution_form))\n self.wait(1)\n\n # Explain the solution terms\n solution_explanation = Text(\n \"Where A is amplitude, omega is angular frequency, and phi is phase shift\",\n font_size=24\n ).to_edge(UP)\n self.play(Transform(terms_explanation, solution_explanation))\n self.wait(2)\n\n # Oscillation\n oscillator = Circle(radius=1.0, color=BLUE)\n oscillator.move_to(4*LEFT)\n self.play(Create(oscillator))\n \n # Create an arrow representing the force\n arrow = Arrow(\n oscillator.get_edge_center(RIGHT),\n oscillator.get_edge_center(RIGHT) + 2*RIGHT,\n buff=0\n )\n self.play(GrowArrow(arrow))\n self.wait(1)\n\n # Oscillate the circle to the right\n self.play(oscillator.animate.move_to(4*RIGHT), run_time=2, rate_func=there_and_back)\n self.wait(1)\n\n # Clear the scene and show the solution again\n self.clear()\n self.wait(1)\n self.play(Write(solution_form))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0619(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_fastsequencescene()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_simpleharmonicmotionscen()\n\n def act_1_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_2_areaundercurve(self):\n axes = Axes(font_size=24, \n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n\n def act_3_simpleharmonicmotionscen(self):\n equation = MathTex(r\"m\\frac{d^2 x}{dt^2} = -kx\")\n self.play(Write(equation))\n self.wait(1)\n\n # Explain what each term represents\n terms_explanation = Text(\n \"Represents mass, spring constant, and position (m, k, x)\",\n font_size=24\n ).to_edge(UP)\n self.play(Write(terms_explanation))\n self.wait(2)\n\n # Show the form of the solution\n solution_form = MathTex(r\"x(t) = A \\cos(\\omega t - \\phi)\")\n self.play(ReplacementTransform(equation, solution_form))\n self.wait(1)\n\n # Explain the solution terms\n solution_explanation = Text(\n \"Where A is amplitude, omega is angular frequency, and phi is phase shift\",\n font_size=24\n ).to_edge(UP)\n self.play(Transform(terms_explanation, solution_explanation))\n self.wait(2)\n\n # Oscillation\n oscillator = Circle(radius=1.0, color=BLUE)\n oscillator.move_to(4*LEFT)\n self.play(Create(oscillator))\n \n # Create an arrow representing the force\n arrow = Arrow(\n oscillator.get_edge_center(RIGHT),\n oscillator.get_edge_center(RIGHT) + 2*RIGHT,\n buff=0\n )\n self.play(GrowArrow(arrow))\n self.wait(1)\n\n # Oscillate the circle to the right\n self.play(oscillator.animate.move_to(4*RIGHT), run_time=2, rate_func=there_and_back)\n self.wait(1)\n\n # Clear the scene and show the solution again\n self.clear()\n self.wait(1)\n self.play(Write(solution_form))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Develop a Manim animation explaining the concept of orthogonality in linear algebra. Visualize orthogonal vectors, subspaces, and projections, step by step.\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: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0768(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects), run_time=0.8)\n \n def construct(self):\n self.act_1_orthogonal()\n self.clear_stage()\n self.act_2_simplegeom()\n self.clear_stage()\n self.act_3_mathplot()\n\n def act_1_orthogonal(self):\n title = Text(\"Orthogonality Revealed\", font_size=40).to_edge(UP)\n dotA = Dot(RIGHT*2 + UP*1, color=YELLOW, radius=0.1)\n labelA = MathTex(\"\\\\mathbf{v}_1\").next_to(dotA, RIGHT, buff=-0.2)\n vectorA = Arrow(ORIGIN, dotA.get_center(), max_tip_length_to_length_ratio=0.2, color=YELLOW)\n \n # Show vectors\n self.play(Write(title))\n self.play(Create(vectorA), FadeIn(labelA), run_time=1.5)\n\n # Orthogonal vector\n dotO = Dot(LEFT*2 + DOWN*1, color=GREEN, radius=0.1)\n labelO = MathTex(\"\\\\perp \\\\quad \\\\mathbf{v}_2\").next_to(dotO, LEFT, buff=0.2)\n vectorO = Arrow(ORIGIN, dotO.get_center(), max_tip_length_to_length_ratio=0.2, color=GREEN)\n plane = Line(ORIGIN, ORIGIN+RIGHT).set_color(WHITE).rotate(-PI/4)\n \n # Animate projection formula\n proj_formula = MathTex(\n r\"\\text{Proj}_{\\mathbf{u}} \\mathbf{v} = \\frac{\\mathbf{v}\\cdot \\mathbf{u}}{\\mathbf{u}\\cdot \\mathbf{u}}\\\\\",\n r\"=\\frac{x_u y_v}{x_u^2+y_u^2}\"\n ).scale(0.7).to_corner(DOWN+LEFT)\n\n self.play(\n Create(plane),\n FadeIn(dotO, labelO, vectorO),\n Write(proj_formula)\n )\n self.wait(2)\n\n # Subspace explanation\n subspace_text = Text(\"Subspace Spanned by Orthogons\", font_size=24).to_edge(DOWN)\n self.play(Write(subspace_text))\n\n # Move vectors up briefly\n self.play(\n vectorA.animate.shift(UP*1.5), \n vectorO.animate.shift(UP*1.5), \n dotA.animate.shift(UP*1.5), \n dotO.animate.shift(UP*1.5)\n )\n\n # Shift vectors back down\n self.play(\n vectorA.animate.shift(DOWN*1.5), \n vectorO.animate.shift(DOWN*1.5), \n dotA.animate.shift(DOWN*1.5), \n dotO.animate.shift(DOWN*1.5)\n )\n self.wait(1)\n\n # Final transition\n self.play(\n FadeOut(title), \n FadeOut(subspace_text), \n FadeOut(vectorA), \n FadeOut(vectorO), \n FadeOut(dotA), \n FadeOut(dotO), \n FadeOut(labelA), \n FadeOut(labelO), \n FadeOut(proj_formula), \n FadeOut(plane)\n )\n self.wait(1)\n\n def act_2_simplegeom(self):\n # --- Configuration ---\n TEXT_START_POS = UP * 2\n CIRCLE_RADIUS = 1.5\n\n # Step 1: Display Title\n title = Tex(\"Simple Geometric Sequence\")\n title.to_edge(UP)\n self.play(Write(title))\n\n # Step 2: Create Moving Text\n moving_text = Tex(\"Moving Upwards\")\n moving_text.move_to(TEXT_START_POS)\n \n self.add(moving_text)\n self.play(\n moving_text.animate.shift(DOWN * 4),\n run_time=2,\n rate_func=linear\n )\n self.remove(moving_text)\n\n # Step 3: Create Circle\n circle = Circle(radius=CIRCLE_RADIUS, color=BLUE)\n self.play(Create(circle))\n\n # Step 4: Transform to Red Square\n square = Square(side_length=CIRCLE_RADIUS * 2, color=RED)\n \n self.play(Transform(circle, square))\n\n # Step 5: Animate Movement\n self.play(\n square.animate.shift(DOWN * 1.5 + RIGHT * 2),\n run_time=2,\n run_back=True,\n )\n\n # Step 6: Cleanup\n self.play(FadeOut(square))\n\n def act_3_mathplot(self):\n func_tex = MathTex(\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_tex))\n axes = Axes(\n x_range=[-2, 2],\n y_range=[-1, 4]\n ).shift(DOWN * 0.5)\n \n self.play(Create(axes))\n self.wait(0.5)\n\n # Plotting the function\n graph = axes.plot(lambda x: x**2, color=BLUE)\n self.play(Create(graph), run_time=2)\n self.wait(2)\n```", "rejected": "```python\n# --- Multi-Act Masterpiece: OrthoWalks ---\n# A three-part educational series showcasing linear algebra concepts through visual storytelling.\n\nfrom manim import *\n\nclass OrthoMasterPiece(Scene):\n def clear_stage(self):\n if self.mobs:\n FadeOut(*self.mobs, run_time=0.8)\n \n def construct(self):\n # Execute each act sequentially after clearing any prior content\n self.act_1_ortho_walk()\n self.clear_stage()\n self.act_2_simple_shape_tale()\n self.clear_stage()\n self.act_3_graphic_story()\n\n def act_1_ortho_walk(self):\n title = Text(\"Orthogonal Walks\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Step 2: Vector Visualization \n vector_a = Arrow(start=ORIGIN, end=RIGHT*2 + UP*1, color=BLUE)\n vector_b = Arrow(start=ORIGIN, end=LEFT*-1 + DOWN*-2, color=GREEN)\n \n self.play(Create(vector_a))\n self.play(GrowArrow(vector_b))\n \n label_a = MathText(\"\\\\vec{a}\", font_size=24).next_to(vector_a.get_end(), RIGHT)\n label_b = MathText(\"\\\\vec{b}\", font_size=24).next_to(vector_b.get_end(), LEFT)\n \n self.add(label_a, label_b)\n\n # Step 3: Projection Explanation \n proj_text = Tex(\"$P$ is the projection of $\\\\vec{v}$ onto $\\\\vec{u}$\").scale(0.7).shift(DOWN * 3)\n self.play(Write(proj_text))\n\n # Simple line representing u\n line_u = Line(START_POINT, END_POINT, stroke_color=YELLOW)\n u_label = Text('u', color=YELLOW).move_to(line_u.get_center())\n \n self.play(Create(line_u), Write(u_label))\n \n # Vector v\n vec_v = Arrow(start=ORIGIN, end=RIGHT*3 + UP*1, color=PURPLE)\n v_label = Text('v', color=PURPLE).next_to(vec_v.get_start(), DOWN)\n \n self.play(Create(vec_v), Write(v_label))\n\n # Step 4: Algebraic Equation\n eq = MathTex(\n \"P = \\\\frac{\\\\vec{v} \\\\cdot \\\\hat{u}}{\\\\hat{u} \\\\cdot \\\\hat{u}} \\\\hat{u}\"\n ).scale(0.7).to_edge(DOWN)\n\n self.play(Write(eq))\n\n # Final State\n final_title = Text(\"Orthogonality drives Linear Transformation\", font_size=30).to_edge(UP)\n self.play(Transform(title, final_title))\n\n self.wait(2)\n\n def act_2_simple_shape_tale(self):\n # 1. Initial Scene: Display a text message centered on-screen\n intro_text = Text(\"Welcome to Shape Animation!\", font_size=32).move_to(ORIGINA)\n self.play(Write(intro_text))\n self.wait(1)\n\n # Move the text upward\n self.play(FadeOut(intro_text, shift=UP))\n self.wait(0.5)\n\n # 2. Circle Appearance: Animate the appearance of a blue circle\n circle = Circle(radius=2, color=BLUE)\n self.play(Create(circle))\n self.wait(1)\n\n # Transform the circle into a red square\n square = Square(side_length=4, color=RED)\n self.transform_from_parts(square, circle)\n self.wait(1)\n\n # 3. Movement Sequence: The square should move downward and to the right simultaneously\n target_pos = RIGHT * 3 + DOWN * 3\n self.play(MoveAlongPath(square, Line(ORIGIN, target_pos)), run_time=2, rate_func=smooth)\n\n # 4. Conclusion: End the animation with the remaining elements fading out\n self.wait(1)\n self.fade_out(square)\n\n def act_3_graphic_story(self):\n func_text = MathTex(\"f(x) = x^2\")\n func_text.to_edge(UP)\n self.play(Write(func_text))\n\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-1, 9]\n )\n axes.shift(DOWN * 0.5)\n\n self.play(Create(axes))\n\n graph = axes.plot(lambda x: x**2, x_range=(-3, 3), color=WHITE)\n self.play(Create(graph))\n\n point_at_two = axes.input_to_graph_point(2, graph)\n dot_at_two = Dot(point_at_two, radius=0.1, color=BLUE)\n self.play(Create(dot_at_two))\n\n # Add vertical line\n vertical_line = DashedLine(\n start=axes.c2p(2, 0),\n end=point_at_two,\n color=GREY\n )\n\n self.play(Create(vertical_line))\n\n # Label the area under curve\n area = Polygon(\n axes.c2p(-2, 0),\n axes.c2p(2, 0),\n point_at_two\n )\n area_set = Area(area, color=BLUE, opacity=0.5)\n\n self.play(FadeIn(area_set))\n\n # Add integral notation\n integral_notation = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\")\n integral_notation.next_to(func_text, DOWN, buff=1)\n self.play(Write(integral_notation))\n\n result_text = MathTex(\"Area = 8\")\n result_text.move_to(integral_notation)\n self.play(ReplacementTransform(integral_notation, result_text))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Each agent only cares about its own state, actions, and rewards\nThe observation space is limited to a local perspective (Partial Observability), ignoring global joint information.\n\n### Other agents are treated as part of the environment\nThe behavior of opponents or teammates is viewed as a random factor in the environmental state transition probabilities, without special handling.\n\n\nThe context location of this section (from highest to current level):\n# Independent Learners and Non-Stationarity Issues\n## Basic Concepts of Independent Learners\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass IndependentLearners(Scene):\n\n def construct(self):\n title = Text('Independent Learners', font_size=40, weight=BOLD)\n subtitle = Text('Basic Concepts & Non-Stationarity Issues', font_size=30, color=BLUE)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.15)\n title_group.to_edge(UP, buff=0.4)\n p1 = Text('• Each agent only cares about its own state, actions, and rewards', font_size=24)\n p1_s1 = Text(' - Observation space is limited to a local perspective (Partial Observability)', font_size=20, color=LIGHT_GREY)\n p1_s2 = Text(' - Global joint information is ignored', font_size=20, color=LIGHT_GREY)\n p2 = Text('• Other agents are treated as part of the environment', font_size=24)\n p2_s1 = Text(' - Opponents/teammates viewed as random factors in transition probabilities', font_size=20, color=LIGHT_GREY)\n p2_s2 = Text(' - No special handling is applied to their behavior', font_size=20, color=LIGHT_GREY)\n text_group = VGroup(p1, p1_s1, p1_s2, p2, p2_s1, p2_s2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n text_group.next_to(title_group, DOWN, buff=0.5).to_edge(LEFT, buff=0.8)\n agent_box = Rectangle(width=2.5, height=1.5, color=BLUE)\n agent_text = Text('Agent i', font_size=24).move_to(agent_box)\n agent = VGroup(agent_box, agent_text)\n env_box = Rectangle(width=4.5, height=2.2, color=GREEN)\n env_text = Text('Environment', font_size=24).move_to(env_box).shift(UP * 0.5)\n other_agents_box = Rectangle(width=3.5, height=0.7, color=RED, fill_opacity=0.1)\n other_agents_box.next_to(env_text, DOWN, buff=0.2)\n other_agents = Text('Other Agents', font_size=20, color=RED).move_to(other_agents_box)\n env = VGroup(env_box, env_text, other_agents_box, other_agents)\n diagram = VGroup(agent, env).arrange(RIGHT, buff=3.5)\n diagram.next_to(text_group, DOWN, buff=0.6)\n diagram.set_x(0)\n a_arrow = Arrow(agent_box.get_right() + UP * 0.3, env_box.get_left() + UP * 0.3, buff=0.1, color=YELLOW)\n a_text = MathTex('A_i', font_size=28).next_to(a_arrow, UP, buff=0.1)\n sr_arrow = Arrow(env_box.get_left() + DOWN * 0.3, agent_box.get_right() + DOWN * 0.3, buff=0.1, color=YELLOW)\n sr_text = MathTex('S_i, R_i', font_size=28).next_to(sr_arrow, DOWN, buff=0.1)\n self.play(Write(title_group))\n self.wait(0.5)\n self.play(FadeIn(p1, shift=RIGHT * 0.5))\n self.play(FadeIn(p1_s1, shift=RIGHT * 0.5), FadeIn(p1_s2, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(p2, shift=RIGHT * 0.5))\n self.play(FadeIn(p2_s1, shift=RIGHT * 0.5), FadeIn(p2_s2, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Create(agent_box), Write(agent_text))\n self.play(Create(env_box), Write(env_text))\n self.play(Create(other_agents_box), Write(other_agents))\n self.play(other_agents_box.animate.set_fill(opacity=0.3), run_time=0.5)\n self.play(other_agents_box.animate.set_fill(opacity=0.1), run_time=0.5)\n self.play(GrowArrow(a_arrow), Write(a_text))\n self.play(GrowArrow(sr_arrow), Write(sr_text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass IndependentLearners(Scene):\n\n def construct(self):\n title = Text('Independent Learners', font_size=40, weight=BOLD)\n subtitle = Text('Basic Concepts & Non-Stationarity Issues', font_size=30, color=BBLUE)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.15)\n title_group.to_edge(UP, buff=0.4)\n p1 = Text('• Each agent only cares about its own state, actions, and rewards', font_size=24)\n p1_s1 = Text(' - Observation space is limited to a local perspective (Partial Observability)', font_size=20, color=LIGHT_GREY)\n p1_s2 = Text(' - Global joint information is ignored', font_size=20, color=LIGHT_GREY)\n p2 = Text('• Other agents are treated as part of the environment', font_size=24)\n p2_s1 = Text(' - Opponents/teammates viewed as random factors in transition probabilities', font_size=20, color=LIGHT_GREY)\n p2_s2 = Text(' - No special handling is applied to their behavior', font_size=20, color=LIGHT_GREY)\n text_group = VGroup(p1, p1_s1, p1_s2, p2, p2_s1, p2_s2).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n text_group.next_to(title_group, DOWN, buff=0.5).to_edge(LEFT, buff=0.8)\n agent_box = Rectangle(width=2.5, height=1.5, color=BLUE)\n agent_text = Text('Agent i', font_size=24).move_to(agent_box)\n agent = VGroup(agent_box, agent_text)\n env_box = Rectangle(width=4.5, height=2.2, color=GREEN)\n env_text = Text('Environment', font_size=24).move_to(env_box).shift(UP * 0.5)\n other_agents_box = Rectangle(width=3.5, height=0.7, color=RED, fill_opacity=0.1)\n other_agents_box.next_to(env_text, DOWN, buff=0.2)\n other_agents = Text('Other Agents', font_size=20, color=RED).move_to(other_agents_box)\n env = VGroup(env_box, env_text, other_agents_box, other_agents)\n diagram = VGroup(agent, env).arrange(RIGHT, buff=3.5)\n diagram.next_to(text_group, DOWN, buff=0.6)\n diagram.set_x(0)\n a_arrow = Arrow(agent_box.get_right() + UP * 0.3, env_box.get_left() + UP * 0.3, buff=0.1, color=YELLOW)\n a_text = MathTex('A_i', font_size=28).next_to(a_arrow, UP, buff=0.1)\n sr_arrow = Arrow(env_box.get_left() + DOWN * 0.3, agent_box.get_right() + DOWN * 0.3, buff=0.1, color=YELLOW)\n sr_text = MathTex('S_i, R_i', font_size=28).next_to(sr_arrow, DOWN, buff=0.1)\n self.play(Write(title_group))\n self.wait(0.5)\n self.play(FadeIn(p1, shift=RIGHT * 0.5))\n self.play(FadeIn(p1_s1, shift=RIGHT * 0.5), FadeIn(p1_s2, shift=RIGHT * 0.5))\n self.wait(0.5)\n self.play(FadeIn(p2, shift=RIGHT * 0.5))\n self.play(FadeIn(p2_s1, shift=RIGHT * 0.5), FadeIn(p2_s2, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Create(agent_box), Write(agent_text))\n self.play(Create(env_box), Write(env_text))\n self.play(Create(other_agents_box), Write(other_agents))\n self.play(other_agents_box.animate.set_fill(opacity=0.3), run_time=0.5)\n self.play(other_agents_box.animate.set_fill(opacity=0.1), run_time=0.5)\n self.play(GrowArrow(a_arrow), Write(a_text))\n self.play(GrowArrow(sr_arrow), Write(sr_text))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Demonstrate the behavior of particles in different states of matter (solid, liquid, gas).", "chosen": "```python\nfrom manim import *\n\nclass StatesOfMatter(Scene):\n def construct(self):\n # Title\n title = Text(\"Behavior of Particles in Different States of Matter\", font_size=36).to_edge(UP)\n self.play(Write(title))\n\n # Solid state\n solid_text = Text(\"Solid\", font_size=28).next_to(title, DOWN, buff=1.5)\n solid_explanation = Text(\n \"In a solid, particles are closely packed and vibrate in fixed positions.\",\n font_size=24\n ).to_edge(DOWN)\n solid_particles = VGroup(*[Dot(radius=0.05, color=BLUE) for _ in range(50)])\n solid_particles.arrange_in_grid(buff=0.5)\n solid_particles.move_to(ORIGIN)\n\n # Liquid state\n liquid_text = Text(\"Liquid\", font_size=28).next_to(solid_text, DOWN, buff=1.5)\n liquid_explanation = Text(\n \"In a liquid, particles are close but not fixed, allowing them to flow \\nand take the shape of the container.\",\n font_size=24\n ).to_edge(DOWN,buff=1)\n liquid_particles = VGroup(*[Dot(radius=0.05, color=BLUE_D) for _ in range(100)])\n liquid_particles.arrange_in_grid(buff=0.5)\n liquid_particles.move_to(ORIGIN)\n\n # Gas state\n gas_text = Text(\"Gas\", font_size=28).next_to(liquid_text, DOWN, buff=1.5)\n gas_explanation = Text(\n \"In a gas, particles are far apart and move freely, filling the entire space available.\",\n font_size=24\n ).to_edge(DOWN)\n gas_particles = VGroup(*[Dot(radius=0.05, color=RED) for _ in range(200)])\n gas_particles.arrange_in_grid(buff=0.5)\n gas_particles.move_to(ORIGIN)\n\n # Show solid state\n self.play(Write(solid_text))\n self.play(Create(solid_particles))\n self.play(Write(solid_explanation))\n self.wait(2)\n\n # Transform solid to liquid state\n self.play(Transform(solid_particles, liquid_particles), ReplacementTransform(solid_text, liquid_text),\n FadeOut(solid_explanation), Write(liquid_explanation))\n self.wait(2)\n\n # Transform liquid to gas state\n self.play(Transform(liquid_particles, gas_particles), ReplacementTransform(liquid_text, gas_text),\n FadeOut(liquid_explanation), Write(gas_explanation))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass StatesOfMatter(Scene):\n def construct(self):\n # Title\n title = Text(\"Behavior of Particles in Different States of Matter\", font_size=36).to_edge(UP)\n self.play(Write(title))\n\n # Solid state\n solid_text = Text(\"Solid\", font_size=28).next_to(title, DOWN, buff=1.5)\n solid_explanation = Text(\n \"In a solid, particles are closely packed and vibrate in fixed positions.\",\n font_size=24\n ).to_edge(DOWN)\n solid_particles = VGroup(*[Dot(radius=0.05, color=BLUE) for _ in range(50)])\n solid_particles.arrange_in_grid(buff=0.5)\n solid_particles.move_to(ORIGIN)\n\n # Liquid state\n liquid_text = Text(\"Liquid\", font_size=28).next_to(solid_text, DOWN, buff=1.5)\n liquid_explanation = Text(\n \"In a liquid, particles are close but not fixed, allowing them to flow \\nand take the shape of the container.\",\n font_size=24\n ).to_edge(DOWN,buff=1)\n liquid_particles = VGroup(*[Dot(radius=0.05, color=BLUE_D) for _ in range(100)])\n liquid_particles.arrange_in_grid(buff=0.5)\n liquid_particles.move_to(ORIGIN)\n\n # Gas state\n gas_text = Text(\"Gas\", font_size=28).next_to(liquid_text, DOWN, buff=1.5)\n gas_explanation = Text(\n \"In a gas, particles are far apart and move freely, filling the entire space available.\",\n font_size=24\n ).to_edge(DOWN)\n gas_particles = VGroup(*[Dot(radius=0.05, color=RED) for _ in range(200)])\n gas_particles.arrange_in_grid(buff=0.5)\n gas_particles.move_to(ORIGIN)\n\n # Show solid state\n self.play(Write(solid_text))\n self.play(Create(solid_particles))\n self.play(Write(solid_explanation))\n self.wait(2)\n\n # Transform solid to liquid state\n self.play(Transform(solid_particles, liquid_particles), ReplacementTransform(target_position=ORIGIN, solid_text, liquid_text),\n FadeOut(solid_explanation), Write(liquid_explanation))\n self.wait(2)\n\n # Transform liquid to gas state\n self.play(Transform(liquid_particles, gas_particles), ReplacementTransform(liquid_text, gas_text),\n FadeOut(liquid_explanation), Write(gas_explanation))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 with a Time Dimension\nActual agents adjust their strategies over time through trial and error, which is a dynamic evolutionary process.\n\n\nThe context of this section (from highest to current level):\n# Classical Games and Nash Equilibrium\n## From Static Equilibrium to Dynamic Processes\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass LearningWithTimeDimension(Scene):\n\n def construct(self):\n context_text = Text('Classical Games and Nash Equilibrium > From Static Equilibrium to Dynamic Processes', font_size=20, color=GRAY).to_edge(UP, buff=0.3)\n title = Text('Learning with a Time Dimension', font_size=36, color=BLUE_C, weight=BOLD).next_to(context_text, DOWN, buff=0.4)\n body_text = VGroup(Text('Actual agents adjust their strategies over time', font_size=28), Text('through trial and error, which is a', font_size=28), Text('dynamic evolutionary process.', font_size=28)).arrange(DOWN, buff=0.1).next_to(title, DOWN, buff=0.5)\n strat_box = Rectangle(width=3.2, height=1, color=YELLOW_E, fill_opacity=0.2)\n strat_text = Text('Strategy (t)', font_size=24)\n strat_node = VGroup(strat_box, strat_text).move_to(DOWN * 0.5)\n env_box = Rectangle(width=3.2, height=1, color=GREEN_E, fill_opacity=0.2)\n env_text = Text('Environment', font_size=24)\n env_node = VGroup(env_box, env_text).move_to(DOWN * 2.5 + RIGHT * 3.5)\n feed_box = Rectangle(width=3.2, height=1, color=RED_E, fill_opacity=0.2)\n feed_text = Text('Feedback / Payoff', font_size=24)\n feed_node = VGroup(feed_box, feed_text).move_to(DOWN * 2.5 + LEFT * 3.5)\n a1 = Arrow(strat_node.get_bottom(), env_node.get_top(), buff=0.15)\n a1_text = Text('Action', font_size=20, color=YELLOW).move_to(a1.get_center() + RIGHT * 0.7 + UP * 0.2)\n a2 = Arrow(env_node.get_left(), feed_node.get_right(), buff=0.15)\n a2_text = Text('Trial & Error', font_size=20, color=GREEN).next_to(a2, UP, buff=0.1)\n a3 = Arrow(feed_node.get_top(), strat_node.get_bottom(), buff=0.15)\n a3_text = Text('Adjustment (t+1)', font_size=20, color=RED).move_to(a3.get_center() + LEFT * 1.0 + UP * 0.2)\n self.play(FadeIn(context_text))\n self.play(Write(title))\n self.play(FadeIn(body_text, shift=DOWN))\n self.wait(1)\n self.play(Create(strat_box), Write(strat_text))\n self.wait(0.5)\n self.play(GrowArrow(a1), FadeIn(a1_text, shift=DOWN))\n self.play(Create(env_box), Write(env_text))\n self.wait(0.5)\n self.play(GrowArrow(a2), FadeIn(a2_text, shift=LEFT))\n self.play(Create(feed_box), Write(feed_text))\n self.wait(0.5)\n self.play(GrowArrow(a3), FadeIn(a3_text, shift=UP))\n cycle_group = VGroup(strat_node, a1, a1_text, env_node, a2, a2_text, feed_node, a3, a3_text)\n self.play(cycle_group.animate.scale(1.05), rate_func=there_and_back, run_time=1.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass LearningWithTimeDimension(Scene):\n\n def construct(self):\n context_text = Text('Classical Games and Nash Equilibrium > From Static Equilibrium to Dynamic Processes', font_size=20, color=GRAY).to_edge(UP, buff=0.3)\n title = Text('Learning with a Time Dimension', font_size=36, color=BBLUE_C, weight=BOLD).next_to(context_text, DOWN, buff=0.4)\n body_text = VGroup(Text('Actual agents adjust their strategies over time', font_size=28), Text('through trial and error, which is a', font_size=28), Text('dynamic evolutionary process.', font_size=28)).arrange(DOWN, buff=0.1).next_to(title, DOWN, buff=0.5)\n strat_box = Rectangle(width=3.2, height=1, color=YELLOW_E, fill_opacity=0.2)\n strat_text = Text('Strategy (t)', font_size=24)\n strat_node = VGroup(strat_box, strat_text).move_to(DOWN * 0.5)\n env_box = Rectangle(width=3.2, height=1, color=GREEN_E, fill_opacity=0.2)\n env_text = Text('Environment', font_size=24)\n env_node = VGroup(env_box, env_text).move_to(DOWN * 2.5 + RIGHT * 3.5)\n feed_box = Rectangle(width=3.2, height=1, color=RED_E, fill_opacity=0.2)\n feed_text = Text('Feedback / Payoff', font_size=24)\n feed_node = VGroup(feed_box, feed_text).move_to(DOWN * 2.5 + LEFT * 3.5)\n a1 = Arrow(strat_node.get_bottom(), env_node.get_top(), buff=0.15)\n a1_text = Text('Action', font_size=20, color=YELLOW).move_to(a1.get_center() + RIGHT * 0.7 + UP * 0.2)\n a2 = Arrow(env_node.get_left(), feed_node.get_right(), buff=0.15)\n a2_text = Text('Trial & Error', font_size=20, color=GREEN).next_to(a2, UP, buff=0.1)\n a3 = Arrow(feed_node.get_top(), strat_node.get_bottom(), buff=0.15)\n a3_text = Text('Adjustment (t+1)', font_size=20, color=RED).move_to(a3.get_center() + LEFT * 1.0 + UP * 0.2)\n self.play(FadeIn(context_text))\n self.play(Write(title))\n self.play(FadeIn(body_text, shift=DOWN))\n self.wait(1)\n self.play(Create(strat_box), Write(strat_text))\n self.wait(0.5)\n self.play(GrowArrow(a1), FadeIn(a1_text, shift=DOWN))\n self.play(Create(env_box), Write(env_text))\n self.wait(0.5)\n self.play(GrowArrow(a2), FadeIn(a2_text, shift=LEFT))\n self.play(Create(feed_box), Write(feed_text))\n self.wait(0.5)\n self.play(GrowArrow(a3), FadeIn(a3_text, shift=UP))\n cycle_group = VGroup(strat_node, a1, a1_text, env_node, a2, a2_text, feed_node, a3, a3_text)\n self.play(cycle_group.animate.scale(1.05), rate_func=there_and_back, run_time=1.5)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an educational animation that visually demonstrates the concept of finding the area under the curve for the function f(x) = x^2, from x=0 to x=2. This should include a coordinate system with labeled axes, the graph of the function, and a shaded region under the curve that represents the area we're interested in. Additionally, I want to introduce the integral symbol and show the mathematical process of calculating the exact area using integration, and then replace the integral with the final numeric solution. Can you provide a step-by-step animation that can help students visually understand this mathematical concept?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n An educational animation demonstrating the calculation of the area \n under the curve f(x) = x^2 from x=0 to x=2.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup: Initialize Coordinate System\n # ------------------------------------------------------------------\n # Create axes with appropriate ranges for f(x) = x^2 from 0 to 2\n # x_range covers 0 to 3 to provide context beyond the integration limit\n # y_range covers 0 to 5 since 2^2 = 4\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},\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 # Add specific tick numbers for clarity\n x_ticks = axes.get_x_axis().add_numbers([1, 2])\n y_ticks = axes.get_y_axis().add_numbers([1, 2, 3, 4])\n\n # ------------------------------------------------------------------\n # 2. Function Plotting: Graph f(x) = x^2\n # ------------------------------------------------------------------\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=BLUE)\n func_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n\n # ------------------------------------------------------------------\n # 3. Region Shading: Area under the curve from x=0 to x=2\n # ------------------------------------------------------------------\n # Create the shaded region representing the definite integral\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n \n # Vertical line to mark the boundary at x=2\n boundary_line = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY, line_func=Line)\n boundary_label = MathTex(\"x=2\").next_to(boundary_line, UP, buff=0.1).set_size(0.7)\n\n # ------------------------------------------------------------------\n # 4. Mathematical Notation: Step-by-Step Calculation\n # ------------------------------------------------------------------\n # Define the steps of the integration process\n # Step 1: The definite integral expression\n integral_expr = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n \n # Step 2: The antiderivative\n antiderivative_expr = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n \n # Step 3: Evaluation at limits\n evaluation_expr = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n \n # Step 4: Final exact numeric solution and approximation\n result_expr = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n # Position the math equations on the right side of the screen\n # We align them to the same position to allow smooth transformation\n math_group = VGroup(integral_expr, antiderivative_expr, evaluation_expr, result_expr)\n math_group.to_edge(RIGHT)\n math_group.shift(UP * 1.5)\n\n # Ensure all subsequent equations start at the same position as the first\n # This ensures the Transform animation morphs them in place\n target_position = integral_expr.get_center()\n antiderivative_expr.move_to(target_position)\n evaluation_expr.move_to(target_position)\n result_expr.move_to(target_position)\n\n # ------------------------------------------------------------------\n # 5. Educational Flow: Animation Sequence\n # ------------------------------------------------------------------\n \n # Draw the coordinate system\n self.play(Create(axes), Write(x_label), Write(y_label), Write(x_ticks), Write(y_ticks))\n self.wait(0.5)\n\n # Plot the function curve\n self.play(Create(graph), Write(func_label))\n self.wait(0.5)\n\n # Highlight the region of interest\n self.play(Create(boundary_line), Write(boundary_label))\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # Display the integral expression\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Animate the calculation steps by transforming the equation\n # Step 1 -> Step 2: Find Antiderivative\n self.play(Transform(integral_expr, antiderivative_expr))\n self.wait(1)\n\n # Step 2 -> Step 3: Evaluate Limits\n self.play(Transform(integral_expr, evaluation_expr))\n self.wait(1)\n\n # Step 3 -> Step 4: Final Result\n self.play(Transform(integral_expr, result_expr))\n self.wait(1)\n\n # Final Emphasis: Highlight the area and the solution\n self.play(\n area.animate.set_opacity(0.8),\n integral_expr.animate.set_color(YELLOW).scale(1.1)\n )\n self.wait(2)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql filename.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n An educational animation demonstrating the calculation of the area \n under the curve f(x) = x^2 from x=0 to x=2.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Scene Setup: Initialize Coordinate System\n # ------------------------------------------------------------------\n # Create axes with appropriate ranges for f(x) = x^2 from 0 to 2\n # x_range covers 0 to 3 to provide context beyond the integration limit\n # y_range covers 0 to 5 since 2^2 = 4\n axes = Axes(font_size=24, \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},\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 # Add specific tick numbers for clarity\n x_ticks = axes.get_x_axis().add_numbers([1, 2])\n y_ticks = axes.get_y_axis().add_numbers([1, 2, 3, 4])\n\n # ------------------------------------------------------------------\n # 2. Function Plotting: Graph f(x) = x^2\n # ------------------------------------------------------------------\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 2.5], color=BLUE)\n func_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n\n # ------------------------------------------------------------------\n # 3. Region Shading: Area under the curve from x=0 to x=2\n # ------------------------------------------------------------------\n # Create the shaded region representing the definite integral\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n \n # Vertical line to mark the boundary at x=2\n boundary_line = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY, line_func=Line)\n boundary_label = MathTex(\"x=2\").next_to(boundary_line, UP, buff=0.1).set_size(0.7)\n\n # ------------------------------------------------------------------\n # 4. Mathematical Notation: Step-by-Step Calculation\n # ------------------------------------------------------------------\n # Define the steps of the integration process\n # Step 1: The definite integral expression\n integral_expr = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n \n # Step 2: The antiderivative\n antiderivative_expr = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n \n # Step 3: Evaluation at limits\n evaluation_expr = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n \n # Step 4: Final exact numeric solution and approximation\n result_expr = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n # Position the math equations on the right side of the screen\n # We align them to the same position to allow smooth transformation\n math_group = VGroup(integral_expr, antiderivative_expr, evaluation_expr, result_expr)\n math_group.to_edge(RIGHT)\n math_group.shift(UP * 1.5)\n\n # Ensure all subsequent equations start at the same position as the first\n # This ensures the Transform animation morphs them in place\n target_position = integral_expr.get_center()\n antiderivative_expr.move_to(target_position)\n evaluation_expr.move_to(target_position)\n result_expr.move_to(target_position)\n\n # ------------------------------------------------------------------\n # 5. Educational Flow: Animation Sequence\n # ------------------------------------------------------------------\n \n # Draw the coordinate system\n self.play(Create(axes), Write(x_label), Write(y_label), Write(x_ticks), Write(y_ticks))\n self.wait(0.5)\n\n # Plot the function curve\n self.play(Create(graph), Write(func_label))\n self.wait(0.5)\n\n # Highlight the region of interest\n self.play(Create(boundary_line), Write(boundary_label))\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # Display the integral expression\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Animate the calculation steps by transforming the equation\n # Step 1 -> Step 2: Find Antiderivative\n self.play(Transform(integral_expr, antiderivative_expr))\n self.wait(1)\n\n # Step 2 -> Step 3: Evaluate Limits\n self.play(Transform(integral_expr, evaluation_expr))\n self.wait(1)\n\n # Step 3 -> Step 4: Final Result\n self.play(Transform(integral_expr, result_expr))\n self.wait(1)\n\n # Final Emphasis: Highlight the area and the solution\n self.play(\n area.animate.set_opacity(0.8),\n integral_expr.animate.set_color(YELLOW).scale(1.1)\n )\n self.wait(2)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql filename.py AreaUnderCurve\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation using ManimCE that visualizes a simple convolutional neural network with alternating convolutional layers and pooling layers? The network should start with a convolutional layer that has 6 feature maps and a 3x3 kernel, then a pooling layer, followed by another convolutional layer with 16 feature maps and a 3x3 kernel, and ending with a final pooling layer. The animation should show the construction of this neural network.", "chosen": "```python\nfrom manim import *\n\nclass ConvolutionNetwork(Scene):\n def construct(self):\n title = Text(\"A Simple CNN\", font_size=36)\n self.play(Write(title))\n conv_layer1 = RoundedRectangle(width=7, height=2.8, corner_radius=0.1, color=BLUE).shift(LEFT*3 + DOWN*1)\n pool_layer1 = RoundedRectangle(width=7, height=1.5, corner_radius=0.1, color=YELLOW).next_to(conv_layer1, DOWN, buff=0.5)\n \n # Create grid for the first convolutional layer\n filters1 = VGroup()\n for i in range(6):\n filter_rect = Rectangle(height=1.5, width=2, fill_opacity=0.8, color=WHITE, fill_color=GREEN).shift(RIGHT*(i%3-1) + UP*(1-(i//3)))\n labels = VGroup(Text(f\"F{i}\", font_size=20, color=BLACK)).move_to(filter_rect.get_center())\n filters1.add(VGroup(filter_rect, labels))\n\n text1 = Tex(\"$\\\\text{Conv}(F=6, K=3 \\\\times 3)$\", font_size=24).to_edge(UP)\n\n self.play(Create(text1))\n self.play(FadeIn(filters1, shift=RIGHT))\n self.play(Create(conv_layer1), FadeIn(pool_layer1, shift=DOWN))\n \n conv_layer2 = RoundedRectangle(width=7, height=3.8, corner_radius=0.1, color=BLUE).shift(RIGHT*3 + DOWN*1)\n pool_layer2 = RoundedRectangle(width=7, height=2.5, corner_radius=0.1, color=YELLOW).next_to(conv_layer2, DOWN, buff=0.5)\n \n # Create grid for the second convolutional layer\n filters2 = VGroup()\n for i in range(16):\n filter_rect = Rectangle(height=1.5, width=2, fill_opacity=0.8, color=WHITE, fill_color=RED).shift(RIGHT*((i%4)-1) + UP*(1-(i//4)*2))\n labels = VGroup(Text(f\"K{i}\", font_size=18, color=BLACK)).move_to(filter_rect.get_bottom())\n filters2.add(VGroup(filter_rect, labels))\n\n text2 = Tex(\"$\\\\text{Conv}(F=16, K=3 \\\\times 3)$\", font_size=24).to_edge(UP)\n\n self.play(Transform(text1, text2))\n self.play(FadeIn(filters2, scale=0.8))\n self.play(Create(conv_layer2), FadeIn(pool_layer2, shift=DOWN))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CNNVisualization(Scene):\n def construct(self):\n # --- Color Palette ---\n conv_color = BLUE\n pool_color = GREEN\n text_color = WHITE\n \n # --- Layer Parameters ---\n \n # First Convolutional Layer: Input -> 6 Feature Maps\n input_shape = [8, 8]\n conv1_maps = 6\n conv1_kernel = 3\n conv1_stride = 1\n\n # Pooling Layer 1: Stride=2\n pool1_stride = 2\n pool1_out_shape = [(input_shape[i]-conv1_kernel+i)//pool1_stride + 1 for i in range(2)]\n\n # Second Convolutional Layer: 6 -> 16 Feature Maps\n conv2_maps = 16\n conv2_stride = 1\n\n # Pooling Layer 2: Stride=2\n pool2_stride = 2\n pool2_out_shape = [(pool1_out_shape[i]-conv2_kernel+i)//pool2_stride + 1 for i in range(2)]\n \n\n # --- Create Visualization Elements ---\n\n # Function to render grid elements based on shape\n def render_grid(shape, color, label_text=None):\n cells = VGroup()\n \n # Draw Grid Cells\n for row_idx in range(shape[0]):\n for col_idx in range(shape[1]):\n cell_rect = Rectangle(\n width=1, \n height=1, \n stroke_width=2,\n fill_opacity=0,\n stroke_color=color,\n ).shift(RIGHT*col_idx + UP*(shape[0]-row_idx-1))\n \n cells.add(cell_rect)\n \n if label_text is not None:\n # Add Label at Bottom Center\n label = Text(label_text, font_size=20).to_edge(DOWN).set_color(text_color)\n \n return VGroup(cells, label)\n else:\n return cells\n \n \n\n # Render Input Image\n input_label = Text(\"Input Image\", font_size=20).set_color(conv_color).to_edge(UP)\n input_grid = render_grid(input_shape, CONTOUR_COLOR, \"Input\")\n \n # Render First Convolutional Layer\n conv1_title = Text(\"Conv 1: 6 Map Channels\", font_size=20, color=CONTOUR_COLOR).next_to(input_label, DOWN, buff=0.5)\n \n # Place each map individually so we can animate them sequentially\n conv1_layers = []\n for m in range(conv1_maps):\n conv_layer = render_grid([7, 7], conv_color, f\"Map {m}\")\n conv1_layers.append(conv_layer)\n\n # Render First Pooling Layer\n pool1_title = Text(\"Pool 1: Stride 2\", font_size=20, color=pool_color).next_to(conv1_title, DOWN, buff=0.5)\n pool1_grid = render_grid(pool1_out_shape, pool_color, \"Pooled\")\n\n # Render Second Convolutional Layer\n conv2_title = Text(\"Conv 2: 16 Map Channels\", font_size=20, color=conTOUR_COLOR).next_to(pool1_title, DOWN, buff=0.5)\n conv2_layers = []\n for m in range(conv2_maps):\n conv_layer = render_grid([3, 3], conv_color, f\"Map {m}\")\n conv2_layers.append(conv_layer)\n\n # Render Final Pooling Layer\n pool2_title = Text(\"Final Pool\", font_size=20, color=pool_color).next_to(conv2_title, DOWN, buff=0.5)\n final_pool_grid = render_grid(pool2_out_shape, pool_color, \"Output\")\n\n\n # --- Animation Sequence ---\n\n self.play(FadeIn(input_label))\n self.play(Create(input_grid[0]))\n self.wait(0.5)\n \n # Animate first convolutional layer appearance\n self.play(Write(conv1_title))\n for map_group in conv1_layers:\n self.play(Create(map_group[0]), run_time=0.2) # Create grid\n self.play(Write(map_group[1])) # Write labels\n self.wait(0.5)\n \n # Move to pooling step\n self.play(FadeIn(pool1_title, shift=DOWN))\n self.play(Create(pool1_grid[0]))\n self.wait(0.5)\n \n # Show second convolutional layer\n self.play(Write(conv2_title))\n for map_group in conv2_layers:\n self.play(Create(map_group[0]), run_time=0.2)\n self.play(Write(map_group[1]))\n self.wait(0.5)\n \n # Move to last pooling step\n self.play(FadeIn(pool2_title, shift=DOWN))\n self.play(Create(final_pool_grid[0]))\n \n # Display full architecture path from beginning to end\n arrow_input_conv1 = Arrow(start=input_grid.get_right(), end=conv1_layers[0].get_left())\n arrow_conv1_pool1 = Arrow(start=conv1_layers[-1].get_right(), end=pool1_grid.get_left())\n arrow_pool1_conv2 = Arrow(start=pool1_grid.get_right(), end=conv2_layers[0].get_left())\n arrow_conv2_pool2 = Arrow(start=conv2_layers[-1].get_right(), end=final_pool_grid.get_left())\n\n self.play(GrowArrow(arrow_input_conv1), GrowArrow(arrow_conv1_pool1), GrowArrow(arrow_pool1_conv2), GrowArrow(arrow_conv2_pool2))\n\n self.wait(1)\n\n# To run this code:\n# manim -pql filename.py CNNVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass IntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n problem = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", r\" \\, dx\",\n font_size=60,\n color=WHITE\n )\n \n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Explanation Text ---\n explanation_text = Tex(\"Evaluating this definite integral gives us:\", \n tex_to_color_map={\"integral\": YELLOW})\n explanation_text.to_edge(DOWN)\n \n self.play(Write(explanation_text))\n self.wait(1)\n\n # --- Step 3: Power Rule Formula ---\n power_rule = MathTex(\n r\"\\int x^n \\, dx =\", r\"\\frac{x^{n+1}}{n+1}\",\n font_size=48,\n color=BLUE\n ).to_edge(UP)\n\n self.play(Write(power_rule))\n self.wait(1)\n\n # Highlight the specific case where n=2\n box = SurroundingRectangle(VGroup(power_rule[1][0], power_rule[1][2]), buff=0.1)\n self.play(Create(box))\n self.wait(2)\n\n # Clear the intermediate steps for clarity before moving on\n self.play(FadeOut(problem), FadeOut(explanation_text), FadeOut(power_rule))\n\n # Show the antiderivative explicitly\n antideriv = MathTex(\n r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{1}\",\n font_size=72\n )\n antideriv.move_to(ORIGIN)\n\n self.play(Write(antideriv))\n self.wait(1)\n\n # --- Step 4: Apply Limits (Substitution) ---\n substituted = MathTex(\n r\"\\frac{1^3}{3} - \\frac{0^3}{3}\",\n font_size=72\n )\n\n self.play(TransformMatchingTex(antideriv, substituted))\n self.wait(1)\n\n # --- Step 5: Solution Calculation ---\n calculated_value = MathTex(\n r\"\\frac{1}{3} - 0 = \\frac{1}{3}\",\n font_size=72\n )\n\n self.play(TransformMatchingTex(substituted, calculated_value))\n self.wait(2)\n\n # Final Answer Box\n result_box = RoundedRectangle(\n width=2.5, height=1.5, corner_radius=0.3,\n fill_opacity=0.2, stroke_width=2\n )\n result_box.center().shift(UP * 1.5 + LEFT * 3)\n\n final_answer = MathTex(\n r\"\\text{Final Area } A = \", r\"\\frac{1}{3}\",\n font_size=72, color=YELLOW\n )\n final_answer.next_to(result_box, DOWN, buff=0.3).align_to(final_answer[0], LEFT)\n\n self.add(result_box)\n self.play(Write(final_answer))\n self.wait(2)\n\n # --- Conclusion Sequence ---\n # Clear all intermediate steps\n intermediate_steps = VGroup(\n problem, explanation_text, power_rule,\n antideriv, substituted, calculated_value,\n result_box, final_answer\n )\n \n self.play(FadeOut(intermediate_steps))\n\n # Re-present only the final solution and explanation\n final_solution = MathTex(\n r\"A = \\frac{1}{3}\"\n ).scale(2).set_color(YELLOW)\n\n final_explanation = Tex(\n \"This numerical value represents the area under the curve $f(x)=x^2$ between $x=0$ and $x=1$.\"\n ).scale(0.7).next_to(final_solution, DOWN, buff=0.5)\n\n self.play(Write(final_solution))\n self.play(Write(final_explanation))\n\n # Hold at the conclusion for emphasis\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Integral ---\n integral_expr = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\\\, dx\"\n ).scale(1.5)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # --- Step 2: Explanation Text ---\n text_explanation1 = Tex(\"Evaluating this definite integral appears\").to_edge(DOWN).shift(UP*0.5)\n text_rule = Tex(\"\\\\text{General Power Rule: } \\\\int x^n\\\\, dx = \\\\frac{x^{n+1}}{n+1}\").next_to(text_explanation1, DOWN, buff=0.3)\n \n self.play(Write(text_explanation1))\n self.wait(1)\n self.play(FadeIn(text_rule, shift=DOWN))\n self.wait(2)\n\n # Fade out the rule text so it doesn't clutter the screen during calculations\n self.play(FadeOut(text_rule))\n\n # --- Step 3: Show Calculations ---\n calc_step1 = MathTex(\n r\"=\", \"[\", \"(1)^{2+1}\", \"/\", \"(2+1)\", \"]\",\n \"-\", \"[\", \"(0)^{2+1}\", \"/\", \"(2+1)\", \"]\"\n ).next_to(integral_expr, RIGHT, buff=0.5).set_color(YELLOW)\n \n self.play(Write(calc_step1))\n self.wait(1)\n\n # Simplify the exponentials\n calc_simplified = MathTex(\n r\"=\", \"[\", \"1^3\", \"/\", \"3\", \"]\",\n \"- [\", \"0^3\", \"/\", \"3\", \"]\"\n ).move_to(calc_step1)\n \n self.play(ReplacementTransform(calc_step1, calc_simplified))\n self.wait(1)\n\n # Final Substitution Values\n calc_substituted = MathTex(\n r\"=\", \"[\", \"1\", \"/\", \"3\", \"]\",\n \"- [\", \"0\", \"/\", \"3\", \"]\"\n ).move_to(calc_simplified)\n \n self.play(ReplacementTransform(calc_simplified, calc_substituted))\n self.wait(1)\n\n # --- Step 4: Transform to Solution ---\n calc_solution = MathTex(\n r\"=\", r\"\\frac{1}{3}\", \"-\", r\"\\frac{0}{3}\"\n ).move_to(calc_substituted)\n \n self.play(TransformMatchingTex(calc_substituted, calc_solution))\n self.wait(1)\n\n # Calculate Arithmetic Result\n calc_result = MathTex(\n r\"=\", r\"\\frac{1}{3}\" \n ).move_to(calc_solution)\n self.play(ReplacementTransform(calc_solution, calc_result))\n self.wait(1)\n\n # --- Step 5: Present Final Answer ---\n final_answer_text = Tex(\"$A$ represents the Area under the Curve\")\n final_group = VGroup(calc_result, final_answer_text).arrange(RIGHT, buff=0.6)\n box = SurroundingRectangle(final_group, color=YELLOW, buff=0.3)\n \n self.play(\n FadeOut(integral_expr),\n FadeOut(text_explanation1),\n FadeOut(box)\n )\n self.play(Write(final_answer_text))\n self.play(Create(box))\n self.wait(2)\n\n # Clear Everything Before Conclusion\n self.play(FadeOut(VGroup(*all_mobs)))\n\n # --- Step 6: Strong Conclusion ---\n final_conclusion = MathTex(\n r\"A\", \"=\", r\"\\frac{1}{3}\",\n tex_to_color_map={\"A\": BLUE}\n ).scale(1.8).center()\n final_label = Tex(\"Area Under the Curve from $x=0$ to $x=1$\")\n \n self.play(Write(final_conclusion))\n self.play(Write(final_label.next_to(final_conclusion, DOWN)))\n self.wait(3)\n\n# To run this code, save it as a .py file and execute via 'manim filename.py DefiniteIntegralSolution'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an animation where a piece of text transforms into the words \"AnimatedBoundary\" and moves towards the top of the screen, followed by a circle appearing with a colorful boundary that cycles through red, gre\n- Act 2: Can you create an educational animation that illustrates the principles of circular motion and tension involved, starting with the general equation of motion under gravity, explaining the relevant terms, then transformin", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0768(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_animatedboundaryscene()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_animatedboundaryscene(self):\n initial_text = Text(\"Transform\", font_size=48)\n target_text = Text(\"AnimatedBoundary\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 2. Movement\n # Move the transformed text towards the top of the screen\n self.play(target_text.animate.to_edge(UP, buff=0.5), run_time=1.5)\n \n # 3. Circle Appearance\n # Spawn a circle with a thick stroke for a visible boundary animation\n circle = Circle(radius=2.0, stroke_width=12)\n circle.time = 0 # Initialize a time attribute for the updater\n \n self.play(Create(circle))\n \n # 4. Color Cycling\n # Define an updater to cycle quickly through red, green, and blue\n def cycle_rgb(mob, dt):\n mob.time += dt * 4 # Multiplier controls the speed of the color cycling\n # Generate smooth RGB values using sine waves offset by 120 degrees\n r = abs(np.sin(mob.time))\n g = abs(np.sin(mob.time + 2 * np.pi / 3))\n b = abs(np.sin(mob.time + 4 * np.pi / 3))\n mob.set_stroke(color=rgb_to_color([r, g, b]))\n \n circle.add_updater(cycle_rgb)\n \n # Allow the animation to display for a short duration\n self.wait(2.5)\n \n # 5. Fade Out\n # Remove the updater for a clean exit, then fade out both objects\n circle.remove_updater(cycle_rgb)\n self.play(FadeOut(target_text), FadeOut(circle))\n self.wait(1)\n\n def act_2_areaundercurve(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0768(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_animatedboundaryscene()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_animatedboundaryscene(self):\n initial_text = Text(\"Transform\", font_size=48)\n target_text = Text(\"AnimatedBoundary\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 2. Movement\n # Move the transformed text towards the top of the screen\n self.play(target_text.animate.to_edge(UP, buff=0.5), run_time=1.5)\n \n # 3. Circle Appearance\n # Spawn a circle with a thick stroke for a visible boundary animation\n circle = Circle(radius=2.0, stroke_width=12)\n circle.time = 0 # Initialize a time attribute for the updater\n \n self.play(Create(circle))\n \n # 4. Color Cycling\n # Define an updater to cycle quickly through red, green, and blue\n def cycle_rgb(mob, dt):\n mob.time += dt * 4 # Multiplier controls the speed of the color cycling\n # Generate smooth RGB values using sine waves offset by 120 degrees\n r = abs(np.sin(mob.time))\n g = abs(np.sin(mob.time + 2 * np.pi / 3))\n b = abs(np.sin(mob.time + 4 * np.pi / 3))\n mob.set_stroke(color=rgb_to_color([r, g, b]))\n \n circle.add_updater(cycle_rgb)\n \n # Allow the animation to display for a short duration\n self.wait(2.5)\n \n # 5. Fade Out\n # Remove the updater for a clean exit, then fade out both objects\n circle.remove_updater(cycle_rgb)\n self.play(FadeOut(target_text), FadeOut(circle))\n self.wait(1)\n\n def act_2_areaundercurve(self):\n axes = Axes(font_size=24, \n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can we model the process of finding a derangement of n distinct elements using a graphical representation?", "chosen": "```python\nfrom manim import *\n\nclass DerangementsScene(Scene):\n def construct(self):\n # Title screen\n title = Text(\"Exploring Permutations and Derangements\", font_size=36)\n subtitle = Text(\"A Graphical Journey\", font_size=28).next_to(title, DOWN)\n \n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Introduction to the concept\n intro_text = Text(\"Imagine a hat with n unique colored balls...\", font_size=28)\n self.play(Write(intro_text))\n self.wait(1.5)\n self.play(FadeOut(intro_text))\n \n # Create nodes representing the elements (n=4 for simplicity)\n n = 4\n radius = 2 # Radius of the circle on which nodes are placed\n node_radius = 0.3 # Radius of each node\n node_colors = [RED, BLUE, GREEN, YELLOW]\n \n # Create circles for nodes\n circles = []\n numbers = []\n node_positions = []\n \n # Position nodes in a circular arrangement\n for i in range(n):\n angle = i * (2 * PI / n) # Dividing the circle into n equal parts\n position = radius * np.array([np.cos(angle), np.sin(angle), 0])\n node_positions.append(position)\n \n # Create the circle and number separately\n circle = Circle(radius=node_radius, color=node_colors[i]).move_to(position)\n number = Text(str(i+1), font_size=24).move_to(position)\n \n circles.append(circle)\n numbers.append(number)\n \n # Group circles and numbers\n circles_group = VGroup(*circles)\n numbers_group = VGroup(*numbers)\n \n # Create the nodes\n self.play(Create(circles_group))\n self.play(Write(numbers_group))\n self.wait(1)\n \n # Explanation text for nodes\n nodes_text = Text(\"These colored nodes represent our elements\", font_size=28)\n self.play(Write(nodes_text))\n self.wait(1)\n self.play(FadeOut(nodes_text))\n \n # Showing all permutation paths\n perm_text = Text(\"All possible permutation paths\", font_size=28)\n self.play(Write(perm_text))\n self.wait(1)\n self.play(FadeOut(perm_text))\n \n # Draw lines between all pairs of nodes to show permutations\n permutation_lines = []\n for i in range(n):\n for j in range(n):\n # Include all possible connections\n start_pos = node_positions[i]\n end_pos = node_positions[j]\n \n # Create a curved line for better visibility\n if i != j: # Only draw lines between different nodes\n line = Line(\n start_pos, \n end_pos,\n stroke_opacity=0.3\n )\n permutation_lines.append(line)\n \n # Create all permutation lines\n perm_lines_group = VGroup(*permutation_lines)\n self.play(Create(perm_lines_group))\n self.wait(1)\n \n # Highlight derangements concept\n derangement_text = Text(\"In derangements, no element stays in place\", font_size=28)\n self.play(Write(derangement_text))\n self.wait(1)\n self.play(FadeOut(derangement_text))\n \n # Remove the permutation lines\n self.play(FadeOut(perm_lines_group))\n \n # Show a specific derangement example\n # Derangement: 1->2, 2->3, 3->4, 4->1\n # In 0-indexed: 0->1, 1->2, 2->3, 3->0\n derangement_indices = [1, 2, 3, 0]\n \n # Create arrows for the derangement\n arrows = []\n for i in range(n):\n j = derangement_indices[i]\n \n # Calculate start and end positions with offset to avoid overlapping with nodes\n start_pos = node_positions[i]\n end_pos = node_positions[j]\n \n # Create an arrow\n arrow = Arrow(\n start=start_pos, \n end=end_pos,\n buff=node_radius, # Leave space for the node\n color=YELLOW\n )\n arrows.append(arrow)\n \n # Create all arrows in sequence\n for arrow in arrows:\n self.play(Create(arrow), run_time=0.5)\n self.wait(1)\n \n # Group all arrows\n arrows_group = VGroup(*arrows)\n \n # Explanation of the derangement\n cycle_text = Text(\"This forms a single cycle derangement\", font_size=28)\n self.play(Write(cycle_text))\n self.wait(1)\n self.play(FadeOut(cycle_text))\n \n # Showing the equation for counting derangements\n self.play(FadeOut(arrows_group))\n \n equation_text = Text(\"The formula for counting derangements:\", font_size=28)\n self.play(Write(equation_text))\n self.wait(1)\n self.play(FadeOut(equation_text))\n \n # Display the formula\n equation = MathTex(r\"D(n) = n! \\sum_{i=0}^{n} \\frac{(-1)^i}{i!}\")\n self.play(Write(equation))\n self.wait(1.5)\n self.play(FadeOut(equation))\n \n # Display the recurrence relation\n recurrence_text = Text(\"Or the recurrence relation:\", font_size=28)\n self.play(Write(recurrence_text))\n self.wait(1)\n self.play(FadeOut(recurrence_text))\n \n recurrence_eq = MathTex(r\"a_{n} = (n-1)(a_{n-1} + a_{n-2})\")\n self.play(Write(recurrence_eq))\n self.wait(1.5)\n self.play(FadeOut(recurrence_eq))\n \n # Conclusion\n conclusion = Text(\"Beauty in combinatorial chaos\", font_size=32)\n self.play(\n FadeOut(circles_group),\n FadeOut(numbers_group),\n Write(conclusion)\n )\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass DerangementsScene(Scene):\n def construct(self):\n # Title screen\n title = Text(\"Exploring Permutations and Derangements\", font_size=36)\n subtitle = Text(\"A Graphical Journey\", font_size=28).next_to(title, DOWN)\n \n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Introduction to the concept\n intro_text = Text(\"Imagine a hat with n unique colored balls...\", font_size=28)\n self.play(Write(intro_text))\n self.wait(1.5)\n self.play(FadeOut(intro_text))\n \n # Create nodes representing the elements (n=4 for simplicity)\n n = 4\n radius = 2 # Radius of the circle on which nodes are placed\n node_radius = 0.3 # Radius of each node\n node_colors = [RED, BBLUE, GREEN, YELLOW]\n \n # Create circles for nodes\n circles = []\n numbers = []\n node_positions = []\n \n # Position nodes in a circular arrangement\n for i in range(n):\n angle = i * (2 * PI / n) # Dividing the circle into n equal parts\n position = radius * np.array([np.cos(angle), np.sin(angle), 0])\n node_positions.append(position)\n \n # Create the circle and number separately\n circle = Circle(radius=node_radius, color=node_colors[i]).move_to(position)\n number = Text(str(i+1), font_size=24).move_to(position)\n \n circles.append(circle)\n numbers.append(number)\n \n # Group circles and numbers\n circles_group = VGroup(*circles)\n numbers_group = VGroup(*numbers)\n \n # Create the nodes\n self.play(Create(circles_group))\n self.play(Write(numbers_group))\n self.wait(1)\n \n # Explanation text for nodes\n nodes_text = Text(\"These colored nodes represent our elements\", font_size=28)\n self.play(Write(nodes_text))\n self.wait(1)\n self.play(FadeOut(nodes_text))\n \n # Showing all permutation paths\n perm_text = Text(\"All possible permutation paths\", font_size=28)\n self.play(Write(perm_text))\n self.wait(1)\n self.play(FadeOut(perm_text))\n \n # Draw lines between all pairs of nodes to show permutations\n permutation_lines = []\n for i in range(n):\n for j in range(n):\n # Include all possible connections\n start_pos = node_positions[i]\n end_pos = node_positions[j]\n \n # Create a curved line for better visibility\n if i != j: # Only draw lines between different nodes\n line = Line(\n start_pos, \n end_pos,\n stroke_opacity=0.3\n )\n permutation_lines.append(line)\n \n # Create all permutation lines\n perm_lines_group = VGroup(*permutation_lines)\n self.play(Create(perm_lines_group))\n self.wait(1)\n \n # Highlight derangements concept\n derangement_text = Text(\"In derangements, no element stays in place\", font_size=28)\n self.play(Write(derangement_text))\n self.wait(1)\n self.play(FadeOut(derangement_text))\n \n # Remove the permutation lines\n self.play(FadeOut(perm_lines_group))\n \n # Show a specific derangement example\n # Derangement: 1->2, 2->3, 3->4, 4->1\n # In 0-indexed: 0->1, 1->2, 2->3, 3->0\n derangement_indices = [1, 2, 3, 0]\n \n # Create arrows for the derangement\n arrows = []\n for i in range(n):\n j = derangement_indices[i]\n \n # Calculate start and end positions with offset to avoid overlapping with nodes\n start_pos = node_positions[i]\n end_pos = node_positions[j]\n \n # Create an arrow\n arrow = Arrow(\n start=start_pos, \n end=end_pos,\n buff=node_radius, # Leave space for the node\n color=YELLOW\n )\n arrows.append(arrow)\n \n # Create all arrows in sequence\n for arrow in arrows:\n self.play(Create(arrow), run_time=0.5)\n self.wait(1)\n \n # Group all arrows\n arrows_group = VGroup(*arrows)\n \n # Explanation of the derangement\n cycle_text = Text(\"This forms a single cycle derangement\", font_size=28)\n self.play(Write(cycle_text))\n self.wait(1)\n self.play(FadeOut(cycle_text))\n \n # Showing the equation for counting derangements\n self.play(FadeOut(arrows_group))\n \n equation_text = Text(\"The formula for counting derangements:\", font_size=28)\n self.play(Write(equation_text))\n self.wait(1)\n self.play(FadeOut(equation_text))\n \n # Display the formula\n equation = MathTex(r\"D(n) = n! \\sum_{i=0}^{n} \\frac{(-1)^i}{i!}\")\n self.play(Write(equation))\n self.wait(1.5)\n self.play(FadeOut(equation))\n \n # Display the recurrence relation\n recurrence_text = Text(\"Or the recurrence relation:\", font_size=28)\n self.play(Write(recurrence_text))\n self.wait(1)\n self.play(FadeOut(recurrence_text))\n \n recurrence_eq = MathTex(r\"a_{n} = (n-1)(a_{n-1} + a_{n-2})\")\n self.play(Write(recurrence_eq))\n self.wait(1.5)\n self.play(FadeOut(recurrence_eq))\n \n # Conclusion\n conclusion = Text(\"Beauty in combinatorial chaos\", font_size=32)\n self.play(\n FadeOut(circles_group),\n FadeOut(numbers_group),\n Write(conclusion)\n )\n self.wait(2)\n self.play(FadeOut(conclusion))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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: I would like to create an animation where the word \"Inscribe\" appears on the screen and then transitions to say \"Inscribe a Square\" and moves downwards. Next, a square should be drawn surrounding the words. After a short", "chosen": "```python\n# Multi-ACT Masterpiece\n\nfrom manim import *\n\nclass MultiActMasterpiece(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n # --- ACT 1: Successive Texts ---\n \n # Create three sequential text blocks\n text_a = Text(\"This is a sample\", font_size=36)\n text_b = Text(\"of different sizes\", font_size=32)\n text_c = Text(\"with highlighting\", font_size=28)\n\n # Group them vertically with spacing for visual separation\n group = VGroup(text_a, text_b, text_c).arrange(DOWN, buff=1)\n\n # Animate their appearance sequentially\n self.play(Write(text_a), run_time=1.5)\n self.play(Write(text_b), run_time=1.5)\n self.play(Write(text_c), run_time=1.5)\n self.wait(1)\n\n # Add rectangular borders around each text block\n rect_a = SurroundingRectangle(text_a, color=BLUE, buff=0.2)\n rect_b = SurroundingRectangle(text_b, color=GREEN, buff=0.2)\n rect_c = SurroundingRectangle(text_c, color=RED, buff=0.2)\n\n # Highlight simultaneously\n self.play(Create(rect_a), Create(rect_b), Create(rect_c), run_time=1.5)\n self.wait(2)\n\n # Fade everything out cleanly\n self.play(\n FadeOut(group),\n FadeOut(rect_a),\n FadeOut(rect_b),\n FadeOut(rect_c),\n run_time=1\n )\n\n # Stage transition\n self.wait(1) # Brief pause before transitioning to Act 2\n self.clear_stage()\n\n # --- ACT 2: Word Transformation ---\n \n # Initial text appearing on screen\n initial_text = Text(\"Inscribe\", font_size=72)\n self.play(Write(initial_text), run_time=1.5)\n self.wait(0.5)\n\n # Transition to new wording and movement\n final_text = Text(\"Inscribe a Square\", font_size=72)\n self.play(\n ReplacementTransform(initial_text, final_text),\n final_text.animate.shift(DOWN * 1.5),\n run_time=1.5\n )\n self.wait(1)\n\n # Draw a blue square surrounding the written text\n box = SurroundingRectangle(final_text, color=BLUE, buff=0.3)\n self.play(Create(box), run_time=1.5)\n self.wait(1)\n\n # Short pause at the end of the second act\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0768(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0)\n\n def construct(self):\n # --- ACT 1 ---\n self.act_1_highlightedtexts()\n \n # Transition: Fade out everything from Act 1\n self.fade_out_all()\n\n # --- ACT 2 ---\n self.act_2_inscribesquareanimation()\n\n def fade_out_all(self):\n # Create a group of all current mobjects\n all_mobs = VGroup(*self.mobjects)\n if all_mobs:\n self.play(FadeOut(all_mobs))\n\n def act_1_highlightedtexts(self):\n text1 = Text(\"This is a sample\", font_size=36).to_edge(UP)\n rect1 = SurroundingRectangle(text1, color=YELLOW, buff=MED_LARGE_BUFF)\n\n text2 = Text(\"of highlighted\", font_size=36).next_to(rect1, DOWN, buff=LARGE_BUFF)\n rect2 = SurroundingRectangle(text2, color=BLUE, buff=MED_LARGE_BUFF)\n\n text3 = Text(\"text groups.\", font_size=36).next_to(rect2, DOWN, buff=LARGE_BUFF)\n rect3 = SurroundingRectangle(text3, color=GREEN, buff=MED_SMALL_BUFF)\n\n # Animate the appearance of the texts and their corresponding rectangles\n self.play(Write(text1), Create(rect1))\n self.wait(0.5)\n self.play(Write(text2), Create(rect2))\n self.wait(0.5)\n self.play(Write(text3), Create(rect3))\n self.wait(1)\n\n def act_2_inscribesquareanimation(self):\n initial_text = Text(\"Inscribe\").scale(0.8).shift(UP * 2)\n final_text = Text(\"Inscribe a Square\").scale(0.8).shift(UP * 2)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n \n # Transform the initial text smoothly into the new phrase\n self.play(TransformMatchingText(initial_text, final_text))\n self.wait(0.5)\n \n # Move the transformed text down slightly\n self.play(final_text.animate.shift(DOWN * 1.5))\n self.wait(0.5)\n \n # Draw the square around the text\n box = SurroundingRectangle(final_text, color=RED, buff=0.3)\n self.play(Create(box))\n \n # Add small dots at each corner for visual clarity\n corners = []\n for point in box.get_corners():\n dot = Dot(point, radius=0.05, color=WHITE)\n self.add(dot)\n corners.append(dot)\n \n # Briefly highlight the corners\n self.play(\n *[dot.animate.scale(1.2) for dot in corners],\n run_time=0.5,\n rate_func=there_and_back\n )\n self.wait(0.5)\n \n # Clear the dots after highlighting\n self.remove(*corners)\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Function of the Target Network\n\nThis is an auxiliary network with temporarily fixed parameters, specifically used to calculate the TD target values. By severing the real-time connection between the target values and the current network parameters, it avoids training instability caused by \"chasing a moving target.\"\n\n\nThe context location of this section (from highest to current level):\n# Advanced Techniques in DQN\n## Key Improvement Ideas in DQN\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TargetNetworkFunction(Scene):\n\n def construct(self):\n context_title = Text('Advanced Techniques in DQN', font_size=34, weight=BOLD)\n context_title.to_edge(UP, buff=0.3)\n context_subtitle = Text('Key Improvement Ideas in DQN', font_size=22, color=GRAY)\n context_subtitle.next_to(context_title, DOWN, buff=0.15)\n self.play(Write(context_title))\n self.play(FadeIn(context_subtitle))\n section_title = Text('Function of the Target Network', font_size=28, color=BLUE)\n section_title.next_to(context_subtitle, DOWN, buff=0.4)\n self.play(Write(section_title))\n bp1 = Text('• Auxiliary network with temporarily fixed parameters.', font_size=20)\n bp2 = Text('• Specifically used to calculate the TD target values.', font_size=20)\n bp3 = Text('• Severs real-time connection between target values and current network parameters.', font_size=20)\n bp4 = Text('• Avoids training instability caused by \"chasing a moving target\".', font_size=20)\n bullet_points = VGroup(bp1, bp2, bp3, bp4)\n bullet_points.arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n bullet_points.next_to(section_title, DOWN, buff=0.3)\n for bp in bullet_points:\n self.play(FadeIn(bp, shift=RIGHT * 0.3), run_time=0.6)\n else:\n pass\n main_net_rect = RoundedRectangle(width=3.2, height=1.2, color=GREEN, fill_opacity=0.1, corner_radius=0.2)\n main_net_text = VGroup(Text('Current Network', font_size=18, color=GREEN), Text('(Updates real-time)', font_size=14, color=GRAY)).arrange(DOWN, buff=0.1)\n main_net = VGroup(main_net_rect, main_net_text)\n main_net.move_to(LEFT * 3.5 + DOWN * 2.6)\n target_net_rect = RoundedRectangle(width=3.2, height=1.2, color=RED, fill_opacity=0.1, corner_radius=0.2)\n target_net_text = VGroup(Text('Target Network', font_size=18, color=RED), Text('(Temporarily fixed)', font_size=14, color=GRAY)).arrange(DOWN, buff=0.1)\n target_net = VGroup(target_net_rect, target_net_text)\n target_net.move_to(RIGHT * 3.5 + DOWN * 2.6)\n copy_arrow = Arrow(main_net.get_right(), target_net.get_left(), color=YELLOW, buff=0.2)\n copy_text = Text('Periodic Copy', font_size=14, color=YELLOW).next_to(copy_arrow, UP, buff=0.1)\n td_target_rect = RoundedRectangle(width=2.5, height=0.8, color=BLUE, fill_opacity=0.1, corner_radius=0.2)\n td_target_text = Text('TD Target Value', font_size=18, color=BLUE)\n td_target_box = VGroup(td_target_rect, td_target_text)\n td_target_box.move_to(RIGHT * 3.5 + DOWN * 0.8)\n td_arrow = Arrow(target_net.get_top(), td_target_box.get_bottom(), color=BLUE, buff=0.1)\n td_calc_text = Text('Calculate', font_size=14, color=BLUE).next_to(td_arrow, LEFT, buff=0.1)\n disconnect_line = DashedLine(main_net.get_top(), td_target_box.get_left(), color=GRAY, dash_length=0.1)\n cross = Cross(stroke_color=RED, stroke_width=6).scale(0.2)\n cross.move_to(disconnect_line.get_center())\n disconnect_text = Text('Severed Connection', font_size=14, color=RED).next_to(cross, UP, buff=0.1)\n self.play(FadeIn(main_net), FadeIn(target_net))\n self.play(GrowArrow(copy_arrow), Write(copy_text))\n self.play(FadeIn(td_target_box), GrowArrow(td_arrow), Write(td_calc_text))\n self.play(Create(disconnect_line), Create(cross), Write(disconnect_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TargetNetworkFunction(Scene):\n\n def construct(self):\n context_title = Text('Advanced Techniques in DQN', font_size=34, weight=BOLD)\n context_title.to_edge(UP, buff=0.3)\n context_subtitle = Text('Key Improvement Ideas in DQN', font_size=22, color=GRAY)\n context_subtitle.next_to(context_title, DOWN, buff=0.15)\n self.play(Write(context_title))\n self.play(FadeIn(context_subtitle))\n section_title = Text('Function of the Target Network', font_size=28, color=BBLUE)\n section_title.next_to(context_subtitle, DOWN, buff=0.4)\n self.play(Write(section_title))\n bp1 = Text('• Auxiliary network with temporarily fixed parameters.', font_size=20)\n bp2 = Text('• Specifically used to calculate the TD target values.', font_size=20)\n bp3 = Text('• Severs real-time connection between target values and current network parameters.', font_size=20)\n bp4 = Text('• Avoids training instability caused by \"chasing a moving target\".', font_size=20)\n bullet_points = VGroup(bp1, bp2, bp3, bp4)\n bullet_points.arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n bullet_points.next_to(section_title, DOWN, buff=0.3)\n for bp in bullet_points:\n self.play(FadeIn(bp, shift=RIGHT * 0.3), run_time=0.6)\n else:\n pass\n main_net_rect = RoundedRectangle(width=3.2, height=1.2, color=GREEN, fill_opacity=0.1, corner_radius=0.2)\n main_net_text = VGroup(Text('Current Network', font_size=18, color=GREEN), Text('(Updates real-time)', font_size=14, color=GRAY)).arrange(DOWN, buff=0.1)\n main_net = VGroup(main_net_rect, main_net_text)\n main_net.move_to(LEFT * 3.5 + DOWN * 2.6)\n target_net_rect = RoundedRectangle(width=3.2, height=1.2, color=RED, fill_opacity=0.1, corner_radius=0.2)\n target_net_text = VGroup(Text('Target Network', font_size=18, color=RED), Text('(Temporarily fixed)', font_size=14, color=GRAY)).arrange(DOWN, buff=0.1)\n target_net = VGroup(target_net_rect, target_net_text)\n target_net.move_to(RIGHT * 3.5 + DOWN * 2.6)\n copy_arrow = Arrow(main_net.get_right(), target_net.get_left(), color=YELLOW, buff=0.2)\n copy_text = Text('Periodic Copy', font_size=14, color=YELLOW).next_to(copy_arrow, UP, buff=0.1)\n td_target_rect = RoundedRectangle(width=2.5, height=0.8, color=BLUE, fill_opacity=0.1, corner_radius=0.2)\n td_target_text = Text('TD Target Value', font_size=18, color=BLUE)\n td_target_box = VGroup(td_target_rect, td_target_text)\n td_target_box.move_to(RIGHT * 3.5 + DOWN * 0.8)\n td_arrow = Arrow(target_net.get_top(), td_target_box.get_bottom(), color=BLUE, buff=0.1)\n td_calc_text = Text('Calculate', font_size=14, color=BLUE).next_to(td_arrow, LEFT, buff=0.1)\n disconnect_line = DashedLine(main_net.get_top(), td_target_box.get_left(), color=GRAY, dash_length=0.1)\n cross = Cross(stroke_color=RED, stroke_width=6).scale(0.2)\n cross.move_to(disconnect_line.get_center())\n disconnect_text = Text('Severed Connection', font_size=14, color=RED).next_to(cross, UP, buff=0.1)\n self.play(FadeIn(main_net), FadeIn(target_net))\n self.play(GrowArrow(copy_arrow), Write(copy_text))\n self.play(FadeIn(td_target_box), GrowArrow(td_arrow), Write(td_calc_text))\n self.play(Create(disconnect_line), Create(cross), Write(disconnect_text))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can quasirandom graphs be distinguished from truly random graphs through their eigenvalues?", "chosen": "```python\nfrom manim import *\n\nclass QuasirandomGraphsEigenvalues(Scene):\n def construct(self):\n # Title\n title = Text(\"Quasirandom Graphs through Eigenvalues\")\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Basic eigenvalue equation\n equation = MathTex(\"A \\\\times v = \\\\lambda v\")\n equation.next_to(title, DOWN, buff=0.5)\n self.play(Write(equation))\n self.wait(1)\n \n # Number line for eigenvalue distribution\n number_line = NumberLine(\n x_range=[-3, 3, 1],\n length=8,\n include_numbers=True,\n ).shift(DOWN)\n \n number_line_label = Text(\"Eigenvalue Distribution\", font_size=24)\n number_line_label.next_to(number_line, UP, buff=0.5)\n \n self.play(Create(number_line), Write(number_line_label))\n self.wait(1)\n \n # Random graph eigenvalues (blue dots)\n random_label = Text(\"Random\", color=BLUE, font_size=24)\n random_label.to_edge(LEFT).shift(UP*0.5)\n self.play(Write(random_label))\n \n # Create dots for random graph (clustered near zero)\n random_dots = VGroup()\n for x in [-0.3, 0.1, 0.4, -0.2, 0.3, -0.1, 0.2]:\n dot = Dot(color=BLUE)\n dot.move_to(number_line.number_to_point(x))\n random_dots.add(dot)\n \n self.play(Create(random_dots))\n self.wait(1)\n \n # Quasirandom graph eigenvalues (red dots)\n quasi_label = Text(\"Quasirandom\", color=RED, font_size=24)\n quasi_label.to_edge(RIGHT).shift(UP*0.5)\n self.play(Write(quasi_label))\n \n # Create dots for quasirandom graph (one large outlier)\n quasi_dots = VGroup()\n \n # Largest eigenvalue\n largest_dot = Dot(color=RED)\n largest_dot.move_to(number_line.number_to_point(-2.5))\n \n # Second largest eigenvalue\n second_dot = Dot(color=RED) \n second_dot.move_to(number_line.number_to_point(-1.0))\n \n # Other eigenvalues\n other_dots = VGroup()\n for x in [-0.3, 0.1, 0.3, -0.2, 0.2]:\n dot = Dot(color=RED)\n dot.move_to(number_line.number_to_point(x))\n other_dots.add(dot)\n \n quasi_dots.add(largest_dot, second_dot, other_dots)\n self.play(Create(quasi_dots))\n self.wait(1)\n \n # Spectral gap equation\n spectral_eq = MathTex(\"\\\\lambda_{1} - \\\\lambda_{2} = \\\\text{Spectral gap}\")\n spectral_eq.to_edge(DOWN)\n self.play(Write(spectral_eq))\n self.wait(1)\n \n # Highlight the spectral gap\n gap_arrow = Arrow(\n largest_dot.get_center(), \n second_dot.get_center(), \n buff=0.1,\n color=YELLOW\n )\n gap_label = Text(\"Spectral Gap\", color=YELLOW, font_size=24)\n gap_label.next_to(gap_arrow, UP)\n \n self.play(Create(gap_arrow), Write(gap_label))\n self.wait(1)\n \n # Clean up the scene\n self.play(FadeOut(random_dots, quasi_dots, gap_arrow, gap_label))\n self.play(FadeOut(number_line, number_line_label, random_label, quasi_label))\n self.play(FadeOut(spectral_eq, equation, title))\n \n # Conclusion\n conclusion = Text(\"Quasirandom graphs have larger spectral gaps\")\n self.play(Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass QuasirandomGraphsEigenvalues(Scene):\n def construct(self):\n # Title\n title = Text(\"Quasirandom Graphs through Eigenvalues\")\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Basic eigenvalue equation\n equation = MathTex(\"A \\\\times v = \\\\lambda v\")\n equation.next_to(title, DOWN, buff=0.5)\n self.play(Write(equation))\n self.wait(1)\n \n # Number line for eigenvalue distribution\n number_line = NumberLine(\n x_range=[-3, 3, 1],\n length=8,\n include_numbers=True,\n ).shift(DOWN)\n \n number_line_label = Text(\"Eigenvalue Distribution\", font_size=24)\n number_line_label.next_to(number_line, UP, buff=0.5)\n \n self.play(Create(number_line), Write(number_line_label))\n self.wait(1)\n \n # Random graph eigenvalues (blue dots)\n random_label = Text(\"Random\", color=BBLUE, font_size=24)\n random_label.to_edge(LEFT).shift(UP*0.5)\n self.play(Write(random_label))\n \n # Create dots for random graph (clustered near zero)\n random_dots = VGroup()\n for x in [-0.3, 0.1, 0.4, -0.2, 0.3, -0.1, 0.2]:\n dot = Dot(color=BLUE)\n dot.move_to(number_line.number_to_point(x))\n random_dots.add(dot)\n \n self.play(Create(random_dots))\n self.wait(1)\n \n # Quasirandom graph eigenvalues (red dots)\n quasi_label = Text(\"Quasirandom\", color=RED, font_size=24)\n quasi_label.to_edge(RIGHT).shift(UP*0.5)\n self.play(Write(quasi_label))\n \n # Create dots for quasirandom graph (one large outlier)\n quasi_dots = VGroup()\n \n # Largest eigenvalue\n largest_dot = Dot(color=RED)\n largest_dot.move_to(number_line.number_to_point(-2.5))\n \n # Second largest eigenvalue\n second_dot = Dot(color=RED) \n second_dot.move_to(number_line.number_to_point(-1.0))\n \n # Other eigenvalues\n other_dots = VGroup()\n for x in [-0.3, 0.1, 0.3, -0.2, 0.2]:\n dot = Dot(color=RED)\n dot.move_to(number_line.number_to_point(x))\n other_dots.add(dot)\n \n quasi_dots.add(largest_dot, second_dot, other_dots)\n self.play(Create(quasi_dots))\n self.wait(1)\n \n # Spectral gap equation\n spectral_eq = MathTex(\"\\\\lambda_{1} - \\\\lambda_{2} = \\\\text{Spectral gap}\")\n spectral_eq.to_edge(DOWN)\n self.play(Write(spectral_eq))\n self.wait(1)\n \n # Highlight the spectral gap\n gap_arrow = Arrow(\n largest_dot.get_center(), \n second_dot.get_center(), \n buff=0.1,\n color=YELLOW\n )\n gap_label = Text(\"Spectral Gap\", color=YELLOW, font_size=24)\n gap_label.next_to(gap_arrow, UP)\n \n self.play(Create(gap_arrow), Write(gap_label))\n self.wait(1)\n \n # Clean up the scene\n self.play(FadeOut(random_dots, quasi_dots, gap_arrow, gap_label))\n self.play(FadeOut(number_line, number_line_label, random_label, quasi_label))\n self.play(FadeOut(spectral_eq, equation, title))\n \n # Conclusion\n conclusion = Text(\"Quasirandom graphs have larger spectral gaps\")\n self.play(Write(conclusion))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass GraficoLucroMensal(Scene):\n def construct(self):\n # 1. CONFIGURAÇÃO DE DADOS E ESTILO\n # Dados simulados para Jan-Jun (em Reais)\n meses_labels = [\"Jan\", \"Fev\", \"Mar\", \"Abr\", \"Mai\", \"Jun\"]\n lucros = [2000, 3500, 4200, 6000, 5800, 8500]\n \n # Paleta de Cores\n bg_color = \"#F5F5F5\"\n axis_color = \"#333333\"\n data_color = \"#2E86AB\"\n highlight_color = \"#E67E22\"\n \n self.camera.background_color = bg_color\n\n # Configuração do Plano Cartesiano\n axes = Axes(\n x_range=[0, 6, 1],\n y_range=[0, 9000, 1000],\n x_length=9,\n y_length=6,\n axis_config={\"color\": axis_color, \"include_ticks\": False},\n tips=False\n )\n \n # Grid Auxiliar (Linhas horizontais a cada 1000)\n grid_lines = VGroup()\n for y in range(1000, 9001, 1000):\n line = Line(\n start=axes.c2p(0, y), \n end=axes.c2p(5, y), \n color=axis_color, \n stroke_width=1, \n stroke_opacity=0.3\n )\n grid_lines.add(line)\n \n # Rótulos dos Eixos\n x_labels = VGroup()\n for i, label in enumerate(meses_labels):\n tex = Text(label, font_size=24, color=axis_color)\n tex.next_to(axes.c2p(i, 0), DOWN, buff=0.2)\n x_labels.add(tex)\n \n y_labels = VGroup()\n for i in range(0, 10):\n val = i * 1000\n if val > 0:\n tex = Text(f\"R$ {val/1000}k\", font_size=20, color=\"#666666\")\n tex.next_to(axes.c2p(0, val), LEFT, buff=0.1)\n y_labels.add(tex)\n\n # Título\n title = Text(\"Lucro mensal em reais\", font_size=36, color=axis_color, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n\n # 2. CONSTRUÇÃO DOS ELEMENTOS DE DADOS (Pontos e Linhas)\n dots = VGroup()\n lines = VGroup()\n value_labels = VGroup()\n \n prev_point = None\n for i, lucro in enumerate(lucros):\n point = axes.c2p(i, lucro)\n \n # Ponto (Dot)\n dot = Dot(point, radius=0.08, color=data_color)\n dots.add(dot)\n \n # Label do Valor\n val_text = Text(f\"R$ {lucro}\", font_size=20, color=data_color)\n val_text.next_to(dot, UP, buff=0.1)\n value_labels.add(val_text)\n \n # Linha Conectiva\n if prev_point is not None:\n line = Line(prev_point, point, color=data_color, stroke_width=4)\n lines.add(line)\n \n prev_point = point\n\n # Agrupamento para Highlights\n # Segmento 1: Jan-Fev (Index 0 da lines, 0 e 1 dos dots)\n highlight_group_1 = VGroup(lines[0], dots[0], dots[1], value_labels[0], value_labels[1])\n # Segmento 2: Fev-Abr (Index 1 e 2 da lines, 1, 2 e 3 dos dots)\n highlight_group_2 = VGroup(lines[1], lines[2], dots[1], dots[2], dots[3], value_labels[1], value_labels[2], value_labels[3])\n # Segmento 3: Abr-Jun (Index 3 e 4 da lines, 3, 4 e 5 dos dots)\n highlight_group_3 = VGroup(lines[3], lines[4], dots[3], dots[4], dots[5], value_labels[3], value_labels[4], value_labels[5])\n\n # 3. SEQUÊNCIA DE ANIMAÇÃO\n \n # Passo 1: Intro (Fade in Title, Axes, Grid)\n self.play(\n FadeIn(title), \n Create(axes), \n Create(grid_lines), \n Write(x_labels), \n Write(y_labels), \n run_time=1.5\n )\n self.wait(0.5)\n \n # Passo 2: Data Entry (Revelar ponto a ponto, desenhando as linhas)\n self.play(Create(dots[0]), Write(value_labels[0]), run_time=0.5)\n \n for i in range(1, 6):\n self.play(\n Create(lines[i-1]), \n Create(dots[i]), \n Write(value_labels[i]), \n run_time=0.6\n )\n \n self.wait(1)\n \n # Passo 3: Highlight Sequence\n scale_factor = 1.5\n \n # Highlight 1: Jan-Fev\n self.play(\n highlight_group_1.animate.set_color(highlight_color).set_stroke(width=8),\n dots[0].animate.scale(scale_factor),\n dots[1].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_1.animate.set_color(data_color).set_stroke(width=4),\n dots[0].animate.scale(1/scale_factor),\n dots[1].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n # Highlight 2: Fev-Abr\n self.play(\n highlight_group_2.animate.set_color(highlight_color).set_stroke(width=8),\n dots[1].animate.scale(scale_factor),\n dots[2].animate.scale(scale_factor),\n dots[3].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_2.animate.set_color(data_color).set_stroke(width=4),\n dots[1].animate.scale(1/scale_factor),\n dots[2].animate.scale(1/scale_factor),\n dots[3].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n # Highlight 3: Abr-Jun\n self.play(\n highlight_group_3.animate.set_color(highlight_color).set_stroke(width=8),\n dots[3].animate.scale(scale_factor),\n dots[4].animate.scale(scale_factor),\n dots[5].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_3.animate.set_color(data_color).set_stroke(width=4),\n dots[3].animate.scale(1/scale_factor),\n dots[4].animate.scale(1/scale_factor),\n dots[5].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n self.wait(1)\n \n # Passo 4: Outro (Fade out tudo)\n all_content = VGroup(title, axes, grid_lines, x_labels, y_labels, dots, lines, value_labels)\n self.play(FadeOut(all_content), run_time=1.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass GraficoLucroMensal(Scene):\n def construct(self):\n # 1. CONFIGURAÇÃO DE DADOS E ESTILO\n # Dados simulados para Jan-Jun (em Reais)\n meses_labels = [\"Jan\", \"Fev\", \"Mar\", \"Abr\", \"Mai\", \"Jun\"]\n lucros = [2000, 3500, 4200, 6000, 5800, 8500]\n \n # Paleta de Cores\n bg_color = \"#F5F5F5\"\n axis_color = \"#333333\"\n data_color = \"#2E86AB\"\n highlight_color = \"#E67E22\"\n \n self.camera.background_color = bg_color\n\n # Configuração do Plano Cartesiano\n axes = Axes(label_font_size=24, \n x_range=[0, 6, 1],\n y_range=[0, 9000, 1000],\n x_length=9,\n y_length=6,\n axis_config={\"color\": axis_color, \"include_ticks\": False},\n tips=False\n )\n \n # Grid Auxiliar (Linhas horizontais a cada 1000)\n grid_lines = VGroup()\n for y in range(1000, 9001, 1000):\n line = Line(\n start=axes.c2p(0, y), \n end=axes.c2p(5, y), \n color=axis_color, \n stroke_width=1, \n stroke_opacity=0.3\n )\n grid_lines.add(line)\n \n # Rótulos dos Eixos\n x_labels = VGroup()\n for i, label in enumerate(meses_labels):\n tex = Text(label, font_size=24, color=axis_color)\n tex.next_to(axes.c2p(i, 0), DOWN, buff=0.2)\n x_labels.add(tex)\n \n y_labels = VGroup()\n for i in range(0, 10):\n val = i * 1000\n if val > 0:\n tex = Text(f\"R$ {val/1000}k\", font_size=20, color=\"#666666\")\n tex.next_to(axes.c2p(0, val), LEFT, buff=0.1)\n y_labels.add(tex)\n\n # Título\n title = Text(\"Lucro mensal em reais\", font_size=36, color=axis_color, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n\n # 2. CONSTRUÇÃO DOS ELEMENTOS DE DADOS (Pontos e Linhas)\n dots = VGroup()\n lines = VGroup()\n value_labels = VGroup()\n \n prev_point = None\n for i, lucro in enumerate(lucros):\n point = axes.c2p(i, lucro)\n \n # Ponto (Dot)\n dot = Dot(point, radius=0.08, color=data_color)\n dots.add(dot)\n \n # Label do Valor\n val_text = Text(f\"R$ {lucro}\", font_size=20, color=data_color)\n val_text.next_to(dot, UP, buff=0.1)\n value_labels.add(val_text)\n \n # Linha Conectiva\n if prev_point is not None:\n line = Line(prev_point, point, color=data_color, stroke_width=4)\n lines.add(line)\n \n prev_point = point\n\n # Agrupamento para Highlights\n # Segmento 1: Jan-Fev (Index 0 da lines, 0 e 1 dos dots)\n highlight_group_1 = VGroup(lines[0], dots[0], dots[1], value_labels[0], value_labels[1])\n # Segmento 2: Fev-Abr (Index 1 e 2 da lines, 1, 2 e 3 dos dots)\n highlight_group_2 = VGroup(lines[1], lines[2], dots[1], dots[2], dots[3], value_labels[1], value_labels[2], value_labels[3])\n # Segmento 3: Abr-Jun (Index 3 e 4 da lines, 3, 4 e 5 dos dots)\n highlight_group_3 = VGroup(lines[3], lines[4], dots[3], dots[4], dots[5], value_labels[3], value_labels[4], value_labels[5])\n\n # 3. SEQUÊNCIA DE ANIMAÇÃO\n \n # Passo 1: Intro (Fade in Title, Axes, Grid)\n self.play(\n FadeIn(title), \n Create(axes), \n Create(grid_lines), \n Write(x_labels), \n Write(y_labels), \n run_time=1.5\n )\n self.wait(0.5)\n \n # Passo 2: Data Entry (Revelar ponto a ponto, desenhando as linhas)\n self.play(Create(dots[0]), Write(value_labels[0]), run_time=0.5)\n \n for i in range(1, 6):\n self.play(\n Create(lines[i-1]), \n Create(dots[i]), \n Write(value_labels[i]), \n run_time=0.6\n )\n \n self.wait(1)\n \n # Passo 3: Highlight Sequence\n scale_factor = 1.5\n \n # Highlight 1: Jan-Fev\n self.play(\n highlight_group_1.animate.set_color(highlight_color).set_stroke(width=8),\n dots[0].animate.scale(scale_factor),\n dots[1].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_1.animate.set_color(data_color).set_stroke(width=4),\n dots[0].animate.scale(1/scale_factor),\n dots[1].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n # Highlight 2: Fev-Abr\n self.play(\n highlight_group_2.animate.set_color(highlight_color).set_stroke(width=8),\n dots[1].animate.scale(scale_factor),\n dots[2].animate.scale(scale_factor),\n dots[3].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_2.animate.set_color(data_color).set_stroke(width=4),\n dots[1].animate.scale(1/scale_factor),\n dots[2].animate.scale(1/scale_factor),\n dots[3].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n # Highlight 3: Abr-Jun\n self.play(\n highlight_group_3.animate.set_color(highlight_color).set_stroke(width=8),\n dots[3].animate.scale(scale_factor),\n dots[4].animate.scale(scale_factor),\n dots[5].animate.scale(scale_factor),\n run_time=0.8\n )\n self.play(\n highlight_group_3.animate.set_color(data_color).set_stroke(width=4),\n dots[3].animate.scale(1/scale_factor),\n dots[4].animate.scale(1/scale_factor),\n dots[5].animate.scale(1/scale_factor),\n run_time=0.5\n )\n \n self.wait(1)\n \n # Passo 4: Outro (Fade out tudo)\n all_content = VGroup(title, axes, grid_lines, x_labels, y_labels, dots, lines, value_labels)\n self.play(FadeOut(all_content), run_time=1.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Generate a Manim animation to explain the concept of surface integrals in vector calculus. Visualize the flux of a vector field through a surface, and include a title saying \"Surface Integrals.\"", "chosen": "```python\nfrom manim import *\n\nclass SurfaceIntegrals(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\").scale(1.5)\n self.play(Write(title))\n self.wait(1)\n\n # Vector Field Representation (Simplified for clarity)\n vector_field_label = MathTex(\"\\\\vec{F}(x,y,z) = x\\\\hat{i} + y\\\\hat{j} + z\\\\hat{k}\")\n \n # Create some vectors on the plane to represent components of the field\n plane_vectors = VGroup()\n points_on_plane = [(1, 1, 0), (-1, -1, 0), (1, -1, 0)]\n colors = [RED, GREEN, BLUE]\n \n for pt, color in zip(points_on_plane, colors):\n start = np.array(pt)\n end = start + np.array([pt[0], pt[1], 0]) * 1.2 # Scale factor\n vec = Arrow(start=start, end=end, buff=0, color=color)\n \n text = MathTex(f\"v_{chr(ord('A')+points_on_plane.index(pt))}\", font_size=24).next_to(end, UP)\n \n plane_vector_group = VGroup(vec, text)\n plane_vectors.add(plane_vector_group)\n \n self.play(FadeIn(vector_field_label), FadeIn(plane_vectors))\n self.wait(2)\n \n # Flux Visualization (Simulated using areas under curves for simplicity)\n flux_title = Text(\"Flux of \\\\vec F through a closed surface S\", font_size=28).to_edge(DOWN)\n self.play(Write(flux_title))\n self.wait(1)\n\n # Simulate area under curve to show integration\n graph_area = RoundedRectangle(width=6, height=4, corner_radius=0.2, color=YELLOW)\n graph_area.shift(RIGHT*1 + DOWN*1)\n \n integral_text = MathTex(\"\\\\iint_S \\\\vec{n} \\\\cdot d\\\\mathbf{S}\", font_size=28).shift(LEFT*1 + DOWN*1)\n \n self.play(Create(graph_area), Write(integral_text))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\n \"Integral calculates total flow through the surface\",\n font_size=24\n )\n conclusion.next_to(integral_text, DOWN, buff=0.5)\n \n self.play(Write(conclusion))\n self.wait(1)\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass SurfaceIntegrals(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\").scale(0.8).to_edge(UP)\n self.play(Write(title))\n\n # Define the parametric surface (a simple sphere for visualization purposes)\n u = np.linspace(-PI/2, PI/2, 20)\n v = np.linspace(0, 2*PI, 20)\n\n vertices = []\n triangles = []\n\n # Create vertices on the unit sphere\n for i, _u in enumerate(u[:-1]):\n for j, _v in enumerate(v[:-1]):\n x = np.cos(_u) * np.sin(_v)\n y = np.sin(_u) * np.sin(_v)\n z = np.cos(_v)\n \n vertex_index = len(vertices)\n vertices.append([x, y, z])\n \n # Add two triangles per grid square to form a mesh\n if i < len(u)-2 and j < len(v)-2:\n triangle1 = [vertex_index + 1, vertex_index, vertex_index + len(v)]\n triangle2 = [vertex_index + 1, vertex_index + len(v), vertex_index + len(v)+1]\n triangles.extend(triangle1)\n triangles.extend(triangle2)\n\n # Create the polygonal surface from the vertices and indices\n surface_mesh = Polygon(\n *[ORIGIN for _ in range(len(vertices))], \n points=vertices,\n stroke_color=BLUE,\n fill_opacity=0.2,\n stroke_width=2,\n stroke_opacity=0.6\n )\n \n # Map each face index to its corresponding vertices\n face_vertices = [[vertices[index] for index in tri] for tri in triangles]\n\n # Vector Field arrows representing normal vectors at selected vertices\n arrow_positions = [\n ORIGIN, \n [-1, 0, 0], \n [1, 0, 0], \n [0, -1, 0],\n [0, 1, 0]\n ]\n arrows = VGroup()\n for pos in arrow_positions:\n vec_field_arrow = Arrow(pos, pos + UP, color=YELLOW, buff=0.1)\n arrows.add(vec_field_arrow)\n \n self.play(Create(surface_mesh))\n \n self.play(LaggedStart(*arrows.animate.scale(1.5)))\n \n integral_text = MathTex(\"\\\\int \\\\int_S\", \"\\\\vec{F} \\\\cdot d\\\\mathbf{n}\", r\"ds\")\n integral_text.to_edge(DOWN).shift(LEFT * 3)\n \n # Highlight area of integration\n highlight_box = RoundedRectangle(\n width=surface_mesh.get_height(),\n height=surface_mesh.get_width(),\n corner_radius=0.1,\n color=GREEN,\n fill_opacity=0.2\n ).move_to(surface_mesh.get_center())\n \n self.play(FadeIn(highlight_box))\n \n self.play(Write(integral_text))\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an animated video showing a sequence of shapes transforming into one another. The shapes should be regular polygons starting with a decagon (10-sided polygon) in blue, then transforming into a hendecagon (11-sided polygon) in yellow, followed by a dodecagon (12-sided polygon) in white. After this sequence, I would like to show a separate polycontagon (30-sided polygon) in green, positioned to the right of the dodecagon. The transformation should be clear and well animated, resulting in a visually appealing educational math video. Could you generate an animation using a tool that could make the elements appear one after the other, with the first three polygons arranged side by side with some space between them, and then clear the screen to introduce the final green polycontagon?", "chosen": "```python\nfrom manim import *\n\nclass PolygonTransformation(Scene):\n def construct(self):\n # --- 1. Initial Setup: Display three regular polygons side-by-side ---\n decagon = RegularPolygon(n=10, color=BLUE, stroke_width=4, fill_opacity=0.1)\n hendecagon = RegularPolygon(n=11, color=YELLOW, stroke_width=4, fill_opacity=0.1)\n dodecagon = RegularPolygon(n=12, color=WHITE, stroke_width=4, fill_opacity=0.1)\n\n # Group and arrange side-by-side with adequate spacing\n polygon_group = VGroup(decagon, hendecagon, dodecagon)\n polygon_group.arrange(RIGHT, buff=1.5)\n\n # Animate their appearance\n self.play(Create(polygon_group), run_time=2)\n self.wait(1)\n\n # --- 2. Transformation Sequence ---\n # Focus the transformation in the center for visual clarity\n self.play(\n FadeOut(hendecagon),\n FadeOut(dodecagon),\n decagon.animate.move_to(ORIGIN)\n )\n\n # Prepare target shapes for the morphing sequence\n target_hendecagon = RegularPolygon(n=11, color=YELLOW, stroke_width=4, fill_opacity=0.1)\n target_dodecagon = RegularPolygon(n=12, color=WHITE, stroke_width=4, fill_opacity=0.1)\n\n # Animate Decagon -> Hendecagon\n self.play(ReplacementTransform(decagon, target_hendecagon), run_time=1.5)\n self.wait(0.5)\n\n # Animate Hendecagon -> Dodecagon\n self.play(ReplacementTransform(target_hendecagon, target_dodecagon), run_time=1.5)\n self.wait(1)\n\n # --- 3. Scene Transition: Clear the screen ---\n self.play(FadeOut(target_dodecagon), run_time=1)\n self.wait(0.5)\n\n # --- 4. Final Element: Triacontagon (30-sided polygon) ---\n triacontagon = RegularPolygon(n=30, color=GREEN, stroke_width=4, fill_opacity=0.1)\n \n # Position it to the right of where the dodecagon was previously located (ORIGIN)\n triacontagon.move_to(ORIGIN + RIGHT * 2.5)\n\n # Animate its appearance\n self.play(Create(triacontagon), run_time=2)\n self.wait(2)\n\n# To run this animation:\n# manim -pql polygon_animation.py PolygonTransformation\n```", "rejected": "```python\nfrom manim import *\n\nclass PolygonTransformation(Scene):\n def construct(self):\n # --- 1. Initial Setup: Display three regular polygons side-by-side ---\n decagon = RegularPolygon(n=10, color=BLUE, stroke_width=4, fill_opacity=0.1)\n hendecagon = RegularPolygon(n=11, color=YELLOW, stroke_width=4, fill_opacity=0.1)\n dodecagon = RegularPolygon(n=12, color=WHITE, stroke_width=4, fill_opacity=0.1)\n\n # Group and arrange side-by-side with adequate spacing\n polygon_group = VGroup(decagon, hendecagon, dodecagon)\n polygon_group.arrange(RIGHT, buff=1.5)\n\n # Animate their appearance\n self.play(Create(polygon_group), run_time=2)\n self.wait(1)\n\n # --- 2. Transformation Sequence ---\n # Focus the transformation in the center for visual clarity\n self.play(\n FadeOut(hendecagon),\n FadeOut(dodecagon),\n decagon.animate.move_to(ORIGIN)\n )\n\n # Prepare target shapes for the morphing sequence\n target_hendecagon = RegularPolygon(n=11, color=YELLOW, stroke_width=4, fill_opacity=0.1)\n target_dodecagon = RegularPolygon(n=12, color=WHITE, stroke_width=4, fill_opacity=0.1)\n\n # Animate Decagon -> Hendecagon\n self.play(ReplacementTransform(target_position=ORIGIN, decagon, target_hendecagon), run_time=1.5)\n self.wait(0.5)\n\n # Animate Hendecagon -> Dodecagon\n self.play(ReplacementTransform(target_hendecagon, target_dodecagon), run_time=1.5)\n self.wait(1)\n\n # --- 3. Scene Transition: Clear the screen ---\n self.play(FadeOut(target_dodecagon), run_time=1)\n self.wait(0.5)\n\n # --- 4. Final Element: Triacontagon (30-sided polygon) ---\n triacontagon = RegularPolygon(n=30, color=GREEN, stroke_width=4, fill_opacity=0.1)\n \n # Position it to the right of where the dodecagon was previously located (ORIGIN)\n triacontagon.move_to(ORIGIN + RIGHT * 2.5)\n\n # Animate its appearance\n self.play(Create(triacontagon), run_time=2)\n self.wait(2)\n\n# To run this animation:\n# manim -pql polygon_animation.py PolygonTransformation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Demonstrate a Manim animation showcasing a neural network logo with text and an underline, scaled to fit within a 4x4 frame.", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkLogo(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Configuration & Style\n # ------------------------------------------------------------------\n # Define a modern, tech-inspired color palette\n NODE_COLOR = BLUE_E\n EDGE_COLOR = PURPLE_B\n TEXT_COLOR = WHITE\n ACCENT_COLOR = TEAL_A\n \n # Define the 4x4 coordinate boundary constraint with padding\n MAX_WIDTH = 4.0\n MAX_HEIGHT = 4.0\n PADDING = 0.2\n \n # ------------------------------------------------------------------\n # 1. Construct Neural Network Icon\n # ------------------------------------------------------------------\n # Create layers of nodes (3-5-3 architecture for visual symmetry)\n layer_1 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(3)])\n layer_2 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(5)])\n layer_3 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(3)])\n \n # Arrange nodes vertically within each layer\n layer_1.arrange(DOWN, buff=0.35)\n layer_2.arrange(DOWN, buff=0.25)\n layer_3.arrange(DOWN, buff=0.35)\n \n # Arrange layers horizontally\n layers = VGroup(layer_1, layer_2, layer_3)\n layers.arrange(RIGHT, buff=0.8)\n \n # Create edges connecting adjacent layers\n edges = VGroup()\n for n1 in layer_1:\n for n2 in layer_2:\n edges.add(Line(n1.get_center(), n2.get_center(), color=EDGE_COLOR, stroke_width=1.5))\n for n2 in layer_2:\n for n3 in layer_3:\n edges.add(Line(n2.get_center(), n3.get_center(), color=EDGE_COLOR, stroke_width=1.5))\n \n # Group icon elements\n network_icon = VGroup(edges, layers)\n \n # ------------------------------------------------------------------\n # 2. Construct Text Label & Underline\n # ------------------------------------------------------------------\n label = Text(\"NEURAL NET\", font_size=36, color=TEXT_COLOR, weight=BOLD)\n # Use a precise Line for the underline to match text width exactly\n underline = Line(\n start=label.get_left() + DOWN * 0.1,\n end=label.get_right() + DOWN * 0.1,\n color=ACCENT_COLOR,\n stroke_width=3\n )\n \n text_group = VGroup(label, underline)\n \n # ------------------------------------------------------------------\n # 3. Assemble & Scale to Fit 4x4 Frame\n # ------------------------------------------------------------------\n # Position network icon above the text label\n logo_group = VGroup(network_icon, text_group)\n logo_group.arrange(DOWN, buff=0.5)\n logo_group.move_to(ORIGIN)\n \n # Enforce the 4x4 coordinate constraint strictly without distortion\n target_width = MAX_WIDTH - 2 * PADDING\n target_height = MAX_HEIGHT - 2 * PADDING\n scale_factor = min(target_width / logo_group.width, target_height / logo_group.height)\n \n if scale_factor < 1.0:\n logo_group.scale(scale_factor)\n \n # ------------------------------------------------------------------\n # 4. Animation Sequence\n # ------------------------------------------------------------------\n # Step 1: Fade in nodes with a staggered effect\n self.play(\n LaggedStartMap(FadeIn, layers, lag_ratio=0.15, run_time=1.0),\n rate_func=smooth\n )\n \n # Step 2: Draw edges with a lagged start for a procedural feel\n self.play(\n LaggedStart(*[Create(edge) for edge in edges], lag_ratio=0.02, run_time=1.5)\n )\n \n # Step 3: Write text label\n self.play(Write(label), run_time=1.0)\n \n # Step 4: Draw underline\n self.play(Create(underline), run_time=0.6)\n \n # Step 5: Subtle pulse effect on nodes to signify activity\n self.play(\n *[node.animate.scale(1.3).set_color(ACCENT_COLOR) for node in layers],\n run_time=0.2\n )\n self.play(\n *[node.animate.scale(1/1.3).set_color(NODE_COLOR) for node in layers],\n run_time=0.2\n )\n \n # Hold final frame\n self.wait(1.0)\n\n# To render this animation, run: manim -pql script_name.py NeuralNetworkLogo\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkLogo(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Configuration & Style\n # ------------------------------------------------------------------\n # Define a modern, tech-inspired color palette\n NODE_COLOR = BBLUE_E\n EDGE_COLOR = PURPLE_B\n TEXT_COLOR = WHITE\n ACCENT_COLOR = TEAL_A\n \n # Define the 4x4 coordinate boundary constraint with padding\n MAX_WIDTH = 4.0\n MAX_HEIGHT = 4.0\n PADDING = 0.2\n \n # ------------------------------------------------------------------\n # 1. Construct Neural Network Icon\n # ------------------------------------------------------------------\n # Create layers of nodes (3-5-3 architecture for visual symmetry)\n layer_1 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(3)])\n layer_2 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(5)])\n layer_3 = VGroup(*[Dot(radius=0.12, color=NODE_COLOR) for _ in range(3)])\n \n # Arrange nodes vertically within each layer\n layer_1.arrange(DOWN, buff=0.35)\n layer_2.arrange(DOWN, buff=0.25)\n layer_3.arrange(DOWN, buff=0.35)\n \n # Arrange layers horizontally\n layers = VGroup(layer_1, layer_2, layer_3)\n layers.arrange(RIGHT, buff=0.8)\n \n # Create edges connecting adjacent layers\n edges = VGroup()\n for n1 in layer_1:\n for n2 in layer_2:\n edges.add(Line(n1.get_center(), n2.get_center(), color=EDGE_COLOR, stroke_width=1.5))\n for n2 in layer_2:\n for n3 in layer_3:\n edges.add(Line(n2.get_center(), n3.get_center(), color=EDGE_COLOR, stroke_width=1.5))\n \n # Group icon elements\n network_icon = VGroup(edges, layers)\n \n # ------------------------------------------------------------------\n # 2. Construct Text Label & Underline\n # ------------------------------------------------------------------\n label = Text(\"NEURAL NET\", font_size=36, color=TEXT_COLOR, weight=BOLD)\n # Use a precise Line for the underline to match text width exactly\n underline = Line(\n start=label.get_left() + DOWN * 0.1,\n end=label.get_right() + DOWN * 0.1,\n color=ACCENT_COLOR,\n stroke_width=3\n )\n \n text_group = VGroup(label, underline)\n \n # ------------------------------------------------------------------\n # 3. Assemble & Scale to Fit 4x4 Frame\n # ------------------------------------------------------------------\n # Position network icon above the text label\n logo_group = VGroup(network_icon, text_group)\n logo_group.arrange(DOWN, buff=0.5)\n logo_group.move_to(ORIGIN)\n \n # Enforce the 4x4 coordinate constraint strictly without distortion\n target_width = MAX_WIDTH - 2 * PADDING\n target_height = MAX_HEIGHT - 2 * PADDING\n scale_factor = min(target_width / logo_group.width, target_height / logo_group.height)\n \n if scale_factor < 1.0:\n logo_group.scale(scale_factor)\n \n # ------------------------------------------------------------------\n # 4. Animation Sequence\n # ------------------------------------------------------------------\n # Step 1: Fade in nodes with a staggered effect\n self.play(\n LaggedStartMap(FadeIn, layers, lag_ratio=0.15, run_time=1.0),\n rate_func=smooth\n )\n \n # Step 2: Draw edges with a lagged start for a procedural feel\n self.play(\n LaggedStart(*[Create(edge) for edge in edges], lag_ratio=0.02, run_time=1.5)\n )\n \n # Step 3: Write text label\n self.play(Write(label), run_time=1.0)\n \n # Step 4: Draw underline\n self.play(Create(underline), run_time=0.6)\n \n # Step 5: Subtle pulse effect on nodes to signify activity\n self.play(\n *[node.animate.scale(1.3).set_color(ACCENT_COLOR) for node in layers],\n run_time=0.2\n )\n self.play(\n *[node.animate.scale(1/1.3).set_color(NODE_COLOR) for node in layers],\n run_time=0.2\n )\n \n # Hold final frame\n self.wait(1.0)\n\n# To render this animation, run: manim -pql script_name.py NeuralNetworkLogo\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that visually explains the difference between the incorrect trigonometric expression \"sin(x) + cos(x) = 1\" and the correct Pythagorean trigonometric identity \"sin²(x) + cos²(x) = 1\". First, show the incorrect equation on the screen and indicate that it's not accurate. Then, replace it with the correct equation while explaining that this is the true Pythagorean identity. Could you also graph the sine and cosine functions for me and label them accordingly? Lastly, I'd like this to conclude by clearing everything away and presenting the correct equation and its explanation one more time for emphasis.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass TrigIdentityAnimation(Scene):\n \"\"\"\n This scene visually distinguishes between the common misconception \n sin(x) + cos(x) = 1 and the correct Pythagorean identity sin^2(x) + cos^2(x) = 1.\n \"\"\"\n\n def construct(self):\n # ==========================================\n # Step 1: Display Incorrect Equation\n # ==========================================\n # Create the incorrect equation using MathTex for precise LaTeX rendering\n incorrect_eq = MathTex(r\"\\sin(x) + \\cos(x) = 1\", font_size=48)\n \n self.play(Write(incorrect_eq))\n self.wait(1)\n \n # Visually indicate the error: Change color to RED and add a Cross\n error_cross = Cross(incorrect_eq, color=RED, stroke_width=6)\n \n self.play(\n incorrect_eq.animate.set_color(RED),\n Create(error_cross)\n )\n self.wait(1)\n \n # ==========================================\n # Step 2: Transition to Correct Identity\n # ==========================================\n # Define the correct Pythagorean identity\n correct_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=48)\n correct_eq.set_color(GREEN)\n \n # Brief textual explanation confirming the identity\n identity_label = Text(\"The True Pythagorean Identity\", font_size=28, color=WHITE)\n identity_label.next_to(correct_eq, DOWN, buff=0.5)\n \n # Transform the incorrect equation to the correct one smoothly\n self.play(\n TransformMatchingTex(incorrect_eq, correct_eq),\n FadeOut(error_cross),\n Write(identity_label)\n )\n self.wait(1)\n \n # ==========================================\n # Step 3: Graph Functions\n # ==========================================\n # Prepare the scene for graphing by moving the equation to the top\n self.play(\n correct_eq.animate.to_edge(UP),\n identity_label.animate.next_to(correct_eq, DOWN, buff=0.3)\n )\n \n # Create coordinate axes suitable for trigonometric functions\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False}\n )\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 # Plot sin(x) and cos(x) using numpy functions for calculation\n sin_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n cos_curve = axes.plot(lambda x: np.cos(x), color=ORANGE)\n \n # Create labels for the curves positioned near the peaks\n sin_label = axes.get_graph_label(\n sin_curve, label=r\"\\sin(x)\", color=BLUE, x_val=PI/2, direction=RIGHT\n )\n cos_label = axes.get_graph_label(\n cos_curve, label=r\"\\cos(x)\", color=ORANGE, x_val=0, direction=UP\n )\n \n # Animate the creation of axes and curves sequentially for clarity\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(sin_curve), Write(sin_label))\n self.play(Create(cos_curve), Write(cos_label))\n self.wait(2)\n \n # ==========================================\n # Step 4: Conclusion\n # ==========================================\n # Clear all graphical elements and text from the scene\n all_elements = VGroup(\n correct_eq, identity_label,\n axes, x_label, y_label,\n sin_curve, cos_curve,\n sin_label, cos_label\n )\n self.play(FadeOut(all_elements))\n \n # Present only the correct equation and its explanation one last time for emphasis\n final_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=60, color=GREEN)\n final_note = Text(\"This identity holds true for all real x.\", font_size=30)\n final_note.next_to(final_eq, DOWN, buff=0.5)\n \n self.play(Write(final_eq), FadeIn(final_note, shift=UP))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass TrigIdentityAnimation(Scene):\n \"\"\"\n This scene visually distinguishes between the common misconception \n sin(x) + cos(x) = 1 and the correct Pythagorean identity sin^2(x) + cos^2(x) = 1.\n \"\"\"\n\n def construct(self):\n # ==========================================\n # Step 1: Display Incorrect Equation\n # ==========================================\n # Create the incorrect equation using MathTex for precise LaTeX rendering\n incorrect_eq = MathTex(r\"\\sin(x) + \\cos(x) = 1\", font_size=48)\n \n self.play(Write(incorrect_eq))\n self.wait(1)\n \n # Visually indicate the error: Change color to RED and add a Cross\n error_cross = Cross(incorrect_eq, color=RED, stroke_width=6)\n \n self.play(\n incorrect_eq.animate.set_color(RED),\n Create(error_cross)\n )\n self.wait(1)\n \n # ==========================================\n # Step 2: Transition to Correct Identity\n # ==========================================\n # Define the correct Pythagorean identity\n correct_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=48)\n correct_eq.set_color(GREEN)\n \n # Brief textual explanation confirming the identity\n identity_label = Text(\"The True Pythagorean Identity\", font_size=28, color=WHITE)\n identity_label.next_to(correct_eq, DOWN, buff=0.5)\n \n # Transform the incorrect equation to the correct one smoothly\n self.play(\n TransformMatchingTex(incorrect_eq, correct_eq),\n FadeOut(error_cross),\n Write(identity_label)\n )\n self.wait(1)\n \n # ==========================================\n # Step 3: Graph Functions\n # ==========================================\n # Prepare the scene for graphing by moving the equation to the top\n self.play(\n correct_eq.animate.to_edge(UP),\n identity_label.animate.next_to(correct_eq, DOWN, buff=0.3)\n )\n \n # Create coordinate axes suitable for trigonometric functions\n axes = Axes(font_size=24, \n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=10,\n y_length=5,\n axis_config={\"include_tip\": False}\n )\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 # Plot sin(x) and cos(x) using numpy functions for calculation\n sin_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n cos_curve = axes.plot(lambda x: np.cos(x), color=ORANGE)\n \n # Create labels for the curves positioned near the peaks\n sin_label = axes.get_graph_label(\n sin_curve, label=r\"\\sin(x)\", color=BLUE, x_val=PI/2, direction=RIGHT\n )\n cos_label = axes.get_graph_label(\n cos_curve, label=r\"\\cos(x)\", color=ORANGE, x_val=0, direction=UP\n )\n \n # Animate the creation of axes and curves sequentially for clarity\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(sin_curve), Write(sin_label))\n self.play(Create(cos_curve), Write(cos_label))\n self.wait(2)\n \n # ==========================================\n # Step 4: Conclusion\n # ==========================================\n # Clear all graphical elements and text from the scene\n all_elements = VGroup(\n correct_eq, identity_label,\n axes, x_label, y_label,\n sin_curve, cos_curve,\n sin_label, cos_label\n )\n self.play(FadeOut(all_elements))\n \n # Present only the correct equation and its explanation one last time for emphasis\n final_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=60, color=GREEN)\n final_note = Text(\"This identity holds true for all real x.\", font_size=30)\n final_note.next_to(final_eq, DOWN, buff=0.5)\n \n self.play(Write(final_eq), FadeIn(final_note, shift=UP))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 across the screen: 1/2, 2/4, and 4/8. Each fraction should be written in black and be large enough to be easily readable. Between the first and second fraction, and the second and third fraction, there should be a blue arrow pointing from one to the next to signify the equivalence of the fractions. Above each arrow, the text \"times 2\" and \"times 4\" respectively should appear, also in blue, indicating the multiplication factor from one fraction to the next. Each element should appear in sequence with slight animations: first the fraction 1/2 is written, then an arrow grows from it to the fraction 2/4 with \"times 2\" appearing at the same time, followed by the fraction 2/4 appearing, and the process repeats for the fraction 4/8 with \"times 4\" above the second arrow. After a short pause where all elements are visible, the entire scene fades out. Could you please create such an animation for my educational content?", "chosen": "```python\nfrom manim import *\n\nclass EquivalentFractions(Scene):\n def construct(self):\n # Set background to white\n self.camera.background_color = WHITE\n\n # Create fractions with black text, large and readable\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=72)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=72)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=72)\n\n # Arrange fractions horizontally with spacing\n fractions = VGroup(f1, f2, f3).arrange(RIGHT, buff=2.5)\n\n # Create blue arrows between fractions\n arrow1 = Arrow(f1.get_right(), f2.get_left(), color=BLUE, buff=0.2)\n arrow2 = Arrow(f2.get_right(), f3.get_left(), color=BLUE, buff=0.2)\n\n # Create blue labels above the 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 # Group all elements for final fade out\n all_elements = VGroup(f1, f2, f3, arrow1, arrow2, label1, label2)\n\n # Animation Sequence\n \n # 1. Write the fraction 1/2\n self.play(Write(f1))\n self.wait(0.5)\n\n # 2. Grow the first arrow and display \"times 2\" label\n self.play(GrowArrow(arrow1), Write(label1))\n self.wait(0.5)\n\n # 3. Write the fraction 2/4\n self.play(Write(f2))\n self.wait(0.5)\n\n # 4. Grow the second arrow and display \"times 4\" label\n self.play(GrowArrow(arrow2), Write(label2))\n self.wait(0.5)\n\n # 5. Write the fraction 4/8\n self.play(Write(f3))\n \n # 6. Pause briefly with all elements visible\n self.wait(1.5)\n\n # 7. Fade out the entire scene\n self.play(FadeOut(all_elements))\n```", "rejected": "```python\nfrom manim import *\n\nclass EquivalentFractions(Scene):\n def construct(self):\n # Set background to white\n self.camera.background_color = WHITE\n\n # Create fractions with black text, large and readable\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=72)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=72)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=72)\n\n # Arrange fractions horizontally with spacing\n fractions = VGroup(f1, f2, f3).arrange(RIGHT, buff=2.5)\n\n # Create blue arrows between fractions\n arrow1 = Arrow(f1.get_right(), f2.get_left(), color=BBLUE, buff=0.2)\n arrow2 = Arrow(f2.get_right(), f3.get_left(), color=BLUE, buff=0.2)\n\n # Create blue labels above the 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 # Group all elements for final fade out\n all_elements = VGroup(f1, f2, f3, arrow1, arrow2, label1, label2)\n\n # Animation Sequence\n \n # 1. Write the fraction 1/2\n self.play(Write(f1))\n self.wait(0.5)\n\n # 2. Grow the first arrow and display \"times 2\" label\n self.play(GrowArrow(arrow1), Write(label1))\n self.wait(0.5)\n\n # 3. Write the fraction 2/4\n self.play(Write(f2))\n self.wait(0.5)\n\n # 4. Grow the second arrow and display \"times 4\" label\n self.play(GrowArrow(arrow2), Write(label2))\n self.wait(0.5)\n\n # 5. Write the fraction 4/8\n self.play(Write(f3))\n \n # 6. Pause briefly with all elements visible\n self.wait(1.5)\n\n # 7. Fade out the entire scene\n self.play(FadeOut(all_elements))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation that explains the solution to the harmonic oscillator differential equation step by step, starting with the equation itself, proposing a trial solution, applying initial conditions to find the general solution, and concluding with the final form of the solution?", "chosen": "```python\nfrom manim import *\n\nclass HarmonicOscillatorSolution(Scene):\n def construct(self):\n # =====================================================================\n # Step 1: Display the Equation\n # =====================================================================\n # Present the standard differential equation for a simple harmonic oscillator.\n diff_eq = MathTex(\n r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\",\n font_size=42\n )\n title = Text(\"Harmonic Oscillator Equation\", font_size=30)\n title.next_to(diff_eq, UP, buff=0.5)\n eq_group = VGroup(title, diff_eq).center()\n\n self.play(Write(title))\n self.play(Write(diff_eq))\n self.wait(2)\n\n # =====================================================================\n # Step 2: Propose a Trial Solution\n # =====================================================================\n # Introduce the general ansatz (trial solution) involving sinusoidal functions.\n trial_solution = MathTex(\n r\"x(t) = A \\cos(\\omega t) + B \\sin(\\omega t)\",\n font_size=42\n )\n trial_label = Text(\"Proposed Trial Solution\", font_size=24, color=BLUE)\n trial_label.next_to(trial_solution, UP, buff=0.3)\n trial_group = VGroup(trial_label, trial_solution)\n\n self.play(\n eq_group.animate.shift(UP * 1.5).scale(0.85),\n FadeIn(trial_group)\n )\n self.wait(2)\n\n # =====================================================================\n # Step 3: Apply Initial Conditions\n # =====================================================================\n # Demonstrate how initial position x(0) and velocity v(0) determine constants A and B.\n ic_title = Text(\"Applying Initial Conditions\", font_size=24, color=GREEN)\n ic_title.next_to(trial_solution, DOWN, buff=0.6)\n\n # Condition 1: Position at t=0\n cond1 = MathTex(\n r\"x(0) = x_0 \\implies A = x_0\",\n font_size=36\n ).next_to(ic_title, DOWN, buff=0.4)\n\n # Condition 2: Velocity at t=0 (derivative of trial solution)\n velocity_expr = MathTex(\n r\"\\dot{x}(t) = -A \\omega \\sin(\\omega t) + B \\omega \\cos(\\omega t)\",\n font_size=36\n ).next_to(cond1, DOWN, buff=0.3)\n\n cond2 = MathTex(\n r\"\\dot{x}(0) = v_0 \\implies B = \\frac{v_0}{\\omega}\",\n font_size=36\n ).next_to(velocity_expr, DOWN, buff=0.3)\n\n self.play(Write(ic_title))\n self.play(Write(cond1))\n self.wait(1)\n self.play(Write(velocity_expr))\n self.play(Write(cond2))\n self.wait(2)\n\n # =====================================================================\n # Step 4: Conclude with Final Form\n # =====================================================================\n # Substitute the derived constants back into the trial solution to show the final result.\n final_solution = MathTex(\n r\"x(t) = x_0 \\cos(\\omega t) + \\frac{v_0}{\\omega} \\sin(\\omega t)\",\n font_size=42,\n color=YELLOW\n )\n final_label = Text(\"Final Solution\", font_size=24, color=GOLD)\n final_label.next_to(final_solution, UP, buff=0.3)\n final_group = VGroup(final_label, final_solution).center()\n\n # Box the final answer for emphasis\n box = SurroundingRectangle(final_solution, color=WHITE, buff=0.2)\n\n # Clear the screen and present the finale\n self.play(\n FadeOut(eq_group),\n FadeOut(trial_group),\n FadeOut(ic_title),\n FadeOut(cond1),\n FadeOut(velocity_expr),\n FadeOut(cond2)\n )\n self.play(Write(final_group))\n self.play(Create(box))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py HarmonicOscillatorSolution\n```", "rejected": "```python\nfrom manim import *\n\nclass HarmonicOscillatorSolution(Scene):\n def construct(self):\n # =====================================================================\n # Step 1: Display the Equation\n # =====================================================================\n # Present the standard differential equation for a simple harmonic oscillator.\n diff_eq = MathTex(\n r\"\\frac{d^2 x}{dt^2} + \\omega^2 x = 0\",\n font_size=42\n )\n title = Text(\"Harmonic Oscillator Equation\", font_size=30)\n title.next_to(diff_eq, UP, buff=0.5)\n eq_group = VGroup(title, diff_eq).center()\n\n self.play(Write(title))\n self.play(Write(diff_eq))\n self.wait(2)\n\n # =====================================================================\n # Step 2: Propose a Trial Solution\n # =====================================================================\n # Introduce the general ansatz (trial solution) involving sinusoidal functions.\n trial_solution = MathTex(\n r\"x(t) = A \\cos(\\omega t) + B \\sin(\\omega t)\",\n font_size=42\n )\n trial_label = Text(\"Proposed Trial Solution\", font_size=24, color=BLUE)\n trial_label.next_to(trial_solution, UP, buff=0.3)\n trial_group = VGroup(trial_label, trial_solution)\n\n self.play(\n eq_group.animate.shift(UP * 1.5).scale(0.85),\n FadeIn(trial_group)\n )\n self.wait(2)\n\n # =====================================================================\n # Step 3: Apply Initial Conditions\n # =====================================================================\n # Demonstrate how initial position x(0) and velocity v(0) determine constants A and B.\n ic_title = Text(\"Applying Initial Conditions\", font_size=24, color=GREEN)\n ic_title.next_to(trial_solution, DOWN, buff=0.6)\n\n # Condition 1: Position at t=0\n cond1 = MathTex(\n r\"x(0) = x_0 \\implies A = x_0\",\n font_size=36\n ).next_to(ic_title, DOWN, buff=0.4)\n\n # Condition 2: Velocity at t=0 (derivative of trial solution)\n velocity_expr = MathTex(\n r\"\\dot{x}(t) = -A \\omega \\sin(\\omega t) + B \\omega \\cos(\\omega t)\",\n font_size=36\n ).next_to(cond1, DOWN, buff=0.3)\n\n cond2 = MathTex(\n r\"\\dot{x}(0) = v_0 \\implies B = \\frac{v_0}{\\omega}\",\n font_size=36\n ).next_to(velocity_expr, DOWN, buff=0.3)\n\n self.play(Write(ic_title))\n self.play(Write(cond1))\n self.wait(1)\n self.play(Write(velocity_expr))\n self.play(Write(cond2))\n self.wait(2)\n\n # =====================================================================\n # Step 4: Conclude with Final Form\n # =====================================================================\n # Substitute the derived constants back into the trial solution to show the final result.\n final_solution = MathTex(\n r\"x(t) = x_0 \\cos(\\omega t) + \\frac{v_0}{\\omega} \\sin(\\omega t)\",\n font_size=42,\n color=YELLOW\n )\n final_label = Text(\"Final Solution\", font_size=24, color=GOLD)\n final_label.next_to(final_solution, UP, buff=0.3)\n final_group = VGroup(final_label, final_solution).center()\n\n # Box the final answer for emphasis\n box = SurroundingRectangle(final_solution, color=WHITE, buff=0.2)\n\n # Clear the screen and present the finale\n self.play(\n FadeOut(eq_group),\n FadeOut(trial_group),\n FadeOut(ic_title),\n FadeOut(cond1),\n FadeOut(velocity_expr),\n FadeOut(cond2)\n )\n self.play(Write(final_group))\n self.play(Create(box))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py HarmonicOscillatorSolution\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- CONFIGURATION & PEDAGOGICAL SETUP ---\n # Define the quadratic function f(x) = (3/16)x^2\n # This coefficient is chosen so the definite integral from 0 to 4 is exactly 4.\n func = lambda x: (3/16) * x**2\n \n # Create Axes with appropriate range for visual clarity\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [0, 3]}\n ).add_coordinates()\n \n # Plot the curve\n curve = axes.plot(func, color=BLUE, x_range=[0, 4])\n \n # Initial Equation Label\n equation_text = MathTex(\"f(x) = \\\\frac{3}{16}x^2\").to_corner(UR)\n \n # --- STEP 1: INITIAL SETUP ---\n # Introduce axes and curve first to establish context\n self.play(Create(axes), Create(curve), Write(equation_text), run_time=2)\n self.wait(1.5) # Pause: Allow viewers to recognize the function shape\n \n # --- STEP 2: SHADING THE AREA ---\n # Define the region between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=GOLD, opacity=0.4)\n boundary_lines = VGroup(\n DashedLine(axes.c2p(0, 0), axes.c2p(0, func(0)), color=YELLOW),\n DashedLine(axes.c2p(4, 0), axes.c2p(4, func(4)), color=YELLOW)\n )\n \n # Animate the shading sweeping in to focus attention on the interval\n self.play(FadeIn(area), Create(boundary_lines), run_time=1.5)\n self.wait(2.0) # Pause: Emphasize the specific region of interest\n \n # --- STEP 3: CONCEPT EXPLANATION ---\n # Connect the visual area to the calculus concept\n concept_text = Text(\"The shaded region represents the\\ndefinite integral from x=0 to x=4\", font_size=24)\n concept_text.next_to(axes, DOWN, buff=0.5)\n \n self.play(Write(concept_text), run_time=1)\n self.wait(2.0) # Pause: Critical moment for conceptual linking\n \n # --- STEP 4: FORMULA TRANSITION ---\n # Replace the function label with the integral notation\n integral_formula = MathTex(\"\\\\int_{0}^{4} \\\\frac{3}{16}x^2 \\\\, dx\")\n integral_formula.move_to(equation_text)\n \n # Smooth transformation implies the equation is being operated upon\n self.play(\n Transform(equation_text, integral_formula),\n FadeOut(concept_text),\n run_time=2\n )\n self.wait(1.0) # Pause: Allow time to read the new notation\n \n # --- STEP 5: SOLUTION REVEAL ---\n # Calculate and display the result\n solution_value = MathTex(\"= 4\", font_size=48)\n solution_value.next_to(integral_formula, RIGHT)\n \n self.play(Write(solution_value), run_time=1)\n self.wait(2.0) # Pause: Verify the calculation result\n \n # --- STEP 6: FINAL FOCUS ---\n # Isolate the result to cement the takeaway\n everything_else = VGroup(axes, curve, area, boundary_lines)\n self.play(FadeOut(everything_else), run_time=1.5)\n \n # Center the remaining formula and solution for final focus\n final_group = VGroup(integral_formula, solution_value)\n self.play(final_group.animate.move_to(ORIGIN).scale(1.5), run_time=1)\n \n self.wait(3.0) # Final Pause: Leave only the mathematical truth visible\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- CONFIGURATION & PEDAGOGICAL SETUP ---\n # Define the quadratic function f(x) = (3/16)x^2\n # This coefficient is chosen so the definite integral from 0 to 4 is exactly 4.\n func = lambda x: (3/16) * x**2\n \n # Create Axes with appropriate range for visual clarity\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 4]},\n y_axis_config={\"numbers_to_include\": [0, 3]}\n ).add_coordinates()\n \n # Plot the curve\n curve = axes.plot(func, color=BLUE, x_range=[0, 4])\n \n # Initial Equation Label\n equation_text = MathTex(\"f(x) = \\\\frac{3}{16}x^2\").to_corner(UR)\n \n # --- STEP 1: INITIAL SETUP ---\n # Introduce axes and curve first to establish context\n self.play(Create(axes), Create(curve), Write(equation_text), run_time=2)\n self.wait(1.5) # Pause: Allow viewers to recognize the function shape\n \n # --- STEP 2: SHADING THE AREA ---\n # Define the region between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=GOLD, opacity=0.4)\n boundary_lines = VGroup(\n DashedLine(axes.c2p(0, 0), axes.c2p(0, func(0)), color=YELLOW),\n DashedLine(axes.c2p(4, 0), axes.c2p(4, func(4)), color=YELLOW)\n )\n \n # Animate the shading sweeping in to focus attention on the interval\n self.play(FadeIn(area), Create(boundary_lines), run_time=1.5)\n self.wait(2.0) # Pause: Emphasize the specific region of interest\n \n # --- STEP 3: CONCEPT EXPLANATION ---\n # Connect the visual area to the calculus concept\n concept_text = Text(\"The shaded region represents the\\ndefinite integral from x=0 to x=4\", font_size=24)\n concept_text.next_to(axes, DOWN, buff=0.5)\n \n self.play(Write(concept_text), run_time=1)\n self.wait(2.0) # Pause: Critical moment for conceptual linking\n \n # --- STEP 4: FORMULA TRANSITION ---\n # Replace the function label with the integral notation\n integral_formula = MathTex(\"\\\\int_{0}^{4} \\\\frac{3}{16}x^2 \\\\, dx\")\n integral_formula.move_to(equation_text)\n \n # Smooth transformation implies the equation is being operated upon\n self.play(\n Transform(equation_text, integral_formula),\n FadeOut(concept_text),\n run_time=2\n )\n self.wait(1.0) # Pause: Allow time to read the new notation\n \n # --- STEP 5: SOLUTION REVEAL ---\n # Calculate and display the result\n solution_value = MathTex(r\"= 4\" + \" = x\", font_size=48)\n solution_value.next_to(integral_formula, RIGHT)\n \n self.play(Write(solution_value), run_time=1)\n self.wait(2.0) # Pause: Verify the calculation result\n \n # --- STEP 6: FINAL FOCUS ---\n # Isolate the result to cement the takeaway\n everything_else = VGroup(axes, curve, area, boundary_lines)\n self.play(FadeOut(everything_else), run_time=1.5)\n \n # Center the remaining formula and solution for final focus\n final_group = VGroup(integral_formula, solution_value)\n self.play(final_group.animate.move_to(ORIGIN).scale(1.5), run_time=1)\n \n self.wait(3.0) # Final Pause: Leave only the mathematical truth visible\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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# Computer Vision Course Outline\n\n## 6. Feature Matching and 3D Reconstruction", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ComputerVisionFeatureMatching(Scene):\n def construct(self):\n title = Text(\"Computer Vision\", font_size=48)\n subtitle = Text(\"Feature Matching and 3D Reconstruction\", font_size=32).next_to(title, DOWN, buff=0.3)\n \n # Create grid for outline\n grid = VGroup()\n items = [\n \"Introduction\",\n \"- Overview\\n- Applications\",\n \"\\nImage Processing\",\n \"- Filters\\n- Morphology\",\n \"\\nObject Detection\",\n \"- Edge detection\\n- Hough transform\"\n ]\n \n item_texts = []\n x_offset = 0\n \n for i, text_str in enumerate(items):\n lines = text_str.split('\\n')\n \n if len(lines) > 1:\n box = RoundedRectangle(corner_radius=0.15, width=7.2, height=0.8 * (len(lines)), color=WHITE, fill_opacity=0.1)\n group = VGroup(Text(text_str, t2c={'Overview': BLUE, 'Applications': RED}, font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n \n box.add(group)\n offset_y = (-box.height + group.get_height()) / 2\n \n for line_text in lines:\n new_group = Text(line_text, font_size=24).move_to(ORIGIN).shift(RIGHT * x_offset + UP * offset_y + LEFT * 3.5)\n item_texts.append(new_group)\n \n if line_text.strip():\n self.play(FadeIn(box), Write(group))\n \n else:\n self.play(Create(box))\n break\n \n grid.add(VGroup(box, group))\n x_offset += 8.0\n \n else:\n text_obj = Text(text_str, font_size=24, t2c={'Edge detection': YELLOW, 'Hough transform': GREEN})\n rect = SurroundingRectangle(text_obj, corner_radius=0.15, color=GRAY, stroke_width=2)\n \n group = VGroup(rect, text_obj)\n grid.add(group)\n self.play(Create(rect), FadeIn(text_obj))\n\n title.to_edge(UP)\n subtitle.next_to(title, DOWN, buff=0.3).set_color(YELLOW)\n\n self.play(Write(title), Write(subtitle))\n self.wait(0.5)\n\n for obj in grid:\n self.play(FadeIn(obj, shift=RIGHT * 0.2), run_time=0.8)\n \n feature_matching_box = RoundedRectangle(\n corner_radius=0.2,\n width=3.5,\n height=1.5,\n color=TEAL,\n fill_opacity=0.2\n )\n \n matching_title = Text(\"Feature Matching\", font_size=28, color=TEAL)\n matching_text = Text(\"- Find corresponding points\\nbetween images\", font_size=24, color=GREY)\n matching_group = VGroup(matching_title, matching_text).arrange(DOWN, buff=0.15)\n \n matching_scene = VGroup(feature_matching_box, matching_group).arrange(DOWN, buff=0.5)\n reconstruction_box = RoundedRectangle(\n corner_radius=0.2,\n width=4.0,\n height=1.5,\n color=PURPLE,\n fill_opacity=0.2\n )\n \n rec_title = Text(\"Reconstruction\", font_size=28, color=PURPLE)\n rec_text = Text(\"- Combine matched features\\nto recover depth\", font_size=24, color=GREY)\n rec_group = VGroup(rec_title, rec_text).arrange(DOWN, buff=0.15)\n \n rec_scene = VGroup(reconstruction_box, rec_group).arrange(DOWN, buff=0.5)\n full_rec = VGroup(matching_scene, rec_scene).arrange(RIGHT, buff=0.8)\n full_rec.shift(LEFT * 4.5 + DOWN * 1.5)\n \n path_match = VMobject(color=YELLOW, stroke_width=2)\n match_start = np.array([full_rec[0][0].get_left()[0], full_rec[0][0].get_top()[1], 0])\n match_end = np.array([full_rec[1][0].get_left()[0], full_rec[1][0].get_bottom()[1], 0])\n \n path_match.set_points_as_corners([\n match_start, \n match_start + RIGHT * 1.5 + UP * 1.5,\n match_end + RIGHT * 1.0 + DOWN * 0.5\n ])\n \n arrow_match = Arrow(start=match_start, end=match_end, color=RED, stroke_width=2, buff=0.15)\n label_match = MathTex(\"+\\\\text{ Match}\", font_size=20).next_to(path_match, UP, buff=0.15)\n label_reconstruct = MathTex(\"\\\\rightarrow \\\\text{ Reconstruct } 3D \\\\space Point\", font_size=20).next_to(arrow_match, RIGHT, buff=0.15).to_edge(DOWN)\n \n plane = NumberPlane(x_range=(-10, 10), y_range=(-10, 10), background_line_style={\"stroke_opacity\": 0}).scale(0.4)\n dot = Dot(point=[3, 2, 0]).scale(0.6)\n triangle = Polygon(np.array([-1, 0, 0]), np.array([4, 0, 0]), np.array([4, 3, 0]))\n \n self.wait(1)\n self.play(FadeIn(full_rec, scale=0.5))\n self.wait(1)\n \n self.play(Create(plane), Indicate(dot, color=GREEN))\n self.wait(1)\n \n self.play(MoveAlongPath(plane.copy(), path_match), MoveAlongPath(dot, path_match), run_time=1.5)\n self.wait(1)\n \n self.play(GrowArrow(arrow_match), FadeIn(label_match, label_reconstruct))\n self.wait(1)\n \n self.play(TransformFromCopy(dot, triangle))\n self.wait(1)\n self.play(FadeOut(triangle, dot, path_match, arrow_match, label_match, label_reconstruct, plane))\n self.wait(1)\n self.play(FocusOn(full_rec[0][0]))\n\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass FeatureMatchingScene(Scene):\n def construct(self):\n title = Text(\"Feature Matching and 3D Reconstruction\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Create a grid of dots representing image features\n dot_grid = VGroup()\n for i in range(8):\n row = VGroup()\n for j in range(8):\n x = -3 + 0.7 * j\n y = -2 + 0.5 * i\n dot = Dot([x, y, 0], color=YELLOW, radius=0.05)\n row.add(dot)\n dot_group = VGroup(row)\n dot_grid.add(dot_group)\n \n self.play(Create(dot_grid))\n self.wait(1)\n\n # Match pairs by connecting corresponding points\n matches = []\n colors = [RED, GREEN, BLUE]\n indices = [(i, i) for i in range(16)]\n \n for idx, (a_idx, b_idx) in enumerate(indices):\n if idx % len(colors) == 0:\n line_color = colors[idx // len(colors)]\n else:\n continue\n \n a_dot = dot_grid[a_idx].copy().set_fill(line_color, opacity=0.7)\n b_dot = dot_grid[b_idx].copy().shift(RIGHT*3).set_fill(line_color, opacity=0.7)\n match_line = Line(\n a_dot.get_center(), \n b_dot.get_center(),\n stroke_width=1,\n stroke_opacity=0.6\n )\n \n matches.append(VGroup(match_line, a_dot, b_dot))\n\n self.play(LaggedStart(*matches, lag_ratio=0.1))\n self.wait()\n\n # Show 3D reconstruction hint\n triangle = Polygon(\n [-2, 0, 0],\n [0, 2, 0],\n [2, 0, 0],\n fill_opacity=0.2,\n stroke_color=WHITE\n ).scale(1.5)\n \n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n z_range=[-1, 1, 1],\n x_length=6,\n y_length=6,\n tips=False\n )\n\n camera_point = Triangle(color=ORANGE, fill_opacity=0.5).rotate(-PI/6).shift(LEFT*3 + UP*2.5)\n camera_text = Tex(\"$\\\\text{Camera}$\").next_to(camera_point, DOWN, buff=0.2)\n\n reconstructed_scene = VGroup(triangle, axes, camera_point, camera_text)\n \n self.play(FadeIn(reconstructed_scene, shift=DOWN))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Here’s an enhanced version of the animation with additional features: \n- Act 3: Create a short Manim scene with a moving dot that leaves a traced VMobject path behind it using an updater.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0347(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_enhancedshaperotation()\n self.clear_stage()\n self.act_3_pointwithtrace()\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_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\n def act_3_pointwithtrace(self):\n path = VMobject()\n dot = Dot()\n path.set_points_as_corners([dot.get_center(), dot.get_center()])\n def update_path(path):\n previous_path = path.copy()\n previous_path.add_points_as_corners([dot.get_center()])\n path.become(previous_path)\n path.add_updater(update_path)\n self.add(path, dot)\n self.play(Rotating(dot, angle=PI, about_point=RIGHT, run_time=2))\n self.wait()\n self.play(dot.animate.shift(UP))\n self.play(dot.animate.shift(LEFT))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0347(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_enhancedshaperotation()\n self.clear_stage()\n self.act_3_pointwithtrace()\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\" + \" = x\", 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_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\n def act_3_pointwithtrace(self):\n path = VMobject()\n dot = Dot()\n path.set_points_as_corners([dot.get_center(), dot.get_center()])\n def update_path(path):\n previous_path = path.copy()\n previous_path.add_points_as_corners([dot.get_center()])\n path.become(previous_path)\n path.add_updater(update_path)\n self.add(path, dot)\n self.play(Rotating(dot, angle=PI, about_point=RIGHT, run_time=2))\n self.wait()\n self.play(dot.animate.shift(UP))\n self.play(dot.animate.shift(LEFT))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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: Create a 12-second logic scene explaining necessary and sufficient conditions with nested sets. Put set A entirely inside set B, animate examples inside and outside A, and label that A is sufficient for B while B is nece", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0006(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_frameboxesanimation()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n\n def act_1_frameboxesanimation(self):\n text1 = Text(\"This is a sample,\", font_size=36)\n text2 = Text(\"of moving,\", font_size=36)\n text3 = Text(\"FrameBoxes.\", font_size=36)\n\n # Stack them vertically with spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n \n # Display all texts initially\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Create the highlighting rectangles\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 # --- Animation Sequence ---\n\n # Initial State: Display blue rectangle highlighting the first text\n self.play(Create(rect1))\n self.wait(1)\n\n # Transition 1: Replace blue rectangle with green rectangle (second text)\n self.play(ReplacementTransform(rect1, rect2))\n self.wait(1)\n\n # Transition 2: Replace green rectangle with red rectangle (third text)\n self.play(ReplacementTransform(rect2, rect3))\n self.wait(1)\n\n # Final Movement: Move the red rectangle upwards, tracking the text\n # Add an updater to ensure the rectangle strictly tracks the text's position\n rect3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n \n # Animate the text moving upwards; the rectangle follows via the updater\n self.play(text3.animate.shift(UP * 2), run_time=2)\n \n self.wait(1)\n rect3.clear_updaters()\n\n def act_2_necessarysufficientsets(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0006(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_frameboxesanimation()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n\n def act_1_frameboxesanimation(self):\n text1 = Text(\"This is a sample,\", font_size=36)\n text2 = Text(\"of moving,\", font_size=36)\n text3 = Text(\"FrameBoxes.\", font_size=36)\n\n # Stack them vertically with spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n \n # Display all texts initially\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Create the highlighting rectangles\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 # --- Animation Sequence ---\n\n # Initial State: Display blue rectangle highlighting the first text\n self.play(Create(rect1))\n self.wait(1)\n\n # Transition 1: Replace blue rectangle with green rectangle (second text)\n self.play(ReplacementTransform(target_position=ORIGIN, rect1, rect2))\n self.wait(1)\n\n # Transition 2: Replace green rectangle with red rectangle (third text)\n self.play(ReplacementTransform(rect2, rect3))\n self.wait(1)\n\n # Final Movement: Move the red rectangle upwards, tracking the text\n # Add an updater to ensure the rectangle strictly tracks the text's position\n rect3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n \n # Animate the text moving upwards; the rectangle follows via the updater\n self.play(text3.animate.shift(UP * 2), run_time=2)\n \n self.wait(1)\n rect3.clear_updaters()\n\n def act_2_necessarysufficientsets(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'm learning robustness to misspecification and want to animate sensitivity analysis: perturb priors/likelihoods, display how outputs shift, and plot robustness measures across a parameter grid with quick scenario comparisons.", "chosen": "```python\nfrom manim import *\n\nclass SensitivityAnalysis(Scene):\n def construct(self):\n # Title\n title = Text(\"Sensitivity Analysis\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n\n # Clear title for main content\n self.play(FadeOut(title))\n\n # Model Parameters\n params_text = Text(\"Model Parameters:\", font_size=36).to_edge(UP)\n \n prior_tex = MathTex(\"\\\\text{Prior} \\\\sim N(\\\\mu_{prior}, \\\\sigma^2)\")\n like_tex = MathTex(\"\\\\text{Like} \\\\sim N(\\\\mu_{like}, \\\\sigma^2)\")\n\n model_params = VGroup(prior_tex, like_tex).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n model_group = VGroup(params_text, model_params).scale(0.7).shift(UP * 2 + LEFT * 3)\n\n # Observations\n obs_text = Text(\"Observations:\", font_size=36).next_to(model_group, DOWN, buff=1)\n obs_rect = RoundedRectangle(corner_radius=0.2, width=3, height=1, color=BLUE)\n obs_label = Text(\"+ Data Points\", font_size=24).move_to(obs_rect.get_center())\n\n observation = VGroup(obs_rect, obs_label).scale(0.5).shift(RIGHT * 3)\n\n # Shift of Results\n shift_text = Text(\"Shift in Outputs:\", font_size=36).next_to(observation, DOWN, buff=1)\n\n up_arrow = Arrow(start=DOWN, end=UP, color=RED, max_tip_length_to_length_ratio=0.2)\n down_arrow = Arrow(start=UP, end=DOWN, color=GREEN, max_tip_length_to_length_ratio=0.2)\n arrows = VGroup(up_arrow, down_arrow).arrange(RIGHT, buff=1)\n\n results_shift = VGroup(shift_text, arrows).scale(0.7).shift(RIGHT * 3 + UP * 1.5)\n\n # Display Components\n components = VGroup(\n model_group,\n obs_text,\n observation,\n shift_text,\n arrows\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n\n self.play(Write(components))\n self.wait(2)\n\n # Highlight Changes\n self.play(\n Indicate(obs_rect),\n Indicate(arrows[0], color=RED),\n Write(MathTex(\"\\\\Delta f < 0\").next_to(arrows[0], RIGHT)),\n run_time=2\n )\n self.play(\n Indicate(arrows[1]),\n Write(MathTex(\"\\\\Delta f > 0\").next_to(arrows[1], RIGHT)),\n run_time=2\n )\n\n # Conclusion\n conclusion = Text(\"Robust Models require stability under\\nparameter changes.\", font_size=32).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(3)\n\n# To run this animation:\n# manim -pql filename.py SensitivityAnalysis\n```", "rejected": "```python\nfrom manim import *\n\n# From manim import *\nclass RobustSensitivityAnalysis(Scene):\n def construct(self):\n # Title\n title = Text(\"Robust Sensitivity Analysis\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create prior and likelihood curves for comparison\n prior_curve = VMobject()\n prior_curve.set_points_smoothly(\n [\n np.array([i, i**2 + 2*i + 1, 0])\n for i in range(-5, 6) if i != 0\n ]\n )\n \n like_curve = VMobject()\n like_curve.set_points_smoothly(\n [\n np.array([i, i**2 + 4*i + 4, 0]) \n for i in range(-5, 6)\n ]\n )\n\n prior_label = Text(\"Prior Distribution\", font_size=28).to_edge(UP)\n like_label = Text(\"Likelihood Function\", font_size=28).to_edge(DOWN)\n \n\n self.play(Create(prior_curve), Write(prior_label))\n self.play(Create(like_curve), Write(like_label))\n\n # Perturbation of Prior\n pert_prior = VMobject()\n pert_prior.set_points_smoothly([\n np.array([i, i**2 + 3*i + 1, 0]) \n for i in range(-5, 6) if i != 0\n ])\n \n self.play(Transform(prior_curve, pert_prior), run_time=1.5)\n \n # Show difference due to perturbation\n diff_text = Text(\"+ 1 added to x^2 term\\nin prior curve\", font_size=20, color=RED)\n diff_text.next_to(Title, DOWN)\n self.play(Write(diff_text))\n \n # Reset to original state\n reset_prio = VMobject().set_points_as_corners([\n [i, i**2 + 2*i + 1, 0]\n for i in range(-5, 7)\n ])\n self.play(Transform(prior_curve, reset_prio), FadeOut(diff_text), run_time=1.5)\n\n # Add Likelihood Shift\n self.play(FadeIn(like_curve), run_time=0.5)\n\n # Compare Scenarios\n compare_title = Text(\"\\nCompare Scenarios with Different Parameters:\", font_size=24, color=YELLOW)\n compare_title.to_edge(LEFT)\n \n self.play(Write(compare_title))\n self.wait(1)\n self.play(FadeOut(Title), FadeOut(diff_text), run_time=0.5)\n\n # Plot Parameter Grid\n param_grid = VGroup()\n labels = [\"Param A\", \"Param B\"]\n \n for i, label in enumerate(labels):\n dot = Dot(radius=0.08, color=BLUE).move_to(RIGHT*(i-1)*3 + UP*2)\n text = MathTex(label, color=WHITE).scale(0.6).next_to(dot, DOWN)\n \n param_group = VGroup(dot, text)\n param_grid.add(param_group)\n \n if i == 0:\n self.play(GrowFromCenter(dot), Write(text))\n self.wait(1)\n else:\n self.play(GrowFromCenter(dot), Write(text), run_time=1.5)\n \n # Animate transition between scenarios\n self.play(MoveAlongPath(prior_curve, Line(start=pert_prior.get_start(), end=pert_prior.get_end())),\n MoveAlongPath(like_curve, Line(start=like_curve.get_start(), end=like_curve.get_end())),\n rate_func=smooth,\n run_time=2)\n \n\n self.wait(2)\n self.play(FadeOut(prior_curve), FadeOut(like_curve), FadeOut(param_grid))\n \n final_msg = Text(\"Conclude: Model is sensitive to specific parameters.\\nConsider regularization or constraints.\", font_size=22)\n self.play(Write(final_msg))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Color Configuration ---\n COLOR_BOUNDS = YELLOW\n COLOR_FUNC = BLUE\n COLOR_RESULT = GREEN\n\n # --- Step 1: Introduction ---\n problem = MathTex(r\"\\int_{0}^{2}\", r\"x^3\", r\"\\,dx\", font_size=72)\n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Bounds Highlight ---\n problem.set_color_by_tex(\"0\", COLOR_BOUNDS)\n problem.set_color_by_tex(\"2\", COLOR_BOUNDS)\n \n self.play(Indicate(problem[0]))\n self.wait(1)\n self.play(problem.animate.shift(UP * 2))\n\n # --- Step 3: Concept Explanation (Power Rule) ---\n rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n color=COLOR_FUNC, \n font_size=48\n )\n rule_label = Text(\"Power Rule for Integration\", font_size=30, color=GRAY).next_to(rule, UP)\n rule_group = VGroup(rule_label, rule).center()\n \n self.play(FadeIn(rule_group))\n self.wait(1)\n\n # Show n=3 application\n application = MathTex(\n r\"n=3 \\implies \\frac{x^{3+1}}{3+1} = \\frac{x^4}{4}\", \n font_size=42\n ).next_to(rule, DOWN, buff=0.5)\n \n self.play(Write(application))\n self.wait(2)\n self.play(FadeOut(rule_group), FadeOut(application))\n\n # --- Step 4: Step-by-Step Integration ---\n antiderivative = MathTex(\n r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=72\n ).move_to(problem)\n \n self.play(Transform(problem, antiderivative))\n self.wait(1)\n\n # --- Step 5: Limit Substitution ---\n substitution = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=60\n ).next_to(problem, DOWN, buff=0.8)\n \n self.play(Write(substitution))\n self.wait(1)\n\n # --- Step 6: Evaluation ---\n evaluation1 = MathTex(\n r\"= \\frac{16}{4} - 0\", \n font_size=60\n ).next_to(substitution, DOWN, buff=0.8)\n \n evaluation2 = MathTex(\n r\"= 4\", \n font_size=80, \n color=COLOR_RESULT\n ).next_to(evaluation1, DOWN, buff=0.8)\n\n self.play(Write(evaluation1))\n self.wait(1)\n self.play(Write(evaluation2))\n \n box = SurroundingRectangle(evaluation2, color=COLOR_RESULT, buff=0.2)\n self.play(DrawBorderThenFill(box))\n self.wait(2)\n\n # Clear screen for conclusion\n self.play(\n FadeOut(problem), FadeOut(substitution), \n FadeOut(evaluation1), FadeOut(evaluation2), FadeOut(box)\n )\n\n # --- Step 7: Conclusion: Area under the curve ---\n axes = Axes(\n x_range=[0, 2.5, 0.5], \n y_range=[0, 9, 1], \n axis_config={\"include_tip\": True}\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)=x^3\")\n graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=COLOR_FUNC)\n area = axes.get_area(graph, x_range=[0, 2], color=COLOR_RESULT, opacity=0.5)\n \n area_label = MathTex(\n r\"\\text{Area} = 4\", \n color=COLOR_RESULT, \n font_size=50\n ).move_to(axes.c2p(1, 2))\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), run_time=2)\n self.play(FadeIn(area))\n self.play(Write(area_label))\n \n # Final emphasis\n self.play(Indicate(area_label), Indicate(area))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Color Configuration ---\n COLOR_BOUNDS = YELLOW\n COLOR_FUNC = BLUE\n COLOR_RESULT = GREEN\n\n # --- Step 1: Introduction ---\n problem = MathTex(r\"\\int_{0}^{2}\", r\"x^3\", r\"\\,dx\", font_size=72)\n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Bounds Highlight ---\n problem.set_color_by_tex(\"0\", COLOR_BOUNDS)\n problem.set_color_by_tex(\"2\", COLOR_BOUNDS)\n \n self.play(Indicate(problem[0]))\n self.wait(1)\n self.play(problem.animate.shift(UP * 2))\n\n # --- Step 3: Concept Explanation (Power Rule) ---\n rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n color=COLOR_FUNC, \n font_size=48\n )\n rule_label = Text(\"Power Rule for Integration\", font_size=30, color=GRAY).next_to(rule, UP)\n rule_group = VGroup(rule_label, rule).center()\n \n self.play(FadeIn(rule_group))\n self.wait(1)\n\n # Show n=3 application\n application = MathTex(\n r\"n=3 \\implies \\frac{x^{3+1}}{3+1} = \\frac{x^4}{4}\", \n font_size=42\n ).next_to(rule, DOWN, buff=0.5)\n \n self.play(Write(application))\n self.wait(2)\n self.play(FadeOut(rule_group), FadeOut(application))\n\n # --- Step 4: Step-by-Step Integration ---\n antiderivative = MathTex(\n r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", \n font_size=72\n ).move_to(problem)\n \n self.play(Transform(problem, antiderivative))\n self.wait(1)\n\n # --- Step 5: Limit Substitution ---\n substitution = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=60\n ).next_to(problem, DOWN, buff=0.8)\n \n self.play(Write(substitution))\n self.wait(1)\n\n # --- Step 6: Evaluation ---\n evaluation1 = MathTex(\n r\"= \\frac{16}{4} - 0\", \n font_size=60\n ).next_to(substitution, DOWN, buff=0.8)\n \n evaluation2 = MathTex(\n r\"= 4\", \n font_size=80, \n color=COLOR_RESULT\n ).next_to(evaluation1, DOWN, buff=0.8)\n\n self.play(Write(evaluation1))\n self.wait(1)\n self.play(Write(evaluation2))\n \n box = SurroundingRectangle(evaluation2, color=COLOR_RESULT, buff=0.2)\n self.play(DrawBorderThenFill(box))\n self.wait(2)\n\n # Clear screen for conclusion\n self.play(\n FadeOut(problem), FadeOut(substitution), \n FadeOut(evaluation1), FadeOut(evaluation2), FadeOut(box)\n )\n\n # --- Step 7: Conclusion: Area under the curve ---\n axes = Axes(label_font_size=24, \n x_range=[0, 2.5, 0.5], \n y_range=[0, 9, 1], \n axis_config={\"include_tip\": True}\n ).scale(0.8)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)=x^3\")\n graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=COLOR_FUNC)\n area = axes.get_area(graph, x_range=[0, 2], color=COLOR_RESULT, opacity=0.5)\n \n area_label = MathTex(\n r\"\\text{Area} = 4\", \n color=COLOR_RESULT, \n font_size=50\n ).move_to(axes.c2p(1, 2))\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), run_time=2)\n self.play(FadeIn(area))\n self.play(Write(area_label))\n \n # Final emphasis\n self.play(Indicate(area_label), Indicate(area))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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, evaluating the bounds, and then revealing the final answer, with written explanations accompanying each step?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralSine(Scene):\n def construct(self):\n # --- Configuration ---\n text_color = WHITE\n highlight_color = YELLOW\n \n # --- Title ---\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # --- Step 1: The Problem ---\n problem = MathTex(\n r\"\\int_{0}^{\\pi}\", r\"\\sin(x)\", r\"\\,dx\", font_size=60\n ).shift(UP * 1)\n problem.set_color_by_tex(\"sin\", BLUE)\n \n explanation1 = Text(\n \"Step 1: Identify the integral problem.\", \n font_size=30, color=text_color\n ).next_to(problem, DOWN, buff=1)\n\n self.play(Write(problem))\n self.play(FadeIn(explanation1))\n self.wait(2)\n\n # --- Step 2: The Antiderivative ---\n antiderivative_step = MathTex(\n r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\", font_size=60\n ).next_to(problem, RIGHT, buff=0.5)\n antiderivative_step.set_color_by_tex(\"cos\", GREEN)\n \n full_eq1 = VGroup(problem, antiderivative_step).center()\n \n explanation2 = Text(\n \"The antiderivative of sin(x) is -cos(x).\", \n font_size=30, color=text_color\n ).next_to(full_eq1, DOWN, buff=1)\n\n self.play(Write(antiderivative_step))\n self.play(FadeOut(explanation1), FadeIn(explanation2))\n self.wait(2)\n\n # --- Step 3: Evaluating the Bounds ---\n self.play(\n full_eq1.animate.shift(UP * 1),\n explanation2.animate.shift(UP * 1)\n )\n\n evaluation_step = MathTex(\n r\"=\", r\"\\left( -\\cos(\\pi) \\right)\", r\"-\", r\"\\left( -\\cos(0) \\right)\", font_size=60\n ).next_to(full_eq1, DOWN, buff=0.5)\n evaluation_step.set_color_by_tex(\"cos\", GREEN)\n\n explanation3 = Text(\n \"Step 2: Apply the Fundamental Theorem of Calculus: F(b) - F(a).\", \n font_size=30, color=text_color\n ).next_to(evaluation_step, DOWN, buff=1)\n\n self.play(Write(evaluation_step))\n self.play(FadeIn(explanation3))\n self.wait(2)\n\n # --- Step 4: Substitution ---\n substitution_step = MathTex(\n r\"=\", r\"\\left( -(-1) \\right)\", r\"-\", r\"\\left( -(1) \\right)\", font_size=60\n ).next_to(evaluation_step, DOWN, buff=0.5)\n substitution_step.set_color_by_tex(\"1\", YELLOW)\n\n explanation4 = Text(\n \"Substitute values: cos(\\pi ) = -1 and cos(0) = 1.\", \n font_size=30, color=text_color\n ).next_to(substitution_step, DOWN, buff=0.5)\n\n self.play(\n FadeOut(explanation3),\n Write(substitution_step),\n FadeIn(explanation4)\n )\n self.wait(2)\n\n # --- Step 5: Final Answer ---\n final_answer = MathTex(\n r\"=\", r\"1\", r\"+\", r\"1\", r\"=\", r\"2\", font_size=70, color=highlight_color\n ).next_to(substitution_step, DOWN, buff=0.8)\n\n explanation_final = Text(\n \"Final Result: The area under the curve is 2.\", \n font_size=30, color=highlight_color\n ).next_to(final_answer, DOWN, buff=0.5)\n\n self.play(\n FadeOut(explanation4),\n Write(final_answer),\n FadeIn(explanation_final)\n )\n \n # Highlight box around the final answer\n box = SurroundingRectangle(final_answer, color=highlight_color, buff=MED_LARGE_BUFF)\n self.play(Create(box))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSine(Scene):\n def construct(self):\n # --- Configuration ---\n text_color = WHITE\n highlight_color = YELLOW\n \n # --- Title ---\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # --- Step 1: The Problem ---\n problem = MathTex(r\"\\int_{0}^{\\pi}\" + \" = x\", r\"\\sin(x)\", r\"\\,dx\", font_size=60\n ).shift(UP * 1)\n problem.set_color_by_tex(\"sin\", BLUE)\n \n explanation1 = Text(\n \"Step 1: Identify the integral problem.\", \n font_size=30, color=text_color\n ).next_to(problem, DOWN, buff=1)\n\n self.play(Write(problem))\n self.play(FadeIn(explanation1))\n self.wait(2)\n\n # --- Step 2: The Antiderivative ---\n antiderivative_step = MathTex(\n r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\", font_size=60\n ).next_to(problem, RIGHT, buff=0.5)\n antiderivative_step.set_color_by_tex(\"cos\", GREEN)\n \n full_eq1 = VGroup(problem, antiderivative_step).center()\n \n explanation2 = Text(\n \"The antiderivative of sin(x) is -cos(x).\", \n font_size=30, color=text_color\n ).next_to(full_eq1, DOWN, buff=1)\n\n self.play(Write(antiderivative_step))\n self.play(FadeOut(explanation1), FadeIn(explanation2))\n self.wait(2)\n\n # --- Step 3: Evaluating the Bounds ---\n self.play(\n full_eq1.animate.shift(UP * 1),\n explanation2.animate.shift(UP * 1)\n )\n\n evaluation_step = MathTex(\n r\"=\", r\"\\left( -\\cos(\\pi) \\right)\", r\"-\", r\"\\left( -\\cos(0) \\right)\", font_size=60\n ).next_to(full_eq1, DOWN, buff=0.5)\n evaluation_step.set_color_by_tex(\"cos\", GREEN)\n\n explanation3 = Text(\n \"Step 2: Apply the Fundamental Theorem of Calculus: F(b) - F(a).\", \n font_size=30, color=text_color\n ).next_to(evaluation_step, DOWN, buff=1)\n\n self.play(Write(evaluation_step))\n self.play(FadeIn(explanation3))\n self.wait(2)\n\n # --- Step 4: Substitution ---\n substitution_step = MathTex(\n r\"=\", r\"\\left( -(-1) \\right)\", r\"-\", r\"\\left( -(1) \\right)\", font_size=60\n ).next_to(evaluation_step, DOWN, buff=0.5)\n substitution_step.set_color_by_tex(\"1\", YELLOW)\n\n explanation4 = Text(\n \"Substitute values: cos(\\pi ) = -1 and cos(0) = 1.\", \n font_size=30, color=text_color\n ).next_to(substitution_step, DOWN, buff=0.5)\n\n self.play(\n FadeOut(explanation3),\n Write(substitution_step),\n FadeIn(explanation4)\n )\n self.wait(2)\n\n # --- Step 5: Final Answer ---\n final_answer = MathTex(\n r\"=\", r\"1\", r\"+\", r\"1\", r\"=\", r\"2\", font_size=70, color=highlight_color\n ).next_to(substitution_step, DOWN, buff=0.8)\n\n explanation_final = Text(\n \"Final Result: The area under the curve is 2.\", \n font_size=30, color=highlight_color\n ).next_to(final_answer, DOWN, buff=0.5)\n\n self.play(\n FadeOut(explanation4),\n Write(final_answer),\n FadeIn(explanation_final)\n )\n \n # Highlight box around the final answer\n box = SurroundingRectangle(final_answer, color=highlight_color, buff=MED_LARGE_BUFF)\n self.play(Create(box))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a **Rectangle** (width=4, height=2) appearing at the center of the screen. Instead of simply moving to (1, 1), the rectangle now **animates smoothly** from the center to its target position while **changing color** from blue to red. As it moves, a **mathematical formula** (e.g., the area calculation `A = width × height = 4 × 2 = 8`) fades in below it, dynamically updating as the rectangle’s dimensions shift. Once the rectangle reaches (1, 1), it **rotates 90 degrees** clockwise, and a **highlighting effect** (a glowing border) emphasizes its final position. Finally, **explanatory text** (\"Rectangle Transformation\") appears at the top of the screen, tying together the visual and mathematical concepts. This enhanced version not only preserves the original movement but also incorporates **dynamic formulas, color transitions, rotational animation, and explanatory text** for a more engaging and educational presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle and Position Tracking\n rect = RoundedRectangle(\n width=4,\n height=2,\n corner_radius=0.1\n )\n \n # Initialize math labels for calculations\n calc_label_start = MathTex(\"A = w \\\\times h = 4 \\\\times 2 = 8\").to_edge(DOWN)\n calc_label_end = MathTex(\"Area = 8\", \"\\\\text{ units}^2\").next_to(rect, DOWN)\n\n # Animate Appearance and Movement\n self.play(Create(rect))\n self.wait(0.5)\n \n # Smoothly move to target position (1, 1)\n self.play(\n rect.animate.shift(RIGHT + UP).set_color(RED),\n Write(calc_label_start), \n run_time=2\n )\n\n # Rotate by 90 degrees clock-wise\n self.play(Rotate(rect, angle=-PI/2, about_point=rect.get_center()), run_time=1.5)\n self.wait(0.5)\n\n # Add highlighting effect\n highlight_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.1)\n self.play(Create(highlight_rect))\n\n # Display Explanatory Text\n title_text = Tex(\"Rectangle Transformation\", font_size=36).to_edge(UP)\n self.play(FadeIn(title_text))\n \n # Update math label to reflect new orientation/state\n self.play(Transform(calc_label_start, calc_label_end))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle\n rect = Rectangle(width=4, height=2)\n \n # Initial Position\n rect.move_to(ORIGIN)\n\n # Target Position\n target_pos = np.array([1, 1, 0])\n\n # Color Transition\n initial_color = BLUE\n target_color = RED\n\n # Mathematical Formula\n math_text = MathTex(\n \"A\", \"=\", \"w\", \"\\\\times\", \"h\", \"=\",\n str(rect.width), \"\\\\times\", str(rect.height),\n \"=\", str(rect.get_area())\n ).next_to(rect, DOWN)\n\n # Explanatory Text\n title_text = Text(\"Rectangle Transformation\").to_edge(UP)\n\n # Animation Sequence\n self.play(Create(title_text))\n self.play(FadeIn(math_text))\n self.play(\n MoveAlongPath(rect, Line(ORIGIN, target_pos)),\n rect.animate.set_fill(target_color).set_stroke(target_color),\n run_time=2\n )\n self.play(Rotate(rect, angle=-PI/2))\n self.play(\n RectLengthAndWidthFromVerticesAnim(rect, [rect.right, rect.up + rect.left]),\n FadeOut(math_text),\n Write(MathTex(\"A = 8\"))\n )\n\n # Highlight Effect\n glow_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.2, stroke_width=12)\n self.play(Create(glow_rect))\n\n# To render this animation, save the code to a file called 'enhanced_rectangle_scene.py'\n# Then run the command: manim -pql enhanced_rectangle_scene.py EnhancedRectangleScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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:\n- Act 2: Here’s an enhanced version of the animation that retains all the original features while adding a dynamic mathematical formula, explanatory text, and a transformation sequence: \n- Act 3: 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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0020(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_lineartoquadratic()\n self.clear_stage()\n self.act_2_broadcastwaveequation()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_lineartoquadratic(self):\n line = Line(start=(-2, 0, 0), end=(2, 0, 0), color=GREEN)\n self.add(line)\n \n # Create axes\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\n \"numbers_to_include\": [-2, -1, 0, 1, 2],\n },\n )\n axes_labels = axes.get_axis_labels()\n axes_group = VGroup(axes, axes_labels)\n axes_group.set_opacity(0)\n self.add(axes_group)\n \n # Fade in axes\n self.play(FadeIn(axes_group))\n \n # Pulse line color\n for _ in range(3):\n self.play(\n line.animate.set_color(BLUE),\n run_time=0.5\n )\n self.play(\n line.animate.set_color(GREEN),\n run_time=0.5\n )\n \n # Transform line to parabola\n parabola = axes.plot(lambda x: x**2, color=GREEN)\n self.play(Transform(line, parabola), run_time=2)\n \n # Add equation\n equation = MathTex(\"y\", \"=\", \"x^2\").to_edge(UP)\n equation[0].set_opacity(0)\n equation[1].set_opacity(0)\n equation[2].set_opacity(0)\n self.add(equation)\n \n # Animate equation parts\n self.play(FadeIn(equation[0]))\n self.wait(0.3)\n self.play(FadeIn(equation[1]))\n self.wait(0.3)\n self.play(FadeIn(equation[2]))\n \n # Group all elements\n all_elements = VGroup(axes_group, line, equation)\n \n # Center and scale down\n self.play(\n all_elements.animate.scale(0.8).move_to(ORIGIN),\n run_time=1.5\n )\n \n # Add caption\n caption = Text(\"Linear to Quadratic Transformation\", font_size=24).to_edge(DOWN)\n caption.set_opacity(0)\n self.play(FadeIn(caption))\n \n self.wait(2)\n\n def act_2_broadcastwaveequation(self):\n text = Text(\"Broadcast\").to_edge(UP)\n self.play(Write(text))\n self.wait(0.5)\n\n # Create the triangle and broadcast effect\n triangle = Triangle().scale(0.5).set_fill(BLUE, opacity=1)\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Broadcast effect\n circles = VGroup()\n for i in range(1, 4):\n circle = Circle(radius=i * 0.5, color=BLUE, stroke_width=2).move_to(triangle.get_center())\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles], lag_ratio=0.3),\n run_time=2\n )\n self.wait(0.5)\n\n # Transform triangle into circle\n circle = Circle(radius=0.5, color=GREEN, fill_opacity=1).move_to(triangle.get_center())\n self.play(Transform(triangle, circle))\n self.wait(0.5)\n\n # Display wave equation and label\n equation = MathTex(\n r\"\\nabla^2 \\phi = \\frac{1}{v^2} \\frac{\\partial^2 \\phi}{\\partial t^2}\",\n color=YELLOW\n ).next_to(text, DOWN, buff=1.0)\n \n label = Text(\"Wave Propagation\", color=WHITE).next_to(equation, RIGHT, buff=0.5)\n \n self.play(Write(equation), FadeIn(label))\n self.wait(2)\n\n # Fade out everything\n self.play(\n FadeOut(text),\n FadeOut(triangle),\n FadeOut(circles),\n FadeOut(equation),\n FadeOut(label)\n )\n\n def act_3_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=72, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. The word moves upward\n self.play(text.animate.shift(UP * 2.5), run_time=1)\n self.wait(0.2)\n\n # 3. A triangle shape appears\n triangle = Triangle(color=BLUE, fill_opacity=0.8)\n triangle.set_height(1.5)\n triangle.move_to(ORIGIN)\n self.play(FadeIn(triangle, scale=0.5), run_time=1)\n\n # Broadcast Signal: Expanding concentric rings\n waves = VGroup()\n for i in range(4):\n ring = Circle(radius=0.1, color=BLUE_A)\n ring.move_to(triangle.get_center())\n ring.set_stroke(width=4, opacity=0.8)\n waves.add(ring)\n\n # Animate the signal emission with a staggered, continuous effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(20).set_stroke(opacity=0)\n for wave in waves\n ],\n lag_ratio=0.3,\n run_time=2.5,\n rate_func=linear\n )\n )\n self.wait(0.5)\n\n # 4. The triangle disappears\n self.play(FadeOut(triangle, scale=0.5), run_time=0.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0020(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_lineartoquadratic()\n self.clear_stage()\n self.act_2_broadcastwaveequation()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_lineartoquadratic(self):\n line = Line(start=(-2, 0, 0), end=(2, 0, 0), color=GREEN)\n self.add(line)\n \n # Create axes\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE},\n x_axis_config={\n \"numbers_to_include\": [-2, -1, 0, 1, 2],\n },\n )\n axes_labels = axes.get_axis_labels()\n axes_group = VGroup(axes, axes_labels)\n axes_group.set_opacity(0)\n self.add(axes_group)\n \n # Fade in axes\n self.play(FadeIn(axes_group))\n \n # Pulse line color\n for _ in range(3):\n self.play(\n line.animate.set_color(BBLUE),\n run_time=0.5\n )\n self.play(\n line.animate.set_color(GREEN),\n run_time=0.5\n )\n \n # Transform line to parabola\n parabola = axes.plot(lambda x: x**2, color=GREEN)\n self.play(Transform(line, parabola), run_time=2)\n \n # Add equation\n equation = MathTex(\"y\", \"=\", \"x^2\").to_edge(UP)\n equation[0].set_opacity(0)\n equation[1].set_opacity(0)\n equation[2].set_opacity(0)\n self.add(equation)\n \n # Animate equation parts\n self.play(FadeIn(equation[0]))\n self.wait(0.3)\n self.play(FadeIn(equation[1]))\n self.wait(0.3)\n self.play(FadeIn(equation[2]))\n \n # Group all elements\n all_elements = VGroup(axes_group, line, equation)\n \n # Center and scale down\n self.play(\n all_elements.animate.scale(0.8).move_to(ORIGIN),\n run_time=1.5\n )\n \n # Add caption\n caption = Text(\"Linear to Quadratic Transformation\", font_size=24).to_edge(DOWN)\n caption.set_opacity(0)\n self.play(FadeIn(caption))\n \n self.wait(2)\n\n def act_2_broadcastwaveequation(self):\n text = Text(\"Broadcast\").to_edge(UP)\n self.play(Write(text))\n self.wait(0.5)\n\n # Create the triangle and broadcast effect\n triangle = Triangle().scale(0.5).set_fill(BLUE, opacity=1)\n self.play(Create(triangle))\n self.wait(0.5)\n\n # Broadcast effect\n circles = VGroup()\n for i in range(1, 4):\n circle = Circle(radius=i * 0.5, color=BLUE, stroke_width=2).move_to(triangle.get_center())\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles], lag_ratio=0.3),\n run_time=2\n )\n self.wait(0.5)\n\n # Transform triangle into circle\n circle = Circle(radius=0.5, color=GREEN, fill_opacity=1).move_to(triangle.get_center())\n self.play(Transform(triangle, circle))\n self.wait(0.5)\n\n # Display wave equation and label\n equation = MathTex(\n r\"\\nabla^2 \\phi = \\frac{1}{v^2} \\frac{\\partial^2 \\phi}{\\partial t^2}\",\n color=YELLOW\n ).next_to(text, DOWN, buff=1.0)\n \n label = Text(\"Wave Propagation\", color=WHITE).next_to(equation, RIGHT, buff=0.5)\n \n self.play(Write(equation), FadeIn(label))\n self.wait(2)\n\n # Fade out everything\n self.play(\n FadeOut(text),\n FadeOut(triangle),\n FadeOut(circles),\n FadeOut(equation),\n FadeOut(label)\n )\n\n def act_3_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=72, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. The word moves upward\n self.play(text.animate.shift(UP * 2.5), run_time=1)\n self.wait(0.2)\n\n # 3. A triangle shape appears\n triangle = Triangle(color=BLUE, fill_opacity=0.8)\n triangle.set_height(1.5)\n triangle.move_to(ORIGIN)\n self.play(FadeIn(triangle, scale=0.5), run_time=1)\n\n # Broadcast Signal: Expanding concentric rings\n waves = VGroup()\n for i in range(4):\n ring = Circle(radius=0.1, color=BLUE_A)\n ring.move_to(triangle.get_center())\n ring.set_stroke(width=4, opacity=0.8)\n waves.add(ring)\n\n # Animate the signal emission with a staggered, continuous effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(20).set_stroke(opacity=0)\n for wave in waves\n ],\n lag_ratio=0.3,\n run_time=2.5,\n rate_func=linear\n )\n )\n self.wait(0.5)\n\n # 4. The triangle disappears\n self.play(FadeOut(triangle, scale=0.5), run_time=0.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 below it. Then, below the formula, can there be an arrow pointing downward to the expanded form of Euler's Formula, \"cos(x) = (e^(ix) + e^(-ix))/2\"? Afterward, I'd like all the elements on the screen to fade out and be replaced by the title \"Euler's Formula Transformation\" at the top of the screen in yellow. Finish up the animation by replacing the title with \"Euler's Identity\" and write out Euler’s famous identity \"e^(iπ) + 1 = 0\" below the title. Make sure each part of the animation is clear and give a brief pause between transitions so viewers can follow along.", "chosen": "```python\nfrom manim import *\n\nclass EulersFormulaScene(Scene):\n def construct(self):\n # --- 1. Initial Scene ---\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```", "rejected": "```python\nfrom manim import *\n\nclass EulersFormulaScene(Scene):\n def construct(self):\n # --- 1. Initial Scene ---\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\" + \" = x\", 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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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# Introduction to the Coq Verification Tool: Simple Proofs and Definitions\n\n\n\n## Prelude: From Classical Problems to Formalization\n\nThe first step in formal verification is to transform a problem described in natural language into a logical proposition that a computer can understand.", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CoqLecture(Scene):\n\n def construct(self):\n main_title = Text('Introduction to the Coq Verification Tool', font_size=42, weight=BOLD)\n subtitle = Text('Simple Proofs and Definitions', font_size=32, color=BLUE)\n title_group = VGroup(main_title, subtitle).arrange(DOWN, buff=0.5)\n self.play(FadeIn(title_group, shift=UP))\n self.wait(2.5)\n self.play(FadeOut(title_group, shift=UP))\n section_title = Text('Prelude: From Classical Problems to Formalization', font_size=36, color=YELLOW)\n section_title.to_edge(UP, buff=1.0)\n self.play(Write(section_title))\n self.wait(1)\n content_text = Paragraph('The first step in formal verification is to transform', 'a problem described in natural language into a', 'logical proposition that a computer can understand.', alignment='center', font_size=28, line_spacing=1.2)\n content_text.next_to(section_title, DOWN, buff=1.0)\n self.play(FadeIn(content_text))\n self.wait(2)\n nl_text = Text('Natural Language', font_size=24)\n nl_box = SurroundingRectangle(nl_text, color=BLUE, corner_radius=0.2, buff=0.2)\n nl_group = VGroup(nl_box, nl_text)\n transform_arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1)\n transform_arrow.scale(1.5)\n lp_text = Text('Logical Proposition', font_size=24)\n lp_box = SurroundingRectangle(lp_text, color=GREEN, corner_radius=0.2, buff=0.2)\n lp_group = VGroup(lp_box, lp_text)\n diagram_group = VGroup(nl_group, transform_arrow, lp_group).arrange(RIGHT, buff=0.8)\n diagram_group.next_to(content_text, DOWN, buff=1.5)\n self.play(Create(nl_box), Write(nl_text))\n self.wait(0.5)\n self.play(GrowArrow(transform_arrow))\n self.wait(0.5)\n self.play(Create(lp_box), Write(lp_text))\n computer_icon = SVGMobject('computer') if False else Text('💻', font_size=36)\n computer_icon.next_to(lp_group, DOWN, buff=0.5)\n self.play(FadeIn(computer_icon, shift=UP))\n self.wait(4)\n self.play(FadeOut(Group(*self.mobjects)))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CoqLecture(Scene):\n\n def construct(self):\n main_title = Text('Introduction to the Coq Verification Tool', font_size=42, weight=BOLD)\n subtitle = Text('Simple Proofs and Definitions', font_size=32, color=BBLUE)\n title_group = VGroup(main_title, subtitle).arrange(DOWN, buff=0.5)\n self.play(FadeIn(title_group, shift=UP))\n self.wait(2.5)\n self.play(FadeOut(title_group, shift=UP))\n section_title = Text('Prelude: From Classical Problems to Formalization', font_size=36, color=YELLOW)\n section_title.to_edge(UP, buff=1.0)\n self.play(Write(section_title))\n self.wait(1)\n content_text = Paragraph('The first step in formal verification is to transform', 'a problem described in natural language into a', 'logical proposition that a computer can understand.', alignment='center', font_size=28, line_spacing=1.2)\n content_text.next_to(section_title, DOWN, buff=1.0)\n self.play(FadeIn(content_text))\n self.wait(2)\n nl_text = Text('Natural Language', font_size=24)\n nl_box = SurroundingRectangle(nl_text, color=BLUE, corner_radius=0.2, buff=0.2)\n nl_group = VGroup(nl_box, nl_text)\n transform_arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1)\n transform_arrow.scale(1.5)\n lp_text = Text('Logical Proposition', font_size=24)\n lp_box = SurroundingRectangle(lp_text, color=GREEN, corner_radius=0.2, buff=0.2)\n lp_group = VGroup(lp_box, lp_text)\n diagram_group = VGroup(nl_group, transform_arrow, lp_group).arrange(RIGHT, buff=0.8)\n diagram_group.next_to(content_text, DOWN, buff=1.5)\n self.play(Create(nl_box), Write(nl_text))\n self.wait(0.5)\n self.play(GrowArrow(transform_arrow))\n self.wait(0.5)\n self.play(Create(lp_box), Write(lp_text))\n computer_icon = SVGMobject('computer') if False else Text('💻', font_size=36)\n computer_icon.next_to(lp_group, DOWN, buff=0.5)\n self.play(FadeIn(computer_icon, shift=UP))\n self.wait(4)\n self.play(FadeOut(Group(*self.mobjects)))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an educational animation that visually demonstrates an atom with a nucleus and three electrons orbiting around it. The nucleus should appear as a red dot in the center, with the electrons being small blue dots moving in a circular path, representing their orbit. The orbit path itself should be a visible circle. First, I'd like to see the atom being assembled piece by piece — the nucleus appears, then the orbit path, followed by the electrons. After the atom is assembled, the electrons should start to move around the nucleus continuously. Once that is established, I want the entire atom to move to the left side of the screen. Then, I'd like a replica of the original atom to appear and move to the right side of the screen. To conclude the animation, I would like both atoms to fade away, leaving the screen empty. Can we make this animation clear, visually appealing, and scientifically accurate for educational purposes?", "chosen": "```python\nfrom manim import *\n\nclass Atom(VGroup):\n \"\"\"\n A custom VGroup representing a Bohr model atom with a nucleus,\n an orbit path, and three evenly spaced orbiting electrons.\n \"\"\"\n def __init__(self, orbit_radius=1.5, **kwargs):\n super().__init__(**kwargs)\n \n # Visual Parameters\n self.orbit_radius = orbit_radius\n \n # 1. Nucleus\n self.nucleus = Dot(color=RED, radius=0.2)\n \n # 2. Orbit Path\n self.orbit = Circle(radius=orbit_radius, color=WHITE, stroke_width=2)\n \n # 3. Electrons (Positioned at 0, 120, 240 degrees)\n self.electrons = VGroup(*[\n Dot(color=BLUE, radius=0.1).move_to(\n self.orbit.point_from_proportion(i / 3)\n )\n for i in range(3)\n ])\n \n # Assemble the atom\n self.add(self.nucleus, self.orbit, self.electrons)\n \n # Updater reference for clean removal\n self._updater = None\n\n def start_orbiting(self, angular_speed=TAU / 2):\n \"\"\"Starts the continuous orbital motion of electrons.\"\"\"\n # Use a ValueTracker to smoothly handle rotation state across animations\n self.tracker = ValueTracker(0)\n \n def orbit_updater(mob, dt):\n # Increment tracker and rotate electrons around the nucleus center\n mob.tracker.increment_value(dt * angular_speed)\n angle = mob.tracker.get_value()\n for i, electron in enumerate(mob.electrons):\n offset = i * (TAU / 3)\n electron.move_to([\n mob.orbit_radius * np.cos(angle + offset),\n mob.orbit_radius * np.sin(angle + offset),\n 0\n ])\n \n self.add_updater(orbit_updater)\n self._updater = orbit_updater\n\n def stop_orbiting(self):\n \"\"\"Stops the orbital motion and cleans up updaters.\"\"\"\n if self._updater:\n self.remove_updater(self._updater)\n self._updater = None\n\n\nclass AtomAnimation(Scene):\n def construct(self):\n # --- Phase 1: Assembly ---\n atom1 = Atom()\n self.add(atom1)\n atom1.set_opacity(0) # Hide initially to animate submobjects\n \n # Animate Assembly Sequence: Nucleus -> Orbit -> Electrons\n self.play(FadeIn(atom1.nucleus), run_time=1.0)\n self.play(Create(atom1.orbit), run_time=1.0)\n self.play(FadeIn(atom1.electrons), run_time=1.0)\n atom1.set_opacity(1)\n \n # --- Phase 2: Orbital Motion ---\n atom1.start_orbiting()\n self.wait(2.0)\n \n # --- Phase 3: Translation to Left ---\n # Updaters persist, so electrons continue orbiting during the shift\n self.play(atom1.animate.shift(LEFT * 3.5), run_time=2.0)\n \n # --- Phase 4: Replication ---\n # Create a fresh instance to prevent updater reference bugs\n atom2 = Atom()\n atom2.move_to(ORIGIN)\n atom2.start_orbiting()\n \n # Animate appearance and movement to the right\n self.play(\n FadeIn(atom2),\n atom2.animate.shift(RIGHT * 3.5),\n run_time=2.0\n )\n self.wait(1.0)\n \n # --- Phase 5: Conclusion ---\n # Stop updaters before fading out to ensure clean removal\n atom1.stop_orbiting()\n atom2.stop_orbiting()\n \n self.play(\n FadeOut(atom1),\n FadeOut(atom2),\n run_time=1.5\n )\n \n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass Atom(VGroup):\n \"\"\"\n A custom VGroup representing a Bohr model atom with a nucleus,\n an orbit path, and three evenly spaced orbiting electrons.\n \"\"\"\n def __init__(self, orbit_radius=1.5, **kwargs):\n super().__init__(**kwargs)\n \n # Visual Parameters\n self.orbit_radius = orbit_radius\n \n # 1. Nucleus\n self.nucleus = Dot(color=RED, radius=0.2)\n \n # 2. Orbit Path\n self.orbit = Circle(radius=orbit_radius, color=WHITE, stroke_width=2)\n \n # 3. Electrons (Positioned at 0, 120, 240 degrees)\n self.electrons = VGroup(*[\n Dot(color=BBLUE, radius=0.1).move_to(\n self.orbit.point_from_proportion(i / 3)\n )\n for i in range(3)\n ])\n \n # Assemble the atom\n self.add(self.nucleus, self.orbit, self.electrons)\n \n # Updater reference for clean removal\n self._updater = None\n\n def start_orbiting(self, angular_speed=TAU / 2):\n \"\"\"Starts the continuous orbital motion of electrons.\"\"\"\n # Use a ValueTracker to smoothly handle rotation state across animations\n self.tracker = ValueTracker(0)\n \n def orbit_updater(mob, dt):\n # Increment tracker and rotate electrons around the nucleus center\n mob.tracker.increment_value(dt * angular_speed)\n angle = mob.tracker.get_value()\n for i, electron in enumerate(mob.electrons):\n offset = i * (TAU / 3)\n electron.move_to([\n mob.orbit_radius * np.cos(angle + offset),\n mob.orbit_radius * np.sin(angle + offset),\n 0\n ])\n \n self.add_updater(orbit_updater)\n self._updater = orbit_updater\n\n def stop_orbiting(self):\n \"\"\"Stops the orbital motion and cleans up updaters.\"\"\"\n if self._updater:\n self.remove_updater(self._updater)\n self._updater = None\n\n\nclass AtomAnimation(Scene):\n def construct(self):\n # --- Phase 1: Assembly ---\n atom1 = Atom()\n self.add(atom1)\n atom1.set_opacity(0) # Hide initially to animate submobjects\n \n # Animate Assembly Sequence: Nucleus -> Orbit -> Electrons\n self.play(FadeIn(atom1.nucleus), run_time=1.0)\n self.play(Create(atom1.orbit), run_time=1.0)\n self.play(FadeIn(atom1.electrons), run_time=1.0)\n atom1.set_opacity(1)\n \n # --- Phase 2: Orbital Motion ---\n atom1.start_orbiting()\n self.wait(2.0)\n \n # --- Phase 3: Translation to Left ---\n # Updaters persist, so electrons continue orbiting during the shift\n self.play(atom1.animate.shift(LEFT * 3.5), run_time=2.0)\n \n # --- Phase 4: Replication ---\n # Create a fresh instance to prevent updater reference bugs\n atom2 = Atom()\n atom2.move_to(ORIGIN)\n atom2.start_orbiting()\n \n # Animate appearance and movement to the right\n self.play(\n FadeIn(atom2),\n atom2.animate.shift(RIGHT * 3.5),\n run_time=2.0\n )\n self.wait(1.0)\n \n # --- Phase 5: Conclusion ---\n # Stop updaters before fading out to ensure clean removal\n atom1.stop_orbiting()\n atom2.stop_orbiting()\n \n self.play(\n FadeOut(atom1),\n FadeOut(atom2),\n run_time=1.5\n )\n \n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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# Computer Vision Course Outline\n\n## 6. Feature Matching and 3D Reconstruction", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ComputerVisionFeatureMatching(Scene):\n def construct(self):\n title = Text(\"Computer Vision\", font_size=48)\n subtitle = Text(\"Feature Matching and 3D Reconstruction\", font_size=32).next_to(title, DOWN, buff=0.3)\n \n # Create grid for outline\n grid = VGroup()\n items = [\n \"Introduction\",\n \"- Overview\\n- Applications\",\n \"\\nImage Processing\",\n \"- Filters\\n- Morphology\",\n \"\\nObject Detection\",\n \"- Edge detection\\n- Hough transform\"\n ]\n \n item_texts = []\n x_offset = 0\n \n for i, text_str in enumerate(items):\n lines = text_str.split('\\n')\n \n if len(lines) > 1:\n box = RoundedRectangle(corner_radius=0.15, width=7.2, height=0.8 * (len(lines)), color=WHITE, fill_opacity=0.1)\n group = VGroup(Text(text_str, t2c={'Overview': BLUE, 'Applications': RED}, font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n \n box.add(group)\n offset_y = (-box.height + group.get_height()) / 2\n \n for line_text in lines:\n new_group = Text(line_text, font_size=24).move_to(ORIGIN).shift(RIGHT * x_offset + UP * offset_y + LEFT * 3.5)\n item_texts.append(new_group)\n \n if line_text.strip():\n self.play(FadeIn(box), Write(group))\n \n else:\n self.play(Create(box))\n break\n \n grid.add(VGroup(box, group))\n x_offset += 8.0\n \n else:\n text_obj = Text(text_str, font_size=24, t2c={'Edge detection': YELLOW, 'Hough transform': GREEN})\n rect = SurroundingRectangle(text_obj, corner_radius=0.15, color=GRAY, stroke_width=2)\n \n group = VGroup(rect, text_obj)\n grid.add(group)\n self.play(Create(rect), FadeIn(text_obj))\n\n title.to_edge(UP)\n subtitle.next_to(title, DOWN, buff=0.3).set_color(YELLOW)\n\n self.play(Write(title), Write(subtitle))\n self.wait(0.5)\n\n for obj in grid:\n self.play(FadeIn(obj, shift=RIGHT * 0.2), run_time=0.8)\n \n feature_matching_box = RoundedRectangle(\n corner_radius=0.2,\n width=3.5,\n height=1.5,\n color=TEAL,\n fill_opacity=0.2\n )\n \n matching_title = Text(\"Feature Matching\", font_size=28, color=TEAL)\n matching_text = Text(\"- Find corresponding points\\nbetween images\", font_size=24, color=GREY)\n matching_group = VGroup(matching_title, matching_text).arrange(DOWN, buff=0.15)\n \n matching_scene = VGroup(feature_matching_box, matching_group).arrange(DOWN, buff=0.5)\n reconstruction_box = RoundedRectangle(\n corner_radius=0.2,\n width=4.0,\n height=1.5,\n color=PURPLE,\n fill_opacity=0.2\n )\n \n rec_title = Text(\"Reconstruction\", font_size=28, color=PURPLE)\n rec_text = Text(\"- Combine matched features\\nto recover depth\", font_size=24, color=GREY)\n rec_group = VGroup(rec_title, rec_text).arrange(DOWN, buff=0.15)\n \n rec_scene = VGroup(reconstruction_box, rec_group).arrange(DOWN, buff=0.5)\n full_rec = VGroup(matching_scene, rec_scene).arrange(RIGHT, buff=0.8)\n full_rec.shift(LEFT * 4.5 + DOWN * 1.5)\n \n path_match = VMobject(color=YELLOW, stroke_width=2)\n match_start = np.array([full_rec[0][0].get_left()[0], full_rec[0][0].get_top()[1], 0])\n match_end = np.array([full_rec[1][0].get_left()[0], full_rec[1][0].get_bottom()[1], 0])\n \n path_match.set_points_as_corners([\n match_start, \n match_start + RIGHT * 1.5 + UP * 1.5,\n match_end + RIGHT * 1.0 + DOWN * 0.5\n ])\n \n arrow_match = Arrow(start=match_start, end=match_end, color=RED, stroke_width=2, buff=0.15)\n label_match = MathTex(\"+\\\\text{ Match}\", font_size=20).next_to(path_match, UP, buff=0.15)\n label_reconstruct = MathTex(\"\\\\rightarrow \\\\text{ Reconstruct } 3D \\\\space Point\", font_size=20).next_to(arrow_match, RIGHT, buff=0.15).to_edge(DOWN)\n \n plane = NumberPlane(x_range=(-10, 10), y_range=(-10, 10), background_line_style={\"stroke_opacity\": 0}).scale(0.4)\n dot = Dot(point=[3, 2, 0]).scale(0.6)\n triangle = Polygon(np.array([-1, 0, 0]), np.array([4, 0, 0]), np.array([4, 3, 0]))\n \n self.wait(1)\n self.play(FadeIn(full_rec, scale=0.5))\n self.wait(1)\n \n self.play(Create(plane), Indicate(dot, color=GREEN))\n self.wait(1)\n \n self.play(MoveAlongPath(plane.copy(), path_match), MoveAlongPath(dot, path_match), run_time=1.5)\n self.wait(1)\n \n self.play(GrowArrow(arrow_match), FadeIn(label_match, label_reconstruct))\n self.wait(1)\n \n self.play(TransformFromCopy(dot, triangle))\n self.wait(1)\n self.play(FadeOut(triangle, dot, path_match, arrow_match, label_match, label_reconstruct, plane))\n self.wait(1)\n self.play(FocusOn(full_rec[0][0]))\n\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass FeatureMatchingAndReconstruction(Scene):\n\n def construct(self):\n title = Text(\"Computer Vision\", font_size=48).to_edge(UP)\n subtitle = Text(\"Feature Matching and 3D Reconstruction\", font_size=36).next_to(title, DOWN, buff=0.5)\n \n # Create a grid of dots representing features on two images\n dot_grid_left = VGroup()\n for i in range(-2, 3, 1): \n row = VGroup()\n for j in range(-2, 3, 1):\n if abs(i) + abs(j) <= 1: \n row.add(Dot(np.array([i*0.5, j*0.5, 0]), radius=0.07))\n dot_grid_left.add(row.arrange(RIGHT, buff=0))\n\n dot_grid_right = VGroup()\n for i in range(-2, 3, 1): \n row = VGroup()\n for j in range(-2, 3, 1):\n if abs(i) + abs(j) <= 1: \n row.add(Dot(np.array([-i-1.5, j*0.5, 0]), radius=0.07))\n dot_grid_right.add(row.arrange(RIGHT, buff=0))\n\n image_labels = [Text(\"Image A\", font_size=24).next_to(dot_grid_left[i], UP, buff=0.2) for i in [1, 4]]\n \n matching_lines = []\n matches = [[0, 1, 2], [3, 4, 5]] \n for img_idx, match_group in enumerate(matches):\n line_group = VGroup()\n for idx in match_group:\n start_pos = dot_grid_left[idx].get_center()\n end_pos = dot_grid_right[idx+len(match_group)].get_center()\n arrow = Arrow(start_pos, end_pos, color=GREEN, stroke_width=2)\n \n # Add small circles at endpoints to make it more readable\n c_start = Dot(start_pos, color=YELLOW, radius=0.05)\n c_end = Dot(end_pos, color=YELLOW, radius=0.05)\n\n line_group.add(c_start, c_end, arrow)\n \n matching_lines.append(line_group)\n\n self.play(FadeIn(title), FadeIn(subtitle))\n self.wait(1.5)\n\n # Display feature grids side-by-side\n self.play(Create(VGroup(image_labels[0], dot_grid_left)), RunTime=1.5)\n self.play(Create(VGroup(image_labels[1], dot_grid_right)), RunTime=1.5)\n self.wait()\n\n # Animate the first set of matching lines between images\n self.play(Create(matching_lines[0]), run_time=1.5)\n self.wait(0.5)\n\n # Highlight specific matched pairs by changing their colors temporarily\n for pair in [(0, 1), (1, 2), (2, 3)]:\n left_dot = dot_grid_left[pair[0]].copy().set_color(YELLOW)\n right_dot = dot_grid_right[pair[1]+len(pair[0])].copy().set_color(YELLOW)\n \n self.play(\n TransformFromCopy(left_dot, dot_grid_left[pair[0]], run_time=0.5),\n TransformFromCopy(right_dot, dot_grid_right[pair[1]+len(pair[0])], run_time=0.5)\n )\n \n self.wait(1)\n\n # Reveal second set of matching lines between images\n self.play(Create(matching_lines[1]), run_time=1.5)\n self.wait(0.5)\n\n # Highlight specific matched pairs by changing their colors temporarily\n for pair in [(3, 4), (4, 5), (5, 6)]:\n left_dot = dot_grid_left[pair[0]].copy().set_color(YELLOW)\n right_dot = dot_grid_right[pair[1]+len(pair[0])+len(pair)-1].copy().set_color(YELLOW)\n \n self.play(\n TransformFromCopy(left_dot, dot_grid_left[pair[0]], run_time=0.5),\n TransformFromCopy(right_dot, dot_grid_right[pair[1]+len(pair[0])+len(pair)-1], run_time=0.5)\n )\n\n self.wait(1)\n\n # Show camera projection formulas\n formula_text = MathTex(r\"\\text{Project points } \\mathbf{x} \\rightarrow \\mathbf{x'}\")\n formula_text.next_to(subtitle, DOWN, buff=0.5)\n self.play(Write(formula_text), run_time=1.5)\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Traversal and Rendering of BSP Trees\n\n**Painter's Algorithm Traversal**\n- Determine traversal order from the viewpoint position\n- Draw the distant subtrees first, then the closer subtrees\n- **Note**: Depth sorting is not required for every frame; only the traversal direction needs to be decided based on the relative position of the viewpoint and the plane (a variant of in-order traversal).\n\n\nThe context of this section (from highest to current level):\n# Computer Graphics and Virtual Reality: Visibility Determination and Hidden Surface Removal\n## BSP Tree Algorithm\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BSPTraversal(Scene):\n\n def construct(self):\n title = Text('Traversal and Rendering of BSP Trees', 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 bullets = BulletedList(\"Painter's Algorithm Traversal\", 'Determine order from viewpoint', 'Draw distant subtrees first', 'Then draw closer subtrees', 'No per-frame depth sorting', 'Variant of in-order traversal', font_size=28)\n bullets.next_to(title_group, DOWN, buff=0.8).to_edge(LEFT, buff=0.5)\n for bullet in bullets:\n self.play(FadeIn(bullet), run_time=0.4)\n else:\n pass\n plane_center = RIGHT * 3.5 + UP * 1.0\n plane = Line(plane_center + UP * 1.5, plane_center + DOWN * 1.5, color=BLUE)\n normal = Arrow(plane_center, plane_center + RIGHT * 1.2, buff=0, color=YELLOW)\n normal_label = Text('n', font_size=20, color=YELLOW).next_to(normal, RIGHT, buff=0.1)\n viewpoint = Dot(plane_center + RIGHT * 2 + UP * 1, color=GREEN)\n viewpoint_label = Text('Viewpoint', font_size=20).next_to(viewpoint, UP, buff=0.1)\n far_label = Text('Far (Back)', font_size=22, color=RED).move_to(plane_center + LEFT * 1.5)\n near_label = Text('Near (Front)', font_size=22, color=GREEN).move_to(plane_center + RIGHT * 1.5 + DOWN * 1)\n self.play(Create(plane), GrowArrow(normal), Write(normal_label), run_time=1)\n self.play(FadeIn(viewpoint), Write(viewpoint_label), run_time=0.6)\n self.play(Write(far_label), Write(near_label), run_time=0.8)\n tree_root = Text('Plane Node', font_size=22).move_to(RIGHT * 3.5 + DOWN * 1.2)\n root_box = SurroundingRectangle(tree_root, color=BLUE, buff=0.1)\n far_node = Text('Far Subtree', font_size=20, color=RED).move_to(tree_root.get_center() + LEFT * 1.5 + DOWN * 1.0)\n far_box = SurroundingRectangle(far_node, color=RED, buff=0.1)\n near_node = Text('Near Subtree', font_size=20, color=GREEN).move_to(tree_root.get_center() + RIGHT * 1.5 + DOWN * 1.0)\n near_box = SurroundingRectangle(near_node, color=GREEN, buff=0.1)\n edge1 = Line(root_box.get_bottom(), far_box.get_top(), color=WHITE)\n edge2 = Line(root_box.get_bottom(), near_box.get_top(), color=WHITE)\n tree_group = VGroup(tree_root, root_box, far_node, far_box, near_node, near_box, edge1, edge2)\n self.play(FadeIn(tree_group), run_time=1.2)\n order_text = Text('Order: Far -> Node -> Near', font_size=22, color=YELLOW).next_to(tree_group, DOWN, buff=0.3)\n self.play(Write(order_text), run_time=0.8)\n self.play(far_box.animate.set_fill(RED, opacity=0.3), run_time=0.5)\n self.play(root_box.animate.set_fill(BLUE, opacity=0.3), run_time=0.5)\n self.play(near_box.animate.set_fill(GREEN, opacity=0.3), run_time=0.5)\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BSPTraversal(Scene):\n\n def construct(self):\n title = Text('Traversal and Rendering of BSP Trees', 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 bullets = BulletedList(\"Painter's Algorithm Traversal\", 'Determine order from viewpoint', 'Draw distant subtrees first', 'Then draw closer subtrees', 'No per-frame depth sorting', 'Variant of in-order traversal', font_size=28)\n bullets.next_to(title_group, DOWN, buff=0.8).to_edge(LEFT, buff=0.5)\n for bullet in bullets:\n self.play(FadeIn(bullet), run_time=0.4)\n else:\n pass\n plane_center = RIGHT * 3.5 + UP * 1.0\n plane = Line(plane_center + UP * 1.5, plane_center + DOWN * 1.5, color=BBLUE)\n normal = Arrow(plane_center, plane_center + RIGHT * 1.2, buff=0, color=YELLOW)\n normal_label = Text('n', font_size=20, color=YELLOW).next_to(normal, RIGHT, buff=0.1)\n viewpoint = Dot(plane_center + RIGHT * 2 + UP * 1, color=GREEN)\n viewpoint_label = Text('Viewpoint', font_size=20).next_to(viewpoint, UP, buff=0.1)\n far_label = Text('Far (Back)', font_size=22, color=RED).move_to(plane_center + LEFT * 1.5)\n near_label = Text('Near (Front)', font_size=22, color=GREEN).move_to(plane_center + RIGHT * 1.5 + DOWN * 1)\n self.play(Create(plane), GrowArrow(normal), Write(normal_label), run_time=1)\n self.play(FadeIn(viewpoint), Write(viewpoint_label), run_time=0.6)\n self.play(Write(far_label), Write(near_label), run_time=0.8)\n tree_root = Text('Plane Node', font_size=22).move_to(RIGHT * 3.5 + DOWN * 1.2)\n root_box = SurroundingRectangle(tree_root, color=BLUE, buff=0.1)\n far_node = Text('Far Subtree', font_size=20, color=RED).move_to(tree_root.get_center() + LEFT * 1.5 + DOWN * 1.0)\n far_box = SurroundingRectangle(far_node, color=RED, buff=0.1)\n near_node = Text('Near Subtree', font_size=20, color=GREEN).move_to(tree_root.get_center() + RIGHT * 1.5 + DOWN * 1.0)\n near_box = SurroundingRectangle(near_node, color=GREEN, buff=0.1)\n edge1 = Line(root_box.get_bottom(), far_box.get_top(), color=WHITE)\n edge2 = Line(root_box.get_bottom(), near_box.get_top(), color=WHITE)\n tree_group = VGroup(tree_root, root_box, far_node, far_box, near_node, near_box, edge1, edge2)\n self.play(FadeIn(tree_group), run_time=1.2)\n order_text = Text('Order: Far -> Node -> Near', font_size=22, color=YELLOW).next_to(tree_group, DOWN, buff=0.3)\n self.play(Write(order_text), run_time=0.8)\n self.play(far_box.animate.set_fill(RED, opacity=0.3), run_time=0.5)\n self.play(root_box.animate.set_fill(BLUE, opacity=0.3), run_time=0.5)\n self.play(near_box.animate.set_fill(GREEN, opacity=0.3), run_time=0.5)\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Familiarize yourself with the general steps of a complete program development to lay the foundation for subsequent chapters.\n\n* Program development is not just about writing code; it encompasses the entire lifecycle from requirement analysis to maintenance.\n\n## The Essence of Program Design\n\n### Program design refers to the process of designing, writing, debugging, and maintaining computer programs based on given requirements.\n* It is an engineering activity that emphasizes the ability to solve practical problems within limited resources.\n\n\nThe context of this section (from highest to current level):\n# Introduction: Overview of the Basics of Program Design\n## Learning Objectives of This Section\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ProgrammingDevelopment(Scene):\n def construct(self):\n title = Text(\"Program Development: General Steps\", font_size=36)\n subtitle = Text(\n \"Requirement Analysis -> Implementation -> Testing -> Maintenance\",\n font_size=28,\n color=BLUE\n )\n \n # Create a visual flow chart using rounded rectangles\n step_labels = [\"Analysis\", \"Design\", \"Code\", \"Test\", \"Maintain\"]\n boxes = VGroup()\n arrows = VGroup()\n\n for i in range(5):\n box = RoundedRectangle(corner_radius=0.3, width=2.7, height=1.5, stroke_width=2)\n label_text = Text(step_labels[i], font_size=18).move_to(box.get_center())\n \n if i == 0:\n box.move_to(LEFT * 3 + UP * 0.5)\n labels_group = VGroup(label_text, box)\n self.play(FadeIn(labels_group))\n \n else:\n prev_box = boxes[-1]\n arrow = Arrow(prev_box.get_right(), box.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.1)\n arrows.add(arrow)\n box.shift(RIGHT * 3)\n \n labels_group = VGroup(label_text, box, arrow)\n self.play(FadeIn(labels_group))\n\n boxes.add(box)\n\n self.wait(1)\n summary_title = Title(\"Summary\")\n summary_list = BulletedList(\n \"Comprehensive life cycle covering requirements through maintenance.\",\n \"Emphasizes problem-solving capabilities under resource constraints.\"\n ).scale(0.8).to_edge(DOWN)\n\n self.play(Write(summary_title))\n self.play(Write(summary_list))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ProgrammingSteps(Scene):\n\n def construct(self):\n title = Text('Program Development Steps', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title))\n items = ['Requirement Analysis\\nand Specification', 'Design and Architecture',\n 'Implementation\\n(Coding)', 'Testing and Debugging']\n boxes = VGroup()\n texts = []\n for i, item_text in enumerate(items):\n box = RoundedRectangle(width=3.2, height=1.8, corner_radius=0.2,\n stroke_color=WHITE, fill_opacity=0.18)\n box.move_to(np.array([i * 2.2 - 3.3, 1.2, 0]))\n box_label = Text(item_text.split('\\n')[0], font_size=17).to_edge(UP, buff=0.12)\n box_title = Text(item_text.split('\\n')[1], font_size=13, color=YELLOW_D).next_to(box_label, DOWN, buff=0.12)\n if i == 0:\n box.set_stroke(color=ORANGE, width=3)\n box_label.set_color(ORANGE)\n box_title.set_color(YELLOW_A)\n else:\n box.set_stroke(color=TEAL_C, width=3)\n box_label.set_color(TEAL_C)\n box_title.set_color(GREEN_D)\n box_group = VGroup(VGroup(box_label, box_title), box)\n boxes.add(box_group)\n texts.append(Text(item_text, font_size=22, line_spacing=1.2))\n arrow1 = Arrow(start=boxes[0].get_right(), end=boxes[1].get_left(),\n buff=0.15, max_tip_length_to_length_ratio=0.12,\n color=ORANGE)\n arrow2 = Arrow(start=boxes[1].get_right(), end=boxes[2].get_left(),\n buff=0.15, max_tip_length_to_length_ratio=0.12,\n color=TEAL_C)\n arrow3 = Arrow(start=boxes[2].get_right(), end=boxes[3].get_left(),\n buff=0.15, max_tip_length_to_length_ratio=0.12,\n color=GREEN_D)\n labels = [Text('Analysis -> Design', font_size=20),\n Text('Design -> Code', font_size=20),\n Text('Code -> Test', font_size=20)]\n labels[0].move_to((boxes[0].get_center()[0] + boxes[1].get_center()[0]) / 2, boxes[0].get_center()[1])\n labels[1].move_to((boxes[1].get_center()[0] + boxes[2].get_center()[0]) / 2, boxes[1].get_center()[1])\n labels[2].move_to((boxes[2].get_center()[0] + boxes[3].get_center()[0]) / 2, boxes[2].get_center()[1])\n self.play(Create(boxes[0]), Write(texts[0]), run_time=1.5)\n self.play(GrowArrow(arrow1), FadeIn(labels[0]), run_time=1.5)\n self.play(FadeIn(texts[1]), Create(boxes[1]), run_time=1.5)\n self.play(GrowArrow(arrow2), FadeIn(labels[1]), run_time=1.5)\n self.play(FadeIn(texts[2]), Create(boxes[2]), run_time=1.5)\n self.play(GrowArrow(arrow3), FadeIn(labels[2]), run_time=1.5)\n self.play(Write(texts[3]), Create(boxes[3]), run_time=1.5)\n\n # Final Highlight\n final_box = SurroundingRectangle(boxes[3], color=BLUE, buff=0.3, corner_radius=0.2)\n final_text = Text(\"Maintain\", font_size=24, weight=BOLD).next_to(final_box, UP, buff=0.2)\n self.play(Create(final_box), Write(final_text))\n\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational animation that explains how to calculate the area under the curve y=x^2 from x=0 to x=2 using definite integrals. Start by showing the function on a graph with labeled axes, and then highlight the area under the curve between these two points. Have a textual explanation appear that indicates this is the area under the curve. Then, step by step, go through the process of calculating the definite integral of x^2 from 0 to 2, showing the mathematical notation and the evaluation of the integral. Finally, present the result of the integral calculation on the screen and hold it there. Please ensure the explanation is clear and suitable for someone with a basic understanding of calculus.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --------------------------------------------------------------\n # 1. Graph Setup\n # --------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=6,\n y_length=4.5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2.5)\n\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot the function y = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = MathTex(\"y = x^2\", color=BLUE).next_to(curve, UR, buff=0.2)\n\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # --------------------------------------------------------------\n # 2. Area Highlighting\n # --------------------------------------------------------------\n area = axes.get_area(curve, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Draw vertical boundary lines for clarity\n line_0 = axes.get_vertical_line(axes.c2p(0, 0), color=WHITE)\n line_2 = axes.get_vertical_line(axes.c2p(2, 4), color=WHITE)\n \n # Label the bounds on the x-axis\n label_0 = MathTex(\"0\").next_to(axes.x_axis.n2p(0), DOWN)\n label_2 = MathTex(\"2\").next_to(axes.x_axis.n2p(2), DOWN)\n\n self.play(\n FadeIn(area),\n Create(line_0),\n Create(line_2),\n Write(label_0),\n Write(label_2),\n run_time=1.5\n )\n\n # --------------------------------------------------------------\n # 3. Textual Context\n # --------------------------------------------------------------\n context_text = Text(\"Area under the curve\", font_size=28).to_edge(UP)\n self.play(Write(context_text))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 4. Step-by-Step Calculation\n # --------------------------------------------------------------\n # Define the mathematical steps\n step1 = MathTex(r\"\\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} \\approx 2.67\", color=GOLD)\n\n # Group and align equations vertically\n equations = VGroup(step1, step2, step3, step4)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.move_to(RIGHT * 3.5 + UP * 0.5)\n\n # Animate each step sequentially\n self.play(Write(step1))\n self.wait(0.5)\n \n self.play(Write(step2))\n self.wait(0.5)\n \n self.play(Write(step3))\n self.wait(0.5)\n \n self.play(Write(step4))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 5. Final Result\n # --------------------------------------------------------------\n # Emphasize the final calculated value with a surrounding box\n result_box = SurroundingRectangle(step4, color=GOLD, buff=0.2)\n final_label = Text(\"Final Area\", font_size=24, color=WHITE).next_to(result_box, DOWN)\n\n self.play(\n Create(result_box),\n Write(final_label),\n step4.animate.scale(1.1)\n )\n \n # Hold the final frame\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --------------------------------------------------------------\n # 1. Graph Setup\n # --------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=6,\n y_length=4.5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).shift(LEFT * 2.5)\n\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Plot the function y = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = MathTex(r\"y = x^2\" + \" = x\", color=BLUE).next_to(curve, UR, buff=0.2)\n\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # --------------------------------------------------------------\n # 2. Area Highlighting\n # --------------------------------------------------------------\n area = axes.get_area(curve, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Draw vertical boundary lines for clarity\n line_0 = axes.get_vertical_line(axes.c2p(0, 0), color=WHITE)\n line_2 = axes.get_vertical_line(axes.c2p(2, 4), color=WHITE)\n \n # Label the bounds on the x-axis\n label_0 = MathTex(\"0\").next_to(axes.x_axis.n2p(0), DOWN)\n label_2 = MathTex(\"2\").next_to(axes.x_axis.n2p(2), DOWN)\n\n self.play(\n FadeIn(area),\n Create(line_0),\n Create(line_2),\n Write(label_0),\n Write(label_2),\n run_time=1.5\n )\n\n # --------------------------------------------------------------\n # 3. Textual Context\n # --------------------------------------------------------------\n context_text = Text(\"Area under the curve\", font_size=28).to_edge(UP)\n self.play(Write(context_text))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 4. Step-by-Step Calculation\n # --------------------------------------------------------------\n # Define the mathematical steps\n step1 = MathTex(r\"\\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} \\approx 2.67\", color=GOLD)\n\n # Group and align equations vertically\n equations = VGroup(step1, step2, step3, step4)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.move_to(RIGHT * 3.5 + UP * 0.5)\n\n # Animate each step sequentially\n self.play(Write(step1))\n self.wait(0.5)\n \n self.play(Write(step2))\n self.wait(0.5)\n \n self.play(Write(step3))\n self.wait(0.5)\n \n self.play(Write(step4))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 5. Final Result\n # --------------------------------------------------------------\n # Emphasize the final calculated value with a surrounding box\n result_box = SurroundingRectangle(step4, color=GOLD, buff=0.2)\n final_label = Text(\"Final Area\", font_size=24, color=WHITE).next_to(result_box, DOWN)\n\n self.play(\n Create(result_box),\n Write(final_label),\n step4.animate.scale(1.1)\n )\n \n # Hold the final frame\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "In what ways can a visual depiction of hidden Markov models reveal the complexity of state sequence prediction?", "chosen": "```python\nfrom manim import *\n\nclass HiddenMarkovModelsAnimation(Scene):\n def construct(self):\n # Introduction - show the title\n title = Text(\"Unveiling Complexity:\", font_size=40).set_color(BLUE)\n subtitle = Text(\"Hidden Markov Models\", font_size=36).set_color(BLUE_C)\n subtitle.next_to(title, DOWN)\n \n intro_group = VGroup(title, subtitle).center()\n \n self.play(Write(title), run_time=1)\n self.play(Write(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(intro_group))\n \n # Element 3: Simple Markov Chain visualization\n markov_title = Text(\"Simple Markov Chain\", font_size=32).set_color(BLUE)\n markov_title.to_edge(UP)\n \n # Create states in a triangle formation for visual clarity\n state_a = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(LEFT*2 + UP*0.5)\n state_b = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(RIGHT*2 + UP*0.5)\n state_c = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(DOWN*1)\n \n state_a_label = Text(\"A\", font_size=24).move_to(state_a)\n state_b_label = Text(\"B\", font_size=24).move_to(state_b)\n state_c_label = Text(\"C\", font_size=24).move_to(state_c)\n \n # Transition arrows between visible states\n arrow_ab = Arrow(state_a.get_right(), state_b.get_left(), color=GRAY, buff=0.1)\n arrow_bc = Arrow(state_b.get_bottom(), state_c.get_right(), color=GRAY, buff=0.1)\n arrow_ca = Arrow(state_c.get_left(), state_a.get_bottom(), color=GRAY, buff=0.1)\n \n visible_group = VGroup(state_a, state_b, state_c, \n state_a_label, state_b_label, state_c_label,\n arrow_ab, arrow_bc, arrow_ca)\n \n self.play(Write(markov_title), run_time=1)\n self.play(Create(state_a), Create(state_b), Create(state_c), run_time=1)\n self.play(Write(state_a_label), Write(state_b_label), Write(state_c_label), run_time=0.5)\n self.play(Create(arrow_ab), Create(arrow_bc), Create(arrow_ca), run_time=1)\n self.wait(1)\n \n # Element 4: Add hidden states layer\n hmm_title = Text(\"Hidden Markov Model\", font_size=32).set_color(BLUE)\n hmm_title.move_to(markov_title)\n \n # Move existing states up to make room for hidden layer\n self.play(Transform(markov_title, hmm_title), run_time=1)\n self.play(visible_group.animate.shift(UP*1.5), run_time=1)\n \n # Create hidden states in triangle formation\n hidden_a = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(LEFT*2 + DOWN*1.5)\n hidden_b = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(RIGHT*2 + DOWN*1.5)\n hidden_c = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(DOWN*3)\n \n hidden_a_label = Text(\"H1\", font_size=24).move_to(hidden_a)\n hidden_b_label = Text(\"H2\", font_size=24).move_to(hidden_b)\n hidden_c_label = Text(\"H3\", font_size=24).move_to(hidden_c)\n \n # Label for the hidden layer\n hidden_label = Text(\"Hidden States\", font_size=28).set_color(RED)\n hidden_label.next_to(hidden_c, DOWN, buff=0.5)\n \n # Transitions between hidden states\n hidden_arrow_ab = Arrow(hidden_a.get_right(), hidden_b.get_left(), color=RED_A, buff=0.1)\n hidden_arrow_bc = Arrow(hidden_b.get_bottom(), hidden_c.get_right(), color=RED_A, buff=0.1)\n hidden_arrow_ca = Arrow(hidden_c.get_left(), hidden_a.get_bottom(), color=RED_A, buff=0.1)\n \n # Element 5: Emission arrows connecting hidden to observable states\n emission_a = DashedLine(hidden_a, state_a, color=\"#FFDF00\") # Using hex code for yellow\n emission_b = DashedLine(hidden_b, state_b, color=\"#FFDF00\")\n emission_c = DashedLine(hidden_c, state_c, color=\"#FFDF00\")\n \n self.play(Create(hidden_a), Create(hidden_b), Create(hidden_c), run_time=1)\n self.play(Write(hidden_a_label), Write(hidden_b_label), Write(hidden_c_label), run_time=0.5)\n self.play(Write(hidden_label), run_time=0.5)\n self.play(Create(hidden_arrow_ab), Create(hidden_arrow_bc), Create(hidden_arrow_ca), run_time=1)\n self.play(Create(emission_a), Create(emission_b), Create(emission_c), run_time=1)\n self.wait(1)\n \n # Emphasize emission probabilities with changing colors\n emission_label = Text(\"Emission Probabilities\", font_size=28).set_color(\"#FFD700\") # Gold color\n emission_label.next_to(hidden_label, DOWN, buff=0.5)\n \n # Highlight emission arrows by changing color\n self.play(Write(emission_label), run_time=0.5)\n self.play(\n emission_a.animate.set_color(YELLOW),\n emission_b.animate.set_color(YELLOW),\n emission_c.animate.set_color(YELLOW),\n run_time=1\n )\n self.wait(1)\n \n # Element 6: Key insight with simple equation representation\n eq_title = Text(\"State Prediction\", font_size=32).set_color(BLUE)\n eq_title.to_edge(UP)\n \n # Simple equation representation for P(State | Observations)\n eq = Text(\"P(State | Observations)\", font_size=32)\n eq.next_to(eq_title, DOWN, buff=0.8)\n \n # Clear everything to focus on the equation\n self.play(\n FadeOut(VGroup(\n visible_group, hidden_a, hidden_b, hidden_c,\n hidden_a_label, hidden_b_label, hidden_c_label,\n hidden_arrow_ab, hidden_arrow_bc, hidden_arrow_ca,\n emission_a, emission_b, emission_c,\n markov_title, hidden_label, emission_label\n )),\n run_time=1\n )\n \n self.play(Write(eq_title), run_time=0.5)\n self.play(Write(eq), run_time=1)\n self.wait(1)\n \n # Element 7: Conclusion with key insight\n conclusion = Text(\"Visualizing HMMs reveals hidden complexity\", font_size=32).set_color(BLUE)\n conclusion.center()\n \n self.play(FadeOut(eq_title), FadeOut(eq), run_time=0.5)\n self.play(Write(conclusion), run_time=1)\n self.wait(1)\n self.play(FadeOut(conclusion), run_time=0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass HiddenMarkovModelsAnimation(Scene):\n def construct(self):\n # Introduction - show the title\n title = Text(\"Unveiling Complexity:\", font_size=40).set_color(BBLUE)\n subtitle = Text(\"Hidden Markov Models\", font_size=36).set_color(BLUE_C)\n subtitle.next_to(title, DOWN)\n \n intro_group = VGroup(title, subtitle).center()\n \n self.play(Write(title), run_time=1)\n self.play(Write(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(intro_group))\n \n # Element 3: Simple Markov Chain visualization\n markov_title = Text(\"Simple Markov Chain\", font_size=32).set_color(BLUE)\n markov_title.to_edge(UP)\n \n # Create states in a triangle formation for visual clarity\n state_a = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(LEFT*2 + UP*0.5)\n state_b = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(RIGHT*2 + UP*0.5)\n state_c = Circle(radius=0.5, color=GREEN, fill_opacity=0.5).shift(DOWN*1)\n \n state_a_label = Text(\"A\", font_size=24).move_to(state_a)\n state_b_label = Text(\"B\", font_size=24).move_to(state_b)\n state_c_label = Text(\"C\", font_size=24).move_to(state_c)\n \n # Transition arrows between visible states\n arrow_ab = Arrow(state_a.get_right(), state_b.get_left(), color=GRAY, buff=0.1)\n arrow_bc = Arrow(state_b.get_bottom(), state_c.get_right(), color=GRAY, buff=0.1)\n arrow_ca = Arrow(state_c.get_left(), state_a.get_bottom(), color=GRAY, buff=0.1)\n \n visible_group = VGroup(state_a, state_b, state_c, \n state_a_label, state_b_label, state_c_label,\n arrow_ab, arrow_bc, arrow_ca)\n \n self.play(Write(markov_title), run_time=1)\n self.play(Create(state_a), Create(state_b), Create(state_c), run_time=1)\n self.play(Write(state_a_label), Write(state_b_label), Write(state_c_label), run_time=0.5)\n self.play(Create(arrow_ab), Create(arrow_bc), Create(arrow_ca), run_time=1)\n self.wait(1)\n \n # Element 4: Add hidden states layer\n hmm_title = Text(\"Hidden Markov Model\", font_size=32).set_color(BLUE)\n hmm_title.move_to(markov_title)\n \n # Move existing states up to make room for hidden layer\n self.play(Transform(markov_title, hmm_title), run_time=1)\n self.play(visible_group.animate.shift(UP*1.5), run_time=1)\n \n # Create hidden states in triangle formation\n hidden_a = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(LEFT*2 + DOWN*1.5)\n hidden_b = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(RIGHT*2 + DOWN*1.5)\n hidden_c = Circle(radius=0.5, color=RED, fill_opacity=0.3).shift(DOWN*3)\n \n hidden_a_label = Text(\"H1\", font_size=24).move_to(hidden_a)\n hidden_b_label = Text(\"H2\", font_size=24).move_to(hidden_b)\n hidden_c_label = Text(\"H3\", font_size=24).move_to(hidden_c)\n \n # Label for the hidden layer\n hidden_label = Text(\"Hidden States\", font_size=28).set_color(RED)\n hidden_label.next_to(hidden_c, DOWN, buff=0.5)\n \n # Transitions between hidden states\n hidden_arrow_ab = Arrow(hidden_a.get_right(), hidden_b.get_left(), color=RED_A, buff=0.1)\n hidden_arrow_bc = Arrow(hidden_b.get_bottom(), hidden_c.get_right(), color=RED_A, buff=0.1)\n hidden_arrow_ca = Arrow(hidden_c.get_left(), hidden_a.get_bottom(), color=RED_A, buff=0.1)\n \n # Element 5: Emission arrows connecting hidden to observable states\n emission_a = DashedLine(hidden_a, state_a, color=\"#FFDF00\") # Using hex code for yellow\n emission_b = DashedLine(hidden_b, state_b, color=\"#FFDF00\")\n emission_c = DashedLine(hidden_c, state_c, color=\"#FFDF00\")\n \n self.play(Create(hidden_a), Create(hidden_b), Create(hidden_c), run_time=1)\n self.play(Write(hidden_a_label), Write(hidden_b_label), Write(hidden_c_label), run_time=0.5)\n self.play(Write(hidden_label), run_time=0.5)\n self.play(Create(hidden_arrow_ab), Create(hidden_arrow_bc), Create(hidden_arrow_ca), run_time=1)\n self.play(Create(emission_a), Create(emission_b), Create(emission_c), run_time=1)\n self.wait(1)\n \n # Emphasize emission probabilities with changing colors\n emission_label = Text(\"Emission Probabilities\", font_size=28).set_color(\"#FFD700\") # Gold color\n emission_label.next_to(hidden_label, DOWN, buff=0.5)\n \n # Highlight emission arrows by changing color\n self.play(Write(emission_label), run_time=0.5)\n self.play(\n emission_a.animate.set_color(YELLOW),\n emission_b.animate.set_color(YELLOW),\n emission_c.animate.set_color(YELLOW),\n run_time=1\n )\n self.wait(1)\n \n # Element 6: Key insight with simple equation representation\n eq_title = Text(\"State Prediction\", font_size=32).set_color(BLUE)\n eq_title.to_edge(UP)\n \n # Simple equation representation for P(State | Observations)\n eq = Text(\"P(State | Observations)\", font_size=32)\n eq.next_to(eq_title, DOWN, buff=0.8)\n \n # Clear everything to focus on the equation\n self.play(\n FadeOut(VGroup(\n visible_group, hidden_a, hidden_b, hidden_c,\n hidden_a_label, hidden_b_label, hidden_c_label,\n hidden_arrow_ab, hidden_arrow_bc, hidden_arrow_ca,\n emission_a, emission_b, emission_c,\n markov_title, hidden_label, emission_label\n )),\n run_time=1\n )\n \n self.play(Write(eq_title), run_time=0.5)\n self.play(Write(eq), run_time=1)\n self.wait(1)\n \n # Element 7: Conclusion with key insight\n conclusion = Text(\"Visualizing HMMs reveals hidden complexity\", font_size=32).set_color(BLUE)\n conclusion.center()\n \n self.play(FadeOut(eq_title), FadeOut(eq), run_time=0.5)\n self.play(Write(conclusion), run_time=1)\n self.wait(1)\n self.play(FadeOut(conclusion), run_time=0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I want an animation that starts by writing the formula for the area of a circle on the screen. Then, a blue circle should appear with a yellow radius labeled 'r' emerging from its center. After that, the formula should transform to highlight the radius part 'r' in the area formula. Next, calculate the circle's area using a specific radius value, let's say r=2, and replace the general area formula on the screen with this specific calculation. Following that, the calculated area should move to a different position while the formula at the original position also changes to show the calculated area. Finally, clear the screen and end the animation with the text \"The area of the circle is 4 pi\" written out. The whole animation should have pauses to let the viewer follow along.", "chosen": "```python\nfrom manim import *\n\nclass CircleAreaAnimation(Scene):\n def construct(self):\n # --- Step 1: Initial Formula ---\n # Split the formula into parts to easily target 'r' for highlighting\n formula = MathTex(\"A\", \"=\", \"\\\\pi\", \"r\", \"^2\").to_edge(UP)\n self.play(Write(formula))\n self.wait(1.5)\n\n # --- Step 2: Geometry Creation ---\n circle = Circle(radius=2, color=BLUE)\n circle.next_to(formula, DOWN, buff=1.5)\n \n radius_line = Line(circle.get_center(), circle.get_right(), color=YELLOW)\n r_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n \n self.play(Create(circle), Create(radius_line), Write(r_label))\n self.wait(1.5)\n\n # --- Step 3: Highlighting ---\n # Highlight the 'r' component in the formula (index 3)\n self.play(formula[3].animate.set_color(YELLOW))\n self.wait(1.5)\n\n # --- Step 4: Calculation & Substitution ---\n # Replace general formula with specific calculation r=2\n formula_sub = MathTex(\"A\", \"=\", \"\\\\pi\", \"(2)\", \"^2\").move_to(formula)\n formula_sub[3].set_color(YELLOW) # Maintain highlight on substituted value\n self.play(ReplacementTransform(formula, formula_sub))\n self.wait(1.5)\n\n # Transform to show the result A = 4\\pi\n formula_res = MathTex(\"A\", \"=\", \"4\\\\pi\").move_to(formula_sub)\n self.play(ReplacementTransform(formula_sub, formula_res))\n self.wait(1.5)\n\n # --- Step 5: Movement & Sync ---\n # Move the calculated area result to a new position\n moving_target = MathTex(\"A\", \"=\", \"4\\\\pi\").shift(RIGHT * 3 + UP * 2)\n \n # Create a copy to move while keeping the original in place\n moving_result = formula_res.copy()\n \n self.play(Transform(moving_result, moving_target))\n self.wait(2)\n\n # --- Step 6: Conclusion ---\n # Clear all elements from the screen\n self.play(FadeOut(VGroup(formula_res, moving_result, circle, radius_line, r_label)))\n self.wait(1)\n\n # Final text output\n final_text = Text(\"The area of the circle is 4 pi\", font_size=40)\n self.play(Write(final_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass CircleAreaAnimation(Scene):\n def construct(self):\n # --- Step 1: Initial Formula ---\n # Split the formula into parts to easily target 'r' for highlighting\n formula = MathTex(\"A\", \"=\", \"\\\\pi\", \"r\", \"^2\").to_edge(UP)\n self.play(Write(formula))\n self.wait(1.5)\n\n # --- Step 2: Geometry Creation ---\n circle = Circle(radius=2, color=BLUE)\n circle.next_to(formula, DOWN, buff=1.5)\n \n radius_line = Line(circle.get_center(), circle.get_right(), color=YELLOW)\n r_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n \n self.play(Create(circle), Create(radius_line), Write(r_label))\n self.wait(1.5)\n\n # --- Step 3: Highlighting ---\n # Highlight the 'r' component in the formula (index 3)\n self.play(formula[3].animate.set_color(YELLOW))\n self.wait(1.5)\n\n # --- Step 4: Calculation & Substitution ---\n # Replace general formula with specific calculation r=2\n formula_sub = MathTex(\"A\", \"=\", \"\\\\pi\", \"(2)\", \"^2\").move_to(formula)\n formula_sub[3].set_color(YELLOW) # Maintain highlight on substituted value\n self.play(ReplacementTransform(target_position=ORIGIN, formula, formula_sub))\n self.wait(1.5)\n\n # Transform to show the result A = 4\\pi\n formula_res = MathTex(\"A\", \"=\", \"4\\\\pi\").move_to(formula_sub)\n self.play(ReplacementTransform(formula_sub, formula_res))\n self.wait(1.5)\n\n # --- Step 5: Movement & Sync ---\n # Move the calculated area result to a new position\n moving_target = MathTex(\"A\", \"=\", \"4\\\\pi\").shift(RIGHT * 3 + UP * 2)\n \n # Create a copy to move while keeping the original in place\n moving_result = formula_res.copy()\n \n self.play(Transform(moving_result, moving_target))\n self.wait(2)\n\n # --- Step 6: Conclusion ---\n # Clear all elements from the screen\n self.play(FadeOut(VGroup(formula_res, moving_result, circle, radius_line, r_label)))\n self.wait(1)\n\n # Final text output\n final_text = Text(\"The area of the circle is 4 pi\", font_size=40)\n self.play(Write(final_text))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can I create an educational video animation using ManimCE that displays a basic arithmetic multiplication problem, starts with a white background, shows the numbers 3 and 2 being multiplied with a blue times symbol, resulting in the number 6, follows up by highlighting the multiplication operation, and then fades everything out after a short pause?", "chosen": "```python\nfrom manim import *\n\nclass MultiplicationAnimation(Scene):\n def construct(self):\n # 1. Scene Setup: Initialize the scene with a white background.\n self.camera.background_color = WHITE\n\n # 2. Element Creation:\n # Create text objects for the numbers \"3\" and \"2\", and a blue times symbol.\n # Color is set to BLACK so the text is visible against the white background.\n number1 = MathTex(\"3\", color=BLACK)\n times_symbol = MathTex(r\"\\times\", color=BLUE)\n number2 = MathTex(\"2\", color=BLACK)\n\n # Arrange them to form the expression \"3 \\times 2\"\n problem = VGroup(number1, times_symbol, number2)\n problem.arrange(RIGHT, buff=0.2)\n problem.move_to(ORIGIN)\n\n # Animate the appearance of the expression\n self.play(Write(problem))\n self.wait(0.5)\n\n # 3. Result Display: Animate the appearance of the result \"6\".\n equals_sign = MathTex(\"=\", color=BLACK)\n result = MathTex(\"6\", color=BLACK)\n result_group = VGroup(equals_sign, result).arrange(RIGHT, buff=0.2)\n result_group.next_to(problem, RIGHT, buff=0.2)\n\n self.play(Write(result_group))\n self.wait(0.5)\n\n # 4. Highlighting: Apply a highlight effect to the entire multiplication operation.\n # A SurroundingRectangle with fill_opacity creates a highlighter effect.\n highlight_box = SurroundingRectangle(\n problem, \n color=YELLOW, \n fill_opacity=0.3, \n buff=0.1\n )\n self.play(Create(highlight_box))\n self.play(Indicate(problem)) # Adds a scale/color pulse effect\n self.wait(1)\n\n # 5. Pause: Insert a short pause in the animation timeline.\n self.wait(1)\n\n # 6. Cleanup: Fade out all elements from the screen.\n all_elements = VGroup(problem, result_group, highlight_box)\n self.play(FadeOut(all_elements))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass MultiplicationAnimation(Scene):\n def construct(self):\n # 1. Scene Setup: Initialize the scene with a white background.\n self.camera.background_color = WHITE\n\n # 2. Element Creation:\n # Create text objects for the numbers \"3\" and \"2\", and a blue times symbol.\n # Color is set to BLACK so the text is visible against the white background.\n number1 = MathTex(\"3\", color=BLACK)\n times_symbol = MathTex(r\"\\times\" + \" = x\", color=BLUE)\n number2 = MathTex(\"2\", color=BLACK)\n\n # Arrange them to form the expression \"3 \\times 2\"\n problem = VGroup(number1, times_symbol, number2)\n problem.arrange(RIGHT, buff=0.2)\n problem.move_to(ORIGIN)\n\n # Animate the appearance of the expression\n self.play(Write(problem))\n self.wait(0.5)\n\n # 3. Result Display: Animate the appearance of the result \"6\".\n equals_sign = MathTex(\"=\", color=BLACK)\n result = MathTex(\"6\", color=BLACK)\n result_group = VGroup(equals_sign, result).arrange(RIGHT, buff=0.2)\n result_group.next_to(problem, RIGHT, buff=0.2)\n\n self.play(Write(result_group))\n self.wait(0.5)\n\n # 4. Highlighting: Apply a highlight effect to the entire multiplication operation.\n # A SurroundingRectangle with fill_opacity creates a highlighter effect.\n highlight_box = SurroundingRectangle(\n problem, \n color=YELLOW, \n fill_opacity=0.3, \n buff=0.1\n )\n self.play(Create(highlight_box))\n self.play(Indicate(problem)) # Adds a scale/color pulse effect\n self.wait(1)\n\n # 5. Pause: Insert a short pause in the animation timeline.\n self.wait(1)\n\n # 6. Cleanup: Fade out all elements from the screen.\n all_elements = VGroup(problem, result_group, highlight_box)\n self.play(FadeOut(all_elements))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the documentation configuration with additional features and explanations:\n\nThe enhanced documentation configuration builds upon the original by adding comprehensive documentation features while maintaining all existing settings. It now includes intersphinx mapping for linking to Python standard library documentation, automatic API documentation generation through autosummary, improved theme customization with logo and favicon support, and version-specific documentation using the releases extension. The configuration also enables SVG image support through sphinx.ext.imgconverter and adds MathJax for mathematical notation. The HTML output is further enhanced with custom CSS in the _static directory and sidebar customization through html_theme_options. The build process now automatically generates API documentation for all modules while excluding test files, and includes improved search functionality through the html_search_options setting. The documentation version is dynamically set from the package version, and the configuration includes comprehensive settings for PDF output through LaTeX customization. All original paths and exclusions are preserved while adding these new capabilities to create a more robust and feature-rich documentation system.", "chosen": "```python\n\"\"\"\nThis script demonstrates how to animate a simple arithmetic problem step-by-step,\nusing Manim Community Edition (ManimCE) v0.19+. The animation shows the calculation \nof 8 divided by 6, demonstrating both integer division and floating point results.\n\nKey Features:\n- Step-by-step visual representation of mathematical operations\n- Highlighting intermediate steps for clarity\n- Simultaneous display of integer and decimal outputs\n\nRun this script with 'manim -pql filename.py ArithmeticProblem' to view the full animation.\n\"\"\"\n\nfrom manim import *\n\nclass ArithmeticProblem(Scene):\n def construct(self):\n # --- Configuration ---\n # Define colors for visual emphasis\n HIGHLIGHT_COLOR = YELLOW\n RESULT_COLOR = BLUE\n \n # Create initial text objects with large font size for visibility\n title = Text(\"Dividing 8 by 6\", font_size=36).to_edge(UP)\n \n # Display the basic equation clearly\n equation_base = MathTex(\"8 \\\\div 6\").scale(1.5)\n self.play(Write(title))\n self.play(Write(equation_base))\n self.wait(1)\n\n # --- Integer Division Sequence ---\n # Show the method for dividing integers first\n int_step = MathTex(\n r\"8 \\div 6 \\approx 1\"\n ).next_to(equation_base, DOWN, buff=0.7).set_color(HIGHLIGHT_COLOR)\n \n self.play(Write(int_step))\n self.wait(2)\n\n # Animate a box around the result to isolate it\n box_integer = SurroundingRectangle(int_step, color=RESULT_COLOR, buff=MED_LARGE_BUFF)\n self.play(Create(box_integer))\n self.wait(2)\n \n # Clear the integer sequence elements for the decimal part\n self.remove(int_step, box_integer)\n\n # --- Decimal Result Sequence ---\n # Re-render the math object to ensure consistent styling across steps\n equation_decimal = MathTex(\"8 / 6\").scale(1.5).move_to(equation_base.get_center())\n self.play(Transform(equation_base, equation_decimal))\n\n # Display the exact fraction format\n frac_result = MathTex(\"\\\\frac{8}{6}\").scale(1.5).next_to(equation_base, DOWN, buff=0.7)\n self.play(Write(frac_result))\n\n # Simplify the fraction to show the reduced form explicitly\n simplified_frac = MathTex(\"\\\\frac{4}{3}\").scale(1.5).next_to(frac_result, RIGHT, buff=0.2)\n self.play(Write(simplified_frac))\n \n # Convert the fraction to its approximate decimal value\n dec_value = MathTex(\"\\\\approx 1.333\\\\ldots\")\n dec_value.next_to(simplified_frac, RIGHT, buff=0.2).set_color(YELLOW)\n self.play(FadeIn(dec_value, shift=RIGHT * 0.5))\n \n # Group the final components for highlighting and scaling up\n final_group = VGroup(equation_base, frac_result, simplified_frac, dec_value)\n self.wait(1)\n\n # Scale up the entire solution set for a moment of emphasis\n self.play(final_group.animate.scale(1.2).set_color(GOLD))\n self.wait(1)\n\n# To run this script, save it as a .py file and execute:\n# manim -pql filename.py ArithmeticProblem\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MatrixMultiplication(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Set background color to black for a dark mode feel\n self.camera.background_color = \"#1E1E1E\"\n\n # --- Title ---\n title_text = Text(\"Matrix Multiplication\", font_size=48, weight=BOLD)\n subtitle_text = Text(\"A Visual Guide\", font_size=36)\n title_group = VGroup(title_text, subtitle_text).arrange(DOWN, buff=0.5)\n title_group.to_edge(UP, buff=1)\n\n # Animate the appearance of the title\n self.play(Write(title_text))\n self.play(FadeIn(subtitle_text, shift=DOWN))\n\n # Wait briefly at the beginning\n self.wait(1)\n\n # --- Step 1: Introduction ---\n intro_text = Text(\n \"Let A be a 2x3 matrix:\\n\\n\\\\begin{bmatrix} 1 & 2 \\\\\\\\ 3 & 4 \\\\end{bmatrix}\",\n font_size=32,\n t2c={\"1\": YELLOW, \"2\": GREEN, \"3\": BLUE},\n line_spacing=1.2\n )\n intro_text.next_to(subtitle_text, DOWN, buff=0.7)\n self.play(Write(intro_text))\n self.wait(1)\n\n # Create the matrix object\n matrix_A = [[1, 2], [3, 4]]\n matrix_obj = Matrix(matrix_A).scale(0.8).next_to(intro_text, DOWN, buff=0.8)\n self.play(Create(matrix_obj))\n self.wait(1)\n\n # Fade out introduction text after showing the matrix\n self.play(FadeOut(intro_text), FadeOut(matrix_obj))\n self.wait(1)\n\n # --- Step 2: Define Vector B ---\n vector_b_text = Text(\n \"\\\\textcolor{orange}{Define another vector } b:\\\\begin{pmatrix} 2\\\\\\\\-1 \\\\end{pmatrix}\",\n font_size=32,\n t2c={\"blue\": ORANGE}\n ).to_edge(RIGHT, buff=1).shift(UP * 0.8)\n\n self.play(Write(vector_b_text))\n vector_B = Arrow(start=LEFT * 2.5 + UP * 1.5, end=RIGHT * 1.5 + DOWN * 0.5, color=ORANGE)\n vector_label = Tex(\"\\\\vec{b}\", color=WHITE).move_to(vector_B.get_center())\n vector_group = VGroup(vector_B, vector_label)\n \n self.play(GrowArrow(vector_B), Write(vector_label))\n self.wait(1)\n\n # Move vectors to make room for multiplication\n self.play(\n matrix_obj.animate.shift(LEFT * 3),\n vector_group.animate.move_to(ORIGIN)\n )\n\n # --- Step 3: Show Element-wise Multiplications ---\n \n element_multiplication = [\n r\"\\left[\\begin{array}{cc} 1 & 2 \\\\ 3 & 4 \\end{array}\\right]\",\n r\"\\times\",\n r\"\\begin{pmatrix} 2 \\cdot 2 \\\\ 4 \\cdot (-1) \\end{pmatrix}\"\n ]\n element_eq = MathTex(*element_multiplication, font_size=36).to_edge(UP, buff=1.5)\n self.play(Write(element_eq))\n self.wait(1)\n\n # --- Step 4: Result Vector C ---\n \n result_vector_c = Arrow(start=vector_B.get_start(), end=vector_B.get_end(), color=GREEN)\n c_label = Tex(\"$\\\\vec{c}$\").next_to(result_vector_c, RIGHT, buff=-0.2)\n result_group = VGroup(result_vector_c, c_label)\n\n product_values = [np.dot(row, [2, -1]) for row in matrix_A]\n product_row1 = MathTex(\"[2, -1]\", font_size=36, color=YELLOW)\n product_row2 = MathTex(\"[3, -4]\", font_size=36, color=YELLOW)\n products = VGroup(product_row1, product_row2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n products.next_to(element_eq, DOWN, buff=0.8)\n\n self.play(TransformFromCopy(vector_B, result_vector_c), Write(c_label))\n self.play(Write(products))\n self.wait(2)\n\n # Final highlight of final equation/result\n final_box = SurroundingRectangle(VGroup(products), color=WHITE, buff=0.3)\n self.play(Create(final_box))\n self.wait(1)\n\n # Fade out everything except the final equation/result box\n self.play(\n FadeOut(title_group),\n FadeOut(vector_b_text),\n FadeOut(matrix_obj),\n FadeOut(element_eq),\n FadeOut(vector_group),\n run_time=1.5\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## Basic Setup of the Simple Keynesian Model\n\n### 1. Core Assumptions (Key Points on the Board)\n\n**Price and Wage Stickiness**: In the short run, the price level \\(P\\) is fixed, and firms adjust their output in response to demand rather than changing prices.", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass KeynesianModelSetup(Scene):\n\n def construct(self):\n title = Tex('\\\\textbf{Basic Setup of the Simple Keynesian Model}', font_size=44)\n title.to_edge(UP, buff=0.5)\n h_line = Line(LEFT, RIGHT).set_length(12).next_to(title, DOWN, buff=0.2)\n subtitle = Tex('\\\\textbf{1. Core Assumptions (Key Points on the Board)}', font_size=36, color=BLUE)\n subtitle.next_to(h_line, DOWN, buff=0.6).to_edge(LEFT, buff=1.0)\n bullet_title = Tex('$\\\\bullet$ \\\\textbf{Price and Wage Stickiness}:', font_size=32, color=YELLOW)\n bullet_title.next_to(subtitle, DOWN, buff=0.6).align_to(subtitle, LEFT)\n text_1 = Tex('In the short run, the price level $P$ is fixed,', font_size=32)\n text_2 = Tex('and firms adjust their output in response', font_size=32)\n text_3 = Tex('to demand rather than changing prices.', font_size=32)\n bullet_text_group = VGroup(text_1, text_2, text_3).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n bullet_text_group.next_to(bullet_title, DOWN, buff=0.3).align_to(bullet_title, LEFT).shift(RIGHT * 0.5)\n node_demand = Text('Demand', font_size=28)\n box_demand = SurroundingRectangle(node_demand, color=WHITE, corner_radius=0.1, buff=0.2)\n grp_demand = VGroup(box_demand, node_demand)\n node_output = Tex('Output ($Y$)', font_size=28)\n box_output = SurroundingRectangle(node_output, color=WHITE, corner_radius=0.1, buff=0.2)\n grp_output = VGroup(box_output, node_output)\n grp_demand.shift(LEFT * 3)\n grp_output.shift(RIGHT * 3)\n arrow = Arrow(grp_demand.get_right(), grp_output.get_left(), buff=0.2, color=YELLOW)\n price_fixed = Tex('Price ($P$) is \\\\textbf{Fixed}', font_size=28, color=RED)\n price_fixed.next_to(arrow, UP, buff=0.2)\n diagram = VGroup(grp_demand, grp_output, arrow, price_fixed)\n diagram.next_to(bullet_text_group, DOWN, buff=1.0).set_x(0)\n self.play(Write(title))\n self.play(Create(h_line))\n self.wait(0.5)\n self.play(Write(subtitle))\n self.wait(0.5)\n self.play(Write(bullet_title))\n self.play(Write(bullet_text_group), run_time=3)\n self.wait(1)\n self.play(FadeIn(grp_demand))\n self.play(GrowArrow(arrow), Write(price_fixed))\n self.play(FadeIn(grp_output))\n self.play(Circumscribe(price_fixed, color=RED, time_width=2))\n self.play(Indicate(grp_output, color=YELLOW))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass KeynesianModelSetup(Scene):\n\n def construct(self):\n title = Tex('\\\\textbf{Basic Setup of the Simple Keynesian Model}', font_size=44)\n title.to_edge(UP, buff=0.5)\n h_line = Line(LEFT, RIGHT).set_length(12).next_to(title, DOWN, buff=0.2)\n subtitle = Tex('\\\\textbf{1. Core Assumptions (Key Points on the Board)}', font_size=36, color=BBLUE)\n subtitle.next_to(h_line, DOWN, buff=0.6).to_edge(LEFT, buff=1.0)\n bullet_title = Tex('$\\\\bullet$ \\\\textbf{Price and Wage Stickiness}:', font_size=32, color=YELLOW)\n bullet_title.next_to(subtitle, DOWN, buff=0.6).align_to(subtitle, LEFT)\n text_1 = Tex('In the short run, the price level $P$ is fixed,', font_size=32)\n text_2 = Tex('and firms adjust their output in response', font_size=32)\n text_3 = Tex('to demand rather than changing prices.', font_size=32)\n bullet_text_group = VGroup(text_1, text_2, text_3).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n bullet_text_group.next_to(bullet_title, DOWN, buff=0.3).align_to(bullet_title, LEFT).shift(RIGHT * 0.5)\n node_demand = Text('Demand', font_size=28)\n box_demand = SurroundingRectangle(node_demand, color=WHITE, corner_radius=0.1, buff=0.2)\n grp_demand = VGroup(box_demand, node_demand)\n node_output = Tex('Output ($Y$)', font_size=28)\n box_output = SurroundingRectangle(node_output, color=WHITE, corner_radius=0.1, buff=0.2)\n grp_output = VGroup(box_output, node_output)\n grp_demand.shift(LEFT * 3)\n grp_output.shift(RIGHT * 3)\n arrow = Arrow(grp_demand.get_right(), grp_output.get_left(), buff=0.2, color=YELLOW)\n price_fixed = Tex('Price ($P$) is \\\\textbf{Fixed}', font_size=28, color=RED)\n price_fixed.next_to(arrow, UP, buff=0.2)\n diagram = VGroup(grp_demand, grp_output, arrow, price_fixed)\n diagram.next_to(bullet_text_group, DOWN, buff=1.0).set_x(0)\n self.play(Write(title))\n self.play(Create(h_line))\n self.wait(0.5)\n self.play(Write(subtitle))\n self.wait(0.5)\n self.play(Write(bullet_title))\n self.play(Write(bullet_text_group), run_time=3)\n self.wait(1)\n self.play(FadeIn(grp_demand))\n self.play(GrowArrow(arrow), Write(price_fixed))\n self.play(FadeIn(grp_output))\n self.play(Circumscribe(price_fixed, color=RED, time_width=2))\n self.play(Indicate(grp_output, color=YELLOW))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 an educational math animation where a narrator demonstrates how to calculate the area under the curve of the function f(x) equals x squared from x equals 1 to x equals 3. The animation should start by writing out \n- Act 2: Create a 12-second Manim scene that explains diminishing marginal utility. Show a total-utility curve that rises but flattens as quantity increases, and add a side panel of marginal-gain bars that shrink with each additi", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0585(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_diminishingmarginalutili()\n\n def act_1_areaundercurve(self):\n func_text = MathTex(\"f(x)\", \"=\", \"x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # Step 2: Display the definite integral expression\n integral_expr = MathTex(\"\\\\int_{1}^{3}\", \"x^2\", \"\\\\,dx\")\n integral_expr.next_to(func_text, DOWN, buff=1)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 3: Animate the integration steps sequentially\n \n # Step 3a: Find the antiderivative\n step1 = MathTex(\"=\", \"\\\\left[\", \"\\\\frac{x^3}{3}\", \"\\\\right]_{1}^{3}\")\n step1.next_to(integral_expr, DOWN, buff=0.5)\n step1.align_to(integral_expr, LEFT)\n self.play(Write(step1))\n self.wait(1)\n\n # Step 3b: Apply the limits of integration\n step2 = MathTex(\"=\", \"\\\\frac{3^3}{3}\", \"-\", \"\\\\frac{1^3}{3}\")\n step2.move_to(step1)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n\n # Step 3c: Simplify the powers\n step3 = MathTex(\"=\", \"\\\\frac{27}{3}\", \"-\", \"\\\\frac{1}{3}\")\n step3.move_to(step2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n\n # Step 3d: Calculate the final value\n step4 = MathTex(\"=\", \"\\\\frac{26}{3}\")\n step4.move_to(step3)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # Step 4: Clear the screen\n all_elements = VGroup(func_text, integral_expr, step4)\n self.play(FadeOut(all_elements))\n self.wait(0.5)\n\n # Step 5: Display the final calculated result prominently for emphasis\n final_result = MathTex(\"\\\\text{Area}\", \"=\", \"\\\\frac{26}{3}\", \"\\\\approx\", \"8.67\")\n final_result.scale(1.5).set_color(YELLOW)\n self.play(Write(final_result))\n self.play(Indicate(final_result))\n self.wait(2)\n\n def act_2_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0585(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_diminishingmarginalutili()\n\n def act_1_areaundercurve(self):\n func_text = MathTex(\"f(x)\", \"=\", \"x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # Step 2: Display the definite integral expression\n integral_expr = MathTex(\"\\\\int_{1}^{3}\", \"x^2\", \"\\\\,dx\")\n integral_expr.next_to(func_text, DOWN, buff=1)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 3: Animate the integration steps sequentially\n \n # Step 3a: Find the antiderivative\n step1 = MathTex(\"=\", \"\\\\left[\", \"\\\\frac{x^3}{3}\", \"\\\\right]_{1}^{3}\")\n step1.next_to(integral_expr, DOWN, buff=0.5)\n step1.align_to(integral_expr, LEFT)\n self.play(Write(step1))\n self.wait(1)\n\n # Step 3b: Apply the limits of integration\n step2 = MathTex(\"=\", \"\\\\frac{3^3}{3}\", \"-\", \"\\\\frac{1^3}{3}\")\n step2.move_to(step1)\n self.play(ReplacementTransform(target_position=ORIGIN, step1, step2))\n self.wait(1)\n\n # Step 3c: Simplify the powers\n step3 = MathTex(\"=\", \"\\\\frac{27}{3}\", \"-\", \"\\\\frac{1}{3}\")\n step3.move_to(step2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n\n # Step 3d: Calculate the final value\n step4 = MathTex(\"=\", \"\\\\frac{26}{3}\")\n step4.move_to(step3)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # Step 4: Clear the screen\n all_elements = VGroup(func_text, integral_expr, step4)\n self.play(FadeOut(all_elements))\n self.wait(0.5)\n\n # Step 5: Display the final calculated result prominently for emphasis\n final_result = MathTex(\"\\\\text{Area}\", \"=\", \"\\\\frac{26}{3}\", \"\\\\approx\", \"8.67\")\n final_result.scale(1.5).set_color(YELLOW)\n self.play(Write(final_result))\n self.play(Indicate(final_result))\n self.wait(2)\n\n def act_2_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational ManimCE animation on 'Primality Testing Algorithms' (Primality Testing: The Ellipse of Speed and Accuracy): How can the concept of ellipses be used to represent the trade-off between speed and accuracy in different primality testing algorithms?\nVisual style guidance: A combination of vibrant blues and deep purples with a hint of golden lines to highlight key points in each explanation. Soft, moving gradients to give a sense of motion and elegance.", "chosen": "```python\nfrom manim import *\n\nclass PrimalityTestingEllipses(Scene):\n def construct(self):\n # Introduction with title\n title = Text(\"Primality Testing: The Ellipse of Speed and Accuracy\", color=BLUE)\n title.scale(0.7)\n title.to_edge(UP)\n self.play(Write(title), run_time=2)\n \n # Create abstract city visual with rectangles\n city = VGroup()\n for i in range(10):\n rect = Rectangle(\n height=np.random.uniform(1, 3), \n width=np.random.uniform(0.5, 1),\n color=PURPLE\n )\n rect.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-2, 1), 0]))\n city.add(rect)\n \n self.play(Create(city), run_time=2)\n \n # Transform city to ellipses (morphing visual)\n ellipses = VGroup()\n for i in range(4):\n ellipse = Ellipse(\n width=np.random.uniform(2, 4), \n height=np.random.uniform(1, 3),\n color=BLUE\n )\n ellipse.move_to(np.array([np.random.uniform(-3, 3), np.random.uniform(-2, 2), 0]))\n ellipses.add(ellipse)\n \n self.play(Transform(city, ellipses), run_time=2)\n self.play(FadeOut(city), run_time=1)\n \n # Create coordinate axes for speed vs accuracy\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": WHITE},\n )\n axes.shift(DOWN * 0.5) # Move axes down slightly for better positioning\n \n # Add axis labels\n x_label = Text(\"Speed\", color=GOLD).next_to(axes.x_axis, DOWN)\n y_label = Text(\"Accuracy\", color=GOLD).next_to(axes.y_axis, LEFT)\n \n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2)\n \n # Create ellipses for different primality testing algorithms\n # Miller-Rabin: Good speed, decent accuracy\n miller_rabin = Ellipse(width=6, height=3, color=BLUE)\n miller_rabin.move_to(axes.c2p(7, 5)) # Position based on speed/accuracy\n miller_rabin_label = Text(\"Miller-Rabin\", color=BLUE).scale(0.6).next_to(miller_rabin, UP)\n \n # AKS: Perfect accuracy, slower speed\n aks = Ellipse(width=3, height=5, color=PURPLE)\n aks.move_to(axes.c2p(3, 8))\n aks_label = Text(\"AKS\", color=PURPLE).scale(0.6).next_to(aks, UP)\n \n # Fermat: Very fast, lower accuracy\n fermat = Ellipse(width=7, height=2, color=GREEN)\n fermat.move_to(axes.c2p(8, 3))\n fermat_label = Text(\"Fermat\", color=GREEN).scale(0.6).next_to(fermat, UP)\n \n # Add ellipses to the scene sequentially\n self.play(Create(miller_rabin), Write(miller_rabin_label), run_time=1)\n self.play(Create(aks), Write(aks_label), run_time=1)\n self.play(Create(fermat), Write(fermat_label), run_time=1)\n \n # Display key insight about the trade-off\n insight_text = Text(\"The trade-off between speed and accuracy\", color=GOLD)\n insight_text.scale(0.7)\n insight_text.to_edge(DOWN)\n self.play(Write(insight_text), run_time=1.5)\n \n # Focus on specific algorithms by highlighting them\n self.play(\n miller_rabin.animate.scale(1.2),\n aks.animate.scale(1.2),\n fermat.animate.scale(1.2),\n run_time=1.5\n )\n \n self.play(\n miller_rabin.animate.scale(1/1.2),\n aks.animate.scale(1/1.2),\n fermat.animate.scale(1/1.2),\n run_time=1\n )\n \n # Show the ellipse equation\n equation1 = MathTex(\"E=\\\\frac{x^2}{a^2}+\\\\frac{y^2}{b^2}=1\", color=WHITE)\n equation1.to_edge(DOWN)\n \n self.play(\n FadeOut(insight_text),\n Write(equation1),\n run_time=2\n )\n \n # Show the second equation\n equation2 = MathTex(\"\\\\epsilon(x)=\\\\log \\\\left(\\\\frac{N}{x}\\\\right) + O(1)\", color=WHITE)\n equation2.to_edge(DOWN)\n \n self.play(\n Transform(equation1, equation2),\n run_time=2\n )\n \n # Conclusion\n conclusion_text = Text(\"Finding the perfect balance in primality testing\", color=BLUE)\n conclusion_text.scale(0.7)\n conclusion_text.to_edge(DOWN)\n \n self.play(\n FadeOut(equation1),\n Write(conclusion_text),\n run_time=1.5\n )\n \n # Transform back to cityscape (visual callback to start)\n final_city = VGroup()\n for i in range(10):\n rect = Rectangle(\n height=np.random.uniform(1, 3), \n width=np.random.uniform(0.5, 1),\n color=BLUE\n )\n rect.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-2, 1), 0]))\n final_city.add(rect)\n \n # Fade out graph elements and transform to final visual\n self.play(\n Transform(miller_rabin, final_city),\n FadeOut(miller_rabin_label),\n FadeOut(aks),\n FadeOut(aks_label),\n FadeOut(fermat),\n FadeOut(fermat_label),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n run_time=2\n )\n \n # Final message\n final_message = Text(\"Speed and accuracy shape our understanding\", color=GOLD)\n final_message.scale(0.7)\n final_message.to_edge(UP)\n \n self.play(\n Transform(title, final_message),\n run_time=1.5\n )\n \n # Fade out remaining text\n self.play(FadeOut(conclusion_text), run_time=1)\n \n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass PrimalityTestingEllipses(Scene):\n def construct(self):\n # Introduction with title\n title = Text(\"Primality Testing: The Ellipse of Speed and Accuracy\", color=BLUE)\n title.scale(0.7)\n title.to_edge(UP)\n self.play(Write(title), run_time=2)\n \n # Create abstract city visual with rectangles\n city = VGroup()\n for i in range(10):\n rect = Rectangle(\n height=np.random.uniform(1, 3), \n width=np.random.uniform(0.5, 1),\n color=PURPLE\n )\n rect.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-2, 1), 0]))\n city.add(rect)\n \n self.play(Create(city), run_time=2)\n \n # Transform city to ellipses (morphing visual)\n ellipses = VGroup()\n for i in range(4):\n ellipse = Ellipse(\n width=np.random.uniform(2, 4), \n height=np.random.uniform(1, 3),\n color=BLUE\n )\n ellipse.move_to(np.array([np.random.uniform(-3, 3), np.random.uniform(-2, 2), 0]))\n ellipses.add(ellipse)\n \n self.play(Transform(city, ellipses), run_time=2)\n self.play(FadeOut(city), run_time=1)\n \n # Create coordinate axes for speed vs accuracy\n axes = Axes(label_font_size=24, \n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": WHITE},\n )\n axes.shift(DOWN * 0.5) # Move axes down slightly for better positioning\n \n # Add axis labels\n x_label = Text(\"Speed\", color=GOLD).next_to(axes.x_axis, DOWN)\n y_label = Text(\"Accuracy\", color=GOLD).next_to(axes.y_axis, LEFT)\n \n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2)\n \n # Create ellipses for different primality testing algorithms\n # Miller-Rabin: Good speed, decent accuracy\n miller_rabin = Ellipse(width=6, height=3, color=BLUE)\n miller_rabin.move_to(axes.c2p(7, 5)) # Position based on speed/accuracy\n miller_rabin_label = Text(\"Miller-Rabin\", color=BLUE).scale(0.6).next_to(miller_rabin, UP)\n \n # AKS: Perfect accuracy, slower speed\n aks = Ellipse(width=3, height=5, color=PURPLE)\n aks.move_to(axes.c2p(3, 8))\n aks_label = Text(\"AKS\", color=PURPLE).scale(0.6).next_to(aks, UP)\n \n # Fermat: Very fast, lower accuracy\n fermat = Ellipse(width=7, height=2, color=GREEN)\n fermat.move_to(axes.c2p(8, 3))\n fermat_label = Text(\"Fermat\", color=GREEN).scale(0.6).next_to(fermat, UP)\n \n # Add ellipses to the scene sequentially\n self.play(Create(miller_rabin), Write(miller_rabin_label), run_time=1)\n self.play(Create(aks), Write(aks_label), run_time=1)\n self.play(Create(fermat), Write(fermat_label), run_time=1)\n \n # Display key insight about the trade-off\n insight_text = Text(\"The trade-off between speed and accuracy\", color=GOLD)\n insight_text.scale(0.7)\n insight_text.to_edge(DOWN)\n self.play(Write(insight_text), run_time=1.5)\n \n # Focus on specific algorithms by highlighting them\n self.play(\n miller_rabin.animate.scale(1.2),\n aks.animate.scale(1.2),\n fermat.animate.scale(1.2),\n run_time=1.5\n )\n \n self.play(\n miller_rabin.animate.scale(1/1.2),\n aks.animate.scale(1/1.2),\n fermat.animate.scale(1/1.2),\n run_time=1\n )\n \n # Show the ellipse equation\n equation1 = MathTex(\"E=\\\\frac{x^2}{a^2}+\\\\frac{y^2}{b^2}=1\", color=WHITE)\n equation1.to_edge(DOWN)\n \n self.play(\n FadeOut(insight_text),\n Write(equation1),\n run_time=2\n )\n \n # Show the second equation\n equation2 = MathTex(\"\\\\epsilon(x)=\\\\log \\\\left(\\\\frac{N}{x}\\\\right) + O(1)\", color=WHITE)\n equation2.to_edge(DOWN)\n \n self.play(\n Transform(equation1, equation2),\n run_time=2\n )\n \n # Conclusion\n conclusion_text = Text(\"Finding the perfect balance in primality testing\", color=BLUE)\n conclusion_text.scale(0.7)\n conclusion_text.to_edge(DOWN)\n \n self.play(\n FadeOut(equation1),\n Write(conclusion_text),\n run_time=1.5\n )\n \n # Transform back to cityscape (visual callback to start)\n final_city = VGroup()\n for i in range(10):\n rect = Rectangle(\n height=np.random.uniform(1, 3), \n width=np.random.uniform(0.5, 1),\n color=BLUE\n )\n rect.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-2, 1), 0]))\n final_city.add(rect)\n \n # Fade out graph elements and transform to final visual\n self.play(\n Transform(miller_rabin, final_city),\n FadeOut(miller_rabin_label),\n FadeOut(aks),\n FadeOut(aks_label),\n FadeOut(fermat),\n FadeOut(fermat_label),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n run_time=2\n )\n \n # Final message\n final_message = Text(\"Speed and accuracy shape our understanding\", color=GOLD)\n final_message.scale(0.7)\n final_message.to_edge(UP)\n \n self.play(\n Transform(title, final_message),\n run_time=1.5\n )\n \n # Fade out remaining text\n self.play(FadeOut(conclusion_text), run_time=1)\n \n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that visually explains how to calculate the area under the curve of the function f(x) = 3x^2 - 2x + 1 from x=1 to x=3 by performing integration, including writing out the function, transforming it into an integral, showing the step-by-step integration process, simplifying the result, and evaluating the final answer?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExplanation(Scene):\n def construct(self):\n # --- Configuration ---\n # Define colors for pedagogical clarity\n FUNC_COLOR = BLUE\n INTEGRAL_COLOR = GOLD\n RESULT_COLOR = GREEN\n AXES_COLOR = WHITE\n \n # --- 1. Display the Function & Graph Context ---\n # Create axes to visualize the context of the area\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 30, 5],\n x_length=6,\n y_length=4,\n axis_config={\"color\": AXES_COLOR, \"include_tip\": True},\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = 3x^2 - 2x + 1\n func = lambda x: 3*x**2 - 2*x + 1\n graph = axes.plot(func, color=FUNC_COLOR, x_range=[0, 3.5])\n \n # Create the function equation Tex\n func_eq = MathTex(r\"f(x)\", \"=\", r\"3x^2\", \"-\", r\"2x\", \"+\", r\"1\", color=FUNC_COLOR, font_size=40)\n func_eq.to_edge(UP)\n \n # Animate Setup\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(func_eq))\n self.wait(1)\n \n # --- 2. Setup the Integral ---\n # Transform the function equation into the definite integral notation\n integral_eq = MathTex(\n r\"\\int_{1}^{3}\", r\"(\", r\"3x^2\", \"-\", r\"2x\", \"+\", r\"1\", r\")\", r\"\\,dx\", font_size=40\n )\n # Color the limits and the dx for emphasis\n integral_eq[0].set_color(INTEGRAL_COLOR) # Limits\n integral_eq[8].set_color(INTEGRAL_COLOR) # dx\n \n # Highlight the area under the curve from x=1 to x=3\n area = axes.get_area(graph, x_range=[1, 3], color=INTEGRAL_COLOR, opacity=0.3)\n \n # Vertical lines to mark limits\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 # Animate Step 2\n self.play(TransformMatchingTex(func_eq, integral_eq))\n self.play(FadeIn(area), Create(line_1), Create(line_3))\n self.wait(1)\n \n # --- 3. Step-by-Step Integration (Antiderivative) ---\n # Show the antiderivative calculation explicitly before simplifying\n step3_text = MathTex(\n r\"=\", r\"\\left[ \\frac{3x^3}{3} - \\frac{2x^2}{2} + x \\right]_{1}^{3}\", font_size=35\n ).next_to(integral_eq, DOWN, buff=0.5)\n \n simplified_antideriv = MathTex(\n r\"=\", r\"\\left[ x^3 - x^2 + x \\right]_{1}^{3}\", font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5)\n \n self.play(Write(step3_text))\n self.wait(1)\n self.play(Transform(step3_text, simplified_antideriv))\n self.wait(1)\n \n # --- 4. Simplification (Substitution) ---\n # Show the substitution of limits: F(3) - F(1)\n substitution_eq = MathTex(\n r\"=\", r\"(\", r\"3^3\", \"-\", r\"3^2\", \"+\", r\"3\", r\")\", \n r\"-\", \n r\"(\", r\"1^3\", \"-\", r\"1^2\", \"+\", r\"1\", r\")\", font_size=40\n ).next_to(simplified_antideriv, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(simplified_antideriv, substitution_eq))\n self.wait(1)\n \n # Calculate the values inside the parentheses\n arithmetic_eq = MathTex(\n r\"=\", r\"(\", r\"27\", \"-\", r\"9\", \"+\", r\"3\", r\")\", \n r\"-\", \n r\"(\", r\"1\", r\")\", font_size=40\n ).next_to(substitution_eq, DOWN, buff=0.5)\n \n self.play(Transform(substitution_eq, arithmetic_eq))\n self.wait(1)\n \n # --- 5. Final Evaluation ---\n # Show the final arithmetic\n final_eq = MathTex(\n r\"=\", r\"21\", \"-\", r\"1\", \"=\", r\"20\", font_size=40, color=RESULT_COLOR\n ).next_to(arithmetic_eq, DOWN, buff=0.5)\n \n self.play(Transform(arithmetic_eq, final_eq))\n \n # Highlight the final answer and the area on the graph\n result_label = MathTex(r\"\\text{Area} = 20\", font_size=36, color=RESULT_COLOR).to_edge(DOWN)\n self.play(\n Write(result_label),\n area.animate.set_fill(RESULT_COLOR, opacity=0.6),\n run_time=1\n )\n \n self.wait(2)\n \n # Final wrap up: Fade out everything except the result for a clean finish\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(labels),\n FadeOut(area),\n FadeOut(line_1),\n FadeOut(line_3),\n FadeOut(integral_eq),\n FadeOut(step3_text),\n FadeOut(substitution_eq),\n FadeOut(arithmetic_eq),\n FadeOut(result_label),\n final_eq.animate.move_to(ORIGIN).scale(1.5)\n )\n \n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExplanation(Scene):\n def construct(self):\n # --- Configuration ---\n # Define colors for pedagogical clarity\n FUNC_COLOR = BBLUE\n INTEGRAL_COLOR = GOLD\n RESULT_COLOR = GREEN\n AXES_COLOR = WHITE\n \n # --- 1. Display the Function & Graph Context ---\n # Create axes to visualize the context of the area\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 30, 5],\n x_length=6,\n y_length=4,\n axis_config={\"color\": AXES_COLOR, \"include_tip\": True},\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Define the function f(x) = 3x^2 - 2x + 1\n func = lambda x: 3*x**2 - 2*x + 1\n graph = axes.plot(func, color=FUNC_COLOR, x_range=[0, 3.5])\n \n # Create the function equation Tex\n func_eq = MathTex(r\"f(x)\", \"=\", r\"3x^2\", \"-\", r\"2x\", \"+\", r\"1\", color=FUNC_COLOR, font_size=40)\n func_eq.to_edge(UP)\n \n # Animate Setup\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(func_eq))\n self.wait(1)\n \n # --- 2. Setup the Integral ---\n # Transform the function equation into the definite integral notation\n integral_eq = MathTex(\n r\"\\int_{1}^{3}\", r\"(\", r\"3x^2\", \"-\", r\"2x\", \"+\", r\"1\", r\")\", r\"\\,dx\", font_size=40\n )\n # Color the limits and the dx for emphasis\n integral_eq[0].set_color(INTEGRAL_COLOR) # Limits\n integral_eq[8].set_color(INTEGRAL_COLOR) # dx\n \n # Highlight the area under the curve from x=1 to x=3\n area = axes.get_area(graph, x_range=[1, 3], color=INTEGRAL_COLOR, opacity=0.3)\n \n # Vertical lines to mark limits\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 # Animate Step 2\n self.play(TransformMatchingTex(func_eq, integral_eq))\n self.play(FadeIn(area), Create(line_1), Create(line_3))\n self.wait(1)\n \n # --- 3. Step-by-Step Integration (Antiderivative) ---\n # Show the antiderivative calculation explicitly before simplifying\n step3_text = MathTex(\n r\"=\", r\"\\left[ \\frac{3x^3}{3} - \\frac{2x^2}{2} + x \\right]_{1}^{3}\", font_size=35\n ).next_to(integral_eq, DOWN, buff=0.5)\n \n simplified_antideriv = MathTex(\n r\"=\", r\"\\left[ x^3 - x^2 + x \\right]_{1}^{3}\", font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5)\n \n self.play(Write(step3_text))\n self.wait(1)\n self.play(Transform(step3_text, simplified_antideriv))\n self.wait(1)\n \n # --- 4. Simplification (Substitution) ---\n # Show the substitution of limits: F(3) - F(1)\n substitution_eq = MathTex(\n r\"=\", r\"(\", r\"3^3\", \"-\", r\"3^2\", \"+\", r\"3\", r\")\", \n r\"-\", \n r\"(\", r\"1^3\", \"-\", r\"1^2\", \"+\", r\"1\", r\")\", font_size=40\n ).next_to(simplified_antideriv, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(simplified_antideriv, substitution_eq))\n self.wait(1)\n \n # Calculate the values inside the parentheses\n arithmetic_eq = MathTex(\n r\"=\", r\"(\", r\"27\", \"-\", r\"9\", \"+\", r\"3\", r\")\", \n r\"-\", \n r\"(\", r\"1\", r\")\", font_size=40\n ).next_to(substitution_eq, DOWN, buff=0.5)\n \n self.play(Transform(substitution_eq, arithmetic_eq))\n self.wait(1)\n \n # --- 5. Final Evaluation ---\n # Show the final arithmetic\n final_eq = MathTex(\n r\"=\", r\"21\", \"-\", r\"1\", \"=\", r\"20\", font_size=40, color=RESULT_COLOR\n ).next_to(arithmetic_eq, DOWN, buff=0.5)\n \n self.play(Transform(arithmetic_eq, final_eq))\n \n # Highlight the final answer and the area on the graph\n result_label = MathTex(r\"\\text{Area} = 20\", font_size=36, color=RESULT_COLOR).to_edge(DOWN)\n self.play(\n Write(result_label),\n area.animate.set_fill(RESULT_COLOR, opacity=0.6),\n run_time=1\n )\n \n self.wait(2)\n \n # Final wrap up: Fade out everything except the result for a clean finish\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(labels),\n FadeOut(area),\n FadeOut(line_1),\n FadeOut(line_3),\n FadeOut(integral_eq),\n FadeOut(step3_text),\n FadeOut(substitution_eq),\n FadeOut(arithmetic_eq),\n FadeOut(result_label),\n final_eq.animate.move_to(ORIGIN).scale(1.5)\n )\n \n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an animation that visually represents a neural network with three layers: the first layer having 20 neurons, the second layer 10 neurons, and the third layer 5 neurons. Each neuron should be relatively small with a clear outline. The neurons should appear one layer at a time, each layer coming from above and then settling into position. After all layers are displayed, I want to see an animation that represents the forward pass of data through this network, going from the first layer to the last. The animation should be clear and hold on the final frame for a short moment before ending. Can you design something like this?", "chosen": "```python\nfrom manim import *\n\nclass SimpleHarmonicMotionScene(Scene):\n def construct(self):\n # Display the differential equation for simple harmonic motion\n equation = MathTex(r\"m\\frac{d^2 x}{dt^2} = -kx\")\n self.play(Write(equation))\n self.wait(1)\n\n # Explain what each term represents\n terms_explanation = Text(\n \"Represents mass, spring constant, and position (m, k, x)\",\n font_size=24\n ).to_edge(UP)\n self.play(Write(terms_explanation))\n self.wait(2)\n\n # Show the form of the solution\n solution_form = MathTex(r\"x(t) = A \\cos(\\omega t - \\phi)\")\n self.play(ReplacementTransform(equation, solution_form))\n self.wait(1)\n\n # Explain the solution terms\n solution_explanation = Text(\n \"Where A is amplitude, omega is angular frequency, and phi is phase shift\",\n font_size=24\n ).to_edge(UP)\n self.play(Transform(terms_explanation, solution_explanation))\n self.wait(2)\n\n # Oscillation\n oscillator = Circle(radius=1.0, color=BLUE)\n oscillator.move_to(4*LEFT)\n self.play(Create(oscillator))\n \n # Create an arrow representing the force\n arrow = Arrow(\n oscillator.get_edge_center(RIGHT),\n oscillator.get_edge_center(RIGHT) + 2*RIGHT,\n buff=0\n )\n self.play(GrowArrow(arrow))\n self.wait(1)\n\n # Oscillate the circle to the right\n self.play(oscillator.animate.move_to(4*RIGHT), run_time=2, rate_func=there_and_back)\n self.wait(1)\n\n # Clear the scene and show the solution again\n self.clear()\n self.wait(1)\n self.play(Write(solution_form))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass SimpleHarmonicMotionScene(Scene):\n def construct(self):\n # Display the differential equation for simple harmonic motion\n equation = MathTex(r\"m\\frac{d^2 x}{dt^2} = -kx\")\n self.play(Write(equation))\n self.wait(1)\n\n # Explain what each term represents\n terms_explanation = Text(\n \"Represents mass, spring constant, and position (m, k, x)\",\n font_size=24\n ).to_edge(UP)\n self.play(Write(terms_explanation))\n self.wait(2)\n\n # Show the form of the solution\n solution_form = MathTex(r\"x(t) = A \\cos(\\omega t - \\phi)\")\n self.play(ReplacementTransform(target_position=ORIGIN, equation, solution_form))\n self.wait(1)\n\n # Explain the solution terms\n solution_explanation = Text(\n \"Where A is amplitude, omega is angular frequency, and phi is phase shift\",\n font_size=24\n ).to_edge(UP)\n self.play(Transform(terms_explanation, solution_explanation))\n self.wait(2)\n\n # Oscillation\n oscillator = Circle(radius=1.0, color=BLUE)\n oscillator.move_to(4*LEFT)\n self.play(Create(oscillator))\n \n # Create an arrow representing the force\n arrow = Arrow(\n oscillator.get_edge_center(RIGHT),\n oscillator.get_edge_center(RIGHT) + 2*RIGHT,\n buff=0\n )\n self.play(GrowArrow(arrow))\n self.wait(1)\n\n # Oscillate the circle to the right\n self.play(oscillator.animate.move_to(4*RIGHT), run_time=2, rate_func=there_and_back)\n self.wait(1)\n\n # Clear the scene and show the solution again\n self.clear()\n self.wait(1)\n self.play(Write(solution_form))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here is the enhanced animation description that builds upon the original while adding significant new features:\n\nThe animation begins with a purple horizontal line centered on the screen, then expands into a more comprehensive demonstration of linear transformations. As the original line shifts upward over 1 second, a coordinate system fades in with labeled x and y axes, and the equation \"y = 0\" appears below the original line position in matching purple. When the line reaches its new position at y=2, the equation smoothly transforms into \"y = 2\" while maintaining color consistency. Simultaneously, a dashed gray line appears at the original y=0 position for reference, and a new green line materializes perpendicular to the purple line at x=0, creating a visual connection between the line's equation and its graphical representation. The animation concludes with all elements pulsing gently to draw attention to the complete system, now showing both the transformed line and its mathematical representation within a proper coordinate framework. This enhanced version maintains the original upward shift while adding coordinate context, mathematical equations, reference lines, and a more sophisticated visual presentation of the linear transformation concept.", "chosen": "```python\nfrom manim import *\n\nclass LinearTransformationScene(Scene):\n def construct(self):\n # Create initial purple line\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```", "rejected": "```python\nfrom manim import *\n\nclass LinearTransformationScene(Scene):\n def construct(self):\n # Create initial purple line\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(label_font_size=24, \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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated video that simulates a basic chemical reaction where an electron reacts with an oxygen atom to form an oxygen ion and then combines with a metal atom to create a metal oxide. The video should start with a title \"Chemical Reaction Simulation\" at the top. Initially, the electron should be on the far left, the oxygen in the middle left, and the metal on the middle right. They should fade in sequentially. The electron then moves to the oxygen and they merge, indicating a reaction. Following this, the metal moves to the oxygen and they bond together, creating a simple metal oxide molecule. Finally, transition the single molecule into a 3x3 lattice structure of metal oxide before fading everything out, concluding the animation.", "chosen": "```python\nfrom manim import *\n\nclass ChemicalReactionSimulation(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n ELECTRON_COLOR = BLUE\n OXYGEN_COLOR = RED\n METAL_COLOR = GREY\n LABEL_COLOR = WHITE\n \n # --- 1. Title ---\n title = Text(\"Chemical Reaction Simulation\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # --- 2. Initial State ---\n # Electron: Small charged particle\n electron = Dot(radius=0.15, color=ELECTRON_COLOR)\n electron_label = MathTex(\"e^-\", color=ELECTRON_COLOR, font_size=24)\n electron_label.next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n electron_group.move_to(LEFT * 5)\n\n # Oxygen Atom\n oxygen = Circle(radius=0.6, color=OXYGEN_COLOR, fill_opacity=0.8, stroke_width=2)\n oxygen_label = MathTex(\"O\", color=LABEL_COLOR, font_size=36)\n oxygen_label.move_to(oxygen.get_center())\n oxygen_group = VGroup(oxygen, oxygen_label)\n oxygen_group.move_to(LEFT * 2)\n\n # Metal Atom\n metal = Circle(radius=0.6, color=METAL_COLOR, fill_opacity=0.8, stroke_width=2)\n metal_label = MathTex(\"M\", color=LABEL_COLOR, font_size=36)\n metal_label.move_to(metal.get_center())\n metal_group = VGroup(metal, metal_label)\n metal_group.move_to(RIGHT * 2)\n\n # Sequential Fade In\n self.play(FadeIn(electron_group), run_time=1)\n self.play(FadeIn(oxygen_group), run_time=1)\n self.play(FadeIn(metal_group), run_time=1)\n self.wait(0.5)\n\n # --- 3. Reaction Step 1: Ion Formation ---\n # Electron moves to Oxygen\n self.play(\n electron_group.animate.move_to(oxygen_group.get_center()),\n run_time=1.5\n )\n \n # Create Oxygen Ion visual (O with negative charge)\n ion_circle = Circle(radius=0.6, color=OXYGEN_COLOR, fill_opacity=0.8, stroke_width=2)\n ion_label = MathTex(\"O\", color=LABEL_COLOR, font_size=36)\n ion_label.move_to(ion_circle.get_center())\n charge_label = MathTex(\"^-\", color=LABEL_COLOR, font_size=36)\n charge_label.next_to(ion_circle, UR, buff=0.1)\n oxygen_ion = VGroup(ion_circle, ion_label, charge_label)\n oxygen_ion.move_to(oxygen_group.get_center())\n\n # Swap electron and oxygen for the ion with a flash effect\n self.play(\n FadeOut(electron_group),\n Transform(oxygen_group, oxygen_ion),\n run_time=1\n )\n # Brief pulse to indicate reaction energy\n self.play(oxygen_group.animate.scale(1.2), run_time=0.15)\n self.play(oxygen_group.animate.scale(1/1.2), run_time=0.15)\n self.wait(0.5)\n\n # --- 4. Reaction Step 2: Bonding ---\n # Metal moves to bond with the Oxygen Ion\n bond_position = ORIGIN\n self.play(\n metal_group.animate.move_to(bond_position + LEFT * 0.8),\n oxygen_group.animate.move_to(bond_position + RIGHT * 0.8),\n run_time=1.5\n )\n \n # Visualize the bond with a line\n bond = Line(\n metal_group.get_right(), \n oxygen_group.get_left(), \n color=WHITE, \n stroke_width=4\n )\n self.play(Create(bond), run_time=0.5)\n \n # Group as a single Metal Oxide molecule\n metal_oxide_unit = VGroup(metal_group, oxygen_group, bond)\n self.wait(0.5)\n\n # --- 5. Lattice Formation ---\n # Create a 3x3 grid of the metal oxide units\n lattice = VGroup()\n for i in range(3):\n for j in range(3):\n unit_copy = metal_oxide_unit.copy()\n # Scale down slightly to fit the grid comfortably\n unit_copy.scale(0.6)\n shift_x = (j - 1) * 1.8\n shift_y = (i - 1) * 1.8\n unit_copy.shift(LEFT * shift_x + UP * shift_y)\n lattice.add(unit_copy)\n \n # Center the lattice\n lattice.move_to(ORIGIN)\n \n # Transform the single unit into the full lattice structure\n self.play(\n ReplacementTransform(metal_oxide_unit, lattice),\n run_time=2\n )\n self.wait(1)\n\n # --- 6. Conclusion ---\n # Fade out everything including title\n self.play(\n FadeOut(lattice),\n FadeOut(title),\n run_time=1.5\n )\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass ChemicalReactionSimulation(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n ELECTRON_COLOR = BLUE\n OXYGEN_COLOR = RED\n METAL_COLOR = GREY\n LABEL_COLOR = WHITE\n \n # --- 1. Title ---\n title = Text(\"Chemical Reaction Simulation\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # --- 2. Initial State ---\n # Electron: Small charged particle\n electron = Dot(radius=0.15, color=ELECTRON_COLOR)\n electron_label = MathTex(\"e^-\", color=ELECTRON_COLOR, font_size=24)\n electron_label.next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n electron_group.move_to(LEFT * 5)\n\n # Oxygen Atom\n oxygen = Circle(radius=0.6, color=OXYGEN_COLOR, fill_opacity=0.8, stroke_width=2)\n oxygen_label = MathTex(\"O\", color=LABEL_COLOR, font_size=36)\n oxygen_label.move_to(oxygen.get_center())\n oxygen_group = VGroup(oxygen, oxygen_label)\n oxygen_group.move_to(LEFT * 2)\n\n # Metal Atom\n metal = Circle(radius=0.6, color=METAL_COLOR, fill_opacity=0.8, stroke_width=2)\n metal_label = MathTex(\"M\", color=LABEL_COLOR, font_size=36)\n metal_label.move_to(metal.get_center())\n metal_group = VGroup(metal, metal_label)\n metal_group.move_to(RIGHT * 2)\n\n # Sequential Fade In\n self.play(FadeIn(electron_group), run_time=1)\n self.play(FadeIn(oxygen_group), run_time=1)\n self.play(FadeIn(metal_group), run_time=1)\n self.wait(0.5)\n\n # --- 3. Reaction Step 1: Ion Formation ---\n # Electron moves to Oxygen\n self.play(\n electron_group.animate.move_to(oxygen_group.get_center()),\n run_time=1.5\n )\n \n # Create Oxygen Ion visual (O with negative charge)\n ion_circle = Circle(radius=0.6, color=OXYGEN_COLOR, fill_opacity=0.8, stroke_width=2)\n ion_label = MathTex(\"O\", color=LABEL_COLOR, font_size=36)\n ion_label.move_to(ion_circle.get_center())\n charge_label = MathTex(\"^-\", color=LABEL_COLOR, font_size=36)\n charge_label.next_to(ion_circle, UR, buff=0.1)\n oxygen_ion = VGroup(ion_circle, ion_label, charge_label)\n oxygen_ion.move_to(oxygen_group.get_center())\n\n # Swap electron and oxygen for the ion with a flash effect\n self.play(\n FadeOut(electron_group),\n Transform(oxygen_group, oxygen_ion),\n run_time=1\n )\n # Brief pulse to indicate reaction energy\n self.play(oxygen_group.animate.scale(1.2), run_time=0.15)\n self.play(oxygen_group.animate.scale(1/1.2), run_time=0.15)\n self.wait(0.5)\n\n # --- 4. Reaction Step 2: Bonding ---\n # Metal moves to bond with the Oxygen Ion\n bond_position = ORIGIN\n self.play(\n metal_group.animate.move_to(bond_position + LEFT * 0.8),\n oxygen_group.animate.move_to(bond_position + RIGHT * 0.8),\n run_time=1.5\n )\n \n # Visualize the bond with a line\n bond = Line(\n metal_group.get_right(), \n oxygen_group.get_left(), \n color=WHITE, \n stroke_width=4\n )\n self.play(Create(bond), run_time=0.5)\n \n # Group as a single Metal Oxide molecule\n metal_oxide_unit = VGroup(metal_group, oxygen_group, bond)\n self.wait(0.5)\n\n # --- 5. Lattice Formation ---\n # Create a 3x3 grid of the metal oxide units\n lattice = VGroup()\n for i in range(3):\n for j in range(3):\n unit_copy = metal_oxide_unit.copy()\n # Scale down slightly to fit the grid comfortably\n unit_copy.scale(0.6)\n shift_x = (j - 1) * 1.8\n shift_y = (i - 1) * 1.8\n unit_copy.shift(LEFT * shift_x + UP * shift_y)\n lattice.add(unit_copy)\n \n # Center the lattice\n lattice.move_to(ORIGIN)\n \n # Transform the single unit into the full lattice structure\n self.play(\n ReplacementTransform(target_position=ORIGIN, metal_oxide_unit, lattice),\n run_time=2\n )\n self.wait(1)\n\n # --- 6. Conclusion ---\n # Fade out everything including title\n self.play(\n FadeOut(lattice),\n FadeOut(title),\n run_time=1.5\n )\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## 3. Deriving Equilibrium Income and the Government Spending Multiplier\n\n### 1. Solving for Equilibrium Income \\(Y\\) (Board Work)\n\nFrom:\n\\[\nY = C_0 + cY + I + G\n\\]\n\nRearrange:\n\\[\nY - cY = C_0 + I + G\n\\]\n\n\\[\n(1 - c)Y = C_0 + I + G\n\\]\n\nThus:\n\\[\nY = \\frac{1}{1 - c}(C_0 + I + G)\n\\]\n\n\nContextual location of this section: None\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass BoardWorkEquation(Scene):\n def construct(self):\n # --- Configuration ---\n title_text = \"Deriving Equilibrium Income and the\\nGovernment Spending Multiplier\"\n \n equation_initial = MathTex(\"Y\", \"=\", \"C_0\", \"+\", \"cY\", \"+\", \"I\", \"+\", \"G\")\n equation_rearranged = MathTex(\n r\"Y - cY &= C_0 + I + G \\\\\",\n \"(1-c)Y &= C_0 + I + G\"\n )\n \n solution_equation = MathTex(\n r\"\\therefore Y &= \\frac{1}{1 - c} (C_0 + I + G)\"\n ).scale_to_fit_width(config.frame_width * 0.8)\n \n title = Text(title_text, font_size=36).to_edge(UP)\n initial_label = Text(\"Initial Equation:\", font_size=28).next_to(equation_initial, UP, buff=0.5)\n rearranged_label = Text(\"Rearranged Form:\", font_size=28).next_to(equation_rearranged, UP, buff=0.5)\n \n equations_group = VGroup(initial_label, equation_initial, rearranged_label, equation_rearranged)\n equations_group.arrange(DOWN, aligned_edge=LEFT, buff=0.7)\n solutions_title = Text(\"\\nSolution:\", font_size=32).to_edge(RIGHT).shift(UP * 0.5)\n solution_box = SurroundingRectangle(solution_equation, color=BLUE, buff=0.3)\n solution_group = VGroup(solutions_title, solution_equation, solution_box).arrange(DOWN, buff=0.5).to_edge(DOWN).set_y(-2.5)\n\n self.play(Write(title))\n self.wait(1)\n \n self.play(FadeIn(initial_label), Write(equation_initial))\n self.wait(2)\n\n self.play(Write(rearranged_label), Write(equation_rearranged))\n self.wait(2)\n\n self.play(Write(solution_box), FadeIn(solutions_title, shift=DOWN))\n self.play(Write(solution_equation))\n self.wait(3)\n\n self.play(FadeOut(VGroup(title, initial_label, equation_initial, rearranged_label, equation_rearranged, solutions_title, solution_box)))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass DerivingEquilibriumIncome(Scene):\n\n def construct(self):\n title = Text(\"Deriving Equilibrium Income and the\\nGovernment Spending Multiplier\", font_size=36).to_edge(UP)\n eq_from = MathTex(\"Y\", \"=\", \"C_0\", \"+\", \"cY\", \"+\", \"I\", \"+\", \"G\").scale(1.2).next_to(title, DOWN, buff=0.8)\n eq_rearrange = MathTex(\"Y\", \"-\", \"cY\", \"=\", \"C_0\", \"+\", \"I\", \"+\", \"G\").scale(1.2).move_to(eq_from.get_center())\n eq_group = VGroup(MathTex(\"(1 - c)\", \"Y\"), \"=\", \"\\\\frac{\"+\"\\\\text{constants}\"+\"}\", \"{\",\"(\", \"1\", \"-\" , \"c\", \")\"} ).scale(1.2).shift(DOWN*1.7)\n \n # Create arrows between equations\n arrow1 = Arrow(start=eq_from.get_bottom(), end=eq_rearrange.get_top(), color=YELLOW, buff=0.1)\n arrow2 = Arrow(start=eq_rearrange.get_bottom(), end=eq_group.get_top(), color=GREEN, buff=0.1)\n\n self.play(Write(title))\n self.wait(0.5)\n self.play(Write(eq_from))\n self.wait(0.5)\n self.play(GrowArrow(arrow1), Write(eq_rearrange))\n self.wait(0.5)\n const_tex = VGroup(MathTex(\"\\\\text{where}\"), MathTex(\"\\\\text{'constants}'\")).arrange(RIGHT, buff=0.2)\n const_tex.next_to(eq_group, LEFT, buff=-0.1).set_color(YELLOW)\n self.play(Write(const_tex), GrowArrow(arrow2), Write(eq_group))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass IntegrationVisualization(Scene):\n def construct(self):\n # 1. Setup Coordinate System and Graph\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=4.5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.2])\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\", x_val=2, direction=UR)\n\n # 2. Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.4)\n \n # Group graphical elements for easy management\n graph_group = VGroup(axes, labels, curve, curve_label, area)\n\n # 3. Mathematical Expressions and Steps\n # Initial problem statement\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42)\n \n # Step-by-step solution\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n final_answer = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=48, color=YELLOW)\n\n # Arrange and position the math steps to the right of the graph\n math_group = VGroup(problem, step1, step2, final_answer).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n math_group.next_to(axes, RIGHT, buff=1.5)\n\n # --- Animation Sequence ---\n \n # Draw the coordinate system and function\n self.play(Create(axes), Write(labels), run_time=1.5)\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # Reveal the shaded area under the curve\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # Display the integral problem\n self.play(Write(problem))\n self.wait(0.5)\n\n # Animate the step-by-step solution\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(final_answer))\n self.wait(1.5)\n\n # --- Final Transition ---\n # Create a centered, larger version of the final answer for the closing screen\n final_centered = final_answer.copy().scale(1.5).move_to(ORIGIN)\n \n # Fade out graph elements and intermediate steps, leaving only the final answer\n self.play(\n FadeOut(graph_group),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n Transform(final_answer, final_centered),\n run_time=2\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrationVisualization(Scene):\n def construct(self):\n # 1. Setup Coordinate System and Graph\n axes = Axes(label_font_size=24, \n x_range=[0, 2.5, 0.5],\n y_range=[0, 5, 1],\n x_length=6,\n y_length=4.5,\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.2])\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\", x_val=2, direction=UR)\n\n # 2. Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.4)\n \n # Group graphical elements for easy management\n graph_group = VGroup(axes, labels, curve, curve_label, area)\n\n # 3. Mathematical Expressions and Steps\n # Initial problem statement\n problem = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42)\n \n # Step-by-step solution\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n final_answer = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=48, color=YELLOW)\n\n # Arrange and position the math steps to the right of the graph\n math_group = VGroup(problem, step1, step2, final_answer).arrange(\n DOWN, aligned_edge=LEFT, buff=0.5\n )\n math_group.next_to(axes, RIGHT, buff=1.5)\n\n # --- Animation Sequence ---\n \n # Draw the coordinate system and function\n self.play(Create(axes), Write(labels), run_time=1.5)\n self.play(Create(curve), Write(curve_label))\n self.wait(0.5)\n\n # Reveal the shaded area under the curve\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # Display the integral problem\n self.play(Write(problem))\n self.wait(0.5)\n\n # Animate the step-by-step solution\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(final_answer))\n self.wait(1.5)\n\n # --- Final Transition ---\n # Create a centered, larger version of the final answer for the closing screen\n final_centered = final_answer.copy().scale(1.5).move_to(ORIGIN)\n \n # Fade out graph elements and intermediate steps, leaving only the final answer\n self.play(\n FadeOut(graph_group),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n Transform(final_answer, final_centered),\n run_time=2\n )\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What transformations preserve boundary congruency when mapping from a torus to a sphere?", "chosen": "```python\nfrom manim import *\n\nclass TorusSphereMapping(Scene):\n def construct(self):\n # Title\n title = Text(\"Torus to Sphere Mapping\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Draw a simple torus\n torus = Circle(radius=1).shift(RIGHT*2 + UP*2)\n inner_circle = Circle(radius=0.3).shift(RIGHT*2 + UP*2)\n torus_group = VGroup(torus, inner_circle)\n \n self.play(Create(inner_circle), Create(torus))\n self.wait(1)\n\n # Clear screen for spherical representation\n self.clear()\n self.wait(1)\n\n # Show a simplified sphere\n sphere = Circle(radius=1)\n \n self.play(Create(sphere))\n self.wait(1)\n\n # Explain topological equivalence\n eq_text = Text(\n \"A torus can be continuously deformed\\ninto a sphere without cutting\",\n font_size=28,\n t2c={\"torus\": YELLOW, \"sphere\": BLUE}\n )\n eq_text.to_edge(DOWN)\n self.play(Write(eq_text))\n\n # Map points on torus to corresponding points on sphere\n # Simplified method: map periphery of inner circle to sphere perimeter\n inner_dot_torus = Dot(point=[-0.7, -0.7, 0], color=YELLOW)\n inner_label_torus = Tex(\"$P_{\\text{T}}$\").next_to(inner_dot_torus, DOWN)\n dot_on_sphere = Dot(point=sphere.point_at_angle(TAU * 0.5), color=BLUE)\n label_on_sphere = Tex(\"$P_{\\text{S}}$\").next_to(dot_on_sphere, RIGHT)\n \n self.play(FadeIn(inner_dot_torus), Write(inner_label_torus))\n self.wait(0.5)\n\n # Animate morphing\n morphed_torus = Circle(radius=1).set_color(YELLOW)\n morphed_torus.move_to([0.3, 0.2, 0])\n morphed_torus.scale(1.5) # Scale up to fit within the original circle area\n \n self.play(TransformFromCopy(inner_dot_torus, morphed_torus))\n self.wait(0.5)\n\n # Connect dots\n line_path = VMobject()\n path_start = [inner_dot_torus.get_center()[0], inner_dot_torus.get_center()[1], 0]\n path_end = [dot_on_sphere.get_center()[0], dot_on_sphere.get_center()[1], 0]\n\n line_path.set_points_as_corners([path_start, path_end])\n\n arrow_up = Arrow(start=path_end, end=path_end + DOWN * 0.2, buff=0.1, color=WHITE)\n text_up = Tex(\"$f(P)$\").scale(0.6).move_to(path_end + DOWN * 0.3)\n \n self.play(Create(line_path), GrowArrow(arrow_up), FadeIn(label_on_sphere), Write(text_up))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"Topological transformation preserves shape boundaries.\", font_size=28)\n conclusion.next_to(eq_text, DOWN, buff=1)\n \n self.play(Write(conclusion))\n\n # Final display\n final_group = VGroup(\n torus_group, \n sphere, \n inner_dot_torus, inner_label_torus, \n dot_on_sphere, label_on_sphere, \n line_path, arrow_up, text_up, \n eq_text, conclusion\n )\n \n box = SurroundingRectangle(final_group, color=GREEN, buff=MED_LARGE_BUFF)\n \n self.wait(2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\n\"\"\"\nTransformation Mapping Torus Surface Area to Sphere\n\nDemonstrates how specific mappings can preserve area while transforming \na toroidal surface onto a spherical one.\n\nFor educational purposes only. No copyright claim applied.\n\"\"\"\n\n# Import necessary functions/classes\nfrom manim import *\n\nclass TorusSphereMapping(Scene):\n def construct(self):\n # Title for the animation sequence\n title = Text(\"Torus to Sphere: Preserving Boundary Congruence\", font_size=36)\n self.play(Write(title))\n \n # Create visual representation of a torus using two circles\n inner_circle = Circle(radius=0.8, color=BLUE).shift(RIGHT*0.7 + UP*0.3)\n outer_circle = Arc(start_angle=PI/4, angle=-PI/2, radius=1.2, color=RED).shift(LEFT*0.2)\n torus_shape = VGroup(inner_circle, outer_circle)\n\n # Label the torus\n torus_label = Text(\"Torus\", font_size=24).next_to(torus_shape, DOWN, buff=0.3)\n\n # Display the initial shape on screen\n self.play(Create(torus_shape), Write(toros_label))\n\n # Animate transformation by moving points along paths to simulate deformation\n # Simple scaling up of the circle shapes to represent the \"stretch\" effect\n transformed_torus = VGroup(\n Circle(radius=1.6, color=BLUE),\n Arc(start_angle=PI/4, angle=PI/2, radius=2.4, color=RED)\n ).shift(UP*0.3)\n \n transformed_label = Text(\"Spherical Shape\", font_size=24).move_to(torus_shape.get_center())\n\n # Transition from torus to simplified spherical shape\n self.play(Transform(torus_shape, transformed_torus), Transform(toros_label, transformed_label), run_time=2)\n\n # Add text explanation about what was done\n explanation_text = Text(\n \"Specific maps exist that preserve area\\nwhile transforming a torus to a sphere\",\n font_size=24,\n t2c={'torus': YELLOW, 'sphere': ORANGE}\n )\n explanation_text.to_edge(DOWN, buff=0.5)\n self.play(FadeIn(explanation_text, shift=UP))\n\n # Final hold at end to let viewers read/examine the results\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated educational video that illustrates the concept of finding the area under a curve using integrals. The animation should include a blue-colored set of axes and a green parabolic function graph. I want to display the area under the curve between the points 0.3 and 4.5 on the x-axis, highlighted with a gradient of red to green with a semi-transparent effect. Also, animate the addition of x-axis labels at the points 0.3 and 4.5. Next, show the corresponding integral notation above this area and then transform it to display the exact algebraic calculation of the integral. Once that's done, demonstrate the final result of the definite integral just below the calculation steps. Finally, clear the other elements away to leave just the highlighted area and the result visible. Make sure each step is clearly shown with sufficient time for a viewer to follow, pausing for a couple of seconds between steps.", "chosen": "```python\nfrom manim import *\n\nclass IntegralArea(Scene):\n def construct(self):\n # --- Step 1: Setup Axes ---\n axes = Axes(\n x_range=[-1, 6, 1],\n y_range=[-1, 8, 1],\n tips=False,\n axis_config={\"color\": BLUE},\n )\n \n self.play(Create(axes))\n self.wait(2)\n\n # --- Step 2: Plot Function ---\n func = lambda x: x**2 + 1\n graph = axes.plot(func, color=GREEN)\n \n self.play(Create(graph))\n self.wait(2)\n\n # --- Step 3: Highlight Area ---\n # Define bounds\n start_point = axes.c2p(0.3, func(0.3))\n end_point = axes.c2p(4.5, func(4.5))\n \n # Create shaded region\n area = axes.get_area(\n graph, \n x_range=(0.3, 4.5),\n color=[RED, GREEN], \n opacity=0.7\n )\n \n self.add(area) # Add initially so we can highlight later\n \n # Animate highlighting\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n self.play(Flash(start_point, color=YELLOW, line_length=0.3))\n self.play(Flash(end_point, color=YELLOW, line_length=0.3))\n self.wait(2)\n\n # --- Step 4: X-Axis Labels ---\n label_start = MathTex(\"0.3\").next_to(start_point, DOWN, buff=0.3).set_color(YELLOW)\n label_end = MathTex(\"4.5\").next_to(end_point, UP, buff=0.3).set_color(YELLOW)\n \n self.play(Write(label_start), Write(label_end))\n self.wait(2)\n\n # --- Step 5: Integral Notation ---\n integral_notation = MathTex(r\"\\int_{0.3}^{4.5}\", r\"x^2\", r\"+ 1 \\, dx\")\n integral_notation.to_edge(UP)\n \n self.play(Write(integral_notation))\n self.wait(2)\n\n # Transform to Algebraic Calculation\n algebra_calculation = MathTex(r\"=\\left[\\frac{x^3}{3} + x\\right]_{0.3}^{4.5}\")\n algebra_calculation.next_to(integral_notation, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(integral_notation, algebra_calculation))\n self.wait(3)\n\n # --- Step 6: Final Result ---\n final_result = MathTex(r\"= \\left(\\frac{4.5^3}{3} + 4.5\\right) - \\left(\\frac{(0.3)^3}{3} + 0.3\\right)\")\n final_result.next_to(algebra_calculation, DOWN, buff=0.5)\n \n self.play(Write(final_result))\n self.wait(3)\n\n # Calculate numerically\n calc_value = (4.5**3)/3 + 4.5 - ((0.3)**3)/3 - 0.3\n numerical_answer = MathTex(f\"\\\\approx {calc_value:.2f}\")\n numerical_answer.next_to(final_result, DOWN, buff=0.5)\n \n self.play(Write(numerical_answer))\n self.wait(4)\n\n # --- Step 7: Cleanup ---\n all_elements_except_area = VGroup(\n axes, graph, \n label_start, label_end, \n integral_notation, algebra_calculation, \n final_result, numerical_answer\n )\n \n self.play(FadeOut(all_elements_except_area), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_AXES = BLUE\n COLOR_FUNCTION = GREEN\n COLOR_AREA = color_gradient(RED, GREEN)\n COLOR_LABELS = WHITE\n \n # Display Blue Axes\n axes = Axes(\n x_range=[-0.5, 5, 1],\n y_range=[-0.5, 8, 1],\n tips=False,\n x_length=7,\n y_length=6,\n x_axis_config={\"color\": COLOR_AXES},\n y_axis_config={\"color\": COLOR_AXES}\n )\n \n self.play(Create(axes))\n self.wait(2)\n\n # Plot Green Parabola Function f(x) = 0.1*x^2\n func = lambda x: 0.1 * x**2\n graph = axes.plot(func, color=COLOR_FUNCTION)\n \n self.play(Create(graph))\n self.wait(2)\n\n # Highlight Area Under Curve from x = 0.3 to x = 4.5 with Red-Green Gradient\n area = axes.get_area(graph, x_range=(0.3, 4.5), color=COLOR_AREA, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait(2)\n\n # Add X-Axis Labels at Points 0.3 and 4.5\n label_start = MathTex(\"0.3\").next_to(axes.n2p([0.3, 0]), DOWN, buff=-0.2).set_color(COLOR_LABELS)\n line_start = Line(start=axes.c2p(0.3, 0), end=axes.c2p(0.3, 1.5)).set_stroke(width=1, color=WHITE)\n \n label_end = MathTex(\"4.5\").next_to(axes.n2p([4.5, 0]), DOWN, buff=0.2).set_color(COLOR_LABELS)\n line_end = Line(start=axes.c2p(4.5, 0), end=axes.c2p(4.5, 1.5)).set_stroke(width=1, color=WHITE)\n \n self.play(\n Write(label_start),\n Create(line_start),\n Write(label_end),\n Create(line_end)\n )\n self.wait(2)\n\n # Animate Integration Notation Above the Area\n notations = [\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"f(x)\", \"\\\\, dx\", font_size=42),\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"(0.1 x^2)\", \"\\\\, dx\", font_size=42)\n ]\n \n math_notation = VGroup(notations[0]).to_edge(UP, buff=1)\n \n self.play(Write(math_notation))\n self.wait(2)\n self.play(ReplacementTransform(notations[0], notations[1]))\n self.wait(2)\n\n # Transform Notation to Exact Algebra Calculation\n calc_step1 = MathTex(\"\\\\left[ \\\\frac{0.1}{3} x^3 \\\\right]\", \"_{0.3}^{4.5}\", font_size=42)\n calc_step1.move_to(math_notation.get_center())\n \n self.play(Transform(match_target_data=True, math_notation, calc_step1))\n self.wait(2)\n\n # Final Result Just Below the Calculation Steps\n final_result = MathTex(\"\\\\approx\", \"{\\\\small 17.68}\", font_size=42)\n final_box = SurroundingRectangle(final_result, color=YELLOW, fill_opacity=0.1)\n \n final_group = VGroup(calc_step1.copy(), final_box, final_result)\n final_group.arrange(DOWN, aligned_edge=LEFT, buff=1).move_to(MathTex(\"A\").get_center())\n\n self.play(Write(final_group[:2]))\n self.play(Write(final_group[2]))\n self.wait(2)\n\n # Clear All Elements Except Area and Result\n remaining_elements = VGroup(axes, graph, area, label_start, line_start, label_end, line_end)\n self.play(FadeOut(remaining_elements, shift=DOWN))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 have an educational animation that visually explains the process of integrating the exponential function e raised to the power of 2x with respect to x. The animation should start by displaying the integra\n- Act 2: I want to create an animation where a piece of text reading \"Indicate\" appears and moves to the top of the screen quickly. Then, another text saying \"This is important\" appears, and I want this text to be highlighted or ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0303(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_integrateexponential()\n self.clear_stage()\n self.act_2_textemphasissequence()\n\n def act_1_integrateexponential(self):\n problem = MathTex(r\"\\int e^{2x} \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem))\n self.wait(2)\n\n # Step 2: Display explanatory text suggesting the exponential rule\n rule_text = MathTex(\n r\"\\text{Rule: } \\int e^{ax} \\, dx = \\frac{1}{a}e^{ax} + C\",\n color=BLUE\n ).scale(0.9).next_to(problem, DOWN, buff=0.5)\n self.play(Write(rule_text))\n self.wait(3)\n\n # Step 3: Show the application of the rule (Intermediate Step)\n intermediate_step = MathTex(r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x}\")\n intermediate_step.scale(1.5).move_to(problem)\n\n self.play(\n ReplacementTransform(problem, intermediate_step),\n rule_text.animate.set_opacity(0.5)\n )\n self.wait(2)\n\n # Step 4: Morph the intermediate step into the final solution\n final_solution = MathTex(r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x} + C\")\n final_solution.scale(1.5).move_to(intermediate_step)\n\n self.play(\n ReplacementTransform(intermediate_step, final_solution),\n FadeOut(rule_text)\n )\n self.wait(2)\n\n # Step 5: Isolate and emphasize the final solution\n result_only = MathTex(r\"\\frac{1}{2}e^{2x} + C\")\n result_only.scale(1.8).set_color(YELLOW)\n\n self.play(\n ReplacementTransform(final_solution, result_only)\n )\n \n # Add a surrounding box for emphasis\n box = SurroundingRectangle(result_only, color=WHITE, buff=0.3)\n self.play(Create(box))\n \n self.wait(4)\n\n def act_2_textemphasissequence(self):\n text_indicate = Text(\"Indicate\", font_size=48)\n self.play(Write(text_indicate))\n self.play(\n text_indicate.animate.to_edge(UP), \n run_time=0.5, \n rate_func=rush_into\n )\n \n # 2. Secondary Text: Display \"This is important\" after the first movement\n text_important = Text(\"This is important\", font_size=48)\n self.play(Write(text_important))\n \n # 3. Emphasis: Apply a highlighting effect to the second text\n highlight_box = SurroundingRectangle(text_important, color=YELLOW, buff=0.1)\n self.play(\n Indicate(text_important, color=YELLOW),\n ShowPassingFlash(highlight_box, time_width=0.5)\n )\n \n # 4. Conclusion: Make the second text disappear after emphasis\n self.play(FadeOut(text_important))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0303(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_integrateexponential()\n self.clear_stage()\n self.act_2_textemphasissequence()\n\n def act_1_integrateexponential(self):\n problem = MathTex(r\"\\int e^{2x} \\, dx\" + \" = x\")\n problem.scale(1.5)\n self.play(Write(problem))\n self.wait(2)\n\n # Step 2: Display explanatory text suggesting the exponential rule\n rule_text = MathTex(\n r\"\\text{Rule: } \\int e^{ax} \\, dx = \\frac{1}{a}e^{ax} + C\",\n color=BLUE\n ).scale(0.9).next_to(problem, DOWN, buff=0.5)\n self.play(Write(rule_text))\n self.wait(3)\n\n # Step 3: Show the application of the rule (Intermediate Step)\n intermediate_step = MathTex(r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x}\")\n intermediate_step.scale(1.5).move_to(problem)\n\n self.play(\n ReplacementTransform(problem, intermediate_step),\n rule_text.animate.set_opacity(0.5)\n )\n self.wait(2)\n\n # Step 4: Morph the intermediate step into the final solution\n final_solution = MathTex(r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x} + C\")\n final_solution.scale(1.5).move_to(intermediate_step)\n\n self.play(\n ReplacementTransform(intermediate_step, final_solution),\n FadeOut(rule_text)\n )\n self.wait(2)\n\n # Step 5: Isolate and emphasize the final solution\n result_only = MathTex(r\"\\frac{1}{2}e^{2x} + C\")\n result_only.scale(1.8).set_color(YELLOW)\n\n self.play(\n ReplacementTransform(final_solution, result_only)\n )\n \n # Add a surrounding box for emphasis\n box = SurroundingRectangle(result_only, color=WHITE, buff=0.3)\n self.play(Create(box))\n \n self.wait(4)\n\n def act_2_textemphasissequence(self):\n text_indicate = Text(\"Indicate\", font_size=48)\n self.play(Write(text_indicate))\n self.play(\n text_indicate.animate.to_edge(UP), \n run_time=0.5, \n rate_func=rush_into\n )\n \n # 2. Secondary Text: Display \"This is important\" after the first movement\n text_important = Text(\"This is important\", font_size=48)\n self.play(Write(text_important))\n \n # 3. Emphasis: Apply a highlighting effect to the second text\n highlight_box = SurroundingRectangle(text_important, color=YELLOW, buff=0.1)\n self.play(\n Indicate(text_important, color=YELLOW),\n ShowPassingFlash(highlight_box, time_width=0.5)\n )\n \n # 4. Conclusion: Make the second text disappear after emphasis\n self.play(FadeOut(text_important))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass AtomVisualization(Scene):\n def construct(self):\n # --- 1. Nucleus Visualization ---\n # Create a cluster of 16 nucleons (8 protons, 8 neutrons)\n protons = VGroup(*[Circle(radius=0.15, color=BLUE, fill_opacity=0.8) for _ in range(8)])\n neutrons = VGroup(*[Circle(radius=0.15, color=BLUE_E, fill_opacity=0.8) for _ in range(8)])\n \n nucleus = VGroup(protons, neutrons)\n # Arrange nucleons in a compact cluster\n nucleus.arrange_in_grid(rows=4, cols=4, buff=0.05)\n nucleus.move_to(ORIGIN)\n \n # Labels for components\n proton_label = Text(\"Protons\", font_size=24, color=BLUE).next_to(nucleus, UL, buff=0.5)\n neutron_label = Text(\"Neutrons\", font_size=24, color=BLUE_E).next_to(nucleus, DL, buff=0.5)\n \n # Fade in nucleus and labels\n self.play(FadeIn(nucleus), Write(proton_label), Write(neutron_label), run_time=2)\n self.wait(0.5)\n \n # --- 2. Electron Orbits ---\n # Define two grey elliptical paths (rotated for a 3D perspective effect)\n inner_orbit = Ellipse(width=3, height=1.5, color=GREY, stroke_opacity=0.6).rotate(PI/4)\n outer_orbit = Ellipse(width=5, height=2.5, color=GREY, stroke_opacity=0.6).rotate(-PI/4)\n \n self.play(Create(inner_orbit), Create(outer_orbit), run_time=1)\n \n # --- 3. Electrons ---\n # Inner Orbit: 2 electrons (Red dots)\n # Outer Orbit: 4 electrons (Red dots)\n inner_electrons = VGroup()\n for i in range(2):\n e = Dot(color=RED, radius=0.08)\n e.move_to(inner_orbit.point_from_proportion(i/2))\n inner_electrons.add(e)\n \n outer_electrons = VGroup()\n for i in range(4):\n e = Dot(color=RED, radius=0.08)\n e.move_to(outer_orbit.point_from_proportion(i/4))\n outer_electrons.add(e)\n \n all_electrons = VGroup(inner_electrons, outer_electrons)\n \n # --- 4. Animation Sequence ---\n # Electrons begin moving along their paths one by one with a slight delay\n electron_animations = []\n \n for electron in inner_electrons:\n electron_animations.append(MoveAlongPath(electron, inner_orbit, rate_func=linear, run_time=4))\n \n for electron in outer_electrons:\n electron_animations.append(MoveAlongPath(electron, outer_orbit, rate_func=linear, run_time=4))\n \n # Play animations with a staggered start (lag_ratio creates the delay)\n self.play(LaggedStart(*electron_animations, lag_ratio=0.2), run_time=4)\n \n # Duration: Continue animation for a short period once all are in motion\n ongoing_animations = []\n for i, electron in enumerate(inner_electrons):\n ongoing_animations.append(MoveAlongPath(electron, inner_orbit, rate_func=linear, run_time=4))\n for i, electron in enumerate(outer_electrons):\n ongoing_animations.append(MoveAlongPath(electron, outer_orbit, rate_func=linear, run_time=4))\n \n self.play(*ongoing_animations, run_time=4)\n \n # --- 5. End Sequence ---\n # Fade out everything\n self.play(\n FadeOut(nucleus), FadeOut(proton_label), FadeOut(neutron_label),\n FadeOut(inner_orbit), FadeOut(outer_orbit), FadeOut(all_electrons),\n run_time=1.5\n )\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass AtomVisualization(Scene):\n def construct(self):\n # --- 1. Nucleus Visualization ---\n # Create a cluster of 16 nucleons (8 protons, 8 neutrons)\n protons = VGroup(*[Circle(radius=0.15, color=BBLUE, fill_opacity=0.8) for _ in range(8)])\n neutrons = VGroup(*[Circle(radius=0.15, color=BLUE_E, fill_opacity=0.8) for _ in range(8)])\n \n nucleus = VGroup(protons, neutrons)\n # Arrange nucleons in a compact cluster\n nucleus.arrange_in_grid(rows=4, cols=4, buff=0.05)\n nucleus.move_to(ORIGIN)\n \n # Labels for components\n proton_label = Text(\"Protons\", font_size=24, color=BLUE).next_to(nucleus, UL, buff=0.5)\n neutron_label = Text(\"Neutrons\", font_size=24, color=BLUE_E).next_to(nucleus, DL, buff=0.5)\n \n # Fade in nucleus and labels\n self.play(FadeIn(nucleus), Write(proton_label), Write(neutron_label), run_time=2)\n self.wait(0.5)\n \n # --- 2. Electron Orbits ---\n # Define two grey elliptical paths (rotated for a 3D perspective effect)\n inner_orbit = Ellipse(width=3, height=1.5, color=GREY, stroke_opacity=0.6).rotate(PI/4)\n outer_orbit = Ellipse(width=5, height=2.5, color=GREY, stroke_opacity=0.6).rotate(-PI/4)\n \n self.play(Create(inner_orbit), Create(outer_orbit), run_time=1)\n \n # --- 3. Electrons ---\n # Inner Orbit: 2 electrons (Red dots)\n # Outer Orbit: 4 electrons (Red dots)\n inner_electrons = VGroup()\n for i in range(2):\n e = Dot(color=RED, radius=0.08)\n e.move_to(inner_orbit.point_from_proportion(i/2))\n inner_electrons.add(e)\n \n outer_electrons = VGroup()\n for i in range(4):\n e = Dot(color=RED, radius=0.08)\n e.move_to(outer_orbit.point_from_proportion(i/4))\n outer_electrons.add(e)\n \n all_electrons = VGroup(inner_electrons, outer_electrons)\n \n # --- 4. Animation Sequence ---\n # Electrons begin moving along their paths one by one with a slight delay\n electron_animations = []\n \n for electron in inner_electrons:\n electron_animations.append(MoveAlongPath(electron, inner_orbit, rate_func=linear, run_time=4))\n \n for electron in outer_electrons:\n electron_animations.append(MoveAlongPath(electron, outer_orbit, rate_func=linear, run_time=4))\n \n # Play animations with a staggered start (lag_ratio creates the delay)\n self.play(LaggedStart(*electron_animations, lag_ratio=0.2), run_time=4)\n \n # Duration: Continue animation for a short period once all are in motion\n ongoing_animations = []\n for i, electron in enumerate(inner_electrons):\n ongoing_animations.append(MoveAlongPath(electron, inner_orbit, rate_func=linear, run_time=4))\n for i, electron in enumerate(outer_electrons):\n ongoing_animations.append(MoveAlongPath(electron, outer_orbit, rate_func=linear, run_time=4))\n \n self.play(*ongoing_animations, run_time=4)\n \n # --- 5. End Sequence ---\n # Fade out everything\n self.play(\n FadeOut(nucleus), FadeOut(proton_label), FadeOut(neutron_label),\n FadeOut(inner_orbit), FadeOut(outer_orbit), FadeOut(all_electrons),\n run_time=1.5\n )\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## 3. Deriving Equilibrium Income and the Government Spending Multiplier\n\n### 1. Solving for Equilibrium Income \\(Y\\) (Board Work)\n\nFrom:\n\\[\nY = C_0 + cY + I + G\n\\]\n\nRearrange:\n\\[\nY - cY = C_0 + I + G\n\\]\n\n\\[\n(1 - c)Y = C_0 + I + G\n\\]\n\nThus:\n\\[\nY = \\frac{1}{1 - c}(C_0 + I + G)\n\\]\n\n\nContextual location of this section: None\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass DeriveEquilibriumIncome(Scene):\n def construct(self):\n title = Text(\"Deriving Equilibrium Income\", font_size=36).to_edge(UP)\n context_text = Text(\n \"Where:\\n$C_{0}$ = autonomous consumption\\n$c$ = marginal propensity to consume\",\n font_size=24,\n ).next_to(title, DOWN, buff=0.5)\n \n equation_initial = MathTex(\"Y = C_0 + cy + I + G\").scale(1.2).shift(DOWN * 1.8)\n \n step_rearrange = MathTex(\"Y - cy = C_0 + I + G\").scale(1.2).shift(UP * 0.7)\n \n step_factor = MathTex(\"(1 - c)Y = C_0 + I + G\").scale(1.2).shift(DOWN * 0.8)\n \n final_equation = MathTex(\"Y = \\\\frac{1}{1-c} (C_0 + I + G)\").scale(1.2).move_to(ORIGIN)\n \n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(context_text, shift=DOWN * 0.5))\n self.wait(1)\n self.play(Write(equation_initial))\n self.wait(1)\n self.play(TransformMatchingTex(equation_initial.copy(), step_rearrange))\n self.wait(1)\n self.play(TransformMatchingTex(step_rearrange.copy(), step_factor))\n self.wait(1)\n self.play(Write(final_equation))\n self.wait(1)\n self.play(FadeOut(VGroup(title, context_text, equation_initial, step_rearrange, step_factor)))\n box = SurroundingRectangle(final_equation, color=BLUE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass DerivingEquilibriumIncome(Scene):\n\n def construct(self):\n title = Text(\"Deriving Equilibrium Income and the\\nGovernment Spending Multiplier\", font_size=36).to_edge(UP)\n eq_from = MathTex(\"Y\", \"=\", \"C_0\", \"+\", \"cY\", \"+\", \"I\", \"+\", \"G\").scale(1.2).next_to(title, DOWN, buff=0.8)\n eq_rearrange = MathTex(\"Y\", \"-\", \"cY\", \"=\", \"C_0\", \"+\", \"I\", \"+\", \"G\").scale(1.2).move_to(eq_from.get_center())\n eq_group = VGroup(MathTex(\"(1 - c)\", \"Y\"), \"=\", \"\\\\frac{\"+\"\\\\text{constants}\"+\"}\", \"{\",\"(\", \"1\", \"-\" , \"c\", \")\"} ).scale(1.2).shift(DOWN*1.7)\n \n # Create arrows between equations\n arrow1 = Arrow(start=eq_from.get_bottom(), end=eq_rearrange.get_top(), color=YELLOW, buff=0.1)\n arrow2 = Arrow(start=eq_rearrange.get_bottom(), end=eq_group.get_top(), color=GREEN, buff=0.1)\n\n self.play(Write(title))\n self.wait(0.5)\n self.play(Write(eq_from))\n self.wait(0.5)\n self.play(GrowArrow(arrow1), Write(eq_rearrange))\n self.wait(0.5)\n const_tex = VGroup(MathTex(\"\\\\text{where}\"), MathTex(\"\\\\text{'constants}'\")).arrange(RIGHT, buff=0.2)\n const_tex.next_to(eq_group, LEFT, buff=-0.1).set_color(YELLOW)\n self.play(Write(const_tex), GrowArrow(arrow2), Write(eq_group))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 Manim scene demonstrating the concept of homology groups in algebraic topology. Visualize cycles, boundaries, and homology classes, step by step.\n- Act 2: I would like to create an animation where a text saying \"Look Here\" appears on the screen, then gets encircled by a shape to highlight it. First, I want the text to be highlighted by a rectangle that automatically adjust\n- Act 3: 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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0187(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_homologygroups()\n self.clear_stage()\n self.act_2_circumscribeanimation()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_homologygroups(self):\n title = Title(\"Homology Groups\")\n self.play(Write(title))\n\n # Fundamental polygon shape\n poly = Polygon(\n [-3,0,0],[-1,-2,0],[1,-2,0],[3,0,0],\n [1,2,0],[-1,2,0]\n )\n self.play(Create(poly))\n \n # Show some cycles\n cycle1 = poly.copy().set_color(RED)\n cycle2 = poly.copy().set_color(BLUE)\n self.play(\n Create(cycle1),\n Create(cycle2)\n )\n\n # Boundary\n bound = DashedLine(\n ORIGIN, [1,-1,0], stroke_width=4\n )\n self.play(Create(bound))\n\n # Quotient notation\n text = MathTex(r\"H_1 = \\frac{Z_1}{B_1}\")\n self.play(FadeIn(text, shift=UP))\n\n # Null-homologous collapse\n self.play(\n ApplyMethod(cycle1.scale, 0), \n run_time=2\n )\n hom_class = SurroundingRectangle(cycle2)\n self.play(Create(hom_class))\n\n def act_2_circumscribeanimation(self):\n intro_text = Text(\"Circumscribe\", font_size=48)\n intro_text.shift(DOWN * 3)\n \n # Animate writing the text and moving it upwards simultaneously\n self.play(Write(intro_text), intro_text.animate.shift(UP * 3))\n \n # Fade out the intro text to clear the screen for the main sequence\n self.play(FadeOut(intro_text))\n\n # --- Main Sequence ---\n # 1. Appearance of \"Look Here\"\n main_text = Text(\"Look Here\", font_size=48)\n self.play(Write(main_text))\n\n # 2. Rectangle Highlight\n # SurroundingRectangle automatically adjusts to the bounds of the text\n rect = SurroundingRectangle(main_text, color=YELLOW, buff=0.3)\n self.play(Create(rect))\n\n # 3. Transformation to Circle\n # Calculate a radius that ensures the circle encompasses the text fully\n # using the diagonal of the text bounds plus a buffer.\n width = main_text.get_width()\n height = main_text.get_height()\n radius = np.sqrt(width**2 + height**2) / 2 + 0.3\n \n circle = Circle(radius=radius, color=YELLOW)\n circle.move_to(main_text.get_center())\n \n # Morph the rectangle into the circle\n self.play(ReplacementTransform(rect, circle))\n\n # 4. Disappearance\n # Fade out both the text and the highlighting shape\n self.play(FadeOut(main_text), FadeOut(circle))\n\n def act_3_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0187(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_homologygroups()\n self.clear_stage()\n self.act_2_circumscribeanimation()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_homologygroups(self):\n title = Title(\"Homology Groups\")\n self.play(Write(title))\n\n # Fundamental polygon shape\n poly = Polygon(\n [-3,0,0],[-1,-2,0],[1,-2,0],[3,0,0],\n [1,2,0],[-1,2,0]\n )\n self.play(Create(poly))\n \n # Show some cycles\n cycle1 = poly.copy().set_color(RED)\n cycle2 = poly.copy().set_color(BLUE)\n self.play(\n Create(cycle1),\n Create(cycle2)\n )\n\n # Boundary\n bound = DashedLine(\n ORIGIN, [1,-1,0], stroke_width=4\n )\n self.play(Create(bound))\n\n # Quotient notation\n text = MathTex(r\"H_1 = \\frac{Z_1}{B_1}\")\n self.play(FadeIn(text, shift=UP))\n\n # Null-homologous collapse\n self.play(\n ApplyMethod(cycle1.scale, 0), \n run_time=2\n )\n hom_class = SurroundingRectangle(cycle2)\n self.play(Create(hom_class))\n\n def act_2_circumscribeanimation(self):\n intro_text = Text(\"Circumscribe\", font_size=48)\n intro_text.shift(DOWN * 3)\n \n # Animate writing the text and moving it upwards simultaneously\n self.play(Write(intro_text), intro_text.animate.shift(UP * 3))\n \n # Fade out the intro text to clear the screen for the main sequence\n self.play(FadeOut(intro_text))\n\n # --- Main Sequence ---\n # 1. Appearance of \"Look Here\"\n main_text = Text(\"Look Here\", font_size=48)\n self.play(Write(main_text))\n\n # 2. Rectangle Highlight\n # SurroundingRectangle automatically adjusts to the bounds of the text\n rect = SurroundingRectangle(main_text, color=YELLOW, buff=0.3)\n self.play(Create(rect))\n\n # 3. Transformation to Circle\n # Calculate a radius that ensures the circle encompasses the text fully\n # using the diagonal of the text bounds plus a buffer.\n width = main_text.get_width()\n height = main_text.get_height()\n radius = np.sqrt(width**2 + height**2) / 2 + 0.3\n \n circle = Circle(radius=radius, color=YELLOW)\n circle.move_to(main_text.get_center())\n \n # Morph the rectangle into the circle\n self.play(ReplacementTransform(rect, circle))\n\n # 4. Disappearance\n # Fade out both the text and the highlighting shape\n self.play(FadeOut(main_text), FadeOut(circle))\n\n def act_3_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create a detailed animation that visually demonstrates how a simple convolutional neural network goes through the forward pass process using an example image I have? The animation should start by showing the image, followed by the layers of the network, including convolutional layers, max pooling, and feedforward layers. Each layer should be visually distinct and the flow of data through the network should be animated step by step. Additionally, I'd like the neural network diagram to be centered and the whole forward pass animation to last for about 15 seconds, ending with a short pause.", "chosen": "```python\nfrom manim import *\n\nclass CNNForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n # Colors for distinct layer types\n COLOR_INPUT = BLUE\n COLOR_CONV = YELLOW\n COLOR_POOL = GREEN\n COLOR_FC = PURPLE\n COLOR_OUT = RED\n \n # --- 1. Input Image Representation ---\n # Grid of squares to simulate a placeholder image\n input_grid = VGroup(*[\n Square(side_length=0.4, fill_opacity=0.8, fill_color=COLOR_INPUT, stroke_color=WHITE, stroke_width=1)\n for _ in range(16)\n ]).arrange_in_grid(rows=4, cols=4, buff=0.05)\n \n input_label = Text(\"Input Image\", font_size=24).next_to(input_grid, DOWN, buff=0.3)\n input_group = VGroup(input_grid, input_label)\n \n # --- 2. Convolutional Layer ---\n # Stacked rectangles to imply depth (feature maps)\n conv_layer = VGroup()\n for i in range(3):\n rect = Rectangle(height=1.2, width=0.8, fill_opacity=0.6, fill_color=COLOR_CONV, stroke_color=WHITE)\n rect.shift(RIGHT * 0.1 * i + UP * 0.1 * i)\n conv_layer.add(rect)\n conv_label = Text(\"Conv Layer\", font_size=24, color=COLOR_CONV).next_to(conv_layer, DOWN, buff=0.3)\n conv_group = VGroup(conv_layer, conv_label)\n \n # --- 3. Max Pooling Layer ---\n # Smaller stacked rectangles to show downsampling\n pool_layer = VGroup()\n for i in range(2):\n rect = Rectangle(height=0.8, width=0.5, fill_opacity=0.6, fill_color=COLOR_POOL, stroke_color=WHITE)\n rect.shift(RIGHT * 0.1 * i + UP * 0.1 * i)\n pool_layer.add(rect)\n pool_label = Text(\"Max Pool\", font_size=24, color=COLOR_POOL).next_to(pool_layer, DOWN, buff=0.3)\n pool_group = VGroup(pool_layer, pool_label)\n \n # --- 4. Feedforward (Dense) Layers ---\n # Nodes and connections\n fc_neurons = VGroup()\n layer_counts = [4, 3, 2]\n for i, count in enumerate(layer_counts):\n col = VGroup(*[Circle(radius=0.15, fill_opacity=0.8, fill_color=COLOR_FC, stroke_color=WHITE) for _ in range(count)])\n col.arrange(DOWN, buff=0.3)\n col.shift(RIGHT * i * 1.2)\n fc_neurons.add(col)\n \n fc_connections = VGroup()\n for i in range(len(layer_counts) - 1):\n for j in range(layer_counts[i]):\n for k in range(layer_counts[i+1]):\n start = fc_neurons[i][j].get_center()\n end = fc_neurons[i+1][k].get_center()\n fc_connections.add(Line(start, end, stroke_width=1, stroke_color=GRAY))\n \n fc_label = Text(\"Feedforward\", font_size=24, color=COLOR_FC).next_to(fc_neurons, DOWN, buff=0.3)\n fc_group = VGroup(fc_neurons, fc_connections, fc_label)\n \n # --- 5. Output Layer ---\n output_node = Circle(radius=0.2, fill_opacity=0.9, fill_color=COLOR_OUT, stroke_color=WHITE)\n output_label = Text(\"Output\", font_size=24, color=COLOR_OUT).next_to(output_node, DOWN, buff=0.3)\n output_group = VGroup(output_node, output_label)\n \n # --- Layout & Centering ---\n all_layers = VGroup(input_group, conv_group, pool_group, fc_group, output_group)\n all_layers.arrange(RIGHT, buff=0.8)\n all_layers.center()\n \n # --- Animation Sequence ---\n # Total duration: ~15 seconds\n \n # 1. Show Input (2s)\n self.play(FadeIn(input_group), run_time=2)\n \n # 2. Flow to Conv & Show Conv Layer (3s)\n arrow1 = Arrow(input_group.get_right(), conv_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow1), FadeIn(conv_group), run_time=2)\n self.play(Indicate(conv_layer, color=YELLOW, scale_factor=1.1), run_time=1)\n \n # 3. Flow to Pool & Show Pool Layer (3s)\n arrow2 = Arrow(conv_group.get_right(), pool_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow2), FadeIn(pool_group), run_time=2)\n self.play(Indicate(pool_layer, color=WHITE, scale_factor=1.1), run_time=1)\n \n # 4. Flow to FC & Show Feedforward Layer (4s)\n arrow3 = Arrow(pool_group.get_right(), fc_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow3), FadeIn(fc_group), run_time=2.5)\n # Animate neurons activating\n self.play(\n fc_neurons[0].animate.set_fill(RED, opacity=1),\n fc_neurons[1].animate.set_fill(RED, opacity=1),\n fc_neurons[2].animate.set_fill(RED, opacity=1),\n run_time=1.5\n )\n \n # 5. Flow to Output & Final Data Pulse (3s)\n arrow4 = Arrow(fc_group.get_right(), output_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow4), FadeIn(output_group), run_time=1.5)\n \n # Animate a pulse moving through the network\n pulse = Dot(color=WHITE, radius=0.1).move_to(input_grid.get_center())\n self.add(pulse)\n self.play(\n pulse.animate.move_to(conv_layer.get_center()),\n run_time=0.5\n )\n self.play(\n pulse.animate.move_to(pool_layer.get_center()),\n run_time=0.5\n )\n self.play(\n pulse.animate.move_to(fc_neurons.get_center()),\n run_time=0.5\n )\n self.play(FadeOut(pulse), run_time=0.2)\n \n # 6. Short Pause at the End (2s)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CNNForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n # Colors for distinct layer types\n COLOR_INPUT = BBLUE\n COLOR_CONV = YELLOW\n COLOR_POOL = GREEN\n COLOR_FC = PURPLE\n COLOR_OUT = RED\n \n # --- 1. Input Image Representation ---\n # Grid of squares to simulate a placeholder image\n input_grid = VGroup(*[\n Square(side_length=0.4, fill_opacity=0.8, fill_color=COLOR_INPUT, stroke_color=WHITE, stroke_width=1)\n for _ in range(16)\n ]).arrange_in_grid(rows=4, cols=4, buff=0.05)\n \n input_label = Text(\"Input Image\", font_size=24).next_to(input_grid, DOWN, buff=0.3)\n input_group = VGroup(input_grid, input_label)\n \n # --- 2. Convolutional Layer ---\n # Stacked rectangles to imply depth (feature maps)\n conv_layer = VGroup()\n for i in range(3):\n rect = Rectangle(height=1.2, width=0.8, fill_opacity=0.6, fill_color=COLOR_CONV, stroke_color=WHITE)\n rect.shift(RIGHT * 0.1 * i + UP * 0.1 * i)\n conv_layer.add(rect)\n conv_label = Text(\"Conv Layer\", font_size=24, color=COLOR_CONV).next_to(conv_layer, DOWN, buff=0.3)\n conv_group = VGroup(conv_layer, conv_label)\n \n # --- 3. Max Pooling Layer ---\n # Smaller stacked rectangles to show downsampling\n pool_layer = VGroup()\n for i in range(2):\n rect = Rectangle(height=0.8, width=0.5, fill_opacity=0.6, fill_color=COLOR_POOL, stroke_color=WHITE)\n rect.shift(RIGHT * 0.1 * i + UP * 0.1 * i)\n pool_layer.add(rect)\n pool_label = Text(\"Max Pool\", font_size=24, color=COLOR_POOL).next_to(pool_layer, DOWN, buff=0.3)\n pool_group = VGroup(pool_layer, pool_label)\n \n # --- 4. Feedforward (Dense) Layers ---\n # Nodes and connections\n fc_neurons = VGroup()\n layer_counts = [4, 3, 2]\n for i, count in enumerate(layer_counts):\n col = VGroup(*[Circle(radius=0.15, fill_opacity=0.8, fill_color=COLOR_FC, stroke_color=WHITE) for _ in range(count)])\n col.arrange(DOWN, buff=0.3)\n col.shift(RIGHT * i * 1.2)\n fc_neurons.add(col)\n \n fc_connections = VGroup()\n for i in range(len(layer_counts) - 1):\n for j in range(layer_counts[i]):\n for k in range(layer_counts[i+1]):\n start = fc_neurons[i][j].get_center()\n end = fc_neurons[i+1][k].get_center()\n fc_connections.add(Line(start, end, stroke_width=1, stroke_color=GRAY))\n \n fc_label = Text(\"Feedforward\", font_size=24, color=COLOR_FC).next_to(fc_neurons, DOWN, buff=0.3)\n fc_group = VGroup(fc_neurons, fc_connections, fc_label)\n \n # --- 5. Output Layer ---\n output_node = Circle(radius=0.2, fill_opacity=0.9, fill_color=COLOR_OUT, stroke_color=WHITE)\n output_label = Text(\"Output\", font_size=24, color=COLOR_OUT).next_to(output_node, DOWN, buff=0.3)\n output_group = VGroup(output_node, output_label)\n \n # --- Layout & Centering ---\n all_layers = VGroup(input_group, conv_group, pool_group, fc_group, output_group)\n all_layers.arrange(RIGHT, buff=0.8)\n all_layers.center()\n \n # --- Animation Sequence ---\n # Total duration: ~15 seconds\n \n # 1. Show Input (2s)\n self.play(FadeIn(input_group), run_time=2)\n \n # 2. Flow to Conv & Show Conv Layer (3s)\n arrow1 = Arrow(input_group.get_right(), conv_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow1), FadeIn(conv_group), run_time=2)\n self.play(Indicate(conv_layer, color=YELLOW, scale_factor=1.1), run_time=1)\n \n # 3. Flow to Pool & Show Pool Layer (3s)\n arrow2 = Arrow(conv_group.get_right(), pool_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow2), FadeIn(pool_group), run_time=2)\n self.play(Indicate(pool_layer, color=WHITE, scale_factor=1.1), run_time=1)\n \n # 4. Flow to FC & Show Feedforward Layer (4s)\n arrow3 = Arrow(pool_group.get_right(), fc_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow3), FadeIn(fc_group), run_time=2.5)\n # Animate neurons activating\n self.play(\n fc_neurons[0].animate.set_fill(RED, opacity=1),\n fc_neurons[1].animate.set_fill(RED, opacity=1),\n fc_neurons[2].animate.set_fill(RED, opacity=1),\n run_time=1.5\n )\n \n # 5. Flow to Output & Final Data Pulse (3s)\n arrow4 = Arrow(fc_group.get_right(), output_group.get_left(), buff=0.2, color=WHITE)\n self.play(GrowArrow(arrow4), FadeIn(output_group), run_time=1.5)\n \n # Animate a pulse moving through the network\n pulse = Dot(color=WHITE, radius=0.1).move_to(input_grid.get_center())\n self.add(pulse)\n self.play(\n pulse.animate.move_to(conv_layer.get_center()),\n run_time=0.5\n )\n self.play(\n pulse.animate.move_to(pool_layer.get_center()),\n run_time=0.5\n )\n self.play(\n pulse.animate.move_to(fc_neurons.get_center()),\n run_time=0.5\n )\n self.play(FadeOut(pulse), run_time=0.2)\n \n # 6. Short Pause at the End (2s)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second logic scene explaining necessary and sufficient conditions with nested sets. Put set A entirely inside set B, animate examples inside and outside A, and label that A is sufficient for B while B is necessary for A. Avoid implying the converse.", "chosen": "```python\nfrom manim import *\n\nclass SufficientNecessaryScene(Scene):\n def construct(self):\n title = Text(\"Sufficient vs Necessary Conditions\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Draw Venn Diagram\n circle_A = Circle(radius=2.0, color=BLUE, fill_opacity=0.15).shift(LEFT*2)\n text_A = MathTex(\"A\").next_to(circle_A, DOWN)\n \n circle_B = Circle(radius=3.0, color=GREEN, fill_opacity=0.15).move_to(RIGHT*2)\n text_B = MathTex(\"B\").next_to(circle_B, UP)\n \n self.add(text_A, text_B)\n self.play(Create(circle_A), Create(circle_B))\n\n # Show elements in A but not in B\n element_in_A_not_in_B = Dot(point=circle_A.point_at_angle(TAU/4) + RIGHT*1.5, color=YELLOW).scale(1.5)\n label_outside = MathTex(\"\\\\text{Not in } B\\\\ \\\\Rightarrow \\\\text{Possible}\").next_to(element_in_A_not_in_B, DOWN)\n \n self.play(FadeIn(element_in_A_not_in_B), Write(label_outside))\n\n # Show elements in both A and B\n shared_element = Dot(point=ORIGIN, color=WHITE).scale(1.5)\n label_inside = MathTex(\"\\\\text{Both in } A\\\\ \\\\wedge \\\\text{in } B\").next_to(shared_element, DOWN)\n\n self.play(Transform(element_in_A_not_in_B, shared_element), FadeOut(label_outside), Write(label_inside))\n\n # Show elements only in B\n element_only_in_B = Dot(point=circle_B.get_right(), color=RED).scale(1.5)\n label_only_in_B = MathTex(\"\\\\text{Only in } B\\\\ \\\\nrightarrow \\\\text{Required by } A\").next_to(element_only_in_B, UP)\n\n self.play(FadeIn(element_only_in_B), Write(label_only_in_B))\n\n # Add labels for condition statements\n statement_sufficient = MathTex(\"\\\\text{If } A \\\\text{ then } B\", color=BLUE).to_edge(DOWN).shift(LEFT*2)\n statement_necessary = MathTex(\"\\\\text{If } B \\\\text{ then } A\", color=GREEN).to_edge(DOWN).shift(RIGHT*2)\n\n self.play(Write(statement_sufficient), Write(statement_necessary))\n \n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass NecessarySufficientSets(Scene):\n def construct(self):\n title = Text(\"Necessary vs Sufficient Conditions\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Draw outer rectangle representing Set B\n b_rect = RoundedRectangle(corner_radius=0.2, width=4, height=2.5, color=BLUE_D)\n b_label = Text(\"Set B\", font_size=28, color=WHITE).next_to(b_rect.get_top(), DOWN, buff=-0.15)\n \n # Draw inner circle representing Set A completely inside Set B\n a_circle = Circle(radius=1.3, color=GREEN_C)\n a_center = ORIGIN + UP * 0.75 + LEFT * 1.5\n a_circle.move_to(a_center) # Move center of circle to make it fit perfectly within B's bounds\n \n a_label = Text(\"Set A\", font_size=28, color=WHITE).move_to(a_circle.get_right())\n \n # Animate creation of sets\n self.play(Create(b_rect), Write(b_label))\n self.play(DrawBorderThenFill(a_circle), Write(a_label))\n\n # Show elements inside both sets\n element_inside_a = Dot(a_center + RIGHT * 0.3, radius=0.12, color=YELLOW)\n text_inside_a = MathTex(\"\\\\text{Element}\", color=YELLOW).next_to(element_inside_a, DOWN, buff=0.1)\n\n element_outside_a = Dot(a_center + RIGHT * 1.5, radius=0.12, color=RED)\n text_outside_a = MathTex(\"\\\\text{Element}\", color=RED).next_to(element_outside_a, DOWN, buff=0.1)\n\n condition_text_sufficient = Tex(\"$A \\\\implies B$ \\\\\\\\ ($A$ is sufficient for $B$)\").scale(0.7).to_edge(RIGHT, buff=1.5).shift(UP * 0.2)\n condition_text_necessary = Tex(\"$\\\\nexists x : (x \\\\in B \\\\land x \\\\notin A)$\").scale(0.65).to_edge(RIGHT, buff=1.5).shift(DOWN * 0.2)\n\n # Animate elements appearing sequentially to show inclusion\n self.add(element_inside_a, text_inside_a)\n self.wait(0.5)\n\n self.add(element_outside_a, text_outside_a)\n self.wait(0.5)\n\n self.play(\n FadeIn(condition_text_sufficient),\n RunTime(1.5)\n )\n\n # Label the necessity relationship separately\n self.play(FadeIn(condition_text_necessary, shift=RIGHT * 0.2))\n self.wait(2)\n\n# To run this animation, save it as 'necessary_sufficient_sets.py' and execute:\n# manim -pql necessary_sufficient_sets.py NecessarySufficientSets\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated video that shows how to test if an infinite series converges or not using the p-test. Start by displaying the sum of 1 over n squared from n equals 1 to infinity. Next, introduce text explaining we will apply the p-test and then show that p, in this case, is 2 which is greater than 1. Then, replace the initial text with a statement that concludes the series is convergent. Finally, clear the screen and end with the statement that the series is convergent being written once more. Can you make this animation engaging and easy to understand?", "chosen": "```python\nfrom manim import *\n\nclass PTestScene(Scene):\n def construct(self):\n # --- Step 1: Display the Series ---\n title = MathTex(\n r\"\\sum_{n=1}^{\\infty}\", \n \"\\\\frac{1}{n^2}\"\n ).scale(1.5).to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # --- Step 2: Introduce P-Test ---\n intro_text = Text(\"Applying the p-test\", font_size=36).next_to(title, DOWN)\n self.play(Write(intro_text))\n self.wait(1.5)\n \n p_value = MathTex(\"p\", \"=\", \"2\").shift(DOWN*1.5 + LEFT*2)\n condition = MathTex(\"\\\\text{where } p > 1 \\\\rightarrow \\\\text{Converges}\")\n \n for obj in [p_value, condition]:\n self.play(Write(obj))\n else:\n pass\n \n self.wait(2)\n \n # --- Step 3: Replace Intro Text ---\n conclusion_text = Text(\"The series is CONVERGENT!\", color=GREEN, font_size=48)\n replacement_group = VGroup(p_value, condition) \n \n self.play(\n ReplacementTransform(intro_text, conclusion_text),\n FadeOut(replacement_group, shift=DOWN)\n )\n self.wait(1)\n\n # Clear Screen\n self.clear()\n self.wait(0.5)\n\n # Final Statement\n final_statement = Text(\"CONVERGENCE OF THE SERIES\", color=GREEN, font_size=48)\n self.play(Write(final_statement))\n\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass PTestScene(Scene):\n def construct(self):\n # --- Step 1: Display the Series ---\n title = MathTex(\"S = \\\\sum_{n=1}^\\\\infty \\\\frac{1}{n^2}\")\n self.play(Write(title))\n self.wait(1)\n\n # --- Step 2: Explain Application of p-Test ---\n explain_text = Text(\n \"We apply the p-test for convergence.\",\n font_size=36,\n color=BLUE\n ).next_to(title, DOWN, buff=0.5)\n \n self.play(FadeIn(explain_text))\n self.wait(2)\n\n # --- Step 3: Identify and Compare p-value ---\n identify_p = Text(\n \"\\\\textit{Here, } p = 2\",\n font_size=36\n )\n compare_p = MathTex(\"\\\\because 2 > 1\", r\"\\implies \\text{Convergent}\")\n compare_p.next_to(identify_p, DOWN, buff=0.5).set_color(GREEN)\n\n comparison_group = VGroup(identify_p, compare_p).to_edge(RIGHT)\n \n self.play(Write(identify_p))\n self.wait(1)\n self.play(Write(compare_p))\n self.wait(2)\n\n # --- Step 4: Replace Initial Explanation with Conclusion ---\n conclusion_text = Text(\n \"The series is Convergent.\",\n font_size=48,\n color=GREEN\n )\n\n self.play(\n FadeOut(title),\n FadeOut(explain_text),\n FadeOut(comparison_group)\n )\n \n self.play(Write(conclusion_text))\n\n # Add a highlight box around the conclusion\n box = SurroundingRectangle(conclusion_text, color=YELLOW, fill_opacity=0.1, buff=0.3)\n self.add(box)\n \n self.wait(2)\n\n # --- Final Step 5: Clear Screen and Re-write Statement ---\n final_conclusion = MathTex(r\"S = \\sum_{n=1}^\\infty \\frac{1}{n^2}\", r\"\\\\ \\text{is Convergent}\").arrange(DOWN, aligned_edge=LEFT)\n \n # Animate clearing the screen\n self.play(\n FadeOut(conclusion_text),\n FadeOut(box)\n )\n \n # Write the conclusion again on the entire screen\n self.play(Write(final_conclusion))\n \n # Highlight the second line specifically\n self.play(final_conclusion.get_part_by_tex('Convergent').animate.set_color(YELLOW).scale(1.2))\n \n # Hold at the final frame briefly\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated explanation video that shows how to integrate the sine function from 0 to pi, including the steps of integrating, evaluating the definite integral, and concluding with the result of the integration?", "chosen": "```python\nfrom manim import *\n\nclass IntegrateSine(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the original integral expression\n # ------------------------------------------------------------------\n lhs = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\")\n eq1 = MathTex(r\"=\")\n rhs1 = MathTex(r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\")\n \n # Arrange the first line horizontally and move to the top\n line1 = VGroup(lhs, eq1, rhs1).arrange(RIGHT, buff=0.2)\n line1.to_edge(UP)\n \n # Animate the appearance of the integral and the antiderivative\n self.play(Write(lhs))\n self.play(Write(eq1), Write(rhs1))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Evaluate the definite integral limits\n # ------------------------------------------------------------------\n eq2 = MathTex(r\"=\")\n rhs2 = MathTex(r\"\\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\")\n \n line2 = VGroup(eq2, rhs2).arrange(RIGHT, buff=0.2)\n line2.next_to(line1, DOWN, aligned_edge=LEFT)\n \n # Align equals signs for a clean derivation layout\n eq2.align_to(eq1, LEFT)\n rhs2.next_to(eq2, RIGHT, buff=0.2)\n \n self.play(Write(line2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Substitute the trigonometric values\n # ------------------------------------------------------------------\n # cos(pi) = -1 and cos(0) = 1\n eq3 = MathTex(r\"=\")\n rhs3 = MathTex(r\"-(-1) - (-1)\")\n \n line3 = VGroup(eq3, rhs3).arrange(RIGHT, buff=0.2)\n line3.next_to(line2, DOWN, aligned_edge=LEFT)\n \n eq3.align_to(eq1, LEFT)\n rhs3.next_to(eq3, RIGHT, buff=0.2)\n \n self.play(Write(line3))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Simplify the expression\n # ------------------------------------------------------------------\n eq4 = MathTex(r\"=\")\n rhs4 = MathTex(r\"1 + 1\")\n \n line4 = VGroup(eq4, rhs4).arrange(RIGHT, buff=0.2)\n line4.next_to(line3, DOWN, aligned_edge=LEFT)\n \n eq4.align_to(eq1, LEFT)\n rhs4.next_to(eq4, RIGHT, buff=0.2)\n \n self.play(Write(line4))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Conclude with the final result\n # ------------------------------------------------------------------\n eq5 = MathTex(r\"=\")\n rhs5 = MathTex(r\"2\")\n \n line5 = VGroup(eq5, rhs5).arrange(RIGHT, buff=0.2)\n line5.next_to(line4, DOWN, aligned_edge=LEFT)\n \n eq5.align_to(eq1, LEFT)\n rhs5.next_to(eq5, RIGHT, buff=0.2)\n \n # Highlight the final result with a bounding box and color change\n rhs5.set_color(YELLOW)\n box = SurroundingRectangle(line5, color=YELLOW, buff=0.1)\n \n self.play(Write(line5))\n self.play(Create(box), Indicate(rhs5))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Visualize the area under the curve\n # ------------------------------------------------------------------\n # Clear the algebraic steps to make room for the graph\n self.play(\n FadeOut(line1), FadeOut(line2), FadeOut(line3),\n FadeOut(line4), FadeOut(line5), FadeOut(box)\n )\n\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 1.2, 0.5],\n axis_config={\"include_tip\": True}\n ).scale(0.9).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define the sine function over the integration bounds\n sine_graph = axes.plot(lambda x: np.sin(x), x_range=[0, np.pi], color=BLUE)\n sine_label = axes.get_graph_label(sine_graph, label=r\"\\sin(x)\")\n\n # Create the area representing the integral\n area = axes.get_area(sine_graph, x_range=[0, np.pi], color=BLUE, opacity=0.3)\n \n result_text = Text(\"Total Area = 2\", font_size=36).to_edge(UP)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sine_graph), Write(sine_label))\n self.play(FadeIn(area), Write(result_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrateSine(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the original integral expression\n # ------------------------------------------------------------------\n lhs = MathTex(r\"\\int_{0}^{\\pi} \\sin(x) \\, dx\")\n eq1 = MathTex(r\"=\")\n rhs1 = MathTex(r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\")\n \n # Arrange the first line horizontally and move to the top\n line1 = VGroup(lhs, eq1, rhs1).arrange(RIGHT, buff=0.2)\n line1.to_edge(UP)\n \n # Animate the appearance of the integral and the antiderivative\n self.play(Write(lhs))\n self.play(Write(eq1), Write(rhs1))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Evaluate the definite integral limits\n # ------------------------------------------------------------------\n eq2 = MathTex(r\"=\")\n rhs2 = MathTex(r\"\\left( -\\cos(\\pi) \\right) - \\left( -\\cos(0) \\right)\")\n \n line2 = VGroup(eq2, rhs2).arrange(RIGHT, buff=0.2)\n line2.next_to(line1, DOWN, aligned_edge=LEFT)\n \n # Align equals signs for a clean derivation layout\n eq2.align_to(eq1, LEFT)\n rhs2.next_to(eq2, RIGHT, buff=0.2)\n \n self.play(Write(line2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Substitute the trigonometric values\n # ------------------------------------------------------------------\n # cos(pi) = -1 and cos(0) = 1\n eq3 = MathTex(r\"=\")\n rhs3 = MathTex(r\"-(-1) - (-1)\")\n \n line3 = VGroup(eq3, rhs3).arrange(RIGHT, buff=0.2)\n line3.next_to(line2, DOWN, aligned_edge=LEFT)\n \n eq3.align_to(eq1, LEFT)\n rhs3.next_to(eq3, RIGHT, buff=0.2)\n \n self.play(Write(line3))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Simplify the expression\n # ------------------------------------------------------------------\n eq4 = MathTex(r\"=\")\n rhs4 = MathTex(r\"1 + 1\")\n \n line4 = VGroup(eq4, rhs4).arrange(RIGHT, buff=0.2)\n line4.next_to(line3, DOWN, aligned_edge=LEFT)\n \n eq4.align_to(eq1, LEFT)\n rhs4.next_to(eq4, RIGHT, buff=0.2)\n \n self.play(Write(line4))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Conclude with the final result\n # ------------------------------------------------------------------\n eq5 = MathTex(r\"=\")\n rhs5 = MathTex(r\"2\")\n \n line5 = VGroup(eq5, rhs5).arrange(RIGHT, buff=0.2)\n line5.next_to(line4, DOWN, aligned_edge=LEFT)\n \n eq5.align_to(eq1, LEFT)\n rhs5.next_to(eq5, RIGHT, buff=0.2)\n \n # Highlight the final result with a bounding box and color change\n rhs5.set_color(YELLOW)\n box = SurroundingRectangle(line5, color=YELLOW, buff=0.1)\n \n self.play(Write(line5))\n self.play(Create(box), Indicate(rhs5))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Visualize the area under the curve\n # ------------------------------------------------------------------\n # Clear the algebraic steps to make room for the graph\n self.play(\n FadeOut(line1), FadeOut(line2), FadeOut(line3),\n FadeOut(line4), FadeOut(line5), FadeOut(box)\n )\n\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 1.2, 0.5],\n axis_config={\"include_tip\": True}\n ).scale(0.9).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define the sine function over the integration bounds\n sine_graph = axes.plot(lambda x: np.sin(x), x_range=[0, np.pi], color=BBLUE)\n sine_label = axes.get_graph_label(sine_graph, label=r\"\\sin(x)\")\n\n # Create the area representing the integral\n area = axes.get_area(sine_graph, x_range=[0, np.pi], color=BLUE, opacity=0.3)\n \n result_text = Text(\"Total Area = 2\", font_size=36).to_edge(UP)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sine_graph), Write(sine_label))\n self.play(FadeIn(area), Write(result_text))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the documentation configuration with additional features and explanations:\n\nThe enhanced documentation configuration builds upon the original by adding comprehensive documentation features while maintaining all existing settings. It now includes intersphinx mapping for linking to Python standard library documentation, automatic API documentation generation through autosummary, improved theme customization with logo and favicon support, and version-specific documentation using the releases extension. The configuration also enables SVG image support through sphinx.ext.imgconverter and adds MathJax for mathematical notation. The HTML output is further enhanced with custom CSS in the _static directory and sidebar customization through html_theme_options. The build process now automatically generates API documentation for all modules while excluding test files, and includes improved search functionality through the html_search_options setting. The documentation version is dynamically set from the package version, and the configuration includes comprehensive settings for PDF output through LaTeX customization. All original paths and exclusions are preserved while adding these new capabilities to create a more robust and feature-rich documentation system.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass VectorAddition(Scene):\n def construct(self):\n # Create vectors representing two forces\n force_a = Arrow(start=ORIGIN, end=[2, 1, 0], color=RED)\n force_b = Arrow(start=ORIGIN, end=[-1, 2, 0], color=BLUE)\n\n # Add labels to identify each vector clearly\n label_a = Text(\"Force A\", font_size=24).next_to(force_a.get_end(), UP + RIGHT)\n label_b = Text(\"Force B\", font_size=24).next_to(force_b.get_start(), DOWN)\n\n self.play(GrowArrow(force_a))\n self.play(Write(label_a))\n\n # Animate the addition of the second vector\n self.play(GrowArrow(force_b))\n self.play(Write(label_b))\n\n # Calculate the resultant vector algebraically for demonstration\n result_vector_algebraic = Arrow(\n start=ORIGIN,\n end=np.array([2, 1, 0]) + np.array([-1, 2, 0]),\n color=YELLOW\n )\n \n # Add a label indicating the resulting force\n label_result = Text(\"Resultant Force\", font_size=24).next_to(result_vector_algebraic.get_end(), UP)\n\n self.play(GrowArrow(result_vector_algebraic))\n self.play(Write(label_result))\n\n # Display the vector components mathematically on screen\n formula = MathTex(\"\\\\vec{F}_{\\\\text{result}} = \\\\vec{A} + \\\\vec{B}\")\n formula.to_edge(DOWN)\n\n self.play(Write(formula))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MatrixMultiplication(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Set background color to black for a dark mode feel\n self.camera.background_color = \"#1E1E1E\"\n\n # --- Title ---\n title_text = Text(\"Matrix Multiplication\", font_size=48, weight=BOLD)\n subtitle_text = Text(\"A Visual Guide\", font_size=36)\n title_group = VGroup(title_text, subtitle_text).arrange(DOWN, buff=0.5)\n title_group.to_edge(UP, buff=1)\n\n # Animate the appearance of the title\n self.play(Write(title_text))\n self.play(FadeIn(subtitle_text, shift=DOWN))\n\n # Wait briefly at the beginning\n self.wait(1)\n\n # --- Step 1: Introduction ---\n intro_text = Text(\n \"Let A be a 2x3 matrix:\\n\\n\\\\begin{bmatrix} 1 & 2 \\\\\\\\ 3 & 4 \\\\end{bmatrix}\",\n font_size=32,\n t2c={\"1\": YELLOW, \"2\": GREEN, \"3\": BLUE},\n line_spacing=1.2\n )\n intro_text.next_to(subtitle_text, DOWN, buff=0.7)\n self.play(Write(intro_text))\n self.wait(1)\n\n # Create the matrix object\n matrix_A = [[1, 2], [3, 4]]\n matrix_obj = Matrix(matrix_A).scale(0.8).next_to(intro_text, DOWN, buff=0.8)\n self.play(Create(matrix_obj))\n self.wait(1)\n\n # Fade out introduction text after showing the matrix\n self.play(FadeOut(intro_text), FadeOut(matrix_obj))\n self.wait(1)\n\n # --- Step 2: Define Vector B ---\n vector_b_text = Text(\n \"\\\\textcolor{orange}{Define another vector } b:\\\\begin{pmatrix} 2\\\\\\\\-1 \\\\end{pmatrix}\",\n font_size=32,\n t2c={\"blue\": ORANGE}\n ).to_edge(RIGHT, buff=1).shift(UP * 0.8)\n\n self.play(Write(vector_b_text))\n vector_B = Arrow(start=LEFT * 2.5 + UP * 1.5, end=RIGHT * 1.5 + DOWN * 0.5, color=ORANGE)\n vector_label = Tex(\"\\\\vec{b}\", color=WHITE).move_to(vector_B.get_center())\n vector_group = VGroup(vector_B, vector_label)\n \n self.play(GrowArrow(vector_B), Write(vector_label))\n self.wait(1)\n\n # Move vectors to make room for multiplication\n self.play(\n matrix_obj.animate.shift(LEFT * 3),\n vector_group.animate.move_to(ORIGIN)\n )\n\n # --- Step 3: Show Element-wise Multiplications ---\n \n element_multiplication = [\n r\"\\left[\\begin{array}{cc} 1 & 2 \\\\ 3 & 4 \\end{array}\\right]\",\n r\"\\times\",\n r\"\\begin{pmatrix} 2 \\cdot 2 \\\\ 4 \\cdot (-1) \\end{pmatrix}\"\n ]\n element_eq = MathTex(*element_multiplication, font_size=36).to_edge(UP, buff=1.5)\n self.play(Write(element_eq))\n self.wait(1)\n\n # --- Step 4: Result Vector C ---\n \n result_vector_c = Arrow(start=vector_B.get_start(), end=vector_B.get_end(), color=GREEN)\n c_label = Tex(\"$\\\\vec{c}$\").next_to(result_vector_c, RIGHT, buff=-0.2)\n result_group = VGroup(result_vector_c, c_label)\n\n product_values = [np.dot(row, [2, -1]) for row in matrix_A]\n product_row1 = MathTex(\"[2, -1]\", font_size=36, color=YELLOW)\n product_row2 = MathTex(\"[3, -4]\", font_size=36, color=YELLOW)\n products = VGroup(product_row1, product_row2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n products.next_to(element_eq, DOWN, buff=0.8)\n\n self.play(TransformFromCopy(vector_B, result_vector_c), Write(c_label))\n self.play(Write(products))\n self.wait(2)\n\n # Final highlight of final equation/result\n final_box = SurroundingRectangle(VGroup(products), color=WHITE, buff=0.3)\n self.play(Create(final_box))\n self.wait(1)\n\n # Fade out everything except the final equation/result box\n self.play(\n FadeOut(title_group),\n FadeOut(vector_b_text),\n FadeOut(matrix_obj),\n FadeOut(element_eq),\n FadeOut(vector_group),\n run_time=1.5\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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#### SSML (Speech Synthesis Markup Language)\n\n##### Definition\nSSML (Speech Synthesis Markup Language) is an XML-based standard markup language defined by the W3C, designed to provide developers with fine-grained control over the speech synthesis process.\n\n##### Core Advantages\nIt addresses the limitations of plain text in expressing emotions, pauses, speech rate, and special pronunciations.\n\n\nContextual location of this section (from highest to current level):\n# Intelligent Voice Technology Course - Detailed Outline for Lesson 15 (Voice Interaction System Integration and API Design, 90 minutes)\n## TTS System Interface Design (30 minutes)\n### TTS Input Format Design\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SSMLAnimation(Scene):\n\n def construct(self):\n title = Text('Speech Synthesis Markup Language', 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 def_title = Text('Definition', font_size=28, color=BLUE)\n def_list = BulletedList('XML-based standard by W3C', 'Fine-grained control over synthesis', font_size=24)\n def_group = VGroup(def_title, def_list).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n adv_title = Text('Core Advantages', font_size=28, color=GREEN)\n adv_list = BulletedList('Addresses plain text limitations', 'Expresses emotions and pauses', 'Adjusts speech rate', 'Handles special pronunciations', font_size=24)\n adv_group = VGroup(adv_title, adv_list).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n left_col = VGroup(def_group, adv_group).arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n example_title = Text('SSML Structure', font_size=24, color=YELLOW)\n ssml_text = Text('\\n Hello \\n \\n world!\\n', font_size=22)\n example_box = SurroundingRectangle(ssml_text, color=GRAY, buff=0.3)\n example_visual = VGroup(ssml_text, example_box)\n example_group = VGroup(example_title, example_visual).arrange(DOWN, buff=0.3)\n main_content = VGroup(left_col, example_group).arrange(RIGHT, buff=1.5, aligned_edge=UP)\n main_content.next_to(title_group, DOWN, buff=0.8)\n self.play(FadeIn(def_title, shift=RIGHT * 0.5), run_time=0.5)\n self.play(Write(def_list), run_time=1.5)\n self.play(FadeIn(adv_title, shift=RIGHT * 0.5), run_time=0.5)\n self.play(Write(adv_list), run_time=2.0)\n self.play(FadeIn(example_title, shift=DOWN * 0.3), run_time=0.5)\n self.play(Write(ssml_text), Create(example_box), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SSMLAnimation(Scene):\n\n def construct(self):\n title = Text('Speech Synthesis Markup Language', 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 def_title = Text('Definition', font_size=28, color=BBLUE)\n def_list = BulletedList('XML-based standard by W3C', 'Fine-grained control over synthesis', font_size=24)\n def_group = VGroup(def_title, def_list).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n adv_title = Text('Core Advantages', font_size=28, color=GREEN)\n adv_list = BulletedList('Addresses plain text limitations', 'Expresses emotions and pauses', 'Adjusts speech rate', 'Handles special pronunciations', font_size=24)\n adv_group = VGroup(adv_title, adv_list).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n left_col = VGroup(def_group, adv_group).arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n example_title = Text('SSML Structure', font_size=24, color=YELLOW)\n ssml_text = Text('\\n Hello \\n \\n world!\\n', font_size=22)\n example_box = SurroundingRectangle(ssml_text, color=GRAY, buff=0.3)\n example_visual = VGroup(ssml_text, example_box)\n example_group = VGroup(example_title, example_visual).arrange(DOWN, buff=0.3)\n main_content = VGroup(left_col, example_group).arrange(RIGHT, buff=1.5, aligned_edge=UP)\n main_content.next_to(title_group, DOWN, buff=0.8)\n self.play(FadeIn(def_title, shift=RIGHT * 0.5), run_time=0.5)\n self.play(Write(def_list), run_time=1.5)\n self.play(FadeIn(adv_title, shift=RIGHT * 0.5), run_time=0.5)\n self.play(Write(adv_list), run_time=2.0)\n self.play(FadeIn(example_title, shift=DOWN * 0.3), run_time=0.5)\n self.play(Write(ssml_text), Create(example_box), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated video that shows how to test if an infinite series converges or not using the p-test. Start by displaying the sum of 1 over n squared from n equals 1 to infinity. Next, introduce text explaining we will apply the p-test and then show that p, in this case, is 2 which is greater than 1. Then, replace the initial text with a statement that concludes the series is convergent. Finally, clear the screen and end with the statement that the series is convergent being written once more. Can you make this animation engaging and easy to understand?", "chosen": "```python\nfrom manim import *\n\nclass PTestScene(Scene):\n def construct(self):\n # --- Step 1: Display the Series ---\n title = MathTex(\n r\"\\sum_{n=1}^{\\infty}\", \n \"\\\\frac{1}{n^2}\"\n ).scale(1.5).to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # --- Step 2: Introduce P-Test ---\n intro_text = Text(\"Applying the p-test\", font_size=36).next_to(title, DOWN)\n self.play(Write(intro_text))\n self.wait(1.5)\n \n p_value = MathTex(\"p\", \"=\", \"2\").shift(DOWN*1.5 + LEFT*2)\n condition = MathTex(\"\\\\text{where } p > 1 \\\\rightarrow \\\\text{Converges}\")\n \n for obj in [p_value, condition]:\n self.play(Write(obj))\n else:\n pass\n \n self.wait(2)\n \n # --- Step 3: Replace Intro Text ---\n conclusion_text = Text(\"The series is CONVERGENT!\", color=GREEN, font_size=48)\n replacement_group = VGroup(p_value, condition) \n \n self.play(\n ReplacementTransform(intro_text, conclusion_text),\n FadeOut(replacement_group, shift=DOWN)\n )\n self.wait(1)\n\n # Clear Screen\n self.clear()\n self.wait(0.5)\n\n # Final Statement\n final_statement = Text(\"CONVERGENCE OF THE SERIES\", color=GREEN, font_size=48)\n self.play(Write(final_statement))\n\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass PTestConvergence(Scene):\n def construct(self):\n # --- Configuration ---\n TITLE_COLOR = YELLOW\n TEST_TEXT_COLOR = BLUE\n CONCLUSION_COLOR = GREEN\n\n # 1. Display the Series Expression\n title = Text(\"Testing Convergence\", font_size=36).to_edge(UP)\n \n # The specific series for the p-test: Sum[n^(-p) : n=1..inf]\n # Where p=2 makes the harmonic series terms decrease faster than 1/n^2\n math_expr = MathTex(\n r\"\\sum_{n=1}^{\\\\infty}\", \n r\"\\\\frac{1}{n^2}\"\n ).scale(1.2)\n\n self.play(Write(title))\n self.play(Write(math_expr))\n\n # Shift up to make room for explanation below\n self.play(FadeOut(title), math_expr.animate.shift(UP * 0.8))\n\n # 2. Introduce the Test Rule\n rule_text = Tex(\n \"We will apply the $p$-test.\", \n f\"$p > 1$ implies convergence.\",\n color=TEST_TEXT_COLOR,\n font_size=32\n )\n rule_text.next_to(math_expr, DOWN, buff=0.7)\n rule_box = SurroundingRectangle(rule_text, color=TEST_BOX_COLOR, buff=0.15)\n\n self.play(Write(rule_text))\n self.play(Create(rule_box))\n\n # Highlight '2' specifically since it determines convergence based on p>1\n highlight_p = MathTex(\"2\").set_color(YELLOW).next_to(rule_text[1], RIGHT, buff=0.1)\n self.play(Write(highlight_p))\n\n self.wait(2)\n\n # Clear rule parts so conclusion starts cleanly\n self.play(FadeOut(rule_text), FadeOut(rule_box), FadeOut(highlight_p))\n\n # 3. Conclusion: Compare p value to threshold\n conclusion_1 = Tex(\n \"$p$ = 2 \", \n \"\\\\text{(squared)}\", \n f\" \\\\color{{green}} {{>} } 1\",\n color=CONCLUSION_COLOR,\n font_size=32\n )\n\n comparison_rect = RoundedRectangle(\n width=conclusion_1.get_width(), \n height=conclusion_1.get_height(),\n corner_radius=0.15,\n fill_opacity=0.15,\n stroke_width=2,\n stroke_color=WHITE\n ).move_to(conclusion_1.get_center())\n\n self.play(Write(conclusion_1), Create(comparison_rect))\n\n # Animate the inequality becoming green text highlighting condition met\n self.play(\n Write(MathTex(\"\\\\rightarrow\")), \n Write(Tex(\"\\\\text{The series is convergent!} \").set_color(CONCLUSION_COLOR)),\n run_time=1.5\n )\n self.wait(2)\n\n # Final Step: Clear screen completely\n self.play(\n FadeOut(conclusion_1),\n FadeOut(comparison_rect),\n FadeOut(MathTex(\"\\\\rightarrow\")),\n FadeOut(Tex(\"\\\\text{The series is convergent!} \"))\n )\n self.wait(0.5)\n\n final_conclusion = Tex(\n \"\\\\text{The series is convergent!}\",\n f\" ($p = 2$)\",\n color=GREEN,\n font_size=36\n )\n final_box = SurroundingRectangle(final_conclusion, color=GREEN, buff=0.2)\n self.play(Write(final_conclusion), Create(final_box))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the nature of geodesics on a torus, and how do they differ from geodesics on a sphere?", "chosen": "```python\nfrom manim import *\n\nclass TorusGeodesicScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Torus Geodesics vs Spherical Cap Curves\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Create a simple 2D representation of a torus for visual clarity\n torus_plane = RoundedRectangle(width=3.5, height=1.8, corner_radius=0.1, color=TEAL_D)\n torus_plane.shift(LEFT * 2.5 + DOWN * 1.2)\n \n torus_label = Text(\"Torus Surface\", font_size=24).next_to(torus_plane, UP)\n self.add(torus_plane)\n self.play(FadeIn(torus_label, shift=DOWN * 0.2))\n\n # Draw a geodesic curve on the torus surface\n torus_geod = Circle(radius=0.7, color=YELLOW, stroke_width=4).shift(RIGHT*1.5)\n torus_path = VMobject()\n torus_path.set_points_as_corners([ORIGIN, RIGHT*1.5, RIGHT*1.5])\n \n # Add dots along the path to show directionality\n dot_start = Dot(torus_path.get_start(), color=RED)\n dot_end = Dot(torus_path.get_end(), color=GREEN)\n\n torus_desc = Text(\n \"Curves that follow the shortest distance between points\\non the surface\",\n font_size=24,\n t2c={\"surface\": BLUE}\n ).next_to(dot_end, DOWN, buff=0.5)\n\n self.play(Create(torus_path), FadeIn(dot_start, dot_end), Write(torus_desc))\n \n # Show how it differs from spherical cap curves by comparing them briefly\n sphere_cap_text = Text(\"Spherical Caps\", font_size=24, color=BLUE).to_edge(DOWN)\n self.play(Transform(title, sphere_cap_text), FadeOut(torus_label, torus_plane))\n self.wait()\n\n # Simple circle representing a sphere\n sphere_circle = Circle(radius=1.5, color=PURPLE)\n sphere_center = Point().set_color(PURPLE)\n sphere_title = Text(\"Sphere Geometry\", font_size=28).to_edge(UP)\n self.play(FadeIn(sphere_circle), FadeIn(sphere_center), Write(sphere_title))\n self.wait()\n\n # An arc showing how great circles intersect at poles\n pole_arc = Arc(start_angle=PI/4, angle=-PI/2, radius=1.5, color=WHITE)\n pole_pole_labels = VGroup(Text(\"+Pole\"), Text(\"-Pole\")).arrange(DOWN, buff=0.2).move_to(pole_arc.point_from_proportion(0.5) + UP * 0.3)\n pole_arrow = Arrow(ORIGIN, UP * 1.5, color=BLUE)\n pole_label = Text(\"Great Circles Intersect Poles\", font_size=24, color=BLUE).next_to(pole_arrow, LEFT, buff=0.3)\n\n self.play(Create(pole_arrow), Write(pole_label), Create(pole_arc), FadeIn(pole_pole_labels))\n self.wait()\n\n # Conclusion\n conclusion = Text(\n \"On a torus, geodesics may loop around the tube,\\nwhereas on a sphere, paths return to their start.\",\n font_size=24,\n line_spacing=1.2\n )\n \n final_box = SurroundingRectangle(conclusion, color=GRAY, fill_opacity=0.1)\n self.play(Write(final_box), Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass GeometricProperties(Scene):\n def construct(self):\n # Title\n title = Text(\"The Geometry of Tori\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create a simple torus using ParametricFunction\n t = np.linspace(0, TAU, 100)\n u = np.linspace(-PI, PI, 50)\n r = 0.8\n R = 1.5\n\n def torus_u(u, v):\n x = (R + r * cos(v)) * cos(u)\n y = (R + r * cos(v)) * sin(u)\n z = r * sin(v)\n return [x, y, z]\n\n torus = ParametricSurface(\n lambda u, v: np.array(torus_u(u, v)),\n resolution=(len(t) // 2, len(u)),\n color=BLUE,\n )\n\n # Display the torus\n self.play(Create(torus))\n self.wait(1)\n\n # Properties of tori vs spheres\n properties_title = Tex(\"$\\\\bullet$ Topological Classification:\", font_size=24)\n prop_torus = Tex(\"\\\\text{A torus}\", font_size=24, color=BLUE)\n prop_sphere = Tex(\"\\\\text{A sphere}\", font_size=24, color=GREEN)\n \n properties_group = VGroup(properties_title, prop_torus, prop_sphere).arrange(DOWN)\n \n # Animate text appearing sequentially\n for part in properties_group:\n self.play(Write(part))\n self.wait(0.5)\n \n else:\n pass\n \n # Show equation for Euler characteristic\n euler_char_eq = MathTex(r\"\\chi(T^2) = \\chi(S^2) = 2\")\n self.play(Write(euler_char_eq))\n self.wait(2)\n \n # Compare curvature at poles vs equator\n curvature_text = Text(\"Curvature varies along the surface\", font_size=24)\n curvature_text.to_edge(UP)\n self.add(curvature_text)\n \n # Draw lines representing geodesic paths on the torus\n line_equator = Line(start=torus.get_center(), end=torus.get_right())\n line_pole = Line(start=torus.get_left(), end=torus.get_right())\n \n self.play(Create(line_equator), Create(line_pole))\n \n # Add labels to explain curvature variation\n eq_label = Text(\"Equator has constant positive curvature\", font_size=20, color=YELLOW)\n pole_label = Text(\"Poles have zero curvature\", font_size=20, color=RED)\n \n eq_label.next_to(line_equator, DOWN, buff=0.5)\n pole_label.next_to(line_pole, UP, buff=0.5)\n \n self.play(Write(eq_label), Write(pole_label))\n \n # Final conclusion about differences between spheres and tori\n final_conclusion = Text(\"Geodesics on tori can wrap around the hole\", font_size=24)\n final_conclusion.to_edge(DOWN)\n \n self.play(Write(final_conclusion))\n\n # Fade out everything except the title\n objects_to_remove = VGroup(torus, line_equator, line_pole, \n eq_label, pole_label, final_conclusion)\n self.remove(objects_to_remove)\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Tori exhibit unique geometrical properties.\", font_size=32)\n self.play(FadeIn(conclusion))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can the PageRank algorithm be visualized as a Markov Chain, and what insights does this provide on its convergence properties?", "chosen": "```python\nfrom manim import *\n\nclass PageRankMarkovChain(Scene):\n def construct(self):\n # Introduction - Title\n title = Text(\"Unveiling PageRank: The Dance of Markov Chains\", font_size=30)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple graph with nodes (webpages)\n # Four circles representing webpages\n nodes = [Circle(radius=0.5, color=BLUE) for _ in range(4)]\n labels = [Text(f\"{i+1}\", font_size=24) for i in range(4)]\n \n # Position the nodes in a square formation\n nodes[0].move_to([-2, 2, 0])\n nodes[1].move_to([2, 2, 0])\n nodes[2].move_to([2, -2, 0])\n nodes[3].move_to([-2, -2, 0])\n \n # Add labels to nodes\n for i, label in enumerate(labels):\n label.move_to(nodes[i].get_center())\n \n # Create directed arrows between nodes (links between webpages)\n arrows = [\n Arrow(nodes[0].get_center(), nodes[1].get_center(), buff=0.5),\n Arrow(nodes[1].get_center(), nodes[2].get_center(), buff=0.5),\n Arrow(nodes[2].get_center(), nodes[3].get_center(), buff=0.5),\n Arrow(nodes[3].get_center(), nodes[0].get_center(), buff=0.5),\n Arrow(nodes[0].get_center(), nodes[2].get_center(), buff=0.5),\n Arrow(nodes[1].get_center(), nodes[3].get_center(), buff=0.5)\n ]\n \n # Group all elements of the graph\n graph = VGroup(*nodes, *arrows)\n \n # Animate the creation of the graph\n self.play(Create(graph))\n self.play(*[Write(label) for label in labels])\n self.wait(1)\n \n # Key Concept 1: Web as a network\n concept1 = Text(\"Key Concept 1: Web as a Network\", font_size=24)\n concept1.to_edge(DOWN)\n self.play(Write(concept1))\n self.wait(1)\n self.play(FadeOut(concept1))\n \n # Key Concept 2: Markov Chains - Random walks\n concept2 = Text(\"Key Concept 2: Markov Chains - Random Walks\", font_size=24)\n concept2.to_edge(DOWN)\n self.play(Write(concept2))\n \n # Show a random walk on the graph with a red dot\n dot = Dot(color=RED).move_to(nodes[0].get_center())\n self.play(Create(dot))\n \n # Animate the dot moving between nodes to simulate a random walk\n self.play(dot.animate.move_to(nodes[1].get_center()))\n self.play(dot.animate.move_to(nodes[3].get_center()))\n self.play(dot.animate.move_to(nodes[0].get_center()))\n self.play(dot.animate.move_to(nodes[2].get_center()))\n \n self.wait(1)\n self.play(FadeOut(concept2), FadeOut(dot))\n \n # Key Concept 3: Transition Probabilities\n concept3 = Text(\"Key Concept 3: Transition Probabilities\", font_size=24)\n concept3.to_edge(DOWN)\n self.play(Write(concept3))\n \n # Show probabilities on arrows (transition probabilities)\n probs = [\n Text(\"1/2\", font_size=20).next_to(arrows[0], UP, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[1], RIGHT, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[2], DOWN, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[3], LEFT, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[4], buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[5], buff=0.1)\n ]\n \n self.play(*[Write(prob) for prob in probs])\n self.wait(1)\n self.play(FadeOut(concept3))\n \n # Key Insight: Convergence to Steady State\n insight = Text(\"Key Insight: Convergence to Steady State\", font_size=24)\n insight.to_edge(DOWN)\n self.play(Write(insight))\n \n # Show the PageRank equation (simplified)\n equation = Text(\"\\pi = \\pi \\times P\", font_size=30)\n equation.next_to(insight, UP, buff=1)\n self.play(Write(equation))\n self.wait(1)\n \n # Show initial values for all nodes (equal probability)\n values = [\n Text(\"0.25\", font_size=20).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Write(value) for value in values])\n self.wait(1)\n \n # First iteration: values change based on Markov transitions\n new_values = [\n Text(\"0.30\", font_size=20, color=GREEN).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.20\", font_size=20, color=GREEN).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.30\", font_size=20, color=GREEN).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.20\", font_size=20, color=GREEN).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Transform(values[i], new_values[i]) for i in range(4)])\n self.wait(1)\n \n # Final steady state (convergence)\n final_values = [\n Text(\"0.29\", font_size=20, color=YELLOW).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.24\", font_size=20, color=YELLOW).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.29\", font_size=20, color=YELLOW).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.18\", font_size=20, color=YELLOW).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Transform(values[i], final_values[i]) for i in range(4)])\n self.wait(1)\n \n # Update the equation to show convergence\n converged_eq = Text(\"\\pi (t+1) = \\pi (t) \\times P\", font_size=30)\n converged_eq.next_to(insight, UP, buff=1)\n self.play(Transform(equation, converged_eq))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(graph),\n FadeOut(VGroup(*labels)),\n FadeOut(VGroup(*probs)),\n FadeOut(VGroup(*values)),\n FadeOut(equation),\n FadeOut(insight)\n )\n \n conclusion = Text(\"The Dance of Markov Chains makes PageRank possible\", font_size=30)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(title))\n```", "rejected": "```python\nfrom manim import *\n\nclass PageRankMarkovChain(Scene):\n def construct(self):\n # Introduction - Title\n title = Text(\"Unveiling PageRank: The Dance of Markov Chains\", font_size=30)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple graph with nodes (webpages)\n # Four circles representing webpages\n nodes = [Circle(radius=0.5, color=BBLUE) for _ in range(4)]\n labels = [Text(f\"{i+1}\", font_size=24) for i in range(4)]\n \n # Position the nodes in a square formation\n nodes[0].move_to([-2, 2, 0])\n nodes[1].move_to([2, 2, 0])\n nodes[2].move_to([2, -2, 0])\n nodes[3].move_to([-2, -2, 0])\n \n # Add labels to nodes\n for i, label in enumerate(labels):\n label.move_to(nodes[i].get_center())\n \n # Create directed arrows between nodes (links between webpages)\n arrows = [\n Arrow(nodes[0].get_center(), nodes[1].get_center(), buff=0.5),\n Arrow(nodes[1].get_center(), nodes[2].get_center(), buff=0.5),\n Arrow(nodes[2].get_center(), nodes[3].get_center(), buff=0.5),\n Arrow(nodes[3].get_center(), nodes[0].get_center(), buff=0.5),\n Arrow(nodes[0].get_center(), nodes[2].get_center(), buff=0.5),\n Arrow(nodes[1].get_center(), nodes[3].get_center(), buff=0.5)\n ]\n \n # Group all elements of the graph\n graph = VGroup(*nodes, *arrows)\n \n # Animate the creation of the graph\n self.play(Create(graph))\n self.play(*[Write(label) for label in labels])\n self.wait(1)\n \n # Key Concept 1: Web as a network\n concept1 = Text(\"Key Concept 1: Web as a Network\", font_size=24)\n concept1.to_edge(DOWN)\n self.play(Write(concept1))\n self.wait(1)\n self.play(FadeOut(concept1))\n \n # Key Concept 2: Markov Chains - Random walks\n concept2 = Text(\"Key Concept 2: Markov Chains - Random Walks\", font_size=24)\n concept2.to_edge(DOWN)\n self.play(Write(concept2))\n \n # Show a random walk on the graph with a red dot\n dot = Dot(color=RED).move_to(nodes[0].get_center())\n self.play(Create(dot))\n \n # Animate the dot moving between nodes to simulate a random walk\n self.play(dot.animate.move_to(nodes[1].get_center()))\n self.play(dot.animate.move_to(nodes[3].get_center()))\n self.play(dot.animate.move_to(nodes[0].get_center()))\n self.play(dot.animate.move_to(nodes[2].get_center()))\n \n self.wait(1)\n self.play(FadeOut(concept2), FadeOut(dot))\n \n # Key Concept 3: Transition Probabilities\n concept3 = Text(\"Key Concept 3: Transition Probabilities\", font_size=24)\n concept3.to_edge(DOWN)\n self.play(Write(concept3))\n \n # Show probabilities on arrows (transition probabilities)\n probs = [\n Text(\"1/2\", font_size=20).next_to(arrows[0], UP, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[1], RIGHT, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[2], DOWN, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[3], LEFT, buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[4], buff=0.1),\n Text(\"1/2\", font_size=20).next_to(arrows[5], buff=0.1)\n ]\n \n self.play(*[Write(prob) for prob in probs])\n self.wait(1)\n self.play(FadeOut(concept3))\n \n # Key Insight: Convergence to Steady State\n insight = Text(\"Key Insight: Convergence to Steady State\", font_size=24)\n insight.to_edge(DOWN)\n self.play(Write(insight))\n \n # Show the PageRank equation (simplified)\n equation = Text(\"\\pi = \\pi \\times P\", font_size=30)\n equation.next_to(insight, UP, buff=1)\n self.play(Write(equation))\n self.wait(1)\n \n # Show initial values for all nodes (equal probability)\n values = [\n Text(\"0.25\", font_size=20).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.25\", font_size=20).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Write(value) for value in values])\n self.wait(1)\n \n # First iteration: values change based on Markov transitions\n new_values = [\n Text(\"0.30\", font_size=20, color=GREEN).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.20\", font_size=20, color=GREEN).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.30\", font_size=20, color=GREEN).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.20\", font_size=20, color=GREEN).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Transform(values[i], new_values[i]) for i in range(4)])\n self.wait(1)\n \n # Final steady state (convergence)\n final_values = [\n Text(\"0.29\", font_size=20, color=YELLOW).next_to(nodes[0], DOWN, buff=0.7),\n Text(\"0.24\", font_size=20, color=YELLOW).next_to(nodes[1], DOWN, buff=0.7),\n Text(\"0.29\", font_size=20, color=YELLOW).next_to(nodes[2], UP, buff=0.7),\n Text(\"0.18\", font_size=20, color=YELLOW).next_to(nodes[3], UP, buff=0.7)\n ]\n \n self.play(*[Transform(values[i], final_values[i]) for i in range(4)])\n self.wait(1)\n \n # Update the equation to show convergence\n converged_eq = Text(\"\\pi (t+1) = \\pi (t) \\times P\", font_size=30)\n converged_eq.next_to(insight, UP, buff=1)\n self.play(Transform(equation, converged_eq))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(graph),\n FadeOut(VGroup(*labels)),\n FadeOut(VGroup(*probs)),\n FadeOut(VGroup(*values)),\n FadeOut(equation),\n FadeOut(insight)\n )\n \n conclusion = Text(\"The Dance of Markov Chains makes PageRank possible\", font_size=30)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(title))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Next Steps\n\n#### Clustering: How to Discover the Intrinsic Cluster Structure in the Reduced-Dimension Space\n- Dimensionality reduction is often a prerequisite step for clustering and can significantly enhance the performance of algorithms like K-Means.\n\n\nContextual location of this section (from highest to current level):\n# Machine Learning Course - Outline for the Fourth Class (Dimensionality Reduction, 90 minutes)\n## Summary and Comparison (10 minutes)\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClusteringScene(Scene):\n\n def construct(self):\n title = Text(\"Clustering\", font_size=60).to_edge(UP)\n subtitle = Text(\"How to discover intrinsic cluster structures\\nin reduced-dimension space\", font_size=36).next_to(title, DOWN, buff=0.5).set_color(YELLOW)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n context_text = Text(\"\\nMachine Learning Course > Class 4 | Dimensionality Reduction \\nSummary and Comparison :: Dimensional Space vs. High-Dimensional Spaces\", font_size=22, color=GRAY).to_corner(DL, buff=0.5)\n self.play(Write(context_text))\n \n # Step 2: Problem Statement\n problem_title = Text(\"Problem: Finding clusters in high-dimensional data\", font_size=32, color=RED)\n problem_desc = Text(\"- Dimensionality reduction helps visualize and analyze complex datasets\", font_size=28)\n problem_group = VGroup(problem_title, problem_desc).arrange(DOWN, aligned_edge=LEFT).shift(RIGHT * 0.5 + UP * 0.5)\n self.play(Write(problem_group))\n\n # Create a simple scatter plot representing high dimensional data points\n dot_radius = 0.15\n dots_high_dim = VGroup()\n colors = [BLUE, GREEN, ORANGE]\n for i in range(len(colors)):\n group_dots = VGroup()\n for _ in range(10): # Number of dots per cluster\n x = np.random.uniform(-2, 2)\n y = np.random.uniform(-2, 2)\n point = Dot(radius=dot_radius, color=colors[i]).move_to([x, y, 0])\n group_dots.add(point)\n dots_high_dim.add(group_dots)\n\n low_dot_radius = 0.15\n dots_low_dim = VGroup()\n for i in range(len(colors)):\n group_dots = VGroup()\n for j in range(3): # Simplified lower dimension representation\n angle = j * PI / 3\n radius = 1.5\n x = radius * np.cos(angle) + dots_high_dim[i][j].get_center()[0]\n y = radius * np.sin(angle) + dots_high_dim[i][j].get_center()[1]\n point = Dot(radius=low_dot_radius, color=colors[i], fill_opacity=0.7).move_to(np.array([x, y, 0]))\n group_dots.add(point)\n dots_low_dim.add(group_dots)\n\n # Step 3: Solution Visualization\n solution_title = Text(\"Solution: Apply Dimensionality Reduction then Clustering\", font_size=32, color=GREEN).to_edge(DOWN)\n self.play(Write(solution_title))\n self.play(Create(dots_high_dim))\n self.wait(1)\n self.play(Transform(dots_high_dim, dots_low_dim))\n self.wait(1)\n\n # Step 4: Conclusion\n conclusion = Text(\"Key Takeaway:\\nDimensionality reduction enhances clustering by simplifying high-dimensional spaces.\", font_size=28, color=YELLOW)\n conclusion_box = SurroundingRectangle(conclusion, corner_radius=0.2, color=WHITE)\n conclusion_group = VGroup(conclusion_box, conclusion).to_edge(DOWN, buff=1.0)\n self.play(Write(conclusion_box), Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass ClusteringScene(Scene):\n\n def construct(self):\n title = Text(\"Clustering: Discovering the intrinsic cluster structure\", font_size=36).to_edge(UP)\n steps_title = Text(\"- Dimensionality reduction enhances clustering algorithms like K-Means.\", font_size=32, color=BLUE).next_to(title, DOWN, buff=1.0)\n \n self.play(Write(title))\n self.play(FadeIn(steps_title, shift=RIGHT))\n self.wait(1)\n # Show visual representation of clusters\n dots_cluster_a = VGroup(Dot([0, 1, 0], radius=0.15, color=RED), Dot([0.8, 0.7, 0], radius=0.15, color=RED), Dot([-1.5, -0.5, 0], radius=0.15, color=RED), Dot([0.5, -1.5, 0], radius=0.15, color=RED))\n dots_cluster_b = VGroup(Dot([-1.2, 1.2, 0], radius=0.15, color=GREEN), Dot([1.5, 0.8, 0], radius=0.15, color=GREEN), Dot([0.3, -0.3, 0], radius=0.15, color=GREEN))\n dots_reduced_space = VGroup(VGroup(dots_cluster_a.copy().shift(RIGHT * 2 + UP * 1.5), Circle(radius=0.5, color=YELLOW).move_to(RIGHT * 2 + UP * 1.5)), VGroup(dots_cluster_b.copy(), Circle(radius=0.5, color=YELLOW).move_to(LEFT * 2 + DOWN * 1)))\n dots_reduced_space.shift(DOWN * 1.5)\n labels = Text(\"Reduced-dimension space\\nwhere clusters become more distinct\", font_size=24, t2c={'Red': RED, 'Green': GREEN}).next_to(dots_reduced_space, DOWN, buff=0.5)\n arrows = [Arrow(start=[0, 0, 0], end=[2, 1.5, 0], stroke_width=3) for _ in range(2)]\n for i in range(2):\n arrow_copy = arrows[i].copy()\n arrow_copy.put_start_and_end_on(dots_reduced_space[i][0].get_center(), dots_reduced_space[i][-2].get_center())\n \n self.add(arrows[i])\n self.play(GrowArrow(arrows[i]))\n self.play(TransformFromCopy(arrows[i], dot_group=i))\n self.wait(0.5)\n else:\n pass\n \n self.play(Write(labels))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialFunctionScene(Scene):\n def construct(self):\n # --- Step 1: Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Clear the title to make room for axes\n self.play(FadeOut(title))\n\n # --- Step 2: Axes Configuration ---\n # Define ranges specifically for exponential growth visualization\n axes = Axes(\n x_range=[-3, 3, 1], \n y_range=[-1, 8, 2],\n tips=False,\n axis_config={\"color\": BLUE}\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.add(axes, labels)\n self.wait(1)\n\n # --- Step 3: Plotting e^x ---\n exp_curve_e = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-2.5, 2])\n exp_label_e = MathTex(\"e^x\").set_color(GREEN).next_to(exp_curve_e, UR, buff=0.3)\n \n self.play(Create(exp_curve_e), Write(exp_label_e))\n self.wait(2)\n\n # --- Step 4: Replacement with 2^x ---\n exp_curve_2 = axes.plot(lambda x: 2**x, color=RED, x_range=[-2.5, 2])\n exp_label_2 = MathTex(\"2^x\").set_color(RED).move_to([2.3, 2.7, 0]) # Upward movement\n \n # Animate replacement while moving the label for improved readability\n self.play(\n Transform(exp_curve_e, exp_curve_2),\n FadeOut(exp_label_e),\n FadeIn(exp_label_2),\n run_time=1.5\n )\n \n # Hold briefly so viewers can compare the shapes\n self.wait(2)\n\n # --- Step 5: Comparison Mode ---\n # Re-render both curves simultaneously to ensure they overlap perfectly\n combined_curves = VGroup(\n axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-2.5, 2]),\n axes.plot(lambda x: 2**x, color=RED, x_range=[-2.5, 2])\n )\n\n # Add labels back individually for clarity during overlap\n combined_labels = VGroup(\n MathTex(\"e^x\").set_color(GREEN).next_to(combined_curves[0], UR, buff=0.3),\n MathTex(\"2^x\").set_color(RED).move_to([2.3, 2.7, 0])\n )\n\n # Simultaneously replace old graph with combined ones\n self.play(\n FadeOut(axes), \n FadeOut(labels), \n Create(combined_curves), \n FadeIn(combined_labels),\n run_time=1.5\n )\n\n # Final hold period to allow viewers to observe the combined graph\n self.wait(3)\n\n# To render this animation, save it as 'exponential_scene.py' and run:\n# manim -pql exponential_scene.py ExponentialFunctionScene\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialFunctions(Scene):\n def construct(self):\n # --- Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Create Axes with specified ranges and colors\n axes = Axes(\n x_range=(-3, 3, 1),\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Display Axes initially\n self.play(Create(axes), Write(labels))\n \n # Plot e^x in Green and Label it\n exp_e_func = MathTex(\"e^x\").scale(0.7).to_edge(DOWN)\n exp_e_graph = axes.plot(lambda x: np.exp(x), color=GREEN)\n \n self.play(Create(exp_e_graph), FadeIn(exp_e_func, shift=DOWN*0.5))\n\n # Show both titles simultaneously\n exp_e_title = MathTex(\"\\\\text{Initial } e^x \\\\text{ Function}\").next_to(exp_e_func, UP, buff=0.5)\n self.play(FadeIn(exp_e_title, shift=UP*0.3))\n \n # Hold view for a moment\n self.wait(2)\n\n # Transition: Replace e^x with 2^x in Red\n exp_2_func = MathTex(\"2^x\").scale(0.7).shift(UP) # Shifted up for improved position\n \n # Draw 2^x function in Red\n exp_2_graph = axes.plot(lambda x: 2**x, color=RED)\n \n # Animate replacement of old graph and its title with the new ones\n self.play(\n ReplacementTransform(match_target_data=True, exp_e_func, exp_2_func),\n Transform(match_target_data=True, exp_e_graph, exp_2_graph),\n run_time=2\n )\n\n # Move the new label further upward for clear separation\n self.play(exp_2_func.animate.shift(UP*0.5))\n\n # Add a corresponding title above the 2^x equation\n exp_2_title = MathTex(\"\\\\text{Replaced with } 2^x\").next_to(exp_2_func, UP, buff=0.5)\n self.play(Write(exp_2_title))\n\n # Hold view again\n self.wait(2)\n\n # Final Step: Return original e^x graph along with the 2^x graph\n # Clear existing elements to reset the stage cleanly\n self.clear()\n \n # Re-create Axes since they were cleared\n axes_final = Axes(\n x_range=(-3, 3, 1),\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE}\n )\n labels_final = axes_final.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Recreate Labels only once at the beginning for efficiency\n self.add(axes_final, labels_final)\n \n # Recreate Titles only once at the beginning for efficiency\n rec_exp_e_title = MathTex(\"\\\\text{Recycled } e^x \\\\text{ Function}\")\n rec_exp_2_title = MathTex(\"\\\\text{Recycled } 2^x \\\\text{ Function}\")\n\n # Plot Original e^x in Green\n orig_e_graph = axes_final.plot(lambda x: np.exp(x), color=GREEN)\n orig_e_func = MathTex(\"e^x\").scale(0.7).to_edge(DOWN)\n self.play(Create(orig_e_graph), FadeIn(rec_exp_e_title, shift=UP*0.3), FadeIn(exp_e_func, shift=DOWN*0.5))\n\n # Plot New 2^x in Red\n orig_2_graph = axes_final.plot(lambda x: 2**x, color=RED)\n orig_2_func = MathTex(\"2^x\").scale(0.7).shift(UP) # Shifted up for improved positioning\n self.play(Create(orig_2_graph), FadeIn(rec_exp_2_title, shift=UP*0.3), FadeIn(exp_2_func, shift=UP*0.3))\n\n # Hold final state briefly\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that displays a survey result for favorite fruits among a group of people. The video should be in portrait mode, suitable for mobile viewing. Begin with a nicely formatted table showing names and their corresponding favorite fruit. Use soft, pastel colors for the table and background to make it visually appealing.\n\nThe fruits listed include bananas, strawberries, and oranges. Next to the table, please show a segmented circle graph representing the quantities of each fruit choice within the group. For each fruit, display its segment growing in the graph to indicate the proportion of people who favor that fruit. Accompany the graph with a legend that uses colored squares to signify the corresponding fruit with labels next to them.\n\nAnimate the cells of the table highlighting corresponding names as the graph is being drawn for each fruit segment. Ensure that each cell highlights with the color corresponding to the fruit selected, and only remove the highlight after its segment on the graph is fully grown.\n\nOnce the graph is complete, shift the entire animation to the left and out of view, to potentially make space for additional content in the video if necessary. The colors, table, and graph should be modern and professional, aimed at delivering clear and informative content for an educational video.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Display the integral representing the area under the curve\n integral_expr = MathTex(r\"\\int_0^3\", r\"x^2\", r\"\\,dx\")\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Highlight the function to integrate\n function_highlight = SurroundingRectangle(integral_expr[1], color=YELLOW)\n self.play(Create(function_highlight))\n self.wait(1)\n\n # Explain the definite integral represents area\n explanation = Text(\"The definite integral represents the area under the curve\", font_size=24).to_edge(UP)\n self.play(Write(explanation))\n self.wait(2)\n\n # Perform integration\n integral_solution = MathTex(r\"=\\left[\\frac{x^3}{3}\\right]_0^3\")\n self.play(ReplacementTransform(integral_expr, integral_solution))\n self.wait(1)\n\n # Calculate the final area value\n final_area = MathTex(r\"= \\frac{3^3}{3} - \\frac{0^3}{3}\")\n self.play(ReplacementTransform(integral_solution, final_area))\n self.wait(1)\n\n final_value = MathTex(r\"= 9\")\n self.play(ReplacementTransform(final_area, final_value))\n self.wait(1)\n\n # Clear the scene and show the final result\n self.clear()\n self.wait(1)\n self.play(FadeIn(final_value))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Display the integral representing the area under the curve\n integral_expr = MathTex(r\"\\int_0^3\" + \" = x\", r\"x^2\", r\"\\,dx\")\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Highlight the function to integrate\n function_highlight = SurroundingRectangle(integral_expr[1], color=YELLOW)\n self.play(Create(function_highlight))\n self.wait(1)\n\n # Explain the definite integral represents area\n explanation = Text(\"The definite integral represents the area under the curve\", font_size=24).to_edge(UP)\n self.play(Write(explanation))\n self.wait(2)\n\n # Perform integration\n integral_solution = MathTex(r\"=\\left[\\frac{x^3}{3}\\right]_0^3\")\n self.play(ReplacementTransform(integral_expr, integral_solution))\n self.wait(1)\n\n # Calculate the final area value\n final_area = MathTex(r\"= \\frac{3^3}{3} - \\frac{0^3}{3}\")\n self.play(ReplacementTransform(integral_solution, final_area))\n self.wait(1)\n\n final_value = MathTex(r\"= 9\")\n self.play(ReplacementTransform(final_area, final_value))\n self.wait(1)\n\n # Clear the scene and show the final result\n self.clear()\n self.wait(1)\n self.play(FadeIn(final_value))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the documentation configuration with additional features and explanations:\n\nThe enhanced documentation configuration builds upon the original by adding comprehensive documentation features while maintaining all existing settings. It now includes intersphinx mapping for linking to Python standard library documentation, automatic API documentation generation through autosummary, improved theme customization with logo and favicon support, and version-specific documentation using the releases extension. The configuration also enables SVG image support through sphinx.ext.imgconverter and adds MathJax for mathematical notation. The HTML output is further enhanced with custom CSS in the _static directory and sidebar customization through html_theme_options. The build process now automatically generates API documentation for all modules while excluding test files, and includes improved search functionality through the html_search_options setting. The documentation version is dynamically set from the package version, and the configuration includes comprehensive settings for PDF output through LaTeX customization. All original paths and exclusions are preserved while adding these new capabilities to create a more robust and feature-rich documentation system.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass VectorAddition(Scene):\n def construct(self):\n # Create vectors representing two forces\n force_a = Arrow(start=ORIGIN, end=[2, 1, 0], color=RED)\n force_b = Arrow(start=ORIGIN, end=[-1, 2, 0], color=BLUE)\n\n # Add labels to identify each vector clearly\n label_a = Text(\"Force A\", font_size=24).next_to(force_a.get_end(), UP + RIGHT)\n label_b = Text(\"Force B\", font_size=24).next_to(force_b.get_start(), DOWN)\n\n self.play(GrowArrow(force_a))\n self.play(Write(label_a))\n\n # Animate the addition of the second vector\n self.play(GrowArrow(force_b))\n self.play(Write(label_b))\n\n # Calculate the resultant vector algebraically for demonstration\n result_vector_algebraic = Arrow(\n start=ORIGIN,\n end=np.array([2, 1, 0]) + np.array([-1, 2, 0]),\n color=YELLOW\n )\n \n # Add a label indicating the resulting force\n label_result = Text(\"Resultant Force\", font_size=24).next_to(result_vector_algebraic.get_end(), UP)\n\n self.play(GrowArrow(result_vector_algebraic))\n self.play(Write(label_result))\n\n # Display the vector components mathematically on screen\n formula = MathTex(\"\\\\vec{F}_{\\\\text{result}} = \\\\vec{A} + \\\\vec{B}\")\n formula.to_edge(DOWN)\n\n self.play(Write(formula))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass VectorFieldScene(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-2, 2, 0.5],\n y_range=[-2, 2, 0.5],\n x_length=6,\n y_length=6,\n ).shift(LEFT * 2 + DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"X\", y_label=\"Y\")\n\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # Define a simple vector field function\n def vector_field(point):\n x = point[0]\n y = point[1]\n \n # Calculate magnitude based on distance from origin\n mag = np.sqrt(x**2 + y**2)\n \n # Limit vectors near the origin to prevent blow-up\n if mag > 1:\n return np.array([x, y, 0]) * 0.7\n else:\n return np.array([x, y, 0])\n\n # Create a grid of dots representing points where vectors will be drawn\n dot_grid = VGroup()\n \n for i in range(-4, 5): \n for j in range(-4, 5):\n dot = Dot(axes.c2p(i, j) + UP * 0.1, color=WHITE)\n dot_grid.add(dot)\n\n self.add(dot_grid)\n\n # Animate vectors being added one by one\n vectors = []\n for dot in dot_grid:\n pos = dot.get_center()\n \n # Draw vector line from dot position\n start_point = pos\n \n # Determine end point based on vector direction\n end_point = start_point + vector_field(pos)\n \n # Add arrow to group so they move together\n arrow = Arrow(start=start_point, end=end_point, buff=0.1, max_tip_length_to_length_ratio=0.2)\n vectors.append(arrow)\n\n self.add(vectors)\n self.wait()\n\n # Display a title above the vectors\n title = Text(\"Vector Field Visualization\").to_edge(UP)\n self.play(Write(title))\n\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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 2: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\n\nclass MultiActMasterpiece_0678(Scene):\n def clear_stage(self):\n if self.mobjects:\n FadeOut(*self.mobjects).set_run_time(0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_textcirclestaranimation()\n self.clear_stage()\n self.act_2_fxsquaringgraphanimation()\n\n def act_1_textcirclestaranimation(self):\n # --- Step 1: Text Transition ---\n initial_text = Text(\"Initial Message\", font_size=48)\n final_text = Text(\"New Upward Shifted Message\", font_size=48)\n\n self.play(Write(initial_text))\n self.wait(0.5)\n\n # Animate transition to the second text with an upward shift effect\n self.play(\n ReplacementTransform(initial_text, final_text),\n final_text.animate.shift(UP * 2),\n run_time=1.5,\n rate_func=smooth\n )\n \n self.wait(0.5)\n self.play(FadeOut(final_text))\n\n # --- Step 2: Shape Sequence ---\n # Create a Circle containing a Star centered within it\n inner_star = Star(n=5, outer_radius=1.2, color=YELLOW)\n outer_circle = Circle(radius=1.8, stroke_color=RED, fill_opacity=0.2)\n\n combined_shape = VGroup(inner_star, outer_circle)\n combined_shape.move_to(ORIGIN)\n\n self.add(combined_shape)\n self.wait(0.5)\n\n # Expand the entire shape group simultaneously while moving the star outward\n self.play(\n combined_shape.animate.scale(2),\n inner_star.animate.shift(RIGHT * 1.5 + UP * 0.5),\n run_time=2,\n rate_func=smooth\n )\n\n self.wait(0.5)\n\n # --- Final Step: Disappearance ---\n # Smoothly remove both elements from the scene\n self.play(FadeOut(combined_shape), run_time=1.5)\n self.wait(1)\n\n def act_2_fxsquaringgraphanimation(self):\n func_expr = MathTex(\"f(x)\", \"=\", \"x^2\")\n func_expr.to_edge(UP)\n self.play(Write(func_expr))\n\n axes = Axes(\n x_range=[-2.5, 2.5],\n y_range=[-1, 5]\n ).scale(1.2).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(\"y\"))\n self.play(Create(axes), Write(labels))\n\n points = [\n (-2, 4), (-1.5, 2.25), (-1, 1), (-0.5, 0.25), (0, 0),\n (0.5, 0.25), (1, 1), (1.5, 2.25), (2, 4)\n ]\n curve = VMobject(color=GREEN)\n curve.set_points_as_corners([axes.c2p(x, y) for x, y in points])\n\n self.play(LaggedStart(*[\n Create(curve.copy().set_stroke(width=i*2))\n for i in range(1, 4)\n ], lag_ratio=0.2))\n \n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass MultiActMasterpiece(Scene):\n def clear_stage(self):\n if self.mobs:\n self.play(\n FadeOut(*self.mobs),\n run_time=0.8,\n rate_func=smoothen\n )\n self.wait(0.4)\n\n def construct(self):\n self.act_1_texttransitions()\n self.clear_stage()\n self.act_2_plotfunction()\n\n def act_1_texttransitions(self):\n orig_text = Text(\"Hello\", font_size=72)\n new_text = Text(\"World!\", font_size=60).shift(UP * 0.5)\n \n # Transition to new text\n self.play(Write(orig_text))\n self.wait(0.5)\n self.play(Transform(orig_text, new_text))\n \n # Upward Shift\n up_shifted = Text(\"Shifted Up\", font_size=60).shift(DOWN * 0.5)\n self.play(Transform(orig_text, up_shifted))\n self.wait(0.5)\n\n # Create Circle and Star\n circle = Circle(radius=1.5, color=WHITE)\n star = Star(n=5, outer_radius=0.5, inner_radius=0.25, color=YELLOW)\n star.move_to(circle.get_center())\n \n group = VGroup(circle, star)\n \n # Expand Shapes\n self.play(Create(group))\n self.wait(0.5)\n self.play(\n group.animate.scale(1.5),\n star.animate.shift(RIGHT * 2),\n run_time=2,\n rate_func=smooth\n )\n \n # Disappear\n self.play(FadeOut(group))\n\n def act_2_plotfunction(self):\n title = MathText(\"f(x)=x^2\", font_size=60).to_edge(UP)\n axes = Axes(\n x_range=[-2.5, 2.5, 0.5], \n y_range=[-0.5, 5, 1],\n tips=False\n ).scale(1.2).shift(DOWN * 0.5 + LEFT * 0.5)\n labels = axes.get_axis_labels(MathText(\"x\", font_size=32), MathText(\"y\", font_size=32))\n \n # Plotting the curve\n curve = axes.plot(lambda x: x**2, x_range=[-2, 2])\n area = axes.get_area(curve, x_range=(-1, 1), color=TEAL, opacity=0.3)\n axis_title = Text(\"Plot of f(x)=x^2\", font_size=24).next_to(area, DOWN, buff=0.2)\n \n self.add(title)\n self.wait(1)\n \n # Show coordinate system with labels\n self.play(Create(axes), Write(labels))\n self.wait(1)\n \n # Draw the curve on the given range\n self.play(Create(curve), FadeIn(axis_title))\n self.wait(2)\n \n # Add shaded region under curve\n self.play(FadeIn(area))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Write Manim code for a scene illustrating the concept of cross products in vector calculus. Visualize the geometric interpretation and properties of cross products, step by step.", "chosen": "```python\n\"\"\"\nCross Product Animation\n\nThis script demonstrates the concept of cross products using vectors \nand their resulting normal vector perpendicular to both original vectors.\n\nAuthor: Your Name\nDate: YYYY-MM-DD\n\"\"\"\n\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Cross Product\", font_size=48).to_edge(UP)\n self.play(Write(title))\n \n # Define two vectors\n u_vec = Vector([2, 1, 0], color=BLUE)\n v_vec = Vector([-1, 2, 0], color=RED)\n\n u_label = MathTex(\"\\\\mathbf{u}\", color=BLUE).next_to(u_vec, UR)\n v_label = MathTex(\"\\\\mathbf{v}\", color=RED).next_to(v_vec, UL)\n\n # Display vectors on screen\n self.play(Create(u_vec), Create(v_vec))\n self.play(Write(u_label), Write(v_label))\n\n # Show right-hand rule\n rhr_text = Text(\n \"Right-Hand Rule:\\nPoint your thumb along \\n\\\\mathbf{u}, index finger along \\\\mathbf{v}.\",\n font_size=28,\n line_spacing=1.2\n )\n rhr_text.to_corner(DOWN + RIGHT).shift(RIGHT * 0.5)\n\n self.play(FadeIn(rhr_text))\n\n # Draw normal vector to represent cross product direction\n n_vec = Arrow(ORIGIN, [u_vec.get_end()[0] + v_vec.get_end()[0], u_vec.get_end()[1] + v_vec.get_end()[1], 0], color=YELLOW)\n n_label = MathTex(\"\\\\mathbf{n} = \\\\mathbf{u} \\\\times \\\\mathbf{v}\", color=YELLOW).next_to(n_vec, UP)\n\n self.play(GrowFromCenter(n_vec), Write(n_label))\n\n # Conclusion\n conclusion_text = Text(\n \"The magnitude of the result is equal to\\nthe area of the parallelogram formed by \\\\mathbf{u} and \\\\mathbf{v}\",\n font_size=26,\n line_spacing=1.2\n )\n\n conclusion_text.next_to(n_vec, DOWN, buff=1.5).set_color(YELLOW)\n\n self.play(Write(conclusion_text))\n\n # Final display\n final_group = VGroup(u_vec, v_vec, n_vec, u_label, v_label, n_label, rhr_text, conclusion_text)\n self.play(final_group.animate.scale(0.7).move_to(ORIGIN))\n\n # Hold at end for visualization\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass CrossProductScene(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"The Geometric Power of Cross Products\", font_size=36).to_edge(UP)\n intro_text = Tex(\n \"Cross product combines vectors into a new one,\\nperpendicular to both original vectors.\"\n ).next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(FadeIn(intro_text))\n self.wait(2)\n\n # Clear screen to prepare for visualizations\n self.clear()\n self.add(title)\n\n # Create two perpendicular vectors\n vec_a = Arrow(start=LEFT*2, end=RIGHT*2, color=RED)\n vec_b = Arrow(start=DOWN*2, end=UP*2, color=BLUE)\n \n labels_a = MathTex(\"\\\\mathbf{a}\", color=WHITE).move_to(vec_a.get_end())\n labels_b = MathTex(\"\\\\mathbf{b}\", color=WHITE).move_to(vec_b.get_start())\n\n # Show vectors and their components\n self.play(Create(vec_a), Write(labels_a))\n self.play(Create(vec_b), Write(labels_b))\n\n # Animate cross product formula\n cross_formula = MathTex(\n \"\\\\mathbf{c} = \\\\mathbf{a} \\\\times \\\\mathbf{b}\",\n r\"\\\\ \\text{where } c = ab\\sin(\\theta)\",\n tex_to_color_map={\"\\\\mathbf{a}\": RED, \"\\\\mathbf{b}\": BLUE}\n ).scale(0.8).shift(DOWN * 2.5 + RIGHT * 2)\n\n self.play(Write(cross_formula[0]))\n self.wait(1)\n self.play(Write(cross_formula[1]))\n\n # Define the resulting cross product vector perpendicularly\n result_vec = Arrow(start=ORIGIN, end=UP*1.5 + LEFT*1.5, color=YELLOW)\n label_c = MathTex(\"\\\\mathbf{c}\", color=WHITE).move_to(result_vec.get_end())\n\n # Highlight that it's perpendicular using a blue circle\n plane = NumberPlane(x_range=(-3, 3), y_range=(-3, 3)).set_opacity(0.1)\n perp_circle = Circle(radius=0.7, color=GREEN).shift(UP*1.5 + LEFT*1.5)\n\n # Animation sequence showing construction of perpendicular component\n self.wait(1)\n self.play(Create(perp_circle))\n self.play(TransformFromCopy(vec_a.copy(), result_vec), TransformFromCopy(vec_b.copy(), perp_angle=result_vec.copy().rotate(-PI/2)))\n self.play(Write(label_c))\n\n # Explain direction via right-hand rule\n rh_rule = Tex(\"Right-hand Rule:\\\\ Up if $\\\\theta$ is acute, Down if obtuse\").to_edge(DOWN)\n self.play(Write(rh_rule))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Mastering cross products opens up powerful tools\\nfor physics, engineering, and math.\", font_size=24).to_edge(DOWN)\n \n # Fade out everything except vectors and formulas, then show final text\n self.play(\n FadeOut(perp_circle),\n FadeOut(plane),\n FadeOut(rh_rule),\n FadeOut(vec_a),\n FadeOut(vec_b),\n FadeOut(labels_a),\n FadeOut(labels_b),\n FadeOut(label_c),\n )\n self.play(Write(conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that walks me through the process of solving the definite integral of x squared from 1 to 3 step by step, including using the power rule, evaluating the integral at the boundaries, and simplifying the result to the final answer? I’d like the animation to start by displaying the problem, then introduce and apply the power rule, and finally, demonstrate how to substitute the limits of integration and simplify to find the definite integral value.", "chosen": "```python\nfrom manim import *\n\nclass SolveDefiniteIntegral(Scene):\n def construct(self):\n # Configure styles for consistency\n label_kwargs = {\"font_size\": 32, \"color\": BLUE}\n eq_kwargs = {\"font_size\": 48}\n\n # --- Step 1: Display the Problem ---\n step1_label = Text(\"1. The Problem\", **label_kwargs).to_edge(UP)\n problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", **eq_kwargs)\n problem.next_to(step1_label, DOWN, buff=0.5)\n \n self.play(Write(step1_label), Write(problem))\n self.wait(1)\n \n # --- Step 2: Apply the Power Rule ---\n step2_label = Text(\"2. Apply Power Rule\", **label_kwargs).to_edge(UP)\n \n # Visual hint for the power rule\n rule_hint = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=YELLOW)\n rule_hint.next_to(problem, RIGHT, buff=1)\n \n antiderivative = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", **eq_kwargs)\n antiderivative.move_to(problem)\n \n self.play(FadeOut(step1_label), FadeIn(step2_label))\n self.play(Write(rule_hint))\n self.wait(1)\n self.play(ReplacementTransform(problem, antiderivative))\n self.play(FadeOut(rule_hint))\n self.wait(1)\n \n # --- Step 3: Evaluate Boundaries ---\n step3_label = Text(\"3. Evaluate Boundaries\", **label_kwargs).to_edge(UP)\n \n substitution = MathTex(r\"\\frac{3^3}{3} - \\frac{1^3}{3}\", **eq_kwargs)\n substitution.move_to(antiderivative)\n \n self.play(FadeOut(step2_label), FadeIn(step3_label))\n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(1)\n \n # --- Step 4: Simplify ---\n step4_label = Text(\"4. Simplify\", **label_kwargs).to_edge(UP)\n \n arithmetic = MathTex(r\"\\frac{27}{3} - \\frac{1}{3}\", **eq_kwargs)\n arithmetic.move_to(substitution)\n \n final_result = MathTex(r\"\\frac{26}{3}\", **eq_kwargs)\n final_result.move_to(arithmetic)\n \n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n \n self.play(FadeOut(step3_label), FadeIn(step4_label))\n self.play(ReplacementTransform(substitution, arithmetic))\n self.wait(0.5)\n self.play(ReplacementTransform(arithmetic, final_result))\n self.play(Write(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass SolveDefiniteIntegral(Scene):\n def construct(self):\n # Configure styles for consistency\n label_kwargs = {\"font_size\": 32, \"color\": BLUE}\n eq_kwargs = {\"font_size\": 48}\n\n # --- Step 1: Display the Problem ---\n step1_label = Text(\"1. The Problem\", **label_kwargs).to_edge(UP)\n problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", **eq_kwargs)\n problem.next_to(step1_label, DOWN, buff=0.5)\n \n self.play(Write(step1_label), Write(problem))\n self.wait(1)\n \n # --- Step 2: Apply the Power Rule ---\n step2_label = Text(\"2. Apply Power Rule\", **label_kwargs).to_edge(UP)\n \n # Visual hint for the power rule\n rule_hint = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=YELLOW)\n rule_hint.next_to(problem, RIGHT, buff=1)\n \n antiderivative = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", **eq_kwargs)\n antiderivative.move_to(problem)\n \n self.play(FadeOut(step1_label), FadeIn(step2_label))\n self.play(Write(rule_hint))\n self.wait(1)\n self.play(ReplacementTransform(problem, antiderivative))\n self.play(FadeOut(rule_hint))\n self.wait(1)\n \n # --- Step 3: Evaluate Boundaries ---\n step3_label = Text(\"3. Evaluate Boundaries\", **label_kwargs).to_edge(UP)\n \n substitution = MathTex(r\"\\frac{3^3}{3} - \\frac{1^3}{3}\", **eq_kwargs)\n substitution.move_to(antiderivative)\n \n self.play(FadeOut(step2_label), FadeIn(step3_label))\n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(1)\n \n # --- Step 4: Simplify ---\n step4_label = Text(\"4. Simplify\", **label_kwargs).to_edge(UP)\n \n arithmetic = MathTex(r\"\\frac{27}{3} - \\frac{1}{3}\", **eq_kwargs)\n arithmetic.move_to(substitution)\n \n final_result = MathTex(r\"\\frac{26}{3}\" + \" = x\", **eq_kwargs)\n final_result.move_to(arithmetic)\n \n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n \n self.play(FadeOut(step3_label), FadeIn(step4_label))\n self.play(ReplacementTransform(substitution, arithmetic))\n self.wait(0.5)\n self.play(ReplacementTransform(arithmetic, final_result))\n self.play(Write(box))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated visualization of a simplified model of the visual cortex, consisting of different layers of neurons connected to each other? Each neuron should be represented as a circle, and connections between neurons across layers should be depicted with lines. I would like to see the connections behaving dynamically, possibly flashing or changing color, to simulate neural activity. Additionally, the network should include an input layer and an output layer, with labels identifying them. And finally, the entire network should shift downward at some point during the animation.", "chosen": "```python\nfrom manim import *\nimport random\n\nclass VisualCortexModel(Scene):\n def construct(self):\n # Network architecture parameters\n layer_sizes = [4, 6, 6, 4] # Input, Hidden 1, Hidden 2, Output\n layer_spacing = 2.5\n neuron_spacing = 0.8\n neuron_radius = 0.25\n\n neurons = []\n connections = []\n\n # Generate Neurons as Circles\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_coord = (i - (len(layer_sizes) - 1) / 2) * layer_spacing\n for j in range(size):\n y_coord = (j - (size - 1) / 2) * neuron_spacing\n neuron = Circle(\n radius=neuron_radius,\n fill_color=BLUE,\n fill_opacity=0.8,\n stroke_color=WHITE,\n stroke_width=2\n )\n neuron.move_to([x_coord, y_coord, 0])\n layer_group.add(neuron)\n neurons.append(layer_group)\n\n # Generate Connections as Lines between adjacent layers\n for i in range(len(neurons) - 1):\n current_layer = neurons[i]\n next_layer = neurons[i + 1]\n layer_connections = 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 color=GRAY,\n stroke_width=1,\n stroke_opacity=0.6\n )\n layer_connections.add(line)\n connections.append(layer_connections)\n\n # Create Labels for Input and Output Layers\n input_label = Text(\"Input Layer\", font_size=24)\n input_label.next_to(neurons[0], DOWN, buff=0.5)\n\n output_label = Text(\"Output Layer\", font_size=24)\n output_label.next_to(neurons[-1], DOWN, buff=0.5)\n\n # Group all elements for global transformation (movement)\n network_group = VGroup(*neurons, *connections, input_label, output_label)\n network_group.move_to(ORIGIN)\n\n # --- Animation Sequence ---\n\n # 1. Animate Network Creation\n self.play(\n *[Create(layer) for layer in neurons],\n *[Create(layer) for layer in connections],\n run_time=2\n )\n self.play(FadeIn(input_label), FadeIn(output_label))\n self.wait(0.5)\n\n # 2. Simulate Neural Activity (Signal Propagation)\n # Flash connections layer by layer to simulate feedforward activity\n for layer_conns in connections:\n self.play(\n *[conn.animate.set_color(YELLOW).set_stroke(width=2.5, opacity=1)\n for conn in layer_conns],\n run_time=0.3\n )\n self.play(\n *[conn.animate.set_color(GRAY).set_stroke(width=1, opacity=0.6)\n for conn in layer_conns],\n run_time=0.3\n )\n\n # Random sporadic firing to simulate background activity\n all_connections = [conn for layer in connections for conn in layer]\n for _ in range(3):\n active_indices = random.sample(range(len(all_connections)), k=5)\n active_conns = [all_connections[i] for i in active_indices]\n self.play(\n *[conn.animate.set_color(RED) for conn in active_conns],\n run_time=0.2\n )\n self.play(\n *[conn.animate.set_color(GRAY) for conn in active_conns],\n run_time=0.2\n )\n\n # 3. Shift Entire Network Downward\n self.play(\n network_group.animate.shift(DOWN * 1.5),\n run_time=1.5\n )\n\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport random\n\nclass VisualCortexModel(Scene):\n def construct(self):\n # Network architecture parameters\n layer_sizes = [4, 6, 6, 4] # Input, Hidden 1, Hidden 2, Output\n layer_spacing = 2.5\n neuron_spacing = 0.8\n neuron_radius = 0.25\n\n neurons = []\n connections = []\n\n # Generate Neurons as Circles\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_coord = (i - (len(layer_sizes) - 1) / 2) * layer_spacing\n for j in range(size):\n y_coord = (j - (size - 1) / 2) * neuron_spacing\n neuron = Circle(\n radius=neuron_radius,\n fill_color=BBLUE,\n fill_opacity=0.8,\n stroke_color=WHITE,\n stroke_width=2\n )\n neuron.move_to([x_coord, y_coord, 0])\n layer_group.add(neuron)\n neurons.append(layer_group)\n\n # Generate Connections as Lines between adjacent layers\n for i in range(len(neurons) - 1):\n current_layer = neurons[i]\n next_layer = neurons[i + 1]\n layer_connections = 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 color=GRAY,\n stroke_width=1,\n stroke_opacity=0.6\n )\n layer_connections.add(line)\n connections.append(layer_connections)\n\n # Create Labels for Input and Output Layers\n input_label = Text(\"Input Layer\", font_size=24)\n input_label.next_to(neurons[0], DOWN, buff=0.5)\n\n output_label = Text(\"Output Layer\", font_size=24)\n output_label.next_to(neurons[-1], DOWN, buff=0.5)\n\n # Group all elements for global transformation (movement)\n network_group = VGroup(*neurons, *connections, input_label, output_label)\n network_group.move_to(ORIGIN)\n\n # --- Animation Sequence ---\n\n # 1. Animate Network Creation\n self.play(\n *[Create(layer) for layer in neurons],\n *[Create(layer) for layer in connections],\n run_time=2\n )\n self.play(FadeIn(input_label), FadeIn(output_label))\n self.wait(0.5)\n\n # 2. Simulate Neural Activity (Signal Propagation)\n # Flash connections layer by layer to simulate feedforward activity\n for layer_conns in connections:\n self.play(\n *[conn.animate.set_color(YELLOW).set_stroke(width=2.5, opacity=1)\n for conn in layer_conns],\n run_time=0.3\n )\n self.play(\n *[conn.animate.set_color(GRAY).set_stroke(width=1, opacity=0.6)\n for conn in layer_conns],\n run_time=0.3\n )\n\n # Random sporadic firing to simulate background activity\n all_connections = [conn for layer in connections for conn in layer]\n for _ in range(3):\n active_indices = random.sample(range(len(all_connections)), k=5)\n active_conns = [all_connections[i] for i in active_indices]\n self.play(\n *[conn.animate.set_color(RED) for conn in active_conns],\n run_time=0.2\n )\n self.play(\n *[conn.animate.set_color(GRAY) for conn in active_conns],\n run_time=0.2\n )\n\n # 3. Shift Entire Network Downward\n self.play(\n network_group.animate.shift(DOWN * 1.5),\n run_time=1.5\n )\n\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation using ManimCE that visualizes a simple convolutional neural network with alternating convolutional layers and pooling layers? The network should start with a convolutional layer that has 6 feature maps and a 3x3 kernel, then a pooling layer, followed by another convolutional layer with 16 feature maps and a 3x3 kernel, and ending with a final pooling layer. The animation should show the construction of this neural network.", "chosen": "```python\nfrom manim import *\n\nclass ConvNetVisualization(Scene):\n def construct(self):\n # Title for the visualization\n title = Text(\"Simple CNN Architecture\", font_size=48).to_edge(UP)\n \n # --- Layer Configuration ---\n conv_layer_params_1 = {\"filters\": 6, \"kernel_size\": (3, 3), \"layer_type\": \"Conv\"}\n pool_layer_params = {\"stride\": 2}\n conv_layer_params_2 = {\"filters\": 16, \"kernel_size\": (3, 3), \"layer_type\": \"Conv\"}\n\n # Create nodes for each type of layer\n conv_nodes_1 = VGroup()\n for _ in range(conv_layer_params_1[\"filters\"]):\n box = RoundedRectangle(corner_radius=0.2, width=2.5, height=1.5, color=BLUE)\n text = MathTex(\"F\").scale(0.7).move_to(box.get_center())\n \n node_group = VGroup(text, box).set_color(YELLOW)\n conv_nodes_1.add(node_group)\n\n pool_node = Circle(radius=0.5, fill_opacity=0.5, stroke_width=2, color=GREEN)\n label_pool = Text(\"Pool\", font_size=18, color=WHITE).next_to(pool_node, DOWN)\n pool_group = VGroup(pool_node, label_pool)\n\n conv_nodes_2 = VGroup()\n for _ in range(conv_layer_params_2[\"filters\"]):\n box = RoundedRectangle(corner_radius=0.2, width=2.5, height=1.5, color=RED)\n text = MathTex(\"\\\\times\\\\times\\\\times\\\\times\").scale(0.7).move_to(box.get_center())\n \n node_group = VGroup(text, box).set_color(PURPLE)\n conv_nodes_2.add(node_group)\n\n # Arrange layers horizontally\n all_layers = VGroup(\n conv_nodes_1,\n pool_group,\n conv_nodes_2\n ).arrange(RIGHT, buff=2.5)\n\n # Animate the creation of each component sequentially\n \n self.play(Write(title))\n self.wait(0.5)\n\n # Show first convolutional layer\n self.play(Create(conv_nodes_1))\n self.wait(1)\n\n # Add Pooling layer\n self.play(FadeIn(pool_group, shift=DOWN * 0.5))\n self.wait(1)\n\n # Show second convolutional layer\n self.play(Create(conv_nodes_2))\n self.wait(1)\n\n# To run this script:\n# manim -pql filename.py ConvNetVisualization\n```", "rejected": "```python\nfrom manim import *\n\nclass CNNVisualization(Scene):\n def construct(self):\n # --- Color Palette ---\n conv_color = BLUE\n pool_color = GREEN\n text_color = WHITE\n \n # --- Layer Parameters ---\n \n # First Convolutional Layer: Input -> 6 Feature Maps\n input_shape = [8, 8]\n conv1_maps = 6\n conv1_kernel = 3\n conv1_stride = 1\n\n # Pooling Layer 1: Stride=2\n pool1_stride = 2\n pool1_out_shape = [(input_shape[i]-conv1_kernel+i)//pool1_stride + 1 for i in range(2)]\n\n # Second Convolutional Layer: 6 -> 16 Feature Maps\n conv2_maps = 16\n conv2_stride = 1\n\n # Pooling Layer 2: Stride=2\n pool2_stride = 2\n pool2_out_shape = [(pool1_out_shape[i]-conv2_kernel+i)//pool2_stride + 1 for i in range(2)]\n \n\n # --- Create Visualization Elements ---\n\n # Function to render grid elements based on shape\n def render_grid(shape, color, label_text=None):\n cells = VGroup()\n \n # Draw Grid Cells\n for row_idx in range(shape[0]):\n for col_idx in range(shape[1]):\n cell_rect = Rectangle(\n width=1, \n height=1, \n stroke_width=2,\n fill_opacity=0,\n stroke_color=color,\n ).shift(RIGHT*col_idx + UP*(shape[0]-row_idx-1))\n \n cells.add(cell_rect)\n \n if label_text is not None:\n # Add Label at Bottom Center\n label = Text(label_text, font_size=20).to_edge(DOWN).set_color(text_color)\n \n return VGroup(cells, label)\n else:\n return cells\n \n \n\n # Render Input Image\n input_label = Text(\"Input Image\", font_size=20).set_color(conv_color).to_edge(UP)\n input_grid = render_grid(input_shape, CONTOUR_COLOR, \"Input\")\n \n # Render First Convolutional Layer\n conv1_title = Text(\"Conv 1: 6 Map Channels\", font_size=20, color=CONTOUR_COLOR).next_to(input_label, DOWN, buff=0.5)\n \n # Place each map individually so we can animate them sequentially\n conv1_layers = []\n for m in range(conv1_maps):\n conv_layer = render_grid([7, 7], conv_color, f\"Map {m}\")\n conv1_layers.append(conv_layer)\n\n # Render First Pooling Layer\n pool1_title = Text(\"Pool 1: Stride 2\", font_size=20, color=pool_color).next_to(conv1_title, DOWN, buff=0.5)\n pool1_grid = render_grid(pool1_out_shape, pool_color, \"Pooled\")\n\n # Render Second Convolutional Layer\n conv2_title = Text(\"Conv 2: 16 Map Channels\", font_size=20, color=conTOUR_COLOR).next_to(pool1_title, DOWN, buff=0.5)\n conv2_layers = []\n for m in range(conv2_maps):\n conv_layer = render_grid([3, 3], conv_color, f\"Map {m}\")\n conv2_layers.append(conv_layer)\n\n # Render Final Pooling Layer\n pool2_title = Text(\"Final Pool\", font_size=20, color=pool_color).next_to(conv2_title, DOWN, buff=0.5)\n final_pool_grid = render_grid(pool2_out_shape, pool_color, \"Output\")\n\n\n # --- Animation Sequence ---\n\n self.play(FadeIn(input_label))\n self.play(Create(input_grid[0]))\n self.wait(0.5)\n \n # Animate first convolutional layer appearance\n self.play(Write(conv1_title))\n for map_group in conv1_layers:\n self.play(Create(map_group[0]), run_time=0.2) # Create grid\n self.play(Write(map_group[1])) # Write labels\n self.wait(0.5)\n \n # Move to pooling step\n self.play(FadeIn(pool1_title, shift=DOWN))\n self.play(Create(pool1_grid[0]))\n self.wait(0.5)\n \n # Show second convolutional layer\n self.play(Write(conv2_title))\n for map_group in conv2_layers:\n self.play(Create(map_group[0]), run_time=0.2)\n self.play(Write(map_group[1]))\n self.wait(0.5)\n \n # Move to last pooling step\n self.play(FadeIn(pool2_title, shift=DOWN))\n self.play(Create(final_pool_grid[0]))\n \n # Display full architecture path from beginning to end\n arrow_input_conv1 = Arrow(start=input_grid.get_right(), end=conv1_layers[0].get_left())\n arrow_conv1_pool1 = Arrow(start=conv1_layers[-1].get_right(), end=pool1_grid.get_left())\n arrow_pool1_conv2 = Arrow(start=pool1_grid.get_right(), end=conv2_layers[0].get_left())\n arrow_conv2_pool2 = Arrow(start=conv2_layers[-1].get_right(), end=final_pool_grid.get_left())\n\n self.play(GrowArrow(arrow_input_conv1), GrowArrow(arrow_conv1_pool1), GrowArrow(arrow_pool1_conv2), GrowArrow(arrow_conv2_pool2))\n\n self.wait(1)\n\n# To run this code:\n# manim -pql filename.py CNNVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I need to create an educational animation to help students understand how to integrate exponential functions. Specifically, I want to showcase the process of integrating the function e raised to the 2x power with respect to x. The animation should start by displaying the integral of e^(2x) with respect to x. Then, it should include a step-by-step explanation that demonstrates integrating by using the reverse power rule, complete with written commentary. After showing the result of this integration, which is one-half times e^(2x) plus a constant of integration, I would like the initial problem to transform smoothly into the final answer. Once that is done, I want to clear the frame and conclude by stating, \"The integral of an exponential\", followed by a display of the final integration result again. The entire process should be paced slowly enough for students to follow along, with each step displayed for a couple of seconds before moving on to the next. Can you create an animation that meets these requirements?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialIntegration(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Initial Display\n # Display the integral of e^(2x) with respect to x initially.\n # ------------------------------------------------------------------\n\n initial_problem = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\"\n ).scale(1.2)\n\n self.play(Write(initial_problem))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Method Explanation\n # Visually demonstrate the method used: Integration by Substitution\n # Show u-substitution explicitly for clarity.\n # ------------------------------------------------------------------\n\n sub_step = MathTex(\n r\"u &= 2x \\\\\",\n r\"du &= 2\\,dx \\\\\",\n r\"dx &= \\frac{1}{2}\\,du\"\n ).arrange(DOWN).scale(0.8)\n \n sub_box = SurroundingRectangle(sub_step, color=BLUE, buff=0.2)\n\n self.play(Write(sub_step))\n self.play(Create(sub_box))\n self.wait(3)\n\n # Animate substitution into the integral expression\n substituted_integral = MathTex(\n r\"\\int \", r\"e^u\", r\" \\cdot \", r\"\\frac{1}{2} \", r\"du\"\n ).scale(1.2)\n \n self.play(TransformMatchingTex(initial_problem, substituted_integral))\n self.wait(3)\n\n # Clear substitutions for the algebraic steps\n self.play(FadeOut(sub_step), FadeOut(sub_box))\n\n # ------------------------------------------------------------------\n # Step 3: Algebra Steps\n # Demonstrate the algebraic manipulation specifically for the power rule.\n # Explicitly show multiplication by the coefficient from du/dx transformation.\n # ------------------------------------------------------------------\n\n algebra_step = MathTex(\n r\"\\int \", r\"e^u\", r\" \\cdot \", r\"\\frac{1}{2}\"\n ).scale(1.2)\n \n self.play(ReplacementTransform(substituted_integral, algebra_step))\n self.wait(2)\n\n antiderivative = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(e^u + C\\right)\"\n ).scale(1.2).next_to(algebra_step, RIGHT)\n\n self.play(Write(antiderivative))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Reverse Substitution\n # Revert back to the original variable x to finalize the solution.\n # Write out the exact form of the result clearly.\n # ------------------------------------------------------------------\n\n reverse_sub = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(e^{2x} + C\\right)\"\n ).scale(1.2)\n \n self.play(ReplacementTransform(antiderivative, reverse_sub))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # Step 5: Transformation\n # Smoothly animate the transition from the initial problem statement \n # to the final simplified result.\n # ------------------------------------------------------------------\n\n final_answer = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\", r\" =\", r\"\\frac{1}{2}\", r\"e^{2x}\", \"+ C\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(reverse_sub, final_answer))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # Step 6: Conclusion\n # Clear the screen completely.\n # Display a brief text statement identifying the concept.\n # Redisplay the final numerical result prominently at the end.\n # ------------------------------------------------------------------\n\n self.clear()\n \n conclusion_text = Text(\"The integral of an exponential\\nfunction involves multiplying by the inverse exponentials' coefficients.\", font_size=36)\n conclusion_text.to_edge(UP)\n self.play(Write(conclusion_text))\n self.wait(3)\n\n final_display = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\", r\" =\", r\"\\frac{1}{2}\", r\"e^{2x}\", \"+ C\"\n ).scale(1.5).set_color(YELLOW)\n final_display.next_to(conclusion_text, DOWN, buff=0.5)\n\n box = SurroundingRectangle(final_display, color=GREEN, buff=0.3)\n \n self.play(Write(box))\n self.play(Write(final_display))\n self.wait(5)\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialIntegration(Scene):\n def construct(self):\n # --- Step 1: Display Initial Problem ---\n initial_problem = MathTex(\n r\"\\int e^{2x} \\, dx\",\n font_size=60,\n color=WHITE\n )\n \n self.play(Write(initial_problem))\n self.wait(2)\n\n # --- Step 2: Explain Substitution Method ---\n substitution_text = Text(\"Apply u-substitution:\", font_size=36).to_edge(UP)\n u_subscript = MathTex(\n r\"u = 2x \\\\ du = 2dx \\\\ \\frac{du}{2} = dx\"\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.5).next_to(substitution_text, DOWN, buff=0.5)\n \n sub_group = VGroup(substitution_text, u_subscript)\n \n self.play(FadeIn(sub_group, shift=DOWN * 0.5))\n self.wait(2)\n\n # Transform initial problem using substitution logic\n transformed_initial = MathTex(\n r\"\\int e^u \\cdot \\frac{du}{2}\",\n font_size=60,\n color=YELLOW\n )\n\n self.play(TransformMatchingTex(initial_problem, transformed_initial))\n self.wait(2)\n\n # Show antiderivative after substitution\n antideriv_sub = MathTex(\n r\"=\\frac{1}{2}\\int e^u \\, du\"\n ).next_to(transformed_initial, RIGHT, buff=0.8)\n \n self.play(Write(antideriv_sub))\n self.wait(2)\n\n # --- Step 3: Apply Reverse Power Rule ---\n power_rule_text = Text(\"Reverse Power Rule:\", font_size=36).to_edge(UP)\n \n # Create boxes around parts of the expression to highlight them during the transformation\n box_u = SurroundingRectangle(u_subscript[0], color=GREEN, fill_opacity=0.1, stroke_width=2)\n box_antideriv = SurroundingRectangle(antideriv_sub[0], color=RED, fill_opacity=0.1, stroke_width=2)\n\n self.play(Write(power_rule_text))\n\n # Highlight 'e^u' and its derivative in antideriv_sub\n self.play(Create(box_u), Create(box_antideriv))\n self.wait(2)\n\n # Perform the actual transformation based on the reverse power rule\n final_result_box = SurroundingRectangle(MathTex(\"\\frac{1}{2}\", \"\\left(e^u\\right)\", \"+ C\"), color=BLUE, fill_opacity=0.1, stroke_width=2)\n self.play(ReplaceTarget(antideriv_sub, MathTex(\"\\\\frac{1}{2}e^u + C\")), Create(final_result_box))\n self.wait(2)\n\n # Clear the screen completely\n self.play(FadeOut(VGroup(sub_group, transformed_initial, antideriv_sub, power_rule_text, box_u, box_antideriv)))\n\n # Conclusion text\n conclusion_text = Text(\"The integral of an exponential\", font_size=48)\n self.play(Write(conclusion_text))\n self.wait(2)\n\n # Re-display the final result prominently at the end\n final_answer = MathTex(\n r\"\\int e^{2x} \\, dx = \\frac{1}{2} e^{2x} + C\",\n font_size=72\n ).set_color(YELLOW)\n \n self.play(FadeIn(final_answer, scale=1.5))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What transformations preserve boundary congruency when mapping from a torus to a sphere?", "chosen": "```python\nfrom manim import *\n\nclass TorusSphereMapping(Scene):\n def construct(self):\n # Title\n title = Text(\"Torus to Sphere Mapping\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Draw a simple torus\n torus = Circle(radius=1).shift(RIGHT*2 + UP*2)\n inner_circle = Circle(radius=0.3).shift(RIGHT*2 + UP*2)\n torus_group = VGroup(torus, inner_circle)\n \n self.play(Create(inner_circle), Create(torus))\n self.wait(1)\n\n # Clear screen for spherical representation\n self.clear()\n self.wait(1)\n\n # Show a simplified sphere\n sphere = Circle(radius=1)\n \n self.play(Create(sphere))\n self.wait(1)\n\n # Explain topological equivalence\n eq_text = Text(\n \"A torus can be continuously deformed\\ninto a sphere without cutting\",\n font_size=28,\n t2c={\"torus\": YELLOW, \"sphere\": BLUE}\n )\n eq_text.to_edge(DOWN)\n self.play(Write(eq_text))\n\n # Map points on torus to corresponding points on sphere\n # Simplified method: map periphery of inner circle to sphere perimeter\n inner_dot_torus = Dot(point=[-0.7, -0.7, 0], color=YELLOW)\n inner_label_torus = Tex(\"$P_{\\text{T}}$\").next_to(inner_dot_torus, DOWN)\n dot_on_sphere = Dot(point=sphere.point_at_angle(TAU * 0.5), color=BLUE)\n label_on_sphere = Tex(\"$P_{\\text{S}}$\").next_to(dot_on_sphere, RIGHT)\n \n self.play(FadeIn(inner_dot_torus), Write(inner_label_torus))\n self.wait(0.5)\n\n # Animate morphing\n morphed_torus = Circle(radius=1).set_color(YELLOW)\n morphed_torus.move_to([0.3, 0.2, 0])\n morphed_torus.scale(1.5) # Scale up to fit within the original circle area\n \n self.play(TransformFromCopy(inner_dot_torus, morphed_torus))\n self.wait(0.5)\n\n # Connect dots\n line_path = VMobject()\n path_start = [inner_dot_torus.get_center()[0], inner_dot_torus.get_center()[1], 0]\n path_end = [dot_on_sphere.get_center()[0], dot_on_sphere.get_center()[1], 0]\n\n line_path.set_points_as_corners([path_start, path_end])\n\n arrow_up = Arrow(start=path_end, end=path_end + DOWN * 0.2, buff=0.1, color=WHITE)\n text_up = Tex(\"$f(P)$\").scale(0.6).move_to(path_end + DOWN * 0.3)\n \n self.play(Create(line_path), GrowArrow(arrow_up), FadeIn(label_on_sphere), Write(text_up))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"Topological transformation preserves shape boundaries.\", font_size=28)\n conclusion.next_to(eq_text, DOWN, buff=1)\n \n self.play(Write(conclusion))\n\n # Final display\n final_group = VGroup(\n torus_group, \n sphere, \n inner_dot_torus, inner_label_torus, \n dot_on_sphere, label_on_sphere, \n line_path, arrow_up, text_up, \n eq_text, conclusion\n )\n \n box = SurroundingRectangle(final_group, color=GREEN, buff=MED_LARGE_BUFF)\n \n self.wait(2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass TorusToSphere(Scene):\n def construct(self):\n # Title\n title = Text(\"Torus to Sphere Mapping\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n\n # Create a torus\n torus = Torus(radius=2.5, tube_radius=0.7).rotate(PI/4, axis=OUT)\n\n # Display the torus\n self.add(torus)\n self.wait(1)\n\n # Transform torus into a sphere while preserving boundary congruency\n # We rotate the torus so that its circular cross-section aligns vertically\n torus_rotated = torus.copy().rotate(-PI/4, about_point=ORIGIN)\n \n # Apply transformation to create the spherical shape\n # Using 'Scale' allows us to maintain the aspect ratio for visual consistency\n self.play(\n Rotate(torus_rotated, angle=PI/2, about_point=ORIGIN),\n Scale(torus_rotated, scale_factor=(torus.get_height()/torus_rotated.get_height()), about_point=ORIGIN),\n run_time=2,\n rate_func=smooth\n )\n \n # Add labels\n label_torus = Tex(\"$\\\\text{Torus}$\", color=YELLOW).next_to(torus, DOWN)\n label_sphere = Tex(\"$\\\\text{Sphere}$\", color=GREEN).move_to(torus_rotated.get_center())\n \n self.play(Write(label_torus))\n self.wait(1)\n\n # Fade out labels and objects\n self.play(\n FadeOut(torus_rotated),\n FadeOut(torus),\n FadeOut(label_torus)\n )\n\n # Show equations\n eq1 = MathTex(\"\\\\pi r^2 \\\\times h\")\n eq2 = MathTex(\"\\\\frac{4}{3} \\\\pi r^3\")\n\n equations = VGroup(eq1, eq2).arrange(DOWN, buff=0.8).scale(0.8).to_edge(RIGHT)\n equations.next_to(label_sphere, LEFT, buff=1)\n\n self.play(Write(equations))\n self.wait(1)\n\n # Clear screen\n self.clear()\n self.wait(0.5)\n self.play(Write(eq1))\n self.play(Write(eq2))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational ManimCE animation on 'Quadratic Residues and Non-Residues' (Visualizing Quadratic Reciprocity: The Dance of Residues): How does the quadratic reciprocity law visually distinguish quadratic residues and non-residues for different prime bases?\nVisual style guidance: Cinematic and engaging visual style with a calm pastel color palette, utilizing blue and orange hues for highlights and patterns, emphasizing visual clarity and focus on the symmetry and elegance inherent in number theory.", "chosen": "```python\nfrom manim import *\n\nclass QuadraticReciprocity(Scene):\n def construct(self):\n # Title\n title = Text(\"Visualizing Quadratic Reciprocity\").scale(0.8)\n subtitle = Text(\"The Dance of Residues\").scale(0.6).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 # Definition of quadratic residues\n definition = Text(\"A number a is a quadratic residue mod p if:\").scale(0.7)\n equation = MathTex(r\"x^2 \\equiv a \\pmod{p}\")\n equation.next_to(definition, DOWN)\n \n self.play(Write(definition))\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(definition), FadeOut(equation))\n \n # Create circles for primes 7 and 11\n circle7 = Circle(radius=1.5, color=BLUE).shift(LEFT * 2)\n label7 = Text(\"Residues mod 7\", color=BLUE).scale(0.6).next_to(circle7, UP)\n \n circle11 = Circle(radius=1.5, color=ORANGE).shift(RIGHT * 2)\n label11 = Text(\"Residues mod 11\", color=ORANGE).scale(0.6).next_to(circle11, UP)\n \n self.play(Create(circle7), Write(label7))\n self.play(Create(circle11), Write(label11))\n self.wait(1)\n \n # Quadratic residues text\n residues7 = Text(\"QR: 1, 2, 4\", color=BLUE).scale(0.6).next_to(circle7, DOWN)\n residues11 = Text(\"QR: 1, 3, 4, 5, 9\", color=ORANGE).scale(0.6).next_to(circle11, DOWN)\n \n self.play(Write(residues7))\n self.play(Write(residues11))\n self.wait(1)\n \n # Quadratic Reciprocity Law\n self.play(\n FadeOut(circle7), FadeOut(label7), FadeOut(residues7),\n FadeOut(circle11), FadeOut(label11), FadeOut(residues11)\n )\n \n reciprocity_title = Text(\"Quadratic Reciprocity Law\").scale(0.7)\n reciprocity_eq = MathTex(r\"\\left(\\frac{p}{q}\\right) \\cdot \\left(\\frac{q}{p}\\right) = (-1)^{\\frac{(p-1)(q-1)}{4}}\")\n reciprocity_eq.next_to(reciprocity_title, DOWN)\n \n self.play(Write(reciprocity_title))\n self.play(Write(reciprocity_eq))\n self.wait(1)\n \n # Grid visualization\n self.play(FadeOut(reciprocity_title), FadeOut(reciprocity_eq))\n \n # Create a 4x4 grid\n grid = VGroup()\n for i in range(4):\n for j in range(4):\n cell = Square(side_length=0.6, color=WHITE)\n cell.move_to([j - 1.5, 1.5 - i, 0])\n grid.add(cell)\n \n self.play(Create(grid))\n \n # Highlight some cells to represent residue patterns\n pattern_cells = [(0, 0), (1, 1), (2, 2), (3, 3), (0, 3), (3, 0)]\n for i, j in pattern_cells:\n cell = grid[i * 4 + j]\n self.play(cell.animate.set_fill(BLUE, opacity=0.5), run_time=0.2)\n \n pattern_title = Text(\"The dance of residues\").scale(0.7).to_edge(DOWN)\n self.play(Write(pattern_title))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(grid), FadeOut(pattern_title))\n \n conclusion = Text(\"Quadratic reciprocity reveals\\nharmony in mathematical chaos\").scale(0.7)\n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass QuadraticReciprocity(Scene):\n def construct(self):\n # Title\n title = Text(\"Visualizing Quadratic Reciprocity\").scale(0.8)\n subtitle = Text(\"The Dance of Residues\").scale(0.6).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 # Definition of quadratic residues\n definition = Text(\"A number a is a quadratic residue mod p if:\").scale(0.7)\n equation = MathTex(r\"x^2 \\equiv a \\pmod{p}\")\n equation.next_to(definition, DOWN)\n \n self.play(Write(definition))\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(definition), FadeOut(equation))\n \n # Create circles for primes 7 and 11\n circle7 = Circle(radius=1.5, color=BBLUE).shift(LEFT * 2)\n label7 = Text(\"Residues mod 7\", color=BLUE).scale(0.6).next_to(circle7, UP)\n \n circle11 = Circle(radius=1.5, color=ORANGE).shift(RIGHT * 2)\n label11 = Text(\"Residues mod 11\", color=ORANGE).scale(0.6).next_to(circle11, UP)\n \n self.play(Create(circle7), Write(label7))\n self.play(Create(circle11), Write(label11))\n self.wait(1)\n \n # Quadratic residues text\n residues7 = Text(\"QR: 1, 2, 4\", color=BLUE).scale(0.6).next_to(circle7, DOWN)\n residues11 = Text(\"QR: 1, 3, 4, 5, 9\", color=ORANGE).scale(0.6).next_to(circle11, DOWN)\n \n self.play(Write(residues7))\n self.play(Write(residues11))\n self.wait(1)\n \n # Quadratic Reciprocity Law\n self.play(\n FadeOut(circle7), FadeOut(label7), FadeOut(residues7),\n FadeOut(circle11), FadeOut(label11), FadeOut(residues11)\n )\n \n reciprocity_title = Text(\"Quadratic Reciprocity Law\").scale(0.7)\n reciprocity_eq = MathTex(r\"\\left(\\frac{p}{q}\\right) \\cdot \\left(\\frac{q}{p}\\right) = (-1)^{\\frac{(p-1)(q-1)}{4}}\")\n reciprocity_eq.next_to(reciprocity_title, DOWN)\n \n self.play(Write(reciprocity_title))\n self.play(Write(reciprocity_eq))\n self.wait(1)\n \n # Grid visualization\n self.play(FadeOut(reciprocity_title), FadeOut(reciprocity_eq))\n \n # Create a 4x4 grid\n grid = VGroup()\n for i in range(4):\n for j in range(4):\n cell = Square(side_length=0.6, color=WHITE)\n cell.move_to([j - 1.5, 1.5 - i, 0])\n grid.add(cell)\n \n self.play(Create(grid))\n \n # Highlight some cells to represent residue patterns\n pattern_cells = [(0, 0), (1, 1), (2, 2), (3, 3), (0, 3), (3, 0)]\n for i, j in pattern_cells:\n cell = grid[i * 4 + j]\n self.play(cell.animate.set_fill(BLUE, opacity=0.5), run_time=0.2)\n \n pattern_title = Text(\"The dance of residues\").scale(0.7).to_edge(DOWN)\n self.play(Write(pattern_title))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(grid), FadeOut(pattern_title))\n \n conclusion = Text(\"Quadratic reciprocity reveals\\nharmony in mathematical chaos\").scale(0.7)\n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second Manim scene that explains a chemical equilibrium shift after adding more reactant. Show a reversible reaction with reactant and product bars, then increase the reactant side and animate the system settling to a new balance with more product than before.", "chosen": "```python\nfrom manim import *\n\nclass EquilibriumShiftStory(Scene):\n def construct(self):\n title = Text('Adding Reactant Shifts The Equilibrium', font_size=29).to_edge(UP)\n react_frame = Rectangle(width=2.2, height=3.0, color=BLUE_D).shift(LEFT * 2.7 + DOWN * 0.05)\n prod_frame = Rectangle(width=2.2, height=3.0, color=TEAL_D).shift(RIGHT * 2.7 + DOWN * 0.05)\n arrow = Arrow(react_frame.get_right(), prod_frame.get_left(), buff=0.2, color=YELLOW_D)\n rev_arrow = Arrow(prod_frame.get_left() + DOWN * 0.28, react_frame.get_right() + DOWN * 0.28, buff=0.2, color=YELLOW_D)\n react_bar = Rectangle(width=0.7, height=1.05, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.45)\n prod_bar = Rectangle(width=0.7, height=1.2, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.45).move_to(prod_frame.get_center() + DOWN * 0.38)\n react_label = Text('reactant', font_size=18, color=BLUE_D).next_to(react_frame, UP, buff=0.12)\n prod_label = Text('product', font_size=18, color=TEAL_D).next_to(prod_frame, UP, buff=0.12)\n add_arrow = Arrow(react_frame.get_left() + LEFT * 0.9, react_bar.get_left(), buff=0.0, color=ORANGE)\n added_bar = Rectangle(width=0.7, height=1.75, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.1)\n settled_react = Rectangle(width=0.7, height=1.35, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.3)\n settled_prod = Rectangle(width=0.7, height=1.75, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.45).move_to(prod_frame.get_center() + DOWN * 0.1)\n caption = Text('Adding reactant disturbs the old balance, so the reaction shifts right until a new equilibrium is reached.', 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), FadeIn(react_frame), FadeIn(prod_frame), FadeIn(react_label), FadeIn(prod_label), GrowArrow(arrow), GrowArrow(rev_arrow), run_time=2.0)\n self.play(FadeIn(react_bar), FadeIn(prod_bar), run_time=1.4)\n self.play(GrowArrow(add_arrow), ReplacementTransform(react_bar, added_bar), run_time=1.6)\n self.play(ReplacementTransform(added_bar, settled_react), ReplacementTransform(prod_bar, settled_prod), run_time=2.0)\n self.play(FadeIn(caption_group), Indicate(settled_prod, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EquilibriumShiftStory(Scene):\n def construct(self):\n title = Text('Adding Reactant Shifts The Equilibrium', font_size=29).to_edge(UP)\n react_frame = Rectangle(width=2.2, height=3.0, color=BLUE_D).shift(LEFT * 2.7 + DOWN * 0.05)\n prod_frame = Rectangle(width=2.2, height=3.0, color=TEAL_D).shift(RIGHT * 2.7 + DOWN * 0.05)\n arrow = Arrow(react_frame.get_right(), prod_frame.get_left(), buff=0.2, color=YELLOW_D)\n rev_arrow = Arrow(prod_frame.get_left() + DOWN * 0.28, react_frame.get_right() + DOWN * 0.28, buff=0.2, color=YELLOW_D)\n react_bar = Rectangle(width=0.7, height=1.05, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.45)\n prod_bar = Rectangle(width=0.7, height=1.2, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.45).move_to(prod_frame.get_center() + DOWN * 0.38)\n react_label = Text('reactant', font_size=18, color=BLUE_D).next_to(react_frame, UP, buff=0.12)\n prod_label = Text('product', font_size=18, color=TEAL_D).next_to(prod_frame, UP, buff=0.12)\n add_arrow = Arrow(react_frame.get_left() + LEFT * 0.9, react_bar.get_left(), buff=0.0, color=ORANGE)\n added_bar = Rectangle(width=0.7, height=1.75, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.1)\n settled_react = Rectangle(width=0.7, height=1.35, color=BLUE_D, fill_color=BLUE_D, fill_opacity=0.45).move_to(react_frame.get_center() + DOWN * 0.3)\n settled_prod = Rectangle(width=0.7, height=1.75, color=TEAL_D, fill_color=TEAL_D, fill_opacity=0.45).move_to(prod_frame.get_center() + DOWN * 0.1)\n caption = Text('Adding reactant disturbs the old balance, so the reaction shifts right until a new equilibrium is reached.', 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), FadeIn(react_frame), FadeIn(prod_frame), FadeIn(react_label), FadeIn(prod_label), GrowArrow(arrow), GrowArrow(rev_arrow), run_time=2.0)\n self.play(FadeIn(react_bar), FadeIn(prod_bar), run_time=1.4)\n self.play(GrowArrow(add_arrow), ReplacementTransform(target_position=ORIGIN, react_bar, added_bar), run_time=1.6)\n self.play(ReplacementTransform(added_bar, settled_react), ReplacementTransform(prod_bar, settled_prod), run_time=2.0)\n self.play(FadeIn(caption_group), Indicate(settled_prod, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that first displays the classic wave equation for a scalar field u, explains what the equation is, mentions that the constant c represents the wave speed, transitions to showing a specific harmonic wave solution of this equation, and then removes everything to focus on the specific solution? Additionally, I'd like the explanations to be written in text at the top of the screen and the equations to be prominently displayed in the center.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n \"\"\"\n Educational animation demonstrating the classic wave equation \n and its specific harmonic wave solution.\n \"\"\"\n def construct(self):\n # --- 1. Define Objects ---\n \n # The classic 1D wave equation for a scalar field u\n wave_equation = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\"\n ).scale(1.5)\n \n # Explanatory text positioned at the top\n # Explicitly stating that c represents the wave speed\n title_text = Text(\n \"The Classic Wave Equation\",\n font_size=36\n ).to_edge(UP)\n \n desc_text = Text(\n \"where c represents the wave speed\",\n font_size=32,\n color=YELLOW\n ).next_to(title_text, DOWN, buff=0.3)\n \n top_text = VGroup(title_text, desc_text)\n\n # The specific harmonic wave solution\n harmonic_solution = MathTex(\n r\"u(x, t) = A \\cos(kx - \\omega t)\"\n ).scale(1.5)\n\n # --- 2. Animation Sequence ---\n\n # Step 1: Display the classic wave equation in the center\n self.play(Write(wave_equation))\n self.wait(1)\n\n # Step 2: Provide textual explanation at the top\n self.play(FadeIn(top_text, shift=UP))\n self.wait(3)\n\n # Step 3: Transition smoothly to the harmonic wave solution\n # ReplacementTransform morphs the general equation into the specific solution\n self.play(\n ReplacementTransform(wave_equation, harmonic_solution),\n run_time=1.5\n )\n self.wait(2)\n\n # Step 4: Remove all previous elements to focus solely on the specific solution\n self.play(FadeOut(top_text))\n \n # Subtle scale-up to emphasize focus on the isolated solution\n self.play(harmonic_solution.animate.scale(1.2))\n self.wait(3)\n\n# To run this code, save it as a .py file and use the command:\n# manim -pql filename.py WaveEquationAnimation\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n \"\"\"\n Educational animation demonstrating the classic wave equation \n and its specific harmonic wave solution.\n \"\"\"\n def construct(self):\n # --- 1. Define Objects ---\n \n # The classic 1D wave equation for a scalar field u\n wave_equation = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\"\n ).scale(1.5)\n \n # Explanatory text positioned at the top\n # Explicitly stating that c represents the wave speed\n title_text = Text(\n \"The Classic Wave Equation\",\n font_size=36\n ).to_edge(UP)\n \n desc_text = Text(\n \"where c represents the wave speed\",\n font_size=32,\n color=YELLOW\n ).next_to(title_text, DOWN, buff=0.3)\n \n top_text = VGroup(title_text, desc_text)\n\n # The specific harmonic wave solution\n harmonic_solution = MathTex(\n r\"u(x, t) = A \\cos(kx - \\omega t)\"\n ).scale(1.5)\n\n # --- 2. Animation Sequence ---\n\n # Step 1: Display the classic wave equation in the center\n self.play(Write(wave_equation))\n self.wait(1)\n\n # Step 2: Provide textual explanation at the top\n self.play(FadeIn(top_text, shift=UP))\n self.wait(3)\n\n # Step 3: Transition smoothly to the harmonic wave solution\n # ReplacementTransform morphs the general equation into the specific solution\n self.play(\n ReplacementTransform(target_position=ORIGIN, wave_equation, harmonic_solution),\n run_time=1.5\n )\n self.wait(2)\n\n # Step 4: Remove all previous elements to focus solely on the specific solution\n self.play(FadeOut(top_text))\n \n # Subtle scale-up to emphasize focus on the isolated solution\n self.play(harmonic_solution.animate.scale(1.2))\n self.wait(3)\n\n# To run this code, save it as a .py file and use the command:\n# manim -pql filename.py WaveEquationAnimation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 10-second Manim scene that shows a training loss curve dropping over epochs and flattening near convergence. Include axes, several highlighted checkpoints, and a short caption about diminishing returns.", "chosen": "```python\nfrom manim import *\n\nclass TrainingLossCurve(Scene):\n def construct(self):\n title = Text(\"Training Loss\", font_size=36).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[0, 4.5, 1], x_length=7, y_length=4, tips=False).shift(DOWN * 0.2)\n axis_labels = axes.get_axis_labels(Text(\"epoch\", font_size=22), Text(\"loss\", font_size=22))\n points = [(0, 4.0), (1, 2.8), (2, 1.9), (3, 1.3), (4, 0.95), (5, 0.72), (6, 0.58), (7, 0.50)]\n graph = VMobject(color=BLUE_D, stroke_width=4)\n graph.set_points_smoothly([axes.c2p(x, y) for x, y in points])\n dots = VGroup(*[Dot(axes.c2p(x, y), color=YELLOW_D, radius=0.06) for x, y in points[1::2]])\n plateau = SurroundingRectangle(VGroup(dots[-2], dots[-1]), color=GREEN_D, buff=0.16)\n caption = Text(\"Early updates help most. Later steps still matter, but less.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(axes), FadeIn(axis_labels), run_time=2)\n self.play(Create(graph), run_time=3)\n self.play(LaggedStart(*[FadeIn(dot) for dot in dots], lag_ratio=0.25), run_time=2)\n self.play(Create(plateau), FadeIn(caption), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass TrainingLossCurve(Scene):\n def construct(self):\n title = Text(\"Training Loss\", font_size=36).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[0, 4.5, 1], x_length=7, y_length=4, tips=False).shift(DOWN * 0.2)\n axis_labels = axes.get_axis_labels(Text(\"epoch\", font_size=22), Text(\"loss\", font_size=22))\n points = [(0, 4.0), (1, 2.8), (2, 1.9), (3, 1.3), (4, 0.95), (5, 0.72), (6, 0.58), (7, 0.50)]\n graph = VMobject(color=BBLUE_D, stroke_width=4)\n graph.set_points_smoothly([axes.c2p(x, y) for x, y in points])\n dots = VGroup(*[Dot(axes.c2p(x, y), color=YELLOW_D, radius=0.06) for x, y in points[1::2]])\n plateau = SurroundingRectangle(VGroup(dots[-2], dots[-1]), color=GREEN_D, buff=0.16)\n caption = Text(\"Early updates help most. Later steps still matter, but less.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(axes), FadeIn(axis_labels), run_time=2)\n self.play(Create(graph), run_time=3)\n self.play(LaggedStart(*[FadeIn(dot) for dot in dots], lag_ratio=0.25), run_time=2)\n self.play(Create(plateau), FadeIn(caption), run_time=2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Performance Optimization and Testing\n\n#### Performance Optimization Strategies\nThe core of VR optimization is ensuring low latency in \"motion-to-photon\" and avoiding screen jitter.\n- **Rendering Optimization**\n - Occlusion Culling: Do not render objects that are not visible\n - Frustum Culling\n - LOD (Level of Detail) System: Use low-poly models for distant objects\n - Dynamic Resolution Scaling: Automatically reduce resolution when the load is high\n\n- **CPU Optimization**\n - Object Pooling: Avoid frequent GC\n - Asynchronous Resource Loading: Prevent frame drops\n - Reduce the frequency of physics calculations or simplify collision bodies\n\n\nThe context of this section (from highest to current level):\n# Graphics and Virtual Reality: VR Application Development and Frontiers\n## VR Development Process\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass VROptimization(Scene):\n\n def construct(self):\n title = Title('Performance Optimization and Testing', font_size=36)\n subtitle = Text('Graphics & VR: VR Application Development Process', font_size=18, color=LIGHT_GREY)\n subtitle.next_to(title, DOWN, buff=0.15)\n core_text = MarkupText(\"Core Strategy: Ensure low latency in 'motion-to-photon' and avoid screen jitter.\", font_size=22)\n core_rect = SurroundingRectangle(core_text, color=YELLOW, fill_opacity=0.1, buff=0.2, corner_radius=0.1)\n core_group = VGroup(core_rect, core_text)\n rend_title = Text('Rendering Optimization', font_size=24, color=BLUE)\n rend_b1 = Text('• Occlusion Culling: Do not render objects that are not visible', font_size=20)\n rend_b2 = Text(\"• Frustum Culling: Ignore objects outside the camera's view\", font_size=20)\n rend_b3 = Text('• LOD (Level of Detail) System: Use low-poly models for distant objects', font_size=20)\n rend_b4 = Text('• Dynamic Resolution Scaling: Automatically reduce resolution under high load', font_size=20)\n rend_group = VGroup(rend_title, rend_b1, rend_b2, rend_b3, rend_b4)\n rend_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n cpu_title = Text('CPU Optimization', font_size=24, color=GREEN)\n cpu_b1 = Text('• Object Pooling: Avoid frequent Garbage Collection (GC)', font_size=20)\n cpu_b2 = Text('• Asynchronous Resource Loading: Prevent frame drops', font_size=20)\n cpu_b3 = Text('• Physics: Reduce calculation frequency or simplify collision bodies', font_size=20)\n cpu_group = VGroup(cpu_title, cpu_b1, cpu_b2, cpu_b3)\n cpu_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n content_group = VGroup(rend_group, cpu_group).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n rest_content = VGroup(core_group, content_group).arrange(DOWN, buff=0.5)\n rest_content.next_to(subtitle, DOWN, buff=0.4)\n if rest_content.width > 13:\n rest_content.scale(13 / rest_content.width)\n else:\n pass\n self.play(Write(title), FadeIn(subtitle))\n self.wait(0.5)\n self.play(Create(core_rect), Write(core_text))\n self.wait(1)\n self.play(Write(rend_title))\n self.play(FadeIn(VGroup(rend_b1, rend_b2, rend_b3, rend_b4), lag_ratio=0.1))\n self.wait(1)\n self.play(Write(cpu_title))\n self.play(FadeIn(VGroup(cpu_b1, cpu_b2, cpu_b3), lag_ratio=0.1))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass VROptimization(Scene):\n\n def construct(self):\n title = Title('Performance Optimization and Testing', font_size=36)\n subtitle = Text('Graphics & VR: VR Application Development Process', font_size=18, color=LIGHT_GREY)\n subtitle.next_to(title, DOWN, buff=0.15)\n core_text = MarkupText(\"Core Strategy: Ensure low latency in 'motion-to-photon' and avoid screen jitter.\", font_size=22)\n core_rect = SurroundingRectangle(core_text, color=YELLOW, fill_opacity=0.1, buff=0.2, corner_radius=0.1)\n core_group = VGroup(core_rect, core_text)\n rend_title = Text('Rendering Optimization', font_size=24, color=BBLUE)\n rend_b1 = Text('• Occlusion Culling: Do not render objects that are not visible', font_size=20)\n rend_b2 = Text(\"• Frustum Culling: Ignore objects outside the camera's view\", font_size=20)\n rend_b3 = Text('• LOD (Level of Detail) System: Use low-poly models for distant objects', font_size=20)\n rend_b4 = Text('• Dynamic Resolution Scaling: Automatically reduce resolution under high load', font_size=20)\n rend_group = VGroup(rend_title, rend_b1, rend_b2, rend_b3, rend_b4)\n rend_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n cpu_title = Text('CPU Optimization', font_size=24, color=GREEN)\n cpu_b1 = Text('• Object Pooling: Avoid frequent Garbage Collection (GC)', font_size=20)\n cpu_b2 = Text('• Asynchronous Resource Loading: Prevent frame drops', font_size=20)\n cpu_b3 = Text('• Physics: Reduce calculation frequency or simplify collision bodies', font_size=20)\n cpu_group = VGroup(cpu_title, cpu_b1, cpu_b2, cpu_b3)\n cpu_group.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n content_group = VGroup(rend_group, cpu_group).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n rest_content = VGroup(core_group, content_group).arrange(DOWN, buff=0.5)\n rest_content.next_to(subtitle, DOWN, buff=0.4)\n if rest_content.width > 13:\n rest_content.scale(13 / rest_content.width)\n else:\n pass\n self.play(Write(title), FadeIn(subtitle))\n self.wait(0.5)\n self.play(Create(core_rect), Write(core_text))\n self.wait(1)\n self.play(Write(rend_title))\n self.play(FadeIn(VGroup(rend_b1, rend_b2, rend_b3, rend_b4), lag_ratio=0.1))\n self.wait(1)\n self.play(Write(cpu_title))\n self.play(FadeIn(VGroup(cpu_b1, cpu_b2, cpu_b3), lag_ratio=0.1))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- Configuration ---\n math_color = YELLOW\n label_color = BLUE\n result_color = GREEN\n\n # --- Step 1: Setup the Integral ---\n step1_label = Text(\"Step 1: Set up the definite integral\", font_size=32, color=label_color).to_edge(UP)\n integral = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", color=math_color).scale(1.5)\n \n self.play(Write(step1_label))\n self.play(Write(integral))\n self.wait(2)\n\n # --- Step 2: Apply the Power Rule ---\n step2_label = Text(\"Step 2: Apply the Power Rule\", font_size=32, color=label_color).to_edge(UP)\n \n # Show the general power rule briefly\n rule_text = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=WHITE).next_to(integral, UP, buff=0.5).shift(RIGHT * 3)\n self.play(ReplacementTransform(step1_label, step2_label), Write(rule_text))\n self.wait(2)\n\n # Transform the integral into the unsimplified antiderivative\n antiderivative_unsimplified = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", color=math_color).scale(1.5)\n self.play(FadeOut(rule_text), Transform(integral, antiderivative_unsimplified))\n self.wait(1)\n\n # Simplify the exponents and denominator\n antiderivative_simplified = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", color=math_color).scale(1.5)\n self.play(Transform(integral, antiderivative_simplified))\n self.wait(2)\n\n # --- Step 3: Evaluate at the Bounds ---\n step3_label = Text(\"Step 3: Evaluate at the bounds\", font_size=32, color=label_color).to_edge(UP)\n \n # Substitution of upper and lower bounds\n evaluation = MathTex(r\"\\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", color=math_color).scale(1.5)\n self.play(ReplacementTransform(step2_label, step3_label), Transform(integral, evaluation))\n self.wait(2)\n\n # --- Step 4: Simplify the Expression ---\n step4_label = Text(\"Step 4: Simplify the expression\", font_size=32, color=label_color).to_edge(UP)\n \n # Calculate the powers and subtract\n calculation = MathTex(r\"\\frac{16}{4} - 0\", color=math_color).scale(1.5)\n self.play(ReplacementTransform(step3_label, step4_label), Transform(integral, calculation))\n self.wait(2)\n\n # --- Step 5: Final Solution ---\n step5_label = Text(\"Step 5: Final Solution\", font_size=32, color=label_color).to_edge(UP)\n \n # Present the final numerical result\n final_result = MathTex(r\"4\", color=result_color).scale(2).move_to(integral.get_center())\n self.play(ReplacementTransform(step4_label, step5_label), Transform(integral, final_result))\n \n # Highlight the final answer\n box = SurroundingRectangle(integral, color=result_color, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- Configuration ---\n math_color = YELLOW\n label_color = BLUE\n result_color = GREEN\n\n # --- Step 1: Setup the Integral ---\n step1_label = Text(\"Step 1: Set up the definite integral\", font_size=32, color=label_color).to_edge(UP)\n integral = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", color=math_color).scale(1.5)\n \n self.play(Write(step1_label))\n self.play(Write(integral))\n self.wait(2)\n\n # --- Step 2: Apply the Power Rule ---\n step2_label = Text(\"Step 2: Apply the Power Rule\", font_size=32, color=label_color).to_edge(UP)\n \n # Show the general power rule briefly\n rule_text = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36, color=WHITE).next_to(integral, UP, buff=0.5).shift(RIGHT * 3)\n self.play(ReplacementTransform(target_position=ORIGIN, step1_label, step2_label), Write(rule_text))\n self.wait(2)\n\n # Transform the integral into the unsimplified antiderivative\n antiderivative_unsimplified = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", color=math_color).scale(1.5)\n self.play(FadeOut(rule_text), Transform(integral, antiderivative_unsimplified))\n self.wait(1)\n\n # Simplify the exponents and denominator\n antiderivative_simplified = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", color=math_color).scale(1.5)\n self.play(Transform(integral, antiderivative_simplified))\n self.wait(2)\n\n # --- Step 3: Evaluate at the Bounds ---\n step3_label = Text(\"Step 3: Evaluate at the bounds\", font_size=32, color=label_color).to_edge(UP)\n \n # Substitution of upper and lower bounds\n evaluation = MathTex(r\"\\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", color=math_color).scale(1.5)\n self.play(ReplacementTransform(step2_label, step3_label), Transform(integral, evaluation))\n self.wait(2)\n\n # --- Step 4: Simplify the Expression ---\n step4_label = Text(\"Step 4: Simplify the expression\", font_size=32, color=label_color).to_edge(UP)\n \n # Calculate the powers and subtract\n calculation = MathTex(r\"\\frac{16}{4} - 0\", color=math_color).scale(1.5)\n self.play(ReplacementTransform(step3_label, step4_label), Transform(integral, calculation))\n self.wait(2)\n\n # --- Step 5: Final Solution ---\n step5_label = Text(\"Step 5: Final Solution\", font_size=32, color=label_color).to_edge(UP)\n \n # Present the final numerical result\n final_result = MathTex(r\"4\", color=result_color).scale(2).move_to(integral.get_center())\n self.play(ReplacementTransform(step4_label, step5_label), Transform(integral, final_result))\n \n # Highlight the final answer\n box = SurroundingRectangle(integral, color=result_color, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational ManimCE animation on 'Euler's Totient Function' (Unveiling Patterns: Euler's Totient Function): What patterns emerge in the Euler's Totient Function when plotted for the sequence of natural numbers?\nVisual style guidance: A harmonious blend of dark blues and bright oranges, contrast creates an engaging and clear depiction, with fluid animations drawing attention to key concepts and mathematical beauty.", "chosen": "```python\nfrom manim import *\n\nclass EulersTotientFunction(Scene):\n def construct(self):\n # Color Definitions\n DARK_BLUE = \"#1874CD\"\n BRIGHT_ORANGE = \"#FFA600\"\n\n # Title\n title = Text(\n \"Unveiling Patterns:\\nEuler's Totient Function\",\n font_size=36,\n color=WHITE\n ).to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n\n # Explanation text\n explanation_text = Tex(\"The function $\\\\phi(n)$ represents the number\", \n \"of integers up to n that are coprime to n.\")\n explanation_text.to_edge(DOWN).set_color(WHITE)\n explanation_text.scale(0.8)\n self.play(Write(explanation_text))\n\n # Create axes\n axes = Axes(\n x_range=[1, 10, 1],\n y_range=[0, 10, 1],\n x_length=8,\n y_length=6,\n tips=False\n )\n axes.set_colors(YELLOW)\n axes.shift(LEFT * 2 + DOWN * 1)\n\n labels = axes.get_axis_labels(Text(\"n\"), Text(\"$\\\\phi(n)$\"))\n self.add(axes, labels)\n \n phi_values = [1, 1, 2, 2, 4, 2, 6, 4, 6]\n \n dots = []\n for i, val in enumerate(phi_values):\n dot = Dot(axes.c2p(i+1, val), radius=0.15, color=ORANGE)\n dots.append(dot)\n\n # Plot points sequentially while highlighting the current value\n for i in range(len(dots)):\n self.play(Create(dots[i]))\n \n if i != len(dots) - 1:\n line_start = axes.c2p(i+1, phi_values[i])\n line_end = axes.c2p((i+1)+1, phi_values[i+1])\n \n # Draw lines between data points to show pattern progression\n line = Line(line_start, line_end, stroke_width=2)\n line.set_stroke(color=DARK_BLUE, opacity=0.7)\n self.play(Create(line), run_time=0.5)\n \n # Highlight the current point briefly during transition\n self.play(\n dots[i].animate.set_fill(PURPLE, opacity=0.8),\n rate_func=there_and_back,\n run_time=0.3\n )\n\n else:\n # Final highlight for clarity at end\n self.play(\n dots[i].animate.set_fill(PURPLE, opacity=0.8),\n run_time=0.8\n )\n\n self.wait(2)\n self.play(FadeOut(VGroup(*dots)), FadeOut(axes), FadeOut(labels), FadeOut(explanation_text), FadeOut(title))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersTotientFunction(Scene):\n def construct(self):\n # --- Color Palette ---\n BLUE_D = \"#287DC6\"\n ORANGE = \"#FFA800\"\n\n # Title\n title = Text(\"Unveiling Patterns: Euler's Totient Function\", font_size=34).to_edge(UP)\n \n # Define phi(n) for n from 1 to 10 using Euler's formula\n values = [phi(i) for i in range(1, 11)]\n\n # Create axes for plotting\n axes = Axes(\n x_range=[0, 11, 1],\n y_range=[0, max(values)+1, 1],\n tips=False,\n x_length=8,\n y_length=4.5\n ).shift(DOWN*1.5)\n\n axis_labels = axes.get_axis_labels(x_label=\"n\", y_label=\"\\phi(n)\")\n\n # Plot data points\n dots = VGroup()\n lines = VGroup()\n\n for i, val in enumerate(range(1, 11)):\n dot_color = BLUE_D if is_prime(val) else ORANGE\n\n point = Dot(axes.c2p(i + 1, values[i]), color=dot_color, radius=0.08)\n \n line_start = axes.c2p(i, 0)\n line_end = axes.c2p(i + 1, values[i])\n \n line = Line(line_start, line_end, stroke_width=2, color=ORANGE, stroke_opacity=i == 0)\n\n dots.add(point)\n lines.add(line)\n\n # Add gridlines for better context\n grid = NumberPlane(\n x_range=(-1, 11),\n y_range=(0, max(values)+2),\n background_line_style={\n \"stroke_color\": BLUE_D,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n ).add_coordinates().scale_to_fit_height(4.5).to_edge(LEFT).shift(DOWN*1.5)\n\n pattern_text = Tex(\n r\"\\textcolor{blue}{Prime } \\cdot \\mathcal{T}(n)\\textcolor{orange}{{\\rm{-Smooth}}} \\\\ \"\n r\"Primes create gaps, Composite gaps yield prime multiples\",\n font_size=24\n ).next_to(dots, DOWN, buff=0.8).set_color_by_tex(\"\\\\textcolor{blue}\", BLUE_D).set_color_by_tex(\"\\\\textcolor{orange}\", ORANGE)\n\n self.play(FadeIn(title))\n self.wait(0.5)\n \n # Draw Grid Lines\n self.play(Create(grid), run_time=2)\n\n # Animate Axes\n self.play(Create(axis_labels), run_time=1.5)\n self.wait(0.5)\n\n # Animate Points\n self.play(LaggedStart(*[Write(dot) for dot in dots], lag_ratio=0.1))\n \n # Connect Dots with Smooth Curves instead of straight lines\n curves = VGroup()\n for i in range(len(lines)-1):\n curve = VMobject(color=ORANGE).set_points_as_corners([lines[i].get_start(), lines[(i+1)].get_end()])\n curves.add(curve)\n\n self.play(Create(curves), run_time=2.5)\n\n self.wait(0.5)\n \n # Display Pattern Explanation\n self.play(Write(pattern_text), run_time=2.5)\n self.wait(2)\n \n # Fade out everything at end\n self.play(FadeOut(VGroup(*self.mobjects)))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that visually demonstrates the Pythagorean theorem? It should include the equation \"a^2 + b^2 = c^2\" written out, followed by a right triangle appearing on the screen. Next, can you show squares being formed on each side of the triangle to represent \"a^2\", \"b^2\", and \"c^2\" respectively? I'd also like two separate pieces of text that explain the concept: one that says \"Consider squares on each side\" and another that changes to say \"Area of c^2 is equal to sum of a^2 and b^2\". To conclude, can you transform the original equation into a final statement at the bottom of the screen, clear everything else, and then rewrite the equation one more time to emphasize the conclusion? Include pauses in the animation to allow the viewer to understand each step.", "chosen": "```python\nfrom manim import *\n\n# From manim import *\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display Equation ---\n equation = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\")\n self.play(Write(equation))\n self.wait(2)\n\n # --- Step 2: Create Triangle ---\n # Define vertices for a 3-4-5 right triangle\n vertex_a = ORIGIN\n vertex_b = RIGHT * 3\n vertex_c = UP * 4\n \n triangle = Polygon(vertex_a, vertex_b, vertex_c)\n \n # Add labels to sides opposite angles A, B, C where angle C is the right angle\n label_c = MathTex(\"c\").next_to(triangle.get_edge_center(UP), DOWN, buff=0.1)\n label_a = MathTex(\"a\").next_to(triangle.get_vertices()[0], LEFT, buff=0.1).shift(DOWN * 0.3)\n label_b = MathTex(\"b\").next_to(triangle.get_vertices()[0], DOWN, buff=0.1).shift(RIGHT * 0.3)\n \n self.play(Create(triangle), Write(label_c), Write(label_a), Write(label_b))\n self.wait(2)\n\n # --- Step 3: Form Squares ---\n # Square A^2\n square_a = RoundedRectangle(width=3, height=3, corner_radius=0.1)\n square_a.move_to([vertex_a[0], vertex_a[1], 0])\n \n # Square B^2\n square_b = RoundedRectangle(width=4, height=4, corner_radius=0.1)\n square_b.move_to([vertex_a[0], vertex_a[1], 0]) # Position relative to the right-angle vertex\n \n # Square C^2\n square_c = Rectangle(height=5, width=5) # Width matches c length exactly \n square_c.next_to(square_a, UR, buff=0) # Aligns perfectly since a=3,b=4,c=5\n\n self.play(\n TransformFromCopy(triangle, square_a),\n TransformFromCopy(triangle, square_b),\n TransformFromCopy(triangle, square_c),\n )\n self.wait(2)\n\n # --- Step 4: Explain Concept ---\n explanation_text1 = Text(\"Consider squares on each side\", font_size=28).to_edge(UP)\n explanation_text2 = Text(\"Area of c^2 equals sum of a^2 and b^2\", font_size=28).to_edge(UP)\n \n self.play(Write(explanation_text1))\n self.wait(1)\n self.play(Transform(explanation_text1, explanation_text2))\n self.wait(2)\n\n # Clear intermediate elements from screen\n self.play(FadeOut(triangle), FadeOut(label_c), FadeOut(label_a), FadeOut(label_b))\n\n # --- Step 6: Final Transformation ---\n final_statement = MathTex(\"\\\\text{Area of } c^2 \\\\rightarrow \\\\sum\\\\limits_{i=a}^{b}\")\n final_statement.to_edge(DOWN, buff=1)\n \n # Animate transformation of the initial equation to the final statement\n self.play(ReplacementTransform(equation.copy(), final_statement))\n \n # Emphasize the conclusion by changing color and scaling up\n self.play(final_statement.animate.scale(1.5).set_color(YELLOW))\n \n # Hold the final state briefly\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\n title_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.5)\n self.play(Write(title_eq))\n self.wait(2)\n\n # --- Step 2: Create Triangle ---\n # Right angle triangle with sides labeled for clarity\n triangle_vertices = [\n ORIGIN,\n RIGHT * 4,\n UP * 3 + RIGHT * 4,\n ]\n triangle = Polygon(\n *triangle_vertices,\n color=BLUE,\n fill_opacity=0.3\n )\n \n # Label the sides based on their lengths\n labels = VGroup()\n for i, start_point in enumerate(triangle_vertices[:-1]):\n end_point = triangle_vertices[i+1]\n \n # Calculate direction vector and rotate it 90 degrees counter-clockwise for labeling position\n direction_vector = (end_point - start_point).normalize()\n label_pos = start_point + direction_vector.rotate(-PI/2) * 0.8\n \n if i == 2:\n # Hypotenuse: C\n label_text = MathTex(\"c\")\n elif i == 0:\n # Side adjacent to hypotenuse (A)\n label_text = MathTex(\"a\")\n else:\n # Side opposite to A (B)\n label_text = MathTex(\"b\")\n \n label_text.next_to(label_pos, LEFT, buff=0.1)\n labels.add(label_text)\n \n # Animate the creation of both the triangle and its labels\n self.play(Create(triangle), Write(labels))\n self.wait(2)\n\n # --- Step 3: Form Squares on Each Side ---\n # Square on 'a' side (adjacent to hypotenuse)\n square_a = Square(side_length=4, color=GREEN)\n square_a.move_to([4, 1.5, 0])\n \n # Square on 'b' side (opposite to 'a')\n square_b = Square(side_length=3, color=YELLOW)\n square_b.move_to([1.5, 2.5, 0])\n\n # Area representation for 'c'\n area_c = Rectangle(width=7.6, height=6.1, color=RED)\n area_c.move_to([2.3, 0.8, 0]) \n area_c.shift(RIGHT*0.3)\n \n self.play(FadeIn(square_a), FadeIn(square_b), FadeIn(area_c))\n self.wait(2)\n\n # --- Step 4: Add Explanatory Text ---\n text_explain = Text(\"Consider squares on each side\", font_size=28).to_edge(UP)\n self.play(Write(text_explain))\n\n self.wait(2)\n\n # Change text to second explanation\n text_change = Text(\"Area of $c^2$ is equal to sum of $a^2$ and $b^2$\", font_size=28).to_edge(UP)\n self.play(Transform(text_explain, text_change))\n\n # Move equations up to make room for the conclusion\n self.play(\n title_eq.animate.to_edge(DOWN),\n text_explain.animate.to_edge(UP)\n )\n\n self.wait(2)\n\n # --- Step 5: Transform Original Equation and Emphasize Conclusion ---\n # Clear intermediate shapes to make space for the final result\n self.play(\n FadeOut(triangle), \n FadeOut(labels), \n FadeOut(square_a), \n FadeOut(square_b), \n FadeOut(area_c),\n )\n \n # Prepare final emphasis\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.8)\n final_box = SurroundingRectangle(final_eq, color=WHITE, buff=0.2)\n final_title = Text(\"Pythagorean Theorem Proved Visually\", font_size=30).next_to(final_eq, DOWN)\n \n self.play(Write(final_eq), run_time=1.5)\n self.play(Create(final_box), write(final_title), run_time=1.5)\n self.wait(3)\n\n# To render this animation, save the file as pyth_theo.py and run:\n# manim -pql pyth_theo.py PythagoreanTheorem\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 before fading out. Also, I want the molecule to be shown with a double bond between the atoms.", "chosen": "```python\nfrom manim import *\n\nclass OxygenMolecule(Scene):\n def construct(self):\n # Create circles for the oxygen atoms (red)\n atom_a = Circle(radius=0.8, color=RED).shift(LEFT*2)\n atom_b = Circle(radius=0.8, color=RED).shift(RIGHT*2)\n\n # Create a line representing the double bond between them\n bond = Line(atom_a.get_right(), atom_b.get_left())\n \n # Group everything so it can animate simultaneously\n molecule_group = VGroup(atom_a, atom_b, bond).move_to(ORIGIN)\n\n # --- Step 1: Fade In ---\n self.play(FadeIn(molecule_group))\n\n # --- Step 2: Rotation ---\n # Rotate the group by 90 degrees about its center of mass\n self.play(\n Rotate(molecule_group, angle=PI/2),\n run_time=2,\n rate_func=smooth\n )\n\n # --- Step 3: Scaling Up ---\n # Scale both the atoms and the bond to double their original sizes\n self.play(\n atom_a.animate.scale(2),\n atom_b.animate.scale(2),\n bond.animate.scale(2),\n run_time=2,\n rate_func=smooth\n )\n \n # --- Step 4: Fade Out ---\n # Remove the molecules from the screen smoothly\n self.play(FadeOut(molecule_group))\n```", "rejected": "```python\nfrom manim import *\n\nclass OxygenMoleculeFormation(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Colors for visual clarity\n atom_color = RED\n bond_color = WHITE\n \n # Initial sizes and positions\n initial_scale = 0.7\n final_scale = 2.0\n\n # Create the atomic structures\n # Simple circles represent the atoms\n atom_left = Circle(radius=0.8, color=atom_color).shift(LEFT*2)\n atom_right = Circle(radius=0.8, color=atom_color).shift(RIGHT*2)\n\n # Define the middle line of the bond\n bond_path = Line(start=-2.6, end=2.6)\n bond_path.set_stroke(color=bond_color, width=2)\n \n # Add bonds on both sides of the central path to simulate a double bond\n bond_left_up = DashedLine(\n start=Point(-2.6, 0.5),\n end=Point(-1.0, 0.5),\n stroke_width=2,\n dash_length=0.1\n )\n bond_left_down = DashedLine(\n start=Point(-2.6, -0.5),\n end=Point(-1.0, -0.5),\n stroke_width=2,\n dash_length=0.1\n )\n\n # Group everything so we can animate the entire unit at once\n molecule_group = VGroup(atom_left, atom_right, bond_path, bond_left_up, bond_left_down)\n\n # --- Step 1: Fade In ---\n self.play(FadeIn(molecule_group))\n self.wait(1)\n\n # --- Step 2: Rotation ---\n # Rotate the whole group around its center point\n self.play(Rotate(molecule_group, angle=PI, about_point=molecule_group.get_center()), run_time=1.5)\n self.wait(1)\n\n # --- Step 3: Scaling Up ---\n self.play(\n atom_left.animate.scale(final_scale / initial_scale).set_fill(opacity=0),\n atom_right.animate.scale(final_scale / initial_scale).set_fill(opacity=0),\n RunTime(1)\n )\n \n self.play(\n atom_left.animate.move_to(ORIGIN + LEFT * 2).scale(initial_scale),\n atom_right.animate.move_to(ORIGIN + RIGHT * 2).scale(initial_scale),\n RunTime(1)\n )\n \n self.wait(1)\n self.play(\n atom_left.animate.scale(2),\n atom_right.animate.scale(2),\n bond_path.animate.scale(2),\n bond_left_up.animate.scale(2),\n bond_left_down.animate.scale(2),\n run_time=1\n )\n self.wait(1)\n\n # --- Final Step: Fade Out ---\n # Animate the mobject disappearing from the screen\n self.play(FadeOut(molecule_group))\n\n# To render this animation, save it as 'oxygen_molecule.py' and run:\n# manim -pql oxygen_molecule.py OxygenMoleculeFormation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows how to find the area under the curve of the function x^2 from x=1 to x=3, including the steps of calculating the integral, plugging in the upper and lower limits, evaluating those, and then presenting the final solution?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Setup Axes and Graph ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True},\n x_length=6,\n y_length=5\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 3.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(0.5)\n\n # --- 2. Highlight Area Under Curve ---\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n line_1 = axes.get_vertical_line(axes.c2p(1, func(1)), color=WHITE)\n line_3 = axes.get_vertical_line(axes.c2p(3, func(3)), color=WHITE)\n \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 self.play(Create(line_1), Create(line_3), Write(label_1), Write(label_3))\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # --- 3. Integral Setup ---\n step1 = MathTex(r\"\\text{Area} = \\int_{1}^{3} x^2 \\, dx\").move_to(RIGHT * 3 + UP * 2)\n self.play(Write(step1))\n self.wait(1)\n\n # --- 4. Step-by-Step Calculation ---\n # Antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\").next_to(step1, DOWN, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n\n # Plug in limits\n step3 = MathTex(r\"= \\left( \\frac{3^3}{3} \\right) - \\left( \\frac{1^3}{3} \\right)\").next_to(step2, DOWN, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(1)\n\n # Evaluate arithmetic\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\").next_to(step3, DOWN, aligned_edge=LEFT)\n self.play(Write(step4))\n self.wait(1)\n\n # --- 5. Final Solution ---\n step5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\").next_to(step4, DOWN, aligned_edge=LEFT)\n step5.set_color(YELLOW)\n \n result_box = SurroundingRectangle(step5, color=YELLOW, buff=0.2)\n \n self.play(Write(step5))\n self.play(Create(result_box), Indicate(step5, color=YELLOW))\n \n # Final emphasis on the area and result\n self.play(\n area.animate.set_opacity(0.8),\n step5.animate.scale(1.2)\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Setup Axes and Graph ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True},\n x_length=6,\n y_length=5\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 3.5], color=BBLUE)\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(0.5)\n\n # --- 2. Highlight Area Under Curve ---\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n line_1 = axes.get_vertical_line(axes.c2p(1, func(1)), color=WHITE)\n line_3 = axes.get_vertical_line(axes.c2p(3, func(3)), color=WHITE)\n \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 self.play(Create(line_1), Create(line_3), Write(label_1), Write(label_3))\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # --- 3. Integral Setup ---\n step1 = MathTex(r\"\\text{Area} = \\int_{1}^{3} x^2 \\, dx\").move_to(RIGHT * 3 + UP * 2)\n self.play(Write(step1))\n self.wait(1)\n\n # --- 4. Step-by-Step Calculation ---\n # Antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\").next_to(step1, DOWN, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n\n # Plug in limits\n step3 = MathTex(r\"= \\left( \\frac{3^3}{3} \\right) - \\left( \\frac{1^3}{3} \\right)\").next_to(step2, DOWN, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(1)\n\n # Evaluate arithmetic\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\").next_to(step3, DOWN, aligned_edge=LEFT)\n self.play(Write(step4))\n self.wait(1)\n\n # --- 5. Final Solution ---\n step5 = MathTex(r\"= \\frac{26}{3} \\approx 8.67\").next_to(step4, DOWN, aligned_edge=LEFT)\n step5.set_color(YELLOW)\n \n result_box = SurroundingRectangle(step5, color=YELLOW, buff=0.2)\n \n self.play(Write(step5))\n self.play(Create(result_box), Indicate(step5, color=YELLOW))\n \n # Final emphasis on the area and result\n self.play(\n area.animate.set_opacity(0.8),\n step5.animate.scale(1.2)\n )\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an educational animation that visually demonstrates the concept of finding the area under a curve using integral calculus. Specifically, the animation should show the following steps: \n\n1. Display the mathematical function f(x) = x^2 on the screen, preferably at the top.\n2. Plot the graph of this quadratic function from x = 0 to x = 2.\n3. Shade the area under the curve between x = 0 and x = 2 to illustrate the concept of integration visually.\n4. Introduce the integral calculus notation for the function's definite integral from 0 to 2.\n5. Show the step-by-step calculation of this integral, starting with the application of the integral formula.\n6. Evaluate the resulting expression at the upper and lower limits of the integral to find the numerical value of the area.\n7. Finally, clear the screen and display only the evaluated result of the integral, which is the exact area under the curve within the specified range.\n\nCan you create an animation that includes all of these educational elements using smooth transitions and suitable waiting times between each step for better understanding?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display Function\n # Show the mathematical function f(x) = x^2 prominently at the top.\n # ------------------------------------------------------------------\n func_title = MathTex(r\"f(x) = x^2\").scale(1.2)\n func_title.to_edge(UP)\n self.play(Write(func_title))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Plot Graph\n # Plot the graph of the quadratic function over the domain x = 0 to x = 2.\n # Axes are set slightly wider for visual clarity.\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [0, 1, 2, 3, 4]},\n ).shift(DOWN * 0.5)\n\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"x^2\", x_val=2, direction=UR)\n \n self.play(Create(axes), Create(graph))\n self.play(Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Shade Area\n # Visually shade the region under the curve between x = 0 and x = 2.\n # ------------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n self.play(FadeIn(area))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Show Notation\n # Introduce the definite integral notation for the function from limits 0 to 2.\n # Positioned to the right of the graph to avoid overlap.\n # ------------------------------------------------------------------\n integral_notation = MathTex(r\"\\text{Area} = \\int_0^2 x^2 \\, dx\")\n integral_notation.shift(RIGHT * 3 + UP * 1)\n self.play(Write(integral_notation))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Step-by-Step Calculation\n # Animate the application of the power rule for integration.\n # ------------------------------------------------------------------\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\")\n step1.next_to(integral_notation, DOWN, aligned_edge=LEFT)\n self.play(Write(step1))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Evaluate Limits\n # Demonstrate the evaluation of the resulting expression at the limits.\n # ------------------------------------------------------------------\n step2 = MathTex(r\"= \\left( \\frac{2^3}{3} \\right) - \\left( \\frac{0^3}{3} \\right)\")\n step2.next_to(step1, DOWN, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n \n step3 = MathTex(r\"= \\frac{8}{3} - 0 = \\frac{8}{3}\")\n step3.next_to(step2, DOWN, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 7: Final Result\n # Clear the screen and display only the final evaluated result.\n # ------------------------------------------------------------------\n all_elements = VGroup(\n func_title, axes, graph, graph_label, \n area, integral_notation, step1, step2, step3\n )\n \n self.play(FadeOut(all_elements))\n \n final_result = MathTex(r\"\\text{Area} = \\frac{8}{3} \\approx 2.67\", color=BLUE).scale(1.5)\n self.play(Write(final_result))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display Function\n # Show the mathematical function f(x) = x^2 prominently at the top.\n # ------------------------------------------------------------------\n func_title = MathTex(r\"f(x) = x^2\").scale(1.2)\n func_title.to_edge(UP)\n self.play(Write(func_title))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Plot Graph\n # Plot the graph of the quadratic function over the domain x = 0 to x = 2.\n # Axes are set slightly wider for visual clarity.\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_include\": [0, 1, 2]},\n y_axis_config={\"numbers_to_include\": [0, 1, 2, 3, 4]},\n ).shift(DOWN * 0.5)\n\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=BBLUE)\n graph_label = axes.get_graph_label(graph, label=\"x^2\", x_val=2, direction=UR)\n \n self.play(Create(axes), Create(graph))\n self.play(Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Shade Area\n # Visually shade the region under the curve between x = 0 and x = 2.\n # ------------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n self.play(FadeIn(area))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Show Notation\n # Introduce the definite integral notation for the function from limits 0 to 2.\n # Positioned to the right of the graph to avoid overlap.\n # ------------------------------------------------------------------\n integral_notation = MathTex(r\"\\text{Area} = \\int_0^2 x^2 \\, dx\")\n integral_notation.shift(RIGHT * 3 + UP * 1)\n self.play(Write(integral_notation))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Step-by-Step Calculation\n # Animate the application of the power rule for integration.\n # ------------------------------------------------------------------\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_0^2\")\n step1.next_to(integral_notation, DOWN, aligned_edge=LEFT)\n self.play(Write(step1))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Evaluate Limits\n # Demonstrate the evaluation of the resulting expression at the limits.\n # ------------------------------------------------------------------\n step2 = MathTex(r\"= \\left( \\frac{2^3}{3} \\right) - \\left( \\frac{0^3}{3} \\right)\")\n step2.next_to(step1, DOWN, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n \n step3 = MathTex(r\"= \\frac{8}{3} - 0 = \\frac{8}{3}\")\n step3.next_to(step2, DOWN, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 7: Final Result\n # Clear the screen and display only the final evaluated result.\n # ------------------------------------------------------------------\n all_elements = VGroup(\n func_title, axes, graph, graph_label, \n area, integral_notation, step1, step2, step3\n )\n \n self.play(FadeOut(all_elements))\n \n final_result = MathTex(r\"\\text{Area} = \\frac{8}{3} \\approx 2.67\", color=BLUE).scale(1.5)\n self.play(Write(final_result))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Display a stationary line from left to right. Show a second line rotating around a point on the left, forming an angle with the stationary line. Label the angle with the Greek letter theta (θ). Animate the rotating line to change its angle, updating the angle and its label dynamically. Change the color of the theta label to red briefly.", "chosen": "```python\nfrom manim import *\n\nclass MovingAngle(Scene):\n def construct(self):\n rotation_center = LEFT\n\n theta_tracker = ValueTracker(110)\n line1 = Line(LEFT, RIGHT)\n line_moving = Line(LEFT, RIGHT)\n line_ref = line_moving.copy()\n line_moving.rotate(\n theta_tracker.get_value() * DEGREES, about_point=rotation_center\n )\n a = Angle(line1, line_moving, radius=0.5, other_angle=False)\n tex = MathTex(r\"\\theta\").move_to(\n Angle(\n line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False\n ).point_from_proportion(0.5)\n )\n\n self.add(line1, line_moving, a, tex)\n self.wait()\n\n line_moving.add_updater(\n lambda x: x.become(line_ref.copy()).rotate(\n theta_tracker.get_value() * DEGREES, about_point=rotation_center\n )\n )\n\n a.add_updater(\n lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))\n )\n tex.add_updater(\n lambda x: x.move_to(\n Angle(\n line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False\n ).point_from_proportion(0.5)\n )\n )\n\n self.play(theta_tracker.animate.set_value(40))\n self.play(theta_tracker.animate.increment_value(140))\n self.play(tex.animate.set_color(RED), run_time=0.5)\n self.play(theta_tracker.animate.set_value(350))\n```", "rejected": "```python\nfrom manim import *\n\nclass MovingAngle(Scene):\n def construct(self):\n rotation_center = LEFT\n\n theta_tracker = ValueTracker(110)\n line1 = Line(LEFT, RIGHT)\n line_moving = Line(LEFT, RIGHT)\n line_ref = line_moving.copy()\n line_moving.rotate(\n theta_tracker.get_value() * DEGREES, about_point=rotation_center\n )\n a = Angle(line1, line_moving, radius=0.5, other_angle=False)\n tex = MathTex(r\"\\theta\" + \" = x\").move_to(\n Angle(\n line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False\n ).point_from_proportion(0.5)\n )\n\n self.add(line1, line_moving, a, tex)\n self.wait()\n\n line_moving.add_updater(\n lambda x: x.become(line_ref.copy()).rotate(\n theta_tracker.get_value() * DEGREES, about_point=rotation_center\n )\n )\n\n a.add_updater(\n lambda x: x.become(Angle(line1, line_moving, radius=0.5, other_angle=False))\n )\n tex.add_updater(\n lambda x: x.move_to(\n Angle(\n line1, line_moving, radius=0.5 + 3 * SMALL_BUFF, other_angle=False\n ).point_from_proportion(0.5)\n )\n )\n\n self.play(theta_tracker.animate.set_value(40))\n self.play(theta_tracker.animate.increment_value(140))\n self.play(tex.animate.set_color(RED), run_time=0.5)\n self.play(theta_tracker.animate.set_value(350))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can bifurcation diagrams be used to analyze the behavior of nonlinear equation systems?", "chosen": "```python\nfrom manim import *\n\nclass BifurcationDiagramScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Mapping Chaos: Bifurcation Diagrams\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Element 1: Chaotic vs stable states visualization\n chaos_dots = VGroup()\n for _ in range(10):\n dot = Dot(radius=0.05, color=BLUE)\n dot.move_to(3 * np.array([\n np.random.uniform(-1, 1),\n np.random.uniform(-1, 1),\n 0\n ]))\n chaos_dots.add(dot)\n \n stable_center = Dot(color=ORANGE, radius=0.2)\n \n self.play(Create(chaos_dots))\n self.wait(0.5)\n self.play(chaos_dots.animate.move_to(ORIGIN))\n self.play(ReplacementTransform(chaos_dots, stable_center))\n self.wait(1)\n \n # Clear screen\n self.play(FadeOut(stable_center))\n \n # Element 2: Parameter changes affecting system behavior\n axes = Axes(\n x_range=[0, 1, 0.5],\n y_range=[0, 1, 0.5],\n axis_config={\"color\": WHITE}\n )\n \n # Initial curve with r=2.0\n initial_curve = axes.plot(lambda x: 2 * x * (1 - x), color=BLUE)\n r_label = Text(\"r = 2.0\", font_size=24).to_corner(UR)\n \n self.play(Create(axes))\n self.play(Create(initial_curve), Write(r_label))\n \n # Changed curve with r=3.2\n changed_curve = axes.plot(lambda x: 3.2 * x * (1 - x), color=ORANGE)\n new_r_label = Text(\"r = 3.2\", font_size=24).to_corner(UR)\n \n self.play(ReplacementTransform(initial_curve, changed_curve),\n ReplacementTransform(r_label, new_r_label))\n self.wait(1)\n \n # Clear screen\n self.play(FadeOut(axes), FadeOut(changed_curve), FadeOut(new_r_label))\n \n # Element 3: Bifurcation diagram\n bif_axes = Axes(\n x_range=[2.8, 4.0, 0.2],\n y_range=[0, 1, 0.2],\n axis_config={\"color\": WHITE}\n )\n \n x_label = Text(\"Parameter (r)\", font_size=24).next_to(bif_axes, DOWN)\n y_label = Text(\"State (x)\", font_size=24).next_to(bif_axes, LEFT).rotate(PI/2)\n \n self.play(Create(bif_axes))\n self.play(Write(x_label), Write(y_label))\n \n # Stable fixed point line\n stable_line = Line(bif_axes.c2p(2.8, 0.65), bif_axes.c2p(3.0, 0.67), color=BLUE)\n stable_label = Text(\"Stable\", font_size=20, color=BLUE).next_to(bif_axes.c2p(2.9, 0.65), UP)\n \n # First bifurcation point\n bif_point = Dot(bif_axes.c2p(3.0, 0.67), color=RED)\n bif_label = Text(\"Bifurcation\", font_size=20, color=RED).next_to(bif_point, UP)\n \n # Period-2 branches\n upper_branch = Line(bif_axes.c2p(3.0, 0.67), bif_axes.c2p(3.5, 0.8), color=BLUE)\n lower_branch = Line(bif_axes.c2p(3.0, 0.67), bif_axes.c2p(3.5, 0.5), color=BLUE)\n period2_label = Text(\"Period-2\", font_size=20, color=BLUE).next_to(bif_axes.c2p(3.3, 0.65), UP)\n \n # Chaotic region (simplified)\n chaos_dots = VGroup()\n for r in [3.6, 3.8]:\n for y in [0.3, 0.5, 0.7]:\n chaos_dots.add(Dot(bif_axes.c2p(r, y), radius=0.03, color=BLUE))\n \n chaos_label = Text(\"Chaos\", font_size=20, color=ORANGE).next_to(bif_axes.c2p(3.8, 0.5), RIGHT)\n \n # Animate the diagram building up\n self.play(Create(stable_line), Write(stable_label))\n self.wait(0.5)\n self.play(FadeIn(bif_point), Write(bif_label))\n self.wait(0.5)\n self.play(Create(upper_branch), Create(lower_branch), Write(period2_label))\n self.wait(0.5)\n self.play(FadeIn(chaos_dots), Write(chaos_label))\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(bif_axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(stable_line), FadeOut(stable_label),\n FadeOut(bif_point), FadeOut(bif_label),\n FadeOut(upper_branch), FadeOut(lower_branch), FadeOut(period2_label),\n FadeOut(chaos_dots), FadeOut(chaos_label)\n )\n \n # Element 4: Key equations\n eq1 = MathTex(r\"\\frac{dx}{dt} = r x (1-x)\")\n eq2 = MathTex(r\"\\frac{dy}{dt} = y - x^2\")\n \n eq1.shift(UP)\n eq2.shift(DOWN)\n \n self.play(Write(eq1))\n self.wait(0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(eq1), FadeOut(eq2))\n \n conclusion = Text(\n \"Bifurcation diagrams reveal how nonlinear systems\\ntransition from stability to chaos.\",\n font_size=24\n )\n conclusion.next_to(title, DOWN, buff=1.5)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fadeout\n self.play(FadeOut(title), FadeOut(conclusion))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass BifurcationDiagramScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Mapping Chaos: Bifurcation Diagrams\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Element 1: Chaotic vs stable states visualization\n chaos_dots = VGroup()\n for _ in range(10):\n dot = Dot(radius=0.05, color=BLUE)\n dot.move_to(3 * np.array([\n np.random.uniform(-1, 1),\n np.random.uniform(-1, 1),\n 0\n ]))\n chaos_dots.add(dot)\n \n stable_center = Dot(color=ORANGE, radius=0.2)\n \n self.play(Create(chaos_dots))\n self.wait(0.5)\n self.play(chaos_dots.animate.move_to(ORIGIN))\n self.play(ReplacementTransform(chaos_dots, stable_center))\n self.wait(1)\n \n # Clear screen\n self.play(FadeOut(stable_center))\n \n # Element 2: Parameter changes affecting system behavior\n axes = Axes(font_size=24, \n x_range=[0, 1, 0.5],\n y_range=[0, 1, 0.5],\n axis_config={\"color\": WHITE}\n )\n \n # Initial curve with r=2.0\n initial_curve = axes.plot(lambda x: 2 * x * (1 - x), color=BLUE)\n r_label = Text(\"r = 2.0\", font_size=24).to_corner(UR)\n \n self.play(Create(axes))\n self.play(Create(initial_curve), Write(r_label))\n \n # Changed curve with r=3.2\n changed_curve = axes.plot(lambda x: 3.2 * x * (1 - x), color=ORANGE)\n new_r_label = Text(\"r = 3.2\", font_size=24).to_corner(UR)\n \n self.play(ReplacementTransform(initial_curve, changed_curve),\n ReplacementTransform(r_label, new_r_label))\n self.wait(1)\n \n # Clear screen\n self.play(FadeOut(axes), FadeOut(changed_curve), FadeOut(new_r_label))\n \n # Element 3: Bifurcation diagram\n bif_axes = Axes(\n x_range=[2.8, 4.0, 0.2],\n y_range=[0, 1, 0.2],\n axis_config={\"color\": WHITE}\n )\n \n x_label = Text(\"Parameter (r)\", font_size=24).next_to(bif_axes, DOWN)\n y_label = Text(\"State (x)\", font_size=24).next_to(bif_axes, LEFT).rotate(PI/2)\n \n self.play(Create(bif_axes))\n self.play(Write(x_label), Write(y_label))\n \n # Stable fixed point line\n stable_line = Line(bif_axes.c2p(2.8, 0.65), bif_axes.c2p(3.0, 0.67), color=BLUE)\n stable_label = Text(\"Stable\", font_size=20, color=BLUE).next_to(bif_axes.c2p(2.9, 0.65), UP)\n \n # First bifurcation point\n bif_point = Dot(bif_axes.c2p(3.0, 0.67), color=RED)\n bif_label = Text(\"Bifurcation\", font_size=20, color=RED).next_to(bif_point, UP)\n \n # Period-2 branches\n upper_branch = Line(bif_axes.c2p(3.0, 0.67), bif_axes.c2p(3.5, 0.8), color=BLUE)\n lower_branch = Line(bif_axes.c2p(3.0, 0.67), bif_axes.c2p(3.5, 0.5), color=BLUE)\n period2_label = Text(\"Period-2\", font_size=20, color=BLUE).next_to(bif_axes.c2p(3.3, 0.65), UP)\n \n # Chaotic region (simplified)\n chaos_dots = VGroup()\n for r in [3.6, 3.8]:\n for y in [0.3, 0.5, 0.7]:\n chaos_dots.add(Dot(bif_axes.c2p(r, y), radius=0.03, color=BLUE))\n \n chaos_label = Text(\"Chaos\", font_size=20, color=ORANGE).next_to(bif_axes.c2p(3.8, 0.5), RIGHT)\n \n # Animate the diagram building up\n self.play(Create(stable_line), Write(stable_label))\n self.wait(0.5)\n self.play(FadeIn(bif_point), Write(bif_label))\n self.wait(0.5)\n self.play(Create(upper_branch), Create(lower_branch), Write(period2_label))\n self.wait(0.5)\n self.play(FadeIn(chaos_dots), Write(chaos_label))\n self.wait(1)\n \n # Clear screen\n self.play(\n FadeOut(bif_axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(stable_line), FadeOut(stable_label),\n FadeOut(bif_point), FadeOut(bif_label),\n FadeOut(upper_branch), FadeOut(lower_branch), FadeOut(period2_label),\n FadeOut(chaos_dots), FadeOut(chaos_label)\n )\n \n # Element 4: Key equations\n eq1 = MathTex(r\"\\frac{dx}{dt} = r x (1-x)\")\n eq2 = MathTex(r\"\\frac{dy}{dt} = y - x^2\")\n \n eq1.shift(UP)\n eq2.shift(DOWN)\n \n self.play(Write(eq1))\n self.wait(0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(eq1), FadeOut(eq2))\n \n conclusion = Text(\n \"Bifurcation diagrams reveal how nonlinear systems\\ntransition from stability to chaos.\",\n font_size=24\n )\n conclusion.next_to(title, DOWN, buff=1.5)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fadeout\n self.play(FadeOut(title), FadeOut(conclusion))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an educational video for children where they can learn to count using fun, animated gummy bear characters. Can you make a vibrant, eye-catching animation of twelve colorful gummy bears that appear one by one on the screen? They should be arranged in an organized grid and come with cheerful background music. Additionally, it would be great if the video starts with a bright and inviting title that says \"Let's Count Gummy Bears!\" and ends with a text stating \"Total: 12 Bears\" after all the gummy bears have appeared. Make sure the colors are soft and appealing to a young audience, and include a smooth transition for all elements to fade out at the end of the video.", "chosen": "```python\nfrom manim import *\n\n# Define a soft, vibrant pastel color palette appealing to young children\nPASTEL_COLORS = [\n \"#FFB7B2\", # Pastel Pink\n \"#FFDAC1\", # Pastel Peach\n \"#E2F0CB\", # Pastel Lime\n \"#B5EAD7\", # Pastel Green\n \"#C7CEEA\", # Pastel Periwinkle\n \"#FF9AA2\", # Pastel Salmon\n \"#FFB347\", # Pastel Orange\n \"#B39CD0\", # Pastel Violet\n \"#B2E2F2\", # Pastel Blue\n \"#F9D1D1\", # Pastel Rose\n \"#96CDD2\", # Pastel Teal\n \"#B8F2B3\", # Pastel Mint\n]\n\nclass GummyBear(VGroup):\n \"\"\"\n A custom Mobject composed of basic shapes to resemble a gummy bear.\n \"\"\"\n def __init__(self, color=RED, **kwargs):\n super().__init__(**kwargs)\n \n # Body: A rounded rectangle for the main torso\n body = RoundedRectangle(\n corner_radius=0.25, height=1.0, width=0.7,\n fill_color=color, fill_opacity=1, stroke_width=0\n )\n \n # Head: A circle on top of the body\n head = Circle(\n radius=0.35, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, UP, buff=0)\n \n # Ears: Two small circles on the head\n ear_left = Circle(\n radius=0.15, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(head, UL, buff=0.1)\n \n ear_right = Circle(\n radius=0.15, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(head, UR, buff=0.1)\n \n # Arms: Small rounded rectangles\n arm_left = RoundedRectangle(\n corner_radius=0.1, height=0.4, width=0.15,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, LEFT, buff=0.1).shift(UP * 0.2).rotate(0.5)\n \n arm_right = RoundedRectangle(\n corner_radius=0.1, height=0.4, width=0.15,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, RIGHT, buff=0.1).shift(UP * 0.2).rotate(-0.5)\n \n # Legs: Small rounded rectangles\n leg_left = RoundedRectangle(\n corner_radius=0.1, height=0.3, width=0.2,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, DOWN, buff=0.1).shift(LEFT * 0.15)\n \n leg_right = RoundedRectangle(\n corner_radius=0.1, height=0.3, width=0.2,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, DOWN, buff=0.1).shift(RIGHT * 0.15)\n \n # Combine all parts into a single group\n self.add(body, head, ear_left, ear_right, arm_left, arm_right, leg_left, leg_right)\n\nclass CountingBearsScene(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # AUDIO PLACEHOLDER\n # ------------------------------------------------------------------\n # To add cheerful background music, place an audio file (e.g., 'music.mp3')\n # in the same directory as this script and uncomment the line below.\n # self.add_sound(\"music.mp3\", gain=0.5, loop=True)\n # ------------------------------------------------------------------\n\n # --- 1. INTRO: Title Text ---\n title = Text(\n \"Let's Count Gummy Bears!\",\n font_size=56,\n color=YELLOW\n )\n # Add a vibrant gradient and a soft outline for contrast\n title.set_color_by_gradient(YELLOW, ORANGE, PINK)\n title.set_stroke(color=WHITE, width=2, opacity=0.5)\n \n # Animate Title Entrance and Exit\n self.play(Write(title), run_time=1.5)\n self.play(title.animate.scale(1.2), run_time=0.5)\n self.play(FadeOut(title, shift=UP), run_time=1)\n self.wait(0.5)\n\n # --- 2. COUNTING: Create and Animate 12 Gummy Bears ---\n bears = VGroup()\n \n for i in range(12):\n color = PASTEL_COLORS[i % len(PASTEL_COLORS)]\n bear = GummyBear(color=color)\n bear.scale(0.8)\n bears.add(bear)\n \n # Arrange in a 3 row x 4 column grid centered on the screen\n bears.arrange_in_grid(rows=3, cols=4, buff=1.0)\n bears.center()\n \n # Animate each bear appearing one by one with a fun pop effect\n for bear in bears:\n self.play(GrowFromCenter(bear), run_time=0.4)\n # Brief pause between appearances to allow children to count\n self.wait(0.2)\n \n self.wait(1)\n\n # --- 3. OUTRO: Display Total Count ---\n total_text = Text(\n \"Total: 12 Bears\",\n font_size=48,\n color=WHITE\n )\n total_text.set_color_by_gradient(BLUE_B, GREEN_B)\n total_text.set_stroke(color=BLACK, width=1, opacity=0.5)\n total_text.next_to(bears, DOWN, buff=1.0)\n \n # Animate the text appearing with a pop effect\n self.play(FadeIn(total_text, scale=0.5), run_time=0.8)\n self.play(Indicate(total_text, color=YELLOW), run_time=1)\n self.wait(2)\n\n # --- 4. ENDING: Smooth Fade Out ---\n # Group everything visible to fade out together smoothly\n all_elements = VGroup(bears, total_text)\n self.play(FadeOut(all_elements, scale=0.8), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\n# Define a soft, vibrant pastel color palette appealing to young children\nPASTEL_COLORS = [\n \"#FFB7B2\", # Pastel Pink\n \"#FFDAC1\", # Pastel Peach\n \"#E2F0CB\", # Pastel Lime\n \"#B5EAD7\", # Pastel Green\n \"#C7CEEA\", # Pastel Periwinkle\n \"#FF9AA2\", # Pastel Salmon\n \"#FFB347\", # Pastel Orange\n \"#B39CD0\", # Pastel Violet\n \"#B2E2F2\", # Pastel Blue\n \"#F9D1D1\", # Pastel Rose\n \"#96CDD2\", # Pastel Teal\n \"#B8F2B3\", # Pastel Mint\n]\n\nclass GummyBear(VGroup):\n \"\"\"\n A custom Mobject composed of basic shapes to resemble a gummy bear.\n \"\"\"\n def __init__(self, color=RED, **kwargs):\n super().__init__(**kwargs)\n \n # Body: A rounded rectangle for the main torso\n body = RoundRect(\n corner_radius=0.25, height=1.0, width=0.7,\n fill_color=color, fill_opacity=1, stroke_width=0\n )\n \n # Head: A circle on top of the body\n head = Circle(\n radius=0.35, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, UP, buff=0)\n \n # Ears: Two small circles on the head\n ear_left = Circle(\n radius=0.15, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(head, UL, buff=0.1)\n \n ear_right = Circle(\n radius=0.15, fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(head, UR, buff=0.1)\n \n # Arms: Small rounded rectangles\n arm_left = RoundedRectangle(\n corner_radius=0.1, height=0.4, width=0.15,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, LEFT, buff=0.1).shift(UP * 0.2).rotate(0.5)\n \n arm_right = RoundedRectangle(\n corner_radius=0.1, height=0.4, width=0.15,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, RIGHT, buff=0.1).shift(UP * 0.2).rotate(-0.5)\n \n # Legs: Small rounded rectangles\n leg_left = RoundedRectangle(\n corner_radius=0.1, height=0.3, width=0.2,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, DOWN, buff=0.1).shift(LEFT * 0.15)\n \n leg_right = RoundedRectangle(\n corner_radius=0.1, height=0.3, width=0.2,\n fill_color=color, fill_opacity=1, stroke_width=0\n ).next_to(body, DOWN, buff=0.1).shift(RIGHT * 0.15)\n \n # Combine all parts into a single group\n self.add(body, head, ear_left, ear_right, arm_left, arm_right, leg_left, leg_right)\n\nclass CountingBearsScene(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # AUDIO PLACEHOLDER\n # ------------------------------------------------------------------\n # To add cheerful background music, place an audio file (e.g., 'music.mp3')\n # in the same directory as this script and uncomment the line below.\n # self.add_sound(\"music.mp3\", gain=0.5, loop=True)\n # ------------------------------------------------------------------\n\n # --- 1. INTRO: Title Text ---\n title = Text(\n \"Let's Count Gummy Bears!\",\n font_size=56,\n color=YELLOW\n )\n # Add a vibrant gradient and a soft outline for contrast\n title.set_color_by_gradient(YELLOW, ORANGE, PINK)\n title.set_stroke(color=WHITE, width=2, opacity=0.5)\n \n # Animate Title Entrance and Exit\n self.play(Write(title), run_time=1.5)\n self.play(title.animate.scale(1.2), run_time=0.5)\n self.play(FadeOut(title, shift=UP), run_time=1)\n self.wait(0.5)\n\n # --- 2. COUNTING: Create and Animate 12 Gummy Bears ---\n bears = VGroup()\n \n for i in range(12):\n color = PASTEL_COLORS[i % len(PASTEL_COLORS)]\n bear = GummyBear(color=color)\n bear.scale(0.8)\n bears.add(bear)\n \n # Arrange in a 3 row x 4 column grid centered on the screen\n bears.arrange_in_grid(rows=3, cols=4, buff=1.0)\n bears.center()\n \n # Animate each bear appearing one by one with a fun pop effect\n for bear in bears:\n self.play(GrowFromCenter(bear), run_time=0.4)\n # Brief pause between appearances to allow children to count\n self.wait(0.2)\n \n self.wait(1)\n\n # --- 3. OUTRO: Display Total Count ---\n total_text = Text(\n \"Total: 12 Bears\",\n font_size=48,\n color=WHITE\n )\n total_text.set_color_by_gradient(BLUE_B, GREEN_B)\n total_text.set_stroke(color=BLACK, width=1, opacity=0.5)\n total_text.next_to(bears, DOWN, buff=1.0)\n \n # Animate the text appearing with a pop effect\n self.play(FadeIn(total_text, scale=0.5), run_time=0.8)\n self.play(Indicate(total_text, color=YELLOW), run_time=1)\n self.wait(2)\n\n # --- 4. ENDING: Smooth Fade Out ---\n # Group everything visible to fade out together smoothly\n all_elements = VGroup(bears, total_text)\n self.play(FadeOut(all_elements, scale=0.8), run_time=2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second quantum-physics scene explaining quantized photon absorption. Show two energy levels, send one photon whose energy does not match the gap and one that does, and animate the electron transition only for the matching photon. State that this is a simplified level diagram.", "chosen": "```python\nfrom manim import *\n\nclass QuantizedAbsorption(Scene):\n def construct(self):\n title = Text(\"A transition absorbs a photon only when its energy matches the gap\", font_size=32).to_edge(UP)\n lower = Line(LEFT * 2, RIGHT * 2, color=BLUE_B).shift(DOWN * 1.3)\n upper = Line(LEFT * 2, RIGHT * 2, color=ORANGE).shift(UP * 1.3)\n labels = VGroup(\n Text(\"lower level\", font_size=22, color=BLUE_B).next_to(lower, LEFT),\n Text(\"upper level\", font_size=22, color=ORANGE).next_to(upper, LEFT),\n )\n electron = Dot(lower.get_center(), color=YELLOW, radius=0.13)\n gap = DoubleArrow(lower.get_right() + RIGHT * 0.5, upper.get_right() + RIGHT * 0.5, color=WHITE, buff=0)\n gap_label = Text(\"energy gap\", font_size=21).next_to(gap, RIGHT)\n mismatch = Arrow(LEFT * 5, lower.get_center(), color=RED, buff=0.2)\n mismatch_label = Text(\"photon energy \\neq gap\", font_size=22, color=RED).next_to(mismatch, UP)\n match = Arrow(LEFT * 5, electron.get_center(), color=GREEN, buff=0.2)\n match_label = Text(\"photon energy = gap\", font_size=22, color=GREEN).next_to(match, DOWN)\n caveat = Text(\"Simplified diagram: real systems can have many allowed levels.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(lower), Create(upper), FadeIn(labels, electron), GrowFromCenter(gap), FadeIn(gap_label))\n self.play(GrowArrow(mismatch), FadeIn(mismatch_label), Wiggle(electron))\n self.play(FadeOut(mismatch, mismatch_label))\n self.play(GrowArrow(match), FadeIn(match_label))\n self.play(electron.animate.move_to(upper.get_center()), Flash(upper.get_center(), color=YELLOW), run_time=2)\n self.play(FadeIn(caveat), Circumscribe(electron, color=YELLOW))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass QuantizedAbsorption(Scene):\n def construct(self):\n title = Text(\"A transition absorbs a photon only when its energy matches the gap\", font_size=32).to_edge(UP)\n lower = Line(LEFT * 2, RIGHT * 2, color=BBLUE_B).shift(DOWN * 1.3)\n upper = Line(LEFT * 2, RIGHT * 2, color=ORANGE).shift(UP * 1.3)\n labels = VGroup(\n Text(\"lower level\", font_size=22, color=BLUE_B).next_to(lower, LEFT),\n Text(\"upper level\", font_size=22, color=ORANGE).next_to(upper, LEFT),\n )\n electron = Dot(lower.get_center(), color=YELLOW, radius=0.13)\n gap = DoubleArrow(lower.get_right() + RIGHT * 0.5, upper.get_right() + RIGHT * 0.5, color=WHITE, buff=0)\n gap_label = Text(\"energy gap\", font_size=21).next_to(gap, RIGHT)\n mismatch = Arrow(LEFT * 5, lower.get_center(), color=RED, buff=0.2)\n mismatch_label = Text(\"photon energy \\neq gap\", font_size=22, color=RED).next_to(mismatch, UP)\n match = Arrow(LEFT * 5, electron.get_center(), color=GREEN, buff=0.2)\n match_label = Text(\"photon energy = gap\", font_size=22, color=GREEN).next_to(match, DOWN)\n caveat = Text(\"Simplified diagram: real systems can have many allowed levels.\", font_size=23).to_edge(DOWN)\n\n self.play(Write(title), Create(lower), Create(upper), FadeIn(labels, electron), GrowFromCenter(gap), FadeIn(gap_label))\n self.play(GrowArrow(mismatch), FadeIn(mismatch_label), Wiggle(electron))\n self.play(FadeOut(mismatch, mismatch_label))\n self.play(GrowArrow(match), FadeIn(match_label))\n self.play(electron.animate.move_to(upper.get_center()), Flash(upper.get_center(), color=YELLOW), run_time=2)\n self.play(FadeIn(caveat), Circumscribe(electron, color=YELLOW))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialFunctionScene(Scene):\n def construct(self):\n # --- Step 1: Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Clear the title to make room for axes\n self.play(FadeOut(title))\n\n # --- Step 2: Axes Configuration ---\n # Define ranges specifically for exponential growth visualization\n axes = Axes(\n x_range=[-3, 3, 1], \n y_range=[-1, 8, 2],\n tips=False,\n axis_config={\"color\": BLUE}\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.add(axes, labels)\n self.wait(1)\n\n # --- Step 3: Plotting e^x ---\n exp_curve_e = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-2.5, 2])\n exp_label_e = MathTex(\"e^x\").set_color(GREEN).next_to(exp_curve_e, UR, buff=0.3)\n \n self.play(Create(exp_curve_e), Write(exp_label_e))\n self.wait(2)\n\n # --- Step 4: Replacement with 2^x ---\n exp_curve_2 = axes.plot(lambda x: 2**x, color=RED, x_range=[-2.5, 2])\n exp_label_2 = MathTex(\"2^x\").set_color(RED).move_to([2.3, 2.7, 0]) # Upward movement\n \n # Animate replacement while moving the label for improved readability\n self.play(\n Transform(exp_curve_e, exp_curve_2),\n FadeOut(exp_label_e),\n FadeIn(exp_label_2),\n run_time=1.5\n )\n \n # Hold briefly so viewers can compare the shapes\n self.wait(2)\n\n # --- Step 5: Comparison Mode ---\n # Re-render both curves simultaneously to ensure they overlap perfectly\n combined_curves = VGroup(\n axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-2.5, 2]),\n axes.plot(lambda x: 2**x, color=RED, x_range=[-2.5, 2])\n )\n\n # Add labels back individually for clarity during overlap\n combined_labels = VGroup(\n MathTex(\"e^x\").set_color(GREEN).next_to(combined_curves[0], UR, buff=0.3),\n MathTex(\"2^x\").set_color(RED).move_to([2.3, 2.7, 0])\n )\n\n # Simultaneously replace old graph with combined ones\n self.play(\n FadeOut(axes), \n FadeOut(labels), \n Create(combined_curves), \n FadeIn(combined_labels),\n run_time=1.5\n )\n\n # Final hold period to allow viewers to observe the combined graph\n self.wait(3)\n\n# To render this animation, save it as 'exponential_scene.py' and run:\n# manim -pql exponential_scene.py ExponentialFunctionScene\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # Title\n title = Text(\"Exponential Function Graph\", font_size=36).to_edge(UP)\n \n # Axes configuration\n axis_config = {\n 'x_range': [-3, 3, 1],\n 'y_range': [0, 8, 1],\n 'x_length': config.frame_width - 2,\n 'y_length': config.frame_height - 2,\n 'axis_color': BLUE,\n 'numbers_to_exclude': [0]\n }\n axes = Axes(**axis_config).shift(DOWN * 0.5)\n\n # Plotting e^x initially\n exp_e_label = MathTex(\"e^x\").scale(0.7).next_to(axes, UP, buff=0.5)\n exp_curve_e = axes.plot(lambda x: np.exp(x), color=GREEN)\n \n self.play(Write(title))\n self.play(Create(axes))\n self.play(Create(exp_curve_e), Write(exp_e_label))\n self.wait(1) # Display graph briefly\n\n # Transition to 2^x\n exp_new_label = MathTex(\"2^x\").scale(0.7).next_to(axes, UP, buff=1.0)\n exp_curve_new = axes.plot(lambda x: 2**x, color=RED)\n \n self.play(\n ReplacementTransform(exp_curve_e, exp_curve_new),\n ReplacementTransform(exp_e_label, exp_new_label),\n run_time=2\n )\n self.wait(1)\n\n # Comparison view\n exp_curve_old = axes.plot(lambda x: np.exp(x), color=GREEN)\n exp_old_label = MathTex(\"e^x\").scale(0.7).move_to(exp_new_label.get_center())\n \n self.play(FadeIn(exp_old_label), Create(exp_curve_old))\n self.wait(2)\n \n # Final state\n final_text = Tex(\"End of Animation\").scale(0.8).to_edge(DOWN)\n self.play(Write(final_text))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialGraph(Scene):\n def construct(self):\n # 1. Title\n title = Text(\"Exponential Function Graph\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Axes\n # x-range [-3, 3], y-range [-1, 8], color Blue\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": [-3, -2, -1, 0, 1, 2, 3]},\n y_axis_config={\"numbers_to_include\": [2, 4, 6, 8]}\n )\n self.play(Create(axes))\n self.wait(0.5)\n\n # 3. First Plot: e^x in Green\n # Limit x_range slightly to keep the curve within the y-limit visually\n graph_exp = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-3, 2.1])\n label_exp = MathTex(\"e^x\", color=GREEN)\n # Position label near the end of the visible curve\n label_exp.next_to(axes.c2p(2.1, np.exp(2.1)), UR, buff=0.2)\n \n self.play(Create(graph_exp), Write(label_exp))\n self.wait(2)\n\n # 4. Transition: Replace e^x with 2^x in Red\n graph_pow2 = axes.plot(lambda x: 2**x, color=RED, x_range=[-3, 3])\n label_pow2 = MathTex(\"2^x\", color=RED)\n # Position label moved up for better visibility as requested\n label_pow2.next_to(axes.c2p(2.5, 2**2.5), UR, buff=0.4)\n \n # Smoothly replace the first graph with the second\n self.play(\n ReplacementTransform(graph_exp, graph_pow2),\n ReplacementTransform(label_exp, label_pow2),\n run_time=2\n )\n self.wait(2)\n\n # 5. Comparison: Bring e^x back alongside 2^x\n # Recreate the e^x graph and label since ReplacementTransform consumed the originals\n graph_exp_final = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-3, 2.1])\n label_exp_final = MathTex(\"e^x\", color=GREEN)\n label_exp_final.next_to(axes.c2p(2.1, np.exp(2.1)), UR, buff=0.2)\n \n self.play(Create(graph_exp_final), Write(label_exp_final))\n self.wait(3)\n\n# To run this animation, use:\n# manim -pql your_filename.py ExponentialGraph\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ExponentialGraph(Scene):\n def construct(self):\n # 1. Title\n title = Text(\"Exponential Function Graph\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Axes\n # x-range [-3, 3], y-range [-1, 8], color Blue\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": [-3, -2, -1, 0, 1, 2, 3]},\n y_axis_config={\"numbers_to_include\": [2, 4, 6, 8]}\n )\n self.play(Create(axes))\n self.wait(0.5)\n\n # 3. First Plot: e^x in Green\n # Limit x_range slightly to keep the curve within the y-limit visually\n graph_exp = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-3, 2.1])\n label_exp = MathTex(r\"e^x\" + \" = x\", color=GREEN)\n # Position label near the end of the visible curve\n label_exp.next_to(axes.c2p(2.1, np.exp(2.1)), UR, buff=0.2)\n \n self.play(Create(graph_exp), Write(label_exp))\n self.wait(2)\n\n # 4. Transition: Replace e^x with 2^x in Red\n graph_pow2 = axes.plot(lambda x: 2**x, color=RED, x_range=[-3, 3])\n label_pow2 = MathTex(\"2^x\", color=RED)\n # Position label moved up for better visibility as requested\n label_pow2.next_to(axes.c2p(2.5, 2**2.5), UR, buff=0.4)\n \n # Smoothly replace the first graph with the second\n self.play(\n ReplacementTransform(graph_exp, graph_pow2),\n ReplacementTransform(label_exp, label_pow2),\n run_time=2\n )\n self.wait(2)\n\n # 5. Comparison: Bring e^x back alongside 2^x\n # Recreate the e^x graph and label since ReplacementTransform consumed the originals\n graph_exp_final = axes.plot(lambda x: np.exp(x), color=GREEN, x_range=[-3, 2.1])\n label_exp_final = MathTex(\"e^x\", color=GREEN)\n label_exp_final.next_to(axes.c2p(2.1, np.exp(2.1)), UR, buff=0.2)\n \n self.play(Create(graph_exp_final), Write(label_exp_final))\n self.wait(3)\n\n# To run this animation, use:\n# manim -pql your_filename.py ExponentialGraph\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here is the enhanced animation instruction that builds upon the original while adding significant new features:\n\nCreate an expanded animation that first introduces the hydrogen ion (H⁺) as a red circle with a white label, fading it in and moving it upward, then simultaneously introduces an electron (e⁻) as a blue circle that orbits around the ion in a diamond-shaped path while leaving a fading trail; as the electron moves, display the Coulomb force equation (F = k·q₁q₂/r²) that appears and scales up near the ion, with variables that highlight when the electron is closest (minimum r) and farthest (maximum r) from the ion; finally, transform both particles into a hydrogen atom by having the electron stop at a stable orbital position while the ion's label changes to 'H' and the force equation fades into a balanced energy state equation (E = -13.6 eV), with all elements smoothly fading out together. The animation should maintain the original timing and motion paths while incorporating these new educational elements through coordinated animations and transformations.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass HydrogenAtomFormation(Scene):\n def construct(self):\n # Create hydrogen ion (H+)\n h_ion = Circle(radius=0.5, color=RED, fill_opacity=1)\n h_label = Tex(\"H$^+$\", color=WHITE).move_to(h_ion.get_center())\n h_group = VGroup(h_ion, h_label)\n \n # Create electron (e-)\n electron = Dot(radius=0.3, color=BLUE, fill_opacity=1)\n e_label = Tex(\"e$^-$\", color=WHITE, font_size=24).move_to(electron.get_center())\n e_group = VGroup(electron, e_label)\n \n # Create diamond path for electron\n diamond_points = [\n np.array([1.5, 0, 0]),\n np.array([0, 2, 0]),\n np.array([-1.5, 0, 0]),\n np.array([0, -2, 0]),\n np.array([1.5, 0, 0])\n ]\n diamond_path = VMobject()\n diamond_path.set_points_smoothly([*diamond_points])\n \n # Create Coulomb force equation\n coulomb_eq = MathTex(\"F = k\\\\frac{q_1 q_2}{r^2}\", font_size=36)\n coulomb_eq.next_to(h_group, DOWN, buff=1)\n \n # Create energy state equation\n energy_eq = MathTex(\"E = -13.6\\\\, \\\\text{eV}\", font_size=36)\n energy_eq.move_to(coulomb_eq.get_center())\n \n # Animation sequence\n self.play(FadeIn(h_group))\n self.play(h_group.animate.shift(UP))\n \n # Electron orbit with trail\n trail = TracedPath(electron.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])\n self.add(trail, e_group)\n \n # Animate electron along diamond path\n electron_move = MoveAlongPath(e_group, diamond_path, run_time=4, rate_func=linear)\n \n # Highlight r in equation at min/max distances\n r_text = coulomb_eq[0][7:8]\n min_r_highlight = ApplyMethod(r_text.set_color, YELLOW)\n max_r_highlight = ApplyMethod(r_text.set_color, GREEN)\n \n # Synchronize equation highlights with electron position\n self.play(\n electron_move,\n FadeIn(coulomb_eq),\n run_time=2\n )\n self.play(min_r_highlight) # At closest point\n self.wait(0.5)\n self.play(max_r_highlight) # At farthest point\n self.wait(0.5)\n \n # Transform to hydrogen atom\n stable_orbit = Circle(radius=1.5, color=BLUE_D).shift(UP)\n final_electron = Dot(radius=0.3, color=BLUE, fill_opacity=1).move_to(stable_orbit.point_from_proportion(0))\n \n self.play(\n Transform(e_group[0], final_electron),\n e_group[1].animate.move_to(final_electron.get_center()),\n Transform(h_label, Tex(\"H\", color=WHITE).move_to(h_ion.get_center())),\n Transform(coulomb_eq, energy_eq),\n run_time=2\n )\n \n # Fade out all elements\n self.play(\n FadeOut(h_group),\n FadeOut(e_group),\n FadeOut(coulomb_eq),\n run_time=2\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass HydrogenAtomFormation(Scene):\n def construct(self):\n # Create hydrogen ion (H+)\n h_ion = Circle(radius=0.5, color=RED, fill_opacity=1)\n h_label = Tex(\"H$^+$\", color=WHITE).move_to(h_ion.get_center())\n h_group = VGroup(h_ion, h_label)\n \n # Create electron (e-)\n electron = Dot(radius=0.3, color=BLUE, fill_opacity=1)\n e_label = Tex(\"e$^-$\", color=WHITE, font_size=24).move_to(electron.get_center())\n e_group = VGroup(electron, e_label)\n \n # Create diamond path for electron\n diamond_points = [\n np.array([1.5, 0, 0]),\n np.array([0, 2, 0]),\n np.array([-1.5, 0, 0]),\n np.array([0, -2, 0]),\n np.array([1.5, 0, 0])\n ]\n diamond_path = VMob()\n diamond_path.set_points_smoothly([*diamond_points])\n \n # Create Coulomb force equation\n coulomb_eq = MathTex(\"F = k\\\\frac{q_1 q_2}{r^2}\", font_size=36)\n coulomb_eq.next_to(h_group, DOWN, buff=1)\n \n # Create energy state equation\n energy_eq = MathTex(\"E = -13.6\\\\, \\\\text{eV}\", font_size=36)\n energy_eq.move_to(coulomb_eq.get_center())\n \n # Animation sequence\n self.play(FadeIn(h_group))\n self.play(h_group.animate.shift(UP))\n \n # Electron orbit with trail\n trail = TracedPath(electron.get_center, dissipating_time=0.5, stroke_opacity=[0, 1])\n self.add(trail, e_group)\n \n # Animate electron along diamond path\n electron_move = MoveAlongPath(e_group, diamond_path, run_time=4, rate_func=linear)\n \n # Highlight r in equation at min/max distances\n r_text = coulomb_eq[0][7:8]\n min_r_highlight = ApplyMethod(r_text.set_color, YELLOW)\n max_r_highlight = ApplyMethod(r_text.set_color, GREEN)\n \n # Synchronize equation highlights with electron position\n self.play(\n electron_move,\n FadeIn(coulomb_eq),\n run_time=2\n )\n self.play(min_r_highlight) # At closest point\n self.wait(0.5)\n self.play(max_r_highlight) # At farthest point\n self.wait(0.5)\n \n # Transform to hydrogen atom\n stable_orbit = Circle(radius=1.5, color=BLUE_D).shift(UP)\n final_electron = Dot(radius=0.3, color=BLUE, fill_opacity=1).move_to(stable_orbit.point_from_proportion(0))\n \n self.play(\n Transform(e_group[0], final_electron),\n e_group[1].animate.move_to(final_electron.get_center()),\n Transform(h_label, Tex(\"H\", color=WHITE).move_to(h_ion.get_center())),\n Transform(coulomb_eq, energy_eq),\n run_time=2\n )\n \n # Fade out all elements\n self.play(\n FadeOut(h_group),\n FadeOut(e_group),\n FadeOut(coulomb_eq),\n run_time=2\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Next Steps\n\n#### Clustering: How to Discover the Intrinsic Cluster Structure in the Reduced-Dimension Space\n- Dimensionality reduction is often a prerequisite step for clustering and can significantly enhance the performance of algorithms like K-Means.\n\n\nContextual location of this section (from highest to current level):\n# Machine Learning Course - Outline for the Fourth Class (Dimensionality Reduction, 90 minutes)\n## Summary and Comparison (10 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\nimport numpy as np\n\nclass ClusteringNextSteps(Scene):\n\n def construct(self):\n title = Text('Next Steps: Clustering', 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 np.random.seed(42)\n high_d_points = VGroup(*[Dot(np.array([np.random.uniform(-1.5, 1.5), np.random.uniform(-1.5, 1.5), 0]) + LEFT * 4 + UP * 0.5, color=GRAY) for _ in range(45)])\n high_d_label = Text('High-Dimensional Space\\n(Hard to cluster)', font_size=20).next_to(high_d_points, DOWN, buff=0.5)\n self.play(FadeIn(high_d_points), Write(high_d_label))\n arrow = Arrow(LEFT * 1.5, RIGHT * 1.5, color=ORANGE).move_to(UP * 0.5)\n arrow_label = Text('Dimensionality\\nReduction', font_size=18).next_to(arrow, UP)\n self.play(GrowArrow(arrow), Write(arrow_label))\n cluster1 = VGroup(*[Dot(np.array([np.random.normal(4, 0.35), np.random.normal(1.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n cluster2 = VGroup(*[Dot(np.array([np.random.normal(5, 0.35), np.random.normal(-0.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n cluster3 = VGroup(*[Dot(np.array([np.random.normal(3, 0.35), np.random.normal(-0.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n low_d_points = VGroup(cluster1, cluster2, cluster3)\n low_d_label = Text('Reduced-Dimension Space\\n(Intrinsic structure revealed)', font_size=20).next_to(low_d_points, DOWN, buff=0.5)\n self.play(TransformFromCopy(high_d_points, low_d_points), Write(low_d_label))\n kmeans_label = Text('K-Means Applied', font_size=20, color=YELLOW).next_to(low_d_points, UP, buff=0.5)\n rect1 = SurroundingRectangle(cluster1, color=RED, buff=0.15)\n rect2 = SurroundingRectangle(cluster2, color=GREEN, buff=0.15)\n rect3 = SurroundingRectangle(cluster3, color=BLUE, buff=0.15)\n self.play(Write(kmeans_label))\n self.play(cluster1.animate.set_color(RED), cluster2.animate.set_color(GREEN), cluster3.animate.set_color(BLUE), Create(rect1), Create(rect2), Create(rect3))\n conclusion = Text('Dimensionality reduction is a prerequisite that significantly\\nenhances the performance of clustering algorithms.', font_size=24, color=WHITE).to_edge(DOWN, buff=0.8)\n self.play(Write(conclusion))\n self.wait(1.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\nimport numpy as np\n\nclass ClusteringNextSteps(Scene):\n\n def construct(self):\n title = Text('Next Steps: Clustering', 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 np.random.seed(42)\n high_d_points = VGroup(*[Dot(np.array([np.random.uniform(-1.5, 1.5), np.random.uniform(-1.5, 1.5), 0]) + LEFT * 4 + UP * 0.5, color=GRAY) for _ in range(45)])\n high_d_label = Text('High-Dimensional Space\\n(Hard to cluster)', font_size=20).next_to(high_d_points, DOWN, buff=0.5)\n self.play(FadeIn(high_d_points), Write(high_d_label))\n arrow = Arrow(LEFT * 1.5, RIGHT * 1.5, color=ORANGE).move_to(UP * 0.5)\n arrow_label = Text('Dimensionality\\nReduction', font_size=18).next_to(arrow, UP)\n self.play(GrowArrow(arrow), Write(arrow_label))\n cluster1 = VGroup(*[Dot(np.array([np.random.normal(4, 0.35), np.random.normal(1.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n cluster2 = VGroup(*[Dot(np.array([np.random.normal(5, 0.35), np.random.normal(-0.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n cluster3 = VGroup(*[Dot(np.array([np.random.normal(3, 0.35), np.random.normal(-0.5, 0.35), 0]), color=GRAY) for _ in range(15)])\n low_d_points = VGroup(cluster1, cluster2, cluster3)\n low_d_label = Text('Reduced-Dimension Space\\n(Intrinsic structure revealed)', font_size=20).next_to(low_d_points, DOWN, buff=0.5)\n self.play(TransformFromCopy(high_d_points, low_d_points), Write(low_d_label))\n kmeans_label = Text('K-Means Applied', font_size=20, color=YELLOW).next_to(low_d_points, UP, buff=0.5)\n rect1 = SurroundingRectangle(cluster1, color=RED, buff=0.15)\n rect2 = SurroundingRectangle(cluster2, color=GREEN, buff=0.15)\n rect3 = SurroundingRectangle(cluster3, color=BBLUE, buff=0.15)\n self.play(Write(kmeans_label))\n self.play(cluster1.animate.set_color(RED), cluster2.animate.set_color(GREEN), cluster3.animate.set_color(BLUE), Create(rect1), Create(rect2), Create(rect3))\n conclusion = Text('Dimensionality reduction is a prerequisite that significantly\\nenhances the performance of clustering algorithms.', font_size=24, color=WHITE).to_edge(DOWN, buff=0.8)\n self.play(Write(conclusion))\n self.wait(1.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 12-second Manim scene that explains diminishing marginal utility. Show a total-utility curve that rises but flattens as quantity increases, and add a side panel of marginal-gain bars that shrink with each additi\n- Act 2: Here’s the enhanced animation instruction: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0195(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_diminishingmarginalutili()\n self.clear_stage()\n self.act_2_enhancedwigglescene()\n\n def act_1_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n\n def act_2_enhancedwigglescene(self):\n wiggle_text = Text(\"Wiggle\").scale(1.5)\n self.play(\n wiggle_text.animate.shift(UP).set_opacity(1),\n run_time=1.5\n )\n self.wait(0.5)\n\n # \"THIS\" appears and wiggles\n this_text = Text(\"THIS\").scale(2).next_to(wiggle_text, DOWN)\n self.play(Write(this_text))\n self.play(Wiggle(this_text))\n self.wait(0.5)\n\n # Morph \"THIS\" into a rotating equation\n equation = MathTex(\"f(x) = \\\\sin(x)\").scale(1.5).move_to(this_text.get_center())\n self.play(Transform(this_text, equation))\n self.play(\n equation.animate.rotate(PI/4),\n equation.animate.set_color_by_gradient(BLUE, GREEN, YELLOW),\n run_time=2\n )\n self.wait(1)\n\n # Fade in explanatory text box\n explanation = Text(\"Wiggle effects highlight key elements\", font_size=24)\n box = SurroundingRectangle(explanation, buff=0.2, color=WHITE)\n explanation_group = VGroup(explanation, box).next_to(equation, DOWN)\n self.play(FadeIn(explanation_group))\n self.wait(1.5)\n\n # Equation dissolves into expanding circles\n circle = Circle(radius=0.5, color=BLUE).move_to(equation.get_center())\n circles = VGroup()\n for i in range(3):\n new_circle = circle.copy().scale(1.5 * (i + 1)).set_opacity(0.7 - 0.2 * i)\n circles.add(new_circle)\n \n self.play(\n FadeOut(equation),\n FadeOut(explanation_group),\n *[Create(c) for c in circles],\n run_time=2\n )\n self.play(FadeOut(circles), FadeOut(wiggle_text))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0195(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_diminishingmarginalutili()\n self.clear_stage()\n self.act_2_enhancedwigglescene()\n\n def act_1_diminishingmarginalutili(self):\n title = Text('Each Additional Unit Adds Less Utility Than The Previous One', font_size=26).to_edge(UP)\n axes = Axes(x_range=[0, 6, 1], y_range=[0, 11, 2], x_length=6.0, y_length=4.6, tips=False).shift(LEFT * 1.7 + DOWN * 0.1)\n utility = axes.plot(lambda x: 4.2 * np.log(x + 1), x_range=[0, 5.2], color=BLUE_D)\n dots = VGroup(*[Dot(axes.c2p(x, 4.2 * np.log(x + 1)), color=BLUE_D, radius=0.06) for x in [1, 2, 3, 4, 5]])\n side_frame = Rectangle(width=2.2, height=3.5, color=GRAY_B).to_edge(RIGHT).shift(DOWN * 0.1)\n bars = VGroup(Rectangle(width=0.36, height=1.55, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=1.12, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.76, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45), Rectangle(width=0.36, height=0.48, color=ORANGE, fill_color=ORANGE, fill_opacity=0.45)).arrange(RIGHT, buff=0.18, aligned_edge=DOWN).move_to(side_frame.get_center() + DOWN * 0.35)\n side_title = Text('marginal gain', font_size=18, color=ORANGE).next_to(side_frame, UP, buff=0.12)\n caption = Text('Total utility keeps increasing, but the extra benefit from one more unit gets smaller each time.', 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(utility), FadeIn(dots), run_time=2.1)\n self.play(FadeIn(side_frame), FadeIn(side_title), LaggedStart(*[GrowFromEdge(bar, DOWN) for bar in bars], lag_ratio=0.14), run_time=1.9)\n self.play(FadeIn(caption_group), Indicate(bars, color=YELLOW_A), run_time=1.5)\n self.wait(1)\n\n def act_2_enhancedwigglescene(self):\n wiggle_text = Text(\"Wiggle\").scale(1.5)\n self.play(\n wiggle_text.animate.shift(UP).set_opacity(1),\n run_time=1.5\n )\n self.wait(0.5)\n\n # \"THIS\" appears and wiggles\n this_text = Text(\"THIS\").scale(2).next_to(wiggle_text, DOWN)\n self.play(Write(this_text))\n self.play(Wiggle(this_text))\n self.wait(0.5)\n\n # Morph \"THIS\" into a rotating equation\n equation = MathTex(r\"f(x) = \\\\sin(x)\" + \" = x\").scale(1.5).move_to(this_text.get_center())\n self.play(Transform(this_text, equation))\n self.play(\n equation.animate.rotate(PI/4),\n equation.animate.set_color_by_gradient(BLUE, GREEN, YELLOW),\n run_time=2\n )\n self.wait(1)\n\n # Fade in explanatory text box\n explanation = Text(\"Wiggle effects highlight key elements\", font_size=24)\n box = SurroundingRectangle(explanation, buff=0.2, color=WHITE)\n explanation_group = VGroup(explanation, box).next_to(equation, DOWN)\n self.play(FadeIn(explanation_group))\n self.wait(1.5)\n\n # Equation dissolves into expanding circles\n circle = Circle(radius=0.5, color=BLUE).move_to(equation.get_center())\n circles = VGroup()\n for i in range(3):\n new_circle = circle.copy().scale(1.5 * (i + 1)).set_opacity(0.7 - 0.2 * i)\n circles.add(new_circle)\n \n self.play(\n FadeOut(equation),\n FadeOut(explanation_group),\n *[Create(c) for c in circles],\n run_time=2\n )\n self.play(FadeOut(circles), FadeOut(wiggle_text))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Function of the Target Network\n\nThis is an auxiliary network with temporarily fixed parameters, specifically used to calculate the TD target values. By severing the real-time connection between the target values and the current network parameters, it avoids training instability caused by \"chasing a moving target.\"\n\n\nThe context location of this section (from highest to current level):\n# Advanced Techniques in DQN\n## Key Improvement Ideas in DQN\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkScene(Scene):\n\n def construct(self):\n title = Text('Advanced Techniques in Deep Q-Networks', font_size=28).to_edge(UP)\n \n subtitle = Text('Key Improvement Idea: Target Network for Stabilized Training', font_size=26, color=BLUE_C).next_to(title, DOWN, buff=0.2)\n \n bullet_text = '• Severs real-time connection between target value predictions and current network parameters.'\n point = BulletedList(bullet_text, font_size=24).shift(DOWN * 0.5)\n \n explanation = Text('\"Chasing a moving target\" refers to instability due to changing targets while weights are still being updated.', font_size=22, line_spacing=1.2).shift(DOWN * 1.5)\n highlight_box = SurroundingRectangle(explanation, color=YELLOW, buff=0.25)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN * 0.2))\n self.wait(1)\n self.play(FadeIn(point, shift=RIGHT * 1))\n self.wait(1)\n \n # Visual representation\n main_net_label = Tex('$Q(s,a)$', font_size=36).set_color_by_tex('$Q$', BLUE_C)\n main_dot = Dot(color=BLUE_C).scale(1.2)\n target_net_label = Tex('$\\\\tilde{Q}(s,a)$', font_size=36, color=GREEN_C).move_to(main_dot.get_center())\n arrow = Arrow(start=main_dot.get_center(), end=target_net_label.get_center(), color=WHITE, stroke_width=2, max_tip_length_to_length_ratio=0.1)\n \n self.play(Create(main_dot), Write(main_net_label))\n self.wait(0.5)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(Write(target_net_label))\n self.wait(1)\n self.play(\n FadeIn(highlight_box),\n Indicate(explanation, color=YELLOW, scale_factor=1.1)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkScene(Scene):\n def construct(self):\n title = Text(\"Target Network\", font_size=36).to_edge(UP)\n \n caption_text = \"\"\"\n Auxiliary network with frozen parameters,\n updating periodically vs. real-time during learning steps.\n \"\"\"\n caption = Paragraph(caption_text, font_size=28).next_to(title, DOWN, buff=0.8)\n\n # Create two networks side-by-side for visual comparison\n net_real = RoundedRectangle(width=2, height=1.5, corner_radius=0.2, color=BLUE)\n net_target = RoundedRectangle(width=2, height=1.5, corner_radius=0.2, color=YELLOW)\n net_label_real = Tex(\"$\\\\theta$\").move_to(net_real.get_center())\n net_label_target = Tex(\"$\\\\theta'$\").move_to(net_target.get_center())\n network_group = VGroup(net_real, net_target, net_label_real, net_label_target).arrange(RIGHT, buff=1.5)\n network_group.next_to(caption, DOWN, buff=1.2)\n\n self.play(Write(title))\n self.play(FadeIn(caption, shift=DOWN * 0.2))\n self.play(Create(net_real), Write(net_label_real), RunTime=1.5)\n self.play(Create(net_target), Write(net_label_target), RunTime=1.5)\n self.wait(1)\n \n # Draw arrows showing signal flow from real to target\n arrow_real_to_target = Arrow(\n start=net_real.get_right(), \n end=net_real.get_right() + RIGHT*1.5 + UP*0.5, \n stroke_width=3, \n color=WHITE\n )\n label_arrow = MathTex(\"\\\\text{TD-Error}\", font_size=24).next_to(arrow_real_to_target, UP, buff=0.2)\n \n self.play(GrowArrow(arrow_real_to_target))\n self.play(Write(label_arrow))\n self.wait(1)\n \n # Add explanation text below the diagram\n explanation_text = [\n \"Updates less frequently than main network.\",\n \"Ensures stable convergence by 'chasing' static targets.\"\n ]\n explanations = [Text(text, font_size=24) for text in explanation_text]\n explanation_group = VGroup(*explanations).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n explanation_group.to_corner(UR, buff=0.5)\n \n # Highlight target network differently to emphasize periodic updates\n highlight_box = SurroundingRectangle(net_target, color=RED, buff=0.15)\n \n self.play(Write(explanation_group[0]))\n self.play(Create(highlight_box))\n self.wait(1)\n \n # Update rule: move box briefly up then back down\n self.play(MoveAlongPath(highlight_box, arc(PHI, ORIGIN, UP)), run_time=1.5)\n self.play(MoveAlongPath(highlight_box, arc(-PHI, ORIGIN, DOWN)), run_time=1.5)\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a multi-act ManimCE scene (`AttentionGridScene`) showing 4 token `RoundedRectangle` boxes, `Arrow` Q/K/V projections, and a 4x4 attention `VGroup(*rows)` heatmap.", "chosen": "```python\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n self.show_tokens()\n self.show_projections()\n self.show_attention()\n\n def show_tokens(self):\n # Create four tokens as rounded rectangles arranged in a 2x2 grid\n tokens = VGroup(\n RoundedRectangle(width=1, height=1.5),\n RoundedRectangle(width=1, height=1.5).shift(RIGHT * 1.5 + UP * 1.5),\n RoundedRectangle(width=1, height=1.5).shift(LEFT * 1.5 + DOWN * 1.5),\n RoundedRectangle(width=1, height=1.5).shift(DOWN * 1.5)\n )\n \n for i, rect in enumerate(tokens):\n if i % 2 == 0:\n rect.set_color(GREEN)\n else:\n rect.set_color(YELLOW)\n\n labels = [\"Q\", \"K\", \"V\"] # First three will be labeled\n\n # Add text labels only to the first three tokens (excluding last one)\n for j in range(len(labels)):\n label_text = Text(labels[j], font_size=36).move_to(tokens[j])\n \n # Animate the creation of each rectangle followed by its corresponding text\n self.play(Create(tokens[j]))\n self.play(FadeIn(label_text))\n self.wait(0.3) # Pause briefly after displaying each element\n \n self.wait(1)\n\n def show_projections(self):\n # Define colors for arrows representing different paths (blue, green, yellow)\n arrow_colors = [BLUE, GREEN, YELLOW]\n \n # Position vectors defining the layout of projections from the center\n positions = [\n ORIGIN + RIGHT * 1.8 + UP * 0.7,\n ORIGIN + LEFT * 1.8 + UP * 0.7,\n ORIGIN + RIGHT * 1.8 + DOWN * 0.7\n ]\n \n # Create projection arrows from the center to specified end points\n arrows = []\n for pos, color in zip(positions, arrow_colors):\n arrow = Arrow(start=ORIGIN, end=pos, buff=0.1)\n arrow.set_color(color)\n arrow.scale(1.2)\n arrows.append(arrow)\n \n # Group all arrows and animate them appearing sequentially\n all_arrows = VGroup(*arrows)\n self.play(LaggedStart(*[Create(arrow) for arrow in all_arrows], lag_ratio=0.3))\n\n # Display labels indicating what is being projected where\n labels = [\"Query\", \"Key\", \"Value\"]\n label_positions = [\n ORIGIN + RIGHT * 1.8 + UP * 1.3,\n ORIGIN + LEFT * 1.8 + UP * 1.3,\n ORIGIN + RIGHT * 1.8 + DOWN * 1.3\n ]\n\n label_objs = []\n for i in range(len(arrows)):\n tex_label = MathTex(\"\\\\rightarrow \", labels[i]).next_to(arrows[i].get_end(), DOWN, buff=0.2)\n tex_label.to_edge(UP, buff=0.2).scale(0.8)\n label_objs.append(tex_label)\n\n for tex_label in label_objs:\n self.play(Write(tex_label))\n self.wait(0.5)\n \n self.wait(1)\n\n def show_attention(self):\n # Clear screen to make room for the large 4x4 matrix\n self.clear()\n \n # Generate random values between 0 and 1 to simulate attention scores\n data = [[np.random.rand() for _ in range(4)] for _ in range(4)]\n max_val = max(max(row) for row in data)\n\n # Configure axes limits based on the maximum value found\n x_min, y_min = 0, 0\n x_max = len(data) - 0.1\n y_max = len(data[0]) - 0.1\n \n # Initialize Axes object\n axes = Axes(\n x_range=[x_min, x_max],\n y_range=[y_min, y_max],\n x_length=7.5,\n y_length=5.5\n ).center()\n\n axis_labels = axes.get_axis_labels(x_label=\"Tokens\", y_label=\"Tokens\")\n\n # Create cells using Rectangles that scale their color intensity based on the score\n cells = VGroup()\n for i in range(len(data)):\n for j in range(len(data[0])):\n cell_rect = Rectangle(\n width=(data[i][j]/max_val)*1.5,\n height=1.5,\n stroke_width=0.5,\n fill_opacity=data[i][j]/max_val,\n stroke_opacity=0.1\n )\n \n # Adjust position so it aligns perfectly within the coordinate system\n offset_x = (-x_max / 2) + ((i+0.5)/len(data))*(x_max-x_min)-cell_rect.width/2\n offset_y = ((y_max-y_min)/2) - ((j+0.5)/len(data[0]))*(y_max-y_min)+cell_rect.height/2\n \n cell_rect.move_to([offset_x, offset_y, 0])\n\n # Highlight selected indices with a white border\n highlight_radius = 0.3\n highlight_circle = Circle(radius=highlight_radius, color=WHITE, stroke_width=2)\n highlight_circle.move_to(cell_rect.get_center())\n \n # Only add highlights for specific elements\n target_indices = [(0, 0), (0, 1), (1, 0), (2, 3)]\n if (i, j) in target_indices:\n cells.add(highlight_circle)\n\n cells.add(cell_rect)\n\n # Render the entire grid\n self.add(axes, axis_labels)\n self.add(cells)\n\n # Add titles above the grid\n title_query = Tex(\"Queries\").to_edge(UP, buff=1)\n title_key = Tex(\"Keys\").to_edge(UP, buff=1)\n \n self.add(title_query, title_key)\n self.wait(2)\n```", "rejected": "```python\nimport numpy as np\nfrom manim import *\n\nclass AttentionGridScene(Scene):\n def construct(self):\n self.token_grid()\n self.projections()\n self.attention_heatmap()\n\n def token_grid(self):\n tokens = VGroup(*[\n RoundedRectangle(\n width=2,\n height=1.5,\n corner_radius=0.2,\n fill_color=BLUE_D,\n fill_opacity=0.8\n ).shift(RIGHT * i + UP * j)\n for j in range(2) for i in range(2)\n ])\n \n labels = VGroup(*[\n MathTex(f\"t_{i+j*2}\").move_to(token.get_center())\n for j in range(2) for i in range(2)\n ])\n\n self.play(Create(tokens))\n self.add(labels)\n\n self.tokens = tokens\n\n def projections(self):\n tokens = self.tokens\n \n # Create projection arrows from each token box\n q_arrows = []\n k_arrows = []\n v_arrows = []\n\n for i, token in enumerate(tokens):\n pos = token.get_center()\n \n if i == 0: \n target_pos = ORIGIN\n elif i == 1: \n target_pos = RIGHT * 3\n else:\n continue\n\n arrow_style = Arrow(start=pos, end=target_pos, color=YELLOW, buff=0.1, max_tip_length_to_length_ratio=0.2)\n\n if i % 2 == 0:\n q_arrows.append(arrow_style.copy().set_stroke(opacity=i==0).scale(i==0))\n k_arrows.append(arrow_style.copy().rotate(-PI/2).set_stroke(color=GREEN_C, opacity=i==1))\n v_arrows.append(arrow_style.copy().rotate(PI/2).set_stroke(color=RED_C, opacity=i==1))\n else:\n pass\n \n self.play(GrowArrow(q_arrows[-1]), run_time=0.6)\n self.play(GrowArrows(k_arrows[-1], v_arrows[-1]), run_time=0.6)\n self.wait(0.2)\n\n self.arrows = [q_arrows, k_arrows, v_arrows]\n\n def attention_heatmap(self):\n rows = VGroup(*[\n VGroup(*[Square(side_length=1, stroke_width=1, color=WHITE, fill_opacity=1.0) for _ in range(4)])\n .arrange(DOWN, buff=0)\n .to_edge(UP, buff=0.5)\n .next_to(row_group, DOWN, buff=0.2)\n for row_group in [[1, 0, 1, 0], [0, 1, 0, 1], [1, 1, 1, 0], [0, 0, 0, 1]]\n ]).arrange(RIGHT, buff=0)\n\n # Animate grid appearing\n self.play(LaggedStartMap(FadeIn, rows, lag_ratio=0.1))\n self.wait(0.5)\n\n # Color cells based on values\n colors = [\n BLUE_D, GRAY_D, GREEN_D, RED_D\n ]\n\n # Fill matrix with different colors\n for r_idx, row in enumerate(rows):\n for c_idx, cell in enumerate([c for c in row]):\n val = colors[r_idx][c_idx]\n cell.set_fill(val, opacity=0.7)\n \n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 and then with a circle, and finally have the text disappear?", "chosen": "```python\nfrom manim import *\n\nclass CircumscribeHighlightScene(Scene):\n def construct(self):\n # Step 1: Text Transformation and Upward Movement\n # Create initial text and target text positioned upwards\n start_text = Text(\"Start\")\n target_text = Text(\"Circumscribe\").shift(UP * 2)\n \n # Transform text content and move upwards simultaneously\n self.play(ReplacementTransform(start_text, target_text))\n self.wait(0.5)\n \n # Step 2: New Text Appearance\n # Introduce \"Look Here\" text below the transformed text\n look_here_text = Text(\"Look Here\")\n look_here_text.next_to(target_text, DOWN, buff=1)\n \n self.play(Write(look_here_text))\n self.wait(0.5)\n \n # Step 3: Highlighting Sequence\n # 3a: Apply default highlight shape (SurroundingRectangle)\n rect_highlight = SurroundingRectangle(look_here_text, color=YELLOW, buff=0.1)\n self.play(Create(rect_highlight))\n self.wait(0.5)\n \n # 3b: Apply circular highlight shape\n # Create a circle and scale it to encompass the text\n circle_highlight = Circle(color=BLUE).move_to(look_here_text)\n circle_highlight.stretch_to_fit_width(look_here_text.width * 1.3)\n \n # Transform the rectangle into the circle\n self.play(ReplacementTransform(rect_highlight, circle_highlight))\n self.wait(1)\n \n # Step 4: Disappearance\n # Animate all text and highlights disappearing from the scene\n self.play(\n FadeOut(target_text),\n FadeOut(look_here_text),\n FadeOut(circle_highlight)\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass CircumscribeHighlightScene(Scene):\n def construct(self):\n # Step 1: Text Transformation and Upward Movement\n # Create initial text and target text positioned upwards\n start_text = Text(\"Start\")\n target_text = Text(\"Circumscribe\").shift(UP * 2)\n \n # Transform text content and move upwards simultaneously\n self.play(ReplacementTransform(target_position=ORIGIN, start_text, target_text))\n self.wait(0.5)\n \n # Step 2: New Text Appearance\n # Introduce \"Look Here\" text below the transformed text\n look_here_text = Text(\"Look Here\")\n look_here_text.next_to(target_text, DOWN, buff=1)\n \n self.play(Write(look_here_text))\n self.wait(0.5)\n \n # Step 3: Highlighting Sequence\n # 3a: Apply default highlight shape (SurroundingRectangle)\n rect_highlight = SurroundingRectangle(look_here_text, color=YELLOW, buff=0.1)\n self.play(Create(rect_highlight))\n self.wait(0.5)\n \n # 3b: Apply circular highlight shape\n # Create a circle and scale it to encompass the text\n circle_highlight = Circle(color=BLUE).move_to(look_here_text)\n circle_highlight.stretch_to_fit_width(look_here_text.width * 1.3)\n \n # Transform the rectangle into the circle\n self.play(ReplacementTransform(rect_highlight, circle_highlight))\n self.wait(1)\n \n # Step 4: Disappearance\n # Animate all text and highlights disappearing from the scene\n self.play(\n FadeOut(target_text),\n FadeOut(look_here_text),\n FadeOut(circle_highlight)\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 both the square and the circle then disappearing. Can this be done in a simple and visually appealing way, possibly with a quick transition for the text and a smooth transformation for the square?", "chosen": "```python\nfrom manim import *\n\nclass MatchWidthAnimation(Scene):\n def construct(self):\n # 1. Text Transition\n # Create initial text and the target text\n text_initial = Text(\"Starting Animation\", font_size=36)\n text_target = Text(\"animate.match_width\", font_size=36)\n \n self.add(text_initial)\n self.wait(0.5)\n \n # Quick transition: morph text and move it upwards simultaneously\n self.play(\n ReplacementTransform(text_initial, text_target),\n text_target.animate.shift(UP * 2),\n run_time=0.8,\n rate_func=smooth\n )\n\n # 2. Shape Setup\n # Create a square and a larger circle\n square = Square(side_length=1.0, color=BLUE)\n circle = Circle(radius=2.0, color=WHITE)\n \n # Position them side-by-side below the text\n shapes = VGroup(square, circle).arrange(RIGHT, buff=1.5)\n shapes.next_to(text_target, DOWN, buff=1)\n \n self.play(FadeIn(square), FadeIn(circle))\n self.wait(0.5)\n\n # 3. Smooth Transformation\n # Animate the square's width to match the circle's width\n self.play(\n square.animate.match_width(circle),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Smoothly fade out both shapes\n self.play(\n FadeOut(square, shift=DOWN * 0.5),\n FadeOut(circle, shift=DOWN * 0.5),\n run_time=0.8\n )\n \n # Fade out the top text\n self.play(FadeOut(text_target))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass MatchWidthAnimation(Scene):\n def construct(self):\n # 1. Text Transition\n # Create initial text and the target text\n text_initial = Text(\"Starting Animation\", font_size=36)\n text_target = Text(\"animate.match_width\", font_size=36)\n \n self.add(text_initial)\n self.wait(0.5)\n \n # Quick transition: morph text and move it upwards simultaneously\n self.play(\n ReplacementTransform(text_initial, text_target),\n text_target.animate.shift(UP * 2),\n run_time=0.8,\n rate_func=smooth\n )\n\n # 2. Shape Setup\n # Create a square and a larger circle\n square = Square(side_length=1.0, color=BBLUE)\n circle = Circle(radius=2.0, color=WHITE)\n \n # Position them side-by-side below the text\n shapes = VGroup(square, circle).arrange(RIGHT, buff=1.5)\n shapes.next_to(text_target, DOWN, buff=1)\n \n self.play(FadeIn(square), FadeIn(circle))\n self.wait(0.5)\n\n # 3. Smooth Transformation\n # Animate the square's width to match the circle's width\n self.play(\n square.animate.match_width(circle),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # 4. Disappearance\n # Smoothly fade out both shapes\n self.play(\n FadeOut(square, shift=DOWN * 0.5),\n FadeOut(circle, shift=DOWN * 0.5),\n run_time=0.8\n )\n \n # Fade out the top text\n self.play(FadeOut(text_target))\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralScene(Scene):\n def construct(self):\n # --- Step 1: Display Problem ---\n problem = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\, dx\",\n font_size=72,\n color=BLUE\n )\n \n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Explanation Text (TextObject) ---\n text_explanation_1 = Text(\"Evaluating this definite integral appears:\", font_size=36)\n box_text_explanation = SurroundingRectangle(text_explanation_1, buff=0.2, color=YELLOW)\n \n self.play(Write(text_explanation_1))\n self.play(Create(box_text_explanation))\n self.wait(2)\n\n # Clear intermediate elements\n self.play(FadeOut(text_explanation_1), FadeOut(box_text_explanation))\n\n # --- Step 3: Rule Display (Power Rule Formula) ---\n power_rule = MathTex(\n r\"\\int\", \"x^n\", \"\\, dx =\", \"\\\\frac{x^{n+1}}{n+1}\",\n font_size=54,\n color=GREEN\n ).to_edge(UP)\n rule_label = Text(\"General Power Rule:\", font_size=32).next_to(power_rule, UP)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(1)\n\n # Apply the rule specifically for n=2\n app_rule_step = MathTex(\n r\"=\", \"\\\\left.\", \"\\\\frac{x^{2+1}}{2+1}\", r\"\\right|_{0}^{1}\"\n ).set_color(GREEN).scale(1.2)\n app_rule_step.next_to(power_rule, DOWN, buff=1)\n \n self.play(Write(app_rule_step))\n self.wait(1)\n\n # --- Step 4: Calculation Steps ---\n calc_step1 = MathTex(\n r\"=\", \"\\\\left.\", \"\\\\frac{x^3}{3}\", r\"\\right|_{0}^{1}\"\n ).set_color(YELLOW).scale(1.2)\n calc_step2_sub = MathTex(\n r\"=\", r\"\\frac{1^3}{3}\" ,\"-\", r\"\\frac{0^3}{3}\"\n ).set_color(ORANGE).scale(1.2)\n \n calc_group = VGroup(calc_step1, calc_step2_sub)\n calc_group.arrange(DOWN, aligned_edge=LEFT).next_to(app_rule_step, DOWN, buff=0.8)\n \n self.play(Write(calc_step1))\n self.wait(1)\n self.play(Write(calc_step2_sub))\n self.wait(2)\n\n # --- Step 5: Solution Transformation ---\n sol_transform = MathTex(\n r\"=\", r\"\\frac{1}{3}\", \"-\", r\"\\frac{0}{3}\"\n ).scale(1.2).move_to(calc_step2_sub.get_center())\n \n self.play(TransformMatchingTex(calc_step2_sub, sol_transform))\n self.wait(1)\n\n # Final Result Box\n result_box = RoundedRectangle(width=2.5, height=0.8, corner_radius=0.3)\n result_box.move_to(sol_transform.get_center()).shift(RIGHT * 0.5 + UP * 0.2)\n final_answer = MathTex(\"\\\\approx 0.33\", color=RED).scale(2).move_to(result_box.get_center())\n\n self.play(Create(result_box), Write(final_answer))\n self.wait(1)\n\n # --- Step 6: Area Explanation ---\n explain_area = Text(\n \"This value represents the area under the curve\\nbetween 0 and 1.\",\n font_size=28,\n line_spacing=1.2\n ).to_edge(DOWN)\n\n self.play(Write(explain_area))\n self.wait(2)\n\n # --- Step 7: Conclusion Sequence ---\n self.play(\n FadeOut(problem),\n FadeOut(rule_label),\n FadeOut(power_rule),\n FadeOut(app_rule_step),\n FadeOut(calc_group),\n FadeOut(result_box),\n FadeOut(final_answer),\n FadeOut(explain_area)\n )\n\n # Re-present only final solution and its explanation\n final_solution = MathTex(\"\\\\frac{1}{3}\", color=RED).scale(4)\n final_text = Text(\"Area Under Curve\", font_size=36).next_to(final_solution, DOWN, buff=0.5)\n\n self.play(Write(final_solution))\n self.play(Write(final_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Initial Display ---\n title = Text(\"Evaluating the Integral\", font_size=36).to_edge(UP)\n \n initial_integral = MathTex(\n r\"\\int_{0}^{1}\", \"x^2\", \"\\\\, dx\"\n ).scale(1.8)\n\n self.play(Write(title))\n self.play(Write(initial_integral))\n\n # Pause briefly at the beginning\n self.wait(1.5)\n\n # --- Step 2: Explanation Phase ---\n evaluation_text = Text(\n \"We evaluate the definite integral using the Power Rule.\", \n font_size=28\n )\n evaluation_text.next_to(title, DOWN, buff=0.7)\n\n rule_title = Text(\"Power Rule:\", font_size=32).next_to(evaluation_text, DOWN, buff=0.5)\n power_rule = MathTex(\n r\"\\int u^n \\\\, du = \\frac{u^{n+1}}{n+1}\"\n ).scale(1.2).next_to(rule_title, DOWN, buff=0.3)\n\n self.play(Write(evaluation_text))\n self.play(Write(rule_title))\n self.play(Write(power_rule))\n\n self.wait(2)\n\n # Clear intermediate steps so they don't interfere with calculations\n self.play(FadeOut(evaluation_text), FadeOut(rule_title), FadeOut(power_rule))\n\n # --- Step 3: Calculation Phases ---\n # Apply Limits: Show the antiderivative with substituted upper limit (1) minus lower limit (0)\n calc_step1 = MathTex(\n r\"=\", \"[\", \"(1)^3 \", \"-\", \"(0)^3\", \"]\",\n ).scale(1.8)\n\n self.play(Write(calc_step1))\n\n # Simplify exponentiation results\n calc_simplified = MathTex(\n r\"=\", \"[\", \"1\", \"-\", \"0\", \"]\",\n ).scale(1.8).move_to(calc_step1.get_center())\n\n self.play(TransformMatchingTex(calc_step1, calc_simplified))\n\n # Subtraction step\n subtraction = MathTex(\n r\"=\", \"1\", \"-\",\n ).scale(1.8).move_to(calc_simplified.get_center())\n \n self.play(TransformMatchingTex(calc_simplified, subtraction))\n\n # Final Result: Area represented numerically\n result_final = MathTex(\n r\"=\", \"1\"\n ).scale(1.8).move_to(subtraction.get_center())\n\n self.play(TransformMatchTarget(subtraction, result_final))\n\n self.wait(1.5)\n\n # End state: All math elements displayed sequentially\n\n # --- Conclusion Sequence ---\n # Clear all visual components except the final numerical result and text\n to_clear = VGroup(title, evaluation_text, rule_title, power_rule, calc_step1, calc_simplified, subtraction)\n remaining_mobs = VGroup(result_final, title)\n\n self.play(FadeOut(to_clear), Circumscribe(remaining_mobs))\n\n # Re-present the key insight clearly with emphasis on physical interpretation\n conclusion_text = Text(\n \"This numeric result represents the exact area under the curve\\nbetween x=0 and x=1.\",\n t2c={\"area\": YELLOW},\n line_spacing=1.2,\n font_size=28\n ).to_edge(DOWN)\n\n box = SurroundingRectangle(conclusion_text, color=BLUE, buff=MED_LARGE_BUFF)\n \n self.play(Write(conclusion_text))\n self.play(Create(box))\n self.play(ConstrainPosition(conclusion_text, ORIGIN)) # Center without scaling\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Generate a Manim animation to explain the concept of divergence and curl in vector calculus. Visualize vector fields and their behavior, and include a title saying \"Divergence and Curl.\"\n- Act 2: 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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0024(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_divergenceandcurl()\n self.clear_stage()\n self.act_2_broadcastanimation()\n\n def act_1_divergenceandcurl(self):\n title = Title(\"Divergence and Curl\")\n self.play(Write(title))\n \n\n div = MathTex(r\"\\text{div } \\vec{F} = \", r\"\\nabla \\cdot \\vec{F}\")\n self.play(Write(div))\n\n curl = MathTex(r\"\\text{curl } \\vec{F} = \", r\"\\nabla \\times \\vec{F}\") \n curl.shift(DOWN) \n self.play(Write(curl)) \n\n self.wait()\n\n self.play(\n FadeOut(div),\n FadeOut(curl),\n FadeOut(title))\n\n plane = NumberPlane() \n self.play(Create(plane))\n \n field = VectorField(lambda pos: np.array([1, (pos[0]-pos[1])/2, 0]))\n self.play(ShowPassingFlash(field.copy(), time_width=0.5))\n \n # vectors grid\n vectors = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n x = i + 0.01*j\n y = j\n vectors.add(Vector(RIGHT+UP*y).shift(RIGHT*x+UP*y).scale(0.7))\n \n self.play(FadeIn(vectors, lag_ratio = 0.01))\n self.wait()\n\n def act_2_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0024(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_divergenceandcurl()\n self.clear_stage()\n self.act_2_broadcastanimation()\n\n def act_1_divergenceandcurl(self):\n title = Title(\"Divergence and Curl\")\n self.play(Write(title))\n \n\n div = MathTex(r\"\\text{div } \\vec{F} = \", r\"\\nabla \\cdot \\vec{F}\")\n self.play(Write(div))\n\n curl = MathTex(r\"\\text{curl } \\vec{F} = \", r\"\\nabla \\times \\vec{F}\") \n curl.shift(DOWN) \n self.play(Write(curl)) \n\n self.wait()\n\n self.play(\n FadeOut(div),\n FadeOut(curl),\n FadeOut(title))\n\n plane = NumberPlane() \n self.play(Create(plane))\n \n field = VectorField(lambda pos: np.array([1, (pos[0]-pos[1])/2, 0]))\n self.play(ShowPassingFlash(field.copy(), time_width=0.5))\n \n # vectors grid\n vectors = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n x = i + 0.01*j\n y = j\n vectors.add(Vector(RIGHT+UP*y).shift(RIGHT*x+UP*y).scale(0.7))\n \n self.play(FadeIn(vectors, lag_ratio = 0.01))\n self.wait()\n\n def act_2_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the effect of adding and removing elements on the levels of the cumulative hierarchy?", "chosen": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"Exploring Hierarchies\", font_size=48)\n subtitle = Text(\"Adding Elements Changes Levels\", font_size=36)\n \n self.play(Write(title))\n self.wait(1)\n self.play(Transform(title, subtitle))\n self.wait(1)\n\n # Create the first level\n level_0 = VGroup(Circle(radius=0.7)).shift(LEFT*2 + DOWN*2)\n label_0 = MathTex(\"\\\\mathcal{A}\").next_to(level_0, RIGHT)\n \n self.play(Create(level_0), Write(label_0))\n self.wait(1)\n\n # Add element to create second level\n level_1 = VGroup(Square(side_length=1.4).rotate(-PI/4)).move_to(level_0.get_center())\n label_1 = MathTex(\"\\\\mathcal{B} \\\\in \\\\mathcal{A}\").next_to(level_1, UP)\n \n self.play(Create(VGroup(level_1, label_1)))\n self.wait(1)\n\n # Remove element from second level back to first level\n self.play(FadeOut(VGroup(level_1, label_1)))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"Hierarchical structures change with additions/removals.\", font_size=32)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(VGroup(title, conclusion)))\n```", "rejected": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"The Power of Addition\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Element addition logic\n element_addition_text = Tex(\n r\"$\\alpha \\rightarrow \\beta$\\\\\"\n r\"Add $\\alpha$ to get new set $S_{n+1}$\\\\\"\n r\"\\includegraphics[scale=0.8]{add_element.png}\"\n ).to_edge(RIGHT).shift(DOWN * 0.5)\n\n self.play(FadeIn(element_addition_text))\n\n # Hierarchical level representation\n levels_title = Text(\"Hierarchical Levels\", font_size=28)\n levels_group = VGroup()\n \n for i in range(4): # Create four sets representing different levels\n circle = Circle(radius=i + 1.5, color=BLUE_D)\n label = Text(f\"L{i}\", font_size=18).move_to(circle.get_center())\n \n group = VGroup(circle, label)\n levels_group.add(group)\n \n levels_group.arrange(RIGHT, buff=2)\n \n self.play(Create(levels_group))\n \n # Add description text below the circles\n desc_text = Text(\n \"Adding elements increases the hierarchy level.\\nThe larger the circle, the higher the level.\",\n font_size=24,\n line_spacing=1.2\n )\n desc_text.next_to(level_desc, DOWN)\n \n self.play(Write(desc_text)) \n \n # Remove elements from the upper layers\n removal_text = Tex(\n \"$\\\\gamma \\\\rightarrow \\\\delta$\\\\\\\\\"\n \"Remove elements to simplify the hierarchy\\\\\\\\\"\n \"\\\\includegraphics[scale=0.7]{remove_elements.png}\"\n ).to_edge(RIGHT).shift(DOWN * 0.5) \n \n self.play(Transform(element_addition_text, removal_text))\n \n # Show simplified hierarchical groups\n simplified_groups = VGroup()\n \n # Create two simplified sets at lower levels\n small_circle = Circle(radius=1.0, color=YELLOW)\n large_circle = Circle(radius=2.5, color=GREEN)\n \n small_label = Text(\"Low Level\", font_size=18).next_to(small_circle, UP)\n large_label = Text(\"High Level\", font_size=18).next_to(large_circle, DOWN)\n \n simplified_groups.add(VGroup(small_circle, small_label))\n simplified_groups.add(VGroup(large_circle, large_label))\n \n simplified_groups.arrange(DOWN, buff=2)\n \n self.play(\n FadeOut(elements),\n TransformMatchingTex(element_addition_text, removal_text),\n FadeOut(levels_group),\n Write(simplified_groups)\n )\n\n self.wait(2)\n \n # Final message\n final_message = Text(\n \"Manipulate hierarchies by adding/removing elements\",\n font_size=24,\n color=WHITE\n )\n box = SurroundingRectangle(final_message, corner_radius=0.2)\n \n self.play(Write(box), Write(final_message))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a **Rectangle** (width=4, height=2) appearing at the center of the screen. Instead of simply moving to (1, 1), the rectangle now **animates smoothly** from the center to its target position while **changing color** from blue to red. As it moves, a **mathematical formula** (e.g., the area calculation `A = width × height = 4 × 2 = 8`) fades in below it, dynamically updating as the rectangle’s dimensions shift. Once the rectangle reaches (1, 1), it **rotates 90 degrees** clockwise, and a **highlighting effect** (a glowing border) emphasizes its final position. Finally, **explanatory text** (\"Rectangle Transformation\") appears at the top of the screen, tying together the visual and mathematical concepts. This enhanced version not only preserves the original movement but also incorporates **dynamic formulas, color transitions, rotational animation, and explanatory text** for a more engaging and educational presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle and Position\n rect = Rectangle(width=4, height=2, stroke_color=BLUE)\n rect.move_to(ORIGIN)\n\n # Animate Rectangle Movement and Color Change\n self.play(\n MoveAlongPath(rect, Line(ORIGIN, ORIGIN + RIGHT*1 + UP*1)),\n rect.animate.set_stroke(color=RED),\n run_time=2,\n rate_func=smooth\n )\n\n # Display Formula\n math_text = MathTex(\"A = w \\\\times h = 4 \\\\times 2 = 8\")\n math_text.next_to(rect, DOWN, buff=1)\n\n self.play(FadeIn(math_text))\n\n # Rotate Rectangle by 90 degrees Clockwise\n self.play(Rotate(rect, angle=PI/2, about_point=rect.get_center()), run_time=1.5)\n\n # Add Highlight Effect (Glowing Border)\n highlight_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.1, fill_opacity=0.3, stroke_width=2)\n highlight_rect.set_stroke(opacity=0.7)\n\n self.add(highlight_rect)\n\n # Show Explanatory Text\n title_text = Text(\"Rectangle Transformation\", font_size=36).to_edge(UP)\n \n self.play(Write(title_text))\n self.wait()\n\n# To render this animation using manim, save the code to a file named \"enhanced_scene.py\" and run:\n# manim -pql enhanced_scene.py EnhancedRectangleScene\n\n# Replace '-p' with '-q' for quick rendering without audio, or remove it entirely for silent rendering.\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle\n rect = Rectangle(\n width=4, \n height=2, \n stroke_color=BLUE,\n fill_opacity=0.5\n )\n \n # Add Mathematical Formula\n math_text = MathTex(\"A =\", \"4\", \"\\\\times\", \"2\", \"=\", \"8\")\n math_group = VGroup(MathTex(\"A =\"), Rect(4, 2).next_to(MathTex(\"A =\"), RIGHT), MathTex(\"=\")).arrange(RIGHT)\n \n self.play(Create(rect))\n self.wait(0.5)\n\n # Move and Change Color\n self.play(\n rect.animate.move_to([1, 1, 0]),\n rect.animate.set_stroke(color=RED),\n run_time=2\n )\n self.wait()\n\n # Display Area Calculation\n self.play(FadeIn(math_group.to_edge(DOWN)))\n self.wait(2)\n \n # Rotate Rectangle\n self.play(rotating_rect.animate.rotate(-PI/2)) # Clockwise rotation by -90 degrees\n self.wait()\n \n # Highlight Final Position\n highlight_box = SurroundingRectangle(rotating_rect, color=YELLOW, buff=0.2)\n self.add(highlight_box)\n self.wait(1)\n self.remove(highlight_box)\n \n # Show Explanatory Text\n title = Tex(\"Rectangle Transformation\").to_edge(UP)\n self.play(Write(title))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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#### Decomposition: Breaking down complex problems into manageable sub-problems\n* Use the \"divide and conquer\" strategy to modularize large systems, thereby reducing the difficulty of solving problems.\n\n\nThe context of this section (from highest to current level):\n# Introduction: Overview of Programming Fundamentals\n## The Essence of Programming\n### The core of programming lies in computational thinking (Computational Thinking)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DecompositionScene(Scene):\n\n def construct(self):\n visual_group = VGroup()\n large_problem = Square(side_length=2.5, color=RED, fill_opacity=0.2)\n large_text = Text('Complex\\nProblem', font_size=24).move_to(large_problem.get_center())\n large_group = VGroup(large_problem, large_text)\n arrow = Arrow(start=LEFT, end=RIGHT, color=YELLOW, stroke_width=4, buff=0.1)\n arrow_text = Text('Divide &\\nConquer', font_size=20, color=YELLOW).next_to(arrow, UP, buff=0.2)\n arrow_group = VGroup(arrow, arrow_text)\n sub_problems = VGroup(*[Square(side_length=1.1, color=GREEN, fill_opacity=0.2) for _ in range(4)])\n sub_problems.arrange_in_grid(rows=2, cols=2, buff=0.3)\n sub_text_1 = Text('Sub 1', font_size=20).move_to(sub_problems[0].get_center())\n sub_text_2 = Text('Sub 2', font_size=20).move_to(sub_problems[1].get_center())\n sub_text_3 = Text('Sub 3', font_size=20).move_to(sub_problems[2].get_center())\n sub_text_4 = Text('Sub 4', font_size=20).move_to(sub_problems[3].get_center())\n sub_group = VGroup(sub_problems, sub_text_1, sub_text_2, sub_text_3, sub_text_4)\n visual_group.add(large_group, arrow_group, sub_group)\n visual_group.arrange(RIGHT, buff=0.8)\n visual_group.move_to(ORIGIN + UP * 0.2)\n heading = Text('Decomposition: Breaking down complex problems into manageable sub-problems', font_size=24)\n heading.next_to(visual_group, UP, buff=0.8)\n context_subtitle = Text('The Essence of Programming: Computational Thinking', font_size=22, color=BLUE)\n context_subtitle.next_to(heading, UP, buff=0.4)\n context_title = Text('Introduction: Overview of Programming Fundamentals', font_size=18, color=GRAY)\n context_title.next_to(context_subtitle, UP, buff=0.2)\n bullet = Text(\"- Use the 'divide and conquer' strategy to modularize large systems,\\n thereby reducing the difficulty of solving problems.\", font_size=22, color=LIGHT_GREY)\n bullet.next_to(visual_group, DOWN, buff=0.8)\n self.play(FadeIn(context_title))\n self.play(FadeIn(context_subtitle))\n self.play(Write(heading))\n self.wait(0.5)\n self.play(FadeIn(large_problem), Write(large_text))\n self.wait(0.5)\n self.play(GrowArrow(arrow), FadeIn(arrow_text))\n self.wait(0.5)\n self.play(TransformFromCopy(large_problem, sub_problems[0]), TransformFromCopy(large_problem, sub_problems[1]), TransformFromCopy(large_problem, sub_problems[2]), TransformFromCopy(large_problem, sub_problems[3]), run_time=1.5)\n self.play(FadeIn(sub_text_1), FadeIn(sub_text_2), FadeIn(sub_text_3), FadeIn(sub_text_4))\n self.wait(0.5)\n self.play(Write(bullet))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DecompositionScene(Scene):\n\n def construct(self):\n visual_group = VGroup()\n large_problem = Square(side_length=2.5, color=RED, fill_opacity=0.2)\n large_text = Text('Complex\\nProblem', font_size=24).move_to(large_problem.get_center())\n large_group = VGroup(large_problem, large_text)\n arrow = Arrow(start=LEFT, end=RIGHT, color=YELLOW, stroke_width=4, buff=0.1)\n arrow_text = Text('Divide &\\nConquer', font_size=20, color=YELLOW).next_to(arrow, UP, buff=0.2)\n arrow_group = VGroup(arrow, arrow_text)\n sub_problems = VGroup(*[Square(side_length=1.1, color=GREEN, fill_opacity=0.2) for _ in range(4)])\n sub_problems.arrange_in_grid(rows=2, cols=2, buff=0.3)\n sub_text_1 = Text('Sub 1', font_size=20).move_to(sub_problems[0].get_center())\n sub_text_2 = Text('Sub 2', font_size=20).move_to(sub_problems[1].get_center())\n sub_text_3 = Text('Sub 3', font_size=20).move_to(sub_problems[2].get_center())\n sub_text_4 = Text('Sub 4', font_size=20).move_to(sub_problems[3].get_center())\n sub_group = VGroup(sub_problems, sub_text_1, sub_text_2, sub_text_3, sub_text_4)\n visual_group.add(large_group, arrow_group, sub_group)\n visual_group.arrange(RIGHT, buff=0.8)\n visual_group.move_to(ORIGIN + UP * 0.2)\n heading = Text('Decomposition: Breaking down complex problems into manageable sub-problems', font_size=24)\n heading.next_to(visual_group, UP, buff=0.8)\n context_subtitle = Text('The Essence of Programming: Computational Thinking', font_size=22, color=BBLUE)\n context_subtitle.next_to(heading, UP, buff=0.4)\n context_title = Text('Introduction: Overview of Programming Fundamentals', font_size=18, color=GRAY)\n context_title.next_to(context_subtitle, UP, buff=0.2)\n bullet = Text(\"- Use the 'divide and conquer' strategy to modularize large systems,\\n thereby reducing the difficulty of solving problems.\", font_size=22, color=LIGHT_GREY)\n bullet.next_to(visual_group, DOWN, buff=0.8)\n self.play(FadeIn(context_title))\n self.play(FadeIn(context_subtitle))\n self.play(Write(heading))\n self.wait(0.5)\n self.play(FadeIn(large_problem), Write(large_text))\n self.wait(0.5)\n self.play(GrowArrow(arrow), FadeIn(arrow_text))\n self.wait(0.5)\n self.play(TransformFromCopy(large_problem, sub_problems[0]), TransformFromCopy(large_problem, sub_problems[1]), TransformFromCopy(large_problem, sub_problems[2]), TransformFromCopy(large_problem, sub_problems[3]), run_time=1.5)\n self.play(FadeIn(sub_text_1), FadeIn(sub_text_2), FadeIn(sub_text_3), FadeIn(sub_text_4))\n self.wait(0.5)\n self.play(Write(bullet))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Generate a Manim animation to explain the concept of surface integrals in vector calculus. Visualize the flux of a vector field through a surface, and include a title saying \"Surface Integrals.\"", "chosen": "```python\nfrom manim import *\n\nclass SurfaceIntegrals(Scene):\n def construct(self):\n # Title\n title = Text(\"Surface Integrals\").scale(1.5)\n self.play(Write(title))\n self.wait(1)\n\n # Vector Field Representation (Simplified for clarity)\n vector_field_label = MathTex(\"\\\\vec{F}(x,y,z) = x\\\\hat{i} + y\\\\hat{j} + z\\\\hat{k}\")\n \n # Create some vectors on the plane to represent components of the field\n plane_vectors = VGroup()\n points_on_plane = [(1, 1, 0), (-1, -1, 0), (1, -1, 0)]\n colors = [RED, GREEN, BLUE]\n \n for pt, color in zip(points_on_plane, colors):\n start = np.array(pt)\n end = start + np.array([pt[0], pt[1], 0]) * 1.2 # Scale factor\n vec = Arrow(start=start, end=end, buff=0, color=color)\n \n text = MathTex(f\"v_{chr(ord('A')+points_on_plane.index(pt))}\", font_size=24).next_to(end, UP)\n \n plane_vector_group = VGroup(vec, text)\n plane_vectors.add(plane_vector_group)\n \n self.play(FadeIn(vector_field_label), FadeIn(plane_vectors))\n self.wait(2)\n \n # Flux Visualization (Simulated using areas under curves for simplicity)\n flux_title = Text(\"Flux of \\\\vec F through a closed surface S\", font_size=28).to_edge(DOWN)\n self.play(Write(flux_title))\n self.wait(1)\n\n # Simulate area under curve to show integration\n graph_area = RoundedRectangle(width=6, height=4, corner_radius=0.2, color=YELLOW)\n graph_area.shift(RIGHT*1 + DOWN*1)\n \n integral_text = MathTex(\"\\\\iint_S \\\\vec{n} \\\\cdot d\\\\mathbf{S}\", font_size=28).shift(LEFT*1 + DOWN*1)\n \n self.play(Create(graph_area), Write(integral_text))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\n \"Integral calculates total flow through the surface\",\n font_size=24\n )\n conclusion.next_to(integral_text, DOWN, buff=0.5)\n \n self.play(Write(conclusion))\n self.wait(1)\n \n self.wait(2)\n```", "rejected": "```python\n# Import necessary classes from ManimCommunityEdition\nfrom manim import *\n\nclass SurfaceIntegralsScene(Scene):\n def construct(self):\n # Display the title at the beginning\n title = Text(\"Surface Integrals\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n\n # Create a simple plane representing a surface\n plane = Plane()\n \n # Add grid lines for better visualization\n plane.add_coordinates(x_range=(-2, 2, 1), y_range=(-2, 2, 1))\n\n # Animate the creation of the plane\n self.play(Create(plane))\n self.wait(1)\n\n # Define a vector field represented by arrows on the plane\n vectors = VGroup(\n Arrow(start=plane.n2p([0, 0]), end=plane.n2p([0.5, 0.5])),\n Arrow(start=plane.n2p([-1, -1]), end=plane.n2p([0, 0]))\n )\n vectors.scale_to_fit_width(plane.width * 0.7)\n\n # Show the vectors on the plane\n self.play(Create(vectors))\n self.wait(1)\n\n # Explain the concept of flux\n flux_text = Tex(\"$\\\\text{Flux} = \\\\iint_S \\\\mathbf{n} \\\\cdot \\\\mathbf{F}$\")\n flux_text.to_edge(DOWN, buff=1.5)\n\n # Animate the explanation text appearing below the visual elements\n self.play(Write(flux_text))\n self.wait(2)\n\n # Clear the screen to demonstrate transformation\n self.play(FadeOut(VGroup(plane, vectors, flux_text)))\n\n # Transform the equation using ReplacementTransform to show substitution\n transformed_flux = MathTex(\"\\\\text{Flux} = \\\\frac{1}{2} \\\\times 1 \\\\times |\\\\mathbf{F}|\")\n transformed_flux.to_edge(DOWN, buff=1.5)\n\n # Perform the replacement transformation smoothly\n self.play(ReplacementTransform(flux_text, transformed_flux))\n self.wait(1)\n\n # Fade out everything to conclude the scene\n self.play(FadeOut(transformed_flux))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 produced by that local linearization.", "chosen": "```python\nfrom manim import *\n\nclass LinearJacobian(Scene):\n def construct(self):\n # --- Configuration ---\n POINT_COLOR = YELLOW\n VECTOR_LENGTH = 1.5\n \n # Create coordinate system\n axes = Axes(\n x_range=[-6, 7], \n y_range=[-3, 8],\n x_length=6,\n y_length=6\n ).shift(LEFT * 2)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Initial Point A\n A_start = np.array([2, 1, 0])\n dot_A = Dot(point=A_start, color=POINT_COLOR, radius=0.1)\n label_A = MathTex(\"A\").next_to(dot_A, UR)\n\n # Input Arrow OA -> OB\n ob_end = np.array([3.3, 1.5, 0]) # Small displacement from A\n vector_OA = Arrow(start=ORIGIN, end=dot_A.get_center(), color=WHITE)\n vector_AB = Arrow(start=dot_A.get_center(), end=ob_end + dot_A.get_center(), color=GREEN)\n\n # Formula for derivative\n deriv_eq = MathTex(\"\\\\frac{d}{dx} f(A) \\\\approx J_{f,A}(\\\\Delta x)\")\n deriv_eq.to_edge(UP)\n \n # Local linear approximation formula\n lin_approx = MathTex(\"f(B) \\\\approx f(A) + J_{f,A}(B-A)\", \"\\\\text{(linear approximation)}\")\n lin_approx.arrange(DOWN).to_edge(UR)\n \n # Display Matrix of partial derivatives\n jacobian_matrix = MathTex(\n r\"J_{f,A}\", \"=\", r\"\\begin{bmatrix}\"\n r\"\\frac{\\partial f}{\\partial x}_A\", \"&\", r\"\\frac{\\partial f}{\\partial y}_A\"\n r\"\\end{bmatrix}\"\n )\n jacobian_box = SurroundingRectangle(jacobian_matrix, buff=0.2, color=YELLOW)\n jacobian_group = VGroup(jacobian_matrix, jacobian_box).scale(0.8)\n jacobian_group.next_to(lin_approx, DOWN, buff=0.5).align_to(lin_approx, LEFT)\n\n # Transform vectors to final state\n ob_final = np.array([4.2, 1.9, 0]) # Final position based on J(f,A)(B-A)\n vector_OA_final = Arrow(start=ORIGIN, end=ob_final, color=WHITE)\n vector_B = Arrow(start=dot_A.get_center(), end=ob_final, color=RED)\n\n self.play(Create(axes), Write(axis_labels))\n self.wait(0.5)\n\n # Step 1: Draw initial point and vectors\n self.play(FadeIn(dot_A), FadeIn(label_A))\n self.wait(0.5)\n\n self.play(GrowArrow(vector_OA), GrowArrow(vector_AB))\n self.wait(0.5)\n\n # Step 2: Animate derivative formula appearing\n self.play(Write(deriv_eq))\n self.wait(1)\n\n # Step 3: Reveal matrix representation\n self.play(Write(lin_approx[0]))\n self.play(Create(jacobian_box), Write(jacobian_matrix[0]), Write(jacobian_matrix[1]))\n self.wait(1.5)\n\n # Step 4: Update vectors using the derived transformation\n self.play(TransformFromCopy(vector_AB, vector_OA_final), TransformFromCopy(vector_AB, vector_B))\n self.wait(1.5)\n\n # Conclusion text\n conclusion_text = Text(\"This is how we approximate functions locally!\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion_text))\n\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass JacobianExplanation(Scene):\n def construct(self):\n # --- Step 1: Visual Setup ---\n \n title = Text(\"Jacobian as Local Linear Map\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Define coordinate system limits for better visual flow during transformations\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n tips=False,\n x_length=7,\n y_length=7\n ).shift(LEFT * 3 + DOWN * 0.8)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n self.add(axes, labels)\n\n # Place a fixed reference point P at coordinates (-2, 1) \n ref_point = Dot(axes.c2p(-2, 1))\n ref_label = MathTex(\"P\").next_to(ref_point, UR, buff=0.2)\n\n # Display the function text near the top of the screen\n func_text = Tex(\"Given Function:\\\\\\\\$f(P+h)=f(P)+A_h$\", font_size=24).to_edge(UP, buff=0.8)\n self.play(Write(func_text))\n\n # Animate moving the reference dot from the origin along the positive x-axis\n self.play(FadeIn(ref_point), Write(ref_label), run_time=2)\n self.wait(1)\n\n # Input vector represented by a blue arrow pointing rightwards\n input_arrow_start = axes.c2p(-2, 1)\n input_vector = Arrow(start=input_arrow_start, end=input_arrow_start + RIGHT*1.5, color=BLUE, stroke_width=4)\n \n # Label for the input direction\n input_label = MathTex(\"\\\\Delta x \\\\rightarrow h_x\").scale(0.6).next_to(input_vector, UP, buff=0.2)\n\n self.play(GrowFromCenter(input_vector), FadeIn(input_label), run_time=2)\n\n # --- Step 2: Mathematical Transformation ---\n\n # Transform the equation showing f(P+h) -> A(h_x, h_y)\n eq_step1 = MathTex(\"f(P+h)\", r\"\\approx \", \"f(P)\", \"+\", \"\\\\begin{bmatrix}a_{11}&a_{12}\\\\a_{21}&a_{22}\\end{bmatrix}\", \"\\\\begin{pmatrix}h_x \\\\\\\\ h_y\\\\end{pmatrix}\")\n eq_step1.scale(0.7).to_edge(DOWN, buff=1.5)\n eq_step1.move_to(eq_step1.get_center())\n\n # Highlight corresponding elements visually\n box_a11 = SurroundingRectangle(eq_step1[5], corner_radius=0.15, color=YELLOW)\n box_hx = SurroundingRectangle(eq_step1[9], corner_radius=0.15, color=GREEN)\n \n self.play(Write(eq_step1[0:5]), run_time=1.5)\n self.play(Create(box_a11), Indicate(eq_step1[5][0:2]), run_time=1)\n self.play(Write(eq_step1[5][2:4]), run_time=1)\n self.play(Write(eq_step1[5][4:6]), run_time=1)\n \n self.wait(0.5)\n \n # Display the specific matrix values\n jacobian_mat = Matrix([[1.2, -0.8], [0.4, -0.3]]).scale(0.6)\n jacobian_mat.next_to(eq_step1, LEFT, buff=1.5)\n jacobian_mat.shift(UP * 0.3) # Align vertically\n \n mat_box = SurroundingRectangle(jacobian_mat, color=RED, buff=0.1)\n label_jac = MathTex(\"J(P)\").set_color(RED).next_to(mat_box, UP, buff=-0.1)\n \n self.play(Write(label_jac), Create(mat_box))\n self.play(Write(jacobian_mat), run_time=2)\n self.wait(1)\n\n # --- Step 3: Result Visualization ---\n \n # Draw the resulting transformed arrow (output vector)\n result_vec_end = axes.c2p(-0.5, 1.2) # Approximate calculation based on given J(P)\n result_vector = Arrow(start=ref_point.get_center(), end=result_vec_end, color=GREEN, stroke_width=4)\n \n # Add a label indicating the displacement due to the transformation\n result_label = MathTex(\"\\\\text{Linearized change } \\\\Delta y\", r\" \\approx \", \"-1.2\", \"+\", \"-0.8\", \"=\", \"-2.0\").scale(0.7)\n result_label.next_to(result_vector, DOWN, buff=0.5)\n \n self.play(GrowFromPoint(result_vector, ref_point.get_center()), Write(result_label), run_time=2)\n self.wait(1)\n \n\n# To render this animation locally, save it to your file system with a .py extension\n# Then execute 'manim -pql filename.py JacobianExplanation'\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that visually explains the convergence of the series sum from n equals 1 to infinity of 1 over n squared using the p-test? The animation should introduce the series, explain how to use the p-test for convergence by displaying a condition, apply the p-test to show that the series converges because p equals 2 is greater than 1, and conclude by stating that the series is convergent. Can you also ensure that each part of the explanation is displayed clearly before moving on to the next, and at the end, clear everything and display the final conclusion again for emphasis?", "chosen": "```python\nfrom manim import *\n\nclass PTestConvergence(Scene):\n def construct(self):\n # ==========================================\n # Step 1: Introduction\n # Visually introduce the series\n # ==========================================\n intro_text = Text(\"Consider the following series:\", font_size=36)\n series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=60)\n \n intro_group = VGroup(intro_text, series).arrange(DOWN, buff=0.5)\n intro_group.to_edge(UP, buff=1)\n \n self.play(Write(intro_text), Write(series))\n self.wait(1)\n \n # ==========================================\n # Step 2: Rule Explanation\n # Display the condition for the p-test\n # ==========================================\n rule_title = Text(\"The p-Series Test:\", font_size=36, color=BLUE)\n rule_converge = MathTex(\n r\"\\sum \\frac{1}{n^p} \\quad \\text{converges if} \\quad p > 1\",\n font_size=40, color=GREEN\n )\n rule_diverge = MathTex(\n r\"\\text{and diverges if} \\quad p \\le 1\",\n font_size=40, color=RED\n )\n \n rule_group = VGroup(rule_title, rule_converge, rule_diverge).arrange(DOWN, buff=0.3)\n rule_group.next_to(intro_group, DOWN, buff=1)\n \n self.play(Write(rule_title), Write(rule_converge))\n self.play(Write(rule_diverge))\n self.wait(2)\n \n # ==========================================\n # Step 3: Application\n # Apply the test to the specific series (p = 2)\n # ==========================================\n # Highlight the exponent in the original series\n series_box = SurroundingRectangle(series[0][4], color=YELLOW, buff=0.1)\n \n # Identify p value\n p_identification = MathTex(r\"p = 2\", font_size=45, color=YELLOW)\n p_identification.next_to(rule_group, DOWN, buff=0.8)\n \n # Show the inequality check\n inequality_check = MathTex(r\"2 > 1\", font_size=45, color=GREEN)\n inequality_check.next_to(p_identification, DOWN, buff=0.4)\n \n logic_text = Text(\"Since p > 1, the condition is met.\", font_size=30)\n logic_text.next_to(inequality_check, DOWN, buff=0.4)\n \n self.play(Create(series_box))\n self.play(Write(p_identification))\n self.wait(0.5)\n self.play(Write(inequality_check))\n self.play(Write(logic_text))\n self.wait(2)\n \n # ==========================================\n # Step 4: Conclusion\n # State clearly that the series is convergent\n # ==========================================\n conclusion = Text(\"Therefore, the series is convergent!\", font_size=42, color=GREEN)\n conclusion_box = SurroundingRectangle(conclusion, color=WHITE, buff=0.2)\n conclusion_group = VGroup(conclusion, conclusion_box).next_to(logic_text, DOWN, buff=0.6)\n \n self.play(Write(conclusion), Create(conclusion_box))\n self.wait(2)\n \n # ==========================================\n # Step 5: Emphasis\n # Clear everything and redisplay final conclusion\n # ==========================================\n all_elements = VGroup(\n intro_group, \n rule_group, \n series_box, \n p_identification, \n inequality_check, \n logic_text, \n conclusion_group\n )\n \n # Fade out all previous elements\n self.play(FadeOut(all_elements))\n \n # Display final conclusion prominently in the center\n final_conclusion = Text(\"The Series Converges\", font_size=72, color=GREEN, weight=BOLD)\n final_box = SurroundingRectangle(final_conclusion, color=YELLOW, buff=0.3)\n final_group = VGroup(final_conclusion, final_box).center()\n \n self.play(Write(final_conclusion), Create(final_box))\n self.play(Indicate(final_conclusion))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass PTestConvergence(Scene):\n def construct(self):\n # ==========================================\n # Step 1: Introduction\n # Visually introduce the series\n # ==========================================\n intro_text = Text(\"Consider the following series:\", font_size=36)\n series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=60)\n \n intro_group = VGroup(intro_text, series).arrange(DOWN, buff=0.5)\n intro_group.to_edge(UP, buff=1)\n \n self.play(Write(intro_text), Write(series))\n self.wait(1)\n \n # ==========================================\n # Step 2: Rule Explanation\n # Display the condition for the p-test\n # ==========================================\n rule_title = Text(\"The p-Series Test:\", font_size=36, color=BBLUE)\n rule_converge = MathTex(\n r\"\\sum \\frac{1}{n^p} \\quad \\text{converges if} \\quad p > 1\",\n font_size=40, color=GREEN\n )\n rule_diverge = MathTex(\n r\"\\text{and diverges if} \\quad p \\le 1\",\n font_size=40, color=RED\n )\n \n rule_group = VGroup(rule_title, rule_converge, rule_diverge).arrange(DOWN, buff=0.3)\n rule_group.next_to(intro_group, DOWN, buff=1)\n \n self.play(Write(rule_title), Write(rule_converge))\n self.play(Write(rule_diverge))\n self.wait(2)\n \n # ==========================================\n # Step 3: Application\n # Apply the test to the specific series (p = 2)\n # ==========================================\n # Highlight the exponent in the original series\n series_box = SurroundingRectangle(series[0][4], color=YELLOW, buff=0.1)\n \n # Identify p value\n p_identification = MathTex(r\"p = 2\", font_size=45, color=YELLOW)\n p_identification.next_to(rule_group, DOWN, buff=0.8)\n \n # Show the inequality check\n inequality_check = MathTex(r\"2 > 1\", font_size=45, color=GREEN)\n inequality_check.next_to(p_identification, DOWN, buff=0.4)\n \n logic_text = Text(\"Since p > 1, the condition is met.\", font_size=30)\n logic_text.next_to(inequality_check, DOWN, buff=0.4)\n \n self.play(Create(series_box))\n self.play(Write(p_identification))\n self.wait(0.5)\n self.play(Write(inequality_check))\n self.play(Write(logic_text))\n self.wait(2)\n \n # ==========================================\n # Step 4: Conclusion\n # State clearly that the series is convergent\n # ==========================================\n conclusion = Text(\"Therefore, the series is convergent!\", font_size=42, color=GREEN)\n conclusion_box = SurroundingRectangle(conclusion, color=WHITE, buff=0.2)\n conclusion_group = VGroup(conclusion, conclusion_box).next_to(logic_text, DOWN, buff=0.6)\n \n self.play(Write(conclusion), Create(conclusion_box))\n self.wait(2)\n \n # ==========================================\n # Step 5: Emphasis\n # Clear everything and redisplay final conclusion\n # ==========================================\n all_elements = VGroup(\n intro_group, \n rule_group, \n series_box, \n p_identification, \n inequality_check, \n logic_text, \n conclusion_group\n )\n \n # Fade out all previous elements\n self.play(FadeOut(all_elements))\n \n # Display final conclusion prominently in the center\n final_conclusion = Text(\"The Series Converges\", font_size=72, color=GREEN, weight=BOLD)\n final_box = SurroundingRectangle(final_conclusion, color=YELLOW, buff=0.3)\n final_group = VGroup(final_conclusion, final_box).center()\n \n self.play(Write(final_conclusion), Create(final_box))\n self.play(Indicate(final_conclusion))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the nature of geodesics on a torus, and how do they differ from geodesics on a sphere?", "chosen": "```python\nfrom manim import *\n\nclass TorusGeodesicScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Torus Geodesics vs Spherical Cap Curves\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n # Create a simple 2D representation of a torus for visual clarity\n torus_plane = RoundedRectangle(width=3.5, height=1.8, corner_radius=0.1, color=TEAL_D)\n torus_plane.shift(LEFT * 2.5 + DOWN * 1.2)\n \n torus_label = Text(\"Torus Surface\", font_size=24).next_to(torus_plane, UP)\n self.add(torus_plane)\n self.play(FadeIn(torus_label, shift=DOWN * 0.2))\n\n # Draw a geodesic curve on the torus surface\n torus_geod = Circle(radius=0.7, color=YELLOW, stroke_width=4).shift(RIGHT*1.5)\n torus_path = VMobject()\n torus_path.set_points_as_corners([ORIGIN, RIGHT*1.5, RIGHT*1.5])\n \n # Add dots along the path to show directionality\n dot_start = Dot(torus_path.get_start(), color=RED)\n dot_end = Dot(torus_path.get_end(), color=GREEN)\n\n torus_desc = Text(\n \"Curves that follow the shortest distance between points\\non the surface\",\n font_size=24,\n t2c={\"surface\": BLUE}\n ).next_to(dot_end, DOWN, buff=0.5)\n\n self.play(Create(torus_path), FadeIn(dot_start, dot_end), Write(torus_desc))\n \n # Show how it differs from spherical cap curves by comparing them briefly\n sphere_cap_text = Text(\"Spherical Caps\", font_size=24, color=BLUE).to_edge(DOWN)\n self.play(Transform(title, sphere_cap_text), FadeOut(torus_label, torus_plane))\n self.wait()\n\n # Simple circle representing a sphere\n sphere_circle = Circle(radius=1.5, color=PURPLE)\n sphere_center = Point().set_color(PURPLE)\n sphere_title = Text(\"Sphere Geometry\", font_size=28).to_edge(UP)\n self.play(FadeIn(sphere_circle), FadeIn(sphere_center), Write(sphere_title))\n self.wait()\n\n # An arc showing how great circles intersect at poles\n pole_arc = Arc(start_angle=PI/4, angle=-PI/2, radius=1.5, color=WHITE)\n pole_pole_labels = VGroup(Text(\"+Pole\"), Text(\"-Pole\")).arrange(DOWN, buff=0.2).move_to(pole_arc.point_from_proportion(0.5) + UP * 0.3)\n pole_arrow = Arrow(ORIGIN, UP * 1.5, color=BLUE)\n pole_label = Text(\"Great Circles Intersect Poles\", font_size=24, color=BLUE).next_to(pole_arrow, LEFT, buff=0.3)\n\n self.play(Create(pole_arrow), Write(pole_label), Create(pole_arc), FadeIn(pole_pole_labels))\n self.wait()\n\n # Conclusion\n conclusion = Text(\n \"On a torus, geodesics may loop around the tube,\\nwhereas on a sphere, paths return to their start.\",\n font_size=24,\n line_spacing=1.2\n )\n \n final_box = SurroundingRectangle(conclusion, color=GRAY, fill_opacity=0.1)\n self.play(Write(final_box), Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass GeodesicTorusSphere(Scene):\n def construct(self):\n # Title\n title = Text(\"Geodesics on Tori and Spheres\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n\n # Create a simple spherical surface for the sphere example\n sphere = Sphere(radius=1.5, resolution=(64, 32)).set_color(YELLOW)\n \n # Create a cross-section plane for visualizing geodesic paths\n plane = Rectangle(width=4, height=1).shift(RIGHT * 1.8 + UP * 0.5).rotate(-PI / 4).set_stroke(WHITE, 2)\n \n # Define two points on the sphere to show the geodesic path between them\n start_point = Dot(sphere.get_center(), color=RED).scale(0.7)\n end_point = Dot(sphere.get_center() + RIGHT * 1.5 + UP * 1.5, color=GREEN).scale(0.7)\n \n # Draw the geodesic line between the two points on the sphere\n geode_path_sphere = ArcBetweenPoints(start_point.get_center(), end_point.get_center(), angle=-PI / 4, radius=1.5).set_stroke(PURPLE, 2)\n\n # Display the first scenario: Geodesics on a sphere\n sphere_title = Text(\"Spherical Surface\", font_size=30).next_to(plane, DOWN)\n self.play(Create(sphere), FadeIn(end_point), FadeIn(start_point), Write(plane), Write(sphere_title))\n self.play(DrawBorderThenFill(geode_path_sphere))\n self.wait(2)\n\n # Clear the screen for the second part about tori\n self.play(FadeOut(all_mobs) for all_mobs in [title, sphere, end_point, start_point, plane, sphere_title])\n \n # Create a simple circular torus shape for visualization purposes\n torus_shape = Circle(radius=1.5, color=YELLOW).shift(LEFT * 2 + UP * 0.5)\n \n # Show internal ring representing the tube of the torus\n inner_circle_torus = Circle(radius=0.4, color=WHITE).move_to(torus_shape.get_center()).rotate(-PI / 4)\n \n # Animate construction of the torus\n torus_animation = Create(torus_shape)\n inner_anima = Create(inner_circle_torus)\n self.play(torus_animation, inner_anima)\n \n # Add labels indicating the major and minor radii\n label_major = MathTex(\"R\").scale(1.5).next_to(torus_shape.get_right(), DOWN, buff=0.5)\n label_minor = MathTex(\"r\").scale(1.5).next_to(torus_shape.get_left(), DOWN, buff=1.5)\n \n self.play(\n Write(label_major),\n Write(label_minor)\n )\n \n # Visualize the direction vectors along the surface \n # (These represent the curvature directions at different positions)\n vector_a = Arrow(torus_shape.get_center(), torus_shape.get_center() + LEFT*1.2, color=ORANGE)\n vector_b = Arrow(torus_shape.get_center(), torus_shape.get_center() + UP*0.8, color=PINK)\n \n self.play(ShowPassingFlash(vector_a), ShowPassingFlash(vector_b))\n\n # Transition text\n transition_text = Text(\"Transition to...\", font_size=30)\n transition_text.next_to(torus_shape, UP, buff=0.5)\n self.play(Write(transition_text))\n self.wait(1)\n \n # Remove transition text and prepare for toroidal geometry explanation\n self.play(FadeOut(transition_text))\n \n # Simplified polygonal representation of a torus\n toroid_poly = Polygon([-1,-1,0], [-1,1,0], [1,1,0], [1,-1,0]).scale(1.2)\n toroid_poly.set_fill(GREEN, opacity=0.3)\n toroid_poly.set_stroke(GRAY, width=2)\n \n # Move it to make room for equations below\n self.play(Transform(torus_shape, toroid_poly), RunTime=1.5)\n \n # Explanation text for toroidal geometry\n eq_tex = MathTex(\"\\\\text{Toroidal Geometry } \\\\rightarrow\")\n eq_tex.to_edge(UP, buff=0.5)\n \n UILabels = VGroup()\n UILabelLabels.add(MathTex(\"\\\\text{Major Radius: } R\"))\n UILabelLabels.add(MathTex(\"\\\\text{Minor Radius: } r\"))\n UILabelLabels.arrange(direction=DOWN, aligned_edge=LEFT, buff=0.3)\n UILabelLabels.scale(0.8)\n UILabelLabels.to_edge(UP, buff=1.5)\n UILabelLabels.shift(LEFT * 0.2)\n \n self.play(Write(eq_tex))\n self.play(Write(UILabelLabels))\n \n\n # Second Scenario: Geodesics on a torus\n\n # Clear current objects and display new text\n self.play(FadeOut(torus_shape), FadeOut(UILabelLabels))\n self.wait(1)\n\n # Display new title\n torus_title = Text(\"Tori: Curved Surfaces\", font_size=30)\n torus_description = Text(\"Similar to spheres but twisted!\", font_size=24).next_to(torus_title, DOWN)\n self.play(Write(torus_title), Write(torus_description))\n self.wait(1)\n\n # Create a simpler grid-like pattern to illustrate torus topology\n grid_rows = 4\n grid_cols = 4\n \n dots = []\n lines_horizontal = []\n lines_vertical = []\n\n # Generate dots arranged in a grid\n dot_radius = 0.1\n spacing = 1.2\n\n for i in range(grid_rows):\n row_dots = []\n \n for j in range(grid_cols):\n x = (j - (grid_cols - 1) / 2) * spacing\n y = (i - (grid_rows - 1) / 2) * spacing\n \n dot = Dot([x, y, 0], radius=dot_radius, color=BLUE)\n row_dots.append(dot)\n \n if len(row_dots) > 1:\n prev_dot = row_dots[-2]\n line_h = Line(prev_dot.get_center(), dot.get_center(), stroke_width=1, stroke_opacity=0.5)\n \n if i == 0:\n lines_horizontal.append(line_h)\n \n else:\n vertical_line_start_y = ((i-1)-((grid_rows-1)/2))*spacing\n vertical_line_end_y = ((i)+((grid_rows-1)/2))*spacing\n \n offset = (vertical_line_start_y-vertical_line_end_y)*0.3\n vertical_offset_line = Line(\n prev_dot.get_center()[0]-offset, prev_dot.get_center()[1],\n dot.get_center()[0]+offset, dot.get_center()[1],\n stroke_width=1, stroke_opacity=0.3,\n color=GRAY\n )\n lines_vertical.append(vertical_offset_line)\n\n dots.extend(row_dots)\n\n # Group everything together\n torus_grid_group = VGroup(VGroup(*dots), VGroup(*lines_horizontal), VGroup(*lines_vertical))\n\n # Position the grid slightly off-center to make room for other elements\n torus_grid_group.move_to(ORIGIN)\n\n #Animate creation of the grid\n self.play(LaggedStart(*[Create(d) for d in dots], lag_ratio=0.1))\n self.wait(0.5)\n \n #Draw horizontal connections\n self.play(LaggedStart(*[Create(l) for l in lines_horizontal], lag_ratio=0.1))\n self.wait(0.5)\n \n #Draw vertical connections\n self.play(LaggedStart(*[Create(vl) for vl in lines_vertical], lag_ratio=0.1))\n self.wait(0.5)\n\n\n # Highlight some specific cells to demonstrate periodicity\n highlight_cells = [\n [0, 0],\n [1, 1],\n [2, 2],\n [3, 3]\n ]\n\n # Get corresponding dots for highlighting\n highlight_dots = [dots[row * grid_cols + col] for row, col in highlight_cells]\n\n # Color-highlight selected dots\n self.play(\n *[ApplyMethod(hd.set_color(RED).scale(1.5)) for hd in highlight_dots]\n )\n\n # Show equation for comparison\n equation = MathTex(\"\\\\text{Curvature Pattern: } k_{\\\\perp}^2 = \\\\frac{1}{R^2} + \\\\frac{1}{r^2}\")\n equation.to_corner(UL)\n equation.shift(DOWN * 0.5)\n\n self.play(Write(equation))\n self.wait(3)\n\n # Clean up for final conclusion\n self.play(\n FadeOut(torus_title),\n FadeOut(torus_description),\n FadeOut(torus_grid_group),\n FadeOut(highlight_dots),\n FadeOut(lines_horizontal),\n FadeOut(lines_vertical),\n FadeOut(equation)\n )\n\n # Final Conclusion\n conclusion = Text(\"The nature of geodesics depends on the underlying geometry.\", font_size=30)\n self.play(Write(conclusion))\n self.wait(1)\n\n # Simple arrow to compare\n arrow = Arrow(\n ORIGIN,\n RIGHT\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "In what creative way can a bifurcation diagram illustrate the process of equilibrium selection in coordination games?", "chosen": "```python\nfrom manim import *\n\nclass EquilibriumSelectionScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling Equilibrium: The Dance of Coordination\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Element 1: Crowd scene - representing coordination games\n crowd_text = Text(\"Coordination Games\", font_size=28)\n crowd_text.to_edge(UP)\n \n # Create a crowd as scattered dots\n crowd = VGroup()\n for _ in range(10):\n dot = Dot(radius=0.1, color=BLUE)\n dot.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-3, 3), 0]))\n crowd.add(dot)\n \n self.play(Write(crowd_text))\n self.play(FadeIn(crowd))\n self.wait(1)\n \n # Element 2: Bifurcation diagram introduction\n bifurcation_text = Text(\"Bifurcation Diagram\", font_size=28)\n bifurcation_text.to_edge(UP)\n \n self.play(Transform(crowd_text, bifurcation_text))\n self.play(FadeOut(crowd))\n \n # Create axes for the bifurcation diagram\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 1, 0.25],\n axis_config={\"color\": BLUE},\n )\n \n # Logistic map equation\n equation = MathTex(\"f(x) = rx(1-x)\")\n equation.next_to(axes, DOWN)\n \n self.play(Create(axes), Write(equation))\n self.wait(1)\n \n # Element 3: Player strategies as dots on the bifurcation diagram\n strategies_text = Text(\"Player Strategies\", font_size=28)\n strategies_text.to_edge(UP)\n \n self.play(Transform(crowd_text, strategies_text))\n \n # Create simplified bifurcation points (red dots)\n dots = VGroup()\n for r in [1, 2, 3, 3.5]:\n if r < 3:\n # Single stable point before bifurcation\n x = 0.6\n dot = Dot(axes.c2p(r, x), color=RED, radius=0.05)\n dots.add(dot)\n else:\n # Bifurcation: two stable points\n dot1 = Dot(axes.c2p(r, 0.8), color=RED, radius=0.05)\n dot2 = Dot(axes.c2p(r, 0.4), color=RED, radius=0.05)\n dots.add(dot1, dot2)\n \n # Player strategy dots (green) showing decision points\n strategy1 = Dot(axes.c2p(2, 0.6), color=GREEN, radius=0.1)\n strategy2 = Dot(axes.c2p(3.5, 0.8), color=GREEN, radius=0.1)\n \n self.play(Create(dots))\n self.play(Create(strategy1), Create(strategy2))\n self.wait(1)\n \n # Element 4: Parameter shift showing effect on equilibria\n shift_text = Text(\"Parameter Shift\", font_size=24, color=YELLOW)\n shift_text.to_edge(DOWN)\n \n self.play(Write(shift_text))\n # Animate strategy shift to show changing equilibrium\n self.play(strategy1.animate.move_to(axes.c2p(3.5, 0.4)))\n self.wait(1)\n \n # Element 5: Highlight stability regions for equilibrium selection\n stability_text = Text(\"Equilibrium Selection\", font_size=28)\n stability_text.to_edge(UP)\n \n self.play(Transform(crowd_text, stability_text))\n \n # Highlight stable and unstable regions\n stable_region = Rectangle(width=2, height=0.3, color=GREEN_A, fill_opacity=0.3)\n stable_region.move_to(axes.c2p(2, 0.6))\n \n unstable_region = Rectangle(width=1, height=0.5, color=RED_A, fill_opacity=0.3)\n unstable_region.move_to(axes.c2p(3.5, 0.6))\n \n self.play(Create(stable_region), Create(unstable_region))\n self.wait(1)\n \n # Element 6: Conclusion - bringing it all together\n self.play(\n FadeOut(crowd_text),\n FadeOut(dots),\n FadeOut(strategy1),\n FadeOut(strategy2),\n FadeOut(shift_text),\n FadeOut(stable_region),\n FadeOut(unstable_region),\n FadeOut(equation),\n FadeOut(axes)\n )\n \n # Final message and equation\n conclusion_text = Text(\"Bifurcation reveals coordination dynamics\", font_size=28)\n final_equation = MathTex(r\"x^* = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\")\n final_equation.next_to(conclusion_text, DOWN)\n \n self.play(Write(conclusion_text))\n self.play(Write(final_equation))\n self.wait(2)\n \n self.play(FadeOut(conclusion_text), FadeOut(final_equation))\n```", "rejected": "```python\nfrom manim import *\n\nclass EquilibriumSelectionScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling Equilibrium: The Dance of Coordination\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Element 1: Crowd scene - representing coordination games\n crowd_text = Text(\"Coordination Games\", font_size=28)\n crowd_text.to_edge(UP)\n \n # Create a crowd as scattered dots\n crowd = VGroup()\n for _ in range(10):\n dot = Dot(radius=0.1, color=BLUE)\n dot.move_to(np.array([np.random.uniform(-5, 5), np.random.uniform(-3, 3), 0]))\n crowd.add(dot)\n \n self.play(Write(crowd_text))\n self.play(FadeIn(crowd))\n self.wait(1)\n \n # Element 2: Bifurcation diagram introduction\n bifurcation_text = Text(\"Bifurcation Diagram\", font_size=28)\n bifurcation_text.to_edge(UP)\n \n self.play(Transform(crowd_text, bifurcation_text))\n self.play(FadeOut(crowd))\n \n # Create axes for the bifurcation diagram\n axes = Axes(label_font_size=24, \n x_range=[0, 4, 1],\n y_range=[0, 1, 0.25],\n axis_config={\"color\": BLUE},\n )\n \n # Logistic map equation\n equation = MathTex(\"f(x) = rx(1-x)\")\n equation.next_to(axes, DOWN)\n \n self.play(Create(axes), Write(equation))\n self.wait(1)\n \n # Element 3: Player strategies as dots on the bifurcation diagram\n strategies_text = Text(\"Player Strategies\", font_size=28)\n strategies_text.to_edge(UP)\n \n self.play(Transform(crowd_text, strategies_text))\n \n # Create simplified bifurcation points (red dots)\n dots = VGroup()\n for r in [1, 2, 3, 3.5]:\n if r < 3:\n # Single stable point before bifurcation\n x = 0.6\n dot = Dot(axes.c2p(r, x), color=RED, radius=0.05)\n dots.add(dot)\n else:\n # Bifurcation: two stable points\n dot1 = Dot(axes.c2p(r, 0.8), color=RED, radius=0.05)\n dot2 = Dot(axes.c2p(r, 0.4), color=RED, radius=0.05)\n dots.add(dot1, dot2)\n \n # Player strategy dots (green) showing decision points\n strategy1 = Dot(axes.c2p(2, 0.6), color=GREEN, radius=0.1)\n strategy2 = Dot(axes.c2p(3.5, 0.8), color=GREEN, radius=0.1)\n \n self.play(Create(dots))\n self.play(Create(strategy1), Create(strategy2))\n self.wait(1)\n \n # Element 4: Parameter shift showing effect on equilibria\n shift_text = Text(\"Parameter Shift\", font_size=24, color=YELLOW)\n shift_text.to_edge(DOWN)\n \n self.play(Write(shift_text))\n # Animate strategy shift to show changing equilibrium\n self.play(strategy1.animate.move_to(axes.c2p(3.5, 0.4)))\n self.wait(1)\n \n # Element 5: Highlight stability regions for equilibrium selection\n stability_text = Text(\"Equilibrium Selection\", font_size=28)\n stability_text.to_edge(UP)\n \n self.play(Transform(crowd_text, stability_text))\n \n # Highlight stable and unstable regions\n stable_region = Rectangle(width=2, height=0.3, color=GREEN_A, fill_opacity=0.3)\n stable_region.move_to(axes.c2p(2, 0.6))\n \n unstable_region = Rectangle(width=1, height=0.5, color=RED_A, fill_opacity=0.3)\n unstable_region.move_to(axes.c2p(3.5, 0.6))\n \n self.play(Create(stable_region), Create(unstable_region))\n self.wait(1)\n \n # Element 6: Conclusion - bringing it all together\n self.play(\n FadeOut(crowd_text),\n FadeOut(dots),\n FadeOut(strategy1),\n FadeOut(strategy2),\n FadeOut(shift_text),\n FadeOut(stable_region),\n FadeOut(unstable_region),\n FadeOut(equation),\n FadeOut(axes)\n )\n \n # Final message and equation\n conclusion_text = Text(\"Bifurcation reveals coordination dynamics\", font_size=28)\n final_equation = MathTex(r\"x^* = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\")\n final_equation.next_to(conclusion_text, DOWN)\n \n self.play(Write(conclusion_text))\n self.play(Write(final_equation))\n self.wait(2)\n \n self.play(FadeOut(conclusion_text), FadeOut(final_equation))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a ManimCE scene (`DynamicAreaScene`) using `ValueTracker`, `always_redraw`, `Axes`, and `axes.get_area(...)` with zero undefined symbols.", "chosen": "```python\nfrom manim import *\n\nclass DynamicAreaScene(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-2, 6, 1]\n )\n \n # Add a function to track area under curve\n func = lambda x : 0.5*(x**2) + 1\n graph = axes.plot(func)\n \n # Show area under the curve from x=-2 to x=2\n area = axes.get_area(graph, x_range=(-2, 2))\n \n # Display labels for the bounds of integration\n label_left = MathTex(\"a\", color=RED).next_to(axes.c2p(-2, 0), DOWN, buff=0.2)\n label_right = MathTex(\"b\", color=GREEN).next_to(axes.c2p(2, 0), DOWN, buff=0.2)\n \n # Animation logic\n self.play(Create(axes), Create(graph))\n self.play(FadeIn(label_left), FadeIn(label_right))\n self.play(Write(area))\n self.wait()\n \n # Update the upper bound to x=1 and recalculate the area\n new_label_right = MathTex(\"c\", color=YELLOW).move_to(label_right.get_center())\n updated_area = axes.get_area(graph, x_range=(-2, 1))\n \n self.play(Transform(label_right, new_label_right), Transform(area, updated_area))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass DynamicAreaScene(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-2, 6],\n y_range=[-1, 7],\n x_length=8,\n y_length=7,\n tips=False,\n )\n \n # Add labels for clarity\n axes_labels = axes.get_axes_labels(x_label=\"t\", y_label=\"f(t)\")\n \n self.play(Create(axes), Write(axes_labels))\n self.wait()\n\n # Define the function f(t) = t^2 + 1\n func_def = MathTex(\"f(t)\", \"=\", \"t^2+\", \"+1\")\n func_def.to_edge(DOWN)\n self.play(Write(func_def))\n self.wait()\n \n\n # Plot the curve of the function on the axes\n graph = axes.plot(lambda t: t**2 + 1, color=GREEN)\n graph_label = axes.get_graph_label(graph, label='t^2 + 1', direction=UR)\n\n self.play(Create(graph), Write(graph_label)) \n self.wait()\n \n \n # Value tracker for changing the area parameter\n param_tracker = ValueTracker(-2)\n \n # Function that returns the area from left_bound to current value of param_tracker\n def get_current_area(left_bound=-2):\n return axes.get_area(graph, x_start=left_bound, x_end=param_tracker.get_value(), color=BLUE, opacity=0.5)\n \n # Initial area\n initial_area = get_current_area()\n \n # Animate the change in the area tracker while continuously redrawing the area\n animation = AlwaysRedraw(get_current_area)\n self.add(initial_area, animation)\n \n # Move the tracker along the axis to change the interval and update the area dynamically\n tracker_dot = Dot(color=YELLOW).add_updater(\n lambda dot: dot.move_to(axes.c2p(param_tracker.get_value(), 0))\n )\n\n self.add(tracker_dot)\n \n #Animate tracking changes from -2 to 4 then back to -2\n self.play(\n param_tracker.animate.set_value(4),\n run_time=2,\n rate_func=smooth\n )\n \n self.play(\n param_tracker.animate.set_value(-2),\n run_time=2,\n rate_func=smooth\n )\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Demonstrate the concept of differential geometry and its applications in physics through a Manim scene.", "chosen": "```python\nfrom manim import *\n\nclass DifferentialGeometry(Scene):\n def construct(self):\n # Title\n title = Text(\"Differential Geometry and Physics\").scale(0.8)\n title.move_to(3 * UP)\n self.play(Write(title))\n self.wait(1)\n\n # Introduction\n intro_text = Text(\"Exploring Curvature and Gravitational Forces\").scale(0.6)\n intro_text.move_to(2 * UP)\n self.play(Write(intro_text))\n self.wait(2)\n\n # Visualization: Curvature and Gravitational Forces\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 6, 1],\n x_length=6,\n y_length=4\n ).shift(DOWN * 1.5)\n\n curve = ParametricFunction(lambda t: [t, np.sin(t), 0], t_range=[-2 * PI, 2 * PI], color=BLUE)\n curve.shift(0.5 * DOWN) # Shift the curve downwards\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # Tangent vectors along the curve\n tangent_vectors = VGroup(*[\n Arrow(\n axes.coords_to_point(t, np.sin(t)),\n axes.coords_to_point(t + 0.5, np.sin(t) + np.cos(t) * 0.5),\n color=YELLOW\n ) for t in np.arange(-2 * PI, 2 * PI, 0.5)\n ])\n\n self.play(Create(tangent_vectors))\n self.wait(1)\n\n # Gravitational force vectors\n gravitational_vectors = VGroup(*[\n Arrow(\n axes.coords_to_point(t, np.sin(t)),\n axes.coords_to_point(t, np.sin(t) - 0.5),\n color=GREEN\n ) for t in np.arange(-2 * PI, 2 * PI, 0.5)\n ])\n\n self.play(Transform(tangent_vectors, gravitational_vectors))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DifferentialGeometry(Scene):\n def construct(self):\n # Title\n title = Text(\"Differential Geometry and Physics\").scale(0.8)\n title.move_to(3 * UP)\n self.play(Write(title))\n self.wait(1)\n\n # Introduction\n intro_text = Text(\"Exploring Curvature and Gravitational Forces\").scale(0.6)\n intro_text.move_to(2 * UP)\n self.play(Write(intro_text))\n self.wait(2)\n\n # Visualization: Curvature and Gravitational Forces\n axes = Axes(font_size=24, \n x_range=[-3, 3, 1],\n y_range=[-1, 6, 1],\n x_length=6,\n y_length=4\n ).shift(DOWN * 1.5)\n\n curve = ParametricFunction(lambda t: [t, np.sin(t), 0], t_range=[-2 * PI, 2 * PI], color=BLUE)\n curve.shift(0.5 * DOWN) # Shift the curve downwards\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # Tangent vectors along the curve\n tangent_vectors = VGroup(*[\n Arrow(\n axes.coords_to_point(t, np.sin(t)),\n axes.coords_to_point(t + 0.5, np.sin(t) + np.cos(t) * 0.5),\n color=YELLOW\n ) for t in np.arange(-2 * PI, 2 * PI, 0.5)\n ])\n\n self.play(Create(tangent_vectors))\n self.wait(1)\n\n # Gravitational force vectors\n gravitational_vectors = VGroup(*[\n Arrow(\n axes.coords_to_point(t, np.sin(t)),\n axes.coords_to_point(t, np.sin(t) - 0.5),\n color=GREEN\n ) for t in np.arange(-2 * PI, 2 * PI, 0.5)\n ])\n\n self.play(Transform(tangent_vectors, gravitational_vectors))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an educational animation that shows how to calculate the area under the curve of the function f(x) = x^2, specifically from x=1 to x=2, including a visual representation of the area, the integral notation, and the step-by-step calculation leading to the final solution.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n Educational animation demonstrating the calculation of the area under \n the curve f(x) = x^2 from x=1 to x=2 using definite integration.\n \"\"\"\n def construct(self):\n # ---------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ---------------------------------------------------------\n # Create axes shifted to the left to leave 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_numbers\": True, \"include_tip\": True},\n ).shift(LEFT * 3)\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 # Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = MathTex(r\"f(x) = x^2\").set_color(BLUE)\n curve_label.next_to(curve, UR, buff=0.5)\n\n # ---------------------------------------------------------\n # 2. Highlight the Area Under the Curve\n # ---------------------------------------------------------\n # Define the shaded region between x=1 and x=2\n area = axes.get_area(\n curve,\n x_range=[1, 2],\n color=GREEN,\n opacity=0.5\n )\n \n # Create dashed vertical lines to clearly mark the integration limits\n line_1 = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, 1), \n color=WHITE\n )\n line_2 = DashedLine(\n start=axes.c2p(2, 0), \n end=axes.c2p(2, 4), \n color=WHITE\n )\n limit_lines = VGroup(line_1, line_2)\n\n # ---------------------------------------------------------\n # 3. Prepare Mathematical Derivation Steps\n # ---------------------------------------------------------\n # Step 1: Display the integral notation\n step1 = MathTex(r\"\\text{Area} = \\int_{1}^{2} x^2 \\, dx\")\n \n # Step 2: Show the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{2}\")\n \n # Step 3: Substitute the limits of integration\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Calculate the final numerical result\n step4 = MathTex(r\"= \\frac{8}{3} - \\frac{1}{3} = \\frac{7}{3} \\approx 2.33\")\n \n # Add a box around the final answer for emphasis\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n \n # Arrange equations vertically on the right side of the screen\n equations = VGroup(step1, step2, step3, step4).arrange(\n DOWN, buff=0.6, aligned_edge=LEFT\n )\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # ---------------------------------------------------------\n # 4. Animation Sequence\n # ---------------------------------------------------------\n \n # Introduce the coordinate system and the function\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 # Visualize the specific area being calculated\n self.play(Create(limit_lines), FadeIn(area))\n self.wait(1)\n\n # Display the integral expression corresponding to the shaded area\n self.play(Write(step1))\n self.wait(1)\n\n # Animate the step-by-step solution\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.play(Create(box))\n self.wait(1)\n \n # Emphasize the connection between the calculated value and the shaded area\n self.play(area.animate.set_fill(color=YELLOW, opacity=0.8), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n Educational animation demonstrating the calculation of the area under \n the curve f(x) = x^2 from x=1 to x=2 using definite integration.\n \"\"\"\n def construct(self):\n # ---------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ---------------------------------------------------------\n # Create axes shifted to the left to leave room for equations on the right\n axes = Axes(font_size=24, \n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_numbers\": True, \"include_tip\": True},\n ).shift(LEFT * 3)\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 # Plot the function f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = MathTex(r\"f(x) = x^2\").set_color(BLUE)\n curve_label.next_to(curve, UR, buff=0.5)\n\n # ---------------------------------------------------------\n # 2. Highlight the Area Under the Curve\n # ---------------------------------------------------------\n # Define the shaded region between x=1 and x=2\n area = axes.get_area(\n curve,\n x_range=[1, 2],\n color=GREEN,\n opacity=0.5\n )\n \n # Create dashed vertical lines to clearly mark the integration limits\n line_1 = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, 1), \n color=WHITE\n )\n line_2 = DashedLine(\n start=axes.c2p(2, 0), \n end=axes.c2p(2, 4), \n color=WHITE\n )\n limit_lines = VGroup(line_1, line_2)\n\n # ---------------------------------------------------------\n # 3. Prepare Mathematical Derivation Steps\n # ---------------------------------------------------------\n # Step 1: Display the integral notation\n step1 = MathTex(r\"\\text{Area} = \\int_{1}^{2} x^2 \\, dx\")\n \n # Step 2: Show the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{2}\")\n \n # Step 3: Substitute the limits of integration\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Calculate the final numerical result\n step4 = MathTex(r\"= \\frac{8}{3} - \\frac{1}{3} = \\frac{7}{3} \\approx 2.33\")\n \n # Add a box around the final answer for emphasis\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n \n # Arrange equations vertically on the right side of the screen\n equations = VGroup(step1, step2, step3, step4).arrange(\n DOWN, buff=0.6, aligned_edge=LEFT\n )\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # ---------------------------------------------------------\n # 4. Animation Sequence\n # ---------------------------------------------------------\n \n # Introduce the coordinate system and the function\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 # Visualize the specific area being calculated\n self.play(Create(limit_lines), FadeIn(area))\n self.wait(1)\n\n # Display the integral expression corresponding to the shaded area\n self.play(Write(step1))\n self.wait(1)\n\n # Animate the step-by-step solution\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.play(Create(box))\n self.wait(1)\n \n # Emphasize the connection between the calculated value and the shaded area\n self.play(area.animate.set_fill(color=YELLOW, opacity=0.8), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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: I would like to create an animation where the word \"Inscribe\" appears on the screen and then transitions to say \"Inscribe a Square\" and moves downwards. Next, a square should be drawn surrounding the words. After a short", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0228(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_inscribeanimation()\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 vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n # Create the initial blue rectangle around the first text\n rect_blue = SurroundingRectangle(text1, color=BLUE)\n self.play(Create(rect_blue))\n self.wait(0.5)\n\n # Replace with green rectangle around the second text\n rect_green = SurroundingRectangle(text2, color=GREEN)\n self.play(ReplacementTransform(rect_blue, rect_green))\n self.wait(0.5)\n\n # Replace with red rectangle around the third text\n rect_red = SurroundingRectangle(text3, color=RED)\n self.play(ReplacementTransform(rect_green, rect_red))\n self.wait(0.5)\n\n # 3. Final Animation\n # Add an updater so the red rectangle strictly tracks the text's position\n rect_red.add_updater(lambda r: r.become(SurroundingRectangle(text3, color=RED)))\n \n # Animate the text moving upwards; the rectangle follows via the updater\n self.play(text3.animate.shift(UP * 3), run_time=3)\n \n # Remove the updater to freeze the rectangle's final state\n rect_red.clear_updaters()\n self.wait(0.5)\n\n def act_2_inscribeanimation(self):\n text = Text(\"Inscribe\")\n self.play(Write(text))\n \n # 2. First Transition:\n # The text transitions to \"Inscribe a Square\", moves downwards,\n # and a square is drawn surrounding the new text.\n text_square = Text(\"Inscribe a Square\").move_to(text).shift(DOWN * 0.5)\n self.play(ReplacementTransform(text, text_square))\n \n square = SurroundingRectangle(text_square, color=BLUE, buff=0.5)\n self.play(Create(square))\n \n # 3. Pause: A short pause occurs while the square and text are visible.\n self.wait(1)\n \n # 4. Fade Out: The square fades away completely.\n self.play(FadeOut(square))\n \n # 5. Second Transition:\n # The text changes to \"Inscribe a Triangle\", moves downwards again,\n # and a triangle is drawn surrounding this new text.\n text_triangle = Text(\"Inscribe a Triangle\").move_to(text_square).shift(DOWN * 0.5)\n self.play(ReplacementTransform(text_square, text_triangle))\n \n triangle = Triangle(color=GREEN)\n triangle.scale(2.0).move_to(text_triangle.get_center())\n self.play(Create(triangle))\n \n # 6. Final Cleanup: Both the triangle and the text disappear from the screen.\n self.play(FadeOut(text_triangle), FadeOut(triangle))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0228(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_inscribeanimation()\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 vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n # Create the initial blue rectangle around the first text\n rect_blue = SurroundingRectangle(text1, color=BBLUE)\n self.play(Create(rect_blue))\n self.wait(0.5)\n\n # Replace with green rectangle around the second text\n rect_green = SurroundingRectangle(text2, color=GREEN)\n self.play(ReplacementTransform(rect_blue, rect_green))\n self.wait(0.5)\n\n # Replace with red rectangle around the third text\n rect_red = SurroundingRectangle(text3, color=RED)\n self.play(ReplacementTransform(rect_green, rect_red))\n self.wait(0.5)\n\n # 3. Final Animation\n # Add an updater so the red rectangle strictly tracks the text's position\n rect_red.add_updater(lambda r: r.become(SurroundingRectangle(text3, color=RED)))\n \n # Animate the text moving upwards; the rectangle follows via the updater\n self.play(text3.animate.shift(UP * 3), run_time=3)\n \n # Remove the updater to freeze the rectangle's final state\n rect_red.clear_updaters()\n self.wait(0.5)\n\n def act_2_inscribeanimation(self):\n text = Text(\"Inscribe\")\n self.play(Write(text))\n \n # 2. First Transition:\n # The text transitions to \"Inscribe a Square\", moves downwards,\n # and a square is drawn surrounding the new text.\n text_square = Text(\"Inscribe a Square\").move_to(text).shift(DOWN * 0.5)\n self.play(ReplacementTransform(text, text_square))\n \n square = SurroundingRectangle(text_square, color=BLUE, buff=0.5)\n self.play(Create(square))\n \n # 3. Pause: A short pause occurs while the square and text are visible.\n self.wait(1)\n \n # 4. Fade Out: The square fades away completely.\n self.play(FadeOut(square))\n \n # 5. Second Transition:\n # The text changes to \"Inscribe a Triangle\", moves downwards again,\n # and a triangle is drawn surrounding this new text.\n text_triangle = Text(\"Inscribe a Triangle\").move_to(text_square).shift(DOWN * 0.5)\n self.play(ReplacementTransform(text_square, text_triangle))\n \n triangle = Triangle(color=GREEN)\n triangle.scale(2.0).move_to(text_triangle.get_center())\n self.play(Create(triangle))\n \n # 6. Final Cleanup: Both the triangle and the text disappear from the screen.\n self.play(FadeOut(text_triangle), FadeOut(triangle))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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## 3. Deriving Equilibrium Income and the Government Spending Multiplier\n\n### 1. Solving for Equilibrium Income \\(Y\\) (Board Work)\n\nFrom:\n\\[\nY = C_0 + cY + I + G\n\\]\n\nRearrange:\n\\[\nY - cY = C_0 + I + G\n\\]\n\n\\[\n(1 - c)Y = C_0 + I + G\n\\]\n\nThus:\n\\[\nY = \\frac{1}{1 - c}(C_0 + I + G)\n\\]\n\n\nContextual location of this section: None\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass BoardWorkEquation(Scene):\n def construct(self):\n # --- Configuration ---\n title_text = \"Deriving Equilibrium Income and the\\nGovernment Spending Multiplier\"\n \n equation_initial = MathTex(\"Y\", \"=\", \"C_0\", \"+\", \"cY\", \"+\", \"I\", \"+\", \"G\")\n equation_rearranged = MathTex(\n r\"Y - cY &= C_0 + I + G \\\\\",\n \"(1-c)Y &= C_0 + I + G\"\n )\n \n solution_equation = MathTex(\n r\"\\therefore Y &= \\frac{1}{1 - c} (C_0 + I + G)\"\n ).scale_to_fit_width(config.frame_width * 0.8)\n \n title = Text(title_text, font_size=36).to_edge(UP)\n initial_label = Text(\"Initial Equation:\", font_size=28).next_to(equation_initial, UP, buff=0.5)\n rearranged_label = Text(\"Rearranged Form:\", font_size=28).next_to(equation_rearranged, UP, buff=0.5)\n \n equations_group = VGroup(initial_label, equation_initial, rearranged_label, equation_rearranged)\n equations_group.arrange(DOWN, aligned_edge=LEFT, buff=0.7)\n solutions_title = Text(\"\\nSolution:\", font_size=32).to_edge(RIGHT).shift(UP * 0.5)\n solution_box = SurroundingRectangle(solution_equation, color=BLUE, buff=0.3)\n solution_group = VGroup(solutions_title, solution_equation, solution_box).arrange(DOWN, buff=0.5).to_edge(DOWN).set_y(-2.5)\n\n self.play(Write(title))\n self.wait(1)\n \n self.play(FadeIn(initial_label), Write(equation_initial))\n self.wait(2)\n\n self.play(Write(rearranged_label), Write(equation_rearranged))\n self.wait(2)\n\n self.play(Write(solution_box), FadeIn(solutions_title, shift=DOWN))\n self.play(Write(solution_equation))\n self.wait(3)\n\n self.play(FadeOut(VGroup(title, initial_label, equation_initial, rearranged_label, equation_rearranged, solutions_title, solution_box)))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass BoardWorkScene(Scene):\n def construct(self):\n title_text = Text(\"Solving for Equilibrium Income Y\", font_size=36, weight=BOLD).to_edge(UP)\n \n from_eq = MathTex(r\"Y =\", \"C_{0}\", \"+ \", r\"cY\", \"+ \", \"I\", \"+ \", \"G\").scale(1.2).next_to(title_text, DOWN, buff=0.8)\n \n rearrange_step1 = MathTex(r\"Y - cY =\", \"C_{0} + I + G\").scale(1.2).next_to(from_eq, DOWN, aligned_edge=LEFT)\n rearrange_step2 = MathTex(r\"(1 - c)Y =\", \"C_{0} + I + G\").scale(1.2).move_to(rearrange_step1.get_center())\n \n solution_step = MathTex(r\"Y =\", r\"\\frac{1}{1-c}\", r\"\\left(C_{0} + I + G\\\\right)\", font_size=30).scale(1.2).next_to(rearrange_step2, DOWN, aligned_edge=LEFT).shift(RIGHT * 0.5)\n \n # Highlight each part of the derivation step by step\n self.play(Write(title_text))\n self.play(Write(from_eq))\n self.wait(1.5)\n\n highlight_box_from = SurroundingRectangle(from_eq[0], color=BLUE, buff=0.1)\n highlight_box_c1 = SurroundingRectangle(from_eq[1], color=YELLOW, buff=0.1)\n highlight_box_ci = SurroundingRectangle(from_eq[3], color=GREEN, buff=0.1)\n highlight_box_i = SurroundingRectangle(from_eq[-2], color=ORANGE, buff=0.1)\n highlight_box_g = SurroundingRectangle(from_eq[-1], color=PURPLE, buff=0.1)\n\n self.play(Create(highlight_box_from), Write(rearrange_step1))\n self.wait(1)\n self.play(Transform(from_eq[3:], from_eq[3:].copy().set_color(GREEN)), Transform(rearrange_step1[1:], rearrange_step1[1:].copy().set_color(GREEN)))\n self.wait(1)\n\n self.play(\n Create(highlight_box_ci),\n Write(rearrange_step1[2]),\n Transform(from_eq[3:], from_eq[3:].copy().set_color(YELLOW)),\n Transform(rearrange_step1[3:], rearrange_step1[3:].copy().set_color(YELLOW))\n )\n self.wait(1)\n\n self.play(\n Create(highlight_box_i),\n Write(rearrange_step1[5])\n )\n self.wait(1)\n\n self.play(\n Create(highlight_box_g),\n Write(rearrange_step1[7])\n )\n\n self.wait(1)\n self.play(FadeIn(highlight_box_from, shift=DOWN * 0.5))\n\n self.play(Write(rearrange_step2))\n self.wait(1)\n\n box_equation = SurroundingRectangle(rearrange_step2, color=WHITE, buff=0.1)\n self.play(Create(box_equation))\n self.wait(1.5)\n\n self.play(Write(solution_step))\n self.wait(1)\n\n arrow_next = Arrow(solution_step[0].get_bottom(), solution_step[1].get_top()).set_color(RED)\n self.play(GrowArrow(arrow_next))\n formula_value = MathTex(r\"\\text{Total } Y = \\\\ \\frac{\\sum(\\text{Income Sources})}{1-\\text{marginal propensity to consume}}\")\n formula_group = VGroup(formula_value).scale(0.8).next_to(solution_step, DOWN, buff=0.8)\n self.play(Write(formula_group))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 illustrating the properties of Laplace transforms. Show how the transform is applied to functions and their inverses, step by step.\n- Act 2: 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 a\n- Act 3: How can I create a simple animation using Manim where the word \"Flash\" appears and moves upwards, followed by the word \"Ta Da\" in yellow color flashing on the screen before disappearing?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0749(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_laplaceproperties()\n self.clear_stage()\n self.act_2_texttocirclesscene()\n self.clear_stage()\n self.act_3_flashsequence()\n\n def act_1_laplaceproperties(self):\n title = Text(\"Properties of Laplace Transforms\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n\n orig_func = MathTex(r\"f(t)\").next_to(title, DOWN).scale(0.8) \n self.play(FadeIn(orig_func))\n\n arrow1 = Arrow(start=orig_func.get_bottom(), end=orig_func.get_bottom()+DOWN) \n lt_text = Text(\"Laplace Transform\").next_to(arrow1, RIGHT).scale(0.6)\n trans_func = MathTex(r\"\\mathcal{L}\\{f(t)\\} = F(s)\").next_to(arrow1, DOWN).scale(0.8)\n self.play(GrowArrow(arrow1), FadeIn(trans_func), FadeIn(lt_text))\n \n linear_text = Text(\"Linearity\").next_to(trans_func, DOWN).scale(0.7)\n self.play(Write(linear_text))\n\n eq1 = MathTex(r\"\\mathcal{L}\\{af(t)\", \"+\", \"bg(t)\\}\", \"=\", \"a\", \n \"\\mathcal{L}\\{f(t)\\}\", \"+\", \"b\", \"\\mathcal{L}\\{g(t)\\}\").next_to(linear_text, DOWN).scale(0.8)\n self.play(Write(eq1))\n \n invlt_text = Text(\"Inverse Laplace \\n Transform\").next_to(eq1, DOWN).scale(0.6) \n self.play(Write(invlt_text))\n\n shift_text = Text(\"Time Shift\").next_to(invlt_text, DOWN).scale(0.7)\n self.play(ReplacementTransform(linear_text, shift_text)) \n \n eq2 = MathTex(r\"\\mathcal{L}\\{f(t-a)\\}\", \"=\", \"e^{-as}\", \n \"\\mathcal{L}\\{f(t)\\}\").next_to(shift_text, DOWN).scale(0.8)\n self.play(ReplacementTransform(eq1, eq2))\n\n def act_2_texttocirclesscene(self):\n initial_text = Text(\"Generic Text\", font_size=36)\n \n # Create the target text\n target_text = Text(\"ShowSubmobjectsOneByOne\", font_size=36)\n \n # Write the initial text, transform it, then move it to the top\n self.play(Write(initial_text))\n self.wait(0.5)\n \n self.play(ReplacementTransform(initial_text, target_text))\n self.play(target_text.animate.to_edge(UP))\n \n # --- Step 2: Circle Setup ---\n # Define three circles with distinct colors for clarity\n c1 = Circle(radius=0.6, color=BLUE).shift(UP * 1.5)\n c2 = Circle(radius=0.6, color=GREEN).shift(DOWN * 0.5 + LEFT * 2)\n c3 = Circle(radius=0.6, color=RED).shift(DOWN * 0.5 + RIGHT * 2)\n \n # Group them to handle them as a single unit\n circles_group = VGroup(c1, c2, c3)\n \n # --- Step 3: Sequential Display ---\n # ShowSubmobjectsOneByOne reveals each item in the VGroup one by one\n self.play(ShowSubmobjectsOneByOne(circles_group))\n self.wait(1)\n \n # --- Step 4: Simultaneous Disappearance ---\n # FadeOut applied to the group removes all circles at once\n self.play(FadeOut(circles_group))\n self.wait(1)\n\n def act_3_flashsequence(self):\n flash_text = Text(\"Flash\")\n self.play(Write(flash_text))\n self.play(flash_text.animate.shift(UP * 2), run_time=1)\n self.wait(0.2)\n\n # 2. Second Element: Display \"Ta Da\" in yellow\n tada_text = Text(\"Ta Da\", color=YELLOW)\n self.play(FadeIn(tada_text))\n\n # 3. Apply a flashing effect to these words\n # Using Succession to rapidly blink the text by toggling opacity\n flash_animations = [\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n ]\n self.play(Succession(*flash_animations, run_time=0.6))\n\n # 4. Animate them disappearing\n self.play(FadeOut(tada_text), run_time=0.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0749(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_laplaceproperties()\n self.clear_stage()\n self.act_2_texttocirclesscene()\n self.clear_stage()\n self.act_3_flashsequence()\n\n def act_1_laplaceproperties(self):\n title = Text(\"Properties of Laplace Transforms\").scale(0.8)\n title.to_edge(UP)\n self.play(Write(title))\n\n orig_func = MathTex(r\"f(t)\").next_to(title, DOWN).scale(0.8) \n self.play(FadeIn(orig_func))\n\n arrow1 = Arrow(start=orig_func.get_bottom(), end=orig_func.get_bottom()+DOWN) \n lt_text = Text(\"Laplace Transform\").next_to(arrow1, RIGHT).scale(0.6)\n trans_func = MathTex(r\"\\mathcal{L}\\{f(t)\\} = F(s)\").next_to(arrow1, DOWN).scale(0.8)\n self.play(GrowArrow(arrow1), FadeIn(trans_func), FadeIn(lt_text))\n \n linear_text = Text(\"Linearity\").next_to(trans_func, DOWN).scale(0.7)\n self.play(Write(linear_text))\n\n eq1 = MathTex(r\"\\mathcal{L}\\{af(t)\", \"+\", \"bg(t)\\}\", \"=\", \"a\", \n \"\\mathcal{L}\\{f(t)\\}\", \"+\", \"b\", \"\\mathcal{L}\\{g(t)\\}\").next_to(linear_text, DOWN).scale(0.8)\n self.play(Write(eq1))\n \n invlt_text = Text(\"Inverse Laplace \\n Transform\").next_to(eq1, DOWN).scale(0.6) \n self.play(Write(invlt_text))\n\n shift_text = Text(\"Time Shift\").next_to(invlt_text, DOWN).scale(0.7)\n self.play(ReplacementTransform(linear_text, shift_text)) \n \n eq2 = MathTex(r\"\\mathcal{L}\\{f(t-a)\\}\", \"=\", \"e^{-as}\", \n \"\\mathcal{L}\\{f(t)\\}\").next_to(shift_text, DOWN).scale(0.8)\n self.play(ReplacementTransform(eq1, eq2))\n\n def act_2_texttocirclesscene(self):\n initial_text = Text(\"Generic Text\", font_size=36)\n \n # Create the target text\n target_text = Text(\"ShowSubmobjectsOneByOne\", font_size=36)\n \n # Write the initial text, transform it, then move it to the top\n self.play(Write(initial_text))\n self.wait(0.5)\n \n self.play(ReplacementTransform(initial_text, target_text))\n self.play(target_text.animate.to_edge(UP))\n \n # --- Step 2: Circle Setup ---\n # Define three circles with distinct colors for clarity\n c1 = Circle(radius=0.6, color=BBLUE).shift(UP * 1.5)\n c2 = Circle(radius=0.6, color=GREEN).shift(DOWN * 0.5 + LEFT * 2)\n c3 = Circle(radius=0.6, color=RED).shift(DOWN * 0.5 + RIGHT * 2)\n \n # Group them to handle them as a single unit\n circles_group = VGroup(c1, c2, c3)\n \n # --- Step 3: Sequential Display ---\n # ShowSubmobjectsOneByOne reveals each item in the VGroup one by one\n self.play(ShowSubmobjectsOneByOne(circles_group))\n self.wait(1)\n \n # --- Step 4: Simultaneous Disappearance ---\n # FadeOut applied to the group removes all circles at once\n self.play(FadeOut(circles_group))\n self.wait(1)\n\n def act_3_flashsequence(self):\n flash_text = Text(\"Flash\")\n self.play(Write(flash_text))\n self.play(flash_text.animate.shift(UP * 2), run_time=1)\n self.wait(0.2)\n\n # 2. Second Element: Display \"Ta Da\" in yellow\n tada_text = Text(\"Ta Da\", color=YELLOW)\n self.play(FadeIn(tada_text))\n\n # 3. Apply a flashing effect to these words\n # Using Succession to rapidly blink the text by toggling opacity\n flash_animations = [\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n tada_text.animate.set_opacity(0),\n tada_text.animate.set_opacity(1),\n ]\n self.play(Succession(*flash_animations, run_time=0.6))\n\n # 4. Animate them disappearing\n self.play(FadeOut(tada_text), run_time=0.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Display three large rectangles vertically aligned on the left side of the screen. After they fade in, each rectangle transforms into a small filled circle on the right side using different fade styles:\n- Act 2: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0678(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_differentfadetransforms()\n self.clear_stage()\n self.act_2_transformmatchingjacobia()\n\n def act_1_differentfadetransforms(self):\n starts = [Rectangle(width=4, height=1) for _ in range(3)]\n VGroup(*starts).arrange(DOWN, buff=1).shift(3*LEFT)\n targets = [Circle(fill_opacity=1).scale(0.25) for _ in range(3)]\n VGroup(*targets).arrange(DOWN, buff=1).shift(3*RIGHT)\n\n self.play(*[FadeIn(s) for s in starts])\n self.play(\n FadeTransform(starts[0], targets[0], stretch=True),\n FadeTransform(starts[1], targets[1], stretch=False, dim_to_match=0),\n FadeTransform(starts[2], targets[2], stretch=False, dim_to_match=1)\n )\n\n self.play(*[FadeOut(mobj) for mobj in self.mobjects])\n\n def act_2_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0678(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_differentfadetransforms()\n self.clear_stage()\n self.act_2_transformmatchingjacobia()\n\n def act_1_differentfadetransforms(self):\n starts = [Rectangle(width=4, height=1) for _ in range(3)]\n VGroup(*starts).arrange(DOWN, buff=1).shift(3*LEFT)\n targets = [Circle(fill_opacity=1).scale(0.25) for _ in range(3)]\n VGroup(*targets).arrange(DOWN, buff=1).shift(3*RIGHT)\n\n self.play(*[FadeIn(s) for s in starts])\n self.play(\n FadeTransform(starts[0], targets[0], stretch=True),\n FadeTransform(starts[1], targets[1], stretch=False, dim_to_match=0),\n FadeTransform(starts[2], targets[2], stretch=False, dim_to_match=1)\n )\n\n self.play(*[FadeOut(mobj) for mobj in self.mobjects])\n\n def act_2_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=BBLUE_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like a step-by-step animation that explains how to calculate the definite integral of x cubed from 1 to 3. Start by showing the integral problem, then explain and show the power rule for integration, followed by applying the power rule to our problem. Next, show how to evaluate the result using the boundaries of 1 and 3. Finally, present the final numerical answer of the integral, and then display it prominently on the screen by itself.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n problem = MathTex(r\"\\int_{1}^{3} x^3 \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Explain the Power Rule ---\n # Move problem to the top to maintain context\n self.play(problem.animate.to_edge(UP).scale(0.8))\n \n rule_title = Text(\"Power Rule for Integration:\", font_size=30).shift(UP * 1.5)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\")\n rule_group = VGroup(rule_title, rule_formula).arrange(DOWN).shift(UP * 0.5)\n \n # Highlight the rule with a surrounding box\n rule_box = SurroundingRectangle(rule_group, color=BLUE, buff=0.3)\n \n self.play(Create(rule_box), Write(rule_group))\n self.wait(3)\n \n # Clear the rule and box to proceed\n self.play(FadeOut(rule_group), FadeOut(rule_box))\n\n # --- Step 3: Apply the Rule ---\n # Transition from the problem to the antiderivative application\n step1 = MathTex(r\"\\int_1^3 x^3 \\, dx = \\left[ \\frac{x^{3+1}}{3+1} \\right]_1^3\")\n step1_simplified = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_1^3\")\n \n # Position the application below the original problem\n step1.next_to(problem, DOWN, buff=1)\n step1_simplified.next_to(step1, DOWN, buff=0.5)\n\n self.play(Write(step1))\n self.wait(1)\n self.play(Write(step1_simplified))\n self.wait(2)\n\n # --- Step 4: Evaluate Boundaries ---\n # Show step-by-step evaluation using upper (3) and lower (1) boundaries\n eval_1 = MathTex(r\"= \\frac{3^4}{4} - \\frac{1^4}{4}\")\n eval_2 = MathTex(r\"= \\frac{81}{4} - \\frac{1}{4}\")\n eval_3 = MathTex(r\"= \\frac{80}{4}\")\n eval_4 = MathTex(r\"= 20\")\n\n # Arrange evaluation steps vertically\n evaluations = VGroup(eval_1, eval_2, eval_3, eval_4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n evaluations.next_to(step1_simplified, DOWN, buff=0.5)\n\n # Animate each step of the evaluation\n for line in evaluations:\n self.play(Write(line))\n self.wait(1.5)\n\n self.wait(2)\n\n # --- Step 5 & 6: Present Final Answer & Final Display ---\n # Clear everything for the final prominent result\n self.play(\n FadeOut(problem), \n FadeOut(step1), \n FadeOut(step1_simplified), \n FadeOut(evaluations)\n )\n\n final_answer = MathTex(\"20\", font_size=144, color=YELLOW)\n \n self.play(DrawBorderThenFill(final_answer))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py DefiniteIntegralCalculation\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n problem = MathTex(r\"\\int_{1}^{3} x^3 \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Explain the Power Rule ---\n # Move problem to the top to maintain context\n self.play(problem.animate.to_edge(UP).scale(0.8))\n \n rule_title = Text(\"Power Rule for Integration:\", font_size=30).shift(UP * 1.5)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\")\n rule_group = VGroup(rule_title, rule_formula).arrange(DOWN).shift(UP * 0.5)\n \n # Highlight the rule with a surrounding box\n rule_box = SurroundingRectangle(rule_group, color=BLUE, buff=0.3)\n \n self.play(Create(rule_box), Write(rule_group))\n self.wait(3)\n \n # Clear the rule and box to proceed\n self.play(FadeOut(rule_group), FadeOut(rule_box))\n\n # --- Step 3: Apply the Rule ---\n # Transition from the problem to the antiderivative application\n step1 = MathTex(r\"\\int_1^3 x^3 \\, dx = \\left[ \\frac{x^{3+1}}{3+1} \\right]_1^3\")\n step1_simplified = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_1^3\")\n \n # Position the application below the original problem\n step1.next_to(problem, DOWN, buff=1)\n step1_simplified.next_to(step1, DOWN, buff=0.5)\n\n self.play(Write(step1))\n self.wait(1)\n self.play(Write(step1_simplified))\n self.wait(2)\n\n # --- Step 4: Evaluate Boundaries ---\n # Show step-by-step evaluation using upper (3) and lower (1) boundaries\n eval_1 = MathTex(r\"= \\frac{3^4}{4} - \\frac{1^4}{4}\")\n eval_2 = MathTex(r\"= \\frac{81}{4} - \\frac{1}{4}\")\n eval_3 = MathTex(r\"= \\frac{80}{4}\" + \" = x\")\n eval_4 = MathTex(r\"= 20\")\n\n # Arrange evaluation steps vertically\n evaluations = VGroup(eval_1, eval_2, eval_3, eval_4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n evaluations.next_to(step1_simplified, DOWN, buff=0.5)\n\n # Animate each step of the evaluation\n for line in evaluations:\n self.play(Write(line))\n self.wait(1.5)\n\n self.wait(2)\n\n # --- Step 5 & 6: Present Final Answer & Final Display ---\n # Clear everything for the final prominent result\n self.play(\n FadeOut(problem), \n FadeOut(step1), \n FadeOut(step1_simplified), \n FadeOut(evaluations)\n )\n\n final_answer = MathTex(\"20\", font_size=144, color=YELLOW)\n \n self.play(DrawBorderThenFill(final_answer))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py DefiniteIntegralCalculation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the animation that maintains all original features while adding significant new elements: \n\nThe enhanced animation begins by constructing the original **MathOperationLayer**, displaying a mathematical operation (+, -, *, /) within a blue-stroked circle, which highlights in orange during activation. To this, we introduce a **dynamic input-output visualization**: as the operation activates, two animated input values (represented as labeled circles) flow into the operation node, while the result emerges as an output circle, with the calculation displayed as a formula (e.g., \"3 + 5 = 8\") above the node. Additionally, we include an **interactive activation function plot**—when the operation executes, the corresponding activation function (e.g., ReLU, Sigmoid) animates alongside the result, showing how the output is transformed. The animation concludes with the operation node fading back to its default state while the formula and activation plot linger briefly for clarity, reinforcing the mathematical relationship between inputs, operation, and activation. This enhancement makes the layer’s function more intuitive by visualizing both the arithmetic process and its subsequent nonlinear transformation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedNetworkScene(Scene):\n def construct(self):\n # --- Configuration ---\n NODE_RADIUS = 0.5\n COLOR_INPUT = BLUE\n COLOR_OUTPUT = GREEN\n COLOR_ACTIVATION = YELLOW\n\n # Create Input Nodes (Left)\n input_node_left = Circle(radius=NODE_RADIUS, color=COLOR_INPUT).shift(LEFT * 3.5 + DOWN * 1.5)\n label_input_left = MathTex(\"I_{in}\", font_size=28, color=WHITE).move_to(input_node_left.get_center())\n \n input_node_right = Circle(radius=NODE_RADIUS, color=COLOR_INPUT).next_to(input_node_left, RIGHT, buff=1)\n label_input_right = MathTex(\"I_{out}\", font_size=28, color=WHITE).move_to(input_node_right.get_center())\n\n input_group = VGroup(\n input_node_left, label_input_left,\n input_node_right, label_input_right\n )\n\n # Create Operation Node (Middle)\n op_circle = Circle(radius=0.7, stroke_color=BLUE, fill_opacity=0.1).shift(ORIGIN)\n op_label = Text(\"+\", font_size=60, weight=BOLD).move_to(op_circle.get_center()).set_stroke(width=2)\n\n operation_group = VGroup(op_circle, op_label)\n\n # Create Activation Plot (Right)\n axes = Axes(\n x_range=[-1, 2],\n y_range=[-1, 2],\n axis_config={\"color\": WHITE}\n ).scale(0.5).to_edge(RIGHT, buff=1).shift(DOWN * 0.5)\n \n relu_func = lambda x: np.maximum(x, 0)\n relu_plot = axes.plot(relu_func, color=GREEN)\n relu_label = MathTex(\"\\\\text{ReLU}(z)\", font_size=24).next_to(axes, UP, buff=0.2)\n\n # Animation Sequence\n self.play(FadeIn(input_group))\n self.wait(0.5)\n \n # Highlight input nodes\n self.play(\n FadeIn(label_input_left),\n FadeIn(label_input_right),\n run_time=1.0\n )\n \n self.wait(0.5)\n\n # Animate flow from left to center\n arrow_left = Arrow(start=input_node_left.get_right(), end=op_circle.get_left(), color=WHITE)\n arrow_right = Arrow(start=input_node_right.get_right(), end=op_circle.get_bottom(), color=WHITE)\n \n self.play(Create(arrow_left))\n self.play(TransformFromCopy(input_node_left, op_circle.copy()))\n self.wait(0.5)\n \n # Show operation mathically\n math_text = MathTex(\"I_{in} \\\\cdot I_{out}\").next_to(operation_group, DOWN, buff=0.5)\n self.play(Write(math_text))\n self.wait(0.5)\n\n # Flow to right side\n self.play(\n TransformFromCopy(input_node_right, op_circle.copy().rotate(-PI/2)),\n Create(arrow_right)\n )\n self.wait(0.5)\n\n self.play(FadeIn(axes), Write(relu_label))\n self.play(Create(relu_plot))\n\n self.wait(1)\n\n # Transition to results\n self.play(\n FadeOut(arrow_left),\n FadeOut(arrow_right),\n FadeOut(math_text)\n )\n\n # Calculate Result\n result_value = 7\n output_circle = Circle(radius=0.7, color=COLOR_OUTPUT, fill_opacity=0.2).next_to(op_circle, RIGHT, buff=1)\n label_result = MathTex(f\"O = {result_value}\", font_size=48).move_to(output_circle.get_center())\n\n self.play(\n TransformFromCopy(op_circle, output_circle),\n Write(label_result),\n FadeOut(axes)\n )\n \n self.wait(0.5)\n\n # Display Activation Function\n active_relu = axes.plot(lambda x: np.maximum(x, 0), color=GREEN)\n active_relu.move_to(axes.get_center()) # Move it up slightly to make space\n \n active_label = MathTex(\"\\\\text{ReLU}(7)\", font_size=24).next_to(active_relu, DOWN, buff=0.2)\n\n self.play(\n FadeIn(active_relu, shift=UP * 0.5),\n Write(active_label)\n )\n\n # Conclusion: Hold final frame briefly\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedMathOperationScene(Scene):\n def construct(self):\n # Create Math Operation Layer\n math_op_circle = Circle(radius=1.5, color=BLUE)\n plus_sign = MathTex(\"+\").scale(2).move_to(math_op_circle.get_center())\n \n self.play(Create(math_op_circle))\n self.play(Write(plus_sign))\n self.wait(1)\n\n # Highlight on Activation\n active_color = ORANGE\n highlight_path = VMobject()\n highlight_path.set_points_as_corners([math_op_circle.point_from_proportion(i/6) for i in range(7)])\n highlight_path.set_stroke(active_color, width=12, opacity=0.5)\n \n self.add(highlight_path)\n self.play(\n math_op_circle.animate.set_stroke(color=active_color),\n plus_sign.animate.set_color(active_color),\n run_time=1.5,\n )\n self.wait(0.5)\n self.play(\n math_op_circle.animate.set_stroke(width=4),\n plus_sign.animate.scale(0.7),\n run_time=0.5\n )\n\n # Dynamic Input-Output Visualization\n # Inputs\n left_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"3\", font_size=24)).arrange(DOWN)\n right_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"5\", font_size=24)).arrange(DOWN)\n inputs_group = VGroup(left_input.shift(LEFT*2.5), right_input.shift(RIGHT*2.5))\n\n # Result\n result_circle = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"8\", font_size=24, color=YELLOW)).arrange(DOWN)\n formula_text = MathTex(\"3 + 5 = 8\").to_edge(UP)\n\n # Animate inputs entering the operation and forming the result\n self.play(FadeIn(inputs_group), Write(formula_text), run_time=1.5)\n self.play(MoveAlongPath(left_input, Line(start=inputs_group[0].get_left(), end=math_op_circle.get_left())), \n MoveAlongPath(right_input, Line(start=inputs_group[1].get_right(), end=math_op_circle.get_right())),\n run_time=1.5)\n\n self.play(Transform(result_circle[0], math_op_circle.copy().set_fill(opacity=0)), \n Transform(result_circle[1], plus_sign.copy()),\n run_time=0.8)\n self.play(ShowPassingFlash(result_circle, time_width=0.2, flash_scale=1.5), run_time=1)\n\n # Interactive Activation Function Plot\n axes = Axes(x_range=[0, 10, 2], y_range=[0, 10, 2], x_length=8, y_length=6)\n relu_plot = axes.plot(lambda x: max(0, x), color=GREEN)\n sigmoid_curve = axes.plot(lambda x: 1/(1+np.exp(-x)), color=RED)\n \n # Show ReLU first since it maps positive numbers linearly\n self.play(Create(axes), Create(relu_plot), run_time=2)\n self.wait(1)\n\n # Switch to Sigmoid after the calculation shows non-linear behavior\n self.play(Transform(relu_plot, sigmoid_curve), run_time=2)\n self.wait(2)\n\n # Conclusion: Fade back to normal state, keep formulas visible\n self.play(\n math_op_circle.animate.set_stroke(color=BLUE, width=4),\n plus_sign.animate.scale(1.4),\n run_time=1.5\n )\n self.play(FadeOut(highlight_path))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # --- Configuration ---\n CURVE_COLOR = BLUE\n AREA_COLOR = BLUE_E\n \n # --- 1. Setup Axes and Graph ---\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_tip\": False}\n )\n \n # Plot f(x) = x^2 as a blue curve\n graph = axes.plot(lambda x: x**2, color=CURVE_COLOR, x_range=[-3, 3], stroke_width=4)\n func_label = MathTex(r\"f(x) = x^2\", font_size=36).next_to(graph, UR, buff=0.2)\n func_label.set_color(CURVE_COLOR)\n\n # --- 2. Initial Equation Display ---\n integral_eq = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\", font_size=42)\n integral_eq.next_to(axes, RIGHT, buff=1.5)\n \n # Animate creation of scene elements\n self.play(Create(axes), Create(graph), Write(func_label))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # --- 3. Move Equation to Top ---\n self.play(integral_eq.animate.to_edge(UP))\n self.wait(0.5)\n\n # --- 4. Shade the Area ---\n area = axes.get_area(graph, x_range=[-2, 2], color=AREA_COLOR, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # --- 5. Calculation Animation Sequence ---\n # Step 1: Write the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", font_size=42)\n step1.next_to(integral_eq, DOWN, buff=0.5)\n \n # Step 2: Evaluate at boundaries\n step2 = MathTex(r\"= \\left( \\frac{2^3}{3} \\right) - \\left( \\frac{(-2)^3}{3} \\right)\", font_size=42)\n step2.next_to(integral_eq, DOWN, buff=0.5)\n \n # Step 3: Simplify\n step3 = MathTex(r\"= \\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\", font_size=42)\n step3.next_to(integral_eq, DOWN, buff=0.5)\n \n # Final Result\n final_result = MathTex(r\"= \\frac{16}{3}\", font_size=42, color=YELLOW)\n final_result.next_to(integral_eq, DOWN, buff=0.5)\n\n # Animate Step 1\n self.play(Write(step1))\n self.wait(1)\n \n # Animate Step 2 (Replace Step 1)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n # Animate Step 3 (Replace Step 2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n # Animate Final Result (Replace Step 3)\n self.play(ReplacementTransform(step3, final_result))\n self.wait(1)\n\n # --- 6. Final State ---\n # Clear all intermediate content\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(func_label),\n FadeOut(area),\n FadeOut(integral_eq),\n FadeOut(final_result)\n )\n \n # Re-display only the final solution for emphasis\n final_solution_display = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx = \\frac{16}{3}\", font_size=60, color=CURVE_COLOR)\n self.play(Write(final_solution_display))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # --- Configuration ---\n CURVE_COLOR = BLUE\n AREA_COLOR = BLUE_E\n \n # --- 1. Setup Axes and Graph ---\n axes = Axes(font_size=24, \n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": WHITE, \"include_tip\": False}\n )\n \n # Plot f(x) = x^2 as a blue curve\n graph = axes.plot(lambda x: x**2, color=CURVE_COLOR, x_range=[-3, 3], stroke_width=4)\n func_label = MathTex(r\"f(x) = x^2\", font_size=36).next_to(graph, UR, buff=0.2)\n func_label.set_color(CURVE_COLOR)\n\n # --- 2. Initial Equation Display ---\n integral_eq = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\", font_size=42)\n integral_eq.next_to(axes, RIGHT, buff=1.5)\n \n # Animate creation of scene elements\n self.play(Create(axes), Create(graph), Write(func_label))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # --- 3. Move Equation to Top ---\n self.play(integral_eq.animate.to_edge(UP))\n self.wait(0.5)\n\n # --- 4. Shade the Area ---\n area = axes.get_area(graph, x_range=[-2, 2], color=AREA_COLOR, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # --- 5. Calculation Animation Sequence ---\n # Step 1: Write the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", font_size=42)\n step1.next_to(integral_eq, DOWN, buff=0.5)\n \n # Step 2: Evaluate at boundaries\n step2 = MathTex(r\"= \\left( \\frac{2^3}{3} \\right) - \\left( \\frac{(-2)^3}{3} \\right)\", font_size=42)\n step2.next_to(integral_eq, DOWN, buff=0.5)\n \n # Step 3: Simplify\n step3 = MathTex(r\"= \\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\", font_size=42)\n step3.next_to(integral_eq, DOWN, buff=0.5)\n \n # Final Result\n final_result = MathTex(r\"= \\frac{16}{3}\", font_size=42, color=YELLOW)\n final_result.next_to(integral_eq, DOWN, buff=0.5)\n\n # Animate Step 1\n self.play(Write(step1))\n self.wait(1)\n \n # Animate Step 2 (Replace Step 1)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n # Animate Step 3 (Replace Step 2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n # Animate Final Result (Replace Step 3)\n self.play(ReplacementTransform(step3, final_result))\n self.wait(1)\n\n # --- 6. Final State ---\n # Clear all intermediate content\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(func_label),\n FadeOut(area),\n FadeOut(integral_eq),\n FadeOut(final_result)\n )\n \n # Re-display only the final solution for emphasis\n final_solution_display = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx = \\frac{16}{3}\", font_size=60, color=CURVE_COLOR)\n self.play(Write(final_solution_display))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an educational animation that shows a blue parabola graph, displays the equation of the parabola as y = x^2, then demonstrates how to find the equation of the yellow tangent line to the parabola at the point where x = 1. Additionally, I want to display the tangent line's equation, y = 2x - 1, and explain that the slope of the tangent line is 2, showing the derivative dy/dx = 2. Finally, the animation should conclude with the words \"Tangents to parabolas\" at the top while re-displaying the parabola and the tangent line. Can you create this with smooth transitions and brief pauses in between each step for clarity?", "chosen": "```python\nfrom manim import *\n\nclass TangentParabolaAnimation(Scene):\n def construct(self):\n # 1. Setup: Initialize Axes\n axes = Axes(\n x_range=[-2, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_length=6,\n y_length=6,\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # 2. Parabola: Plot y = x^2 in Blue\n parabola = axes.plot(lambda x: x**2, color=BLUE, x_range=[-2, 2.2])\n parabola_eq = MathTex(\"y = x^2\", color=BLUE).to_edge(UL).shift(RIGHT)\n \n self.play(Create(parabola), Write(parabola_eq))\n self.wait(1)\n\n # 3. Tangent Construction: Mark the point at x = 1\n point_coord = axes.c2p(1, 1)\n dot = Dot(point_coord, color=WHITE)\n dot_label = MathTex(\"P(1, 1)\").next_to(dot, UR, buff=0.1)\n \n self.play(FadeIn(dot), Write(dot_label))\n self.wait(0.5)\n\n # 4. Tangent Line: Plot y = 2x - 1 in Yellow\n tangent_line = axes.plot(lambda x: 2*x - 1, color=YELLOW, x_range=[-0.5, 2.5])\n tangent_eq = MathTex(\"y = 2x - 1\", color=YELLOW).next_to(parabola_eq, DOWN, aligned_edge=LEFT)\n \n self.play(Create(tangent_line), Write(tangent_eq))\n self.wait(1)\n\n # 5. Derivative Explanation: Show slope is 2\n derivative_text = MathTex(r\"\\frac{dy}{dx} = 2x \\implies \\text{at } x=1, \\text{ slope } = 2\").next_to(tangent_eq, DOWN, aligned_edge=LEFT)\n slope_note = Text(\"Slope = 2\", font_size=24, color=YELLOW).next_to(derivative_text, DOWN, aligned_edge=LEFT)\n \n self.play(Write(derivative_text), Write(slope_note))\n self.wait(1.5)\n\n # 6. Conclusion: Display title and ensure graphs are visible\n self.play(\n FadeOut(parabola_eq), \n FadeOut(tangent_eq), \n FadeOut(derivative_text), \n FadeOut(slope_note),\n FadeOut(dot_label)\n )\n \n title = Text(\"Tangents to parabolas\", font_size=40).to_edge(UP)\n self.play(Write(title))\n \n # Indicate the parabola and tangent line to re-display them clearly\n self.play(Indicate(parabola), Indicate(tangent_line))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass TangentParabolaAnimation(Scene):\n def construct(self):\n # 1. Setup: Initialize Axes\n axes = Axes(font_size=24, \n x_range=[-2, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_length=6,\n y_length=6,\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # 2. Parabola: Plot y = x^2 in Blue\n parabola = axes.plot(lambda x: x**2, color=BLUE, x_range=[-2, 2.2])\n parabola_eq = MathTex(\"y = x^2\", color=BLUE).to_edge(UL).shift(RIGHT)\n \n self.play(Create(parabola), Write(parabola_eq))\n self.wait(1)\n\n # 3. Tangent Construction: Mark the point at x = 1\n point_coord = axes.c2p(1, 1)\n dot = Dot(point_coord, color=WHITE)\n dot_label = MathTex(\"P(1, 1)\").next_to(dot, UR, buff=0.1)\n \n self.play(FadeIn(dot), Write(dot_label))\n self.wait(0.5)\n\n # 4. Tangent Line: Plot y = 2x - 1 in Yellow\n tangent_line = axes.plot(lambda x: 2*x - 1, color=YELLOW, x_range=[-0.5, 2.5])\n tangent_eq = MathTex(\"y = 2x - 1\", color=YELLOW).next_to(parabola_eq, DOWN, aligned_edge=LEFT)\n \n self.play(Create(tangent_line), Write(tangent_eq))\n self.wait(1)\n\n # 5. Derivative Explanation: Show slope is 2\n derivative_text = MathTex(r\"\\frac{dy}{dx} = 2x \\implies \\text{at } x=1, \\text{ slope } = 2\").next_to(tangent_eq, DOWN, aligned_edge=LEFT)\n slope_note = Text(\"Slope = 2\", font_size=24, color=YELLOW).next_to(derivative_text, DOWN, aligned_edge=LEFT)\n \n self.play(Write(derivative_text), Write(slope_note))\n self.wait(1.5)\n\n # 6. Conclusion: Display title and ensure graphs are visible\n self.play(\n FadeOut(parabola_eq), \n FadeOut(tangent_eq), \n FadeOut(derivative_text), \n FadeOut(slope_note),\n FadeOut(dot_label)\n )\n \n title = Text(\"Tangents to parabolas\", font_size=40).to_edge(UP)\n self.play(Write(title))\n \n # Indicate the parabola and tangent line to re-display them clearly\n self.play(Indicate(parabola), Indicate(tangent_line))\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What geometric patterns emerge when visualizing the Poincaré Map of a pendulum with an oscillating pivot point?", "chosen": "```python\nfrom manim import *\n\nclass PoincareMapsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unveiling the Patterns: Poincaré Maps\", font_size=32)\n subtitle = Text(\"and Oscillating Pendulums\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n title_group = VGroup(title, subtitle)\n \n self.play(Write(title), Write(subtitle))\n self.wait(1)\n self.play(title_group.animate.to_edge(UP))\n \n # Pendulum visualization\n pendulum = self.create_pendulum()\n pendulum.next_to(title_group, DOWN, buff=1)\n self.play(Create(pendulum))\n self.wait(1)\n \n # Equation\n equation = MathTex(r\"\\theta''(t) + \\gamma\\theta'(t) + \\omega^2\\sin(\\theta(t)) = f(\\omega_ft)\")\n equation.next_to(pendulum, DOWN, buff=1)\n self.play(Write(equation))\n self.wait(1)\n \n # Clear for next section\n self.play(FadeOut(pendulum), FadeOut(equation))\n \n # Phase space\n phase_text = Text(\"Phase Space\", font_size=28)\n phase_text.next_to(title_group, DOWN, buff=1)\n self.play(Write(phase_text))\n \n phase_space = self.create_phase_space()\n phase_space.next_to(phase_text, DOWN, buff=1)\n self.play(Create(phase_space))\n self.wait(1)\n \n # Clear for next section\n self.play(FadeOut(phase_text), FadeOut(phase_space))\n \n # Poincaré map\n poincare_text = Text(\"Poincaré Map\", font_size=28)\n poincare_text.next_to(title_group, DOWN, buff=1)\n self.play(Write(poincare_text))\n \n poincare_eq = MathTex(r\"P(x_n, y_n) = (x_{n+1}, y_{n+1})\")\n poincare_eq.next_to(poincare_text, DOWN, buff=1)\n self.play(Write(poincare_eq))\n \n poincare_map = self.create_poincare_map()\n poincare_map.next_to(poincare_eq, DOWN, buff=1)\n self.play(Create(poincare_map))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Beautiful patterns emerge!\", font_size=28)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(title_group),\n FadeOut(poincare_text),\n FadeOut(poincare_eq),\n FadeOut(poincare_map),\n FadeOut(conclusion)\n )\n \n def create_pendulum(self):\n # Simple pendulum\n pivot = Dot()\n bob = Dot()\n bob.move_to(DOWN * 2)\n line = Line(pivot.get_center(), bob.get_center())\n return VGroup(pivot, line, bob)\n \n def create_phase_space(self):\n # Simple phase space\n axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=4, y_length=4)\n orbit = Circle(radius=1.5, color=BLUE)\n orbit.move_to(axes.get_center())\n return VGroup(axes, orbit)\n \n def create_poincare_map(self):\n # Poincaré map dots\n dots = VGroup()\n for i in range(12):\n angle = i * 2 * PI / 12\n radius = 1.5\n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n dot = Dot(point=[x, y, 0], radius=0.1, color=RED)\n dots.add(dot)\n return dots\n```", "rejected": "```python\nfrom manim import *\n\nclass PoincareMapsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unveiling the Patterns: Poincaré Maps\", font_size=32)\n subtitle = Text(\"and Oscillating Pendulums\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n title_group = VGroup(title, subtitle)\n \n self.play(Write(title), Write(subtitle))\n self.wait(1)\n self.play(title_group.animate.to_edge(UP))\n \n # Pendulum visualization\n pendulum = self.create_pendulum()\n pendulum.next_to(title_group, DOWN, buff=1)\n self.play(Create(pendulum))\n self.wait(1)\n \n # Equation\n equation = MathTex(r\"\\theta''(t) + \\gamma\\theta'(t) + \\omega^2\\sin(\\theta(t)) = f(\\omega_ft)\")\n equation.next_to(pendulum, DOWN, buff=1)\n self.play(Write(equation))\n self.wait(1)\n \n # Clear for next section\n self.play(FadeOut(pendulum), FadeOut(equation))\n \n # Phase space\n phase_text = Text(\"Phase Space\", font_size=28)\n phase_text.next_to(title_group, DOWN, buff=1)\n self.play(Write(phase_text))\n \n phase_space = self.create_phase_space()\n phase_space.next_to(phase_text, DOWN, buff=1)\n self.play(Create(phase_space))\n self.wait(1)\n \n # Clear for next section\n self.play(FadeOut(phase_text), FadeOut(phase_space))\n \n # Poincaré map\n poincare_text = Text(\"Poincaré Map\", font_size=28)\n poincare_text.next_to(title_group, DOWN, buff=1)\n self.play(Write(poincare_text))\n \n poincare_eq = MathTex(r\"P(x_n, y_n) = (x_{n+1}, y_{n+1})\")\n poincare_eq.next_to(poincare_text, DOWN, buff=1)\n self.play(Write(poincare_eq))\n \n poincare_map = self.create_poincare_map()\n poincare_map.next_to(poincare_eq, DOWN, buff=1)\n self.play(Create(poincare_map))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Beautiful patterns emerge!\", font_size=28)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(title_group),\n FadeOut(poincare_text),\n FadeOut(poincare_eq),\n FadeOut(poincare_map),\n FadeOut(conclusion)\n )\n \n def create_pendulum(self):\n # Simple pendulum\n pivot = Dot()\n bob = Dot()\n bob.move_to(DOWN * 2)\n line = Line(pivot.get_center(), bob.get_center())\n return VGroup(pivot, line, bob)\n \n def create_phase_space(self):\n # Simple phase space\n axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=4, y_length=4)\n orbit = Circle(radius=1.5, color=BLUE)\n orbit.move_to(axes.get_center())\n return VGroup(axes, orbit)\n \n def create_poincare_map(self):\n # Poincaré map dots\n dots = VGroup()\n for i in range(12):\n angle = i * 2 * PI / 12\n radius = 1.5\n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n dot = Dot(point=[x, y, 0], radius=0.1, color=RED)\n dots.add(dot)\n return dots\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows how to find the area under the curve of the function x^2 from x=1 to x=3, including the steps of calculating the integral, plugging in the upper and lower limits, evaluating those, and then presenting the final solution?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Setup Axes ---\n axes = Axes(\n x_range=[-0.5, 3.5, 1],\n y_range=[-0.5, 6, 1]\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n self.add(axes, labels)\n self.wait()\n\n # --- Step 2: Plot Function ---\n graph = axes.plot(lambda x: x**2, color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2).set_color(BLUE)\n \n self.play(Create(graph))\n self.play(Write(graph_label))\n self.wait()\n \n # Highlight the region between x=1 and x=3\n area = axes.get_area(graph, x_range=(1, 3), color=GREEN, opacity=0.3)\n \n self.play(FadeIn(area))\n self.wait()\n\n # --- Step 3: Display Integral Notation ---\n integral_notation = MathTex(\"\\\\int_{1}^{3}\", \"x^2\", \"\\\\, dx\")\n integral_notation.to_edge(UP)\n integral_notation.scale(1.2)\n\n self.play(Write(integral_notation))\n self.wait()\n\n # Show antiderivative step\n antiderivative_step = MathTex(\"\\\\left[ \\\\frac{x^3}{3} \\\\right]_{1}^{3}\")\n antiderivative_step.next_to(integral_notation, DOWN, aligned_edge=LEFT)\n antiderivative_step.shift(RIGHT * 0.5)\n \n self.play(Write(antiderivative_step))\n\n # Calculate by plugging in limits\n calculation_step = MathTex(\"\\\\frac{3^3}{3} - \\\\frac{1^3}{3}\")\n calculation_step.move_to(antiderivative_step)\n \n self.play(TransformMatchingTex(antiderivative_step, calculation_step))\n self.wait()\n\n # Final result\n final_solution = MathTex(\"\\\\frac{27}{3} - \\\\frac{1}{3}\", \"=\", \"\\\\frac{26}{3}\")\n final_solution.move_to(calculation_step)\n final_result_box = SurroundingRectangle(final_solution, color=YELLOW, buff=MED_LARGE_BUFF)\n\n self.play(ReplacementTransform(calculation_step, final_solution))\n self.wait()\n\n # Box around the final answer for emphasis\n self.play(Create(final_result_box))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_FUNCTION = BLUE_D\n COLOR_REGION = GREEN_D\n COLOR_GRID = WHITE\n \n # Display the function f(x) = x^2 on axes ranging from 0 to 4 for both axis ranges.\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n tips=False,\n x_length=6.0,\n y_length=4.8\n ).shift(LEFT * 0.7)\n \n labels = axes.get_axis_labels(MathTex(\"x\"), MathTex(\"f(x)\"))\n \n func_curve = axes.plot(lambda x: x**2, color=COLOR_FUNCTION, x_range=[0, 4])\n func_label = MathTex(\"f(x)=x^2\", font_size=28).next_to(func_curve, UR, buff=-1.5)\n grid = NumberPlane(\n x_range=(-1, 4, 1),\n y_range=(0, 11, 2),\n background_lines=True\n ).set_stroke(width=1, opacity=0.1).shift(LEFT * 0.7)\n\n # Define bounds for the integration region\n bound_start = Dot(axes.c2p(1, 1), color=YELLOW)\n bound_end = Dot(axes.c2p(3, 9), color=RED)\n line_bounds = DashedLine(bound_start.get_center(), bound_end.get_center(), stroke_width=2)\n \n # Create shaded region representing the definite integral\n region = axes.get_area(func_curve, x_range=[1, 3], color=COLOR_REGION, opacity=0.3)\n\n # Step-by-step equations aligned at top-left corner\n eq_step1 = MathTex(r\"\\int_{1}^{3}\", \"x^2\", r\"\\,dx\").to_edge(UP, buff=0.5).align_on_border(LEFT, buff=1.5)\n eq_step2 = MathTex(r\"=\\left[\\frac{x^3}{3}\\right]_{1}^{3}\").next_to(eq_step1, DOWN, buff=0.3).match_style(eq_step1)\n eq_eval = MathTex(r\"=\", \"\\frac{27}{3}\", \"-\", \"\\frac{1}{3}\", \"=\", \"\\\\frac{26}{3} \\approx \", \"8.67\").next_to(eq_step2, DOWN, buff=0.3).match_style(eq_step1)\n \n # Highlight the numerical result for emphasis\n box_result = SurroundingRectangle(eq_eval[-2:], color=YELLOW, buff=0.1)\n text_solution = Text(\"Area Under Curve:\", font_size=24, weight=BOLD).to_corner(UR, buff=0.5).shift(RIGHT * 1.5 + UP * 1)\n \n # Animation Sequence\n\n # 1. Plot Function: Visualize the curve over its domain.\n self.play(Create(grid), Write(labels))\n self.play(Create(func_curve), FadeIn(func_label))\n\n # 2. Highlight Region: Visually mark the specific interval [1, 3].\n self.play(FadeIn(line_bounds), FadeIn(region), FadeIn(bound_start), FadeIn(bound_end))\n self.wait(1)\n\n # 3. Show Equations: Present the mathematical calculations sequentially.\n self.play(Write(eq_step1))\n self.wait(1)\n \n self.play(Write(eq_step2))\n self.wait(1)\n \n self.play(Write(eq_eval))\n self.wait(1)\n\n # 4. Emphasize Result: Frame the final value distinctly.\n self.play(Create(box_result))\n self.play(Write(text_solution))\n \n # Final Pause\n self.wait(2)\n\n# To run this script:\n# manim -pql filename.py AreaUnderCurve\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins by sequentially constructing a molecule, introducing an oxygen atom (shifted left), an electron (above it), a metal atom (shifted right), a positive charge (above the metal), and a negative charge (near the electron). Each component fades in individually before the entire molecule is highlighted. The molecule then transforms into a 3x3 metal oxide grid, which further morphs into a carbon lattice structure. The grid scales down and moves to the upper-left corner. Meanwhile, an electron follows a smooth, predefined octagonal path around the oxygen atom, emphasizing electron movement in atomic bonding. To enhance clarity, dynamic labels appear next to each component (e.g., \"O²⁻,\" \"M⁺,\" \"e⁻\") as they are introduced, and a LaTeX formula (e.g., *M + O₂ → MO*) fades in during the transformation to the metal oxide grid. Finally, a color gradient highlights electron density around the oxygen, reinforcing the concept of charge distribution. The animation concludes with all elements remaining visible, allowing for a clear comparison between atomic and lattice structures.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedMoleculeAnimation(Scene):\n def construct(self):\n # Create components\n oxygen = Circle(radius=0.5, color=RED, fill_opacity=1).shift(LEFT * 2)\n electron = Dot(color=BLUE).next_to(oxygen, UP)\n metal = Circle(radius=0.5, color=GOLD, fill_opacity=1).shift(RIGHT * 2)\n positive_charge = Tex(\"+\", color=WHITE).next_to(metal, UP)\n negative_charge = Tex(\"-\", color=WHITE).next_to(electron, UP)\n\n # Labels\n oxygen_label = Tex(\"O$^{2-}$\", color=WHITE).next_to(oxygen, DOWN)\n metal_label = Tex(\"M$^+$\", color=WHITE).next_to(metal, DOWN)\n electron_label = Tex(\"e$^-$\", color=WHITE).next_to(electron, RIGHT)\n\n # Animate components appearing\n self.play(FadeIn(oxygen))\n self.play(FadeIn(oxygen_label))\n self.play(FadeIn(electron))\n self.play(FadeIn(electron_label))\n self.play(FadeIn(metal))\n self.play(FadeIn(metal_label))\n self.play(FadeIn(positive_charge))\n self.play(FadeIn(negative_charge))\n\n # Highlight the molecule\n self.play(\n oxygen.animate.set_fill(opacity=0.7),\n electron.animate.set_fill(opacity=0.7),\n metal.animate.set_fill(opacity=0.7),\n run_time=2\n )\n\n # Create metal oxide grid\n grid = VGroup(*[\n Square(side_length=1, color=GOLD, fill_opacity=0.5)\n for _ in range(9)\n ]).arrange_in_grid(rows=3, cols=3, buff=0.1)\n grid[4].set_fill(RED, opacity=0.5) # Oxygen in the center\n\n # Transform molecule to grid\n self.play(\n ReplacementTransform(VGroup(oxygen, metal, electron), grid),\n FadeOut(VGroup(oxygen_label, metal_label, electron_label, positive_charge, negative_charge)),\n run_time=2\n )\n\n # Show formula\n formula = MathTex(\"M + O_2 \\\\rightarrow MO\", color=WHITE).to_edge(UP)\n self.play(Write(formula))\n\n # Morph grid into carbon lattice\n carbon_lattice = VGroup(*[\n Circle(radius=0.3, color=BLUE, fill_opacity=0.5)\n for _ in range(9)\n ]).arrange_in_grid(rows=3, cols=3, buff=0.5)\n for i in [0, 2, 4, 6, 8]:\n carbon_lattice[i].set_fill(BLUE, opacity=0.8)\n\n self.play(\n ReplacementTransform(grid, carbon_lattice),\n run_time=2\n )\n\n # Move lattice to upper-left\n self.play(\n carbon_lattice.animate.scale(0.5).to_corner(UL),\n formula.animate.scale(0.7).next_to(carbon_lattice, RIGHT, buff=0.5),\n run_time=1.5\n )\n\n # Recreate electron for path animation\n electron_recreated = Dot(color=BLUE).move_to(oxygen.get_center() + UP * 0.5)\n self.play(FadeIn(electron_recreated))\n\n # Define octagonal path\n path = Circle(radius=1, color=BLUE).shift(LEFT * 2)\n path.apply_complex_function(lambda z: z ** (1/4))\n path.scale(0.8)\n\n # Animate electron along path\n self.play(\n MoveAlongPath(electron_recreated, path),\n run_time=4,\n rate_func=linear\n )\n\n # Show electron density gradient\n gradient = VGroup(*[\n Circle(radius=r, color=BLUE, fill_opacity=0.1 * (4 - i))\n for i, r in enumerate([1.5, 1.2, 0.9, 0.6])\n ]).move_to(oxygen.get_center())\n\n self.play(\n FadeIn(gradient),\n run_time=2\n )\n\n # Keep all elements visible\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedMoleculeAnimation(Scene):\n def construct(self):\n # Create components\n oxygen = Circle(radius=0.5, color=RED, fill_opacity=1).shift(LEFT * 2)\n electron = Dot(color=BBLUE).next_to(oxygen, UP)\n metal = Circle(radius=0.5, color=GOLD, fill_opacity=1).shift(RIGHT * 2)\n positive_charge = Tex(\"+\", color=WHITE).next_to(metal, UP)\n negative_charge = Tex(\"-\", color=WHITE).next_to(electron, UP)\n\n # Labels\n oxygen_label = Tex(\"O$^{2-}$\", color=WHITE).next_to(oxygen, DOWN)\n metal_label = Tex(\"M$^+$\", color=WHITE).next_to(metal, DOWN)\n electron_label = Tex(\"e$^-$\", color=WHITE).next_to(electron, RIGHT)\n\n # Animate components appearing\n self.play(FadeIn(oxygen))\n self.play(FadeIn(oxygen_label))\n self.play(FadeIn(electron))\n self.play(FadeIn(electron_label))\n self.play(FadeIn(metal))\n self.play(FadeIn(metal_label))\n self.play(FadeIn(positive_charge))\n self.play(FadeIn(negative_charge))\n\n # Highlight the molecule\n self.play(\n oxygen.animate.set_fill(opacity=0.7),\n electron.animate.set_fill(opacity=0.7),\n metal.animate.set_fill(opacity=0.7),\n run_time=2\n )\n\n # Create metal oxide grid\n grid = VGroup(*[\n Square(side_length=1, color=GOLD, fill_opacity=0.5)\n for _ in range(9)\n ]).arrange_in_grid(rows=3, cols=3, buff=0.1)\n grid[4].set_fill(RED, opacity=0.5) # Oxygen in the center\n\n # Transform molecule to grid\n self.play(\n ReplacementTransform(VGroup(oxygen, metal, electron), grid),\n FadeOut(VGroup(oxygen_label, metal_label, electron_label, positive_charge, negative_charge)),\n run_time=2\n )\n\n # Show formula\n formula = MathTex(\"M + O_2 \\\\rightarrow MO\", color=WHITE).to_edge(UP)\n self.play(Write(formula))\n\n # Morph grid into carbon lattice\n carbon_lattice = VGroup(*[\n Circle(radius=0.3, color=BLUE, fill_opacity=0.5)\n for _ in range(9)\n ]).arrange_in_grid(rows=3, cols=3, buff=0.5)\n for i in [0, 2, 4, 6, 8]:\n carbon_lattice[i].set_fill(BLUE, opacity=0.8)\n\n self.play(\n ReplacementTransform(grid, carbon_lattice),\n run_time=2\n )\n\n # Move lattice to upper-left\n self.play(\n carbon_lattice.animate.scale(0.5).to_corner(UL),\n formula.animate.scale(0.7).next_to(carbon_lattice, RIGHT, buff=0.5),\n run_time=1.5\n )\n\n # Recreate electron for path animation\n electron_recreated = Dot(color=BLUE).move_to(oxygen.get_center() + UP * 0.5)\n self.play(FadeIn(electron_recreated))\n\n # Define octagonal path\n path = Circle(radius=1, color=BLUE).shift(LEFT * 2)\n path.apply_complex_function(lambda z: z ** (1/4))\n path.scale(0.8)\n\n # Animate electron along path\n self.play(\n MoveAlongPath(electron_recreated, path),\n run_time=4,\n rate_func=linear\n )\n\n # Show electron density gradient\n gradient = VGroup(*[\n Circle(radius=r, color=BLUE, fill_opacity=0.1 * (4 - i))\n for i, r in enumerate([1.5, 1.2, 0.9, 0.6])\n ]).move_to(oxygen.get_center())\n\n self.play(\n FadeIn(gradient),\n run_time=2\n )\n\n # Keep all elements visible\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "In what way do stable and unstable manifolds guide the trajectory behavior in a non-linear dynamical system, like the pendulum, as energy levels shift?", "chosen": "```python\nfrom manim import *\n\nclass PendulumManifolds(Scene):\n def construct(self):\n # Title\n title = Text(\"Navigating the Dance of Stability: Pendulum and Manifolds\", font_size=28)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Basic pendulum visualization\n pendulum_origin = Dot(UP * 2)\n pendulum_bob = Dot(DOWN * 2)\n pendulum_string = Line(pendulum_origin.get_center(), pendulum_bob.get_center())\n pendulum = VGroup(pendulum_origin, pendulum_string, pendulum_bob)\n \n pendulum_label = Text(\"Low Energy Pendulum\", font_size=20).next_to(pendulum, DOWN)\n self.play(Create(pendulum), Write(pendulum_label))\n self.wait(1)\n \n # Basic equation\n eq1 = MathTex(r\"\\dot{\\theta} = -\\frac{g}{l} \\sin(\\theta)\")\n self.play(Write(eq1.next_to(pendulum, RIGHT)))\n self.wait(1)\n \n # Second equation\n eq2 = MathTex(r\"\\frac{d\\theta}{dt} = f(\\theta, E)\")\n self.play(Transform(eq1, eq2.next_to(pendulum, RIGHT)))\n self.wait(1)\n \n # Clear screen for phase space\n self.play(FadeOut(pendulum), FadeOut(pendulum_label), FadeOut(eq1))\n \n # Phase space setup\n phase_title = Text(\"Phase Space\", font_size=24)\n self.play(Write(phase_title.next_to(title, DOWN)))\n \n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n x_length=6,\n y_length=6,\n )\n \n x_label = Text(\"\\theta \", font_size=20).next_to(axes.x_axis, RIGHT)\n y_label = Text(\"ω\", font_size=20).next_to(axes.y_axis, UP)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n \n # Fixed point\n fixed_point = Dot(axes.c2p(0, 0), color=YELLOW)\n fixed_label = Text(\"Fixed Point\", font_size=20, color=YELLOW).next_to(fixed_point, DOWN)\n \n self.play(Create(fixed_point), Write(fixed_label))\n \n # Stable manifold - simplified as a line\n stable_line = Line(axes.c2p(-2, -2), axes.c2p(2, 2), color=BLUE)\n stable_label = Text(\"Stable Manifold\", font_size=20, color=BLUE).next_to(stable_line, UP+LEFT)\n \n self.play(Create(stable_line), Write(stable_label))\n \n # Unstable manifold - simplified as a line\n unstable_line = Line(axes.c2p(-2, 2), axes.c2p(2, -2), color=RED)\n unstable_label = Text(\"Unstable Manifold\", font_size=20, color=RED).next_to(unstable_line, UP+RIGHT)\n \n self.play(Create(unstable_line), Write(unstable_label))\n \n # Low energy trajectory\n low_energy = Circle(radius=1, color=GREEN).move_to(axes.c2p(0, 0))\n low_label = Text(\"Low Energy\", font_size=20, color=GREEN).to_edge(RIGHT)\n \n self.play(Create(low_energy), Write(low_label))\n self.wait(1)\n \n # Show trajectory following stable manifold\n stable_arrow = Arrow(axes.c2p(1.5, 1.3), axes.c2p(1, 1), color=BLUE)\n self.play(Create(stable_arrow))\n stable_dot = Dot(axes.c2p(1.5, 1.3), color=GREEN)\n self.play(Create(stable_dot))\n self.play(stable_dot.animate.move_to(axes.c2p(1, 1)))\n self.play(stable_dot.animate.move_to(axes.c2p(0.5, 0.5)))\n self.play(stable_dot.animate.move_to(axes.c2p(0, 0)))\n self.wait(1)\n \n # High energy trajectory\n high_energy = Circle(radius=2, color=ORANGE).move_to(axes.c2p(0, 0))\n high_label = Text(\"High Energy\", font_size=20, color=ORANGE).next_to(low_label, DOWN)\n \n self.play(Create(high_energy), Write(high_label))\n \n # Show trajectory following unstable manifold\n unstable_arrow = Arrow(axes.c2p(-0.5, 0.5), axes.c2p(-1, 1), color=RED)\n self.play(Create(unstable_arrow))\n unstable_dot = Dot(axes.c2p(-0.5, 0.5), color=ORANGE)\n self.play(Create(unstable_dot))\n self.play(unstable_dot.animate.move_to(axes.c2p(-1, 1)))\n self.play(unstable_dot.animate.move_to(axes.c2p(-1.5, 1.5)))\n self.play(unstable_dot.animate.move_to(axes.c2p(-2, 2)))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Manifolds guide trajectories as energy levels change\", font_size=24)\n \n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(fixed_point), FadeOut(fixed_label),\n FadeOut(stable_line), FadeOut(stable_label),\n FadeOut(unstable_line), FadeOut(unstable_label),\n FadeOut(low_energy), FadeOut(low_label),\n FadeOut(high_energy), FadeOut(high_label),\n FadeOut(stable_arrow), FadeOut(stable_dot),\n FadeOut(unstable_arrow), FadeOut(unstable_dot),\n FadeOut(phase_title), FadeOut(title)\n )\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass PendulumManifolds(Scene):\n def construct(self):\n # Title\n title = Text(\"Navigating the Dance of Stability: Pendulum and Manifolds\", font_size=28)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Basic pendulum visualization\n pendulum_origin = Dot(UP * 2)\n pendulum_bob = Dot(DOWN * 2)\n pendulum_string = Line(pendulum_origin.get_center(), pendulum_bob.get_center())\n pendulum = VGroup(pendulum_origin, pendulum_string, pendulum_bob)\n \n pendulum_label = Text(\"Low Energy Pendulum\", font_size=20).next_to(pendulum, DOWN)\n self.play(Create(pendulum), Write(pendulum_label))\n self.wait(1)\n \n # Basic equation\n eq1 = MathTex(r\"\\dot{\\theta} = -\\frac{g}{l} \\sin(\\theta)\")\n self.play(Write(eq1.next_to(pendulum, RIGHT)))\n self.wait(1)\n \n # Second equation\n eq2 = MathTex(r\"\\frac{d\\theta}{dt} = f(\\theta, E)\")\n self.play(Transform(eq1, eq2.next_to(pendulum, RIGHT)))\n self.wait(1)\n \n # Clear screen for phase space\n self.play(FadeOut(pendulum), FadeOut(pendulum_label), FadeOut(eq1))\n \n # Phase space setup\n phase_title = Text(\"Phase Space\", font_size=24)\n self.play(Write(phase_title.next_to(title, DOWN)))\n \n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-3, 3, 1],\n x_length=6,\n y_length=6,\n )\n \n x_label = Text(\"\\theta \", font_size=20).next_to(axes.x_axis, RIGHT)\n y_label = Text(\"ω\", font_size=20).next_to(axes.y_axis, UP)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n \n # Fixed point\n fixed_point = Dot(axes.c2p(0, 0), color=YELLOW)\n fixed_label = Text(\"Fixed Point\", font_size=20, color=YELLOW).next_to(fixed_point, DOWN)\n \n self.play(Create(fixed_point), Write(fixed_label))\n \n # Stable manifold - simplified as a line\n stable_line = Line(axes.c2p(-2, -2), axes.c2p(2, 2), color=BBLUE)\n stable_label = Text(\"Stable Manifold\", font_size=20, color=BLUE).next_to(stable_line, UP+LEFT)\n \n self.play(Create(stable_line), Write(stable_label))\n \n # Unstable manifold - simplified as a line\n unstable_line = Line(axes.c2p(-2, 2), axes.c2p(2, -2), color=RED)\n unstable_label = Text(\"Unstable Manifold\", font_size=20, color=RED).next_to(unstable_line, UP+RIGHT)\n \n self.play(Create(unstable_line), Write(unstable_label))\n \n # Low energy trajectory\n low_energy = Circle(radius=1, color=GREEN).move_to(axes.c2p(0, 0))\n low_label = Text(\"Low Energy\", font_size=20, color=GREEN).to_edge(RIGHT)\n \n self.play(Create(low_energy), Write(low_label))\n self.wait(1)\n \n # Show trajectory following stable manifold\n stable_arrow = Arrow(axes.c2p(1.5, 1.3), axes.c2p(1, 1), color=BLUE)\n self.play(Create(stable_arrow))\n stable_dot = Dot(axes.c2p(1.5, 1.3), color=GREEN)\n self.play(Create(stable_dot))\n self.play(stable_dot.animate.move_to(axes.c2p(1, 1)))\n self.play(stable_dot.animate.move_to(axes.c2p(0.5, 0.5)))\n self.play(stable_dot.animate.move_to(axes.c2p(0, 0)))\n self.wait(1)\n \n # High energy trajectory\n high_energy = Circle(radius=2, color=ORANGE).move_to(axes.c2p(0, 0))\n high_label = Text(\"High Energy\", font_size=20, color=ORANGE).next_to(low_label, DOWN)\n \n self.play(Create(high_energy), Write(high_label))\n \n # Show trajectory following unstable manifold\n unstable_arrow = Arrow(axes.c2p(-0.5, 0.5), axes.c2p(-1, 1), color=RED)\n self.play(Create(unstable_arrow))\n unstable_dot = Dot(axes.c2p(-0.5, 0.5), color=ORANGE)\n self.play(Create(unstable_dot))\n self.play(unstable_dot.animate.move_to(axes.c2p(-1, 1)))\n self.play(unstable_dot.animate.move_to(axes.c2p(-1.5, 1.5)))\n self.play(unstable_dot.animate.move_to(axes.c2p(-2, 2)))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Manifolds guide trajectories as energy levels change\", font_size=24)\n \n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(fixed_point), FadeOut(fixed_label),\n FadeOut(stable_line), FadeOut(stable_label),\n FadeOut(unstable_line), FadeOut(unstable_label),\n FadeOut(low_energy), FadeOut(low_label),\n FadeOut(high_energy), FadeOut(high_label),\n FadeOut(stable_arrow), FadeOut(stable_dot),\n FadeOut(unstable_arrow), FadeOut(unstable_dot),\n FadeOut(phase_title), FadeOut(title)\n )\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that visually represents the steps involved in solving a triple integral, starting with the integration with respect to z, followed by y, and finally x, for the function xyz over the range from 0 to 1 for each variable? I would like the animation to display the mathematical problem, then show step-by-step integration with explanatory text for each variable, and conclude with the final solution.", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Render the full mathematical problem\n # ------------------------------------------------------------------\n # Define the initial triple integral expression\n # Splitting into multiple strings allows TransformMatchingTex to \n # accurately animate the parts of the equation that change.\n initial_integral = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{1}\", r\"\\int_{0}^{1}\", \n r\"x y z\", r\"\\, dz\", r\"\\, dy\", r\"\\, dx\"\n ).scale(1.2)\n \n # Title text\n title = Tex(\"Solving a Triple Integral\", font_size=40)\n title.to_edge(UP)\n \n # Display title and initial problem\n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Step-by-Step Integration\n # ------------------------------------------------------------------\n \n # --- Step 1: Integration with respect to z ---\n step1_text = Tex(\"Step 1: Integrate with respect to $z$\", color=BLUE)\n step1_text.next_to(initial_integral, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Define the intermediate result after integrating z:\n # Integral of (xy * z^2/2) from 0 to 1 -> xy/2\n # We keep the outer integrals for the next step\n after_z = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{1}\", \n r\"\\frac{x y}{2}\", r\"\\, dy\", r\"\\, dx\"\n ).scale(1.2)\n after_z.move_to(initial_integral) # Align with previous equation\n \n # Animate the transition from initial to after_z\n self.play(TransformMatchingTex(initial_integral, after_z))\n self.wait(1)\n \n # Clean up step 1 text\n self.play(FadeOut(step1_text))\n \n # --- Step 2: Integration with respect to y ---\n step2_text = Tex(\"Step 2: Integrate with respect to $y$\", color=GREEN)\n step2_text.next_to(after_z, DOWN, buff=0.5)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Define the intermediate result after integrating y:\n # Integral of (x/2 * y^2/2) from 0 to 1 -> x/4\n after_y = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\frac{x}{4}\", r\"\\, dx\"\n ).scale(1.2)\n after_y.move_to(after_z)\n \n # Animate the transition\n self.play(TransformMatchingTex(after_z, after_y))\n self.wait(1)\n \n # Clean up step 2 text\n self.play(FadeOut(step2_text))\n \n # --- Step 3: Integration with respect to x ---\n step3_text = Tex(\"Step 3: Integrate with respect to $x$\", color=YELLOW)\n step3_text.next_to(after_y, DOWN, buff=0.5)\n \n self.play(Write(step3_text))\n self.wait(1)\n \n # Define the final result:\n # Integral of (x/4) from 0 to 1 -> 1/8\n final_result = MathTex(r\"\\frac{1}{8}\").scale(1.5)\n final_result.move_to(after_y)\n \n # Animate the transition to final result\n self.play(TransformMatchingTex(after_y, final_result))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 3. Conclusion: Display final solution clearly\n # ------------------------------------------------------------------\n self.play(FadeOut(step3_text))\n \n # Add a label and highlight the final result\n conclusion_text = Tex(\"Final Solution:\", color=WHITE)\n conclusion_text.next_to(final_result, LEFT, buff=0.5)\n \n # Draw a surrounding rectangle to emphasize the answer\n box = SurroundingRectangle(final_result, color=GOLD, buff=0.3)\n \n self.play(Write(conclusion_text))\n self.play(Create(box))\n \n # Hold the final scene\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Render the full mathematical problem\n # ------------------------------------------------------------------\n # Define the initial triple integral expression\n # Splitting into multiple strings allows TransformMatchingTex to \n # accurately animate the parts of the equation that change.\n initial_integral = MathTex(r\"\\int_{0}^{1}\" + \" = x\", r\"\\int_{0}^{1}\", r\"\\int_{0}^{1}\", \n r\"x y z\", r\"\\, dz\", r\"\\, dy\", r\"\\, dx\"\n ).scale(1.2)\n \n # Title text\n title = Tex(\"Solving a Triple Integral\", font_size=40)\n title.to_edge(UP)\n \n # Display title and initial problem\n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Step-by-Step Integration\n # ------------------------------------------------------------------\n \n # --- Step 1: Integration with respect to z ---\n step1_text = Tex(\"Step 1: Integrate with respect to $z$\", color=BLUE)\n step1_text.next_to(initial_integral, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Define the intermediate result after integrating z:\n # Integral of (xy * z^2/2) from 0 to 1 -> xy/2\n # We keep the outer integrals for the next step\n after_z = MathTex(\n r\"\\int_{0}^{1}\", r\"\\int_{0}^{1}\", \n r\"\\frac{x y}{2}\", r\"\\, dy\", r\"\\, dx\"\n ).scale(1.2)\n after_z.move_to(initial_integral) # Align with previous equation\n \n # Animate the transition from initial to after_z\n self.play(TransformMatchingTex(initial_integral, after_z))\n self.wait(1)\n \n # Clean up step 1 text\n self.play(FadeOut(step1_text))\n \n # --- Step 2: Integration with respect to y ---\n step2_text = Tex(\"Step 2: Integrate with respect to $y$\", color=GREEN)\n step2_text.next_to(after_z, DOWN, buff=0.5)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Define the intermediate result after integrating y:\n # Integral of (x/2 * y^2/2) from 0 to 1 -> x/4\n after_y = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\frac{x}{4}\", r\"\\, dx\"\n ).scale(1.2)\n after_y.move_to(after_z)\n \n # Animate the transition\n self.play(TransformMatchingTex(after_z, after_y))\n self.wait(1)\n \n # Clean up step 2 text\n self.play(FadeOut(step2_text))\n \n # --- Step 3: Integration with respect to x ---\n step3_text = Tex(\"Step 3: Integrate with respect to $x$\", color=YELLOW)\n step3_text.next_to(after_y, DOWN, buff=0.5)\n \n self.play(Write(step3_text))\n self.wait(1)\n \n # Define the final result:\n # Integral of (x/4) from 0 to 1 -> 1/8\n final_result = MathTex(r\"\\frac{1}{8}\").scale(1.5)\n final_result.move_to(after_y)\n \n # Animate the transition to final result\n self.play(TransformMatchingTex(after_y, final_result))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 3. Conclusion: Display final solution clearly\n # ------------------------------------------------------------------\n self.play(FadeOut(step3_text))\n \n # Add a label and highlight the final result\n conclusion_text = Tex(\"Final Solution:\", color=WHITE)\n conclusion_text.next_to(final_result, LEFT, buff=0.5)\n \n # Draw a surrounding rectangle to emphasize the answer\n box = SurroundingRectangle(final_result, color=GOLD, buff=0.3)\n \n self.play(Write(conclusion_text))\n self.play(Create(box))\n \n # Hold the final scene\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "What is the effect of adding and removing elements on the levels of the cumulative hierarchy?", "chosen": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"The Effect of Adding Elements\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Create set A\n circle_A = Circle(radius=1.0, color=BLUE).shift(LEFT*3 + DOWN*1)\n text_A = MathTex(\"\\\\text{Set } A\").next_to(circle_A, UP, buff=0.5)\n self.play(Create(circle_A), Write(text_A))\n\n # Add element x to Set A\n dot_x = Dot(color=RED).move_to(circle_A.get_center())\n text_add = Text(\"+ Element \\\\( x \\\\)\", font_size=28).to_edge(UP)\n \n self.play(FadeIn(dot_x), Write(text_add))\n self.wait(1)\n\n # Show H(A) level\n h_a_rect = RoundedRectangle(width=7, height=2, corner_radius=0.2, color=YELLOW).shift(RIGHT*3)\n h_a_text = MathTex(\"\\\\text{H}(A)\").next_to(h_a_rect, DOWN, buff=0.5)\n self.play(Create(h_a_rect), Write(h_a_text))\n self.wait(1)\n\n # Remove element x from Set A\n self.remove(dot_x, text_add)\n\n # Show H(A \\ {x}) level\n h_a_minus_rect = RoundedRectangle(width=7, height=2, corner_radius=0.2, color=GREEN).shift(DOWN*2)\n h_a_minus_text = MathTex(\"\\\\text{H}(A\\\\setminus\\\\{x\\\\})\").next_to(h_a_minus_rect, DOWN, buff=0.5)\n self.play(TransformFromCopy(h_a_rect, h_a_minus_rect), TransformFromCopy(h_a_text, h_a_minus_text))\n self.wait(1)\n\n # Compare both hierarchies\n arrow = Arrow(start=h_a_rect.get_right(), end=h_a_minus_rect.get_left(), buff=0.3)\n compare_text = Text(\"Adding/removing elements changes the hierarchy structure.\", font_size=24, color=WHITE).to_edge(DOWN)\n \n self.play(GrowArrow(arrow), Write(compare_text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CumulativeHierarchy(Scene):\n def construct(self):\n # Title\n title = Text(\"The Power of Addition\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Element addition logic\n element_addition_text = Tex(\n r\"$\\alpha \\rightarrow \\beta$\\\\\"\n r\"Add $\\alpha$ to get new set $S_{n+1}$\\\\\"\n r\"\\includegraphics[scale=0.8]{add_element.png}\"\n ).to_edge(RIGHT).shift(DOWN * 0.5)\n\n self.play(FadeIn(element_addition_text))\n\n # Hierarchical level representation\n levels_title = Text(\"Hierarchical Levels\", font_size=28)\n levels_group = VGroup()\n \n for i in range(4): # Create four sets representing different levels\n circle = Circle(radius=i + 1.5, color=BLUE_D)\n label = Text(f\"L{i}\", font_size=18).move_to(circle.get_center())\n \n group = VGroup(circle, label)\n levels_group.add(group)\n \n levels_group.arrange(RIGHT, buff=2)\n \n self.play(Create(levels_group))\n \n # Add description text below the circles\n desc_text = Text(\n \"Adding elements increases the hierarchy level.\\nThe larger the circle, the higher the level.\",\n font_size=24,\n line_spacing=1.2\n )\n desc_text.next_to(level_desc, DOWN)\n \n self.play(Write(desc_text)) \n \n # Remove elements from the upper layers\n removal_text = Tex(\n \"$\\\\gamma \\\\rightarrow \\\\delta$\\\\\\\\\"\n \"Remove elements to simplify the hierarchy\\\\\\\\\"\n \"\\\\includegraphics[scale=0.7]{remove_elements.png}\"\n ).to_edge(RIGHT).shift(DOWN * 0.5) \n \n self.play(Transform(element_addition_text, removal_text))\n \n # Show simplified hierarchical groups\n simplified_groups = VGroup()\n \n # Create two simplified sets at lower levels\n small_circle = Circle(radius=1.0, color=YELLOW)\n large_circle = Circle(radius=2.5, color=GREEN)\n \n small_label = Text(\"Low Level\", font_size=18).next_to(small_circle, UP)\n large_label = Text(\"High Level\", font_size=18).next_to(large_circle, DOWN)\n \n simplified_groups.add(VGroup(small_circle, small_label))\n simplified_groups.add(VGroup(large_circle, large_label))\n \n simplified_groups.arrange(DOWN, buff=2)\n \n self.play(\n FadeOut(elements),\n TransformMatchingTex(element_addition_text, removal_text),\n FadeOut(levels_group),\n Write(simplified_groups)\n )\n\n self.wait(2)\n \n # Final message\n final_message = Text(\n \"Manipulate hierarchies by adding/removing elements\",\n font_size=24,\n color=WHITE\n )\n box = SurroundingRectangle(final_message, corner_radius=0.2)\n \n self.play(Write(box), Write(final_message))\n \n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### **Homework**\n\n#### Explain in your own words why HTTPS requires both symmetric and asymmetric cryptography.\nHint: Please discuss this in terms of security (the need for key exchange) and performance (efficiency of large data transmission).\n\n\nContextual location of this section (from highest to current level):\n# Outline of Lecture 13 for Computer Networks Course (Basics of Network Security: Threat Models, Cryptographic Intuition, and Authentication, 90 minutes)\n## Summary & Homework (5 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass HTTPSHomework(Scene):\n\n def construct(self):\n title = Text('Homework: HTTPS Cryptography', 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 question = Text('Why does HTTPS require both symmetric\\nand asymmetric cryptography?', font_size=32, line_spacing=1.2)\n question.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(question), run_time=2)\n asym_title = Text('Asymmetric Crypto', font_size=28, color=BLUE, weight=BOLD)\n asym_desc1 = Text('Security Focus', font_size=24)\n asym_desc2 = Text('Secure Key Exchange', font_size=24)\n asym_group = VGroup(asym_title, asym_desc1, asym_desc2).arrange(DOWN, buff=0.3)\n asym_box = SurroundingRectangle(asym_group, color=BLUE, buff=0.4)\n asym_full = VGroup(asym_box, asym_group)\n sym_title = Text('Symmetric Crypto', font_size=28, color=GREEN, weight=BOLD)\n sym_desc1 = Text('Performance Focus', font_size=24)\n sym_desc2 = Text('Efficient Data Transfer', font_size=24)\n sym_group = VGroup(sym_title, sym_desc1, sym_desc2).arrange(DOWN, buff=0.3)\n sym_box = SurroundingRectangle(sym_group, color=GREEN, buff=0.4)\n sym_full = VGroup(sym_box, sym_group)\n boxes = VGroup(asym_full, sym_full).arrange(RIGHT, buff=2.0)\n boxes.next_to(question, DOWN, buff=1.0)\n arrow = Arrow(asym_full.get_right(), sym_full.get_left(), buff=0.2, color=WHITE)\n self.play(FadeIn(asym_full), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.play(FadeIn(sym_full), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass HTTPSHomework(Scene):\n\n def construct(self):\n title = Text('Homework: HTTPS Cryptography', 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 question = Text('Why does HTTPS require both symmetric\\nand asymmetric cryptography?', font_size=32, line_spacing=1.2)\n question.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(question), run_time=2)\n asym_title = Text('Asymmetric Crypto', font_size=28, color=BBLUE, weight=BOLD)\n asym_desc1 = Text('Security Focus', font_size=24)\n asym_desc2 = Text('Secure Key Exchange', font_size=24)\n asym_group = VGroup(asym_title, asym_desc1, asym_desc2).arrange(DOWN, buff=0.3)\n asym_box = SurroundingRectangle(asym_group, color=BLUE, buff=0.4)\n asym_full = VGroup(asym_box, asym_group)\n sym_title = Text('Symmetric Crypto', font_size=28, color=GREEN, weight=BOLD)\n sym_desc1 = Text('Performance Focus', font_size=24)\n sym_desc2 = Text('Efficient Data Transfer', font_size=24)\n sym_group = VGroup(sym_title, sym_desc1, sym_desc2).arrange(DOWN, buff=0.3)\n sym_box = SurroundingRectangle(sym_group, color=GREEN, buff=0.4)\n sym_full = VGroup(sym_box, sym_group)\n boxes = VGroup(asym_full, sym_full).arrange(RIGHT, buff=2.0)\n boxes.next_to(question, DOWN, buff=1.0)\n arrow = Arrow(asym_full.get_right(), sym_full.get_left(), buff=0.2, color=WHITE)\n self.play(FadeIn(asym_full), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.play(FadeIn(sym_full), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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?", "chosen": "```python\nfrom manim import *\n\nclass SolveFirstOrderODE(Scene):\n \"\"\"\n Educational animation visualizing the step-by-step solution process \n for the first-order differential equation y' - y = 0.\n \"\"\"\n def construct(self):\n # --- Configuration ---\n HIGHLIGHT_COLOR = YELLOW\n TEXT_COLOR = BLUE\n FINAL_COLOR = GREEN\n\n # 1. Introduction and Initial Equation\n # Explanatory text at the top to guide the viewer\n explanation = Text(\n \"Step 1: Start with the differential equation\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The initial differential equation y' - y = 0\n # Splitting into parts allows for potential individual highlighting\n eq_initial = MathTex(\"y'\", \"-\", \"y\", \"=\", \"0\", font_size=48)\n eq_initial.move_to(ORIGIN)\n \n self.play(Write(explanation))\n self.play(Write(eq_initial))\n self.wait(2)\n \n # 2. Forming the Characteristic Equation\n # Update header text to explain the substitution logic\n explanation_step2 = Text(\n \"Step 2: Form the characteristic equation (assume y = e^{rx})\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The characteristic equation r - 1 = 0\n eq_characteristic = MathTex(\"r\", \"-\", \"1\", \"=\", \"0\", font_size=48)\n eq_characteristic.move_to(ORIGIN)\n \n # Transform text and equation to visually link the ODE to its algebraic counterpart\n self.play(Transform(explanation, explanation_step2))\n self.play(TransformMatchingTex(eq_initial, eq_characteristic))\n self.wait(2)\n \n # 3. Finding the Root\n # Update header text\n explanation_step3 = Text(\n \"Step 3: Solve for the root r\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The root r = 1\n eq_root = MathTex(\"r\", \"=\", \"1\", font_size=48)\n eq_root.move_to(ORIGIN)\n eq_root.set_color(HIGHLIGHT_COLOR)\n \n # Create a brief highlight around the characteristic equation before solving\n box = SurroundingRectangle(eq_characteristic, color=HIGHLIGHT_COLOR, buff=0.1)\n \n self.play(Transform(explanation, explanation_step3))\n self.play(Create(box))\n self.wait(0.5)\n self.play(ReplacementTransform(eq_characteristic, eq_root), FadeOut(box))\n self.wait(2)\n \n # 4. General Solution\n # Update header text\n explanation_step4 = Text(\n \"Step 4: Write the general solution\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The general solution y = C e^x\n eq_solution = MathTex(\"y\", \"=\", \"C\", \"e^{x}\", font_size=48)\n eq_solution.move_to(ORIGIN)\n \n # Note explicitly stating that C is an arbitrary constant\n constant_note = Text(\n \"where C is an arbitrary constant\",\n font_size=28,\n color=HIGHLIGHT_COLOR\n ).next_to(eq_solution, DOWN, buff=0.5)\n \n self.play(Transform(explanation, explanation_step4))\n self.play(ReplacementTransform(eq_root, eq_solution))\n self.play(Write(constant_note))\n self.wait(2)\n \n # 5. Conclusion\n # Final emphasis on the solution\n final_text = Text(\n \"Final General Solution\",\n font_size=40,\n color=FINAL_COLOR\n ).to_edge(UP, buff=1.0)\n \n # Box around the solution for emphasis\n final_box = SurroundingRectangle(eq_solution, color=FINAL_COLOR, buff=0.3)\n \n self.play(\n Transform(explanation, final_text),\n FadeOut(constant_note),\n Create(final_box)\n )\n \n # Hold the final frame\n self.wait(3)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql filename.py SolveFirstOrderODE\n```", "rejected": "```python\nfrom manim import *\n\nclass SolveFirstOrderODE(Scene):\n \"\"\"\n Educational animation visualizing the step-by-step solution process \n for the first-order differential equation y' - y = 0.\n \"\"\"\n def construct(self):\n # --- Configuration ---\n HIGHLIGHT_COLOR = YELLOW\n TEXT_COLOR = BBLUE\n FINAL_COLOR = GREEN\n\n # 1. Introduction and Initial Equation\n # Explanatory text at the top to guide the viewer\n explanation = Text(\n \"Step 1: Start with the differential equation\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The initial differential equation y' - y = 0\n # Splitting into parts allows for potential individual highlighting\n eq_initial = MathTex(\"y'\", \"-\", \"y\", \"=\", \"0\", font_size=48)\n eq_initial.move_to(ORIGIN)\n \n self.play(Write(explanation))\n self.play(Write(eq_initial))\n self.wait(2)\n \n # 2. Forming the Characteristic Equation\n # Update header text to explain the substitution logic\n explanation_step2 = Text(\n \"Step 2: Form the characteristic equation (assume y = e^{rx})\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The characteristic equation r - 1 = 0\n eq_characteristic = MathTex(\"r\", \"-\", \"1\", \"=\", \"0\", font_size=48)\n eq_characteristic.move_to(ORIGIN)\n \n # Transform text and equation to visually link the ODE to its algebraic counterpart\n self.play(Transform(explanation, explanation_step2))\n self.play(TransformMatchingTex(eq_initial, eq_characteristic))\n self.wait(2)\n \n # 3. Finding the Root\n # Update header text\n explanation_step3 = Text(\n \"Step 3: Solve for the root r\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The root r = 1\n eq_root = MathTex(\"r\", \"=\", \"1\", font_size=48)\n eq_root.move_to(ORIGIN)\n eq_root.set_color(HIGHLIGHT_COLOR)\n \n # Create a brief highlight around the characteristic equation before solving\n box = SurroundingRectangle(eq_characteristic, color=HIGHLIGHT_COLOR, buff=0.1)\n \n self.play(Transform(explanation, explanation_step3))\n self.play(Create(box))\n self.wait(0.5)\n self.play(ReplacementTransform(eq_characteristic, eq_root), FadeOut(box))\n self.wait(2)\n \n # 4. General Solution\n # Update header text\n explanation_step4 = Text(\n \"Step 4: Write the general solution\",\n font_size=36,\n color=TEXT_COLOR\n ).to_edge(UP, buff=1.0)\n \n # The general solution y = C e^x\n eq_solution = MathTex(\"y\", \"=\", \"C\", \"e^{x}\", font_size=48)\n eq_solution.move_to(ORIGIN)\n \n # Note explicitly stating that C is an arbitrary constant\n constant_note = Text(\n \"where C is an arbitrary constant\",\n font_size=28,\n color=HIGHLIGHT_COLOR\n ).next_to(eq_solution, DOWN, buff=0.5)\n \n self.play(Transform(explanation, explanation_step4))\n self.play(ReplacementTransform(eq_root, eq_solution))\n self.play(Write(constant_note))\n self.wait(2)\n \n # 5. Conclusion\n # Final emphasis on the solution\n final_text = Text(\n \"Final General Solution\",\n font_size=40,\n color=FINAL_COLOR\n ).to_edge(UP, buff=1.0)\n \n # Box around the solution for emphasis\n final_box = SurroundingRectangle(eq_solution, color=FINAL_COLOR, buff=0.3)\n \n self.play(\n Transform(explanation, final_text),\n FadeOut(constant_note),\n Create(final_box)\n )\n \n # Hold the final frame\n self.wait(3)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql filename.py SolveFirstOrderODE\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### String Input and Output\n\nCommon usage is as follows:\n\n```c\nchar name[20];\nscanf(\"%s\", name); // Read a word until a space or newline is encountered\nprintf(\"%s\\n\", name); // Output the string\n```\n\nTwo issues to be aware of:\n- The array must have sufficient length, otherwise overflow can occur; when inputting, the array name is the address, so no `&` is needed;\n- `scanf(\"%s\", ...)` cannot read a whole sentence with spaces; if you need to read an entire line, you can use functions like `gets` or `fgets` (but be mindful of safety and usage details).\n\n\nThe context of this section (from highest to current level):\n# Batch Data Processing\n## Strings and String Arrays: Batch Processing of Text Data\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass StringInputOutput(Scene):\n\n def construct(self):\n title = Text('String Input and Output', 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 line1 = Text('char name[20];', font_size=28, color=GREEN_C)\n line2 = Text('scanf(\"%s\", name);', font_size=28, color=BLUE_C)\n line3 = Text('printf(\"%s\\\\n\", name);', font_size=28, color=TEAL_C)\n code_group = VGroup(line1, line2, line3).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n code_bg = SurroundingRectangle(code_group, color=GRAY, fill_color=BLACK, fill_opacity=0.5, buff=0.3)\n code_block = VGroup(code_bg, code_group)\n code_block.next_to(title_group, DOWN, buff=0.6)\n self.play(FadeIn(code_bg), Write(code_group), run_time=1.5)\n bullet_1 = Text('- Array must have sufficient length to prevent overflow.', font_size=24)\n bullet_2 = Text(\"- No '&' needed in scanf: array name is the address.\", font_size=24)\n bullet_3 = Text('- scanf stops at spaces; use fgets() for full lines.', font_size=24)\n notes_group = VGroup(bullet_1, bullet_2, bullet_3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n notes_group.next_to(code_block, DOWN, buff=0.8)\n box1 = SurroundingRectangle(line1, color=YELLOW, buff=0.05)\n self.play(Create(box1), FadeIn(bullet_1), run_time=1.5)\n box2 = SurroundingRectangle(line2, color=ORANGE, buff=0.05)\n self.play(ReplacementTransform(box1, box2), FadeIn(bullet_2), run_time=1.5)\n box3 = SurroundingRectangle(line2, color=RED, buff=0.05)\n self.play(ReplacementTransform(box2, box3), FadeIn(bullet_3), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass StringInputOutput(Scene):\n\n def construct(self):\n title = Text('String Input and Output', 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 line1 = Text('char name[20];', font_size=28, color=GREEN_C)\n line2 = Text('scanf(\"%s\", name);', font_size=28, color=BLUE_C)\n line3 = Text('printf(\"%s\\\\n\", name);', font_size=28, color=TEAL_C)\n code_group = VGroup(line1, line2, line3).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n code_bg = SurroundingRectangle(code_group, color=GRAY, fill_color=BLACK, fill_opacity=0.5, buff=0.3)\n code_block = VGroup(code_bg, code_group)\n code_block.next_to(title_group, DOWN, buff=0.6)\n self.play(FadeIn(code_bg), Write(code_group), run_time=1.5)\n bullet_1 = Text('- Array must have sufficient length to prevent overflow.', font_size=24)\n bullet_2 = Text(\"- No '&' needed in scanf: array name is the address.\", font_size=24)\n bullet_3 = Text('- scanf stops at spaces; use fgets() for full lines.', font_size=24)\n notes_group = VGroup(bullet_1, bullet_2, bullet_3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n notes_group.next_to(code_block, DOWN, buff=0.8)\n box1 = SurroundingRectangle(line1, color=YELLOW, buff=0.05)\n self.play(Create(box1), FadeIn(bullet_1), run_time=1.5)\n box2 = SurroundingRectangle(line2, color=ORANGE, buff=0.05)\n self.play(ReplacementTransform(target_position=ORIGIN, box1, box2), FadeIn(bullet_2), run_time=1.5)\n box3 = SurroundingRectangle(line2, color=RED, buff=0.05)\n self.play(ReplacementTransform(box2, box3), FadeIn(bullet_3), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to see an educational animation that visually explains how to evaluate the definite integral of x cubed from 0 to 1. The video should start by displaying the integral problem, and then go step by step through the process of solving it using the power rule for integration. After that, it should show how to apply the bounds of the integral and simplify the final answer. Finally, it should conclude by showing the simplified solution on a clear screen. Can you create such an animation that is easy to understand, possibly for use in a math classroom?", "chosen": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n # Define colors for different stages of the animation\n PROBLEM_COLOR = YELLOW\n RULE_COLOR = BLUE\n STEP_COLOR = WHITE\n FINAL_COLOR = GREEN\n \n # --- Step 1: Problem Display ---\n problem = MathTex(r\"\\int_{0}^{1} x^3 \\, dx\", font_size=72, color=PROBLEM_COLOR)\n \n self.play(Write(problem))\n self.wait(2)\n \n # Move the problem to the top to make room for the step-by-step work\n self.play(problem.animate.to_edge(UP))\n \n # --- Step 2: Integration Step (Power Rule) ---\n # Display the Power Rule for context\n rule = MathTex(\n r\"\\text{Power Rule: } \\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=RULE_COLOR\n ).next_to(problem, DOWN, buff=1)\n \n self.play(Write(rule))\n self.wait(1.5)\n \n # Show the application of the rule to the specific problem\n step1 = MathTex(\n r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{1}\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(problem, RIGHT, buff=0.5)\n \n self.play(Write(step1))\n self.wait(1)\n self.play(FadeOut(rule))\n \n # Simplify the exponents and denominators\n step2 = MathTex(\n r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{1}\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step1, DOWN, buff=0.8).align_to(step1, LEFT)\n \n self.play(Write(step2))\n self.wait(1.5)\n \n # --- Step 3: Bound Application ---\n # Visually demonstrate substituting the upper bound (1) and lower bound (0)\n step3 = MathTex(\n r\"= \\left( \\frac{1^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step2, DOWN, buff=0.8).align_to(step2, LEFT)\n \n self.play(TransformMatchingTex(step2.copy(), step3), run_time=1.5)\n self.wait(1.5)\n \n # --- Step 4: Simplification ---\n # Animate the arithmetic simplification process\n step4 = MathTex(\n r\"= \\frac{1}{4} - 0\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step3, DOWN, buff=0.8).align_to(step3, LEFT)\n \n self.play(TransformMatchingTex(step3.copy(), step4))\n self.wait(1)\n \n # --- Step 5: Conclusion ---\n # Fade out all intermediate steps for a clean, uncluttered screen\n self.play(\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n FadeOut(step4)\n )\n \n # Display the simplified final solution prominently\n final_solution = MathTex(\n r\"\\int_{0}^{1} x^3 \\, dx = \\frac{1}{4}\", \n font_size=80, \n color=FINAL_COLOR\n )\n \n self.play(Write(final_solution))\n \n # Add a subtle box to frame the solution cleanly\n box = SurroundingRectangle(final_solution, color=WHITE, buff=0.3, corner_radius=0.1)\n self.play(Create(box))\n \n # Hold on the final clean screen to let students absorb the result\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EvaluateDefiniteIntegral(Scene):\n def construct(self):\n # Define colors for different stages of the animation\n PROBLEM_COLOR = YELLOW\n RULE_COLOR = BLUE\n STEP_COLOR = WHITE\n FINAL_COLOR = GREEN\n \n # --- Step 1: Problem Display ---\n problem = MathTex(r\"\\int_{0}^{1} x^3 \\, dx\", font_size=72, color=PROBLEM_COLOR)\n \n self.play(Write(problem))\n self.wait(2)\n \n # Move the problem to the top to make room for the step-by-step work\n self.play(problem.animate.to_edge(UP))\n \n # --- Step 2: Integration Step (Power Rule) ---\n # Display the Power Rule for context\n rule = MathTex(\n r\"\\text{Power Rule: } \\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=RULE_COLOR\n ).next_to(problem, DOWN, buff=1)\n \n self.play(Write(rule))\n self.wait(1.5)\n \n # Show the application of the rule to the specific problem\n step1 = MathTex(\n r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{1}\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(problem, RIGHT, buff=0.5)\n \n self.play(Write(step1))\n self.wait(1)\n self.play(FadeOut(rule))\n \n # Simplify the exponents and denominators\n step2 = MathTex(\n r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{1}\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step1, DOWN, buff=0.8).align_to(step1, LEFT)\n \n self.play(Write(step2))\n self.wait(1.5)\n \n # --- Step 3: Bound Application ---\n # Visually demonstrate substituting the upper bound (1) and lower bound (0)\n step3 = MathTex(\n r\"= \\left( \\frac{1^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step2, DOWN, buff=0.8).align_to(step2, LEFT)\n \n self.play(TransformMatchingTex(step2.copy(), step3), run_time=1.5)\n self.wait(1.5)\n \n # --- Step 4: Simplification ---\n # Animate the arithmetic simplification process\n step4 = MathTex(r\"= \\frac{1}{4} - 0\" + \" = x\", \n font_size=60, \n color=STEP_COLOR\n ).next_to(step3, DOWN, buff=0.8).align_to(step3, LEFT)\n \n self.play(TransformMatchingTex(step3.copy(), step4))\n self.wait(1)\n \n # --- Step 5: Conclusion ---\n # Fade out all intermediate steps for a clean, uncluttered screen\n self.play(\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n FadeOut(step4)\n )\n \n # Display the simplified final solution prominently\n final_solution = MathTex(\n r\"\\int_{0}^{1} x^3 \\, dx = \\frac{1}{4}\", \n font_size=80, \n color=FINAL_COLOR\n )\n \n self.play(Write(final_solution))\n \n # Add a subtle box to frame the solution cleanly\n box = SurroundingRectangle(final_solution, color=WHITE, buff=0.3, corner_radius=0.1)\n self.play(Create(box))\n \n # Hold on the final clean screen to let students absorb the result\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like to create an educational animation that visually explains how to evaluate the definite integral of x cubed from 0 to 2 using the power rule for integration. The animation should include the following steps: display the problem, write an explanation of applying the power rule, demonstrate the power rule itself, perform the integration step by step, evaluate the integral with the given bounds, show the final solution, and finally, conclude by clearly presenting the final numerical result. Can you make this animation engaging, with each step appearing in sequence and with appropriate pauses to allow viewers to follow along?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- Step 1: Problem Display ---\n title = Text(\"Evaluating a Definite Integral Using Power Rule\", font_size=36)\n title.to_edge(UP)\n\n problem = MathTex(\n r\"\\int_{0}^{2}\", \"x^3\", \"\\, dx\"\n ).scale(1.5).next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # Move the equation up slightly to make room for explanations\n self.play(FadeIn(problem.copy().shift(UP*0.8)))\n\n # Clear screen for explanations\n self.clear()\n self.wait(0.5)\n\n # --- Step 2: Explanation ---\n explanation_text = Text(\n \"Apply the Power Rule for Integration:\",\n font_size=32,\n color=BLUE\n )\n \n # Power Rule formula displayed separately so it scales smoothly during transformation\n power_rule_formula = MathTex(\n r\"\\text{If } f(x) = x^n \\Rightarrow F(x) = \\frac{x^{n+1}}{n+1}\"\n ).scale(0.7).to_edge(DOWN)\n\n self.play(Write(explanation_text))\n self.play(Write(power_rule_formula))\n\n # Animate the rule scaling down while moving it below the text\n self.play(\n power_rule_formula.animate.scale(0.5).move_to(ORIGIN).shift(DOWN*2),\n run_time=1.5\n )\n\n self.wait(2)\n\n # Fade out explanations for calculation steps\n self.play(FadeOut(explanation_text), FadeOut(power_rule_formula))\n self.wait(0.5)\n\n # --- Steps 3-5: Calculation ---\n # Antiderivative step\n antideriv_step = MathTex(\n r\"=\\left[ \\frac{x^{3+1}}{3+1}\\right]_{0}^{2}\",\n r\"=\", \n r\"\\left[ \\frac{x^4}{4}\\right]_{0}^{2}\",\n font_size=40\n ).next_to(problem, DOWN, buff=0.8)\n\n # Substitution of bounds step\n eval_bounds = MathTex(\n r\"=\\left( \\frac{2^4}{4}\\right)\", \"-\", \"(0)\"\n ).scale(0.9).next_to(antideriv_step, RIGHT, buff=0.5)\n\n self.play(Write(antideriv_step))\n self.wait(1)\n \n # Show substitution explicitly\n self.play(Write(eval_bounds))\n self.wait(1)\n\n # Simplification step\n simplification = MathTex(\n r\"=\", r\"\\frac{16}{4}\", r\"- 0\",\n font_size=40\n ).scale(0.9).next_to(eval_bounds, DOWN, aligned_edge=LEFT)\n\n self.play(Write(simplification))\n self.wait(1)\n\n # Final arithmetic step\n final_arithmetic = MathTex(\n r\"=\", r\"4\", font_size=40\n ).scale(1.5).next_to(simplification, DOWN, aligned_edge=LEFT)\n box = SurroundingRectangle(final_arithmetic, color=YELLOW, buff=MED_LARGE_BUFF)\n \n self.play(Write(final_arithmetic))\n self.play(Create(box))\n self.wait(2)\n\n # --- Step 6: Conclusion ---\n conclusion_title = Text(\"Final Solution:\", font_size=36, color=GREEN).to_edge(DOWN)\n self.play(Write(conclusion_title))\n self.wait(1)\n \n # Center the final result prominently at the bottom\n final_result = MathTex(\"4\").scale(2).set_color(GREEN)\n final_box = SurroundingRectangle(final_result, color=GOLD, buff=LARGE_BUFF)\n\n self.play(\n final_arithmetic.animate.move_to(ORIGIN).scale(1.5),\n box.animate.move_to(ORIGIN).scale(1.5),\n Write(conclusion_title),\n RunTime=2\n )\n \n # Add background box for emphasis\n full_group = VGroup(final_box, final_result, conclusion_title)\n self.play(FadeIn(full_group, shift=DOWN))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralEvaluation(Scene):\n def construct(self):\n # --- Step 1: Display Problem ---\n problem = MathTex(\n r\"\\int_{0}^{2}\", \"x^3\", \"\\\\,dx\",\n font_size=60\n ).to_edge(UP)\n \n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Explanation Text ---\n explanation_text = Tex(\"Apply Power Rule:\", \"$\\\\frac{d}{dx}(x^n) = nx^{n-1}$\").next_to(problem, DOWN, buff=0.8).scale(0.7)\n self.play(Write(explanation_text))\n\n # Add a vertical line between problem and explanation text\n vertical_line = Line(start=problem.get_bottom(), end=explanation_text.get_top(), color=GRAY_A, stroke_width=2)\n self.add(vertical_line)\n self.wait(2)\n\n # Clear explanation text after writing it\n self.remove(explanation_text)\n\n # --- Step 3: Demonstrate Power Rule ---\n power_rule_display = MathTex(\n r\"=\\left[\\frac{x^{3+1}}{3+1}\\right]_{0}^{2}\",\n r\"=\\left[\\frac{x^4}{4}\\right]_{0}^{2}\"\n ).move_to(ORIGIN).shift(DOWN * 1)\n \n self.play(Write(power_rule_display))\n self.wait(2)\n \n # Fade out demonstration elements\n self.fade_out(power_rule_display)\n \n # Move problem up to make room for intermediate calculations\n self.play(problem.animate.shift(UP * 0.5))\n\n # --- Step 4: Perform Integration Steps ---\n # Antiderivative calculation\n antiderivative_step = MathTex(\n r\"=\\frac{x^4}{4}\",\n r\"\\Big|_{0}^{2}\",\n font_size=40,\n ).next_to(problem, DOWN, buff=1.5).align_to(problem, LEFT)\n \n self.play(Write(antiderivative_step))\n self.wait(1)\n\n # Substitution of upper and lower limits\n substitution_step = MathTex(\n r\"=\\frac{(2)^4}{4}-\\frac{(0)^4}{4}\",\n font_size=40,\n ).next_to(antiderivative_step, RIGHT, buff=0.5).set_color(YELLOW)\n \n self.play(Write(substitution_step))\n self.wait(2)\n\n # Simplification of powers\n simplification_step = MathTex(\n r\"=\\frac{16}{4}-0\",\n r\"=4\"\n ).move_to(substitution_step).set_color(GREEN)\n self.play(TransformMatchingTex(substitution_step.copy(), simplification_step))\n self.wait(2)\n\n # Final Solution Box\n box = SurroundingRectangle(simplification_step, color=GREEN, fill_opacity=0.1, buff=0.2)\n self.play(Create(box), Indicate(simplification_step, scale_factor=1.2))\n self.wait(2)\n\n # --- Step 5: Conclusion ---\n conclusion_text = Text(\"Final Result:\", font_size=24, color=YELLOW).to_edge(RIGHT).shift(UP * 3.5 + RIGHT * 0.5)\n final_result = MathTex(r\"4\", font_size=72, color=GOLD).next_to(conclusion_text, RIGHT)\n \n self.play(FadeIn(conclusion_text), Write(final_result))\n self.wait(2)\n \n # Group final components to move them down cleanly\n final_group = VGroup(conclusion_text, final_result, box)\n self.play(final_group.animate.scale(0.8).shift(DOWN * 1.5), run_time=1.5)\n \n # Pause at the end for viewer engagement\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a **Rectangle** (width=4, height=2) appearing at the center of the screen. Instead of simply moving to (1, 1), the rectangle now **animates smoothly** from the center to its target position while **changing color** from blue to red. As it moves, a **mathematical formula** (e.g., the area calculation `A = width × height = 4 × 2 = 8`) fades in below it, dynamically updating as the rectangle’s dimensions shift. Once the rectangle reaches (1, 1), it **rotates 90 degrees** clockwise, and a **highlighting effect** (a glowing border) emphasizes its final position. Finally, **explanatory text** (\"Rectangle Transformation\") appears at the top of the screen, tying together the visual and mathematical concepts. This enhanced version not only preserves the original movement but also incorporates **dynamic formulas, color transitions, rotational animation, and explanatory text** for a more engaging and educational presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRectangleAnimation(Scene):\n def construct(self):\n # Create rectangle\n rectangle = Rectangle(width=4, height=2, color=BLUE)\n rectangle.move_to(ORIGIN)\n \n # Add rectangle to scene\n self.play(Create(rectangle))\n self.wait(0.5)\n \n # Create formula\n formula = MathTex(\"A = width \\\\times height = 4 \\\\times 2 = 8\")\n formula.next_to(rectangle, DOWN, buff=0.5)\n \n # Animate rectangle moving and changing color\n self.play(\n rectangle.animate.move_to([1, 1, 0]).set_color(RED),\n Write(formula),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate rectangle\n self.play(Rotate(rectangle, angle=PI/2), run_time=1)\n \n # Add glowing border effect\n glow = SurroundingRectangle(rectangle, color=YELLOW, buff=0.1, fill_opacity=0.1)\n self.play(Create(glow), run_time=0.5)\n self.wait(0.5)\n \n # Add title text\n title = Text(\"Rectangle Transformation\", font_size=24)\n title.to_edge(UP)\n self.play(Write(title), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRectangleAnimation(Scene):\n def construct(self):\n # Create rectangle\n rectangle = Rectangle(width=4, height=2, color=BLUE)\n rectangle.move_to(ORIGIN)\n \n # Add rectangle to scene\n self.play(Create(rectangle))\n self.wait(0.5)\n \n # Create formula\n formula = MathTex(\"A = width \\\\times height = 4 \\\\times 2 = 8\")\n formula.next_to(rectangle, DOWN, buff=0.5)\n \n # Animate rectangle moving and changing color\n self.play(\n rectangle.animate.move_to([1, 1, 0]).set_color(RED),\n Write(formula),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate rectangle\n self.play(Rotate(rectangle, angle=PI/2), run_time=1)\n \n # Add glowing border effect\n glow = SurroundingRectangle(rectangle, color=YELLOW, buff=0.1, fill_opacity=0.1)\n self.play(Create(glow), run_time=0.5)\n self.wait(0.5)\n \n # Add title text\n title = Text(\"Rectangle Transformation\", font_size=24)\n title.to_edge(UP)\n self.play(Write(title), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### **When Approximation is Needed**\n#### Large Networks, Complex Structure, and High Real-Time Requirements\nEspecially when the network is dense or has a large \"tree width\" (treewidth) making exact inference extremely slow, approximate inference is the only viable option.\n\n---\n\n## Summary & Homework (5 minutes)\n\n### **Review of This Section**: BN Definition, Decomposition, Inference Problems, Variable Elimination\nSummarize how Bayesian networks combine the intuitiveness of graph theory with the rigor of probability theory, and the complete process from modeling to computation.\n\n\nThe context of this section within the overall structure (from highest to current level):\n# Introduction to Artificial Intelligence Course - Detailed Outline for the Seventh Lesson (Bayesian Networks: Structured Probability Inference, 90 minutes)\n## Approximate Inference (10 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ApproximateInferenceAndSummary(Scene):\n\n def construct(self):\n title = Text('Approximate Inference & Summary', 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 subtitle1 = Text('Why Approximate?', font_size=30, color=BLUE)\n items1 = VGroup(Text('- Large Networks', font_size=24), Text('- Complex Structure', font_size=24), Text('- High Real-Time Needs', font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n positions = [UP, UR, DR, DOWN, DL, UL]\n nodes = VGroup(*[Dot(point=p * 0.9, color=YELLOW, radius=0.08) for p in positions])\n edges = VGroup()\n for i in range(len(nodes)):\n for j in range(i + 1, len(nodes)):\n edges.add(Line(nodes[i].get_center(), nodes[j].get_center(), color=GRAY, stroke_width=1.5))\n else:\n pass\n else:\n pass\n graph_label = Text('Dense Graph = Slow Exact Inference', font_size=20, color=RED).next_to(nodes, DOWN, buff=0.2)\n graph = VGroup(edges, nodes, graph_label)\n left_group = VGroup(subtitle1, items1, graph).arrange(DOWN, buff=0.6)\n subtitle2 = Text('BN Course Summary', font_size=30, color=GREEN)\n steps = ['1. BN Definition', '2. Decomposition', '3. Inference Problems', '4. Variable Elimination']\n flow_nodes = VGroup()\n for step in steps:\n t = Text(step, font_size=22)\n box = SurroundingRectangle(t, color=GREEN, buff=0.2)\n flow_nodes.add(VGroup(t, box))\n else:\n pass\n flow_nodes.arrange(DOWN, buff=0.5)\n arrows = VGroup()\n for i in range(len(flow_nodes) - 1):\n arr = Arrow(flow_nodes[i].get_bottom(), flow_nodes[i + 1].get_top(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=WHITE)\n arrows.add(arr)\n else:\n pass\n summary_flow = VGroup(flow_nodes, arrows)\n right_group = VGroup(subtitle2, summary_flow).arrange(DOWN, buff=0.6)\n content = VGroup(left_group, right_group).arrange(RIGHT, buff=1.5).next_to(title_group, DOWN, buff=0.5)\n self.play(Write(subtitle1, run_time=0.8))\n self.play(FadeIn(items1, shift=RIGHT, run_time=1))\n self.play(Create(edges, run_time=1), FadeIn(nodes, run_time=1))\n self.play(Write(graph_label, run_time=0.8))\n self.play(Write(subtitle2, run_time=0.8))\n self.play(Create(flow_nodes[0], run_time=0.6))\n for i in range(len(arrows)):\n self.play(Create(arrows[i], run_time=0.4))\n self.play(Create(flow_nodes[i + 1], run_time=0.6))\n else:\n pass\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ApproximateInferenceAndSummary(Scene):\n\n def construct(self):\n title = Text('Approximate Inference & Summary', 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 subtitle1 = Text('Why Approximate?', font_size=30, color=BBLUE)\n items1 = VGroup(Text('- Large Networks', font_size=24), Text('- Complex Structure', font_size=24), Text('- High Real-Time Needs', font_size=24)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n positions = [UP, UR, DR, DOWN, DL, UL]\n nodes = VGroup(*[Dot(point=p * 0.9, color=YELLOW, radius=0.08) for p in positions])\n edges = VGroup()\n for i in range(len(nodes)):\n for j in range(i + 1, len(nodes)):\n edges.add(Line(nodes[i].get_center(), nodes[j].get_center(), color=GRAY, stroke_width=1.5))\n else:\n pass\n else:\n pass\n graph_label = Text('Dense Graph = Slow Exact Inference', font_size=20, color=RED).next_to(nodes, DOWN, buff=0.2)\n graph = VGroup(edges, nodes, graph_label)\n left_group = VGroup(subtitle1, items1, graph).arrange(DOWN, buff=0.6)\n subtitle2 = Text('BN Course Summary', font_size=30, color=GREEN)\n steps = ['1. BN Definition', '2. Decomposition', '3. Inference Problems', '4. Variable Elimination']\n flow_nodes = VGroup()\n for step in steps:\n t = Text(step, font_size=22)\n box = SurroundingRectangle(t, color=GREEN, buff=0.2)\n flow_nodes.add(VGroup(t, box))\n else:\n pass\n flow_nodes.arrange(DOWN, buff=0.5)\n arrows = VGroup()\n for i in range(len(flow_nodes) - 1):\n arr = Arrow(flow_nodes[i].get_bottom(), flow_nodes[i + 1].get_top(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=WHITE)\n arrows.add(arr)\n else:\n pass\n summary_flow = VGroup(flow_nodes, arrows)\n right_group = VGroup(subtitle2, summary_flow).arrange(DOWN, buff=0.6)\n content = VGroup(left_group, right_group).arrange(RIGHT, buff=1.5).next_to(title_group, DOWN, buff=0.5)\n self.play(Write(subtitle1, run_time=0.8))\n self.play(FadeIn(items1, shift=RIGHT, run_time=1))\n self.play(Create(edges, run_time=1), FadeIn(nodes, run_time=1))\n self.play(Write(graph_label, run_time=0.8))\n self.play(Write(subtitle2, run_time=0.8))\n self.play(Create(flow_nodes[0], run_time=0.6))\n for i in range(len(arrows)):\n self.play(Create(arrows[i], run_time=0.4))\n self.play(Create(flow_nodes[i + 1], run_time=0.6))\n else:\n pass\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Continuous Derivation (Parallel Presentation)\n* By analogy with discrete derivation, convert summation to integration by taking the limit, and consider $x(t)$ as the sum of an infinite number of rectangular pulses of infinitesimal width.\n\n## Graphical Convolution: Flip-Shift-Multiply-Integrate/Sum (25 minutes)\nGraphical methods are key to understanding the physical process of convolution and help in intuitively judging the waveform characteristics of the output signal.\n\n\nContextual location within the document (from highest to current level):\n# Signals and Systems Course - Detailed Outline for the Fifth Lecture (Convolution and Time-Domain Analysis, 90 minutes)\n## Derivation of Convolution from Impulse Decomposition (20 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ConvolutionLecture(Scene):\n\n def construct(self):\n title1 = Text('Continuous Derivation', font_size=40, color=BLUE, weight=BOLD).to_edge(UP)\n bullet_points = VGroup(Text('• By analogy with discrete derivation, convert summation', font_size=28), Text(' to integration by taking the limit.', font_size=28), Text('• Consider x(t) as the sum of an infinite number of', font_size=28), Text(' rectangular pulses of infinitesimal width.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.15).next_to(title1, DOWN, buff=0.5)\n math_pulse = MathTex('\\\\hat{x}(t) = \\\\sum_{k=-\\\\infty}^{\\\\infty} x(k\\\\Delta) p_{\\\\Delta}(t-k\\\\Delta) \\\\Delta', font_size=36)\n math_limit = MathTex('\\\\text{As } \\\\Delta \\\\to 0: \\\\quad \\\\Delta \\\\to d\\\\tau, \\\\quad k\\\\Delta \\\\to \\\\tau, \\\\quad p_{\\\\Delta}(t) \\\\to \\\\delta(t)', font_size=32)\n math_continuous = MathTex('x(t) = \\\\int_{-\\\\infty}^{\\\\infty} x(\\\\tau)\\\\delta(t-\\\\tau)d\\\\tau', font_size=42, color=YELLOW)\n math_group = VGroup(math_pulse, math_limit, math_continuous).arrange(DOWN, buff=0.5).next_to(bullet_points, DOWN, buff=0.6)\n self.play(Write(title1))\n self.play(FadeIn(bullet_points, shift=UP * 0.2))\n self.wait(1)\n self.play(Write(math_pulse))\n self.play(FadeIn(math_limit, shift=UP * 0.2))\n self.play(Write(math_continuous))\n self.wait(3)\n self.play(FadeOut(title1, bullet_points, math_group))\n self.wait(0.5)\n title2 = Text('Graphical Convolution', font_size=40, color=YELLOW, weight=BOLD).to_edge(UP)\n subtitle2 = Text('Flip - Shift - Multiply - Integrate/Sum', font_size=32, color=GREEN).next_to(title2, DOWN, buff=0.3)\n desc_group = VGroup(Text('• Graphical methods are key to understanding the physical process of convolution.', font_size=26), Text('• Helps in intuitively judging the waveform characteristics of the output signal.', font_size=26)).arrange(DOWN, aligned_edge=LEFT, buff=0.2).next_to(subtitle2, DOWN, buff=0.6)\n steps = ['1. Flip', '2. Shift', '3. Multiply', '4. Integrate / Sum']\n boxes = VGroup()\n for step in steps:\n box = Rectangle(width=3.2, height=1.2, color=BLUE, fill_opacity=0.1)\n t = Text(step, font_size=24).move_to(box.get_center())\n boxes.add(VGroup(box, t))\n else:\n pass\n boxes.arrange(RIGHT, buff=0.5).scale(0.8).next_to(desc_group, DOWN, buff=1.0)\n arrows = VGroup()\n for i in range(len(boxes) - 1):\n arrow = Arrow(start=boxes[i].get_right(), end=boxes[i + 1].get_left(), buff=0.1, color=WHITE, max_tip_length_to_length_ratio=0.2)\n arrows.add(arrow)\n else:\n pass\n self.play(Write(title2))\n self.play(FadeIn(subtitle2, shift=UP * 0.2))\n self.wait(1)\n self.play(Write(desc_group))\n self.wait(1)\n for i in range(len(boxes)):\n self.play(Create(boxes[i]), run_time=0.8)\n if i < len(boxes) - 1:\n self.play(GrowArrow(arrows[i]), run_time=0.5)\n else:\n pass\n else:\n pass\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ConvolutionLecture(Scene):\n\n def construct(self):\n title1 = Text('Continuous Derivation', font_size=40, color=BLUE, weight=BOLD).to_edge(UP)\n bullet_points = VGroup(Text('• By analogy with discrete derivation, convert summation', font_size=28), Text(' to integration by taking the limit.', font_size=28), Text('• Consider x(t) as the sum of an infinite number of', font_size=28), Text(' rectangular pulses of infinitesimal width.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.15).next_to(title1, DOWN, buff=0.5)\n math_pulse = MathTex('\\\\hat{x}(t) = \\\\sum_{k=-\\\\infty}^{\\\\infty} x(k\\\\Delta) p_{\\\\Delta}(t-k\\\\Delta) \\\\Delta', font_size=36)\n math_limit = MathTex('\\\\text{As } \\\\Delta \\\\to 0: \\\\quad \\\\Delta \\\\to d\\\\tau, \\\\quad k\\\\Delta \\\\to \\\\tau, \\\\quad p_{\\\\Delta}(t) \\\\to \\\\delta(t)', font_size=32)\n math_continuous = MathTex('x(t) = \\\\int_{-\\\\infty}^{\\\\infty} x(\\\\tau)\\\\delta(t-\\\\tau)d\\\\tau', font_size=42, color=YELLOW)\n math_group = VGroup(math_pulse, math_limit, math_continuous).arrange(DOWN, buff=0.5).next_to(bullet_points, DOWN, buff=0.6)\n self.play(Write(title1))\n self.play(FadeIn(bullet_points, shift=UP * 0.2))\n self.wait(1)\n self.play(Write(math_pulse))\n self.play(FadeIn(math_limit, shift=UP * 0.2))\n self.play(Write(math_continuous))\n self.wait(3)\n self.play(FadeOut(title1, bullet_points, math_group))\n self.wait(0.5)\n title2 = Text('Graphical Convolution', font_size=40, color=YELLOW, weight=BOLD).to_edge(UP)\n subtitle2 = Text('Flip - Shift - Multiply - Integrate/Sum', font_size=32, color=GREEN).next_to(title2, DOWN, buff=0.3)\n desc_group = VGroup(Text('• Graphical methods are key to understanding the physical process of convolution.', font_size=26), Text('• Helps in intuitively judging the waveform characteristics of the output signal.', font_size=26)).arrange(DOWN, aligned_edge=LEFT, buff=0.2).next_to(subtitle2, DOWN, buff=0.6)\n steps = ['1. Flip', '2. Shift', '3. Multiply', '4. Integrate / Sum']\n boxes = VGroup()\n for step in steps:\n box = Rectangle(width=3.2, height=1.2, color=BLUE, fill_opacity=0.1)\n t = Text(step, font_size=24).move_to(box.get_center())\n boxes.add(VGroup(box, t))\n else:\n pass\n boxes.arrange(RIGHT, buff=0.5).scale(0.8).next_to(desc_group, DOWN, buff=1.0)\n arrows = VGroup()\n for i in range(len(boxes) - 1):\n arrow = Arrow(start=boxes[i].get_right(), end=boxes[i + 1].get_left(), buff=0.1, color=WHITE, max_tip_length_to_length_ratio=0.2)\n arrows.add(arrow)\n else:\n pass\n self.play(Write(title2))\n self.play(FadeIn(subtitle2, shift=UP * 0.2))\n self.wait(1)\n self.play(Write(desc_group))\n self.wait(1)\n for i in range(len(boxes)):\n self.play(Create(boxes[i]), run_time=0.8)\n if i < len(boxes) - 1:\n self.play(GrowArrow(arrows[i]), run_time=0.5)\n else:\n pass\n else:\n pass\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that visually shows the calculation of the area under the curve y = x^2 from x=0 to x=2, including the graph, the shaded area, and step by step integration to find the exact area, with transitions between each step of the explanation?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ------------------------------------------------------------------\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, \"numbers_to_exclude\": [0]},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define the function y = x^2 and plot it\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.8], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Highlight the Region and Shade the Area\n # ------------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines and labels\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=YELLOW)\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n start_label = MathTex(\"0\").next_to(axes.c2p(0, 0), DOWN)\n end_label = MathTex(\"2\").next_to(axes.c2p(2, 0), DOWN)\n\n self.play(\n FadeIn(area),\n Create(line_start),\n Create(line_end),\n Write(start_label),\n Write(end_label)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 3. Prepare Space for Step-by-Step Integration\n # ------------------------------------------------------------------\n # Shift the graph slightly to make room for the math equations\n graph_group = VGroup(\n axes, labels, graph, graph_label, area, \n line_start, line_end, start_label, end_label\n )\n self.play(graph_group.animate.scale(0.8).to_edge(LEFT, buff=0.5))\n\n # Define the integration steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\", font_size=42)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=42, color=YELLOW)\n\n # Group and arrange equations on the right\n equations = VGroup(step1, step2, step3, step4)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # ------------------------------------------------------------------\n # 4. Animate the Mathematical Derivation\n # ------------------------------------------------------------------\n self.play(Write(step1))\n self.wait(1.5)\n \n self.play(Write(step2))\n self.wait(1.5)\n \n self.play(Write(step3))\n self.wait(1.5)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n self.play(Create(box))\n self.wait(3)\n\n # Fade out everything for a clean finish\n self.play(\n FadeOut(graph_group),\n FadeOut(equations),\n FadeOut(box)\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Coordinate System and Graph\n # ------------------------------------------------------------------\n axes = Axes(font_size=24, \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, \"numbers_to_exclude\": [0]},\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define the function y = x^2 and plot it\n graph = axes.plot(lambda x: x**2, x_range=[0, 2.8], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Highlight the Region and Shade the Area\n # ------------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines and labels\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=YELLOW)\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n start_label = MathTex(\"0\").next_to(axes.c2p(0, 0), DOWN)\n end_label = MathTex(\"2\").next_to(axes.c2p(2, 0), DOWN)\n\n self.play(\n FadeIn(area),\n Create(line_start),\n Create(line_end),\n Write(start_label),\n Write(end_label)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 3. Prepare Space for Step-by-Step Integration\n # ------------------------------------------------------------------\n # Shift the graph slightly to make room for the math equations\n graph_group = VGroup(\n axes, labels, graph, graph_label, area, \n line_start, line_end, start_label, end_label\n )\n self.play(graph_group.animate.scale(0.8).to_edge(LEFT, buff=0.5))\n\n # Define the integration steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\", font_size=42)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", font_size=42, color=YELLOW)\n\n # Group and arrange equations on the right\n equations = VGroup(step1, step2, step3, step4)\n equations.arrange(DOWN, aligned_edge=LEFT, buff=0.8)\n equations.to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n # ------------------------------------------------------------------\n # 4. Animate the Mathematical Derivation\n # ------------------------------------------------------------------\n self.play(Write(step1))\n self.wait(1.5)\n \n self.play(Write(step2))\n self.wait(1.5)\n \n self.play(Write(step3))\n self.wait(1.5)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.1)\n self.play(Create(box))\n self.wait(3)\n\n # Fade out everything for a clean finish\n self.play(\n FadeOut(graph_group),\n FadeOut(equations),\n FadeOut(box)\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an educational animation where a trigonometric function composed of the sine and cosine functions is shown. First, display the function \"f(x) = sin(x) + cos(x)\" on the screen. Then, introduce the idea of a trigonometric identity with a text saying \"Use a trigonometric identity\" at the top of the screen. After that, use the identity to transform the original function into \"f(x) = √2 sin(x + π/4)\" and show this process on the screen. Next, I want to see the graph of the original function, so please include axes and plot the function \"f(x) = sin(x) + cos(x)\", with the graph labeled as \"f(x)\". Finally, clear everything except the graph of the function from the screen and display it once more for emphasis. The animation should allow some time between steps for viewers to understand each part, so include brief pauses as needed.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass TrigIdentityAnimation(Scene):\n def construct(self):\n # 1. Initial Display: Show the function text \"f(x) = sin(x) + cos(x)\"\n original_eq = MathTex(\"f(x)\", \"=\", \"\\\\sin(x)\", \"+\", \"\\\\cos(x)\")\n self.play(Write(original_eq))\n self.wait(1)\n\n # 2. Identity Introduction: Display text at the top of the screen\n identity_hint = Text(\"Use a trigonometric identity\", font_size=36)\n identity_hint.to_edge(UP)\n self.play(Write(identity_hint))\n self.wait(1)\n\n # 3. Transformation: Transform original function into equivalent form\n transformed_eq = MathTex(\"f(x)\", \"=\", \"\\\\sqrt{2}\", \"\\\\sin\\\\left(x + \\\\frac{\\\\pi}{4}\\\\right)\")\n self.play(ReplacementTransform(original_eq, transformed_eq))\n self.wait(1.5)\n\n # 4. Graphing: Create coordinate axes, plot the graph, and label it\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI / 2],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True},\n x_length=10,\n y_length=6\n )\n \n # Plot the original function f(x) = sin(x) + cos(x)\n graph = axes.plot(\n lambda x: np.sin(x) + np.cos(x), \n color=BLUE, \n x_range=[-2 * PI, 2 * PI]\n )\n graph_label = MathTex(\"f(x)\", color=BLUE).next_to(graph, UR, buff=0.2)\n \n # Transition to graphing phase\n self.play(\n FadeOut(identity_hint), \n transformed_eq.animate.to_edge(UP).shift(DOWN * 0.5)\n )\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1.5)\n\n # 5. Emphasis: Clear all elements except the function graph, then display again\n self.play(\n FadeOut(axes), \n FadeOut(graph_label), \n FadeOut(transformed_eq)\n )\n \n # Fade out and recreate the graph for emphasis\n self.play(FadeOut(graph))\n self.wait(0.5)\n self.play(Create(graph), run_time=2)\n self.play(graph.animate.set_stroke(width=6), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass TrigIdentityAnimation(Scene):\n def construct(self):\n # 1. Initial Display: Show the function text \"f(x) = sin(x) + cos(x)\"\n original_eq = MathTex(\"f(x)\", \"=\", \"\\\\sin(x)\", \"+\", \"\\\\cos(x)\")\n self.play(Write(original_eq))\n self.wait(1)\n\n # 2. Identity Introduction: Display text at the top of the screen\n identity_hint = Text(\"Use a trigonometric identity\", font_size=36)\n identity_hint.to_edge(UP)\n self.play(Write(identity_hint))\n self.wait(1)\n\n # 3. Transformation: Transform original function into equivalent form\n transformed_eq = MathTex(\"f(x)\", \"=\", \"\\\\sqrt{2}\", \"\\\\sin\\\\left(x + \\\\frac{\\\\pi}{4}\\\\right)\")\n self.play(ReplacementTransform(original_eq, transformed_eq))\n self.wait(1.5)\n\n # 4. Graphing: Create coordinate axes, plot the graph, and label it\n axes = Axes(font_size=24, \n x_range=[-2 * PI, 2 * PI, PI / 2],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True},\n x_length=10,\n y_length=6\n )\n \n # Plot the original function f(x) = sin(x) + cos(x)\n graph = axes.plot(\n lambda x: np.sin(x) + np.cos(x), \n color=BLUE, \n x_range=[-2 * PI, 2 * PI]\n )\n graph_label = MathTex(\"f(x)\", color=BLUE).next_to(graph, UR, buff=0.2)\n \n # Transition to graphing phase\n self.play(\n FadeOut(identity_hint), \n transformed_eq.animate.to_edge(UP).shift(DOWN * 0.5)\n )\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1.5)\n\n # 5. Emphasis: Clear all elements except the function graph, then display again\n self.play(\n FadeOut(axes), \n FadeOut(graph_label), \n FadeOut(transformed_eq)\n )\n \n # Fade out and recreate the graph for emphasis\n self.play(FadeOut(graph))\n self.wait(0.5)\n self.play(Create(graph), run_time=2)\n self.play(graph.animate.set_stroke(width=6), run_time=1)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 Basic Ideas and Core Constraints of Mechanism Design\n* Master the three core elements of mechanism design: outcome function, payment rule, and information structure.\n* Gain a deep understanding of the two key constraints: incentive compatibility (IC) and individual rationality (IR).\n\n\n\n\n\n\n\n\n## Incentive Compatibility\n\n### Basic Definition of Incentive Compatibility\n* Under the rules set by the mechanism, reporting one's true type is the best strategy for participants.\n\n\nThe context of this section (from highest to current level):\n# Mechanism Design and Incentive Compatibility\n## Course Introduction and Learning Objectives\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MechanismDesignLecture(Scene):\n\n def construct(self):\n main_title = Text('Mechanism Design and Incentive Compatibility', font_size=36, weight=BOLD, color=BLUE)\n main_title.to_edge(UP, buff=0.5)\n self.play(Write(main_title))\n self.wait(0.5)\n section_title = Text('Learning Objectives', font_size=30, color=YELLOW)\n section_title.next_to(main_title, DOWN, buff=0.6)\n subtitle = Text('Understanding the Basic Ideas and Core Constraints of Mechanism Design', font_size=22, color=LIGHT_GREY)\n subtitle.next_to(section_title, DOWN, buff=0.3)\n self.play(FadeIn(section_title), FadeIn(subtitle))\n self.wait(0.5)\n obj_1 = Text('• Master the three core elements of mechanism design:\\n outcome function, payment rule, and information structure.', font_size=24, line_spacing=1.2)\n obj_2 = Text('• Gain a deep understanding of the two key constraints:\\n incentive compatibility (IC) and individual rationality (IR).', font_size=24, line_spacing=1.2)\n objectives = VGroup(obj_1, obj_2).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n objectives.next_to(subtitle, DOWN, buff=0.8)\n self.play(FadeIn(obj_1, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(FadeIn(obj_2, shift=RIGHT * 0.5))\n self.wait(2)\n self.play(FadeOut(objectives), FadeOut(subtitle), FadeOut(section_title))\n ic_title = Text('Incentive Compatibility', font_size=32, color=YELLOW)\n ic_title.next_to(main_title, DOWN, buff=0.6)\n ic_def_box = VGroup()\n ic_subtitle = Text('Basic Definition:', font_size=26, color=GREEN)\n ic_text = Text(\"Under the rules set by the mechanism, reporting one's\\ntrue type is the best strategy for participants.\", font_size=24, line_spacing=1.2)\n ic_def_box.add(ic_subtitle, ic_text).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n ic_def_box.next_to(ic_title, DOWN, buff=0.6)\n self.play(FadeIn(ic_title))\n self.play(Write(ic_subtitle))\n self.play(FadeIn(ic_text))\n self.wait(1)\n agent_group = VGroup()\n agent = Circle(radius=0.6, color=WHITE, fill_opacity=0.1)\n agent_label = Text('Participant', font_size=20)\n agent_type = MathTex('\\\\text{True Type: } \\\\theta', font_size=24, color=ORANGE)\n agent_type.next_to(agent, DOWN)\n agent_group.add(agent, agent_label, agent_type)\n agent_group.move_to(LEFT * 3.5 + DOWN * 1.8)\n mech_group = VGroup()\n mech = Rectangle(width=2.5, height=1.2, color=BLUE, fill_opacity=0.1)\n mech_label = Text('Mechanism', font_size=22)\n mech_label.move_to(mech.get_center())\n mech_group.add(mech, mech_label)\n mech_group.move_to(RIGHT * 3.5 + DOWN * 1.8)\n arrow = Arrow(agent.get_right(), mech.get_left(), buff=0.2, color=WHITE)\n report_text = MathTex('\\\\text{Report } \\\\hat{\\\\theta} = \\\\theta', font_size=24, color=YELLOW)\n report_text.next_to(arrow, UP, buff=0.2)\n best_response = Text('Best Strategy\\n(Maximized Payoff)', font_size=20, color=GREEN, line_spacing=1.2)\n best_response.next_to(mech_group, DOWN, buff=0.3)\n self.play(FadeIn(agent_group))\n self.wait(0.5)\n self.play(FadeIn(mech_group))\n self.wait(0.5)\n self.play(GrowArrow(arrow), FadeIn(report_text))\n self.wait(0.5)\n self.play(FadeIn(best_response))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MechanismDesignLecture(Scene):\n\n def construct(self):\n main_title = Text('Mechanism Design and Incentive Compatibility', font_size=36, weight=BOLD, color=BLUE)\n main_title.to_edge(UP, buff=0.5)\n self.play(Write(main_title))\n self.wait(0.5)\n section_title = Text('Learning Objectives', font_size=30, color=YELLOW)\n section_title.next_to(main_title, DOWN, buff=0.6)\n subtitle = Text('Understanding the Basic Ideas and Core Constraints of Mechanism Design', font_size=22, color=LIGHT_GREY)\n subtitle.next_to(section_title, DOWN, buff=0.3)\n self.play(FadeIn(section_title), FadeIn(subtitle))\n self.wait(0.5)\n obj_1 = Text('• Master the three core elements of mechanism design:\\n outcome function, payment rule, and information structure.', font_size=24, line_spacing=1.2)\n obj_2 = Text('• Gain a deep understanding of the two key constraints:\\n incentive compatibility (IC) and individual rationality (IR).', font_size=24, line_spacing=1.2)\n objectives = VGroup(obj_1, obj_2).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n objectives.next_to(subtitle, DOWN, buff=0.8)\n self.play(FadeIn(obj_1, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(FadeIn(obj_2, shift=RIGHT * 0.5))\n self.wait(2)\n self.play(FadeOut(objectives), FadeOut(subtitle), FadeOut(section_title))\n ic_title = Text('Incentive Compatibility', font_size=32, color=YELLOW)\n ic_title.next_to(main_title, DOWN, buff=0.6)\n ic_def_box = VGroup()\n ic_subtitle = Text('Basic Definition:', font_size=26, color=GREEN)\n ic_text = Text(\"Under the rules set by the mechanism, reporting one's\\ntrue type is the best strategy for participants.\", font_size=24, line_spacing=1.2)\n ic_def_box.add(ic_subtitle, ic_text).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n ic_def_box.next_to(ic_title, DOWN, buff=0.6)\n self.play(FadeIn(ic_title))\n self.play(Write(ic_subtitle))\n self.play(FadeIn(ic_text))\n self.wait(1)\n agent_group = VGroup()\n agent = Circle(radius=0.6, color=WHITE, fill_opacity=0.1)\n agent_label = Text('Participant', font_size=20)\n agent_type = MathTex('\\\\text{True Type: } \\\\theta', font_size=24, color=ORANGE)\n agent_type.next_to(agent, DOWN)\n agent_group.add(agent, agent_label, agent_type)\n agent_group.move_to(LEFT * 3.5 + DOWN * 1.8)\n mech_group = VGroup()\n mech = Rectangle(width=2.5, height=1.2, color=BLUE, fill_opacity=0.1)\n mech_label = Text('Mechanism', font_size=22)\n mech_label.move_to(mech.get_center())\n mech_group.add(mech, mech_label)\n mech_group.move_to(RIGHT * 3.5 + DOWN * 1.8)\n arrow = Arrow(agent.get_right(), mech.get_left(), buff=0.2, color=WHITE)\n report_text = MathTex('\\\\text{Report } \\\\hat{\\\\theta} = \\\\theta', font_size=24, color=YELLOW)\n report_text.next_to(arrow, UP, buff=0.2)\n best_response = Text('Best Strategy\\n(Maximized Payoff)', font_size=20, color=GREEN, line_spacing=1.2)\n best_response.next_to(mech_group, DOWN, buff=0.3)\n self.play(FadeIn(agent_group))\n self.wait(0.5)\n self.play(FadeIn(mech_group))\n self.wait(0.5)\n self.play(GrowArrow(arrow), FadeIn(report_text))\n self.wait(0.5)\n self.play(FadeIn(best_response))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a **Rectangle** (width=4, height=2) appearing at the center of the screen. Instead of simply moving to (1, 1), the rectangle now **animates smoothly** from the center to its target position while **changing color** from blue to red. As it moves, a **mathematical formula** (e.g., the area calculation `A = width × height = 4 × 2 = 8`) fades in below it, dynamically updating as the rectangle’s dimensions shift. Once the rectangle reaches (1, 1), it **rotates 90 degrees** clockwise, and a **highlighting effect** (a glowing border) emphasizes its final position. Finally, **explanatory text** (\"Rectangle Transformation\") appears at the top of the screen, tying together the visual and mathematical concepts. This enhanced version not only preserves the original movement but also incorporates **dynamic formulas, color transitions, rotational animation, and explanatory text** for a more engaging and educational presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle and Position\n rect = Rectangle(width=4, height=2, stroke_color=BLUE)\n rect.move_to(ORIGIN)\n\n # Animate Rectangle Movement and Color Change\n self.play(\n MoveAlongPath(rect, Line(ORIGIN, ORIGIN + RIGHT*1 + UP*1)),\n rect.animate.set_stroke(color=RED),\n run_time=2,\n rate_func=smooth\n )\n\n # Display Formula\n math_text = MathTex(\"A = w \\\\times h = 4 \\\\times 2 = 8\")\n math_text.next_to(rect, DOWN, buff=1)\n\n self.play(FadeIn(math_text))\n\n # Rotate Rectangle by 90 degrees Clockwise\n self.play(Rotate(rect, angle=PI/2, about_point=rect.get_center()), run_time=1.5)\n\n # Add Highlight Effect (Glowing Border)\n highlight_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.1, fill_opacity=0.3, stroke_width=2)\n highlight_rect.set_stroke(opacity=0.7)\n\n self.add(highlight_rect)\n\n # Show Explanatory Text\n title_text = Text(\"Rectangle Transformation\", font_size=36).to_edge(UP)\n \n self.play(Write(title_text))\n self.wait()\n\n# To render this animation using manim, save the code to a file named \"enhanced_scene.py\" and run:\n# manim -pql enhanced_scene.py EnhancedRectangleScene\n\n# Replace '-p' with '-q' for quick rendering without audio, or remove it entirely for silent rendering.\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRectangleScene(Scene):\n def construct(self):\n # Create Rectangle\n rect = Rectangle(width=4, height=2)\n \n # Initial Position\n rect.move_to(ORIGIN)\n\n # Target Position\n target_pos = np.array([1, 1, 0])\n\n # Color Transition\n initial_color = BLUE\n target_color = RED\n\n # Mathematical Formula\n math_text = MathTex(\n \"A\", \"=\", \"w\", \"\\\\times\", \"h\", \"=\",\n str(rect.width), \"\\\\times\", str(rect.height),\n \"=\", str(rect.get_area())\n ).next_to(rect, DOWN)\n\n # Explanatory Text\n title_text = Text(\"Rectangle Transformation\").to_edge(UP)\n\n # Animation Sequence\n self.play(Create(title_text))\n self.play(FadeIn(math_text))\n self.play(\n MoveAlongPath(rect, Line(ORIGIN, target_pos)),\n rect.animate.set_fill(target_color).set_stroke(target_color),\n run_time=2\n )\n self.play(Rotate(rect, angle=-PI/2))\n self.play(\n RectLengthAndWidthFromVerticesAnim(rect, [rect.right, rect.up + rect.left]),\n FadeOut(math_text),\n Write(MathTex(\"A = 8\"))\n )\n\n # Highlight Effect\n glow_rect = SurroundingRectangle(rect, color=YELLOW, buff=0.2, stroke_width=12)\n self.play(Create(glow_rect))\n\n# To render this animation, save the code to a file called 'enhanced_rectangle_scene.py'\n# Then run the command: manim -pql enhanced_rectangle_scene.py EnhancedRectangleScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 before fading out. Also, I want the molecule to be shown with a double bond between the atoms.", "chosen": "```python\nfrom manim import *\n\nclass OxygenBondAnimation(Scene):\n def construct(self):\n # --- Configuration ---\n atom_color = RED\n bond_color = WHITE\n \n # Create the oxygen atoms\n atom_left = Circle(radius=0.7, color=atom_color)\n atom_right = Circle(radius=0.7, color=atom_color)\n \n # Position them initially side-by-side for rotation effect\n atom_group = VGroup(atom_left, atom_right).arrange(RIGHT, buff=1)\n\n # Add bonds between corresponding parts of each circle\n bond1 = Line(\n start=atom_left.get_center() + UP * 0.3,\n end=atom_right.get_center() + DOWN * 0.6,\n stroke_width=6,\n stroke_color=bond_color\n )\n \n bond2 = Line(\n start=atom_left.get_center() + DOWN * 0.3,\n end=atom_right.get_center() + UP * 0.6,\n stroke_width=6,\n stroke_color=bond_color\n )\n\n # Group everything for atomic structure\n molecule = VGroup(bond1, bond2, atom_group)\n\n # --- Animation Sequence ---\n\n # Step 1: Fade In\n self.play(FadeIn(molecule))\n self.wait(0.5)\n\n # Step 2: Rotation\n self.play(\n Rotate(molecule, angle=TAU),\n run_time=3,\n rate_func=linear\n )\n self.wait(0.5)\n\n # Step 3: Scaling Up\n self.play(\n molecule.animate.scale(2),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(1)\n\n # Step 4: Fade Out\n self.play(FadeOut(molecule))\n\n# To render this animation, save it as 'oxygen_bond.py' and run:\n# manim -pql oxygen_bond.py OxygenBondAnimation\n```", "rejected": "```python\nfrom manim import *\n\nclass OxygenMoleculeScene(Scene):\n def construct(self):\n # --- Configuration ---\n atom_radius = 0.6\n bond_color = BLUE\n atom_color = RED\n\n # Create O atoms\n o1 = Circle(radius=atom_radius, color=atom_color)\n o2 = Circle(radius=atom_radius, color=atom_color)\n\n # Position them side-by-side initially for rotation effect\n o1.move_to(LEFT * 2)\n o2.move_to(RIGHT * 2)\n\n # Create Double Bond line segments (centered between atoms)\n bond_start = ORIGIN + LEFT * (o1.radius + 0.1) # Buffer so they don't overlap exactly\n bond_end = ORIGIN + RIGHT * (o2.radius + 0.1)\n\n # Add bonds at top and bottom positions along the line connecting them\n bond_top = Line(bond_start, bond_end, stroke_width=8).set_stroke(bond_color, opacity=0.7)\n bond_bottom = Line(bond_start, bond_end, stroke_width=8).shift(DOWN*0.1).set_stroke(bond_color, opacity=0.7)\n\n # Group elements including bonds\n molecule_group = VGroup(\n o1,\n o2,\n bond_top,\n bond_bottom\n )\n\n # Animation Sequence\n\n # Step 1: Fade In Atoms\n self.play(FadeIn(o1, shift=RIGHT))\n self.play(FadeIn(o2, shift=LEFT))\n\n # Move them towards center slightly for scaling effect later\n self.play(MoveAlongPath(o1, arc_segment([o1.get_center(), [0,1,-1], [0,1,1]], radius=1)))\n self.play(MoveAlongPath(o2, arc_segment([o2.get_center(), [-0.5,1,-0.5], [0,1,0.5]], radius=1)))\n\n # Step 2: Rotate Around Central Axis (Simulating Rotation of Molecule in Space)\n central_axis = Vector().put_start_and_end_on(o1.get_center(), o2.get_center())\n \n # Animate rotation about this axis\n self.play(Rotating(molecule_group, angle=PI, about_point=ORIGIN, run_time=2, rate_func=smooth))\n\n # Step 3: Scale Up to Double Size\n target_scale_factor = 2\n \n self.play(\n o1.animate.scale(target_scale_factor),\n o2.animate.scale(target_scale_factor),\n RunTime(0.8),\n rate_func=smoothen\n )\n \n # Re-render bonds after scaling to ensure they also expand correctly\n bond_top.put_start_and_end_on(o1.get_right() + UP * (atom_radius * target_scale_factor), \n o2.get_left() + DOWN * (atom_radius * target_scale_factor))\n bond_bottom.put_start_and_end_on(o1.get_right() + DOWN * (atom_radius * target_scale_factor), \n o2.get_left())\n\n # Step 4: Fade Out\n self.play(FadeOut(molecule_group))\n\n# To render this animation locally, save it to a file and execute:\n# manim -pql filename.py OxygenMoleculeScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that visibly explains the steps to calculate the definite integral of the function 3x^2 from 0 to 2, complete with the integration process, simplifying the result, and presenting the final answer?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralSteps(Scene):\n \"\"\"\n An educational animation explaining the definite integral of 3x^2 from 0 to 2.\n The scene combines a geometric representation (area under the curve) \n with the symbolic step-by-step calculation.\n \"\"\"\n def construct(self):\n # --- 1. Setup Axes and Function ---\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 15, 2],\n x_length=5,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Function f(x) = 3x^2\n graph = axes.plot(lambda x: 3 * x**2, x_range=[0, 2.2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = 3x^2\", buff=0.1)\n\n # Area under the curve from 0 to 2\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n \n # Animate the graph and the area to provide geometric context\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 2. Symbolic Integration Setup ---\n # Place the equations on the right side of the screen\n calc_group = VGroup().shift(RIGHT * 3 + UP * 1.5)\n\n # Step 1: The initial integral\n step1 = MathTex(r\"\\int_{0}^{2} 3x^2 \\, dx\", font_size=48, color=WHITE)\n step1.move_to(calc_group)\n \n self.play(Write(step1))\n self.wait(1)\n\n # Step 2: Finding the antiderivative\n # The antiderivative of 3x^2 is x^3\n step2 = MathTex(r\"= \\left[ x^3 \\right]_{0}^{2}\", font_size=48, color=WHITE)\n step2.next_to(step1, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.play(Indicate(step2))\n self.wait(1)\n\n # Step 3: Substituting the limits (Fundamental Theorem of Calculus)\n step3 = MathTex(r\"= (2)^3 - (0)^3\", font_size=48, color=WHITE)\n step3.next_to(step2, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # Step 4: Simplification\n step4 = MathTex(r\"= 8 - 0\", font_size=48, color=WHITE)\n step4.next_to(step3, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Step 5: Final Answer\n step5 = MathTex(r\"= 8\", font_size=60, color=YELLOW)\n step5.next_to(step4, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step5))\n self.play(Circumscribe(step5, color=YELLOW))\n self.wait(2)\n\n # --- 3. Final Conclusion ---\n # Create a final summary text\n final_text = Text(\"The area under the curve is 8\", font_size=30).shift(DOWN * 3)\n \n self.play(Write(final_text))\n self.wait(3)\n\n # Fade out everything for a clean finish\n self.play(\n FadeOut(axes), \n FadeOut(graph), \n FadeOut(graph_label), \n FadeOut(area), \n FadeOut(labels),\n FadeOut(step1), \n FadeOut(step2), \n FadeOut(step3), \n FadeOut(step4), \n FadeOut(step5),\n FadeOut(final_text)\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSteps(Scene):\n \"\"\"\n An educational animation explaining the definite integral of 3x^2 from 0 to 2.\n The scene combines a geometric representation (area under the curve) \n with the symbolic step-by-step calculation.\n \"\"\"\n def construct(self):\n # --- 1. Setup Axes and Function ---\n axes = Axes(label_font_size=24, \n x_range=[0, 2.5, 0.5],\n y_range=[0, 15, 2],\n x_length=5,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT, buff=1)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Function f(x) = 3x^2\n graph = axes.plot(lambda x: 3 * x**2, x_range=[0, 2.2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = 3x^2\", buff=0.1)\n\n # Area under the curve from 0 to 2\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n \n # Animate the graph and the area to provide geometric context\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 2. Symbolic Integration Setup ---\n # Place the equations on the right side of the screen\n calc_group = VGroup().shift(RIGHT * 3 + UP * 1.5)\n\n # Step 1: The initial integral\n step1 = MathTex(r\"\\int_{0}^{2} 3x^2 \\, dx\", font_size=48, color=WHITE)\n step1.move_to(calc_group)\n \n self.play(Write(step1))\n self.wait(1)\n\n # Step 2: Finding the antiderivative\n # The antiderivative of 3x^2 is x^3\n step2 = MathTex(r\"= \\left[ x^3 \\right]_{0}^{2}\", font_size=48, color=WHITE)\n step2.next_to(step1, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.play(Indicate(step2))\n self.wait(1)\n\n # Step 3: Substituting the limits (Fundamental Theorem of Calculus)\n step3 = MathTex(r\"= (2)^3 - (0)^3\", font_size=48, color=WHITE)\n step3.next_to(step2, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # Step 4: Simplification\n step4 = MathTex(r\"= 8 - 0\", font_size=48, color=WHITE)\n step4.next_to(step3, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Step 5: Final Answer\n step5 = MathTex(r\"= 8\", font_size=60, color=YELLOW)\n step5.next_to(step4, DOWN, buff=0.8, aligned_edge=LEFT)\n \n self.play(Write(step5))\n self.play(Circumscribe(step5, color=YELLOW))\n self.wait(2)\n\n # --- 3. Final Conclusion ---\n # Create a final summary text\n final_text = Text(\"The area under the curve is 8\", font_size=30).shift(DOWN * 3)\n \n self.play(Write(final_text))\n self.wait(3)\n\n # Fade out everything for a clean finish\n self.play(\n FadeOut(axes), \n FadeOut(graph), \n FadeOut(graph_label), \n FadeOut(area), \n FadeOut(labels),\n FadeOut(step1), \n FadeOut(step2), \n FadeOut(step3), \n FadeOut(step4), \n FadeOut(step5),\n FadeOut(final_text)\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains the original features while adding significant new elements: \n\nThe animation begins with a purple horizontal line centered on the screen, stretching from (-3, 0) to (3, 0). As the line smoothly shifts upward by 2 units, a coordinate system fades in beneath it, with labeled x and y axes to provide spatial context. Simultaneously, a mathematical expression appears above the moving line, dynamically rendering as \\( y = 2 \\) to indicate its new vertical position. Once the line reaches its destination, it briefly pulses to emphasize its final position, and then a dashed copy of the original line fades in below, connected by a vertical arrow annotated with \"Δy = 2\" to visually represent the displacement. The entire sequence is accompanied by a subtle color shift in the background to enhance visual appeal, and explanatory text at the bottom of the screen summarizes the transformation: \"A vertical translation shifts the line upward by 2 units.\" This enriched animation not only demonstrates the movement but also reinforces the mathematical and conceptual understanding of translations in a coordinate plane.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedLineTranslation(Scene):\n def construct(self):\n # Create initial line\n line = Line(start=[-3, 0, 0], end=[3, 0, 0], color=PURPLE)\n \n # Create coordinate system\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 3, 1],\n x_length=8,\n y_length=5,\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-2, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Create equation\n equation = MathTex(\"y = 0\", color=WHITE).next_to(line, UP)\n \n # Create translated line\n translated_line = line.copy()\n translated_line.shift(UP * 2)\n \n # Create dashed original line\n dashed_line = DashedVMobject(line.copy(), num_dashes=20, color=GRAY)\n \n # Create displacement arrow and label\n arrow = Arrow(start=line.get_center(), end=translated_line.get_center(), buff=0, color=YELLOW)\n delta_label = MathTex(r\"\\Delta y = 2\", color=YELLOW).next_to(arrow, RIGHT)\n \n # Create explanation text\n explanation = Text(\"A vertical translation shifts the line upward by 2 units.\", font_size=24)\n explanation.to_edge(DOWN)\n \n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n self.play(FadeIn(axes), FadeIn(axes_labels))\n self.wait(0.5)\n \n # Update equation during translation\n equation_target = MathTex(\"y = 2\", color=WHITE).next_to(translated_line, UP)\n self.play(\n Transform(line, translated_line),\n Transform(equation, equation_target),\n run_time=2\n )\n \n # Pulse effect\n self.play(\n line.animate.set_color(PINK),\n Flash(line, color=PINK, flash_radius=3.5),\n run_time=0.5\n )\n self.play(line.animate.set_color(PURPLE))\n \n # Show displacement\n self.play(FadeIn(dashed_line))\n self.play(GrowArrow(arrow), FadeIn(delta_label))\n self.wait(1)\n \n # Add explanation\n self.play(Write(explanation))\n self.wait(2)\n \n # Final fade out\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedLineTranslation(Scene):\n def construct(self):\n # Create initial line\n line = Line(start=[-3, 0, 0], end=[3, 0, 0], color=PURPLE)\n \n # Create coordinate system\n axes = Axes(label_font_size=24, \n x_range=[-4, 4, 1],\n y_range=[-2, 3, 1],\n x_length=8,\n y_length=5,\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-2, 4, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Create equation\n equation = MathTex(\"y = 0\", color=WHITE).next_to(line, UP)\n \n # Create translated line\n translated_line = line.copy()\n translated_line.shift(UP * 2)\n \n # Create dashed original line\n dashed_line = DashedVMobject(line.copy(), num_dashes=20, color=GRAY)\n \n # Create displacement arrow and label\n arrow = Arrow(start=line.get_center(), end=translated_line.get_center(), buff=0, color=YELLOW)\n delta_label = MathTex(r\"\\Delta y = 2\", color=YELLOW).next_to(arrow, RIGHT)\n \n # Create explanation text\n explanation = Text(\"A vertical translation shifts the line upward by 2 units.\", font_size=24)\n explanation.to_edge(DOWN)\n \n # Animation sequence\n self.play(Create(line), Write(equation))\n self.wait(0.5)\n self.play(FadeIn(axes), FadeIn(axes_labels))\n self.wait(0.5)\n \n # Update equation during translation\n equation_target = MathTex(\"y = 2\", color=WHITE).next_to(translated_line, UP)\n self.play(\n Transform(line, translated_line),\n Transform(equation, equation_target),\n run_time=2\n )\n \n # Pulse effect\n self.play(\n line.animate.set_color(PINK),\n Flash(line, color=PINK, flash_radius=3.5),\n run_time=0.5\n )\n self.play(line.animate.set_color(PURPLE))\n \n # Show displacement\n self.play(FadeIn(dashed_line))\n self.play(GrowArrow(arrow), FadeIn(delta_label))\n self.wait(1)\n \n # Add explanation\n self.play(Write(explanation))\n self.wait(2)\n \n # Final fade out\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that displays a sequence of numbers, specifically the powers of 3 (1, 3, 9, 27, 81, 243, ...), accompanied by arrows between them indicating multiplication by 3? Start with a title saying \"Observe a sequência abaixo:\" which means \"Observe the sequence below:\" in Portuguese. Use a gentle color scheme with a light background, and have the arrows appear in sequence with a dynamic effect. Once all elements are shown, fade them out and clear the screen. Ensure the animation is vertical (portrait mode) and suitable for a mobile display.", "chosen": "```python\nfrom manim import *\n\n# --- Configuration for Vertical/Mobile Layout (9:16) ---\nconfig.pixel_width = 1080\nconfig.pixel_height = 1920\nconfig.frame_height = 16.0\nconfig.frame_width = 9.0\nconfig.background_color = \"#FAFAFA\" # Gentle light background\n\n\nclass PowersOfThree(Scene):\n def construct(self):\n # --- Color Palette ---\n text_color = \"#2C3E50\" # Dark slate for readability\n accent_color = \"#3498DB\" # Gentle blue for arrows/labels\n\n # --- Title ---\n title = Text(\n \"Observe a sequência abaixo:\",\n font_size=40,\n color=text_color,\n weight=BOLD,\n ).to_edge(UP, buff=1.0)\n\n # --- Sequence Numbers ---\n values = [1, 3, 9, 27, 81, 243]\n number_mobs = VGroup(\n *[MathTex(str(v), font_size=56, color=text_color) for v in values]\n )\n number_mobs.arrange(DOWN, buff=1.2)\n number_mobs.next_to(title, DOWN, buff=1.0)\n\n # --- Arrows and \"\\times 3\" Labels ---\n connectors = VGroup()\n for i in range(len(values) - 1):\n arrow = Arrow(\n start=number_mobs[i].get_bottom(),\n end=number_mobs[i + 1].get_top(),\n buff=0.15,\n color=accent_color,\n stroke_width=5,\n max_tip_length_to_length_ratio=0.15,\n )\n label = MathTex(\n r\"\\times 3\",\n font_size=32,\n color=accent_color,\n ).next_to(arrow, RIGHT, buff=0.25)\n\n connectors.add(VGroup(arrow, label))\n\n # --- Animation Sequence ---\n\n # 1. Show title\n self.play(Write(title), run_time=1.2)\n self.wait(0.5)\n\n # 2. First number appears\n self.play(FadeIn(number_mobs[0], shift=DOWN * 0.3), run_time=0.8)\n\n # 3. Sequentially reveal arrows and subsequent numbers\n for i in range(len(values) - 1):\n self.wait(0.2)\n # Dynamic arrow entrance\n self.play(\n GrowArrow(connectors[i][0]),\n Write(connectors[i][1]),\n run_time=0.7,\n )\n # Next number fades in\n self.play(\n FadeIn(number_mobs[i + 1], shift=DOWN * 0.3),\n run_time=0.6,\n )\n\n # Hold for observation\n self.wait(2)\n\n # 4. Fade out everything and clear the screen\n self.play(FadeOut(*self.mobjects), run_time=1.5)\n\n\n# To render: manim -pql --pixel_width 1080 --pixel_height 1920 filename.py PowersOfThree\n```", "rejected": "```python\nfrom manim import *\n\n# --- Configuration for Vertical/Mobile Layout (9:16) ---\nconfig.pixel_width = 1080\nconfig.pixel_height = 1920\nconfig.frame_height = 16.0\nconfig.frame_width = 9.0\nconfig.background_color = \"#FAFAFA\" # Gentle light background\n\n\nclass PowersOfThree(Scene):\n def construct(self):\n # --- Color Palette ---\n text_color = \"#2C3E50\" # Dark slate for readability\n accent_color = \"#3498DB\" # Gentle blue for arrows/labels\n\n # --- Title ---\n title = Text(\n \"Observe a sequência abaixo:\",\n font_size=40,\n color=text_color,\n weight=BOLD,\n ).to_edge(UP, buff=1.0)\n\n # --- Sequence Numbers ---\n values = [1, 3, 9, 27, 81, 243]\n number_mobs = VGroup(\n *[MathTex(str(v), font_size=56, color=text_color) for v in values]\n )\n number_mobs.arrange(DOWN, buff=1.2)\n number_mobs.next_to(title, DOWN, buff=1.0)\n\n # --- Arrows and \"\\times 3\" Labels ---\n connectors = VGroup()\n for i in range(len(values) - 1):\n arrow = Arrow(\n start=number_mobs[i].get_bottom(),\n end=number_mobs[i + 1].get_top(),\n buff=0.15,\n color=accent_color,\n stroke_width=5,\n max_tip_length_to_length_ratio=0.15,\n )\n label = MathTex(r\"\\times 3\" + \" = x\",\n font_size=32,\n color=accent_color,\n ).next_to(arrow, RIGHT, buff=0.25)\n\n connectors.add(VGroup(arrow, label))\n\n # --- Animation Sequence ---\n\n # 1. Show title\n self.play(Write(title), run_time=1.2)\n self.wait(0.5)\n\n # 2. First number appears\n self.play(FadeIn(number_mobs[0], shift=DOWN * 0.3), run_time=0.8)\n\n # 3. Sequentially reveal arrows and subsequent numbers\n for i in range(len(values) - 1):\n self.wait(0.2)\n # Dynamic arrow entrance\n self.play(\n GrowArrow(connectors[i][0]),\n Write(connectors[i][1]),\n run_time=0.7,\n )\n # Next number fades in\n self.play(\n FadeIn(number_mobs[i + 1], shift=DOWN * 0.3),\n run_time=0.6,\n )\n\n # Hold for observation\n self.wait(2)\n\n # 4. Fade out everything and clear the screen\n self.play(FadeOut(*self.mobjects), run_time=1.5)\n\n\n# To render: manim -pql --pixel_width 1080 --pixel_height 1920 filename.py PowersOfThree\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an educational animation using ManimCE that illustrates how light rays interact with a pair of lenses? The lenses should be displayed as blue and semi-transparent, and there should be one on the left and o\n- Act 2: 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:", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass MultiActMasterpiece_0687(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n\n # --- ACT 1: Lenses Interacting With Light Rays ---\n \n title = Text('Light Rays Through Lenses', font_size=36)\n title.to_edge(UP)\n \n lens_left = RoundedRectangle(width=1.5, height=1.2, corner_radius=0.1, color=BLUE)\n lens_right = RoundedRectangle(width=1.5, height=1.2, corner_radius=0.1, color=BLUE)\n lens_group = VGroup(lens_left, lens_right).arrange(RIGHT, buff=3)\n lens_group.next_to(title, DOWN, buff=0.5)\n \n ray_in = DashedLine(start=lens_left.get_right(), end=lens_left.get_right()+RIGHT*3, stroke_width=2)\n ray_out = DashedLine(start=lens_right.get_left(), end=lens_right.get_left()-LEFT*3, stroke_width=2)\n \n # Animation sequence for Act 1\n self.play(Write(title))\n self.play(Create(lens_left), Create(ray_in))\n self.play(Create(lens_right), Create(ray_out))\n self.wait()\n\n # --- ACT 2: Enhanced Hexagon Transformation ---\n\n hexagon = RegularPolygon(n=6, radius=1.5, color=GREEN)\n hex_label = MathTex(\"H\", font_size=36).move_to(hexagon.get_center())\n hex_text = Tex(\"A regular hexagon has six equal sides.\", font_size=24).to_corner(DL)\n\n # Display initial state with label and text\n self.play(Create(hexagon), Write(hex_text))\n self.add(hex_label)\n self.wait(1)\n\n # Transform hexagon into a star by changing vertices\n star_vertices = [\n ORIGIN,\n RIGHT * 1.5 + UP * 0.866,\n LEFT * 0.75 + UP * 0.866 + RIGHT * 0.25,\n LEFT * 0.75 + DOWN * 0.866 + RIGHT * 0.25,\n LEFT * 0.75 + DOWN * 0.866 + LEFT * 0.25,\n RIGHT * 1.5 + DOWN * 0.866\n ]\n star = Polygon(*star_vertices, color=YELLOW)\n\n # Add star label and explanation text\n star_label = MathTex(\"S\", font_size=36).move_to(star.get_center())\n transform_eq = MathTex(\"\\\\text{Hex} \\\\rightarrow \\\\text{Star}\", font_size=30).next_to(hex_text, DOWN, buff=0.5)\n formula = MathTex(\n \"\\\\frac{(n-2)\\\\cdot 180^{\\circ}}{n}=\\\\frac{(6-2)\\\\cdot 180^{\\circ}}{6}=120^{\\circ}\",\n font_size=24\n ).scale(0.7).to_edge(RIGHT, buff=1.5)\n\n # Animate transformation and explanations\n self.play(Transform(hexagon, star), FadeIn(hex_label))\n self.play(Write(transform_eq))\n self.play(Write(formula))\n self.wait(2)\n\n # Clean up screen at the end\n self.play(FadeOut(VGroup(hexagon, hex_label, hex_text, transform_eq, formula)))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0678(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n\n def construct(self):\n # --- ACT 1 ---\n \n # Create two lenses: Blue lens on the left, red lens on the right\n left_lens = Rectangle(width=1.2, height=2.5, color=BLUE, fill_opacity=0.3).shift(LEFT*3)\n right_lens = Circle(radius=0.8, color=RED, fill_opacity=0.5).move_to(RIGHT*2)\n \n # Display both lenses simultaneously for clarity\n self.play(Create(left_lens), Create(right_lens))\n\n # Animate a ray entering from above, passing through the blue lens,\n # then reflecting off the red lens at its surface, moving down.\n entry_ray = Line(start=UP*2.5, end=ORIGIN, stroke_width=4, color=YELLOW)\n first_reflection = Dot(entry_ray.get_end(), radius=0.05, color=WHITE)\n second_reflection = Dot(right_lens.get_right(), radius=0.05, color=WHITE)\n exit_ray = Arrow(second_reflection.get_center(), DOWN*1, buff=0, color=GREEN, max_tip_length_to_length_ratio=0.1)\n \n self.play(GrowFromEdge(entry_ray, UP)) \n self.play(MoveAlongPath(first_reflection, entry_ray), run_time=1.5) \n \n # Lens refraction logic simplified for visual effect\n # Actual physics requires Snell's Law calculations which is beyond basic Manim usage scope\n self.play(\n MoveToPoint(first_reflection, right_lens.get_left()),\n Indicate(right_lens),\n run_time=1.5\n )\n \n # Simulate reflection by moving along the circle path\n arc_path = Arc(center=right_lens.get_center(), radius=1.5, start_angle=PI, angle=-PI/2)\n self.play(MoveAlongPath(second_reflection, arc_path), run_time=1.5)\n \n self.play(GrowArrow(exit_ray))\n\n # Add labels for educational context\n label_blue = Text(\"First Lens\", font_size=24).next_to(left_lens, UP)\n label_red = Text(\"Second Lens\", font_size=24).next_to(right_lens, UP)\n \n self.add(label_blue, label_red)\n\n # Conclusion statement\n conclusion_text = Text(\"The interaction demonstrates how light passes through and reflects off surfaces.\", font_size=24)\n conclusion_box = SurroundingRectangle(conclusion_text, color=BLUE, buff=0.2)\n self.play(Write(conclusion_text), Create(conclusion_box))\n \n self.wait(3)\n\n # Fade out everything to transition to the next part\n self.play(\n FadeOut(left_lens), FadeOut(right_lens), \n FadeOut(entry_ray), FadeOut(first_reflection), \n FadeOut(second_reflection), FadeOut(exit_ray),\n FadeOut(label_blue), FadeOut(label_red),\n FadeOut(conclusion_text), FadeOut(conclusion_box)\n )\n\n # --- ACT 2 ---\n\n # Draw the initial regular hexagon\n hexagon = RegularPolygon(n=6, radius=2, color=BLUE)\n self.play(Create(hexagon))\n self.wait(0.5)\n\n # Transform it smoothly into a star polygon\n star = Star(n=6, outer_radius=2, inner_radius=1, color=RED)\n self.play(Transform(hexagon, star), run_time=2)\n self.wait(0.5)\n\n # Add explanatory text about the properties of stars\n explanation = Text(\"Stars have interior angles summing up to (n-2)*180 degrees\", font_size=24)\n explanation.to_edge(DOWN)\n self.play(Write(explanation))\n self.wait(2)\n\n # Clear the screen for the final mathematical derivation\n self.play(FadeOut(VGroup(hexagon, explanation)))\n self.wait(0.5)\n\n # Write the equation for the sum of interior angles of a polygon\n math_eq = MathTex(r\"\\text{Sum} = (\\text{n}-2) \\times 180^\\circ\")\n self.play(Write(math_eq))\n self.wait(1)\n\n # Highlight the specific case of n=6 (hexagon/star)\n box = SurroundingRectangle(MathTex(r\"6\"), color=GREEN, buff=0.2)\n self.play(Create(box))\n self.wait(1)\n\n # Reveal the numerical result for hexagons/stars\n result = MathTex(r\"\\text{Sum} = 720^\\circ\")\n result.next_to(math_eq, DOWN)\n self.play(Write(result))\n self.wait(2)\n\n# To render this animation, save it as 'MultiActMasterpiece_0678.py' and run:\n# manim -pql MultiActMasterpiece_0678.py MultiActMasterpiece_0678\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Why do spectral methods offer advantages over finite-difference methods for problems with smooth solutions?", "chosen": "```python\nfrom manim import *\n\nclass SpectralMethodsAdvantage(Scene):\n def construct(self):\n # Set background color to deep blue\n self.camera.background_color = \"#0C2D48\"\n \n # Title\n title = Text(\"Spectral Methods: The Smooth Operator's Advantage\", font_size=32, color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Introduction text\n intro = Text(\"Why are spectral methods better for smooth solutions?\", font_size=24, color=WHITE)\n intro.next_to(title, DOWN, buff=1)\n self.play(FadeIn(intro))\n self.wait(1)\n self.play(FadeOut(intro))\n \n # Visual Element 1: Finite Difference vs Spectral Method\n # Create axes\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-1.5, 1.5],\n x_length=6,\n y_length=3,\n )\n \n # Original smooth function\n smooth_curve = axes.plot(lambda x: np.sin(x), color=GREEN)\n curve_label = Text(\"Smooth Solution\", font_size=20, color=GREEN)\n curve_label.next_to(axes, UP)\n \n self.play(Create(axes), Create(smooth_curve), Write(curve_label))\n self.wait(1)\n \n # Finite difference approximation\n fd_points = VGroup()\n for i in range(-6, 7):\n x = i * 0.5\n y = np.sin(x)\n point = Dot(axes.c2p(x, y), color=BLUE)\n fd_points.add(point)\n \n fd_label = Text(\"Finite Difference: Many Points Needed\", font_size=20, color=BLUE)\n fd_label.next_to(axes, UP)\n \n self.play(FadeOut(curve_label), Write(fd_label), Create(fd_points))\n self.wait(1)\n \n # Spectral approximation\n spectral_points = VGroup()\n for i in range(-2, 3):\n x = i * 1.5\n y = np.sin(x)\n point = Dot(axes.c2p(x, y), color=GREEN, radius=0.1)\n spectral_points.add(point)\n \n spectral_label = Text(\"Spectral Method: Few Points for Accuracy\", font_size=20, color=GREEN)\n spectral_label.next_to(axes, UP)\n \n self.play(FadeOut(fd_points), FadeOut(fd_label), Create(spectral_points), Write(spectral_label))\n self.wait(1)\n \n self.play(\n FadeOut(spectral_points), \n FadeOut(spectral_label), \n FadeOut(smooth_curve), \n FadeOut(axes)\n )\n \n # Element 2: Convergence Rates\n conv_axes = Axes(\n x_range=[0, 5],\n y_range=[0, 5],\n x_length=5,\n y_length=4,\n axis_config={\"color\": WHITE},\n )\n \n x_label = Text(\"Number of Points\", font_size=16, color=WHITE).next_to(conv_axes, DOWN)\n y_label = Text(\"Error\", font_size=16, color=WHITE).next_to(conv_axes, LEFT)\n \n # Linear convergence for FD\n fd_graph = conv_axes.plot(lambda x: 5 - x, x_range=[0, 5], color=BLUE)\n fd_conv_label = Text(\"Finite Difference: Linear Convergence\", font_size=16, color=BLUE)\n fd_conv_label.next_to(conv_axes, UP)\n \n self.play(Create(conv_axes), Write(x_label), Write(y_label))\n self.play(Create(fd_graph), Write(fd_conv_label))\n self.wait(1)\n \n # Exponential convergence for spectral\n spec_graph = conv_axes.plot(lambda x: 5 * np.exp(-x), x_range=[0, 5], color=GREEN)\n spec_conv_label = Text(\"Spectral Method: Exponential Convergence\", font_size=16, color=GREEN)\n spec_conv_label.next_to(fd_conv_label, DOWN)\n \n self.play(Create(spec_graph), Write(spec_conv_label))\n self.wait(1)\n \n self.play(\n FadeOut(conv_axes), \n FadeOut(x_label), \n FadeOut(y_label),\n FadeOut(fd_graph), \n FadeOut(fd_conv_label),\n FadeOut(spec_graph), \n FadeOut(spec_conv_label)\n )\n \n # Element 3: Key equations\n eq1 = Text(\"u'(x) = f(x), x in [a,b]\", font_size=24, color=WHITE)\n eq1.move_to(UP)\n \n eq2 = Text(\"u(x) \\approx sum of c_k φ_k(x)\", font_size=24, color=WHITE)\n eq2.next_to(eq1, DOWN, buff=1)\n \n self.play(Write(eq1))\n self.wait(0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Spectral methods converge exponentially for smooth solutions!\", font_size=24, color=WHITE)\n conclusion.move_to(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n final_title = Text(\"Spectral Methods: The Smooth Operator's Choice\", font_size=28, color=GREEN)\n final_title.to_edge(DOWN)\n \n self.play(\n FadeOut(eq1),\n FadeOut(eq2),\n FadeOut(conclusion),\n Write(final_title)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass SpectralMethodsAdvantage(Scene):\n def construct(self):\n # Set background color to deep blue\n self.camera.background_color = \"#0C2D48\"\n \n # Title\n title = Text(\"Spectral Methods: The Smooth Operator's Advantage\", font_size=32, color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Introduction text\n intro = Text(\"Why are spectral methods better for smooth solutions?\", font_size=24, color=WHITE)\n intro.next_to(title, DOWN, buff=1)\n self.play(FadeIn(intro))\n self.wait(1)\n self.play(FadeOut(intro))\n \n # Visual Element 1: Finite Difference vs Spectral Method\n # Create axes\n axes = Axes(label_font_size=24, \n x_range=[-3, 3],\n y_range=[-1.5, 1.5],\n x_length=6,\n y_length=3,\n )\n \n # Original smooth function\n smooth_curve = axes.plot(lambda x: np.sin(x), color=GREEN)\n curve_label = Text(\"Smooth Solution\", font_size=20, color=GREEN)\n curve_label.next_to(axes, UP)\n \n self.play(Create(axes), Create(smooth_curve), Write(curve_label))\n self.wait(1)\n \n # Finite difference approximation\n fd_points = VGroup()\n for i in range(-6, 7):\n x = i * 0.5\n y = np.sin(x)\n point = Dot(axes.c2p(x, y), color=BLUE)\n fd_points.add(point)\n \n fd_label = Text(\"Finite Difference: Many Points Needed\", font_size=20, color=BLUE)\n fd_label.next_to(axes, UP)\n \n self.play(FadeOut(curve_label), Write(fd_label), Create(fd_points))\n self.wait(1)\n \n # Spectral approximation\n spectral_points = VGroup()\n for i in range(-2, 3):\n x = i * 1.5\n y = np.sin(x)\n point = Dot(axes.c2p(x, y), color=GREEN, radius=0.1)\n spectral_points.add(point)\n \n spectral_label = Text(\"Spectral Method: Few Points for Accuracy\", font_size=20, color=GREEN)\n spectral_label.next_to(axes, UP)\n \n self.play(FadeOut(fd_points), FadeOut(fd_label), Create(spectral_points), Write(spectral_label))\n self.wait(1)\n \n self.play(\n FadeOut(spectral_points), \n FadeOut(spectral_label), \n FadeOut(smooth_curve), \n FadeOut(axes)\n )\n \n # Element 2: Convergence Rates\n conv_axes = Axes(\n x_range=[0, 5],\n y_range=[0, 5],\n x_length=5,\n y_length=4,\n axis_config={\"color\": WHITE},\n )\n \n x_label = Text(\"Number of Points\", font_size=16, color=WHITE).next_to(conv_axes, DOWN)\n y_label = Text(\"Error\", font_size=16, color=WHITE).next_to(conv_axes, LEFT)\n \n # Linear convergence for FD\n fd_graph = conv_axes.plot(lambda x: 5 - x, x_range=[0, 5], color=BLUE)\n fd_conv_label = Text(\"Finite Difference: Linear Convergence\", font_size=16, color=BLUE)\n fd_conv_label.next_to(conv_axes, UP)\n \n self.play(Create(conv_axes), Write(x_label), Write(y_label))\n self.play(Create(fd_graph), Write(fd_conv_label))\n self.wait(1)\n \n # Exponential convergence for spectral\n spec_graph = conv_axes.plot(lambda x: 5 * np.exp(-x), x_range=[0, 5], color=GREEN)\n spec_conv_label = Text(\"Spectral Method: Exponential Convergence\", font_size=16, color=GREEN)\n spec_conv_label.next_to(fd_conv_label, DOWN)\n \n self.play(Create(spec_graph), Write(spec_conv_label))\n self.wait(1)\n \n self.play(\n FadeOut(conv_axes), \n FadeOut(x_label), \n FadeOut(y_label),\n FadeOut(fd_graph), \n FadeOut(fd_conv_label),\n FadeOut(spec_graph), \n FadeOut(spec_conv_label)\n )\n \n # Element 3: Key equations\n eq1 = Text(\"u'(x) = f(x), x in [a,b]\", font_size=24, color=WHITE)\n eq1.move_to(UP)\n \n eq2 = Text(\"u(x) \\approx sum of c_k φ_k(x)\", font_size=24, color=WHITE)\n eq2.next_to(eq1, DOWN, buff=1)\n \n self.play(Write(eq1))\n self.wait(0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Spectral methods converge exponentially for smooth solutions!\", font_size=24, color=WHITE)\n conclusion.move_to(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n final_title = Text(\"Spectral Methods: The Smooth Operator's Choice\", font_size=28, color=GREEN)\n final_title.to_edge(DOWN)\n \n self.play(\n FadeOut(eq1),\n FadeOut(eq2),\n FadeOut(conclusion),\n Write(final_title)\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an animation that shows the wave equation for a vibrating string, followed by displaying the speed of light. Then, move the wave equation to the top of the screen and place the speed of light directly below it. Afterward, add a text explanation beneath them stating that the general solution to the wave equation involves sine and cosine functions, or exponentials with an imaginary argument. Next, transform the wave equation into an example solution involving a combination of cosine and sine functions, and replace the explanatory text with a new one that indicates the waves are traveling in the x direction. Finally, clear the screen by fading everything out.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationScene(Scene):\n def construct(self):\n # --- Step 1: Initial Display ---\n # Create the wave equation and display the speed of light\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n ).to_edge(LEFT).shift(DOWN * 1)\n\n speed_light = MathTex(\"c \\\\approx 3 \\\\times 10^8 \\\\text{ m/s}\", font_size=40).next_to(wave_eq, DOWN, buff=0.6)\n\n self.play(Write(wave_eq))\n self.play(Write(speed_light))\n\n # Wait briefly after initial display\n self.wait(1)\n\n # --- Step 2: Reorganization ---\n # Move the wave equation to the top and position the speed of light directly below it\n self.play(\n wave_eq.animate.to_edge(UP),\n speed_light.animate.next_to(wave_eq, DOWN, buff=1)\n )\n\n # Add the explanatory text below the equations\n explanation = Text(\n \"The general solution involves sine and cosine functions,\\nor exponentials with an imaginary argument.\",\n font_size=28,\n color=WHITE\n ).next_to(speed_light, DOWN, buff=0.7)\n\n self.play(Write(explanation))\n\n # Wait briefly after reorganization\n self.wait(1.5)\n\n # --- Step 3: Transformation & Replacement ---\n # Transform the wave equation into an example solution\n specific_solution = MathTex(\n r\"u(x,t) = A \\cos(kx - \\omega t)\",\n font_size=48\n ).move_to(wave_eq.get_center())\n\n self.play(Transform(wave_eq, specific_solution))\n\n # Replace the explanatory text with a new statement about travel direction\n travel_text = Text(\n \"This represents waves traveling in the positive x-direction.\",\n font_size=28,\n color=GREEN\n ).match_width(explanation).next_to(speed_light, DOWN, buff=0.7).center()\n\n self.play(ReplacementTransform(explanation, travel_text))\n\n # Wait briefly after transformation\n self.wait(2)\n\n # --- Step 4: Cleanup ---\n # Clear the screen by fading everything out simultaneously\n all_objects = VGroup(wave_eq, speed_light, travel_text)\n \n self.play(FadeOut(all_objects, shift=DOWN))\n \n # Final pause\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationScene(Scene):\n def construct(self):\n # --- Step 1: Display Initial Equations ---\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2} = c^2 \\frac{\\partial^2 u}{\\partial x^2}\"\n )\n \n light_speed = MathTex(\"c\", r\"=\", \"3.00 \\times 10^8\", r\"\\text{ m/s}\")\n\n equations = VGroup(wave_eq, light_speed).arrange(DOWN, buff=0.6)\n self.play(Write(equations))\n self.wait(1)\n\n # Move initial equations to specific positions\n self.play(\n wave_eq.animate.to_edge(UP),\n run_time=1.5\n )\n self.play(\n light_speed.animate.next_to(wave_eq, DOWN, buff=0.5).shift(RIGHT * 0.5),\n run_time=1.5\n )\n\n # --- Step 2: Add Explanatory Text ---\n explain_text = Tex(\n r\"The general solution involves sine and cosine functions,\", \n r\"or exponentials with an imaginary argument.\"\n ).to_edge(DOWN)\n\n self.play(Write(explain_text))\n self.wait(2)\n\n # --- Step 3: Transform Wave Equation ---\n solution_eq = MathTex(\n r\"u(x,t) =\", \n r\"A \\cos(kx - \\omega t)\", \"+\", \n r\"B \\sin(kx + \\omega t)\"\n ).next_to(light_speed, UP, buff=0.7)\n\n self.play(TransformMatchingTex(wave_eq, solution_eq))\n self.wait(1)\n\n # Replace explanatory text with new information about travel direction\n travel_text = Tex(\"These waves are propagating in the positive $x$-direction.\")\n travel_text.move_to(explain_text.get_center())\n\n self.play(ReplaceExtraneousTarget(explain_text, FadeOut))\n self.play(Write(travel_text))\n\n # Final step: Clear the screen\n self.wait(2)\n all_mobs = VGroup(solution_eq, light_speed, travel_text)\n self.play(FadeOut(all_mobs))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I need to create an educational animation to help students understand how to integrate exponential functions. Specifically, I want to showcase the process of integrating the function e raised to the 2x power with respect to x. The animation should start by displaying the integral of e^(2x) with respect to x. Then, it should include a step-by-step explanation that demonstrates integrating by using the reverse power rule, complete with written commentary. After showing the result of this integration, which is one-half times e^(2x) plus a constant of integration, I would like the initial problem to transform smoothly into the final answer. Once that is done, I want to clear the frame and conclude by stating, \"The integral of an exponential\", followed by a display of the final integration result again. The entire process should be paced slowly enough for students to follow along, with each step displayed for a couple of seconds before moving on to the next. Can you create an animation that meets these requirements?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialIntegration(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Initial Display\n # Display the integral of e^(2x) with respect to x initially.\n # ------------------------------------------------------------------\n\n initial_problem = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\"\n ).scale(1.2)\n\n self.play(Write(initial_problem))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 2: Method Explanation\n # Visually demonstrate the method used: Integration by Substitution\n # Show u-substitution explicitly for clarity.\n # ------------------------------------------------------------------\n\n sub_step = MathTex(\n r\"u &= 2x \\\\\",\n r\"du &= 2\\,dx \\\\\",\n r\"dx &= \\frac{1}{2}\\,du\"\n ).arrange(DOWN).scale(0.8)\n \n sub_box = SurroundingRectangle(sub_step, color=BLUE, buff=0.2)\n\n self.play(Write(sub_step))\n self.play(Create(sub_box))\n self.wait(3)\n\n # Animate substitution into the integral expression\n substituted_integral = MathTex(\n r\"\\int \", r\"e^u\", r\" \\cdot \", r\"\\frac{1}{2} \", r\"du\"\n ).scale(1.2)\n \n self.play(TransformMatchingTex(initial_problem, substituted_integral))\n self.wait(3)\n\n # Clear substitutions for the algebraic steps\n self.play(FadeOut(sub_step), FadeOut(sub_box))\n\n # ------------------------------------------------------------------\n # Step 3: Algebra Steps\n # Demonstrate the algebraic manipulation specifically for the power rule.\n # Explicitly show multiplication by the coefficient from du/dx transformation.\n # ------------------------------------------------------------------\n\n algebra_step = MathTex(\n r\"\\int \", r\"e^u\", r\" \\cdot \", r\"\\frac{1}{2}\"\n ).scale(1.2)\n \n self.play(ReplacementTransform(substituted_integral, algebra_step))\n self.wait(2)\n\n antiderivative = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(e^u + C\\right)\"\n ).scale(1.2).next_to(algebra_step, RIGHT)\n\n self.play(Write(antiderivative))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Reverse Substitution\n # Revert back to the original variable x to finalize the solution.\n # Write out the exact form of the result clearly.\n # ------------------------------------------------------------------\n\n reverse_sub = MathTex(\n r\"=\", r\"\\frac{1}{2}\", r\"\\left(e^{2x} + C\\right)\"\n ).scale(1.2)\n \n self.play(ReplacementTransform(antiderivative, reverse_sub))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # Step 5: Transformation\n # Smoothly animate the transition from the initial problem statement \n # to the final simplified result.\n # ------------------------------------------------------------------\n\n final_answer = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\", r\" =\", r\"\\frac{1}{2}\", r\"e^{2x}\", \"+ C\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(reverse_sub, final_answer))\n self.wait(3)\n\n # ------------------------------------------------------------------\n # Step 6: Conclusion\n # Clear the screen completely.\n # Display a brief text statement identifying the concept.\n # Redisplay the final numerical result prominently at the end.\n # ------------------------------------------------------------------\n\n self.clear()\n \n conclusion_text = Text(\"The integral of an exponential\\nfunction involves multiplying by the inverse exponentials' coefficients.\", font_size=36)\n conclusion_text.to_edge(UP)\n self.play(Write(conclusion_text))\n self.wait(3)\n\n final_display = MathTex(\n r\"\\int \", r\"e^{2x}\", r\" \\, dx\", r\" =\", r\"\\frac{1}{2}\", r\"e^{2x}\", \"+ C\"\n ).scale(1.5).set_color(YELLOW)\n final_display.next_to(conclusion_text, DOWN, buff=0.5)\n\n box = SurroundingRectangle(final_display, color=GREEN, buff=0.3)\n \n self.play(Write(box))\n self.play(Write(final_display))\n self.wait(5)\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialIntegration(Scene):\n def construct(self):\n # --- Configuration ---\n COMMENTARY_COLOR = BLUE_C\n MATH_COLOR = YELLOW\n\n # Display the integral expression initially\n problem_expr = MathTex(\"\\\\int\", \"e^{2x}\", \"\\\\,dx\")\n problem_expr.scale(1.8)\n \n self.play(Write(problem_expr))\n self.wait(2)\n\n # Step 1: Substitution\n sub_text = Text(\"Substitute u = 2x\", font_size=36).to_edge(UP)\n self.add(sub_text)\n \n u_eq = MathTex(\"u\", \"=\", \"2x\").scale(1.2)\n du_dx = MathTex(\"\\\\frac{du}{dx}\", \"=\", \"2\")\n dx = MathTex(\"dx\", \"=\", \"\\\\frac{1}{2}du\")\n\n substitution_group = VGroup(u_eq, du_dx, dx).arrange(RIGHT, buff=1).next_to(sub_text, DOWN, buff=0.5)\n self.play(FadeIn(sub_text, shift=DOWN), Write(substitution_group))\n\n transformed_integral = MathTex(\"\\\\int\", \"e^u\", \"\\\\cdot \\\\frac{1}{2}du\")\n transformed_integral.next_to(sub_problem_expr, RIGHT, buff=1.5)\n \n self.play(TransformMatchingGroups(\n problem_expr.copy().shift(LEFT*3 + UP*1.5),\n transformed_integral.shift(LEFT*3 + UP*1.5)\n ))\n \n self.wait(2)\n\n # Step 2: Integration\n integrated_u = MathTex(\"\\\\int\", \"e^u\", \"\\\\cdot \\\\frac{1}{2}du\", \"=\", \"\\\\frac{1}{2}\\\\int\", \"e^u\", \"du\")\n integrated_u.move_next_to(transformed_integral, DOWN, aligned_edge=RIGHT, buff=0.5)\n \n antiderivative_u = MathTex(\"\\\\frac{1}{2}(e^u)\", \"+ C\")\n antiderivative_u.move_next_to(integrated_u, DOWN, aligned_edge=RIGHT, buff=0.5)\n \n # Highlight the constants being multiplied during the transformation\n highlight_box = SurroundingRectangle(VGroup(integrated_u, antiderivative_u), color=YELLOW)\n \n self.play(Write(integrated_u))\n self.play(Write(antiderivative_u), Create(highlight_box))\n self.wait(2)\n\n # Step 3: Back-substitution\n back_sub_title = Text(\"Back-Substitute: u = 2x\", font_color=ORANGE).to_edge(UP)\n back_sub_result = MathTex(\"\\\\frac{1}{2}e^{2x}\", \"+ C\")\n back_sub_result.move_next_to(antiderivative_u, DOWN, aligned_edge=RIGHT, buff=0.5)\n \n self.play(ReplaceTarget(back_sub_result, back_sub_title))\n \n self.play(Write(back_sub_result)) \n \n # Show the conclusion text briefly\n conclusion_text = Tex(\"The integral of an exponential function\", font_size=36).to_edge(DOWN)\n self.play(Write(conclusion_text))\n self.wait(2)\n\n # Final Result Reveal\n final_result = MathTex(\"\\\\int\", \"e^{2x}\", \"\\\\,dx\", \"=\", \"\\\\frac{1}{2}e^{2x}\", \"+ C\")\n final_result.to_edge(UP, buff=1)\n \n self.play(Write(final_result))\n self.wait(2)\n\n# To run this animation, save it as 'exponential_integration.py' and execute:\n# manim -pql exponential_integration.py ExponentialIntegration\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an animated video using ManimCE that demonstrates projectile motion with the effects of air resistance where the animation starts with the title \"Projectile motion with air resistance\" followed by a subtitle \"The motion is influenced by gravity and drag force.\" Then, show two physics equations representing the drag force and the resulting acceleration due to gravity and drag force. Finally, animate a dot following a parabolic path to represent the projectile motion influenced by these forces, making sure the animation of the projectile motion lasts for about four seconds.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ProjectileMotionWithDrag(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n title = Text(\n \"Projectile motion with air resistance\", \n font_size=40, \n color=BLUE\n )\n subtitle = Text(\n \"The motion is influenced by gravity and drag force.\", \n font_size=24, \n color=GRAY\n )\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title), run_time=2)\n self.play(FadeIn(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle), run_time=0.5)\n\n # ------------------------------------------------------------------\n # 2. Equations Display\n # ------------------------------------------------------------------\n # Drag Force Equation (Quadratic Drag Model)\n eq_drag = MathTex(\n r\"\\vec{F}_{\\text{drag}} = -\\frac{1}{2} \\rho C_d A |\\vec{v}| \\vec{v}\", \n font_size=36\n )\n # Resulting Acceleration Equation\n eq_accel = MathTex(\n r\"\\vec{a} = \\vec{g} + \\frac{\\vec{F}_{\\text{drag}}}{m}\", \n font_size=36\n )\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.5)\n equations.to_edge(UP)\n \n self.play(Write(equations), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Animation Setup & Physics Simulation\n # ------------------------------------------------------------------\n # Physical Constants\n g = 9.81 # Gravity (m/s^2)\n v0 = 20.0 # Initial velocity (m/s)\n theta = 50 * DEGREES # Launch angle\n k_over_m = 0.15 # Simplified drag coefficient ratio (rho*Cd*A / 2m)\n dt = 0.01 # Time step for integration\n \n # Numerical Integration (Euler Method)\n # Since drag depends on the square of velocity, the acceleration is \n # non-linear, making a closed-form solution impossible.\n trajectory_points = []\n x, y = 0.0, 0.0\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n t = 0.0\n \n trajectory_points.append([x, y, 0])\n \n while y >= 0 and t < 10:\n v_mag = np.sqrt(vx**2 + vy**2)\n \n # Calculate Acceleration Components\n ax = -k_over_m * v_mag * vx\n ay = -g - k_over_m * v_mag * vy\n \n # Update Velocity and Position\n vx += ax * dt\n vy += ay * dt\n x += vx * dt\n y += vy * dt\n \n t += dt\n trajectory_points.append([x, y, 0])\n \n if y < 0:\n break\n \n # Convert physics coordinates to Manim scene coordinates\n # Scale factor to fit within default frame\n scale_factor = 0.35 \n scene_points = [\n [p[0] * scale_factor, p[1] * scale_factor, 0] \n for p in trajectory_points\n ]\n \n # Create Axes for context\n axes = Axes(\n x_range=[0, 15, 1],\n y_range=[0, 8, 1],\n axis_config={\"include_tip\": True},\n color=GRAY\n )\n axes.scale(scale_factor)\n axes.shift(LEFT * 3 + DOWN * 2)\n \n # Align trajectory points with axes origin\n origin = axes.get_origin()\n final_points = [p + origin for p in scene_points]\n \n # Create Path and Projectile\n path = VMobject()\n path.set_points_smoothly(final_points)\n path.set_stroke(color=BLUE, width=3, opacity=0.8)\n \n projectile = Dot(color=RED, radius=0.15)\n projectile.move_to(final_points[0])\n\n # ------------------------------------------------------------------\n # 4. Execution of Motion Animation\n # ------------------------------------------------------------------\n # Move equations to the side to clear view for trajectory\n self.play(equations.animate.to_edge(RIGHT).scale(0.7), run_time=1)\n \n self.play(Create(axes), run_time=1)\n \n # Animate projectile along the calculated path\n # Duration set to approximately 4 seconds as requested\n # rate_func=linear ensures the physics timing baked into the path is visually consistent\n self.play(\n MoveAlongPath(projectile, path),\n Create(path),\n run_time=4,\n rate_func=linear\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ProjectileMotionWithDrag(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n title = Text(\n \"Projectile motion with air resistance\", \n font_size=40, \n color=BLUE\n )\n subtitle = Text(\n \"The motion is influenced by gravity and drag force.\", \n font_size=24, \n color=GRAY\n )\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title), run_time=2)\n self.play(FadeIn(subtitle), run_time=1)\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle), run_time=0.5)\n\n # ------------------------------------------------------------------\n # 2. Equations Display\n # ------------------------------------------------------------------\n # Drag Force Equation (Quadratic Drag Model)\n eq_drag = MathTex(\n r\"\\vec{F}_{\\text{drag}} = -\\frac{1}{2} \\rho C_d A |\\vec{v}| \\vec{v}\", \n font_size=36\n )\n # Resulting Acceleration Equation\n eq_accel = MathTex(\n r\"\\vec{a} = \\vec{g} + \\frac{\\vec{F}_{\\text{drag}}}{m}\", \n font_size=36\n )\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.5)\n equations.to_edge(UP)\n \n self.play(Write(equations), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Animation Setup & Physics Simulation\n # ------------------------------------------------------------------\n # Physical Constants\n g = 9.81 # Gravity (m/s^2)\n v0 = 20.0 # Initial velocity (m/s)\n theta = 50 * DEGREES # Launch angle\n k_over_m = 0.15 # Simplified drag coefficient ratio (rho*Cd*A / 2m)\n dt = 0.01 # Time step for integration\n \n # Numerical Integration (Euler Method)\n # Since drag depends on the square of velocity, the acceleration is \n # non-linear, making a closed-form solution impossible.\n trajectory_points = []\n x, y = 0.0, 0.0\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n t = 0.0\n \n trajectory_points.append([x, y, 0])\n \n while y >= 0 and t < 10:\n v_mag = np.sqrt(vx**2 + vy**2)\n \n # Calculate Acceleration Components\n ax = -k_over_m * v_mag * vx\n ay = -g - k_over_m * v_mag * vy\n \n # Update Velocity and Position\n vx += ax * dt\n vy += ay * dt\n x += vx * dt\n y += vy * dt\n \n t += dt\n trajectory_points.append([x, y, 0])\n \n if y < 0:\n break\n \n # Convert physics coordinates to Manim scene coordinates\n # Scale factor to fit within default frame\n scale_factor = 0.35 \n scene_points = [\n [p[0] * scale_factor, p[1] * scale_factor, 0] \n for p in trajectory_points\n ]\n \n # Create Axes for context\n axes = Axes(font_size=24, \n x_range=[0, 15, 1],\n y_range=[0, 8, 1],\n axis_config={\"include_tip\": True},\n color=GRAY\n )\n axes.scale(scale_factor)\n axes.shift(LEFT * 3 + DOWN * 2)\n \n # Align trajectory points with axes origin\n origin = axes.get_origin()\n final_points = [p + origin for p in scene_points]\n \n # Create Path and Projectile\n path = VMobject()\n path.set_points_smoothly(final_points)\n path.set_stroke(color=BLUE, width=3, opacity=0.8)\n \n projectile = Dot(color=RED, radius=0.15)\n projectile.move_to(final_points[0])\n\n # ------------------------------------------------------------------\n # 4. Execution of Motion Animation\n # ------------------------------------------------------------------\n # Move equations to the side to clear view for trajectory\n self.play(equations.animate.to_edge(RIGHT).scale(0.7), run_time=1)\n \n self.play(Create(axes), run_time=1)\n \n # Animate projectile along the calculated path\n # Duration set to approximately 4 seconds as requested\n # rate_func=linear ensures the physics timing baked into the path is visually consistent\n self.play(\n MoveAlongPath(projectile, path),\n Create(path),\n run_time=4,\n rate_func=linear\n )\n \n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe animation begins by simultaneously fading in a **circle** and a **triangle** (positioned as in the original script). After a brief pause, the circle smoothly transforms into a **square** while the triangle morphs into a **pentagon**, demonstrating shape-shifting capabilities. As this transformation occurs, a **mathematical formula** (e.g., Euler’s formula, *V - E + F = 2*) appears below the shapes, explaining the topological relationship between vertices (*V*), edges (*E*), and faces (*F*). The shapes then rotate in opposite directions (the square clockwise, the pentagon counterclockwise) while a **dynamic counter** tracks the rotation angle in real time. Finally, the shapes merge into a single **hexagon**, which pulses with a color gradient before fading out, leaving only the formula on screen. Throughout the animation, **explanatory text** appears at key moments, guiding the viewer through the geometric transformations and their mathematical significance. \n\nThis enhanced version retains the original elements (circle and triangle) while adding shape morphing, mathematical context, rotational animation, real-time angle tracking, and explanatory text—making it both visually engaging and educational.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial objects\n circle = Circle(radius=1)\n triangle = Triangle()\n \n # Arrange them side-by-side for symmetry\n shapes_group = VGroup(circle, triangle).arrange(RIGHT)\n \n # Fade in the shapes\n self.play(FadeIn(shapes_group))\n self.wait(1)\n\n # Define target shapes\n square = Square(side_length=2)\n pentagon = RegularPolygon(n=5, radius=2)\n \n # Animate the transition from circle to square and triangle to pentagon\n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=2,\n rate_func=smooth\n )\n \n # Add mathematical formula\n math_text = MathTex(\"V - E + F = 2\")\n math_text.next_to(shapes_group, DOWN, buff=1.5)\n self.play(Write(math_text))\n\n # Rotate shapes in opposite directions\n square_anim = Rotate(square, angle=TAU, about_point=square.get_center(), run_time=8, rate_func=linear)\n pentagon_anim = Rotate(pentagon, angle=-TAU, about_point=pentagon.get_center(), run_time=8, rate_func=linear)\n\n # Track rotation angles\n angle_tracker_square = ValueTracker(0)\n angle_tracker_pentagon = ValueTracker(0)\n \n # Display real-time rotation angles\n display_angle_square = Text(f\"Angle: {angle_tracker_square.get_value():.2f} rad\", font_size=36).to_edge(DOWN)\n display_angle_pentagon = Text(f\"Angle: {angle_tracker_pentagon.get_value():.2f} rad\", font_size=36).to_edge(DOWN)\n display_angle_pentagon.shift(UP * 0.5)\n \n self.add(display_angle_square, display_angle_pentagon)\n \n def update_display_shape1(mob):\n mob.text_string = f\"Angle: {angle_tracker_square.get_value():.2f} rad\"\n \n def update_display_shape2(mob):\n mob.text_string = f\"Angle: {angle_tracker_pentagon.get_value():.2f} rad\"\n\n display_angle_square.add_updater(update_display_shape1)\n display_angle_pentagon.add_updater(update_display_shape2)\n\n self.add(angle_tracker_square, angle_tracker_pentagon)\n \n self.play(\n square_anim,\n pentagon_anim,\n rate_func=linear,\n run_time=7\n )\n\n # Merge shapes into hexagon\n hexagon = RegularPolygon(n=6, radius=2)\n hexagon.move_to(shape_center := shapes_group.get_center())\n\n self.play(\n Transform(VGroup(circle, triangle, square, pentagon), hexagon),\n run_time=2\n )\n self.remove(angle_tracker_square, angle_tracker_pentagon)\n self.wait()\n\n # Pulse hexagon with color gradient\n colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE]\n for i in range(len(colors)):\n hexagon.set_color(colors[i])\n self.play(hexagon.animate.scale(1.1), run_time=0.1)\n self.play(hexagon.animate.scale(1/1.1), run_time=0.1)\n \n self.wait(1)\n\n # Remove hexagon and show formula\n self.play(FadeOut(hexagon))\n self.wait(2)\n self.play(FadeOut(display_angle_square, display_angle_pentagon), Write(MathTex(\"\\\\text{Educational Animation}\", \"\\\\text{Demonstrating Shape Morphism}\", font_size=36)))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial shapes\n circle = Circle(radius=1)\n triangle = Triangle()\n \n # Animate initial appearance\n self.play(FadeIn(circle), FadeIn(triangle))\n self.wait(1)\n\n # Morph shapes into target forms\n square = Square(side_length=1.8, stroke_color=YELLOW)\n pentagon = RegularPolygon(n=5, side_length=1.6, stroke_color=GREEN)\n \n math_formula = MathTex(\"V - E + F = 2\").next_to(VGroup(square, pentagon), DOWN, buff=1)\n explanation_text = Text(\"Topological Relationship\", font_size=28).to_edge(DOWN)\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n Write(math_formula),\n Write(explanation_text)\n )\n self.wait(2)\n\n # Rotate shapes in opposite directions\n square_rot = Rotate(square, angle=PI, about_point=square.get_center())\n pent_rot = Rotate(pentagon, angle=-PI, about_point=pentagon.get_center(), run_time=4, rate_func=linear)\n \n self.add(MathTex(\"\\\\theta_s(t)\").move_to(RIGHT*3+UP*1.5), MathTex(\"\\\\theta_p(t)\").move_to(LEFT*3+UP*1.5)) # Add angular counters\n \n self.play(\n LaggedStart(\n square_rot,\n pent_rot,\n lag_ratio=0.5\n ),\n run_time=4,\n rate_func=smooth\n )\n\n hexagon = Polygon(\n ORIGIN,\n UP * 1.5,\n RIGHT * 1.2 + UP * 0.7,\n RIGHT * 1.2 - UP * 0.7,\n ORIGIN,\n LEFT * 1.2 - UP * 0.7,\n LEFT * 1.2 + UP * 0.7,\n ORIGIN,\n stroke_width=4\n ).set_stroke(YELLOW, opacity=0.8)\n hex_gradient = [colors.rgb_to_hex([i/255, i/255, i/255]) for i in range(255)]\n \n hexagon.apply_function(lambda p: np.array([\n p[0],\n p[1],\n sum(hex_gradient[int((p[0]/3.0)*255)]) if abs(p[0]/3.0)<1 else 0\n ]))\n\n # Merge shapes into hexagon\n self.play(Transform(VGroup(square, pentagon), hexagon), run_time=1.5)\n self.wait(1)\n\n # Pulse hexagon with color gradient\n pulse_animation = []\n for _ in range(5):\n colors_arr = [\n BLUE_E,\n GREEN_C,\n RED_D,\n YELLOW_C,\n PINK_A,\n PURPLE_D,\n WHITE\n ]\n \n pulse_animation.append(\n ApplyMethod(hexagon.set_color, np.random.choice(colors_arr)),\n run_time=0.3\n )\n \n self.play(*pulse_animation, run_time=1.5)\n\n # FinalfadeOut\n final_group = VGroup(hexagon, math_formula, explanation_text)\n self.play(FadeOut(final_group), run_time=1.5)\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational math animation that visually demonstrates the concept of limits in calculus using a graph? Specifically, I'd like to see a simple graph, like a parabola for the function y=x^2, where you show how the value of the function approaches a certain point as x approaches the value of 2. Also, include a text explanation stating \"As x approaches 2, the value of x^2 approaches 4.\" at the top of the screen and highlight the point on the graph (2,4) with a red dot and a dashed yellow line from the x-axis to this point to signify the approach.", "chosen": "```python\nfrom manim import *\n\nclass LimitVisualization(Scene):\n def construct(self):\n # 1. Setup Axes\n # Configure ranges to ensure x=2 and y=4 are clearly visible\n axes = Axes(\n x_range=[-1, 4, 1],\n y_range=[-1, 10, 2],\n x_axis_config={\"numbers_to_include\": [2]},\n y_axis_config={\"numbers_to_include\": [4]},\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the parabola y = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 3. Text Annotation\n # Positioned at the top of the screen as requested\n explanation_text = Text(\n \"As x approaches 2, the value of x^2 approaches 4.\",\n font_size=32\n ).to_edge(UP, buff=0.5)\n\n # 4. Limit Visualization Elements\n # ValueTracker to animate the x value approaching 2\n x_tracker = ValueTracker(0)\n \n # Moving dot that follows the curve based on the tracker\n moving_dot = always_redraw(lambda: Dot(\n point=axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2),\n color=WHITE\n ))\n \n # Dynamic helper line that follows the moving dot to the x-axis\n moving_line = always_redraw(lambda: DashedLine(\n start=axes.c2p(x_tracker.get_value(), 0),\n end=axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2),\n color=GRAY,\n stroke_opacity=0.5\n ))\n\n # Static red dot at the limit point (2, 4)\n limit_dot = Dot(axes.c2p(2, 4), color=RED, radius=0.1)\n \n # Dashed yellow line from x-axis (2, 0) to limit point (2, 4)\n limit_line = DashedLine(\n start=axes.c2p(2, 0),\n end=axes.c2p(2, 4),\n color=YELLOW,\n dash_length=0.1\n )\n\n # 5. Animation Sequence\n # Initialize the scene with axes, graph, and text\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(Write(explanation_text))\n self.wait(0.5)\n\n # Add the moving dot and its helper line to the scene\n self.add(moving_line, moving_dot)\n \n # Animate x approaching 2\n self.play(\n x_tracker.animate.set_value(2),\n run_time=3,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # Highlight the specific limit point and projection line\n # Fade out the dynamic helper line and replace it with the final yellow dashed line\n self.play(\n FadeOut(moving_line),\n Transform(moving_dot, limit_dot),\n Create(limit_line),\n run_time=1\n )\n \n # Hold the final state for observation\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass LimitVisualization(Scene):\n def construct(self):\n # 1. Setup Axes\n # Configure ranges to ensure x=2 and y=4 are clearly visible\n axes = Axes(font_size=24, \n x_range=[-1, 4, 1],\n y_range=[-1, 10, 2],\n x_axis_config={\"numbers_to_include\": [2]},\n y_axis_config={\"numbers_to_include\": [4]},\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the parabola y = x^2\n graph = axes.plot(lambda x: x**2, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"y = x^2\")\n\n # 3. Text Annotation\n # Positioned at the top of the screen as requested\n explanation_text = Text(\n \"As x approaches 2, the value of x^2 approaches 4.\",\n font_size=32\n ).to_edge(UP, buff=0.5)\n\n # 4. Limit Visualization Elements\n # ValueTracker to animate the x value approaching 2\n x_tracker = ValueTracker(0)\n \n # Moving dot that follows the curve based on the tracker\n moving_dot = always_redraw(lambda: Dot(\n point=axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2),\n color=WHITE\n ))\n \n # Dynamic helper line that follows the moving dot to the x-axis\n moving_line = always_redraw(lambda: DashedLine(\n start=axes.c2p(x_tracker.get_value(), 0),\n end=axes.c2p(x_tracker.get_value(), x_tracker.get_value()**2),\n color=GRAY,\n stroke_opacity=0.5\n ))\n\n # Static red dot at the limit point (2, 4)\n limit_dot = Dot(axes.c2p(2, 4), color=RED, radius=0.1)\n \n # Dashed yellow line from x-axis (2, 0) to limit point (2, 4)\n limit_line = DashedLine(\n start=axes.c2p(2, 0),\n end=axes.c2p(2, 4),\n color=YELLOW,\n dash_length=0.1\n )\n\n # 5. Animation Sequence\n # Initialize the scene with axes, graph, and text\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(Write(explanation_text))\n self.wait(0.5)\n\n # Add the moving dot and its helper line to the scene\n self.add(moving_line, moving_dot)\n \n # Animate x approaching 2\n self.play(\n x_tracker.animate.set_value(2),\n run_time=3,\n rate_func=smooth\n )\n self.wait(0.5)\n\n # Highlight the specific limit point and projection line\n # Fade out the dynamic helper line and replace it with the final yellow dashed line\n self.play(\n FadeOut(moving_line),\n Transform(moving_dot, limit_dot),\n Create(limit_line),\n run_time=1\n )\n \n # Hold the final state for observation\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'm learning about k-means clustering and want a clear visualization of convergence.\nAnimate three clusters of data points in 2D and show centroids shifting as assignments update, step by step across Lloyd iterations.\nPlot the objective function value over iterations and highlight misclassified points during early steps.\nInclude a close-up view of a tricky boundary region to explain how centroid updates resolve it.", "chosen": "```python\nimport numpy as np\nfrom manim import *\n\nclass KMeansClusteringScene(Scene):\n\n def construct(self):\n title = Text('K-Means Clustering Convergence', font_size=40)\n title.to_edge(UP, buff=0.3)\n self.play(Write(title), run_time=2.0)\n np.random.seed(7)\n true_centers = [np.array([-2.5, -1.0]), np.array([2.5, -1.0]), np.array([0.0, 2.0])]\n all_pts = []\n for c in true_centers:\n pts = np.random.normal(loc=c, scale=0.5, size=(15, 2))\n all_pts.extend(pts)\n all_pts = np.array(all_pts)\n dots = VGroup()\n for p in all_pts:\n d = Dot(radius=0.06, color=GRAY)\n d.move_to([p[0], p[1], 0])\n dots.add(d)\n self.play(FadeIn(dots), run_time=2.0)\n k = 3\n colors = [RED, GREEN, BLUE]\n init_indices = [2, 17, 32]\n centroid_markers = VGroup()\n labels = VGroup()\n for i in range(k):\n pos = [all_pts[init_indices[i]][0], all_pts[init_indices[i]][1], 0]\n marker = VGroup(Circle(radius=0.22, color=colors[i], stroke_width=2), Dot(radius=0.12, color=colors[i]))\n marker.move_to(pos)\n centroid_markers.add(marker)\n lab = Text(f'C{i + 1}', font_size=24, color=colors[i])\n lab.move_to(np.array(pos) + UP * 0.4)\n labels.add(lab)\n self.play(FadeIn(centroid_markers), FadeIn(labels), run_time=2.0)\n assignments = [0] * len(dots)\n for step in range(1, 5):\n c_pos = np.array([m.get_center()[:2] for m in centroid_markers])\n anims = []\n for j, d in enumerate(dots):\n p = d.get_center()[:2]\n dists = np.linalg.norm(c_pos - p, axis=1)\n idx = int(np.argmin(dists))\n assignments[j] = idx\n anims.append(d.animate.set_color(colors[idx]))\n self.play(AnimationGroup(*anims, lag_ratio=0.02), run_time=2.0)\n move_anims = []\n create_lines = []\n fade_lines = []\n for i in range(k):\n assigned = [dots[j].get_center()[:2] for j in range(len(dots)) if assignments[j] == i]\n if assigned:\n mean = np.mean(assigned, axis=0)\n else:\n mean = centroid_markers[i].get_center()[:2]\n old_pos = centroid_markers[i].get_center()\n new_pos = np.array([mean[0], mean[1], 0])\n line = Line(old_pos, new_pos, color=colors[i], stroke_width=3)\n create_lines.append(Create(line))\n fade_lines.append(FadeOut(line))\n move_anims.append(centroid_markers[i].animate.move_to(new_pos))\n move_anims.append(labels[i].animate.move_to(new_pos + UP * 0.4))\n self.play(AnimationGroup(*create_lines, *move_anims, lag_ratio=0.05), run_time=2.0 * 0.7)\n self.play(AnimationGroup(*fade_lines), run_time=2.0 * 0.3)\n self.play(Circumscribe(centroid_markers), run_time=2.0)\n summary = VGroup(Text('1. Centroids are initialized randomly.', font_size=22), Text('2. Points are assigned to the nearest centroid.', font_size=22), Text('3. Centroids shift to the cluster mean until convergence.', font_size=22))\n summary.arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n summary.scale(0.8)\n summary.to_edge(DOWN, buff=0.35)\n self.play(FadeIn(summary), run_time=2.0)\n self.wait(1)\n```", "rejected": "```python\nimport numpy as np\nfrom manim import *\n\nclass KMeansClusteringScene(Scene):\n\n def construct(self):\n title = Text('K-Means Clustering Convergence', font_size=40)\n title.to_edge(UP, buff=0.3)\n self.play(Write(title), run_time=2.0)\n np.random.seed(7)\n true_centers = [np.array([-2.5, -1.0]), np.array([2.5, -1.0]), np.array([0.0, 2.0])]\n all_pts = []\n for c in true_centers:\n pts = np.random.normal(loc=c, scale=0.5, size=(15, 2))\n all_pts.extend(pts)\n all_pts = np.array(all_pts)\n dots = VGroup()\n for p in all_pts:\n d = Dot(radius=0.06, color=GRAY)\n d.move_to([p[0], p[1], 0])\n dots.add(d)\n self.play(FadeIn(dots), run_time=2.0)\n k = 3\n colors = [RED, GREEN, BBLUE]\n init_indices = [2, 17, 32]\n centroid_markers = VGroup()\n labels = VGroup()\n for i in range(k):\n pos = [all_pts[init_indices[i]][0], all_pts[init_indices[i]][1], 0]\n marker = VGroup(Circle(radius=0.22, color=colors[i], stroke_width=2), Dot(radius=0.12, color=colors[i]))\n marker.move_to(pos)\n centroid_markers.add(marker)\n lab = Text(f'C{i + 1}', font_size=24, color=colors[i])\n lab.move_to(np.array(pos) + UP * 0.4)\n labels.add(lab)\n self.play(FadeIn(centroid_markers), FadeIn(labels), run_time=2.0)\n assignments = [0] * len(dots)\n for step in range(1, 5):\n c_pos = np.array([m.get_center()[:2] for m in centroid_markers])\n anims = []\n for j, d in enumerate(dots):\n p = d.get_center()[:2]\n dists = np.linalg.norm(c_pos - p, axis=1)\n idx = int(np.argmin(dists))\n assignments[j] = idx\n anims.append(d.animate.set_color(colors[idx]))\n self.play(AnimationGroup(*anims, lag_ratio=0.02), run_time=2.0)\n move_anims = []\n create_lines = []\n fade_lines = []\n for i in range(k):\n assigned = [dots[j].get_center()[:2] for j in range(len(dots)) if assignments[j] == i]\n if assigned:\n mean = np.mean(assigned, axis=0)\n else:\n mean = centroid_markers[i].get_center()[:2]\n old_pos = centroid_markers[i].get_center()\n new_pos = np.array([mean[0], mean[1], 0])\n line = Line(old_pos, new_pos, color=colors[i], stroke_width=3)\n create_lines.append(Create(line))\n fade_lines.append(FadeOut(line))\n move_anims.append(centroid_markers[i].animate.move_to(new_pos))\n move_anims.append(labels[i].animate.move_to(new_pos + UP * 0.4))\n self.play(AnimationGroup(*create_lines, *move_anims, lag_ratio=0.05), run_time=2.0 * 0.7)\n self.play(AnimationGroup(*fade_lines), run_time=2.0 * 0.3)\n self.play(Circumscribe(centroid_markers), run_time=2.0)\n summary = VGroup(Text('1. Centroids are initialized randomly.', font_size=22), Text('2. Points are assigned to the nearest centroid.', font_size=22), Text('3. Centroids shift to the cluster mean until convergence.', font_size=22))\n summary.arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n summary.scale(0.8)\n summary.to_edge(DOWN, buff=0.35)\n self.play(FadeIn(summary), run_time=2.0)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an educational animation that introduces viewers to the concept of exponential functions by graphing them using Manim. Start with a title that says \"Exponential Function Graph\" at the top. First, display a set of axes suitable for exponential growth with a range for x from -3 to 3 and y from -1 to 8. The axes should be in blue. Then plot the function e^x on these axes in green and label the curve accordingly. After showing the graph for a bit, introduce a second exponential function, 2^x. Replace the first graph with this new one, drawing the new function in red and moving the label up for better visibility. Finally, I would like the initial e^x graph to come back on screen alongside the 2^x graph for comparison. Both graphs should be labeled clearly, and after some time, the animation should end. Can you create an animation that follows these guidelines?", "chosen": "```python\nfrom manim import *\n\nclass ExponentialFunctionGraph(Scene):\n def construct(self):\n # --- Step 1: Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n self.play(Write(title))\n \n # Fade out the title so we can work cleanly with axes/graphs later\n self.play(FadeOut(title))\n\n # --- Step 2: Axes Setup ---\n # Create axes with ranges (-3, 8) and color Blue\n # Using logarithmic scaling helps visualize the rapid increase of exponential functions\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[0, 8, 1],\n x_length=7,\n y_length=5,\n tips=False,\n axis_config={\"color\": BLUE},\n ).shift(DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n self.play(Create(axes), Write(labels))\n self.wait()\n\n # --- Step 3: Plot e^x ---\n exp_func_e = MathTex(r\"f(x)\", \"=\", r\"\\text{e}^x\")\n exp_graph_e = axes.plot(lambda x: np.exp(x), color=GREEN)\n exp_label_e = MathTex(r\"\\text{e}^x\").next_to(exp_graph_e, UR, buff=0.2).set_color(GREEN)\n\n self.play(Create(exp_graph_e), Write(exp_label_e), Write(exp_func_e))\n self.wait(1)\n\n # Move the original equation to make room for the second function\n self.play(MoveAlongPath(exp_func_e.copy(), exp_graph_e), run_time=2)\n self.wait(1)\n\n # --- Step 4: Introduce 2^x ---\n exp_func_2 = MathTex(r\"g(x)\", \"=\", r\"2^x\")\n exp_graph_2 = axes.plot(lambda x: 2**x, color=RED)\n exp_label_2 = MathTex(r\"2^x\").move_to(exp_label_e.get_center()).set_color(RED).shift(UP * 0.5)\n\n # Animate the transformation of e^x to 2^x\n self.play(\n ReplacementTransform(exp_graph_e, exp_graph_2),\n ReplacementTransform(exp_label_e, exp_label_2),\n ReplacementTransform(exp_func_e, exp_func_2)\n )\n self.wait(1)\n\n # --- Step 5: Show both functions simultaneously ---\n # Reposition the equations to the left and right for comparison\n eq_left = VGroup(MathTex(\"\\\\text{Initial: } f(x) =\", r\"\\\\ \\text{Current: } g(x) =\"), MathTex(\"\\\\text{e}^x\", \"\\\\quad\", r\"2^x\")).arrange(DOWN, aligned_edge=LEFT)\n eq_right = VGroup(MathTex(\"\\\\text{Current: } g(x) = \"), MathTex(\"2^x\")).arrange(DOWN, aligned_edge=RIGHT)\n\n eq_left.to_edge(LEFT).scale(0.8)\n eq_right.next_to(eq_left, RIGHT, buff=1).scale(0.8)\n\n # Shift existing curves to make space for the labels\n self.play(\n exp_graph_2.animate.shift(LEFT * 0.5 + UP * 0.5),\n exp_label_2.animate.move_to(ORIGIN + LEFT * 0.5 + UP * 0.5).shift(LEFT * 0.5 + DOWN * 0.5),\n exp_graph_e.animate.shift(RIGHT * 0.5 + UP * 0.5),\n exp_label_e.animate.move_to(ORIGIN + RIGHT * 0.5 + UP * 0.5).shift(RIGHT * 0.5 + DOWN * 0.5),\n Write(eq_left),\n Write(eq_right)\n )\n\n self.wait(2)\n\n # End of Animation\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass ExponentialFunctions(Scene):\n def construct(self):\n # --- Title ---\n title = Text(\"Exponential Function Graph\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Create Axes with specified ranges and colors\n axes = Axes(\n x_range=(-3, 3, 1),\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE},\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Display Axes initially\n self.play(Create(axes), Write(labels))\n \n # Plot e^x in Green and Label it\n exp_e_func = MathTex(\"e^x\").scale(0.7).to_edge(DOWN)\n exp_e_graph = axes.plot(lambda x: np.exp(x), color=GREEN)\n \n self.play(Create(exp_e_graph), FadeIn(exp_e_func, shift=DOWN*0.5))\n\n # Show both titles simultaneously\n exp_e_title = MathTex(\"\\\\text{Initial } e^x \\\\text{ Function}\").next_to(exp_e_func, UP, buff=0.5)\n self.play(FadeIn(exp_e_title, shift=UP*0.3))\n \n # Hold view for a moment\n self.wait(2)\n\n # Transition: Replace e^x with 2^x in Red\n exp_2_func = MathTex(\"2^x\").scale(0.7).shift(UP) # Shifted up for improved position\n \n # Draw 2^x function in Red\n exp_2_graph = axes.plot(lambda x: 2**x, color=RED)\n \n # Animate replacement of old graph and its title with the new ones\n self.play(\n ReplacementTransform(match_target_data=True, exp_e_func, exp_2_func),\n Transform(match_target_data=True, exp_e_graph, exp_2_graph),\n run_time=2\n )\n\n # Move the new label further upward for clear separation\n self.play(exp_2_func.animate.shift(UP*0.5))\n\n # Add a corresponding title above the 2^x equation\n exp_2_title = MathTex(\"\\\\text{Replaced with } 2^x\").next_to(exp_2_func, UP, buff=0.5)\n self.play(Write(exp_2_title))\n\n # Hold view again\n self.wait(2)\n\n # Final Step: Return original e^x graph along with the 2^x graph\n # Clear existing elements to reset the stage cleanly\n self.clear()\n \n # Re-create Axes since they were cleared\n axes_final = Axes(\n x_range=(-3, 3, 1),\n y_range=[-1, 8, 1],\n axis_config={\"color\": BLUE}\n )\n labels_final = axes_final.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Recreate Labels only once at the beginning for efficiency\n self.add(axes_final, labels_final)\n \n # Recreate Titles only once at the beginning for efficiency\n rec_exp_e_title = MathTex(\"\\\\text{Recycled } e^x \\\\text{ Function}\")\n rec_exp_2_title = MathTex(\"\\\\text{Recycled } 2^x \\\\text{ Function}\")\n\n # Plot Original e^x in Green\n orig_e_graph = axes_final.plot(lambda x: np.exp(x), color=GREEN)\n orig_e_func = MathTex(\"e^x\").scale(0.7).to_edge(DOWN)\n self.play(Create(orig_e_graph), FadeIn(rec_exp_e_title, shift=UP*0.3), FadeIn(exp_e_func, shift=DOWN*0.5))\n\n # Plot New 2^x in Red\n orig_2_graph = axes_final.plot(lambda x: 2**x, color=RED)\n orig_2_func = MathTex(\"2^x\").scale(0.7).shift(UP) # Shifted up for improved positioning\n self.play(Create(orig_2_graph), FadeIn(rec_exp_2_title, shift=UP*0.3), FadeIn(exp_2_func, shift=UP*0.3))\n\n # Hold final state briefly\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Generate a Manim animation to explain the concept of divergence and curl in vector calculus. Visualize vector fields and their behavior, and include a title saying \"Divergence and Curl.\"", "chosen": "```python\nfrom manim import *\n\nclass DivergenceAndCurl(Scene):\n def construct(self):\n title = Title(\"Divergence and Curl\")\n self.play(Write(title))\n \n\n div = MathTex(r\"\\text{div } \\vec{F} = \", r\"\\nabla \\cdot \\vec{F}\")\n self.play(Write(div))\n\n curl = MathTex(r\"\\text{curl } \\vec{F} = \", r\"\\nabla \\times \\vec{F}\") \n curl.shift(DOWN) \n self.play(Write(curl)) \n\n self.wait()\n\n self.play(\n FadeOut(div),\n FadeOut(curl),\n FadeOut(title))\n\n plane = NumberPlane() \n self.play(Create(plane))\n \n field = VectorField(lambda pos: np.array([1, (pos[0]-pos[1])/2, 0]))\n self.play(ShowPassingFlash(field.copy(), time_width=0.5))\n \n # vectors grid\n vectors = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n x = i + 0.01*j\n y = j\n vectors.add(Vector(RIGHT+UP*y).shift(RIGHT*x+UP*y).scale(0.7))\n \n self.play(FadeIn(vectors, lag_ratio = 0.01))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass DivergenceAndCurl(Scene):\n def construct(self):\n title = Title(\"Divergence and Curl\")\n self.play(Write(title))\n \n\n div = MathTex(r\"\\text{div } \\vec{F} = \", r\"\\nabla \\cdot \\vec{F}\")\n self.play(Write(div))\n\n curl = MathTex(r\"\\text{curl } \\vec{F} = \", r\"\\nabla \\times \\vec{F}\") \n curl.shift(DOWN) \n self.play(Write(curl)) \n\n self.wait()\n\n self.play(\n FadeOut(div),\n FadeOut(curl),\n FadeOut(title))\n\n plane = NumberPlane() \n self.play(Create(plane))\n \n field = VectorField(lambda pos: np.array([1, (pos[0]-pos[1])/2, 0]))\n self.play(ShowPassingFlash(field.copy(), time_width=0.5))\n \n # vectors grid\n vectors = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n x = i + 0.01*j\n y = j\n vectors.add(Vector(RIGHT+UP*y).shift(RIGHT*x+UP*y).scale(0.7))\n \n self.play(FadeIn(vectors, lag_ratio = 0.01))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 produced by that local linearization.", "chosen": "```python\nfrom manim import *\n\nclass LinearJacobian(Scene):\n def construct(self):\n # --- Configuration ---\n POINT_COLOR = YELLOW\n VECTOR_LENGTH = 1.5\n \n # Create coordinate system\n axes = Axes(\n x_range=[-6, 7], \n y_range=[-3, 8],\n x_length=6,\n y_length=6\n ).shift(LEFT * 2)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Initial Point A\n A_start = np.array([2, 1, 0])\n dot_A = Dot(point=A_start, color=POINT_COLOR, radius=0.1)\n label_A = MathTex(\"A\").next_to(dot_A, UR)\n\n # Input Arrow OA -> OB\n ob_end = np.array([3.3, 1.5, 0]) # Small displacement from A\n vector_OA = Arrow(start=ORIGIN, end=dot_A.get_center(), color=WHITE)\n vector_AB = Arrow(start=dot_A.get_center(), end=ob_end + dot_A.get_center(), color=GREEN)\n\n # Formula for derivative\n deriv_eq = MathTex(\"\\\\frac{d}{dx} f(A) \\\\approx J_{f,A}(\\\\Delta x)\")\n deriv_eq.to_edge(UP)\n \n # Local linear approximation formula\n lin_approx = MathTex(\"f(B) \\\\approx f(A) + J_{f,A}(B-A)\", \"\\\\text{(linear approximation)}\")\n lin_approx.arrange(DOWN).to_edge(UR)\n \n # Display Matrix of partial derivatives\n jacobian_matrix = MathTex(\n r\"J_{f,A}\", \"=\", r\"\\begin{bmatrix}\"\n r\"\\frac{\\partial f}{\\partial x}_A\", \"&\", r\"\\frac{\\partial f}{\\partial y}_A\"\n r\"\\end{bmatrix}\"\n )\n jacobian_box = SurroundingRectangle(jacobian_matrix, buff=0.2, color=YELLOW)\n jacobian_group = VGroup(jacobian_matrix, jacobian_box).scale(0.8)\n jacobian_group.next_to(lin_approx, DOWN, buff=0.5).align_to(lin_approx, LEFT)\n\n # Transform vectors to final state\n ob_final = np.array([4.2, 1.9, 0]) # Final position based on J(f,A)(B-A)\n vector_OA_final = Arrow(start=ORIGIN, end=ob_final, color=WHITE)\n vector_B = Arrow(start=dot_A.get_center(), end=ob_final, color=RED)\n\n self.play(Create(axes), Write(axis_labels))\n self.wait(0.5)\n\n # Step 1: Draw initial point and vectors\n self.play(FadeIn(dot_A), FadeIn(label_A))\n self.wait(0.5)\n\n self.play(GrowArrow(vector_OA), GrowArrow(vector_AB))\n self.wait(0.5)\n\n # Step 2: Animate derivative formula appearing\n self.play(Write(deriv_eq))\n self.wait(1)\n\n # Step 3: Reveal matrix representation\n self.play(Write(lin_approx[0]))\n self.play(Create(jacobian_box), Write(jacobian_matrix[0]), Write(jacobian_matrix[1]))\n self.wait(1.5)\n\n # Step 4: Update vectors using the derived transformation\n self.play(TransformFromCopy(vector_AB, vector_OA_final), TransformFromCopy(vector_AB, vector_B))\n self.wait(1.5)\n\n # Conclusion text\n conclusion_text = Text(\"This is how we approximate functions locally!\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion_text))\n\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass LinearApproximationScene(Scene):\n def construct(self):\n # Display title at the top of the screen\n title = Text(\"A function's derivative is its best linear approximation\", font_size=36)\n title.to_edge(UP)\n \n self.play(Write(title))\n self.wait(2)\n\n # Create a coordinate system\n axes = Axes(\n x_range=[-5, 5],\n y_range=[-5, 5],\n axis_width=8,\n tips=False\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.add(axes, axes_labels)\n \n # Plot f(x) = sin(x)\n graph = axes.plot(lambda x: np.sin(x), color=BLUE)\n graph_label = MathTex(\"f(x)\", font_size=28).next_to(graph, UR, buff=-0.1)\n \n self.add(graph, graph_label)\n self.wait(2)\n\n # Add a point P at x = pi/4 on the curve\n point_p = Point(pi/4, np.sin(pi/4)) + axes.c2p(-1,-1)\n p_label = MathTex(\"(\\\\frac{\\pi}{4}, \\\\sin(\\\\frac{\\pi}{4}))\").scale(0.7).next_to(point_p, DOWN)\n \n self.play(Create(point_p), Write(p_label))\n self.wait(2)\n\n # Draw the tangent line at point P\n tangent_slope = np.cos(np.pi/4)\n tan_line = Line(start=point_p + LEFT*2, end=point_p + RIGHT*(np.tan(tangent_slope)*2))\n tan_eq = MathTex(\"f'(x) = \\\\frac{d}{dx} \\\\sin(x)\", r\"= \\cos(x)\").to_corner(UR)\n \n self.play(DrawBorderThenFill(tan_line), Write(tan_eq))\n self.wait(2)\n\n # Animate moving along the curve from A to B\n point_a = Point(-pi/2, np.sin(-pi/2)) + axes.c2p(-1,-1)\n point_b = Point(3*pi/4, np.sin(3*pi/4)) + axes.c2p(-1,-1)\n arrow_start = point_a + UP*0.5\n arrow_end = point_b + UP*0.5\n \n arrow = Arrow(arrow_start, arrow_end, buff=0.1, color=YELLOW)\n arc = Arc(radius=abs((3*pi/4)-(-pi/2)), start_angle=(-pi/2)/2, angle=(3*pi/4)/2, color=GREEN)\n \n self.play(GrowFromPoint(arrow, point_a), GrowFromCenter(arc))\n self.wait(2)\n\n # Transform the equation using partial derivatives\n eq_initial = MathTex(\"\\\\Delta y \\\\approx f'(a)(x-a)\")\n eq_partial = MathTex(\"\\\\Delta y \\\\approx f'(a)\\\\partial x\")\n eq_jacobian = MathTex(\"\\\\Delta y \\\\approx J(a)\\\\partial x\")\n\n eq_initial.move_to(ORIGIN).shift(UP * 1.5)\n eq_partial.next_to(eq_initial, DOWN, buff=0.5).set_color(YELLOW)\n eq_jacobian.next_to(eq_partial, DOWN, buff=0.5).set_color(PINK)\n\n self.play(Write(eq_initial))\n self.play(ReplacementTransform(eq_initial.copy(), eq_partial))\n self.play(ReplacementTransform(eq_partial.copy(), eq_jacobian))\n\n # Move equations down to make room for the matrix\n eq_group = VGroup(eq_initial, eq_partial, eq_jacobian)\n eq_group.shift(DOWN * 2.5)\n\n # Highlight the jacobian expression\n box = SurroundingRectangle(eq_jacobian, color=RED, buff=0.2)\n self.play(Create(box))\n\n # Define the matrix representation of the linear transformation\n matrix_data = [\n [\"1\", \"0\"],\n [\"0\", \"-1\"]\n ]\n jacobian_matrix = Matrix(matrix_data).scale(0.8).move_to(ORIGIN)\n\n # Animate the appearance of the matrix\n self.play(FadeIn(jacobian_matrix))\n\n # Create arrows representing the inputs and outputs\n input_arrow = Arrow(LEFT * 3, ORIGIN, color=BLUE)\n output_arrow = Arrow(ORIGIN, RIGHT * 3, color=RED)\n\n input_text = MathTex(\"\\text{Input } (\\partial x )\").next_to(input_arrow, DOWN, buff=0.2)\n output_text = MathTex(\"\\rightarrow \\\\text{Output } (\\Delta y )\").next_to(output_arrow, DOWN, buff=0.2)\n\n self.play(GrowArrow(input_arrow), GrowArrow(output_arrow), Write(input_text), Write(output_text))\n\n # Group everything together so we can animate it smoothly\n full_scene = VGroup(\n axes, \n axes_labels, \n graph, \n graph_label, \n point_p, \n p_label, \n tan_line, \n tan_eq, \n arc, \n eq_group, \n box, \n jacobian_matrix, \n input_arrow, \n output_arrow, \n input_text, \n output_text\n )\n\n # Fade out the entire scene to conclude\n self.fade_out(full_scene)\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Please create an educational animation that explains Euler's Formula and visually demonstrates how it connects complex exponentials with trigonometric functions on a complex plane. The animation should start with writing out Euler's Formula, followed by a brief written explanation of its significance in complex analysis. Then, show a complex plane and a circle representing the unit circle in the complex plane. Additionally, include a moving red dot on the circumference of the circle and an arrow from the origin to the red dot, showing how as the dot moves, it represents the complex exponential traveling around the unit circle. The animation should be clear and paced well for an educational presentation.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulersFormulaExplanation(Scene):\n def construct(self):\n # --- Part 1: Euler's Formula Display ---\n formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\", font_size=60)\n formula.to_edge(UP)\n \n self.play(Write(formula), run_time=2)\n self.wait(1)\n\n # --- Part 2: Significance Explanation ---\n explanation = Text(\n \"Bridges complex exponentials\\nwith trigonometric functions.\",\n font_size=24,\n color=LIGHT_GREY\n )\n explanation.next_to(formula, DOWN, buff=0.5)\n \n self.play(FadeIn(explanation, shift=UP * 0.3))\n self.wait(2)\n \n # Transition to visualization\n self.play(FadeOut(formula), FadeOut(explanation))\n self.wait(0.5)\n\n # --- Part 3: Complex Plane Setup ---\n plane = ComplexPlane(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n plane.add_coordinates()\n \n # Axis labels\n real_label = Text(\"Real\", font_size=20).next_to(plane.x_axis.get_end(), RIGHT)\n imag_label = Text(\"Imaginary\", font_size=20).next_to(plane.y_axis.get_end(), UP)\n \n # Draw the unit circle\n unit_circle = Circle(radius=1, color=WHITE, stroke_width=2)\n \n self.play(\n Create(plane), \n Create(unit_circle), \n FadeIn(real_label), \n FadeIn(imag_label), \n run_time=2\n )\n self.wait(1)\n\n # --- Part 4: Dynamic Visualization ---\n theta = ValueTracker(0)\n \n # Helper function to get point on complex plane from theta\n def get_point_on_circle():\n z = np.exp(1j * theta.get_value())\n return plane.n2p(z)\n \n # Red dot representing the complex number e^(ix)\n dot = Dot(color=RED, radius=0.08)\n dot.add_updater(lambda d: d.move_to(get_point_on_circle()))\n \n # Dynamic arrow from origin to the dot\n arrow = always_redraw(lambda: Arrow(\n start=ORIGIN, \n end=get_point_on_circle(), \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n ))\n \n # Vector label\n vector_label = MathTex(r\"e^{i\\theta}\", font_size=24, color=YELLOW)\n vector_label.add_updater(lambda l: l.next_to(arrow, UR, buff=0.1))\n \n # Projection lines for cosine and sine\n cos_line = DashedLine(ORIGIN, ORIGIN, color=BLUE)\n cos_line.add_updater(\n lambda m: m.put_start_and_end_on(\n ORIGIN, \n plane.coords_to_point(np.cos(theta.get_value()), 0)\n )\n )\n\n sin_line = DashedLine(ORIGIN, ORIGIN, color=GREEN)\n sin_line.add_updater(\n lambda m: m.put_start_and_end_on(\n plane.coords_to_point(0, 0), \n plane.coords_to_point(0, np.sin(theta.get_value()))\n )\n )\n\n # Labels for the components\n cos_label = MathTex(r\"\\cos(x)\", color=BLUE, font_size=30)\n cos_label.add_updater(lambda m: m.next_to(cos_line, DOWN, buff=0.1))\n\n sin_label = MathTex(r\"i\\sin(x)\", color=GREEN, font_size=30)\n sin_label.add_updater(lambda m: m.next_to(sin_line, LEFT, buff=0.1))\n\n # Add dynamic elements to scene\n self.add(arrow, dot, vector_label, cos_line, sin_line, cos_label, sin_label)\n self.wait(0.5)\n \n # Animate the rotation from 0 to 2*PI\n self.play(\n theta.animate.set_value(TAU), \n run_time=6, \n rate_func=linear\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulersFormulaExplanation(Scene):\n def construct(self):\n # --- Part 1: Euler's Formula Display ---\n formula = MathTex(r\"e^{ix} = \\cos(x) + i\\sin(x)\", font_size=60)\n formula.to_edge(UP)\n \n self.play(Write(formula), run_time=2)\n self.wait(1)\n\n # --- Part 2: Significance Explanation ---\n explanation = Text(\n \"Bridges complex exponentials\\nwith trigonometric functions.\",\n font_size=24,\n color=LIGHT_GREY\n )\n explanation.next_to(formula, DOWN, buff=0.5)\n \n self.play(FadeIn(explanation, shift=UP * 0.3))\n self.wait(2)\n \n # Transition to visualization\n self.play(FadeOut(formula), FadeOut(explanation))\n self.wait(0.5)\n\n # --- Part 3: Complex Plane Setup ---\n plane = ComplexPlane(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n plane.add_coordinates()\n \n # Axis labels\n real_label = Text(\"Real\", font_size=20).next_to(plane.x_axis.get_end(), RIGHT)\n imag_label = Text(\"Imaginary\", font_size=20).next_to(plane.y_axis.get_end(), UP)\n \n # Draw the unit circle\n unit_circle = Circle(radius=1, color=WHITE, stroke_width=2)\n \n self.play(\n Create(plane), \n Create(unit_circle), \n FadeIn(real_label), \n FadeIn(imag_label), \n run_time=2\n )\n self.wait(1)\n\n # --- Part 4: Dynamic Visualization ---\n theta = ValueTracker(0)\n \n # Helper function to get point on complex plane from theta\n def get_point_on_circle():\n z = np.exp(1j * theta.get_value())\n return plane.n2p(z)\n \n # Red dot representing the complex number e^(ix)\n dot = Dot(color=RED, radius=0.08)\n dot.add_updater(lambda d: d.move_to(get_point_on_circle()))\n \n # Dynamic arrow from origin to the dot\n arrow = always_redraw(lambda: Arrow(\n start=ORIGIN, \n end=get_point_on_circle(), \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n ))\n \n # Vector label\n vector_label = MathTex(r\"e^{i\\theta}\", font_size=24, color=YELLOW)\n vector_label.add_updater(lambda l: l.next_to(arrow, UR, buff=0.1))\n \n # Projection lines for cosine and sine\n cos_line = DashedLine(ORIGIN, ORIGIN, color=BBLUE)\n cos_line.add_updater(\n lambda m: m.put_start_and_end_on(\n ORIGIN, \n plane.coords_to_point(np.cos(theta.get_value()), 0)\n )\n )\n\n sin_line = DashedLine(ORIGIN, ORIGIN, color=GREEN)\n sin_line.add_updater(\n lambda m: m.put_start_and_end_on(\n plane.coords_to_point(0, 0), \n plane.coords_to_point(0, np.sin(theta.get_value()))\n )\n )\n\n # Labels for the components\n cos_label = MathTex(r\"\\cos(x)\", color=BLUE, font_size=30)\n cos_label.add_updater(lambda m: m.next_to(cos_line, DOWN, buff=0.1))\n\n sin_label = MathTex(r\"i\\sin(x)\", color=GREEN, font_size=30)\n sin_label.add_updater(lambda m: m.next_to(sin_line, LEFT, buff=0.1))\n\n # Add dynamic elements to scene\n self.add(arrow, dot, vector_label, cos_line, sin_line, cos_label, sin_label)\n self.wait(0.5)\n \n # Animate the rotation from 0 to 2*PI\n self.play(\n theta.animate.set_value(TAU), \n run_time=6, \n rate_func=linear\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc\n- Act 2: I would like to have an educational animation that visually explains the process of integrating the exponential function e raised to the power of 2x with respect to x. The animation should start by displaying the integra", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0402(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_integralareaanimation()\n self.clear_stage()\n self.act_2_exponentialintegration()\n\n def act_1_integralareaanimation(self):\n func_title = MathTex(\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Graph Plotting: Plot f(x) = x^2 for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"color\": WHITE},\n y_axis_config={\"color\": WHITE}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=\"x^2\")\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Indication: Highlight area between x=0 and x=1\n area = axes.get_area(graph, x_range=[0, 1])\n \n # 4. Visual Enhancement: Gradient fill from blue to green with transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_fill(opacity=0.5)\n \n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n self.play(FadeIn(area), Write(integral_label))\n self.wait(1)\n\n # 5. Solution Transformation: Transform label to 1/3 and move to bottom\n solution = MathTex(r\"\\frac{1}{3}\")\n solution.move_to(integral_label.get_center())\n \n self.play(ReplacementTransform(integral_label, solution))\n self.play(solution.animate.to_edge(DOWN))\n self.wait(1)\n\n # 6. Final Scene: Clear everything except the solution\n self.play(\n FadeOut(func_title),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(area)\n )\n \n # Display only the final solution briefly before ending\n self.wait(2)\n\n def act_2_exponentialintegration(self):\n problem = MathTex(r\"\\int e^{2x} \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(2)\n\n # 2. Hint Text\n hint = Text(\n \"Use the exponential integration rule:\", \n font_size=28, \n color=BLUE\n )\n hint.next_to(problem, DOWN, buff=0.8)\n \n rule_formula = MathTex(r\"\\int e^{kx} \\, dx = \\frac{1}{k}e^{kx} + C\", font_size=28)\n rule_formula.next_to(hint, DOWN, buff=0.2)\n \n self.play(FadeIn(hint, shift=UP), FadeIn(rule_formula, shift=UP))\n self.wait(3)\n\n # 3. Step-by-Step Solution\n # Intermediate step: Apply the rule (1/k coefficient)\n intermediate = MathTex(r\"\\frac{1}{2} e^{2x}\")\n intermediate.scale(1.5)\n \n # Morph the problem into the intermediate step\n self.play(FadeOut(hint), FadeOut(rule_formula))\n self.play(ReplacementTransform(problem, intermediate))\n self.wait(1)\n\n # Final solution: Add the constant of integration\n final_solution = MathTex(r\"\\frac{1}{2} e^{2x} + C\")\n final_solution.scale(1.5)\n \n # Morph the intermediate step smoothly into the final solution\n self.play(TransformMatchingTex(intermediate, final_solution))\n self.wait(2)\n\n # 4. Final Emphasis\n # Highlight the result by boxing it and changing color\n box = SurroundingRectangle(final_solution, color=YELLOW, buff=MED_LARGE_BUFF)\n \n self.play(Create(box))\n self.play(final_solution.animate.set_color(YELLOW))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0402(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_integralareaanimation()\n self.clear_stage()\n self.act_2_exponentialintegration()\n\n def act_1_integralareaanimation(self):\n func_title = MathTex(\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Graph Plotting: Plot f(x) = x^2 for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"color\": WHITE},\n y_axis_config={\"color\": WHITE}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=\"x^2\")\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Indication: Highlight area between x=0 and x=1\n area = axes.get_area(graph, x_range=[0, 1])\n \n # 4. Visual Enhancement: Gradient fill from blue to green with transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_fill(opacity=0.5)\n \n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n self.play(FadeIn(area), Write(integral_label))\n self.wait(1)\n\n # 5. Solution Transformation: Transform label to 1/3 and move to bottom\n solution = MathTex(r\"\\frac{1}{3}\")\n solution.move_to(integral_label.get_center())\n \n self.play(ReplacementTransform(target_position=ORIGIN, integral_label, solution))\n self.play(solution.animate.to_edge(DOWN))\n self.wait(1)\n\n # 6. Final Scene: Clear everything except the solution\n self.play(\n FadeOut(func_title),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(area)\n )\n \n # Display only the final solution briefly before ending\n self.wait(2)\n\n def act_2_exponentialintegration(self):\n problem = MathTex(r\"\\int e^{2x} \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(2)\n\n # 2. Hint Text\n hint = Text(\n \"Use the exponential integration rule:\", \n font_size=28, \n color=BLUE\n )\n hint.next_to(problem, DOWN, buff=0.8)\n \n rule_formula = MathTex(r\"\\int e^{kx} \\, dx = \\frac{1}{k}e^{kx} + C\", font_size=28)\n rule_formula.next_to(hint, DOWN, buff=0.2)\n \n self.play(FadeIn(hint, shift=UP), FadeIn(rule_formula, shift=UP))\n self.wait(3)\n\n # 3. Step-by-Step Solution\n # Intermediate step: Apply the rule (1/k coefficient)\n intermediate = MathTex(r\"\\frac{1}{2} e^{2x}\")\n intermediate.scale(1.5)\n \n # Morph the problem into the intermediate step\n self.play(FadeOut(hint), FadeOut(rule_formula))\n self.play(ReplacementTransform(problem, intermediate))\n self.wait(1)\n\n # Final solution: Add the constant of integration\n final_solution = MathTex(r\"\\frac{1}{2} e^{2x} + C\")\n final_solution.scale(1.5)\n \n # Morph the intermediate step smoothly into the final solution\n self.play(TransformMatchingTex(intermediate, final_solution))\n self.wait(2)\n\n # 4. Final Emphasis\n # Highlight the result by boxing it and changing color\n box = SurroundingRectangle(final_solution, color=YELLOW, buff=MED_LARGE_BUFF)\n \n self.play(Create(box))\n self.play(final_solution.animate.set_color(YELLOW))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Preview: Lecture 15 on Q-learning / Policy Gradient\n* Hint: Subsequent lectures will cover how to use Monte Carlo or temporal difference methods to replace the expectation calculations in DP.\n\n## Summary & Homework (5 minutes)\n\n### **Review of This Section**: MDP, Value Functions, PI/VI\n* Summarize the logical chain from problem definition (MDP) to core tools (Bellman equations) and then to solution algorithms (DP).\n\n\nThe context of this section (from highest to current level):\n# Introduction to Artificial Intelligence Course - Detailed Outline of the Eighth Lesson (Decision Making and Planning: MDP and Dynamic Programming, 90 minutes)\n## Transition from Planning to Learning (10 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SummaryAndPreview(Scene):\n\n def construct(self):\n title = Text('Summary and Preview', 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 node1_text = Text('Problem Definition\\n(MDP)', font_size=26, line_spacing=0.8)\n node2_text = Text('Core Tools\\n(Bellman Eqs)', font_size=26, line_spacing=0.8)\n node3_text = Text('Solution Algorithms\\n(DP: PI / VI)', font_size=26, line_spacing=0.8)\n nodes = VGroup(node1_text, node2_text, node3_text).arrange(RIGHT, buff=1.8)\n nodes.next_to(title_group, DOWN, buff=1.2)\n box1 = SurroundingRectangle(node1_text, color=BLUE, buff=0.25)\n box2 = SurroundingRectangle(node2_text, color=GREEN, buff=0.25)\n box3 = SurroundingRectangle(node3_text, color=RED, buff=0.25)\n arrow1 = Arrow(box1.get_right(), box2.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n arrow2 = Arrow(box2.get_right(), box3.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n self.play(Write(node1_text), Create(box1), run_time=1)\n self.play(Create(arrow1), run_time=0.5)\n self.play(Write(node2_text), Create(box2), run_time=1)\n self.play(Create(arrow2), run_time=0.5)\n self.play(Write(node3_text), Create(box3), run_time=1)\n preview_title = Text('Preview: Transition to Learning', font_size=30, color=YELLOW)\n preview_list = BulletedList('Next topics: Q-learning and Policy Gradient', 'Use Monte Carlo or Temporal Difference methods', 'Replace the expectation calculations in DP', font_size=28)\n preview_group = VGroup(preview_title, preview_list).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n preview_group.next_to(nodes, DOWN, buff=1.2)\n preview_group.set_x(0)\n self.play(FadeIn(preview_title, shift=DOWN * 0.2), run_time=1)\n self.play(Write(preview_list), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SummaryAndPreview(Scene):\n\n def construct(self):\n title = Text('Summary and Preview', 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 node1_text = Text('Problem Definition\\n(MDP)', font_size=26, line_spacing=0.8)\n node2_text = Text('Core Tools\\n(Bellman Eqs)', font_size=26, line_spacing=0.8)\n node3_text = Text('Solution Algorithms\\n(DP: PI / VI)', font_size=26, line_spacing=0.8)\n nodes = VGroup(node1_text, node2_text, node3_text).arrange(RIGHT, buff=1.8)\n nodes.next_to(title_group, DOWN, buff=1.2)\n box1 = SurroundingRectangle(node1_text, color=BBLUE, buff=0.25)\n box2 = SurroundingRectangle(node2_text, color=GREEN, buff=0.25)\n box3 = SurroundingRectangle(node3_text, color=RED, buff=0.25)\n arrow1 = Arrow(box1.get_right(), box2.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n arrow2 = Arrow(box2.get_right(), box3.get_left(), buff=0.15, max_tip_length_to_length_ratio=0.15)\n self.play(Write(node1_text), Create(box1), run_time=1)\n self.play(Create(arrow1), run_time=0.5)\n self.play(Write(node2_text), Create(box2), run_time=1)\n self.play(Create(arrow2), run_time=0.5)\n self.play(Write(node3_text), Create(box3), run_time=1)\n preview_title = Text('Preview: Transition to Learning', font_size=30, color=YELLOW)\n preview_list = BulletedList('Next topics: Q-learning and Policy Gradient', 'Use Monte Carlo or Temporal Difference methods', 'Replace the expectation calculations in DP', font_size=28)\n preview_group = VGroup(preview_title, preview_list).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n preview_group.next_to(nodes, DOWN, buff=1.2)\n preview_group.set_x(0)\n self.play(FadeIn(preview_title, shift=DOWN * 0.2), run_time=1)\n self.play(Write(preview_list), run_time=2)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an animation that visualizes an Eulerian Path on a graph. The graph should have six vertices arranged in a circular pattern and ten directed edges connecting the vertices. The animation should show the vertices and edges appearing consecutively with some delay between them to make it clear. Once the graph is displayed, I want to highlight an Eulerian Path by changing the color of the vertices and the path edges to blue as it travels through the graph, including returning paths. After showing the Eulerian Path, the animation should display the text \"Eulerian Path\" at the top of the screen and then create a smaller copy of the graph with the path below the label. Finally, the entire scene should fade out. Can you create this animation for me, ensuring that the visualization is clear and the path distinctly marked?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulerianPathVisualization(Scene):\n def construct(self):\n # ==========================================\n # 1. Graph Configuration & Data Setup\n # ==========================================\n # Define 6 vertices arranged in a circular pattern\n num_vertices = 6\n radius = 2.5\n vertices = []\n vertex_labels = VGroup()\n \n for i in range(num_vertices):\n angle = i * 2 * PI / num_vertices + PI / 2 # Start from top\n pos = np.array([radius * np.cos(angle), radius * np.sin(angle), 0])\n dot = Dot(pos, radius=0.2, color=WHITE)\n label = Text(str(i), font_size=20).move_to(dot)\n vertices.append(dot)\n vertex_labels.add(label)\n \n # Define 10 directed edges supporting an Eulerian Path\n # Graph Theory Check:\n # Vertex 0: Out=3, In=2 (Start Node)\n # Vertex 3: Out=1, In=2 (End Node)\n # Others: Balanced (In=Out)\n # This configuration guarantees an Eulerian Path from 0 to 3.\n edge_indices = [\n (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0), # Outer cycle (6 edges)\n (0, 2), (2, 4), (4, 0), # Inner triangle (3 edges)\n (0, 3) # Connecting chord (1 edge)\n ]\n \n # Create Arrow objects for edges\n edges = VGroup()\n edge_map = {} # Map (start, end) tuple to Arrow object for easy retrieval\n \n for u, v in edge_indices:\n start_pos = vertices[u].get_center()\n end_pos = vertices[v].get_center()\n \n # Use CurvedArrow for non-adjacent vertices to avoid overlap\n diff = (v - u) % num_vertices\n if diff == 1 or diff == 5:\n arrow = Arrow(start_pos, end_pos, buff=0.3, color=WHITE, stroke_width=4, max_tip_length_to_length_ratio=0.1)\n else:\n arrow = CurvedArrow(start_pos, end_pos, angle=-PI/4, color=WHITE, stroke_width=4)\n \n edges.add(arrow)\n edge_map[(u, v)] = arrow\n \n # Group all graph elements\n graph_group = VGroup(*vertices, vertex_labels, *edges)\n \n # ==========================================\n # 2. Graph Construction Animation\n # ==========================================\n # Animate vertices and labels appearing consecutively\n self.play(LaggedStart(*[Create(v) for v in vertices], lag_ratio=0.1), run_time=1.5)\n self.play(FadeIn(vertex_labels), run_time=0.5)\n # Animate edges appearing consecutively with a slight delay\n self.play(LaggedStart(*[Create(e) for e in edges], lag_ratio=0.2), run_time=2.0)\n \n self.wait(0.5)\n\n # ==========================================\n # 3. Path Highlighting Animation\n # ==========================================\n # Define the Eulerian Path sequence of vertices\n # Path: 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 0 -> 2 -> 4 -> 0 -> 3\n path_sequence = [0, 1, 2, 3, 4, 5, 0, 2, 4, 0, 3]\n \n # Create a tracer dot to visualize the traversal movement\n tracer = Dot(vertices[path_sequence[0]].get_center(), radius=0.15, color=YELLOW)\n self.play(Create(tracer))\n \n # Highlight start vertex\n self.play(vertices[path_sequence[0]].animate.set_color(BLUE), run_time=0.5)\n \n # Traverse the path, highlighting edges and vertices\n for i in range(len(path_sequence) - 1):\n u = path_sequence[i]\n v = path_sequence[i+1]\n \n edge = edge_map[(u, v)]\n target_vertex = vertices[v]\n \n # Animate tracer moving along the edge, changing colors to blue\n self.play(\n MoveAlongPath(tracer, edge),\n edge.animate.set_color(BLUE),\n target_vertex.animate.set_color(BLUE),\n run_time=0.8\n )\n \n self.wait(0.5)\n self.play(FadeOut(tracer))\n\n # ==========================================\n # 4. Labeling\n # ==========================================\n # Display the text \"Eulerian Path\" at the top\n title = Text(\"Eulerian Path\", font_size=48).to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=1.5)\n \n self.wait(0.5)\n\n # ==========================================\n # 5. Transformation\n # ==========================================\n # Create a smaller copy of the graph (including the highlighted path)\n # and position it below the text label.\n target_graph = graph_group.copy()\n target_graph.scale(0.5)\n target_graph.next_to(title, DOWN, buff=0.5)\n \n # Transform the original graph into the smaller version\n self.play(Transform(graph_group, target_graph), run_time=2.0)\n \n self.wait(1.0)\n\n # ==========================================\n # 6. Conclusion\n # ==========================================\n # Fade out the entire scene\n self.play(\n FadeOut(graph_group),\n FadeOut(title),\n run_time=1.5\n )\n \n self.wait(0.5)\n\n# To run this animation: manim -pql filename.py EulerianPathVisualization\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulerianPathVisualization(Scene):\n def construct(self):\n # ==========================================\n # 1. Graph Configuration & Data Setup\n # ==========================================\n # Define 6 vertices arranged in a circular pattern\n num_vertices = 6\n radius = 2.5\n vertices = []\n vertex_labels = VGroup()\n \n for i in range(num_vertices):\n angle = i * 2 * PI / num_vertices + PI / 2 # Start from top\n pos = np.array([radius * np.cos(angle), radius * np.sin(angle), 0])\n dot = Dot(pos, radius=0.2, color=WHITE)\n label = Text(str(i), font_size=20).move_to(dot)\n vertices.append(dot)\n vertex_labels.add(label)\n \n # Define 10 directed edges supporting an Eulerian Path\n # Graph Theory Check:\n # Vertex 0: Out=3, In=2 (Start Node)\n # Vertex 3: Out=1, In=2 (End Node)\n # Others: Balanced (In=Out)\n # This configuration guarantees an Eulerian Path from 0 to 3.\n edge_indices = [\n (0, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 0), # Outer cycle (6 edges)\n (0, 2), (2, 4), (4, 0), # Inner triangle (3 edges)\n (0, 3) # Connecting chord (1 edge)\n ]\n \n # Create Arrow objects for edges\n edges = VGroup()\n edge_map = {} # Map (start, end) tuple to Arrow object for easy retrieval\n \n for u, v in edge_indices:\n start_pos = vertices[u].get_center()\n end_pos = vertices[v].get_center()\n \n # Use CurvedArrow for non-adjacent vertices to avoid overlap\n diff = (v - u) % num_vertices\n if diff == 1 or diff == 5:\n arrow = Arrow(start_pos, end_pos, buff=0.3, color=WHITE, stroke_width=4, max_tip_length_to_length_ratio=0.1)\n else:\n arrow = CurvedArrow(start_pos, end_pos, angle=-PI/4, color=WHITE, stroke_width=4)\n \n edges.add(arrow)\n edge_map[(u, v)] = arrow\n \n # Group all graph elements\n graph_group = VGroup(*vertices, vertex_labels, *edges)\n \n # ==========================================\n # 2. Graph Construction Animation\n # ==========================================\n # Animate vertices and labels appearing consecutively\n self.play(LaggedStart(*[Create(v) for v in vertices], lag_ratio=0.1), run_time=1.5)\n self.play(FadeIn(vertex_labels), run_time=0.5)\n # Animate edges appearing consecutively with a slight delay\n self.play(LaggedStart(*[Create(e) for e in edges], lag_ratio=0.2), run_time=2.0)\n \n self.wait(0.5)\n\n # ==========================================\n # 3. Path Highlighting Animation\n # ==========================================\n # Define the Eulerian Path sequence of vertices\n # Path: 0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 0 -> 2 -> 4 -> 0 -> 3\n path_sequence = [0, 1, 2, 3, 4, 5, 0, 2, 4, 0, 3]\n \n # Create a tracer dot to visualize the traversal movement\n tracer = Dot(vertices[path_sequence[0]].get_center(), radius=0.15, color=YELLOW)\n self.play(Create(tracer))\n \n # Highlight start vertex\n self.play(vertices[path_sequence[0]].animate.set_color(BBLUE), run_time=0.5)\n \n # Traverse the path, highlighting edges and vertices\n for i in range(len(path_sequence) - 1):\n u = path_sequence[i]\n v = path_sequence[i+1]\n \n edge = edge_map[(u, v)]\n target_vertex = vertices[v]\n \n # Animate tracer moving along the edge, changing colors to blue\n self.play(\n MoveAlongPath(tracer, edge),\n edge.animate.set_color(BLUE),\n target_vertex.animate.set_color(BLUE),\n run_time=0.8\n )\n \n self.wait(0.5)\n self.play(FadeOut(tracer))\n\n # ==========================================\n # 4. Labeling\n # ==========================================\n # Display the text \"Eulerian Path\" at the top\n title = Text(\"Eulerian Path\", font_size=48).to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=1.5)\n \n self.wait(0.5)\n\n # ==========================================\n # 5. Transformation\n # ==========================================\n # Create a smaller copy of the graph (including the highlighted path)\n # and position it below the text label.\n target_graph = graph_group.copy()\n target_graph.scale(0.5)\n target_graph.next_to(title, DOWN, buff=0.5)\n \n # Transform the original graph into the smaller version\n self.play(Transform(graph_group, target_graph), run_time=2.0)\n \n self.wait(1.0)\n\n # ==========================================\n # 6. Conclusion\n # ==========================================\n # Fade out the entire scene\n self.play(\n FadeOut(graph_group),\n FadeOut(title),\n run_time=1.5\n )\n \n self.wait(0.5)\n\n# To run this animation: manim -pql filename.py EulerianPathVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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**Target Network**\n\n- **Purpose**: Solves the \"Moving Target\" problem. If the target network is not fixed, updating $\\theta$ will simultaneously change both the predicted value and the target value, leading to unstable training.\n- **Update Methods**:\n - **Hard Update**: Directly copies $\\theta^- \\leftarrow \\theta$ at fixed intervals (e.g., every 1000 steps).\n - **Soft Update**: $\\theta^- \\leftarrow \\tau\\theta + (1-\\tau)\\theta^-$, where $\\tau \\ll 1$, making the target change smoother (common in DDPG/SAC).\n\n**[Suggested Diagram: DQN architecture diagram showing the interaction between the current network, target network, and the experience replay buffer]**\n\n\nContextual location of this section (from highest to current level):\n# Embodied Intelligence: Deep Reinforcement Learning\n## DQN and Its Improvements\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TargetNetworkScene(Scene):\n\n def construct(self):\n title = Text('Target Network in DQN', 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 purpose_txt = Text('Purpose: Solves Moving Target problem to stabilize training', font_size=24)\n purpose_txt.next_to(title_group, DOWN, buff=0.4).to_edge(LEFT, buff=0.5)\n self.play(FadeIn(purpose_txt, shift=DOWN * 0.2))\n updates_title = Text('Update Methods:', font_size=24, color=YELLOW)\n updates_title.next_to(purpose_txt, DOWN, buff=0.3).align_to(purpose_txt, LEFT)\n hard_upd = VGroup(MathTex('\\\\bullet', font_size=28), Text('Hard Update:', font_size=22, color=ORANGE, weight=BOLD), MathTex('\\\\theta^- \\\\leftarrow \\\\theta \\\\text{ (periodic)}', font_size=28)).arrange(RIGHT, buff=0.2)\n soft_upd = VGroup(MathTex('\\\\bullet', font_size=28), Text('Soft Update:', font_size=22, color=ORANGE, weight=BOLD), MathTex('\\\\theta^- \\\\leftarrow \\\\tau\\\\theta + (1-\\\\tau)\\\\theta^-', font_size=28)).arrange(RIGHT, buff=0.2)\n updates_group = VGroup(hard_upd, soft_upd).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n updates_group.next_to(updates_title, DOWN, buff=0.2).align_to(updates_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(updates_title))\n self.play(FadeIn(hard_upd, shift=RIGHT * 0.2))\n self.play(FadeIn(soft_upd, shift=RIGHT * 0.2))\n buffer_txt = Text('Replay Buffer', font_size=22)\n buffer_box = SurroundingRectangle(buffer_txt, color=BLUE, buff=0.2)\n buffer_group = VGroup(buffer_txt, buffer_box).move_to(LEFT * 4.5 + DOWN * 2)\n curr_net_txt = MathTex('\\\\text{Current Network } \\\\theta', font_size=24)\n curr_net_box = SurroundingRectangle(curr_net_txt, color=GREEN, buff=0.2)\n curr_net_group = VGroup(curr_net_txt, curr_net_box).move_to(LEFT * 0.5 + DOWN * 1)\n tgt_net_txt = MathTex('\\\\text{Target Network } \\\\theta^-', font_size=24)\n tgt_net_box = SurroundingRectangle(tgt_net_txt, color=RED, buff=0.2)\n tgt_net_group = VGroup(tgt_net_txt, tgt_net_box).move_to(LEFT * 0.5 + DOWN * 3)\n arrow_s = Arrow(buffer_group.get_right(), curr_net_group.get_left(), buff=0.1, color=LIGHT_GREY)\n label_s = MathTex('s', font_size=24).next_to(arrow_s, UP, buff=0.05)\n arrow_sp = Arrow(buffer_group.get_right(), tgt_net_group.get_left(), buff=0.1, color=LIGHT_GREY)\n label_sp = MathTex(\"s'\", font_size=24).next_to(arrow_sp, DOWN, buff=0.05)\n out_curr = MathTex('Q(s, a; \\\\theta)', font_size=24).next_to(curr_net_group, RIGHT, buff=0.8)\n out_tgt = MathTex(\"Q(s', a'; \\\\theta^-)\", font_size=24).next_to(tgt_net_group, RIGHT, buff=0.8)\n arrow_out1 = Arrow(curr_net_group.get_right(), out_curr.get_left(), buff=0.1, color=WHITE)\n arrow_out2 = Arrow(tgt_net_group.get_right(), out_tgt.get_left(), buff=0.1, color=WHITE)\n arrow_update = Arrow(curr_net_group.get_bottom(), tgt_net_group.get_top(), buff=0.1, color=YELLOW)\n label_update = Text('Update', font_size=18, color=YELLOW).next_to(arrow_update, RIGHT, buff=0.1)\n self.play(Create(buffer_group), run_time=0.8)\n self.play(Create(arrow_s), Write(label_s), Create(arrow_sp), Write(label_sp), run_time=0.8)\n self.play(Create(curr_net_group), Create(tgt_net_group), run_time=0.8)\n self.play(Create(arrow_out1), Write(out_curr), Create(arrow_out2), Write(out_tgt), run_time=0.8)\n self.play(Create(arrow_update), Write(label_update), run_time=0.8)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TargetNetworkScene(Scene):\n\n def construct(self):\n title = Text('Target Network in DQN', 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 purpose_txt = Text('Purpose: Solves Moving Target problem to stabilize training', font_size=24)\n purpose_txt.next_to(title_group, DOWN, buff=0.4).to_edge(LEFT, buff=0.5)\n self.play(FadeIn(purpose_txt, shift=DOWN * 0.2))\n updates_title = Text('Update Methods:', font_size=24, color=YELLOW)\n updates_title.next_to(purpose_txt, DOWN, buff=0.3).align_to(purpose_txt, LEFT)\n hard_upd = VGroup(MathTex('\\\\bullet', font_size=28), Text('Hard Update:', font_size=22, color=ORANGE, weight=BOLD), MathTex('\\\\theta^- \\\\leftarrow \\\\theta \\\\text{ (periodic)}', font_size=28)).arrange(RIGHT, buff=0.2)\n soft_upd = VGroup(MathTex('\\\\bullet', font_size=28), Text('Soft Update:', font_size=22, color=ORANGE, weight=BOLD), MathTex('\\\\theta^- \\\\leftarrow \\\\tau\\\\theta + (1-\\\\tau)\\\\theta^-', font_size=28)).arrange(RIGHT, buff=0.2)\n updates_group = VGroup(hard_upd, soft_upd).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n updates_group.next_to(updates_title, DOWN, buff=0.2).align_to(updates_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(updates_title))\n self.play(FadeIn(hard_upd, shift=RIGHT * 0.2))\n self.play(FadeIn(soft_upd, shift=RIGHT * 0.2))\n buffer_txt = Text('Replay Buffer', font_size=22)\n buffer_box = SurroundingRectangle(buffer_txt, color=BLUE, buff=0.2)\n buffer_group = VGroup(buffer_txt, buffer_box).move_to(LEFT * 4.5 + DOWN * 2)\n curr_net_txt = MathTex('\\\\text{Current Network } \\\\theta', font_size=24)\n curr_net_box = SurroundingRectangle(curr_net_txt, color=GREEN, buff=0.2)\n curr_net_group = VGroup(curr_net_txt, curr_net_box).move_to(LEFT * 0.5 + DOWN * 1)\n tgt_net_txt = MathTex('\\\\text{Target Network } \\\\theta^-', font_size=24)\n tgt_net_box = SurroundingRectangle(tgt_net_txt, color=RED, buff=0.2)\n tgt_net_group = VGroup(tgt_net_txt, tgt_net_box).move_to(LEFT * 0.5 + DOWN * 3)\n arrow_s = Arrow(buffer_group.get_right(), curr_net_group.get_left(), buff=0.1, color=LIGHT_GREY)\n label_s = MathTex('s', font_size=24).next_to(arrow_s, UP, buff=0.05)\n arrow_sp = Arrow(buffer_group.get_right(), tgt_net_group.get_left(), buff=0.1, color=LIGHT_GREY)\n label_sp = MathTex(\"s'\", font_size=24).next_to(arrow_sp, DOWN, buff=0.05)\n out_curr = MathTex('Q(s, a; \\\\theta)', font_size=24).next_to(curr_net_group, RIGHT, buff=0.8)\n out_tgt = MathTex(r\"Q(s', a'; \\\\theta^-)\" + \" = x\", font_size=24).next_to(tgt_net_group, RIGHT, buff=0.8)\n arrow_out1 = Arrow(curr_net_group.get_right(), out_curr.get_left(), buff=0.1, color=WHITE)\n arrow_out2 = Arrow(tgt_net_group.get_right(), out_tgt.get_left(), buff=0.1, color=WHITE)\n arrow_update = Arrow(curr_net_group.get_bottom(), tgt_net_group.get_top(), buff=0.1, color=YELLOW)\n label_update = Text('Update', font_size=18, color=YELLOW).next_to(arrow_update, RIGHT, buff=0.1)\n self.play(Create(buffer_group), run_time=0.8)\n self.play(Create(arrow_s), Write(label_s), Create(arrow_sp), Write(label_sp), run_time=0.8)\n self.play(Create(curr_net_group), Create(tgt_net_group), run_time=0.8)\n self.play(Create(arrow_out1), Write(out_curr), Create(arrow_out2), Write(out_tgt), run_time=0.8)\n self.play(Create(arrow_update), Write(label_update), run_time=0.8)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I need a visual representation for an educational video on chemistry, specifically showcasing a reaction at the molecular level. Can you create an animation with the following features?\n\n1. Show an oxygen molecule composed of two oxygen atoms, with a single unpaired electron nearby.\n2. Introduce a layer of carbon atoms from above.\n3. These three components should appear sequentially on the screen with a small delay between their appearances.\n4. After they have appeared, I want the unpaired electron to move along a curved path from one oxygen atom towards the carbon layer.\n5. Finally, end the animation by reorganizing the oxygen molecule, the unpaired electron, and the carbon layer into a product of a chemical reaction, showing them rearrange and align vertically.\n\nThe animation should be simple, without any complex backgrounds or additional elements, and it should convey the basic process of the reaction's mechanism.", "chosen": "```python\nfrom manim import *\n\nclass MolecularReaction(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n O_COLOR = RED\n C_COLOR = GREY_B\n E_COLOR = BLUE\n BOND_COLOR = WHITE\n LABEL_COLOR = WHITE\n\n # --- 1. Initial Setup: Oxygen Molecule (O₂) & Unpaired Electron ---\n # Create two oxygen atoms represented as circles with labels\n o_atom_1 = Circle(radius=0.5, color=O_COLOR, fill_opacity=1.0)\n o_atom_2 = Circle(radius=0.5, color=O_COLOR, fill_opacity=1.0)\n o_label_1 = Text(\"O\", font_size=24, color=LABEL_COLOR).move_to(o_atom_1.get_center())\n o_label_2 = Text(\"O\", font_size=24, color=LABEL_COLOR).move_to(o_atom_2.get_center())\n \n # Group and arrange horizontally to represent the O=O bond\n o_group = VGroup(o_atom_1, o_label_1, o_atom_2, o_label_2)\n o_group.arrange(RIGHT, buff=0.15)\n \n o_bond = Line(o_atom_1.get_center(), o_atom_2.get_center(), color=BOND_COLOR, stroke_width=4)\n o2_molecule = VGroup(o_bond, o_group)\n o2_molecule.move_to(LEFT * 3 + DOWN * 1)\n\n # Create unpaired electron as a small dot with a label\n electron_dot = Dot(radius=0.12, color=E_COLOR)\n electron_label = MathTex(\"e^-\", color=E_COLOR, font_size=24)\n electron_label.next_to(electron_dot, RIGHT, buff=0.1)\n electron_group = VGroup(electron_dot, electron_label)\n electron_group.next_to(o2_molecule, RIGHT, buff=0.8)\n\n # --- 2. Sequential Appearance ---\n \n # Step A: Oxygen molecule appears\n self.play(Create(o2_molecule), run_time=1.0)\n self.wait(0.5)\n \n # Step B: Unpaired electron appears\n self.play(FadeIn(electron_group), run_time=0.8)\n self.wait(0.5)\n\n # Step C: Carbon layer appears from above\n # Create a row of carbon atoms to represent a surface layer\n c_atoms = VGroup()\n for _ in range(5):\n c_atom = Circle(radius=0.5, color=C_COLOR, fill_opacity=1.0)\n c_label = Text(\"C\", font_size=24, color=LABEL_COLOR).move_to(c_atom.get_center())\n c_atoms.add(VGroup(c_atom, c_label))\n \n c_atoms.arrange(RIGHT, buff=0.2)\n # Start position above the visible frame\n c_atoms.move_to(UP * 4)\n \n # Animate the carbon layer entering the scene\n target_c_pos = RIGHT * 3 + DOWN * 1\n self.play(c_atoms.animate.move_to(target_c_pos), run_time=1.5)\n self.wait(0.5)\n\n # --- 3. Electron Movement ---\n # Define a curved path from the Oxygen molecule to the Carbon layer\n start_point = electron_group.get_center()\n # Target a specific carbon atom in the layer (e.g., the middle one)\n target_c_atom = c_atoms[2]\n end_point = target_c_atom.get_center() + UP * 0.7\n \n # Create a curved path using ArcBetweenPoints\n electron_path = ArcBetweenPoints(start_point, end_point, angle=PI/4)\n \n # Optional: Show the path faintly to guide the eye\n path_guide = DashedVMobject(electron_path, color=WHITE, stroke_opacity=0.3)\n self.play(Create(path_guide), run_time=0.5)\n \n # Animate the electron moving along the curved path\n self.play(MoveAlongPath(electron_group, electron_path), run_time=2.0, rate_func=smooth)\n self.play(FadeOut(path_guide), run_time=0.3)\n\n # --- 4. Reaction Completion ---\n # Reorganize components into a vertical product alignment (O-O-C with integrated e^-)\n \n # Define final positions for the product stack centered at ORIGIN\n final_o1_pos = UP * 2.0\n final_o2_pos = UP * 0.5\n final_c_pos = DOWN * 1.0\n final_e_pos = RIGHT * 0.8 + DOWN * 0.25 # Electron resides near the bond interface\n \n # Identify unused components to fade out for clarity\n unused_carbons = VGroup(*[c for i, c in enumerate(c_atoms) if i != 2])\n \n # Execute the rearrangement animation\n self.play(\n FadeOut(unused_carbons),\n o_atom_1.animate.move_to(final_o1_pos),\n o_label_1.animate.move_to(final_o1_pos),\n o_atom_2.animate.move_to(final_o2_pos),\n o_label_2.animate.move_to(final_o2_pos),\n target_c_atom.animate.move_to(final_c_pos),\n electron_group.animate.move_to(final_e_pos).scale(0.8),\n run_time=2.5\n )\n \n # Redraw bonds for the final vertical product state\n new_bond_1 = Line(final_o1_pos, final_o2_pos, color=BOND_COLOR, stroke_width=4)\n new_bond_2 = Line(final_o2_pos, final_c_pos, color=BOND_COLOR, stroke_width=4)\n \n self.play(\n FadeOut(o_bond),\n Create(new_bond_1),\n Create(new_bond_2),\n run_time=1.0\n )\n \n # Add a product label to signify reaction completion\n product_label = Text(\"Product Complex\", font_size=28, color=LABEL_COLOR)\n product_stack = VGroup(o_atom_1, o_atom_2, target_c_atom, new_bond_1, new_bond_2)\n product_label.next_to(product_stack, RIGHT, buff=1.0)\n \n self.play(FadeIn(product_label), run_time=1.0)\n \n # Hold final state\n self.wait(2.0)\n```", "rejected": "```python\nfrom manim import *\n\nclass MolecularReaction(Scene):\n def construct(self):\n # --- Configuration & Colors ---\n O_COLOR = RED\n C_COLOR = GREY_B\n E_COLOR = BLUE\n BOND_COLOR = WHITE\n LABEL_COLOR = WHITE\n\n # --- 1. Initial Setup: Oxygen Molecule (O₂) & Unpaired Electron ---\n # Create two oxygen atoms represented as circles with labels\n o_atom_1 = Circle(radius=0.5, color=O_COLOR, fill_opacity=1.0)\n o_atom_2 = Circle(radius=0.5, color=O_COLOR, fill_opacity=1.0)\n o_label_1 = Text(\"O\", font_size=24, color=LABEL_COLOR).move_to(o_atom_1.get_center())\n o_label_2 = Text(\"O\", font_size=24, color=LABEL_COLOR).move_to(o_atom_2.get_center())\n \n # Group and arrange horizontally to represent the O=O bond\n o_group = VGroup(o_atom_1, o_label_1, o_atom_2, o_label_2)\n o_group.arrange(RIGHT, buff=0.15)\n \n o_bond = Line(o_atom_1.get_center(), o_atom_2.get_center(), color=BOND_COLOR, stroke_width=4)\n o2_molecule = VGroup(o_bond, o_group)\n o2_molecule.move_to(LEFT * 3 + DOWN * 1)\n\n # Create unpaired electron as a small dot with a label\n electron_dot = Dot(radius=0.12, color=E_COLOR)\n electron_label = MathTex(r\"e^-\" + \" = x\", color=E_COLOR, font_size=24)\n electron_label.next_to(electron_dot, RIGHT, buff=0.1)\n electron_group = VGroup(electron_dot, electron_label)\n electron_group.next_to(o2_molecule, RIGHT, buff=0.8)\n\n # --- 2. Sequential Appearance ---\n \n # Step A: Oxygen molecule appears\n self.play(Create(o2_molecule), run_time=1.0)\n self.wait(0.5)\n \n # Step B: Unpaired electron appears\n self.play(FadeIn(electron_group), run_time=0.8)\n self.wait(0.5)\n\n # Step C: Carbon layer appears from above\n # Create a row of carbon atoms to represent a surface layer\n c_atoms = VGroup()\n for _ in range(5):\n c_atom = Circle(radius=0.5, color=C_COLOR, fill_opacity=1.0)\n c_label = Text(\"C\", font_size=24, color=LABEL_COLOR).move_to(c_atom.get_center())\n c_atoms.add(VGroup(c_atom, c_label))\n \n c_atoms.arrange(RIGHT, buff=0.2)\n # Start position above the visible frame\n c_atoms.move_to(UP * 4)\n \n # Animate the carbon layer entering the scene\n target_c_pos = RIGHT * 3 + DOWN * 1\n self.play(c_atoms.animate.move_to(target_c_pos), run_time=1.5)\n self.wait(0.5)\n\n # --- 3. Electron Movement ---\n # Define a curved path from the Oxygen molecule to the Carbon layer\n start_point = electron_group.get_center()\n # Target a specific carbon atom in the layer (e.g., the middle one)\n target_c_atom = c_atoms[2]\n end_point = target_c_atom.get_center() + UP * 0.7\n \n # Create a curved path using ArcBetweenPoints\n electron_path = ArcBetweenPoints(start_point, end_point, angle=PI/4)\n \n # Optional: Show the path faintly to guide the eye\n path_guide = DashedVMobject(electron_path, color=WHITE, stroke_opacity=0.3)\n self.play(Create(path_guide), run_time=0.5)\n \n # Animate the electron moving along the curved path\n self.play(MoveAlongPath(electron_group, electron_path), run_time=2.0, rate_func=smooth)\n self.play(FadeOut(path_guide), run_time=0.3)\n\n # --- 4. Reaction Completion ---\n # Reorganize components into a vertical product alignment (O-O-C with integrated e^-)\n \n # Define final positions for the product stack centered at ORIGIN\n final_o1_pos = UP * 2.0\n final_o2_pos = UP * 0.5\n final_c_pos = DOWN * 1.0\n final_e_pos = RIGHT * 0.8 + DOWN * 0.25 # Electron resides near the bond interface\n \n # Identify unused components to fade out for clarity\n unused_carbons = VGroup(*[c for i, c in enumerate(c_atoms) if i != 2])\n \n # Execute the rearrangement animation\n self.play(\n FadeOut(unused_carbons),\n o_atom_1.animate.move_to(final_o1_pos),\n o_label_1.animate.move_to(final_o1_pos),\n o_atom_2.animate.move_to(final_o2_pos),\n o_label_2.animate.move_to(final_o2_pos),\n target_c_atom.animate.move_to(final_c_pos),\n electron_group.animate.move_to(final_e_pos).scale(0.8),\n run_time=2.5\n )\n \n # Redraw bonds for the final vertical product state\n new_bond_1 = Line(final_o1_pos, final_o2_pos, color=BOND_COLOR, stroke_width=4)\n new_bond_2 = Line(final_o2_pos, final_c_pos, color=BOND_COLOR, stroke_width=4)\n \n self.play(\n FadeOut(o_bond),\n Create(new_bond_1),\n Create(new_bond_2),\n run_time=1.0\n )\n \n # Add a product label to signify reaction completion\n product_label = Text(\"Product Complex\", font_size=28, color=LABEL_COLOR)\n product_stack = VGroup(o_atom_1, o_atom_2, target_c_atom, new_bond_1, new_bond_2)\n product_label.next_to(product_stack, RIGHT, buff=1.0)\n \n self.play(FadeIn(product_label), run_time=1.0)\n \n # Hold final state\n self.wait(2.0)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like an animated educational video that illustrates the concept of finding the area under a curve using integrals. The animation should include a blue-colored set of axes and a green parabolic function graph. I want to display the area under the curve between the points 0.3 and 4.5 on the x-axis, highlighted with a gradient of red to green with a semi-transparent effect. Also, animate the addition of x-axis labels at the points 0.3 and 4.5. Next, show the corresponding integral notation above this area and then transform it to display the exact algebraic calculation of the integral. Once that's done, demonstrate the final result of the definite integral just below the calculation steps. Finally, clear the other elements away to leave just the highlighted area and the result visible. Make sure each step is clearly shown with sufficient time for a viewer to follow, pausing for a couple of seconds between steps.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Setup Axes ---\n axes = Axes(\n x_range=[-0.5, 5.0, 1], y_range=[-1, 16, 4],\n tips=False,\n ).shift(LEFT*2)\n \n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n self.play(Create(axes), Write(axis_labels))\n self.wait(1)\n\n # --- Step 2: Plot Green Parabola f(x) = 0.2*x^2 + 0.5 ---\n func = lambda t: 0.2*t**2 + 0.5\n graph = axes.plot(func, color=GREEN, x_range=[-0.5, 5])\n \n self.play(Create(graph))\n self.wait(1)\n\n # --- Step 3: Highlight Area Under Curve ---\n # Define bounds specifically from 0.3 to 4.5 inclusive\n area = axes.get_area(\n graph, \n x_range=(0.3, 4.5), \n color=RED, opacity=0.3\n )\n \n # Add vertical lines to mark start and end points exactly\n line_start = Line(start=axes.c2p(0.3, 0), end=axes.c2p(0.3, func(0.3)), color=WHITE).set_stroke(width=2)\n line_end = Line(start=axes.c2p(4.5, 0), end=axes.c2p(4.5, func(4.5)), color=WHITE).set_stroke(width=2)\n \n label_start = MathTex(\"a=0.3\").next_to(line_start, UP, buff=0.2)\n label_end = MathTex(\"b=4.5\").next_to(line_end, DOWN, buff=0.1)\n \n self.play(FadeIn(area), Create(line_start), FadeIn(label_start),\n Create(line_end), FadeIn(label_end))\n self.wait(2)\n\n # --- Step 4: Animate X-Axis Labels ---\n label_a = MathTex(\"0.3\").scale(0.8).move_to([0.3, -0.75, 0]).set_color(YELLOW)\n label_b = MathTex(\"4.5\").scale(0.8).move_to([4.5, -0.75, 0]).set_color(ORANGE)\n \n self.play(Write(label_a), Write(label_b))\n self.wait(1.5)\n\n # --- Step 5: Display Integral Notation Above Area ---\n integral_notation = MathTex(\n r\"\\int_{0.3}^{4.5}\", \"f(x)\", \"\\\\, dx\"\n ).to_edge(UP, buff=0.5).scale(0.9)\n \n self.play(Write(integral_notation))\n self.wait(2)\n\n # --- Step 6: Transform To Algebraic Calculation ---\n algebra_calculation = MathTex(\n r\"=\", r\"\\left[ \", \"0.2x^3\", \"+ 0.5x\", r\"\\right]_{0.3}^{4.5}\"\n ).next_to(integral_notation, DOWN, aligned_edge=LEFT, buff=0.3).scale(0.9)\n \n self.play(TransformMatchingTex(integral_notation, algebra_calculation))\n self.wait(1.5)\n\n # --- Step 7: Show Final Result Just Below Calculations ---\n final_result = MathTex(\n r\"=\", r\"\\frac{1}{3}(4.5)^3 + \\frac{1}{2}(4.5) - (\\text{lower limit terms})\"\n ).next_to(algebra_calculation, DOWN, aligned_edge=LEFT, buff=0.3).scale(0.8)\n \n # Simplify lower limits by evaluating them explicitly up front\n lower_limit_eval = MathTex(\n r\"=\", r\"\\frac{1}{3}(0.3)^3 + \\frac{1}{2}(0.3)\"\n ).next_to(final_result, DOWN, aligned_edge=RIGHT, buff=0.4).scale(0.8)\n \n self.play(Write(lower_limit_eval)) # Pre-evaluate low-end values for clarity\n \n self.play(Write(final_result))\n self.wait(2)\n\n # --- Step 8: Clear Elements Leaving Only Highlighted Area and Result ---\n to_remove = VGroup(\n axes, axis_labels, graph, line_start, line_end, \n label_a, label_b, label_start, label_end\n )\n \n self.play(\n FadeOut(to_remove), \n final_result.animate.shift(DOWN*1.5),\n lower_limit_eval.animate.move_to(ORIGIN).scale(1.5).set_opacity(0.7)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Configuration ---\n COLOR_AXES = BLUE\n COLOR_FUNCTION = GREEN\n COLOR_AREA = color_gradient(RED, GREEN)\n COLOR_LABELS = WHITE\n \n # Display Blue Axes\n axes = Axes(\n x_range=[-0.5, 5, 1],\n y_range=[-0.5, 8, 1],\n tips=False,\n x_length=7,\n y_length=6,\n x_axis_config={\"color\": COLOR_AXES},\n y_axis_config={\"color\": COLOR_AXES}\n )\n \n self.play(Create(axes))\n self.wait(2)\n\n # Plot Green Parabola Function f(x) = 0.1*x^2\n func = lambda x: 0.1 * x**2\n graph = axes.plot(func, color=COLOR_FUNCTION)\n \n self.play(Create(graph))\n self.wait(2)\n\n # Highlight Area Under Curve from x = 0.3 to x = 4.5 with Red-Green Gradient\n area = axes.get_area(graph, x_range=(0.3, 4.5), color=COLOR_AREA, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait(2)\n\n # Add X-Axis Labels at Points 0.3 and 4.5\n label_start = MathTex(\"0.3\").next_to(axes.n2p([0.3, 0]), DOWN, buff=-0.2).set_color(COLOR_LABELS)\n line_start = Line(start=axes.c2p(0.3, 0), end=axes.c2p(0.3, 1.5)).set_stroke(width=1, color=WHITE)\n \n label_end = MathTex(\"4.5\").next_to(axes.n2p([4.5, 0]), DOWN, buff=0.2).set_color(COLOR_LABELS)\n line_end = Line(start=axes.c2p(4.5, 0), end=axes.c2p(4.5, 1.5)).set_stroke(width=1, color=WHITE)\n \n self.play(\n Write(label_start),\n Create(line_start),\n Write(label_end),\n Create(line_end)\n )\n self.wait(2)\n\n # Animate Integration Notation Above the Area\n notations = [\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"f(x)\", \"\\\\, dx\", font_size=42),\n MathTex(\"\\\\int_{0.3}^{4.5}\", \"(0.1 x^2)\", \"\\\\, dx\", font_size=42)\n ]\n \n math_notation = VGroup(notations[0]).to_edge(UP, buff=1)\n \n self.play(Write(math_notation))\n self.wait(2)\n self.play(ReplacementTransform(notations[0], notations[1]))\n self.wait(2)\n\n # Transform Notation to Exact Algebra Calculation\n calc_step1 = MathTex(\"\\\\left[ \\\\frac{0.1}{3} x^3 \\\\right]\", \"_{0.3}^{4.5}\", font_size=42)\n calc_step1.move_to(math_notation.get_center())\n \n self.play(Transform(match_target_data=True, math_notation, calc_step1))\n self.wait(2)\n\n # Final Result Just Below the Calculation Steps\n final_result = MathTex(\"\\\\approx\", \"{\\\\small 17.68}\", font_size=42)\n final_box = SurroundingRectangle(final_result, color=YELLOW, fill_opacity=0.1)\n \n final_group = VGroup(calc_step1.copy(), final_box, final_result)\n final_group.arrange(DOWN, aligned_edge=LEFT, buff=1).move_to(MathTex(\"A\").get_center())\n\n self.play(Write(final_group[:2]))\n self.play(Write(final_group[2]))\n self.wait(2)\n\n # Clear All Elements Except Area and Result\n remaining_elements = VGroup(axes, graph, area, label_start, line_start, label_end, line_end)\n self.play(FadeOut(remaining_elements, shift=DOWN))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated visualization of a Recurrent Neural Network (RNN) using three layers with 6, 8, and 4 neurons respectively, where the middle layer is recurrent and has colored neurons, accompanied by a label that says \"Recurrent Neural Network\" at the top, and display arrows indicating the input and output flows for the recurrent layer? Additionally, can you animate a signal passing through the network?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass RNNVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n n_input = 6\n n_recurrent = 8\n n_output = 4\n \n neuron_radius = 0.25\n neuron_spacing = 0.45\n layer_x_spacing = 4.0\n \n # Colors\n color_input = BLUE_E\n color_recurrent = GREEN_E # Distinct color for the recurrent layer\n color_output = BLUE_E\n color_connection = GRAY\n color_signal = YELLOW\n color_loop = RED\n \n # --- Title ---\n title = Text(\"Recurrent Neural Network\", font_size=40, color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n \n # --- Helper Functions ---\n def create_layer(n_neurons, color, x_pos):\n \"\"\"Creates a vertically centered group of neuron circles.\"\"\"\n layer = VGroup()\n start_y = -((n_neurons - 1) * neuron_spacing) / 2\n for i in range(n_neurons):\n neuron = Circle(\n radius=neuron_radius, \n fill_color=color, \n fill_opacity=0.9, \n stroke_color=WHITE, \n stroke_width=2\n )\n y_pos = start_y + i * neuron_spacing\n neuron.move_to([x_pos, y_pos, 0])\n layer.add(neuron)\n return layer\n\n def create_connections(layer1, layer2):\n \"\"\"Creates lines between all neurons of two adjacent layers.\"\"\"\n connections = VGroup()\n for n1 in layer1:\n for n2 in layer2:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n color=color_connection, \n stroke_width=1, \n stroke_opacity=0.4\n )\n connections.add(line)\n return connections\n \n # --- Create Layers ---\n input_layer = create_layer(n_input, color_input, -layer_x_spacing)\n recurrent_layer = create_layer(n_recurrent, color_recurrent, 0)\n output_layer = create_layer(n_output, color_output, layer_x_spacing)\n \n self.play(FadeIn(input_layer), FadeIn(recurrent_layer), FadeIn(output_layer))\n \n # --- Create Connections ---\n conn_in_rec = create_connections(input_layer, recurrent_layer)\n conn_rec_out = create_connections(recurrent_layer, output_layer)\n \n self.play(Create(conn_in_rec), Create(conn_rec_out), run_time=1.5)\n \n # --- Flow Arrows (Input/Output Indicators) ---\n # Large arrows indicating general flow direction into and out of the recurrent layer\n flow_arrow_in = Arrow(\n start=input_layer.get_right() + LEFT * 0.5, \n end=recurrent_layer.get_left() + RIGHT * 0.5, \n color=BLUE, \n buff=0,\n stroke_width=4,\n max_tip_length_to_length_ratio=0.15\n ).shift(UP * 3.0)\n \n flow_arrow_out = Arrow(\n start=recurrent_layer.get_right() + LEFT * 0.5, \n end=output_layer.get_left() + RIGHT * 0.5, \n color=BLUE, \n buff=0,\n stroke_width=4,\n max_tip_length_to_length_ratio=0.15\n ).shift(UP * 3.0)\n \n self.play(GrowArrow(flow_arrow_in), GrowArrow(flow_arrow_out))\n \n # --- Recurrent Feedback Loop ---\n # Create an arc above the recurrent layer to represent the feedback loop\n hidden_top_y = (n_recurrent - 1) * neuron_spacing / 2\n loop_center_y = hidden_top_y + 0.8\n loop_center = recurrent_layer.get_center() + UP * loop_center_y\n loop_radius = 1.2\n \n recurrent_arc = Arc(\n radius=loop_radius, \n angle=PI, \n start_angle=0, \n color=color_loop, \n stroke_width=5\n )\n recurrent_arc.add_tip()\n recurrent_arc.move_to(loop_center)\n \n recurrent_label = Text(\"Recurrent Feedback\", font_size=24, color=color_loop)\n recurrent_label.next_to(recurrent_arc, UP, buff=0.2)\n \n self.play(Create(recurrent_arc), FadeIn(recurrent_label))\n \n # --- Signal Animation ---\n signal = Dot(color=color_signal, radius=0.15)\n \n # Select central neurons for the main signal path for clarity\n p_input = input_layer[len(input_layer)//2].get_center()\n p_recurrent = recurrent_layer[len(recurrent_layer)//2].get_center()\n p_output = output_layer[len(output_layer)//2].get_center()\n \n # Initialize signal position\n signal.move_to(p_input)\n self.play(FadeIn(signal))\n \n # 1. Animate Input -> Recurrent\n path1 = Line(p_input, p_recurrent)\n self.play(MoveAlongPath(signal, path1), run_time=1.5, rate_func=smooth)\n \n # 2. Animate Recurrent Loop (Recurrent -> Arc -> Recurrent)\n arc_start = recurrent_arc.get_start()\n arc_end = recurrent_arc.get_end()\n \n path_up = Line(p_recurrent, arc_start)\n path_down = Line(arc_end, p_recurrent)\n \n self.play(MoveAlongPath(signal, path_up), run_time=0.5, rate_func=smooth)\n self.play(MoveAlongPath(signal, recurrent_arc), run_time=2.0, rate_func=smooth)\n self.play(MoveAlongPath(signal, path_down), run_time=0.5, rate_func=smooth)\n \n # 3. Animate Recurrent -> Output\n path3 = Line(p_recurrent, p_output)\n self.play(MoveAlongPath(signal, path3), run_time=1.5, rate_func=smooth)\n \n # Finish\n self.play(FadeOut(signal))\n self.wait(1)\n\n# To run this scene, use the command: \n# manim -pql scene.py RNNVisualization\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass RNNVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n n_input = 6\n n_recurrent = 8\n n_output = 4\n \n neuron_radius = 0.25\n neuron_spacing = 0.45\n layer_x_spacing = 4.0\n \n # Colors\n color_input = BBLUE_E\n color_recurrent = GREEN_E # Distinct color for the recurrent layer\n color_output = BLUE_E\n color_connection = GRAY\n color_signal = YELLOW\n color_loop = RED\n \n # --- Title ---\n title = Text(\"Recurrent Neural Network\", font_size=40, color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n \n # --- Helper Functions ---\n def create_layer(n_neurons, color, x_pos):\n \"\"\"Creates a vertically centered group of neuron circles.\"\"\"\n layer = VGroup()\n start_y = -((n_neurons - 1) * neuron_spacing) / 2\n for i in range(n_neurons):\n neuron = Circle(\n radius=neuron_radius, \n fill_color=color, \n fill_opacity=0.9, \n stroke_color=WHITE, \n stroke_width=2\n )\n y_pos = start_y + i * neuron_spacing\n neuron.move_to([x_pos, y_pos, 0])\n layer.add(neuron)\n return layer\n\n def create_connections(layer1, layer2):\n \"\"\"Creates lines between all neurons of two adjacent layers.\"\"\"\n connections = VGroup()\n for n1 in layer1:\n for n2 in layer2:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n color=color_connection, \n stroke_width=1, \n stroke_opacity=0.4\n )\n connections.add(line)\n return connections\n \n # --- Create Layers ---\n input_layer = create_layer(n_input, color_input, -layer_x_spacing)\n recurrent_layer = create_layer(n_recurrent, color_recurrent, 0)\n output_layer = create_layer(n_output, color_output, layer_x_spacing)\n \n self.play(FadeIn(input_layer), FadeIn(recurrent_layer), FadeIn(output_layer))\n \n # --- Create Connections ---\n conn_in_rec = create_connections(input_layer, recurrent_layer)\n conn_rec_out = create_connections(recurrent_layer, output_layer)\n \n self.play(Create(conn_in_rec), Create(conn_rec_out), run_time=1.5)\n \n # --- Flow Arrows (Input/Output Indicators) ---\n # Large arrows indicating general flow direction into and out of the recurrent layer\n flow_arrow_in = Arrow(\n start=input_layer.get_right() + LEFT * 0.5, \n end=recurrent_layer.get_left() + RIGHT * 0.5, \n color=BLUE, \n buff=0,\n stroke_width=4,\n max_tip_length_to_length_ratio=0.15\n ).shift(UP * 3.0)\n \n flow_arrow_out = Arrow(\n start=recurrent_layer.get_right() + LEFT * 0.5, \n end=output_layer.get_left() + RIGHT * 0.5, \n color=BLUE, \n buff=0,\n stroke_width=4,\n max_tip_length_to_length_ratio=0.15\n ).shift(UP * 3.0)\n \n self.play(GrowArrow(flow_arrow_in), GrowArrow(flow_arrow_out))\n \n # --- Recurrent Feedback Loop ---\n # Create an arc above the recurrent layer to represent the feedback loop\n hidden_top_y = (n_recurrent - 1) * neuron_spacing / 2\n loop_center_y = hidden_top_y + 0.8\n loop_center = recurrent_layer.get_center() + UP * loop_center_y\n loop_radius = 1.2\n \n recurrent_arc = Arc(\n radius=loop_radius, \n angle=PI, \n start_angle=0, \n color=color_loop, \n stroke_width=5\n )\n recurrent_arc.add_tip()\n recurrent_arc.move_to(loop_center)\n \n recurrent_label = Text(\"Recurrent Feedback\", font_size=24, color=color_loop)\n recurrent_label.next_to(recurrent_arc, UP, buff=0.2)\n \n self.play(Create(recurrent_arc), FadeIn(recurrent_label))\n \n # --- Signal Animation ---\n signal = Dot(color=color_signal, radius=0.15)\n \n # Select central neurons for the main signal path for clarity\n p_input = input_layer[len(input_layer)//2].get_center()\n p_recurrent = recurrent_layer[len(recurrent_layer)//2].get_center()\n p_output = output_layer[len(output_layer)//2].get_center()\n \n # Initialize signal position\n signal.move_to(p_input)\n self.play(FadeIn(signal))\n \n # 1. Animate Input -> Recurrent\n path1 = Line(p_input, p_recurrent)\n self.play(MoveAlongPath(signal, path1), run_time=1.5, rate_func=smooth)\n \n # 2. Animate Recurrent Loop (Recurrent -> Arc -> Recurrent)\n arc_start = recurrent_arc.get_start()\n arc_end = recurrent_arc.get_end()\n \n path_up = Line(p_recurrent, arc_start)\n path_down = Line(arc_end, p_recurrent)\n \n self.play(MoveAlongPath(signal, path_up), run_time=0.5, rate_func=smooth)\n self.play(MoveAlongPath(signal, recurrent_arc), run_time=2.0, rate_func=smooth)\n self.play(MoveAlongPath(signal, path_down), run_time=0.5, rate_func=smooth)\n \n # 3. Animate Recurrent -> Output\n path3 = Line(p_recurrent, p_output)\n self.play(MoveAlongPath(signal, path3), run_time=1.5, rate_func=smooth)\n \n # Finish\n self.play(FadeOut(signal))\n self.wait(1)\n\n# To run this scene, use the command: \n# manim -pql scene.py RNNVisualization\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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**Integration Methods**\n- Large models can play multiple roles in the system: task planner (brain), knowledge base (encyclopedia), and code generator (programmer).\n- VLA models (such as RT-2) have achieved end-to-end unified modeling of vision-language-action.\n\n\nContextual location of this section (from highest to current level):\n# LLM Code Generation Examples: Achieving Precise Control Through API Calls\n## Summary\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass IntegrationMethods(Scene):\n\n def construct(self):\n title = Text('Integration Methods', font_size=44, weight=BOLD, color=BLUE)\n bullet1 = MarkupText('• Large models can play multiple roles in the system:', font_size=30)\n\n def create_role_box(text, color):\n box = RoundedRectangle(corner_radius=0.2, height=1.2, width=3.5, color=color, fill_opacity=0.15)\n label = Text(text, font_size=24, line_spacing=1).move_to(box.get_center())\n return VGroup(box, label)\n box1 = create_role_box('Task Planner\\n(Brain)', RED)\n box2 = create_role_box('Knowledge Base\\n(Encyclopedia)', GREEN)\n box3 = create_role_box('Code Generator\\n(Programmer)', ORANGE)\n roles_group = VGroup(box1, box2, box3).arrange(RIGHT, buff=0.5)\n bullet2 = MarkupText('• VLA models (such as RT-2) have achieved end-to-end unified modeling:', font_size=30)\n vision_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=TEAL, fill_opacity=0.2)\n vision_text = Text('Vision', font_size=24).move_to(vision_box)\n vision = VGroup(vision_box, vision_text)\n plus = Text('+', font_size=32, weight=BOLD)\n language_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=PURPLE, fill_opacity=0.2)\n language_text = Text('Language', font_size=24).move_to(language_box)\n language = VGroup(language_box, language_text)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1, max_stroke_width_to_length_ratio=5)\n action_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=YELLOW, fill_opacity=0.2)\n action_text = Text('Action', font_size=24).move_to(action_box)\n action = VGroup(action_box, action_text)\n vla_group = VGroup(vision, plus, language, arrow, action).arrange(RIGHT, buff=0.4)\n content_group = VGroup(title, bullet1, roles_group, bullet2, vla_group).arrange(DOWN, buff=0.6, aligned_edge=LEFT)\n title.set_x(0)\n roles_group.set_x(0)\n vla_group.set_x(0)\n content_group.move_to(ORIGIN)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet1, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(box1, shift=UP), FadeIn(box2, shift=UP), FadeIn(box3, shift=UP), lag_ratio=0.2)\n self.wait(1)\n self.play(FadeIn(bullet2, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(vision, shift=RIGHT))\n self.play(Write(plus))\n self.play(FadeIn(language, shift=RIGHT))\n self.play(GrowArrow(arrow))\n self.play(FadeIn(action, shift=RIGHT))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass IntegrationMethods(Scene):\n\n def construct(self):\n title = Text('Integration Methods', font_size=44, weight=BOLD, color=BBLUE)\n bullet1 = MarkupText('• Large models can play multiple roles in the system:', font_size=30)\n\n def create_role_box(text, color):\n box = RoundedRectangle(corner_radius=0.2, height=1.2, width=3.5, color=color, fill_opacity=0.15)\n label = Text(text, font_size=24, line_spacing=1).move_to(box.get_center())\n return VGroup(box, label)\n box1 = create_role_box('Task Planner\\n(Brain)', RED)\n box2 = create_role_box('Knowledge Base\\n(Encyclopedia)', GREEN)\n box3 = create_role_box('Code Generator\\n(Programmer)', ORANGE)\n roles_group = VGroup(box1, box2, box3).arrange(RIGHT, buff=0.5)\n bullet2 = MarkupText('• VLA models (such as RT-2) have achieved end-to-end unified modeling:', font_size=30)\n vision_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=TEAL, fill_opacity=0.2)\n vision_text = Text('Vision', font_size=24).move_to(vision_box)\n vision = VGroup(vision_box, vision_text)\n plus = Text('+', font_size=32, weight=BOLD)\n language_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=PURPLE, fill_opacity=0.2)\n language_text = Text('Language', font_size=24).move_to(language_box)\n language = VGroup(language_box, language_text)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1, max_stroke_width_to_length_ratio=5)\n action_box = RoundedRectangle(corner_radius=0.1, height=0.8, width=2.0, color=YELLOW, fill_opacity=0.2)\n action_text = Text('Action', font_size=24).move_to(action_box)\n action = VGroup(action_box, action_text)\n vla_group = VGroup(vision, plus, language, arrow, action).arrange(RIGHT, buff=0.4)\n content_group = VGroup(title, bullet1, roles_group, bullet2, vla_group).arrange(DOWN, buff=0.6, aligned_edge=LEFT)\n title.set_x(0)\n roles_group.set_x(0)\n vla_group.set_x(0)\n content_group.move_to(ORIGIN)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet1, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(box1, shift=UP), FadeIn(box2, shift=UP), FadeIn(box3, shift=UP), lag_ratio=0.2)\n self.wait(1)\n self.play(FadeIn(bullet2, shift=RIGHT))\n self.wait(0.5)\n self.play(FadeIn(vision, shift=RIGHT))\n self.play(Write(plus))\n self.play(FadeIn(language, shift=RIGHT))\n self.play(GrowArrow(arrow))\n self.play(FadeIn(action, shift=RIGHT))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a 12-second logic scene explaining necessary and sufficient conditions with nested sets. Put set A entirely inside set B, animate examples inside and outside A, and label that A is sufficient for B while B is necessary for A. Avoid implying the converse.", "chosen": "```python\nfrom manim import *\n\nclass NecessarySufficientSets(Scene):\n def construct(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass NecessarySufficientSets(Scene):\n def construct(self):\n title = Text(\"Nested sets make necessity and sufficiency visible\", font_size=36).to_edge(UP)\n set_b = Circle(radius=2.4, color=BLUE_B, fill_opacity=0.1)\n set_a = Circle(radius=1.15, color=ORANGE, fill_opacity=0.16).shift(LEFT * 0.4)\n label_b = Text(\"B\", font_size=30, color=BLUE_B).next_to(set_b, UR, buff=-0.55)\n label_a = Text(\"A\", font_size=30, color=ORANGE).move_to(set_a.get_top() + DOWN * 0.3)\n inside = Dot(set_a.get_center() + DOWN * 0.35, color=YELLOW)\n only_b = Dot(set_b.get_center() + RIGHT * 1.65, color=TEAL_B)\n sufficient = Text(\"A is sufficient for B: A \\rightarrow B\", font_size=25, color=ORANGE).to_edge(DOWN)\n necessary = Text(\"B is necessary for A: without B, no A\", font_size=25, color=BLUE_B).to_edge(DOWN)\n converse = Text(\"But B does not imply A.\", font_size=27, color=RED).to_edge(DOWN)\n\n self.play(Write(title), Create(set_b), Create(set_a), FadeIn(label_b, label_a))\n self.play(FadeIn(inside), Indicate(set_a, color=ORANGE), FadeIn(sufficient))\n self.play(Indicate(set_b, color=BLUE_B), ReplacementTransform(target_position=ORIGIN, sufficient, necessary))\n self.play(FadeIn(only_b), ReplacementTransform(necessary, converse))\n self.play(Circumscribe(only_b, color=RED))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Could you create an educational animation that visually demonstrates the concept of finding the area under the curve of the function f(x) = x^2 from x=0 to x=2 using definite integration? I want the animation to include the following elements:\n\n1. Display a pair of X and Y axes with appropriate ranges and a blue color for the axes.\n2. At the top, show the integral formula of the function from 0 to 2.\n3. Plot the graph of the function f(x) = x^2 with a white color and label it with its equation.\n4. Highlight the area under the graph between 0 and 2 in green with some transparency to denote the area we are finding.\n5. Directly below the integral, show the calculation of the definite integral using the formula for the area under the curve: (upper bound)^3/3 - (lower bound)^3/3.\n6. After displaying the calculation, simplify the expression to show the final numerical value of the integral.\n7. After the calculation is shown, clear the other elements while leaving the simplified result displayed for a moment longer before ending the animation.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. SETUP: Display X and Y axes with appropriate ranges in blue.\n # ------------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n labels.set_color(BLUE)\n \n self.play(Create(axes), Write(labels), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. FORMULA DISPLAY: Show the integral formula at the top.\n # ------------------------------------------------------------------\n integral_formula = MathTex(\n r\"\\int_{0}^{2} x^2 \\, dx\",\n font_size=40\n ).to_edge(UP)\n \n self.play(Write(integral_formula), run_time=1)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. GRAPH PLOTTING: Plot f(x) = x^2 in white and label it.\n # ------------------------------------------------------------------\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=WHITE)\n graph_label = MathTex(r\"f(x) = x^2\", color=WHITE).next_to(graph, UR, buff=0.2)\n \n self.play(Create(graph), Write(graph_label), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. AREA HIGHLIGHTING: Highlight area under graph from x=0 to x=2.\n # ------------------------------------------------------------------\n area = axes.get_area(\n graph, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.5\n )\n \n self.play(FadeIn(area), run_time=1)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. CALCULATION DISPLAY: Step-by-step calculation below formula.\n # ------------------------------------------------------------------\n # Step 5a: Antiderivative using Power Rule\n calc_step_1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\",\n font_size=36\n ).next_to(integral_formula, DOWN, buff=0.5).align_to(integral_formula, LEFT)\n \n # Step 5b: Explicit substitution (upper^3/3 - lower^3/3)\n calc_step_2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\",\n font_size=36\n ).next_to(calc_step_1, DOWN, buff=0.3).align_to(calc_step_1, LEFT)\n \n self.play(Write(calc_step_1), run_time=1)\n self.wait(1)\n self.play(Write(calc_step_2), run_time=1)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. SIMPLIFICATION: Reveal the final numerical value.\n # ------------------------------------------------------------------\n final_result = MathTex(\n r\"= \\frac{8}{3}\",\n font_size=36,\n color=YELLOW\n ).next_to(calc_step_2, DOWN, buff=0.3).align_to(calc_step_2, LEFT)\n \n self.play(Write(final_result), run_time=1)\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 7. CONCLUSION: Clear all visuals except the simplified final result.\n # ------------------------------------------------------------------\n elements_to_remove = VGroup(\n axes, labels, \n graph, graph_label, \n area, \n integral_formula, calc_step_1, calc_step_2\n )\n \n # Fade out everything and center the final result for emphasis\n self.play(\n FadeOut(elements_to_remove),\n final_result.animate.move_to(ORIGIN).scale(1.5),\n run_time=1.5\n )\n \n self.wait(2)\n self.play(FadeOut(final_result))\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. SETUP: Display X and Y axes with appropriate ranges in blue.\n # ------------------------------------------------------------------\n axes = Axes(font_size=24, \n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n labels.set_color(BLUE)\n \n self.play(Create(axes), Write(labels), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. FORMULA DISPLAY: Show the integral formula at the top.\n # ------------------------------------------------------------------\n integral_formula = MathTex(\n r\"\\int_{0}^{2} x^2 \\, dx\",\n font_size=40\n ).to_edge(UP)\n \n self.play(Write(integral_formula), run_time=1)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. GRAPH PLOTTING: Plot f(x) = x^2 in white and label it.\n # ------------------------------------------------------------------\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=WHITE)\n graph_label = MathTex(r\"f(x) = x^2\", color=WHITE).next_to(graph, UR, buff=0.2)\n \n self.play(Create(graph), Write(graph_label), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. AREA HIGHLIGHTING: Highlight area under graph from x=0 to x=2.\n # ------------------------------------------------------------------\n area = axes.get_area(\n graph, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.5\n )\n \n self.play(FadeIn(area), run_time=1)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. CALCULATION DISPLAY: Step-by-step calculation below formula.\n # ------------------------------------------------------------------\n # Step 5a: Antiderivative using Power Rule\n calc_step_1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\",\n font_size=36\n ).next_to(integral_formula, DOWN, buff=0.5).align_to(integral_formula, LEFT)\n \n # Step 5b: Explicit substitution (upper^3/3 - lower^3/3)\n calc_step_2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\",\n font_size=36\n ).next_to(calc_step_1, DOWN, buff=0.3).align_to(calc_step_1, LEFT)\n \n self.play(Write(calc_step_1), run_time=1)\n self.wait(1)\n self.play(Write(calc_step_2), run_time=1)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. SIMPLIFICATION: Reveal the final numerical value.\n # ------------------------------------------------------------------\n final_result = MathTex(\n r\"= \\frac{8}{3}\",\n font_size=36,\n color=YELLOW\n ).next_to(calc_step_2, DOWN, buff=0.3).align_to(calc_step_2, LEFT)\n \n self.play(Write(final_result), run_time=1)\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # 7. CONCLUSION: Clear all visuals except the simplified final result.\n # ------------------------------------------------------------------\n elements_to_remove = VGroup(\n axes, labels, \n graph, graph_label, \n area, \n integral_formula, calc_step_1, calc_step_2\n )\n \n # Fade out everything and center the final result for emphasis\n self.play(\n FadeOut(elements_to_remove),\n final_result.animate.move_to(ORIGIN).scale(1.5),\n run_time=1.5\n )\n \n self.wait(2)\n self.play(FadeOut(final_result))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- Step 1: Display Problem ---\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem), run_time=2)\n self.wait(1)\n\n # --- Step 2: Clarify Limits ---\n limits_text = Text(\"Evaluation ranges from 0 to 2\", font_size=30)\n limits_text.next_to(problem, DOWN, buff=0.5)\n self.play(FadeIn(limits_text), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(limits_text), run_time=1)\n\n # --- Step 3: Explain Rule ---\n rule_label = Text(\"General Power Rule:\", font_size=30)\n rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n rule_group = VGroup(rule_label, rule).arrange(RIGHT, buff=0.3)\n rule_group.next_to(problem, DOWN, buff=0.7)\n \n self.play(Write(rule_label), Write(rule), run_time=2)\n self.wait(1)\n self.play(FadeOut(rule_group), run_time=1)\n\n # --- Step 4: Apply Rule ---\n application = MathTex(r\"x^3 \\rightarrow \\frac{x^4}{4}\")\n application.next_to(problem, DOWN, buff=0.7)\n self.play(Write(application), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(application), run_time=1)\n\n # --- Step 5: Simplify ---\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.move_to(problem)\n self.play(ReplacementTransform(problem.copy(), antiderivative), run_time=2)\n self.play(FadeOut(problem))\n self.wait(1)\n\n # --- Step 6: Evaluate Limits ---\n substitution = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n substitution.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(substitution), run_time=2)\n self.wait(1)\n\n # --- Step 7: Final Solution ---\n calculation = MathTex(r\"= \\frac{16}{4} - 0 = 4\")\n calculation.next_to(substitution, DOWN, buff=0.5)\n self.play(Write(calculation), run_time=2)\n self.wait(2)\n\n # --- Step 8: Conclusion ---\n final_result = MathTex(r\"4\")\n final_result.scale(2).set_color(GREEN)\n \n self.play(\n FadeOut(antiderivative),\n FadeOut(substitution),\n ReplacementTransform(calculation, final_result.move_to(ORIGIN)),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralEvaluation(Scene):\n def construct(self):\n # --- Step 1: Display Problem ---\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem), run_time=2)\n self.wait(1)\n\n # --- Step 2: Clarify Limits ---\n limits_text = Text(\"Evaluation ranges from 0 to 2\", font_size=30)\n limits_text.next_to(problem, DOWN, buff=0.5)\n self.play(FadeIn(limits_text), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(limits_text), run_time=1)\n\n # --- Step 3: Explain Rule ---\n rule_label = Text(\"General Power Rule:\", font_size=30)\n rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\")\n rule_group = VGroup(rule_label, rule).arrange(RIGHT, buff=0.3)\n rule_group.next_to(problem, DOWN, buff=0.7)\n \n self.play(Write(rule_label), Write(rule), run_time=2)\n self.wait(1)\n self.play(FadeOut(rule_group), run_time=1)\n\n # --- Step 4: Apply Rule ---\n application = MathTex(r\"x^3 \\rightarrow \\frac{x^4}{4}\")\n application.next_to(problem, DOWN, buff=0.7)\n self.play(Write(application), run_time=1.5)\n self.wait(1)\n self.play(FadeOut(application), run_time=1)\n\n # --- Step 5: Simplify ---\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.move_to(problem)\n self.play(ReplacementTransform(target_position=ORIGIN, problem.copy(), antiderivative), run_time=2)\n self.play(FadeOut(problem))\n self.wait(1)\n\n # --- Step 6: Evaluate Limits ---\n substitution = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n substitution.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(substitution), run_time=2)\n self.wait(1)\n\n # --- Step 7: Final Solution ---\n calculation = MathTex(r\"= \\frac{16}{4} - 0 = 4\")\n calculation.next_to(substitution, DOWN, buff=0.5)\n self.play(Write(calculation), run_time=2)\n self.wait(2)\n\n # --- Step 8: Conclusion ---\n final_result = MathTex(r\"4\")\n final_result.scale(2).set_color(GREEN)\n \n self.play(\n FadeOut(antiderivative),\n FadeOut(substitution),\n ReplacementTransform(calculation, final_result.move_to(ORIGIN)),\n run_time=2\n )\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Once the graph is displayed, I would like the animation to indicate the area under the curve specifically between x = 0 and x = 1 with a label showing the integral of x^2 from 0 to 1 written below the graph. Can the animation then fill this area with a gradient from blue to green while maintaining some transparency, followed by the transformation of the integral label into the exact value of the area calculated, which is 1/3, and placing this solution at the bottom of the screen? Lastly, can the animation clear the screen and display only the final solution for a brief moment before ending?", "chosen": "```python\nfrom manim import *\n\nclass IntegralAnimation(Scene):\n def construct(self):\n # 1. Display Function: Write f(x) = x^2 at the top of the screen\n func_text = MathTex(\"f(x) = x^2\")\n func_text.to_edge(UP)\n self.play(Write(func_text))\n\n # 2. Plot Graph: Plot the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2, 2, 1],\n y_range=[0, 4, 1],\n axis_config={\"include_numbers\": True}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n \n self.play(Create(axes), Create(graph))\n\n # 3 & 4. Highlight Area, Fill and Gradient: \n # Indicate area under curve between x=0 and x=1\n # Apply blue-to-green gradient with partial transparency\n area = axes.get_area(graph, x_range=[0, 1])\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_opacity(0.5)\n \n # Place a label below the graph showing the integral expression\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\")\n integral_label.next_to(axes, DOWN)\n \n self.play(FadeIn(area), Write(integral_label))\n\n # 5. Calculate and Transform: Transform label to value (1/3) and move to bottom\n result_text = MathTex(r\"\\frac{1}{3}\")\n result_text.move_to(integral_label)\n \n self.play(Transform(integral_label, result_text))\n self.play(integral_label.animate.to_edge(DOWN))\n\n # 6. Final Display: Clear screen, show only solution, then end\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area),\n run_time=1.5\n )\n \n # Center the final solution for a brief moment\n self.play(integral_label.animate.move_to(ORIGIN))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralAnimation(Scene):\n def construct(self):\n # 1. Display Function: Write f(x) = x^2 at the top of the screen\n func_text = MathTex(\"f(x) = x^2\")\n func_text.to_edge(UP)\n self.play(Write(func_text))\n\n # 2. Plot Graph: Plot the function for x ranging from -2 to 2\n axes = Axes(font_size=24, \n x_range=[-2, 2, 1],\n y_range=[0, 4, 1],\n axis_config={\"include_numbers\": True}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n \n self.play(Create(axes), Create(graph))\n\n # 3 & 4. Highlight Area, Fill and Gradient: \n # Indicate area under curve between x=0 and x=1\n # Apply blue-to-green gradient with partial transparency\n area = axes.get_area(graph, x_range=[0, 1])\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_opacity(0.5)\n \n # Place a label below the graph showing the integral expression\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\")\n integral_label.next_to(axes, DOWN)\n \n self.play(FadeIn(area), Write(integral_label))\n\n # 5. Calculate and Transform: Transform label to value (1/3) and move to bottom\n result_text = MathTex(r\"\\frac{1}{3}\")\n result_text.move_to(integral_label)\n \n self.play(Transform(integral_label, result_text))\n self.play(integral_label.animate.to_edge(DOWN))\n\n # 6. Final Display: Clear screen, show only solution, then end\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area),\n run_time=1.5\n )\n \n # Center the final solution for a brief moment\n self.play(integral_label.animate.move_to(ORIGIN))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a ManimCE scene (`DynamicAreaScene`) using `ValueTracker`, `always_redraw`, `Axes`, and `axes.get_area(...)` with zero undefined symbols.", "chosen": "```python\nfrom manim import *\n\nclass DynamicAreaScene(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-2, 6, 1]\n )\n \n # Add a function to track area under curve\n func = lambda x : 0.5*(x**2) + 1\n graph = axes.plot(func)\n \n # Show area under the curve from x=-2 to x=2\n area = axes.get_area(graph, x_range=(-2, 2))\n \n # Display labels for the bounds of integration\n label_left = MathTex(\"a\", color=RED).next_to(axes.c2p(-2, 0), DOWN, buff=0.2)\n label_right = MathTex(\"b\", color=GREEN).next_to(axes.c2p(2, 0), DOWN, buff=0.2)\n \n # Animation logic\n self.play(Create(axes), Create(graph))\n self.play(FadeIn(label_left), FadeIn(label_right))\n self.play(Write(area))\n self.wait()\n \n # Update the upper bound to x=1 and recalculate the area\n new_label_right = MathTex(\"c\", color=YELLOW).move_to(label_right.get_center())\n updated_area = axes.get_area(graph, x_range=(-2, 1))\n \n self.play(Transform(label_right, new_label_right), Transform(area, updated_area))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass DynamicAreaScene(Scene):\n def construct(self):\n # Create axes with specified ranges for x and y\n axes = Axes(\n x_range=[-2, 6],\n y_range=[-1, 7],\n x_length=8,\n y_length=6,\n tips=False,\n )\n \n # Add labels to axes\n axis_labels = axes.get_axis_labels(x_label=\"t\", y_label=\"v(t)\")\n \n # Define initial functions with their domains\n func_def_1 = lambda t: max(0, min(2*(t**2) - 4*t + 4, 7)) if -2 <= t < 2 else 0\n domain_1 = [-2, 2]\n area_1 = axes.get_area(lambda x: func_def_1(x), x_range=domain_1)\n \n func_def_2 = lambda t: max(0, min(-t**2 + 2*t + 1, 7)) if 2 <= t <= 6 else 0\n domain_2_start = 2\n domain_2_end = 6\n \n # Initialize ValueTrackers for tracking changes to the bounds of integration\n tracker_left = ValueTracker(domain_1[0])\n tracker_right = ValueTracker(domain_2_end)\n\n # Function that returns the current area based on trackers' values\n current_domain = [tracker_left.get_value(), tracker_right.get_value()]\n \n def get_current_area():\n return axes.get_area(\n lambda x: func_def_2(x),\n x_range=current_domain,\n )\n\n # Animate the creation of the axes and initial areas\n self.play(Create(axes))\n self.play(Write(axis_labels))\n self.play(FadeIn(area_1))\n \n # Display the function equation for f(t)\n func_text = MathTex(\"f(t)\", \"= \", \"t^2\", \"- 2t + 4\").to_edge(DOWN)\n self.play(Write(func_text))\n\n # Create a rectangle representing the integral limits\n rect_limit = SurroundingRectangle(VGroup(axes.n2p(current_domain[0]), axes.n2p(tracker_left.get_value())),\n color=RED, buff=-0.1)\n self.add(rect_limit)\n \n # Display the integral notation\n integral_notation = MathTex(\"\\\\int_{a}^{b}\", \"\\\\frac{d}{dt}\", \"f(t)\", \"\\\\, dt\")\n integral_notation.to_corner(UL).scale(0.7)\n self.play(Write(integral_notation))\n\n # Animation group handling both the trackable area change and the limit visual indicator\n animation_group = LaggedStart(\n UpdateFromFunc(\n area_1, \n lambda m: m.become(get_current_area()).set_color(GREEN)\n ),\n UpdateFromAlphaPoints(\n rect_limit, \n VGroup(axes.n2p([tracker_left.get_value(), tracker_left.get_value()]),\n axes.n2p([current_domain[-1], current_domain[-1]])).center().shift(RIGHT*0.1)\n .animate.move_to(axes.c2p(max(min(tracker_left.get_value(), tracker_right.get_value()), 0), 0)),\n ),\n lag_ratio=0.5\n )\n \n # Move the tracker right by updating its value smoothly over time\n tracker_left.animate.set_value(domain_2_start).add_update_callback(animation_group)\n tracker_right.animate.set_value(domain_2_end).add_update_callback(animation_group)\n \n # Play the animation group continuously until the end of the scene\n self.add(always_redraw(update_func=lambda m: m.become(get_current_area())))\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### **Representation**\n\n#### $x[n]=\\sum_{k=0}^{N-1} C_k e^{j\\frac{2\\pi}{N}kn}$\nSince the discrete complex exponential signal is periodic with respect to frequency $k$ (with a period of $N$), the summation in the series only needs to be carried out over $N$ terms within one period, rather than an infinite series.\n\n\nThe context of this section (from highest to current level):\n# Signals and Systems Course - Detailed Outline for Lecture 6 (Fourier Series)\n## Discrete Time Fourier Series (DTFS)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DTFSRepresentation(Scene):\n\n def construct(self):\n title = Text('Discrete Time Fourier Series (DTFS)', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('Representation', font_size=32, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n formula = MathTex('x[n]', '=', '\\\\sum_{k=0}^{N-1}', 'C_k', 'e^{j\\\\frac{2\\\\pi}{N}kn}')\n formula.scale(1.5)\n formula.next_to(subtitle, DOWN, buff=1.0)\n formula[2].set_color(YELLOW)\n formula[4].set_color(GREEN)\n self.play(Write(formula[0:2]))\n self.play(Write(formula[2]))\n self.play(Write(formula[3:]))\n self.wait(1)\n explanation = VGroup(Tex('Since the discrete complex exponential signal is periodic'), Tex('with respect to frequency $k$ (with a period of $N$),'), Tex('the summation in the series only needs to be carried out'), Tex('over $N$ terms within one period, rather than an infinite series.')).arrange(DOWN, aligned_edge=LEFT)\n explanation.scale(0.8)\n explanation.next_to(formula, DOWN, buff=1.0)\n self.play(FadeIn(explanation[0:2], shift=UP))\n self.play(Indicate(formula[4], color=GREEN, scale_factor=1.1))\n self.wait(1)\n self.play(FadeIn(explanation[2:], shift=UP))\n self.play(Indicate(formula[2], color=YELLOW, scale_factor=1.1))\n self.wait(2)\n self.play(FadeOut(Group(title, subtitle, formula, explanation)))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DTFSRepresentation(Scene):\n\n def construct(self):\n title = Text('Discrete Time Fourier Series (DTFS)', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n subtitle = Text('Representation', font_size=32, color=BBLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(1)\n formula = MathTex('x[n]', '=', '\\\\sum_{k=0}^{N-1}', 'C_k', 'e^{j\\\\frac{2\\\\pi}{N}kn}')\n formula.scale(1.5)\n formula.next_to(subtitle, DOWN, buff=1.0)\n formula[2].set_color(YELLOW)\n formula[4].set_color(GREEN)\n self.play(Write(formula[0:2]))\n self.play(Write(formula[2]))\n self.play(Write(formula[3:]))\n self.wait(1)\n explanation = VGroup(Tex('Since the discrete complex exponential signal is periodic'), Tex('with respect to frequency $k$ (with a period of $N$),'), Tex('the summation in the series only needs to be carried out'), Tex('over $N$ terms within one period, rather than an infinite series.')).arrange(DOWN, aligned_edge=LEFT)\n explanation.scale(0.8)\n explanation.next_to(formula, DOWN, buff=1.0)\n self.play(FadeIn(explanation[0:2], shift=UP))\n self.play(Indicate(formula[4], color=GREEN, scale_factor=1.1))\n self.wait(1)\n self.play(FadeIn(explanation[2:], shift=UP))\n self.play(Indicate(formula[2], color=YELLOW, scale_factor=1.1))\n self.wait(2)\n self.play(FadeOut(Group(title, subtitle, formula, explanation)))\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### All pumping results remain in the language\nRegardless of how many times $y$ is repeated (including 0 times, i.e., removing $y$), the generated string must still belong to the original language $L$.\n\n\nThe context of this section (from highest to current level):\n# 7. Closure Properties and the Pumping Lemma for Regular Languages\n## Formal Statement of the Pumping Lemma for Regular Languages\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PumpingLemmaResults(Scene):\n\n def construct(self):\n title = Title('All Pumping Results Remain in the Language')\n self.play(Write(title))\n desc = Tex('Regardless of how many times $y$ is repeated\\\\\\\\', '(including 0 times, i.e., removing $y$),\\\\\\\\', 'the generated string must still belong to the original language $L$.').scale(0.75).next_to(title, DOWN, buff=0.4)\n self.play(FadeIn(desc, shift=DOWN))\n self.wait(1)\n condition = MathTex('\\\\forall i \\\\ge 0, \\\\quad', 'x', 'y', '^i', 'z', '\\\\in L').scale(1.1)\n condition[1].set_color(BLUE)\n condition[2].set_color(YELLOW)\n condition[4].set_color(GREEN)\n condition.next_to(desc, DOWN, buff=0.5)\n box = SurroundingRectangle(condition, color=WHITE, buff=0.2)\n self.play(Write(condition))\n self.play(Create(box))\n self.wait(1)\n eq0 = MathTex('i = 0 :\\\\quad', 'x', 'z', '\\\\in L')\n eq0[1].set_color(BLUE)\n eq0[2].set_color(GREEN)\n eq1 = MathTex('i = 1 :\\\\quad', 'x', 'y', 'z', '\\\\in L')\n eq1[1].set_color(BLUE)\n eq1[2].set_color(YELLOW)\n eq1[3].set_color(GREEN)\n eq2 = MathTex('i = 2 :\\\\quad', 'x', 'y', 'y', 'z', '\\\\in L')\n eq2[1].set_color(BLUE)\n eq2[2].set_color(YELLOW)\n eq2[3].set_color(YELLOW)\n eq2[4].set_color(GREEN)\n eq3 = MathTex('i = 3 :\\\\quad', 'x', 'y', 'y', 'y', 'z', '\\\\in L')\n eq3[1].set_color(BLUE)\n eq3[2].set_color(YELLOW)\n eq3[3].set_color(YELLOW)\n eq3[4].set_color(YELLOW)\n eq3[5].set_color(GREEN)\n dots = MathTex('\\\\vdots')\n examples = VGroup(eq0, eq1, eq2, eq3, dots).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n examples.scale(0.9)\n examples.next_to(box, DOWN, buff=0.4)\n self.play(FadeIn(eq1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq0, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq2, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq3, shift=RIGHT))\n self.wait(1)\n self.play(Write(dots))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PumpingLemmaResults(Scene):\n\n def construct(self):\n title = Title('All Pumping Results Remain in the Language')\n self.play(Write(title))\n desc = Tex('Regardless of how many times $y$ is repeated\\\\\\\\', '(including 0 times, i.e., removing $y$),\\\\\\\\', 'the generated string must still belong to the original language $L$.').scale(0.75).next_to(title, DOWN, buff=0.4)\n self.play(FadeIn(desc, shift=DOWN))\n self.wait(1)\n condition = MathTex('\\\\forall i \\\\ge 0, \\\\quad', 'x', 'y', '^i', 'z', '\\\\in L').scale(1.1)\n condition[1].set_color(BLUE)\n condition[2].set_color(YELLOW)\n condition[4].set_color(GREEN)\n condition.next_to(desc, DOWN, buff=0.5)\n box = SurroundingRectangle(condition, color=WHITE, buff=0.2)\n self.play(Write(condition))\n self.play(Create(box))\n self.wait(1)\n eq0 = MathTex('i = 0 :\\\\quad', 'x', 'z', '\\\\in L')\n eq0[1].set_color(BLUE)\n eq0[2].set_color(GREEN)\n eq1 = MathTex('i = 1 :\\\\quad', 'x', 'y', 'z', '\\\\in L')\n eq1[1].set_color(BLUE)\n eq1[2].set_color(YELLOW)\n eq1[3].set_color(GREEN)\n eq2 = MathTex('i = 2 :\\\\quad', 'x', 'y', 'y', 'z', '\\\\in L')\n eq2[1].set_color(BLUE)\n eq2[2].set_color(YELLOW)\n eq2[3].set_color(YELLOW)\n eq2[4].set_color(GREEN)\n eq3 = MathTex('i = 3 :\\\\quad', 'x', 'y', 'y', 'y', 'z', '\\\\in L')\n eq3[1].set_color(BLUE)\n eq3[2].set_color(YELLOW)\n eq3[3].set_color(YELLOW)\n eq3[4].set_color(YELLOW)\n eq3[5].set_color(GREEN)\n dots = MathTex('\\\\vdots')\n examples = VGroup(eq0, eq1, eq2, eq3, dots).arrange(DOWN, aligned_edge=LEFT, buff=0.25)\n examples.scale(0.9)\n examples.next_to(box, DOWN, buff=0.4)\n self.play(FadeIn(eq1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq0, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq2, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(eq3, shift=RIGHT))\n self.wait(1)\n self.play(Write(dots))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the animation that maintains all original features while adding explanatory text, a mathematical formula transformation, and a more dynamic sequence:\n\nThe enhanced animation begins by displaying the text \"animate.match_points\" at the top of the screen while simultaneously introducing a red circle (right side) and blue square (left side) with their respective fill properties. As the circle transforms into a square using match_points, a LaTeX text box appears below explaining \"Morphing preserves area: πr² → s²\" while the formula itself animates from the circle's area formula to the square's area formula. During the transformation, dashed construction lines appear briefly to show how corresponding points are matched between the shapes. After the morphing completes, both shapes pulse gently to emphasize the successful transformation before fading out, while the explanatory text remains visible for an additional second before also fading away. The entire sequence maintains the original timing but adds these educational elements to better demonstrate the mathematical concept behind the point-matching transformation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedMatchPoints(Scene):\n def construct(self):\n # Create shapes\n circle = Circle(radius=1.5, color=RED, fill_opacity=0.5)\n square = Square(side_length=2.5, color=BLUE, fill_opacity=0.5)\n \n # Position shapes\n circle.shift(RIGHT * 2)\n square.shift(LEFT * 2)\n \n # Add title\n title = Text(\"animate.match_points\", font_size=24).to_edge(UP)\n \n # Add explanation text\n explanation = Tex(\"Morphing preserves area: $\\\\pi r^2 \\\\rightarrow s^2$\", font_size=24)\n explanation.next_to(title, DOWN, buff=0.5)\n \n # Add area formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\", font_size=24).next_to(circle, DOWN)\n square_formula = MathTex(\"A = s^2\", font_size=24).next_to(square, DOWN)\n \n # Animation sequence\n self.play(\n Write(title),\n Create(circle),\n Create(square),\n Write(explanation),\n Write(circle_formula),\n Write(square_formula)\n )\n self.wait(0.5)\n \n # Show construction lines\n construction_lines = VGroup()\n for i in range(8):\n line = DashedLine(\n circle.point_from_proportion(i/8),\n square.point_from_proportion(i/8),\n color=YELLOW,\n stroke_width=2\n )\n construction_lines.add(line)\n \n self.play(Create(construction_lines), run_time=1)\n self.wait(0.5)\n self.play(FadeOut(construction_lines), run_time=0.5)\n \n # Transform circle to square\n self.play(circle.animate.match_points(square), run_time=2)\n \n # Pulse effect\n self.play(\n circle.animate.scale(1.1),\n square.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.1),\n square.animate.scale(1/1.1),\n run_time=0.5\n )\n \n # Fade out\n self.play(\n FadeOut(circle),\n FadeOut(square),\n FadeOut(circle_formula),\n FadeOut(square_formula),\n run_time=1\n )\n self.wait(1)\n self.play(FadeOut(title), FadeOut(explanation))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedMatchPoints(Scene):\n def construct(self):\n # Create shapes\n circle = Circle(radius=1.5, color=RED, fill_opacity=0.5)\n square = Square(side_length=2.5, color=BBLUE, fill_opacity=0.5)\n \n # Position shapes\n circle.shift(RIGHT * 2)\n square.shift(LEFT * 2)\n \n # Add title\n title = Text(\"animate.match_points\", font_size=24).to_edge(UP)\n \n # Add explanation text\n explanation = Tex(\"Morphing preserves area: $\\\\pi r^2 \\\\rightarrow s^2$\", font_size=24)\n explanation.next_to(title, DOWN, buff=0.5)\n \n # Add area formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\", font_size=24).next_to(circle, DOWN)\n square_formula = MathTex(\"A = s^2\", font_size=24).next_to(square, DOWN)\n \n # Animation sequence\n self.play(\n Write(title),\n Create(circle),\n Create(square),\n Write(explanation),\n Write(circle_formula),\n Write(square_formula)\n )\n self.wait(0.5)\n \n # Show construction lines\n construction_lines = VGroup()\n for i in range(8):\n line = DashedLine(\n circle.point_from_proportion(i/8),\n square.point_from_proportion(i/8),\n color=YELLOW,\n stroke_width=2\n )\n construction_lines.add(line)\n \n self.play(Create(construction_lines), run_time=1)\n self.wait(0.5)\n self.play(FadeOut(construction_lines), run_time=0.5)\n \n # Transform circle to square\n self.play(circle.animate.match_points(square), run_time=2)\n \n # Pulse effect\n self.play(\n circle.animate.scale(1.1),\n square.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.1),\n square.animate.scale(1/1.1),\n run_time=0.5\n )\n \n # Fade out\n self.play(\n FadeOut(circle),\n FadeOut(square),\n FadeOut(circle_formula),\n FadeOut(square_formula),\n run_time=1\n )\n self.wait(1)\n self.play(FadeOut(title), FadeOut(explanation))\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a ManimCE scene (`VectorFieldFlow`) with `Axes(x_axis_config={'include_tip': True})` and `Arrow` vectors using a 2D `(u, v)` vector function.", "chosen": "```python\nfrom manim import *\n\nclass VectorFieldFlow(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-3, 3],\n x_length=6,\n y_length=6,\n tips=True\n ).add_coordinates()\n \n self.add(axes)\n self.wait(1)\n\n # Define the vector field function u=x^2, v=y^2\n def func(pos):\n x, y = pos[:2]\n return np.array([\n max(-0.8 + abs(x) ** 2, 0),\n max(-0.8 + abs(y) ** 2, 0),\n 0\n ])\n \n # Generate arrows representing the flow of the vector field\n arrow_group = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n start = np.array([i, j, 0])\n end = start + func(start)\n if not any(abs(end - start) < 0.1): # Filter very small vectors\n arr = Arrow(start, end, color=blue, buff=0).set_opacity(0.8)\n arrow_group.add(arr)\n \n self.play(Create(arrow_group), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass VectorFieldFlow(Scene):\n def construct(self):\n # Display axes with included tips for visual clarity\n axes = Axes(\n x_range=[-6, 6, 2],\n y_range=[-3, 3, 1],\n x_length=8,\n y_length=4,\n axis_config={\"color\": BLUE},\n x_axis_config={\"include_tip\": True}, \n ).shift(LEFT * 2)\n\n # Define a simple 2D vector field u = x^2 + y, v = y^2 - x\n def vector_func(point):\n x, y = point[:2]\n u = x**2 + y\n v = y**2 - x\n return np.array([u, v, 0]) * 0.1\n\n # Create the vector field by applying the func to points along the gridlines\n vectors = ArrowsBetweenPoints(\n start_positions=axes.c2p(np.arange(-5, 5, 1), np.arange(-2, 2, 0.5)),\n end_positions=vector_func(axes.c2p(np.arange(-5, 5, 1), np.arange(-2, 2, 0.5))),\n color=GREEN,\n max_width=0.3,\n min_width=0.2,\n density=1.0,\n )\n\n self.add(axes)\n self.play(Create(vectors))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 illustrates the principles of circular motion and tension involved, starting with the general equation of motion under gravity, explaining the relevant terms, then transformin\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: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0442(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_equivalentfractions()\n self.clear_stage()\n self.act_3_samplingtheorem()\n\n def act_1_areaundercurve(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n\n def act_2_equivalentfractions(self):\n self.camera.background_color = WHITE\n\n # Create fraction text objects with large font size for readability\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=72)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=72)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=72)\n\n # Arrange fractions horizontally with sufficient spacing for arrows\n fractions = VGroup(f1, f2, f3)\n fractions.arrange(RIGHT, buff=3.0)\n fractions.move_to(ORIGIN)\n\n # Create blue arrows between fractions\n arrow1 = Arrow(\n start=f1.get_right() + RIGHT * 0.2,\n end=f2.get_left() - RIGHT * 0.2,\n color=BLUE\n )\n arrow2 = Arrow(\n start=f2.get_right() + RIGHT * 0.2,\n end=f3.get_left() - RIGHT * 0.2,\n color=BLUE\n )\n\n # Create blue labels above the 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(f1))\n\n # 2. Grow arrow from 1/2 to 2/4 and display label \"times 2\"\n self.play(GrowArrow(arrow1), Write(label1))\n\n # 3. Write the fraction 2/4\n self.play(Write(f2))\n\n # 4. Grow arrow from 2/4 to 4/8 and display label \"times 4\"\n self.play(GrowArrow(arrow2), Write(label2))\n\n # 5. Write the fraction 4/8\n self.play(Write(f3))\n\n # 6. Pause briefly with all elements visible\n self.wait(1)\n\n # 7. Fade out the entire scene\n self.play(FadeOut(*self.mobjects))\n\n def act_3_samplingtheorem(self):\n title = Text('Nyquist Sampling Theorem', 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 thm_text = Text('To recover an analog signal without distortion:', font_size=28)\n thm_text.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(thm_text, run_time=1))\n formula = MathTex('f_s \\\\ge 2f_{max}', font_size=52, color=YELLOW)\n formula.next_to(thm_text, DOWN, buff=0.5)\n box = SurroundingRectangle(formula, color=BLUE, buff=0.25)\n self.play(Write(formula, run_time=1))\n self.play(Create(box, run_time=0.8))\n self.wait(0.5)\n prac_text = Text('Practical Selection: Slightly higher than Nyquist rate', font_size=28, color=GREEN)\n prac_text.next_to(box, DOWN, buff=0.8)\n self.play(Write(prac_text, run_time=1))\n cd_text1 = MathTex('\\\\text{CD Audio } f_{max} \\\\approx 20\\\\text{ kHz}', font_size=32)\n cd_text2 = MathTex('\\\\rightarrow \\\\text{Nyquist Rate } = 40\\\\text{ kHz}', font_size=32)\n cd_text3 = MathTex('\\\\rightarrow \\\\text{Chosen } f_s = 44.1\\\\text{ kHz}', font_size=32, color=ORANGE)\n cd_group = VGroup(cd_text1, cd_text2, cd_text3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n cd_group.next_to(prac_text, DOWN, buff=0.4)\n self.play(FadeIn(cd_text1, shift=DOWN * 0.2, run_time=0.8))\n self.play(FadeIn(cd_text2, shift=DOWN * 0.2, run_time=0.8))\n self.play(FadeIn(cd_text3, shift=DOWN * 0.2, run_time=0.8))\n self.wait(1.5)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0442(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_equivalentfractions()\n self.clear_stage()\n self.act_3_samplingtheorem()\n\n def act_1_areaundercurve(self):\n axes = Axes(font_size=24, \n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n axis_config={\"color\": BLUE},\n )\n\n curve = axes.plot(lambda x: 0.1 * x**2, color=GREEN)\n area = axes.get_area(curve, x_range=(0, 4), color=YELLOW, opacity=0.5)\n\n problem = MathTex(r\"A=\\int_{0}^{4} 0.1x^2 \\,dx\", color=WHITE)\n problem.to_corner(UL)\n\n self.play(Write(problem))\n self.wait(1)\n\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n self.play(FadeIn(area, scale=0.5))\n self.wait(1)\n\n solution = MathTex(r\"A=\\dfrac{1}{3}0.1\\cdot 4^3\", color=WHITE)\n solution.next_to(problem, DOWN)\n\n self.play(ReplacementTransform(area, solution))\n self.wait(1)\n\n self.play(FadeOut(axes), FadeOut(curve), FadeOut(solution))\n self.wait(1)\n\n def act_2_equivalentfractions(self):\n self.camera.background_color = WHITE\n\n # Create fraction text objects with large font size for readability\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=72)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=72)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=72)\n\n # Arrange fractions horizontally with sufficient spacing for arrows\n fractions = VGroup(f1, f2, f3)\n fractions.arrange(RIGHT, buff=3.0)\n fractions.move_to(ORIGIN)\n\n # Create blue arrows between fractions\n arrow1 = Arrow(\n start=f1.get_right() + RIGHT * 0.2,\n end=f2.get_left() - RIGHT * 0.2,\n color=BLUE\n )\n arrow2 = Arrow(\n start=f2.get_right() + RIGHT * 0.2,\n end=f3.get_left() - RIGHT * 0.2,\n color=BLUE\n )\n\n # Create blue labels above the 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(f1))\n\n # 2. Grow arrow from 1/2 to 2/4 and display label \"times 2\"\n self.play(GrowArrow(arrow1), Write(label1))\n\n # 3. Write the fraction 2/4\n self.play(Write(f2))\n\n # 4. Grow arrow from 2/4 to 4/8 and display label \"times 4\"\n self.play(GrowArrow(arrow2), Write(label2))\n\n # 5. Write the fraction 4/8\n self.play(Write(f3))\n\n # 6. Pause briefly with all elements visible\n self.wait(1)\n\n # 7. Fade out the entire scene\n self.play(FadeOut(*self.mobjects))\n\n def act_3_samplingtheorem(self):\n title = Text('Nyquist Sampling Theorem', 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 thm_text = Text('To recover an analog signal without distortion:', font_size=28)\n thm_text.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(thm_text, run_time=1))\n formula = MathTex('f_s \\\\ge 2f_{max}', font_size=52, color=YELLOW)\n formula.next_to(thm_text, DOWN, buff=0.5)\n box = SurroundingRectangle(formula, color=BLUE, buff=0.25)\n self.play(Write(formula, run_time=1))\n self.play(Create(box, run_time=0.8))\n self.wait(0.5)\n prac_text = Text('Practical Selection: Slightly higher than Nyquist rate', font_size=28, color=GREEN)\n prac_text.next_to(box, DOWN, buff=0.8)\n self.play(Write(prac_text, run_time=1))\n cd_text1 = MathTex('\\\\text{CD Audio } f_{max} \\\\approx 20\\\\text{ kHz}', font_size=32)\n cd_text2 = MathTex('\\\\rightarrow \\\\text{Nyquist Rate } = 40\\\\text{ kHz}', font_size=32)\n cd_text3 = MathTex('\\\\rightarrow \\\\text{Chosen } f_s = 44.1\\\\text{ kHz}', font_size=32, color=ORANGE)\n cd_group = VGroup(cd_text1, cd_text2, cd_text3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n cd_group.next_to(prac_text, DOWN, buff=0.4)\n self.play(FadeIn(cd_text1, shift=DOWN * 0.2, run_time=0.8))\n self.play(FadeIn(cd_text2, shift=DOWN * 0.2, run_time=0.8))\n self.play(FadeIn(cd_text3, shift=DOWN * 0.2, run_time=0.8))\n self.wait(1.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I would like to create an animated educational video that visually demonstrates the graph of the cosine function and its derivative and antiderivative. The animation should have the following features:\n\n1. Start by showcasing the cosine graph with proper axes labeled, ranging from -4 to 4 on the x-axis and -2 to 2 on the y-axis. The axes should be in blue color.\n\n2. Label the cosine graph with the mathematical notation '\\cos(x)'. The actual graph should be in white color.\n\n3. After displaying the cosine graph for a short time, introduce its derivative. The derivative graph should be in green color and labeled accordingly.\n\n4. Next, I want to show the antiderivative of the cosine function. Transform the original cosine graph into the antiderivative, display it in pink color, and update the label.\n\n5. Once the graphs have been shown, clear the screen and conclude the video with a textual message saying \"This is the graph of cosine and its derivatives\" on the screen, ensuring that the text is easily readable.\n\n6. The video should allow for short pauses so viewers can comprehend each section before moving on to the next.\n\nPlease create this animation in a way that those without knowledge of advanced mathematics or coding can understand and appreciate the relationships between the cosine function and its derivative and antiderivative.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass CosineCalculusScene(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Create and Display Axes\n # ------------------------------------------------------------------\n # Define axes with x ranging from -4 to 4 and y from -2 to 2.\n # Set the axis lines to Blue as requested.\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 2, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": [-4, -2, 0, 2, 4]},\n y_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n )\n \n # Add coordinate numbers and standard 'x' and 'y' labels for clarity.\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Animate the creation of the axes and labels.\n self.play(Create(axes), Write(axes_labels))\n # Short pause to let viewers orient themselves with the coordinate system.\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Plot the Cosine Function\n # ------------------------------------------------------------------\n # Create the graph for cos(x). Color is White.\n # We use numpy (np) for the mathematical function evaluation.\n cos_graph = axes.plot(lambda x: np.cos(x), color=WHITE)\n \n # Create the label for the function using LaTeX formatting.\n cos_label = MathTex(r\"\\cos(x)\", color=WHITE).next_to(axes, UR, buff=0.5)\n \n # Animate the drawing of the cosine curve and its label.\n self.play(Create(cos_graph), Write(cos_label))\n # Pause to allow viewers to recognize the standard cosine wave shape.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Introduce the Derivative\n # ------------------------------------------------------------------\n # The derivative of cos(x) is -sin(x).\n # Create the graph for the derivative. Color is Green.\n deriv_graph = axes.plot(lambda x: -np.sin(x), color=GREEN)\n \n # Label explicitly identifies this as the derivative.\n deriv_label = MathTex(r\"\\frac{d}{dx}\\cos(x) = -\\sin(x)\", color=GREEN).next_to(axes, DR, buff=0.5)\n \n # Animate the appearance of the derivative graph alongside the original.\n self.play(Create(deriv_graph), Write(deriv_label))\n # Pause to compare the slope of the cosine wave with the value of the derivative.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Show the Antiderivative\n # ------------------------------------------------------------------\n # The antiderivative (integral) of cos(x) is sin(x).\n # Create the target graph for the transformation. Color is Pink.\n antideriv_graph = axes.plot(lambda x: np.sin(x), color=PINK)\n \n # Create the updated label reflecting the integration operation.\n antideriv_label = MathTex(r\"\\int \\cos(x) \\, dx = \\sin(x)\", color=PINK).next_to(axes, UL, buff=0.5)\n \n # Transform the original white cosine graph into the pink antiderivative graph.\n # This visually demonstrates the relationship between the function and its integral.\n # We use ReplacementTransform to morph the curve and update the label to match.\n self.play(\n ReplacementTransform(cos_graph, antideriv_graph),\n ReplacementTransform(cos_label, antideriv_label),\n run_time=2\n )\n # Pause to observe the phase shift from cosine to sine.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Conclusion\n # ------------------------------------------------------------------\n # Clear all mathematical objects from the screen to focus on the final message.\n self.play(\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(deriv_graph),\n FadeOut(deriv_label),\n FadeOut(antideriv_graph),\n FadeOut(antideriv_label)\n )\n \n # Display the concluding textual message.\n # Using 'Text' instead of 'MathTex' for standard sentence readability.\n # Font size is increased for easy reading.\n conclusion_text = Text(\n \"This is the graph of cosine and its derivatives\",\n font_size=40,\n color=WHITE\n ).center()\n \n # Write the text to the screen.\n self.play(Write(conclusion_text))\n # Final pause to ensure the message is read.\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass CosineCalculusScene(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Create and Display Axes\n # ------------------------------------------------------------------\n # Define axes with x ranging from -4 to 4 and y from -2 to 2.\n # Set the axis lines to Blue as requested.\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 2, 1],\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": [-4, -2, 0, 2, 4]},\n y_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n )\n \n # Add coordinate numbers and standard 'x' and 'y' labels for clarity.\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Animate the creation of the axes and labels.\n self.play(Create(axes), Write(axes_labels))\n # Short pause to let viewers orient themselves with the coordinate system.\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Plot the Cosine Function\n # ------------------------------------------------------------------\n # Create the graph for cos(x). Color is White.\n # We use numpy (np) for the mathematical function evaluation.\n cos_graph = axes.plot(lambda x: np.cos(x), color=WHITE)\n \n # Create the label for the function using LaTeX formatting.\n cos_label = MathTex(r\"\\cos(x)\", color=WHITE).next_to(axes, UR, buff=0.5)\n \n # Animate the drawing of the cosine curve and its label.\n self.play(Create(cos_graph), Write(cos_label))\n # Pause to allow viewers to recognize the standard cosine wave shape.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Introduce the Derivative\n # ------------------------------------------------------------------\n # The derivative of cos(x) is -sin(x).\n # Create the graph for the derivative. Color is Green.\n deriv_graph = axes.plot(lambda x: -np.sin(x), color=GREEN)\n \n # Label explicitly identifies this as the derivative.\n deriv_label = MathTex(r\"\\frac{d}{dx}\\cos(x) = -\\sin(x)\", color=GREEN).next_to(axes, DR, buff=0.5)\n \n # Animate the appearance of the derivative graph alongside the original.\n self.play(Create(deriv_graph), Write(deriv_label))\n # Pause to compare the slope of the cosine wave with the value of the derivative.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Show the Antiderivative\n # ------------------------------------------------------------------\n # The antiderivative (integral) of cos(x) is sin(x).\n # Create the target graph for the transformation. Color is Pink.\n antideriv_graph = axes.plot(lambda x: np.sin(x), color=PINK)\n \n # Create the updated label reflecting the integration operation.\n antideriv_label = MathTex(r\"\\int \\cos(x) \\, dx = \\sin(x)\", color=PINK).next_to(axes, UL, buff=0.5)\n \n # Transform the original white cosine graph into the pink antiderivative graph.\n # This visually demonstrates the relationship between the function and its integral.\n # We use ReplacementTransform to morph the curve and update the label to match.\n self.play(\n ReplacementTransform(target_position=ORIGIN, cos_graph, antideriv_graph),\n ReplacementTransform(cos_label, antideriv_label),\n run_time=2\n )\n # Pause to observe the phase shift from cosine to sine.\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Conclusion\n # ------------------------------------------------------------------\n # Clear all mathematical objects from the screen to focus on the final message.\n self.play(\n FadeOut(axes),\n FadeOut(axes_labels),\n FadeOut(deriv_graph),\n FadeOut(deriv_label),\n FadeOut(antideriv_graph),\n FadeOut(antideriv_label)\n )\n \n # Display the concluding textual message.\n # Using 'Text' instead of 'MathTex' for standard sentence readability.\n # Font size is increased for easy reading.\n conclusion_text = Text(\n \"This is the graph of cosine and its derivatives\",\n font_size=40,\n color=WHITE\n ).center()\n \n # Write the text to the screen.\n self.play(Write(conclusion_text))\n # Final pause to ensure the message is read.\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding significant new elements: \n\nThe animation begins with a **green square** being drawn and filled, followed by its smooth transformation into a **blue circle** with a matching fill opacity. As the circle appears, a **LaTeX formula** (e.g., \\(A = \\pi r^2\\)) materializes above it, dynamically scaling to emphasize the area relationship between squares and circles. The circle then pulses with an **\"Indicate\"** effect, while a **text label** (\"Circle Area Formula\") fades in below it. Next, the circle morphs into a **regular pentagon** (purple, with fill) to demonstrate another geometric transition, accompanied by a new formula (\\(A = \\frac{1}{4} \\sqrt{5(5 + 2\\sqrt{5})} \\cdot s^2\\)) appearing. Finally, the pentagon **fades out**, leaving behind a lingering **trail of fading dots** that trace its vertices, creating a visually striking exit. This expanded sequence reinforces geometric concepts while adding depth through formulas, labels, and additional shape transformations.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial square\n square = Square(color=GREEN, fill_opacity=0.5)\n self.play(Create(square), run_time=2)\n self.play(square.animate.set_fill(GREEN, opacity=0.5), run_time=1)\n self.wait(1)\n\n # Transform square to circle with formula\n circle = Circle(color=BLUE, fill_opacity=0.5)\n formula = MathTex(\"A = \\\\pi r^2\").scale(1.5).to_edge(UP)\n self.play(Transform(square, circle), run_time=2)\n self.play(Write(formula), run_time=1.5)\n self.play(Indicate(circle), run_time=1)\n \n # Add label below circle\n label = Text(\"Circle Area Formula\").next_to(circle, DOWN)\n self.play(FadeIn(label), run_time=1)\n self.wait(1.5)\n\n # Transform circle to pentagon with new formula\n pentagon = RegularPolygon(n=5, color=PURPLE, fill_opacity=0.5)\n pentagon_formula = MathTex(\n \"A = \\\\frac{1}{4} \\\\sqrt{5(5 + 2\\\\sqrt{5})} \\\\cdot s^2\"\n ).scale(1.2).to_edge(UP)\n self.play(\n Transform(square, pentagon),\n Transform(formula, pentagon_formula),\n FadeOut(label),\n run_time=2\n )\n self.wait(2)\n\n # Fade out pentagon with vertex trail\n dots = VGroup(*[Dot(point, color=YELLOW) for point in pentagon.get_vertices()])\n self.play(FadeIn(dots), run_time=0.5)\n self.play(\n FadeOut(square),\n FadeOut(formula),\n *[FadeOut(dot) for dot in dots],\n run_time=2\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial square\n square = Square(color=GREEN, fill_opacity=0.5)\n self.play(Create(square), run_time=2)\n self.play(square.animate.set_fill(GREEN, opacity=0.5), run_time=1)\n self.wait(1)\n\n # Transform square to circle with formula\n circle = Circle(color=BBLUE, fill_opacity=0.5)\n formula = MathTex(\"A = \\\\pi r^2\").scale(1.5).to_edge(UP)\n self.play(Transform(square, circle), run_time=2)\n self.play(Write(formula), run_time=1.5)\n self.play(Indicate(circle), run_time=1)\n \n # Add label below circle\n label = Text(\"Circle Area Formula\").next_to(circle, DOWN)\n self.play(FadeIn(label), run_time=1)\n self.wait(1.5)\n\n # Transform circle to pentagon with new formula\n pentagon = RegularPolygon(n=5, color=PURPLE, fill_opacity=0.5)\n pentagon_formula = MathTex(\n \"A = \\\\frac{1}{4} \\\\sqrt{5(5 + 2\\\\sqrt{5})} \\\\cdot s^2\"\n ).scale(1.2).to_edge(UP)\n self.play(\n Transform(square, pentagon),\n Transform(formula, pentagon_formula),\n FadeOut(label),\n run_time=2\n )\n self.wait(2)\n\n # Fade out pentagon with vertex trail\n dots = VGroup(*[Dot(point, color=YELLOW) for point in pentagon.get_vertices()])\n self.play(FadeIn(dots), run_time=0.5)\n self.play(\n FadeOut(square),\n FadeOut(formula),\n *[FadeOut(dot) for dot in dots],\n run_time=2\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the animation that maintains all original features while adding significant new elements: \n\nThe enhanced animation begins by constructing the original **MathOperationLayer**, displaying a mathematical operation (+, -, *, /) within a blue-stroked circle, which highlights in orange during activation. To this, we introduce a **dynamic input-output visualization**: as the operation activates, two animated input values (represented as labeled circles) flow into the operation node, while the result emerges as an output circle, with the calculation displayed as a formula (e.g., \"3 + 5 = 8\") above the node. Additionally, we include an **interactive activation function plot**—when the operation executes, the corresponding activation function (e.g., ReLU, Sigmoid) animates alongside the result, showing how the output is transformed. The animation concludes with the operation node fading back to its default state while the formula and activation plot linger briefly for clarity, reinforcing the mathematical relationship between inputs, operation, and activation. This enhancement makes the layer’s function more intuitive by visualizing both the arithmetic process and its subsequent nonlinear transformation.", "chosen": "```python\nimport numpy as np\n\nfrom manim import *\n\nclass EnhancedMathOpScene(Scene):\n def construct(self):\n\n # Create Operation Node\n op_node = Circle(radius=0.6).set_stroke(color=BLUE)\n op_text = Text(\"+\", font_size=40).move_to(op_node.get_center())\n \n self.play(Create(op_node))\n self.play(Write(op_text))\n\n # Animate Input Circles\n left_input = Dot(point=np.array([1.5, 0, 0]), color=YELLOW).scale(0.7)\n right_input = Dot(point=np.array([-1.5, 0, 0]), color=YELLOW).scale(0.7)\n\n self.play(FadeIn(left_input))\n self.play(FadeIn(right_input))\n\n # Display Calculation Formula\n calc_formula = MathTex(\"3 + 5 = 8\").to_edge(UP)\n self.play(Write(calc_formula))\n\n # Animate Activation Plot (ReLU example)\n axes = Axes(\n x_range=[-1, 6],\n y_range=[-1, 6],\n x_length=7,\n y_length=5\n ).shift(DOWN * 2.5)\n\n relu_curve = axes.plot(lambda x: max(x, 0), color=GREEN)\n relu_label = MathTex(\"f(x)=\\\\text{ReLU}(x)\").next_to(axes, DOWN)\n\n self.add(axes, relu_curve, relu_label)\n\n # Highlight Result Value\n result_circle = Dot(point=np.array([0, 0, 0]), color=PURPLE).scale(0.7)\n self.play(FadeIn(result_circle))\n\n # Final Fade Out Sequence\n final_group = VGroup(\n op_node, op_text, \n left_input, right_input, \n calc_formula, \n axes, relu_curve, relu_label,\n result_circle\n )\n\n self.wait()\n self.play(FadeOut(final_group))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedMathOperationScene(Scene):\n def construct(self):\n # Create Math Operation Layer\n math_op_circle = Circle(radius=1.5, color=BLUE)\n plus_sign = MathTex(\"+\").scale(2).move_to(math_op_circle.get_center())\n \n self.play(Create(math_op_circle))\n self.play(Write(plus_sign))\n self.wait(1)\n\n # Highlight on Activation\n active_color = ORANGE\n highlight_path = VMobject()\n highlight_path.set_points_as_corners([math_op_circle.point_from_proportion(i/6) for i in range(7)])\n highlight_path.set_stroke(active_color, width=12, opacity=0.5)\n \n self.add(highlight_path)\n self.play(\n math_op_circle.animate.set_stroke(color=active_color),\n plus_sign.animate.set_color(active_color),\n run_time=1.5,\n )\n self.wait(0.5)\n self.play(\n math_op_circle.animate.set_stroke(width=4),\n plus_sign.animate.scale(0.7),\n run_time=0.5\n )\n\n # Dynamic Input-Output Visualization\n # Inputs\n left_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"3\", font_size=24)).arrange(DOWN)\n right_input = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"5\", font_size=24)).arrange(DOWN)\n inputs_group = VGroup(left_input.shift(LEFT*2.5), right_input.shift(RIGHT*2.5))\n\n # Result\n result_circle = VGroup(Circle(radius=0.5, fill_opacity=0.3, stroke_width=2), Text(\"8\", font_size=24, color=YELLOW)).arrange(DOWN)\n formula_text = MathTex(\"3 + 5 = 8\").to_edge(UP)\n\n # Animate inputs entering the operation and forming the result\n self.play(FadeIn(inputs_group), Write(formula_text), run_time=1.5)\n self.play(MoveAlongPath(left_input, Line(start=inputs_group[0].get_left(), end=math_op_circle.get_left())), \n MoveAlongPath(right_input, Line(start=inputs_group[1].get_right(), end=math_op_circle.get_right())),\n run_time=1.5)\n\n self.play(Transform(result_circle[0], math_op_circle.copy().set_fill(opacity=0)), \n Transform(result_circle[1], plus_sign.copy()),\n run_time=0.8)\n self.play(ShowPassingFlash(result_circle, time_width=0.2, flash_scale=1.5), run_time=1)\n\n # Interactive Activation Function Plot\n axes = Axes(x_range=[0, 10, 2], y_range=[0, 10, 2], x_length=8, y_length=6)\n relu_plot = axes.plot(lambda x: max(0, x), color=GREEN)\n sigmoid_curve = axes.plot(lambda x: 1/(1+np.exp(-x)), color=RED)\n \n # Show ReLU first since it maps positive numbers linearly\n self.play(Create(axes), Create(relu_plot), run_time=2)\n self.wait(1)\n\n # Switch to Sigmoid after the calculation shows non-linear behavior\n self.play(Transform(relu_plot, sigmoid_curve), run_time=2)\n self.wait(2)\n\n # Conclusion: Fade back to normal state, keep formulas visible\n self.play(\n math_op_circle.animate.set_stroke(color=BLUE, width=4),\n plus_sign.animate.scale(1.4),\n run_time=1.5\n )\n self.play(FadeOut(highlight_path))\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Function of the Target Network\n\nThis is an auxiliary network with temporarily fixed parameters, specifically used to calculate the TD target values. By severing the real-time connection between the target values and the current network parameters, it avoids training instability caused by \"chasing a moving target.\"\n\n\nThe context location of this section (from highest to current level):\n# Advanced Techniques in DQN\n## Key Improvement Ideas in DQN\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass FunctionOfTargetNetwork(Scene):\n\n def construct(self):\n title = Text('Function of the Target Network', font_size=36)\n title.to_edge(UP, buff=0.75)\n self.play(Write(title))\n context_text = Text('Key Improvement Idea\\nAdvanced Techniques in DQN > Key Improvements')\n context_box = SurroundingRectangle(context_text, color=BLUE_D, buff=0.2)\n context_group = VGroup(context_box, context_text).to_edge(DOWN, buff=0.8)\n self.add(context_group)\n desc1 = Text(\"Auxiliary network with temporarily fixed parameters\", font_size=24)\n desc1.next_to(title, DOWN, buff=1.2)\n box_target_net = RoundedRectangle(corner_radius=0.2, width=3.0, height=1.8, fill_opacity=0.1)\n label_tn = Text('Target Network', font_size=20, color=YELLOW)\n tnp = MathTex('\\\\theta^{\\\\text{t}}').next_to(label_tn, RIGHT, buff=0.2)\n label_fixed_params = Text('Fixed Parameters', font_size=20, color=ORANGE)\n param_block = VGroup(tnp, label_fixed_params).arrange(RIGHT, buff=0.2)\n param_rect = SurroundingRectangle(param_block, color=RED_D, stroke_width=2)\n param_group = VGroup(box_target_net, label_tn, param_rect, param_block)\n calc_label = Text('Calculate TD Target Values:', font_size=24, color=GREEN)\n arrow_calc = Arrow(start=LEFT, end=RIGHT, color=WHITE, max_tip_length_to_length_ratio=0.12)\n calc_group = VGroup(calc_label, arrow_calc).arrange(RIGHT, buff=0.5)\n calc_group.next_to(desc1, DOWN, buff=0.8).align_to(desc1, LEFT)\n eq_td = MathTex('T_{D} = r + \\\\gamma \\\\max_a Q(s', '\\\\rightarrow', 's\\' ,a | \\\\theta^{\\\\text{t}} }')\n eq_td[0].set_color(YELLOW)\n eq_td[2][1:].set_color(TEAL)\n eq_td[2][-1].set_color(GREEN)\n td_title = Text('\"Chasing\" a Moving Target', font_size=24, color=RED_A)\n td_desc = Text('Real-time connection between target values and current net params causes instability.', font_size=20)\n td_group = VGroup(td_title, td_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n td_group.next_to(eq_td, DOWN, buff=0.8).shift(LEFT * 0.5 + UP * 0.2)\n td_box = SurroundingRectangle(VGroup(td_title, td_desc), color=RED_D, buff=0.3)\n sd_txt = Text('Separate Data Flow:\\nReduce Instability', font_size=20, color=BLUE_B)\n sd_box = SurroundingRectangle(sd_txt, color=BLUE_E, stroke_width=3, corner_radius=0.2)\n sd_g = VGroup(sd_box, sd_txt).move_to([1.2, 0.2, 0])\n self.play(FadeIn(param_group, shift=DOWN))\n self.play(Write(calc_label), GrowArrow(arrow_calc))\n self.play(Write(eq_td))\n self.play(Write(td_box), Write(td_title), FadeIn(td_desc, shift=DOWN))\n self.play(Create(sd_box), Write(sd_txt))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass TargetNetworkScene(Scene):\n def construct(self):\n title = Text(\"Target Network\", font_size=36).to_edge(UP)\n \n caption_text = \"\"\"\n Auxiliary network with frozen parameters,\n updating periodically vs. real-time during learning steps.\n \"\"\"\n caption = Paragraph(caption_text, font_size=28).next_to(title, DOWN, buff=0.8)\n\n # Create two networks side-by-side for visual comparison\n net_real = RoundedRectangle(width=2, height=1.5, corner_radius=0.2, color=BLUE)\n net_target = RoundedRectangle(width=2, height=1.5, corner_radius=0.2, color=YELLOW)\n net_label_real = Tex(\"$\\\\theta$\").move_to(net_real.get_center())\n net_label_target = Tex(\"$\\\\theta'$\").move_to(net_target.get_center())\n network_group = VGroup(net_real, net_target, net_label_real, net_label_target).arrange(RIGHT, buff=1.5)\n network_group.next_to(caption, DOWN, buff=1.2)\n\n self.play(Write(title))\n self.play(FadeIn(caption, shift=DOWN * 0.2))\n self.play(Create(net_real), Write(net_label_real), RunTime=1.5)\n self.play(Create(net_target), Write(net_label_target), RunTime=1.5)\n self.wait(1)\n \n # Draw arrows showing signal flow from real to target\n arrow_real_to_target = Arrow(\n start=net_real.get_right(), \n end=net_real.get_right() + RIGHT*1.5 + UP*0.5, \n stroke_width=3, \n color=WHITE\n )\n label_arrow = MathTex(\"\\\\text{TD-Error}\", font_size=24).next_to(arrow_real_to_target, UP, buff=0.2)\n \n self.play(GrowArrow(arrow_real_to_target))\n self.play(Write(label_arrow))\n self.wait(1)\n \n # Add explanation text below the diagram\n explanation_text = [\n \"Updates less frequently than main network.\",\n \"Ensures stable convergence by 'chasing' static targets.\"\n ]\n explanations = [Text(text, font_size=24) for text in explanation_text]\n explanation_group = VGroup(*explanations).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n explanation_group.to_corner(UR, buff=0.5)\n \n # Highlight target network differently to emphasize periodic updates\n highlight_box = SurroundingRectangle(net_target, color=RED, buff=0.15)\n \n self.play(Write(explanation_group[0]))\n self.play(Create(highlight_box))\n self.wait(1)\n \n # Update rule: move box briefly up then back down\n self.play(MoveAlongPath(highlight_box, arc(PHI, ORIGIN, UP)), run_time=1.5)\n self.play(MoveAlongPath(highlight_box, arc(-PHI, ORIGIN, DOWN)), run_time=1.5)\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "How can I create an animated video using the ManimCE Python library where a labeled square is surrounded by a colorful, moving boundary? I want the square, with a text that says \"Math is Fun!\", to increase and decrease in size, and after a short pause, both the square and its animated boundary should disappear from the view.", "chosen": "```python\nfrom manim import *\n\nclass MathFunScene(Scene):\n def construct(self):\n # =====================================================================\n # 1. Scene Setup: Initialize a square labeled with \"Math is Fun!\"\n # =====================================================================\n \n # Create the square and the text label\n square = Square(side_length=2, color=BLUE, fill_opacity=0.2)\n label = Text(\"Math is Fun!\", font_size=36)\n \n # Group the square and label so they transform as a single unit\n main_group = VGroup(square, label)\n \n # Animate the initial appearance\n self.play(Create(square), Write(label))\n \n # =====================================================================\n # 2. Boundary Animation: Surround with a colorful, moving boundary\n # =====================================================================\n \n # Create a circle to act as the boundary, surrounding the square\n # (A circle with radius 1.5 comfortably surrounds a square with side_length=2)\n boundary = Circle(radius=1.5, color=WHITE, stroke_width=3)\n boundary.move_to(square.get_center())\n \n # Define an updater to make the boundary continuously rotate and cycle colors\n def update_boundary(mob, dt):\n mob.rotate(dt * PI)\n colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE]\n index = int(self.time * 2) % len(colors)\n mob.set_color(colors[index])\n \n boundary.add_updater(update_boundary)\n \n self.play(Create(boundary))\n \n # =====================================================================\n # 3. Scaling Animation: Increase and then decrease in size\n # =====================================================================\n \n # Scale up the square and label by 1.5x\n self.play(\n main_group.animate.scale(1.5),\n run_time=1.5,\n rate_func=smooth\n )\n \n # Scale back down to the original size\n self.play(\n main_group.animate.scale(1/1.5),\n run_time=1.5,\n rate_func=smooth\n )\n \n # =====================================================================\n # 4. Pause: Insert a short pause after scaling completes\n # =====================================================================\n \n self.wait(1)\n \n # =====================================================================\n # 5. Disappearance: Animate square and boundary to disappear\n # =====================================================================\n \n # Remove the updater before fading out to ensure clean removal\n boundary.remove_updater(update_boundary)\n \n # Fade out all elements simultaneously\n self.play(\n FadeOut(main_group),\n FadeOut(boundary),\n run_time=1\n )\n\n# To run this script:\n# 1. Save the code to a file named 'math_fun.py'\n# 2. Run the command: manim -pql math_fun.py MathFunScene\n# (-p previews the video, -ql renders in low quality for speed)\n```", "rejected": "```python\nfrom manim import *\n\nclass MathFunScene(Scene):\n def construct(self):\n # =====================================================================\n # 1. Scene Setup: Initialize a square labeled with \"Math is Fun!\"\n # =====================================================================\n \n # Create the square and the text label\n square = Square(side_length=2, color=BBLUE, fill_opacity=0.2)\n label = Text(\"Math is Fun!\", font_size=36)\n \n # Group the square and label so they transform as a single unit\n main_group = VGroup(square, label)\n \n # Animate the initial appearance\n self.play(Create(square), Write(label))\n \n # =====================================================================\n # 2. Boundary Animation: Surround with a colorful, moving boundary\n # =====================================================================\n \n # Create a circle to act as the boundary, surrounding the square\n # (A circle with radius 1.5 comfortably surrounds a square with side_length=2)\n boundary = Circle(radius=1.5, color=WHITE, stroke_width=3)\n boundary.move_to(square.get_center())\n \n # Define an updater to make the boundary continuously rotate and cycle colors\n def update_boundary(mob, dt):\n mob.rotate(dt * PI)\n colors = [RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE]\n index = int(self.time * 2) % len(colors)\n mob.set_color(colors[index])\n \n boundary.add_updater(update_boundary)\n \n self.play(Create(boundary))\n \n # =====================================================================\n # 3. Scaling Animation: Increase and then decrease in size\n # =====================================================================\n \n # Scale up the square and label by 1.5x\n self.play(\n main_group.animate.scale(1.5),\n run_time=1.5,\n rate_func=smooth\n )\n \n # Scale back down to the original size\n self.play(\n main_group.animate.scale(1/1.5),\n run_time=1.5,\n rate_func=smooth\n )\n \n # =====================================================================\n # 4. Pause: Insert a short pause after scaling completes\n # =====================================================================\n \n self.wait(1)\n \n # =====================================================================\n # 5. Disappearance: Animate square and boundary to disappear\n # =====================================================================\n \n # Remove the updater before fading out to ensure clean removal\n boundary.remove_updater(update_boundary)\n \n # Fade out all elements simultaneously\n self.play(\n FadeOut(main_group),\n FadeOut(boundary),\n run_time=1\n )\n\n# To run this script:\n# 1. Save the code to a file named 'math_fun.py'\n# 2. Run the command: manim -pql math_fun.py MathFunScene\n# (-p previews the video, -ql renders in low quality for speed)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Why do spectral methods offer advantages over finite-difference methods for problems with smooth solutions?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SpectralFiniteDifferenceComparison(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Spectral Methods vs Finite-Difference Methods\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n\n # Explanation text about smooth solutions\n explanation = Text(\n \"For smooth solutions,\\nSpectral methods often converge faster\\nand require fewer points.\",\n font_size=28,\n t2c={\"smooth\": YELLOW}\n )\n explanation.next_to(title, DOWN, buff=1)\n self.play(FadeIn(explanation))\n \n # Draw equations on the right side\n eq_spectral = MathTex(r\"\\text{Error} \\propto N^{-\\alpha}\", color=GREEN).to_edge(RIGHT, buff=1.5).shift(UP * 1)\n eq_finite = MathTex(r\"\\text{Error} \\propto h^p\", color=RED).next_to(eq_spectral, DOWN, buff=0.5)\n \n # Create labels for each equation\n label_spectral = Text(\"Smooth Solution: High Convergence Rate\", font_size=20, color=GREEN).next_to(eq_spectral, LEFT, buff=0.5)\n label_finite = Text(\"Non-smooth Solutions: Polynomial Error\", font_size=20, color=RED).next_to(eq_finite, LEFT, buff=0.5)\n \n self.play(Write(label_spectral))\n self.play(Write(eq_spectral))\n self.play(Write(label_finite))\n self.play(Write(eq_finite))\n\n # Add dots to illustrate higher accuracy\n dot_high_accuracy = Dot(color=GREEN).move_to([1.2, 1.2, 0])\n dot_low_accuracy = Dot(color=RED).move_to([-1.2, -1.2, 0])\n\n self.add(dot_high_accuracy, dot_low_accuracy)\n\n # Highlight the relationship between high convergence rate and low number of points\n highlight_box = SurroundingRectangle(VGroup(eq_spectral, label_spectral), color=YELLOW, buff=0.2)\n self.play(Create(highlight_box))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Choose method based on solution characteristics.\", font_size=28)\n conclusion.to_edge(DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clean up\n self.play(\n FadeOut(title),\n FadeOut(explanation),\n FadeOut(eq_spectral),\n FadeOut(eq_finite),\n FadeOut(label_spectral),\n FadeOut(label_finite),\n FadeOut(highlight_box),\n FadeOut(conclusion),\n FadeOut(dot_high_accuracy),\n FadeOut(dot_low_accuracy)\n )\n\n# To run this code, save it to a file (e.g., spectral_vs_fd.py) \n# and execute it using the command: manim -pql filename.py ClassName\n```", "rejected": "```python\nfrom manim import *\n\nclass SpectralMethodsScene(Scene):\n def construct(self):\n title = Text(\"Spectral Methods: Where Smoothness Meets Precision\", font_size=36).to_edge(UP)\n \n # Create graph of f(x) = sin(pi*x)\n axes = Axes(\n x_range=[-1, 1, 1],\n y_range=[-1.5, 1.5, 1],\n axis_width=4,\n tips=False\n ).shift(DOWN * 1.5)\n\n labels = axes.get_axis_labels(Text(\"x\"), Text(\"f(x)\"))\n \n func = lambda x: np.sin(np.pi * x)\n graph = axes.plot(func, color=BLUE)\n \n label_func = MathTex(\"\\\\text{Smooth Solution} \\\\rightarrow \\\\sin(\\\\pi x)\", font_size=28).next_to(graph, UR, buff=0.2)\n \n self.play(Write(title))\n self.wait(1)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(graph), FadeIn(label_func))\n self.wait(2)\n\n # Show Fourier series approximation\n fourier_series = MathTex(\"\\\\sum_{k=0}^{N}\", \"a_k\", \"\\\\cos(k\\\\omega x)\", \"+\", \"b_k\", \"\\\\sin(k\\\\omega x)\")\n self.play(FadeOut(label_func))\n \n # Animate the convergence of the series\n for k in range(1, 6):\n terms = [i for i in range(1, k + 1)]\n \n # Generate coefficients for the first k terms\n ak_coeffs = [\"a_\" + str(i) if i % 2 == 0 else \"-a_\" + str(i) for i in terms]\n bk_coeffs = [\"b_\" + str(i) if i % 2 != 0 else \"-b_\" + str(i) for i in terms]\n\n cos_terms = VGroup()\n sin_terms = VGroup()\n\n for coeff, term in zip(ak_coeffs, terms):\n cos_term = MathTex(coeff, r\"\\cos(\", f\"k_{term}\\\\omega \", \"x )\")\n cos_terms.add(cos_term)\n \n for coeff, term in zip(bk_coeffs, terms):\n sin_term = MathTex(coeff, r\"\\sin(\", f\"({k}-\", \"k_\", f\"{terms[-1]}\\\\omega \", \"x )\")\n sin_terms.add(sin_term)\n \n partial_sum = MathTex(\"\\\\sum_{k=0}^{\" + str(k) + \"}\").scale(0.7)\n full_expression = MathTex(\"\\\\sum_{k=1}^{\" + str(k) + \"}\", \"a_k\", \"\\\\cos(\", \"k\\\\omega x\", \")\",\n \"+ b_k\", \"\\\\sin(\", \"(k-\", \"k_\", str(terms[-1])+\"\\\\omega \", \"x )\")\n\n # Group equations for animation sequence\n eq_group = VGroup(partial_sum, full_expression).arrange(RIGHT, buff=1.5)\n\n # Display current partial sum and update graph\n self.play(ReplacementTransform(fourier_series.copy(), eq_group.to_edge(DOWN)))\n self.wait(1)\n\n # Update graph only up to the current order\n updated_graph = axes.plot(lambda x: np.sum([np.cos(j*np.pi*x) * ((j**2)*(-1)**((j%2)+1)) \n for j in range(1,k+1)]), color=GREEN)\n \n self.play(Transform(graph,updated_graph), run_time=2)\n self.wait(0.5)\n\n final_label = MathTex(\"\\\\Rightarrow \\\\quad \\\\text{High Accuracy at Low Discretization Points}\")\n final_label.next_to(eq_group, DOWN, buff=1.5)\n self.play(Write(final_label))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animated video that shows the steps to solve the definite integral of x cubed from 0 to 2, including the application of the Fundamental Theorem of Calculus and the evaluation of the integral at the given bounds, concluding with the final numerical result?", "chosen": "```python\nfrom manim import *\n\nclass IntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n # Visually present the integral expression: \\int ₀^2 x^3 dx\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(1)\n \n # Move problem to the top to make room for subsequent steps\n self.play(problem.animate.to_edge(UP, buff=0.5))\n self.wait(0.5)\n\n # --- Step 2: Find the Antiderivative ---\n # Animate the derivation of the antiderivative using the power rule.\n label_anti = Text(\"Find Antiderivative (Power Rule):\", font_size=28)\n label_anti.next_to(problem, DOWN, buff=0.5).align_to(problem, LEFT)\n \n antiderivative = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.next_to(label_anti, RIGHT, buff=0.2)\n \n self.play(Write(label_anti))\n self.play(Write(antiderivative))\n self.wait(1)\n\n # --- Step 3: Apply Fundamental Theorem of Calculus ---\n # Show the substitution of the upper bound (2) and lower bound (0).\n label_ftc = Text(\"Apply Fundamental Theorem of Calculus:\", font_size=28)\n label_ftc.next_to(label_anti, DOWN, buff=0.5).align_to(label_anti, LEFT)\n \n substitution = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n substitution.next_to(label_ftc, RIGHT, buff=0.2)\n \n self.play(Write(label_ftc))\n self.play(Write(substitution))\n self.wait(1)\n\n # --- Step 4: Evaluate ---\n # Animate the arithmetic calculation (F(2) - F(0)).\n label_eval = Text(\"Evaluate:\", font_size=28)\n label_eval.next_to(label_ftc, DOWN, buff=0.5).align_to(label_ftc, LEFT)\n \n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n calculation.next_to(label_eval, RIGHT, buff=0.2)\n \n self.play(Write(label_eval))\n self.play(Write(calculation))\n self.wait(1)\n\n # --- Step 5: Final Result ---\n # Clearly display the final numerical answer.\n result = MathTex(r\"= 4\")\n result.next_to(label_eval, DOWN, buff=0.5).align_to(calculation, LEFT)\n result.set_color(YELLOW)\n result.scale(1.2)\n \n self.play(Write(result))\n self.wait(0.5)\n \n # Box the final result for emphasis\n box = SurroundingRectangle(result, color=BLUE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Final wrap-up: Clear the steps and show the final answer prominently\n steps_group = VGroup(\n label_anti, antiderivative, \n label_ftc, substitution, \n label_eval, calculation\n )\n \n self.play(FadeOut(steps_group), FadeOut(problem))\n self.play(result.animate.move_to(ORIGIN).scale(1.5))\n self.play(box.animate.move_to(ORIGIN).scale(1.5))\n \n final_label = Text(\"Final Result\", font_size=36).next_to(box, UP)\n self.play(Write(final_label))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralSolution(Scene):\n def construct(self):\n # --- Step 1: Display the Problem ---\n # Visually present the integral expression: \\int ₀^2 x^3 dx\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.scale(1.5)\n \n self.play(Write(problem))\n self.wait(1)\n \n # Move problem to the top to make room for subsequent steps\n self.play(problem.animate.to_edge(UP, buff=0.5))\n self.wait(0.5)\n\n # --- Step 2: Find the Antiderivative ---\n # Animate the derivation of the antiderivative using the power rule.\n label_anti = Text(\"Find Antiderivative (Power Rule):\", font_size=28)\n label_anti.next_to(problem, DOWN, buff=0.5).align_to(problem, LEFT)\n \n antiderivative = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative.next_to(label_anti, RIGHT, buff=0.2)\n \n self.play(Write(label_anti))\n self.play(Write(antiderivative))\n self.wait(1)\n\n # --- Step 3: Apply Fundamental Theorem of Calculus ---\n # Show the substitution of the upper bound (2) and lower bound (0).\n label_ftc = Text(\"Apply Fundamental Theorem of Calculus:\", font_size=28)\n label_ftc.next_to(label_anti, DOWN, buff=0.5).align_to(label_anti, LEFT)\n \n substitution = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n substitution.next_to(label_ftc, RIGHT, buff=0.2)\n \n self.play(Write(label_ftc))\n self.play(Write(substitution))\n self.wait(1)\n\n # --- Step 4: Evaluate ---\n # Animate the arithmetic calculation (F(2) - F(0)).\n label_eval = Text(\"Evaluate:\", font_size=28)\n label_eval.next_to(label_ftc, DOWN, buff=0.5).align_to(label_ftc, LEFT)\n \n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n calculation.next_to(label_eval, RIGHT, buff=0.2)\n \n self.play(Write(label_eval))\n self.play(Write(calculation))\n self.wait(1)\n\n # --- Step 5: Final Result ---\n # Clearly display the final numerical answer.\n result = MathTex(r\"= 4\")\n result.next_to(label_eval, DOWN, buff=0.5).align_to(calculation, LEFT)\n result.set_color(YELLOW)\n result.scale(1.2)\n \n self.play(Write(result))\n self.wait(0.5)\n \n # Box the final result for emphasis\n box = SurroundingRectangle(result, color=BBLUE, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n\n # Final wrap-up: Clear the steps and show the final answer prominently\n steps_group = VGroup(\n label_anti, antiderivative, \n label_ftc, substitution, \n label_eval, calculation\n )\n \n self.play(FadeOut(steps_group), FadeOut(problem))\n self.play(result.animate.move_to(ORIGIN).scale(1.5))\n self.play(box.animate.move_to(ORIGIN).scale(1.5))\n \n final_label = Text(\"Final Result\", font_size=36).next_to(box, UP)\n self.play(Write(final_label))\n self.wait(3)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding a dynamic mathematical formula, explanatory annotations, and a more engaging transition sequence: \n\nThe animation begins with the text \"Hello!\" appearing at the top of the screen, which then smoothly transforms into \"Goodbye!\" using a `Transform` effect. Below it, the warning message \"Watch out!\" in red fades in and is highlighted with a `Circumscribe` animation. To deepen the context, a mathematical formula (e.g., \\( e^{i\\pi} + 1 = 0 \\)) emerges beside the warning text, accompanied by an explanatory label (\"Euler's Identity\") that fades in below it. The formula and label pulse gently with a `Flash` effect to emphasize their significance. As the scene concludes, all elements—the main text, warning, formula, and label—dissolve simultaneously in a coordinated `FadeOut` while a new background grid subtly appears, reinforcing the mathematical theme. This enriched version maintains the original structure while adding educational depth and visual sophistication.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedTransition(Scene):\n def construct(self):\n # Create initial texts\n hello_text = Text(\"Hello!\", font_size=72).to_edge(UP)\n \n goodbye_text = Text(\"Goodbye!\", font_size=72).move_to(hello_text.get_center())\n \n # Transform Hello to Goodbye\n self.play(Write(hello_text))\n self.wait(0.5)\n self.play(Transform(hello_text, goodbye_text))\n self.wait(0.5)\n\n # Warning text\n watch_out = Text(\"Watch out!\", color=RED, font_size=60).next_to(goodbye_text, DOWN, buff=0.8)\n \n # Show warning text and highlight it\n self.play(FadeIn(watch_out))\n self.play(Circumscribe(watch_out, color=YELLOW))\n self.wait(0.5)\n\n # Mathematical Formula\n equation = MathTex(\n r\"e^{\\pi i}\", \"+\", \"1\", \"=\", \"0\",\n font_size=48,\n color=BLUE\n ).shift(RIGHT * 2.5)\n equation.next_to(watch_out, RIGHT, buff=0.5)\n \n # Explanatory Label for Euler's Identity\n label = Text(\"Euler's Identity\", font_size=28).next_to(equation, UP, buff=0.3)\n \n # Animate the appearance of the math and label\n self.play(Write(label), Write(equation))\n self.wait(0.5)\n \n # Pulse effect to emphasize the formula\n self.play(Flash(equation, color=GREEN, flash_radius=2))\n self.wait(0.5)\n\n # Fade out all elements\n all_elements = VGroup(hello_text, watch_out, equation, label)\n self.play(FadeOut(all_elements))\n\n # Add a subtle background grid\n plane = NumberPlane()\n plane.add_coordinates()\n self.play(Create(plane))\n self.wait(2)\n```", "rejected": "```python\n# ---\n# Animation Title: Enhanced Hello-Bye Sequence\n# Author: Your Name Here\n# Description: Demonstrates advanced sequencing, transformations,\n# highlighting, and cleanup for educational content.\n# ---\nfrom manim import *\n\nclass EnhancedSequence(Scene):\n def construct(self):\n # --- Step 1: Initial Text Transformation ---\n hello_text = Text(\"Hello!\", font_size=72).to_edge(UP)\n \n self.play(Write(hello_text))\n self.wait(0.5)\n\n goodbye_text = Text(\"Goodbye!\", font_size=72).move_to(hello_text.get_center())\n \n # Transform from \"Hello!\" to \"Goodbye!\"\n self.play(Transform(hello_text, goodbye_text))\n self.wait(0.5)\n\n # Fade out both texts\n self.play(FadeOut(hello_text))\n self.wait(0.5)\n\n # --- Step 2: Warning Message and Highlight ---\n watch_out = Text(\"Watch out!\", color=RED, font_size=48).shift(DOWN * 1.5)\n \n # Fading in\n self.play(Write(watch_out))\n\n # Circumscibe effect to highlight the warning\n self.play(Circumscribe(watch_out, color=YELLOW, buff=MED_LARGE_BUFF))\n self.wait(1)\n\n # --- Step 3: Mathematical Context ---\n # Display Euler's Identity near the warning text\n identity = MathTex(\n r\"e^{i\\pi} + 1\", \"=\", \"0\",\n font_size=60\n ).next_to(watch_out, RIGHT, buff=1.5)\n \n # Add a title under the equation\n label = Text(\"Euler's Identity\", font_size=28, color=BLUE).next_to(identity, DOWN, buff=0.3)\n\n # Animate the formula entering\n self.play(Write(identity), Write(label))\n self.wait(0.5)\n\n # Pulsating Flash effect to emphasize the math\n flash_effect = Flash(\n identity, \n color=ORANGE, \n line_length=0.5, \n num_lines=20\n )\n self.add(flash_effect) # Adding temporarily to ensure timing matches\n self.play(flash_effect)\n self.remove(flash_effect) # Clean up after playback\n\n # Wait briefly before conclusion\n self.wait(0.5)\n\n # --- Conclusion: Coordinated Cleanup and Grid Reveal ---\n all_elements = VGroup(watch_out, identity, label)\n\n # Simultaneous fading out of all visible elements\n self.play(FadeOut(all_elements))\n\n # Create a grid to reinforce the mathematical theme\n plane = NumberPlane()\n plane.scale(0.7) # Scale down slightly so it fits nicely\n\n # Animate the grid appearing\n self.play(Create(plane), run_time=1.5)\n self.wait(2)\n\n# To render this animation, save the script as 'enhanced_sequence.py' and execute:\n# manim -pql enhanced_sequence.py EnhancedSequence\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation with additional features: \n\nThe scene begins with a vertical arrangement of three text elements (\"This is a sample,\" \"of moving,\" \"FrameBoxes\") displayed in sequence. Each text is dynamically highlighted by a colored rectangle (blue, green, red) that smoothly transforms from one to the next using `ReplacementTransform`. After the final red rectangle appears, it duplicates and animates upward along a curved path, creating a trailing effect with fading opacity. Simultaneously, a mathematical formula (e.g., \\( \\text{FrameBox}(t) = \\text{Position}(t) + \\text{Color}(t) \\)) fades in below the text group, explaining the transformation logic. The formula then morphs into a simplified version (\\( \\text{Movement} = \\text{Path} \\times \\text{Time} \\)) as the rectangle completes its motion. Finally, all elements dissolve into a new set of transformed shapes—perhaps the rectangles becoming circles or arrows—reinforcing the concept of dynamic visual transitions. The entire sequence is timed with smooth pauses and coordinated movements to enhance clarity and engagement. \n\nThis version retains the original’s core animations while adding explanatory math, path effects, and shape transformations for deeper pedagogical impact.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedFrameBoxAnimation(Scene):\n def construct(self):\n # Create text elements\n texts = [\n Text(\"This is a sample\", font_size=36),\n Text(\"of moving\", font_size=36),\n Text(\"FrameBoxes\", font_size=36)\n ]\n \n # Arrange texts vertically\n text_group = VGroup(*texts).arrange(DOWN, buff=0.5)\n text_group.move_to(ORIGIN)\n \n # Create colored rectangles for highlighting\n colors = [BLUE, GREEN, RED]\n rects = []\n for text, color in zip(texts, colors):\n rect = SurroundingRectangle(text, color=color, fill_opacity=0.3, buff=0.2)\n rects.append(rect)\n \n # Animate text and rectangles sequentially\n self.play(Write(texts[0]))\n self.play(Create(rects[0]))\n self.wait(0.5)\n \n self.play(Write(texts[1]))\n self.play(ReplacementTransform(rects[0], rects[1]))\n self.wait(0.5)\n \n self.play(Write(texts[2]))\n self.play(ReplacementTransform(rects[1], rects[2]))\n self.wait(0.5)\n \n # Duplicate and animate the red rectangle along a curved path\n final_rect = rects[2]\n duplicate_rect = final_rect.copy()\n \n path = ParametricFunction(\n lambda t: np.array([\n t * 2,\n np.sin(t * PI) * 1.5 + 1,\n 0\n ]),\n t_range=[0, 2]\n )\n \n self.play(\n duplicate_rect.animate.move_to(path.get_start()),\n run_time=0.3\n )\n \n self.play(\n MoveAlongPath(duplicate_rect, path),\n rate_func=linear,\n run_time=2\n )\n \n # Create fading trail effect\n trail_rects = []\n for i in range(5):\n trail_rect = duplicate_rect.copy().set_opacity(0.5 - i * 0.1)\n trail_rects.append(trail_rect)\n self.add(trail_rect)\n self.play(\n trail_rect.animate.shift(UP * 0.5).set_opacity(0),\n run_time=0.5\n )\n \n # Display mathematical formula\n formula1 = MathTex(\n r\"\\text{FrameBox}(t) = \\text{Position}(t) + \\text{Color}(t)\",\n font_size=36\n )\n formula1.next_to(text_group, DOWN, buff=1)\n \n self.play(FadeIn(formula1))\n self.wait(1)\n \n # Morph formula into simplified version\n formula2 = MathTex(\n r\"\\text{Movement} = \\text{Path} \\times \\text{Time}\",\n font_size=36\n )\n formula2.move_to(formula1)\n \n self.play(Transform(formula1, formula2))\n self.wait(1)\n \n # Transform rectangles into circles\n circles = []\n for rect in rects:\n circle = Circle(\n radius=0.5,\n color=rect.get_color(),\n fill_opacity=0.3\n )\n circle.move_to(rect)\n circles.append(circle)\n \n self.play(\n *[ReplacementTransform(rect, circle) for rect, circle in zip(rects, circles)],\n FadeOut(formula1),\n run_time=1.5\n )\n \n # Final dissolve\n self.play(\n *[FadeOut(circle) for circle in circles],\n *[FadeOut(text) for text in texts],\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedFrameBoxAnimation(Scene):\n def construct(self):\n # Create text elements\n texts = [\n Text(\"This is a sample\", font_size=36),\n Text(\"of moving\", font_size=36),\n Text(\"FrameBoxes\", font_size=36)\n ]\n \n # Arrange texts vertically\n text_group = VGroup(*texts).arrange(DOWN, buff=0.5)\n text_group.move_to(ORIGIN)\n \n # Create colored rectangles for highlighting\n colors = [BLUE, GREEN, RED]\n rects = []\n for text, color in zip(texts, colors):\n rect = SurroundingRectangle(text, color=color, fill_opacity=0.3, buff=0.2)\n rects.append(rect)\n \n # Animate text and rectangles sequentially\n self.play(Write(texts[0]))\n self.play(Create(rects[0]))\n self.wait(0.5)\n \n self.play(Write(texts[1]))\n self.play(ReplacementTransform(target_position=ORIGIN, rects[0], rects[1]))\n self.wait(0.5)\n \n self.play(Write(texts[2]))\n self.play(ReplacementTransform(rects[1], rects[2]))\n self.wait(0.5)\n \n # Duplicate and animate the red rectangle along a curved path\n final_rect = rects[2]\n duplicate_rect = final_rect.copy()\n \n path = ParametricFunction(\n lambda t: np.array([\n t * 2,\n np.sin(t * PI) * 1.5 + 1,\n 0\n ]),\n t_range=[0, 2]\n )\n \n self.play(\n duplicate_rect.animate.move_to(path.get_start()),\n run_time=0.3\n )\n \n self.play(\n MoveAlongPath(duplicate_rect, path),\n rate_func=linear,\n run_time=2\n )\n \n # Create fading trail effect\n trail_rects = []\n for i in range(5):\n trail_rect = duplicate_rect.copy().set_opacity(0.5 - i * 0.1)\n trail_rects.append(trail_rect)\n self.add(trail_rect)\n self.play(\n trail_rect.animate.shift(UP * 0.5).set_opacity(0),\n run_time=0.5\n )\n \n # Display mathematical formula\n formula1 = MathTex(\n r\"\\text{FrameBox}(t) = \\text{Position}(t) + \\text{Color}(t)\",\n font_size=36\n )\n formula1.next_to(text_group, DOWN, buff=1)\n \n self.play(FadeIn(formula1))\n self.wait(1)\n \n # Morph formula into simplified version\n formula2 = MathTex(\n r\"\\text{Movement} = \\text{Path} \\times \\text{Time}\",\n font_size=36\n )\n formula2.move_to(formula1)\n \n self.play(Transform(formula1, formula2))\n self.wait(1)\n \n # Transform rectangles into circles\n circles = []\n for rect in rects:\n circle = Circle(\n radius=0.5,\n color=rect.get_color(),\n fill_opacity=0.3\n )\n circle.move_to(rect)\n circles.append(circle)\n \n self.play(\n *[ReplacementTransform(rect, circle) for rect, circle in zip(rects, circles)],\n FadeOut(formula1),\n run_time=1.5\n )\n \n # Final dissolve\n self.play(\n *[FadeOut(circle) for circle in circles],\n *[FadeOut(text) for text in texts],\n run_time=1\n )\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 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 a\n- Act 2: Could you please create an educational animation that visually demonstrates how to find the area under the curve of the function y = x^2 from x = 0 to x = 2? Begin by showing the function itself, then draw the graph on a\n- Act 3: 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?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0073(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_textandcircleanimation()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_textandcircleanimation(self):\n initial_text = Text(\"Loading...\", font_size=36)\n target_text = Text(\"ShowSubmobjectsOneByOne\", font_size=36)\n \n # Write the initial text to the scene\n self.play(Write(initial_text))\n self.wait(0.5)\n \n # Morph the initial text into the target string\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 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 # --- 2. Sequential Circle Display ---\n \n # Define the three circles with specific positions\n # Circle 1: Top center (below the text)\n circle_1 = Circle(radius=0.5, color=BLUE).shift(DOWN * 1)\n \n # Circle 2: Diagonally below to the left\n circle_2 = Circle(radius=0.5, color=GREEN).shift(DOWN * 2.5 + LEFT * 2)\n \n # Circle 3: Diagonally below to the right\n circle_3 = Circle(radius=0.5, color=RED).shift(DOWN * 2.5 + RIGHT * 2)\n \n # Group the circles to handle them as a single unit\n circles_group = VGroup(circle_1, circle_2, circle_3)\n \n # Display circles sequentially using ShowSubmobjectsOneByOne\n self.play(ShowSubmobjectsOneByOne(circles_group))\n self.wait(0.5)\n\n # --- 3. Simultaneous Disappearance ---\n \n # Fade out all circles simultaneously\n self.play(FadeOut(circles_group))\n \n # End scene pause\n self.wait()\n\n def act_2_areaundercurve(self):\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n axis_labels = axes.get_axis_labels(\"x\", \"y\")\n \n # Define the function graph\n curve = axes.plot(lambda x: x**2, color=YELLOW)\n\n # 2. Visualization: Plot the function and add a label\n curve_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait()\n\n # 3. Integral Expression: Display the mathematical expression for the area\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait()\n\n # 4. Highlight Area: Visually highlight the region under the curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait()\n\n # 5. Show Result: Calculate and display the numerical result\n # We separate the equals sign and the value to easily isolate the final result later\n equals = MathTex(\"=\").next_to(integral_expr, RIGHT)\n result_value = MathTex(r\"\\frac{8}{3}\").next_to(equals, RIGHT)\n \n self.play(Write(equals), Write(result_value))\n self.wait()\n\n # 6. Cleanup: Remove all elements except the final calculated result\n to_remove = VGroup(\n axes, axis_labels, curve, curve_label, \n integral_expr, equals, area\n )\n \n self.play(FadeOut(to_remove))\n \n # Move the final result to the center and scale it up for emphasis\n self.play(result_value.animate.move_to(ORIGIN).scale(1.5))\n self.wait()\n\n def act_3_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=72, color=BLUE)\n self.play(Write(text))\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(text.animate.shift(UP * 2.5))\n self.wait(0.5)\n\n # 3. Signal Emission\n # Create the triangle (antenna/transmitter)\n triangle = Triangle(color=YELLOW, fill_opacity=0.8, stroke_width=2)\n triangle.scale(0.6).move_to(ORIGIN)\n self.play(DrawBorderThenFill(triangle))\n\n # Create concentric arcs for the broadcast signal\n waves = VGroup()\n for i in range(4):\n arc = Arc(\n radius=0.3, \n start_angle=0, \n angle=PI, \n color=WHITE, \n stroke_width=4\n )\n arc.move_to(triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out sequentially for a pulsing effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(4).set_opacity(0)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2.0,\n rate_func=smooth\n )\n\n # 4. Disappearance\n self.play(FadeOut(triangle))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0073(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_textandcircleanimation()\n self.clear_stage()\n self.act_2_areaundercurve()\n self.clear_stage()\n self.act_3_broadcastanimation()\n\n def act_1_textandcircleanimation(self):\n initial_text = Text(\"Loading...\", font_size=36)\n target_text = Text(\"ShowSubmobjectsOneByOne\", font_size=36)\n \n # Write the initial text to the scene\n self.play(Write(initial_text))\n self.wait(0.5)\n \n # Morph the initial text into the target string\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 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 # --- 2. Sequential Circle Display ---\n \n # Define the three circles with specific positions\n # Circle 1: Top center (below the text)\n circle_1 = Circle(radius=0.5, color=BLUE).shift(DOWN * 1)\n \n # Circle 2: Diagonally below to the left\n circle_2 = Circle(radius=0.5, color=GREEN).shift(DOWN * 2.5 + LEFT * 2)\n \n # Circle 3: Diagonally below to the right\n circle_3 = Circle(radius=0.5, color=RED).shift(DOWN * 2.5 + RIGHT * 2)\n \n # Group the circles to handle them as a single unit\n circles_group = VGroup(circle_1, circle_2, circle_3)\n \n # Display circles sequentially using ShowSubmobjectsOneByOne\n self.play(ShowSubmobjectsOneByOne(circles_group))\n self.wait(0.5)\n\n # --- 3. Simultaneous Disappearance ---\n \n # Fade out all circles simultaneously\n self.play(FadeOut(circles_group))\n \n # End scene pause\n self.wait()\n\n def act_2_areaundercurve(self):\n axes = Axes(label_font_size=24, \n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n axis_labels = axes.get_axis_labels(\"x\", \"y\")\n \n # Define the function graph\n curve = axes.plot(lambda x: x**2, color=YELLOW)\n\n # 2. Visualization: Plot the function and add a label\n curve_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n self.play(Create(axes), Write(axis_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait()\n\n # 3. Integral Expression: Display the mathematical expression for the area\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait()\n\n # 4. Highlight Area: Visually highlight the region under the curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait()\n\n # 5. Show Result: Calculate and display the numerical result\n # We separate the equals sign and the value to easily isolate the final result later\n equals = MathTex(\"=\").next_to(integral_expr, RIGHT)\n result_value = MathTex(r\"\\frac{8}{3}\").next_to(equals, RIGHT)\n \n self.play(Write(equals), Write(result_value))\n self.wait()\n\n # 6. Cleanup: Remove all elements except the final calculated result\n to_remove = VGroup(\n axes, axis_labels, curve, curve_label, \n integral_expr, equals, area\n )\n \n self.play(FadeOut(to_remove))\n \n # Move the final result to the center and scale it up for emphasis\n self.play(result_value.animate.move_to(ORIGIN).scale(1.5))\n self.wait()\n\n def act_3_broadcastanimation(self):\n text = Text(\"Broadcast\", font_size=72, color=BLUE)\n self.play(Write(text))\n self.wait(0.5)\n\n # 2. Upward Movement\n self.play(text.animate.shift(UP * 2.5))\n self.wait(0.5)\n\n # 3. Signal Emission\n # Create the triangle (antenna/transmitter)\n triangle = Triangle(color=YELLOW, fill_opacity=0.8, stroke_width=2)\n triangle.scale(0.6).move_to(ORIGIN)\n self.play(DrawBorderThenFill(triangle))\n\n # Create concentric arcs for the broadcast signal\n waves = VGroup()\n for i in range(4):\n arc = Arc(\n radius=0.3, \n start_angle=0, \n angle=PI, \n color=WHITE, \n stroke_width=4\n )\n arc.move_to(triangle.get_top())\n waves.add(arc)\n\n # Animate waves expanding and fading out sequentially for a pulsing effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(4).set_opacity(0)\n for wave in waves\n ],\n lag_ratio=0.3\n ),\n run_time=2.0,\n rate_func=smooth\n )\n\n # 4. Disappearance\n self.play(FadeOut(triangle))\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here’s an enhanced version of the animation that retains all the original features while adding a dynamic mathematical formula, explanatory annotations, and a more engaging transition sequence: \n\nThe animation begins with the text \"Hello!\" appearing at the top of the screen, which then smoothly transforms into \"Goodbye!\" using a `Transform` effect. Below it, the warning message \"Watch out!\" in red fades in and is highlighted with a `Circumscribe` animation. To deepen the context, a mathematical formula (e.g., \\( e^{i\\pi} + 1 = 0 \\)) emerges beside the warning text, accompanied by an explanatory label (\"Euler's Identity\") that fades in below it. The formula and label pulse gently with a `Flash` effect to emphasize their significance. As the scene concludes, all elements—the main text, warning, formula, and label—dissolve simultaneously in a coordinated `FadeOut` while a new background grid subtly appears, reinforcing the mathematical theme. This enriched version maintains the original structure while adding educational depth and visual sophistication.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedTransition(Scene):\n def construct(self):\n # Create initial texts\n hello_text = Text(\"Hello!\", font_size=72).to_edge(UP)\n \n goodbye_text = Text(\"Goodbye!\", font_size=72).move_to(hello_text.get_center())\n \n # Transform Hello to Goodbye\n self.play(Write(hello_text))\n self.wait(0.5)\n self.play(Transform(hello_text, goodbye_text))\n self.wait(0.5)\n\n # Warning text\n watch_out = Text(\"Watch out!\", color=RED, font_size=60).next_to(goodbye_text, DOWN, buff=0.8)\n \n # Show warning text and highlight it\n self.play(FadeIn(watch_out))\n self.play(Circumscribe(watch_out, color=YELLOW))\n self.wait(0.5)\n\n # Mathematical Formula\n equation = MathTex(\n r\"e^{\\pi i}\", \"+\", \"1\", \"=\", \"0\",\n font_size=48,\n color=BLUE\n ).shift(RIGHT * 2.5)\n equation.next_to(watch_out, RIGHT, buff=0.5)\n \n # Explanatory Label for Euler's Identity\n label = Text(\"Euler's Identity\", font_size=28).next_to(equation, UP, buff=0.3)\n \n # Animate the appearance of the math and label\n self.play(Write(label), Write(equation))\n self.wait(0.5)\n \n # Pulse effect to emphasize the formula\n self.play(Flash(equation, color=GREEN, flash_radius=2))\n self.wait(0.5)\n\n # Fade out all elements\n all_elements = VGroup(hello_text, watch_out, equation, label)\n self.play(FadeOut(all_elements))\n\n # Add a subtle background grid\n plane = NumberPlane()\n plane.add_coordinates()\n self.play(Create(plane))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedTextScene(Scene):\n def construct(self):\n # Display initial text\n hello_text = Text(\"Hello!\", font_size=72).to_edge(UP)\n \n self.play(Write(hello_text))\n \n # Transform text from Hello! to Goodbye!\n goodbye_text = Text(\"Goodbye!\", font_color=RED, font_size=72).move_to(hello_text.get_center())\n \n self.transform_from_copy(goodbye_text, hello_text)\n\n # Fade in warning text and highlight it with Circumscribe\n warning_text = Text(\"Watch out!\", color=RED, font_size=60).next_to(goodbye_text, DOWN, buff=1)\n circumscribe_animation = Circumscribe(warning_text, color=YELLOW, buff=0.2)\n \n self.add(warning_text)\n self.play(circumscribe_animation)\n\n # Define Euler's Identity with its explanation\n identity = MathTex(\n r\"e^{{i\\pi}}\", \"+\", \"1\", \"=\", \"0\"\n ).scale(1.8).shift(DOWN * 1.5)\n \n explanation = Tex(\"Euler's Identity\").scale(0.6).next_to(identity, UP)\n \n self.play(FadeIn(explanation), Write(identity))\n\n # Add Flash effect to animate the math content\n flash_effect = Flash(identity, color=GREEN, line_length=0.15, num_lines=20, flash_radius=1.0, time_width=0.2)\n \n self.play(flash_effect)\n\n # Create background grid for final scene\n grid = NumberPlane(x_length=7, y_length=4.5, x_unit=1, y_unit=1)\n \n # Simultaneous FadeOut of all elements\n all_elements = VGroup(\n goodbye_text, \n warning_text,\n explanation, \n identity, \n grid\n )\n \n self.play(FadeOut(all_elements), run_time=1.5)\n\n # Animate Grid appearance on conclusion\n self.play(Create(grid), run_time=2)\n \n # Hold the final frame briefly\n self.wait()\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 before fading out. Also, I want the molecule to be shown with a double bond between the atoms.", "chosen": "```python\nfrom manim import *\n\nclass OxygenMolecule(Scene):\n def construct(self):\n # Create circles for the oxygen atoms (red)\n atom_a = Circle(radius=0.8, color=RED).shift(LEFT*2)\n atom_b = Circle(radius=0.8, color=RED).shift(RIGHT*2)\n\n # Create a line representing the double bond between them\n bond = Line(atom_a.get_right(), atom_b.get_left())\n \n # Group everything so it can animate simultaneously\n molecule_group = VGroup(atom_a, atom_b, bond).move_to(ORIGIN)\n\n # --- Step 1: Fade In ---\n self.play(FadeIn(molecule_group))\n\n # --- Step 2: Rotation ---\n # Rotate the group by 90 degrees about its center of mass\n self.play(\n Rotate(molecule_group, angle=PI/2),\n run_time=2,\n rate_func=smooth\n )\n\n # --- Step 3: Scaling Up ---\n # Scale both the atoms and the bond to double their original sizes\n self.play(\n atom_a.animate.scale(2),\n atom_b.animate.scale(2),\n bond.animate.scale(2),\n run_time=2,\n rate_func=smooth\n )\n \n # --- Step 4: Fade Out ---\n # Remove the molecules from the screen smoothly\n self.play(FadeOut(molecule_group))\n```", "rejected": "```python\nfrom manim import *\n\nclass OxygenMoleculeScene(Scene):\n def construct(self):\n # --- Configuration ---\n atom_radius = 0.6\n bond_color = BLUE\n atom_color = RED\n\n # Create O atoms\n o1 = Circle(radius=atom_radius, color=atom_color)\n o2 = Circle(radius=atom_radius, color=atom_color)\n\n # Position them side-by-side initially for rotation effect\n o1.move_to(LEFT * 2)\n o2.move_to(RIGHT * 2)\n\n # Create Double Bond line segments (centered between atoms)\n bond_start = ORIGIN + LEFT * (o1.radius + 0.1) # Buffer so they don't overlap exactly\n bond_end = ORIGIN + RIGHT * (o2.radius + 0.1)\n\n # Add bonds at top and bottom positions along the line connecting them\n bond_top = Line(bond_start, bond_end, stroke_width=8).set_stroke(bond_color, opacity=0.7)\n bond_bottom = Line(bond_start, bond_end, stroke_width=8).shift(DOWN*0.1).set_stroke(bond_color, opacity=0.7)\n\n # Group elements including bonds\n molecule_group = VGroup(\n o1,\n o2,\n bond_top,\n bond_bottom\n )\n\n # Animation Sequence\n\n # Step 1: Fade In Atoms\n self.play(FadeIn(o1, shift=RIGHT))\n self.play(FadeIn(o2, shift=LEFT))\n\n # Move them towards center slightly for scaling effect later\n self.play(MoveAlongPath(o1, arc_segment([o1.get_center(), [0,1,-1], [0,1,1]], radius=1)))\n self.play(MoveAlongPath(o2, arc_segment([o2.get_center(), [-0.5,1,-0.5], [0,1,0.5]], radius=1)))\n\n # Step 2: Rotate Around Central Axis (Simulating Rotation of Molecule in Space)\n central_axis = Vector().put_start_and_end_on(o1.get_center(), o2.get_center())\n \n # Animate rotation about this axis\n self.play(Rotating(molecule_group, angle=PI, about_point=ORIGIN, run_time=2, rate_func=smooth))\n\n # Step 3: Scale Up to Double Size\n target_scale_factor = 2\n \n self.play(\n o1.animate.scale(target_scale_factor),\n o2.animate.scale(target_scale_factor),\n RunTime(0.8),\n rate_func=smoothen\n )\n \n # Re-render bonds after scaling to ensure they also expand correctly\n bond_top.put_start_and_end_on(o1.get_right() + UP * (atom_radius * target_scale_factor), \n o2.get_left() + DOWN * (atom_radius * target_scale_factor))\n bond_bottom.put_start_and_end_on(o1.get_right() + DOWN * (atom_radius * target_scale_factor), \n o2.get_left())\n\n # Step 4: Fade Out\n self.play(FadeOut(molecule_group))\n\n# To render this animation locally, save it to a file and execute:\n# manim -pql filename.py OxygenMoleculeScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an animation that shows a simple feedforward neural network with three layers, where the first layer has 4 neurons, the second layer has 8 neurons, and the output layer has 2 neurons, with ReLU activation functions in the first two layers and a Sigmoid activation function in the output layer, and can you also animate the forward pass of information through the neural network?", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n layer_sizes = [4, 8, 2]\n layer_labels = [\"Input Layer\", \"Hidden Layer\\n(ReLU)\", \"Output Layer\\n(Sigmoid)\"]\n neuron_radius = 0.2\n layer_spacing = 3.5\n \n # Colors\n neuron_color = WHITE\n connection_color = GRAY_B\n signal_color = YELLOW\n active_color = BLUE\n\n # --- 1. Create Neurons ---\n layers = VGroup()\n for i, size in enumerate(layer_sizes):\n layer = VGroup()\n for j in range(size):\n y_pos = (j - (size - 1) / 2) * (2 * neuron_radius + 0.4)\n x_pos = (i - 1) * layer_spacing\n neuron = Circle(radius=neuron_radius, color=neuron_color, fill_opacity=0.2)\n neuron.move_to([x_pos, y_pos, 0])\n layer.add(neuron)\n layers.add(layer)\n\n # --- 2. Create Connections ---\n connections = VGroup()\n # Store connections by layer transition for forward pass animation\n layer_connections = []\n \n for i in range(len(layer_sizes) - 1):\n layer_from = layers[i]\n layer_to = layers[i+1]\n current_layer_connections = VGroup()\n for n_from in layer_from:\n for n_to in layer_to:\n line = Line(\n n_from.get_right(), \n n_to.get_left(), \n stroke_width=1, \n color=connection_color, \n stroke_opacity=0.5\n )\n current_layer_connections.add(line)\n connections.add(current_layer_connections)\n layer_connections.append(current_layer_connections)\n\n # --- 3. Create Labels ---\n labels = VGroup()\n for i, text in enumerate(layer_labels):\n label = Text(text, font_size=24).next_to(layers[i], UP, buff=0.5)\n labels.add(label)\n\n # --- Animation Sequence ---\n \n # 1. Build the Network\n self.play(FadeIn(layers), FadeIn(connections), Write(labels), run_time=1.5)\n self.wait(1)\n\n # 2. Animate Forward Pass: Input -> Hidden\n # Highlight input layer activation\n self.play(\n layers[0].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n \n # Create and animate signal dots from Input to Hidden\n signals_1 = VGroup()\n for line in layer_connections[0]:\n dot = Dot(radius=0.04, color=signal_color).move_to(line.get_start())\n signals_1.add(dot)\n \n self.add(signals_1)\n self.play(\n LaggedStart(*[\n MoveAlongPath(dot, line) \n for dot, line in zip(signals_1, layer_connections[0])\n ], lag_ratio=0.02),\n run_time=1.5\n )\n self.remove(signals_1)\n \n # Highlight hidden layer activation\n self.play(\n layers[1].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n self.wait(0.2)\n\n # 3. Animate Forward Pass: Hidden -> Output\n # Create and animate signal dots from Hidden to Output\n signals_2 = VGroup()\n for line in layer_connections[1]:\n dot = Dot(radius=0.04, color=signal_color).move_to(line.get_start())\n signals_2.add(dot)\n \n self.add(signals_2)\n self.play(\n LaggedStart(*[\n MoveAlongPath(dot, line) \n for dot, line in zip(signals_2, layer_connections[1])\n ], lag_ratio=0.02),\n run_time=1.5\n )\n self.remove(signals_2)\n \n # Highlight output layer activation\n self.play(\n layers[2].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n self.wait(2)\n\n # 4. Reset and Outro\n self.play(\n layers.animate.set_color(neuron_color).set_fill(opacity=0.2),\n connections.animate.set_color(connection_color).set_stroke(opacity=0.5),\n FadeOut(labels),\n run_time=1\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n layer_sizes = [4, 8, 2]\n layer_labels = [\"Input Layer\", \"Hidden Layer\\n(ReLU)\", \"Output Layer\\n(Sigmoid)\"]\n neuron_radius = 0.2\n layer_spacing = 3.5\n \n # Colors\n neuron_color = WHITE\n connection_color = GRAY_B\n signal_color = YELLOW\n active_color = BBLUE\n\n # --- 1. Create Neurons ---\n layers = VGroup()\n for i, size in enumerate(layer_sizes):\n layer = VGroup()\n for j in range(size):\n y_pos = (j - (size - 1) / 2) * (2 * neuron_radius + 0.4)\n x_pos = (i - 1) * layer_spacing\n neuron = Circle(radius=neuron_radius, color=neuron_color, fill_opacity=0.2)\n neuron.move_to([x_pos, y_pos, 0])\n layer.add(neuron)\n layers.add(layer)\n\n # --- 2. Create Connections ---\n connections = VGroup()\n # Store connections by layer transition for forward pass animation\n layer_connections = []\n \n for i in range(len(layer_sizes) - 1):\n layer_from = layers[i]\n layer_to = layers[i+1]\n current_layer_connections = VGroup()\n for n_from in layer_from:\n for n_to in layer_to:\n line = Line(\n n_from.get_right(), \n n_to.get_left(), \n stroke_width=1, \n color=connection_color, \n stroke_opacity=0.5\n )\n current_layer_connections.add(line)\n connections.add(current_layer_connections)\n layer_connections.append(current_layer_connections)\n\n # --- 3. Create Labels ---\n labels = VGroup()\n for i, text in enumerate(layer_labels):\n label = Text(text, font_size=24).next_to(layers[i], UP, buff=0.5)\n labels.add(label)\n\n # --- Animation Sequence ---\n \n # 1. Build the Network\n self.play(FadeIn(layers), FadeIn(connections), Write(labels), run_time=1.5)\n self.wait(1)\n\n # 2. Animate Forward Pass: Input -> Hidden\n # Highlight input layer activation\n self.play(\n layers[0].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n \n # Create and animate signal dots from Input to Hidden\n signals_1 = VGroup()\n for line in layer_connections[0]:\n dot = Dot(radius=0.04, color=signal_color).move_to(line.get_start())\n signals_1.add(dot)\n \n self.add(signals_1)\n self.play(\n LaggedStart(*[\n MoveAlongPath(dot, line) \n for dot, line in zip(signals_1, layer_connections[0])\n ], lag_ratio=0.02),\n run_time=1.5\n )\n self.remove(signals_1)\n \n # Highlight hidden layer activation\n self.play(\n layers[1].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n self.wait(0.2)\n\n # 3. Animate Forward Pass: Hidden -> Output\n # Create and animate signal dots from Hidden to Output\n signals_2 = VGroup()\n for line in layer_connections[1]:\n dot = Dot(radius=0.04, color=signal_color).move_to(line.get_start())\n signals_2.add(dot)\n \n self.add(signals_2)\n self.play(\n LaggedStart(*[\n MoveAlongPath(dot, line) \n for dot, line in zip(signals_2, layer_connections[1])\n ], lag_ratio=0.02),\n run_time=1.5\n )\n self.remove(signals_2)\n \n # Highlight output layer activation\n self.play(\n layers[2].animate.set_fill(color=active_color, opacity=0.8),\n run_time=0.5\n )\n self.wait(2)\n\n # 4. Reset and Outro\n self.play(\n layers.animate.set_color(neuron_color).set_fill(opacity=0.2),\n connections.animate.set_color(connection_color).set_stroke(opacity=0.5),\n FadeOut(labels),\n run_time=1\n )\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Energy Consumption Model\n\n#### Local Energy Consumption\nAccording to the Dynamic Voltage and Frequency Scaling (DVFS) theory, chip energy consumption is proportional to the square of the frequency. Let the effective switching capacitance coefficient be $\\kappa$, then the local energy consumption $E_{loc}$ is:\n$$ E_{loc} = \\kappa (f_{loc})^2 \\cdot (D \\cdot C) $$\n\n\nThe context location of this section (from highest to current level):\n# Computational Offloading and Service Migration\n## Mathematical Modeling and Decision Making for Computational Offloading\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass EnergyConsumptionModel(Scene):\n\n def construct(self):\n title = Text('Energy Consumption Model', font_size=40, weight=BOLD)\n title.to_edge(UP)\n subtitle = Text('Local Energy Consumption', font_size=30, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n text_group = VGroup(Tex('According to the Dynamic Voltage and Frequency Scaling (DVFS) theory,'), Tex('chip energy consumption is proportional to the square of the frequency.'), Tex('Let the effective switching capacitance coefficient be $\\\\kappa$,'), Tex('then the local energy consumption $E_{loc}$ is:')).arrange(DOWN, aligned_edge=LEFT, buff=0.2).scale(0.7)\n text_group.next_to(subtitle, DOWN, buff=0.6)\n text_group[2].shift(DOWN * 0.2)\n text_group[3].shift(DOWN * 0.2)\n equation = MathTex('E_{loc}', '=', '\\\\kappa', '(f_{loc})^2', '\\\\cdot', '(D \\\\cdot C)')\n equation.scale(1.2)\n equation.next_to(text_group, DOWN, buff=0.8)\n equation[0].set_color(YELLOW)\n equation[2].set_color(ORANGE)\n equation[3].set_color(GREEN)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n self.wait(0.5)\n self.play(Write(text_group[0:2]))\n self.wait(1)\n self.play(Write(text_group[2:4]))\n self.wait(1)\n self.play(Write(equation))\n self.wait(1)\n frame = SurroundingRectangle(equation, color=YELLOW, buff=0.2)\n self.play(Create(frame))\n self.wait(2)\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass EnergyConsumptionModel(Scene):\n\n def construct(self):\n title = Text('Energy Consumption Model', font_size=40, weight=BOLD)\n title.to_edge(UP)\n subtitle = Text('Local Energy Consumption', font_size=30, color=BBLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n text_group = VGroup(Tex('According to the Dynamic Voltage and Frequency Scaling (DVFS) theory,'), Tex('chip energy consumption is proportional to the square of the frequency.'), Tex('Let the effective switching capacitance coefficient be $\\\\kappa$,'), Tex('then the local energy consumption $E_{loc}$ is:')).arrange(DOWN, aligned_edge=LEFT, buff=0.2).scale(0.7)\n text_group.next_to(subtitle, DOWN, buff=0.6)\n text_group[2].shift(DOWN * 0.2)\n text_group[3].shift(DOWN * 0.2)\n equation = MathTex('E_{loc}', '=', '\\\\kappa', '(f_{loc})^2', '\\\\cdot', '(D \\\\cdot C)')\n equation.scale(1.2)\n equation.next_to(text_group, DOWN, buff=0.8)\n equation[0].set_color(YELLOW)\n equation[2].set_color(ORANGE)\n equation[3].set_color(GREEN)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n self.wait(0.5)\n self.play(Write(text_group[0:2]))\n self.wait(1)\n self.play(Write(text_group[2:4]))\n self.wait(1)\n self.play(Write(equation))\n self.wait(1)\n frame = SurroundingRectangle(equation, color=YELLOW, buff=0.2)\n self.play(Create(frame))\n self.wait(2)\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n self.wait(0.5)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create a ManimCE scene (`VectorFieldFlow`) with `Axes(x_axis_config={'include_tip': True})` and `Arrow` vectors using a 2D `(u, v)` vector function.", "chosen": "```python\nfrom manim import *\n\nclass VectorFieldFlow(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-3, 3],\n x_length=6,\n y_length=6,\n tips=True\n ).add_coordinates()\n \n self.add(axes)\n self.wait(1)\n\n # Define the vector field function u=x^2, v=y^2\n def func(pos):\n x, y = pos[:2]\n return np.array([\n max(-0.8 + abs(x) ** 2, 0),\n max(-0.8 + abs(y) ** 2, 0),\n 0\n ])\n \n # Generate arrows representing the flow of the vector field\n arrow_group = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n start = np.array([i, j, 0])\n end = start + func(start)\n if not any(abs(end - start) < 0.1): # Filter very small vectors\n arr = Arrow(start, end, color=blue, buff=0).set_opacity(0.8)\n arrow_group.add(arr)\n \n self.play(Create(arrow_group), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass VectorFieldFlow(Scene):\n def construct(self):\n # --- Configuration ---\n \n # Define the domain for our 2D grid of points\n x_start = -3\n y_start = -2\n step_size = 1\n \n # Create axes with tips included on both ends\n axes = Axes(\n x_range=[-6, 6, 2],\n y_range=[-4, 4, 2],\n x_axis_config={\n 'numbers_to_include': [-6, -4, -2, 0, 2, 4, 6], \n 'include_tip': False\n },\n y_axis_config={\n 'numbers_to_exclude': [0],\n 'numbers_with_elongated_ticks': [],\n 'include_tip': True,\n }\n ).shift(LEFT*3)\n \n # Add labels explicitly since include_tip is set to false initially\n x_label = MathTex(\"X\").next_to(axes.c2p(-6, 0), DOWN, buff=0).set_color(RED)\n y_label = MathTex(\"Y\").next_to(axes.c2p(0, 4), LEFT, buff=0).set_color(GREEN)\n \n self.add(axes, x_label, y_label)\n\n # --- Function Definition ---\n # Simple scalar field F(x,y) = sin(sqrt(x^2 + y^2))\n def scalar_field(pos):\n x, y = pos\n r = np.sqrt(x**2 + y**2)\n return np.sin(r)\n \n # Vector Field u, v components from gradient\n # Grad(F) = (-cos(r)x/r, -cos(r)y/r)\n def vector_field(point):\n x, y = point\n r = max(0.01, np.sqrt(x**2 + y**2)) # Avoid division by zero\n cos_r = np.cos(np.sqrt(x**2 + y**2))\n \n u = -cos_r * x / r\n v = -cos_r * y / r\n \n # Scale arrows so they're visible but not too large\n scale_factor = 1\n return Arrow([x, y, 0], [x + u*scale_factor, y + v*scale_factor, 0], color=WHITE)\n\n # --- Grid Generation ---\n # Generate grid points across specified range with given spacing\n grid_points = VGroup()\n for i in np.arange(x_start, 7, step_size): # End at 6 to stay within view bounds\n for j in np.arange(y_start, 5, step_size):\n if i != 0 or j != 0: # Skip origin to avoid overlap issues\n grid_point = Dot(axes.c2p(i, j), radius=0.03)\n grid_points.add(grid_point)\n \n # Animate creation of dots for visual flow effect\n dots_animation = LaggedStart(*grid_points.animate.scale(1.2), lag_ratio=0.1)\n dots_animation.update_runtime(4.0)\n \n # Draw vectors at each dot location\n vectors = VGroup()\n for dot in grid_points:\n vec = vector_field(dot.get_center())\n vectors.add(vec)\n \n vectors_animated = LaggedStart(*vectors, lag_ratio=0.03)\n vectors_animated.update_runtime(8.0)\n\n # --- Animation Sequence ---\n\n # Step 1: Display Domain Dots\n self.play(dots_animation)\n self.wait(1)\n\n # Step 2: Streamline Flow Visualization\n self.play(Create(vectors), run_time=9)\n \n # Highlight key paths based on initial direction flow\n highlight_paths = [\n [[1, 1], [2, 2]], # Diagonal up-right\n [[-1, -1], [-2, -2]], # Diagonal down-left\n [[1, -1], [2, -2]], # Downward diagonal\n [[-1, 1], [-2, 2]] # Upward diagonal\n ]\n \n path_groups = []\n for start_pt, end_pt in highlight_paths:\n line_group = VGroup(\n Line(axes.c2p(start_pt[0], start_pt[1]), axes.c2p(end_pt[0], end_pt[1]), stroke_width=6, stroke_opacity=0),\n Line(axes.c2p(start_pt[0], start_pt[1]), axes.c2p(end_pt[0], end_pt[1]), stroke_width=6, stroke_color=GREEN)\n )\n path_groups.append(line_group)\n \n self.play(LaggedStart(*path_groups, lag_ratio=0.2))\n\n # Final Hold\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Can you create an educational animation that shows how to find the area under the curve of the function x^2 from x=1 to x=3, including the steps of calculating the integral, plugging in the upper and lower limits, evaluating those, and then presenting the final solution?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Setup Axes ---\n axes = Axes(\n x_range=[-0.5, 3.5, 1],\n y_range=[-0.5, 6, 1]\n )\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n self.add(axes, labels)\n self.wait()\n\n # --- Step 2: Plot Function ---\n graph = axes.plot(lambda x: x**2, color=BLUE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2).set_color(BLUE)\n \n self.play(Create(graph))\n self.play(Write(graph_label))\n self.wait()\n \n # Highlight the region between x=1 and x=3\n area = axes.get_area(graph, x_range=(1, 3), color=GREEN, opacity=0.3)\n \n self.play(FadeIn(area))\n self.wait()\n\n # --- Step 3: Display Integral Notation ---\n integral_notation = MathTex(\"\\\\int_{1}^{3}\", \"x^2\", \"\\\\, dx\")\n integral_notation.to_edge(UP)\n integral_notation.scale(1.2)\n\n self.play(Write(integral_notation))\n self.wait()\n\n # Show antiderivative step\n antiderivative_step = MathTex(\"\\\\left[ \\\\frac{x^3}{3} \\\\right]_{1}^{3}\")\n antiderivative_step.next_to(integral_notation, DOWN, aligned_edge=LEFT)\n antiderivative_step.shift(RIGHT * 0.5)\n \n self.play(Write(antiderivative_step))\n\n # Calculate by plugging in limits\n calculation_step = MathTex(\"\\\\frac{3^3}{3} - \\\\frac{1^3}{3}\")\n calculation_step.move_to(antiderivative_step)\n \n self.play(TransformMatchingTex(antiderivative_step, calculation_step))\n self.wait()\n\n # Final result\n final_solution = MathTex(\"\\\\frac{27}{3} - \\\\frac{1}{3}\", \"=\", \"\\\\frac{26}{3}\")\n final_solution.move_to(calculation_step)\n final_result_box = SurroundingRectangle(final_solution, color=YELLOW, buff=MED_LARGE_BUFF)\n\n self.play(ReplacementTransform(calculation_step, final_solution))\n self.wait()\n\n # Box around the final answer for emphasis\n self.play(Create(final_result_box))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- Step 1: Graphical Representation ---\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n tips=False,\n )\n \n graph = axes.plot(lambda x: x**2, color=BLUE)\n labels = axes.get_axes_labels(\"x\", \"f(x)\")\n \n self.play(Create(axes), Create(graph), Write(labels))\n self.wait(1)\n\n # Add shaded region for integration bounds\n area = axes.get_area(graph, x_range=(1, 3), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Highlight vertical boundaries\n line_left = DashedLine(start=ORIGIN, end=UP*8, stroke_width=2).shift(RIGHT*1)\n line_right = DashedLine(start=ORIGIN, end=UP*16, stroke_width=2).shift(RIGHT*3)\n self.play(Create(line_left), Create(line_right))\n\n # Display equation f(x) = x^2\n eq_func = MathTex(\"f(x)\", \"=\", \"x^2\").to_edge(UP)\n self.play(Write(eq_func))\n self.wait(1)\n\n # --- Step 2: Integral Calculation ---\n \n # Animate the step-by-step calculation of the definite integral\n integral_calc = MathTex(\"\\\\int_{1}^{3}\", \"x^2\", \"\\\\,dx\")\n self.play(Write(integral_calc.to_edge(DOWN)))\n self.wait(0.5)\n\n antideriv = MathTex(\"\\\\left[ \\\\frac{x^3}{3} \\\\right]\", \"_{1}\", \"^{3}\")\n antideriv.next_to(integral_calc, DOWN, buff=0.5)\n self.play(Write(antideriv))\n self.wait(0.5)\n\n # --- Step 3: Substitution of Limits ---\n \n # Show substitution of upper limit (3) and lower limit (1)\n eval_at_limits = MathTex(\"\\\\frac{3^3}{3}\", \"-\", \"\\\\frac{1^3}{3}\")\n eval_at_limits.next_to(antideriv, RIGHT, buff=0.5)\n self.play(Write(eval_at_limits))\n self.wait(0.5)\n\n # Simplify numerical calculations\n calc_simplification = MathTex(\"=\", \"\\\\frac{27}{3}\", \"-\", \"\\\\frac{1}{3}\")\n calc_simplification.next_to(eval_at_limits, RIGHT, buff=0.5)\n self.play(Write(calc_simplification))\n self.wait(0.5)\n\n # Final arithmetic evaluation\n final_arithmetic = MathTex(\"=\", \"\\\\frac{26}{3}\")\n final_arithmetic.next_to(calc_simplification, RIGHT, buff=0.5)\n self.play(Write(final_arithmetic))\n self.wait(1)\n\n # --- Step 4: Conclusion ---\n \n # Present the final calculated value clearly\n result_box = RoundedRectangle(corner_radius=0.2, width=4, height=1.5)\n final_result = MathTex(\"\\\\text{Area} =\", \"\\\\frac{26}{3} \\\\\\\\\", r\"\\approx \", \"8.67\")\n final_result.move_to(result_box.get_center())\n \n self.play(\n FadeIn(result_box),\n Write(final_result)\n )\n\n # Emphasize the answer by highlighting it briefly\n box_animation = SurroundWithColor(result_box, color=YELLOW)\n self.play(box_animation, run_time=1)\n\n # Hold the conclusion on screen\n self.wait(2)\n\n# To render this animation, save the code above to a file named 'area_under_curve.py'\n# Then run the command: manim -pql area_under_curve.py AreaUnderCurve\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Here's an enhanced version of the documentation configuration with additional features and explanations:\n\nThe enhanced documentation configuration builds upon the original by adding comprehensive documentation features while maintaining all existing settings. It now includes intersphinx mapping for linking to Python standard library documentation, automatic API documentation generation through autosummary, improved theme customization with logo and favicon support, and version-specific documentation using the releases extension. The configuration also enables SVG image support through sphinx.ext.imgconverter and adds MathJax for mathematical notation. The HTML output is further enhanced with custom CSS in the _static directory and sidebar customization through html_theme_options. The build process now automatically generates API documentation for all modules while excluding test files, and includes improved search functionality through the html_search_options setting. The documentation version is dynamically set from the package version, and the configuration includes comprehensive settings for PDF output through LaTeX customization. All original paths and exclusions are preserved while adding these new capabilities to create a more robust and feature-rich documentation system.", "chosen": "```python\n\"\"\"\nThis script demonstrates how to animate a simple arithmetic problem step-by-step,\nusing Manim Community Edition (ManimCE) v0.19+. The animation shows the calculation \nof 8 divided by 6, demonstrating both integer division and floating point results.\n\nKey Features:\n- Step-by-step visual representation of mathematical operations\n- Highlighting intermediate steps for clarity\n- Simultaneous display of integer and decimal outputs\n\nRun this script with 'manim -pql filename.py ArithmeticProblem' to view the full animation.\n\"\"\"\n\nfrom manim import *\n\nclass ArithmeticProblem(Scene):\n def construct(self):\n # --- Configuration ---\n # Define colors for visual emphasis\n HIGHLIGHT_COLOR = YELLOW\n RESULT_COLOR = BLUE\n \n # Create initial text objects with large font size for visibility\n title = Text(\"Dividing 8 by 6\", font_size=36).to_edge(UP)\n \n # Display the basic equation clearly\n equation_base = MathTex(\"8 \\\\div 6\").scale(1.5)\n self.play(Write(title))\n self.play(Write(equation_base))\n self.wait(1)\n\n # --- Integer Division Sequence ---\n # Show the method for dividing integers first\n int_step = MathTex(\n r\"8 \\div 6 \\approx 1\"\n ).next_to(equation_base, DOWN, buff=0.7).set_color(HIGHLIGHT_COLOR)\n \n self.play(Write(int_step))\n self.wait(2)\n\n # Animate a box around the result to isolate it\n box_integer = SurroundingRectangle(int_step, color=RESULT_COLOR, buff=MED_LARGE_BUFF)\n self.play(Create(box_integer))\n self.wait(2)\n \n # Clear the integer sequence elements for the decimal part\n self.remove(int_step, box_integer)\n\n # --- Decimal Result Sequence ---\n # Re-render the math object to ensure consistent styling across steps\n equation_decimal = MathTex(\"8 / 6\").scale(1.5).move_to(equation_base.get_center())\n self.play(Transform(equation_base, equation_decimal))\n\n # Display the exact fraction format\n frac_result = MathTex(\"\\\\frac{8}{6}\").scale(1.5).next_to(equation_base, DOWN, buff=0.7)\n self.play(Write(frac_result))\n\n # Simplify the fraction to show the reduced form explicitly\n simplified_frac = MathTex(\"\\\\frac{4}{3}\").scale(1.5).next_to(frac_result, RIGHT, buff=0.2)\n self.play(Write(simplified_frac))\n \n # Convert the fraction to its approximate decimal value\n dec_value = MathTex(\"\\\\approx 1.333\\\\ldots\")\n dec_value.next_to(simplified_frac, RIGHT, buff=0.2).set_color(YELLOW)\n self.play(FadeIn(dec_value, shift=RIGHT * 0.5))\n \n # Group the final components for highlighting and scaling up\n final_group = VGroup(equation_base, frac_result, simplified_frac, dec_value)\n self.wait(1)\n\n # Scale up the entire solution set for a moment of emphasis\n self.play(final_group.animate.scale(1.2).set_color(GOLD))\n self.wait(1)\n\n# To run this script, save it as a .py file and execute:\n# manim -pql filename.py ArithmeticProblem\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass VectorFieldScene(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-2, 2, 0.5],\n y_range=[-2, 2, 0.5],\n x_length=6,\n y_length=6,\n ).shift(LEFT * 2 + DOWN * 0.5)\n\n labels = axes.get_axis_labels(x_label=\"X\", y_label=\"Y\")\n\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # Define a simple vector field function\n def vector_field(point):\n x = point[0]\n y = point[1]\n \n # Calculate magnitude based on distance from origin\n mag = np.sqrt(x**2 + y**2)\n \n # Limit vectors near the origin to prevent blow-up\n if mag > 1:\n return np.array([x, y, 0]) * 0.7\n else:\n return np.array([x, y, 0])\n\n # Create a grid of dots representing points where vectors will be drawn\n dot_grid = VGroup()\n \n for i in range(-4, 5): \n for j in range(-4, 5):\n dot = Dot(axes.c2p(i, j) + UP * 0.1, color=WHITE)\n dot_grid.add(dot)\n\n self.add(dot_grid)\n\n # Animate vectors being added one by one\n vectors = []\n for dot in dot_grid:\n pos = dot.get_center()\n \n # Draw vector line from dot position\n start_point = pos\n \n # Determine end point based on vector direction\n end_point = start_point + vector_field(pos)\n \n # Add arrow to group so they move together\n arrow = Arrow(start=start_point, end=end_point, buff=0.1, max_tip_length_to_length_ratio=0.2)\n vectors.append(arrow)\n\n self.add(vectors)\n self.wait()\n\n # Display a title above the vectors\n title = Text(\"Vector Field Visualization\").to_edge(UP)\n self.play(Write(title))\n\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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 Points and Difficulties\n### Key Points: Differences between Block Ciphers and Stream Ciphers, Various Modes of Operation\n* The core difference lies in the method of data processing: block processing (which requires padding) vs stream processing (which does not require padding).\n* Focus on understanding the operation mechanisms of the four modes: ECB (not recommended), CBC (classic), CTR (efficient), and GCM (secure and efficient).\n\n\nThe context of this section (from highest to current level):\n# Basics of Symmetric Cryptography\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CipherModes(Scene):\n\n def construct(self):\n title = Text('Block vs Stream Ciphers & Modes', 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 block_title = Text('Block Cipher', font_size=28, color=BLUE)\n block_desc = Text('Block processing, requires padding', font_size=20)\n b1 = Text('Block', font_size=16)\n b2 = Text('Block', font_size=16)\n b3 = Text('Pad', font_size=16, color=ORANGE)\n sr1 = SurroundingRectangle(b1, color=BLUE, buff=0.15)\n sr2 = SurroundingRectangle(b2, color=BLUE, buff=0.15)\n sr3 = SurroundingRectangle(b3, color=ORANGE, buff=0.15)\n blocks = VGroup(VGroup(b1, sr1), VGroup(b2, sr2), VGroup(b3, sr3)).arrange(RIGHT, buff=0.1)\n block_vgroup = VGroup(block_title, block_desc, blocks).arrange(DOWN, buff=0.3)\n stream_title = Text('Stream Cipher', font_size=28, color=GREEN)\n stream_desc = Text('Stream processing, no padding', font_size=20)\n s_text = Text('Continuous Data Stream...', font_size=16, color=GREEN)\n s_rect = SurroundingRectangle(s_text, color=GREEN, buff=0.15)\n stream_vis = VGroup(s_text, s_rect)\n stream_vgroup = VGroup(stream_title, stream_desc, stream_vis).arrange(DOWN, buff=0.3)\n compare_group = VGroup(block_vgroup, stream_vgroup).arrange(RIGHT, buff=1.0)\n compare_group.next_to(title_group, DOWN, buff=0.4)\n self.play(FadeIn(compare_group, shift=UP), run_time=2)\n modes_title = Text('Modes of Operation', font_size=28, color=YELLOW)\n mode_ecb = VGroup(Text('ECB', font_size=24, weight=BOLD), Text('Not recommended', font_size=18)).arrange(DOWN, buff=0.1)\n rect_ecb = SurroundingRectangle(mode_ecb, color=RED, buff=0.2)\n grp_ecb = VGroup(rect_ecb, mode_ecb)\n mode_cbc = VGroup(Text('CBC', font_size=24, weight=BOLD), Text('Classic', font_size=18)).arrange(DOWN, buff=0.1)\n rect_cbc = SurroundingRectangle(mode_cbc, color=BLUE, buff=0.2)\n grp_cbc = VGroup(rect_cbc, mode_cbc)\n mode_ctr = VGroup(Text('CTR', font_size=24, weight=BOLD), Text('Efficient', font_size=18)).arrange(DOWN, buff=0.1)\n rect_ctr = SurroundingRectangle(mode_ctr, color=TEAL, buff=0.2)\n grp_ctr = VGroup(rect_ctr, mode_ctr)\n mode_gcm = VGroup(Text('GCM', font_size=24, weight=BOLD), Text('Secure and Efficient', font_size=18)).arrange(DOWN, buff=0.1)\n rect_gcm = SurroundingRectangle(mode_gcm, color=GREEN, buff=0.2)\n grp_gcm = VGroup(rect_gcm, mode_gcm)\n row1 = VGroup(grp_ecb, grp_cbc).arrange(RIGHT, buff=1.0)\n row2 = VGroup(grp_ctr, grp_gcm).arrange(RIGHT, buff=1.0)\n modes_grid = VGroup(row1, row2).arrange(DOWN, buff=0.3)\n modes_section = VGroup(modes_title, modes_grid).arrange(DOWN, buff=0.3)\n modes_section.next_to(compare_group, DOWN, buff=0.4)\n self.play(Write(modes_title), run_time=1)\n self.play(Create(rect_ecb), Write(mode_ecb), Create(rect_cbc), Write(mode_cbc), run_time=1.5)\n self.play(Create(rect_ctr), Write(mode_ctr), Create(rect_gcm), Write(mode_gcm), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CipherModes(Scene):\n\n def construct(self):\n title = Text('Block vs Stream Ciphers & Modes', 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 block_title = Text('Block Cipher', font_size=28, color=BBLUE)\n block_desc = Text('Block processing, requires padding', font_size=20)\n b1 = Text('Block', font_size=16)\n b2 = Text('Block', font_size=16)\n b3 = Text('Pad', font_size=16, color=ORANGE)\n sr1 = SurroundingRectangle(b1, color=BLUE, buff=0.15)\n sr2 = SurroundingRectangle(b2, color=BLUE, buff=0.15)\n sr3 = SurroundingRectangle(b3, color=ORANGE, buff=0.15)\n blocks = VGroup(VGroup(b1, sr1), VGroup(b2, sr2), VGroup(b3, sr3)).arrange(RIGHT, buff=0.1)\n block_vgroup = VGroup(block_title, block_desc, blocks).arrange(DOWN, buff=0.3)\n stream_title = Text('Stream Cipher', font_size=28, color=GREEN)\n stream_desc = Text('Stream processing, no padding', font_size=20)\n s_text = Text('Continuous Data Stream...', font_size=16, color=GREEN)\n s_rect = SurroundingRectangle(s_text, color=GREEN, buff=0.15)\n stream_vis = VGroup(s_text, s_rect)\n stream_vgroup = VGroup(stream_title, stream_desc, stream_vis).arrange(DOWN, buff=0.3)\n compare_group = VGroup(block_vgroup, stream_vgroup).arrange(RIGHT, buff=1.0)\n compare_group.next_to(title_group, DOWN, buff=0.4)\n self.play(FadeIn(compare_group, shift=UP), run_time=2)\n modes_title = Text('Modes of Operation', font_size=28, color=YELLOW)\n mode_ecb = VGroup(Text('ECB', font_size=24, weight=BOLD), Text('Not recommended', font_size=18)).arrange(DOWN, buff=0.1)\n rect_ecb = SurroundingRectangle(mode_ecb, color=RED, buff=0.2)\n grp_ecb = VGroup(rect_ecb, mode_ecb)\n mode_cbc = VGroup(Text('CBC', font_size=24, weight=BOLD), Text('Classic', font_size=18)).arrange(DOWN, buff=0.1)\n rect_cbc = SurroundingRectangle(mode_cbc, color=BLUE, buff=0.2)\n grp_cbc = VGroup(rect_cbc, mode_cbc)\n mode_ctr = VGroup(Text('CTR', font_size=24, weight=BOLD), Text('Efficient', font_size=18)).arrange(DOWN, buff=0.1)\n rect_ctr = SurroundingRectangle(mode_ctr, color=TEAL, buff=0.2)\n grp_ctr = VGroup(rect_ctr, mode_ctr)\n mode_gcm = VGroup(Text('GCM', font_size=24, weight=BOLD), Text('Secure and Efficient', font_size=18)).arrange(DOWN, buff=0.1)\n rect_gcm = SurroundingRectangle(mode_gcm, color=GREEN, buff=0.2)\n grp_gcm = VGroup(rect_gcm, mode_gcm)\n row1 = VGroup(grp_ecb, grp_cbc).arrange(RIGHT, buff=1.0)\n row2 = VGroup(grp_ctr, grp_gcm).arrange(RIGHT, buff=1.0)\n modes_grid = VGroup(row1, row2).arrange(DOWN, buff=0.3)\n modes_section = VGroup(modes_title, modes_grid).arrange(DOWN, buff=0.3)\n modes_section.next_to(compare_group, DOWN, buff=0.4)\n self.play(Write(modes_title), run_time=1)\n self.play(Create(rect_ecb), Write(mode_ecb), Create(rect_cbc), Write(mode_cbc), run_time=1.5)\n self.play(Create(rect_ctr), Write(mode_ctr), Create(rect_gcm), Write(mode_gcm), run_time=1.5)\n self.wait(1)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### Example to Establish a Template\nThis example illustrates a standard proof template: choose a string $\\to$ limit the range of decompositions $\\to$ pump to destroy structure $\\to$ reach a contradiction.\n\n## Common Misconceptions with the Pumping Lemma\n\n### Incorrect String Selection\nChoosing a string that is too simple (e.g., $(ab)^p$), even if it remains in the language after pumping, does not prove that the language is regular; it only indicates that a counterexample has not been found.\n\n\nThe context of this section (from highest to current level):\n# 7. Closure Properties and the Pumping Lemma for Regular Languages\n## Typical Examples of the Pumping Lemma\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PumpingLemmaExamples(Scene):\n\n def construct(self):\n title = Title('Typical Examples of the Pumping Lemma', font_size=40)\n self.play(FadeIn(title))\n template_title = Text('1. Standard Proof Template', color=BLUE_C, font_size=32)\n template_title.next_to(title, DOWN, buff=0.4).align_to(title, LEFT)\n template_title.shift(RIGHT * 0.5)\n self.play(Write(template_title))\n steps = ['Choose a string', 'Limit the range\\nof decompositions', 'Pump to destroy\\nstructure', 'Reach a\\ncontradiction']\n flowchart_boxes = VGroup()\n for step in steps:\n box = VGroup(Rectangle(width=3.0, height=1.2, color=WHITE, fill_color=BLUE_E, fill_opacity=0.6), Text(step, font_size=22).move_to(ORIGIN))\n flowchart_boxes.add(box)\n else:\n pass\n flowchart_boxes.arrange(RIGHT, buff=0.8)\n arrows = VGroup()\n for i in range(len(flowchart_boxes) - 1):\n arrow = Arrow(start=flowchart_boxes[i].get_right(), end=flowchart_boxes[i + 1].get_left(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=YELLOW)\n arrows.add(arrow)\n else:\n pass\n full_flowchart = VGroup(flowchart_boxes, arrows)\n full_flowchart.scale_to_fit_width(config.frame_width - 1.5)\n full_flowchart.next_to(template_title, DOWN, buff=0.4)\n full_flowchart.align_to(template_title, LEFT)\n for i in range(len(flowchart_boxes)):\n self.play(Create(flowchart_boxes[i][0]), Write(flowchart_boxes[i][1]), run_time=0.6)\n if i < len(arrows):\n self.play(GrowArrow(arrows[i]), run_time=0.4)\n else:\n pass\n else:\n pass\n misc_title = Text('2. Common Misconceptions: Incorrect String Selection', color=RED_C, font_size=32)\n misc_title.next_to(full_flowchart, DOWN, buff=0.8).align_to(template_title, LEFT)\n self.play(FadeIn(misc_title))\n warning_lines = VGroup(Tex('Choosing a string that is too simple (e.g., $(ab)^p$),', font_size=30), Tex('even if it remains in the language after pumping,', font_size=30), Tex('does not prove that the language is regular;', font_size=30), Tex('it only indicates that a counterexample has not been found.', font_size=30, color=YELLOW)).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n warning_lines.next_to(misc_title, DOWN, buff=0.3).align_to(misc_title, LEFT)\n warning_lines.shift(RIGHT * 0.5)\n for line in warning_lines:\n self.play(Write(line), run_time=0.8)\n else:\n pass\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PumpingLemmaExamples(Scene):\n\n def construct(self):\n title = Title('Typical Examples of the Pumping Lemma', font_size=40)\n self.play(FadeIn(title))\n template_title = Text('1. Standard Proof Template', color=BBLUE_C, font_size=32)\n template_title.next_to(title, DOWN, buff=0.4).align_to(title, LEFT)\n template_title.shift(RIGHT * 0.5)\n self.play(Write(template_title))\n steps = ['Choose a string', 'Limit the range\\nof decompositions', 'Pump to destroy\\nstructure', 'Reach a\\ncontradiction']\n flowchart_boxes = VGroup()\n for step in steps:\n box = VGroup(Rectangle(width=3.0, height=1.2, color=WHITE, fill_color=BLUE_E, fill_opacity=0.6), Text(step, font_size=22).move_to(ORIGIN))\n flowchart_boxes.add(box)\n else:\n pass\n flowchart_boxes.arrange(RIGHT, buff=0.8)\n arrows = VGroup()\n for i in range(len(flowchart_boxes) - 1):\n arrow = Arrow(start=flowchart_boxes[i].get_right(), end=flowchart_boxes[i + 1].get_left(), buff=0.1, max_tip_length_to_length_ratio=0.2, color=YELLOW)\n arrows.add(arrow)\n else:\n pass\n full_flowchart = VGroup(flowchart_boxes, arrows)\n full_flowchart.scale_to_fit_width(config.frame_width - 1.5)\n full_flowchart.next_to(template_title, DOWN, buff=0.4)\n full_flowchart.align_to(template_title, LEFT)\n for i in range(len(flowchart_boxes)):\n self.play(Create(flowchart_boxes[i][0]), Write(flowchart_boxes[i][1]), run_time=0.6)\n if i < len(arrows):\n self.play(GrowArrow(arrows[i]), run_time=0.4)\n else:\n pass\n else:\n pass\n misc_title = Text('2. Common Misconceptions: Incorrect String Selection', color=RED_C, font_size=32)\n misc_title.next_to(full_flowchart, DOWN, buff=0.8).align_to(template_title, LEFT)\n self.play(FadeIn(misc_title))\n warning_lines = VGroup(Tex('Choosing a string that is too simple (e.g., $(ab)^p$),', font_size=30), Tex('even if it remains in the language after pumping,', font_size=30), Tex('does not prove that the language is regular;', font_size=30), Tex('it only indicates that a counterexample has not been found.', font_size=30, color=YELLOW)).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n warning_lines.next_to(misc_title, DOWN, buff=0.3).align_to(misc_title, LEFT)\n warning_lines.shift(RIGHT * 0.5)\n for line in warning_lines:\n self.play(Write(line), run_time=0.8)\n else:\n pass\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0072(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_revolutionarytransformat()\n self.clear_stage()\n self.act_2_naivebayesrule()\n\n def act_1_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_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0072(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_revolutionarytransformat()\n self.clear_stage()\n self.act_2_naivebayesrule()\n\n def act_1_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_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```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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\nTherefore, the pipeline mainly improves the **number of instructions completed per unit of time**, rather than the processing speed of individual tasks.\n\n## Relationship Between Pipeline Depth and Benefits\n\nIncreasing the number of pipeline stages (deepening the pipeline, i.e., Superpipelining) theoretically can:\n\n- Further divide the logic delay of each stage, shortening the clock cycle;\n- Increase the potential maximum clock frequency.\n\n\nThe context location of this section (from highest level to current):\n# Instruction Pipeline Basics - Course Notes\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass PipelineDepthScene(Scene):\n\n def construct(self):\n title = Text('Pipeline Depth', font_size=36)\n subtitle = Text('Relationship between Depth and Performance', font_size=28)\n group = VGroup(title, subtitle).arrange(DOWN, buff=0.2)\n self.play(Write(group))\n box = RoundedRectangle(width=7, height=1.5, corner_radius=0.3)\n arrow = Arrow(box.get_right(), box.get_left())\n label_box = Text('Pipelined Execution\\n(per instruction)', font_size=20)\n label_arrow = MathTex('\\\\rightarrow', font_size=36)\n labels = VGroup(label_box, label_arrow).arrange(RIGHT, buff=0.2)\n labels.next_to(arrow, UP, buff=-0.2)\n self.play(Create(box), GrowArrow(arrow), FadeIn(labels))\n bullet1 = Text('- Logic Delay Division', color=GREEN)\n bullet2 = Text('- Clock Cycle Shortening')\n bullet3 = Text('- Maximum Frequency Gain')\n bullets = VGroup(bullet1, bullet2, bullet3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n for b in bullets:\n b.to_edge(UP, buff=1.5)\n b.shift((box.get_center()[0] + b.get_width()) * RIGHT)\n else:\n None\n desc1 = Text('Deepening the pipeline divides stage delays,\\nreducing overall clock cycles.')\n desc2 = Text('With shorter cycles, we can achieve higher frequencies.\\nThis enables more instructions per second.')\n descs = VGroup(desc1, desc2).arrange(DOWN, aligned_edge=RIGHT, buff=0.2)\n for d in descs:\n d.to_edge(DOWN, buff=1)\n d.shift((-box.get_center()[0] - d.get_width()) * LEFT)\n else:\n None\n for item, desc in zip([bullet2, bullet3], [desc1, desc2]):\n rect = SurroundingRectangle(item, color=YELLOW, buff=0.15)\n self.play(Create(rect), Write(desc))\n else:\n pass\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass PipelineDepthBenefits(Scene):\n\n def construct(self):\n title = Text('Relationship Between Pipeline Depth and Benefits', font_size=36)\n subtitle = Text(\"Deepening the pipeline (Superpipelining)\", font_size=28, color=GREEN).next_to(title, DOWN, buff=0.25)\n \n bullet_text = 'Further divide the logic delay of each stage, shortening the clock cycle;\\nIncrease the potential maximum clock frequency.'\n bullets = Text(bullet_text, font_size=28, t2c={'shortening': YELLOW, 'increase': BLUE}).to_edge(LEFT, buff=1.5).shift(DOWN * 1)\n box = SurroundingRectangle(VGroup(subtitle, bullets), buff=0.3, color=ORANGE, corner_radius=0.15)\n \n self.play(FadeIn(title))\n self.play(Write(subtitle))\n self.play(Create(box), FadeIn(bullets))\n \n # Create diagram components\n label_input = Text('Input', font_size=24).move_to(np.array([-5, 2.5, 0]))\n input_box = RoundedRectangle(width=2, height=1.2, corner_radius=0.15, fill_opacity=0.1, stroke_width=2).move_to(label_input.get_center())\n line1 = Line(start=input_box.get_right(), end=np.array([0, 2.5, 0]), stroke_width=2)\n \n labels_stages = ['Stage A', 'Stage B', 'Stage C'].copy()\n boxes_stages = [RoundedRectangle(width=2, height=1.2, corner_radius=0.15, fill_color=YELLOW, fill_opacity=0.2, stroke_width=1) for _ in range(len(labels_stages))]\n lines_stages = []\n \n for i, b in enumerate(range(-2 + len(boxes_stages), 3)):\n start_point = np.array([b, -2, 0])\n \n if i == 0:\n start_point += np.array([0, 2.5, 0])\n \n for j in range(i + 1, min(2, i + 1)):\n lines_stages.append(Line(start=start_point, end=start_point + UP * 2.7, stroke_width=2, dash_pattern=[2, 1], opacity=0.5))\n start_point += UP * 1.3\n \n else:\n start_point += np.array([0, 0, 0])\n \n for j in range(i, min(2, i + 1)):\n lines_stages.append(Line(start=start_point, end=start_point + UP * 2.7, stroke_width=2, dash_pattern=[2, 1], opacity=0.5))\n start_point += UP * 1.3\n \n start_point += DOWN * 0.5\n \n boxes_stages[i].move_to(start_point)\n\n else:\n pass\n \n last_label = Text('Output', font_size=24).move_to(np.array([3, -2, 0]))\n last_box = RoundedRectangle(width=2, height=1.2, corner_radius=0.15, fill_opacity=0.1, stroke_width=2).move_to(last_label.get_center())\n\n # Animate Diagram Components\n self.play(Write(label_input))\n self.play(Create(input_box), GrowArrow(line1))\n \n for l, b in zip(labels_stages, boxes_stages):\n txt_obj = Text(l, font_size=24).move_to(b.get_top())\n \n if l == 'Stage A':\n self.play(Write(txt_obj), Create(b), RunTime(1.5))\n elif l == 'Stage C' and \"output\" in str(l):\n self.play(Create(b), Write(txt_obj), RunTime(1.5))\n else:\n self.play(GrowFromCenter(b), Write(txt_obj))\n \n self.play(Create(lines_stages), RunTime(1.5))\n \n self.play(Write(last_box), Write(last_label))\n\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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 top of the screen and then show a title saying \"Linear transformation effect\". After that, there should be a grid representing the 2D plane and a yellow vector starting from the origin. This vector should then be transformed according to the matrix, changing its color to red to highlight the effect of the transformation. Finally, the animation should end with a text at the bottom saying \"Transformed Vector\" to emphasize the result. Can the animation also include a small pause between each step to give viewers time to understand what's happening, and then clear the screen at the end?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass LinearTransformationScene(Scene):\n \"\"\"\n An educational animation demonstrating how a 2x2 matrix transforms a 2D vector.\n Designed for students learning linear algebra concepts visually.\n \"\"\"\n def construct(self):\n # Define the 2x2 transformation matrix (Scale + Shear)\n # This matrix maps (x, y) to (2x + y, 0x + 2y)\n matrix_data = np.array([[2, 1], \n [0, 2]])\n \n # Define the original vector v = [2, 1]\n original_coords = np.array([2, 1, 0])\n \n # Calculate the transformed vector: M * v\n transformed_coords = np.dot(matrix_data, original_coords[:2])\n transformed_coords_3d = np.array([transformed_coords[0], transformed_coords[1], 0])\n\n # ------------------------------------------------------------------\n # Step 1: Initialization - Display the matrix at the top\n # ------------------------------------------------------------------\n matrix_tex = Matrix(matrix_data.tolist())\n matrix_tex.to_edge(UP)\n \n matrix_label = Text(\"Transformation Matrix A =\", font_size=28)\n matrix_label.next_to(matrix_tex, LEFT)\n \n matrix_group = VGroup(matrix_label, matrix_tex)\n \n self.play(Write(matrix_group))\n self.wait(1.5) # Pause for comprehension\n\n # ------------------------------------------------------------------\n # Step 2: Title - Show the scene title\n # ------------------------------------------------------------------\n title = Text(\"Linear transformation effect\", font_size=36)\n title.next_to(matrix_group, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.wait(1.5) # Pause to establish context\n\n # ------------------------------------------------------------------\n # Step 3: Scene Setup - Render the coordinate plane grid\n # ------------------------------------------------------------------\n plane = NumberPlane(\n x_range=(-6, 6, 1),\n y_range=(-4, 4, 1),\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.6\n },\n axis_config={\n \"include_numbers\": True,\n \"font_size\": 24,\n \"include_tip\": True\n }\n )\n \n self.play(Create(plane), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Original Vector - Draw a yellow vector from origin\n # ------------------------------------------------------------------\n original_vector = Arrow(\n start=ORIGIN, \n end=original_coords, \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n )\n vector_label = MathTex(r\"\\vec{v}\", color=YELLOW).next_to(original_vector.get_end(), UR, buff=0.1)\n \n self.play(GrowArrow(original_vector), Write(vector_label))\n self.wait(1.5) # Pause to observe the original state\n\n # ------------------------------------------------------------------\n # Step 5: Transformation - Animate vector change + Color shift\n # ------------------------------------------------------------------\n # Animate the vector moving to new coordinates and changing color\n self.play(\n original_vector.animate.put_start_and_end_on(ORIGIN, transformed_coords_3d).set_color(RED),\n vector_label.animate.move_to(transformed_coords_3d + UR * 0.2).set_color(RED),\n run_time=2,\n rate_func=smooth\n )\n self.wait(1.5) # Pause to observe the transformation effect\n\n # ------------------------------------------------------------------\n # Step 6: Conclusion - Display result text at bottom\n # ------------------------------------------------------------------\n conclusion_text = Text(\"Transformed Vector\", font_size=36, color=RED)\n conclusion_text.to_edge(DOWN, buff=1.0)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 7: Cleanup - Clear the screen entirely\n # ------------------------------------------------------------------\n self.clear()\n self.wait(0.5)\n\n# To run this script:\n# 1. Ensure Manim is installed: pip install manim\n# 2. Save this code to a file, e.g., 'linear_transform.py'\n# 3. Run via terminal: manim -pql linear_transform.py LinearTransformationScene\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass LinearTransformationScene(Scene):\n \"\"\"\n An educational animation demonstrating how a 2x2 matrix transforms a 2D vector.\n Designed for students learning linear algebra concepts visually.\n \"\"\"\n def construct(self):\n # Define the 2x2 transformation matrix (Scale + Shear)\n # This matrix maps (x, y) to (2x + y, 0x + 2y)\n matrix_data = np.array([[2, 1], \n [0, 2]])\n \n # Define the original vector v = [2, 1]\n original_coords = np.array([2, 1, 0])\n \n # Calculate the transformed vector: M * v\n transformed_coords = np.dot(matrix_data, original_coords[:2])\n transformed_coords_3d = np.array([transformed_coords[0], transformed_coords[1], 0])\n\n # ------------------------------------------------------------------\n # Step 1: Initialization - Display the matrix at the top\n # ------------------------------------------------------------------\n matrix_tex = Matrix(matrix_data.tolist())\n matrix_tex.to_edge(UP)\n \n matrix_label = Text(\"Transformation Matrix A =\", font_size=28)\n matrix_label.next_to(matrix_tex, LEFT)\n \n matrix_group = VGroup(matrix_label, matrix_tex)\n \n self.play(Write(matrix_group))\n self.wait(1.5) # Pause for comprehension\n\n # ------------------------------------------------------------------\n # Step 2: Title - Show the scene title\n # ------------------------------------------------------------------\n title = Text(\"Linear transformation effect\", font_size=36)\n title.next_to(matrix_group, DOWN, buff=0.5)\n \n self.play(Write(title))\n self.wait(1.5) # Pause to establish context\n\n # ------------------------------------------------------------------\n # Step 3: Scene Setup - Render the coordinate plane grid\n # ------------------------------------------------------------------\n plane = NumberPlane(\n x_range=(-6, 6, 1),\n y_range=(-4, 4, 1),\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.6\n },\n axis_config={\n \"include_numbers\": True,\n \"font_size\": 24,\n \"include_tip\": True\n }\n )\n \n self.play(Create(plane), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 4: Original Vector - Draw a yellow vector from origin\n # ------------------------------------------------------------------\n original_vector = Arrow(\n start=ORIGIN, \n end=original_coords, \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n )\n vector_label = MathTex(r\"\\vec{v}\" + \" = x\", color=YELLOW).next_to(original_vector.get_end(), UR, buff=0.1)\n \n self.play(GrowArrow(original_vector), Write(vector_label))\n self.wait(1.5) # Pause to observe the original state\n\n # ------------------------------------------------------------------\n # Step 5: Transformation - Animate vector change + Color shift\n # ------------------------------------------------------------------\n # Animate the vector moving to new coordinates and changing color\n self.play(\n original_vector.animate.put_start_and_end_on(ORIGIN, transformed_coords_3d).set_color(RED),\n vector_label.animate.move_to(transformed_coords_3d + UR * 0.2).set_color(RED),\n run_time=2,\n rate_func=smooth\n )\n self.wait(1.5) # Pause to observe the transformation effect\n\n # ------------------------------------------------------------------\n # Step 6: Conclusion - Display result text at bottom\n # ------------------------------------------------------------------\n conclusion_text = Text(\"Transformed Vector\", font_size=36, color=RED)\n conclusion_text.to_edge(DOWN, buff=1.0)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 7: Cleanup - Clear the screen entirely\n # ------------------------------------------------------------------\n self.clear()\n self.wait(0.5)\n\n# To run this script:\n# 1. Ensure Manim is installed: pip install manim\n# 2. Save this code to a file, e.g., 'linear_transform.py'\n# 3. Run via terminal: manim -pql linear_transform.py LinearTransformationScene\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Create an educational animation that visually explains the process of solving a triple integral problem step by step. Start with the triple integral of the function xyz over the cube defined by 0 to 1 on all axes. First, display the integral formula on the screen. Then, guide me through each integration step one at a time, integrating first with respect to x, then y, and finally z, using text explanations placed at the top of the screen before each step. At each step, replace the previous mathematical step with the new integral expression that results from performing the integration. After completing all integration steps, show the final numerical answer. Clear the screen before showing me the concluding answer again to reinforce it. Make sure to pause briefly after introducing new information so I can follow along with the computation.", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Initialization ---\n initial_formula = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\"\n )\n initial_formula.scale(1.5)\n \n self.play(Write(initial_formula))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=36, color=BLUE)\n step1_text.to_edge(UP)\n \n # Result after integrating xyz dx from 0 to 1 is (1/2)yz\n step1_formula = MathTex(r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\")\n step1_formula.scale(1.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(initial_formula, step1_formula))\n self.wait(2)\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y\", font_size=36, color=BLUE)\n step2_text.to_edge(UP)\n \n # Result after integrating (1/2)yz dy from 0 to 1 is (1/4)z\n step2_formula = MathTex(r\"\\int_0^1 \\frac{1}{4}z \\, dz\")\n step2_formula.scale(1.5)\n \n self.play(ReplacementTransform(step1_text, step2_text))\n self.wait(1)\n self.play(ReplacementTransform(step1_formula, step2_formula))\n self.wait(2)\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", font_size=36, color=BLUE)\n step3_text.to_edge(UP)\n \n # Result after integrating (1/4)z dz from 0 to 1 is 1/8\n step3_formula = MathTex(r\"\\left[ \\frac{1}{8}z^2 \\right]_0^1 = \\frac{1}{8}\")\n step3_formula.scale(1.5)\n \n self.play(ReplacementTransform(step2_text, step3_text))\n self.wait(1)\n self.play(ReplacementTransform(step2_formula, step3_formula))\n self.wait(3)\n\n # --- Conclusion ---\n # Clear the screen completely\n self.play(FadeOut(step3_text), FadeOut(step3_formula))\n self.wait(1)\n\n # Display the final numerical answer prominently\n final_text = Text(\"Final Answer\", font_size=48)\n final_value = MathTex(r\"\\frac{1}{8}\", font_size=72, color=YELLOW)\n \n final_group = VGroup(final_text, final_value)\n final_group.arrange(DOWN, buff=0.5)\n \n self.play(Write(final_text))\n self.play(Write(final_value))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py TripleIntegralSolution\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Initialization ---\n initial_formula = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\"\n )\n initial_formula.scale(1.5)\n \n self.play(Write(initial_formula))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x\", font_size=36, color=BLUE)\n step1_text.to_edge(UP)\n \n # Result after integrating xyz dx from 0 to 1 is (1/2)yz\n step1_formula = MathTex(r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\")\n step1_formula.scale(1.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n self.play(ReplacementTransform(target_position=ORIGIN, initial_formula, step1_formula))\n self.wait(2)\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y\", font_size=36, color=BLUE)\n step2_text.to_edge(UP)\n \n # Result after integrating (1/2)yz dy from 0 to 1 is (1/4)z\n step2_formula = MathTex(r\"\\int_0^1 \\frac{1}{4}z \\, dz\")\n step2_formula.scale(1.5)\n \n self.play(ReplacementTransform(step1_text, step2_text))\n self.wait(1)\n self.play(ReplacementTransform(step1_formula, step2_formula))\n self.wait(2)\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", font_size=36, color=BLUE)\n step3_text.to_edge(UP)\n \n # Result after integrating (1/4)z dz from 0 to 1 is 1/8\n step3_formula = MathTex(r\"\\left[ \\frac{1}{8}z^2 \\right]_0^1 = \\frac{1}{8}\")\n step3_formula.scale(1.5)\n \n self.play(ReplacementTransform(step2_text, step3_text))\n self.wait(1)\n self.play(ReplacementTransform(step2_formula, step3_formula))\n self.wait(3)\n\n # --- Conclusion ---\n # Clear the screen completely\n self.play(FadeOut(step3_text), FadeOut(step3_formula))\n self.wait(1)\n\n # Display the final numerical answer prominently\n final_text = Text(\"Final Answer\", font_size=48)\n final_value = MathTex(r\"\\frac{1}{8}\", font_size=72, color=YELLOW)\n \n final_group = VGroup(final_text, final_value)\n final_group.arrange(DOWN, buff=0.5)\n \n self.play(Write(final_text))\n self.play(Write(final_value))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py TripleIntegralSolution\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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: 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 2: Can you create an educational animation using Manim that starts by writing the function f(x) = x^2 at the top of the screen? After showing the function, can it plot the graph of the function for x going from -2 to 2? Onc", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0729(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_textshapeanimation()\n self.clear_stage()\n self.act_2_integralareaanimation()\n\n def act_1_textshapeanimation(self):\n text_initial = Text(\"Initial Message\", font_size=36)\n text_new = Text(\"New Message\", font_size=36).shift(UP * 1.5)\n \n # Display initial text\n self.play(Write(text_initial))\n self.wait(1)\n \n # Transition to new message with an upward shift\n self.play(ReplacementTransform(text_initial, text_new))\n self.wait(1)\n \n # Fade out text to prepare the scene for the shapes\n self.play(FadeOut(text_new))\n\n # Step 2: Shape Expansion\n # Create a circle and a star\n circle = Circle(radius=1.0, color=BLUE)\n star = Star(outer_radius=0.5, color=YELLOW, fill_opacity=1)\n \n # Position the star inside the circle at the center\n star.move_to(circle.get_center())\n \n # Group the circle and star to animate them simultaneously\n shapes_group = VGroup(circle, star)\n \n # Create the shapes on screen\n self.play(Create(shapes_group))\n self.wait(1)\n \n # Animate expansion: circle scales up and star moves away from the center\n self.play(\n circle.animate.scale(2.0),\n star.animate.scale(1.5).shift(UP * 1.0),\n run_time=2\n )\n self.wait(1)\n\n # Step 3: Disappearance\n # Animate both shapes disappearing from the screen\n self.play(FadeOut(shapes_group))\n\n def act_2_integralareaanimation(self):\n func_title = MathTex(\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Graph Plotting: Plot f(x) = x^2 for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"color\": WHITE},\n y_axis_config={\"color\": WHITE}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=\"x^2\")\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Indication: Highlight area between x=0 and x=1\n area = axes.get_area(graph, x_range=[0, 1])\n \n # 4. Visual Enhancement: Gradient fill from blue to green with transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_fill(opacity=0.5)\n \n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n self.play(FadeIn(area), Write(integral_label))\n self.wait(1)\n\n # 5. Solution Transformation: Transform label to 1/3 and move to bottom\n solution = MathTex(r\"\\frac{1}{3}\")\n solution.move_to(integral_label.get_center())\n \n self.play(ReplacementTransform(integral_label, solution))\n self.play(solution.animate.to_edge(DOWN))\n self.wait(1)\n\n # 6. Final Scene: Clear everything except the solution\n self.play(\n FadeOut(func_title),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(area)\n )\n \n # Display only the final solution briefly before ending\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0729(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_textshapeanimation()\n self.clear_stage()\n self.act_2_integralareaanimation()\n\n def act_1_textshapeanimation(self):\n text_initial = Text(\"Initial Message\", font_size=36)\n text_new = Text(\"New Message\", font_size=36).shift(UP * 1.5)\n \n # Display initial text\n self.play(Write(text_initial))\n self.wait(1)\n \n # Transition to new message with an upward shift\n self.play(ReplacementTransform(text_initial, text_new))\n self.wait(1)\n \n # Fade out text to prepare the scene for the shapes\n self.play(FadeOut(text_new))\n\n # Step 2: Shape Expansion\n # Create a circle and a star\n circle = Circle(radius=1.0, color=BLUE)\n star = Star(outer_radius=0.5, color=YELLOW, fill_opacity=1)\n \n # Position the star inside the circle at the center\n star.move_to(circle.get_center())\n \n # Group the circle and star to animate them simultaneously\n shapes_group = VGroup(circle, star)\n \n # Create the shapes on screen\n self.play(Create(shapes_group))\n self.wait(1)\n \n # Animate expansion: circle scales up and star moves away from the center\n self.play(\n circle.animate.scale(2.0),\n star.animate.scale(1.5).shift(UP * 1.0),\n run_time=2\n )\n self.wait(1)\n\n # Step 3: Disappearance\n # Animate both shapes disappearing from the screen\n self.play(FadeOut(shapes_group))\n\n def act_2_integralareaanimation(self):\n func_title = MathTex(r\"f(x) = x^2\" + \" = x\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Graph Plotting: Plot f(x) = x^2 for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"color\": WHITE},\n y_axis_config={\"color\": WHITE}\n ).shift(DOWN * 0.5)\n \n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n graph_label = axes.get_graph_label(graph, label=\"x^2\")\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Indication: Highlight area between x=0 and x=1\n area = axes.get_area(graph, x_range=[0, 1])\n \n # 4. Visual Enhancement: Gradient fill from blue to green with transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_fill(opacity=0.5)\n \n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n self.play(FadeIn(area), Write(integral_label))\n self.wait(1)\n\n # 5. Solution Transformation: Transform label to 1/3 and move to bottom\n solution = MathTex(r\"\\frac{1}{3}\")\n solution.move_to(integral_label.get_center())\n \n self.play(ReplacementTransform(integral_label, solution))\n self.play(solution.animate.to_edge(DOWN))\n self.wait(1)\n\n # 6. Final Scene: Clear everything except the solution\n self.play(\n FadeOut(func_title),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(graph_label),\n FadeOut(area)\n )\n \n # Display only the final solution briefly before ending\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "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?", "chosen": "```python\nfrom manim import *\n\nclass BroadcastAnimation(Scene):\n def construct(self):\n # 1. The word \"Broadcast\" appears on screen\n text = Text(\"Broadcast\", font_size=72, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. The word moves upward\n self.play(text.animate.shift(UP * 2.5), run_time=1)\n self.wait(0.2)\n\n # 3. A triangle shape appears\n triangle = Triangle(color=BLUE, fill_opacity=0.8)\n triangle.set_height(1.5)\n triangle.move_to(ORIGIN)\n self.play(FadeIn(triangle, scale=0.5), run_time=1)\n\n # Broadcast Signal: Expanding concentric rings\n waves = VGroup()\n for i in range(4):\n ring = Circle(radius=0.1, color=BLUE_A)\n ring.move_to(triangle.get_center())\n ring.set_stroke(width=4, opacity=0.8)\n waves.add(ring)\n\n # Animate the signal emission with a staggered, continuous effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(20).set_stroke(opacity=0)\n for wave in waves\n ],\n lag_ratio=0.3,\n run_time=2.5,\n rate_func=linear\n )\n )\n self.wait(0.5)\n\n # 4. The triangle disappears\n self.play(FadeOut(triangle, scale=0.5), run_time=0.5)\n self.wait(1)\n\n# To render this animation, use the command:\n# manim -pql filename.py BroadcastAnimation\n```", "rejected": "```python\nfrom manim import *\n\nclass BroadcastAnimation(Scene):\n def construct(self):\n # 1. The word \"Broadcast\" appears on screen\n text = Text(\"Broadcast\", font_size=72, color=WHITE)\n self.play(Write(text), run_time=1.5)\n self.wait(0.5)\n\n # 2. The word moves upward\n self.play(text.animate.shift(UP * 2.5), run_time=1)\n self.wait(0.2)\n\n # 3. A triangle shape appears\n triangle = Triangle(color=BBLUE, fill_opacity=0.8)\n triangle.set_height(1.5)\n triangle.move_to(ORIGIN)\n self.play(FadeIn(triangle, scale=0.5), run_time=1)\n\n # Broadcast Signal: Expanding concentric rings\n waves = VGroup()\n for i in range(4):\n ring = Circle(radius=0.1, color=BLUE_A)\n ring.move_to(triangle.get_center())\n ring.set_stroke(width=4, opacity=0.8)\n waves.add(ring)\n\n # Animate the signal emission with a staggered, continuous effect\n self.play(\n LaggedStart(\n *[\n wave.animate.scale(20).set_stroke(opacity=0)\n for wave in waves\n ],\n lag_ratio=0.3,\n run_time=2.5,\n rate_func=linear\n )\n )\n self.wait(0.5)\n\n # 4. The triangle disappears\n self.play(FadeOut(triangle, scale=0.5), run_time=0.5)\n self.wait(1)\n\n# To render this animation, use the command:\n# manim -pql filename.py BroadcastAnimation\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "I'd like an educational animation that visually explains how to calculate the definite integral of the function x^3 from 0 to 2. Start by displaying the integral problem on the screen. Then, show the power rule of integration for n-th powers of x, followed by the actual integration step of our specific problem, using the power rule. After integrating, demonstrate how to evaluate the definite integral, step by step. Conclude by simplifying the final answer and present a clean view of the final solution to the viewer.", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Display the Problem\n # ------------------------------------------------------------------\n problem_label = Text(\"Calculate the definite integral:\", font_size=36)\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem_group = VGroup(problem_label, problem).arrange(DOWN, buff=0.4)\n \n self.play(Write(problem_label), Write(problem))\n self.wait(1)\n\n # Move problem to the top to make room for the solution steps\n self.play(problem_group.animate.scale(0.8).to_edge(UP))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Explain the Rule\n # ------------------------------------------------------------------\n rule_title = Text(\"Power Rule of Integration:\", font_size=32, color=BLUE)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\", color=BLUE)\n rule_group = VGroup(rule_title, rule_formula).arrange(DOWN, buff=0.3)\n rule_group.move_to(ORIGIN)\n\n self.play(Write(rule_title))\n self.play(Write(rule_formula))\n self.wait(2)\n\n # Emphasize the rule before applying it\n self.play(Indicate(rule_formula, scale_factor=1.1, color=WHITE))\n self.wait(1)\n\n # Transition out the rule and the label\n self.play(FadeOut(rule_group), FadeOut(problem_label))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Apply the Rule\n # ------------------------------------------------------------------\n # Reposition the problem to the top left for a clean derivation stack\n self.play(problem.animate.scale(1.25).to_edge(UP + LEFT, buff=1))\n\n # Show the substitution step (n=3)\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\")\n step1.next_to(problem, DOWN, buff=0.5, aligned_edge=LEFT)\n \n # Transform the problem directly into the first step for visual continuity\n self.play(ReplacementTransform(problem.copy(), step1))\n self.wait(1)\n\n # Simplify the exponent and denominator\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Evaluate\n # ------------------------------------------------------------------\n # Substitute the upper and lower limits\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Simplify and Conclude\n # ------------------------------------------------------------------\n # Perform the arithmetic\n step4 = MathTex(r\"= \\frac{16}{4} - 0\")\n step4.next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Final Answer\n final_answer = MathTex(r\"= 4\")\n final_answer.next_to(step4, DOWN, buff=0.5, aligned_edge=LEFT)\n final_answer.set_color(GREEN)\n final_answer.scale(1.2)\n \n self.play(Write(final_answer))\n self.wait(1)\n\n # Final clean view: box the complete solution\n solution_group = VGroup(problem, step1, step2, step3, step4, final_answer)\n box = SurroundingRectangle(solution_group, color=YELLOW, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Display the Problem\n # ------------------------------------------------------------------\n problem_label = Text(\"Calculate the definite integral:\", font_size=36)\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem_group = VGroup(problem_label, problem).arrange(DOWN, buff=0.4)\n \n self.play(Write(problem_label), Write(problem))\n self.wait(1)\n\n # Move problem to the top to make room for the solution steps\n self.play(problem_group.animate.scale(0.8).to_edge(UP))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Explain the Rule\n # ------------------------------------------------------------------\n rule_title = Text(\"Power Rule of Integration:\", font_size=32, color=BBLUE)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\", color=BLUE)\n rule_group = VGroup(rule_title, rule_formula).arrange(DOWN, buff=0.3)\n rule_group.move_to(ORIGIN)\n\n self.play(Write(rule_title))\n self.play(Write(rule_formula))\n self.wait(2)\n\n # Emphasize the rule before applying it\n self.play(Indicate(rule_formula, scale_factor=1.1, color=WHITE))\n self.wait(1)\n\n # Transition out the rule and the label\n self.play(FadeOut(rule_group), FadeOut(problem_label))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Apply the Rule\n # ------------------------------------------------------------------\n # Reposition the problem to the top left for a clean derivation stack\n self.play(problem.animate.scale(1.25).to_edge(UP + LEFT, buff=1))\n\n # Show the substitution step (n=3)\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\")\n step1.next_to(problem, DOWN, buff=0.5, aligned_edge=LEFT)\n \n # Transform the problem directly into the first step for visual continuity\n self.play(ReplacementTransform(problem.copy(), step1))\n self.wait(1)\n\n # Simplify the exponent and denominator\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Evaluate\n # ------------------------------------------------------------------\n # Substitute the upper and lower limits\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\")\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Simplify and Conclude\n # ------------------------------------------------------------------\n # Perform the arithmetic\n step4 = MathTex(r\"= \\frac{16}{4} - 0\")\n step4.next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Final Answer\n final_answer = MathTex(r\"= 4\")\n final_answer.next_to(step4, DOWN, buff=0.5, aligned_edge=LEFT)\n final_answer.set_color(GREEN)\n final_answer.scale(1.2)\n \n self.play(Write(final_answer))\n self.wait(1)\n\n # Final clean view: box the complete solution\n solution_group = VGroup(problem, step1, step2, step3, step4, final_answer)\n box = SurroundingRectangle(solution_group, color=YELLOW, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n```"}
{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block (`from manim import *`). Never truncate code and never output prose before the code block.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "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### LSD-SLAM\n\n**LSD-SLAM (Large-Scale Direct SLAM):**\n\n#### Monocular SLAM Based on Semi-Dense Direct Method\n\n#### Proposed by TUM in 2014\n* A milestone in direct methods, demonstrating SLAM can be done without feature points.\n\n**Key Features:**\n\n#### **Semi-Dense Depth Estimation**\n\n##### Depth Estimation in Regions with High Gradients\n\n##### Depth Filter Update\n* Continuously converges the depth value of each pixel using Bayesian estimation.\n\n#### **Direct Image Alignment**\n\n##### Minimizing Photometric Error\n\n##### Sim(3) Pose Graph Optimization\n* Explicitly handles scale factors in the optimization to correct scale drift.\n\n#### **Scale Drift Awareness**\n\n##### Detects and Corrects Scale Drift\n\n\nThe context of this section (from highest to current level):\n# Embodied Intelligence: Visual Perception and SLAM\n## Classical SLAM Systems\n", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass LsdSlamScene(Scene):\n\n def construct(self):\n title = Text(\"Monocular SLAM Based on Semi-Dense Direct Method\", font_size=36)\n subtitle = Text(\"Proposed by TUM in 2014\", font_size=28, color=GRAY).next_to(title, DOWN, buff=0.2)\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n bullet_list = BulletedList(\n \"A milestone in direct methods, demonstrating SLAM can be done without feature points.\",\n font_size=28\n )\n features_title = Text(\"Key Features:\", font_size=36, weight=BOLD).to_edge(UP, buff=0.5)\n self.play(Write(features_title))\n semi_dense_text = Text(\"- Semi-Dense Depth Estimation\\n- Depth Estimation in Regions with High Gradients\\n- Depth Filter Update:\\n • Continuous convergence via Bayesian estimation.\", font_size=28, line_spacing=1.2)\n sim3_text = Text(\"- Direct Image Alignment\\n- Minimizing photometric error\\n- Sim(3) Pose Graph Optimization:\\n • Handles scale factors explicitly for scale drift correction.\", font_size=28, line_spacing=1.2)\n semi_dense_box = RoundedRectangle(corner_radius=0.2, width=7.2, height=2.8, fill_color=BLUE_D, fill_opacity=0.1)\n semidense_label = Text(\"Semi-\\nDense\\ndepth\\nest.\\nmethod\", font_size=24, color=YELLOW).move_to(RIGHT * 4 + UP * 1.2)\n semi_denselist_group = VGroup(semi_dense_box, semidense_label, semi_dense_text).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n sim3box = RoundedRectangle(corner_radius=0.2, width=6.2, height=2.2, fill_color=GREEN_C, fill_opacity=0.1)\n sim3label = Text(\"Sim(3)\\npose graph\\noptimization\", font_size=24, color=ORANGE).move_to(LEFT * 4 + UP * 0.8)\n sim3listgroup = VGroup(sim3box, sim3label, sim3_text).arrange(DOWN, aligned_edge=LEFT, buff=0.2)\n boxes = VGroup(semi_denselist_group, sim3listgroup).arrange(RIGHT, buff=2.0).shift(UP * 0.8)\n arrows = VGroup(Arrow(start=boxes.get_left() + RIGHT * 1.2 + DOWN * 0.5, end=semi_denselist_group.get_right(), stroke_width=2), Arrow(start=boxes.get_left() + RIGHT * 1.2 + DOWN * 0.5, end=sim3listgroup.get_left(), stroke_width=2)).set_stroke(WHITE, opacity=0.8)\n self.play(Write(bullet_list))\n self.play(Create(arrows), FadeIn(semi_denselist_group), FadeIn(sim3listgroup))\n conclusion_text = Text(\"• Enables high-resolution maps\\n• Handles large-scale scenes\\n• Robust against scale changes\", font_size=28, t2c={\"high-resolution\": YELLOW})\n conclusion_box = SurroundingRectangle(conclusion_text, corner_radius=0.2, color=WHITE, buff=0.2)\n conclusion_group = VGroup(conclusion_box, conclusion_text).to_edge(DOWN, buff=1.0)\n self.play(FadeIn(conclusion_group))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass LsdSlamScene(Scene):\n def construct(self):\n title = Text(\"LSD-SLAM\", font_size=72)\n subtitle = Tex(\"\\\\textit{Monocular SLAM based on semi-dense direct method}\", font_size=36).next_to(title, DOWN, buff=0.8)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=DOWN))\n self.wait(1)\n\n # --- Key Features Section ---\n features_title = Title(\"Key Features\").scale(0.8)\n features_group = VGroup(features_title)\n \n # Feature 1: Semi-Dense Depth Estimation\n semidense_title = Tex(\"$\\\\bullet$ \\\\textbf{Semi-dense depth estimation}\\\\\\\\Depth estimated in regions with high gradients\")\n semifilter_title = Tex(\"$\\\\bullet$ \\\\textbf{Depth filter update}\\\\\\\\Continuously converges pixel values via Bayesian estimation\")\n \n semidense_box = SurroundingRectangle(semidense_title, color=BLUE, buff=0.3)\n semifilter_box = SurroundingRectangle(semifilter_title, color=YELLOW, buff=0.3)\n \n semigroup = VGroup(semi_dense_depth_text=semidense_box, semipfilter_update_box=semifilter_box)\n semigroup.arrange(DOWN, aligned_edge=LEFT, buff=0.5).to_edge(RIGHT, buff=0.8).shift(UP * 0.5)\n \n # Feature 2: Direct Image Alignment\n align_title = Tex(\"$\\\\bullet$ \\\\textbf{Minimizes photometric error}\")\n sim3_title = Tex(\"$\\\\bullet$ \\\\textbf{Sim(3)} pose graph optimization\\\\\\\\Explicitly handles scale factors to correct drift\")\n \n align_box = SurroundingRectangle(align_title, color=GREEN, buff=0.3)\n sim3_box = SurroundingRectangle(sim3_title, color=PURPLE, buff=0.3)\n \n aligngroup = VGroup(\n align_box,\n sim3_box\n ).arrange(DOWN, aligned_edge=LEFT, buff=0.5).to_edge(RIGHT, buff=0.8).shift(DOWN * 0.5)\n \n features_group.add(semidense_box, semifilter_box, semidense_title, semipfilter_update_box, \n align_box, sim3_box, align_title, sim3_title)\n \n\n # Add labels for scaling effect\n semilabel = Text(\"High Gradient Areas\", font_size=24, color=BLUE).move_to(semidense_title.get_center())\n filterlabel = Text(\"Bayesian Estimation\", font_size=24, color=YELLOW).move_to(semifilter_title.get_bottom())\n \n alignlabel = Text(\"Photometric Cost Function\", font_size=24, color=GREEN).move_to(align_title.get_top())\n sim3label = Text(\"Sim(3) Optimizer\\nHandles scales\", font_size=20, color=PURPLE).move_to(sim3_title.get_center())\n\n # Animate key features sequentially\n self.wait()\n self.play(Write(semidense_title), Create(semidense_box))\n self.play(Write(filterlabel), Indicate(semidense_box, color=BLUE))\n self.wait(0.5)\n self.play(Write(semifilter_update_box), Write(semifilter_title))\n self.play(Write(semilabel), Indicate(semifilter_update_box, color=YELLOW))\n self.wait(0.5)\n\n self.play(Write(align_title), Create(align_box))\n self.play(Write(alignlabel), Indicate(align_box, color=GREEN))\n self.wait(0.5)\n self.play(Write(sim3box), Write(sim3_title))\n self.play(Write(sim3label), Indicate(sim3_box, color=PURPLE))\n self.wait(1)\n self.play(FadeOut(VGroup(*features_group)))\n self.wait()\n\n # Conclusion\n conclusion = Text(\"A major milestone in direct methods:\\\\SLAM can operate without feature points.\", font_size=28)\n self.play(Write(conclusion))\n box = SurroundingRectangle(conclusion, color=ORANGE)\n self.play(Create(box))\n self.wait(2)\n```"}