{"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 \n- Act 2: 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, ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0621(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_movingangle()\n self.clear_stage()\n self.act_2_multiplicationanimation()\n\n def act_1_movingangle(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\n def act_2_multiplicationanimation(self):\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 *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0621(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_movingangle()\n self.clear_stage()\n self.act_2_multiplicationanimation()\n\n def act_1_movingangle(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 = MathText(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\n def act_2_multiplicationanimation(self):\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does the flow of a Hamiltonian vector field preserve the symplectic form on a manifold?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SymplecticGeometry(Scene):\n def construct(self):\n # Scene setup and introduction\n title = Text(\"The Flow of Symplectic Harmony\", font_size=36)\n subtitle = Text(\"Hamiltonian Vector Fields Unveiled\", font_size=24, color=BLUE)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Create a simple representation of a symplectic manifold\n circle = Circle(radius=3, color=BLUE_E)\n \n # Create a grid of dots inside the circle\n manifold = VGroup()\n for r in np.linspace(0.5, 2.5, 5):\n for theta in np.linspace(0, 2*PI, 8, endpoint=False):\n x, y = r * np.cos(theta), r * np.sin(theta)\n dot = Dot(point=[x, y, 0], color=RED)\n manifold.add(dot)\n \n manifold_text = Text(\"Symplectic Manifold\", font_size=24)\n manifold_text.to_edge(UP)\n \n self.play(Write(manifold_text))\n self.play(Create(circle), Create(manifold))\n self.wait(1)\n \n # Show the symplectic form as a grid pattern\n symplectic_grid = VGroup()\n \n # Create concentric circles to represent the symplectic form\n for r in np.linspace(1, 3, 3):\n circle_arc = Circle(radius=r, color=BLUE_C, stroke_width=1)\n symplectic_grid.add(circle_arc)\n \n # Add radial lines\n for angle in np.linspace(0, 2*PI, 8, endpoint=False):\n x, y = 3 * np.cos(angle), 3 * np.sin(angle)\n line = Line(start=[0, 0, 0], end=[x, y, 0], color=BLUE_C, stroke_width=1)\n symplectic_grid.add(line)\n \n symplectic_text = Text(\"Symplectic Form\", font_size=24)\n symplectic_text.next_to(manifold_text, DOWN)\n \n self.play(Write(symplectic_text))\n self.play(Create(symplectic_grid))\n self.wait(1)\n \n # Show Hamiltonian vector field as arrows\n arrows = VGroup()\n for dot in manifold:\n position = dot.get_center()\n r = np.sqrt(position[0]**2 + position[1]**2)\n if r > 0.1: # Avoid division by zero near the origin\n direction = [-position[1]/r, position[0]/r, 0]\n arrow = Arrow(start=position, end=np.array(position) + 0.5 * np.array(direction), color=YELLOW)\n arrows.add(arrow)\n \n hamiltonian_text = Text(\"Hamiltonian Vector Field\", font_size=24)\n hamiltonian_text.next_to(symplectic_text, DOWN)\n \n self.play(Write(hamiltonian_text))\n self.play(Create(arrows))\n self.wait(1)\n \n # Show the Lie derivative equation\n lie_derivative = Text(\"L_X_H ω = 0\", font_size=24)\n lie_derivative.next_to(hamiltonian_text, DOWN, buff=0.5)\n \n self.play(Write(lie_derivative))\n self.wait(1)\n \n # Animate flow along the Hamiltonian vector field\n self.play(Rotate(manifold, angle=PI/4), run_time=2)\n \n # Update the arrows after rotation\n self.play(FadeOut(arrows))\n new_arrows = VGroup()\n for dot in manifold:\n position = dot.get_center()\n r = np.sqrt(position[0]**2 + position[1]**2)\n if r > 0.1:\n direction = [-position[1]/r, position[0]/r, 0]\n arrow = Arrow(start=position, end=np.array(position) + 0.5 * np.array(direction), color=YELLOW)\n new_arrows.add(arrow)\n \n self.play(Create(new_arrows))\n \n # Highlight preservation of symplectic form\n preserved_text = Text(\"Symplectic Form Preserved\", font_size=24, color=GREEN)\n preserved_text.next_to(lie_derivative, DOWN, buff=0.5)\n \n self.play(Write(preserved_text))\n self.wait(1)\n \n # Show the symplectic form equation\n symplectic_form = Text(\"ω(dq ∧ dp)\", font_size=24)\n symplectic_form.next_to(preserved_text, DOWN, buff=0.5)\n \n self.play(Write(symplectic_form))\n self.wait(1)\n \n # Final message\n conclusion = Text(\"Embracing the eternal rhythm of symplectic harmony\", font_size=24)\n conclusion.to_edge(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Fade everything out\n self.play(\n *[FadeOut(mob) for mob in self.mobjects]\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SymplecticGeometry(Scene):\n def construct(self):\n # Scene setup and introduction\n title = Text(\"The Flow of Symplectic Harmony\", font_size=36)\n subtitle = Text(\"Hamiltonian Vector Fields Unveiled\", font_size=24, color=BBLUE)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Create a simple representation of a symplectic manifold\n circle = Circle(radius=3, color=BLUE_E)\n \n # Create a grid of dots inside the circle\n manifold = VGroup()\n for r in np.linspace(0.5, 2.5, 5):\n for theta in np.linspace(0, 2*PI, 8, endpoint=False):\n x, y = r * np.cos(theta), r * np.sin(theta)\n dot = Dot(point=[x, y, 0], color=RED)\n manifold.add(dot)\n \n manifold_text = Text(\"Symplectic Manifold\", font_size=24)\n manifold_text.to_edge(UP)\n \n self.play(Write(manifold_text))\n self.play(Create(circle), Create(manifold))\n self.wait(1)\n \n # Show the symplectic form as a grid pattern\n symplectic_grid = VGroup()\n \n # Create concentric circles to represent the symplectic form\n for r in np.linspace(1, 3, 3):\n circle_arc = Circle(radius=r, color=BLUE_C, stroke_width=1)\n symplectic_grid.add(circle_arc)\n \n # Add radial lines\n for angle in np.linspace(0, 2*PI, 8, endpoint=False):\n x, y = 3 * np.cos(angle), 3 * np.sin(angle)\n line = Line(start=[0, 0, 0], end=[x, y, 0], color=BLUE_C, stroke_width=1)\n symplectic_grid.add(line)\n \n symplectic_text = Text(\"Symplectic Form\", font_size=24)\n symplectic_text.next_to(manifold_text, DOWN)\n \n self.play(Write(symplectic_text))\n self.play(Create(symplectic_grid))\n self.wait(1)\n \n # Show Hamiltonian vector field as arrows\n arrows = VGroup()\n for dot in manifold:\n position = dot.get_center()\n r = np.sqrt(position[0]**2 + position[1]**2)\n if r > 0.1: # Avoid division by zero near the origin\n direction = [-position[1]/r, position[0]/r, 0]\n arrow = Arrow(start=position, end=np.array(position) + 0.5 * np.array(direction), color=YELLOW)\n arrows.add(arrow)\n \n hamiltonian_text = Text(\"Hamiltonian Vector Field\", font_size=24)\n hamiltonian_text.next_to(symplectic_text, DOWN)\n \n self.play(Write(hamiltonian_text))\n self.play(Create(arrows))\n self.wait(1)\n \n # Show the Lie derivative equation\n lie_derivative = Text(\"L_X_H ω = 0\", font_size=24)\n lie_derivative.next_to(hamiltonian_text, DOWN, buff=0.5)\n \n self.play(Write(lie_derivative))\n self.wait(1)\n \n # Animate flow along the Hamiltonian vector field\n self.play(Rotate(manifold, angle=PI/4), run_time=2)\n \n # Update the arrows after rotation\n self.play(FadeOut(arrows))\n new_arrows = VGroup()\n for dot in manifold:\n position = dot.get_center()\n r = np.sqrt(position[0]**2 + position[1]**2)\n if r > 0.1:\n direction = [-position[1]/r, position[0]/r, 0]\n arrow = Arrow(start=position, end=np.array(position) + 0.5 * np.array(direction), color=YELLOW)\n new_arrows.add(arrow)\n \n self.play(Create(new_arrows))\n \n # Highlight preservation of symplectic form\n preserved_text = Text(\"Symplectic Form Preserved\", font_size=24, color=GREEN)\n preserved_text.next_to(lie_derivative, DOWN, buff=0.5)\n \n self.play(Write(preserved_text))\n self.wait(1)\n \n # Show the symplectic form equation\n symplectic_form = Text(\"ω(dq ∧ dp)\", font_size=24)\n symplectic_form.next_to(preserved_text, DOWN, buff=0.5)\n \n self.play(Write(symplectic_form))\n self.wait(1)\n \n # Final message\n conclusion = Text(\"Embracing the eternal rhythm of symplectic harmony\", font_size=24)\n conclusion.to_edge(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Fade everything out\n self.play(\n *[FadeOut(mob) for mob in self.mobjects]\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\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 = MathText(\"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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using Manim that introduces the wave equation, describes its components including wave speed, then extends it to three dimensions and ends by showing an example solution involving terms like amplitude, wave number, and angular frequency, with each concept and equation appearing on screen sequentially and concluding by fading everything out?", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationIntroduction(Scene):\n def construct(self):\n # --- 1. Introduction ---\n # Display the title\n title = Text(\"The Wave Equation\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n\n # --- 2. 1D Wave Equation ---\n # Define the 1D Wave Equation with separated components for indexing\n eq_1d = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n self.play(Write(eq_1d))\n self.wait(1)\n\n # --- 3. Component Breakdown: Wave Speed ---\n # Highlight wave speed (c) and label it\n c_box = SurroundingRectangle(eq_1d[2], color=YELLOW)\n c_label = Text(\"Wave Speed\", font_size=24, color=YELLOW).next_to(c_box, DOWN)\n \n self.play(\n Create(c_box),\n eq_1d[2].animate.set_color(YELLOW),\n FadeIn(c_label)\n )\n self.wait(2)\n \n # Clean up labels before transitioning\n self.play(FadeOut(c_box), FadeOut(c_label), eq_1d[2].animate.set_color(WHITE))\n self.wait(0.5)\n\n # --- 4. Extension to 3D ---\n # Define the 3D Wave Equation using the Laplacian operator\n eq_3d = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\nabla^2 u\",\n font_size=48\n )\n eq_3d.move_to(eq_1d) # Ensure it appears in the same location\n \n # Smoothly transition from 1D to 3D\n self.play(ReplacementTransform(eq_1d, eq_3d))\n self.wait(1)\n\n # --- 5. Example Solution ---\n # Display the harmonic wave solution\n solution = MathTex(\n \"u(x, t)\", \"=\", \"A\", r\"\\cos(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \")\",\n font_size=48\n )\n solution.next_to(eq_3d, DOWN, buff=1)\n self.play(Write(solution))\n self.wait(1)\n\n # --- 6. Label Solution Components Sequentially ---\n # Amplitude (A)\n amp_box = SurroundingRectangle(solution[2], color=BLUE)\n amp_label = Text(\"Amplitude\", font_size=24, color=BLUE).next_to(amp_box, DOWN)\n self.play(Create(amp_box), solution[2].animate.set_color(BLUE), FadeIn(amp_label))\n self.wait(1)\n\n # Wave Number (k)\n k_box = SurroundingRectangle(solution[4], color=GREEN)\n k_label = Text(\"Wave Number\", font_size=24, color=GREEN).next_to(k_box, DOWN)\n self.play(Create(k_box), solution[4].animate.set_color(GREEN), FadeIn(k_label))\n self.wait(1)\n\n # Angular Frequency (omega)\n omega_box = SurroundingRectangle(solution[7], color=RED)\n omega_label = Text(\"Angular Frequency\", font_size=24, color=RED).next_to(omega_box, DOWN)\n self.play(Create(omega_box), solution[7].animate.set_color(RED), FadeIn(omega_label))\n self.wait(2)\n\n # --- 7. Conclusion ---\n # Fade out all elements\n all_elements = VGroup(\n eq_3d, solution, \n amp_box, amp_label, \n k_box, k_label, \n omega_box, omega_label\n )\n self.play(FadeOut(all_elements), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationIntroduction(Scene):\n def construct(self):\n # --- 1. Introduction ---\n # Display the title\n title = Text(\"The Wave Equation\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n\n # --- 2. 1D Wave Equation ---\n # Define the 1D Wave Equation with separated components for indexing\n eq_1d = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n self.play(Write(eq_1d))\n self.wait(1)\n\n # --- 3. Component Breakdown: Wave Speed ---\n # Highlight wave speed (c) and label it\n c_box = SurroundingRectangle(eq_1d[2], color=YELLOW)\n c_label = Text(\"Wave Speed\", font_size=24, color=YELLOW).next_to(c_box, DOWN)\n \n self.play(\n Create(c_box),\n eq_1d[2].animate.set_color(YELLOW),\n FadeIn(c_label)\n )\n self.wait(2)\n \n # Clean up labels before transitioning\n self.play(FadeOut(c_box), FadeOut(c_label), eq_1d[2].animate.set_color(WHITE))\n self.wait(0.5)\n\n # --- 4. Extension to 3D ---\n # Define the 3D Wave Equation using the Laplacian operator\n eq_3d = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\nabla^2 u\",\n font_size=48\n )\n eq_3d.move_to(eq_1d) # Ensure it appears in the same location\n \n # Smoothly transition from 1D to 3D\n self.play(ReplacementTransform(eq_1d, eq_3d))\n self.wait(1)\n\n # --- 5. Example Solution ---\n # Display the harmonic wave solution\n solution = MathTex(\n \"u(x, t)\", \"=\", \"A\", r\"\\cos(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \")\",\n font_size=48\n )\n solution.next_to(eq_3d, DOWN, buff=1)\n self.play(Write(solution))\n self.wait(1)\n\n # --- 6. Label Solution Components Sequentially ---\n # Amplitude (A)\n amp_box = SurroundingRectangle(solution[2], color=BBLUE)\n amp_label = Text(\"Amplitude\", font_size=24, color=BLUE).next_to(amp_box, DOWN)\n self.play(Create(amp_box), solution[2].animate.set_color(BLUE), FadeIn(amp_label))\n self.wait(1)\n\n # Wave Number (k)\n k_box = SurroundingRectangle(solution[4], color=GREEN)\n k_label = Text(\"Wave Number\", font_size=24, color=GREEN).next_to(k_box, DOWN)\n self.play(Create(k_box), solution[4].animate.set_color(GREEN), FadeIn(k_label))\n self.wait(1)\n\n # Angular Frequency (omega)\n omega_box = SurroundingRectangle(solution[7], color=RED)\n omega_label = Text(\"Angular Frequency\", font_size=24, color=RED).next_to(omega_box, DOWN)\n self.play(Create(omega_box), solution[7].animate.set_color(RED), FadeIn(omega_label))\n self.wait(2)\n\n # --- 7. Conclusion ---\n # Fade out all elements\n all_elements = VGroup(\n eq_3d, solution, \n amp_box, amp_label, \n k_box, k_label, \n omega_box, omega_label\n )\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\n\nclass DivergenceAndCurl(Scene):\n def construct(self):\n title = Title(\"Divergence and Curl\")\n self.play(Write(title))\n \n\n div = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Initial Setup ---\n # Display a circle and a line segment representing the radius. Label the radius clearly with 'r'.\n circle = Circle(radius=2, color=BLUE)\n radius_line = Line(ORIGIN, circle.get_right(), color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n\n self.play(Create(circle), Create(radius_line), Write(radius_label))\n self.wait(2)\n\n # --- Step 2: Area Explanation ---\n # Reveal text explaining that the area of a circle is given by the formula 'Area = \\pi r^2'.\n area_explanation = Tex(\"The area of a circle is given by the formula: $\\\\text{Area} = \\\\pi r^2$\").to_edge(UP)\n \n self.play(Write(area_explanation))\n self.wait(3)\n\n # --- Step 3: Formula Transformation ---\n # Transform the explanation text into the mathematical formula and reposition it to the bottom of the screen.\n area_formula = MathTex(r\"\\text{Area} = \\pi r^2\")\n area_formula.move_to(area_explanation.get_center())\n \n self.play(ReplacementTransform(area_explanation, area_formula))\n self.play(area_formula.animate.to_edge(DOWN, buff=1.5))\n self.wait(2)\n\n # --- Step 4: Circumference Illustration ---\n # Animate a dot moving along the circumference of the circle to visually demonstrate the concept of perimeter.\n dot = Dot(color=RED).move_to(circle.get_right())\n \n self.play(FadeIn(dot))\n self.play(MoveAlongPath(dot, circle, rate_func=linear), run_time=4)\n self.wait(1)\n\n # --- Step 5: Final Conclusion ---\n # Display the text 'Circumference = 2\\pi r' below the circle.\n circ_formula = MathTex(r\"\\text{Circumference} = 2\\pi r\").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: Initial Setup ---\n # Display a circle and a line segment representing the radius. Label the radius clearly with 'r'.\n circle = Circle(radius=2, color=BBLUE)\n radius_line = Line(ORIGIN, circle.get_right(), color=YELLOW)\n radius_label = MathTex(\"r\", color=YELLOW).next_to(radius_line, UP, buff=0.1)\n\n self.play(Create(circle), Create(radius_line), Write(radius_label))\n self.wait(2)\n\n # --- Step 2: Area Explanation ---\n # Reveal text explaining that the area of a circle is given by the formula 'Area = \\pi r^2'.\n area_explanation = Tex(\"The area of a circle is given by the formula: $\\\\text{Area} = \\\\pi r^2$\").to_edge(UP)\n \n self.play(Write(area_explanation))\n self.wait(3)\n\n # --- Step 3: Formula Transformation ---\n # Transform the explanation text into the mathematical formula and reposition it to the bottom of the screen.\n area_formula = MathTex(r\"\\text{Area} = \\pi r^2\")\n area_formula.move_to(area_explanation.get_center())\n \n self.play(ReplacementTransform(area_explanation, area_formula))\n self.play(area_formula.animate.to_edge(DOWN, buff=1.5))\n self.wait(2)\n\n # --- Step 4: Circumference Illustration ---\n # Animate a dot moving along the circumference of the circle to visually demonstrate the concept of perimeter.\n dot = Dot(color=RED).move_to(circle.get_right())\n \n self.play(FadeIn(dot))\n self.play(MoveAlongPath(dot, circle, rate_func=linear), run_time=4)\n self.wait(1)\n\n # --- Step 5: Final Conclusion ---\n # Display the text 'Circumference = 2\\pi r' below the circle.\n circ_formula = MathTex(r\"\\text{Circumference} = 2\\pi r\").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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 sequence where a text appears and changes to describe the animation that follows. The animation should show a square growing from one of its edges in four different directions: down, right, up, and left. Each time a square grows from an edge, the text should change to indicate the direction from which the square is growing. The text should be displayed above the square and should change quickly with a transition effect before each new square animation begins. After showing all four squares growing in the respective directions, all squares should disappear from the screen. Can you create this animation in a simple and visually appealing way?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Display the function\n function = MathTex(r\"f(x) = 3 - x^2\")\n self.play(Write(function))\n self.wait(1)\n\n # Indicate the area of interest\n area_description = Text(\"Area under the curve from x=1 to x=2\", font_size=24).to_edge(UP)\n self.play(Write(area_description))\n self.wait(2)\n\n # Setup the definite integral\n definite_integral = MathTex(r\"\\int_1^2 (3 - x^2) \\,dx\")\n self.play(Transform(function, definite_integral))\n self.wait(1)\n\n # Steps to find the area\n step1 = MathTex(r\"= \\left[ 3x - \\frac{x^3}{3} \\right]_1^2\")\n self.play(ReplacementTransform(definite_integral.copy(), step1))\n self.wait(1)\n\n step2_description = Text(\"Calculate the definite integral\", font_size=24).to_edge(UP)\n self.play(Transform(area_description, step2_description))\n self.wait(2)\n\n # Show the final result\n final_area = MathTex(r\"= (6 - \\frac{8}{3}) - (3 - \\frac{1}{3})\", r\"= \\frac{7}{3}\")\n self.play(ReplacementTransform(step1, final_area))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The area is 7/3 square units\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_area))\n self.play(Write(conclusion))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Display the function\n function = MathText(r\"f(x) = 3 - x^2\")\n self.play(Write(function))\n self.wait(1)\n\n # Indicate the area of interest\n area_description = Text(\"Area under the curve from x=1 to x=2\", font_size=24).to_edge(UP)\n self.play(Write(area_description))\n self.wait(2)\n\n # Setup the definite integral\n definite_integral = MathTex(r\"\\int_1^2 (3 - x^2) \\,dx\")\n self.play(Transform(function, definite_integral))\n self.wait(1)\n\n # Steps to find the area\n step1 = MathTex(r\"= \\left[ 3x - \\frac{x^3}{3} \\right]_1^2\")\n self.play(ReplacementTransform(definite_integral.copy(), step1))\n self.wait(1)\n\n step2_description = Text(\"Calculate the definite integral\", font_size=24).to_edge(UP)\n self.play(Transform(area_description, step2_description))\n self.wait(2)\n\n # Show the final result\n final_area = MathTex(r\"= (6 - \\frac{8}{3}) - (3 - \\frac{1}{3})\", r\"= \\frac{7}{3}\")\n self.play(ReplacementTransform(step1, final_area))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The area is 7/3 square units\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_area))\n self.play(Write(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 explaining how to integrate the sine function from 0 to π/2, show the mathematical steps, and conclude with the final result?", "chosen": "```python\nfrom manim import *\n\nclass AtomAnimation(Scene):\n def construct(self):\n # Create an atom with electrons orbiting around the nucleus\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n```", "rejected": "```python\nfrom manim import *\n\nclass AtomAnimation(Scene):\n def construct(self):\n # Create an atom with electrons orbiting around the nucleus\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BBLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Elements: Fractions (Black text, large)\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=120)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=120)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=120)\n\n # Position fractions horizontally\n f1.shift(LEFT * 4)\n f2.shift(ORIGIN)\n f3.shift(RIGHT * 4)\n\n # 2. Connectors: Blue arrows\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 # 3. Labels: Blue text above arrows\n label1 = Text(\"times 2\", color=BLUE, font_size=30).next_to(arrow1, UP)\n label2 = Text(\"times 4\", color=BLUE, font_size=30).next_to(arrow2, UP)\n\n # --- Animation Sequence ---\n\n # Step 1: Write the fraction 1/2\n self.play(Write(f1), run_time=1)\n self.wait(0.2)\n\n # Step 2: Grow first arrow and display \"times 2\"\n self.play(\n GrowArrow(arrow1), \n Write(label1), \n run_time=0.8\n )\n\n # Step 3: Reveal the fraction 2/4\n self.play(FadeIn(f2, shift=LEFT * 0.3), run_time=0.8)\n self.wait(0.2)\n\n # Step 4: Grow second arrow and display \"times 4\"\n self.play(\n GrowArrow(arrow2), \n Write(label2), \n run_time=0.8\n )\n\n # Step 5: Reveal the fraction 4/8\n self.play(FadeIn(f3, shift=LEFT * 0.3), run_time=0.8)\n\n # Step 6: Pause briefly with all elements visible\n self.wait(2)\n\n # Step 7: Fade out the entire scene\n all_elements = VGroup(f1, f2, f3, arrow1, arrow2, label1, label2)\n self.play(FadeOut(all_elements), run_time=1)\n self.wait(0.5)\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 # 1. Elements: Fractions (Black text, large)\n f1 = MathTex(r\"\\frac{1}{2}\", color=BLACK, font_size=120)\n f2 = MathTex(r\"\\frac{2}{4}\", color=BLACK, font_size=120)\n f3 = MathTex(r\"\\frac{4}{8}\", color=BLACK, font_size=120)\n\n # Position fractions horizontally\n f1.shift(LEFT * 4)\n f2.shift(ORIGIN)\n f3.shift(RIGHT * 4)\n\n # 2. Connectors: Blue arrows\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 # 3. Labels: Blue text above arrows\n label1 = Text(\"times 2\", color=BLUE, font_size=30).next_to(arrow1, UP)\n label2 = Text(\"times 4\", color=BLUE, font_size=30).next_to(arrow2, UP)\n\n # --- Animation Sequence ---\n\n # Step 1: Write the fraction 1/2\n self.play(Write(f1), run_time=1)\n self.wait(0.2)\n\n # Step 2: Grow first arrow and display \"times 2\"\n self.play(\n GrowArrow(arrow1), \n Write(label1), \n run_time=0.8\n )\n\n # Step 3: Reveal the fraction 2/4\n self.play(FadeIn(f2, shift=LEFT * 0.3), run_time=0.8)\n self.wait(0.2)\n\n # Step 4: Grow second arrow and display \"times 4\"\n self.play(\n GrowArrow(arrow2), \n Write(label2), \n run_time=0.8\n )\n\n # Step 5: Reveal the fraction 4/8\n self.play(FadeIn(f3, shift=LEFT * 0.3), run_time=0.8)\n\n # Step 6: Pause briefly with all elements visible\n self.wait(2)\n\n # Step 7: Fade out the entire scene\n all_elements = VGroup(f1, f2, f3, arrow1, arrow2, label1, label2)\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE) 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Setup ---\n # Create the circle\n circle = Circle(radius=2, color=BLUE)\n \n # Create a center point for visual clarity\n center_dot = Dot(ORIGIN, color=WHITE)\n \n # Create the radius line from center to the right edge\n radius_line = Line(ORIGIN, circle.get_right(), color=YELLOW)\n \n # Label the radius\n radius_label = MathTex(\"r\").next_to(radius_line, UP, buff=0.1)\n \n # Animate the initial setup\n self.play(Create(circle), Create(center_dot), Create(radius_line), Write(radius_label))\n self.wait() # Pause for viewers to process the circle and radius\n\n # --- 2. Area Explanation ---\n # Display explanatory text first\n area_text = Text(\"The area of a circle is given by the formula Area = \\pi r^2\", font_size=32).to_edge(UP)\n self.play(Write(area_text))\n self.wait()\n \n # Create the mathematical formula object at the same position as the text\n area_formula = MathTex(r\"\\text{Area} = \\pi r^2\", color=YELLOW, font_size=36).move_to(area_text)\n \n # Transform text into a formal mathematical formula object\n self.play(ReplacementTransform(area_text, area_formula))\n \n # Reposition the formula to the bottom of the screen\n self.play(area_formula.animate.to_edge(DOWN))\n self.wait() # Pause to allow time to read the formula\n\n # --- 3. Circumference Illustration ---\n # Create a dot on the circumference to trace the perimeter\n moving_dot = Dot(color=RED).move_to(circle.get_right())\n self.play(FadeIn(moving_dot))\n \n # Animate the dot moving along the circumference at a constant speed\n self.play(MoveAlongPath(moving_dot, circle), run_time=3, rate_func=linear)\n \n # Display the Circumference formula below the circle\n circ_formula = MathTex(r\"\\text{Circumference} = 2\\pi r\", color=BLUE, font_size=36)\n circ_formula.next_to(circle, DOWN, buff=0.5)\n \n self.play(Write(circ_formula))\n self.wait() # Final pause to review all concepts\n```", "rejected": "```python\nfrom manim import *\n\nclass CircleConcept(Scene):\n def construct(self):\n # --- 1. Initial Setup ---\n # Create the circle\n circle = Circle(radius=2, color=BBLUE)\n \n # Create a center point for visual clarity\n center_dot = Dot(ORIGIN, color=WHITE)\n \n # Create the radius line from center to the right edge\n radius_line = Line(ORIGIN, circle.get_right(), color=YELLOW)\n \n # Label the radius\n radius_label = MathTex(\"r\").next_to(radius_line, UP, buff=0.1)\n \n # Animate the initial setup\n self.play(Create(circle), Create(center_dot), Create(radius_line), Write(radius_label))\n self.wait() # Pause for viewers to process the circle and radius\n\n # --- 2. Area Explanation ---\n # Display explanatory text first\n area_text = Text(\"The area of a circle is given by the formula Area = \\pi r^2\", font_size=32).to_edge(UP)\n self.play(Write(area_text))\n self.wait()\n \n # Create the mathematical formula object at the same position as the text\n area_formula = MathTex(r\"\\text{Area} = \\pi r^2\", color=YELLOW, font_size=36).move_to(area_text)\n \n # Transform text into a formal mathematical formula object\n self.play(ReplacementTransform(area_text, area_formula))\n \n # Reposition the formula to the bottom of the screen\n self.play(area_formula.animate.to_edge(DOWN))\n self.wait() # Pause to allow time to read the formula\n\n # --- 3. Circumference Illustration ---\n # Create a dot on the circumference to trace the perimeter\n moving_dot = Dot(color=RED).move_to(circle.get_right())\n self.play(FadeIn(moving_dot))\n \n # Animate the dot moving along the circumference at a constant speed\n self.play(MoveAlongPath(moving_dot, circle), run_time=3, rate_func=linear)\n \n # Display the Circumference formula below the circle\n circ_formula = MathTex(r\"\\text{Circumference} = 2\\pi r\", color=BLUE, font_size=36)\n circ_formula.next_to(circle, DOWN, buff=0.5)\n \n self.play(Write(circ_formula))\n self.wait() # Final pause to review all concepts\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 that shows a simple feed-forward neural network with three layers, where the input layer has 4 nodes, the hidden layer has 6 nodes using ReLU activation, then another layer with 4 nodes also using ReLU, and finally an output layer with a single node using a Sigmoid activation function? Arrange the layers from left to right with some space in between, and animate a forward pass through the network.\"", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # Configuration\n layer_sizes = [4, 6, 4, 1]\n layer_names = [\"Input\", \"Hidden 1\", \"Hidden 2\", \"Output\"]\n activations = [\"\", \"ReLU\", \"ReLU\", \"Sigmoid\"]\n layer_colors = [BLUE, GREEN, GREEN, ORANGE]\n \n # Layout settings\n x_spacing = 2.5\n start_x = -3.5\n node_radius = 0.2\n node_spacing = 0.8\n signal_color = YELLOW\n \n # Groups to store network components\n layers = []\n all_edges = []\n edge_groups = []\n labels = VGroup()\n activation_labels = VGroup()\n \n # 1. Create Nodes (Layers)\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_pos = start_x + i * x_spacing\n \n # Calculate vertical centering\n total_height = (size - 1) * node_spacing\n start_y = total_height / 2\n \n for j in range(size):\n node = Circle(radius=node_radius, color=layer_colors[i], fill_opacity=0.3, stroke_width=2)\n node.move_to([x_pos, start_y - j * node_spacing, 0])\n layer_group.add(node)\n \n layers.append(layer_group)\n \n # Create Layer Labels (Top)\n name_text = Text(\n layer_names[i], \n font_size=24, \n color=WHITE\n ).next_to(layer_group, UP, buff=0.5)\n labels.add(name_text)\n \n # Create Activation Labels (Bottom)\n if activations[i]:\n act_text = Text(\n activations[i], \n font_size=20, \n color=layer_colors[i]\n ).next_to(layer_group, DOWN, buff=0.5)\n activation_labels.add(act_text)\n\n # 2. Create Edges (Fully Connected between adjacent layers)\n for i in range(len(layers) - 1):\n current_layer = layers[i]\n next_layer = layers[i + 1]\n edge_group = VGroup()\n \n for start_node in current_layer:\n for end_node in next_layer:\n line = Line(\n start=start_node.get_right(),\n end=end_node.get_left(),\n stroke_width=1,\n stroke_color=WHITE,\n stroke_opacity=0.2\n )\n edge_group.add(line)\n all_edges.append(line)\n \n edge_groups.append(edge_group)\n\n # --- Animation Sequence ---\n \n # Step 1: Draw the network structure\n self.play(\n FadeIn(VGroup(*layers)),\n Create(VGroup(*all_edges)),\n run_time=2\n )\n \n # Step 2: Show Labels\n self.play(\n FadeIn(labels),\n FadeIn(activation_labels),\n run_time=1\n )\n \n self.wait(0.5)\n \n # Step 3: Animate Forward Pass (Signals)\n def animate_layer_flow(from_layer_idx, to_layer_idx):\n from_nodes = layers[from_layer_idx]\n to_nodes = layers[to_layer_idx]\n \n # Pulse the source nodes to indicate firing\n self.play(\n *[node.animate.set_fill(layer_colors[from_layer_idx], opacity=1).scale(1.2) for node in from_nodes],\n run_time=0.3\n )\n self.play(\n *[node.animate.set_fill(layer_colors[from_layer_idx], opacity=0.3).scale(1/1.2) for node in from_nodes],\n run_time=0.3\n )\n \n # Create signals moving along the edges\n local_signals = VGroup()\n animations_list = []\n \n for start_node in from_nodes:\n for end_node in to_nodes:\n sig = Dot(\n point=start_node.get_right(), \n radius=0.06, \n color=signal_color\n )\n local_signals.add(sig)\n # Define path from the right edge of the start node to the left edge of the end node\n path = Line(start_node.get_right(), end_node.get_left())\n animations_list.append(MoveAlongPath(sig, path, rate_func=linear))\n \n self.add(local_signals)\n self.play(*animations_list, run_time=1.5)\n self.remove(local_signals)\n \n # Pulse the destination layer to show activation\n self.play(\n *[node.animate.set_fill(layer_colors[to_layer_idx], opacity=1).scale(1.2) for node in to_nodes],\n run_time=0.2\n )\n self.play(\n *[node.animate.set_fill(layer_colors[to_layer_idx], opacity=0.3).scale(1/1.2) for node in to_nodes],\n run_time=0.2\n )\n\n # Execute flow between layers\n # Input -> Hidden 1\n animate_layer_flow(0, 1)\n \n # Hidden 1 -> Hidden 2\n animate_layer_flow(1, 2)\n \n # Hidden 2 -> Output\n animate_layer_flow(2, 3)\n \n # Final Highlight on Output (Sigmoid)\n output_node = layers[3][0]\n sigmoid_label = activation_labels[-1]\n \n # Highlight Sigmoid label and output node\n self.play(\n output_node.animate.set_fill(ORANGE, opacity=1).set_stroke(width=4),\n sigmoid_label.animate.set_color(YELLOW).scale(1.2),\n run_time=1\n )\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, 6, 4, 1]\n layer_names = [\"Input\", \"Hidden 1\", \"Hidden 2\", \"Output\"]\n activations = [\"\", \"ReLU\", \"ReLU\", \"Sigmoid\"]\n layer_colors = [BBLUE, GREEN, GREEN, ORANGE]\n \n # Layout settings\n x_spacing = 2.5\n start_x = -3.5\n node_radius = 0.2\n node_spacing = 0.8\n signal_color = YELLOW\n \n # Groups to store network components\n layers = []\n all_edges = []\n edge_groups = []\n labels = VGroup()\n activation_labels = VGroup()\n \n # 1. Create Nodes (Layers)\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n x_pos = start_x + i * x_spacing\n \n # Calculate vertical centering\n total_height = (size - 1) * node_spacing\n start_y = total_height / 2\n \n for j in range(size):\n node = Circle(radius=node_radius, color=layer_colors[i], fill_opacity=0.3, stroke_width=2)\n node.move_to([x_pos, start_y - j * node_spacing, 0])\n layer_group.add(node)\n \n layers.append(layer_group)\n \n # Create Layer Labels (Top)\n name_text = Text(\n layer_names[i], \n font_size=24, \n color=WHITE\n ).next_to(layer_group, UP, buff=0.5)\n labels.add(name_text)\n \n # Create Activation Labels (Bottom)\n if activations[i]:\n act_text = Text(\n activations[i], \n font_size=20, \n color=layer_colors[i]\n ).next_to(layer_group, DOWN, buff=0.5)\n activation_labels.add(act_text)\n\n # 2. Create Edges (Fully Connected between adjacent layers)\n for i in range(len(layers) - 1):\n current_layer = layers[i]\n next_layer = layers[i + 1]\n edge_group = VGroup()\n \n for start_node in current_layer:\n for end_node in next_layer:\n line = Line(\n start=start_node.get_right(),\n end=end_node.get_left(),\n stroke_width=1,\n stroke_color=WHITE,\n stroke_opacity=0.2\n )\n edge_group.add(line)\n all_edges.append(line)\n \n edge_groups.append(edge_group)\n\n # --- Animation Sequence ---\n \n # Step 1: Draw the network structure\n self.play(\n FadeIn(VGroup(*layers)),\n Create(VGroup(*all_edges)),\n run_time=2\n )\n \n # Step 2: Show Labels\n self.play(\n FadeIn(labels),\n FadeIn(activation_labels),\n run_time=1\n )\n \n self.wait(0.5)\n \n # Step 3: Animate Forward Pass (Signals)\n def animate_layer_flow(from_layer_idx, to_layer_idx):\n from_nodes = layers[from_layer_idx]\n to_nodes = layers[to_layer_idx]\n \n # Pulse the source nodes to indicate firing\n self.play(\n *[node.animate.set_fill(layer_colors[from_layer_idx], opacity=1).scale(1.2) for node in from_nodes],\n run_time=0.3\n )\n self.play(\n *[node.animate.set_fill(layer_colors[from_layer_idx], opacity=0.3).scale(1/1.2) for node in from_nodes],\n run_time=0.3\n )\n \n # Create signals moving along the edges\n local_signals = VGroup()\n animations_list = []\n \n for start_node in from_nodes:\n for end_node in to_nodes:\n sig = Dot(\n point=start_node.get_right(), \n radius=0.06, \n color=signal_color\n )\n local_signals.add(sig)\n # Define path from the right edge of the start node to the left edge of the end node\n path = Line(start_node.get_right(), end_node.get_left())\n animations_list.append(MoveAlongPath(sig, path, rate_func=linear))\n \n self.add(local_signals)\n self.play(*animations_list, run_time=1.5)\n self.remove(local_signals)\n \n # Pulse the destination layer to show activation\n self.play(\n *[node.animate.set_fill(layer_colors[to_layer_idx], opacity=1).scale(1.2) for node in to_nodes],\n run_time=0.2\n )\n self.play(\n *[node.animate.set_fill(layer_colors[to_layer_idx], opacity=0.3).scale(1/1.2) for node in to_nodes],\n run_time=0.2\n )\n\n # Execute flow between layers\n # Input -> Hidden 1\n animate_layer_flow(0, 1)\n \n # Hidden 1 -> Hidden 2\n animate_layer_flow(1, 2)\n \n # Hidden 2 -> Output\n animate_layer_flow(2, 3)\n \n # Final Highlight on Output (Sigmoid)\n output_node = layers[3][0]\n sigmoid_label = activation_labels[-1]\n \n # Highlight Sigmoid label and output node\n self.play(\n output_node.animate.set_fill(ORANGE, opacity=1).set_stroke(width=4),\n sigmoid_label.animate.set_color(YELLOW).scale(1.2),\n run_time=1\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralAnimation(Scene):\n def construct(self):\n # 1. Axes Setup\n # Display X and Y axes with appropriate ranges, colored blue\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # 2. Formula Display\n # Show the integral formula of the function from 0 to 2 at the top of the screen\n formula = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(formula))\n self.wait(0.5)\n\n # 3. Function Plot\n # Plot the graph of f(x) = x^2 in white and label it with its equation\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # 4. Area Highlighting\n # Highlight the area under the curve between x=0 and x=2 in green with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # 5. Calculation Steps\n # Directly below the integral formula, display the step-by-step calculation\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(formula, DOWN, buff=0.5)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(step1, DOWN, buff=0.3)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\").next_to(step2, DOWN, buff=0.3)\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(0.5)\n\n # 6. Final Result\n # Simplify the expression to show the final numerical value of the integral\n final_result = MathTex(r\"= \\frac{8}{3}\").next_to(step3, DOWN, buff=0.3)\n self.play(Write(final_result))\n self.wait(1)\n\n # 7. Cleanup and Conclusion\n # Fade out all elements except the simplified final result\n elements_to_remove = VGroup(\n axes, labels, formula, graph, graph_label, area, step1, step2, step3\n )\n \n self.play(\n FadeOut(elements_to_remove),\n final_result.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Hold the final result on screen for a moment before ending\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # 1. Axes Setup\n # Display X and Y axes with appropriate ranges, colored blue\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n self.play(Create(axes), Write(labels))\n self.wait(0.5)\n\n # 2. Formula Display\n # Show the integral formula of the function from 0 to 2 at the top of the screen\n formula = MathText(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(formula))\n self.wait(0.5)\n\n # 3. Function Plot\n # Plot the graph of f(x) = x^2 in white and label it with its equation\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = MathTex(\"f(x) = x^2\").next_to(graph, UR, buff=0.2)\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # 4. Area Highlighting\n # Highlight the area under the curve between x=0 and x=2 in green with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(0.5)\n\n # 5. Calculation Steps\n # Directly below the integral formula, display the step-by-step calculation\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(formula, DOWN, buff=0.5)\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(step1, DOWN, buff=0.3)\n step3 = MathTex(r\"= \\frac{8}{3} - 0\").next_to(step2, DOWN, buff=0.3)\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(0.5)\n\n # 6. Final Result\n # Simplify the expression to show the final numerical value of the integral\n final_result = MathTex(r\"= \\frac{8}{3}\").next_to(step3, DOWN, buff=0.3)\n self.play(Write(final_result))\n self.wait(1)\n\n # 7. Cleanup and Conclusion\n # Fade out all elements except the simplified final result\n elements_to_remove = VGroup(\n axes, labels, formula, graph, graph_label, area, step1, step2, step3\n )\n \n self.play(\n FadeOut(elements_to_remove),\n final_result.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Hold the final result on screen for a moment 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 compute the definite integral of x cubed from 0 to 2 using the power rule for integration, including the step-by-step calculation and ending with the presentation of the final result as the area under the curve?", "chosen": "```python\nfrom manim import *\n\nclass IntegralPowerRuleScene(Scene):\n \"\"\"\n Educational animation demonstrating the computation of the definite integral\n of x^3 from 0 to 2 using the power rule, culminating in a visual representation\n of the area under the curve.\n \"\"\"\n def construct(self):\n # ---------------------------------------------------------\n # 1. Setup Coordinate System and Function Plot\n # ---------------------------------------------------------\n # Create axes with appropriate ranges to display the function clearly\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT, buff=1)\n\n # Add axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot the function f(x) = x^3\n curve = axes.plot(lambda x: x**3, color=BLUE, x_range=[0, 2])\n func_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^3\"))\n\n # Animate the creation of the graph environment\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(func_label))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Display the Integral Expression\n # ---------------------------------------------------------\n # Step 1: The original integral\n integral_expr = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx\", font_size=42\n ).to_edge(RIGHT, buff=1).shift(UP * 2)\n\n self.play(Write(integral_expr))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 3. Animate Step-by-Step Calculation\n # ---------------------------------------------------------\n # Step 2: Apply Power Rule (Antiderivative)\n antiderivative_expr = MathTex(\n r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=42\n ).next_to(integral_expr, DOWN, aligned_edge=LEFT)\n\n # Highlight the power rule logic with a temporary note\n rule_note = Tex(\n \"Power Rule: $\\\\int x^n dx = \\\\frac{x^{n+1}}{n+1}$\", \n font_size=30, \n color=YELLOW\n ).next_to(antiderivative_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(rule_note))\n self.play(Write(antiderivative_expr))\n self.wait(1)\n self.play(FadeOut(rule_note))\n\n # Step 3: Substitute Limits\n substitution_expr = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=42\n ).next_to(antiderivative_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(substitution_expr))\n self.wait(1)\n\n # Step 4: Simplify arithmetic and show final result\n result_expr = MathTex(\n r\"= \\frac{16}{4} - 0 = 4\", font_size=42, color=GREEN\n ).next_to(substitution_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(result_expr))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 4. Visualize the Area Under the Curve\n # ---------------------------------------------------------\n # Create the area object under the curve from x=0 to x=2\n area = axes.get_area(\n curve, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.5\n )\n\n # Create vertical lines for integration bounds\n line_0 = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_2 = axes.get_vertical_line(axes.c2p(2, 8), color=GRAY)\n\n # Label for the area value near the filled region\n area_label = MathTex(\"4\", font_size=36, color=BLACK).move_to(axes.c2p(1, 2))\n\n # Highlight the connection between the calculation result and the geometry\n result_box = SurroundingRectangle(result_expr, color=GREEN, buff=0.1)\n\n # Animate the filling of the area to connect the calculation to the geometry\n self.play(\n Create(result_box),\n FadeIn(area, scale=0.5),\n Create(line_0),\n Create(line_2),\n Write(area_label),\n run_time=2\n )\n self.wait(2)\n\n # ---------------------------------------------------------\n # 5. Cleanup for Final Emphasis\n # ---------------------------------------------------------\n # Fade out the derivation steps to emphasize the geometric result\n self.play(\n FadeOut(integral_expr),\n FadeOut(antiderivative_expr),\n FadeOut(substitution_expr),\n FadeOut(result_expr),\n FadeOut(result_box)\n )\n \n # Scale the area label for final emphasis\n self.play(area_label.animate.scale(1.5).set_color(GREEN))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralPowerRuleScene(Scene):\n \"\"\"\n Educational animation demonstrating the computation of the definite integral\n of x^3 from 0 to 2 using the power rule, culminating in a visual representation\n of the area under the curve.\n \"\"\"\n def construct(self):\n # ---------------------------------------------------------\n # 1. Setup Coordinate System and Function Plot\n # ---------------------------------------------------------\n # Create axes with appropriate ranges to display the function clearly\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=6,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT, buff=1)\n\n # Add axis labels\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Plot the function f(x) = x^3\n curve = axes.plot(lambda x: x**3, color=BLUE, x_range=[0, 2])\n func_label = axes.get_graph_label(curve, label=MathText(\"f(x) = x^3\"))\n\n # Animate the creation of the graph environment\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(func_label))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Display the Integral Expression\n # ---------------------------------------------------------\n # Step 1: The original integral\n integral_expr = MathTex(\n r\"\\int_{0}^{2} x^3 \\, dx\", font_size=42\n ).to_edge(RIGHT, buff=1).shift(UP * 2)\n\n self.play(Write(integral_expr))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 3. Animate Step-by-Step Calculation\n # ---------------------------------------------------------\n # Step 2: Apply Power Rule (Antiderivative)\n antiderivative_expr = MathTex(\n r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=42\n ).next_to(integral_expr, DOWN, aligned_edge=LEFT)\n\n # Highlight the power rule logic with a temporary note\n rule_note = Tex(\n \"Power Rule: $\\\\int x^n dx = \\\\frac{x^{n+1}}{n+1}$\", \n font_size=30, \n color=YELLOW\n ).next_to(antiderivative_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(rule_note))\n self.play(Write(antiderivative_expr))\n self.wait(1)\n self.play(FadeOut(rule_note))\n\n # Step 3: Substitute Limits\n substitution_expr = MathTex(\n r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=42\n ).next_to(antiderivative_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(substitution_expr))\n self.wait(1)\n\n # Step 4: Simplify arithmetic and show final result\n result_expr = MathTex(\n r\"= \\frac{16}{4} - 0 = 4\", font_size=42, color=GREEN\n ).next_to(substitution_expr, DOWN, aligned_edge=LEFT)\n\n self.play(Write(result_expr))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 4. Visualize the Area Under the Curve\n # ---------------------------------------------------------\n # Create the area object under the curve from x=0 to x=2\n area = axes.get_area(\n curve, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.5\n )\n\n # Create vertical lines for integration bounds\n line_0 = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_2 = axes.get_vertical_line(axes.c2p(2, 8), color=GRAY)\n\n # Label for the area value near the filled region\n area_label = MathTex(\"4\", font_size=36, color=BLACK).move_to(axes.c2p(1, 2))\n\n # Highlight the connection between the calculation result and the geometry\n result_box = SurroundingRectangle(result_expr, color=GREEN, buff=0.1)\n\n # Animate the filling of the area to connect the calculation to the geometry\n self.play(\n Create(result_box),\n FadeIn(area, scale=0.5),\n Create(line_0),\n Create(line_2),\n Write(area_label),\n run_time=2\n )\n self.wait(2)\n\n # ---------------------------------------------------------\n # 5. Cleanup for Final Emphasis\n # ---------------------------------------------------------\n # Fade out the derivation steps to emphasize the geometric result\n self.play(\n FadeOut(integral_expr),\n FadeOut(antiderivative_expr),\n FadeOut(substitution_expr),\n FadeOut(result_expr),\n FadeOut(result_box)\n )\n \n # Scale the area label for final emphasis\n self.play(area_label.animate.scale(1.5).set_color(GREEN))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starts by showing the one-dimensional wave equation on the screen, then brings in text from above that explains it describes wave propagation. After that, replace the text with another sentence indicating a specific solution to the equation being a sine wave function. Then transform the wave equation on screen into an expression of this sine wave solution, listing out and labeling its parameters such as amplitude, wavenumber, frequency, and phase offset. Finish the animation by replacing all elements on screen with a simplified version of the sine wave solution that does not include the phase offset. Make sure each step is clear and give me a moment to comprehend each part before moving on to the next.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the one-dimensional wave equation\n # ------------------------------------------------------------------\n wave_eq = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n self.play(Write(wave_eq))\n self.wait(2) # Pause for comprehension\n\n # ------------------------------------------------------------------\n # Step 2: Animate text entering from above explaining propagation\n # ------------------------------------------------------------------\n prop_text = Tex(\n \"This equation describes wave propagation.\",\n font_size=36,\n color=BLUE_B\n ).next_to(wave_eq, UP, buff=1)\n \n # Animate text entering from above\n self.play(FadeIn(prop_text, shift=DOWN))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Replace explanatory text with sine wave solution statement\n # ------------------------------------------------------------------\n sol_text = Tex(\n \"A specific solution is a sine wave function.\",\n font_size=36,\n color=BLUE_B\n ).next_to(wave_eq, UP, buff=1)\n\n self.play(ReplacementTransform(prop_text, sol_text))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Transform the wave equation into the sine wave solution\n # ------------------------------------------------------------------\n # Define the sine wave solution with individual components for coloring\n # u(x,t) = A sin(kx - ωt + φ)\n sine_sol = MathTex(\n \"u(x,t)\", \"=\", \"A\", r\"\\sin(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\",\n font_size=48\n )\n \n # Color code the parameters for clarity in the next step\n sine_sol[2].set_color(RED) # A\n sine_sol[4].set_color(BLUE) # k\n sine_sol[7].set_color(GREEN) # ω\n sine_sol[10].set_color(YELLOW) # φ\n\n # Fade out the explanation text and transform the PDE into the solution\n self.play(\n FadeOut(sol_text),\n ReplacementTransform(wave_eq, sine_sol)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Explicitly list and label the parameters\n # ------------------------------------------------------------------\n # Create labels corresponding to the colored parameters\n labels = VGroup(\n MathTex(\"A\", \": \\\\text{Amplitude}\").set_color(RED),\n MathTex(\"k\", \": \\\\text{Wavenumber}\").set_color(BLUE),\n MathTex(r\"\\omega\", \": \\\\text{Frequency}\").set_color(GREEN),\n MathTex(r\"\\phi\", \": \\\\text{Phase Offset}\").set_color(YELLOW)\n )\n labels.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n labels.next_to(sine_sol, DOWN, buff=1)\n \n # Animate the labels appearing one by one for methodical pacing\n for label in labels:\n self.play(FadeIn(label, shift=UP))\n self.wait(1)\n \n self.wait(3) # Extra time to read the parameters\n\n # ------------------------------------------------------------------\n # Step 6: Clear screen and display simplified sine wave solution\n # ------------------------------------------------------------------\n # Clear the screen\n self.play(FadeOut(sine_sol), FadeOut(labels))\n \n # Define the simplified solution (no phase offset)\n # u(x,t) = A sin(kx - ωt)\n simple_sol = MathTex(\n \"u(x,t)\", \"=\", \"A\", r\"\\sin(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \")\",\n font_size=54,\n color=YELLOW\n )\n \n # Write the final simplified equation\n self.play(Write(simple_sol))\n self.wait(3) # Final pause\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the one-dimensional wave equation\n # ------------------------------------------------------------------\n wave_eq = MathText(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n self.play(Write(wave_eq))\n self.wait(2) # Pause for comprehension\n\n # ------------------------------------------------------------------\n # Step 2: Animate text entering from above explaining propagation\n # ------------------------------------------------------------------\n prop_text = Tex(\n \"This equation describes wave propagation.\",\n font_size=36,\n color=BLUE_B\n ).next_to(wave_eq, UP, buff=1)\n \n # Animate text entering from above\n self.play(FadeIn(prop_text, shift=DOWN))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 3: Replace explanatory text with sine wave solution statement\n # ------------------------------------------------------------------\n sol_text = Tex(\n \"A specific solution is a sine wave function.\",\n font_size=36,\n color=BLUE_B\n ).next_to(wave_eq, UP, buff=1)\n\n self.play(ReplacementTransform(prop_text, sol_text))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: Transform the wave equation into the sine wave solution\n # ------------------------------------------------------------------\n # Define the sine wave solution with individual components for coloring\n # u(x,t) = A sin(kx - ωt + φ)\n sine_sol = MathTex(\n \"u(x,t)\", \"=\", \"A\", r\"\\sin(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\",\n font_size=48\n )\n \n # Color code the parameters for clarity in the next step\n sine_sol[2].set_color(RED) # A\n sine_sol[4].set_color(BLUE) # k\n sine_sol[7].set_color(GREEN) # ω\n sine_sol[10].set_color(YELLOW) # φ\n\n # Fade out the explanation text and transform the PDE into the solution\n self.play(\n FadeOut(sol_text),\n ReplacementTransform(wave_eq, sine_sol)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Explicitly list and label the parameters\n # ------------------------------------------------------------------\n # Create labels corresponding to the colored parameters\n labels = VGroup(\n MathTex(\"A\", \": \\\\text{Amplitude}\").set_color(RED),\n MathTex(\"k\", \": \\\\text{Wavenumber}\").set_color(BLUE),\n MathTex(r\"\\omega\", \": \\\\text{Frequency}\").set_color(GREEN),\n MathTex(r\"\\phi\", \": \\\\text{Phase Offset}\").set_color(YELLOW)\n )\n labels.arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n labels.next_to(sine_sol, DOWN, buff=1)\n \n # Animate the labels appearing one by one for methodical pacing\n for label in labels:\n self.play(FadeIn(label, shift=UP))\n self.wait(1)\n \n self.wait(3) # Extra time to read the parameters\n\n # ------------------------------------------------------------------\n # Step 6: Clear screen and display simplified sine wave solution\n # ------------------------------------------------------------------\n # Clear the screen\n self.play(FadeOut(sine_sol), FadeOut(labels))\n \n # Define the simplified solution (no phase offset)\n # u(x,t) = A sin(kx - ωt)\n simple_sol = MathTex(\n \"u(x,t)\", \"=\", \"A\", r\"\\sin(\", \"k\", \"x\", \"-\", r\"\\omega\", \"t\", \")\",\n font_size=54,\n color=YELLOW\n )\n \n # Write the final simplified equation\n self.play(Write(simple_sol))\n self.wait(3) # Final pause\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(label_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 demonstrates how to calculate the area under the curve of x squared from x = 1 to x = 3, showing each step including the integral setup, applying the power rule of integration, and the final solution?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Axes and Function\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True, \"numbers_to_include\": [1, 3]},\n tips=False\n ).scale(0.8).to_edge(DOWN)\n\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 3.2], color=BLUE)\n func_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n # 2. Create the Area Under the Curve\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n line_left = axes.get_vertical_line(axes.input_to_graph_point(1, graph), color=WHITE)\n line_right = axes.get_vertical_line(axes.input_to_graph_point(3, graph), color=WHITE)\n\n # 3. Prepare the Math Steps\n # Step 1: Integral Setup\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\")\n \n # Step 2: Explicitly show the power rule application before simplifying the exponent\n step2 = MathTex(r\"= \\left[ \\frac{x^{2+1}}{2+1} \\right]_{1}^{3} = \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\")\n \n # Step 3: Evaluation of Bounds\n step3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Final Solution including both exact fraction and decimal approximation\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3} = \\frac{26}{3} \\approx 8.67\")\n\n # Group and position the equations at the top to avoid overlapping with the graph\n math_steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n math_steps.to_edge(UP).shift(DOWN * 0.2)\n\n # 4. Animation Sequence\n \n # Introduce the graph and axes\n self.play(Create(axes), Create(graph), Write(func_label))\n self.wait(0.5)\n \n # Highlight the area of interest\n self.play(FadeIn(area), Create(line_left), Create(line_right))\n self.wait(0.5)\n \n # Display the integral setup\n self.play(Write(step1))\n self.wait(1)\n \n # Apply Power Rule\n self.play(Write(step2))\n self.wait(1)\n \n # Evaluate Bounds\n self.play(Write(step3))\n self.wait(1)\n \n # Show Final Result\n self.play(Write(step4))\n self.wait(1)\n \n # Final highlight pulse for emphasis\n self.play(step4.animate.set_color(YELLOW).scale(1.1), run_time=0.5)\n self.play(step4.animate.scale(1/1.1), run_time=0.5)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Axes and Function\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True, \"numbers_to_include\": [1, 3]},\n tips=False\n ).scale(0.8).to_edge(DOWN)\n\n func = lambda x: x**2\n graph = axes.plot(func, x_range=[0, 3.2], color=BLUE)\n func_label = MathText(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n # 2. Create the Area Under the Curve\n area = axes.get_area(graph, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n line_left = axes.get_vertical_line(axes.input_to_graph_point(1, graph), color=WHITE)\n line_right = axes.get_vertical_line(axes.input_to_graph_point(3, graph), color=WHITE)\n\n # 3. Prepare the Math Steps\n # Step 1: Integral Setup\n step1 = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\")\n \n # Step 2: Explicitly show the power rule application before simplifying the exponent\n step2 = MathTex(r\"= \\left[ \\frac{x^{2+1}}{2+1} \\right]_{1}^{3} = \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\")\n \n # Step 3: Evaluation of Bounds\n step3 = MathTex(r\"= \\frac{3^3}{3} - \\frac{1^3}{3}\")\n \n # Step 4: Final Solution including both exact fraction and decimal approximation\n step4 = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3} = \\frac{26}{3} \\approx 8.67\")\n\n # Group and position the equations at the top to avoid overlapping with the graph\n math_steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n math_steps.to_edge(UP).shift(DOWN * 0.2)\n\n # 4. Animation Sequence\n \n # Introduce the graph and axes\n self.play(Create(axes), Create(graph), Write(func_label))\n self.wait(0.5)\n \n # Highlight the area of interest\n self.play(FadeIn(area), Create(line_left), Create(line_right))\n self.wait(0.5)\n \n # Display the integral setup\n self.play(Write(step1))\n self.wait(1)\n \n # Apply Power Rule\n self.play(Write(step2))\n self.wait(1)\n \n # Evaluate Bounds\n self.play(Write(step3))\n self.wait(1)\n \n # Show Final Result\n self.play(Write(step4))\n self.wait(1)\n \n # Final highlight pulse for emphasis\n self.play(step4.animate.set_color(YELLOW).scale(1.1), run_time=0.5)\n self.play(step4.animate.scale(1/1.1), run_time=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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\n\nclass EulersFormula(Scene):\n def construct(self):\n # 1. Title Display\n title = Text(\"Euler's Formula\", font_size=48)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Title Movement\n self.play(title.animate.to_edge(UP))\n self.wait(0.5)\n\n # 3. Formula Introduction\n formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=36)\n self.play(Write(formula))\n self.wait(1)\n\n # Prepare for Complex Plane Visualization\n self.play(FadeOut(formula))\n\n # 4. Complex Plane Visualization\n plane = ComplexPlane(\n x_range=[-2, 2],\n y_range=[-2, 2],\n background_line_style={\n \"stroke_color\": GREY_B,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n )\n \n # Using ParametricFunction ensures the circle perfectly matches the plane's scaling\n unit_circle = ParametricFunction(\n lambda t: plane.c2p(np.cos(t), np.sin(t)),\n t_range=[0, TAU],\n color=BLUE\n )\n \n theta = ValueTracker(0)\n \n line = always_redraw(lambda: Line(\n start=plane.c2p(0, 0),\n end=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=YELLOW\n ))\n \n dot = always_redraw(lambda: Dot(\n point=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=RED\n ))\n \n angle_arc = always_redraw(lambda: Arc(\n radius=0.3,\n start_angle=0,\n angle=theta.get_value(),\n color=GREEN\n ))\n\n self.play(Create(plane), Create(unit_circle))\n self.add(line, dot, angle_arc)\n\n # 5. Rotation Completion\n # Using linear rate_func ensures constant angular velocity\n self.play(theta.animate.set_value(TAU), run_time=4, rate_func=linear)\n self.wait(0.5)\n\n # 6. Screen Clear\n self.clear()\n self.wait(0.5)\n\n # 7. Conclusion\n final_formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=48)\n self.play(Write(final_formula))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulersFormula(Scene):\n def construct(self):\n # 1. Title Display\n title = Text(\"Euler's Formula\", font_size=48)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Title Movement\n self.play(title.animate.to_edge(UP))\n self.wait(0.5)\n\n # 3. Formula Introduction\n formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=36)\n self.play(Write(formula))\n self.wait(1)\n\n # Prepare for Complex Plane Visualization\n self.play(FadeOut(formula))\n\n # 4. Complex Plane Visualization\n plane = ComplexPlane(\n x_range=[-2, 2],\n y_range=[-2, 2],\n background_line_style={\n \"stroke_color\": GREY_B,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n )\n \n # Using ParametricFunction ensures the circle perfectly matches the plane's scaling\n unit_circle = ParametricFunction(\n lambda t: plane.c2p(np.cos(t), np.sin(t)),\n t_range=[0, TAU],\n color=BLUE\n )\n \n theta = ValueTracker(0)\n \n line = AlwaysUpToCondition(lambda: Line(\n start=plane.c2p(0, 0),\n end=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=YELLOW\n ))\n \n dot = always_redraw(lambda: Dot(\n point=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=RED\n ))\n \n angle_arc = always_redraw(lambda: Arc(\n radius=0.3,\n start_angle=0,\n angle=theta.get_value(),\n color=GREEN\n ))\n\n self.play(Create(plane), Create(unit_circle))\n self.add(line, dot, angle_arc)\n\n # 5. Rotation Completion\n # Using linear rate_func ensures constant angular velocity\n self.play(theta.animate.set_value(TAU), run_time=4, rate_func=linear)\n self.wait(0.5)\n\n # 6. Screen Clear\n self.clear()\n self.wait(0.5)\n\n # 7. Conclusion\n final_formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=48)\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\"Projectile motion with air resistance\", font_size=40)\n subtitle = Text(\"The motion is influenced by gravity and drag force.\", font_size=24, color=GRAY)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title), run_time=1.5)\n self.play(FadeIn(subtitle), run_time=0.5)\n self.wait(0.5)\n \n title_group = VGroup(title, subtitle)\n self.play(title_group.animate.to_edge(UP), run_time=1)\n \n # ------------------------------------------------------------------\n # 2. Equations Display\n # ------------------------------------------------------------------\n # Equation for drag force (quadratic model)\n eq_drag = MathTex(r\"\\vec{F}_d = -\\frac{1}{2} \\rho C_d A v^2 \\hat{v}\", font_size=36)\n # Equation for resulting acceleration\n eq_accel = MathTex(r\"\\vec{a} = \\vec{g} - \\frac{\\rho C_d A}{2m} v^2 \\hat{v}\", font_size=36)\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.5)\n equations.next_to(title_group, DOWN, buff=0.5)\n \n self.play(Write(equations), run_time=2)\n self.wait(1)\n \n # Shift equations to make room for the trajectory\n self.play(equations.animate.to_edge(LEFT), run_time=1)\n \n # ------------------------------------------------------------------\n # 3. Animation Core - Physics Calculation & Trajectory\n # ------------------------------------------------------------------\n # Physical parameters\n g = 9.81 # Gravity (m/s^2)\n dt = 0.02 # Time step for integration\n v0 = 25.0 # Initial velocity (m/s)\n theta = 60 * DEGREES # Launch angle\n k = 0.1 # Simplified quadratic drag coefficient (rho * Cd * A / 2m)\n \n # Initial velocity components\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n x, y = 0.0, 0.0\n \n # List to store trajectory points\n points = []\n \n # Numerical Integration (Euler method)\n while y >= 0:\n points.append([x, y, 0])\n v = np.sqrt(vx**2 + vy**2)\n \n # Acceleration components\n ax = -k * v * vx\n ay = -g - k * v * vy\n \n # Update velocities\n vx += ax * dt\n vy += ay * dt\n \n # Update positions\n x += vx * dt\n y += vy * dt\n \n # Safety break\n if len(points) > 2000:\n break\n \n # Create Axes and scale the trajectory to fit the screen\n max_x = max(p[0] for p in points) if points else 1.0\n max_y = max(p[1] for p in points) if points else 1.0\n \n axes = Axes(\n x_range=[0, max_x + 2, 5],\n y_range=[0, max_y + 2, 5],\n axis_config={\"include_tip\": True}\n ).scale(0.8).shift(DOWN * 1.0 + RIGHT * 1.0)\n \n # Convert physics points to Manim coordinate space\n path_points = [axes.c2p(p[0], p[1]) for p in points]\n \n trajectory = VMobject()\n trajectory.set_points_as_corners(path_points)\n trajectory.set_stroke(BLUE, width=4)\n \n # Create the projectile dot\n dot = Dot(color=YELLOW, radius=0.1)\n dot.move_to(path_points[0])\n \n # Traced path to show the trajectory as the dot moves\n trace = TracedPath(dot.get_center, stroke_color=BLUE, stroke_width=4)\n \n self.play(Create(axes), run_time=1)\n self.add(trace, dot)\n \n # ------------------------------------------------------------------\n # 4. Duration Constraint\n # ------------------------------------------------------------------\n # Animate the dot moving along the calculated path for ~4 seconds\n self.play(\n MoveAlongPath(dot, trajectory),\n run_time=4,\n rate_func=linear\n )\n \n self.wait(1)\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(\"Projectile motion with air resistance\", font_size=40)\n subtitle = Text(\"The motion is influenced by gravity and drag force.\", font_size=24, color=GRAY)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title), run_time=1.5)\n self.play(FadeIn(subtitle), run_time=0.5)\n self.wait(0.5)\n \n title_group = VGroup(title, subtitle)\n self.play(title_group.animate.to_edge(UP), run_time=1)\n \n # ------------------------------------------------------------------\n # 2. Equations Display\n # ------------------------------------------------------------------\n # Equation for drag force (quadratic model)\n eq_drag = MathTex(r\"\\vec{F}_d = -\\frac{1}{2} \\rho C_d A v^2 \\hat{v}\", font_size=36)\n # Equation for resulting acceleration\n eq_accel = MathTex(r\"\\vec{a} = \\vec{g} - \\frac{\\rho C_d A}{2m} v^2 \\hat{v}\", font_size=36)\n \n equations = VGroup(eq_drag, eq_accel).arrange(DOWN, buff=0.5)\n equations.next_to(title_group, DOWN, buff=0.5)\n \n self.play(Write(equations), run_time=2)\n self.wait(1)\n \n # Shift equations to make room for the trajectory\n self.play(equations.animate.to_edge(LEFT), run_time=1)\n \n # ------------------------------------------------------------------\n # 3. Animation Core - Physics Calculation & Trajectory\n # ------------------------------------------------------------------\n # Physical parameters\n g = 9.81 # Gravity (m/s^2)\n dt = 0.02 # Time step for integration\n v0 = 25.0 # Initial velocity (m/s)\n theta = 60 * DEGREES # Launch angle\n k = 0.1 # Simplified quadratic drag coefficient (rho * Cd * A / 2m)\n \n # Initial velocity components\n vx = v0 * np.cos(theta)\n vy = v0 * np.sin(theta)\n x, y = 0.0, 0.0\n \n # List to store trajectory points\n points = []\n \n # Numerical Integration (Euler method)\n while y >= 0:\n points.append([x, y, 0])\n v = np.sqrt(vx**2 + vy**2)\n \n # Acceleration components\n ax = -k * v * vx\n ay = -g - k * v * vy\n \n # Update velocities\n vx += ax * dt\n vy += ay * dt\n \n # Update positions\n x += vx * dt\n y += vy * dt\n \n # Safety break\n if len(points) > 2000:\n break\n \n # Create Axes and scale the trajectory to fit the screen\n max_x = max(p[0] for p in points) if points else 1.0\n max_y = max(p[1] for p in points) if points else 1.0\n \n axes = Axes(label_font_size=24, \n x_range=[0, max_x + 2, 5],\n y_range=[0, max_y + 2, 5],\n axis_config={\"include_tip\": True}\n ).scale(0.8).shift(DOWN * 1.0 + RIGHT * 1.0)\n \n # Convert physics points to Manim coordinate space\n path_points = [axes.c2p(p[0], p[1]) for p in points]\n \n trajectory = VMobject()\n trajectory.set_points_as_corners(path_points)\n trajectory.set_stroke(BLUE, width=4)\n \n # Create the projectile dot\n dot = Dot(color=YELLOW, radius=0.1)\n dot.move_to(path_points[0])\n \n # Traced path to show the trajectory as the dot moves\n trace = TracedPath(dot.get_center, stroke_color=BLUE, stroke_width=4)\n \n self.play(Create(axes), run_time=1)\n self.add(trace, dot)\n \n # ------------------------------------------------------------------\n # 4. Duration Constraint\n # ------------------------------------------------------------------\n # Animate the dot moving along the calculated path for ~4 seconds\n self.play(\n MoveAlongPath(dot, trajectory),\n run_time=4,\n rate_func=linear\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 one on the right of the screen. Please show multiple red light rays originating from the left side traveling horizontally across the screen with varying vertical starting positions to demonstrate the different paths the rays take after passing through both lenses.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(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```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visually explains the process of solving a basic definite integral using the power rule of integration. It should start by presenting the problem of integrating x cubed from 0 to 1. Then, it should display a text saying \"Using the power rule of integration\" followed by the formula for the power rule. After this, the video should show the step-by-step substitution of the values into the power rule formula and transform the original problem to reflect this integration step. Next, the animation should update the text to \"Evaluating the definite integral\" and demonstrate how to evaluate the result at the bounds of 0 and 1. Finally, it should display the final solution and conclude by clearing the screen and showing the result by itself. Can you create this educational animation using simple and engaging visuals?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- 1. Problem Presentation ---\n problem = MathTex(r\"\\int_0^1 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 the rule\n self.play(problem.animate.to_edge(UP))\n self.wait(1)\n\n # --- 2. Rule Introduction ---\n rule_text = Text(\"Using the power rule of integration\", font_size=36)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36)\n \n rule_group = VGroup(rule_text, rule_formula).arrange(DOWN, buff=0.5)\n rule_group.shift(UP * 0.5)\n\n self.play(Write(rule_text))\n self.play(Write(rule_formula))\n self.wait(2)\n \n # Fade out the rule text and formula to focus on substitution\n self.play(FadeOut(rule_group))\n\n # --- 3. Step-by-Step Substitution ---\n # Substituting n=3 into the formula\n substitution_1 = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_0^1\")\n substitution_1.scale(1.2)\n \n self.play(ReplacementTransform(problem, substitution_1))\n self.wait(1)\n \n # Simplifying the fraction\n substitution_2 = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^1\")\n substitution_2.scale(1.2)\n \n self.play(ReplacementTransform(substitution_1, substitution_2))\n self.wait(1)\n\n # --- 4. Evaluation ---\n eval_text = Text(\"Evaluating the definite integral\", font_size=36)\n eval_text.to_edge(UP)\n \n evaluation_step = MathTex(r\"\\frac{1^4}{4} - \\frac{0^4}{4}\")\n evaluation_step.scale(1.2)\n \n self.play(Write(eval_text))\n self.play(ReplacementTransform(substitution_2, evaluation_step))\n self.wait(2)\n\n # --- 5. Conclusion ---\n final_solution = MathTex(r\"= \\frac{1}{4}\")\n final_solution.scale(1.2).next_to(evaluation_step, RIGHT)\n \n self.play(Write(final_solution))\n self.wait(2)\n \n # Clear the screen and show only the final result\n self.play(FadeOut(eval_text), FadeOut(evaluation_step), FadeOut(final_solution))\n \n final_answer = MathTex(r\"\\frac{1}{4}\", font_size=100)\n final_answer.set_color(YELLOW)\n \n self.play(Write(final_answer))\n self.play(final_answer.animate.scale(1.2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n def construct(self):\n # --- 1. Problem Presentation ---\n problem = MathText(r\"\\int_0^1 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 the rule\n self.play(problem.animate.to_edge(UP))\n self.wait(1)\n\n # --- 2. Rule Introduction ---\n rule_text = Text(\"Using the power rule of integration\", font_size=36)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36)\n \n rule_group = VGroup(rule_text, rule_formula).arrange(DOWN, buff=0.5)\n rule_group.shift(UP * 0.5)\n\n self.play(Write(rule_text))\n self.play(Write(rule_formula))\n self.wait(2)\n \n # Fade out the rule text and formula to focus on substitution\n self.play(FadeOut(rule_group))\n\n # --- 3. Step-by-Step Substitution ---\n # Substituting n=3 into the formula\n substitution_1 = MathTex(r\"\\left[ \\frac{x^{3+1}}{3+1} \\right]_0^1\")\n substitution_1.scale(1.2)\n \n self.play(ReplacementTransform(problem, substitution_1))\n self.wait(1)\n \n # Simplifying the fraction\n substitution_2 = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^1\")\n substitution_2.scale(1.2)\n \n self.play(ReplacementTransform(substitution_1, substitution_2))\n self.wait(1)\n\n # --- 4. Evaluation ---\n eval_text = Text(\"Evaluating the definite integral\", font_size=36)\n eval_text.to_edge(UP)\n \n evaluation_step = MathTex(r\"\\frac{1^4}{4} - \\frac{0^4}{4}\")\n evaluation_step.scale(1.2)\n \n self.play(Write(eval_text))\n self.play(ReplacementTransform(substitution_2, evaluation_step))\n self.wait(2)\n\n # --- 5. Conclusion ---\n final_solution = MathTex(r\"= \\frac{1}{4}\")\n final_solution.scale(1.2).next_to(evaluation_step, RIGHT)\n \n self.play(Write(final_solution))\n self.wait(2)\n \n # Clear the screen and show only the final result\n self.play(FadeOut(eval_text), FadeOut(evaluation_step), FadeOut(final_solution))\n \n final_answer = MathTex(r\"\\frac{1}{4}\", font_size=100)\n final_answer.set_color(YELLOW)\n \n self.play(Write(final_answer))\n self.play(final_answer.animate.scale(1.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 the concept of a sine wave through a simple video. Can you show a sine function equation, follow it with a sentence describing it as the graph of a sine function, and then actually draw the sine wave graph? I'd also like to include a sentence stating that sine waves are periodic in nature, with a note on their amplitude and period afterward. Finally, clear the screen and restate the sine function equation to conclude the animation. The text should be easy to read and positioned appropriately.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineWaveExplanation(Scene):\n def construct(self):\n # 1. Display Equation\n equation = MathTex(r\"y = \\sin(x)\", font_size=60)\n equation.to_edge(UP, buff=1.0)\n self.play(Write(equation))\n self.wait(1)\n\n # 2. Description\n description = Text(\"This is the graph of a sine function\", font_size=36, color=WHITE)\n description.next_to(equation, DOWN, buff=0.5)\n self.play(FadeIn(description))\n self.wait(1)\n\n # 3. Graph Plotting\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=4,\n axis_config={\"include_tip\": True, \"include_numbers\": False}\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(\n x_label=MathTex(\"x\"), \n y_label=MathTex(\"y\")\n )\n \n sine_graph = axes.plot(\n lambda x: np.sin(x), \n x_range=[-2 * PI, 2 * PI], \n color=BLUE, \n stroke_width=4\n )\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sine_graph), run_time=3)\n self.wait(1)\n\n # 4. Periodicity Note\n periodicity = Text(\"Sine waves are periodic in nature\", font_size=32, color=GREEN)\n periodicity.to_edge(DOWN, buff=1.0)\n self.play(Write(periodicity))\n self.wait(1)\n\n # 5. Properties Detail\n properties = Text(\"Amplitude: 1 | Period: 2\\pi \", font_size=32, color=YELLOW)\n properties.next_to(periodicity, UP, buff=0.3)\n self.play(FadeIn(properties))\n self.wait(2)\n\n # 6. Clear Screen\n all_objects = VGroup(equation, description, axes, labels, sine_graph, periodicity, properties)\n self.play(FadeOut(all_objects))\n self.wait(0.5)\n\n # 7. Conclusion\n conclusion_eq = MathTex(r\"y = \\sin(x)\", font_size=80)\n conclusion_eq.move_to(ORIGIN)\n self.play(Write(conclusion_eq))\n self.play(conclusion_eq.animate.scale(1.2).set_color(BLUE))\n self.wait(2)\n self.play(FadeOut(conclusion_eq))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineWaveExplanation(Scene):\n def construct(self):\n # 1. Display Equation\n equation = MathTex(r\"y = \\sin(x)\", font_size=60)\n equation.to_edge(UP, buff=1.0)\n self.play(Write(equation))\n self.wait(1)\n\n # 2. Description\n description = Text(\"This is the graph of a sine function\", font_size=36, color=WHITE)\n description.next_to(equation, DOWN, buff=0.5)\n self.play(FadeIn(description))\n self.wait(1)\n\n # 3. Graph Plotting\n axes = Axes(label_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=4,\n axis_config={\"include_tip\": True, \"include_numbers\": False}\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(\n x_label=MathTex(\"x\"), \n y_label=MathTex(\"y\")\n )\n \n sine_graph = axes.plot(\n lambda x: np.sin(x), \n x_range=[-2 * PI, 2 * PI], \n color=BLUE, \n stroke_width=4\n )\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sine_graph), run_time=3)\n self.wait(1)\n\n # 4. Periodicity Note\n periodicity = Text(\"Sine waves are periodic in nature\", font_size=32, color=GREEN)\n periodicity.to_edge(DOWN, buff=1.0)\n self.play(Write(periodicity))\n self.wait(1)\n\n # 5. Properties Detail\n properties = Text(\"Amplitude: 1 | Period: 2\\pi \", font_size=32, color=YELLOW)\n properties.next_to(periodicity, UP, buff=0.3)\n self.play(FadeIn(properties))\n self.wait(2)\n\n # 6. Clear Screen\n all_objects = VGroup(equation, description, axes, labels, sine_graph, periodicity, properties)\n self.play(FadeOut(all_objects))\n self.wait(0.5)\n\n # 7. Conclusion\n conclusion_eq = MathTex(r\"y = \\sin(x)\", font_size=80)\n conclusion_eq.move_to(ORIGIN)\n self.play(Write(conclusion_eq))\n self.play(conclusion_eq.animate.scale(1.2).set_color(BLUE))\n self.wait(2)\n self.play(FadeOut(conclusion_eq))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Bézout's Identity' (Walking the Lattice: Understanding Bézout's Identity): How can the graphical representation of Bézout's Identity reveal the relationship between coprime integers?\nVisual style guidance: A modern educational design using contrasting colors such as dark blues and bright greens for clarity. Visualizations feature dynamic motions, pixelation of paths for illustration, and an orchestration of fluid grid patterns merging into algebraic clarity for storytelling.", "chosen": "```python\nfrom manim import *\n\nclass BezoultIdentityScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Walking the Lattice: Understanding Bézout's Identity\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Define coprime numbers\n a, b = 3, 5 # These are coprime (gcd = 1)\n \n # Explain Bezout's Identity\n bezout_eq = Text(f\"For coprime integers a={a}, b={b}:\", font_size=28)\n bezout_eq.next_to(title, DOWN, buff=0.5)\n self.play(Write(bezout_eq))\n self.wait(1)\n \n # The equation\n equation = Text(f\"{a}x + {b}y = 1\", font_size=32)\n equation.next_to(bezout_eq, DOWN, buff=0.5)\n self.play(Write(equation))\n self.wait(1)\n \n # Create a grid\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-4, 4, 1],\n axis_config={\"include_tip\": False}\n )\n axes.shift(DOWN * 0.5)\n \n self.play(\n FadeOut(bezout_eq),\n Create(axes)\n )\n \n # Mark the origin\n origin = Dot(axes.c2p(0, 0), color=WHITE)\n origin_label = Text(\"(0,0)\", font_size=24).next_to(origin, DOWN+LEFT, buff=0.1)\n self.play(Create(origin), Write(origin_label))\n \n # Show a solution: (2, -1)\n x1, y1 = 2, -1\n point1 = Dot(axes.c2p(x1, y1), color=YELLOW)\n label1 = Text(f\"({x1},{y1})\", font_size=24).next_to(point1, UP, buff=0.1)\n path1 = Line(axes.c2p(0, 0), axes.c2p(x1, y1), color=YELLOW)\n \n self.play(Create(path1), Create(point1), Write(label1))\n self.wait(1)\n \n # Show calculation\n calc1 = Text(f\"{a}({x1}) + {b}({y1}) = {a*x1 + b*y1}\", font_size=28)\n calc1.to_edge(DOWN, buff=0.5)\n self.play(Write(calc1))\n self.wait(1)\n \n # Show another solution: (-3, 2)\n x2, y2 = -3, 2\n point2 = Dot(axes.c2p(x2, y2), color=RED)\n label2 = Text(f\"({x2},{y2})\", font_size=24).next_to(point2, UP, buff=0.1)\n path2 = Line(axes.c2p(0, 0), axes.c2p(x2, y2), color=RED)\n \n self.play(Create(path2), Create(point2), Write(label2))\n self.wait(1)\n \n # Update calculation\n calc2 = Text(f\"{a}({x2}) + {b}({y2}) = {a*x2 + b*y2}\", font_size=28)\n calc2.to_edge(DOWN, buff=0.5)\n self.play(Transform(calc1, calc2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Bézout's Identity reveals how coprime integers\\nform paths on the integer lattice.\", font_size=28)\n conclusion.move_to(ORIGIN)\n \n self.play(\n FadeOut(axes),\n FadeOut(origin),\n FadeOut(origin_label),\n FadeOut(path1),\n FadeOut(point1),\n FadeOut(label1),\n FadeOut(path2),\n FadeOut(point2),\n FadeOut(label2),\n FadeOut(calc1),\n FadeOut(equation),\n Write(conclusion)\n )\n \n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(title))\n```", "rejected": "```python\nfrom manim import *\n\nclass BezoultIdentityScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Walking the Lattice: Understanding Bézout's Identity\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Define coprime numbers\n a, b = 3, 5 # These are coprime (gcd = 1)\n \n # Explain Bezout's Identity\n bezout_eq = Text(f\"For coprime integers a={a}, b={b}:\", font_size=28)\n bezout_eq.next_to(title, DOWN, buff=0.5)\n self.play(Write(bezout_eq))\n self.wait(1)\n \n # The equation\n equation = Text(f\"{a}x + {b}y = 1\", font_size=32)\n equation.next_to(bezout_eq, DOWN, buff=0.5)\n self.play(Write(equation))\n self.wait(1)\n \n # Create a grid\n axes = Axes(label_font_size=24, \n x_range=[-4, 4, 1],\n y_range=[-4, 4, 1],\n axis_config={\"include_tip\": False}\n )\n axes.shift(DOWN * 0.5)\n \n self.play(\n FadeOut(bezout_eq),\n Create(axes)\n )\n \n # Mark the origin\n origin = Dot(axes.c2p(0, 0), color=WHITE)\n origin_label = Text(\"(0,0)\", font_size=24).next_to(origin, DOWN+LEFT, buff=0.1)\n self.play(Create(origin), Write(origin_label))\n \n # Show a solution: (2, -1)\n x1, y1 = 2, -1\n point1 = Dot(axes.c2p(x1, y1), color=YELLOW)\n label1 = Text(f\"({x1},{y1})\", font_size=24).next_to(point1, UP, buff=0.1)\n path1 = Line(axes.c2p(0, 0), axes.c2p(x1, y1), color=YELLOW)\n \n self.play(Create(path1), Create(point1), Write(label1))\n self.wait(1)\n \n # Show calculation\n calc1 = Text(f\"{a}({x1}) + {b}({y1}) = {a*x1 + b*y1}\", font_size=28)\n calc1.to_edge(DOWN, buff=0.5)\n self.play(Write(calc1))\n self.wait(1)\n \n # Show another solution: (-3, 2)\n x2, y2 = -3, 2\n point2 = Dot(axes.c2p(x2, y2), color=RED)\n label2 = Text(f\"({x2},{y2})\", font_size=24).next_to(point2, UP, buff=0.1)\n path2 = Line(axes.c2p(0, 0), axes.c2p(x2, y2), color=RED)\n \n self.play(Create(path2), Create(point2), Write(label2))\n self.wait(1)\n \n # Update calculation\n calc2 = Text(f\"{a}({x2}) + {b}({y2}) = {a*x2 + b*y2}\", font_size=28)\n calc2.to_edge(DOWN, buff=0.5)\n self.play(Transform(calc1, calc2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Bézout's Identity reveals how coprime integers\\nform paths on the integer lattice.\", font_size=28)\n conclusion.move_to(ORIGIN)\n \n self.play(\n FadeOut(axes),\n FadeOut(origin),\n FadeOut(origin_label),\n FadeOut(path1),\n FadeOut(point1),\n FadeOut(label1),\n FadeOut(path2),\n FadeOut(point2),\n FadeOut(label2),\n FadeOut(calc1),\n FadeOut(equation),\n Write(conclusion)\n )\n \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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 step-by-step animated video demonstration that explains how to solve a triple integral problem where I have to integrate the function xyz over the cube with sides between 0 and 1, showing each stage of integration with respect to each variable x, y, and z, including written explanations of each step positioned at the top of the screen?", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Configuration ---\n text_style = {\n \"font_size\": 30,\n \"color\": YELLOW\n }\n equation_scale = 1.2\n\n # --- Step 0: Introduction ---\n # Display the initial problem statement\n intro_text = Text(\"Problem: Evaluate the triple integral over the unit cube\", **text_style)\n intro_text.to_edge(UP, buff=0.5)\n\n initial_problem = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\"\n )\n initial_problem.scale(equation_scale)\n initial_problem.next_to(intro_text, DOWN, buff=1)\n\n self.play(Write(intro_text), Write(initial_problem))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x (treat y, z as constants)\", **text_style)\n step1_text.to_edge(UP, buff=0.5)\n\n step1_eq = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{x^2}{2} yz \\right]_{x=0}^{x=1} \\, dy \\, dz\",\n r\"=\",\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\"\n )\n step1_eq.scale(equation_scale)\n step1_eq.next_to(step1_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(intro_text, step1_text))\n self.play(ReplacementTransform(initial_problem, step1_eq))\n self.wait(2)\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y (treat z as constant)\", **text_style)\n step2_text.to_edge(UP, buff=0.5)\n\n step2_eq = MathTex(\n r\"\\int_0^1 \\left[ \\frac{y^2}{4} z \\right]_{y=0}^{y=1} \\, dz\",\n r\"=\",\n r\"\\int_0^1 \\frac{1}{4}z \\, dz\"\n )\n step2_eq.scale(equation_scale)\n step2_eq.next_to(step2_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(step1_text, step2_text))\n self.play(ReplacementTransform(step1_eq, step2_eq))\n self.wait(2)\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", **text_style)\n step3_text.to_edge(UP, buff=0.5)\n\n step3_eq = MathTex(\n r\"\\left[ \\frac{z^2}{8} \\right]_{z=0}^{z=1}\",\n r\"=\",\n r\"\\frac{1}{8}\"\n )\n step3_eq.scale(equation_scale)\n step3_eq.next_to(step3_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(step2_text, step3_text))\n self.play(ReplacementTransform(step2_eq, step3_eq))\n self.wait(2)\n\n # --- Final Result ---\n final_text = Text(\"Final Result\", **text_style)\n final_text.to_edge(UP, buff=0.5)\n\n final_result = MathTex(r\"\\frac{1}{8}\", font_size=72, color=YELLOW)\n final_result.next_to(final_text, DOWN, buff=1)\n\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n\n self.play(ReplacementTransform(step3_text, final_text))\n self.play(ReplacementTransform(step3_eq, final_result))\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Configuration ---\n text_style = {\n \"font_size\": 30,\n \"color\": YELLOW\n }\n equation_scale = 1.2\n\n # --- Step 0: Introduction ---\n # Display the initial problem statement\n intro_text = Text(\"Problem: Evaluate the triple integral over the unit cube\", **text_style)\n intro_text.to_edge(UP, buff=0.5)\n\n initial_problem = MathText(\n r\"\\int_0^1 \\int_0^1 \\int_0^1 xyz \\, dx \\, dy \\, dz\"\n )\n initial_problem.scale(equation_scale)\n initial_problem.next_to(intro_text, DOWN, buff=1)\n\n self.play(Write(intro_text), Write(initial_problem))\n self.wait(2)\n\n # --- Step 1: Integrate with respect to x ---\n step1_text = Text(\"Step 1: Integrate with respect to x (treat y, z as constants)\", **text_style)\n step1_text.to_edge(UP, buff=0.5)\n\n step1_eq = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{x^2}{2} yz \\right]_{x=0}^{x=1} \\, dy \\, dz\",\n r\"=\",\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}yz \\, dy \\, dz\"\n )\n step1_eq.scale(equation_scale)\n step1_eq.next_to(step1_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(intro_text, step1_text))\n self.play(ReplacementTransform(initial_problem, step1_eq))\n self.wait(2)\n\n # --- Step 2: Integrate with respect to y ---\n step2_text = Text(\"Step 2: Integrate with respect to y (treat z as constant)\", **text_style)\n step2_text.to_edge(UP, buff=0.5)\n\n step2_eq = MathTex(\n r\"\\int_0^1 \\left[ \\frac{y^2}{4} z \\right]_{y=0}^{y=1} \\, dz\",\n r\"=\",\n r\"\\int_0^1 \\frac{1}{4}z \\, dz\"\n )\n step2_eq.scale(equation_scale)\n step2_eq.next_to(step2_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(step1_text, step2_text))\n self.play(ReplacementTransform(step1_eq, step2_eq))\n self.wait(2)\n\n # --- Step 3: Integrate with respect to z ---\n step3_text = Text(\"Step 3: Integrate with respect to z\", **text_style)\n step3_text.to_edge(UP, buff=0.5)\n\n step3_eq = MathTex(\n r\"\\left[ \\frac{z^2}{8} \\right]_{z=0}^{z=1}\",\n r\"=\",\n r\"\\frac{1}{8}\"\n )\n step3_eq.scale(equation_scale)\n step3_eq.next_to(step3_text, DOWN, buff=1)\n\n self.play(ReplacementTransform(step2_text, step3_text))\n self.play(ReplacementTransform(step2_eq, step3_eq))\n self.wait(2)\n\n # --- Final Result ---\n final_text = Text(\"Final Result\", **text_style)\n final_text.to_edge(UP, buff=0.5)\n\n final_result = MathTex(r\"\\frac{1}{8}\", font_size=72, color=YELLOW)\n final_result.next_to(final_text, DOWN, buff=1)\n\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n\n self.play(ReplacementTransform(step3_text, final_text))\n self.play(ReplacementTransform(step3_eq, final_result))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 order of operations in matrix multiplication influence the propagation and magnitude of rounding errors?", "chosen": "```python\nfrom manim import *\n\nclass MatrixRoundingErrorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Subtle Dance of Numbers:\", font_size=32).to_edge(UP)\n subtitle = Text(\"Rounding Error in Matrix Multiplication\", font_size=24).next_to(title, DOWN)\n \n # Introduction\n intro_text = Text(\"In numerical analysis, rounding errors affect calculations.\", font_size=20)\n intro_text.to_edge(DOWN)\n \n # Create simplified matrix representations\n matrix_a = Square(side_length=1, color=BLUE).to_edge(LEFT).shift(UP)\n label_a = Text(\"A\", font_size=24).move_to(matrix_a.get_center())\n \n matrix_b = Square(side_length=1, color=GREEN).next_to(matrix_a, RIGHT, buff=2)\n label_b = Text(\"B\", font_size=24).move_to(matrix_b.get_center())\n \n matrix_c = Square(side_length=1, color=YELLOW).next_to(matrix_b, RIGHT, buff=2)\n label_c = Text(\"C\", font_size=24).move_to(matrix_c.get_center())\n \n # Create pathways\n pathway1_text = Text(\"Pathway 1: (A \\times B) \\times C\", font_size=20).to_edge(UP + LEFT).shift(DOWN * 2.5)\n pathway2_text = Text(\"Pathway 2: A \\times (B \\times C)\", font_size=20).to_edge(UP + RIGHT).shift(DOWN * 2.5)\n \n # Create arrows for pathways\n arrow_ab = Arrow(matrix_a.get_right(), matrix_b.get_left(), color=WHITE)\n arrow_bc = Arrow(matrix_b.get_right(), matrix_c.get_left(), color=WHITE)\n \n # Create result matrices\n result_ab = Square(side_length=1, color=PURPLE).next_to(matrix_b, DOWN, buff=2)\n label_ab = Text(\"A\\times B\", font_size=20).move_to(result_ab.get_center())\n \n result_bc = Square(side_length=1, color=ORANGE).next_to(matrix_c, DOWN, buff=2)\n label_bc = Text(\"B\\times C\", font_size=20).move_to(result_bc.get_center())\n \n # Create arrows to result matrices\n arrow_a_to_ab = Arrow(matrix_a.get_bottom(), result_ab.get_left(), color=WHITE)\n arrow_b_to_ab = Arrow(matrix_b.get_bottom(), result_ab.get_top(), color=WHITE)\n \n arrow_b_to_bc = Arrow(matrix_b.get_bottom(), result_bc.get_left(), color=WHITE)\n arrow_c_to_bc = Arrow(matrix_c.get_bottom(), result_bc.get_top(), color=WHITE)\n \n # Create error representation (small red dots)\n error_dot1 = Dot(color=RED).scale(0.5).move_to(arrow_ab.get_center())\n error_dot2 = Dot(color=RED).scale(0.5).move_to(arrow_bc.get_center())\n \n # Show equations\n assoc_eq = Text(\"(AB)C = A(BC)\", font_size=30)\n assoc_eq.to_edge(DOWN)\n \n # Animation sequence\n \n # Introduction\n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(Write(intro_text))\n self.wait(2)\n \n # Show matrices\n self.play(\n FadeOut(intro_text),\n Create(matrix_a),\n Write(label_a),\n Create(matrix_b),\n Write(label_b),\n Create(matrix_c),\n Write(label_c)\n )\n self.wait(1)\n \n # Show associativity equation\n self.play(Write(assoc_eq))\n self.wait(1)\n \n # Show pathways\n self.play(\n Write(pathway1_text),\n Write(pathway2_text)\n )\n self.wait(1)\n \n # Show arrows\n self.play(\n Create(arrow_ab),\n Create(arrow_bc)\n )\n self.wait(1)\n \n # Show error dots\n self.play(\n FadeIn(error_dot1),\n FadeIn(error_dot2)\n )\n self.wait(1)\n \n # Show result matrices for pathway 1\n self.play(\n Create(result_ab),\n Write(label_ab),\n Create(arrow_a_to_ab),\n Create(arrow_b_to_ab)\n )\n self.wait(1)\n \n # Propagate error for pathway 1\n self.play(\n error_dot1.animate.scale(1.5).move_to(result_ab.get_center())\n )\n self.wait(1)\n \n # Show result matrices for pathway 2\n self.play(\n Create(result_bc),\n Write(label_bc),\n Create(arrow_b_to_bc),\n Create(arrow_c_to_bc)\n )\n self.wait(1)\n \n # Propagate error for pathway 2\n self.play(\n error_dot2.animate.scale(1.5).move_to(result_bc.get_center())\n )\n self.wait(1)\n \n # Final message\n final_text1 = Text(\"In theory: (AB)C = A(BC)\", font_size=20)\n final_text1.to_edge(DOWN).shift(UP * 0.5)\n final_text2 = Text(\"In practice: Different orders yield different rounding errors\", font_size=20)\n final_text2.next_to(final_text1, DOWN, buff=0.2)\n \n self.play(\n FadeOut(assoc_eq),\n Write(final_text1),\n Write(final_text2)\n )\n self.wait(2)\n \n # Cleanup\n self.play(\n *[FadeOut(mob) for mob in self.mobjects]\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass MatrixRoundingErrorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Subtle Dance of Numbers:\", font_size=32).to_edge(UP)\n subtitle = Text(\"Rounding Error in Matrix Multiplication\", font_size=24).next_to(title, DOWN)\n \n # Introduction\n intro_text = Text(\"In numerical analysis, rounding errors affect calculations.\", font_size=20)\n intro_text.to_edge(DOWN)\n \n # Create simplified matrix representations\n matrix_a = Square(side_length=1, color=BBLUE).to_edge(LEFT).shift(UP)\n label_a = Text(\"A\", font_size=24).move_to(matrix_a.get_center())\n \n matrix_b = Square(side_length=1, color=GREEN).next_to(matrix_a, RIGHT, buff=2)\n label_b = Text(\"B\", font_size=24).move_to(matrix_b.get_center())\n \n matrix_c = Square(side_length=1, color=YELLOW).next_to(matrix_b, RIGHT, buff=2)\n label_c = Text(\"C\", font_size=24).move_to(matrix_c.get_center())\n \n # Create pathways\n pathway1_text = Text(\"Pathway 1: (A \\times B) \\times C\", font_size=20).to_edge(UP + LEFT).shift(DOWN * 2.5)\n pathway2_text = Text(\"Pathway 2: A \\times (B \\times C)\", font_size=20).to_edge(UP + RIGHT).shift(DOWN * 2.5)\n \n # Create arrows for pathways\n arrow_ab = Arrow(matrix_a.get_right(), matrix_b.get_left(), color=WHITE)\n arrow_bc = Arrow(matrix_b.get_right(), matrix_c.get_left(), color=WHITE)\n \n # Create result matrices\n result_ab = Square(side_length=1, color=PURPLE).next_to(matrix_b, DOWN, buff=2)\n label_ab = Text(\"A\\times B\", font_size=20).move_to(result_ab.get_center())\n \n result_bc = Square(side_length=1, color=ORANGE).next_to(matrix_c, DOWN, buff=2)\n label_bc = Text(\"B\\times C\", font_size=20).move_to(result_bc.get_center())\n \n # Create arrows to result matrices\n arrow_a_to_ab = Arrow(matrix_a.get_bottom(), result_ab.get_left(), color=WHITE)\n arrow_b_to_ab = Arrow(matrix_b.get_bottom(), result_ab.get_top(), color=WHITE)\n \n arrow_b_to_bc = Arrow(matrix_b.get_bottom(), result_bc.get_left(), color=WHITE)\n arrow_c_to_bc = Arrow(matrix_c.get_bottom(), result_bc.get_top(), color=WHITE)\n \n # Create error representation (small red dots)\n error_dot1 = Dot(color=RED).scale(0.5).move_to(arrow_ab.get_center())\n error_dot2 = Dot(color=RED).scale(0.5).move_to(arrow_bc.get_center())\n \n # Show equations\n assoc_eq = Text(\"(AB)C = A(BC)\", font_size=30)\n assoc_eq.to_edge(DOWN)\n \n # Animation sequence\n \n # Introduction\n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(Write(intro_text))\n self.wait(2)\n \n # Show matrices\n self.play(\n FadeOut(intro_text),\n Create(matrix_a),\n Write(label_a),\n Create(matrix_b),\n Write(label_b),\n Create(matrix_c),\n Write(label_c)\n )\n self.wait(1)\n \n # Show associativity equation\n self.play(Write(assoc_eq))\n self.wait(1)\n \n # Show pathways\n self.play(\n Write(pathway1_text),\n Write(pathway2_text)\n )\n self.wait(1)\n \n # Show arrows\n self.play(\n Create(arrow_ab),\n Create(arrow_bc)\n )\n self.wait(1)\n \n # Show error dots\n self.play(\n FadeIn(error_dot1),\n FadeIn(error_dot2)\n )\n self.wait(1)\n \n # Show result matrices for pathway 1\n self.play(\n Create(result_ab),\n Write(label_ab),\n Create(arrow_a_to_ab),\n Create(arrow_b_to_ab)\n )\n self.wait(1)\n \n # Propagate error for pathway 1\n self.play(\n error_dot1.animate.scale(1.5).move_to(result_ab.get_center())\n )\n self.wait(1)\n \n # Show result matrices for pathway 2\n self.play(\n Create(result_bc),\n Write(label_bc),\n Create(arrow_b_to_bc),\n Create(arrow_c_to_bc)\n )\n self.wait(1)\n \n # Propagate error for pathway 2\n self.play(\n error_dot2.animate.scale(1.5).move_to(result_bc.get_center())\n )\n self.wait(1)\n \n # Final message\n final_text1 = Text(\"In theory: (AB)C = A(BC)\", font_size=20)\n final_text1.to_edge(DOWN).shift(UP * 0.5)\n final_text2 = Text(\"In practice: Different orders yield different rounding errors\", font_size=20)\n final_text2.next_to(final_text1, DOWN, buff=0.2)\n \n self.play(\n FadeOut(assoc_eq),\n Write(final_text1),\n Write(final_text2)\n )\n self.wait(2)\n \n # Cleanup\n self.play(\n *[FadeOut(mob) for mob in self.mobjects]\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does Chern-Weil theory enable the visualization of vector bundle topology through curvature forms?", "chosen": "```python\nfrom manim import *\n\nclass ChernWeilTheory(Scene):\n def construct(self):\n # Title sequence\n title = Text(\"Unveiling Topology through Curvature\", color=BLUE)\n subtitle = Text(\"A Dive into Chern-Weil Theory\", color=BLUE).scale(0.7)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\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))\n \n # Element 1: Universe with various surfaces\n universe = Circle(radius=3, color=BLUE).set_fill(BLUE, opacity=0.1)\n surface1 = Circle(radius=0.5, color=GREEN).shift(UP + LEFT * 2)\n surface2 = Ellipse(width=1.2, height=0.8, color=GREEN).shift(DOWN * 1.5 + RIGHT)\n surface3 = Square(side_length=0.8, color=GREEN).shift(UP * 1.5 + RIGHT * 2)\n \n # Display universe and surfaces\n self.play(Create(universe), run_time=2)\n self.play(Create(surface1), Create(surface2), Create(surface3), run_time=2)\n self.wait(1)\n \n # Element 2: Sphere with tangent planes\n self.play(FadeOut(universe), FadeOut(surface1), FadeOut(surface2), FadeOut(surface3))\n \n sphere = Circle(radius=1.5, color=GREEN).set_fill(GREEN, opacity=0.2)\n sphere_text = Text(\"Spherical Surface\", color=GREEN).scale(0.6)\n sphere_text.next_to(sphere, UP)\n \n # Display sphere and tangent planes\n self.play(Create(sphere), Write(sphere_text), run_time=2)\n \n # Add tangent planes (simplified as lines)\n tangent1 = Line(LEFT * 2, ORIGIN, color=YELLOW).shift(UP * 1.5)\n tangent2 = Line(ORIGIN, RIGHT * 2, color=YELLOW).shift(DOWN * 1.5)\n \n self.play(Create(tangent1), Create(tangent2), run_time=2)\n self.wait(1)\n \n # Element 3: Curvature visualization\n self.play(FadeOut(sphere_text))\n curvature_text = Text(\"Curvature Forms\", color=YELLOW).scale(0.8)\n curvature_text.to_edge(UP)\n \n # Simplified curvature equation\n curvature_eq = Text(\"K = ∇^2\", color=WHITE)\n curvature_eq.next_to(curvature_text, DOWN)\n \n # Display curvature text and equation\n self.play(Write(curvature_text), Write(curvature_eq), run_time=2)\n \n # Animate curvature transformation\n curve1 = Circle(radius=0.3, color=YELLOW).move_to(tangent1.get_center())\n curve2 = Circle(radius=0.3, color=YELLOW).move_to(tangent2.get_center())\n \n self.play(Transform(tangent1, curve1), Transform(tangent2, curve2), run_time=2)\n self.wait(1)\n \n # Element 4: Transformation to cohomological classes\n self.play(FadeOut(curvature_text), FadeOut(curvature_eq))\n \n coho_text = Text(\"Cohomological Classes\", color=BLUE).scale(0.8)\n coho_text.to_edge(UP)\n \n # Chern class equation\n chern_eq = Text(\"c_i = Tr(F^i)\", color=WHITE)\n chern_eq.next_to(coho_text, DOWN)\n \n # Display cohomological text and equation\n self.play(Write(coho_text), Write(chern_eq), run_time=2)\n \n # Transform curvature forms to cohomological classes\n coho1 = RegularPolygon(n=5, color=BLUE).scale(0.3).move_to(curve1.get_center())\n coho2 = RegularPolygon(n=5, color=BLUE).scale(0.3).move_to(curve2.get_center())\n \n self.play(Transform(tangent1, coho1), Transform(tangent2, coho2), run_time=2)\n self.wait(1)\n \n # Element 5: Topological invariants\n self.play(FadeOut(coho_text), FadeOut(chern_eq))\n \n topo_text = Text(\"Topological Invariants\", color=GREEN).scale(0.8)\n topo_text.to_edge(UP)\n \n # Display topological invariants text\n self.play(Write(topo_text), run_time=1)\n \n # Create simplified swirling patterns\n swirl = Circle(radius=1, color=GREEN).shift(DOWN)\n arrow = Arrow(LEFT, RIGHT, color=GREEN).next_to(swirl, UP)\n \n self.play(Create(swirl), Create(arrow), run_time=2)\n self.wait(1)\n \n # Element 6: Connection between curvature and topology\n self.play(FadeOut(topo_text), FadeOut(swirl), FadeOut(arrow), FadeOut(tangent1), \n FadeOut(tangent2), FadeOut(sphere))\n \n conclusion_text = Text(\"Chern-Weil Theory:\", color=YELLOW).scale(0.8)\n conclusion_subtext = Text(\"Connecting Curvature to Topology\", color=YELLOW).scale(0.6)\n conclusion_subtext.next_to(conclusion_text, DOWN)\n \n # Display conclusion text\n self.play(Write(conclusion_text), run_time=1)\n self.play(Write(conclusion_subtext), run_time=1)\n \n # Create a symbolic connection\n connection = Line(LEFT * 2, RIGHT * 2, color=GOLD)\n curv_symbol = Circle(radius=0.5, color=GREEN).move_to(LEFT * 2)\n topo_symbol = RegularPolygon(n=5, color=BLUE).scale(0.5).move_to(RIGHT * 2)\n \n # Display connection between curvature and topology\n self.play(Create(connection), Create(curv_symbol), Create(topo_symbol), run_time=2)\n \n # Add labels\n curv_label = Text(\"Curvature\", color=GREEN).scale(0.5)\n curv_label.next_to(curv_symbol, DOWN)\n topo_label = Text(\"Topology\", color=BLUE).scale(0.5)\n topo_label.next_to(topo_symbol, DOWN)\n \n self.play(Write(curv_label), Write(topo_label), run_time=1)\n self.wait(2)\n \n # Group all conclusion elements for easy fade out\n conclusion_group = VGroup(\n conclusion_text, conclusion_subtext, connection, \n curv_symbol, topo_symbol, curv_label, topo_label\n )\n \n # Final fade out\n self.play(FadeOut(conclusion_group), run_time=2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ChernWeilTheory(Scene):\n def construct(self):\n # Title sequence\n title = Text(\"Unveiling Topology through Curvature\", color=BBLUE)\n subtitle = Text(\"A Dive into Chern-Weil Theory\", color=BLUE).scale(0.7)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\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))\n \n # Element 1: Universe with various surfaces\n universe = Circle(radius=3, color=BLUE).set_fill(BLUE, opacity=0.1)\n surface1 = Circle(radius=0.5, color=GREEN).shift(UP + LEFT * 2)\n surface2 = Ellipse(width=1.2, height=0.8, color=GREEN).shift(DOWN * 1.5 + RIGHT)\n surface3 = Square(side_length=0.8, color=GREEN).shift(UP * 1.5 + RIGHT * 2)\n \n # Display universe and surfaces\n self.play(Create(universe), run_time=2)\n self.play(Create(surface1), Create(surface2), Create(surface3), run_time=2)\n self.wait(1)\n \n # Element 2: Sphere with tangent planes\n self.play(FadeOut(universe), FadeOut(surface1), FadeOut(surface2), FadeOut(surface3))\n \n sphere = Circle(radius=1.5, color=GREEN).set_fill(GREEN, opacity=0.2)\n sphere_text = Text(\"Spherical Surface\", color=GREEN).scale(0.6)\n sphere_text.next_to(sphere, UP)\n \n # Display sphere and tangent planes\n self.play(Create(sphere), Write(sphere_text), run_time=2)\n \n # Add tangent planes (simplified as lines)\n tangent1 = Line(LEFT * 2, ORIGIN, color=YELLOW).shift(UP * 1.5)\n tangent2 = Line(ORIGIN, RIGHT * 2, color=YELLOW).shift(DOWN * 1.5)\n \n self.play(Create(tangent1), Create(tangent2), run_time=2)\n self.wait(1)\n \n # Element 3: Curvature visualization\n self.play(FadeOut(sphere_text))\n curvature_text = Text(\"Curvature Forms\", color=YELLOW).scale(0.8)\n curvature_text.to_edge(UP)\n \n # Simplified curvature equation\n curvature_eq = Text(\"K = ∇^2\", color=WHITE)\n curvature_eq.next_to(curvature_text, DOWN)\n \n # Display curvature text and equation\n self.play(Write(curvature_text), Write(curvature_eq), run_time=2)\n \n # Animate curvature transformation\n curve1 = Circle(radius=0.3, color=YELLOW).move_to(tangent1.get_center())\n curve2 = Circle(radius=0.3, color=YELLOW).move_to(tangent2.get_center())\n \n self.play(Transform(tangent1, curve1), Transform(tangent2, curve2), run_time=2)\n self.wait(1)\n \n # Element 4: Transformation to cohomological classes\n self.play(FadeOut(curvature_text), FadeOut(curvature_eq))\n \n coho_text = Text(\"Cohomological Classes\", color=BLUE).scale(0.8)\n coho_text.to_edge(UP)\n \n # Chern class equation\n chern_eq = Text(\"c_i = Tr(F^i)\", color=WHITE)\n chern_eq.next_to(coho_text, DOWN)\n \n # Display cohomological text and equation\n self.play(Write(coho_text), Write(chern_eq), run_time=2)\n \n # Transform curvature forms to cohomological classes\n coho1 = RegularPolygon(n=5, color=BLUE).scale(0.3).move_to(curve1.get_center())\n coho2 = RegularPolygon(n=5, color=BLUE).scale(0.3).move_to(curve2.get_center())\n \n self.play(Transform(tangent1, coho1), Transform(tangent2, coho2), run_time=2)\n self.wait(1)\n \n # Element 5: Topological invariants\n self.play(FadeOut(coho_text), FadeOut(chern_eq))\n \n topo_text = Text(\"Topological Invariants\", color=GREEN).scale(0.8)\n topo_text.to_edge(UP)\n \n # Display topological invariants text\n self.play(Write(topo_text), run_time=1)\n \n # Create simplified swirling patterns\n swirl = Circle(radius=1, color=GREEN).shift(DOWN)\n arrow = Arrow(LEFT, RIGHT, color=GREEN).next_to(swirl, UP)\n \n self.play(Create(swirl), Create(arrow), run_time=2)\n self.wait(1)\n \n # Element 6: Connection between curvature and topology\n self.play(FadeOut(topo_text), FadeOut(swirl), FadeOut(arrow), FadeOut(tangent1), \n FadeOut(tangent2), FadeOut(sphere))\n \n conclusion_text = Text(\"Chern-Weil Theory:\", color=YELLOW).scale(0.8)\n conclusion_subtext = Text(\"Connecting Curvature to Topology\", color=YELLOW).scale(0.6)\n conclusion_subtext.next_to(conclusion_text, DOWN)\n \n # Display conclusion text\n self.play(Write(conclusion_text), run_time=1)\n self.play(Write(conclusion_subtext), run_time=1)\n \n # Create a symbolic connection\n connection = Line(LEFT * 2, RIGHT * 2, color=GOLD)\n curv_symbol = Circle(radius=0.5, color=GREEN).move_to(LEFT * 2)\n topo_symbol = RegularPolygon(n=5, color=BLUE).scale(0.5).move_to(RIGHT * 2)\n \n # Display connection between curvature and topology\n self.play(Create(connection), Create(curv_symbol), Create(topo_symbol), run_time=2)\n \n # Add labels\n curv_label = Text(\"Curvature\", color=GREEN).scale(0.5)\n curv_label.next_to(curv_symbol, DOWN)\n topo_label = Text(\"Topology\", color=BLUE).scale(0.5)\n topo_label.next_to(topo_symbol, DOWN)\n \n self.play(Write(curv_label), Write(topo_label), run_time=1)\n self.wait(2)\n \n # Group all conclusion elements for easy fade out\n conclusion_group = VGroup(\n conclusion_text, conclusion_subtext, connection, \n curv_symbol, topo_symbol, curv_label, topo_label\n )\n \n # Final fade out\n self.play(FadeOut(conclusion_group), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 CosineEducationalAnimation(Scene):\n def construct(self):\n # --- 1. Initial Setup: Cosine Graph ---\n # Create axes with blue color as specified, ranges -4 to 4 and -2 to 2\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 ).add_coordinates()\n\n # Add axis labels for clarity\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n axes_group = VGroup(axes, x_label, y_label)\n\n # Plot cos(x) in white\n cos_graph = axes.plot(lambda x: np.cos(x), color=WHITE)\n cos_label = MathTex(r\"\\cos(x)\", color=WHITE).next_to(cos_graph, UR, buff=0.5)\n\n # Animation: Introduce Axes and Cosine Graph\n self.play(Create(axes_group), run_time=1.5)\n self.play(Create(cos_graph), Write(cos_label), run_time=2)\n self.wait(2) # Pause for viewer comprehension\n\n # --- 2. Derivative Visualization ---\n # The derivative of cos(x) is -sin(x)\n deriv_graph = axes.plot(lambda x: -np.sin(x), color=GREEN)\n deriv_label = MathTex(\n r\"\\frac{d}{dx}\\cos(x) = -\\sin(x)\", color=GREEN\n ).next_to(deriv_graph, UR, buff=0.5).shift(DOWN * 0.5)\n\n # Animation: Introduce Derivative alongside the base function\n self.play(Create(deriv_graph), Write(deriv_label), run_time=2)\n self.wait(2) # Pause for viewer comprehension\n\n # --- 3. Antiderivative Visualization ---\n # The antiderivative of cos(x) is sin(x)\n anti_graph = axes.plot(lambda x: np.sin(x), color=PINK)\n anti_label = MathTex(\n r\"\\int \\cos(x) dx = \\sin(x)\", color=PINK\n ).next_to(anti_graph, UR, buff=0.5).shift(DOWN * 1.0)\n\n # Animation: Transform display by removing derivative, showing antiderivative\n self.play(\n FadeOut(deriv_graph), FadeOut(deriv_label),\n Create(anti_graph), Write(anti_label),\n run_time=2\n )\n self.wait(2) # Pause for viewer comprehension\n\n # --- 4. Conclusion ---\n # Clear all mathematical elements smoothly\n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(cos_graph), FadeOut(cos_label),\n FadeOut(anti_graph), FadeOut(anti_label),\n run_time=1.5\n )\n\n # Display Final Message\n final_text = Text(\n \"This is the graph of cosine and its derivatives\",\n font_size=48,\n color=WHITE\n )\n\n self.play(Write(final_text), run_time=2)\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass CosineEducationalAnimation(Scene):\n def construct(self):\n # --- 1. Initial Setup: Cosine Graph ---\n # Create axes with blue color as specified, ranges -4 to 4 and -2 to 2\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-2, 2, 1],\n axis_config={\"color\": BBLUE},\n x_axis_config={\"numbers_to_include\": [-4, -2, 0, 2, 4]},\n y_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n ).add_coordinates()\n\n # Add axis labels for clarity\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n axes_group = VGroup(axes, x_label, y_label)\n\n # Plot cos(x) in white\n cos_graph = axes.plot(lambda x: np.cos(x), color=WHITE)\n cos_label = MathTex(r\"\\cos(x)\", color=WHITE).next_to(cos_graph, UR, buff=0.5)\n\n # Animation: Introduce Axes and Cosine Graph\n self.play(Create(axes_group), run_time=1.5)\n self.play(Create(cos_graph), Write(cos_label), run_time=2)\n self.wait(2) # Pause for viewer comprehension\n\n # --- 2. Derivative Visualization ---\n # The derivative of cos(x) is -sin(x)\n deriv_graph = axes.plot(lambda x: -np.sin(x), color=GREEN)\n deriv_label = MathTex(\n r\"\\frac{d}{dx}\\cos(x) = -\\sin(x)\", color=GREEN\n ).next_to(deriv_graph, UR, buff=0.5).shift(DOWN * 0.5)\n\n # Animation: Introduce Derivative alongside the base function\n self.play(Create(deriv_graph), Write(deriv_label), run_time=2)\n self.wait(2) # Pause for viewer comprehension\n\n # --- 3. Antiderivative Visualization ---\n # The antiderivative of cos(x) is sin(x)\n anti_graph = axes.plot(lambda x: np.sin(x), color=PINK)\n anti_label = MathTex(\n r\"\\int \\cos(x) dx = \\sin(x)\", color=PINK\n ).next_to(anti_graph, UR, buff=0.5).shift(DOWN * 1.0)\n\n # Animation: Transform display by removing derivative, showing antiderivative\n self.play(\n FadeOut(deriv_graph), FadeOut(deriv_label),\n Create(anti_graph), Write(anti_label),\n run_time=2\n )\n self.wait(2) # Pause for viewer comprehension\n\n # --- 4. Conclusion ---\n # Clear all mathematical elements smoothly\n self.play(\n FadeOut(axes), FadeOut(x_label), FadeOut(y_label),\n FadeOut(cos_graph), FadeOut(cos_label),\n FadeOut(anti_graph), FadeOut(anti_label),\n run_time=1.5\n )\n\n # Display Final Message\n final_text = Text(\n \"This is the graph of cosine and its derivatives\",\n font_size=48,\n color=WHITE\n )\n\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 IntegrateExponential(Scene):\n def construct(self):\n # --- Scene 1: Initial Display ---\n problem = MathTex(r\"\\int e^{2x} \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem), run_time=1)\n self.wait(2)\n\n # --- Scene 2: Step-by-Step Explanation ---\n # Highlight the exponent\n box = SurroundingRectangle(problem[0][4], color=YELLOW) # Approximate indexing for 2x\n self.play(Create(box))\n self.wait(2)\n\n # Correction Note\n note = Text(\"Note: Not the Power Rule. Use u-substitution.\", font_size=24, color=YELLOW).next_to(problem, DOWN)\n self.play(Write(note))\n self.wait(2)\n\n # Substitution Logic\n sub_text = MathTex(r\"u = 2x\", r\"\\quad du = 2 \\, dx\").next_to(note, DOWN)\n self.play(Write(sub_text))\n self.wait(2)\n\n # --- Scene 3: Integration Process ---\n # Transform to u-sub form\n step1 = MathTex(r\"\\int e^u \\cdot \\frac{1}{2} \\, du\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(problem.copy(), step1))\n self.wait(2)\n\n # --- Scene 4: Result Reveal ---\n # Integrate\n step2 = MathTex(r\"\\frac{1}{2}e^u + C\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(step1, step2))\n self.wait(2)\n\n # --- Scene 5: Transformation (Back-Substitution & Morph) ---\n # Morph u back to 2x\n final_result = MathTex(r\"\\frac{1}{2}e^{2x} + C\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(step2, final_result))\n self.wait(2)\n\n # Clean up intermediate steps for the morph effect\n self.play(FadeOut(sub_text), FadeOut(note), FadeOut(box), FadeOut(step1))\n final_result.move_to(ORIGIN)\n self.play(final_result.animate.scale(1.5))\n \n # Show connection to initial problem via fluid morph\n problem_small = MathTex(r\"\\int e^{2x} \\, dx\").scale(0.8)\n problem_small.next_to(final_result, UP, buff=1)\n self.play(ReplacementTransform(problem_small, final_result.copy()))\n self.wait(2)\n\n # --- Scene 6: Conclusion ---\n # Clear frame\n self.clear()\n self.wait(0.5)\n\n # Final Text\n title = Text(\"The integral of an exponential\", font_size=36)\n title.to_edge(UP)\n result_final = MathTex(r\"\\frac{1}{2}e^{2x} + C\").scale(1.5)\n result_final.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.wait(2)\n self.play(Write(result_final))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrateExponential(Scene):\n def construct(self):\n # --- Scene 1: Initial Display ---\n problem = MathText(r\"\\int e^{2x} \\, dx\")\n problem.scale(1.5)\n self.play(Write(problem), run_time=1)\n self.wait(2)\n\n # --- Scene 2: Step-by-Step Explanation ---\n # Highlight the exponent\n box = SurroundingRectangle(problem[0][4], color=YELLOW) # Approximate indexing for 2x\n self.play(Create(box))\n self.wait(2)\n\n # Correction Note\n note = Text(\"Note: Not the Power Rule. Use u-substitution.\", font_size=24, color=YELLOW).next_to(problem, DOWN)\n self.play(Write(note))\n self.wait(2)\n\n # Substitution Logic\n sub_text = MathTex(r\"u = 2x\", r\"\\quad du = 2 \\, dx\").next_to(note, DOWN)\n self.play(Write(sub_text))\n self.wait(2)\n\n # --- Scene 3: Integration Process ---\n # Transform to u-sub form\n step1 = MathTex(r\"\\int e^u \\cdot \\frac{1}{2} \\, du\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(problem.copy(), step1))\n self.wait(2)\n\n # --- Scene 4: Result Reveal ---\n # Integrate\n step2 = MathTex(r\"\\frac{1}{2}e^u + C\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(step1, step2))\n self.wait(2)\n\n # --- Scene 5: Transformation (Back-Substitution & Morph) ---\n # Morph u back to 2x\n final_result = MathTex(r\"\\frac{1}{2}e^{2x} + C\").next_to(sub_text, DOWN)\n self.play(TransformMatchingTex(step2, final_result))\n self.wait(2)\n\n # Clean up intermediate steps for the morph effect\n self.play(FadeOut(sub_text), FadeOut(note), FadeOut(box), FadeOut(step1))\n final_result.move_to(ORIGIN)\n self.play(final_result.animate.scale(1.5))\n \n # Show connection to initial problem via fluid morph\n problem_small = MathTex(r\"\\int e^{2x} \\, dx\").scale(0.8)\n problem_small.next_to(final_result, UP, buff=1)\n self.play(ReplacementTransform(problem_small, final_result.copy()))\n self.wait(2)\n\n # --- Scene 6: Conclusion ---\n # Clear frame\n self.clear()\n self.wait(0.5)\n\n # Final Text\n title = Text(\"The integral of an exponential\", font_size=36)\n title.to_edge(UP)\n result_final = MathTex(r\"\\frac{1}{2}e^{2x} + C\").scale(1.5)\n result_final.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.wait(2)\n self.play(Write(result_final))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 constructing a multi-layered visual cortex network with labeled layers (Layer 1 to Layer 4) and randomized receptive fields connecting neurons across layers. As the network appears, a title (\"Visual Cortex Receptive Fields\") fades in at the top of the screen. The animation then highlights the receptive fields in sequence, pulsing yellow to show connectivity, but now accompanied by a dynamic mathematical formula (e.g., *wᵢⱼ = exp(−dᵢⱼ²/σ²)*) that appears below the network to explain the Gaussian-weighted connectivity pattern. After the pulsing sequence, the entire network shifts downward, and labels for \"Input Layer\" and \"Output Layer\" appear. Next, a new feature is introduced: the neurons in the output layer transform into a bar chart representing their activation levels, with each neuron's height scaling proportionally to a simulated output signal (e.g., random values between 0 and 1). Simultaneously, an explanatory text box fades in, describing how receptive fields aggregate input to produce output activations. Finally, the animation concludes with a slow fade-out of all elements, leaving only the title and formula visible. This enhanced version retains all original features while adding mathematical context, dynamic transformations, and explanatory text to deepen understanding.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass VisualCortexAnimation(Scene):\n def construct(self):\n # Title and formula\n title = Text(\"Visual Cortex Receptive Fields\", font_size=36).to_edge(UP)\n formula = MathTex(r\"w_{ij} = \\exp\\left(-\\frac{d_{ij}^2}{\\sigma^2}\\right)\").next_to(title, DOWN)\n \n # Network layers\n layers = VGroup()\n layer_labels = VGroup()\n for i in range(4):\n layer = VGroup(*[Circle(radius=0.2, fill_opacity=0.8, fill_color=BLUE) for _ in range(6)])\n layer.arrange(DOWN, buff=0.4)\n layer.shift(RIGHT * i * 2)\n layers.add(layer)\n \n label = Text(f\"Layer {i+1}\", font_size=24).next_to(layer, UP)\n layer_labels.add(label)\n \n network = VGroup(layers, layer_labels).center()\n \n # Receptive field connections\n connections = VGroup()\n for i in range(3):\n for j, neuron in enumerate(layers[i]):\n for k in range(3):\n target = layers[i+1][(j + k - 1) % len(layers[i+1])]\n line = Line(\n neuron.get_right(),\n target.get_left(),\n stroke_width=2,\n color=YELLOW\n )\n connections.add(line)\n \n # Input/output labels\n input_label = Text(\"Input Layer\", font_size=24).next_to(layers[0], LEFT)\n output_label = Text(\"Output Layer\", font_size=24).next_to(layers[-1], RIGHT)\n \n # Bar chart for output activations\n bars = VGroup()\n activations = np.random.uniform(0, 1, size=6)\n for i, neuron in enumerate(layers[-1]):\n bar = Rectangle(\n width=0.4,\n height=activations[i],\n fill_opacity=0.8,\n fill_color=GREEN,\n stroke_width=2\n ).move_to(neuron.get_center()).align_to(neuron, DOWN)\n bars.add(bar)\n \n # Explanation text\n explanation = Text(\n \"Receptive fields aggregate input signals\\n\"\n \"through Gaussian-weighted connections\\nto produce output activations\",\n font_size=24,\n t2c={\"Gaussian-weighted\": YELLOW}\n ).to_edge(DOWN)\n \n # Animation sequence\n self.play(FadeIn(title), Write(formula))\n self.wait(0.5)\n \n self.play(\n LaggedStart(*[FadeIn(layer) for layer in layers], lag_ratio=0.2),\n LaggedStart(*[FadeIn(label) for label in layer_labels], lag_ratio=0.2),\n run_time=2\n )\n self.wait()\n \n self.play(Create(connections), run_time=2)\n self.wait()\n \n # Highlight connections\n for i in range(0, len(connections), 3):\n self.play(\n *[connections[j].animate.set_stroke(width=6, opacity=1) for j in range(i, min(i+3, len(connections)))],\n run_time=0.5\n )\n self.play(\n *[connections[j].animate.set_stroke(width=2, opacity=0.7) for j in range(i, min(i+3, len(connections)))],\n run_time=0.5\n )\n \n self.wait()\n \n # Shift network down and add labels\n self.play(\n network.animate.shift(DOWN),\n FadeIn(input_label),\n FadeIn(output_label)\n )\n self.wait()\n \n # Transform to bar chart\n self.play(\n Transform(layers[-1], bars),\n FadeIn(explanation),\n run_time=2\n )\n self.wait(2)\n \n # Fade out\n self.play(\n *[FadeOut(mob) for mob in self.mobjects if mob not in [title, formula]],\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass VisualCortexAnimation(Scene):\n def construct(self):\n # Title and formula\n title = Text(\"Visual Cortex Receptive Fields\", font_size=36).to_edge(UP)\n formula = MathTex(r\"w_{ij} = \\exp\\left(-\\frac{d_{ij}^2}{\\sigma^2}\\right)\").next_to(title, DOWN)\n \n # Network layers\n layers = VGroup()\n layer_labels = VGroup()\n for i in range(4):\n layer = VGroup(*[Circle(radius=0.2, fill_opacity=0.8, fill_color=BBLUE) for _ in range(6)])\n layer.arrange(DOWN, buff=0.4)\n layer.shift(RIGHT * i * 2)\n layers.add(layer)\n \n label = Text(f\"Layer {i+1}\", font_size=24).next_to(layer, UP)\n layer_labels.add(label)\n \n network = VGroup(layers, layer_labels).center()\n \n # Receptive field connections\n connections = VGroup()\n for i in range(3):\n for j, neuron in enumerate(layers[i]):\n for k in range(3):\n target = layers[i+1][(j + k - 1) % len(layers[i+1])]\n line = Line(\n neuron.get_right(),\n target.get_left(),\n stroke_width=2,\n color=YELLOW\n )\n connections.add(line)\n \n # Input/output labels\n input_label = Text(\"Input Layer\", font_size=24).next_to(layers[0], LEFT)\n output_label = Text(\"Output Layer\", font_size=24).next_to(layers[-1], RIGHT)\n \n # Bar chart for output activations\n bars = VGroup()\n activations = np.random.uniform(0, 1, size=6)\n for i, neuron in enumerate(layers[-1]):\n bar = Rectangle(\n width=0.4,\n height=activations[i],\n fill_opacity=0.8,\n fill_color=GREEN,\n stroke_width=2\n ).move_to(neuron.get_center()).align_to(neuron, DOWN)\n bars.add(bar)\n \n # Explanation text\n explanation = Text(\n \"Receptive fields aggregate input signals\\n\"\n \"through Gaussian-weighted connections\\nto produce output activations\",\n font_size=24,\n t2c={\"Gaussian-weighted\": YELLOW}\n ).to_edge(DOWN)\n \n # Animation sequence\n self.play(FadeIn(title), Write(formula))\n self.wait(0.5)\n \n self.play(\n LaggedStart(*[FadeIn(layer) for layer in layers], lag_ratio=0.2),\n LaggedStart(*[FadeIn(label) for label in layer_labels], lag_ratio=0.2),\n run_time=2\n )\n self.wait()\n \n self.play(Create(connections), run_time=2)\n self.wait()\n \n # Highlight connections\n for i in range(0, len(connections), 3):\n self.play(\n *[connections[j].animate.set_stroke(width=6, opacity=1) for j in range(i, min(i+3, len(connections)))],\n run_time=0.5\n )\n self.play(\n *[connections[j].animate.set_stroke(width=2, opacity=0.7) for j in range(i, min(i+3, len(connections)))],\n run_time=0.5\n )\n \n self.wait()\n \n # Shift network down and add labels\n self.play(\n network.animate.shift(DOWN),\n FadeIn(input_label),\n FadeIn(output_label)\n )\n self.wait()\n \n # Transform to bar chart\n self.play(\n Transform(layers[-1], bars),\n FadeIn(explanation),\n run_time=2\n )\n self.wait(2)\n \n # Fade out\n self.play(\n *[FadeOut(mob) for mob in self.mobjects if mob not in [title, formula]],\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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\": BBLUE},\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 step response with overshoot and settling. Show the input step, the output curve, and captions describing rise, overshoot, and settling behavior.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ControlStepResponseStory(Scene):\n def construct(self):\n title = Text(\"Step Response Reveals Overshoot and Settling\", font_size=34).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[0, 1.6, 0.2], x_length=6.8, y_length=4.4, tips=False).shift(DOWN * 0.2)\n step = VMobject(color=GRAY_B, stroke_width=4).set_points_as_corners([axes.c2p(0.3, 0), axes.c2p(1.0, 0), axes.c2p(1.0, 1.0), axes.c2p(7.4, 1.0)])\n response = axes.plot(lambda x: 1 - np.exp(-1.1 * (x - 1.0)) * np.cos(2.8 * max(x - 1.0, 0)), x_range=[1.0, 7.4], color=BLUE_D)\n target = DashedLine(axes.c2p(1.0, 1.0), axes.c2p(7.4, 1.0), color=YELLOW_D, stroke_width=3)\n caption_a = Text(\"The step input asks the system to move to a new target value.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_b = Text(\"The output rises quickly, overshoots, and then oscillates down.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_c = Text(\"Settling means the response finally stays near the target.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(axes), Create(step), FadeIn(caption_a), run_time=4)\n self.play(Create(target), Create(response), ReplacementTransform(caption_a, caption_b), run_time=5)\n self.play(Indicate(target), ReplacementTransform(caption_b, caption_c), run_time=4)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ControlStepResponseStory(Scene):\n def construct(self):\n title = Text(\"Step Response Reveals Overshoot and Settling\", font_size=34).to_edge(UP)\n axes = Axes(x_range=[0, 8, 1], y_range=[0, 1.6, 0.2], x_length=6.8, y_length=4.4, tips=False).shift(DOWN * 0.2)\n step = VMobject(color=GRAY_B, stroke_width=4).set_points_as_corners([axes.c2p(0.3, 0), axes.c2p(1.0, 0), axes.c2p(1.0, 1.0), axes.c2p(7.4, 1.0)])\n response = axes.plot(lambda x: 1 - np.exp(-1.1 * (x - 1.0)) * np.cos(2.8 * max(x - 1.0, 0)), x_range=[1.0, 7.4], color=BBLUE_D)\n target = DashedLine(axes.c2p(1.0, 1.0), axes.c2p(7.4, 1.0), color=YELLOW_D, stroke_width=3)\n caption_a = Text(\"The step input asks the system to move to a new target value.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_b = Text(\"The output rises quickly, overshoots, and then oscillates down.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n caption_c = Text(\"Settling means the response finally stays near the target.\", font_size=23, color=GRAY_D).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(axes), Create(step), FadeIn(caption_a), run_time=4)\n self.play(Create(target), Create(response), ReplacementTransform(caption_a, caption_b), run_time=5)\n self.play(Indicate(target), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 the process of solving the integral of sin(x) cos(x) with respect to x using the substitution method? In the video, first display the integral, then add text about using the substitution method at the top, show the chosen substitution with 'u' for sin(x) and 'du' for cos(x) dx, rewrite the integral in terms of 'u', solve it, back-substitute to get the answer in terms of x, and finally clear the screen and display only the final solved integral.", "chosen": "```python\nfrom manim import *\n\nclass IntegralSubstitution(Scene):\n def construct(self):\n # Step 1: Display the original integral\n original_integral = MathTex(r\"\\int \\sin(x)\\cos(x) \\, dx\")\n original_integral.scale(1.5)\n self.play(Write(original_integral))\n self.wait(1)\n\n # Step 2: Add text at the top of the screen stating: \"Using the Substitution Method\"\n title = Text(\"Using the Substitution Method\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # Step 3: Explicitly show the chosen substitution variables\n substitution = VGroup(\n MathTex(r\"u = \\sin(x)\"),\n MathTex(r\"du = \\cos(x) \\, dx\")\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n sub_box = SurroundingRectangle(substitution, color=BLUE, buff=0.3)\n \n self.play(Write(substitution), Create(sub_box))\n self.wait(2)\n\n # Step 4: Rewrite the integral entirely in terms of u\n integral_u = MathTex(r\"\\int u \\, du\")\n self.play(ReplacementTransform(original_integral, integral_u))\n self.wait(2)\n\n # Step 5: Solve the simplified integral\n solved_u = MathTex(r\"= \\frac{1}{2}u^2 + C\")\n solved_u.next_to(integral_u, RIGHT)\n self.play(Write(solved_u))\n self.wait(2)\n\n # Step 6: Perform back-substitution to express the final answer in terms of x\n solved_x = MathTex(r\"= \\frac{1}{2}\\sin^2(x) + C\")\n self.play(ReplacementTransform(solved_u, solved_x))\n self.wait(3)\n\n # Step 7: Clear the screen completely\n all_mobs = VGroup(title, substitution, sub_box, integral_u, solved_x)\n self.play(FadeOut(all_mobs))\n self.wait(1)\n\n # Step 8: Display only the final solved integral\n final_result = MathTex(\n r\"\\int \\sin(x)\\cos(x) \\, dx = \\frac{1}{2}\\sin^2(x) + C\",\n font_size=48\n )\n self.play(Write(final_result))\n self.play(final_result.animate.set_color(YELLOW))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralSubstitution(Scene):\n def construct(self):\n # Step 1: Display the original integral\n original_integral = MathText(r\"\\int \\sin(x)\\cos(x) \\, dx\")\n original_integral.scale(1.5)\n self.play(Write(original_integral))\n self.wait(1)\n\n # Step 2: Add text at the top of the screen stating: \"Using the Substitution Method\"\n title = Text(\"Using the Substitution Method\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n\n # Step 3: Explicitly show the chosen substitution variables\n substitution = VGroup(\n MathTex(r\"u = \\sin(x)\"),\n MathTex(r\"du = \\cos(x) \\, dx\")\n ).arrange(DOWN, aligned_edge=LEFT).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n \n sub_box = SurroundingRectangle(substitution, color=BLUE, buff=0.3)\n \n self.play(Write(substitution), Create(sub_box))\n self.wait(2)\n\n # Step 4: Rewrite the integral entirely in terms of u\n integral_u = MathTex(r\"\\int u \\, du\")\n self.play(ReplacementTransform(original_integral, integral_u))\n self.wait(2)\n\n # Step 5: Solve the simplified integral\n solved_u = MathTex(r\"= \\frac{1}{2}u^2 + C\")\n solved_u.next_to(integral_u, RIGHT)\n self.play(Write(solved_u))\n self.wait(2)\n\n # Step 6: Perform back-substitution to express the final answer in terms of x\n solved_x = MathTex(r\"= \\frac{1}{2}\\sin^2(x) + C\")\n self.play(ReplacementTransform(solved_u, solved_x))\n self.wait(3)\n\n # Step 7: Clear the screen completely\n all_mobs = VGroup(title, substitution, sub_box, integral_u, solved_x)\n self.play(FadeOut(all_mobs))\n self.wait(1)\n\n # Step 8: Display only the final solved integral\n final_result = MathTex(\n r\"\\int \\sin(x)\\cos(x) \\, dx = \\frac{1}{2}\\sin^2(x) + C\",\n font_size=48\n )\n self.play(Write(final_result))\n self.play(final_result.animate.set_color(YELLOW))\n self.wait(3)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Initial Display: Render the definite integral of x^2 with limits from 0 to 1.\n integral = MathTex(r\"\\int_0^1 x^2 \\, dx\")\n integral.scale(1.5)\n self.play(Write(integral))\n self.wait(1)\n\n # 2. Contextual Explanation: Animate the appearance of text stating evaluation.\n eval_text = Text(\"We are evaluating this definite integral\", font_size=36)\n eval_text.next_to(integral, DOWN, buff=0.5)\n self.play(FadeIn(eval_text, shift=UP))\n self.wait(2)\n\n # 3. Rule Display: Show the general power rule for integrals.\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", color=BLUE_B)\n power_rule.to_edge(RIGHT, buff=1).shift(UP)\n rule_label = Text(\"Power Rule:\", font_size=24).next_to(power_rule, UP)\n \n self.play(FadeOut(eval_text), Write(rule_label), Write(power_rule))\n self.wait(2)\n\n # 4. Calculation Process: Visually demonstrate the application of limits to the antiderivative.\n antiderivative = MathTex(r\"\\int_0^1 x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_0^1\")\n antiderivative.scale(1.2)\n antiderivative.move_to(integral.get_center())\n \n self.play(\n ReplacementTransform(integral, antiderivative),\n FadeOut(rule_label),\n FadeOut(power_rule)\n )\n self.wait(2)\n\n # 5. Substitution & Transformation: Animate transition to solved numerical values.\n substitution = MathTex(r\"= \\frac{1^3}{3} - \\frac{0^3}{3}\")\n substitution.scale(1.2)\n substitution.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(substitution))\n self.wait(1)\n\n # 6. Final Result: Reveal the final calculated answer.\n final_answer = MathTex(r\"= \\frac{1}{3}\", color=YELLOW)\n final_answer.scale(1.2)\n final_answer.next_to(substitution, DOWN, buff=0.5)\n self.play(Write(final_answer))\n self.wait(1)\n\n # 7. Geometric Interpretation: Display text explaining the area under the curve.\n area_text = Text(\n \"This value represents the area under the curve between 0 and 1\",\n font_size=30\n )\n area_text.next_to(final_answer, DOWN, buff=0.8)\n self.play(FadeIn(area_text))\n self.wait(2)\n\n # 8. Conclusion Sequence: Clear everything, then bring back only final solution and explanation.\n self.play(FadeOut(VGroup(antiderivative, substitution, final_answer, area_text)))\n self.wait(0.5)\n\n conclusion_eq = MathTex(r\"\\int_0^1 x^2 \\, dx = \\frac{1}{3}\")\n conclusion_eq.scale(1.5)\n conclusion_text = Text(\n \"Represents the area under the curve from 0 to 1\",\n font_size=36\n )\n conclusion_text.next_to(conclusion_eq, DOWN, buff=0.8)\n\n self.play(Write(conclusion_eq), FadeIn(conclusion_text, shift=UP))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralScene(Scene):\n def construct(self):\n # 1. Initial Display: Render the definite integral of x^2 with limits from 0 to 1.\n integral = MathText(r\"\\int_0^1 x^2 \\, dx\")\n integral.scale(1.5)\n self.play(Write(integral))\n self.wait(1)\n\n # 2. Contextual Explanation: Animate the appearance of text stating evaluation.\n eval_text = Text(\"We are evaluating this definite integral\", font_size=36)\n eval_text.next_to(integral, DOWN, buff=0.5)\n self.play(FadeIn(eval_text, shift=UP))\n self.wait(2)\n\n # 3. Rule Display: Show the general power rule for integrals.\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", color=BLUE_B)\n power_rule.to_edge(RIGHT, buff=1).shift(UP)\n rule_label = Text(\"Power Rule:\", font_size=24).next_to(power_rule, UP)\n \n self.play(FadeOut(eval_text), Write(rule_label), Write(power_rule))\n self.wait(2)\n\n # 4. Calculation Process: Visually demonstrate the application of limits to the antiderivative.\n antiderivative = MathTex(r\"\\int_0^1 x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_0^1\")\n antiderivative.scale(1.2)\n antiderivative.move_to(integral.get_center())\n \n self.play(\n ReplacementTransform(integral, antiderivative),\n FadeOut(rule_label),\n FadeOut(power_rule)\n )\n self.wait(2)\n\n # 5. Substitution & Transformation: Animate transition to solved numerical values.\n substitution = MathTex(r\"= \\frac{1^3}{3} - \\frac{0^3}{3}\")\n substitution.scale(1.2)\n substitution.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(substitution))\n self.wait(1)\n\n # 6. Final Result: Reveal the final calculated answer.\n final_answer = MathTex(r\"= \\frac{1}{3}\", color=YELLOW)\n final_answer.scale(1.2)\n final_answer.next_to(substitution, DOWN, buff=0.5)\n self.play(Write(final_answer))\n self.wait(1)\n\n # 7. Geometric Interpretation: Display text explaining the area under the curve.\n area_text = Text(\n \"This value represents the area under the curve between 0 and 1\",\n font_size=30\n )\n area_text.next_to(final_answer, DOWN, buff=0.8)\n self.play(FadeIn(area_text))\n self.wait(2)\n\n # 8. Conclusion Sequence: Clear everything, then bring back only final solution and explanation.\n self.play(FadeOut(VGroup(antiderivative, substitution, final_answer, area_text)))\n self.wait(0.5)\n\n conclusion_eq = MathTex(r\"\\int_0^1 x^2 \\, dx = \\frac{1}{3}\")\n conclusion_eq.scale(1.5)\n conclusion_text = Text(\n \"Represents the area under the curve from 0 to 1\",\n font_size=36\n )\n conclusion_text.next_to(conclusion_eq, DOWN, buff=0.8)\n\n self.play(Write(conclusion_eq), FadeIn(conclusion_text, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 transforming the text \"CyclicReplace\" at the top of the screen, as in the original script. Then, introduce the four shapes (square, star, circle, triangle) arranged horizontally, but now each shape should be labeled with its name in small text below it for clarity. As the `CyclicReplace` animation swaps their positions, simultaneously animate a mathematical formula (e.g., a permutation cycle notation like \\((1\\ 2\\ 3\\ 4)\\)) appearing above the shapes, dynamically updating to reflect the current cyclic order. After the shapes finish rearranging, morph them into a new set of related geometric forms (e.g., square → cube, star → pentagon, circle → ellipse, triangle → pyramid) while smoothly fading out the labels. Finally, display a concluding text box explaining the concept of cyclic permutations in group theory, with the shapes shrinking and aligning around it to emphasize the connection. The entire sequence should maintain smooth transitions, synchronized timing, and clear visual storytelling.", "chosen": "```python\nfrom manim import *\n\nclass CyclicReplaceWithFormula(Scene):\n def construct(self):\n # Initial text\n title = Text(\"CyclicReplace\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Shapes with labels\n shapes = VGroup(\n VGroup(Square(color=BLUE), Text(\"Square\", font_size=24).next_to(Square(), DOWN)),\n VGroup(Star(color=RED), Text(\"Star\", font_size=24).next_to(Star(), DOWN)),\n VGroup(Circle(color=GREEN), Text(\"Circle\", font_size=24).next_to(Circle(), DOWN)),\n VGroup(Triangle(color=YELLOW), Text(\"Triangle\", font_size=24).next_to(Triangle(), DOWN))\n ).arrange(RIGHT, buff=1.5)\n\n self.play(*[Create(shape[0]) for shape in shapes], *[Write(shape[1]) for shape in shapes])\n self.wait(0.5)\n\n # Permutation formula\n formula = MathTex(r\"(1\\ 2\\ 3\\ 4)\").next_to(title, DOWN)\n self.play(Write(formula))\n self.wait(0.5)\n\n # Cyclic replacement animation\n for _ in range(4):\n new_shapes = shapes.copy()\n new_shapes[0].move_to(shapes[1].get_center())\n new_shapes[1].move_to(shapes[2].get_center())\n new_shapes[2].move_to(shapes[3].get_center())\n new_shapes[3].move_to(shapes[0].get_center())\n self.play(\n *[Transform(shapes[i], new_shapes[i]) for i in range(4)],\n formula.animate.become(MathTex(r\"(1\\ 2\\ 3\\ 4)\").next_to(title, DOWN)),\n run_time=1.5\n )\n shapes = new_shapes\n self.wait(0.5)\n\n # Morph shapes and fade labels\n morphed_shapes = VGroup(\n Cube(side_length=0.8, color=BLUE),\n RegularPolygon(n=5, color=RED),\n Ellipse(width=1.5, height=1, color=GREEN),\n Polygon([0,0,0], [1,0,0], [0.5,1,0], [0,0,0], color=YELLOW)\n )\n for i in range(4):\n morphed_shapes[i].move_to(shapes[i][0].get_center())\n\n self.play(\n *[Transform(shapes[i][0], morphed_shapes[i]) for i in range(4)],\n *[FadeOut(shapes[i][1]) for i in range(4)],\n run_time=2\n )\n self.wait(1)\n\n # Explanation text\n explanation = Text(\n \"Cyclic permutations are elements of the symmetric group\\nthat rearrange objects in a circular fashion.\",\n font_size=24,\n color=WHITE\n ).to_edge(DOWN)\n box = SurroundingRectangle(explanation, buff=0.5, color=WHITE)\n\n # Shrink shapes and arrange around explanation\n self.play(\n *[shapes[i][0].animate.scale(0.5).move_to(\n explanation.get_corner(UL) + (i+1) * RIGHT * 1.5 + UP * 0.5\n ) for i in range(4)],\n Write(explanation),\n Create(box),\n run_time=2\n )\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass CyclicReplaceWithFormula(Scene):\n def construct(self):\n # Initial text\n title = Text(\"CyclicReplace\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Shapes with labels\n shapes = VGroup(\n VGroup(Square(color=BLUE), Text(\"Square\", font_size=24).next_to(Square(), DOWN)),\n VGroup(Star(color=RED), Text(\"Star\", font_size=24).next_to(Star(), DOWN)),\n VGroup(Circle(color=GREEN), Text(\"Circle\", font_size=24).next_to(Circle(), DOWN)),\n VGroup(Triangle(color=YELLOW), Text(\"Triangle\", font_size=24).next_to(Triangle(), DOWN))\n ).arrange(RIGHT, buff=1.5)\n\n self.play(*[Create(shape[0]) for shape in shapes], *[Write(shape[1]) for shape in shapes])\n self.wait(0.5)\n\n # Permutation formula\n formula = MathText(r\"(1\\ 2\\ 3\\ 4)\").next_to(title, DOWN)\n self.play(Write(formula))\n self.wait(0.5)\n\n # Cyclic replacement animation\n for _ in range(4):\n new_shapes = shapes.copy()\n new_shapes[0].move_to(shapes[1].get_center())\n new_shapes[1].move_to(shapes[2].get_center())\n new_shapes[2].move_to(shapes[3].get_center())\n new_shapes[3].move_to(shapes[0].get_center())\n self.play(\n *[Transform(shapes[i], new_shapes[i]) for i in range(4)],\n formula.animate.become(MathTex(r\"(1\\ 2\\ 3\\ 4)\").next_to(title, DOWN)),\n run_time=1.5\n )\n shapes = new_shapes\n self.wait(0.5)\n\n # Morph shapes and fade labels\n morphed_shapes = VGroup(\n Cube(side_length=0.8, color=BLUE),\n RegularPolygon(n=5, color=RED),\n Ellipse(width=1.5, height=1, color=GREEN),\n Polygon([0,0,0], [1,0,0], [0.5,1,0], [0,0,0], color=YELLOW)\n )\n for i in range(4):\n morphed_shapes[i].move_to(shapes[i][0].get_center())\n\n self.play(\n *[Transform(shapes[i][0], morphed_shapes[i]) for i in range(4)],\n *[FadeOut(shapes[i][1]) for i in range(4)],\n run_time=2\n )\n self.wait(1)\n\n # Explanation text\n explanation = Text(\n \"Cyclic permutations are elements of the symmetric group\\nthat rearrange objects in a circular fashion.\",\n font_size=24,\n color=WHITE\n ).to_edge(DOWN)\n box = SurroundingRectangle(explanation, buff=0.5, color=WHITE)\n\n # Shrink shapes and arrange around explanation\n self.play(\n *[shapes[i][0].animate.scale(0.5).move_to(\n explanation.get_corner(UL) + (i+1) * RIGHT * 1.5 + UP * 0.5\n ) for i in range(4)],\n Write(explanation),\n Create(box),\n run_time=2\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 please create an animation that shows the process of finding the derivative of the function f(x) = x^3 + 3x^2 + 2x + 1, demonstrates the calculation of the derivative step by step, and then identifies the critical points of the derived function? The animation should start by writing the original function on the screen, then move the function to the top and show a text below saying \"Calculating the derivative\". Then, replace the original function with its derivative, simplify it to show \"f'(x) = 3x^2 + 6x + 2\", and then change the text to \"Find critical points\". Afterwards, replace the simplified derivative with the critical points \"x=-2, x=-1/3\" and then clear the screen and conclude by showing the critical points again to emphasize the result.", "chosen": "```python\nfrom manim import *\n\nclass DerivativeProcess(Scene):\n def construct(self):\n # 1. Write the original function on the screen\n func_original = MathTex(\"f(x)\", \"=\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\", \"+\", \"1\")\n self.play(Write(func_original))\n self.wait(1)\n\n # 2. Move the function to the top\n self.play(func_original.animate.to_edge(UP))\n self.wait(0.5)\n\n # 3. Show text below saying \"Calculating the derivative\"\n calc_text = Text(\"Calculating the derivative\", font_size=36)\n calc_text.next_to(func_original, DOWN, buff=1.0)\n self.play(Write(calc_text))\n self.wait(1)\n\n # 4. Replace the original function with its derivative and simplify\n func_derivative = MathTex(\"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x\", \"+\", \"2\")\n func_derivative.move_to(func_original)\n self.play(TransformMatchingTex(func_original, func_derivative))\n self.wait(1)\n\n # 5. Change the text to \"Find critical points\"\n crit_text = Text(\"Find critical points\", font_size=36)\n crit_text.next_to(func_derivative, DOWN, buff=1.0)\n self.play(ReplacementTransform(calc_text, crit_text))\n self.wait(1)\n\n # 6. Replace the simplified derivative with the critical points\n critical_points = MathTex(\"x=-2,\", \"x=-\\\\frac{1}{3}\")\n critical_points.move_to(func_derivative)\n self.play(TransformMatchingTex(func_derivative, critical_points))\n self.wait(2)\n\n # 7. Clear the screen\n self.play(FadeOut(critical_points), FadeOut(crit_text))\n self.wait(0.5)\n\n # 8. Conclude by showing the critical points again to emphasize the result\n final_points = MathTex(\"x=-2,\", \"x=-\\\\frac{1}{3}\", color=YELLOW).scale(1.5)\n self.play(Write(final_points))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DerivativeProcess(Scene):\n def construct(self):\n # 1. Write the original function on the screen\n func_original = MathText(\"f(x)\", \"=\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\", \"+\", \"1\")\n self.play(Write(func_original))\n self.wait(1)\n\n # 2. Move the function to the top\n self.play(func_original.animate.to_edge(UP))\n self.wait(0.5)\n\n # 3. Show text below saying \"Calculating the derivative\"\n calc_text = Text(\"Calculating the derivative\", font_size=36)\n calc_text.next_to(func_original, DOWN, buff=1.0)\n self.play(Write(calc_text))\n self.wait(1)\n\n # 4. Replace the original function with its derivative and simplify\n func_derivative = MathTex(\"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x\", \"+\", \"2\")\n func_derivative.move_to(func_original)\n self.play(TransformMatchingTex(func_original, func_derivative))\n self.wait(1)\n\n # 5. Change the text to \"Find critical points\"\n crit_text = Text(\"Find critical points\", font_size=36)\n crit_text.next_to(func_derivative, DOWN, buff=1.0)\n self.play(ReplacementTransform(calc_text, crit_text))\n self.wait(1)\n\n # 6. Replace the simplified derivative with the critical points\n critical_points = MathTex(\"x=-2,\", \"x=-\\\\frac{1}{3}\")\n critical_points.move_to(func_derivative)\n self.play(TransformMatchingTex(func_derivative, critical_points))\n self.wait(2)\n\n # 7. Clear the screen\n self.play(FadeOut(critical_points), FadeOut(crit_text))\n self.wait(0.5)\n\n # 8. Conclude by showing the critical points again to emphasize the result\n final_points = MathTex(\"x=-2,\", \"x=-\\\\frac{1}{3}\", color=YELLOW).scale(1.5)\n self.play(Write(final_points))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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^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=BBLUE).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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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_0387(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_stringinputoutput()\n self.clear_stage()\n self.act_2_contrapositive()\n\n def act_1_stringinputoutput(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\n def act_2_contrapositive(self):\n title = Text('Contrapositive', 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_stmt = MathTex('P \\\\rightarrow Q', font_size=60)\n equiv_arrow = MathTex('\\\\Leftrightarrow', font_size=60)\n contra_stmt = MathTex('\\\\neg Q \\\\rightarrow \\\\neg P', font_size=60)\n eq_group = VGroup(orig_stmt, equiv_arrow, contra_stmt).arrange(RIGHT, buff=1)\n eq_group.shift(UP * 0.5)\n box_orig = SurroundingRectangle(orig_stmt, color=BLUE, buff=0.2)\n box_contra = SurroundingRectangle(contra_stmt, color=GREEN, buff=0.2)\n label_orig = Text('Original Statement', font_size=28, color=BLUE)\n label_orig.next_to(box_orig, UP, buff=0.3)\n label_contra = Text('Contrapositive', font_size=28, color=GREEN)\n label_contra.next_to(box_contra, UP, buff=0.3)\n text_diff = Text('When direct proof is difficult...', font_size=32)\n text_diff.next_to(eq_group, DOWN, buff=1.5)\n text_sol = Text('...prove its contrapositive instead!', font_size=32, color=YELLOW)\n text_sol.next_to(text_diff, DOWN, buff=0.4)\n self.play(Write(orig_stmt))\n self.play(Create(box_orig), Write(label_orig), run_time=1)\n self.play(Write(equiv_arrow))\n self.play(Write(contra_stmt))\n self.play(Create(box_contra), Write(label_contra), run_time=1)\n self.wait(0.5)\n self.play(Write(text_diff))\n self.play(Write(text_sol))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0387(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_stringinputoutput()\n self.clear_stage()\n self.act_2_contrapositive()\n\n def act_1_stringinputoutput(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\n def act_2_contrapositive(self):\n title = Text('Contrapositive', 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_stmt = MathText('P \\\\rightarrow Q', font_size=60)\n equiv_arrow = MathTex('\\\\Leftrightarrow', font_size=60)\n contra_stmt = MathTex('\\\\neg Q \\\\rightarrow \\\\neg P', font_size=60)\n eq_group = VGroup(orig_stmt, equiv_arrow, contra_stmt).arrange(RIGHT, buff=1)\n eq_group.shift(UP * 0.5)\n box_orig = SurroundingRectangle(orig_stmt, color=BLUE, buff=0.2)\n box_contra = SurroundingRectangle(contra_stmt, color=GREEN, buff=0.2)\n label_orig = Text('Original Statement', font_size=28, color=BLUE)\n label_orig.next_to(box_orig, UP, buff=0.3)\n label_contra = Text('Contrapositive', font_size=28, color=GREEN)\n label_contra.next_to(box_contra, UP, buff=0.3)\n text_diff = Text('When direct proof is difficult...', font_size=32)\n text_diff.next_to(eq_group, DOWN, buff=1.5)\n text_sol = Text('...prove its contrapositive instead!', font_size=32, color=YELLOW)\n text_sol.next_to(text_diff, DOWN, buff=0.4)\n self.play(Write(orig_stmt))\n self.play(Create(box_orig), Write(label_orig), run_time=1)\n self.play(Write(equiv_arrow))\n self.play(Write(contra_stmt))\n self.play(Create(box_contra), Write(label_contra), run_time=1)\n self.wait(0.5)\n self.play(Write(text_diff))\n self.play(Write(text_sol))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 music-theory scene showing how three evenly spaced beats and four evenly spaced beats fit into one shared cycle. Use two aligned timelines, pulse each rhythm in sequence, and highlight that they realign at the cycle boundary rather than on every beat.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass PolyrhythmAlignment(Scene):\n def construct(self):\n title = Text(\"Three against four realigns at the shared cycle\", font_size=37).to_edge(UP)\n start_x, end_x = -5.0, 5.0\n lane3 = Line([start_x, 1.0, 0], [end_x, 1.0, 0], color=BLUE_B)\n lane4 = Line([start_x, -0.7, 0], [end_x, -0.7, 0], color=ORANGE)\n label3 = Text(\"3 beats\", font_size=25, color=BLUE_B).next_to(lane3, LEFT)\n label4 = Text(\"4 beats\", font_size=25, color=ORANGE).next_to(lane4, LEFT)\n xs3 = np.linspace(start_x, end_x, 4)\n xs4 = np.linspace(start_x, end_x, 5)\n beats3 = VGroup(*[Dot([x, 1.0, 0], color=BLUE_B, radius=0.11) for x in xs3])\n beats4 = VGroup(*[Dot([x, -0.7, 0], color=ORANGE, radius=0.11) for x in xs4])\n start_line = DashedLine([start_x, 1.5, 0], [start_x, -1.2, 0], color=GREEN)\n end_line = DashedLine([end_x, 1.5, 0], [end_x, -1.2, 0], color=GREEN)\n caption = Text(\"Internal beats differ; both rhythms meet again at the boundary.\", font_size=24).to_edge(DOWN)\n\n self.play(Write(title), Create(lane3), Create(lane4), FadeIn(label3, label4, beats3, beats4))\n self.play(Create(start_line), Flash(beats3[0], color=GREEN), Flash(beats4[0], color=GREEN))\n self.play(Succession(*[Flash(dot, color=BLUE_B, flash_radius=0.35) for dot in beats3[1:]], lag_ratio=1), run_time=3)\n self.play(Succession(*[Flash(dot, color=ORANGE, flash_radius=0.35) for dot in beats4[1:]], lag_ratio=1), run_time=3)\n self.play(Create(end_line), Indicate(VGroup(beats3[-1], beats4[-1]), color=GREEN), FadeIn(caption))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass PolyrhythmAlignment(Scene):\n def construct(self):\n title = Text(\"Three against four realigns at the shared cycle\", font_size=37).to_edge(UP)\n start_x, end_x = -5.0, 5.0\n lane3 = Line([start_x, 1.0, 0], [end_x, 1.0, 0], color=BBLUE_B)\n lane4 = Line([start_x, -0.7, 0], [end_x, -0.7, 0], color=ORANGE)\n label3 = Text(\"3 beats\", font_size=25, color=BLUE_B).next_to(lane3, LEFT)\n label4 = Text(\"4 beats\", font_size=25, color=ORANGE).next_to(lane4, LEFT)\n xs3 = np.linspace(start_x, end_x, 4)\n xs4 = np.linspace(start_x, end_x, 5)\n beats3 = VGroup(*[Dot([x, 1.0, 0], color=BLUE_B, radius=0.11) for x in xs3])\n beats4 = VGroup(*[Dot([x, -0.7, 0], color=ORANGE, radius=0.11) for x in xs4])\n start_line = DashedLine([start_x, 1.5, 0], [start_x, -1.2, 0], color=GREEN)\n end_line = DashedLine([end_x, 1.5, 0], [end_x, -1.2, 0], color=GREEN)\n caption = Text(\"Internal beats differ; both rhythms meet again at the boundary.\", font_size=24).to_edge(DOWN)\n\n self.play(Write(title), Create(lane3), Create(lane4), FadeIn(label3, label4, beats3, beats4))\n self.play(Create(start_line), Flash(beats3[0], color=GREEN), Flash(beats4[0], color=GREEN))\n self.play(Succession(*[Flash(dot, color=BLUE_B, flash_radius=0.35) for dot in beats3[1:]], lag_ratio=1), run_time=3)\n self.play(Succession(*[Flash(dot, color=ORANGE, flash_radius=0.35) for dot in beats4[1:]], lag_ratio=1), run_time=3)\n self.play(Create(end_line), Indicate(VGroup(beats3[-1], beats4[-1]), color=GREEN), FadeIn(caption))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Manim scene explaining a confidence interval as uncertainty around an estimate. Show a dot estimate on a number line, expand a translucent interval band, compare narrow and wide intervals, and end with a plain-language caption.", "chosen": "```python\nfrom manim import *\n\nclass ConfidenceIntervalBand(Scene):\n def construct(self):\n title = Text(\"Confidence interval = estimate plus uncertainty\", font_size=32).to_edge(UP)\n line = NumberLine(x_range=[0, 10, 1], length=8.5, include_numbers=True).shift(UP * 0.65)\n estimate = Dot(line.n2p(5), color=YELLOW_D, radius=0.09)\n estimate_label = Text(\"estimate\", font_size=24, color=YELLOW_D).next_to(estimate, UP, buff=0.3)\n def interval(left, right, color):\n width = abs(line.n2p(right)[0] - line.n2p(left)[0])\n rect = Rectangle(width=width, height=0.42, stroke_color=color, fill_color=color, fill_opacity=0.2)\n return rect.move_to((line.n2p(left) + line.n2p(right)) / 2)\n narrow = interval(4.4, 5.6, TEAL_D)\n wide = interval(3.3, 6.7, BLUE_D)\n narrow_brace = BraceBetweenPoints(line.n2p(4.4), line.n2p(5.6), direction=DOWN, color=TEAL_D)\n wide_brace = BraceBetweenPoints(line.n2p(3.3), line.n2p(6.7), direction=DOWN, color=BLUE_D)\n narrow_label = Text(\"narrower\", font_size=25, color=TEAL_D).next_to(narrow_brace, DOWN, buff=0.22)\n wide_label = Text(\"wider means more uncertainty\", font_size=25, color=BLUE_B).next_to(wide_brace, DOWN, buff=0.22)\n caption = Text(\"The interval is a range of plausible values, not a second estimate.\", font_size=23, color=WHITE).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(line), FadeIn(estimate), FadeIn(estimate_label), run_time=3)\n self.play(FadeIn(narrow), Create(narrow_brace), FadeIn(narrow_label), run_time=3)\n self.play(ReplacementTransform(narrow, wide), ReplacementTransform(narrow_brace, wide_brace), ReplacementTransform(narrow_label, wide_label), run_time=4)\n self.play(FadeIn(caption), run_time=2)\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass ConfidenceIntervalBand(Scene):\n def construct(self):\n title = Text(\"Confidence interval = estimate plus uncertainty\", font_size=32).to_edge(UP)\n line = NumberLine(x_range=[0, 10, 1], length=8.5, include_numbers=True).shift(UP * 0.65)\n estimate = Dot(line.n2p(5), color=YELLOW_D, radius=0.09)\n estimate_label = Text(\"estimate\", font_size=24, color=YELLOW_D).next_to(estimate, UP, buff=0.3)\n def interval(left, right, color):\n width = abs(line.n2p(right)[0] - line.n2p(left)[0])\n rect = Rectangle(width=width, height=0.42, stroke_color=color, fill_color=color, fill_opacity=0.2)\n return rect.move_to((line.n2p(left) + line.n2p(right)) / 2)\n narrow = interval(4.4, 5.6, TEAL_D)\n wide = interval(3.3, 6.7, BBLUE_D)\n narrow_brace = BraceBetweenPoints(line.n2p(4.4), line.n2p(5.6), direction=DOWN, color=TEAL_D)\n wide_brace = BraceBetweenPoints(line.n2p(3.3), line.n2p(6.7), direction=DOWN, color=BLUE_D)\n narrow_label = Text(\"narrower\", font_size=25, color=TEAL_D).next_to(narrow_brace, DOWN, buff=0.22)\n wide_label = Text(\"wider means more uncertainty\", font_size=25, color=BLUE_B).next_to(wide_brace, DOWN, buff=0.22)\n caption = Text(\"The interval is a range of plausible values, not a second estimate.\", font_size=23, color=WHITE).to_edge(DOWN)\n\n self.play(FadeIn(title), Create(line), FadeIn(estimate), FadeIn(estimate_label), run_time=3)\n self.play(FadeIn(narrow), Create(narrow_brace), FadeIn(narrow_label), run_time=3)\n self.play(ReplacementTransform(narrow, wide), ReplacementTransform(narrow_brace, wide_brace), ReplacementTransform(narrow_label, wide_label), run_time=4)\n self.play(FadeIn(caption), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 teaches how to find the derivative of the function f(x) = x^3 + 3x^2 + 2x using the power rule, show the step-by-step process, including simplifying the expression to its final form, and then conclude by clearly displaying the final derivative on the screen?", "chosen": "```python\nfrom manim import *\n\nclass DerivativePowerRule(Scene):\n \"\"\"\n An educational animation demonstrating how to find the derivative of\n f(x) = x^3 + 3x^2 + 2x using the power rule, step-by-step.\n \"\"\"\n def construct(self):\n # Define colors to track individual terms through the animation\n color_term1 = BLUE\n color_term2 = GREEN\n color_term3 = YELLOW\n\n # ------------------------------------------------------------------\n # 1. Scene Setup: Display the original function\n # ------------------------------------------------------------------\n # Separate terms into different substrings for color tracking\n func = MathTex(\n \"f(x)\", \"=\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\"\n )\n func.set_color_by_tex(\"x^3\", color_term1)\n func.set_color_by_tex(\"3x^2\", color_term2)\n func.set_color_by_tex(\"2x\", color_term3)\n func.scale(1.2)\n func.to_edge(UP)\n\n # Title for the scene\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36)\n title.next_to(func, UP, buff=0.3)\n\n self.play(Write(title))\n self.play(Write(func))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Step-by-Step Derivation: Setup Derivative Notation\n # ------------------------------------------------------------------\n # Define the derivative notation line\n deriv_intro = MathTex(\n \"f'(x)\", \"=\", r\"\\frac{d}{dx}\", r\"\\left(\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\", r\"\\right)\"\n )\n deriv_intro.set_color_by_tex(\"x^3\", color_term1)\n deriv_intro.set_color_by_tex(\"3x^2\", color_term2)\n deriv_intro.set_color_by_tex(\"2x\", color_term3)\n deriv_intro.scale(1.2)\n deriv_intro.move_to(func)\n\n self.play(ReplacementTransform(func, deriv_intro))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Apply Power Rule to Each Term Individually\n # ------------------------------------------------------------------\n # Show the application of the power rule: n * x^(n-1)\n # Break down the coefficients and exponents to show the mechanics\n power_rule_step = MathTex(\n \"f'(x)\", \"=\", \n \"3\", \"x^{3-1}\", \"+\", \n \"3\", r\"\\cdot\", \"2\", \"x^{2-1}\", \"+\", \n \"2\", r\"\\cdot\", \"1\", \"x^{1-1}\"\n )\n # Color code the coefficients coming down\n power_rule_step[2].set_color(color_term1) # 3\n power_rule_step[3].set_color(color_term1) # x^{3-1}\n power_rule_step[5].set_color(color_term2) # 3\n power_rule_step[7].set_color(color_term2) # 2\n power_rule_step[8].set_color(color_term2) # x^{2-1}\n power_rule_step[10].set_color(color_term3) # 2\n power_rule_step[12].set_color(color_term3) # 1\n power_rule_step[13].set_color(color_term3) # x^{1-1}\n power_rule_step.scale(1.2)\n power_rule_step.next_to(deriv_intro, DOWN, buff=0.5)\n\n # Highlight the Power Rule formula briefly\n rule_text = MathTex(r\"\\frac{d}{dx}x^n = nx^{n-1}\", color=RED)\n rule_box = SurroundingRectangle(rule_text, color=YELLOW, buff=0.2)\n rule_group = VGroup(rule_text, rule_box).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n self.play(Write(rule_group))\n self.play(ReplacementTransform(deriv_intro.copy(), power_rule_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Simplify the Expression (Intermediate Step)\n # ------------------------------------------------------------------\n # Show the result after subtracting exponents and multiplying coefficients\n # f'(x) = 3x^2 + 6x^1 + 2x^0\n simplified_step = MathTex(\n \"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x^1\", \"+\", \"2x^0\"\n )\n simplified_step.set_color_by_tex(\"3x^2\", color_term1)\n simplified_step.set_color_by_tex(\"6x^1\", color_term2)\n simplified_step.set_color_by_tex(\"2x^0\", color_term3)\n simplified_step.scale(1.2)\n simplified_step.next_to(power_rule_step, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(power_rule_step, simplified_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Final Simplification and Output\n # ------------------------------------------------------------------\n # Final form: x^1 becomes x, x^0 becomes 1\n final_deriv = MathTex(\n \"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x\", \"+\", \"2\"\n )\n final_deriv.set_color_by_tex(\"3x^2\", color_term1)\n final_deriv.set_color_by_tex(\"6x\", color_term2)\n final_deriv.set_color_by_tex(\"2\", color_term3)\n final_deriv.scale(1.2)\n final_deriv.next_to(simplified_step, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(simplified_step, final_deriv))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Conclusion: Highlight Final Result\n # ------------------------------------------------------------------\n # Draw a box around the final derivative to emphasize the solution\n final_box = SurroundingRectangle(final_deriv, color=GREEN, buff=0.3)\n conclusion_text = Text(\"Final Derivative\", color=GREEN, font_size=36)\n conclusion_text.next_to(final_box, DOWN, buff=0.2)\n\n self.play(Create(final_box), Write(conclusion_text))\n self.wait(2)\n\n # Clean up the screen and center the final result for a clear conclusion\n self.play(\n FadeOut(title), \n FadeOut(rule_group), \n FadeOut(final_box), \n FadeOut(conclusion_text)\n )\n self.play(final_deriv.animate.scale(1.5).center())\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DerivativePowerRule(Scene):\n \"\"\"\n An educational animation demonstrating how to find the derivative of\n f(x) = x^3 + 3x^2 + 2x using the power rule, step-by-step.\n \"\"\"\n def construct(self):\n # Define colors to track individual terms through the animation\n color_term1 = BBLUE\n color_term2 = GREEN\n color_term3 = YELLOW\n\n # ------------------------------------------------------------------\n # 1. Scene Setup: Display the original function\n # ------------------------------------------------------------------\n # Separate terms into different substrings for color tracking\n func = MathTex(\n \"f(x)\", \"=\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\"\n )\n func.set_color_by_tex(\"x^3\", color_term1)\n func.set_color_by_tex(\"3x^2\", color_term2)\n func.set_color_by_tex(\"2x\", color_term3)\n func.scale(1.2)\n func.to_edge(UP)\n\n # Title for the scene\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36)\n title.next_to(func, UP, buff=0.3)\n\n self.play(Write(title))\n self.play(Write(func))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Step-by-Step Derivation: Setup Derivative Notation\n # ------------------------------------------------------------------\n # Define the derivative notation line\n deriv_intro = MathTex(\n \"f'(x)\", \"=\", r\"\\frac{d}{dx}\", r\"\\left(\", \"x^3\", \"+\", \"3x^2\", \"+\", \"2x\", r\"\\right)\"\n )\n deriv_intro.set_color_by_tex(\"x^3\", color_term1)\n deriv_intro.set_color_by_tex(\"3x^2\", color_term2)\n deriv_intro.set_color_by_tex(\"2x\", color_term3)\n deriv_intro.scale(1.2)\n deriv_intro.move_to(func)\n\n self.play(ReplacementTransform(func, deriv_intro))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Apply Power Rule to Each Term Individually\n # ------------------------------------------------------------------\n # Show the application of the power rule: n * x^(n-1)\n # Break down the coefficients and exponents to show the mechanics\n power_rule_step = MathTex(\n \"f'(x)\", \"=\", \n \"3\", \"x^{3-1}\", \"+\", \n \"3\", r\"\\cdot\", \"2\", \"x^{2-1}\", \"+\", \n \"2\", r\"\\cdot\", \"1\", \"x^{1-1}\"\n )\n # Color code the coefficients coming down\n power_rule_step[2].set_color(color_term1) # 3\n power_rule_step[3].set_color(color_term1) # x^{3-1}\n power_rule_step[5].set_color(color_term2) # 3\n power_rule_step[7].set_color(color_term2) # 2\n power_rule_step[8].set_color(color_term2) # x^{2-1}\n power_rule_step[10].set_color(color_term3) # 2\n power_rule_step[12].set_color(color_term3) # 1\n power_rule_step[13].set_color(color_term3) # x^{1-1}\n power_rule_step.scale(1.2)\n power_rule_step.next_to(deriv_intro, DOWN, buff=0.5)\n\n # Highlight the Power Rule formula briefly\n rule_text = MathTex(r\"\\frac{d}{dx}x^n = nx^{n-1}\", color=RED)\n rule_box = SurroundingRectangle(rule_text, color=YELLOW, buff=0.2)\n rule_group = VGroup(rule_text, rule_box).to_edge(RIGHT, buff=1).shift(UP * 0.5)\n\n self.play(Write(rule_group))\n self.play(ReplacementTransform(deriv_intro.copy(), power_rule_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Simplify the Expression (Intermediate Step)\n # ------------------------------------------------------------------\n # Show the result after subtracting exponents and multiplying coefficients\n # f'(x) = 3x^2 + 6x^1 + 2x^0\n simplified_step = MathTex(\n \"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x^1\", \"+\", \"2x^0\"\n )\n simplified_step.set_color_by_tex(\"3x^2\", color_term1)\n simplified_step.set_color_by_tex(\"6x^1\", color_term2)\n simplified_step.set_color_by_tex(\"2x^0\", color_term3)\n simplified_step.scale(1.2)\n simplified_step.next_to(power_rule_step, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(power_rule_step, simplified_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Final Simplification and Output\n # ------------------------------------------------------------------\n # Final form: x^1 becomes x, x^0 becomes 1\n final_deriv = MathTex(\n \"f'(x)\", \"=\", \"3x^2\", \"+\", \"6x\", \"+\", \"2\"\n )\n final_deriv.set_color_by_tex(\"3x^2\", color_term1)\n final_deriv.set_color_by_tex(\"6x\", color_term2)\n final_deriv.set_color_by_tex(\"2\", color_term3)\n final_deriv.scale(1.2)\n final_deriv.next_to(simplified_step, DOWN, buff=0.5)\n\n self.play(ReplacementTransform(simplified_step, final_deriv))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Conclusion: Highlight Final Result\n # ------------------------------------------------------------------\n # Draw a box around the final derivative to emphasize the solution\n final_box = SurroundingRectangle(final_deriv, color=GREEN, buff=0.3)\n conclusion_text = Text(\"Final Derivative\", color=GREEN, font_size=36)\n conclusion_text.next_to(final_box, DOWN, buff=0.2)\n\n self.play(Create(final_box), Write(conclusion_text))\n self.wait(2)\n\n # Clean up the screen and center the final result for a clear conclusion\n self.play(\n FadeOut(title), \n FadeOut(rule_group), \n FadeOut(final_box), \n FadeOut(conclusion_text)\n )\n self.play(final_deriv.animate.scale(1.5).center())\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 begins by transforming the initial text into the word \"Circumscribe\" positioned at the top of the screen, while simultaneously fading in the phrase \"Look Here\" at the center. As the first circumscribe animation highlights this text with a rectangle, a corresponding mathematical formula (A = πr²) appears below it, with each element fading in sequentially. The scene then transitions to a circular circumscribe effect around the text, during which the formula morphs into a circle diagram with radius and area labels. As the text disappears, the circle diagram grows larger and transforms into a 3D sphere, with the original formula reappearing beside it in a glowing highlight effect. Throughout the animation, explanatory text boxes fade in at key moments to explain the relationship between circumscription and the mathematical concepts being shown, creating a more comprehensive educational presentation that connects geometric visualization with mathematical formulas. The entire sequence concludes with all elements fading out in a coordinated cascade.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedCircumscribeAnimation(Scene):\n def construct(self):\n # Initial text setup\n title = Text(\"Circumscribe\").to_edge(UP)\n center_text = Text(\"Look Here\").scale(1.5)\n formula = MathTex(\"A = \\\\pi r^2\").next_to(center_text, DOWN, buff=1)\n\n # First animation: transform and fade in elements\n self.play(Write(title), FadeIn(center_text, shift=UP))\n self.wait(0.5)\n\n # Circumscribe animation with rectangle\n self.play(Circumscribe(center_text, color=YELLOW, fade_out=True))\n self.play(FadeIn(formula, shift=UP))\n self.wait(1)\n\n # Circular circumscribe and formula transformation\n self.play(Circumscribe(center_text, Circle, fade_out=True))\n \n # Create circle diagram\n circle = Circle(radius=1.5, color=BLUE).next_to(formula, DOWN, buff=1)\n radius_line = Line(circle.get_center(), circle.get_right(), color=RED)\n radius_label = MathTex(\"r\").next_to(radius_line, UP)\n area_label = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n \n self.play(\n Transform(formula, area_label),\n Create(circle),\n Create(radius_line),\n Write(radius_label)\n )\n self.wait(1)\n\n # Fade out text and transform to 3D sphere\n self.play(\n FadeOut(center_text),\n FadeOut(title),\n circle.animate.scale(1.5).set_color(BLUE_E)\n )\n \n # Create 3D sphere\n sphere = Sphere(radius=1.5, resolution=(20, 20)).set_color(BLUE_E)\n sphere.move_to(circle)\n formula_3d = MathTex(\"A = 4\\\\pi r^2\").next_to(sphere, RIGHT, buff=1)\n \n self.play(\n ReplacementTransform(circle, sphere),\n Write(formula_3d)\n )\n self.play(Circumscribe(formula_3d, color=YELLOW, fade_out=True))\n \n # Add explanatory text boxes\n explanation1 = Text(\"Circumscription visualizes boundaries\").scale(0.7)\n explanation1.to_edge(DOWN)\n explanation2 = Text(\"Mathematical formulas describe these shapes\").scale(0.7)\n explanation2.next_to(explanation1, DOWN)\n \n self.play(FadeIn(explanation1))\n self.wait(0.5)\n self.play(FadeIn(explanation2))\n self.wait(1)\n \n # Coordinated fade out\n self.play(\n FadeOut(sphere),\n FadeOut(formula_3d),\n FadeOut(explanation1),\n FadeOut(explanation2),\n FadeOut(radius_line),\n FadeOut(radius_label)\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedCircumscribeAnimation(Scene):\n def construct(self):\n # Initial text setup\n title = Text(\"Circumscribe\").to_edge(UP)\n center_text = Text(\"Look Here\").scale(1.5)\n formula = MathTex(\"A = \\\\pi r^2\").next_to(center_text, DOWN, buff=1)\n\n # First animation: transform and fade in elements\n self.play(Write(title), FadeIn(center_text, shift=UP))\n self.wait(0.5)\n\n # Circumscribe animation with rectangle\n self.play(Circumscribe(center_text, color=YELLOW, fade_out=True))\n self.play(FadeIn(formula, shift=UP))\n self.wait(1)\n\n # Circular circumscribe and formula transformation\n self.play(Circumscribe(center_text, Circle, fade_out=True))\n \n # Create circle diagram\n circle = Circle(radius=1.5, color=BBLUE).next_to(formula, DOWN, buff=1)\n radius_line = Line(circle.get_center(), circle.get_right(), color=RED)\n radius_label = MathTex(\"r\").next_to(radius_line, UP)\n area_label = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n \n self.play(\n Transform(formula, area_label),\n Create(circle),\n Create(radius_line),\n Write(radius_label)\n )\n self.wait(1)\n\n # Fade out text and transform to 3D sphere\n self.play(\n FadeOut(center_text),\n FadeOut(title),\n circle.animate.scale(1.5).set_color(BLUE_E)\n )\n \n # Create 3D sphere\n sphere = Sphere(radius=1.5, resolution=(20, 20)).set_color(BLUE_E)\n sphere.move_to(circle)\n formula_3d = MathTex(\"A = 4\\\\pi r^2\").next_to(sphere, RIGHT, buff=1)\n \n self.play(\n ReplacementTransform(circle, sphere),\n Write(formula_3d)\n )\n self.play(Circumscribe(formula_3d, color=YELLOW, fade_out=True))\n \n # Add explanatory text boxes\n explanation1 = Text(\"Circumscription visualizes boundaries\").scale(0.7)\n explanation1.to_edge(DOWN)\n explanation2 = Text(\"Mathematical formulas describe these shapes\").scale(0.7)\n explanation2.next_to(explanation1, DOWN)\n \n self.play(FadeIn(explanation1))\n self.wait(0.5)\n self.play(FadeIn(explanation2))\n self.wait(1)\n \n # Coordinated fade out\n self.play(\n FadeOut(sphere),\n FadeOut(formula_3d),\n FadeOut(explanation1),\n FadeOut(explanation2),\n FadeOut(radius_line),\n FadeOut(radius_label)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(label_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Understanding Spark SQL and Stream Processing\nLearn to use Spark SQL for processing structured data, understand the principles of the Catalyst optimizer; master the basic stream processing models of Spark Streaming and Structured Streaming.\n\n\nContext location within the document (from highest to current level):\n# Spark Data Processing\n## Course Objectives\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SparkDataProcessing(Scene):\n\n def construct(self):\n title = Text('Spark SQL & Stream Processing', 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 header_left = Text('Spark SQL', font_size=28, color=BLUE, weight=BOLD)\n header_left.move_to(LEFT * 3.5 + UP * 1.5)\n t1 = Text('Structured Data', font_size=22)\n t2 = Text('Spark SQL Engine', font_size=22)\n t3 = Text('Catalyst Optimizer', font_size=22, color=YELLOW)\n r1 = SurroundingRectangle(t1, color=BLUE, buff=0.2)\n r2 = SurroundingRectangle(t2, color=BLUE, buff=0.2)\n r3 = SurroundingRectangle(t3, color=ORANGE, buff=0.2)\n g1 = VGroup(t1, r1)\n g2 = VGroup(t2, r2)\n g3 = VGroup(t3, r3)\n left_flow = VGroup(g1, g2, g3).arrange(DOWN, buff=0.8)\n left_flow.next_to(header_left, DOWN, buff=0.5)\n a1 = Arrow(g1.get_bottom(), g2.get_top(), buff=0.1)\n a2 = Arrow(g2.get_bottom(), g3.get_top(), buff=0.1)\n header_right = Text('Stream Processing', font_size=28, color=GREEN, weight=BOLD)\n header_right.move_to(RIGHT * 3.5 + UP * 1.5)\n s1 = Text('Data Stream', font_size=22)\n s2 = Text('Spark Streaming', font_size=22)\n s3 = Text('Structured Streaming', font_size=22, color=YELLOW)\n sr1 = SurroundingRectangle(s1, color=GREEN, buff=0.2)\n sr2 = SurroundingRectangle(s2, color=GREEN, buff=0.2)\n sr3 = SurroundingRectangle(s3, color=ORANGE, buff=0.2)\n sg1 = VGroup(s1, sr1)\n sg2 = VGroup(s2, sr2)\n sg3 = VGroup(s3, sr3)\n sg_models = VGroup(sg2, sg3).arrange(RIGHT, buff=0.4)\n sg1.next_to(header_right, DOWN, buff=0.5)\n sg_models.next_to(sg1, DOWN, buff=1.0)\n sa1 = Arrow(sg1.get_bottom(), sg2.get_top(), buff=0.1)\n sa2 = Arrow(sg1.get_bottom(), sg3.get_top(), buff=0.1)\n self.play(Write(header_left), Write(header_right), run_time=1)\n self.play(FadeIn(g1), FadeIn(sg1), run_time=1)\n self.play(GrowArrow(a1), GrowArrow(sa1), GrowArrow(sa2), run_time=0.8)\n self.play(FadeIn(g2), FadeIn(sg2), FadeIn(sg3), run_time=1)\n self.play(GrowArrow(a2), run_time=0.8)\n self.play(FadeIn(g3), run_time=1)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SparkDataProcessing(Scene):\n\n def construct(self):\n title = Text('Spark SQL & Stream Processing', 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 header_left = Text('Spark SQL', font_size=28, color=BBLUE, weight=BOLD)\n header_left.move_to(LEFT * 3.5 + UP * 1.5)\n t1 = Text('Structured Data', font_size=22)\n t2 = Text('Spark SQL Engine', font_size=22)\n t3 = Text('Catalyst Optimizer', font_size=22, color=YELLOW)\n r1 = SurroundingRectangle(t1, color=BLUE, buff=0.2)\n r2 = SurroundingRectangle(t2, color=BLUE, buff=0.2)\n r3 = SurroundingRectangle(t3, color=ORANGE, buff=0.2)\n g1 = VGroup(t1, r1)\n g2 = VGroup(t2, r2)\n g3 = VGroup(t3, r3)\n left_flow = VGroup(g1, g2, g3).arrange(DOWN, buff=0.8)\n left_flow.next_to(header_left, DOWN, buff=0.5)\n a1 = Arrow(g1.get_bottom(), g2.get_top(), buff=0.1)\n a2 = Arrow(g2.get_bottom(), g3.get_top(), buff=0.1)\n header_right = Text('Stream Processing', font_size=28, color=GREEN, weight=BOLD)\n header_right.move_to(RIGHT * 3.5 + UP * 1.5)\n s1 = Text('Data Stream', font_size=22)\n s2 = Text('Spark Streaming', font_size=22)\n s3 = Text('Structured Streaming', font_size=22, color=YELLOW)\n sr1 = SurroundingRectangle(s1, color=GREEN, buff=0.2)\n sr2 = SurroundingRectangle(s2, color=GREEN, buff=0.2)\n sr3 = SurroundingRectangle(s3, color=ORANGE, buff=0.2)\n sg1 = VGroup(s1, sr1)\n sg2 = VGroup(s2, sr2)\n sg3 = VGroup(s3, sr3)\n sg_models = VGroup(sg2, sg3).arrange(RIGHT, buff=0.4)\n sg1.next_to(header_right, DOWN, buff=0.5)\n sg_models.next_to(sg1, DOWN, buff=1.0)\n sa1 = Arrow(sg1.get_bottom(), sg2.get_top(), buff=0.1)\n sa2 = Arrow(sg1.get_bottom(), sg3.get_top(), buff=0.1)\n self.play(Write(header_left), Write(header_right), run_time=1)\n self.play(FadeIn(g1), FadeIn(sg1), run_time=1)\n self.play(GrowArrow(a1), GrowArrow(sa1), GrowArrow(sa2), run_time=0.8)\n self.play(FadeIn(g2), FadeIn(sg2), FadeIn(sg3), run_time=1)\n self.play(GrowArrow(a2), run_time=0.8)\n self.play(FadeIn(g3), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Riesz Representation Theorem be used to visually define and contrast dual spaces of L² versus L¹ spaces?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass RieszRepresentationTheoremVisualization(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Visualizing Dual Spaces: The Riesz Representation Theorem\", font_size=30)\n subtitle = Text(\"Functional Analysis\", font_size=24, color=YELLOW)\n \n # Position the title and subtitle\n title.move_to(UP)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Key Insight\n insight = Text(\"Dual spaces of L^2 and L¹ have different structures\", font_size=28)\n self.play(Write(insight))\n self.wait(1)\n self.play(FadeOut(insight))\n \n # Split screen setup\n l2_title = Text(\"L^2 Space\", font_size=24, color=BLUE)\n l1_title = Text(\"L¹ Space\", font_size=24, color=RED)\n \n # Position titles\n l2_title.to_corner(UP + LEFT)\n l1_title.to_corner(UP + RIGHT)\n \n # Display titles\n self.play(Write(l2_title), Write(l1_title))\n \n # Create a vertical line to divide the screen\n divider = Line(start=3.5 * UP, end=3.5 * DOWN)\n self.play(Create(divider))\n \n # L^2 representation\n # Create vectors to represent elements in L^2\n vector1 = Arrow(start=ORIGIN, end=[1, 1, 0], color=BLUE)\n vector2 = Arrow(start=ORIGIN, end=[-1, 1, 0], color=BLUE_A)\n \n # Position in left half\n vector1.shift(3 * LEFT + DOWN)\n vector2.shift(3 * LEFT + DOWN)\n \n # Display vectors\n self.play(Create(vector1))\n self.play(Create(vector2))\n \n # L¹ representation\n # Create curves to represent functions in L¹\n curve1 = FunctionGraph(lambda x: 0.5 * np.sin(x) + 0.5, x_range=[-3, 3], color=RED)\n curve2 = FunctionGraph(lambda x: 0.5 * np.cos(x) - 0.5, x_range=[-3, 3], color=RED_A)\n \n # Position in right half\n curve1.shift(3 * RIGHT + 0.5 * UP)\n curve2.shift(3 * RIGHT + 0.5 * DOWN)\n \n # Scale curves to fit\n curve1.scale(0.5)\n curve2.scale(0.5)\n \n # Display curves\n self.play(Create(curve1))\n self.play(Create(curve2))\n \n # Animate L^2 inner product\n inner_product_text = Text(\"Inner Product in L^2\", font_size=20, color=BLUE)\n inner_product_text.next_to(vector1, DOWN)\n \n # Equation for L^2 inner product - simplified\n eq_l2 = Text(\" = integral f(x)g(x) dx\", font_size=18, color=BLUE)\n eq_l2.next_to(inner_product_text, DOWN)\n \n self.play(Write(inner_product_text))\n self.play(Write(eq_l2))\n \n # Animate alignment of vectors in L^2\n self.play(Rotate(vector2, about_point=vector1.get_end(), angle=PI/4))\n \n # Highlight the alignment with a circle\n circle = Circle(radius=0.3, color=YELLOW)\n circle.move_to(vector1.get_end())\n self.play(Create(circle))\n self.play(FadeOut(circle))\n \n # Animate L¹ dual space\n dual_l1_text = Text(\"Dual Space of L¹\", font_size=20, color=RED)\n dual_l1_text.next_to(curve1, DOWN)\n \n # Equation for L¹ dual - simplified\n eq_l1 = Text(\"T in (L¹)* -> g in L\\infty \", font_size=18, color=RED)\n eq_l1.next_to(dual_l1_text, DOWN)\n \n self.play(Write(dual_l1_text))\n self.play(Write(eq_l1))\n \n # Animate chaos in L¹\n # Create multiple curves to show chaotic nature\n curves = []\n for i in range(5):\n curve = FunctionGraph(\n lambda x: 0.2 * np.sin(x + i) + 0.2 * i - 0.5,\n x_range=[-2, 2],\n color=RED\n )\n curve.scale(0.4)\n curve.shift(3 * RIGHT)\n curves.append(curve)\n \n # Create and fade out curves in sequence\n for curve in curves:\n self.play(Create(curve), run_time=0.3)\n for curve in curves:\n self.play(FadeOut(curve), run_time=0.2)\n \n # Conclusion\n self.play(\n FadeOut(vector1),\n FadeOut(vector2),\n FadeOut(curve1),\n FadeOut(curve2),\n FadeOut(inner_product_text),\n FadeOut(dual_l1_text),\n FadeOut(eq_l2),\n FadeOut(eq_l1),\n FadeOut(l2_title),\n FadeOut(l1_title),\n FadeOut(divider)\n )\n \n conclusion = Text(\"The Riesz Representation Theorem reveals\\nthe elegant structure of dual spaces\",\n font_size=28)\n \n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass RieszRepresentationTheoremVisualization(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Visualizing Dual Spaces: The Riesz Representation Theorem\", font_size=30)\n subtitle = Text(\"Functional Analysis\", font_size=24, color=YELLOW)\n \n # Position the title and subtitle\n title.move_to(UP)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Key Insight\n insight = Text(\"Dual spaces of L^2 and L¹ have different structures\", font_size=28)\n self.play(Write(insight))\n self.wait(1)\n self.play(FadeOut(insight))\n \n # Split screen setup\n l2_title = Text(\"L^2 Space\", font_size=24, color=BBLUE)\n l1_title = Text(\"L¹ Space\", font_size=24, color=RED)\n \n # Position titles\n l2_title.to_corner(UP + LEFT)\n l1_title.to_corner(UP + RIGHT)\n \n # Display titles\n self.play(Write(l2_title), Write(l1_title))\n \n # Create a vertical line to divide the screen\n divider = Line(start=3.5 * UP, end=3.5 * DOWN)\n self.play(Create(divider))\n \n # L^2 representation\n # Create vectors to represent elements in L^2\n vector1 = Arrow(start=ORIGIN, end=[1, 1, 0], color=BLUE)\n vector2 = Arrow(start=ORIGIN, end=[-1, 1, 0], color=BLUE_A)\n \n # Position in left half\n vector1.shift(3 * LEFT + DOWN)\n vector2.shift(3 * LEFT + DOWN)\n \n # Display vectors\n self.play(Create(vector1))\n self.play(Create(vector2))\n \n # L¹ representation\n # Create curves to represent functions in L¹\n curve1 = FunctionGraph(lambda x: 0.5 * np.sin(x) + 0.5, x_range=[-3, 3], color=RED)\n curve2 = FunctionGraph(lambda x: 0.5 * np.cos(x) - 0.5, x_range=[-3, 3], color=RED_A)\n \n # Position in right half\n curve1.shift(3 * RIGHT + 0.5 * UP)\n curve2.shift(3 * RIGHT + 0.5 * DOWN)\n \n # Scale curves to fit\n curve1.scale(0.5)\n curve2.scale(0.5)\n \n # Display curves\n self.play(Create(curve1))\n self.play(Create(curve2))\n \n # Animate L^2 inner product\n inner_product_text = Text(\"Inner Product in L^2\", font_size=20, color=BLUE)\n inner_product_text.next_to(vector1, DOWN)\n \n # Equation for L^2 inner product - simplified\n eq_l2 = Text(\" = integral f(x)g(x) dx\", font_size=18, color=BLUE)\n eq_l2.next_to(inner_product_text, DOWN)\n \n self.play(Write(inner_product_text))\n self.play(Write(eq_l2))\n \n # Animate alignment of vectors in L^2\n self.play(Rotate(vector2, about_point=vector1.get_end(), angle=PI/4))\n \n # Highlight the alignment with a circle\n circle = Circle(radius=0.3, color=YELLOW)\n circle.move_to(vector1.get_end())\n self.play(Create(circle))\n self.play(FadeOut(circle))\n \n # Animate L¹ dual space\n dual_l1_text = Text(\"Dual Space of L¹\", font_size=20, color=RED)\n dual_l1_text.next_to(curve1, DOWN)\n \n # Equation for L¹ dual - simplified\n eq_l1 = Text(\"T in (L¹)* -> g in L\\infty \", font_size=18, color=RED)\n eq_l1.next_to(dual_l1_text, DOWN)\n \n self.play(Write(dual_l1_text))\n self.play(Write(eq_l1))\n \n # Animate chaos in L¹\n # Create multiple curves to show chaotic nature\n curves = []\n for i in range(5):\n curve = FunctionGraph(\n lambda x: 0.2 * np.sin(x + i) + 0.2 * i - 0.5,\n x_range=[-2, 2],\n color=RED\n )\n curve.scale(0.4)\n curve.shift(3 * RIGHT)\n curves.append(curve)\n \n # Create and fade out curves in sequence\n for curve in curves:\n self.play(Create(curve), run_time=0.3)\n for curve in curves:\n self.play(FadeOut(curve), run_time=0.2)\n \n # Conclusion\n self.play(\n FadeOut(vector1),\n FadeOut(vector2),\n FadeOut(curve1),\n FadeOut(curve2),\n FadeOut(inner_product_text),\n FadeOut(dual_l1_text),\n FadeOut(eq_l2),\n FadeOut(eq_l1),\n FadeOut(l2_title),\n FadeOut(l1_title),\n FadeOut(divider)\n )\n \n conclusion = Text(\"The Riesz Representation Theorem reveals\\nthe elegant structure of dual spaces\",\n font_size=28)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 educational animation that helps visualize the process of calculating a definite integral, specifically for the integral of x cubed from 0 to 3. The animation should start by displaying the integral problem, followed by an explanation and demonstration of the power rule for integration. Then it should show the step where the power rule is applied to the initial problem, evaluate the integral at the upper and lower bounds, simplify the result, and then conclude by clearly presenting the final simplified solution. Can the demonstration be paced with pauses between steps, and include written explanations before each mathematical step?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Initial Problem ---\n title = Text(\"Calculating a Definite Integral\", font_size=36)\n title.to_edge(UP)\n \n initial_integral = MathTex(r\"\\int_0^3\", r\"x^3\", r\"\\, dx\", font_size=48)\n initial_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 2: Explain the Power Rule ---\n rule_text = Text(\"Recall the Power Rule for Integration:\", font_size=28)\n rule_text.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(Write(rule_text))\n self.wait(1)\n \n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40)\n power_rule.next_to(rule_text, DOWN, buff=0.5)\n \n self.play(Write(power_rule))\n self.wait(3)\n \n # --- Step 3: Apply the Power Rule ---\n apply_text = Text(\"Apply the rule to $x^3$ (where $n=3$):\", font_size=28)\n apply_text.next_to(power_rule, DOWN, buff=0.8)\n \n self.play(Write(apply_text))\n self.wait(1)\n \n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^3\", font_size=48)\n antiderivative.move_to(initial_integral)\n \n # Clear explanation texts to keep focus on the math\n self.play(\n FadeOut(title),\n FadeOut(rule_text),\n FadeOut(power_rule),\n FadeOut(apply_text)\n )\n self.play(ReplacementTransform(initial_integral, antiderivative))\n self.wait(2)\n \n # --- Step 4: Evaluate at Bounds ---\n eval_text = Text(\"Evaluate at the upper and lower bounds:\", font_size=28)\n eval_text.next_to(antiderivative, DOWN, buff=0.8)\n \n self.play(Write(eval_text))\n self.wait(1)\n \n substitution = MathTex(r\"\\frac{3^4}{4} - \\frac{0^4}{4}\", font_size=48)\n substitution.next_to(eval_text, DOWN, buff=0.5)\n \n self.play(Write(substitution))\n self.wait(2)\n \n # --- Step 5: Simplify the Arithmetic ---\n simplify_text = Text(\"Simplify the arithmetic:\", font_size=28)\n simplify_text.next_to(substitution, DOWN, buff=0.8)\n \n self.play(Write(simplify_text))\n self.wait(1)\n \n calculation = MathTex(r\"\\frac{81}{4} - 0\", font_size=48)\n calculation.next_to(simplify_text, DOWN, buff=0.5)\n \n self.play(Write(calculation))\n self.wait(2)\n \n # --- Step 6: Final Solution ---\n final_text = Text(\"Final Solution\", font_size=32, color=GREEN)\n final_text.to_edge(UP)\n \n final_result = MathTex(r\"\\frac{81}{4}\", font_size=60, color=YELLOW)\n final_result.move_to(antiderivative)\n \n # Clear previous steps for an impactful conclusion\n self.play(\n FadeOut(eval_text),\n FadeOut(substitution),\n FadeOut(simplify_text),\n FadeOut(calculation),\n FadeOut(antiderivative)\n )\n self.play(Write(final_text))\n self.play(Write(final_result))\n self.wait(1)\n \n # Highlight the final result\n box = SurroundingRectangle(final_result, color=BLUE, buff=0.3)\n self.play(Create(box))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Initial Problem ---\n title = Text(\"Calculating a Definite Integral\", font_size=36)\n title.to_edge(UP)\n \n initial_integral = MathTex(r\"\\int_0^3\", r\"x^3\", r\"\\, dx\", font_size=48)\n initial_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(title))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 2: Explain the Power Rule ---\n rule_text = Text(\"Recall the Power Rule for Integration:\", font_size=28)\n rule_text.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(Write(rule_text))\n self.wait(1)\n \n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40)\n power_rule.next_to(rule_text, DOWN, buff=0.5)\n \n self.play(Write(power_rule))\n self.wait(3)\n \n # --- Step 3: Apply the Power Rule ---\n apply_text = Text(\"Apply the rule to $x^3$ (where $n=3$):\", font_size=28)\n apply_text.next_to(power_rule, DOWN, buff=0.8)\n \n self.play(Write(apply_text))\n self.wait(1)\n \n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^3\", font_size=48)\n antiderivative.move_to(initial_integral)\n \n # Clear explanation texts to keep focus on the math\n self.play(\n FadeOut(title),\n FadeOut(rule_text),\n FadeOut(power_rule),\n FadeOut(apply_text)\n )\n self.play(ReplacementTransform(initial_integral, antiderivative))\n self.wait(2)\n \n # --- Step 4: Evaluate at Bounds ---\n eval_text = Text(\"Evaluate at the upper and lower bounds:\", font_size=28)\n eval_text.next_to(antiderivative, DOWN, buff=0.8)\n \n self.play(Write(eval_text))\n self.wait(1)\n \n substitution = MathTex(r\"\\frac{3^4}{4} - \\frac{0^4}{4}\", font_size=48)\n substitution.next_to(eval_text, DOWN, buff=0.5)\n \n self.play(Write(substitution))\n self.wait(2)\n \n # --- Step 5: Simplify the Arithmetic ---\n simplify_text = Text(\"Simplify the arithmetic:\", font_size=28)\n simplify_text.next_to(substitution, DOWN, buff=0.8)\n \n self.play(Write(simplify_text))\n self.wait(1)\n \n calculation = MathTex(r\"\\frac{81}{4} - 0\", font_size=48)\n calculation.next_to(simplify_text, DOWN, buff=0.5)\n \n self.play(Write(calculation))\n self.wait(2)\n \n # --- Step 6: Final Solution ---\n final_text = Text(\"Final Solution\", font_size=32, color=GREEN)\n final_text.to_edge(UP)\n \n final_result = MathTex(r\"\\frac{81}{4}\", font_size=60, color=YELLOW)\n final_result.move_to(antiderivative)\n \n # Clear previous steps for an impactful conclusion\n self.play(\n FadeOut(eval_text),\n FadeOut(substitution),\n FadeOut(simplify_text),\n FadeOut(calculation),\n FadeOut(antiderivative)\n )\n self.play(Write(final_text))\n self.play(Write(final_result))\n self.wait(1)\n \n # Highlight the final result\n box = SurroundingRectangle(final_result, color=BBLUE, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 green line while adding significant new features: \n\nThe animation begins by drawing a vibrant green line from (-3, -2) to (3, 2) in a smooth, continuous motion. As the line completes, a coordinate system fades in, with labeled x and y axes to provide spatial context. Simultaneously, the parametric equation of the line, \\( y = \\frac{2}{3}x \\), appears above it in a matching green color, reinforcing the mathematical relationship. The line then transforms dynamically into a vector arrow, with its components (6 units in x, 4 units in y) displayed as dashed construction lines, illustrating the underlying displacement. Finally, the scene highlights the slope of the line with a right triangle animation, where the rise and run are labeled, and the angle of inclination is calculated and displayed in degrees. This enriched visualization not only shows the line but also teaches key concepts of linear equations, vectors, and trigonometry in a cohesive sequence.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedLineAnimation(Scene):\n def construct(self):\n # Create the green line\n line = Line(start=(-3, -2, 0), end=(3, 2, 0), color=GREEN)\n \n # Animate the line drawing\n self.play(Create(line), run_time=2)\n self.wait(0.5)\n \n # Add coordinate axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BLUE},\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 # Fade in axes\n self.play(FadeIn(axes), Write(axes_labels), run_time=1.5)\n self.wait(0.5)\n \n # Display the equation\n equation = MathTex(\"y = \\\\frac{2}{3}x\", color=GREEN).to_edge(UP)\n self.play(Write(equation))\n self.wait(1)\n \n # Transform line into a vector arrow\n vector = Arrow(start=(-3, -2, 0), end=(3, 2, 0), color=GREEN, buff=0)\n self.play(Transform(line, vector))\n self.wait(0.5)\n \n # Show vector components\n x_component = DashedLine(start=(-3, -2, 0), end=(3, -2, 0), color=RED)\n y_component = DashedLine(start=(3, -2, 0), end=(3, 2, 0), color=BLUE)\n component_labels = VGroup(\n MathTex(\"\\\\Delta x = 6\", color=RED).next_to(x_component, DOWN),\n MathTex(\"\\\\Delta y = 4\", color=BLUE).next_to(y_component, RIGHT)\n )\n \n self.play(\n Create(x_component),\n Create(y_component),\n Write(component_labels),\n run_time=1.5\n )\n self.wait(1)\n \n # Highlight slope with a right triangle\n triangle = Polygon(\n [-3, -2, 0],\n [3, -2, 0],\n [3, 2, 0],\n color=YELLOW,\n fill_opacity=0.3,\n stroke_width=2\n )\n slope_label = MathTex(\"\\\\text{Slope} = \\\\frac{\\\\Delta y}{\\\\Delta x} = \\\\frac{2}{3}\", color=YELLOW)\n slope_label.next_to(triangle, LEFT)\n \n angle = Angle(Line(start=[3, -2, 0], end=[0, -2, 0]), Line(start=[3, -2, 0], end=[3, 2, 0]), radius=0.8)\n angle_label = MathTex(\"\\\\theta = \\\\arctan\\\\left(\\\\frac{2}{3}\\\\right) \\\\approx 33.69^\\\\circ\", color=YELLOW)\n angle_label.next_to(angle, DOWN)\n \n self.play(\n Create(triangle),\n Write(slope_label),\n run_time=1.5\n )\n self.wait(0.5)\n \n self.play(\n Create(angle),\n Write(angle_label),\n run_time=1.5\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedLineAnimation(Scene):\n def construct(self):\n # Create the green line\n line = Line(start=(-3, -2, 0), end=(3, 2, 0), color=GREEN)\n \n # Animate the line drawing\n self.play(Create(line), run_time=2)\n self.wait(0.5)\n \n # Add coordinate axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-3, 3, 1],\n axis_config={\"color\": BBLUE},\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 # Fade in axes\n self.play(FadeIn(axes), Write(axes_labels), run_time=1.5)\n self.wait(0.5)\n \n # Display the equation\n equation = MathTex(\"y = \\\\frac{2}{3}x\", color=GREEN).to_edge(UP)\n self.play(Write(equation))\n self.wait(1)\n \n # Transform line into a vector arrow\n vector = Arrow(start=(-3, -2, 0), end=(3, 2, 0), color=GREEN, buff=0)\n self.play(Transform(line, vector))\n self.wait(0.5)\n \n # Show vector components\n x_component = DashedLine(start=(-3, -2, 0), end=(3, -2, 0), color=RED)\n y_component = DashedLine(start=(3, -2, 0), end=(3, 2, 0), color=BLUE)\n component_labels = VGroup(\n MathTex(\"\\\\Delta x = 6\", color=RED).next_to(x_component, DOWN),\n MathTex(\"\\\\Delta y = 4\", color=BLUE).next_to(y_component, RIGHT)\n )\n \n self.play(\n Create(x_component),\n Create(y_component),\n Write(component_labels),\n run_time=1.5\n )\n self.wait(1)\n \n # Highlight slope with a right triangle\n triangle = Polygon(\n [-3, -2, 0],\n [3, -2, 0],\n [3, 2, 0],\n color=YELLOW,\n fill_opacity=0.3,\n stroke_width=2\n )\n slope_label = MathTex(\"\\\\text{Slope} = \\\\frac{\\\\Delta y}{\\\\Delta x} = \\\\frac{2}{3}\", color=YELLOW)\n slope_label.next_to(triangle, LEFT)\n \n angle = Angle(Line(start=[3, -2, 0], end=[0, -2, 0]), Line(start=[3, -2, 0], end=[3, 2, 0]), radius=0.8)\n angle_label = MathTex(\"\\\\theta = \\\\arctan\\\\left(\\\\frac{2}{3}\\\\right) \\\\approx 33.69^\\\\circ\", color=YELLOW)\n angle_label.next_to(angle, DOWN)\n \n self.play(\n Create(triangle),\n Write(slope_label),\n run_time=1.5\n )\n self.wait(0.5)\n \n self.play(\n Create(angle),\n Write(angle_label),\n 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # ------------------------------------------------------------------\n # 1. Initial Scene Setup\n # ------------------------------------------------------------------\n \n # Create axes with appropriate range, shifting down to make room for equations\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Plot the function f(x) = x^2 in blue across the full axis range\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-3, 3])\n \n # Initial integral equation positioned next to the graph\n integral_eq = MathTex(\n r\"\\int_{-2}^{2} x^2 \\, dx\", \n font_size=40\n ).next_to(axes, RIGHT, buff=1).shift(UP * 2)\n \n # Animate the creation of the initial scene elements\n self.play(Create(axes), Write(labels), Create(graph), Write(integral_eq))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Animation Sequence\n # ------------------------------------------------------------------\n \n # Step 1: Equation Movement\n # Move the integral equation to the top of the screen\n self.play(integral_eq.animate.to_edge(UP, buff=0.5))\n \n # Step 2: Area Shading\n # Shade the area under the curve from x = -2 to x = 2 in blue\n area = axes.get_area(graph, x_range=(-2, 2), color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n \n # Step 3: Step-by-Step Calculation\n # Each step replaces the previous one clearly below the moved equation\n \n # Antiderivative step\n step1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Evaluation at boundaries step\n step2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Simplification step\n step3 = MathTex(\n r\"= \\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Final result step\n step4 = MathTex(\n r\"= \\frac{16}{3}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Animate each calculation step replacing the previous one\n self.play(Write(step1))\n self.wait(1)\n \n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 4. Final Emphasis\n # ------------------------------------------------------------------\n \n # Clear all content from the screen except the final solution\n self.play(\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(graph),\n FadeOut(area),\n FadeOut(integral_eq)\n )\n \n # Emphasize the final solution distinctly by moving it to the center and scaling it up\n self.play(\n step4.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Add a highlight box around the final result\n highlight_box = SurroundingRectangle(step4, color=YELLOW, buff=0.3)\n self.play(Create(highlight_box))\n \n # Hold on final result\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Scene Setup\n # ------------------------------------------------------------------\n \n # Create axes with appropriate range, shifting down to make room for equations\n axes = Axes(label_font_size=24, \n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).shift(DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n # Plot the function f(x) = x^2 in blue across the full axis range\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-3, 3])\n \n # Initial integral equation positioned next to the graph\n integral_eq = MathTex(\n r\"\\int_{-2}^{2} x^2 \\, dx\", \n font_size=40\n ).next_to(axes, RIGHT, buff=1).shift(UP * 2)\n \n # Animate the creation of the initial scene elements\n self.play(Create(axes), Write(labels), Create(graph), Write(integral_eq))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 2. Animation Sequence\n # ------------------------------------------------------------------\n \n # Step 1: Equation Movement\n # Move the integral equation to the top of the screen\n self.play(integral_eq.animate.to_edge(UP, buff=0.5))\n \n # Step 2: Area Shading\n # Shade the area under the curve from x = -2 to x = 2 in blue\n area = axes.get_area(graph, x_range=(-2, 2), color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n \n # Step 3: Step-by-Step Calculation\n # Each step replaces the previous one clearly below the moved equation\n \n # Antiderivative step\n step1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Evaluation at boundaries step\n step2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Simplification step\n step3 = MathTex(\n r\"= \\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Final result step\n step4 = MathTex(\n r\"= \\frac{16}{3}\", \n font_size=40\n ).next_to(integral_eq, DOWN, buff=0.5).align_to(integral_eq, LEFT)\n \n # Animate each calculation step replacing the previous one\n self.play(Write(step1))\n self.wait(1)\n \n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 4. Final Emphasis\n # ------------------------------------------------------------------\n \n # Clear all content from the screen except the final solution\n self.play(\n FadeOut(axes),\n FadeOut(labels),\n FadeOut(graph),\n FadeOut(area),\n FadeOut(integral_eq)\n )\n \n # Emphasize the final solution distinctly by moving it to the center and scaling it up\n self.play(\n step4.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Add a highlight box around the final result\n highlight_box = SurroundingRectangle(step4, color=YELLOW, buff=0.3)\n self.play(Create(highlight_box))\n \n # Hold on final result\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 inserting elements into an AVL tree to maintain its balance, with pauses between each insertion to clearly see the tree structure?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass TaylorSeriesApproximation(Scene):\n def construct(self):\n # Display the function to be approximated\n function_tex = MathTex(r\"f(x) = e^x\").to_edge(UP)\n self.play(Write(function_tex))\n self.wait(1)\n\n # Show the Taylor series approximation text\n approx_text = Tex(\n \"Taylor series approximation of \", r\"$f(x)$\", r\" up to nth term:\",\n font_size=24\n ).next_to(function_tex, DOWN)\n self.play(Write(approx_text))\n self.wait(2)\n\n # Taylor series up to 4 terms\n taylor = MathTex(\n r\"f(x) \\approx 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\"\n )\n self.play(Write(taylor))\n self.wait(2)\n\n # Show the Taylor polynomial of degree 4\n taylor_polynomial = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\"\n ).next_to(taylor, DOWN)\n self.play(Transform(taylor, taylor_polynomial))\n self.wait(2)\n\n # Graph f(x) and P_4(x)\n graph_group = VGroup()\n axes = Axes(\n x_range=[-2, 2],\n y_range=[0, 6],\n axis_config={\"color\": BLUE},\n ).to_edge(DOWN)\n\n exp_function = axes.plot(lambda x: np.exp(x), color=GREEN)\n taylor_graph = axes.plot(lambda x: 1 + x + x**2/2 + x**3/6 + x**4/24, color=YELLOW)\n\n original_graph_label = axes.get_graph_label(exp_function, label='f(x)=e^x')\n taylor_graph_label = axes.get_graph_label(taylor_graph, label='P_4(x)', x_val=2, direction=UP)\n\n graph_group.add(axes, exp_function, taylor_graph, original_graph_label, taylor_graph_label)\n self.play(FadeIn(graph_group))\n self.wait(2)\n\n # Clear the scene and present only the graphs\n self.play(FadeOut(taylor_polynomial), FadeOut(approx_text), FadeOut(function_tex))\n self.wait(3)\n\n # Highlight the difference in a certain interval\n interval_highlight = axes.get_riemann_rectangles(exp_function, x_range=[-1, 1], dx=0.1)\n self.play(Create(interval_highlight))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass TaylorSeriesApproximation(Scene):\n def construct(self):\n # Display the function to be approximated\n function_tex = MathTex(r\"f(x) = e^x\").to_edge(UP)\n self.play(Write(function_tex))\n self.wait(1)\n\n # Show the Taylor series approximation text\n approx_text = Tex(\n \"Taylor series approximation of \", r\"$f(x)$\", r\" up to nth term:\",\n font_size=24\n ).next_to(function_tex, DOWN)\n self.play(Write(approx_text))\n self.wait(2)\n\n # Taylor series up to 4 terms\n taylor = MathTex(\n r\"f(x) \\approx 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\"\n )\n self.play(Write(taylor))\n self.wait(2)\n\n # Show the Taylor polynomial of degree 4\n taylor_polynomial = MathTex(\n r\"P_4(x) = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\frac{x^4}{4!}\"\n ).next_to(taylor, DOWN)\n self.play(Transform(taylor, taylor_polynomial))\n self.wait(2)\n\n # Graph f(x) and P_4(x)\n graph_group = VGroup()\n axes = Axes(label_font_size=24, \n x_range=[-2, 2],\n y_range=[0, 6],\n axis_config={\"color\": BLUE},\n ).to_edge(DOWN)\n\n exp_function = axes.plot(lambda x: np.exp(x), color=GREEN)\n taylor_graph = axes.plot(lambda x: 1 + x + x**2/2 + x**3/6 + x**4/24, color=YELLOW)\n\n original_graph_label = axes.get_graph_label(exp_function, label='f(x)=e^x')\n taylor_graph_label = axes.get_graph_label(taylor_graph, label='P_4(x)', x_val=2, direction=UP)\n\n graph_group.add(axes, exp_function, taylor_graph, original_graph_label, taylor_graph_label)\n self.play(FadeIn(graph_group))\n self.wait(2)\n\n # Clear the scene and present only the graphs\n self.play(FadeOut(taylor_polynomial), FadeOut(approx_text), FadeOut(function_tex))\n self.wait(3)\n\n # Highlight the difference in a certain interval\n interval_highlight = axes.get_riemann_rectangles(exp_function, x_range=[-1, 1], dx=0.1)\n self.play(Create(interval_highlight))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\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(MathText(\"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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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_names = [\"Input Layer\", \"Hidden Layer (ReLU)\", \"Output Layer (Sigmoid)\"]\n layer_colors = [BLUE, GREEN, RED]\n \n signal_color = YELLOW\n edge_color = WHITE\n \n # --- Create Neurons ---\n layers = VGroup()\n for i, size in enumerate(layer_sizes):\n layer = VGroup(*[\n Circle(radius=0.2, color=layer_colors[i], fill_opacity=0.3) \n for _ in range(size)\n ])\n # Adjust vertical spacing for the larger hidden layer\n buff = 0.35 if size == 8 else 0.6\n layer.arrange(DOWN, buff=buff)\n layers.add(layer)\n \n # Arrange layers horizontally\n layers.arrange(RIGHT, buff=2.5)\n \n # --- Create Connections ---\n all_edges = VGroup()\n for i in range(len(layer_sizes) - 1):\n layer_edges = VGroup()\n for n1 in layers[i]:\n for n2 in layers[i+1]:\n edge = Line(\n n1.get_right(), n2.get_left(), \n stroke_width=1, color=edge_color, stroke_opacity=0.3\n )\n layer_edges.add(edge)\n all_edges.add(layer_edges)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, name in enumerate(layer_names):\n label = Text(name, font_size=24, color=layer_colors[i])\n label.next_to(layers[i], UP, buff=0.5)\n labels.add(label)\n \n title = Text(\"Feedforward Neural Network\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n \n # 1. Draw Structure\n self.play(Write(title))\n self.play(\n FadeIn(layers), \n Write(labels),\n run_time=1.5\n )\n self.play(Create(all_edges), run_time=1.5)\n self.wait(0.5)\n \n # 2. Activate Input Layer\n self.play(\n *[layers[0][j].animate.set_fill(signal_color, opacity=0.8) for j in range(layer_sizes[0])],\n run_time=0.5\n )\n \n # 3. Forward Pass: Input -> Hidden\n self.animate_layer_flow(layers, all_edges, 0, signal_color)\n \n # 4. Forward Pass: Hidden -> Output\n self.animate_layer_flow(layers, all_edges, 1, signal_color)\n \n self.wait(2)\n \n # 5. Reset colors for loopability\n self.play(\n *[layers[i][j].animate.set_fill(layer_colors[i], opacity=0.3) \n for i in range(len(layer_sizes)) for j in range(layer_sizes[i])]\n )\n self.wait(0.5)\n\n def animate_layer_flow(self, layers, all_edges, layer_idx, signal_color):\n \"\"\"Animates signals moving from one layer to the next and activates the receiving neurons.\"\"\"\n edges = all_edges[layer_idx]\n \n # Create signal dots\n signals = VGroup()\n for edge in edges:\n dot = Dot(radius=0.06, color=signal_color)\n dot.move_to(edge.get_start())\n signals.add(dot)\n \n self.add(signals)\n \n # Animate signals moving along edges\n self.play(\n *[MoveAlongPath(dot, edge) for dot, edge in zip(signals, edges)],\n run_time=1.5,\n rate_func=linear\n )\n \n # Activate receiving neurons\n self.play(\n *[layers[layer_idx+1][j].animate.set_fill(signal_color, opacity=0.8) \n for j in range(len(layers[layer_idx+1]))],\n run_time=0.3\n )\n \n # Fade out signals\n self.play(FadeOut(signals), run_time=0.3)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n layer_sizes = [4, 8, 2]\n layer_names = [\"Input Layer\", \"Hidden Layer (ReLU)\", \"Output Layer (Sigmoid)\"]\n layer_colors = [BBLUE, GREEN, RED]\n \n signal_color = YELLOW\n edge_color = WHITE\n \n # --- Create Neurons ---\n layers = VGroup()\n for i, size in enumerate(layer_sizes):\n layer = VGroup(*[\n Circle(radius=0.2, color=layer_colors[i], fill_opacity=0.3) \n for _ in range(size)\n ])\n # Adjust vertical spacing for the larger hidden layer\n buff = 0.35 if size == 8 else 0.6\n layer.arrange(DOWN, buff=buff)\n layers.add(layer)\n \n # Arrange layers horizontally\n layers.arrange(RIGHT, buff=2.5)\n \n # --- Create Connections ---\n all_edges = VGroup()\n for i in range(len(layer_sizes) - 1):\n layer_edges = VGroup()\n for n1 in layers[i]:\n for n2 in layers[i+1]:\n edge = Line(\n n1.get_right(), n2.get_left(), \n stroke_width=1, color=edge_color, stroke_opacity=0.3\n )\n layer_edges.add(edge)\n all_edges.add(layer_edges)\n \n # --- Create Labels ---\n labels = VGroup()\n for i, name in enumerate(layer_names):\n label = Text(name, font_size=24, color=layer_colors[i])\n label.next_to(layers[i], UP, buff=0.5)\n labels.add(label)\n \n title = Text(\"Feedforward Neural Network\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n \n # 1. Draw Structure\n self.play(Write(title))\n self.play(\n FadeIn(layers), \n Write(labels),\n run_time=1.5\n )\n self.play(Create(all_edges), run_time=1.5)\n self.wait(0.5)\n \n # 2. Activate Input Layer\n self.play(\n *[layers[0][j].animate.set_fill(signal_color, opacity=0.8) for j in range(layer_sizes[0])],\n run_time=0.5\n )\n \n # 3. Forward Pass: Input -> Hidden\n self.animate_layer_flow(layers, all_edges, 0, signal_color)\n \n # 4. Forward Pass: Hidden -> Output\n self.animate_layer_flow(layers, all_edges, 1, signal_color)\n \n self.wait(2)\n \n # 5. Reset colors for loopability\n self.play(\n *[layers[i][j].animate.set_fill(layer_colors[i], opacity=0.3) \n for i in range(len(layer_sizes)) for j in range(layer_sizes[i])]\n )\n self.wait(0.5)\n\n def animate_layer_flow(self, layers, all_edges, layer_idx, signal_color):\n \"\"\"Animates signals moving from one layer to the next and activates the receiving neurons.\"\"\"\n edges = all_edges[layer_idx]\n \n # Create signal dots\n signals = VGroup()\n for edge in edges:\n dot = Dot(radius=0.06, color=signal_color)\n dot.move_to(edge.get_start())\n signals.add(dot)\n \n self.add(signals)\n \n # Animate signals moving along edges\n self.play(\n *[MoveAlongPath(dot, edge) for dot, edge in zip(signals, edges)],\n run_time=1.5,\n rate_func=linear\n )\n \n # Activate receiving neurons\n self.play(\n *[layers[layer_idx+1][j].animate.set_fill(signal_color, opacity=0.8) \n for j in range(len(layers[layer_idx+1]))],\n run_time=0.3\n )\n \n # Fade out signals\n self.play(FadeOut(signals), run_time=0.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### LRU Algorithm\n- Based on the idea that \"the past approximates the future,\" it evicts the page that has been least recently used, achieving performance close to OPT.\n- A strict implementation requires hardware support (such as timestamps or stacks), and due to high overhead, general-purpose operating systems rarely adopt it directly.\n\n\nThe context of this section (from highest to current level):\n# Advanced Memory Management and Virtual Memory Implementation\n## Common Page Replacement Algorithms\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass LRUAlgorithm(Scene):\n\n def construct(self):\n title = Text('LRU Algorithm', 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 pt1 = Text('- Idea: Past approximates the future', font_size=24)\n pt2 = Text('- Evicts the least recently used page', font_size=24)\n pt3 = Text('- Performance is close to OPT', font_size=24)\n pt4 = Text('- Requires hardware support (e.g., stacks)', font_size=24)\n pt5 = Text('- High overhead, rarely used directly in OS', font_size=24)\n pts = VGroup(pt1, pt2, pt3, pt4, pt5).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n pts.next_to(title_group, DOWN, buff=1.0).to_edge(LEFT, buff=0.8)\n stack_title = Text('Hardware Stack', font_size=24, color=YELLOW)\n pages = ['Page B', 'Page D', 'Page C', 'Page A']\n stack_elements = VGroup()\n for p in pages:\n txt = Text(p, font_size=20)\n rect = SurroundingRectangle(txt, color=BLUE, buff=0.15)\n stack_elements.add(VGroup(txt, rect))\n else:\n pass\n stack_elements.arrange(DOWN, buff=0.1)\n stack_group = VGroup(stack_title, stack_elements).arrange(DOWN, buff=0.4)\n stack_group.next_to(title_group, DOWN, buff=1.0).to_edge(RIGHT, buff=2.0)\n mru_label = Text('MRU', font_size=20, color=GREEN).next_to(stack_elements[0], RIGHT, buff=0.3)\n lru_label = Text('LRU', font_size=20, color=RED).next_to(stack_elements[-1], RIGHT, buff=0.3)\n self.play(Write(pt1), Write(pt2), run_time=1.5)\n self.play(Write(pt3), run_time=1)\n self.play(FadeIn(stack_title), FadeIn(stack_elements), run_time=1.5)\n self.play(FadeIn(mru_label), FadeIn(lru_label), run_time=1)\n self.play(Write(pt4), Write(pt5), run_time=1.5)\n evict_box = SurroundingRectangle(stack_elements[-1], color=RED, buff=0.05)\n self.play(Create(evict_box), Indicate(lru_label, color=RED, scale_factor=1.2), run_time=1.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass LRUAlgorithm(Scene):\n\n def construct(self):\n title = Text('LRU Algorithm', 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 pt1 = Text('- Idea: Past approximates the future', font_size=24)\n pt2 = Text('- Evicts the least recently used page', font_size=24)\n pt3 = Text('- Performance is close to OPT', font_size=24)\n pt4 = Text('- Requires hardware support (e.g., stacks)', font_size=24)\n pt5 = Text('- High overhead, rarely used directly in OS', font_size=24)\n pts = VGroup(pt1, pt2, pt3, pt4, pt5).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n pts.next_to(title_group, DOWN, buff=1.0).to_edge(LEFT, buff=0.8)\n stack_title = Text('Hardware Stack', font_size=24, color=YELLOW)\n pages = ['Page B', 'Page D', 'Page C', 'Page A']\n stack_elements = VGroup()\n for p in pages:\n txt = Text(p, font_size=20)\n rect = SurroundingRectangle(txt, color=BBLUE, buff=0.15)\n stack_elements.add(VGroup(txt, rect))\n else:\n pass\n stack_elements.arrange(DOWN, buff=0.1)\n stack_group = VGroup(stack_title, stack_elements).arrange(DOWN, buff=0.4)\n stack_group.next_to(title_group, DOWN, buff=1.0).to_edge(RIGHT, buff=2.0)\n mru_label = Text('MRU', font_size=20, color=GREEN).next_to(stack_elements[0], RIGHT, buff=0.3)\n lru_label = Text('LRU', font_size=20, color=RED).next_to(stack_elements[-1], RIGHT, buff=0.3)\n self.play(Write(pt1), Write(pt2), run_time=1.5)\n self.play(Write(pt3), run_time=1)\n self.play(FadeIn(stack_title), FadeIn(stack_elements), run_time=1.5)\n self.play(FadeIn(mru_label), FadeIn(lru_label), run_time=1)\n self.play(Write(pt4), Write(pt5), run_time=1.5)\n evict_box = SurroundingRectangle(stack_elements[-1], color=RED, buff=0.05)\n self.play(Create(evict_box), Indicate(lru_label, color=RED, scale_factor=1.2), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 studying statistics and want a visual of CDFs that evolves as we collect more samples. Start from a small sample empirical CDF, then overlay the theoretical CDF, and show convergence as sample size grows. Include multiple distributions, shading to indicate probability mass, and a timeline that demonstrates how the CDF sharpens with more data.", "chosen": "```python\nfrom manim import *\nimport random\nimport math\n\nclass EmpiricalCDFConvergence(Scene):\n\n def construct(self):\n title = Text('Empirical CDFs Convergence', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0)\n formula = MathTex('F_n(x) = \\\\frac{1}{n} \\\\sum_{i=1}^{n} I(X_i \\\\leq x)', font_size=28)\n formula.next_to(title, DOWN, buff=0.3)\n self.play(Write(formula), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(formula))\n axes = Axes(x_range=[-3, 3, 1], y_range=[0, 1.1, 0.25], x_length=10, y_length=5, axis_config={'include_tip': False})\n axes.shift(DOWN * 0.5)\n x_label = MathTex('x', font_size=24)\n x_label.next_to(axes.x_axis, RIGHT, buff=0.2)\n y_label = MathTex('F(x)', font_size=24)\n y_label.next_to(axes.y_axis, UP, buff=0.2)\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2.0)\n\n def normal_cdf(x):\n return 0.5 * (1 + math.erf(x / math.sqrt(2)))\n true_cdf_graph = axes.plot(normal_cdf, x_range=[-3, 3], color=BLUE, stroke_width=3)\n true_cdf_label = Text('True CDF', font_size=20, color=BLUE)\n true_cdf_label.next_to(axes.c2p(2, 0.9), RIGHT, buff=0.1)\n self.play(Create(true_cdf_graph), run_time=2.0)\n self.play(Write(true_cdf_label), run_time=0.5)\n self.wait(2)\n\n def generate_normal_samples(n):\n samples = []\n for _ in range(n // 2 + 1):\n u1 = random.random()\n u2 = random.random()\n z1 = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2)\n z2 = math.sqrt(-2 * math.log(u1)) * math.sin(2 * math.pi * u2)\n samples.extend([z1, z2])\n return samples[:n]\n\n def empirical_cdf(samples, x):\n count = sum((1 for s in samples if s <= x))\n return count / len(samples)\n sample_sizes = [5, 10, 30, 100, 500]\n colors = [RED, ORANGE, YELLOW, GREEN, PURPLE]\n prev_graph = None\n prev_label = None\n for i, n in enumerate(sample_sizes):\n random.seed(42)\n samples = generate_normal_samples(n)\n samples.sort()\n x_vals = [-3] + samples + [3]\n y_vals = [0]\n for j in range(len(samples)):\n y_vals.append((j + 1) / n)\n y_vals.append(1)\n step_points = []\n for j in range(len(x_vals) - 1):\n step_points.append(axes.c2p(x_vals[j], y_vals[j]))\n step_points.append(axes.c2p(x_vals[j + 1], y_vals[j]))\n step_points.append(axes.c2p(x_vals[-1], y_vals[-1]))\n empirical_graph = VMobject(color=colors[i], stroke_width=2)\n empirical_graph.set_points_as_corners(step_points)\n label_text = f'n = {n}'\n empirical_label = Text(label_text, font_size=18, color=colors[i])\n empirical_label.next_to(axes.c2p(-2.5, 0.9 - i * 0.12), LEFT, buff=0.1)\n if i == 0:\n self.play(Create(empirical_graph), Write(empirical_label), run_time=2.0)\n else:\n if prev_graph:\n self.play(FadeOut(prev_graph, run_time=0.3), FadeOut(prev_label, run_time=0.3), Create(empirical_graph, run_time=2.0 * 0.7))\n else:\n self.play(Create(empirical_graph), run_time=2.0)\n self.play(Write(empirical_label), run_time=0.3)\n self.wait(1.5)\n if i < len(sample_sizes) - 1:\n prev_graph = empirical_graph\n prev_label = empirical_label\n else:\n final_empirical = empirical_graph\n final_label = empirical_label\n self.wait(2)\n all_graphs = VGroup()\n all_labels = VGroup()\n random.seed(42)\n for i, n in enumerate([10, 50, 200]):\n samples = generate_normal_samples(n)\n samples.sort()\n x_vals = [-3] + samples + [3]\n y_vals = [0]\n for j in range(len(samples)):\n y_vals.append((j + 1) / n)\n y_vals.append(1)\n step_points = []\n for j in range(len(x_vals) - 1):\n step_points.append(axes.c2p(x_vals[j], y_vals[j]))\n step_points.append(axes.c2p(x_vals[j + 1], y_vals[j]))\n step_points.append(axes.c2p(x_vals[-1], y_vals[-1]))\n g = VMobject(color=[RED, ORANGE, GREEN][i], stroke_width=1.5)\n g.set_points_as_corners(step_points)\n all_graphs.add(g)\n lab = Text(f'n={n}', font_size=14, color=[RED, ORANGE, GREEN][i])\n lab.next_to(axes.c2p(1.5, 0.3 + i * 0.15), RIGHT, buff=0.05)\n all_labels.add(lab)\n self.play(FadeOut(final_empirical), FadeOut(final_label))\n self.play(*[Create(g) for g in all_graphs], *[Write(lab) for lab in all_labels], run_time=2.0)\n self.wait(2)\n theorem_box = Rectangle(width=8, height=1.2, fill_color=BLACK, fill_opacity=0.8, stroke_color=YELLOW)\n theorem_box.to_edge(DOWN, buff=0.3)\n theorem_text = Text('Glivenko-Cantelli Theorem: sup|Fₙ(x) - F(x)| \\rightarrow 0', font_size=20)\n theorem_text.move_to(theorem_box.get_center())\n self.play(Create(theorem_box), Write(theorem_text), run_time=2.0)\n self.wait(3)\n summary_title = Text('Key Takeaways', font_size=28, color=YELLOW)\n summary_title.to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('• Empirical CDFs approximate true distributions', font_size=20), Text('• More data \\rightarrow better approximation', font_size=20), Text('• Convergence guaranteed by Glivenko-Cantelli', font_size=20)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n takeaways.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeOut(title), FadeOut(axes), FadeOut(x_label), FadeOut(y_label), FadeOut(true_cdf_graph), FadeOut(true_cdf_label), FadeOut(all_graphs), FadeOut(all_labels), FadeOut(theorem_box), FadeOut(theorem_text), run_time=1)\n self.play(Write(summary_title), run_time=1)\n for takeaway in takeaways:\n self.play(Write(takeaway), run_time=0.8)\n self.wait(2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport random\nimport math\n\nclass EmpiricalCDFConvergence(Scene):\n\n def construct(self):\n title = Text('Empirical CDFs Convergence', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0)\n formula = MathTex('F_n(x) = \\\\frac{1}{n} \\\\sum_{i=1}^{n} I(X_i \\\\leq x)', font_size=28)\n formula.next_to(title, DOWN, buff=0.3)\n self.play(Write(formula), run_time=2.0)\n self.wait(2.0)\n self.play(FadeOut(formula))\n axes = Axes(label_font_size=24, x_range=[-3, 3, 1], y_range=[0, 1.1, 0.25], x_length=10, y_length=5, axis_config={'include_tip': False})\n axes.shift(DOWN * 0.5)\n x_label = MathTex('x', font_size=24)\n x_label.next_to(axes.x_axis, RIGHT, buff=0.2)\n y_label = MathTex('F(x)', font_size=24)\n y_label.next_to(axes.y_axis, UP, buff=0.2)\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2.0)\n\n def normal_cdf(x):\n return 0.5 * (1 + math.erf(x / math.sqrt(2)))\n true_cdf_graph = axes.plot(normal_cdf, x_range=[-3, 3], color=BLUE, stroke_width=3)\n true_cdf_label = Text('True CDF', font_size=20, color=BLUE)\n true_cdf_label.next_to(axes.c2p(2, 0.9), RIGHT, buff=0.1)\n self.play(Create(true_cdf_graph), run_time=2.0)\n self.play(Write(true_cdf_label), run_time=0.5)\n self.wait(2)\n\n def generate_normal_samples(n):\n samples = []\n for _ in range(n // 2 + 1):\n u1 = random.random()\n u2 = random.random()\n z1 = math.sqrt(-2 * math.log(u1)) * math.cos(2 * math.pi * u2)\n z2 = math.sqrt(-2 * math.log(u1)) * math.sin(2 * math.pi * u2)\n samples.extend([z1, z2])\n return samples[:n]\n\n def empirical_cdf(samples, x):\n count = sum((1 for s in samples if s <= x))\n return count / len(samples)\n sample_sizes = [5, 10, 30, 100, 500]\n colors = [RED, ORANGE, YELLOW, GREEN, PURPLE]\n prev_graph = None\n prev_label = None\n for i, n in enumerate(sample_sizes):\n random.seed(42)\n samples = generate_normal_samples(n)\n samples.sort()\n x_vals = [-3] + samples + [3]\n y_vals = [0]\n for j in range(len(samples)):\n y_vals.append((j + 1) / n)\n y_vals.append(1)\n step_points = []\n for j in range(len(x_vals) - 1):\n step_points.append(axes.c2p(x_vals[j], y_vals[j]))\n step_points.append(axes.c2p(x_vals[j + 1], y_vals[j]))\n step_points.append(axes.c2p(x_vals[-1], y_vals[-1]))\n empirical_graph = VMobject(color=colors[i], stroke_width=2)\n empirical_graph.set_points_as_corners(step_points)\n label_text = f'n = {n}'\n empirical_label = Text(label_text, font_size=18, color=colors[i])\n empirical_label.next_to(axes.c2p(-2.5, 0.9 - i * 0.12), LEFT, buff=0.1)\n if i == 0:\n self.play(Create(empirical_graph), Write(empirical_label), run_time=2.0)\n else:\n if prev_graph:\n self.play(FadeOut(prev_graph, run_time=0.3), FadeOut(prev_label, run_time=0.3), Create(empirical_graph, run_time=2.0 * 0.7))\n else:\n self.play(Create(empirical_graph), run_time=2.0)\n self.play(Write(empirical_label), run_time=0.3)\n self.wait(1.5)\n if i < len(sample_sizes) - 1:\n prev_graph = empirical_graph\n prev_label = empirical_label\n else:\n final_empirical = empirical_graph\n final_label = empirical_label\n self.wait(2)\n all_graphs = VGroup()\n all_labels = VGroup()\n random.seed(42)\n for i, n in enumerate([10, 50, 200]):\n samples = generate_normal_samples(n)\n samples.sort()\n x_vals = [-3] + samples + [3]\n y_vals = [0]\n for j in range(len(samples)):\n y_vals.append((j + 1) / n)\n y_vals.append(1)\n step_points = []\n for j in range(len(x_vals) - 1):\n step_points.append(axes.c2p(x_vals[j], y_vals[j]))\n step_points.append(axes.c2p(x_vals[j + 1], y_vals[j]))\n step_points.append(axes.c2p(x_vals[-1], y_vals[-1]))\n g = VMobject(color=[RED, ORANGE, GREEN][i], stroke_width=1.5)\n g.set_points_as_corners(step_points)\n all_graphs.add(g)\n lab = Text(f'n={n}', font_size=14, color=[RED, ORANGE, GREEN][i])\n lab.next_to(axes.c2p(1.5, 0.3 + i * 0.15), RIGHT, buff=0.05)\n all_labels.add(lab)\n self.play(FadeOut(final_empirical), FadeOut(final_label))\n self.play(*[Create(g) for g in all_graphs], *[Write(lab) for lab in all_labels], run_time=2.0)\n self.wait(2)\n theorem_box = Rectangle(width=8, height=1.2, fill_color=BLACK, fill_opacity=0.8, stroke_color=YELLOW)\n theorem_box.to_edge(DOWN, buff=0.3)\n theorem_text = Text('Glivenko-Cantelli Theorem: sup|Fₙ(x) - F(x)| \\rightarrow 0', font_size=20)\n theorem_text.move_to(theorem_box.get_center())\n self.play(Create(theorem_box), Write(theorem_text), run_time=2.0)\n self.wait(3)\n summary_title = Text('Key Takeaways', font_size=28, color=YELLOW)\n summary_title.to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('• Empirical CDFs approximate true distributions', font_size=20), Text('• More data \\rightarrow better approximation', font_size=20), Text('• Convergence guaranteed by Glivenko-Cantelli', font_size=20)).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n takeaways.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeOut(title), FadeOut(axes), FadeOut(x_label), FadeOut(y_label), FadeOut(true_cdf_graph), FadeOut(true_cdf_label), FadeOut(all_graphs), FadeOut(all_labels), FadeOut(theorem_box), FadeOut(theorem_text), run_time=1)\n self.play(Write(summary_title), run_time=1)\n for takeaway in takeaways:\n self.play(Write(takeaway), run_time=0.8)\n self.wait(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 demonstrates the concept of finding the area under a curve using integration. Specifically, I want to show the graph of \\( x^2 \\) along with its plot, then visually display the area under the curve between 0 and 1.5. Following that, I want to introduce the integral symbol and expression that represents the computation of this area. Can you illustrate the step-by-step process of solving the integral, ultimately revealing the numerical value of the area? Finally, clear everything and just present the final numerical solution on the screen.", "chosen": "```python\nfrom manim import *\n\nclass IntegrationArea(Scene):\n def construct(self):\n # 1. Setup: Initialize the coordinate system\n axes = Axes(\n x_range=[0, 2, 0.5],\n y_range=[0, 4, 1],\n x_length=6,\n y_length=4,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_exclude\": [0]\n },\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plotting: Draw the graph of f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2])\n graph_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^2\"), x_val=1.8, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(graph_label))\n self.wait(1)\n\n # 3. Area Visualization: Highlight area under the curve from 0 to 1.5\n area = axes.get_area(curve, x_range=[0, 1.5], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines for visual clarity\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(1.5, 1.5**2), color=GRAY)\n area_label = MathTex(\"\\\\text{Area}\").set_color(GREEN).next_to(area, RIGHT, buff=0.2)\n\n self.play(FadeIn(area), Create(line_start), Create(line_end), Write(area_label))\n self.wait(1)\n\n # 4. Integral Expression: Display the integral symbol and expression\n eq_position = RIGHT * 3.5 + UP * 2\n step1 = MathTex(r\"\\int_{0}^{1.5}\", \"x^2\", r\"\\, dx\").move_to(eq_position)\n\n self.play(FadeOut(area_label), Write(step1))\n self.wait(2)\n\n # 5. Step-by-Step Solution: Animate the algebraic steps\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{1.5}\").next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n\n step3 = MathTex(r\"= \\frac{(1.5)^3}{3} - \\frac{0^3}{3}\").next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(1)\n\n step4 = MathTex(r\"= \\frac{3.375}{3} - 0\").next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step4))\n self.wait(1)\n\n # 6. Result Reveal: Show the final computed numerical value\n step5 = MathTex(r\"= 1.125\").next_to(step4, DOWN, buff=0.5, aligned_edge=LEFT).set_color(YELLOW)\n self.play(Write(step5))\n self.wait(2)\n\n # 7. Final Scene: Clear everything and present only the final numerical solution\n elements_to_remove = VGroup(\n axes, labels, curve, graph_label, area, line_start, line_end,\n step1, step2, step3, step4\n )\n \n final_result = MathTex(r\"1.125\", font_size=90, color=YELLOW).move_to(ORIGIN)\n\n self.play(\n FadeOut(elements_to_remove),\n ReplacementTransform(step5, final_result)\n )\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrationArea(Scene):\n def construct(self):\n # 1. Setup: Initialize the coordinate system\n axes = Axes(label_font_size=24, \n x_range=[0, 2, 0.5],\n y_range=[0, 4, 1],\n x_length=6,\n y_length=4,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_exclude\": [0]\n },\n ).shift(LEFT * 2)\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plotting: Draw the graph of f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2])\n graph_label = axes.get_graph_label(curve, label=MathTex(\"f(x) = x^2\"), x_val=1.8, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(graph_label))\n self.wait(1)\n\n # 3. Area Visualization: Highlight area under the curve from 0 to 1.5\n area = axes.get_area(curve, x_range=[0, 1.5], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines for visual clarity\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(1.5, 1.5**2), color=GRAY)\n area_label = MathTex(\"\\\\text{Area}\").set_color(GREEN).next_to(area, RIGHT, buff=0.2)\n\n self.play(FadeIn(area), Create(line_start), Create(line_end), Write(area_label))\n self.wait(1)\n\n # 4. Integral Expression: Display the integral symbol and expression\n eq_position = RIGHT * 3.5 + UP * 2\n step1 = MathTex(r\"\\int_{0}^{1.5}\", \"x^2\", r\"\\, dx\").move_to(eq_position)\n\n self.play(FadeOut(area_label), Write(step1))\n self.wait(2)\n\n # 5. Step-by-Step Solution: Animate the algebraic steps\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{1.5}\").next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(1)\n\n step3 = MathTex(r\"= \\frac{(1.5)^3}{3} - \\frac{0^3}{3}\").next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(1)\n\n step4 = MathTex(r\"= \\frac{3.375}{3} - 0\").next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step4))\n self.wait(1)\n\n # 6. Result Reveal: Show the final computed numerical value\n step5 = MathTex(r\"= 1.125\").next_to(step4, DOWN, buff=0.5, aligned_edge=LEFT).set_color(YELLOW)\n self.play(Write(step5))\n self.wait(2)\n\n # 7. Final Scene: Clear everything and present only the final numerical solution\n elements_to_remove = VGroup(\n axes, labels, curve, graph_label, area, line_start, line_end,\n step1, step2, step3, step4\n )\n \n final_result = MathTex(r\"1.125\", font_size=90, color=YELLOW).move_to(ORIGIN)\n\n self.play(\n FadeOut(elements_to_remove),\n ReplacementTransform(step5, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup & Styling\n # Create axes with blue color and labels\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 2, 1],\n axis_config={\"color\": BLUE}\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define and plot the function y = 0.25x^2 in green\n graph = axes.plot(lambda x: 0.25 * x**2, x_range=[0, 2], color=GREEN)\n \n # Animate the creation of axes and the function graph\n self.play(Create(axes), Create(labels), Create(graph), run_time=2)\n self.wait(1)\n \n # 2. Area Visualization\n # Highlight area under curve from x=0 to x=2 in yellow with 50% opacity\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n area_label = Text(\"Area under curve\", font_size=24).next_to(area, RIGHT, buff=0.5).shift(UP * 0.5)\n \n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n \n # 3. Mathematical Transformation\n # Transform the \"Area under curve\" text label into the integral notation\n integral_notation = MathTex(r\"\\int_{0}^{2} 0.25x^2 \\, dx\", font_size=42)\n integral_notation.move_to(area_label.get_center())\n \n self.play(ReplacementTransform(area_label, integral_notation))\n \n # Move this integral notation to the top of the screen\n self.play(integral_notation.animate.to_edge(UP))\n self.wait(1)\n \n # 4. Calculation & Result\n # Define the step-by-step calculation process\n step1 = MathTex(r\"= \\left[ \\frac{0.25}{3}x^3 \\right]_{0}^{2}\", font_size=36).next_to(integral_notation, DOWN, buff=0.5)\n step2 = MathTex(r\"= \\frac{0.25}{3}(2^3) - \\frac{0.25}{3}(0^3)\", font_size=36).next_to(step1, DOWN, buff=0.4)\n step3 = MathTex(r\"= \\frac{0.25 \\cdot 8}{3} = \\frac{2}{3}\", font_size=36).next_to(step2, DOWN, buff=0.4)\n final_result = MathTex(r\"\\approx 0.667\", font_size=48, color=YELLOW).next_to(step3, DOWN, buff=0.5)\n \n # Reveal calculations sequentially\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(final_result))\n self.wait(2)\n \n # 5. Conclusion\n # Clear all visual elements from the screen except for the final numerical area value\n to_fade = VGroup(axes, labels, graph, area, integral_notation, step1, step2, step3)\n \n # Move final result to center for emphasis before ending\n self.play(\n FadeOut(to_fade),\n final_result.animate.move_to(ORIGIN).scale(1.5)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup & Styling\n # Create axes with blue color and labels\n axes = Axes(label_font_size=24, \n x_range=[0, 3, 1],\n y_range=[0, 2, 1],\n axis_config={\"color\": BLUE}\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Define and plot the function y = 0.25x^2 in green\n graph = axes.plot(lambda x: 0.25 * x**2, x_range=[0, 2], color=GREEN)\n \n # Animate the creation of axes and the function graph\n self.play(Create(axes), Create(labels), Create(graph), run_time=2)\n self.wait(1)\n \n # 2. Area Visualization\n # Highlight area under curve from x=0 to x=2 in yellow with 50% opacity\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n area_label = Text(\"Area under curve\", font_size=24).next_to(area, RIGHT, buff=0.5).shift(UP * 0.5)\n \n self.play(FadeIn(area), Write(area_label))\n self.wait(1)\n \n # 3. Mathematical Transformation\n # Transform the \"Area under curve\" text label into the integral notation\n integral_notation = MathTex(r\"\\int_{0}^{2} 0.25x^2 \\, dx\", font_size=42)\n integral_notation.move_to(area_label.get_center())\n \n self.play(ReplacementTransform(area_label, integral_notation))\n \n # Move this integral notation to the top of the screen\n self.play(integral_notation.animate.to_edge(UP))\n self.wait(1)\n \n # 4. Calculation & Result\n # Define the step-by-step calculation process\n step1 = MathTex(r\"= \\left[ \\frac{0.25}{3}x^3 \\right]_{0}^{2}\", font_size=36).next_to(integral_notation, DOWN, buff=0.5)\n step2 = MathTex(r\"= \\frac{0.25}{3}(2^3) - \\frac{0.25}{3}(0^3)\", font_size=36).next_to(step1, DOWN, buff=0.4)\n step3 = MathTex(r\"= \\frac{0.25 \\cdot 8}{3} = \\frac{2}{3}\", font_size=36).next_to(step2, DOWN, buff=0.4)\n final_result = MathTex(r\"\\approx 0.667\", font_size=48, color=YELLOW).next_to(step3, DOWN, buff=0.5)\n \n # Reveal calculations sequentially\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(final_result))\n self.wait(2)\n \n # 5. Conclusion\n # Clear all visual elements from the screen except for the final numerical area value\n to_fade = VGroup(axes, labels, graph, area, integral_notation, step1, step2, step3)\n \n # Move final result to center for emphasis before ending\n self.play(\n FadeOut(to_fade),\n final_result.animate.move_to(ORIGIN).scale(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 complex plane with a dot initially positioned at the complex number \\(-2 + 1i\\). As the animation progresses, the dot moves smoothly to new positions based on updates to a complex value tracker:\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: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0097(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_complexvaluetrackerexamp()\n self.clear_stage()\n self.act_2_fastsequenceanimation()\n self.clear_stage()\n self.act_3_scaletofitanimation()\n\n def act_1_complexvaluetrackerexamp(self):\n tracker = ComplexValueTracker(-2+1j)\n dot = Dot().add_updater(\n lambda x: x.move_to(tracker.points)\n )\n\n self.add(NumberPlane(), dot)\n\n self.play(tracker.animate.set_value(3+2j))\n self.play(tracker.animate.set_value(tracker.get_value() * 1j))\n self.play(tracker.animate.set_value(tracker.get_value() - 2j))\n self.play(tracker.animate.set_value(tracker.get_value() / (-2 + 3j)))\n\n def act_2_fastsequenceanimation(self):\n text = Text(\"Starting Sequence\").to_edge(DOWN)\n self.play(Write(text), run_time=0.3)\n self.play(text.animate.shift(UP * 3), run_time=0.4)\n\n # 2. Shape Appearance: A circle appears on the screen\n circle = Circle(radius=1.5)\n self.play(Create(circle), run_time=0.3)\n original_position = circle.get_center()\n\n # 3. Pause: 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, side_length=3)\n self.play(ReplacementTransform(circle, square), run_time=0.3)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN + RIGHT), run_time=0.3)\n\n # 6. Shift and Rotate: The square shifts further right and rotates slightly\n self.play(square.animate.shift(RIGHT * 2).rotate(PI / 6), run_time=0.3)\n\n # 7. Pause: Brief pause immediately after the rotation\n self.wait(0.2)\n\n # 8. Reversion: The square reverts back to a circle\n target_circle = Circle(radius=1.5).move_to(square.get_center())\n self.play(ReplacementTransform(square, target_circle), run_time=0.3)\n\n # 9. Return: The circle returns to its original position\n self.play(target_circle.animate.move_to(original_position), run_time=0.4)\n\n def act_3_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0097(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_complexvaluetrackerexamp()\n self.clear_stage()\n self.act_2_fastsequenceanimation()\n self.clear_stage()\n self.act_3_scaletofitanimation()\n\n def act_1_complexvaluetrackerexamp(self):\n tracker = ComplexValueTracker(-2+1j)\n dot = Dot().add_updater(\n lambda x: x.move_to(tracker.points)\n )\n\n self.add(NumberPlane(), dot)\n\n self.play(tracker.animate.set_value(3+2j))\n self.play(tracker.animate.set_value(tracker.get_value() * 1j))\n self.play(tracker.animate.set_value(tracker.get_value() - 2j))\n self.play(tracker.animate.set_value(tracker.get_value() / (-2 + 3j)))\n\n def act_2_fastsequenceanimation(self):\n text = Text(\"Starting Sequence\").to_edge(DOWN)\n self.play(Write(text), run_time=0.3)\n self.play(text.animate.shift(UP * 3), run_time=0.4)\n\n # 2. Shape Appearance: A circle appears on the screen\n circle = Circle(radius=1.5)\n self.play(Create(circle), run_time=0.3)\n original_position = circle.get_center()\n\n # 3. Pause: 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, side_length=3)\n self.play(ReplacementTransform(circle, square), run_time=0.3)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN + RIGHT), run_time=0.3)\n\n # 6. Shift and Rotate: The square shifts further right and rotates slightly\n self.play(square.animate.shift(RIGHT * 2).rotate(PI / 6), run_time=0.3)\n\n # 7. Pause: Brief pause immediately after the rotation\n self.wait(0.2)\n\n # 8. Reversion: The square reverts back to a circle\n target_circle = Circle(radius=1.5).move_to(square.get_center())\n self.play(ReplacementTransform(square, target_circle), run_time=0.3)\n\n # 9. Return: The circle returns to its original position\n self.play(target_circle.animate.move_to(original_position), run_time=0.4)\n\n def act_3_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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 model introspection and want to see a dynamic summary table being generated like torchinfo, expanding rows for each layer with parameter counts.\nStart with a compact header and progressively reveal layers showing shapes, channels, and total parameters.\nHighlight how the total parameter count grows as the network is built up.\nUse a clean table layout with gentle transitions.", "chosen": "```python\nfrom manim import *\n\nclass ModelIntrospectionDynamics(Scene):\n\n def construct(self):\n title = Text('Model Introspection Dynamics', font_size=40)\n subtitle = Text('Understanding How AI Models Think', font_size=24)\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n self.play(Write(title), run_time=2.0 * 0.6)\n self.play(FadeIn(subtitle), run_time=2.0 * 0.4)\n input_neurons = VGroup(*[Circle(radius=0.2, color=BLUE) for _ in range(3)])\n hidden_neurons = VGroup(*[Circle(radius=0.2, color=GREEN) for _ in range(4)])\n output_neurons = VGroup(*[Circle(radius=0.2, color=RED) for _ in range(2)])\n input_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.arrange(DOWN, buff=0.4)\n output_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.shift(RIGHT * 2)\n output_neurons.shift(RIGHT * 4)\n connections = VGroup()\n for i in input_neurons:\n for h in hidden_neurons:\n connections.add(Line(i.get_right(), h.get_left(), stroke_width=1, color=GRAY))\n for h in hidden_neurons:\n for o in output_neurons:\n connections.add(Line(h.get_right(), o.get_left(), stroke_width=1, color=GRAY))\n nn_group = VGroup(input_neurons, hidden_neurons, output_neurons, connections)\n nn_group.scale(0.8).to_edge(LEFT, buff=0.5).shift(UP * 0.5)\n input_label = Text('Input', font_size=20).next_to(input_neurons, DOWN)\n hidden_label = Text('Hidden', font_size=20).next_to(hidden_neurons, DOWN)\n output_label = Text('Output', font_size=20).next_to(output_neurons, DOWN)\n labels = VGroup(input_label, hidden_label, output_label)\n self.play(FadeOut(title_group), run_time=0.5)\n self.play(FadeIn(connections), run_time=2.0 * 0.4)\n self.play(FadeIn(input_neurons), FadeIn(hidden_neurons), FadeIn(output_neurons), run_time=2.0 * 0.4)\n self.play(FadeIn(labels), run_time=2.0 * 0.2)\n inspect_arrow = Arrow(output_neurons.get_right() + RIGHT * 0.2, output_neurons.get_right() + RIGHT * 1.5, color=YELLOW)\n inspect_text = Text('Inspect', font_size=20).next_to(inspect_arrow, UP)\n self.play(GrowArrow(inspect_arrow), Write(inspect_text), run_time=2.0)\n db_axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=3.5, y_length=3.5, axis_config={'include_tip': False}).to_edge(RIGHT, buff=0.5).shift(UP * 0.3)\n boundary = DashedLine(db_axes.c2p(-2.5, 2.5), db_axes.c2p(2.5, -2.5), color=YELLOW)\n pts_a = [db_axes.c2p(-1.5, 1.5), db_axes.c2p(-2, 0.5), db_axes.c2p(-1, 2), db_axes.c2p(-0.5, 1)]\n pts_b = [db_axes.c2p(1.5, -1.5), db_axes.c2p(2, -0.5), db_axes.c2p(1, -2), db_axes.c2p(0.5, -1)]\n dots_a = VGroup(*[Dot(p, color=BLUE, radius=0.08) for p in pts_a])\n dots_b = VGroup(*[Dot(p, color=RED, radius=0.08) for p in pts_b])\n db_title = Text('Decision Boundary', font_size=24).next_to(db_axes, UP)\n self.play(FadeIn(db_axes), Write(db_title), run_time=2.0 * 0.4)\n self.play(FadeIn(dots_a, dots_b), run_time=2.0 * 0.3)\n self.play(Create(boundary), run_time=2.0 * 0.3)\n dyn_axes = Axes(x_range=[0, 10, 1], y_range=[0, 1, 0.2], x_length=5, y_length=2.5, axis_config={'include_tip': False}, x_axis_config={'numbers_to_include': [0, 5, 10]}, y_axis_config={'numbers_to_include': [0, 0.5, 1.0]}).to_edge(DOWN, buff=0.3).shift(RIGHT * 2)\n import math\n dyn_graph = dyn_axes.plot(lambda x: 0.5 + 0.4 * math.sin(x) * math.exp(-0.1 * x), color=GREEN, x_range=[0, 10])\n dyn_label = Text('Activation Dynamics', font_size=20).next_to(dyn_axes, UP)\n self.play(FadeIn(dyn_axes), run_time=2.0 * 0.3)\n self.play(Create(dyn_graph), Write(dyn_label), run_time=2.0 * 0.7)\n outcomes = VGroup(Text('• Analyze decisions', font_size=22), Text('• Apply introspection', font_size=22), Text('• Visualize dynamics', font_size=22)).arrange(DOWN, aligned_edge=LEFT, buff=0.2).to_corner(DL, buff=0.5)\n self.play(FadeIn(outcomes), run_time=2.0)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass ModelIntrospectionDynamics(Scene):\n\n def construct(self):\n title = Text('Model Introspection Dynamics', font_size=40)\n subtitle = Text('Understanding How AI Models Think', font_size=24)\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n self.play(Write(title), run_time=2.0 * 0.6)\n self.play(FadeIn(subtitle), run_time=2.0 * 0.4)\n input_neurons = VGroup(*[Circle(radius=0.2, color=BBLUE) for _ in range(3)])\n hidden_neurons = VGroup(*[Circle(radius=0.2, color=GREEN) for _ in range(4)])\n output_neurons = VGroup(*[Circle(radius=0.2, color=RED) for _ in range(2)])\n input_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.arrange(DOWN, buff=0.4)\n output_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.shift(RIGHT * 2)\n output_neurons.shift(RIGHT * 4)\n connections = VGroup()\n for i in input_neurons:\n for h in hidden_neurons:\n connections.add(Line(i.get_right(), h.get_left(), stroke_width=1, color=GRAY))\n for h in hidden_neurons:\n for o in output_neurons:\n connections.add(Line(h.get_right(), o.get_left(), stroke_width=1, color=GRAY))\n nn_group = VGroup(input_neurons, hidden_neurons, output_neurons, connections)\n nn_group.scale(0.8).to_edge(LEFT, buff=0.5).shift(UP * 0.5)\n input_label = Text('Input', font_size=20).next_to(input_neurons, DOWN)\n hidden_label = Text('Hidden', font_size=20).next_to(hidden_neurons, DOWN)\n output_label = Text('Output', font_size=20).next_to(output_neurons, DOWN)\n labels = VGroup(input_label, hidden_label, output_label)\n self.play(FadeOut(title_group), run_time=0.5)\n self.play(FadeIn(connections), run_time=2.0 * 0.4)\n self.play(FadeIn(input_neurons), FadeIn(hidden_neurons), FadeIn(output_neurons), run_time=2.0 * 0.4)\n self.play(FadeIn(labels), run_time=2.0 * 0.2)\n inspect_arrow = Arrow(output_neurons.get_right() + RIGHT * 0.2, output_neurons.get_right() + RIGHT * 1.5, color=YELLOW)\n inspect_text = Text('Inspect', font_size=20).next_to(inspect_arrow, UP)\n self.play(GrowArrow(inspect_arrow), Write(inspect_text), run_time=2.0)\n db_axes = Axes(x_range=[-3, 3, 1], y_range=[-3, 3, 1], x_length=3.5, y_length=3.5, axis_config={'include_tip': False}).to_edge(RIGHT, buff=0.5).shift(UP * 0.3)\n boundary = DashedLine(db_axes.c2p(-2.5, 2.5), db_axes.c2p(2.5, -2.5), color=YELLOW)\n pts_a = [db_axes.c2p(-1.5, 1.5), db_axes.c2p(-2, 0.5), db_axes.c2p(-1, 2), db_axes.c2p(-0.5, 1)]\n pts_b = [db_axes.c2p(1.5, -1.5), db_axes.c2p(2, -0.5), db_axes.c2p(1, -2), db_axes.c2p(0.5, -1)]\n dots_a = VGroup(*[Dot(p, color=BLUE, radius=0.08) for p in pts_a])\n dots_b = VGroup(*[Dot(p, color=RED, radius=0.08) for p in pts_b])\n db_title = Text('Decision Boundary', font_size=24).next_to(db_axes, UP)\n self.play(FadeIn(db_axes), Write(db_title), run_time=2.0 * 0.4)\n self.play(FadeIn(dots_a, dots_b), run_time=2.0 * 0.3)\n self.play(Create(boundary), run_time=2.0 * 0.3)\n dyn_axes = Axes(x_range=[0, 10, 1], y_range=[0, 1, 0.2], x_length=5, y_length=2.5, axis_config={'include_tip': False}, x_axis_config={'numbers_to_include': [0, 5, 10]}, y_axis_config={'numbers_to_include': [0, 0.5, 1.0]}).to_edge(DOWN, buff=0.3).shift(RIGHT * 2)\n import math\n dyn_graph = dyn_axes.plot(lambda x: 0.5 + 0.4 * math.sin(x) * math.exp(-0.1 * x), color=GREEN, x_range=[0, 10])\n dyn_label = Text('Activation Dynamics', font_size=20).next_to(dyn_axes, UP)\n self.play(FadeIn(dyn_axes), run_time=2.0 * 0.3)\n self.play(Create(dyn_graph), Write(dyn_label), run_time=2.0 * 0.7)\n outcomes = VGroup(Text('• Analyze decisions', font_size=22), Text('• Apply introspection', font_size=22), Text('• Visualize dynamics', font_size=22)).arrange(DOWN, aligned_edge=LEFT, buff=0.2).to_corner(DL, buff=0.5)\n self.play(FadeIn(outcomes), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\n x_range=[-4, 4, 1],\n y_range=[-2, 3, 1],\n x_length=8,\n y_length=5,\n axis_config={\"color\": BBLUE},\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Time Shift: $x[n-n_0] \\leftrightarrow z^{-n_0}X(z)$\nThis property indicates that a multiplication factor of $z^{-1}$ in the Z-domain corresponds to a unit delay in the time domain, which is fundamental for analyzing digital filter structures.\n\n\nThe context of this section (from highest to current level):\n# Signals and Systems Course - Detailed Outline for Lecture Twelve (Z-Transforms and Discrete System Analysis, 90 minutes)\n## Properties of the Z-Transform (20 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TimeShiftProperty(Scene):\n\n def construct(self):\n title = Text('Properties of the Z-Transform: Time Shift', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_ul = Underline(title)\n formula = MathTex('x[n-n_0]', '\\\\overset{\\\\mathcal{Z}}{\\\\longleftrightarrow}', 'z^{-n_0}X(z)', font_size=56)\n formula[0].set_color(BLUE)\n formula[2].set_color(YELLOW)\n input_signal = MathTex('x[n]', font_size=44, color=BLUE)\n delay_rect = Rectangle(width=1.5, height=1.2, color=WHITE)\n delay_text = MathTex('z^{-1}', font_size=44, color=YELLOW)\n delay_block = VGroup(delay_rect, delay_text)\n output_signal = MathTex('x[n-1]', font_size=44, color=BLUE)\n arrow_in = Arrow(LEFT, RIGHT, buff=0).set_length(1.5)\n arrow_out = Arrow(LEFT, RIGHT, buff=0).set_length(1.5)\n diagram = VGroup(input_signal, arrow_in, delay_block, arrow_out, output_signal)\n diagram.arrange(RIGHT, buff=0.3)\n desc_1 = Text('Multiplication by ', font_size=28)\n desc_math = MathTex('z^{-1}', font_size=36, color=YELLOW)\n desc_2 = Text(' corresponds to a unit delay.', font_size=28)\n desc_line1 = VGroup(desc_1, desc_math, desc_2).arrange(RIGHT, buff=0.1)\n desc_line2 = Text('Fundamental for analyzing digital filter structures.', font_size=28, color=LIGHT_GREY)\n descriptions = VGroup(desc_line1, desc_line2).arrange(DOWN, buff=0.3)\n content_group = VGroup(formula, diagram, descriptions)\n content_group.arrange(DOWN, buff=1.2)\n content_group.next_to(title_ul, DOWN, buff=0.8)\n self.play(Write(title), Create(title_ul))\n self.wait(0.5)\n self.play(Write(formula[0]))\n self.play(Write(formula[1]))\n self.play(Write(formula[2]))\n self.wait(1)\n self.play(FadeIn(input_signal, shift=RIGHT))\n self.play(GrowArrow(arrow_in))\n self.play(Create(delay_rect), Write(delay_text))\n self.play(GrowArrow(arrow_out))\n self.play(FadeIn(output_signal, shift=RIGHT))\n self.wait(1)\n self.play(Write(desc_line1))\n self.wait(0.5)\n self.play(Write(desc_line2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass TimeShiftProperty(Scene):\n\n def construct(self):\n title = Text('Properties of the Z-Transform: Time Shift', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n title_ul = Underline(title)\n formula = MathText('x[n-n_0]', '\\\\overset{\\\\mathcal{Z}}{\\\\longleftrightarrow}', 'z^{-n_0}X(z)', font_size=56)\n formula[0].set_color(BLUE)\n formula[2].set_color(YELLOW)\n input_signal = MathTex('x[n]', font_size=44, color=BLUE)\n delay_rect = Rectangle(width=1.5, height=1.2, color=WHITE)\n delay_text = MathTex('z^{-1}', font_size=44, color=YELLOW)\n delay_block = VGroup(delay_rect, delay_text)\n output_signal = MathTex('x[n-1]', font_size=44, color=BLUE)\n arrow_in = Arrow(LEFT, RIGHT, buff=0).set_length(1.5)\n arrow_out = Arrow(LEFT, RIGHT, buff=0).set_length(1.5)\n diagram = VGroup(input_signal, arrow_in, delay_block, arrow_out, output_signal)\n diagram.arrange(RIGHT, buff=0.3)\n desc_1 = Text('Multiplication by ', font_size=28)\n desc_math = MathTex('z^{-1}', font_size=36, color=YELLOW)\n desc_2 = Text(' corresponds to a unit delay.', font_size=28)\n desc_line1 = VGroup(desc_1, desc_math, desc_2).arrange(RIGHT, buff=0.1)\n desc_line2 = Text('Fundamental for analyzing digital filter structures.', font_size=28, color=LIGHT_GREY)\n descriptions = VGroup(desc_line1, desc_line2).arrange(DOWN, buff=0.3)\n content_group = VGroup(formula, diagram, descriptions)\n content_group.arrange(DOWN, buff=1.2)\n content_group.next_to(title_ul, DOWN, buff=0.8)\n self.play(Write(title), Create(title_ul))\n self.wait(0.5)\n self.play(Write(formula[0]))\n self.play(Write(formula[1]))\n self.play(Write(formula[2]))\n self.wait(1)\n self.play(FadeIn(input_signal, shift=RIGHT))\n self.play(GrowArrow(arrow_in))\n self.play(Create(delay_rect), Write(delay_text))\n self.play(GrowArrow(arrow_out))\n self.play(FadeIn(output_signal, shift=RIGHT))\n self.wait(1)\n self.play(Write(desc_line1))\n self.wait(0.5)\n self.play(Write(desc_line2))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 geometrically visualize the map from the Chow group to the cohomology ring via the cycle class map?", "chosen": "```python\nfrom manim import *\n\nclass CycleClassMapScene(Scene):\n def construct(self):\n # Element 1: Title screen\n title = Text(\"From Cycles to Cohomology:\", color=BLUE).shift(UP * 0.5)\n subtitle = Text(\"Unlocking the Cycle Class Map\", color=BLUE).shift(DOWN * 0.5)\n \n # Create a grid for background (simplified)\n grid = VGroup()\n for i in range(-5, 6):\n h_line = Line(5*LEFT + i*UP, 5*RIGHT + i*UP, color=BLUE_E, stroke_opacity=0.3)\n v_line = Line(i*RIGHT + 5*UP, i*RIGHT + 5*DOWN, color=BLUE_E, stroke_opacity=0.3)\n grid.add(h_line, v_line)\n \n # Play title animation\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1.5)\n self.play(Create(grid), run_time=2)\n self.wait(1)\n self.play(FadeOut(grid), FadeOut(title), FadeOut(subtitle))\n \n # Element 2: Complex algebraic cycles\n tapestry_text = Text(\"Complex Algebraic Cycles\", color=WHITE).to_edge(UP)\n \n # Create an intricate geometric shape representing algebraic cycles\n cycles_group = VGroup()\n \n # Create several ellipses with different colors for the tapestry\n for i in range(5):\n ellipse = Ellipse(\n width=3 + i*0.4,\n height=2 + i*0.3,\n color=GOLD if i % 2 == 0 else PURPLE,\n stroke_width=2,\n fill_opacity=0.2\n ).rotate(PI/6 * i)\n cycles_group.add(ellipse)\n \n # Add some lines to represent intersections\n for i in range(4):\n line = Line(\n start=2*LEFT + (i-1.5)*UP,\n end=2*RIGHT + (1.5-i)*UP,\n color=BLUE,\n stroke_width=2\n )\n cycles_group.add(line)\n \n cycles_group.scale(0.8).shift(DOWN * 0.5)\n \n # Display the tapestry\n self.play(Write(tapestry_text))\n self.play(Create(cycles_group), run_time=3)\n self.wait(1)\n \n # Element 3: Zoom into a section and colorize cycles\n zoom_text = Text(\"Chow Group Cycles\", color=WHITE).to_edge(UP)\n \n # Create zoom effect by scaling\n cycles_group_zoomed = cycles_group.copy().scale(1.5)\n \n self.play(\n FadeOut(tapestry_text),\n FadeIn(zoom_text),\n Transform(cycles_group, cycles_group_zoomed),\n run_time=2\n )\n \n # Highlight different cycles with colors\n cycle1 = Ellipse(width=2, height=1.5, color=RED, fill_opacity=0.3).shift(LEFT*0.5)\n cycle2 = Ellipse(width=1.8, height=1.3, color=GREEN, fill_opacity=0.3).shift(RIGHT*0.5 + UP*0.3)\n cycle3 = Ellipse(width=1.6, height=1.7, color=BLUE, fill_opacity=0.3).shift(DOWN*0.5)\n \n self.play(\n FadeIn(cycle1),\n FadeIn(cycle2),\n FadeIn(cycle3),\n run_time=2\n )\n self.wait(1)\n \n # Element 4: Transform to cohomology ring\n cohomology_text = Text(\"Cohomology Ring\", color=WHITE).to_edge(UP)\n \n # Simpler representation for cohomology\n dot1 = Dot(color=RED).shift(LEFT*2)\n dot2 = Dot(color=GREEN).shift(UP*2)\n dot3 = Dot(color=BLUE).shift(RIGHT*2)\n \n line1 = Line(dot1.get_center(), dot2.get_center(), color=YELLOW)\n line2 = Line(dot2.get_center(), dot3.get_center(), color=YELLOW)\n line3 = Line(dot3.get_center(), dot1.get_center(), color=YELLOW)\n \n cohomology_group = VGroup(dot1, dot2, dot3, line1, line2, line3)\n cohomology_group.scale(0.8).shift(DOWN * 0.5)\n \n self.play(\n FadeOut(zoom_text),\n FadeOut(cycles_group),\n FadeOut(cycle1),\n FadeOut(cycle2),\n FadeOut(cycle3),\n FadeIn(cohomology_text),\n run_time=1\n )\n \n self.play(Create(cohomology_group), run_time=2)\n self.wait(1)\n \n # Element 5: Cycle class map\n map_text = Text(\"The Cycle Class Map\", color=WHITE).to_edge(UP)\n \n # Create equation for cycle class map (simplified)\n equation = Text(\"Chow(X) \\rightarrow H*(X, Z)\", color=WHITE).shift(UP * 0.5)\n equation2 = Text(\"\\alpha \\rightarrow cl(\\alpha )\", color=WHITE).shift(DOWN * 0.5)\n \n self.play(\n FadeOut(cohomology_text),\n FadeOut(cohomology_group),\n FadeIn(map_text),\n run_time=1\n )\n \n self.play(Write(equation), run_time=2)\n self.play(Write(equation2), run_time=2)\n self.wait(1)\n \n # Element 6: Final visualization with both sides\n conclusion_text = Text(\"Bridging Algebra and Topology\", color=WHITE).to_edge(UP)\n \n # Recreate simplified versions of both visual elements\n cycles_simple = VGroup(\n Ellipse(width=2, height=1.5, color=GOLD, fill_opacity=0.2),\n Ellipse(width=1.8, height=1.8, color=PURPLE, fill_opacity=0.2).rotate(PI/4)\n ).scale(0.6).shift(LEFT * 3)\n \n cohomology_simple = VGroup(\n Dot(color=RED).shift(UP*0.5),\n Dot(color=BLUE).shift(DOWN*0.5),\n Line(UP*0.5, DOWN*0.5, color=YELLOW)\n ).scale(0.8).shift(RIGHT * 3)\n \n arrow = Arrow(LEFT * 1.5, RIGHT * 1.5, color=WHITE, buff=0.5)\n \n final_group = VGroup(cycles_simple, arrow, cohomology_simple)\n \n self.play(\n FadeOut(map_text),\n FadeOut(equation),\n FadeOut(equation2),\n FadeIn(conclusion_text),\n run_time=1\n )\n \n self.play(Create(final_group), run_time=3)\n self.wait(2)\n \n # Fade everything out\n self.play(\n FadeOut(conclusion_text),\n FadeOut(final_group),\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass CycleClassMapScene(Scene):\n def construct(self):\n # Element 1: Title screen\n title = Text(\"From Cycles to Cohomology:\", color=BBLUE).shift(UP * 0.5)\n subtitle = Text(\"Unlocking the Cycle Class Map\", color=BLUE).shift(DOWN * 0.5)\n \n # Create a grid for background (simplified)\n grid = VGroup()\n for i in range(-5, 6):\n h_line = Line(5*LEFT + i*UP, 5*RIGHT + i*UP, color=BLUE_E, stroke_opacity=0.3)\n v_line = Line(i*RIGHT + 5*UP, i*RIGHT + 5*DOWN, color=BLUE_E, stroke_opacity=0.3)\n grid.add(h_line, v_line)\n \n # Play title animation\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1.5)\n self.play(Create(grid), run_time=2)\n self.wait(1)\n self.play(FadeOut(grid), FadeOut(title), FadeOut(subtitle))\n \n # Element 2: Complex algebraic cycles\n tapestry_text = Text(\"Complex Algebraic Cycles\", color=WHITE).to_edge(UP)\n \n # Create an intricate geometric shape representing algebraic cycles\n cycles_group = VGroup()\n \n # Create several ellipses with different colors for the tapestry\n for i in range(5):\n ellipse = Ellipse(\n width=3 + i*0.4,\n height=2 + i*0.3,\n color=GOLD if i % 2 == 0 else PURPLE,\n stroke_width=2,\n fill_opacity=0.2\n ).rotate(PI/6 * i)\n cycles_group.add(ellipse)\n \n # Add some lines to represent intersections\n for i in range(4):\n line = Line(\n start=2*LEFT + (i-1.5)*UP,\n end=2*RIGHT + (1.5-i)*UP,\n color=BLUE,\n stroke_width=2\n )\n cycles_group.add(line)\n \n cycles_group.scale(0.8).shift(DOWN * 0.5)\n \n # Display the tapestry\n self.play(Write(tapestry_text))\n self.play(Create(cycles_group), run_time=3)\n self.wait(1)\n \n # Element 3: Zoom into a section and colorize cycles\n zoom_text = Text(\"Chow Group Cycles\", color=WHITE).to_edge(UP)\n \n # Create zoom effect by scaling\n cycles_group_zoomed = cycles_group.copy().scale(1.5)\n \n self.play(\n FadeOut(tapestry_text),\n FadeIn(zoom_text),\n Transform(cycles_group, cycles_group_zoomed),\n run_time=2\n )\n \n # Highlight different cycles with colors\n cycle1 = Ellipse(width=2, height=1.5, color=RED, fill_opacity=0.3).shift(LEFT*0.5)\n cycle2 = Ellipse(width=1.8, height=1.3, color=GREEN, fill_opacity=0.3).shift(RIGHT*0.5 + UP*0.3)\n cycle3 = Ellipse(width=1.6, height=1.7, color=BLUE, fill_opacity=0.3).shift(DOWN*0.5)\n \n self.play(\n FadeIn(cycle1),\n FadeIn(cycle2),\n FadeIn(cycle3),\n run_time=2\n )\n self.wait(1)\n \n # Element 4: Transform to cohomology ring\n cohomology_text = Text(\"Cohomology Ring\", color=WHITE).to_edge(UP)\n \n # Simpler representation for cohomology\n dot1 = Dot(color=RED).shift(LEFT*2)\n dot2 = Dot(color=GREEN).shift(UP*2)\n dot3 = Dot(color=BLUE).shift(RIGHT*2)\n \n line1 = Line(dot1.get_center(), dot2.get_center(), color=YELLOW)\n line2 = Line(dot2.get_center(), dot3.get_center(), color=YELLOW)\n line3 = Line(dot3.get_center(), dot1.get_center(), color=YELLOW)\n \n cohomology_group = VGroup(dot1, dot2, dot3, line1, line2, line3)\n cohomology_group.scale(0.8).shift(DOWN * 0.5)\n \n self.play(\n FadeOut(zoom_text),\n FadeOut(cycles_group),\n FadeOut(cycle1),\n FadeOut(cycle2),\n FadeOut(cycle3),\n FadeIn(cohomology_text),\n run_time=1\n )\n \n self.play(Create(cohomology_group), run_time=2)\n self.wait(1)\n \n # Element 5: Cycle class map\n map_text = Text(\"The Cycle Class Map\", color=WHITE).to_edge(UP)\n \n # Create equation for cycle class map (simplified)\n equation = Text(\"Chow(X) \\rightarrow H*(X, Z)\", color=WHITE).shift(UP * 0.5)\n equation2 = Text(\"\\alpha \\rightarrow cl(\\alpha )\", color=WHITE).shift(DOWN * 0.5)\n \n self.play(\n FadeOut(cohomology_text),\n FadeOut(cohomology_group),\n FadeIn(map_text),\n run_time=1\n )\n \n self.play(Write(equation), run_time=2)\n self.play(Write(equation2), run_time=2)\n self.wait(1)\n \n # Element 6: Final visualization with both sides\n conclusion_text = Text(\"Bridging Algebra and Topology\", color=WHITE).to_edge(UP)\n \n # Recreate simplified versions of both visual elements\n cycles_simple = VGroup(\n Ellipse(width=2, height=1.5, color=GOLD, fill_opacity=0.2),\n Ellipse(width=1.8, height=1.8, color=PURPLE, fill_opacity=0.2).rotate(PI/4)\n ).scale(0.6).shift(LEFT * 3)\n \n cohomology_simple = VGroup(\n Dot(color=RED).shift(UP*0.5),\n Dot(color=BLUE).shift(DOWN*0.5),\n Line(UP*0.5, DOWN*0.5, color=YELLOW)\n ).scale(0.8).shift(RIGHT * 3)\n \n arrow = Arrow(LEFT * 1.5, RIGHT * 1.5, color=WHITE, buff=0.5)\n \n final_group = VGroup(cycles_simple, arrow, cohomology_simple)\n \n self.play(\n FadeOut(map_text),\n FadeOut(equation),\n FadeOut(equation2),\n FadeIn(conclusion_text),\n run_time=1\n )\n \n self.play(Create(final_group), run_time=3)\n self.wait(2)\n \n # Fade everything out\n self.play(\n FadeOut(conclusion_text),\n FadeOut(final_group),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Here’s an enhanced version of the animation that retains the original nonagon while adding significant new features: \n- Act 2: I would like to create an animated sequence where a text appears and changes to describe the animation that follows. The animation should show a square growing from one of its edges in four different directions: down, ri", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0762(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_enhancednonagon()\n self.clear_stage()\n self.act_2_areaundercurveexample()\n\n def act_1_enhancednonagon(self):\n nonagon = RegularPolygon(n=9, radius=3.5, color=PINK)\n nonagon.set_fill(PINK, opacity=0.2)\n \n # Animate the creation of the nonagon\n self.play(Create(nonagon), run_time=2)\n self.wait(0.5)\n \n # Highlight vertices with dots and labels\n vertices = nonagon.get_vertices()\n dots = VGroup(*[Dot(vertex, color=YELLOW, radius=0.1).set_opacity(0.8) for vertex in vertices])\n labels = VGroup(*[\n Text(chr(65 + i), font_size=24, color=WHITE).next_to(vertex, direction=vertex / np.linalg.norm(vertex), buff=0.2)\n for i, vertex in enumerate(vertices)\n ])\n \n self.play(LaggedStart(*[Create(dot) for dot in dots], lag_ratio=0.1))\n self.play(LaggedStart(*[Write(label) for label in labels], lag_ratio=0.1))\n self.wait(1)\n \n # Display the interior angle formula\n formula = MathTex(\n r\"\\text{Interior angle} = \\frac{(9-2) \\times 180^\\circ}{9} = 140^\\circ\",\n font_size=36\n ).to_edge(DOWN)\n \n explanation = Text(\n \"For a regular n-sided polygon, the interior angle is given by (n-2)*180° / n.\",\n font_size=24,\n color=BLUE_C\n ).next_to(formula, UP)\n \n self.play(Write(formula))\n self.play(FadeIn(explanation))\n self.wait(2)\n \n # Morph nonagon into a nine-pointed star (enneagram)\n star = Star(n=9, outer_radius=3.5, color=GOLD, density=3)\n star.set_fill(GOLD, opacity=0.3)\n \n self.play(\n Transform(nonagon, star),\n FadeOut(dots),\n FadeOut(labels),\n FadeOut(formula),\n FadeOut(explanation),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate the star\n self.play(Rotate(star, angle=2*PI/9, about_point=ORIGIN), run_time=3, rate_func=smooth)\n self.wait(2)\n\n def act_2_areaundercurveexample(self):\n function = MathTex(r\"f(x) = 3 - x^2\")\n self.play(Write(function))\n self.wait(1)\n\n # Indicate the area of interest\n area_description = Text(\"Area under the curve from x=1 to x=2\", font_size=24).to_edge(UP)\n self.play(Write(area_description))\n self.wait(2)\n\n # Setup the definite integral\n definite_integral = MathTex(r\"\\int_1^2 (3 - x^2) \\,dx\")\n self.play(Transform(function, definite_integral))\n self.wait(1)\n\n # Steps to find the area\n step1 = MathTex(r\"= \\left[ 3x - \\frac{x^3}{3} \\right]_1^2\")\n self.play(ReplacementTransform(definite_integral.copy(), step1))\n self.wait(1)\n\n step2_description = Text(\"Calculate the definite integral\", font_size=24).to_edge(UP)\n self.play(Transform(area_description, step2_description))\n self.wait(2)\n\n # Show the final result\n final_area = MathTex(r\"= (6 - \\frac{8}{3}) - (3 - \\frac{1}{3})\", r\"= \\frac{7}{3}\")\n self.play(ReplacementTransform(step1, final_area))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The area is 7/3 square units\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_area))\n self.play(Write(conclusion))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0762(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_enhancednonagon()\n self.clear_stage()\n self.act_2_areaundercurveexample()\n\n def act_1_enhancednonagon(self):\n nonagon = RegularPolygon(n=9, radius=3.5, color=PINK)\n nonagon.set_fill(PINK, opacity=0.2)\n \n # Animate the creation of the nonagon\n self.play(Create(nonagon), run_time=2)\n self.wait(0.5)\n \n # Highlight vertices with dots and labels\n vertices = nonagon.get_vertices()\n dots = VGroup(*[Dot(vertex, color=YELLOW, radius=0.1).set_opacity(0.8) for vertex in vertices])\n labels = VGroup(*[\n Text(chr(65 + i), font_size=24, color=WHITE).next_to(vertex, direction=vertex / np.linalg.norm(vertex), buff=0.2)\n for i, vertex in enumerate(vertices)\n ])\n \n self.play(LaggedStart(*[Create(dot) for dot in dots], lag_ratio=0.1))\n self.play(LaggedStart(*[Write(label) for label in labels], lag_ratio=0.1))\n self.wait(1)\n \n # Display the interior angle formula\n formula = MathTex(\n r\"\\text{Interior angle} = \\frac{(9-2) \\times 180^\\circ}{9} = 140^\\circ\",\n font_size=36\n ).to_edge(DOWN)\n \n explanation = Text(\n \"For a regular n-sided polygon, the interior angle is given by (n-2)*180° / n.\",\n font_size=24,\n color=BBLUE_C\n ).next_to(formula, UP)\n \n self.play(Write(formula))\n self.play(FadeIn(explanation))\n self.wait(2)\n \n # Morph nonagon into a nine-pointed star (enneagram)\n star = Star(n=9, outer_radius=3.5, color=GOLD, density=3)\n star.set_fill(GOLD, opacity=0.3)\n \n self.play(\n Transform(nonagon, star),\n FadeOut(dots),\n FadeOut(labels),\n FadeOut(formula),\n FadeOut(explanation),\n run_time=2\n )\n self.wait(0.5)\n \n # Rotate the star\n self.play(Rotate(star, angle=2*PI/9, about_point=ORIGIN), run_time=3, rate_func=smooth)\n self.wait(2)\n\n def act_2_areaundercurveexample(self):\n function = MathTex(r\"f(x) = 3 - x^2\")\n self.play(Write(function))\n self.wait(1)\n\n # Indicate the area of interest\n area_description = Text(\"Area under the curve from x=1 to x=2\", font_size=24).to_edge(UP)\n self.play(Write(area_description))\n self.wait(2)\n\n # Setup the definite integral\n definite_integral = MathTex(r\"\\int_1^2 (3 - x^2) \\,dx\")\n self.play(Transform(function, definite_integral))\n self.wait(1)\n\n # Steps to find the area\n step1 = MathTex(r\"= \\left[ 3x - \\frac{x^3}{3} \\right]_1^2\")\n self.play(ReplacementTransform(definite_integral.copy(), step1))\n self.wait(1)\n\n step2_description = Text(\"Calculate the definite integral\", font_size=24).to_edge(UP)\n self.play(Transform(area_description, step2_description))\n self.wait(2)\n\n # Show the final result\n final_area = MathTex(r\"= (6 - \\frac{8}{3}) - (3 - \\frac{1}{3})\", r\"= \\frac{7}{3}\")\n self.play(ReplacementTransform(step1, final_area))\n self.wait(1)\n\n # Conclusion\n conclusion = Text(\"The area is 7/3 square units\", font_size=24).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_area))\n self.play(Write(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 instruction that builds upon the original while adding significant new features:\n- Act 2: I would like to create an animation where the text \"animate.arrange\" is transformed and shifted upwards at the beginning, run over a short period. Then, I want three numbers \"3\", \"1\", \"2\" to appear on the screen from lef\n- Act 3: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0163(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_squaretocirclewithmath()\n self.clear_stage()\n self.act_2_arrangeanimation()\n self.clear_stage()\n self.act_3_scaletofitanimation()\n\n def act_1_squaretocirclewithmath(self):\n square = Square(color=GREEN, fill_opacity=1)\n square_label = MathTex(\"A = s^2\").next_to(square, DOWN)\n \n # Draw square and its area formula\n self.play(DrawBorderThenFill(square))\n self.play(Write(square_label))\n self.wait(1)\n \n # Transform square to circle\n circle = Circle(color=BLUE, fill_opacity=1)\n circle.move_to(square.get_center())\n circle_area = MathTex(r\"A = \\pi r^2\").next_to(circle, DOWN)\n \n self.play(\n ReplacementTransform(square, circle),\n ReplacementTransform(square_label, circle_area)\n )\n self.wait(1)\n \n # Show radius and pulse circle\n radius_line = DashedLine(circle.get_center(), circle.get_right())\n radius_label = MathTex(\"r = 1\").next_to(radius_line, UP)\n \n self.play(\n Create(radius_line),\n Write(radius_label),\n Indicate(circle)\n )\n self.wait(1)\n \n # Transform circle to circumscribed square\n big_square = Square(side_length=2, color=RED, fill_opacity=0.5)\n big_square.move_to(circle.get_center())\n ratio_text = MathTex(r\"\\frac{A_{\\square}}{A_{\\bigcirc}} = \\frac{4}{\\pi}\").scale(0.8)\n ratio_text.move_to(UP * 2)\n \n self.play(\n ReplacementTransform(circle, big_square),\n FadeOut(radius_line),\n FadeOut(radius_label),\n ReplacementTransform(circle_area, ratio_text)\n )\n \n # Add explanatory text\n explanation = Text(\"Circumscribed square area to circle area ratio\").scale(0.6)\n explanation.next_to(ratio_text, DOWN)\n self.play(Write(explanation))\n self.wait(2)\n \n # Fade out all elements\n self.play(\n FadeOut(big_square),\n FadeOut(explanation)\n )\n self.wait(0.5)\n self.play(FadeOut(ratio_text))\n self.wait(1)\n\n def act_2_arrangeanimation(self):\n title = Text(\"animate.arrange\", font_size=48)\n self.play(Write(title))\n \n # Shift text upwards over a short duration\n self.play(title.animate.shift(UP * 2.5), run_time=0.5)\n\n # 2. Number Appearance\n # Create individual text objects for independent rearrangement\n num_3 = Text(\"3\", font_size=48)\n num_1 = Text(\"1\", font_size=48)\n num_2 = Text(\"2\", font_size=48)\n\n # Group in specific visual order: 3, 1, 2 from left to right\n numbers = VGroup(num_3, num_1, num_2)\n numbers.arrange(RIGHT, buff=1.0)\n numbers.next_to(title, DOWN, buff=1.5)\n\n # Display numbers from left to right\n self.play(LaggedStart(*[FadeIn(num) for num in numbers], lag_ratio=0.2))\n\n # 3. Rearrangement\n # Brief pause after numbers appear\n self.wait(0.5)\n\n # Calculate target positions for ascending numerical order (1, 2, 3)\n sorted_targets = VGroup(num_1, num_2, num_3)\n sorted_targets.arrange(RIGHT, buff=1.0)\n \n # Match center to prevent the group from jumping to a new location\n sorted_targets.move_to(numbers.get_center())\n\n # Animate rearrangement with equal spacing\n self.play(\n num_1.animate.move_to(sorted_targets[0].get_center()),\n num_2.animate.move_to(sorted_targets[1].get_center()),\n num_3.animate.move_to(sorted_targets[2].get_center()),\n run_time=1.5\n )\n\n # 4. Cleanup\n self.wait(0.5)\n self.play(FadeOut(title), FadeOut(numbers))\n\n def act_3_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0163(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_squaretocirclewithmath()\n self.clear_stage()\n self.act_2_arrangeanimation()\n self.clear_stage()\n self.act_3_scaletofitanimation()\n\n def act_1_squaretocirclewithmath(self):\n square = Square(color=GREEN, fill_opacity=1)\n square_label = MathTex(\"A = s^2\").next_to(square, DOWN)\n \n # Draw square and its area formula\n self.play(DrawBorderThenFill(square))\n self.play(Write(square_label))\n self.wait(1)\n \n # Transform square to circle\n circle = Circle(color=BBLUE, fill_opacity=1)\n circle.move_to(square.get_center())\n circle_area = MathTex(r\"A = \\pi r^2\").next_to(circle, DOWN)\n \n self.play(\n ReplacementTransform(square, circle),\n ReplacementTransform(square_label, circle_area)\n )\n self.wait(1)\n \n # Show radius and pulse circle\n radius_line = DashedLine(circle.get_center(), circle.get_right())\n radius_label = MathTex(\"r = 1\").next_to(radius_line, UP)\n \n self.play(\n Create(radius_line),\n Write(radius_label),\n Indicate(circle)\n )\n self.wait(1)\n \n # Transform circle to circumscribed square\n big_square = Square(side_length=2, color=RED, fill_opacity=0.5)\n big_square.move_to(circle.get_center())\n ratio_text = MathTex(r\"\\frac{A_{\\square}}{A_{\\bigcirc}} = \\frac{4}{\\pi}\").scale(0.8)\n ratio_text.move_to(UP * 2)\n \n self.play(\n ReplacementTransform(circle, big_square),\n FadeOut(radius_line),\n FadeOut(radius_label),\n ReplacementTransform(circle_area, ratio_text)\n )\n \n # Add explanatory text\n explanation = Text(\"Circumscribed square area to circle area ratio\").scale(0.6)\n explanation.next_to(ratio_text, DOWN)\n self.play(Write(explanation))\n self.wait(2)\n \n # Fade out all elements\n self.play(\n FadeOut(big_square),\n FadeOut(explanation)\n )\n self.wait(0.5)\n self.play(FadeOut(ratio_text))\n self.wait(1)\n\n def act_2_arrangeanimation(self):\n title = Text(\"animate.arrange\", font_size=48)\n self.play(Write(title))\n \n # Shift text upwards over a short duration\n self.play(title.animate.shift(UP * 2.5), run_time=0.5)\n\n # 2. Number Appearance\n # Create individual text objects for independent rearrangement\n num_3 = Text(\"3\", font_size=48)\n num_1 = Text(\"1\", font_size=48)\n num_2 = Text(\"2\", font_size=48)\n\n # Group in specific visual order: 3, 1, 2 from left to right\n numbers = VGroup(num_3, num_1, num_2)\n numbers.arrange(RIGHT, buff=1.0)\n numbers.next_to(title, DOWN, buff=1.5)\n\n # Display numbers from left to right\n self.play(LaggedStart(*[FadeIn(num) for num in numbers], lag_ratio=0.2))\n\n # 3. Rearrangement\n # Brief pause after numbers appear\n self.wait(0.5)\n\n # Calculate target positions for ascending numerical order (1, 2, 3)\n sorted_targets = VGroup(num_1, num_2, num_3)\n sorted_targets.arrange(RIGHT, buff=1.0)\n \n # Match center to prevent the group from jumping to a new location\n sorted_targets.move_to(numbers.get_center())\n\n # Animate rearrangement with equal spacing\n self.play(\n num_1.animate.move_to(sorted_targets[0].get_center()),\n num_2.animate.move_to(sorted_targets[1].get_center()),\n num_3.animate.move_to(sorted_targets[2].get_center()),\n run_time=1.5\n )\n\n # 4. Cleanup\n self.wait(0.5)\n self.play(FadeOut(title), FadeOut(numbers))\n\n def act_3_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 significant new elements: \n- Act 2: How can I create an animation that starts with a semi-transparent red triangle, then transitions into a semi-transparent yellow square, followed by a brief highlight of the square before it disappears?\n- Act 3: 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 ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0233(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_enhancedrotationscene()\n self.clear_stage()\n self.act_2_shapetransitionscene()\n self.clear_stage()\n self.act_3_ptestconvergence()\n\n def act_1_enhancedrotationscene(self):\n line = Line(start=[-2, 1, 0], end=[2, -1, 0], color=BLUE)\n circle = Circle(radius=1, color=RED)\n \n # Group them\n group = VGroup(line, circle)\n \n # Add them to the scene\n self.play(Create(line), Create(circle))\n self.wait(0.5)\n \n # Rotate the group\n self.play(Rotate(group, angle=45 * DEGREES, about_point=ORIGIN))\n self.wait(0.5)\n \n # Transform the line into a sine wave\n def sine_wave(t):\n return np.array([\n t,\n np.sin(t * 2) * 0.5,\n 0\n ])\n \n sine_func = ParametricFunction(\n sine_wave,\n t_range=[-3, 3],\n color=GREEN\n ).rotate(45 * DEGREES, about_point=ORIGIN)\n \n # Split the circle into two orbiting circles\n small_circle1 = Circle(radius=0.4, color=YELLOW).move_to([0.5, 0.5, 0])\n small_circle2 = Circle(radius=0.4, color=PURPLE).move_to([-0.5, -0.5, 0])\n \n # Animate transformations\n self.play(\n Transform(line, sine_func),\n ReplacementTransform(circle, VGroup(small_circle1, small_circle2))\n )\n \n # Orbit the small circles\n self.play(\n small_circle1.animate.move_to([-0.5, 0.5, 0]),\n small_circle2.animate.move_to([0.5, -0.5, 0]),\n run_time=2\n )\n \n # Add rotation formula\n rotation_formula = MathTex(\n r\"R(\\theta) = \\begin{pmatrix} \\cos\\theta & -\\sin\\theta \\\\ \\sin\\theta & \\cos\\theta \\end{pmatrix}\",\n color=WHITE\n ).to_edge(UP)\n \n self.play(Write(rotation_formula))\n self.wait(1)\n \n # Fade out all elements except the formula\n self.play(\n FadeOut(line),\n FadeOut(small_circle1),\n FadeOut(small_circle2),\n run_time=1\n )\n \n self.wait(2)\n\n def act_2_shapetransitionscene(self):\n triangle = Triangle()\n triangle.set_fill(RED, opacity=0.5)\n triangle.set_stroke(RED, width=2)\n\n # 2. Target Object: Semi-transparent yellow square\n square = Square()\n square.set_fill(YELLOW, opacity=0.5)\n square.set_stroke(YELLOW, width=2)\n\n # Show the triangle\n self.play(FadeIn(triangle))\n self.wait(0.5)\n\n # 3. Transformation: Morph the triangle into the square\n # ReplacementTransform interpolates points and colors, replacing the original mobject\n self.play(ReplacementTransform(triangle, square), run_time=1.5)\n self.wait(0.2)\n\n # 4. Highlight Effect: A brief scale pulse and flash\n # Scale up and down quickly to create a \"pop\" effect\n self.play(\n square.animate.scale(1.2), \n run_time=0.15, \n rate_func=there_and_back\n )\n # Add a flash for extra visual emphasis\n self.play(Flash(square, color=YELLOW, line_length=0.3, flash_radius=0.5))\n self.wait(0.5)\n\n # 5. Disappearance: Fade out the square\n self.play(FadeOut(square))\n self.wait(1)\n\n def act_3_ptestconvergence(self):\n series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=72)\n self.play(Write(series))\n self.wait(1)\n\n # 2. Explanation: Introduce the \"p-test\"\n intro_text = Text(\"We will apply the p-test\", font_size=36, color=BLUE)\n intro_text.next_to(series, DOWN, buff=1)\n self.play(Write(intro_text))\n self.wait(1)\n\n # 3. Application: Show that p = 2 and explicitly show 2 > 1\n logic_group = VGroup(\n MathTex(r\"p = 2\", font_size=48),\n MathTex(r\"2 > 1\", font_size=48, color=YELLOW)\n ).arrange(RIGHT, buff=0.8).next_to(intro_text, DOWN, buff=0.5)\n\n self.play(FadeIn(logic_group, shift=UP * 0.3))\n self.wait(2)\n\n # 4. Conclusion: Smoothly replace the explanation text with the conclusion statement\n conclusion_text = Text(\"The series is convergent.\", font_size=48, color=GREEN)\n conclusion_text.move_to(intro_text)\n\n self.play(\n ReplacementTransform(VGroup(intro_text, logic_group), conclusion_text),\n series.animate.set_opacity(0.3)\n )\n self.wait(2)\n\n # 5. Final Scene: Clear the screen and re-write the conclusion\n self.play(FadeOut(VGroup(series, conclusion_text)))\n self.wait(0.5)\n\n final_statement = Text(\"The series is convergent.\", font_size=60, color=GREEN)\n self.play(Write(final_statement))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0233(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_enhancedrotationscene()\n self.clear_stage()\n self.act_2_shapetransitionscene()\n self.clear_stage()\n self.act_3_ptestconvergence()\n\n def act_1_enhancedrotationscene(self):\n line = Line(start=[-2, 1, 0], end=[2, -1, 0], color=BLUE)\n circle = Circle(radius=1, color=RED)\n \n # Group them\n group = VGroup(line, circle)\n \n # Add them to the scene\n self.play(Create(line), Create(circle))\n self.wait(0.5)\n \n # Rotate the group\n self.play(Rotate(group, angle=45 * DEGREES, about_point=ORIGIN))\n self.wait(0.5)\n \n # Transform the line into a sine wave\n def sine_wave(t):\n return np.array([\n t,\n np.sin(t * 2) * 0.5,\n 0\n ])\n \n sine_func = ParametricFunction(\n sine_wave,\n t_range=[-3, 3],\n color=GREEN\n ).rotate(45 * DEGREES, about_point=ORIGIN)\n \n # Split the circle into two orbiting circles\n small_circle1 = Circle(radius=0.4, color=YELLOW).move_to([0.5, 0.5, 0])\n small_circle2 = Circle(radius=0.4, color=PURPLE).move_to([-0.5, -0.5, 0])\n \n # Animate transformations\n self.play(\n Transform(line, sine_func),\n ReplacementTransform(circle, VGroup(small_circle1, small_circle2))\n )\n \n # Orbit the small circles\n self.play(\n small_circle1.animate.move_to([-0.5, 0.5, 0]),\n small_circle2.animate.move_to([0.5, -0.5, 0]),\n run_time=2\n )\n \n # Add rotation formula\n rotation_formula = MathText(\n r\"R(\\theta) = \\begin{pmatrix} \\cos\\theta & -\\sin\\theta \\\\ \\sin\\theta & \\cos\\theta \\end{pmatrix}\",\n color=WHITE\n ).to_edge(UP)\n \n self.play(Write(rotation_formula))\n self.wait(1)\n \n # Fade out all elements except the formula\n self.play(\n FadeOut(line),\n FadeOut(small_circle1),\n FadeOut(small_circle2),\n run_time=1\n )\n \n self.wait(2)\n\n def act_2_shapetransitionscene(self):\n triangle = Triangle()\n triangle.set_fill(RED, opacity=0.5)\n triangle.set_stroke(RED, width=2)\n\n # 2. Target Object: Semi-transparent yellow square\n square = Square()\n square.set_fill(YELLOW, opacity=0.5)\n square.set_stroke(YELLOW, width=2)\n\n # Show the triangle\n self.play(FadeIn(triangle))\n self.wait(0.5)\n\n # 3. Transformation: Morph the triangle into the square\n # ReplacementTransform interpolates points and colors, replacing the original mobject\n self.play(ReplacementTransform(triangle, square), run_time=1.5)\n self.wait(0.2)\n\n # 4. Highlight Effect: A brief scale pulse and flash\n # Scale up and down quickly to create a \"pop\" effect\n self.play(\n square.animate.scale(1.2), \n run_time=0.15, \n rate_func=there_and_back\n )\n # Add a flash for extra visual emphasis\n self.play(Flash(square, color=YELLOW, line_length=0.3, flash_radius=0.5))\n self.wait(0.5)\n\n # 5. Disappearance: Fade out the square\n self.play(FadeOut(square))\n self.wait(1)\n\n def act_3_ptestconvergence(self):\n series = MathTex(r\"\\sum_{n=1}^{\\infty} \\frac{1}{n^2}\", font_size=72)\n self.play(Write(series))\n self.wait(1)\n\n # 2. Explanation: Introduce the \"p-test\"\n intro_text = Text(\"We will apply the p-test\", font_size=36, color=BLUE)\n intro_text.next_to(series, DOWN, buff=1)\n self.play(Write(intro_text))\n self.wait(1)\n\n # 3. Application: Show that p = 2 and explicitly show 2 > 1\n logic_group = VGroup(\n MathTex(r\"p = 2\", font_size=48),\n MathTex(r\"2 > 1\", font_size=48, color=YELLOW)\n ).arrange(RIGHT, buff=0.8).next_to(intro_text, DOWN, buff=0.5)\n\n self.play(FadeIn(logic_group, shift=UP * 0.3))\n self.wait(2)\n\n # 4. Conclusion: Smoothly replace the explanation text with the conclusion statement\n conclusion_text = Text(\"The series is convergent.\", font_size=48, color=GREEN)\n conclusion_text.move_to(intro_text)\n\n self.play(\n ReplacementTransform(VGroup(intro_text, logic_group), conclusion_text),\n series.animate.set_opacity(0.3)\n )\n self.wait(2)\n\n # 5. Final Scene: Clear the screen and re-write the conclusion\n self.play(FadeOut(VGroup(series, conclusion_text)))\n self.wait(0.5)\n\n final_statement = Text(\"The series is convergent.\", font_size=60, color=GREEN)\n self.play(Write(final_statement))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Simple Address Translation Process\n1. Extract the page number P from the logical address.\n2. Query the page table to find the physical block number F corresponding to page number P.\n3. Physical address = `F * page size + offset d` (usually implemented through binary concatenation).\n\n\nContext location within the document (from highest to current level):\n# 07-Fundamentals of Memory Management and Paging\n## Pages, Frames, and Address Translation Process\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AddressTranslation(Scene):\n\n def construct(self):\n title = Title('Simple Address Translation Process')\n self.add(title)\n logical_p_rect = Rectangle(width=1.5, height=1.0, color=BLUE)\n logical_p_text = MathTex('P').move_to(logical_p_rect)\n logical_p = VGroup(logical_p_rect, logical_p_text)\n logical_d_rect = Rectangle(width=2.5, height=1.0, color=GREEN)\n logical_d_text = MathTex('d').move_to(logical_d_rect)\n logical_d = VGroup(logical_d_rect, logical_d_text)\n logical_addr = VGroup(logical_p, logical_d).arrange(RIGHT, buff=0)\n logical_label = Text('Logical Address', font_size=24).next_to(logical_addr, UP)\n logical_group = VGroup(logical_label, logical_addr).move_to(UP * 1.5 + LEFT * 2.5)\n table = Table([['0', '12'], ['...', '...'], ['P', 'F']], col_labels=[Text('Page'), Text('Frame')], include_outer_lines=True).scale(0.6).move_to(RIGHT * 3.5 + DOWN * 0.5)\n table_label = Text('Page Table', font_size=24).next_to(table, UP)\n table_group = VGroup(table_label, table)\n phys_f_rect = Rectangle(width=1.5, height=1.0, color=RED)\n phys_f_text = MathTex('F').move_to(phys_f_rect)\n phys_f = VGroup(phys_f_rect, phys_f_text)\n phys_d_rect = Rectangle(width=2.5, height=1.0, color=GREEN)\n phys_d_text = MathTex('d').move_to(phys_d_rect)\n phys_d = VGroup(phys_d_rect, phys_d_text)\n phys_addr = VGroup(phys_f, phys_d).arrange(RIGHT, buff=0)\n phys_label = Text('Physical Address', font_size=24).next_to(phys_addr, DOWN)\n phys_group = VGroup(phys_addr, phys_label).move_to(DOWN * 2.0 + LEFT * 2.5)\n step1_text = Text('1. Extract the page number P from the logical address.', font_size=22).to_edge(DOWN)\n step2_text = Text('2. Query the page table to find the physical block number F.', font_size=22).to_edge(DOWN)\n step3_text = VGroup(Text('3. Physical address = F * page size + offset d', font_size=22), Text('(Implemented through binary concatenation)', font_size=18, color=GRAY)).arrange(DOWN, buff=0.1).to_edge(DOWN)\n self.play(FadeIn(logical_group), FadeIn(table_group))\n self.wait(1)\n self.play(Write(step1_text))\n self.play(logical_p_rect.animate.set_fill(BLUE, opacity=0.3))\n arrow_p_to_table = CurvedArrow(logical_p_rect.get_right(), table.get_rows()[3].get_left(), angle=-PI / 4, color=BLUE)\n self.play(Create(arrow_p_to_table))\n self.wait(1)\n self.play(FadeOut(step1_text), FadeIn(step2_text))\n row_highlight = SurroundingRectangle(table.get_rows()[3], color=YELLOW, buff=0.05)\n self.play(Create(row_highlight))\n self.play(table.get_cell((4, 2)).animate.set_color(RED))\n self.wait(1)\n self.play(FadeOut(step2_text), FadeIn(step3_text))\n self.play(FadeIn(phys_label), Create(phys_f_rect), Create(phys_d_rect))\n arrow_f_to_phys = CurvedArrow(table.get_cell((4, 2)).get_bottom(), phys_f_rect.get_top(), angle=PI / 4, color=RED)\n self.play(Create(arrow_f_to_phys))\n f_copy = table.get_cell((4, 2)).copy()\n self.play(f_copy.animate.move_to(phys_f_text.get_center()))\n self.play(FadeIn(phys_f_text), FadeOut(f_copy))\n self.play(phys_f_rect.animate.set_fill(RED, opacity=0.3))\n arrow_d_to_phys = DashedLine(logical_d_rect.get_bottom(), phys_d_rect.get_top(), color=GREEN).add_tip()\n self.play(Create(arrow_d_to_phys))\n self.play(logical_d_rect.animate.set_fill(GREEN, opacity=0.3))\n d_copy = logical_d_text.copy()\n self.play(d_copy.animate.move_to(phys_d_text.get_center()))\n self.play(FadeIn(phys_d_text), FadeOut(d_copy))\n self.play(phys_d_rect.animate.set_fill(GREEN, opacity=0.3))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass AddressTranslation(Scene):\n\n def construct(self):\n title = Title('Simple Address Translation Process')\n self.add(title)\n logical_p_rect = Rectangle(width=1.5, height=1.0, color=BBLUE)\n logical_p_text = MathTex('P').move_to(logical_p_rect)\n logical_p = VGroup(logical_p_rect, logical_p_text)\n logical_d_rect = Rectangle(width=2.5, height=1.0, color=GREEN)\n logical_d_text = MathTex('d').move_to(logical_d_rect)\n logical_d = VGroup(logical_d_rect, logical_d_text)\n logical_addr = VGroup(logical_p, logical_d).arrange(RIGHT, buff=0)\n logical_label = Text('Logical Address', font_size=24).next_to(logical_addr, UP)\n logical_group = VGroup(logical_label, logical_addr).move_to(UP * 1.5 + LEFT * 2.5)\n table = Table([['0', '12'], ['...', '...'], ['P', 'F']], col_labels=[Text('Page'), Text('Frame')], include_outer_lines=True).scale(0.6).move_to(RIGHT * 3.5 + DOWN * 0.5)\n table_label = Text('Page Table', font_size=24).next_to(table, UP)\n table_group = VGroup(table_label, table)\n phys_f_rect = Rectangle(width=1.5, height=1.0, color=RED)\n phys_f_text = MathTex('F').move_to(phys_f_rect)\n phys_f = VGroup(phys_f_rect, phys_f_text)\n phys_d_rect = Rectangle(width=2.5, height=1.0, color=GREEN)\n phys_d_text = MathTex('d').move_to(phys_d_rect)\n phys_d = VGroup(phys_d_rect, phys_d_text)\n phys_addr = VGroup(phys_f, phys_d).arrange(RIGHT, buff=0)\n phys_label = Text('Physical Address', font_size=24).next_to(phys_addr, DOWN)\n phys_group = VGroup(phys_addr, phys_label).move_to(DOWN * 2.0 + LEFT * 2.5)\n step1_text = Text('1. Extract the page number P from the logical address.', font_size=22).to_edge(DOWN)\n step2_text = Text('2. Query the page table to find the physical block number F.', font_size=22).to_edge(DOWN)\n step3_text = VGroup(Text('3. Physical address = F * page size + offset d', font_size=22), Text('(Implemented through binary concatenation)', font_size=18, color=GRAY)).arrange(DOWN, buff=0.1).to_edge(DOWN)\n self.play(FadeIn(logical_group), FadeIn(table_group))\n self.wait(1)\n self.play(Write(step1_text))\n self.play(logical_p_rect.animate.set_fill(BLUE, opacity=0.3))\n arrow_p_to_table = CurvedArrow(logical_p_rect.get_right(), table.get_rows()[3].get_left(), angle=-PI / 4, color=BLUE)\n self.play(Create(arrow_p_to_table))\n self.wait(1)\n self.play(FadeOut(step1_text), FadeIn(step2_text))\n row_highlight = SurroundingRectangle(table.get_rows()[3], color=YELLOW, buff=0.05)\n self.play(Create(row_highlight))\n self.play(table.get_cell((4, 2)).animate.set_color(RED))\n self.wait(1)\n self.play(FadeOut(step2_text), FadeIn(step3_text))\n self.play(FadeIn(phys_label), Create(phys_f_rect), Create(phys_d_rect))\n arrow_f_to_phys = CurvedArrow(table.get_cell((4, 2)).get_bottom(), phys_f_rect.get_top(), angle=PI / 4, color=RED)\n self.play(Create(arrow_f_to_phys))\n f_copy = table.get_cell((4, 2)).copy()\n self.play(f_copy.animate.move_to(phys_f_text.get_center()))\n self.play(FadeIn(phys_f_text), FadeOut(f_copy))\n self.play(phys_f_rect.animate.set_fill(RED, opacity=0.3))\n arrow_d_to_phys = DashedLine(logical_d_rect.get_bottom(), phys_d_rect.get_top(), color=GREEN).add_tip()\n self.play(Create(arrow_d_to_phys))\n self.play(logical_d_rect.animate.set_fill(GREEN, opacity=0.3))\n d_copy = logical_d_text.copy()\n self.play(d_copy.animate.move_to(phys_d_text.get_center()))\n self.play(FadeIn(phys_d_text), FadeOut(d_copy))\n self.play(phys_d_rect.animate.set_fill(GREEN, opacity=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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does the tensor product of two vector spaces correlate with the creation of a 'grid-like' structure representing all possible pairs of vectors?", "chosen": "```python\nfrom manim import *\n\nclass TensorProductScene(Scene):\n def construct(self):\n # Title screen\n title = Text(\"Exploring Vector Spaces:\", font_size=42)\n subtitle = Text(\"The Magic of Tensor Products\", font_size=36)\n title_group = VGroup(title, subtitle).arrange(DOWN).scale(0.8)\n \n # Animate the title\n self.play(Write(title_group))\n self.wait(1)\n self.play(FadeOut(title_group))\n \n # Introduction to vector spaces\n intro_text = Text(\"Two Vector Spaces\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Create two lines to represent vector spaces V and W\n v_space = Line(start=LEFT * 3, end=RIGHT * 3, color=BLUE)\n w_space = Line(start=DOWN * 3, end=UP * 3, color=RED)\n \n v_label = Text(\"V\", font_size=36, color=BLUE).next_to(v_space, DOWN)\n w_label = Text(\"W\", font_size=36, color=RED).next_to(w_space, RIGHT)\n \n # Animate the creation of the two vector spaces\n self.play(Create(v_space), Write(v_label))\n self.play(Create(w_space), Write(w_label))\n self.wait(1)\n \n # Key concept: Grid formation\n key_concept = Text(\"Key Concept: Grid of Possibilities\", font_size=36)\n self.play(Write(key_concept))\n self.wait(1)\n self.play(FadeOut(key_concept))\n \n # Create additional horizontal lines representing vectors in V\n horizontal_lines = VGroup()\n for i in range(-2, 3):\n if i == 0:\n continue # Skip the center line as we already have it\n line = Line(\n start=LEFT * 3 + UP * i,\n end=RIGHT * 3 + UP * i,\n color=BLUE_D,\n stroke_width=2\n )\n horizontal_lines.add(line)\n \n # Create additional vertical lines representing vectors in W\n vertical_lines = VGroup()\n for i in range(-2, 3):\n if i == 0:\n continue # Skip the center line as we already have it\n line = Line(\n start=LEFT * i + UP * 3,\n end=LEFT * i + DOWN * 3,\n color=RED_D,\n stroke_width=2\n )\n vertical_lines.add(line)\n \n # Animate the creation of the grid\n self.play(Create(horizontal_lines), run_time=1)\n self.play(Create(vertical_lines), run_time=1)\n self.wait(1)\n \n # Explain the intersections as tensor products\n intersection_text = Text(\"Intersections: Tensor Products\", font_size=32)\n self.play(Write(intersection_text))\n self.wait(1)\n self.play(FadeOut(intersection_text))\n \n # Create dots at the intersections\n dots = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n dot = Dot(point=RIGHT * i + UP * j, color=YELLOW)\n dots.add(dot)\n \n # Animate the creation of intersection points\n self.play(Create(dots), run_time=1.5)\n self.wait(1)\n \n # Zoom into one specific intersection\n zoom_text = Text(\"Each Point: v ⊗ w\", font_size=32)\n self.play(Write(zoom_text))\n self.wait(1)\n self.play(FadeOut(zoom_text))\n \n # Highlight a specific intersection point\n selected_dot = Dot(point=RIGHT * 1 + UP * 2, color=GREEN, radius=0.15)\n self.play(\n FadeOut(dots),\n Create(selected_dot)\n )\n \n # Show how this point represents a tensor product\n arrow = Arrow(start=RIGHT * 1 + UP * 2, end=RIGHT * 1.5 + UP * 2.5, color=WHITE)\n new_vector = Dot(point=RIGHT * 1.5 + UP * 2.5, color=PURPLE, radius=0.1)\n new_label = Text(\"v ⊗ w\", font_size=24, color=PURPLE).next_to(new_vector, RIGHT)\n \n self.play(\n Create(arrow),\n Create(new_vector),\n Write(new_label)\n )\n self.wait(1)\n \n # Mathematical definition section\n formula_text = Text(\"Mathematical Definition\", font_size=32)\n self.play(\n FadeOut(arrow),\n FadeOut(new_vector),\n FadeOut(new_label),\n FadeOut(selected_dot),\n Write(formula_text)\n )\n self.wait(1)\n self.play(FadeOut(formula_text))\n \n # Show the first formula: the definition of tensor product\n formula = Text(\"V ⊗ W = { v_i ⊗ w_j | v_i ∈ V, w_j ∈ W }\", font_size=32)\n self.play(Write(formula))\n self.wait(1)\n \n # Show the second formula: distributive property\n formula2 = Text(\"(c₁v₁ + c₂v₂) ⊗ w = c₁(v₁ ⊗ w) + c₂(v₂ ⊗ w)\", font_size=32)\n self.play(Transform(formula, formula2))\n self.wait(1)\n \n # Clean up the scene for the conclusion\n self.play(\n FadeOut(formula),\n FadeOut(horizontal_lines),\n FadeOut(vertical_lines),\n FadeOut(v_space),\n FadeOut(w_space),\n FadeOut(v_label),\n FadeOut(w_label)\n )\n \n # Show the conclusion\n conclusion = Text(\"Tensor products create a grid-like structure\\nrepresenting all possible combinations\\nof vectors from two spaces\", \n font_size=32)\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n \n # Final message\n final_text = Text(\"The Magic of Tensor Products\", font_size=42, color=YELLOW)\n self.play(Write(final_text))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass TensorProductScene(Scene):\n def construct(self):\n # Title screen\n title = Text(\"Exploring Vector Spaces:\", font_size=42)\n subtitle = Text(\"The Magic of Tensor Products\", font_size=36)\n title_group = VGroup(title, subtitle).arrange(DOWN).scale(0.8)\n \n # Animate the title\n self.play(Write(title_group))\n self.wait(1)\n self.play(FadeOut(title_group))\n \n # Introduction to vector spaces\n intro_text = Text(\"Two Vector Spaces\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Create two lines to represent vector spaces V and W\n v_space = Line(start=LEFT * 3, end=RIGHT * 3, color=BBLUE)\n w_space = Line(start=DOWN * 3, end=UP * 3, color=RED)\n \n v_label = Text(\"V\", font_size=36, color=BLUE).next_to(v_space, DOWN)\n w_label = Text(\"W\", font_size=36, color=RED).next_to(w_space, RIGHT)\n \n # Animate the creation of the two vector spaces\n self.play(Create(v_space), Write(v_label))\n self.play(Create(w_space), Write(w_label))\n self.wait(1)\n \n # Key concept: Grid formation\n key_concept = Text(\"Key Concept: Grid of Possibilities\", font_size=36)\n self.play(Write(key_concept))\n self.wait(1)\n self.play(FadeOut(key_concept))\n \n # Create additional horizontal lines representing vectors in V\n horizontal_lines = VGroup()\n for i in range(-2, 3):\n if i == 0:\n continue # Skip the center line as we already have it\n line = Line(\n start=LEFT * 3 + UP * i,\n end=RIGHT * 3 + UP * i,\n color=BLUE_D,\n stroke_width=2\n )\n horizontal_lines.add(line)\n \n # Create additional vertical lines representing vectors in W\n vertical_lines = VGroup()\n for i in range(-2, 3):\n if i == 0:\n continue # Skip the center line as we already have it\n line = Line(\n start=LEFT * i + UP * 3,\n end=LEFT * i + DOWN * 3,\n color=RED_D,\n stroke_width=2\n )\n vertical_lines.add(line)\n \n # Animate the creation of the grid\n self.play(Create(horizontal_lines), run_time=1)\n self.play(Create(vertical_lines), run_time=1)\n self.wait(1)\n \n # Explain the intersections as tensor products\n intersection_text = Text(\"Intersections: Tensor Products\", font_size=32)\n self.play(Write(intersection_text))\n self.wait(1)\n self.play(FadeOut(intersection_text))\n \n # Create dots at the intersections\n dots = VGroup()\n for i in range(-2, 3):\n for j in range(-2, 3):\n dot = Dot(point=RIGHT * i + UP * j, color=YELLOW)\n dots.add(dot)\n \n # Animate the creation of intersection points\n self.play(Create(dots), run_time=1.5)\n self.wait(1)\n \n # Zoom into one specific intersection\n zoom_text = Text(\"Each Point: v ⊗ w\", font_size=32)\n self.play(Write(zoom_text))\n self.wait(1)\n self.play(FadeOut(zoom_text))\n \n # Highlight a specific intersection point\n selected_dot = Dot(point=RIGHT * 1 + UP * 2, color=GREEN, radius=0.15)\n self.play(\n FadeOut(dots),\n Create(selected_dot)\n )\n \n # Show how this point represents a tensor product\n arrow = Arrow(start=RIGHT * 1 + UP * 2, end=RIGHT * 1.5 + UP * 2.5, color=WHITE)\n new_vector = Dot(point=RIGHT * 1.5 + UP * 2.5, color=PURPLE, radius=0.1)\n new_label = Text(\"v ⊗ w\", font_size=24, color=PURPLE).next_to(new_vector, RIGHT)\n \n self.play(\n Create(arrow),\n Create(new_vector),\n Write(new_label)\n )\n self.wait(1)\n \n # Mathematical definition section\n formula_text = Text(\"Mathematical Definition\", font_size=32)\n self.play(\n FadeOut(arrow),\n FadeOut(new_vector),\n FadeOut(new_label),\n FadeOut(selected_dot),\n Write(formula_text)\n )\n self.wait(1)\n self.play(FadeOut(formula_text))\n \n # Show the first formula: the definition of tensor product\n formula = Text(\"V ⊗ W = { v_i ⊗ w_j | v_i ∈ V, w_j ∈ W }\", font_size=32)\n self.play(Write(formula))\n self.wait(1)\n \n # Show the second formula: distributive property\n formula2 = Text(\"(c₁v₁ + c₂v₂) ⊗ w = c₁(v₁ ⊗ w) + c₂(v₂ ⊗ w)\", font_size=32)\n self.play(Transform(formula, formula2))\n self.wait(1)\n \n # Clean up the scene for the conclusion\n self.play(\n FadeOut(formula),\n FadeOut(horizontal_lines),\n FadeOut(vertical_lines),\n FadeOut(v_space),\n FadeOut(w_space),\n FadeOut(v_label),\n FadeOut(w_label)\n )\n \n # Show the conclusion\n conclusion = Text(\"Tensor products create a grid-like structure\\nrepresenting all possible combinations\\nof vectors from two spaces\", \n font_size=32)\n \n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n \n # Final message\n final_text = Text(\"The Magic of Tensor Products\", font_size=42, color=YELLOW)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 PowerRuleDerivative(Scene):\n def construct(self):\n # Define colors to track terms visually through the steps\n color_x2 = BLUE\n color_3x = GREEN\n color_const = RED\n \n # --- Step 1: Display the original function ---\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n func_text = MathTex(\n \"f(x)\", \"=\", \"x^2\", \"+\", \"3x\", \"+\", \"2\",\n substrings_to_isolate=[\"x^2\", \"3x\", \"2\"]\n )\n func_text.set_color_by_tex(\"x^2\", color_x2)\n func_text.set_color_by_tex(\"3x\", color_3x)\n func_text.set_color_by_tex(\"2\", color_const)\n func_text.scale(1.2)\n \n self.play(Write(func_text))\n self.wait(1)\n \n # --- Step 2: Apply the derivative operator ---\n deriv_step1 = MathTex(\n \"f'(x)\", \"=\", \"\\\\frac{d}{dx}\", \"(\", \"x^2\", \"+\", \"3x\", \"+\", \"2\", \")\"\n )\n deriv_step1.set_color_by_tex(\"x^2\", color_x2)\n deriv_step1.set_color_by_tex(\"3x\", color_3x)\n deriv_step1.set_color_by_tex(\"2\", color_const)\n \n self.play(ReplacementTransform(func_text, deriv_step1))\n self.wait(1)\n \n # --- Step 3: Explain the Power Rule ---\n rule_text = MathTex(\"\\\\frac{d}{dx}x^n = nx^{n-1}\", font_size=36, color=YELLOW)\n rule_text.next_to(deriv_step1, DOWN, buff=0.8)\n rule_label = Text(\"Power Rule:\", font_size=28, color=YELLOW).next_to(rule_text, LEFT, buff=0.2)\n \n self.play(Write(rule_label), Write(rule_text))\n self.wait(2)\n \n # --- Step 4: Differentiate x^2 ---\n step1_exp = Text(\"Step 1: Bring down 2, subtract 1 from exponent\", font_size=24)\n step1_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[4].animate.set_color(YELLOW), Write(step1_exp))\n self.wait(1)\n self.play(FadeOut(step1_exp))\n \n # --- Step 5: Differentiate 3x ---\n step2_exp = Text(\"Step 2: Derivative of 3x is 3\", font_size=24)\n step2_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[6].animate.set_color(YELLOW), Write(step2_exp))\n self.wait(1)\n self.play(FadeOut(step2_exp))\n \n # --- Step 6: Differentiate the constant 2 ---\n step3_exp = Text(\"Step 3: Derivative of a constant is 0\", font_size=24)\n step3_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[8].animate.set_color(YELLOW), Write(step3_exp))\n self.wait(1)\n self.play(FadeOut(step3_exp), FadeOut(rule_label), FadeOut(rule_text))\n \n # --- Step 7: Show intermediate result ---\n intermediate_result = MathTex(\n \"f'(x)\", \"=\", \"2x\", \"+\", \"3\", \"+\", \"0\"\n )\n intermediate_result.set_color_by_tex(\"2x\", color_x2)\n intermediate_result.set_color_by_tex(\"3\", color_3x)\n intermediate_result.set_color_by_tex(\"0\", color_const)\n intermediate_result.scale(1.2)\n \n self.play(ReplacementTransform(deriv_step1, intermediate_result))\n self.wait(1)\n \n # --- Step 8: Simplify to final result ---\n final_result = MathTex(\n \"f'(x)\", \"=\", \"2x\", \"+\", \"3\"\n )\n final_result.set_color_by_tex(\"2x\", color_x2)\n final_result.set_color_by_tex(\"3\", color_3x)\n final_result.scale(1.5)\n \n self.play(\n ReplacementTransform(intermediate_result, final_result),\n final_result.animate.move_to(ORIGIN)\n )\n self.play(Circumscribe(final_result))\n self.wait(1)\n \n # --- Step 9: Closing Message ---\n closing_message = Text(\"That's the derivative!\", font_size=40, color=BLUE)\n closing_message.next_to(final_result, DOWN, buff=1)\n \n self.play(Write(closing_message))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PowerRuleDerivative(Scene):\n def construct(self):\n # Define colors to track terms visually through the steps\n color_x2 = BBLUE\n color_3x = GREEN\n color_const = RED\n \n # --- Step 1: Display the original function ---\n title = Text(\"Finding the Derivative using the Power Rule\", font_size=36).to_edge(UP)\n self.play(Write(title))\n \n func_text = MathTex(\n \"f(x)\", \"=\", \"x^2\", \"+\", \"3x\", \"+\", \"2\",\n substrings_to_isolate=[\"x^2\", \"3x\", \"2\"]\n )\n func_text.set_color_by_tex(\"x^2\", color_x2)\n func_text.set_color_by_tex(\"3x\", color_3x)\n func_text.set_color_by_tex(\"2\", color_const)\n func_text.scale(1.2)\n \n self.play(Write(func_text))\n self.wait(1)\n \n # --- Step 2: Apply the derivative operator ---\n deriv_step1 = MathTex(\n \"f'(x)\", \"=\", \"\\\\frac{d}{dx}\", \"(\", \"x^2\", \"+\", \"3x\", \"+\", \"2\", \")\"\n )\n deriv_step1.set_color_by_tex(\"x^2\", color_x2)\n deriv_step1.set_color_by_tex(\"3x\", color_3x)\n deriv_step1.set_color_by_tex(\"2\", color_const)\n \n self.play(ReplacementTransform(func_text, deriv_step1))\n self.wait(1)\n \n # --- Step 3: Explain the Power Rule ---\n rule_text = MathTex(\"\\\\frac{d}{dx}x^n = nx^{n-1}\", font_size=36, color=YELLOW)\n rule_text.next_to(deriv_step1, DOWN, buff=0.8)\n rule_label = Text(\"Power Rule:\", font_size=28, color=YELLOW).next_to(rule_text, LEFT, buff=0.2)\n \n self.play(Write(rule_label), Write(rule_text))\n self.wait(2)\n \n # --- Step 4: Differentiate x^2 ---\n step1_exp = Text(\"Step 1: Bring down 2, subtract 1 from exponent\", font_size=24)\n step1_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[4].animate.set_color(YELLOW), Write(step1_exp))\n self.wait(1)\n self.play(FadeOut(step1_exp))\n \n # --- Step 5: Differentiate 3x ---\n step2_exp = Text(\"Step 2: Derivative of 3x is 3\", font_size=24)\n step2_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[6].animate.set_color(YELLOW), Write(step2_exp))\n self.wait(1)\n self.play(FadeOut(step2_exp))\n \n # --- Step 6: Differentiate the constant 2 ---\n step3_exp = Text(\"Step 3: Derivative of a constant is 0\", font_size=24)\n step3_exp.next_to(rule_text, DOWN, buff=0.5)\n self.play(deriv_step1[8].animate.set_color(YELLOW), Write(step3_exp))\n self.wait(1)\n self.play(FadeOut(step3_exp), FadeOut(rule_label), FadeOut(rule_text))\n \n # --- Step 7: Show intermediate result ---\n intermediate_result = MathTex(\n \"f'(x)\", \"=\", \"2x\", \"+\", \"3\", \"+\", \"0\"\n )\n intermediate_result.set_color_by_tex(\"2x\", color_x2)\n intermediate_result.set_color_by_tex(\"3\", color_3x)\n intermediate_result.set_color_by_tex(\"0\", color_const)\n intermediate_result.scale(1.2)\n \n self.play(ReplacementTransform(deriv_step1, intermediate_result))\n self.wait(1)\n \n # --- Step 8: Simplify to final result ---\n final_result = MathTex(\n \"f'(x)\", \"=\", \"2x\", \"+\", \"3\"\n )\n final_result.set_color_by_tex(\"2x\", color_x2)\n final_result.set_color_by_tex(\"3\", color_3x)\n final_result.scale(1.5)\n \n self.play(\n ReplacementTransform(intermediate_result, final_result),\n final_result.animate.move_to(ORIGIN)\n )\n self.play(Circumscribe(final_result))\n self.wait(1)\n \n # --- Step 9: Closing Message ---\n closing_message = Text(\"That's the derivative!\", font_size=40, color=BLUE)\n closing_message.next_to(final_result, DOWN, buff=1)\n \n self.play(Write(closing_message))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 chemistry animation using Manim that shows a simplified chemical structure with both oxygen and metal elements arranged in a grid pattern? Also, include an electron moving in a complex path around this grid, some lithium ions placed to the side and below the grid, and have everything fade out at the end. The animation should start with the title 'Chemical Structure Example' at the top of the screen.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemicalStructureAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n # Display the main title at the top of the screen to establish context\n # for the educational visualization.\n title = Text(\"Chemical Structure Example\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Structure (Oxygen and Metal Elements)\n # ------------------------------------------------------------------\n # Construct a simplified crystal lattice representing a metal oxide.\n # A checkerboard pattern simulates an ionic crystal structure where \n # cations (Metal, M) and anions (Oxygen, O) alternate to minimize \n # electrostatic repulsion (e.g., a rock-salt type lattice).\n grid_group = VGroup()\n atom_radius = 0.35\n spacing = 1.5\n\n # Generate a 3x3 grid centered at the origin\n for row in range(3):\n for col in range(3):\n # Calculate coordinates relative to the center\n x = (col - 1) * spacing\n y = (1 - row) * spacing\n \n # Determine element type based on grid position parity\n if (row + col) % 2 == 0:\n # Metal Atom: Represented by Blue circles (standard CPK adaptation)\n atom = Circle(radius=atom_radius, color=BLUE_D, fill_opacity=0.7, fill_color=BLUE_D)\n label = Text(\"M\", font_size=24, color=WHITE)\n else:\n # Oxygen Atom: Represented by Red circles (standard CPK coloring)\n atom = Circle(radius=atom_radius, color=RED_D, fill_opacity=0.7, fill_color=RED_D)\n label = Text(\"O\", font_size=24, color=WHITE)\n \n # Center the label within the atom circle and group them\n label.move_to(atom.get_center())\n atom_group = VGroup(atom, label)\n atom_group.move_to([x, y, 0])\n grid_group.add(atom_group)\n\n # Animate the creation of the lattice structure\n self.play(FadeIn(grid_group, shift=UP), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Lithium Ions (Side and Below)\n # ------------------------------------------------------------------\n # Position Lithium ions outside the primary grid. In battery chemistry,\n # lithium often occupies interstitial sites or electrolyte regions adjacent\n # to the active material surface rather than the primary structural framework.\n li_ions = VGroup()\n li_color = GOLD_A\n \n # Define positions: to the side (right) and below the main grid\n li_positions = [\n [3.0, 1.0, 0], [3.0, -1.0, 0], # Side\n [1.0, -3.0, 0], [-1.0, -3.0, 0] # Below\n ]\n \n for pos in li_positions:\n ion = Circle(radius=atom_radius * 0.8, color=li_color, fill_opacity=0.8, fill_color=li_color)\n label = Text(\"Li+\", font_size=20, color=WHITE)\n label.move_to(ion.get_center())\n li_group = VGroup(ion, label).move_to(pos)\n li_ions.add(li_group)\n\n # Fade in the ions to show their presence relative to the lattice\n self.play(FadeIn(li_ions), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Electron Animation (Complex, Non-linear Path)\n # ------------------------------------------------------------------\n # Visualize electron transport around the structure. The path is complex\n # and non-linear to represent quantum mechanical probability clouds or\n # scattering paths rather than simple classical orbits.\n electron = Dot(color=YELLOW, radius=0.1)\n \n # Define a Lissajous-like curve for the electron trajectory.\n # This harmonic motion (sin(t), cos(2t)) simulates the oscillating \n # movement of a charge carrier in a solid-state potential energy landscape.\n def electron_path(t):\n tau = t * 2 * PI\n x = 2.5 * np.sin(tau) + 0.5 * np.cos(3 * tau)\n y = 2.0 * np.cos(2 * tau) + 0.5 * np.sin(4 * tau)\n return np.array([x, y, 0])\n\n # Create the visual path object (faint yellow line)\n path = ParametricFunction(\n electron_path, \n t_range=(0, 1), \n color=YELLOW_A, \n stroke_opacity=0.3\n )\n \n # Reveal the trajectory path and animate the electron simultaneously\n self.add(electron)\n self.play(\n Create(path, run_time=1),\n MoveAlongPath(electron, path), \n run_time=4, \n rate_func=linear\n )\n\n # ------------------------------------------------------------------\n # 5. Ending Sequence (Fade Out)\n # ------------------------------------------------------------------\n # Conclude the animation by smoothly removing all visual elements\n # from the screen.\n all_elements = VGroup(title, grid_group, li_ions, electron, path)\n self.play(FadeOut(all_elements), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemicalStructureAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n # Display the main title at the top of the screen to establish context\n # for the educational visualization.\n title = Text(\"Chemical Structure Example\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Structure (Oxygen and Metal Elements)\n # ------------------------------------------------------------------\n # Construct a simplified crystal lattice representing a metal oxide.\n # A checkerboard pattern simulates an ionic crystal structure where \n # cations (Metal, M) and anions (Oxygen, O) alternate to minimize \n # electrostatic repulsion (e.g., a rock-salt type lattice).\n grid_group = VGroup()\n atom_radius = 0.35\n spacing = 1.5\n\n # Generate a 3x3 grid centered at the origin\n for row in range(3):\n for col in range(3):\n # Calculate coordinates relative to the center\n x = (col - 1) * spacing\n y = (1 - row) * spacing\n \n # Determine element type based on grid position parity\n if (row + col) % 2 == 0:\n # Metal Atom: Represented by Blue circles (standard CPK adaptation)\n atom = Circle(radius=atom_radius, color=BBLUE_D, fill_opacity=0.7, fill_color=BLUE_D)\n label = Text(\"M\", font_size=24, color=WHITE)\n else:\n # Oxygen Atom: Represented by Red circles (standard CPK coloring)\n atom = Circle(radius=atom_radius, color=RED_D, fill_opacity=0.7, fill_color=RED_D)\n label = Text(\"O\", font_size=24, color=WHITE)\n \n # Center the label within the atom circle and group them\n label.move_to(atom.get_center())\n atom_group = VGroup(atom, label)\n atom_group.move_to([x, y, 0])\n grid_group.add(atom_group)\n\n # Animate the creation of the lattice structure\n self.play(FadeIn(grid_group, shift=UP), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Lithium Ions (Side and Below)\n # ------------------------------------------------------------------\n # Position Lithium ions outside the primary grid. In battery chemistry,\n # lithium often occupies interstitial sites or electrolyte regions adjacent\n # to the active material surface rather than the primary structural framework.\n li_ions = VGroup()\n li_color = GOLD_A\n \n # Define positions: to the side (right) and below the main grid\n li_positions = [\n [3.0, 1.0, 0], [3.0, -1.0, 0], # Side\n [1.0, -3.0, 0], [-1.0, -3.0, 0] # Below\n ]\n \n for pos in li_positions:\n ion = Circle(radius=atom_radius * 0.8, color=li_color, fill_opacity=0.8, fill_color=li_color)\n label = Text(\"Li+\", font_size=20, color=WHITE)\n label.move_to(ion.get_center())\n li_group = VGroup(ion, label).move_to(pos)\n li_ions.add(li_group)\n\n # Fade in the ions to show their presence relative to the lattice\n self.play(FadeIn(li_ions), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Electron Animation (Complex, Non-linear Path)\n # ------------------------------------------------------------------\n # Visualize electron transport around the structure. The path is complex\n # and non-linear to represent quantum mechanical probability clouds or\n # scattering paths rather than simple classical orbits.\n electron = Dot(color=YELLOW, radius=0.1)\n \n # Define a Lissajous-like curve for the electron trajectory.\n # This harmonic motion (sin(t), cos(2t)) simulates the oscillating \n # movement of a charge carrier in a solid-state potential energy landscape.\n def electron_path(t):\n tau = t * 2 * PI\n x = 2.5 * np.sin(tau) + 0.5 * np.cos(3 * tau)\n y = 2.0 * np.cos(2 * tau) + 0.5 * np.sin(4 * tau)\n return np.array([x, y, 0])\n\n # Create the visual path object (faint yellow line)\n path = ParametricFunction(\n electron_path, \n t_range=(0, 1), \n color=YELLOW_A, \n stroke_opacity=0.3\n )\n \n # Reveal the trajectory path and animate the electron simultaneously\n self.add(electron)\n self.play(\n Create(path, run_time=1),\n MoveAlongPath(electron, path), \n run_time=4, \n rate_func=linear\n )\n\n # ------------------------------------------------------------------\n # 5. Ending Sequence (Fade Out)\n # ------------------------------------------------------------------\n # Conclude the animation by smoothly removing all visual elements\n # from the screen.\n all_elements = VGroup(title, grid_group, li_ions, electron, path)\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 enhanced animation begins by displaying a 3-layer neural network (4-7-4 neurons) centered on the screen, with the middle layer slightly transparent to emphasize depth. As the training animation starts, five random data points appear at the input layer, each represented as glowing dots that pulse to indicate activation. The data propagates through the network, with dynamic weight lines flashing to show signal strength, while a real-time loss function graph materializes in the upper-right corner, updating with each training step to visualize convergence. Simultaneously, a LaTeX formula for backpropagation (∇L = ∂L/∂y · ∂y/∂w) fades in below the network, with terms highlighted in sync with the flow of gradients during training. The animation concludes with the network’s output neurons lighting up to represent predictions, while the loss graph stabilizes and a text label (\"Training Complete\") appears. This version not only demonstrates the training process but also educates viewers about the underlying mathematics and performance metrics.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Create neural network layers\n input_layer = VGroup(*[Circle(radius=0.2, color=BLUE, fill_opacity=1) for _ in range(4)])\n hidden_layer = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.7) for _ in range(7)])\n output_layer = VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=1) for _ in range(4)])\n \n # Position layers\n input_layer.arrange(DOWN, buff=0.5).shift(LEFT * 3)\n hidden_layer.arrange(DOWN, buff=0.4).shift(ORIGIN)\n output_layer.arrange(DOWN, buff=0.5).shift(RIGHT * 3)\n \n # Add network to scene\n self.play(\n LaggedStart(\n *[Create(layer) for layer in [input_layer, hidden_layer, output_layer]],\n lag_ratio=0.3\n ),\n run_time=2\n )\n self.wait(0.5)\n \n # Create connections\n connections = VGroup()\n for input_neuron in input_layer:\n for hidden_neuron in hidden_layer:\n line = Line(\n input_neuron.get_right(),\n hidden_neuron.get_left(),\n stroke_width=1,\n color=WHITE\n )\n connections.add(line)\n \n for hidden_neuron in hidden_layer:\n for output_neuron in output_layer:\n line = Line(\n hidden_neuron.get_right(),\n output_neuron.get_left(),\n stroke_width=1,\n color=WHITE\n )\n connections.add(line)\n \n self.play(Create(connections), run_time=2)\n self.wait(0.5)\n \n # Create data points\n data_points = VGroup(*[\n Dot(color=YELLOW, radius=0.15).move_to(neuron).set_opacity(0)\n for neuron in input_layer\n ])\n \n # Animate data points appearing\n self.play(\n *[data_point.animate.set_opacity(1) for data_point in data_points],\n run_time=1\n )\n \n # Create loss graph axes\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 5, 1],\n x_length=3,\n y_length=2,\n axis_config={\"color\": WHITE}\n ).to_corner(UR)\n \n # Create loss graph\n loss_graph = axes.plot_line_graph(\n x_values=[0],\n y_values=[4.5],\n line_color=YELLOW,\n add_vertex_dots=False\n )\n \n # Add axes and initial graph\n self.play(\n Create(axes),\n Create(loss_graph[\"line_graph\"]),\n run_time=1\n )\n \n # Create backprop formula\n formula = MathTex(\n r\"\\nabla L = \\frac{\\partial L}{\\partial y} \\cdot \\frac{\\partial y}{\\partial w}\",\n font_size=36\n ).next_to(input_layer, DOWN, buff=1.5)\n \n self.play(Write(formula), run_time=1.5)\n \n # Training animation\n for epoch in range(1, 6):\n # Animate data propagation\n for i, data_point in enumerate(data_points):\n data_point_copy = data_point.copy()\n self.play(\n data_point_copy.animate.scale(1.5).set_color(ORANGE),\n run_time=0.3\n )\n self.play(\n data_point_copy.animate.move_to(hidden_layer[np.random.randint(0, 7)]),\n run_time=0.5\n )\n self.play(\n data_point_copy.animate.move_to(output_layer[i]),\n run_time=0.5\n )\n self.play(FadeOut(data_point_copy), run_time=0.3)\n \n # Update loss graph\n new_loss = max(0.1, 4.5 - epoch * 0.8 + np.random.uniform(-0.2, 0.2))\n new_graph = axes.plot_line_graph(\n x_values=list(range(epoch + 1)),\n y_values=[4.5 - i * 0.8 + np.random.uniform(-0.2, 0.2) for i in range(epoch + 1)],\n line_color=YELLOW,\n add_vertex_dots=False\n )\n \n # Highlight formula terms\n self.play(\n formula[0][:2].animate.set_color(BLUE),\n formula[0][3:9].animate.set_color(GREEN),\n formula[0][10:16].animate.set_color(RED),\n run_time=0.5\n )\n self.play(\n formula[0][:2].animate.set_color(WHITE),\n formula[0][3:9].animate.set_color(WHITE),\n formula[0][10:16].animate.set_color(WHITE),\n run_time=0.5\n )\n \n self.play(\n Transform(loss_graph[\"line_graph\"], new_graph[\"line_graph\"]),\n run_time=0.7\n )\n \n # Final output activation\n self.play(\n *[Flash(neuron, color=RED, flash_radius=0.3) for neuron in output_layer],\n run_time=1.5\n )\n \n # Training complete text\n complete_text = Text(\"Training Complete\", font_size=24).next_to(formula, DOWN, buff=0.5)\n self.play(Write(complete_text), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # Create neural network layers\n input_layer = VGroup(*[Circle(radius=0.2, color=BBLUE, fill_opacity=1) for _ in range(4)])\n hidden_layer = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.7) for _ in range(7)])\n output_layer = VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=1) for _ in range(4)])\n \n # Position layers\n input_layer.arrange(DOWN, buff=0.5).shift(LEFT * 3)\n hidden_layer.arrange(DOWN, buff=0.4).shift(ORIGIN)\n output_layer.arrange(DOWN, buff=0.5).shift(RIGHT * 3)\n \n # Add network to scene\n self.play(\n LaggedStart(\n *[Create(layer) for layer in [input_layer, hidden_layer, output_layer]],\n lag_ratio=0.3\n ),\n run_time=2\n )\n self.wait(0.5)\n \n # Create connections\n connections = VGroup()\n for input_neuron in input_layer:\n for hidden_neuron in hidden_layer:\n line = Line(\n input_neuron.get_right(),\n hidden_neuron.get_left(),\n stroke_width=1,\n color=WHITE\n )\n connections.add(line)\n \n for hidden_neuron in hidden_layer:\n for output_neuron in output_layer:\n line = Line(\n hidden_neuron.get_right(),\n output_neuron.get_left(),\n stroke_width=1,\n color=WHITE\n )\n connections.add(line)\n \n self.play(Create(connections), run_time=2)\n self.wait(0.5)\n \n # Create data points\n data_points = VGroup(*[\n Dot(color=YELLOW, radius=0.15).move_to(neuron).set_opacity(0)\n for neuron in input_layer\n ])\n \n # Animate data points appearing\n self.play(\n *[data_point.animate.set_opacity(1) for data_point in data_points],\n run_time=1\n )\n \n # Create loss graph axes\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 5, 1],\n x_length=3,\n y_length=2,\n axis_config={\"color\": WHITE}\n ).to_corner(UR)\n \n # Create loss graph\n loss_graph = axes.plot_line_graph(\n x_values=[0],\n y_values=[4.5],\n line_color=YELLOW,\n add_vertex_dots=False\n )\n \n # Add axes and initial graph\n self.play(\n Create(axes),\n Create(loss_graph[\"line_graph\"]),\n run_time=1\n )\n \n # Create backprop formula\n formula = MathTex(\n r\"\\nabla L = \\frac{\\partial L}{\\partial y} \\cdot \\frac{\\partial y}{\\partial w}\",\n font_size=36\n ).next_to(input_layer, DOWN, buff=1.5)\n \n self.play(Write(formula), run_time=1.5)\n \n # Training animation\n for epoch in range(1, 6):\n # Animate data propagation\n for i, data_point in enumerate(data_points):\n data_point_copy = data_point.copy()\n self.play(\n data_point_copy.animate.scale(1.5).set_color(ORANGE),\n run_time=0.3\n )\n self.play(\n data_point_copy.animate.move_to(hidden_layer[np.random.randint(0, 7)]),\n run_time=0.5\n )\n self.play(\n data_point_copy.animate.move_to(output_layer[i]),\n run_time=0.5\n )\n self.play(FadeOut(data_point_copy), run_time=0.3)\n \n # Update loss graph\n new_loss = max(0.1, 4.5 - epoch * 0.8 + np.random.uniform(-0.2, 0.2))\n new_graph = axes.plot_line_graph(\n x_values=list(range(epoch + 1)),\n y_values=[4.5 - i * 0.8 + np.random.uniform(-0.2, 0.2) for i in range(epoch + 1)],\n line_color=YELLOW,\n add_vertex_dots=False\n )\n \n # Highlight formula terms\n self.play(\n formula[0][:2].animate.set_color(BLUE),\n formula[0][3:9].animate.set_color(GREEN),\n formula[0][10:16].animate.set_color(RED),\n run_time=0.5\n )\n self.play(\n formula[0][:2].animate.set_color(WHITE),\n formula[0][3:9].animate.set_color(WHITE),\n formula[0][10:16].animate.set_color(WHITE),\n run_time=0.5\n )\n \n self.play(\n Transform(loss_graph[\"line_graph\"], new_graph[\"line_graph\"]),\n run_time=0.7\n )\n \n # Final output activation\n self.play(\n *[Flash(neuron, color=RED, flash_radius=0.3) for neuron in output_layer],\n run_time=1.5\n )\n \n # Training complete text\n complete_text = Text(\"Training Complete\", font_size=24).next_to(formula, DOWN, buff=0.5)\n self.play(Write(complete_text), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 set of axes, and include a label for the curve. Afterward, display the integral expression for the area under the curve and highlight the actual area under the graph between those two points. Once the area is highlighted, show the calculated result of the integral. Finally, clear everything else away and leave only the final result of the integration on the screen.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Function Introduction\n # Display the function equation centrally\n func_intro = MathTex(\"y = x^2\", font_size=48)\n self.play(Write(func_intro))\n self.wait(1)\n self.play(FadeOut(func_intro))\n\n # 2. Graphing\n # Draw axes and plot the curve with labels\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Plot y = x^2 (extended slightly beyond x=2 for visual context)\n curve = axes.plot(lambda x: x**2, x_range=[0, 2.5], color=YELLOW)\n curve_label = MathTex(\"y = x^2\", font_size=36).next_to(curve, UR, buff=0.1)\n\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # 3. Integral Setup\n # Display the definite integral expression\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=48)\n integral_expr.to_edge(UP)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # 4. Area Highlighting\n # Visually highlight the area under the graph between x=0 and x=2\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # 5. Calculation\n # Show the calculated numerical result next to the integral\n result_expr = MathTex(r\"= \\frac{8}{3}\", font_size=48)\n result_expr.next_to(integral_expr, RIGHT, buff=0.2)\n \n self.play(Write(result_expr))\n self.wait(1.5)\n\n # 6. Final Scene\n # Clear all previous elements so only the final integration result remains\n final_result = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\frac{8}{3}\", font_size=60)\n final_result.move_to(ORIGIN)\n \n # Group all elements to be cleared\n elements_to_clear = VGroup(\n axes, axes_labels, curve, curve_label, \n area, integral_expr, result_expr\n )\n\n self.play(\n FadeOut(elements_to_clear),\n FadeIn(final_result)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Function Introduction\n # Display the function equation centrally\n func_intro = MathTex(\"y = x^2\", font_size=48)\n self.play(Write(func_intro))\n self.wait(1)\n self.play(FadeOut(func_intro))\n\n # 2. Graphing\n # Draw axes and plot the curve with labels\n axes = Axes(label_font_size=24, \n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Plot y = x^2 (extended slightly beyond x=2 for visual context)\n curve = axes.plot(lambda x: x**2, x_range=[0, 2.5], color=YELLOW)\n curve_label = MathTex(\"y = x^2\", font_size=36).next_to(curve, UR, buff=0.1)\n\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(1)\n\n # 3. Integral Setup\n # Display the definite integral expression\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=48)\n integral_expr.to_edge(UP)\n \n self.play(Write(integral_expr))\n self.wait(1)\n\n # 4. Area Highlighting\n # Visually highlight the area under the graph between x=0 and x=2\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(1)\n\n # 5. Calculation\n # Show the calculated numerical result next to the integral\n result_expr = MathTex(r\"= \\frac{8}{3}\", font_size=48)\n result_expr.next_to(integral_expr, RIGHT, buff=0.2)\n \n self.play(Write(result_expr))\n self.wait(1.5)\n\n # 6. Final Scene\n # Clear all previous elements so only the final integration result remains\n final_result = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\frac{8}{3}\", font_size=60)\n final_result.move_to(ORIGIN)\n \n # Group all elements to be cleared\n elements_to_clear = VGroup(\n axes, axes_labels, curve, curve_label, \n area, integral_expr, result_expr\n )\n\n self.play(\n FadeOut(elements_to_clear),\n FadeIn(final_result)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 2: Create a 10-second Manim scene that introduces a simplified benzene ring. Show a hexagonal carbon skeleton, alternating double bonds, and labels for several carbon and hydrogen positions.\n- Act 3: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0587(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_torqueleverarm()\n self.clear_stage()\n self.act_2_benzeneringlabels()\n self.clear_stage()\n self.act_3_textshapeanimation()\n\n def act_1_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_2_benzeneringlabels(self):\n title = Text(\"Benzene Ring\", font_size=36).to_edge(UP)\n hexagon = RegularPolygon(n=6, radius=1.6, color=BLUE_D)\n carbon_labels = VGroup(*[\n Text(\"C\", font_size=24).move_to(hexagon.point_from_proportion(i / 6) * 0.82)\n for i in range(6)\n ])\n bonds = VGroup()\n vertices = [hexagon.point_from_proportion(i / 6) for i in range(6)]\n for i in [0, 2, 4]:\n start = vertices[i]\n end = vertices[(i + 1) % 6]\n offset = 0.08 * normalize(rotate_vector(end - start, PI / 2))\n bonds.add(Line(start + offset, end + offset, color=YELLOW_D, stroke_width=4))\n hydrogen_labels = VGroup(*[\n Text(\"H\", font_size=22, color=GRAY_C).move_to(vertex * 1.28)\n for vertex in vertices\n ])\n note = Text(\"Alternating bonds capture the familiar benzene motif.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(hexagon), run_time=2)\n self.play(FadeIn(carbon_labels), FadeIn(hydrogen_labels), run_time=3)\n self.play(LaggedStart(*[Create(bond) for bond in bonds], lag_ratio=0.2), run_time=3)\n self.play(FadeIn(note), run_time=1)\n self.wait(1)\n\n def act_3_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0587(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_torqueleverarm()\n self.clear_stage()\n self.act_2_benzeneringlabels()\n self.clear_stage()\n self.act_3_textshapeanimation()\n\n def act_1_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=BBLUE_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_2_benzeneringlabels(self):\n title = Text(\"Benzene Ring\", font_size=36).to_edge(UP)\n hexagon = RegularPolygon(n=6, radius=1.6, color=BLUE_D)\n carbon_labels = VGroup(*[\n Text(\"C\", font_size=24).move_to(hexagon.point_from_proportion(i / 6) * 0.82)\n for i in range(6)\n ])\n bonds = VGroup()\n vertices = [hexagon.point_from_proportion(i / 6) for i in range(6)]\n for i in [0, 2, 4]:\n start = vertices[i]\n end = vertices[(i + 1) % 6]\n offset = 0.08 * normalize(rotate_vector(end - start, PI / 2))\n bonds.add(Line(start + offset, end + offset, color=YELLOW_D, stroke_width=4))\n hydrogen_labels = VGroup(*[\n Text(\"H\", font_size=22, color=GRAY_C).move_to(vertex * 1.28)\n for vertex in vertices\n ])\n note = Text(\"Alternating bonds capture the familiar benzene motif.\", font_size=24, color=GRAY_C).to_edge(DOWN)\n self.play(FadeIn(title), Create(hexagon), run_time=2)\n self.play(FadeIn(carbon_labels), FadeIn(hydrogen_labels), run_time=3)\n self.play(LaggedStart(*[Create(bond) for bond in bonds], lag_ratio=0.2), run_time=3)\n self.play(FadeIn(note), run_time=1)\n self.wait(1)\n\n def act_3_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 fading in a red proton labeled \"P⁺\" at the center, surrounded by a faint blue circular orbit. A small white electron dot appears on the orbit and smoothly begins rotating around the proton. As the electron moves, a glowing trail fades in behind it, emphasizing its path. Simultaneously, a dynamic mathematical formula appears above the scene, displaying the Bohr model energy levels: \\( E_n = -\\frac{13.6 \\text{ eV}}{n^2} \\), with the principal quantum number \\( n \\) incrementing from 1 to 2 as the electron completes its orbit. The orbit then smoothly transitions into a larger ellipse, illustrating an excited state, while the formula updates to reflect the higher energy level. Finally, a brief flash of light appears near the electron, simulating a photon emission as it transitions back to the ground state, with the orbit shrinking to its original size and the formula reverting to \\( n = 1 \\). The entire sequence is accompanied by explanatory labels (\"Ground State\" and \"Excited State\") that fade in and out at the appropriate moments. \n\nThis enhanced version not only visualizes the electron's motion but also incorporates key quantum mechanical concepts, making the animation both visually engaging and educational.", "chosen": "```python\nfrom manim import *\n\nclass BohrModelAnimation(Scene):\n def construct(self):\n # Create proton\n proton = Dot(color=RED, radius=0.3)\n proton_label = MathTex(\"P^+\", color=WHITE).move_to(proton.get_center())\n \n # Create orbit\n orbit = Circle(radius=1.5, color=BLUE, stroke_width=1, fill_opacity=0.1, fill_color=BLUE)\n \n # Create electron\n electron = Dot(color=WHITE, radius=0.15).move_to(orbit.point_at_angle(0))\n \n # Add initial objects\n self.play(FadeIn(proton), Write(proton_label), Create(orbit), FadeIn(electron))\n self.wait(0.5)\n \n # Animate electron moving around the orbit\n trail = TracedPath(electron.get_center, stroke_color=YELLOW, stroke_width=2)\n self.add(trail)\n self.play(MoveAlongPath(electron, orbit), run_time=2, rate_func=linear)\n \n # Show ground state label\n ground_state = Text(\"Ground State\", color=GREEN).to_edge(UP)\n self.play(Write(ground_state))\n self.wait(0.5)\n \n # Show energy formula\n energy_formula = MathTex(\"E_n = -\\\\frac{13.6 \\\\text{ eV}}{n^2}\", \"n=1\", color=YELLOW).to_edge(UP)\n self.play(Transform(ground_state, energy_formula))\n self.wait(1)\n \n # Transition to excited state\n excited_orbit = Ellipse(width=3, height=2.5, color=PINK, stroke_width=1, fill_opacity=0.1, fill_color=PINK)\n excited_state = Text(\"Excited State\", color=ORANGE).to_edge(UP)\n energy_formula_n2 = MathTex(\"E_n = -\\\\frac{13.6 \\\\text{ eV}}{n^2}\", \"n=2\", color=YELLOW).to_edge(UP)\n \n self.play(\n Transform(orbit, excited_orbit),\n Transform(energy_formula, energy_formula_n2),\n FadeOut(ground_state),\n run_time=1.5\n )\n self.play(Write(excited_state))\n self.wait(1)\n \n # Animate electron in excited state\n self.play(MoveAlongPath(electron, excited_orbit), run_time=3, rate_func=linear)\n \n # Emit photon and return to ground state\n photon = Dot(color=YELLOW, radius=0.2).next_to(electron, RIGHT, buff=0.1)\n photon_arrow = Arrow(photon.get_center(), photon.get_center() + RIGHT, color=YELLOW, buff=0)\n \n self.play(\n FadeIn(photon),\n GrowArrow(photon_arrow),\n run_time=0.5\n )\n self.play(\n FadeOut(photon),\n FadeOut(photon_arrow),\n Transform(orbit, Circle(radius=1.5, color=BLUE, stroke_width=1, fill_opacity=0.1, fill_color=BLUE)),\n Transform(energy_formula_n2, energy_formula),\n FadeOut(excited_state),\n run_time=1.5\n )\n self.wait(1)\n \n # Final animation of electron\n self.play(MoveAlongPath(electron, orbit), run_time=2, rate_func=linear)\n self.wait(1)\n \n # Fade out everything\n self.play(*[FadeOut(mob) for mob in self.mobjects])\n```", "rejected": "```python\nfrom manim import *\n\nclass BohrModelAnimation(Scene):\n def construct(self):\n # Create proton\n proton = Dot(color=RED, radius=0.3)\n proton_label = MathTex(\"P^+\", color=WHITE).move_to(proton.get_center())\n \n # Create orbit\n orbit = Circle(radius=1.5, color=BBLUE, stroke_width=1, fill_opacity=0.1, fill_color=BLUE)\n \n # Create electron\n electron = Dot(color=WHITE, radius=0.15).move_to(orbit.point_at_angle(0))\n \n # Add initial objects\n self.play(FadeIn(proton), Write(proton_label), Create(orbit), FadeIn(electron))\n self.wait(0.5)\n \n # Animate electron moving around the orbit\n trail = TracedPath(electron.get_center, stroke_color=YELLOW, stroke_width=2)\n self.add(trail)\n self.play(MoveAlongPath(electron, orbit), run_time=2, rate_func=linear)\n \n # Show ground state label\n ground_state = Text(\"Ground State\", color=GREEN).to_edge(UP)\n self.play(Write(ground_state))\n self.wait(0.5)\n \n # Show energy formula\n energy_formula = MathTex(\"E_n = -\\\\frac{13.6 \\\\text{ eV}}{n^2}\", \"n=1\", color=YELLOW).to_edge(UP)\n self.play(Transform(ground_state, energy_formula))\n self.wait(1)\n \n # Transition to excited state\n excited_orbit = Ellipse(width=3, height=2.5, color=PINK, stroke_width=1, fill_opacity=0.1, fill_color=PINK)\n excited_state = Text(\"Excited State\", color=ORANGE).to_edge(UP)\n energy_formula_n2 = MathTex(\"E_n = -\\\\frac{13.6 \\\\text{ eV}}{n^2}\", \"n=2\", color=YELLOW).to_edge(UP)\n \n self.play(\n Transform(orbit, excited_orbit),\n Transform(energy_formula, energy_formula_n2),\n FadeOut(ground_state),\n run_time=1.5\n )\n self.play(Write(excited_state))\n self.wait(1)\n \n # Animate electron in excited state\n self.play(MoveAlongPath(electron, excited_orbit), run_time=3, rate_func=linear)\n \n # Emit photon and return to ground state\n photon = Dot(color=YELLOW, radius=0.2).next_to(electron, RIGHT, buff=0.1)\n photon_arrow = Arrow(photon.get_center(), photon.get_center() + RIGHT, color=YELLOW, buff=0)\n \n self.play(\n FadeIn(photon),\n GrowArrow(photon_arrow),\n run_time=0.5\n )\n self.play(\n FadeOut(photon),\n FadeOut(photon_arrow),\n Transform(orbit, Circle(radius=1.5, color=BLUE, stroke_width=1, fill_opacity=0.1, fill_color=BLUE)),\n Transform(energy_formula_n2, energy_formula),\n FadeOut(excited_state),\n run_time=1.5\n )\n self.wait(1)\n \n # Final animation of electron\n self.play(MoveAlongPath(electron, orbit), run_time=2, rate_func=linear)\n self.wait(1)\n \n # Fade out everything\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Permission Checks\n- Simply having the correct parameter format is not enough; the kernel also needs to check logical permissions, such as whether the current user has the right to read from or write to the target file.\n- This type of check based on identity (UID/GID) and capabilities (Capability) is the foundation of the operating system's security model.\n\n\nThe context location of this section (from highest to current level):\n# System Call Execution Flow and Kernel Structure Practice\n## Parameter Checks and Security in System Calls\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PermissionChecks(Scene):\n\n def construct(self):\n title = Text('Permission Checks in System Calls', 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 process_text = Text('User Process\\nUID / GID\\nCapabilities', font_size=26)\n process_box = SurroundingRectangle(process_text, color=BLUE, buff=0.3)\n process_group = VGroup(process_text, process_box).move_to(LEFT * 4 + UP * 0.8)\n file_text = Text('Target File\\nRead / Write\\nPermissions', font_size=26)\n file_box = SurroundingRectangle(file_text, color=GREEN, buff=0.3)\n file_group = VGroup(file_text, file_box).move_to(RIGHT * 4 + UP * 0.8)\n kernel_text = Text('Kernel\\nSecurity Check', font_size=26, color=YELLOW)\n kernel_box = SurroundingRectangle(kernel_text, color=YELLOW, buff=0.3)\n kernel_group = VGroup(kernel_text, kernel_box).move_to(UP * 0.8)\n arrow1 = Arrow(process_group.get_right(), kernel_group.get_left(), buff=0.15)\n arrow2 = Arrow(kernel_group.get_right(), file_group.get_left(), buff=0.15)\n self.play(FadeIn(process_group), FadeIn(file_group), run_time=1)\n self.play(GrowArrow(arrow1), run_time=0.5)\n self.play(FadeIn(kernel_group), run_time=1)\n check_highlight = SurroundingRectangle(kernel_group, color=RED, buff=0.1)\n self.play(Create(check_highlight), run_time=0.5)\n self.play(FadeOut(check_highlight), run_time=0.5)\n self.play(GrowArrow(arrow2), run_time=0.5)\n blist = BulletedList('Logical permission checks for read/write access', 'Based on Identity (UID/GID) and Capabilities', 'Foundation of the OS security model', font_size=30)\n blist.next_to(kernel_group, DOWN, buff=1.2)\n for item in blist:\n self.play(FadeIn(item, shift=RIGHT * 0.5), run_time=0.8)\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 PermissionChecks(Scene):\n\n def construct(self):\n title = Text('Permission Checks in System Calls', 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 process_text = Text('User Process\\nUID / GID\\nCapabilities', font_size=26)\n process_box = SurroundingRectangle(process_text, color=BBLUE, buff=0.3)\n process_group = VGroup(process_text, process_box).move_to(LEFT * 4 + UP * 0.8)\n file_text = Text('Target File\\nRead / Write\\nPermissions', font_size=26)\n file_box = SurroundingRectangle(file_text, color=GREEN, buff=0.3)\n file_group = VGroup(file_text, file_box).move_to(RIGHT * 4 + UP * 0.8)\n kernel_text = Text('Kernel\\nSecurity Check', font_size=26, color=YELLOW)\n kernel_box = SurroundingRectangle(kernel_text, color=YELLOW, buff=0.3)\n kernel_group = VGroup(kernel_text, kernel_box).move_to(UP * 0.8)\n arrow1 = Arrow(process_group.get_right(), kernel_group.get_left(), buff=0.15)\n arrow2 = Arrow(kernel_group.get_right(), file_group.get_left(), buff=0.15)\n self.play(FadeIn(process_group), FadeIn(file_group), run_time=1)\n self.play(GrowArrow(arrow1), run_time=0.5)\n self.play(FadeIn(kernel_group), run_time=1)\n check_highlight = SurroundingRectangle(kernel_group, color=RED, buff=0.1)\n self.play(Create(check_highlight), run_time=0.5)\n self.play(FadeOut(check_highlight), run_time=0.5)\n self.play(GrowArrow(arrow2), run_time=0.5)\n blist = BulletedList('Logical permission checks for read/write access', 'Based on Identity (UID/GID) and Capabilities', 'Foundation of the OS security model', font_size=30)\n blist.next_to(kernel_group, DOWN, buff=1.2)\n for item in blist:\n self.play(FadeIn(item, shift=RIGHT * 0.5), run_time=0.8)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 please create an educational animation for me that shows the area under the curve y = x^2, from x=0 to x=2, using a blue and green gradient to fill the area? Also, include a set of axes with blue lines, label the curve and the area, and have the elements fade out at the end. I'd like a step-by-step animation where the axes and the curve are drawn first, followed by the labels, then the area filled in, and finally everything fades out.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Draw Axes ---\n # Render coordinate axes with blue lines as specified\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n ).add_coordinates()\n\n self.play(Create(axes), run_time=2)\n self.wait(0.5)\n\n # --- 2. Draw Curve ---\n # Animate the plotting of y = x^2\n curve = axes.plot(lambda x: x**2, color=YELLOW)\n self.play(Create(curve), run_time=2)\n self.wait(0.5)\n\n # --- 3. Add Labels ---\n # Fade in text labels for the curve and area\n curve_label = axes.get_graph_label(\n curve, \n label=\"y = x^2\", \n x_val=2.2, \n direction=UR,\n color=WHITE\n )\n area_label = MathTex(\"\\\\text{Area}\", color=WHITE).move_to(axes.c2p(1.3, 1.0))\n\n self.play(FadeIn(curve_label), FadeIn(area_label))\n self.wait(1)\n\n # --- 4. Fill Area ---\n # Create the area under the curve from x=0 to x=2\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.8)\n # Apply the blue-to-green gradient\n area.set_color_by_gradient(BLUE, GREEN)\n\n # Animate the filling of the region\n self.play(FadeIn(area), run_time=2)\n self.wait(2)\n\n # --- 5. Fade Out ---\n # Group all elements and fade them out smoothly\n all_elements = VGroup(axes, curve, area, curve_label, area_label)\n self.play(FadeOut(all_elements), run_time=2)\n\n# To run this animation: manim -pql filename.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --- 1. Draw Axes ---\n # Render coordinate axes with blue lines as specified\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n ).add_coordinates()\n\n self.play(Create(axes), run_time=2)\n self.wait(0.5)\n\n # --- 2. Draw Curve ---\n # Animate the plotting of y = x^2\n curve = axes.plot(lambda x: x**2, color=YELLOW)\n self.play(Create(curve), run_time=2)\n self.wait(0.5)\n\n # --- 3. Add Labels ---\n # Fade in text labels for the curve and area\n curve_label = axes.get_graph_label(\n curve, \n label=\"y = x^2\", \n x_val=2.2, \n direction=UR,\n color=WHITE\n )\n area_label = MathText(\"\\\\text{Area}\", color=WHITE).move_to(axes.c2p(1.3, 1.0))\n\n self.play(FadeIn(curve_label), FadeIn(area_label))\n self.wait(1)\n\n # --- 4. Fill Area ---\n # Create the area under the curve from x=0 to x=2\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.8)\n # Apply the blue-to-green gradient\n area.set_color_by_gradient(BLUE, GREEN)\n\n # Animate the filling of the region\n self.play(FadeIn(area), run_time=2)\n self.wait(2)\n\n # --- 5. Fade Out ---\n # Group all elements and fade them out smoothly\n all_elements = VGroup(axes, curve, area, curve_label, area_label)\n self.play(FadeOut(all_elements), run_time=2)\n\n# To run this animation: 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Summary of Main Methods and Techniques Learned in the Course\nCreate a mind map covering all core concepts from basic signal processing to advanced image processing applications.\n\n\nContextual location of this section (from highest to current level):\n# Comprehensive Image Processing Applications\n## Homework\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ImageProcessingSummary(Scene):\n\n def construct(self):\n title = Text('Course Summary: Methods & Techniques', 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 center_text = VGroup(Text('Image', font_size=28, weight=BOLD), Text('Processing', font_size=28, weight=BOLD)).arrange(DOWN, buff=0.1).move_to(UP * 0.2)\n center_box = SurroundingRectangle(center_text, color=BLUE, buff=0.25)\n center_group = VGroup(center_text, center_box)\n self.play(FadeIn(center_group), run_time=1)\n cat1 = Text('Signal Processing', font_size=22, color=YELLOW).move_to(LEFT * 4 + UP * 1.8)\n cat2 = Text('Spatial Domain', font_size=22, color=YELLOW).move_to(RIGHT * 4 + UP * 1.8)\n cat3 = Text('Frequency Domain', font_size=22, color=YELLOW).move_to(LEFT * 4 + DOWN * 1.2)\n cat4 = Text('Advanced Apps', font_size=22, color=YELLOW).move_to(RIGHT * 4 + DOWN * 1.2)\n box1 = SurroundingRectangle(cat1, color=GREEN, buff=0.15)\n box2 = SurroundingRectangle(cat2, color=GREEN, buff=0.15)\n box3 = SurroundingRectangle(cat3, color=GREEN, buff=0.15)\n box4 = SurroundingRectangle(cat4, color=GREEN, buff=0.15)\n line1 = Line(center_box.get_left(), box1.get_right(), color=GRAY)\n line2 = Line(center_box.get_right(), box2.get_left(), color=GRAY)\n line3 = Line(center_box.get_left(), box3.get_right(), color=GRAY)\n line4 = Line(center_box.get_right(), box4.get_left(), color=GRAY)\n self.play(Create(VGroup(line1, line2, line3, line4)), run_time=1.2)\n self.play(FadeIn(VGroup(cat1, box1, cat2, box2, cat3, box3, cat4, box4)), run_time=1.5)\n\n def create_sub_list(items, parent_box):\n vg = VGroup(*[Text('• ' + item, font_size=18, color=LIGHT_GRAY) for item in items])\n vg.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n vg.next_to(parent_box, DOWN, buff=0.2)\n vg.align_to(parent_box, LEFT).shift(RIGHT * 0.1)\n return vg\n sub1 = create_sub_list(['Sampling', 'Quantization'], box1)\n sub2 = create_sub_list(['Convolution', 'Smoothing', 'Sharpening'], box2)\n sub3 = create_sub_list(['Fourier Transform', 'Filtering'], box3)\n sub4 = create_sub_list(['Segmentation', 'Feature Extraction'], box4)\n self.play(Write(VGroup(sub1, sub2, sub3, sub4)), run_time=2.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ImageProcessingSummary(Scene):\n\n def construct(self):\n title = Text('Course Summary: Methods & Techniques', 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 center_text = VGroup(Text('Image', font_size=28, weight=BOLD), Text('Processing', font_size=28, weight=BOLD)).arrange(DOWN, buff=0.1).move_to(UP * 0.2)\n center_box = SurroundingRectangle(center_text, color=BBLUE, buff=0.25)\n center_group = VGroup(center_text, center_box)\n self.play(FadeIn(center_group), run_time=1)\n cat1 = Text('Signal Processing', font_size=22, color=YELLOW).move_to(LEFT * 4 + UP * 1.8)\n cat2 = Text('Spatial Domain', font_size=22, color=YELLOW).move_to(RIGHT * 4 + UP * 1.8)\n cat3 = Text('Frequency Domain', font_size=22, color=YELLOW).move_to(LEFT * 4 + DOWN * 1.2)\n cat4 = Text('Advanced Apps', font_size=22, color=YELLOW).move_to(RIGHT * 4 + DOWN * 1.2)\n box1 = SurroundingRectangle(cat1, color=GREEN, buff=0.15)\n box2 = SurroundingRectangle(cat2, color=GREEN, buff=0.15)\n box3 = SurroundingRectangle(cat3, color=GREEN, buff=0.15)\n box4 = SurroundingRectangle(cat4, color=GREEN, buff=0.15)\n line1 = Line(center_box.get_left(), box1.get_right(), color=GRAY)\n line2 = Line(center_box.get_right(), box2.get_left(), color=GRAY)\n line3 = Line(center_box.get_left(), box3.get_right(), color=GRAY)\n line4 = Line(center_box.get_right(), box4.get_left(), color=GRAY)\n self.play(Create(VGroup(line1, line2, line3, line4)), run_time=1.2)\n self.play(FadeIn(VGroup(cat1, box1, cat2, box2, cat3, box3, cat4, box4)), run_time=1.5)\n\n def create_sub_list(items, parent_box):\n vg = VGroup(*[Text('• ' + item, font_size=18, color=LIGHT_GRAY) for item in items])\n vg.arrange(DOWN, aligned_edge=LEFT, buff=0.15)\n vg.next_to(parent_box, DOWN, buff=0.2)\n vg.align_to(parent_box, LEFT).shift(RIGHT * 0.1)\n return vg\n sub1 = create_sub_list(['Sampling', 'Quantization'], box1)\n sub2 = create_sub_list(['Convolution', 'Smoothing', 'Sharpening'], box2)\n sub3 = create_sub_list(['Fourier Transform', 'Filtering'], box3)\n sub4 = create_sub_list(['Segmentation', 'Feature Extraction'], box4)\n self.play(Write(VGroup(sub1, sub2, sub3, sub4)), run_time=2.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a step-by-step animated video that visually illustrates how to solve a triple integral problem? Specifically, show the process of evaluating the triple integral of xyz over the region from 0 to 1 for x, y, and z, including each stage of integration with respect to x, y, and then z, along with explanations at each step.", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Colors for highlighting variables and differentials\n COLOR_X = YELLOW\n COLOR_Y = BLUE\n COLOR_Z = GREEN\n COLOR_TEXT = WHITE\n\n # 1. Initial Expression\n # Split the expression into parts to color the differentials\n initial_integral = MathTex(\n r\"\\int_0^1\", r\"\\int_0^1\", r\"\\int_0^1\", \n \"x\", \"y\", \"z\", \n r\"\\,dx\", r\"\\,dy\", r\"\\,dz\"\n )\n \n explanation = Text(\n \"Evaluate the triple integral of xyz over the unit cube.\", \n font_size=28, \n color=COLOR_TEXT\n ).to_edge(UP)\n\n self.play(Write(explanation))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 1: Integration with respect to x ---\n step1_text = Text(\n \"Step 1: Integrate with respect to x (treat y, z as constants)\", \n font_size=26, \n color=COLOR_X\n ).to_edge(UP)\n\n # Highlight x and dx\n self.play(\n initial_integral[3].animate.set_color(COLOR_X),\n initial_integral[6].animate.set_color(COLOR_X),\n ReplacementTransform(explanation, step1_text)\n )\n self.wait(1)\n\n # The intermediate result after integrating x: [1/2 * x^2 * yz] from 0 to 1\n step1_eval = MathTex(\n r\"\\int_0^1 \\int_0^1\", r\"\\left[ \\frac{1}{2}x^2 yz \\right]_0^1\", r\"\\,dy \\,dz\"\n )\n self.play(ReplacementTransform(initial_integral, step1_eval))\n self.wait(1)\n\n # The simplified result after evaluating the x-limits\n step1_simplified = MathTex(\n r\"\\int_0^1 \\int_0^1\", r\"\\frac{1}{2}yz\", r\"\\,dy \\,dz\"\n )\n self.play(ReplacementTransform(step1_eval, step1_simplified))\n self.wait(2)\n\n # --- Step 2: Integration with respect to y ---\n step2_text = Text(\n \"Step 2: Integrate with respect to y (treat z as constant)\", \n font_size=26, \n color=COLOR_Y\n ).to_edge(UP)\n\n # Highlight y and dy\n self.play(\n step1_simplified[1].animate.set_color(COLOR_Y),\n ReplacementTransform(step1_text, step2_text)\n )\n self.wait(1)\n\n # Intermediate result after integrating y: [1/4 * y^2 * z] from 0 to 1\n step2_eval = MathTex(\n r\"\\int_0^1\", r\"\\left[ \\frac{1}{4}y^2 z \\right]_0^1\", r\"\\,dz\"\n )\n self.play(ReplacementTransform(step1_simplified, step2_eval))\n self.wait(1)\n\n # Simplified result after evaluating the y-limits\n step2_simplified = MathTex(\n r\"\\int_0^1\", r\"\\frac{1}{4}z\", r\"\\,dz\"\n )\n self.play(ReplacementTransform(step2_eval, step2_simplified))\n self.wait(2)\n\n # --- Step 3: Integration with respect to z ---\n step3_text = Text(\n \"Step 3: Integrate with respect to z\", \n font_size=26, \n color=COLOR_Z\n ).to_edge(UP)\n\n # Highlight z and dz\n self.play(\n step2_simplified[1].animate.set_color(COLOR_Z),\n ReplacementTransform(step2_text, step3_text)\n )\n self.wait(1)\n\n # Intermediate result after integrating z: [1/8 * z^2] from 0 to 1\n step3_eval = MathTex(\n r\"\\left[ \\frac{1}{8}z^2 \\right]_0^1\"\n )\n self.play(ReplacementTransform(step2_simplified, step3_eval))\n self.wait(1)\n\n # Final scalar result\n final_result = MathTex(r\"= \\frac{1}{8}\")\n final_line = VGroup(step3_eval, final_result).arrange(RIGHT, buff=0.5)\n \n self.play(\n step3_eval.animate.move_to(ORIGIN).shift(LEFT),\n Write(final_result.shift(RIGHT))\n )\n self.wait(2)\n\n # --- Conclusion ---\n box = SurroundingRectangle(final_line, color=YELLOW, buff=0.3)\n conclusion_text = Text(\n \"Final Solution\", \n font_size=32, \n color=YELLOW\n ).next_to(box, DOWN, buff=0.5)\n \n self.play(Create(box), Write(conclusion_text))\n self.play(Indicate(final_line))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # Colors for highlighting variables and differentials\n COLOR_X = YELLOW\n COLOR_Y = BBLUE\n COLOR_Z = GREEN\n COLOR_TEXT = WHITE\n\n # 1. Initial Expression\n # Split the expression into parts to color the differentials\n initial_integral = MathTex(\n r\"\\int_0^1\", r\"\\int_0^1\", r\"\\int_0^1\", \n \"x\", \"y\", \"z\", \n r\"\\,dx\", r\"\\,dy\", r\"\\,dz\"\n )\n \n explanation = Text(\n \"Evaluate the triple integral of xyz over the unit cube.\", \n font_size=28, \n color=COLOR_TEXT\n ).to_edge(UP)\n\n self.play(Write(explanation))\n self.play(Write(initial_integral))\n self.wait(2)\n\n # --- Step 1: Integration with respect to x ---\n step1_text = Text(\n \"Step 1: Integrate with respect to x (treat y, z as constants)\", \n font_size=26, \n color=COLOR_X\n ).to_edge(UP)\n\n # Highlight x and dx\n self.play(\n initial_integral[3].animate.set_color(COLOR_X),\n initial_integral[6].animate.set_color(COLOR_X),\n ReplacementTransform(explanation, step1_text)\n )\n self.wait(1)\n\n # The intermediate result after integrating x: [1/2 * x^2 * yz] from 0 to 1\n step1_eval = MathTex(\n r\"\\int_0^1 \\int_0^1\", r\"\\left[ \\frac{1}{2}x^2 yz \\right]_0^1\", r\"\\,dy \\,dz\"\n )\n self.play(ReplacementTransform(initial_integral, step1_eval))\n self.wait(1)\n\n # The simplified result after evaluating the x-limits\n step1_simplified = MathTex(\n r\"\\int_0^1 \\int_0^1\", r\"\\frac{1}{2}yz\", r\"\\,dy \\,dz\"\n )\n self.play(ReplacementTransform(step1_eval, step1_simplified))\n self.wait(2)\n\n # --- Step 2: Integration with respect to y ---\n step2_text = Text(\n \"Step 2: Integrate with respect to y (treat z as constant)\", \n font_size=26, \n color=COLOR_Y\n ).to_edge(UP)\n\n # Highlight y and dy\n self.play(\n step1_simplified[1].animate.set_color(COLOR_Y),\n ReplacementTransform(step1_text, step2_text)\n )\n self.wait(1)\n\n # Intermediate result after integrating y: [1/4 * y^2 * z] from 0 to 1\n step2_eval = MathTex(\n r\"\\int_0^1\", r\"\\left[ \\frac{1}{4}y^2 z \\right]_0^1\", r\"\\,dz\"\n )\n self.play(ReplacementTransform(step1_simplified, step2_eval))\n self.wait(1)\n\n # Simplified result after evaluating the y-limits\n step2_simplified = MathTex(\n r\"\\int_0^1\", r\"\\frac{1}{4}z\", r\"\\,dz\"\n )\n self.play(ReplacementTransform(step2_eval, step2_simplified))\n self.wait(2)\n\n # --- Step 3: Integration with respect to z ---\n step3_text = Text(\n \"Step 3: Integrate with respect to z\", \n font_size=26, \n color=COLOR_Z\n ).to_edge(UP)\n\n # Highlight z and dz\n self.play(\n step2_simplified[1].animate.set_color(COLOR_Z),\n ReplacementTransform(step2_text, step3_text)\n )\n self.wait(1)\n\n # Intermediate result after integrating z: [1/8 * z^2] from 0 to 1\n step3_eval = MathTex(\n r\"\\left[ \\frac{1}{8}z^2 \\right]_0^1\"\n )\n self.play(ReplacementTransform(step2_simplified, step3_eval))\n self.wait(1)\n\n # Final scalar result\n final_result = MathTex(r\"= \\frac{1}{8}\")\n final_line = VGroup(step3_eval, final_result).arrange(RIGHT, buff=0.5)\n \n self.play(\n step3_eval.animate.move_to(ORIGIN).shift(LEFT),\n Write(final_result.shift(RIGHT))\n )\n self.wait(2)\n\n # --- Conclusion ---\n box = SurroundingRectangle(final_line, color=YELLOW, buff=0.3)\n conclusion_text = Text(\n \"Final Solution\", \n font_size=32, \n color=YELLOW\n ).next_to(box, DOWN, buff=0.5)\n \n self.play(Create(box), Write(conclusion_text))\n self.play(Indicate(final_line))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the process of solving an integration by parts problem, specifically integrating the function x times e to the power of x? I would like the animation to first display the problem, then show the steps for setting 'u' and 'dv', followed by an explanation of the integration by parts formula, and finally demonstrate the calculation steps with the final solution including the constant of integration. Each step should be shown clearly and give enough time for the viewer to follow along.", "chosen": "```python\nfrom manim import *\n\nclass IntegrationByParts(Scene):\n def construct(self):\n # Define colors for consistent visual language throughout the animation\n COLOR_U = BLUE\n COLOR_DV = YELLOW\n COLOR_V = GREEN\n COLOR_DU = RED\n COLOR_RESULT = YELLOW\n \n # ---------------------------------------------------------\n # Step 1: Display the initial problem\n # ---------------------------------------------------------\n problem = MathTex(r\"\\int x e^x \\, dx\", font_size=72)\n problem_label = Text(\"Problem:\", font_size=36).next_to(problem, LEFT, buff=1)\n \n self.play(Write(problem_label), Write(problem))\n self.wait(2)\n \n # Move problem to the top to make room for steps\n self.play(\n problem.animate.to_edge(UP, buff=1),\n problem_label.animate.to_edge(UP, buff=1).next_to(problem, LEFT, buff=1)\n )\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 2: Define variables u and dv\n # ---------------------------------------------------------\n u_def = MathTex(r\"u = x\", font_size=48, color=COLOR_U)\n du_def = MathTex(r\"du = dx\", font_size=48, color=COLOR_DU)\n dv_def = MathTex(r\"dv = e^x \\, dx\", font_size=48, color=COLOR_DV)\n v_def = MathTex(r\"v = e^x\", font_size=48, color=COLOR_V)\n\n # Arrange them in two columns\n u_group = VGroup(u_def, du_def).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n dv_group = VGroup(dv_def, v_def).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n \n definitions = VGroup(u_group, dv_group).arrange(RIGHT, buff=2).shift(UP * 0.5)\n \n def_label = Text(\"Step 1: Choose u and dv\", font_size=32).next_to(definitions, UP, buff=0.5)\n\n self.play(Write(def_label))\n self.play(Write(u_def), Write(dv_def))\n self.wait(2)\n self.play(Write(du_def), Write(v_def))\n self.wait(3)\n\n # ---------------------------------------------------------\n # Step 3: Explain the Integration by Parts Formula\n # ---------------------------------------------------------\n formula = MathTex(r\"\\int u \\, dv = uv - \\int v \\, du\", font_size=48)\n # Color code the formula to match the definitions\n formula.set_color_by_tex(\"u\", COLOR_U)\n formula.set_color_by_tex(\"du\", COLOR_DU)\n formula.set_color_by_tex(\"dv\", COLOR_DV)\n formula.set_color_by_tex(\"v\", COLOR_V)\n \n formula.shift(DOWN * 1)\n formula_label = Text(\"The Integration by Parts Formula:\", font_size=32).next_to(formula, UP, buff=0.5)\n\n self.play(FadeIn(formula_label), Write(formula))\n self.wait(3)\n\n # Clear the setup definitions to focus on the calculation\n self.play(\n FadeOut(def_label), \n FadeOut(formula_label), \n FadeOut(u_group), \n FadeOut(dv_group)\n )\n self.play(formula.animate.shift(UP * 1.5))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 4: Demonstrate the calculation steps\n # ---------------------------------------------------------\n # Step A: Substitute into formula\n step1 = MathTex(\n r\"\\int x e^x \\, dx = \", \n r\"x\", r\"e^x\", r\" - \\int \", r\"e^x\", r\" \", r\"dx\",\n font_size=48\n )\n # Manually color the parts of the substituted formula\n step1[1].set_color(COLOR_U) # x\n step1[2].set_color(COLOR_V) # e^x\n step1[4].set_color(COLOR_V) # e^x (inside integral)\n step1[6].set_color(COLOR_DU) # dx\n \n step1.next_to(formula, DOWN, buff=0.8, aligned_edge=LEFT)\n\n self.play(Write(step1))\n self.wait(4)\n\n # Step B: Simplify the integral\n step2 = MathTex(\n r\"\\int x e^x \\, dx = x e^x - \\int e^x \\, dx\",\n font_size=48\n )\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(3)\n\n # ---------------------------------------------------------\n # Step 5: Final Solution with Constant of Integration\n # ---------------------------------------------------------\n # Step C: Solve the final integral and add + C\n step3 = MathTex(\n r\"\\int x e^x \\, dx = x e^x - e^x + C\",\n font_size=48\n )\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n # Highlight the constant of integration\n step3.set_color_by_tex(\"C\", COLOR_RESULT)\n \n self.play(Write(step3))\n self.wait(2)\n\n # Draw a box around the final answer for emphasis\n final_box = SurroundingRectangle(step3, color=WHITE, buff=0.2)\n result_text = Text(\"Final Solution\", font_size=32).next_to(final_box, DOWN, buff=0.5)\n\n self.play(Create(final_box), Write(result_text))\n self.wait(5)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrationByParts(Scene):\n def construct(self):\n # Define colors for consistent visual language throughout the animation\n COLOR_U = BLUE\n COLOR_DV = YELLOW\n COLOR_V = GREEN\n COLOR_DU = RED\n COLOR_RESULT = YELLOW\n \n # ---------------------------------------------------------\n # Step 1: Display the initial problem\n # ---------------------------------------------------------\n problem = MathText(r\"\\int x e^x \\, dx\", font_size=72)\n problem_label = Text(\"Problem:\", font_size=36).next_to(problem, LEFT, buff=1)\n \n self.play(Write(problem_label), Write(problem))\n self.wait(2)\n \n # Move problem to the top to make room for steps\n self.play(\n problem.animate.to_edge(UP, buff=1),\n problem_label.animate.to_edge(UP, buff=1).next_to(problem, LEFT, buff=1)\n )\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 2: Define variables u and dv\n # ---------------------------------------------------------\n u_def = MathTex(r\"u = x\", font_size=48, color=COLOR_U)\n du_def = MathTex(r\"du = dx\", font_size=48, color=COLOR_DU)\n dv_def = MathTex(r\"dv = e^x \\, dx\", font_size=48, color=COLOR_DV)\n v_def = MathTex(r\"v = e^x\", font_size=48, color=COLOR_V)\n\n # Arrange them in two columns\n u_group = VGroup(u_def, du_def).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n dv_group = VGroup(dv_def, v_def).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n \n definitions = VGroup(u_group, dv_group).arrange(RIGHT, buff=2).shift(UP * 0.5)\n \n def_label = Text(\"Step 1: Choose u and dv\", font_size=32).next_to(definitions, UP, buff=0.5)\n\n self.play(Write(def_label))\n self.play(Write(u_def), Write(dv_def))\n self.wait(2)\n self.play(Write(du_def), Write(v_def))\n self.wait(3)\n\n # ---------------------------------------------------------\n # Step 3: Explain the Integration by Parts Formula\n # ---------------------------------------------------------\n formula = MathTex(r\"\\int u \\, dv = uv - \\int v \\, du\", font_size=48)\n # Color code the formula to match the definitions\n formula.set_color_by_tex(\"u\", COLOR_U)\n formula.set_color_by_tex(\"du\", COLOR_DU)\n formula.set_color_by_tex(\"dv\", COLOR_DV)\n formula.set_color_by_tex(\"v\", COLOR_V)\n \n formula.shift(DOWN * 1)\n formula_label = Text(\"The Integration by Parts Formula:\", font_size=32).next_to(formula, UP, buff=0.5)\n\n self.play(FadeIn(formula_label), Write(formula))\n self.wait(3)\n\n # Clear the setup definitions to focus on the calculation\n self.play(\n FadeOut(def_label), \n FadeOut(formula_label), \n FadeOut(u_group), \n FadeOut(dv_group)\n )\n self.play(formula.animate.shift(UP * 1.5))\n self.wait(1)\n\n # ---------------------------------------------------------\n # Step 4: Demonstrate the calculation steps\n # ---------------------------------------------------------\n # Step A: Substitute into formula\n step1 = MathTex(\n r\"\\int x e^x \\, dx = \", \n r\"x\", r\"e^x\", r\" - \\int \", r\"e^x\", r\" \", r\"dx\",\n font_size=48\n )\n # Manually color the parts of the substituted formula\n step1[1].set_color(COLOR_U) # x\n step1[2].set_color(COLOR_V) # e^x\n step1[4].set_color(COLOR_V) # e^x (inside integral)\n step1[6].set_color(COLOR_DU) # dx\n \n step1.next_to(formula, DOWN, buff=0.8, aligned_edge=LEFT)\n\n self.play(Write(step1))\n self.wait(4)\n\n # Step B: Simplify the integral\n step2 = MathTex(\n r\"\\int x e^x \\, dx = x e^x - \\int e^x \\, dx\",\n font_size=48\n )\n step2.next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n \n self.play(Write(step2))\n self.wait(3)\n\n # ---------------------------------------------------------\n # Step 5: Final Solution with Constant of Integration\n # ---------------------------------------------------------\n # Step C: Solve the final integral and add + C\n step3 = MathTex(\n r\"\\int x e^x \\, dx = x e^x - e^x + C\",\n font_size=48\n )\n step3.next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n # Highlight the constant of integration\n step3.set_color_by_tex(\"C\", COLOR_RESULT)\n \n self.play(Write(step3))\n self.wait(2)\n\n # Draw a box around the final answer for emphasis\n final_box = SurroundingRectangle(step3, color=WHITE, buff=0.2)\n result_text = Text(\"Final Solution\", font_size=32).next_to(final_box, DOWN, buff=0.5)\n\n self.play(Create(final_box), Write(result_text))\n self.wait(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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\nIn this enhanced animation, we begin by displaying a **Triangle** at the center of the screen, which smoothly rotates by **90 degrees (π/2 radians)** while simultaneously transforming into a **Circle** over **3 seconds**. To enrich the visualization, we introduce a **dynamic mathematical equation** that appears below the shapes, tracking the transformation process with the formula: \n\\[ \\text{Shape}(t) = (1 - t) \\cdot \\text{Triangle} + t \\cdot \\text{Circle} \\] \nwhere \\( t \\) represents the interpolation factor from 0 to 1. Additionally, a **color gradient** shifts the shape from **blue (Triangle)** to **red (Circle)** as the transformation progresses. Once the Circle is fully formed, it **pulses twice** with a glowing effect before splitting into **three smaller circles** that orbit around the original position, demonstrating a secondary transformation. Finally, **explanatory text** fades in, stating: *\"A triangle morphing into a circle via linear interpolation.\"* This layered approach combines smooth geometric transformations with visual and mathematical reinforcement, making the concept more engaging and educational.", "chosen": "```python\nfrom manim import *\n\nclass MorphTriangleToCircle(Scene):\n def construct(self):\n # Create initial triangle and circle\n triangle = Triangle(color=BLUE).scale(1.5)\n circle = Circle(color=RED).scale(1.5)\n \n # Display the equation\n equation = MathTex(\n r\"\\text{Shape}(t) = (1 - t) \\cdot \\text{Triangle} + t \\cdot \\text{Circle}\"\n ).to_edge(DOWN)\n \n # Add initial shapes and equation\n self.play(Create(triangle), Write(equation))\n self.wait(0.5)\n \n # Animate transformation from triangle to circle\n self.play(\n Rotate(triangle, angle=PI/2),\n Transform(triangle, circle, run_time=3),\n triangle.animate.set_color(RED),\n )\n self.wait(0.5)\n \n # Pulsing effect for the circle\n self.play(\n triangle.animate.scale(1.2).set_opacity(0.8),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1/1.2).set_opacity(1),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1.2).set_opacity(0.8),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1/1.2).set_opacity(1),\n run_time=0.5\n )\n \n # Split into three orbiting circles\n small_circles = VGroup(*[Circle(color=RED, radius=0.5) for _ in range(3)])\n small_circles.arrange_in_grid(rows=1, buff=1.5)\n small_circles.move_to(triangle.get_center())\n \n self.play(Transform(triangle, small_circles))\n \n # Orbit animation\n self.play(\n small_circles[0].animate.shift(UP * 1.5),\n small_circles[1].animate.shift(DOWN * 1.5),\n small_circles[2].animate.shift(RIGHT * 1.5),\n run_time=1.5\n )\n \n # Add explanatory text\n text = Text(\"A triangle morphing into a circle via linear interpolation.\").to_edge(UP)\n self.play(FadeIn(text))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass MorphTriangleToCircle(Scene):\n def construct(self):\n # Create initial triangle and circle\n triangle = Triangle(color=BBLUE).scale(1.5)\n circle = Circle(color=RED).scale(1.5)\n \n # Display the equation\n equation = MathTex(\n r\"\\text{Shape}(t) = (1 - t) \\cdot \\text{Triangle} + t \\cdot \\text{Circle}\"\n ).to_edge(DOWN)\n \n # Add initial shapes and equation\n self.play(Create(triangle), Write(equation))\n self.wait(0.5)\n \n # Animate transformation from triangle to circle\n self.play(\n Rotate(triangle, angle=PI/2),\n Transform(triangle, circle, run_time=3),\n triangle.animate.set_color(RED),\n )\n self.wait(0.5)\n \n # Pulsing effect for the circle\n self.play(\n triangle.animate.scale(1.2).set_opacity(0.8),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1/1.2).set_opacity(1),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1.2).set_opacity(0.8),\n run_time=0.5\n )\n self.play(\n triangle.animate.scale(1/1.2).set_opacity(1),\n run_time=0.5\n )\n \n # Split into three orbiting circles\n small_circles = VGroup(*[Circle(color=RED, radius=0.5) for _ in range(3)])\n small_circles.arrange_in_grid(rows=1, buff=1.5)\n small_circles.move_to(triangle.get_center())\n \n self.play(Transform(triangle, small_circles))\n \n # Orbit animation\n self.play(\n small_circles[0].animate.shift(UP * 1.5),\n small_circles[1].animate.shift(DOWN * 1.5),\n small_circles[2].animate.shift(RIGHT * 1.5),\n run_time=1.5\n )\n \n # Add explanatory text\n text = Text(\"A triangle morphing into a circle via linear interpolation.\").to_edge(UP)\n self.play(FadeIn(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 educational video segment that shows how to calculate the definite integral of x cubed from 0 to 2, including an explanation of the power rule for integrals, and ending with a clear presentation of the final answer?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Color Palette ---\n RULE_COLOR = BLUE\n RESULT_COLOR = YELLOW\n\n # 1. Title and Problem Introduction\n title = Text(\"Calculating a Definite Integral\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n problem = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=60)\n problem.next_to(title, DOWN, buff=1)\n self.play(Write(problem))\n self.wait(1.5)\n\n # 2. Explaining the Power Rule\n rule_label = Text(\"Power Rule for Integrals:\", font_size=30, color=RULE_COLOR)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\", font_size=42, color=RULE_COLOR)\n rule_group = VGroup(rule_label, rule_formula).arrange(DOWN, buff=0.2)\n rule_group.next_to(problem, DOWN, buff=1)\n\n self.play(FadeIn(rule_group))\n self.wait(3)\n self.play(FadeOut(rule_group))\n\n # 3. Step-by-Step Derivation\n # Step 1: Apply the Power Rule to find the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=54)\n step1.next_to(problem, DOWN, buff=0.8)\n step1.align_to(problem, LEFT)\n \n self.play(Write(step1))\n self.wait(1.5)\n\n # Step 2: Substitute the upper and lower limits\n step2 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=54)\n step2.next_to(step1, DOWN, buff=0.6)\n step2.align_to(step1, LEFT)\n \n self.play(Write(step2))\n self.wait(1.5)\n\n # Step 3: Simplify the arithmetic\n step3 = MathTex(r\"= \\frac{16}{4} - 0\", font_size=54)\n step3.next_to(step2, DOWN, buff=0.6)\n step3.align_to(step2, LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # 4. Final Answer Emphasis\n final_answer = MathTex(r\"= 4\", font_size=72, color=RESULT_COLOR)\n final_answer.next_to(step3, DOWN, buff=0.8)\n final_answer.align_to(step3, LEFT)\n \n box = SurroundingRectangle(final_answer, color=RESULT_COLOR, buff=0.2)\n \n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(1)\n\n # Clear the screen to focus on the final result\n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n )\n \n # Center and scale up the final answer\n self.play(\n final_answer.animate.move_to(ORIGIN).scale(1.5),\n box.animate.move_to(ORIGIN).scale(1.5)\n )\n \n final_text = Text(\"Final Answer: 4\", font_size=42, color=RESULT_COLOR).next_to(final_answer, UP, buff=1)\n self.play(Write(final_text))\n \n self.wait(3)\n\n# To run this animation:\n# manim -pql scene_file.py DefiniteIntegralX3\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralX3(Scene):\n def construct(self):\n # --- Color Palette ---\n RULE_COLOR = BBLUE\n RESULT_COLOR = YELLOW\n\n # 1. Title and Problem Introduction\n title = Text(\"Calculating a Definite Integral\", font_size=36)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n problem = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=60)\n problem.next_to(title, DOWN, buff=1)\n self.play(Write(problem))\n self.wait(1.5)\n\n # 2. Explaining the Power Rule\n rule_label = Text(\"Power Rule for Integrals:\", font_size=30, color=RULE_COLOR)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1} + C\", font_size=42, color=RULE_COLOR)\n rule_group = VGroup(rule_label, rule_formula).arrange(DOWN, buff=0.2)\n rule_group.next_to(problem, DOWN, buff=1)\n\n self.play(FadeIn(rule_group))\n self.wait(3)\n self.play(FadeOut(rule_group))\n\n # 3. Step-by-Step Derivation\n # Step 1: Apply the Power Rule to find the antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=54)\n step1.next_to(problem, DOWN, buff=0.8)\n step1.align_to(problem, LEFT)\n \n self.play(Write(step1))\n self.wait(1.5)\n\n # Step 2: Substitute the upper and lower limits\n step2 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=54)\n step2.next_to(step1, DOWN, buff=0.6)\n step2.align_to(step1, LEFT)\n \n self.play(Write(step2))\n self.wait(1.5)\n\n # Step 3: Simplify the arithmetic\n step3 = MathTex(r\"= \\frac{16}{4} - 0\", font_size=54)\n step3.next_to(step2, DOWN, buff=0.6)\n step3.align_to(step2, LEFT)\n \n self.play(Write(step3))\n self.wait(1)\n\n # 4. Final Answer Emphasis\n final_answer = MathTex(r\"= 4\", font_size=72, color=RESULT_COLOR)\n final_answer.next_to(step3, DOWN, buff=0.8)\n final_answer.align_to(step3, LEFT)\n \n box = SurroundingRectangle(final_answer, color=RESULT_COLOR, buff=0.2)\n \n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(1)\n\n # Clear the screen to focus on the final result\n self.play(\n FadeOut(title),\n FadeOut(problem),\n FadeOut(step1),\n FadeOut(step2),\n FadeOut(step3),\n )\n \n # Center and scale up the final answer\n self.play(\n final_answer.animate.move_to(ORIGIN).scale(1.5),\n box.animate.move_to(ORIGIN).scale(1.5)\n )\n \n final_text = Text(\"Final Answer: 4\", font_size=42, color=RESULT_COLOR).next_to(final_answer, UP, buff=1)\n self.play(Write(final_text))\n \n self.wait(3)\n\n# To run this animation:\n# manim -pql scene_file.py DefiniteIntegralX3\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Data Pipeline Scheduling\n#### Scheduling Strategies\n##### Time-based Scheduling: Scheduled Execution\nThe most common strategy, such as \"run at 2 AM every day.\" Suitable for generating periodic reports.\n\n##### Event-driven Scheduling: Triggered Execution\nTriggered by specific events, such as \"a new file appears in an S3 bucket\" or \"a webhook call is received.\" Suitable for batch processing with high time sensitivity.\n\n##### Dependency-based Scheduling: Dependency Relationships\nTask B can only start after Task A has successfully completed. This is the foundation for building complex workflows.\n\n##### Hybrid Scheduling\nCombines time and dependencies, for example, \"Task A runs daily at 8 AM and must wait for Task B to complete.\"\n\n\nThe context location of this section (from highest level to current):\n# Lesson 9: Data Pipeline Design\n## Main Content\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SchedulingStrategies(Scene):\n\n def construct(self):\n title = Text('Data Pipeline Scheduling Strategies', 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 content_group = VGroup().shift(DOWN * 0.5)\n time_title = Text('1. Time-based (Scheduled)', font_size=28, color=BLUE_B)\n time_desc = Text(\"Periodic execution, e.g., 'Every day at 2 AM'\", font_size=22)\n time_box = VGroup(time_title, time_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n event_title = Text('2. Event-driven (Triggered)', font_size=28, color=GREEN_B)\n event_desc = Text(\"Triggered by external events, e.g., 'New S3 File'\", font_size=22)\n event_box = VGroup(event_title, event_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n dep_title = Text('3. Dependency-based (Workflow)', font_size=28, color=YELLOW_B)\n dep_desc = Text('Task B starts only after Task A completes', font_size=22)\n dep_box = VGroup(dep_title, dep_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n hybrid_title = Text('4. Hybrid Scheduling', font_size=28, color=RED_B)\n hybrid_desc = Text('Combines time constraints and task dependencies', font_size=22)\n hybrid_box = VGroup(hybrid_title, hybrid_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n content_group.add(time_box, event_box, dep_box, hybrid_box)\n content_group.arrange(DOWN, buff=0.4, aligned_edge=LEFT).to_edge(LEFT, buff=1.5)\n task_a = Text('Task A', font_size=20).shift(RIGHT * 4 + UP * 0.2)\n rect_a = SurroundingRectangle(task_a, color=WHITE, buff=0.2)\n task_b = Text('Task B', font_size=20).next_to(task_a, RIGHT, buff=1.2)\n rect_b = SurroundingRectangle(task_b, color=WHITE, buff=0.2)\n arrow = Arrow(rect_a.get_right(), rect_b.get_left(), buff=0.1)\n dep_viz = VGroup(rect_a, task_a, arrow, rect_b, task_b).scale(0.8).next_to(dep_box, RIGHT, buff=0.5)\n self.play(FadeIn(time_box, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(event_box, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(dep_box, shift=RIGHT), Create(dep_viz))\n self.wait(1)\n self.play(FadeIn(hybrid_box, shift=RIGHT))\n self.wait(2)\n highlight_rect = SurroundingRectangle(hybrid_box, color=ORANGE, buff=0.15)\n self.play(Create(highlight_rect))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SchedulingStrategies(Scene):\n\n def construct(self):\n title = Text('Data Pipeline Scheduling Strategies', 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 content_group = VGroup().shift(DOWN * 0.5)\n time_title = Text('1. Time-based (Scheduled)', font_size=28, color=BBLUE_B)\n time_desc = Text(\"Periodic execution, e.g., 'Every day at 2 AM'\", font_size=22)\n time_box = VGroup(time_title, time_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n event_title = Text('2. Event-driven (Triggered)', font_size=28, color=GREEN_B)\n event_desc = Text(\"Triggered by external events, e.g., 'New S3 File'\", font_size=22)\n event_box = VGroup(event_title, event_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n dep_title = Text('3. Dependency-based (Workflow)', font_size=28, color=YELLOW_B)\n dep_desc = Text('Task B starts only after Task A completes', font_size=22)\n dep_box = VGroup(dep_title, dep_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n hybrid_title = Text('4. Hybrid Scheduling', font_size=28, color=RED_B)\n hybrid_desc = Text('Combines time constraints and task dependencies', font_size=22)\n hybrid_box = VGroup(hybrid_title, hybrid_desc).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n content_group.add(time_box, event_box, dep_box, hybrid_box)\n content_group.arrange(DOWN, buff=0.4, aligned_edge=LEFT).to_edge(LEFT, buff=1.5)\n task_a = Text('Task A', font_size=20).shift(RIGHT * 4 + UP * 0.2)\n rect_a = SurroundingRectangle(task_a, color=WHITE, buff=0.2)\n task_b = Text('Task B', font_size=20).next_to(task_a, RIGHT, buff=1.2)\n rect_b = SurroundingRectangle(task_b, color=WHITE, buff=0.2)\n arrow = Arrow(rect_a.get_right(), rect_b.get_left(), buff=0.1)\n dep_viz = VGroup(rect_a, task_a, arrow, rect_b, task_b).scale(0.8).next_to(dep_box, RIGHT, buff=0.5)\n self.play(FadeIn(time_box, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(event_box, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(dep_box, shift=RIGHT), Create(dep_viz))\n self.wait(1)\n self.play(FadeIn(hybrid_box, shift=RIGHT))\n self.wait(2)\n highlight_rect = SurroundingRectangle(hybrid_box, color=ORANGE, buff=0.15)\n self.play(Create(highlight_rect))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 role does the covariance matrix play in shaping the contour plots of a joint normal distribution?", "chosen": "```python\nfrom manim import *\n\nclass CovarianceMatrixScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Decoding the Shape of Normal Distributions\", font_size=32)\n subtitle = Text(\"The Covariance Matrix\", font_size=28)\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n \n # Display title\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1)\n self.wait(0.5)\n self.play(FadeOut(title_group))\n \n # Introduce the covariance matrix\n matrix_title = Text(\"Covariance Matrix\", font_size=32)\n matrix_title.to_edge(UP)\n \n # Create the covariance matrix equation\n matrix_equation = MathTex(\n r\"\\Sigma = \\begin{bmatrix} \\sigma_1^2 & \\rho \\sigma_1 \\sigma_2 \\\\ \\rho \\sigma_1 \\sigma_2 & \\sigma_2^2 \\end{bmatrix}\"\n )\n \n self.play(Write(matrix_title), run_time=1)\n self.play(Write(matrix_equation), run_time=2)\n self.wait(0.5)\n \n # Create an ellipse to represent a joint normal distribution\n explanation = Text(\"Contour plot of a joint normal distribution\", font_size=24)\n explanation.next_to(matrix_equation, DOWN, buff=1)\n \n # Center the ellipse in the middle of the screen\n ellipse = Ellipse(\n width=3.0, \n height=1.5, \n color=BLUE,\n fill_opacity=0.5\n ).shift(DOWN * 0.5)\n \n self.play(Write(explanation), run_time=1)\n self.play(Create(ellipse), run_time=1.5)\n self.wait(0.5)\n \n # Create arrows to represent eigenvectors\n arrow1 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + RIGHT * 1.5, \n color=YELLOW,\n buff=0\n )\n \n arrow2 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + UP * 0.75, \n color=YELLOW,\n buff=0\n )\n \n eigenvector_text = Text(\"Eigenvectors determine orientation\", font_size=24)\n eigenvector_text.next_to(ellipse, DOWN, buff=1)\n \n self.play(FadeOut(explanation))\n self.play(Create(arrow1), Create(arrow2), run_time=1.5)\n self.play(Write(eigenvector_text), run_time=1)\n self.wait(0.5)\n \n # Show how changing the covariance affects the shape\n self.play(FadeOut(eigenvector_text))\n eigenvalue_text = Text(\"Eigenvalues determine stretching\", font_size=24)\n eigenvalue_text.next_to(ellipse, DOWN, buff=1)\n \n # Rotate and stretch the ellipse to show different covariance values\n new_ellipse = Ellipse(\n width=4.0, \n height=1.0, \n color=BLUE,\n fill_opacity=0.5\n ).shift(DOWN * 0.5)\n new_ellipse.rotate(PI/4) # 45 degree rotation\n \n # Create new arrows for the rotated ellipse - better aligned with principal axes\n new_arrow1 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + RIGHT * 1.414 + UP * 1.414, \n color=YELLOW,\n buff=0\n )\n \n new_arrow2 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + LEFT * 0.707 + UP * 0.707, \n color=YELLOW,\n buff=0\n )\n \n self.play(Write(eigenvalue_text), run_time=1)\n self.play(\n Transform(ellipse, new_ellipse),\n Transform(arrow1, new_arrow1),\n Transform(arrow2, new_arrow2),\n run_time=2\n )\n self.wait(0.5)\n \n # Add the eigenvalue equation - simplified to avoid LaTeX issues\n eigenvalue_equation = MathTex(\n r\"\\lambda_1, \\lambda_2 = \\text{ Eigenvalues of } \\Sigma\"\n )\n eigenvalue_equation.next_to(eigenvalue_text, DOWN, buff=0.5)\n \n self.play(Write(eigenvalue_equation), run_time=1.5)\n self.wait(0.5)\n \n # Conclusion\n self.play(\n FadeOut(matrix_title),\n FadeOut(matrix_equation),\n FadeOut(ellipse),\n FadeOut(arrow1),\n FadeOut(arrow2),\n FadeOut(eigenvalue_text),\n FadeOut(eigenvalue_equation)\n )\n \n conclusion = Text(\"The covariance matrix shapes the contour plots\", font_size=32)\n conclusion.to_edge(UP)\n \n bullet1 = Text(\"• Orientation - Determined by eigenvectors\", font_size=24)\n bullet2 = Text(\"• Scale - Controlled by eigenvalues\", font_size=24)\n bullet3 = Text(\"• Interconnectedness - Shown through correlation\", font_size=24)\n \n bullet1.next_to(conclusion, DOWN, buff=0.7)\n bullet2.next_to(bullet1, DOWN, buff=0.5)\n bullet3.next_to(bullet2, DOWN, buff=0.5)\n \n self.play(Write(conclusion), run_time=1.5)\n self.play(Write(bullet1), run_time=1)\n self.play(Write(bullet2), run_time=1)\n self.play(Write(bullet3), run_time=1)\n self.wait(1)\n \n # Final fade out\n self.play(\n FadeOut(conclusion),\n FadeOut(bullet1),\n FadeOut(bullet2),\n FadeOut(bullet3),\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass CovarianceMatrixScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Decoding the Shape of Normal Distributions\", font_size=32)\n subtitle = Text(\"The Covariance Matrix\", font_size=28)\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n \n # Display title\n self.play(Write(title), run_time=1.5)\n self.play(Write(subtitle), run_time=1)\n self.wait(0.5)\n self.play(FadeOut(title_group))\n \n # Introduce the covariance matrix\n matrix_title = Text(\"Covariance Matrix\", font_size=32)\n matrix_title.to_edge(UP)\n \n # Create the covariance matrix equation\n matrix_equation = MathText(\n r\"\\Sigma = \\begin{bmatrix} \\sigma_1^2 & \\rho \\sigma_1 \\sigma_2 \\\\ \\rho \\sigma_1 \\sigma_2 & \\sigma_2^2 \\end{bmatrix}\"\n )\n \n self.play(Write(matrix_title), run_time=1)\n self.play(Write(matrix_equation), run_time=2)\n self.wait(0.5)\n \n # Create an ellipse to represent a joint normal distribution\n explanation = Text(\"Contour plot of a joint normal distribution\", font_size=24)\n explanation.next_to(matrix_equation, DOWN, buff=1)\n \n # Center the ellipse in the middle of the screen\n ellipse = Ellipse(\n width=3.0, \n height=1.5, \n color=BLUE,\n fill_opacity=0.5\n ).shift(DOWN * 0.5)\n \n self.play(Write(explanation), run_time=1)\n self.play(Create(ellipse), run_time=1.5)\n self.wait(0.5)\n \n # Create arrows to represent eigenvectors\n arrow1 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + RIGHT * 1.5, \n color=YELLOW,\n buff=0\n )\n \n arrow2 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + UP * 0.75, \n color=YELLOW,\n buff=0\n )\n \n eigenvector_text = Text(\"Eigenvectors determine orientation\", font_size=24)\n eigenvector_text.next_to(ellipse, DOWN, buff=1)\n \n self.play(FadeOut(explanation))\n self.play(Create(arrow1), Create(arrow2), run_time=1.5)\n self.play(Write(eigenvector_text), run_time=1)\n self.wait(0.5)\n \n # Show how changing the covariance affects the shape\n self.play(FadeOut(eigenvector_text))\n eigenvalue_text = Text(\"Eigenvalues determine stretching\", font_size=24)\n eigenvalue_text.next_to(ellipse, DOWN, buff=1)\n \n # Rotate and stretch the ellipse to show different covariance values\n new_ellipse = Ellipse(\n width=4.0, \n height=1.0, \n color=BLUE,\n fill_opacity=0.5\n ).shift(DOWN * 0.5)\n new_ellipse.rotate(PI/4) # 45 degree rotation\n \n # Create new arrows for the rotated ellipse - better aligned with principal axes\n new_arrow1 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + RIGHT * 1.414 + UP * 1.414, \n color=YELLOW,\n buff=0\n )\n \n new_arrow2 = Arrow(\n start=DOWN * 0.5, \n end=DOWN * 0.5 + LEFT * 0.707 + UP * 0.707, \n color=YELLOW,\n buff=0\n )\n \n self.play(Write(eigenvalue_text), run_time=1)\n self.play(\n Transform(ellipse, new_ellipse),\n Transform(arrow1, new_arrow1),\n Transform(arrow2, new_arrow2),\n run_time=2\n )\n self.wait(0.5)\n \n # Add the eigenvalue equation - simplified to avoid LaTeX issues\n eigenvalue_equation = MathTex(\n r\"\\lambda_1, \\lambda_2 = \\text{ Eigenvalues of } \\Sigma\"\n )\n eigenvalue_equation.next_to(eigenvalue_text, DOWN, buff=0.5)\n \n self.play(Write(eigenvalue_equation), run_time=1.5)\n self.wait(0.5)\n \n # Conclusion\n self.play(\n FadeOut(matrix_title),\n FadeOut(matrix_equation),\n FadeOut(ellipse),\n FadeOut(arrow1),\n FadeOut(arrow2),\n FadeOut(eigenvalue_text),\n FadeOut(eigenvalue_equation)\n )\n \n conclusion = Text(\"The covariance matrix shapes the contour plots\", font_size=32)\n conclusion.to_edge(UP)\n \n bullet1 = Text(\"• Orientation - Determined by eigenvectors\", font_size=24)\n bullet2 = Text(\"• Scale - Controlled by eigenvalues\", font_size=24)\n bullet3 = Text(\"• Interconnectedness - Shown through correlation\", font_size=24)\n \n bullet1.next_to(conclusion, DOWN, buff=0.7)\n bullet2.next_to(bullet1, DOWN, buff=0.5)\n bullet3.next_to(bullet2, DOWN, buff=0.5)\n \n self.play(Write(conclusion), run_time=1.5)\n self.play(Write(bullet1), run_time=1)\n self.play(Write(bullet2), run_time=1)\n self.play(Write(bullet3), run_time=1)\n self.wait(1)\n \n # Final fade out\n self.play(\n FadeOut(conclusion),\n FadeOut(bullet1),\n FadeOut(bullet2),\n FadeOut(bullet3),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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#### Power Set\nThe power set of a set $A$ is the set of all subsets of $A$, denoted by $\\mathcal{P}(A)$ or $2^A$.\n$$ \\mathcal{P}(A) = \\{S \\mid S \\subseteq A\\} $$\n\n* **Example**:\n If $A = \\{a, b\\}$, then $\\mathcal{P}(A) = \\{\\emptyset, \\{a\\}, \\{b\\}, \\{a, b\\}\\}$.\n If a finite set $A$ has $n$ elements, then its power set contains $2^n$ elements.\n\n## Generalized Operations and Indexed Operations\n\nWhen dealing with operations involving multiple or even infinite sets, we need to extend the basic concepts of union and intersection.\n\n\nContextual location of this section (from highest to current level):\n# Naive Set Theory\n## Basic Set Operations\n### Special Sets\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass PowerSet(Scene):\n\n def construct(self):\n title = Text('Power Set', 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_text = Text('The power set of A is the set of all subsets of A', font_size=28)\n def_formula = MathTex('\\\\mathcal{P}(A) = \\\\{S \\\\mid S \\\\subseteq A\\\\}', font_size=36, color=YELLOW)\n def_group = VGroup(def_text, def_formula).arrange(DOWN, buff=0.3)\n def_group.next_to(title_group, DOWN, buff=0.5)\n self.play(Write(def_text), run_time=1)\n self.play(FadeIn(def_formula, shift=UP * 0.2), run_time=1)\n ex_title = Text('Example:', font_size=28, weight=BOLD, color=BLUE)\n ex_A = MathTex('A = \\\\{a, b\\\\}', font_size=32)\n ex_step1 = VGroup(ex_title, ex_A).arrange(RIGHT, buff=0.3)\n ex_subsets_text = Text('Subsets:', font_size=28)\n ex_subsets = MathTex('\\\\emptyset, \\\\ \\\\{a\\\\}, \\\\ \\\\{b\\\\}, \\\\ \\\\{a, b\\\\}', font_size=32)\n ex_step2 = VGroup(ex_subsets_text, ex_subsets).arrange(RIGHT, buff=0.3)\n ex_PA = MathTex('\\\\mathcal{P}(A) = \\\\{\\\\emptyset, \\\\{a\\\\}, \\\\{b\\\\}, \\\\{a, b\\\\}\\\\}', font_size=36, color=GREEN)\n ex_group = VGroup(ex_step1, ex_step2, ex_PA).arrange(DOWN, buff=0.4)\n ex_group.next_to(def_group, DOWN, buff=0.6)\n self.play(Write(ex_step1), run_time=1)\n self.play(Write(ex_step2), run_time=1.5)\n self.play(FadeIn(ex_PA, shift=UP * 0.2), run_time=1)\n card_rule = MathTex('\\\\text{If } |A| = n, \\\\text{ then } |\\\\mathcal{P}(A)| = 2^n', font_size=32)\n card_box = SurroundingRectangle(card_rule, color=ORANGE, buff=0.2)\n card_group = VGroup(card_rule, card_box)\n card_group.next_to(ex_group, DOWN, buff=0.6)\n self.play(Write(card_rule), run_time=1)\n self.play(Create(card_box), 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 PowerSet(Scene):\n\n def construct(self):\n title = Text('Power Set', 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_text = Text('The power set of A is the set of all subsets of A', font_size=28)\n def_formula = MathTex('\\\\mathcal{P}(A) = \\\\{S \\\\mid S \\\\subseteq A\\\\}', font_size=36, color=YELLOW)\n def_group = VGroup(def_text, def_formula).arrange(DOWN, buff=0.3)\n def_group.next_to(title_group, DOWN, buff=0.5)\n self.play(Write(def_text), run_time=1)\n self.play(FadeIn(def_formula, shift=UP * 0.2), run_time=1)\n ex_title = Text('Example:', font_size=28, weight=BOLD, color=BBLUE)\n ex_A = MathTex('A = \\\\{a, b\\\\}', font_size=32)\n ex_step1 = VGroup(ex_title, ex_A).arrange(RIGHT, buff=0.3)\n ex_subsets_text = Text('Subsets:', font_size=28)\n ex_subsets = MathTex('\\\\emptyset, \\\\ \\\\{a\\\\}, \\\\ \\\\{b\\\\}, \\\\ \\\\{a, b\\\\}', font_size=32)\n ex_step2 = VGroup(ex_subsets_text, ex_subsets).arrange(RIGHT, buff=0.3)\n ex_PA = MathTex('\\\\mathcal{P}(A) = \\\\{\\\\emptyset, \\\\{a\\\\}, \\\\{b\\\\}, \\\\{a, b\\\\}\\\\}', font_size=36, color=GREEN)\n ex_group = VGroup(ex_step1, ex_step2, ex_PA).arrange(DOWN, buff=0.4)\n ex_group.next_to(def_group, DOWN, buff=0.6)\n self.play(Write(ex_step1), run_time=1)\n self.play(Write(ex_step2), run_time=1.5)\n self.play(FadeIn(ex_PA, shift=UP * 0.2), run_time=1)\n card_rule = MathTex('\\\\text{If } |A| = n, \\\\text{ then } |\\\\mathcal{P}(A)| = 2^n', font_size=32)\n card_box = SurroundingRectangle(card_rule, color=ORANGE, buff=0.2)\n card_group = VGroup(card_rule, card_box)\n card_group.next_to(ex_group, DOWN, buff=0.6)\n self.play(Write(card_rule), run_time=1)\n self.play(Create(card_box), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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: Here’s an enhanced version of the animation that retains all the original features while adding significant new elements: \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_0632(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_integralanimation()\n self.clear_stage()\n self.act_2_enhancedshapetransformat()\n self.clear_stage()\n self.act_3_flashsequence()\n\n def act_1_integralanimation(self):\n func_text = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\n )\n self.wait(2)\n\n def act_2_enhancedshapetransformat(self):\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\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_0632(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_integralanimation()\n self.clear_stage()\n self.act_2_enhancedshapetransformat()\n self.clear_stage()\n self.act_3_flashsequence()\n\n def act_1_integralanimation(self):\n func_text = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BBLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\n )\n self.wait(2)\n\n def act_2_enhancedshapetransformat(self):\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\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Demonstrate the concept of torque and rotational motion.\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_0720(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_torqueandrotationalmotio()\n self.clear_stage()\n self.act_2_equilibriumincomederivat()\n\n def act_1_torqueandrotationalmotio(self):\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\n def act_2_equilibriumincomederivat(self):\n title = Tex('\\\\textbf{Solving for Equilibrium Income (Y)}', font_size=44)\n title.to_edge(UP, buff=0.5)\n title_underline = Underline(title, color=BLUE)\n text1 = Tex('Define total autonomous expenditure:', font_size=36)\n eq1 = MathTex('A', '\\\\equiv', 'C_0', '+', 'I', '+', 'G', font_size=44)\n eq1[0].set_color(BLUE)\n group1 = VGroup(text1, eq1).arrange(DOWN, buff=0.3)\n text2 = Tex('Then:', font_size=36)\n eq2 = MathTex('Y', '=', '\\\\frac{1}{1 - c}', 'A', font_size=44)\n eq2[0].set_color(GREEN)\n eq2[2].set_color(YELLOW)\n eq2[3].set_color(BLUE)\n group2 = VGroup(text2, eq2).arrange(DOWN, buff=0.3)\n hint_box = SurroundingRectangle(eq2[2], color=YELLOW, buff=0.1)\n hint_text1 = Tex('Here, ', '$\\\\frac{1}{1 - c}$', ' is the ', '\\\\textbf{multiplier},', font_size=32)\n hint_text1[1].set_color(YELLOW)\n hint_text1[3].set_color(YELLOW)\n hint_text2 = Tex('indicating how much the equilibrium income will change\\\\\\\\', 'when autonomous expenditure changes by one unit.', font_size=32)\n hint_group = VGroup(hint_text1, hint_text2).arrange(DOWN, buff=0.2)\n content = VGroup(group1, group2, hint_group).arrange(DOWN, buff=0.8)\n content.next_to(title, DOWN, buff=0.6)\n self.play(Write(title), Create(title_underline))\n self.wait(0.5)\n self.play(FadeIn(text1, shift=UP * 0.3))\n self.play(Write(eq1))\n self.wait(1)\n self.play(FadeIn(text2, shift=UP * 0.3))\n self.play(Write(eq2))\n self.wait(1)\n self.play(Create(hint_box))\n self.play(FadeIn(hint_group, shift=UP * 0.3))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0720(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_torqueandrotationalmotio()\n self.clear_stage()\n self.act_2_equilibriumincomederivat()\n\n def act_1_torqueandrotationalmotio(self):\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\": BBLUE, \"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\n def act_2_equilibriumincomederivat(self):\n title = Tex('\\\\textbf{Solving for Equilibrium Income (Y)}', font_size=44)\n title.to_edge(UP, buff=0.5)\n title_underline = Underline(title, color=BLUE)\n text1 = Tex('Define total autonomous expenditure:', font_size=36)\n eq1 = MathTex('A', '\\\\equiv', 'C_0', '+', 'I', '+', 'G', font_size=44)\n eq1[0].set_color(BLUE)\n group1 = VGroup(text1, eq1).arrange(DOWN, buff=0.3)\n text2 = Tex('Then:', font_size=36)\n eq2 = MathTex('Y', '=', '\\\\frac{1}{1 - c}', 'A', font_size=44)\n eq2[0].set_color(GREEN)\n eq2[2].set_color(YELLOW)\n eq2[3].set_color(BLUE)\n group2 = VGroup(text2, eq2).arrange(DOWN, buff=0.3)\n hint_box = SurroundingRectangle(eq2[2], color=YELLOW, buff=0.1)\n hint_text1 = Tex('Here, ', '$\\\\frac{1}{1 - c}$', ' is the ', '\\\\textbf{multiplier},', font_size=32)\n hint_text1[1].set_color(YELLOW)\n hint_text1[3].set_color(YELLOW)\n hint_text2 = Tex('indicating how much the equilibrium income will change\\\\\\\\', 'when autonomous expenditure changes by one unit.', font_size=32)\n hint_group = VGroup(hint_text1, hint_text2).arrange(DOWN, buff=0.2)\n content = VGroup(group1, group2, hint_group).arrange(DOWN, buff=0.8)\n content.next_to(title, DOWN, buff=0.6)\n self.play(Write(title), Create(title_underline))\n self.wait(0.5)\n self.play(FadeIn(text1, shift=UP * 0.3))\n self.play(Write(eq1))\n self.wait(1)\n self.play(FadeIn(text2, shift=UP * 0.3))\n self.play(Write(eq2))\n self.wait(1)\n self.play(Create(hint_box))\n self.play(FadeIn(hint_group, shift=UP * 0.3))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Description:** \n\nIn this advanced animation, we begin by smoothly drawing a maroon-colored regular hexagon with a radius of 3, just like the original. However, we now enhance the scene by dynamically labeling each vertex with letters (A to F) as they appear, reinforcing the hexagon’s structure. Once the hexagon is fully formed, we animate the appearance of its center point (O) and draw dashed lines from the center to each vertex, visually emphasizing its radial symmetry. Simultaneously, a related mathematical formula fades in below the hexagon, displaying the interior angle sum (720°) and side length formula for a regular hexagon (side length = radius). To further deepen understanding, we then morph the hexagon into an equilateral triangle by connecting every other vertex, demonstrating how a hexagon can be decomposed into six smaller triangles. Finally, we highlight one of these triangles with a contrasting color and animate a transformation back to the original hexagon, reinforcing the geometric relationship between the two shapes. The entire sequence is accompanied by smooth transitions and explanatory text that appears step-by-step, making the animation both visually engaging and educational.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedHexagonAnimation(Scene):\n def construct(self):\n # Create a maroon hexagon\n hexagon = RegularPolygon(n=6, radius=3, color=MAROON)\n vertices = hexagon.get_vertices()\n \n # Animate drawing the hexagon\n self.play(Create(hexagon), run_time=2)\n \n # Label each vertex with letters A-F\n labels = []\n for i, vertex in enumerate(vertices):\n label = Text(chr(65 + i), font_size=24).move_to(vertex * 1.2)\n labels.append(label)\n self.play(Write(label), run_time=0.3)\n \n # Add center point O\n center = Dot(color=YELLOW).move_to(ORIGIN)\n center_label = Text(\"O\", font_size=24).next_to(center, DOWN, buff=0.1)\n self.play(FadeIn(center), Write(center_label), run_time=0.5)\n \n # Draw dashed lines from center to vertices\n radial_lines = VGroup()\n for vertex in vertices:\n line = DashedLine(ORIGIN, vertex, color=BLUE, stroke_width=2)\n radial_lines.add(line)\n self.play(Create(radial_lines), run_time=2)\n \n # Display mathematical formulas\n formula1 = MathTex(r\"\\text{Sum of interior angles} = 720^\\circ\", font_size=32)\n formula2 = MathTex(r\"\\text{Side length} = \\text{radius}\", font_size=32)\n formulas = VGroup(formula1, formula2).arrange(DOWN, buff=0.5).to_edge(DOWN)\n self.play(Write(formulas), run_time=1.5)\n \n # Morph hexagon into equilateral triangle\n triangle_vertices = [vertices[0], vertices[2], vertices[4], vertices[0]]\n triangle = Polygon(*triangle_vertices, color=GREEN)\n self.play(Transform(hexagon, triangle), run_time=2)\n self.wait(1)\n \n # Highlight one of the smaller triangles\n small_triangle = Polygon(ORIGIN, vertices[0], vertices[1], color=PURPLE, fill_opacity=0.5)\n self.play(FadeIn(small_triangle), run_time=1)\n self.wait(1)\n \n # Transform back to hexagon\n self.play(\n Transform(hexagon, RegularPolygon(n=6, radius=3, color=MAROON)),\n FadeOut(small_triangle),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedHexagonAnimation(Scene):\n def construct(self):\n # Create a maroon hexagon\n hexagon = RegularPolygon(n=6, radius=3, color=MAROON)\n vertices = hexagon.get_vertices()\n \n # Animate drawing the hexagon\n self.play(Create(hexagon), run_time=2)\n \n # Label each vertex with letters A-F\n labels = []\n for i, vertex in enumerate(vertices):\n label = Text(chr(65 + i), font_size=24).move_to(vertex * 1.2)\n labels.append(label)\n self.play(Write(label), run_time=0.3)\n \n # Add center point O\n center = Dot(color=YELLOW).move_to(ORIGIN)\n center_label = Text(\"O\", font_size=24).next_to(center, DOWN, buff=0.1)\n self.play(FadeIn(center), Write(center_label), run_time=0.5)\n \n # Draw dashed lines from center to vertices\n radial_lines = VGroup()\n for vertex in vertices:\n line = DashedLine(ORIGIN, vertex, color=BBLUE, stroke_width=2)\n radial_lines.add(line)\n self.play(Create(radial_lines), run_time=2)\n \n # Display mathematical formulas\n formula1 = MathTex(r\"\\text{Sum of interior angles} = 720^\\circ\", font_size=32)\n formula2 = MathTex(r\"\\text{Side length} = \\text{radius}\", font_size=32)\n formulas = VGroup(formula1, formula2).arrange(DOWN, buff=0.5).to_edge(DOWN)\n self.play(Write(formulas), run_time=1.5)\n \n # Morph hexagon into equilateral triangle\n triangle_vertices = [vertices[0], vertices[2], vertices[4], vertices[0]]\n triangle = Polygon(*triangle_vertices, color=GREEN)\n self.play(Transform(hexagon, triangle), run_time=2)\n self.wait(1)\n \n # Highlight one of the smaller triangles\n small_triangle = Polygon(ORIGIN, vertices[0], vertices[1], color=PURPLE, fill_opacity=0.5)\n self.play(FadeIn(small_triangle), run_time=1)\n self.wait(1)\n \n # Transform back to hexagon\n self.play(\n Transform(hexagon, RegularPolygon(n=6, radius=3, color=MAROON)),\n FadeOut(small_triangle),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Upcoming Section Preview\n\n#### System Integration and Frontiers\nAfter mastering the core algorithms of ASR and TTS, the final part of the course (Lectures 15-16) will explore how to integrate these technologies into actual dialogue systems and look ahead at the latest frontiers with multimodal voice large models like GPT-4o.\n- We will focus on the engineering challenges of implementing full-duplex conversations and end-to-end voice large models.\n\n\nContextual position of this section (from highest to current level):\n# Intelligent Voice Technology Course - Detailed Outline for Lecture 14 (End-to-End TTS and Frontier Technologies (Core Lecture), 90 minutes)\n## Summary of Key Points for This Lecture (10 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SystemIntegrationAndFrontiers(Scene):\n\n def construct(self):\n title = Text('System Integration and Frontiers', 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 mastered_text = Text('Mastered Core:\\nASR and TTS', font_size=26, color=BLUE)\n mastered_box = SurroundingRectangle(mastered_text, color=BLUE, buff=0.4)\n mastered_group = VGroup(mastered_text, mastered_box)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.2)\n next_text = Text('Lectures 15-16:\\nSystem Integration\\nand Frontiers', font_size=26, color=GREEN)\n next_box = SurroundingRectangle(next_text, color=GREEN, buff=0.4)\n next_group = VGroup(next_text, next_box)\n flow_group = VGroup(mastered_group, arrow, next_group).arrange(RIGHT, buff=0.8)\n flow_group.next_to(title_group, DOWN, buff=1.0)\n self.play(FadeIn(mastered_text), Create(mastered_box), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=0.8)\n self.play(FadeIn(next_text), Create(next_box), run_time=1.5)\n challenges_title = Text('Key Engineering Challenges:', font_size=28, color=YELLOW)\n challenges_title.next_to(flow_group, DOWN, buff=1.0).to_edge(LEFT, buff=1.5)\n item1 = Text('- Implementing full-duplex conversations', font_size=24)\n item2 = Text('- End-to-end voice large models (e.g., GPT-4o)', font_size=24)\n items = VGroup(item1, item2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n items.next_to(challenges_title, DOWN, buff=0.4).align_to(challenges_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(challenges_title), run_time=1.0)\n self.play(FadeIn(item1, shift=RIGHT * 0.5), run_time=1.0)\n self.play(FadeIn(item2, shift=RIGHT * 0.5), run_time=1.0)\n self.wait(1.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass SystemIntegrationAndFrontiers(Scene):\n\n def construct(self):\n title = Text('System Integration and Frontiers', 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 mastered_text = Text('Mastered Core:\\nASR and TTS', font_size=26, color=BBLUE)\n mastered_box = SurroundingRectangle(mastered_text, color=BLUE, buff=0.4)\n mastered_group = VGroup(mastered_text, mastered_box)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.2)\n next_text = Text('Lectures 15-16:\\nSystem Integration\\nand Frontiers', font_size=26, color=GREEN)\n next_box = SurroundingRectangle(next_text, color=GREEN, buff=0.4)\n next_group = VGroup(next_text, next_box)\n flow_group = VGroup(mastered_group, arrow, next_group).arrange(RIGHT, buff=0.8)\n flow_group.next_to(title_group, DOWN, buff=1.0)\n self.play(FadeIn(mastered_text), Create(mastered_box), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=0.8)\n self.play(FadeIn(next_text), Create(next_box), run_time=1.5)\n challenges_title = Text('Key Engineering Challenges:', font_size=28, color=YELLOW)\n challenges_title.next_to(flow_group, DOWN, buff=1.0).to_edge(LEFT, buff=1.5)\n item1 = Text('- Implementing full-duplex conversations', font_size=24)\n item2 = Text('- End-to-end voice large models (e.g., GPT-4o)', font_size=24)\n items = VGroup(item1, item2).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n items.next_to(challenges_title, DOWN, buff=0.4).align_to(challenges_title, LEFT).shift(RIGHT * 0.5)\n self.play(Write(challenges_title), run_time=1.0)\n self.play(FadeIn(item1, shift=RIGHT * 0.5), run_time=1.0)\n self.play(FadeIn(item2, shift=RIGHT * 0.5), run_time=1.0)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 def construct(self):\n # --------------------------------------------------------------\n # 1. Coordinate System\n # Create axes with a range that comfortably fits the function\n # --------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 5.5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_numbers\": True,\n \"include_tip\": True,\n \"numbers_to_exclude\": [0],\n },\n ).add_coordinates().shift(LEFT * 2.5)\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 # Animate the creation of the coordinate system\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 2. Function Graph\n # Plot f(x) = x^2\n # --------------------------------------------------------------\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n graph_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 3. Shaded Region\n # Highlight the area under the curve from x=0 to x=2\n # --------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Add a vertical line at x=2 and a label for visual clarity\n v_line = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY)\n v_label = MathTex(\"2\").next_to(v_line, DOWN)\n\n self.play(Create(v_line), Write(v_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 4. Integral Symbol\n # Display the definite integral expression representing the area\n # --------------------------------------------------------------\n integral_expr = MathTex(\n r\"\\text{Area} = \\int_{0}^{2}\", r\"x^2\", r\"\\, dx\"\n ).scale(1.2).to_edge(RIGHT).shift(UP * 2)\n\n self.play(Write(integral_expr))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 5. Calculation Process\n # Visually demonstrate the integration steps below the integral\n # --------------------------------------------------------------\n \n # Step 5a: Find the antiderivative\n step1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\"\n ).scale(1.2).next_to(integral_expr, DOWN, aligned_edge=LEFT)\n\n # Step 5b: Evaluate at bounds\n step2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\"\n ).scale(1.2).next_to(step1, DOWN, aligned_edge=LEFT)\n\n self.play(Write(step1))\n self.wait(2) # Pause for students to understand the antiderivative\n self.play(Write(step2))\n self.wait(2) # Pause for students to understand the evaluation\n\n # --------------------------------------------------------------\n # 6. Final Solution\n # Display the final numeric result\n # --------------------------------------------------------------\n final_solution = MathTex(\n r\"= \\frac{8}{3} \\approx 2.67\", \n font_size=40, \n color=GREEN\n ).next_to(step2, DOWN, aligned_edge=LEFT)\n\n # Highlight the final result with a surrounding box\n solution_box = SurroundingRectangle(final_solution, color=YELLOW, buff=0.2)\n\n self.play(Write(final_solution))\n self.play(Create(solution_box))\n self.wait(3)\n\n# To run this code:\n# 1. Install manim: pip install manim\n# 2. Run via command line: manim -pql filename.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # --------------------------------------------------------------\n # 1. Coordinate System\n # Create axes with a range that comfortably fits the function\n # --------------------------------------------------------------\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 5.5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_numbers\": True,\n \"include_tip\": True,\n \"numbers_to_exclude\": [0],\n },\n ).add_coordinates().shift(LEFT * 2.5)\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 # Animate the creation of the coordinate system\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 2. Function Graph\n # Plot f(x) = x^2\n # --------------------------------------------------------------\n graph = axes.plot(lambda x: x**2, color=BBLUE, x_range=[0, 2.5])\n graph_label = MathTex(\"f(x) = x^2\", color=BLUE).next_to(graph, UR, buff=0.2)\n\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 3. Shaded Region\n # Highlight the area under the curve from x=0 to x=2\n # --------------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n \n # Add a vertical line at x=2 and a label for visual clarity\n v_line = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY)\n v_label = MathTex(\"2\").next_to(v_line, DOWN)\n\n self.play(Create(v_line), Write(v_label))\n self.play(FadeIn(area))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 4. Integral Symbol\n # Display the definite integral expression representing the area\n # --------------------------------------------------------------\n integral_expr = MathTex(\n r\"\\text{Area} = \\int_{0}^{2}\", r\"x^2\", r\"\\, dx\"\n ).scale(1.2).to_edge(RIGHT).shift(UP * 2)\n\n self.play(Write(integral_expr))\n self.wait(1)\n\n # --------------------------------------------------------------\n # 5. Calculation Process\n # Visually demonstrate the integration steps below the integral\n # --------------------------------------------------------------\n \n # Step 5a: Find the antiderivative\n step1 = MathTex(\n r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\"\n ).scale(1.2).next_to(integral_expr, DOWN, aligned_edge=LEFT)\n\n # Step 5b: Evaluate at bounds\n step2 = MathTex(\n r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\"\n ).scale(1.2).next_to(step1, DOWN, aligned_edge=LEFT)\n\n self.play(Write(step1))\n self.wait(2) # Pause for students to understand the antiderivative\n self.play(Write(step2))\n self.wait(2) # Pause for students to understand the evaluation\n\n # --------------------------------------------------------------\n # 6. Final Solution\n # Display the final numeric result\n # --------------------------------------------------------------\n final_solution = MathTex(\n r\"= \\frac{8}{3} \\approx 2.67\", \n font_size=40, \n color=GREEN\n ).next_to(step2, DOWN, aligned_edge=LEFT)\n\n # Highlight the final result with a surrounding box\n solution_box = SurroundingRectangle(final_solution, color=YELLOW, buff=0.2)\n\n self.play(Write(final_solution))\n self.play(Create(solution_box))\n self.wait(3)\n\n# To run this code:\n# 1. Install manim: pip install manim\n# 2. Run via command line: 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Setup: Initialize coordinate axes and plot a quadratic function\n # We use f(x) = (3/16)x^2 so that the integral from 0 to 4 evaluates to a clean integer (4).\n axes = Axes(\n x_range=[-1, 5, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_include\": [0, 4],\n \"font_size\": 24\n }\n ).shift(LEFT * 2)\n \n func = lambda x: (3/16) * x**2\n curve = axes.plot(func, x_range=[-1, 4.5], color=BLUE)\n \n self.play(Create(axes), Create(curve))\n self.wait()\n\n # 2. Labeling: Display the equation of the curve near the graph\n equation_label = MathTex(\n r\"f(x) = \\frac{3}{16}x^2\", \n font_size=36\n ).next_to(curve, UR, buff=0.3)\n \n self.play(Write(equation_label))\n self.wait()\n\n # 3. Shading: Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=GREEN, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait()\n\n # 4. Explanation: Display a text description stating the shaded region is the integral\n explanation_text = Text(\n \"The shaded region represents the definite integral from 0 to 4\", \n font_size=24, \n color=GRAY_A\n ).to_edge(DOWN, buff=1)\n \n self.play(Write(explanation_text))\n self.wait(2)\n\n # 5. Formula Transition: Animate the equation label being replaced by the integral formula\n integral_formula = MathTex(\n r\"\\int_{0}^{4} f(x) \\, dx\", \n font_size=42, \n color=YELLOW\n ).move_to(equation_label)\n \n self.play(\n ReplacementTransform(equation_label, integral_formula),\n FadeOut(explanation_text)\n )\n self.wait(2)\n\n # 6. Calculation: Compute and display the actual numerical value of the area\n # Integral of (3/16)x^2 from 0 to 4 is [ (1/16)x^3 ] from 0 to 4 = 64/16 = 4\n result_text = MathTex(\n r\"= 4\", \n font_size=42, \n color=YELLOW\n ).next_to(integral_formula, RIGHT)\n \n self.play(Write(result_text))\n self.wait(2)\n\n # 7. Conclusion: Clear all elements from the screen except the final calculated solution\n # Prepare the final emphasized solution\n final_solution = MathTex(\n r\"\\text{Area} = \\int_{0}^{4} f(x) \\, dx = 4\", \n font_size=48, \n color=YELLOW\n ).move_to(ORIGIN)\n \n full_calculation = VGroup(integral_formula, result_text)\n \n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n ReplacementTransform(full_calculation, final_solution)\n )\n \n # Hold the final state for emphasis\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # 1. Setup: Initialize coordinate axes and plot a quadratic function\n # We use f(x) = (3/16)x^2 so that the integral from 0 to 4 evaluates to a clean integer (4).\n axes = Axes(label_font_size=24, \n x_range=[-1, 5, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_include\": [0, 4],\n \"font_size\": 24\n }\n ).shift(LEFT * 2)\n \n func = lambda x: (3/16) * x**2\n curve = axes.plot(func, x_range=[-1, 4.5], color=BLUE)\n \n self.play(Create(axes), Create(curve))\n self.wait()\n\n # 2. Labeling: Display the equation of the curve near the graph\n equation_label = MathTex(\n r\"f(x) = \\frac{3}{16}x^2\", \n font_size=36\n ).next_to(curve, UR, buff=0.3)\n \n self.play(Write(equation_label))\n self.wait()\n\n # 3. Shading: Shade the area under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=[0, 4], color=GREEN, opacity=0.5)\n \n self.play(FadeIn(area))\n self.wait()\n\n # 4. Explanation: Display a text description stating the shaded region is the integral\n explanation_text = Text(\n \"The shaded region represents the definite integral from 0 to 4\", \n font_size=24, \n color=GRAY_A\n ).to_edge(DOWN, buff=1)\n \n self.play(Write(explanation_text))\n self.wait(2)\n\n # 5. Formula Transition: Animate the equation label being replaced by the integral formula\n integral_formula = MathTex(\n r\"\\int_{0}^{4} f(x) \\, dx\", \n font_size=42, \n color=YELLOW\n ).move_to(equation_label)\n \n self.play(\n ReplacementTransform(equation_label, integral_formula),\n FadeOut(explanation_text)\n )\n self.wait(2)\n\n # 6. Calculation: Compute and display the actual numerical value of the area\n # Integral of (3/16)x^2 from 0 to 4 is [ (1/16)x^3 ] from 0 to 4 = 64/16 = 4\n result_text = MathTex(\n r\"= 4\", \n font_size=42, \n color=YELLOW\n ).next_to(integral_formula, RIGHT)\n \n self.play(Write(result_text))\n self.wait(2)\n\n # 7. Conclusion: Clear all elements from the screen except the final calculated solution\n # Prepare the final emphasized solution\n final_solution = MathTex(\n r\"\\text{Area} = \\int_{0}^{4} f(x) \\, dx = 4\", \n font_size=48, \n color=YELLOW\n ).move_to(ORIGIN)\n \n full_calculation = VGroup(integral_formula, result_text)\n \n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n ReplacementTransform(full_calculation, final_solution)\n )\n \n # Hold the final state for emphasis\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass VariablesAndConstants(Scene):\n\n def construct(self):\n context = Text('Context: Basic Components of a Program', font_size=20, color=GRAY)\n context.to_corner(UL)\n title = Text('Basic Concepts of Variables and Constants', font_size=32, weight=BOLD)\n title.to_edge(UP, buff=0.8)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.wait(0.5)\n item1 = Text('Variable:', font_size=26, color=BLUE)\n sub1_l1 = Text('• A storage unit in memory with a', font_size=22)\n sub1_l2 = Text(' specific type and name;', font_size=22)\n sub1 = VGroup(sub1_l1, sub1_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n sub2_l1 = Text('• The value of a variable can be changed', font_size=22)\n sub2_l2 = Text(' during program execution (Reassigned).', font_size=22)\n sub2 = VGroup(sub2_l1, sub2_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n sub3_l1 = Text('• The type determines the bit width', font_size=22)\n sub3_l2 = Text(' and interpretation method.', font_size=22)\n sub3 = VGroup(sub3_l1, sub3_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n text_group = VGroup(item1, sub1, sub2, sub3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n text_group.to_edge(LEFT, buff=0.5).shift(DOWN * 0.5)\n for sub in [sub1, sub2, sub3]:\n sub.shift(RIGHT * 0.5)\n else:\n pass\n mem_box = Rectangle(width=3.5, height=2.2, color=BLUE, fill_color=BLUE, fill_opacity=0.1)\n mem_label = Text('Memory Unit', font_size=20, color=GRAY).next_to(mem_box, UP)\n var_name = Text('Name: my_var', font_size=20, color=YELLOW).next_to(mem_box, DOWN)\n var_type = Text('Type: int8', font_size=20, color=GREEN).next_to(var_name, DOWN, buff=0.1)\n visual_group = VGroup(mem_box, mem_label, var_name, var_type)\n visual_group.to_edge(RIGHT, buff=1.0).shift(DOWN * 0.5)\n val_42 = Text('42', font_size=48, color=WHITE).move_to(mem_box)\n val_100 = Text('100', font_size=48, color=RED).move_to(mem_box)\n self.play(Write(item1))\n self.play(Write(sub1))\n self.wait(0.5)\n self.play(Create(mem_box), Write(mem_label))\n self.play(Write(var_name), Write(var_type))\n self.play(FadeIn(val_42, shift=DOWN * 0.2))\n self.wait(1)\n self.play(Write(sub2))\n self.wait(0.5)\n self.play(ReplacementTransform(val_42, val_100))\n self.wait(1)\n self.play(Write(sub3))\n self.wait(0.5)\n binary_text = Text('01100100', font_size=24, color=YELLOW)\n binary_label = Text(\"(8-bit two's complement)\", font_size=16, color=GRAY)\n bin_group = VGroup(binary_text, binary_label).arrange(DOWN, buff=0.1)\n bin_group.move_to(mem_box).shift(DOWN * 0.4)\n self.play(val_100.animate.shift(UP * 0.3).scale(0.8), FadeIn(bin_group, shift=UP * 0.2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass VariablesAndConstants(Scene):\n\n def construct(self):\n context = Text('Context: Basic Components of a Program', font_size=20, color=GRAY)\n context.to_corner(UL)\n title = Text('Basic Concepts of Variables and Constants', font_size=32, weight=BOLD)\n title.to_edge(UP, buff=0.8)\n self.play(FadeIn(context))\n self.play(Write(title))\n self.wait(0.5)\n item1 = Text('Variable:', font_size=26, color=BBLUE)\n sub1_l1 = Text('• A storage unit in memory with a', font_size=22)\n sub1_l2 = Text(' specific type and name;', font_size=22)\n sub1 = VGroup(sub1_l1, sub1_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n sub2_l1 = Text('• The value of a variable can be changed', font_size=22)\n sub2_l2 = Text(' during program execution (Reassigned).', font_size=22)\n sub2 = VGroup(sub2_l1, sub2_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n sub3_l1 = Text('• The type determines the bit width', font_size=22)\n sub3_l2 = Text(' and interpretation method.', font_size=22)\n sub3 = VGroup(sub3_l1, sub3_l2).arrange(DOWN, aligned_edge=LEFT, buff=0.1)\n text_group = VGroup(item1, sub1, sub2, sub3).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n text_group.to_edge(LEFT, buff=0.5).shift(DOWN * 0.5)\n for sub in [sub1, sub2, sub3]:\n sub.shift(RIGHT * 0.5)\n else:\n pass\n mem_box = Rectangle(width=3.5, height=2.2, color=BLUE, fill_color=BLUE, fill_opacity=0.1)\n mem_label = Text('Memory Unit', font_size=20, color=GRAY).next_to(mem_box, UP)\n var_name = Text('Name: my_var', font_size=20, color=YELLOW).next_to(mem_box, DOWN)\n var_type = Text('Type: int8', font_size=20, color=GREEN).next_to(var_name, DOWN, buff=0.1)\n visual_group = VGroup(mem_box, mem_label, var_name, var_type)\n visual_group.to_edge(RIGHT, buff=1.0).shift(DOWN * 0.5)\n val_42 = Text('42', font_size=48, color=WHITE).move_to(mem_box)\n val_100 = Text('100', font_size=48, color=RED).move_to(mem_box)\n self.play(Write(item1))\n self.play(Write(sub1))\n self.wait(0.5)\n self.play(Create(mem_box), Write(mem_label))\n self.play(Write(var_name), Write(var_type))\n self.play(FadeIn(val_42, shift=DOWN * 0.2))\n self.wait(1)\n self.play(Write(sub2))\n self.wait(0.5)\n self.play(ReplacementTransform(val_42, val_100))\n self.wait(1)\n self.play(Write(sub3))\n self.wait(0.5)\n binary_text = Text('01100100', font_size=24, color=YELLOW)\n binary_label = Text(\"(8-bit two's complement)\", font_size=16, color=GRAY)\n bin_group = VGroup(binary_text, binary_label).arrange(DOWN, buff=0.1)\n bin_group.move_to(mem_box).shift(DOWN * 0.4)\n self.play(val_100.animate.shift(UP * 0.3).scale(0.8), FadeIn(bin_group, shift=UP * 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the concept of Simple Harmonic Motion (SHM), starting with the display of its differential equation, followed by an explanation and introduction of angular frequency, and then showing how the equation is rewritten using angular frequency? Additionally, can you demonstrate the general solution of the equation involving cosine function, explain the meaning of phase difference within the context, and finally clear the scene to focus on the final solution?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Differential Equation\n # ------------------------------------------------------------------\n diff_eq = MathTex(\n r\"\\frac{d^2x}{dt^2}\", r\"+\", r\"\\omega^2\", r\"x\", r\"=\", r\"0\",\n font_size=48\n )\n diff_eq.to_edge(UP)\n \n self.play(Write(diff_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Introduce Angular Frequency\n # ------------------------------------------------------------------\n omega_text = Tex(\n r\"Angular Frequency ($\\omega$): \\\\ Rate of change of the phase \\\\ of a sinusoidal waveform\",\n font_size=28,\n color=BLUE_B\n )\n omega_text.next_to(diff_eq, DOWN, buff=0.6)\n \n self.play(FadeIn(omega_text))\n self.play(Indicate(diff_eq[2], color=BLUE_B, scale_factor=1.2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Rewrite/Emphasize the Equation\n # ------------------------------------------------------------------\n # Visually emphasize the omega^2 term to bridge concept to formula\n box_omega = SurroundingRectangle(diff_eq[2], color=YELLOW, buff=0.1)\n self.play(Create(box_omega))\n self.wait(1)\n self.play(FadeOut(box_omega))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # Step 4: Present the General Solution\n # ------------------------------------------------------------------\n solution_eq = MathTex(\n r\"x(t)\", r\"=\", r\"A\", r\"\\cos(\", r\"\\omega\", r\"t\", r\"+\", r\"\\phi\", r\")\",\n font_size=48\n )\n solution_eq.next_to(omega_text, DOWN, buff=0.6)\n \n # Color code the variables for clarity\n solution_eq[0].set_color(YELLOW) # x(t)\n solution_eq[2].set_color(GREEN) # A\n solution_eq[4].set_color(BLUE_B) # omega\n solution_eq[7].set_color(RED) # phi\n \n self.play(Write(solution_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Explain Phase Difference\n # ------------------------------------------------------------------\n phase_text = Tex(\n r\"Phase Difference ($\\phi$): \\\\ Shifts the wave horizontally \\\\ along the time axis\",\n font_size=28,\n color=RED\n )\n phase_text.next_to(solution_eq, DOWN, buff=0.6)\n \n # Highlight phi in the solution equation\n self.play(FadeIn(phase_text))\n self.play(Indicate(solution_eq[7], color=RED, scale_factor=1.2))\n self.wait(1)\n\n # Visual demonstration of the horizontal shift using a graph\n axes = Axes(\n x_range=[0, 4 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=5,\n y_length=2.5\n ).scale(0.6).to_edge(RIGHT, buff=1).shift(DOWN * 0.5)\n \n graph_base = axes.plot(lambda x: np.cos(x), color=WHITE)\n graph_shifted = axes.plot(lambda x: np.cos(x + PI/4), color=RED)\n \n self.play(Create(axes), Create(graph_base), run_time=1.5)\n self.play(Transform(graph_base, graph_shifted), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Final Focus\n # ------------------------------------------------------------------\n # Clear the scene of all intermediate explanations and derivations\n items_to_remove = VGroup(\n diff_eq, omega_text, phase_text, axes, graph_base\n )\n \n # Fade out everything except the final solution equation\n self.play(\n FadeOut(items_to_remove),\n solution_eq.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Final pause on the clean result\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SimpleHarmonicMotion(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Differential Equation\n # ------------------------------------------------------------------\n diff_eq = MathText(\n r\"\\frac{d^2x}{dt^2}\", r\"+\", r\"\\omega^2\", r\"x\", r\"=\", r\"0\",\n font_size=48\n )\n diff_eq.to_edge(UP)\n \n self.play(Write(diff_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 2: Introduce Angular Frequency\n # ------------------------------------------------------------------\n omega_text = Tex(\n r\"Angular Frequency ($\\omega$): \\\\ Rate of change of the phase \\\\ of a sinusoidal waveform\",\n font_size=28,\n color=BLUE_B\n )\n omega_text.next_to(diff_eq, DOWN, buff=0.6)\n \n self.play(FadeIn(omega_text))\n self.play(Indicate(diff_eq[2], color=BLUE_B, scale_factor=1.2))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 3: Rewrite/Emphasize the Equation\n # ------------------------------------------------------------------\n # Visually emphasize the omega^2 term to bridge concept to formula\n box_omega = SurroundingRectangle(diff_eq[2], color=YELLOW, buff=0.1)\n self.play(Create(box_omega))\n self.wait(1)\n self.play(FadeOut(box_omega))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # Step 4: Present the General Solution\n # ------------------------------------------------------------------\n solution_eq = MathTex(\n r\"x(t)\", r\"=\", r\"A\", r\"\\cos(\", r\"\\omega\", r\"t\", r\"+\", r\"\\phi\", r\")\",\n font_size=48\n )\n solution_eq.next_to(omega_text, DOWN, buff=0.6)\n \n # Color code the variables for clarity\n solution_eq[0].set_color(YELLOW) # x(t)\n solution_eq[2].set_color(GREEN) # A\n solution_eq[4].set_color(BLUE_B) # omega\n solution_eq[7].set_color(RED) # phi\n \n self.play(Write(solution_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 5: Explain Phase Difference\n # ------------------------------------------------------------------\n phase_text = Tex(\n r\"Phase Difference ($\\phi$): \\\\ Shifts the wave horizontally \\\\ along the time axis\",\n font_size=28,\n color=RED\n )\n phase_text.next_to(solution_eq, DOWN, buff=0.6)\n \n # Highlight phi in the solution equation\n self.play(FadeIn(phase_text))\n self.play(Indicate(solution_eq[7], color=RED, scale_factor=1.2))\n self.wait(1)\n\n # Visual demonstration of the horizontal shift using a graph\n axes = Axes(\n x_range=[0, 4 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n x_length=5,\n y_length=2.5\n ).scale(0.6).to_edge(RIGHT, buff=1).shift(DOWN * 0.5)\n \n graph_base = axes.plot(lambda x: np.cos(x), color=WHITE)\n graph_shifted = axes.plot(lambda x: np.cos(x + PI/4), color=RED)\n \n self.play(Create(axes), Create(graph_base), run_time=1.5)\n self.play(Transform(graph_base, graph_shifted), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # Step 6: Final Focus\n # ------------------------------------------------------------------\n # Clear the scene of all intermediate explanations and derivations\n items_to_remove = VGroup(\n diff_eq, omega_text, phase_text, axes, graph_base\n )\n \n # Fade out everything except the final solution equation\n self.play(\n FadeOut(items_to_remove),\n solution_eq.animate.move_to(ORIGIN).scale(1.5)\n )\n \n # Final pause on the clean result\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 walks through the steps of calculating a basic definite integral of x^2 from 0 to 1, including writing out the problem, using the power rule for integration, evaluating the limits, and presenting the simplified final solution, all accompanied by relevant explanations and pauses between each step for clarity?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralWalkthrough(Scene):\n def construct(self):\n # --- Configuration and Colors ---\n TEXT_COLOR = WHITE\n HIGHLIGHT_COLOR = YELLOW\n RULE_COLOR = BLUE\n\n # --- Step 1: Display the Problem Statement ---\n title = Text(\"Calculating a Definite Integral\", font_size=36).to_edge(UP)\n problem = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\", font_size=72)\n problem.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Visually Demonstrate the Power Rule ---\n power_rule_text = Text(\"Using the Power Rule for Integration:\", font_size=30, color=RULE_COLOR)\n power_rule_text.next_to(problem, DOWN, buff=0.8)\n power_rule_formula = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=48, \n color=RULE_COLOR\n ).next_to(power_rule_text, DOWN, buff=0.3)\n\n self.play(Write(power_rule_text), Write(power_rule_formula))\n self.wait(3)\n\n # Apply the Power Rule to the specific problem\n application_label = Text(\"Apply the rule where n = 2:\", font_size=30).next_to(power_rule_formula, DOWN, buff=0.5)\n antiderivative_step = MathTex(\n r\"\\int_{0}^{1} x^2 \\, dx = \\left[ \\frac{x^{2+1}}{2+1} \\right]_0^1\", \n font_size=60\n ).move_to(problem)\n\n self.play(Write(application_label))\n self.play(ReplacementTransform(problem, antiderivative_step))\n self.wait(2)\n\n # Simplify the antiderivative expression\n simplified_antiderivative = MathTex(\n r\"\\left[ \\frac{x^3}{3} \\right]_0^1\", \n font_size=60\n ).move_to(antiderivative_step)\n\n self.play(ReplacementTransform(antiderivative_step, simplified_antiderivative))\n self.wait(2)\n\n # Clear the top section to make room for evaluation\n self.play(\n FadeOut(power_rule_text), \n FadeOut(power_rule_formula), \n FadeOut(application_label)\n )\n\n # --- Step 3: Substitution of the Limits ---\n eval_label = Text(\"Evaluate at the upper and lower limits:\", font_size=36, color=GREEN)\n eval_label.next_to(simplified_antiderivative, DOWN, buff=0.8)\n \n substitution_expr = MathTex(\n r\"= \\left( \\frac{1^3}{3} \\right) - \\left( \\frac{0^3}{3} \\right)\", \n font_size=60\n ).next_to(eval_label, DOWN, buff=0.5)\n\n self.play(Write(eval_label))\n self.play(Write(substitution_expr))\n self.wait(3)\n\n # --- Step 4: Step-by-step Arithmetic and Final Solution ---\n arithmetic_step = MathTex(\n r\"= \\frac{1}{3} - 0\", \n font_size=60\n ).next_to(substitution_expr, DOWN, buff=0.8)\n\n self.play(Write(arithmetic_step))\n self.wait(2)\n\n final_solution = MathTex(\n r\"= \\frac{1}{3}\", \n font_size=72, \n color=HIGHLIGHT_COLOR\n ).next_to(arithmetic_step, DOWN, buff=0.8)\n\n # Box the final answer\n final_box = SurroundingRectangle(final_solution, color=HIGHLIGHT_COLOR, buff=0.2)\n\n self.play(Write(final_solution))\n self.play(Create(final_box))\n self.wait(3)\n\n # Final Conclusion\n conclusion = Text(\"The area under x^2 from 0 to 1 is 1/3.\", font_size=36).to_edge(DOWN)\n self.play(Write(conclusion))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralWalkthrough(Scene):\n def construct(self):\n # --- Configuration and Colors ---\n TEXT_COLOR = WHITE\n HIGHLIGHT_COLOR = YELLOW\n RULE_COLOR = BLUE\n\n # --- Step 1: Display the Problem Statement ---\n title = Text(\"Calculating a Definite Integral\", font_size=36).to_edge(UP)\n problem = MathText(r\"\\int_{0}^{1} x^2 \\, dx\", font_size=72)\n problem.next_to(title, DOWN, buff=1)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(2)\n\n # --- Step 2: Visually Demonstrate the Power Rule ---\n power_rule_text = Text(\"Using the Power Rule for Integration:\", font_size=30, color=RULE_COLOR)\n power_rule_text.next_to(problem, DOWN, buff=0.8)\n power_rule_formula = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=48, \n color=RULE_COLOR\n ).next_to(power_rule_text, DOWN, buff=0.3)\n\n self.play(Write(power_rule_text), Write(power_rule_formula))\n self.wait(3)\n\n # Apply the Power Rule to the specific problem\n application_label = Text(\"Apply the rule where n = 2:\", font_size=30).next_to(power_rule_formula, DOWN, buff=0.5)\n antiderivative_step = MathTex(\n r\"\\int_{0}^{1} x^2 \\, dx = \\left[ \\frac{x^{2+1}}{2+1} \\right]_0^1\", \n font_size=60\n ).move_to(problem)\n\n self.play(Write(application_label))\n self.play(ReplacementTransform(problem, antiderivative_step))\n self.wait(2)\n\n # Simplify the antiderivative expression\n simplified_antiderivative = MathTex(\n r\"\\left[ \\frac{x^3}{3} \\right]_0^1\", \n font_size=60\n ).move_to(antiderivative_step)\n\n self.play(ReplacementTransform(antiderivative_step, simplified_antiderivative))\n self.wait(2)\n\n # Clear the top section to make room for evaluation\n self.play(\n FadeOut(power_rule_text), \n FadeOut(power_rule_formula), \n FadeOut(application_label)\n )\n\n # --- Step 3: Substitution of the Limits ---\n eval_label = Text(\"Evaluate at the upper and lower limits:\", font_size=36, color=GREEN)\n eval_label.next_to(simplified_antiderivative, DOWN, buff=0.8)\n \n substitution_expr = MathTex(\n r\"= \\left( \\frac{1^3}{3} \\right) - \\left( \\frac{0^3}{3} \\right)\", \n font_size=60\n ).next_to(eval_label, DOWN, buff=0.5)\n\n self.play(Write(eval_label))\n self.play(Write(substitution_expr))\n self.wait(3)\n\n # --- Step 4: Step-by-step Arithmetic and Final Solution ---\n arithmetic_step = MathTex(\n r\"= \\frac{1}{3} - 0\", \n font_size=60\n ).next_to(substitution_expr, DOWN, buff=0.8)\n\n self.play(Write(arithmetic_step))\n self.wait(2)\n\n final_solution = MathTex(\n r\"= \\frac{1}{3}\", \n font_size=72, \n color=HIGHLIGHT_COLOR\n ).next_to(arithmetic_step, DOWN, buff=0.8)\n\n # Box the final answer\n final_box = SurroundingRectangle(final_solution, color=HIGHLIGHT_COLOR, buff=0.2)\n\n self.play(Write(final_solution))\n self.play(Create(final_box))\n self.wait(3)\n\n # Final Conclusion\n conclusion = Text(\"The area under x^2 from 0 to 1 is 1/3.\", font_size=36).to_edge(DOWN)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the concept of the one-dimensional wave equation using math formulas. Start with the wave equation itself, then provide a brief explanation that this represents a one-dimensional wave equation. Next, show an important aspect of seeking solutions for this wave equation where the solutions take the form of two functions, one moving forward and one moving backward in time. Transition to the general form of the wave solution that combines these two functions. Lastly, mention that in the case of harmonic waves, these functions could be sine or cosine. Allow brief pauses between each step to let viewers digest the information, and clear the screen towards the end before presenting the final wave solution one more time for emphasis.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n \"\"\"\n Educational animation illustrating the one-dimensional wave equation,\n its d'Alembert solution, and the harmonic case.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduction - Display the one-dimensional wave equation\n # ------------------------------------------------------------------\n wave_equation = MathTex(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n \n self.play(Write(wave_equation))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # Step 2: Explanation - Text explanation of the formula\n # ------------------------------------------------------------------\n explanation_text = Text(\n \"This formula represents the one-dimensional wave equation.\",\n font_size=32,\n color=GREY_B\n )\n explanation_text.next_to(wave_equation, DOWN, buff=0.7)\n \n self.play(FadeIn(explanation_text, shift=UP))\n self.wait(2)\n self.play(FadeOut(explanation_text))\n\n # ------------------------------------------------------------------\n # Step 3: Solution Concept - Introduce forward and backward functions\n # ------------------------------------------------------------------\n self.play(wave_equation.animate.to_edge(UP))\n \n concept_text = Text(\n \"Solutions take the form of two traveling waves:\",\n font_size=32\n ).next_to(wave_equation, DOWN, buff=0.5)\n \n # f(x - ct) represents a wave moving to the right\n func_right = MathTex(\"f(x - ct)\", font_size=40, color=BLUE)\n label_right = Text(\"Right-moving\", font_size=24, color=BLUE)\n label_right.next_to(func_right, DOWN, buff=0.1)\n group_right = VGroup(func_right, label_right).shift(LEFT * 3 + DOWN * 1)\n \n # g(x + ct) represents a wave moving to the left\n func_left = MathTex(\"g(x + ct)\", font_size=40, color=YELLOW)\n label_left = Text(\"Left-moving\", font_size=24, color=YELLOW)\n label_left.next_to(func_left, DOWN, buff=0.1)\n group_left = VGroup(func_left, label_left).shift(RIGHT * 3 + DOWN * 1)\n \n self.play(Write(concept_text))\n self.play(FadeIn(group_right, shift=RIGHT), FadeIn(group_left, shift=LEFT))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: General Form - Combine into d'Alembert's solution\n # ------------------------------------------------------------------\n general_solution = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n font_size=48\n )\n general_solution.move_to(ORIGIN)\n \n # Clear previous components and transition smoothly\n clear_group = VGroup(wave_equation, concept_text, group_right, group_left)\n self.play(FadeOut(clear_group), Write(general_solution))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Harmonic Case - Mention sine/cosine representation\n # ------------------------------------------------------------------\n harmonic_text = Text(\n \"For harmonic waves, these functions can be sine or cosine:\",\n font_size=28,\n color=TEAL\n ).next_to(general_solution, UP, buff=0.7)\n \n harmonic_eq = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t)\",\n font_size=40,\n color=BLUE_B\n ).next_to(general_solution, DOWN, buff=0.7)\n \n self.play(Write(harmonic_text), Write(harmonic_eq))\n self.wait(2.5)\n\n # ------------------------------------------------------------------\n # Step 6: Emphasis Finale - Clear screen and show final solution\n # ------------------------------------------------------------------\n # Clear all objects from the scene\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n \n # Re-display the general solution prominently for emphasis\n final_solution = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n font_size=60\n )\n \n # Add a surrounding rectangle for visual emphasis\n box = SurroundingRectangle(final_solution, buff=0.5, color=BLUE)\n \n self.play(Write(final_solution), Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n \"\"\"\n Educational animation illustrating the one-dimensional wave equation,\n its d'Alembert solution, and the harmonic case.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduction - Display the one-dimensional wave equation\n # ------------------------------------------------------------------\n wave_equation = MathText(\n r\"\\frac{\\partial^2 u}{\\partial t^2}\", \"=\", \"c^2\", r\"\\frac{\\partial^2 u}{\\partial x^2}\",\n font_size=48\n )\n \n self.play(Write(wave_equation))\n self.wait(1.5)\n\n # ------------------------------------------------------------------\n # Step 2: Explanation - Text explanation of the formula\n # ------------------------------------------------------------------\n explanation_text = Text(\n \"This formula represents the one-dimensional wave equation.\",\n font_size=32,\n color=GREY_B\n )\n explanation_text.next_to(wave_equation, DOWN, buff=0.7)\n \n self.play(FadeIn(explanation_text, shift=UP))\n self.wait(2)\n self.play(FadeOut(explanation_text))\n\n # ------------------------------------------------------------------\n # Step 3: Solution Concept - Introduce forward and backward functions\n # ------------------------------------------------------------------\n self.play(wave_equation.animate.to_edge(UP))\n \n concept_text = Text(\n \"Solutions take the form of two traveling waves:\",\n font_size=32\n ).next_to(wave_equation, DOWN, buff=0.5)\n \n # f(x - ct) represents a wave moving to the right\n func_right = MathTex(\"f(x - ct)\", font_size=40, color=BLUE)\n label_right = Text(\"Right-moving\", font_size=24, color=BLUE)\n label_right.next_to(func_right, DOWN, buff=0.1)\n group_right = VGroup(func_right, label_right).shift(LEFT * 3 + DOWN * 1)\n \n # g(x + ct) represents a wave moving to the left\n func_left = MathTex(\"g(x + ct)\", font_size=40, color=YELLOW)\n label_left = Text(\"Left-moving\", font_size=24, color=YELLOW)\n label_left.next_to(func_left, DOWN, buff=0.1)\n group_left = VGroup(func_left, label_left).shift(RIGHT * 3 + DOWN * 1)\n \n self.play(Write(concept_text))\n self.play(FadeIn(group_right, shift=RIGHT), FadeIn(group_left, shift=LEFT))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 4: General Form - Combine into d'Alembert's solution\n # ------------------------------------------------------------------\n general_solution = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n font_size=48\n )\n general_solution.move_to(ORIGIN)\n \n # Clear previous components and transition smoothly\n clear_group = VGroup(wave_equation, concept_text, group_right, group_left)\n self.play(FadeOut(clear_group), Write(general_solution))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # Step 5: Harmonic Case - Mention sine/cosine representation\n # ------------------------------------------------------------------\n harmonic_text = Text(\n \"For harmonic waves, these functions can be sine or cosine:\",\n font_size=28,\n color=TEAL\n ).next_to(general_solution, UP, buff=0.7)\n \n harmonic_eq = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t)\",\n font_size=40,\n color=BLUE_B\n ).next_to(general_solution, DOWN, buff=0.7)\n \n self.play(Write(harmonic_text), Write(harmonic_eq))\n self.wait(2.5)\n\n # ------------------------------------------------------------------\n # Step 6: Emphasis Finale - Clear screen and show final solution\n # ------------------------------------------------------------------\n # Clear all objects from the scene\n self.play(FadeOut(*self.mobjects))\n self.wait(0.5)\n \n # Re-display the general solution prominently for emphasis\n final_solution = MathTex(\n r\"u(x, t)\", \"=\", \"f(x - ct)\", \"+\", \"g(x + ct)\",\n font_size=60\n )\n \n # Add a surrounding rectangle for visual emphasis\n box = SurroundingRectangle(final_solution, buff=0.5, color=BLUE)\n \n self.play(Write(final_solution), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starts with the text \"Let's learn about quadratic functions!\" then transitions to showing the general quadratic formula \"f(x) = ax^2 + bx + c\"? After that, could you replace it with a specific example of a quadratic function, say \"f(x) = 2x^2 - 3x + 1\", and graph this specific function? Lastly, can you highlight the vertex of the parabola and conclude with showing the formula to find the vertex of a quadratic function?", "chosen": "```python\nfrom manim import *\n\nclass QuadraticFunctionsSequence(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"Let's learn about quadratic functions!\", font_size=40)\n self.play(FadeIn(title), run_time=2)\n self.wait(1)\n self.play(FadeOut(title), run_time=1)\n\n # --- Step 2: General Formula ---\n # Color coding coefficients for pedagogical clarity\n general_formula = MathTex(\n \"f(x)\", \"=\", \"a\", \"x^2\", \"+\", \"b\", \"x\", \"+\", \"c\",\n font_size=48\n )\n # Assign colors to coefficients\n general_formula.set_color_by_tex(\"a\", GOLD)\n general_formula.set_color_by_tex(\"b\", BLUE)\n general_formula.set_color_by_tex(\"c\", RED)\n \n self.play(Write(general_formula), run_time=2)\n self.wait(1)\n\n # --- Step 3: Specific Example ---\n specific_formula = MathTex(\n \"f(x)\", \"=\", \"2\", \"x^2\", \"-\", \"3\", \"x\", \"+\", \"1\",\n font_size=48\n )\n specific_formula.set_color_by_tex(\"2\", GOLD)\n specific_formula.set_color_by_tex(\"3\", BLUE)\n specific_formula.set_color_by_tex(\"1\", RED)\n \n # Smooth transformation from general to specific\n self.play(TransformMatchingTex(general_formula, specific_formula), run_time=2)\n self.wait(1)\n\n # --- Step 4: Graphing ---\n # Move formula to top-left to make room for graph\n self.play(specific_formula.animate.to_corner(UL), run_time=1)\n\n axes = Axes(\n x_range=[-2, 3, 1],\n y_range=[-2, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"include_numbers\": True},\n y_axis_config={\"include_numbers\": True},\n )\n \n # Define the function f(x) = 2x^2 - 3x + 1\n quadratic_curve = axes.plot(lambda x: 2*x**2 - 3*x + 1, color=GREEN)\n \n self.play(Create(axes), run_time=1.5)\n self.play(Create(quadratic_curve), run_time=2)\n self.wait(1)\n\n # --- Step 5: Vertex Highlight ---\n # Calculate vertex coordinates analytically: x = -b/2a = 3/4 = 0.75\n # y = 2(0.75)^2 - 3(0.75) + 1 = -0.125\n vertex_x = 0.75\n vertex_y = -0.125\n vertex_point = axes.c2p(vertex_x, vertex_y)\n \n dot = Dot(point=vertex_point, color=RED, radius=0.1)\n vertex_label = MathTex(r\"\\left(\\frac{3}{4}, -\\frac{1}{8}\\right)\", font_size=30).next_to(dot, RIGHT)\n \n self.play(DrawBorderThenFill(dot), Write(vertex_label), run_time=2)\n self.play(FocusOn(dot), run_time=1) # Pulse/focus effect\n self.wait(1)\n\n # --- Step 6: Conclusion (Vertex Formula) ---\n # Fade out graph elements to direct focus to the formula\n self.play(\n FadeOut(axes), \n FadeOut(quadratic_curve), \n FadeOut(dot), \n FadeOut(vertex_label),\n specific_formula.animate.to_edge(UP).scale(0.7),\n run_time=1.5\n )\n\n vertex_formula = MathTex(r\"x = -\\frac{b}{2a}\", font_size=60)\n vertex_formula.set_color_by_tex(\"b\", BLUE)\n vertex_formula.set_color_by_tex(\"a\", GOLD)\n \n self.play(Write(vertex_formula), run_time=2)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass QuadraticFunctionsSequence(Scene):\n def construct(self):\n # --- Step 1: Introduction ---\n title = Text(\"Let's learn about quadratic functions!\", font_size=40)\n self.play(FadeIn(title), run_time=2)\n self.wait(1)\n self.play(FadeOut(title), run_time=1)\n\n # --- Step 2: General Formula ---\n # Color coding coefficients for pedagogical clarity\n general_formula = MathTex(\n \"f(x)\", \"=\", \"a\", \"x^2\", \"+\", \"b\", \"x\", \"+\", \"c\",\n font_size=48\n )\n # Assign colors to coefficients\n general_formula.set_color_by_tex(\"a\", GOLD)\n general_formula.set_color_by_tex(\"b\", BLUE)\n general_formula.set_color_by_tex(\"c\", RED)\n \n self.play(Write(general_formula), run_time=2)\n self.wait(1)\n\n # --- Step 3: Specific Example ---\n specific_formula = MathTex(\n \"f(x)\", \"=\", \"2\", \"x^2\", \"-\", \"3\", \"x\", \"+\", \"1\",\n font_size=48\n )\n specific_formula.set_color_by_tex(\"2\", GOLD)\n specific_formula.set_color_by_tex(\"3\", BLUE)\n specific_formula.set_color_by_tex(\"1\", RED)\n \n # Smooth transformation from general to specific\n self.play(TransformMatchingTex(general_formula, specific_formula), run_time=2)\n self.wait(1)\n\n # --- Step 4: Graphing ---\n # Move formula to top-left to make room for graph\n self.play(specific_formula.animate.to_corner(UL), run_time=1)\n\n axes = Axes(label_font_size=24, \n x_range=[-2, 3, 1],\n y_range=[-2, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"include_numbers\": True},\n y_axis_config={\"include_numbers\": True},\n )\n \n # Define the function f(x) = 2x^2 - 3x + 1\n quadratic_curve = axes.plot(lambda x: 2*x**2 - 3*x + 1, color=GREEN)\n \n self.play(Create(axes), run_time=1.5)\n self.play(Create(quadratic_curve), run_time=2)\n self.wait(1)\n\n # --- Step 5: Vertex Highlight ---\n # Calculate vertex coordinates analytically: x = -b/2a = 3/4 = 0.75\n # y = 2(0.75)^2 - 3(0.75) + 1 = -0.125\n vertex_x = 0.75\n vertex_y = -0.125\n vertex_point = axes.c2p(vertex_x, vertex_y)\n \n dot = Dot(point=vertex_point, color=RED, radius=0.1)\n vertex_label = MathTex(r\"\\left(\\frac{3}{4}, -\\frac{1}{8}\\right)\", font_size=30).next_to(dot, RIGHT)\n \n self.play(DrawBorderThenFill(dot), Write(vertex_label), run_time=2)\n self.play(FocusOn(dot), run_time=1) # Pulse/focus effect\n self.wait(1)\n\n # --- Step 6: Conclusion (Vertex Formula) ---\n # Fade out graph elements to direct focus to the formula\n self.play(\n FadeOut(axes), \n FadeOut(quadratic_curve), \n FadeOut(dot), \n FadeOut(vertex_label),\n specific_formula.animate.to_edge(UP).scale(0.7),\n run_time=1.5\n )\n\n vertex_formula = MathTex(r\"x = -\\frac{b}{2a}\", font_size=60)\n vertex_formula.set_color_by_tex(\"b\", BLUE)\n vertex_formula.set_color_by_tex(\"a\", GOLD)\n \n self.play(Write(vertex_formula), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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#### Contrapositive\n\nThe contrapositive is not only an equivalence but is also frequently used in inference rules: $P \\rightarrow Q \\Leftrightarrow \\neg Q \\rightarrow \\neg P$.\nIn proofs, if directly proving $P \\rightarrow Q$ is difficult, one often turns to proving its contrapositive instead.\n\n\nThe context of this section (from highest to current level):\n# Discrete Mathematics: Propositional Logic, Logical Equivalence, and Consequence Relation\n## Consequence Relation\n### Basic Inference Rules\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass Contrapositive(Scene):\n\n def construct(self):\n title = Text('Contrapositive', 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_stmt = MathTex('P \\\\rightarrow Q', font_size=60)\n equiv_arrow = MathTex('\\\\Leftrightarrow', font_size=60)\n contra_stmt = MathTex('\\\\neg Q \\\\rightarrow \\\\neg P', font_size=60)\n eq_group = VGroup(orig_stmt, equiv_arrow, contra_stmt).arrange(RIGHT, buff=1)\n eq_group.shift(UP * 0.5)\n box_orig = SurroundingRectangle(orig_stmt, color=BLUE, buff=0.2)\n box_contra = SurroundingRectangle(contra_stmt, color=GREEN, buff=0.2)\n label_orig = Text('Original Statement', font_size=28, color=BLUE)\n label_orig.next_to(box_orig, UP, buff=0.3)\n label_contra = Text('Contrapositive', font_size=28, color=GREEN)\n label_contra.next_to(box_contra, UP, buff=0.3)\n text_diff = Text('When direct proof is difficult...', font_size=32)\n text_diff.next_to(eq_group, DOWN, buff=1.5)\n text_sol = Text('...prove its contrapositive instead!', font_size=32, color=YELLOW)\n text_sol.next_to(text_diff, DOWN, buff=0.4)\n self.play(Write(orig_stmt))\n self.play(Create(box_orig), Write(label_orig), run_time=1)\n self.play(Write(equiv_arrow))\n self.play(Write(contra_stmt))\n self.play(Create(box_contra), Write(label_contra), run_time=1)\n self.wait(0.5)\n self.play(Write(text_diff))\n self.play(Write(text_sol))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass Contrapositive(Scene):\n\n def construct(self):\n title = Text('Contrapositive', 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_stmt = MathTex('P \\\\rightarrow Q', font_size=60)\n equiv_arrow = MathTex('\\\\Leftrightarrow', font_size=60)\n contra_stmt = MathTex('\\\\neg Q \\\\rightarrow \\\\neg P', font_size=60)\n eq_group = VGroup(orig_stmt, equiv_arrow, contra_stmt).arrange(RIGHT, buff=1)\n eq_group.shift(UP * 0.5)\n box_orig = SurroundingRectangle(orig_stmt, color=BBLUE, buff=0.2)\n box_contra = SurroundingRectangle(contra_stmt, color=GREEN, buff=0.2)\n label_orig = Text('Original Statement', font_size=28, color=BLUE)\n label_orig.next_to(box_orig, UP, buff=0.3)\n label_contra = Text('Contrapositive', font_size=28, color=GREEN)\n label_contra.next_to(box_contra, UP, buff=0.3)\n text_diff = Text('When direct proof is difficult...', font_size=32)\n text_diff.next_to(eq_group, DOWN, buff=1.5)\n text_sol = Text('...prove its contrapositive instead!', font_size=32, color=YELLOW)\n text_sol.next_to(text_diff, DOWN, buff=0.4)\n self.play(Write(orig_stmt))\n self.play(Create(box_orig), Write(label_orig), run_time=1)\n self.play(Write(equiv_arrow))\n self.play(Write(contra_stmt))\n self.play(Create(box_contra), Write(label_contra), run_time=1)\n self.wait(0.5)\n self.play(Write(text_diff))\n self.play(Write(text_sol))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 ManimCE that explains how to integrate the sine function? Start by showing the integral of sin(x) with respect to x, then give a textual explanation that it's the integral of the sine function, followed by the mathematical rule showing the integral of sin(x) equals negative cosine of x plus the integration constant C. Next, substitute the integral of sin(x) with the solution including the integration constant. After that, remind viewers not to forget the integration constant by updating the text explanation. Finally, clear the screen and present the final solution neatly.", "chosen": "```python\nfrom manim import *\n\nclass SineIntegration(Scene):\n def construct(self):\n # Step 1: Display Formula\n # Show the integral of sin(x) with respect to x\n integral_expr = MathTex(r\"\\int \\sin(x) \\, dx\")\n integral_expr.scale(1.5)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 2: Textual Explanation\n # Provide text stating this is the integral of the sine function\n explanation = Text(\"This is the integral of the sine function.\", font_size=32)\n explanation.next_to(integral_expr, DOWN, buff=1)\n self.play(Write(explanation))\n self.wait(2)\n\n # Step 3: Mathematical Rule\n # Display the rule: the integral of sin(x) equals negative cosine of x plus C\n rule = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\")\n rule.scale(1.2)\n rule.shift(DOWN * 2)\n \n self.play(\n integral_expr.animate.shift(UP * 1),\n explanation.animate.shift(UP * 1),\n Write(rule)\n )\n self.wait(2)\n\n # Step 4: Substitution\n # Update the display to substitute the integral of sin(x) with the solution\n solution_expr = MathTex(r\"-\\cos(x) + C\")\n solution_expr.scale(1.5)\n solution_expr.move_to(integral_expr.get_center())\n solution_expr.set_color_by_tex(\"C\", YELLOW)\n \n self.play(\n FadeOut(rule),\n ReplacementTransform(integral_expr, solution_expr)\n )\n self.wait(1)\n\n # Step 5: Reminder\n # Update the text explanation to remind viewers not to forget the integration constant\n reminder = Text(\"Don't forget the integration constant, C!\", font_size=32, color=YELLOW)\n reminder.move_to(explanation.get_center())\n \n self.play(ReplacementTransform(explanation, reminder))\n self.wait(3)\n\n # Step 6: Final Presentation\n # Clear the screen and present the final solution neatly\n self.play(FadeOut(solution_expr), FadeOut(reminder))\n \n final_solution = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\")\n final_solution.scale(1.8)\n final_solution.set_color_by_tex(\"C\", YELLOW)\n \n # Adding a frame around the final answer for educational clarity\n box = SurroundingRectangle(final_solution, color=BLUE, buff=0.3)\n \n self.play(Write(final_solution), Create(box))\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 SineIntegration\n```", "rejected": "```python\nfrom manim import *\n\nclass SineIntegration(Scene):\n def construct(self):\n # Step 1: Display Formula\n # Show the integral of sin(x) with respect to x\n integral_expr = MathText(r\"\\int \\sin(x) \\, dx\")\n integral_expr.scale(1.5)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 2: Textual Explanation\n # Provide text stating this is the integral of the sine function\n explanation = Text(\"This is the integral of the sine function.\", font_size=32)\n explanation.next_to(integral_expr, DOWN, buff=1)\n self.play(Write(explanation))\n self.wait(2)\n\n # Step 3: Mathematical Rule\n # Display the rule: the integral of sin(x) equals negative cosine of x plus C\n rule = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\")\n rule.scale(1.2)\n rule.shift(DOWN * 2)\n \n self.play(\n integral_expr.animate.shift(UP * 1),\n explanation.animate.shift(UP * 1),\n Write(rule)\n )\n self.wait(2)\n\n # Step 4: Substitution\n # Update the display to substitute the integral of sin(x) with the solution\n solution_expr = MathTex(r\"-\\cos(x) + C\")\n solution_expr.scale(1.5)\n solution_expr.move_to(integral_expr.get_center())\n solution_expr.set_color_by_tex(\"C\", YELLOW)\n \n self.play(\n FadeOut(rule),\n ReplacementTransform(integral_expr, solution_expr)\n )\n self.wait(1)\n\n # Step 5: Reminder\n # Update the text explanation to remind viewers not to forget the integration constant\n reminder = Text(\"Don't forget the integration constant, C!\", font_size=32, color=YELLOW)\n reminder.move_to(explanation.get_center())\n \n self.play(ReplacementTransform(explanation, reminder))\n self.wait(3)\n\n # Step 6: Final Presentation\n # Clear the screen and present the final solution neatly\n self.play(FadeOut(solution_expr), FadeOut(reminder))\n \n final_solution = MathTex(r\"\\int \\sin(x) \\, dx = -\\cos(x) + C\")\n final_solution.scale(1.8)\n final_solution.set_color_by_tex(\"C\", YELLOW)\n \n # Adding a frame around the final answer for educational clarity\n box = SurroundingRectangle(final_solution, color=BLUE, buff=0.3)\n \n self.play(Write(final_solution), Create(box))\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 SineIntegration\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Manim scene explaining net diffusion across a permeable membrane. Begin with many particles on the left and fewer on the right, animate particles moving in both directions, and show that the net flow is from high to low concentration without implying that individual particles stop moving.", "chosen": "```python\nfrom manim import *\n\nclass MembraneNetDiffusion(Scene):\n def construct(self):\n title = Text(\"Diffusion is random motion with a net direction\", font_size=36).to_edge(UP)\n chamber = Rectangle(width=9, height=4.2, color=GRAY_B).shift(DOWN * 0.2)\n membrane = DashedLine(chamber.get_top(), chamber.get_bottom(), color=WHITE)\n high = Text(\"higher concentration\", font_size=23, color=BLUE_B).next_to(chamber, UP).shift(LEFT * 2.3)\n low = Text(\"lower concentration\", font_size=23, color=TEAL_B).next_to(chamber, UP).shift(RIGHT * 2.3)\n left_positions = [\n (-3.7, 1.0), (-3.0, 1.2), (-2.2, 0.9), (-3.5, 0.2),\n (-2.7, 0.3), (-1.8, 0.1), (-3.8, -0.7), (-3.0, -0.8),\n (-2.1, -0.6), (-3.4, -1.4), (-2.6, -1.5), (-1.7, -1.2),\n ]\n right_positions = [(1.8, 0.8), (3.0, 0.4), (2.2, -0.8), (3.5, -1.2)]\n left_dots = VGroup(*[Dot([x, y - 0.2, 0], color=BLUE_B, radius=0.09) for x, y in left_positions])\n right_dots = VGroup(*[Dot([x, y - 0.2, 0], color=TEAL_B, radius=0.09) for x, y in right_positions])\n both_directions = VGroup(\n Arrow(LEFT * 1.2 + UP * 1.45, RIGHT * 1.2 + UP * 1.45, color=BLUE_B, buff=0),\n Arrow(RIGHT * 1.2 + UP * 1.05, LEFT * 1.2 + UP * 1.05, color=TEAL_B, buff=0),\n )\n both_label = Text(\"individual particles cross both ways\", font_size=23).to_edge(DOWN)\n net_arrow = Arrow(LEFT * 2, RIGHT * 2, color=YELLOW, stroke_width=8).to_edge(DOWN)\n net_label = Text(\"net flow: high to low\", font_size=25, color=YELLOW).next_to(net_arrow, DOWN, buff=0.1)\n\n self.play(Write(title), Create(chamber), Create(membrane), FadeIn(high, low))\n self.play(LaggedStart(FadeIn(left_dots), FadeIn(right_dots), lag_ratio=0.3))\n self.play(GrowArrow(both_directions[0]), GrowArrow(both_directions[1]), FadeIn(both_label))\n crossings = [\n left_dots[2].animate.move_to([1.4, 0.75, 0]),\n left_dots[5].animate.move_to([2.5, 0.0, 0]),\n left_dots[8].animate.move_to([3.4, -0.55, 0]),\n left_dots[11].animate.move_to([1.8, -1.35, 0]),\n right_dots[0].animate.move_to([-1.6, 0.9, 0]),\n ]\n self.play(AnimationGroup(*crossings, lag_ratio=0.15), run_time=3)\n self.play(FadeOut(both_label), GrowArrow(net_arrow), FadeIn(net_label))\n takeaway = Text(\"Random motion continues even when concentrations become equal.\", font_size=23).to_edge(DOWN)\n self.play(ReplacementTransform(VGroup(net_arrow, net_label), takeaway))\n self.play(Indicate(both_directions))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass MembraneNetDiffusion(Scene):\n def construct(self):\n title = Text(\"Diffusion is random motion with a net direction\", font_size=36).to_edge(UP)\n chamber = Rectangle(width=9, height=4.2, color=GRAY_B).shift(DOWN * 0.2)\n membrane = DashedLine(chamber.get_top(), chamber.get_bottom(), color=WHITE)\n high = Text(\"higher concentration\", font_size=23, color=BBLUE_B).next_to(chamber, UP).shift(LEFT * 2.3)\n low = Text(\"lower concentration\", font_size=23, color=TEAL_B).next_to(chamber, UP).shift(RIGHT * 2.3)\n left_positions = [\n (-3.7, 1.0), (-3.0, 1.2), (-2.2, 0.9), (-3.5, 0.2),\n (-2.7, 0.3), (-1.8, 0.1), (-3.8, -0.7), (-3.0, -0.8),\n (-2.1, -0.6), (-3.4, -1.4), (-2.6, -1.5), (-1.7, -1.2),\n ]\n right_positions = [(1.8, 0.8), (3.0, 0.4), (2.2, -0.8), (3.5, -1.2)]\n left_dots = VGroup(*[Dot([x, y - 0.2, 0], color=BLUE_B, radius=0.09) for x, y in left_positions])\n right_dots = VGroup(*[Dot([x, y - 0.2, 0], color=TEAL_B, radius=0.09) for x, y in right_positions])\n both_directions = VGroup(\n Arrow(LEFT * 1.2 + UP * 1.45, RIGHT * 1.2 + UP * 1.45, color=BLUE_B, buff=0),\n Arrow(RIGHT * 1.2 + UP * 1.05, LEFT * 1.2 + UP * 1.05, color=TEAL_B, buff=0),\n )\n both_label = Text(\"individual particles cross both ways\", font_size=23).to_edge(DOWN)\n net_arrow = Arrow(LEFT * 2, RIGHT * 2, color=YELLOW, stroke_width=8).to_edge(DOWN)\n net_label = Text(\"net flow: high to low\", font_size=25, color=YELLOW).next_to(net_arrow, DOWN, buff=0.1)\n\n self.play(Write(title), Create(chamber), Create(membrane), FadeIn(high, low))\n self.play(LaggedStart(FadeIn(left_dots), FadeIn(right_dots), lag_ratio=0.3))\n self.play(GrowArrow(both_directions[0]), GrowArrow(both_directions[1]), FadeIn(both_label))\n crossings = [\n left_dots[2].animate.move_to([1.4, 0.75, 0]),\n left_dots[5].animate.move_to([2.5, 0.0, 0]),\n left_dots[8].animate.move_to([3.4, -0.55, 0]),\n left_dots[11].animate.move_to([1.8, -1.35, 0]),\n right_dots[0].animate.move_to([-1.6, 0.9, 0]),\n ]\n self.play(AnimationGroup(*crossings, lag_ratio=0.15), run_time=3)\n self.play(FadeOut(both_label), GrowArrow(net_arrow), FadeIn(net_label))\n takeaway = Text(\"Random motion continues even when concentrations become equal.\", font_size=23).to_edge(DOWN)\n self.play(ReplacementTransform(VGroup(net_arrow, net_label), takeaway))\n self.play(Indicate(both_directions))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 chemistry animation using ManimCE that shows the following sequence:\n1. Start by fading in individual particles: an electron, an oxygen atom, a metal atom, a positive ion, and a negative ion.\n2. After a brief pause, these particles should combine, or transform, into a grid pattern that represents a metal oxide on a 3x3 grid.\n3. Wait for a moment, then transform this metal oxide grid into a lithium grid structure made of a 2x2 grid pattern.\n4. Wait again, and then change this lithium grid to a carbon grid structure, which is made up of a single element in a 3x3 grid pattern.\n5. Finally, I want the initial electron to move along a complex path made of 9 points that form a loop with stops at the 3rd and 6th points in the pattern. The electron should complete this path loop within 2 seconds.\nThe animation should include waiting periods between each major step so the viewers can understand the changes happening on the screen. Can you help create this animation?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # --- Step 1: Fade In Individual Particles ---\n electron = Dot(radius=0.15, color=YELLOW)\n electron_label = MathTex(\"e^-\", font_size=24).next_to(electron, DOWN)\n electron_group = VGroup(electron, electron_label)\n\n oxygen = Dot(radius=0.25, color=RED)\n oxygen_label = MathTex(\"O\", font_size=24).next_to(oxygen, DOWN)\n oxygen_group = VGroup(oxygen, oxygen_label)\n\n metal = Dot(radius=0.25, color=GREY)\n metal_label = MathTex(\"M\", font_size=24).next_to(metal, DOWN)\n metal_group = VGroup(metal, metal_label)\n\n pos_ion = Dot(radius=0.25, color=BLUE)\n pos_ion_label = MathTex(\"M^+\", font_size=24).next_to(pos_ion, DOWN)\n pos_ion_group = VGroup(pos_ion, pos_ion_label)\n\n neg_ion = Dot(radius=0.25, color=ORANGE)\n neg_ion_label = MathTex(\"O^{2-}\", font_size=24).next_to(neg_ion, DOWN)\n neg_ion_group = VGroup(neg_ion, neg_ion_label)\n\n initial_particles = VGroup(\n electron_group, oxygen_group, metal_group, pos_ion_group, neg_ion_group\n ).arrange(RIGHT, buff=0.6)\n \n # Add slight vertical offsets for a scattered look\n oxygen_group.shift(UP * 0.3)\n pos_ion_group.shift(DOWN * 0.3)\n electron_group.shift(UP * 0.5)\n\n self.play(FadeIn(initial_particles))\n self.wait(1)\n\n # --- Step 2: Transform to 3x3 Metal Oxide Grid ---\n metal_oxide_dots = VGroup()\n for i in range(3):\n for j in range(3):\n # Alternating colors to represent metal and oxygen lattice\n color = RED if (i + j) % 2 == 0 else GREY\n dot = Dot(radius=0.2, color=color)\n metal_oxide_dots.add(dot)\n \n metal_oxide_grid = metal_oxide_dots.arrange_in_grid(rows=3, cols=3, buff=0.5)\n \n self.play(ReplacementTransform(initial_particles, metal_oxide_grid))\n self.wait(1)\n\n # --- Step 3: Transform to 2x2 Lithium Grid ---\n lithium_dots = VGroup()\n for _ in range(4):\n dot = Dot(radius=0.25, color=PURPLE)\n lithium_dots.add(dot)\n \n lithium_grid = lithium_dots.arrange_in_grid(rows=2, cols=2, buff=0.6)\n \n self.play(ReplacementTransform(metal_oxide_grid, lithium_grid))\n self.wait(1)\n\n # --- Step 4: Transform to 3x3 Carbon Grid ---\n carbon_dots = VGroup()\n for _ in range(9):\n dot = Dot(radius=0.2, color=DARK_GREY)\n carbon_dots.add(dot)\n \n carbon_grid = carbon_dots.arrange_in_grid(rows=3, cols=3, buff=0.5)\n \n self.play(ReplacementTransform(lithium_grid, carbon_grid))\n self.wait(1)\n\n # --- Step 5: Electron Path Animation ---\n # Define 9 points forming a complex loop\n path_points = []\n radius = 2.0\n for k in range(9):\n angle = k * (2 * PI / 9)\n # Add variation for a complex path\n r = radius + 0.4 * np.sin(3 * angle)\n x = r * np.cos(angle)\n y = r * np.sin(angle)\n path_points.append(np.array([x, y, 0]))\n \n # Draw the path visually\n full_path = VMobject()\n full_path.set_points_as_corners(path_points + [path_points[0]])\n full_path.set_color(WHITE).set_opacity(0.3)\n self.add(full_path)\n \n # Create a new electron for the path animation\n moving_electron = Dot(radius=0.15, color=YELLOW)\n moving_electron.move_to(path_points[0])\n self.add(moving_electron)\n \n # Define path segments to allow stops at 3rd (index 2) and 6th (index 5) points\n seg1 = VMobject().set_points_as_corners(path_points[0:3])\n seg2 = VMobject().set_points_as_corners(path_points[2:6])\n seg3 = VMobject().set_points_as_corners(path_points[5:9] + [path_points[0]])\n \n # Total duration within 2 seconds (including stops)\n self.play(MoveAlongPath(moving_electron, seg1), run_time=0.5, rate_func=linear)\n self.wait(0.2) # Stop at 3rd point\n self.play(MoveAlongPath(moving_electron, seg2), run_time=0.5, rate_func=linear)\n self.wait(0.2) # Stop at 6th point\n self.play(MoveAlongPath(moving_electron, seg3), run_time=0.6, rate_func=linear)\n \n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # --- Step 1: Fade In Individual Particles ---\n electron = Dot(radius=0.15, color=YELLOW)\n electron_label = MathTex(\"e^-\", font_size=24).next_to(electron, DOWN)\n electron_group = VGroup(electron, electron_label)\n\n oxygen = Dot(radius=0.25, color=RED)\n oxygen_label = MathTex(\"O\", font_size=24).next_to(oxygen, DOWN)\n oxygen_group = VGroup(oxygen, oxygen_label)\n\n metal = Dot(radius=0.25, color=GREY)\n metal_label = MathTex(\"M\", font_size=24).next_to(metal, DOWN)\n metal_group = VGroup(metal, metal_label)\n\n pos_ion = Dot(radius=0.25, color=BLUE)\n pos_ion_label = MathTex(\"M^+\", font_size=24).next_to(pos_ion, DOWN)\n pos_ion_group = VGroup(pos_ion, pos_ion_label)\n\n neg_ion = Dot(radius=0.25, color=ORANGE)\n neg_ion_label = MathTex(\"O^{2-}\", font_size=24).next_to(neg_ion, DOWN)\n neg_ion_group = VGroup(neg_ion, neg_ion_label)\n\n initial_particles = VGroup(\n electron_group, oxygen_group, metal_group, pos_ion_group, neg_ion_group\n ).arrange(RIGHT, buff=0.6)\n \n # Add slight vertical offsets for a scattered look\n oxygen_group.shift(UP * 0.3)\n pos_ion_group.shift(DOWN * 0.3)\n electron_group.shift(UP * 0.5)\n\n self.play(FadeIn(initial_particles))\n self.wait(1)\n\n # --- Step 2: Transform to 3x3 Metal Oxide Grid ---\n metal_oxide_dots = VGroup()\n for i in range(3):\n for j in range(3):\n # Alternating colors to represent metal and oxygen lattice\n color = RED if (i + j) % 2 == 0 else GREY\n dot = Dot(radius=0.2, color=color)\n metal_oxide_dots.add(dot)\n \n metal_oxide_grid = metal_oxide_dots.arrange_in_grid(rows=3, cols=3, buff=0.5)\n \n self.play(ReplacementTransform(initial_particles, metal_oxide_grid))\n self.wait(1)\n\n # --- Step 3: Transform to 2x2 Lithium Grid ---\n lithium_dots = VGroup()\n for _ in range(4):\n dot = Dot(radius=0.25, color=PURPLE)\n lithium_dots.add(dot)\n \n lithium_grid = lithium_dots.arrange_in_grid(rows=2, cols=2, buff=0.6)\n \n self.play(ReplacementTransform(metal_oxide_grid, lithium_grid))\n self.wait(1)\n\n # --- Step 4: Transform to 3x3 Carbon Grid ---\n carbon_dots = VGroup()\n for _ in range(9):\n dot = Dot(radius=0.2, color=DARK_GREY)\n carbon_dots.add(dot)\n \n carbon_grid = carbon_dots.arrange_in_grid(rows=3, cols=3, buff=0.5)\n \n self.play(ReplacementTransform(lithium_grid, carbon_grid))\n self.wait(1)\n\n # --- Step 5: Electron Path Animation ---\n # Define 9 points forming a complex loop\n path_points = []\n radius = 2.0\n for k in range(9):\n angle = k * (2 * PI / 9)\n # Add variation for a complex path\n r = radius + 0.4 * np.sin(3 * angle)\n x = r * np.cos(angle)\n y = r * np.sin(angle)\n path_points.append(np.array([x, y, 0]))\n \n # Draw the path visually\n full_path = VMob()\n full_path.set_points_as_corners(path_points + [path_points[0]])\n full_path.set_color(WHITE).set_opacity(0.3)\n self.add(full_path)\n \n # Create a new electron for the path animation\n moving_electron = Dot(radius=0.15, color=YELLOW)\n moving_electron.move_to(path_points[0])\n self.add(moving_electron)\n \n # Define path segments to allow stops at 3rd (index 2) and 6th (index 5) points\n seg1 = VMobject().set_points_as_corners(path_points[0:3])\n seg2 = VMobject().set_points_as_corners(path_points[2:6])\n seg3 = VMobject().set_points_as_corners(path_points[5:9] + [path_points[0]])\n \n # Total duration within 2 seconds (including stops)\n self.play(MoveAlongPath(moving_electron, seg1), run_time=0.5, rate_func=linear)\n self.wait(0.2) # Stop at 3rd point\n self.play(MoveAlongPath(moving_electron, seg2), run_time=0.5, rate_func=linear)\n self.wait(0.2) # Stop at 6th point\n self.play(MoveAlongPath(moving_electron, seg3), run_time=0.6, rate_func=linear)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 math video that explains the process of evaluating the definite integral of sine from 0 to pi. Start by displaying the integral problem, then show the steps to compute the integral with the antiderivative of sine, and evaluate it at the upper and lower bounds. Include on-screen text to guide me through the evaluation of the antiderivative at the bounds. Finally, display the simplified solution and present the final result separately before ending the video.", "chosen": "```python\nfrom manim import *\n\nclass EvaluateSineIntegral(Scene):\n def construct(self):\n # 1. Setup and Display Problem\n integral = MathTex(\n r\"\\int_{0}^{\\pi}\", r\"\\sin(x)\", r\"\\,dx\"\n ).scale(1.5)\n \n self.play(Write(integral))\n self.wait(1)\n self.play(integral.animate.to_edge(UP))\n\n # 2. Compute Antiderivative\n guide_text_1 = Text(\n \"Find the antiderivative of sin(x):\", \n font_size=24, \n color=BLUE\n ).next_to(integral, DOWN, buff=0.5)\n \n antiderivative = MathTex(\n r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\"\n ).scale(1.5).next_to(guide_text_1, DOWN, buff=0.3)\n \n self.play(Write(guide_text_1), Write(antiderivative))\n self.wait(2)\n self.play(FadeOut(guide_text_1))\n\n # 3. Evaluate Bounds with Guiding Text\n guide_text_2 = Text(\n \"Evaluate at upper bound minus lower bound:\", \n font_size=24, \n color=GREEN\n ).next_to(integral, DOWN, buff=0.5)\n \n evaluation = MathTex(\n r\"=\", r\"-\\cos(\\pi)\", r\"-\", r\"\\left(-\\cos(0)\\right)\"\n ).scale(1.5).next_to(guide_text_2, DOWN, buff=0.3)\n \n self.play(Write(guide_text_2), ReplacementTransform(antiderivative.copy(), evaluation))\n self.wait(2)\n self.play(FadeOut(guide_text_2))\n\n # 4. Simplify Values\n calc_text = Text(\n \"Since cos(\\pi ) = -1 and cos(0) = 1\", \n font_size=24, \n color=YELLOW\n ).next_to(integral, DOWN, buff=0.5)\n \n simplification = MathTex(\n r\"=\", r\"-(-1)\", r\"-\", r\"(-1)\"\n ).scale(1.5).next_to(calc_text, DOWN, buff=0.3)\n \n self.play(Write(calc_text), TransformMatchingTex(evaluation, simplification))\n self.wait(2)\n self.play(FadeOut(calc_text))\n\n # 5. Final Arithmetic and Result\n final_arithmetic = MathTex(\n r\"=\", r\"1\", r\"+\", r\"1\"\n ).scale(1.5).next_to(integral, DOWN, buff=0.5)\n \n final_result = MathTex(\n r\"=\", r\"2\"\n ).scale(2.0).set_color(YELLOW).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(simplification, final_arithmetic))\n self.wait(1)\n \n # Clear screen and present final result distinctly\n self.play(\n FadeOut(integral), \n FadeOut(final_arithmetic), \n ReplacementTransform(final_arithmetic.copy(), final_result)\n )\n \n result_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n conclusion = Text(\"The area under the curve is 2\", font_size=32).next_to(result_box, DOWN, buff=0.5)\n \n self.play(Create(result_box), Write(conclusion))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass EvaluateSineIntegral(Scene):\n def construct(self):\n # 1. Setup and Display Problem\n integral = MathTex(\n r\"\\int_{0}^{\\pi}\", r\"\\sin(x)\", r\"\\,dx\"\n ).scale(1.5)\n \n self.play(Write(integral))\n self.wait(1)\n self.play(integral.animate.to_edge(UP))\n\n # 2. Compute Antiderivative\n guide_text_1 = Text(\n \"Find the antiderivative of sin(x):\", \n font_size=24, \n color=BBLUE\n ).next_to(integral, DOWN, buff=0.5)\n \n antiderivative = MathTex(\n r\"=\", r\"\\left[ -\\cos(x) \\right]_{0}^{\\pi}\"\n ).scale(1.5).next_to(guide_text_1, DOWN, buff=0.3)\n \n self.play(Write(guide_text_1), Write(antiderivative))\n self.wait(2)\n self.play(FadeOut(guide_text_1))\n\n # 3. Evaluate Bounds with Guiding Text\n guide_text_2 = Text(\n \"Evaluate at upper bound minus lower bound:\", \n font_size=24, \n color=GREEN\n ).next_to(integral, DOWN, buff=0.5)\n \n evaluation = MathTex(\n r\"=\", r\"-\\cos(\\pi)\", r\"-\", r\"\\left(-\\cos(0)\\right)\"\n ).scale(1.5).next_to(guide_text_2, DOWN, buff=0.3)\n \n self.play(Write(guide_text_2), ReplacementTransform(antiderivative.copy(), evaluation))\n self.wait(2)\n self.play(FadeOut(guide_text_2))\n\n # 4. Simplify Values\n calc_text = Text(\n \"Since cos(\\pi ) = -1 and cos(0) = 1\", \n font_size=24, \n color=YELLOW\n ).next_to(integral, DOWN, buff=0.5)\n \n simplification = MathTex(\n r\"=\", r\"-(-1)\", r\"-\", r\"(-1)\"\n ).scale(1.5).next_to(calc_text, DOWN, buff=0.3)\n \n self.play(Write(calc_text), TransformMatchingTex(evaluation, simplification))\n self.wait(2)\n self.play(FadeOut(calc_text))\n\n # 5. Final Arithmetic and Result\n final_arithmetic = MathTex(\n r\"=\", r\"1\", r\"+\", r\"1\"\n ).scale(1.5).next_to(integral, DOWN, buff=0.5)\n \n final_result = MathTex(\n r\"=\", r\"2\"\n ).scale(2.0).set_color(YELLOW).move_to(ORIGIN)\n \n self.play(TransformMatchingTex(simplification, final_arithmetic))\n self.wait(1)\n \n # Clear screen and present final result distinctly\n self.play(\n FadeOut(integral), \n FadeOut(final_arithmetic), \n ReplacementTransform(final_arithmetic.copy(), final_result)\n )\n \n result_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n conclusion = Text(\"The area under the curve is 2\", font_size=32).next_to(result_box, DOWN, buff=0.5)\n \n self.play(Create(result_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 gated activations and want to visualize the gradient of a gate that combines Tanh and Sigmoid derivatives. Show the chain rule decomposition: tanh' times gate, sigmoid' times gate, and illustrate how the overall gradient evolves across time steps, with color coding for each component.", "chosen": "```python\nfrom manim import *\n\nclass GatedActivationsGradientScene(Scene):\n\n def construct(self):\n title = Text('Gated Activations: Gradient Flow', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0)\n intro = Text('Gated activations serve as guiding compasses', font_size=24)\n intro.next_to(title, DOWN, buff=0.4)\n self.play(Write(intro), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(intro), run_time=2.0 * 0.5)\n self.visualize_gated_unit()\n\n def visualize_gated_unit(self):\n gate_box = Rectangle(width=3, height=2, color=BLUE, stroke_width=3)\n gate_box.shift(UP * 0.5)\n gate_label = Text('GATE', font_size=20, color=BLUE)\n gate_label.move_to(gate_box.get_center())\n self.play(Create(gate_box), Write(gate_label), run_time=2.0)\n input_x = MathTex('x', font_size=32, color=WHITE)\n input_x.move_to(gate_box.get_left() + LEFT * 1.5)\n input_gate = MathTex('g(x)', font_size=28, color=YELLOW)\n input_gate.move_to(gate_box.get_left() + LEFT * 1.5 + DOWN * 0.8)\n self.play(Write(input_x), Write(input_gate), run_time=2.0)\n arrow_x = Arrow(input_x.get_right(), gate_box.get_left() + UP * 0.3, buff=0.1, color=WHITE)\n arrow_gate = Arrow(input_gate.get_right(), gate_box.get_left() + DOWN * 0.3, buff=0.1, color=YELLOW)\n self.play(Create(arrow_x), Create(arrow_gate), run_time=2.0)\n output = MathTex('y = x \\\\cdot \\\\sigma(g)', font_size=28, color=GREEN)\n output.move_to(gate_box.get_right() + RIGHT * 2)\n arrow_out = Arrow(gate_box.get_right(), output.get_left(), buff=0.1, color=GREEN)\n self.play(Create(arrow_out), Write(output), run_time=2.0)\n self.wait(0.5)\n self.play(arrow_x.animate.set_color(RED), arrow_gate.animate.set_color(RED), arrow_out.animate.set_color(RED), run_time=2.0)\n grad_formula = MathTex('\\\\frac{\\\\partial L}{\\\\partial x} = \\\\frac{\\\\partial L}{\\\\partial y} \\\\cdot \\\\sigma(g)', font_size=26, color=RED)\n grad_formula.to_edge(DOWN, buff=0.8)\n self.play(Write(grad_formula), run_time=2.0)\n self.wait(0.5)\n self.show_gate_effects()\n\n def show_gate_effects(self):\n scenarios = VGroup()\n box1 = Rectangle(width=2, height=1.2, color=GRAY)\n label1 = Text('Gate = 0', font_size=18, color=GRAY)\n desc1 = Text('Blocks gradient', font_size=14, color=GRAY)\n box1.add(label1.move_to(box1.get_center()))\n desc1.next_to(box1, DOWN, buff=0.1)\n box2 = Rectangle(width=2, height=1.2, color=YELLOW)\n label2 = Text('Gate = 0.5', font_size=18, color=YELLOW)\n desc2 = Text('Attenuates gradient', font_size=14, color=YELLOW)\n box2.add(label2.move_to(box2.get_center()))\n desc2.next_to(box2, DOWN, buff=0.1)\n box3 = Rectangle(width=2, height=1.2, color=GREEN)\n label3 = Text('Gate = 1', font_size=18, color=GREEN)\n desc3 = Text('Passes full gradient', font_size=14, color=GREEN)\n box3.add(label3.move_to(box3.get_center()))\n desc3.next_to(box3, DOWN, buff=0.1)\n scenarios = VGroup(VGroup(box1, desc1), VGroup(box2, desc2), VGroup(box3, desc3))\n scenarios.arrange(RIGHT, buff=0.5)\n scenarios.move_to(DOWN * 1.5)\n old_elements = [m for m in self.mobjects if m != self.mobjects[0]]\n self.play(FadeOut(*old_elements), run_time=2.0 * 0.5)\n self.play(FadeIn(scenarios[0]), run_time=2.0 * 0.5)\n self.play(FadeIn(scenarios[1]), run_time=2.0)\n self.play(FadeIn(scenarios[2]), run_time=2.0)\n self.wait(0.5)\n insight = Text('Gates enable selective gradient flow during training', font_size=22, color=BLUE)\n insight.to_edge(DOWN, buff=0.5)\n self.play(Write(insight), run_time=2.0)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass GatedActivationsGradientScene(Scene):\n\n def construct(self):\n title = Text('Gated Activations: Gradient Flow', font_size=36)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title), run_time=2.0)\n intro = Text('Gated activations serve as guiding compasses', font_size=24)\n intro.next_to(title, DOWN, buff=0.4)\n self.play(Write(intro), run_time=2.0)\n self.wait(0.5)\n self.play(FadeOut(intro), run_time=2.0 * 0.5)\n self.visualize_gated_unit()\n\n def visualize_gated_unit(self):\n gate_box = Rectangle(width=3, height=2, color=BLUE, stroke_width=3)\n gate_box.shift(UP * 0.5)\n gate_label = Text('GATE', font_size=20, color=BLUE)\n gate_label.move_to(gate_box.get_center())\n self.play(Create(gate_box), Write(gate_label), run_time=2.0)\n input_x = MathText('x', font_size=32, color=WHITE)\n input_x.move_to(gate_box.get_left() + LEFT * 1.5)\n input_gate = MathTex('g(x)', font_size=28, color=YELLOW)\n input_gate.move_to(gate_box.get_left() + LEFT * 1.5 + DOWN * 0.8)\n self.play(Write(input_x), Write(input_gate), run_time=2.0)\n arrow_x = Arrow(input_x.get_right(), gate_box.get_left() + UP * 0.3, buff=0.1, color=WHITE)\n arrow_gate = Arrow(input_gate.get_right(), gate_box.get_left() + DOWN * 0.3, buff=0.1, color=YELLOW)\n self.play(Create(arrow_x), Create(arrow_gate), run_time=2.0)\n output = MathTex('y = x \\\\cdot \\\\sigma(g)', font_size=28, color=GREEN)\n output.move_to(gate_box.get_right() + RIGHT * 2)\n arrow_out = Arrow(gate_box.get_right(), output.get_left(), buff=0.1, color=GREEN)\n self.play(Create(arrow_out), Write(output), run_time=2.0)\n self.wait(0.5)\n self.play(arrow_x.animate.set_color(RED), arrow_gate.animate.set_color(RED), arrow_out.animate.set_color(RED), run_time=2.0)\n grad_formula = MathTex('\\\\frac{\\\\partial L}{\\\\partial x} = \\\\frac{\\\\partial L}{\\\\partial y} \\\\cdot \\\\sigma(g)', font_size=26, color=RED)\n grad_formula.to_edge(DOWN, buff=0.8)\n self.play(Write(grad_formula), run_time=2.0)\n self.wait(0.5)\n self.show_gate_effects()\n\n def show_gate_effects(self):\n scenarios = VGroup()\n box1 = Rectangle(width=2, height=1.2, color=GRAY)\n label1 = Text('Gate = 0', font_size=18, color=GRAY)\n desc1 = Text('Blocks gradient', font_size=14, color=GRAY)\n box1.add(label1.move_to(box1.get_center()))\n desc1.next_to(box1, DOWN, buff=0.1)\n box2 = Rectangle(width=2, height=1.2, color=YELLOW)\n label2 = Text('Gate = 0.5', font_size=18, color=YELLOW)\n desc2 = Text('Attenuates gradient', font_size=14, color=YELLOW)\n box2.add(label2.move_to(box2.get_center()))\n desc2.next_to(box2, DOWN, buff=0.1)\n box3 = Rectangle(width=2, height=1.2, color=GREEN)\n label3 = Text('Gate = 1', font_size=18, color=GREEN)\n desc3 = Text('Passes full gradient', font_size=14, color=GREEN)\n box3.add(label3.move_to(box3.get_center()))\n desc3.next_to(box3, DOWN, buff=0.1)\n scenarios = VGroup(VGroup(box1, desc1), VGroup(box2, desc2), VGroup(box3, desc3))\n scenarios.arrange(RIGHT, buff=0.5)\n scenarios.move_to(DOWN * 1.5)\n old_elements = [m for m in self.mobjects if m != self.mobjects[0]]\n self.play(FadeOut(*old_elements), run_time=2.0 * 0.5)\n self.play(FadeIn(scenarios[0]), run_time=2.0 * 0.5)\n self.play(FadeIn(scenarios[1]), run_time=2.0)\n self.play(FadeIn(scenarios[2]), run_time=2.0)\n self.wait(0.5)\n insight = Text('Gates enable selective gradient flow during training', font_size=22, color=BLUE)\n insight.to_edge(DOWN, buff=0.5)\n self.play(Write(insight), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = BBLUE\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 process of integrating the trigonometric function sin(x)cos(x) by using a trigonometric identity to simplify the integral and then solve it step-by-step?", "chosen": "```python\nfrom manim import *\n\nclass IntegrateSinCosX(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title and Original Integral\n # ------------------------------------------------------------------\n title = Text(\"Integrating sin(x)cos(x)\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Display the original integral\n original_integral = MathTex(r\"\\int \\sin(x) \\cos(x) \\, dx\")\n original_integral.next_to(title, DOWN, buff=1)\n self.play(Write(original_integral))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Trigonometric Identity\n # ------------------------------------------------------------------\n # Show the standard double angle identity\n identity = MathTex(r\"\\sin(2x) = 2 \\sin(x) \\cos(x)\")\n identity.next_to(original_integral, DOWN, buff=1)\n \n # Use a box to emphasize the identity being applied\n identity_box = SurroundingRectangle(identity, color=YELLOW, buff=0.2)\n self.play(Write(identity), Create(identity_box))\n self.wait(1)\n\n # Rearrange the identity to isolate sin(x)cos(x)\n identity_rearranged = MathTex(r\"\\sin(x) \\cos(x) = \\frac{1}{2} \\sin(2x)\")\n identity_rearranged.move_to(identity)\n identity_rearranged_box = SurroundingRectangle(identity_rearranged, color=YELLOW, buff=0.2)\n \n # Transform the identity equation visually\n self.play(\n ReplacementTransform(identity, identity_rearranged),\n ReplacementTransform(identity_box, identity_rearranged_box)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Substitution\n # ------------------------------------------------------------------\n # Create the substituted integral\n substituted_integral = MathTex(r\"\\int \\frac{1}{2} \\sin(2x) \\, dx\")\n substituted_integral.move_to(original_integral)\n\n # Animate the substitution process\n self.play(\n ReplacementTransform(original_integral, substituted_integral),\n FadeOut(identity_rearranged),\n FadeOut(identity_rearranged_box)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Factoring out the constant\n # ------------------------------------------------------------------\n # Pull the 1/2 out of the integral\n factored_integral = MathTex(r\"= \\frac{1}{2} \\int \\sin(2x) \\, dx\")\n factored_integral.move_to(substituted_integral)\n self.play(ReplacementTransform(substituted_integral, factored_integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Integration Step\n # ------------------------------------------------------------------\n # Show the immediate result of the integration before simplification\n integrated_step = MathTex(r\"= \\frac{1}{2} \\left( -\\frac{1}{2} \\cos(2x) \\right) + C\")\n integrated_step.next_to(factored_integral, DOWN, aligned_edge=LEFT)\n self.play(Write(integrated_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Simplification\n # ------------------------------------------------------------------\n # Show the final simplified result\n final_result = MathTex(r\"= -\\frac{1}{4} \\cos(2x) + C\")\n final_result.next_to(integrated_step, DOWN, aligned_edge=LEFT)\n self.play(Write(final_result))\n self.wait(0.5)\n\n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=GREEN, buff=0.3)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrateSinCosX(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Title and Original Integral\n # ------------------------------------------------------------------\n title = Text(\"Integrating sin(x)cos(x)\", font_size=40)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Display the original integral\n original_integral = MathText(r\"\\int \\sin(x) \\cos(x) \\, dx\")\n original_integral.next_to(title, DOWN, buff=1)\n self.play(Write(original_integral))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Trigonometric Identity\n # ------------------------------------------------------------------\n # Show the standard double angle identity\n identity = MathTex(r\"\\sin(2x) = 2 \\sin(x) \\cos(x)\")\n identity.next_to(original_integral, DOWN, buff=1)\n \n # Use a box to emphasize the identity being applied\n identity_box = SurroundingRectangle(identity, color=YELLOW, buff=0.2)\n self.play(Write(identity), Create(identity_box))\n self.wait(1)\n\n # Rearrange the identity to isolate sin(x)cos(x)\n identity_rearranged = MathTex(r\"\\sin(x) \\cos(x) = \\frac{1}{2} \\sin(2x)\")\n identity_rearranged.move_to(identity)\n identity_rearranged_box = SurroundingRectangle(identity_rearranged, color=YELLOW, buff=0.2)\n \n # Transform the identity equation visually\n self.play(\n ReplacementTransform(identity, identity_rearranged),\n ReplacementTransform(identity_box, identity_rearranged_box)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Substitution\n # ------------------------------------------------------------------\n # Create the substituted integral\n substituted_integral = MathTex(r\"\\int \\frac{1}{2} \\sin(2x) \\, dx\")\n substituted_integral.move_to(original_integral)\n\n # Animate the substitution process\n self.play(\n ReplacementTransform(original_integral, substituted_integral),\n FadeOut(identity_rearranged),\n FadeOut(identity_rearranged_box)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Factoring out the constant\n # ------------------------------------------------------------------\n # Pull the 1/2 out of the integral\n factored_integral = MathTex(r\"= \\frac{1}{2} \\int \\sin(2x) \\, dx\")\n factored_integral.move_to(substituted_integral)\n self.play(ReplacementTransform(substituted_integral, factored_integral))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Integration Step\n # ------------------------------------------------------------------\n # Show the immediate result of the integration before simplification\n integrated_step = MathTex(r\"= \\frac{1}{2} \\left( -\\frac{1}{2} \\cos(2x) \\right) + C\")\n integrated_step.next_to(factored_integral, DOWN, aligned_edge=LEFT)\n self.play(Write(integrated_step))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Simplification\n # ------------------------------------------------------------------\n # Show the final simplified result\n final_result = MathTex(r\"= -\\frac{1}{4} \\cos(2x) + C\")\n final_result.next_to(integrated_step, DOWN, aligned_edge=LEFT)\n self.play(Write(final_result))\n self.wait(0.5)\n\n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=GREEN, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### CFL Closure Under Kleene Star\nCFLs are closed under the closure operation, which can be achieved through the recursive rule $S \\to S_1 S | \\epsilon$ to generate repetitions.\n\n\nThe context of this section (from highest to current level):\n# Properties of Context-Free Languages\n## Overview of Closure Properties of Context-Free Languages\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CFLKleeneStar(Scene):\n\n def construct(self):\n title = Text('Properties of Context-Free Languages', font_size=40, weight=BOLD)\n subtitle = Text('Closure Under Kleene Star', font_size=32, color=BLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2).to_edge(UP)\n statement = Text('CFLs are closed under the Kleene Star operation.', font_size=30)\n explanation = Text('This is achieved by adding a new start variable and a recursive rule\\nto generate repetitions of the original language.', font_size=26, t2c={'recursive rule': YELLOW}, line_spacing=1.2, t2w={'recursive rule': BOLD})\n text_group = VGroup(statement, explanation).arrange(DOWN, buff=0.4)\n grammar_rule = MathTex('S \\\\to S_1 S \\\\mid \\\\epsilon', font_size=56)\n rule_box = SurroundingRectangle(grammar_rule, color=YELLOW, buff=0.3)\n rule_group = VGroup(grammar_rule, rule_box)\n deriv_text = Text('Example Derivation:', font_size=28, color=GREEN)\n step1 = MathTex('S', font_size=36)\n step2 = MathTex('\\\\Rightarrow S_1 S', font_size=36)\n step3 = MathTex('\\\\Rightarrow S_1 S_1 S', font_size=36)\n step4 = MathTex('\\\\Rightarrow \\\\dots \\\\Rightarrow S_1 S_1 \\\\dots S_1 \\\\epsilon', font_size=36)\n deriv_group = VGroup(step1, step2, step3, step4).arrange(RIGHT, buff=0.2)\n deriv_section = VGroup(deriv_text, deriv_group).arrange(DOWN, buff=0.4)\n main_content = VGroup(text_group, rule_group, deriv_section).arrange(DOWN, buff=0.8)\n main_content.next_to(header, DOWN, buff=0.6)\n self.play(Write(header))\n self.wait(0.5)\n self.play(FadeIn(statement, shift=UP * 0.2))\n self.wait(0.5)\n self.play(FadeIn(explanation, shift=UP * 0.2))\n self.wait(0.5)\n self.play(Write(grammar_rule))\n self.play(Create(rule_box))\n self.wait(1)\n self.play(FadeIn(deriv_text, shift=RIGHT * 0.2))\n self.wait(0.5)\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(step4))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CFLKleeneStar(Scene):\n\n def construct(self):\n title = Text('Properties of Context-Free Languages', font_size=40, weight=BOLD)\n subtitle = Text('Closure Under Kleene Star', font_size=32, color=BBLUE)\n header = VGroup(title, subtitle).arrange(DOWN, buff=0.2).to_edge(UP)\n statement = Text('CFLs are closed under the Kleene Star operation.', font_size=30)\n explanation = Text('This is achieved by adding a new start variable and a recursive rule\\nto generate repetitions of the original language.', font_size=26, t2c={'recursive rule': YELLOW}, line_spacing=1.2, t2w={'recursive rule': BOLD})\n text_group = VGroup(statement, explanation).arrange(DOWN, buff=0.4)\n grammar_rule = MathTex('S \\\\to S_1 S \\\\mid \\\\epsilon', font_size=56)\n rule_box = SurroundingRectangle(grammar_rule, color=YELLOW, buff=0.3)\n rule_group = VGroup(grammar_rule, rule_box)\n deriv_text = Text('Example Derivation:', font_size=28, color=GREEN)\n step1 = MathTex('S', font_size=36)\n step2 = MathTex('\\\\Rightarrow S_1 S', font_size=36)\n step3 = MathTex('\\\\Rightarrow S_1 S_1 S', font_size=36)\n step4 = MathTex('\\\\Rightarrow \\\\dots \\\\Rightarrow S_1 S_1 \\\\dots S_1 \\\\epsilon', font_size=36)\n deriv_group = VGroup(step1, step2, step3, step4).arrange(RIGHT, buff=0.2)\n deriv_section = VGroup(deriv_text, deriv_group).arrange(DOWN, buff=0.4)\n main_content = VGroup(text_group, rule_group, deriv_section).arrange(DOWN, buff=0.8)\n main_content.next_to(header, DOWN, buff=0.6)\n self.play(Write(header))\n self.wait(0.5)\n self.play(FadeIn(statement, shift=UP * 0.2))\n self.wait(0.5)\n self.play(FadeIn(explanation, shift=UP * 0.2))\n self.wait(0.5)\n self.play(Write(grammar_rule))\n self.play(Create(rule_box))\n self.wait(1)\n self.play(FadeIn(deriv_text, shift=RIGHT * 0.2))\n self.wait(0.5)\n self.play(Write(step1))\n self.wait(0.5)\n self.play(Write(step2))\n self.wait(0.5)\n self.play(Write(step3))\n self.wait(0.5)\n self.play(Write(step4))\n self.wait(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 role of group theory in simplifying the counting of distinct patterns on an n x n grid using the Cycle Counting Theorem?", "chosen": "```python\nfrom manim import *\n\nclass CycleCountingTheorem(Scene):\n def construct(self):\n # Title\n title = Text(\"The Secret Language of Patterns\", font_size=40)\n subtitle = Text(\"Symmetry and the Cycle Counting Theorem\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(\n title.animate.scale(0.5).to_edge(UP),\n FadeOut(subtitle)\n )\n \n # Create a 3x3 grid\n grid = VGroup()\n for i in range(3):\n for j in range(3):\n square = Square(side_length=0.7)\n square.move_to([i-1, j-1, 0])\n grid.add(square)\n \n grid_text = Text(\"An n x n grid\", font_size=32)\n grid_text.next_to(grid, UP, buff=0.5)\n \n self.play(Write(grid_text))\n self.play(Create(grid))\n self.wait(1)\n \n # Create a pattern on the grid\n pattern = VGroup()\n positions = [(0, 0), (0, 2), (2, 0), (2, 2)] # Corner squares\n for i, j in positions:\n filled_square = Square(side_length=0.5, fill_opacity=1, fill_color=ORANGE)\n filled_square.move_to([i-1, j-1, 0])\n pattern.add(filled_square)\n \n pattern_text = Text(\"A pattern\", font_size=32)\n pattern_text.next_to(grid, DOWN, buff=0.5)\n \n self.play(Write(pattern_text))\n self.play(FadeIn(pattern))\n self.wait(1)\n \n # Rotation\n self.play(\n FadeOut(grid_text),\n Transform(pattern_text, Text(\"Rotation\", font_size=32).next_to(grid, DOWN, buff=0.5))\n )\n \n self.play(Rotate(pattern, PI/2, about_point=ORIGIN))\n self.wait(1)\n \n # Reflection\n self.play(\n Transform(pattern_text, Text(\"Reflection\", font_size=32).next_to(grid, DOWN, buff=0.5))\n )\n \n self.play(pattern.animate.flip(UP))\n self.wait(1)\n \n # Clean up\n self.play(\n FadeOut(grid),\n FadeOut(pattern),\n FadeOut(pattern_text)\n )\n \n # Group theory\n group_text = Text(\"Group Theory\", font_size=36)\n self.play(Write(group_text))\n self.wait(1)\n \n # Simple group diagram - circular representation of transformations\n circle = Circle(radius=1.5)\n \n # Create elements with better positioning\n e_text = Text(\"e\", font_size=24) # Identity\n r_text = Text(\"r\", font_size=24) # Rotation\n s_text = Text(\"s\", font_size=24) # Reflection\n \n e_text.move_to(circle.point_at_angle(0))\n r_text.move_to(circle.point_at_angle(TAU/3))\n s_text.move_to(circle.point_at_angle(2*TAU/3))\n \n elements = VGroup(e_text, r_text, s_text)\n \n self.play(\n FadeOut(group_text),\n Create(circle),\n Write(elements)\n )\n self.wait(1)\n \n # Cycle counting theorem\n self.play(\n FadeOut(circle),\n FadeOut(elements)\n )\n \n formula = MathTex(r\"\\text{Number of distinct patterns} = \\frac{1}{|G|} \\sum_{g \\in G} |\\text{Fix}(g)|\")\n formula_text = Text(\"Cycle Counting Theorem\", font_size=32)\n formula_text.next_to(formula, UP, buff=0.5)\n \n self.play(Write(formula_text))\n self.play(Write(formula))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Group theory reveals pattern symmetries\", font_size=32)\n \n self.play(\n FadeOut(formula),\n FadeOut(formula_text),\n Write(conclusion)\n )\n self.wait(2)\n \n # Final fadeout\n self.play(\n FadeOut(conclusion),\n FadeOut(title)\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass CycleCountingTheorem(Scene):\n def construct(self):\n # Title\n title = Text(\"The Secret Language of Patterns\", font_size=40)\n subtitle = Text(\"Symmetry and the Cycle Counting Theorem\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(\n title.animate.scale(0.5).to_edge(UP),\n FadeOut(subtitle)\n )\n \n # Create a 3x3 grid\n grid = VGroup()\n for i in range(3):\n for j in range(3):\n square = Square(side_length=0.7)\n square.move_to([i-1, j-1, 0])\n grid.add(square)\n \n grid_text = Text(\"An n x n grid\", font_size=32)\n grid_text.next_to(grid, UP, buff=0.5)\n \n self.play(Write(grid_text))\n self.play(Create(grid))\n self.wait(1)\n \n # Create a pattern on the grid\n pattern = VGroup()\n positions = [(0, 0), (0, 2), (2, 0), (2, 2)] # Corner squares\n for i, j in positions:\n filled_square = Square(side_length=0.5, fill_opacity=1, fill_color=ORANGE)\n filled_square.move_to([i-1, j-1, 0])\n pattern.add(filled_square)\n \n pattern_text = Text(\"A pattern\", font_size=32)\n pattern_text.next_to(grid, DOWN, buff=0.5)\n \n self.play(Write(pattern_text))\n self.play(FadeIn(pattern))\n self.wait(1)\n \n # Rotation\n self.play(\n FadeOut(grid_text),\n Transform(pattern_text, Text(\"Rotation\", font_size=32).next_to(grid, DOWN, buff=0.5))\n )\n \n self.play(Rotate(pattern, PI/2, about_point=ORIGIN))\n self.wait(1)\n \n # Reflection\n self.play(\n Transform(pattern_text, Text(\"Reflection\", font_size=32).next_to(grid, DOWN, buff=0.5))\n )\n \n self.play(pattern.animate.flip(UP))\n self.wait(1)\n \n # Clean up\n self.play(\n FadeOut(grid),\n FadeOut(pattern),\n FadeOut(pattern_text)\n )\n \n # Group theory\n group_text = Text(\"Group Theory\", font_size=36)\n self.play(Write(group_text))\n self.wait(1)\n \n # Simple group diagram - circular representation of transformations\n circle = Circle(radius=1.5)\n \n # Create elements with better positioning\n e_text = Text(\"e\", font_size=24) # Identity\n r_text = Text(\"r\", font_size=24) # Rotation\n s_text = Text(\"s\", font_size=24) # Reflection\n \n e_text.move_to(circle.point_at_angle(0))\n r_text.move_to(circle.point_at_angle(TAU/3))\n s_text.move_to(circle.point_at_angle(2*TAU/3))\n \n elements = VGroup(e_text, r_text, s_text)\n \n self.play(\n FadeOut(group_text),\n Create(circle),\n Write(elements)\n )\n self.wait(1)\n \n # Cycle counting theorem\n self.play(\n FadeOut(circle),\n FadeOut(elements)\n )\n \n formula = MathText(r\"\\text{Number of distinct patterns} = \\frac{1}{|G|} \\sum_{g \\in G} |\\text{Fix}(g)|\")\n formula_text = Text(\"Cycle Counting Theorem\", font_size=32)\n formula_text.next_to(formula, UP, buff=0.5)\n \n self.play(Write(formula_text))\n self.play(Write(formula))\n self.wait(2)\n \n # Conclusion\n conclusion = Text(\"Group theory reveals pattern symmetries\", font_size=32)\n \n self.play(\n FadeOut(formula),\n FadeOut(formula_text),\n Write(conclusion)\n )\n self.wait(2)\n \n # Final fadeout\n self.play(\n FadeOut(conclusion),\n FadeOut(title)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects before starting the next act.\n5. Keep all `MathTex(r\"...\")` strings as single raw string literals with balanced `{}` braces—never concatenate strings with `+`.", "prompt": "Show the process of electromagnetic induction according to Faraday's law.", "chosen": "```python\nfrom manim import *\n\nclass FaradaysLaw(Scene):\n def construct(self):\n # Title and explanation\n title = Text(\"Faraday's Law of Electromagnetic Induction\", font_size=36).to_edge(UP)\n explanation = Text(\n \"A changing magnetic field induces an electromotive force (EMF)\", \n font_size=24\n ).next_to(title, DOWN)\n\n # Coil representing the conductor\n coil = VGroup(*[Circle(radius=0.3, color=BLUE) for _ in range(10)])\n coil.arrange(RIGHT, buff=0.1).move_to(ORIGIN)\n\n # Initial magnetic field\n initial_field = Arrow(start=UP, end=DOWN, color=RED).next_to(coil, UP)\n\n # Movement of magnetic field\n final_field = Arrow(start=UP, end=DOWN, color=GREEN).next_to(coil, UP).shift(RIGHT)\n\n # Create loop for changing the magnetic field\n magnetic_field_animation = self.change_magnetic_field(initial_field, final_field)\n\n # EMF or current induction animation\n current_animation = self.create_current_animation(coil)\n\n # Display the elements\n self.play(Write(title), Write(explanation))\n self.wait(1)\n self.play(Create(coil), Create(initial_field))\n self.play(magnetic_field_animation)\n self.play(current_animation)\n self.wait(1)\n\n # Formulas and explanations\n formulas = MathTex(\n r\"\\text{EMF} = -N\\frac{d\\Phi}{dt}\",\n ).arrange(DOWN, aligned_edge=LEFT).scale(1.2).to_edge(DOWN, buff=2)\n\n explanations = Text(\n \"N - Number of turns,\\n\"\n \"Phi = BA - Magnetic flux,\\n\"\n \"B - External magnetic field,\\n\"\n \"A - Area of the coil\",\n font_size=24\n ).next_to(formulas, DOWN, buff=0.5).align_to(formulas[0], LEFT)\n\n # Apply color to specific terms\n explanations[0:1].set_color(YELLOW) # N\n explanations[5:10].set_color(YELLOW) # Phi\n explanations[16:17].set_color(YELLOW) # B\n explanations[22:23].set_color(YELLOW) # A\n\n self.play(Write(formulas), Write(explanations))\n self.wait(2)\n\n def change_magnetic_field(self, initial_field, final_field):\n return Transform(initial_field, final_field)\n\n def create_current_animation(self, coil):\n current_animation = []\n for _ in range(5):\n current = Arrow(start=LEFT, end=RIGHT, color=YELLOW).next_to(coil, DOWN)\n current_animation.append(Create(current))\n current_animation.append(FadeOut(current))\n return AnimationGroup(*current_animation)\n```", "rejected": "```python\nfrom manim import *\n\nclass FaradaysLaw(Scene):\n def construct(self):\n # Title and explanation\n title = Text(\"Faraday's Law of Electromagnetic Induction\", font_size=36).to_edge(UP)\n explanation = Text(\n \"A changing magnetic field induces an electromotive force (EMF)\", \n font_size=24\n ).next_to(title, DOWN)\n\n # Coil representing the conductor\n coil = VGroup(*[Circle(radius=0.3, color=BLUE) for _ in range(10)])\n coil.arrange(RIGHT, buff=0.1).move_to(ORIGIN)\n\n # Initial magnetic field\n initial_field = Arrow(start=UP, end=DOWN, color=RED).next_to(coil, UP)\n\n # Movement of magnetic field\n final_field = Arrow(start=UP, end=DOWN, color=GREEN).next_to(coil, UP).shift(RIGHT)\n\n # Create loop for changing the magnetic field\n magnetic_field_animation = self.change_magnetic_field(initial_field, final_field)\n\n # EMF or current induction animation\n current_animation = self.create_current_animation(coil)\n\n # Display the elements\n self.play(Write(title), Write(explanation))\n self.wait(1)\n self.play(Create(coil), Create(initial_field))\n self.play(magnetic_field_animation)\n self.play(current_animation)\n self.wait(1)\n\n # Formulas and explanations\n formulas = MathText(\n r\"\\text{EMF} = -N\\frac{d\\Phi}{dt}\",\n ).arrange(DOWN, aligned_edge=LEFT).scale(1.2).to_edge(DOWN, buff=2)\n\n explanations = Text(\n \"N - Number of turns,\\n\"\n \"Phi = BA - Magnetic flux,\\n\"\n \"B - External magnetic field,\\n\"\n \"A - Area of the coil\",\n font_size=24\n ).next_to(formulas, DOWN, buff=0.5).align_to(formulas[0], LEFT)\n\n # Apply color to specific terms\n explanations[0:1].set_color(YELLOW) # N\n explanations[5:10].set_color(YELLOW) # Phi\n explanations[16:17].set_color(YELLOW) # B\n explanations[22:23].set_color(YELLOW) # A\n\n self.play(Write(formulas), Write(explanations))\n self.wait(2)\n\n def change_magnetic_field(self, initial_field, final_field):\n return Transform(initial_field, final_field)\n\n def create_current_animation(self, coil):\n current_animation = []\n for _ in range(5):\n current = Arrow(start=LEFT, end=RIGHT, color=YELLOW).next_to(coil, DOWN)\n current_animation.append(Create(current))\n current_animation.append(FadeOut(current))\n return AnimationGroup(*current_animation)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 creating a unit circle and a sine curve, both displayed in sequence. A dot is then introduced and animated to move around the circle at a controlled speed, with its position dynamically updating. Simultaneously, a dashed red vertical line extends from the sine curve’s starting point to the dot’s current position, visually tracing the sine wave as the dot orbits the circle. To enhance understanding, a new feature is introduced: a real-time projection of the dot’s y-coordinate onto the sine curve, represented by a second dot that moves along the sine wave in sync with the orbiting dot. Additionally, a mathematical formula (e.g., \\( y = \\sin(\\theta) \\)) appears next to the sine curve, fading in with explanatory text that highlights the relationship between circular motion and the sine function. The animation concludes by labeling the sine curve, removing dynamic elements, and displaying a final static image of the sine wave with its formula, reinforcing the connection between the unit circle and trigonometric functions. This expanded version provides deeper insight into the underlying mathematics while maintaining the original’s visual clarity.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedSineWave(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-1, 10, 1],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"color\": BLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create unit circle\n circle = Circle(radius=1, color=WHITE).shift(LEFT * 3)\n circle_center = Dot(circle.get_center(), color=YELLOW)\n\n # Create sine curve\n sine_curve = axes.plot(lambda x: np.sin(x), color=GREEN)\n\n # Add labels\n circle_label = Tex(\"Unit Circle\").next_to(circle, UP)\n sine_label = Tex(\"$y = \\\\sin(\\\\theta)$\").next_to(sine_curve, UP)\n\n # Create dot on the circle and its projection\n dot = Dot(color=RED).move_to(circle.point_from_proportion(0))\n projection_dot = Dot(color=PURPLE).move_to(axes.c2p(0, np.sin(0)))\n\n # Create vertical line from sine curve to dot\n vertical_line = DashedLine(\n start=axes.c2p(0, 0),\n end=dot.get_center(),\n color=RED,\n stroke_width=2,\n )\n\n # Animation sequence\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(circle), Write(circle_label))\n self.play(Create(sine_curve), Write(sine_label))\n self.wait(1)\n\n # Add dot and vertical line\n self.play(FadeIn(dot), FadeIn(projection_dot))\n self.play(Create(vertical_line))\n self.wait(1)\n\n # Animate dot moving around the circle\n theta_tracker = ValueTracker(0)\n dot.add_updater(\n lambda d: d.move_to(\n circle.point_from_proportion(theta_tracker.get_value() % 1)\n )\n )\n projection_dot.add_updater(\n lambda d: d.move_to(\n axes.c2p(\n theta_tracker.get_value() * 2 * PI,\n np.sin(theta_tracker.get_value() * 2 * PI),\n )\n )\n )\n vertical_line.add_updater(\n lambda l: l.become(\n DashedLine(\n start=axes.c2p(\n theta_tracker.get_value() * 2 * PI, 0\n ),\n end=dot.get_center(),\n color=RED,\n stroke_width=2,\n )\n )\n )\n\n # Add formula and explanation\n formula = MathTex(\"y = \\\\sin(\\\\theta)\").to_edge(UP)\n explanation = Tex(\"Projection of the dot's y-coordinate\").next_to(formula, DOWN)\n self.play(Write(formula), Write(explanation))\n self.wait(1)\n\n # Animate the dot moving\n self.play(\n theta_tracker.animate.set_value(1),\n rate_func=linear,\n run_time=5,\n )\n self.wait(1)\n\n # Remove updaters and dynamic elements\n dot.clear_updaters()\n projection_dot.clear_updaters()\n vertical_line.clear_updaters()\n self.play(\n FadeOut(dot),\n FadeOut(projection_dot),\n FadeOut(vertical_line),\n FadeOut(explanation),\n )\n self.wait(1)\n\n # Final static image\n self.play(FadeOut(circle), FadeOut(circle_label))\n self.play(sine_curve.animate.set_color(YELLOW))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedSineWave(Scene):\n def construct(self):\n # Create axes\n axes = Axes(\n x_range=[-1, 10, 1],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"color\": BBLUE},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # Create unit circle\n circle = Circle(radius=1, color=WHITE).shift(LEFT * 3)\n circle_center = Dot(circle.get_center(), color=YELLOW)\n\n # Create sine curve\n sine_curve = axes.plot(lambda x: np.sin(x), color=GREEN)\n\n # Add labels\n circle_label = Tex(\"Unit Circle\").next_to(circle, UP)\n sine_label = Tex(\"$y = \\\\sin(\\\\theta)$\").next_to(sine_curve, UP)\n\n # Create dot on the circle and its projection\n dot = Dot(color=RED).move_to(circle.point_from_proportion(0))\n projection_dot = Dot(color=PURPLE).move_to(axes.c2p(0, np.sin(0)))\n\n # Create vertical line from sine curve to dot\n vertical_line = DashedLine(\n start=axes.c2p(0, 0),\n end=dot.get_center(),\n color=RED,\n stroke_width=2,\n )\n\n # Animation sequence\n self.play(Create(axes), Write(axes_labels))\n self.play(Create(circle), Write(circle_label))\n self.play(Create(sine_curve), Write(sine_label))\n self.wait(1)\n\n # Add dot and vertical line\n self.play(FadeIn(dot), FadeIn(projection_dot))\n self.play(Create(vertical_line))\n self.wait(1)\n\n # Animate dot moving around the circle\n theta_tracker = ValueTracker(0)\n dot.add_updater(\n lambda d: d.move_to(\n circle.point_from_proportion(theta_tracker.get_value() % 1)\n )\n )\n projection_dot.add_updater(\n lambda d: d.move_to(\n axes.c2p(\n theta_tracker.get_value() * 2 * PI,\n np.sin(theta_tracker.get_value() * 2 * PI),\n )\n )\n )\n vertical_line.add_updater(\n lambda l: l.become(\n DashedLine(\n start=axes.c2p(\n theta_tracker.get_value() * 2 * PI, 0\n ),\n end=dot.get_center(),\n color=RED,\n stroke_width=2,\n )\n )\n )\n\n # Add formula and explanation\n formula = MathTex(\"y = \\\\sin(\\\\theta)\").to_edge(UP)\n explanation = Tex(\"Projection of the dot's y-coordinate\").next_to(formula, DOWN)\n self.play(Write(formula), Write(explanation))\n self.wait(1)\n\n # Animate the dot moving\n self.play(\n theta_tracker.animate.set_value(1),\n rate_func=linear,\n run_time=5,\n )\n self.wait(1)\n\n # Remove updaters and dynamic elements\n dot.clear_updaters()\n projection_dot.clear_updaters()\n vertical_line.clear_updaters()\n self.play(\n FadeOut(dot),\n FadeOut(projection_dot),\n FadeOut(vertical_line),\n FadeOut(explanation),\n )\n self.wait(1)\n\n # Final static image\n self.play(FadeOut(circle), FadeOut(circle_label))\n self.play(sine_curve.animate.set_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates basic chemistry concepts for my students. Can you show the transformation of an electron into an oxygen atom, then show a grid formation of metal oxides, followed by the appearance of a single carbon atom? After that, I want the carbon atom to move along a complex path with specific stopping points. To wrap up, all the elements and compounds should fade out together.", "chosen": "```python\nfrom manim import *\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # Container to track all visible elements for proper lifecycle management\n # and the final simultaneous fade-out.\n all_elements = VGroup()\n\n # =========================================================================\n # Step 1: Transform Electron into Oxygen Atom\n # =========================================================================\n # Create a small blue dot representing an electron\n electron = Dot(color=BLUE_E, radius=0.15)\n electron_label = Text(\"e⁻\", font_size=24, color=WHITE).next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n\n # Create the target Oxygen atom representation (larger red circle with label)\n oxygen_atom = Circle(radius=0.6, color=RED, fill_opacity=0.8)\n oxygen_label = Text(\"O\", font_size=40, color=WHITE).move_to(oxygen_atom.get_center())\n oxygen_group = VGroup(oxygen_atom, oxygen_label)\n\n # Place initial electron in center-left\n electron_group.move_to(LEFT * 3)\n oxygen_group.move_to(LEFT * 3)\n\n self.play(FadeIn(electron_group))\n all_elements.add(electron_group)\n\n # Transformation animation: Morphs the electron visual into the oxygen atom\n # Note: Scientifically this represents a conceptual shift in focus rather than \n # literal transmutation, suitable for illustrating atomic building blocks.\n self.play(ReplacementTransform(electron_group, oxygen_group, run_time=2))\n \n # Update tracked elements: remove old reference, add new reference\n all_elements.remove(electron_group)\n all_elements.add(oxygen_group)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 2: Generate Grid Formation of Metal Oxides\n # =========================================================================\n # Create a grid representing a metal oxide (MO) lattice structure\n metal_oxide_grid = VGroup()\n rows, cols = 4, 4\n spacing = 0.9\n\n for r in range(rows):\n for c in range(cols):\n # Calculate grid position centered on screen, slightly above origin\n x = (c - cols / 2 + 0.5) * spacing\n y = (r - rows / 2 + 0.5) * spacing + 2.5\n\n # Alternate colors to simulate Metal (Grey) and Oxygen (Red) ions\n if (r + c) % 2 == 0:\n ion = Circle(radius=0.3, color=RED, fill_opacity=0.7)\n ion_label = Text(\"O\", font_size=20, color=WHITE)\n else:\n ion = Circle(radius=0.35, color=GREY, fill_opacity=0.7)\n ion_label = Text(\"M\", font_size=20, color=WHITE)\n\n ion_label.move_to(ion.get_center())\n ion_group = VGroup(ion, ion_label).move_to([x, y, 0])\n metal_oxide_grid.add(ion_group)\n\n # Animate the grid appearing with a staggered lag effect\n self.play(LaggedStartMap(FadeIn, metal_oxide_grid, lag_ratio=0.1))\n all_elements.add(metal_oxide_grid)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 3: Introduce Single Carbon Atom\n # =========================================================================\n # Create Carbon atom (Dark Grey/Black)\n carbon_atom = Circle(radius=0.5, color=GREY_E, fill_opacity=0.9)\n carbon_label = Text(\"C\", font_size=35, color=WHITE).move_to(carbon_atom.get_center())\n carbon_group = VGroup(carbon_atom, carbon_label)\n\n # Start position for Carbon (bottom left)\n start_pos = LEFT * 5 + DOWN * 3\n carbon_group.move_to(start_pos)\n\n self.play(FadeIn(carbon_group, scale=0.5))\n all_elements.add(carbon_group)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 4: Carbon Atom Movement Along Complex Path with Stops\n # =========================================================================\n # Define specific waypoints for the complex path\n # This creates a trajectory that weaves through the scene\n waypoints = [\n start_pos, # Start\n LEFT * 2 + DOWN * 2, # Point 1\n LEFT * 2 + UP * 1, # Point 2 (Near Oxygen)\n RIGHT * 2 + UP * 1, # Point 3 (Near Oxides)\n RIGHT * 2 + DOWN * 2, # Point 4\n ORIGIN + DOWN * 3 # Point 5 (Center-bottom)\n ]\n\n # Visualize the path for students (dashed/smooth line)\n path_guide = VMobject(color=YELLOW, stroke_width=2, stroke_opacity=0.5)\n path_guide.set_points_smoothly([wp for wp in waypoints])\n\n # Show the path\n self.play(Create(path_guide), run_time=1.5)\n all_elements.add(path_guide)\n\n # Animate movement between waypoints with specific stopping points\n # We iterate through segments to allow for Wait() pauses at each node\n for i in range(len(waypoints) - 1):\n end_point = waypoints[i + 1]\n\n # Move carbon to the next waypoint\n self.play(\n carbon_group.animate.move_to(end_point),\n run_time=1.5,\n rate_func=smooth\n )\n \n # Specific stopping point pause to emphasize location\n self.wait(0.8)\n\n # =========================================================================\n # Step 5: Simultaneous Fade Out\n # =========================================================================\n # Clean up the scene by fading out all created elements together\n # This ensures proper object lifecycle management and scene reset\n self.play(FadeOut(all_elements), run_time=2)\n \n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # Container to track all visible elements for proper lifecycle management\n # and the final simultaneous fade-out.\n all_elements = VGroup()\n\n # =========================================================================\n # Step 1: Transform Electron into Oxygen Atom\n # =========================================================================\n # Create a small blue dot representing an electron\n electron = Dot(color=BBLUE_E, radius=0.15)\n electron_label = Text(\"e⁻\", font_size=24, color=WHITE).next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n\n # Create the target Oxygen atom representation (larger red circle with label)\n oxygen_atom = Circle(radius=0.6, color=RED, fill_opacity=0.8)\n oxygen_label = Text(\"O\", font_size=40, color=WHITE).move_to(oxygen_atom.get_center())\n oxygen_group = VGroup(oxygen_atom, oxygen_label)\n\n # Place initial electron in center-left\n electron_group.move_to(LEFT * 3)\n oxygen_group.move_to(LEFT * 3)\n\n self.play(FadeIn(electron_group))\n all_elements.add(electron_group)\n\n # Transformation animation: Morphs the electron visual into the oxygen atom\n # Note: Scientifically this represents a conceptual shift in focus rather than \n # literal transmutation, suitable for illustrating atomic building blocks.\n self.play(ReplacementTransform(electron_group, oxygen_group, run_time=2))\n \n # Update tracked elements: remove old reference, add new reference\n all_elements.remove(electron_group)\n all_elements.add(oxygen_group)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 2: Generate Grid Formation of Metal Oxides\n # =========================================================================\n # Create a grid representing a metal oxide (MO) lattice structure\n metal_oxide_grid = VGroup()\n rows, cols = 4, 4\n spacing = 0.9\n\n for r in range(rows):\n for c in range(cols):\n # Calculate grid position centered on screen, slightly above origin\n x = (c - cols / 2 + 0.5) * spacing\n y = (r - rows / 2 + 0.5) * spacing + 2.5\n\n # Alternate colors to simulate Metal (Grey) and Oxygen (Red) ions\n if (r + c) % 2 == 0:\n ion = Circle(radius=0.3, color=RED, fill_opacity=0.7)\n ion_label = Text(\"O\", font_size=20, color=WHITE)\n else:\n ion = Circle(radius=0.35, color=GREY, fill_opacity=0.7)\n ion_label = Text(\"M\", font_size=20, color=WHITE)\n\n ion_label.move_to(ion.get_center())\n ion_group = VGroup(ion, ion_label).move_to([x, y, 0])\n metal_oxide_grid.add(ion_group)\n\n # Animate the grid appearing with a staggered lag effect\n self.play(LaggedStartMap(FadeIn, metal_oxide_grid, lag_ratio=0.1))\n all_elements.add(metal_oxide_grid)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 3: Introduce Single Carbon Atom\n # =========================================================================\n # Create Carbon atom (Dark Grey/Black)\n carbon_atom = Circle(radius=0.5, color=GREY_E, fill_opacity=0.9)\n carbon_label = Text(\"C\", font_size=35, color=WHITE).move_to(carbon_atom.get_center())\n carbon_group = VGroup(carbon_atom, carbon_label)\n\n # Start position for Carbon (bottom left)\n start_pos = LEFT * 5 + DOWN * 3\n carbon_group.move_to(start_pos)\n\n self.play(FadeIn(carbon_group, scale=0.5))\n all_elements.add(carbon_group)\n \n self.wait(0.5)\n\n # =========================================================================\n # Step 4: Carbon Atom Movement Along Complex Path with Stops\n # =========================================================================\n # Define specific waypoints for the complex path\n # This creates a trajectory that weaves through the scene\n waypoints = [\n start_pos, # Start\n LEFT * 2 + DOWN * 2, # Point 1\n LEFT * 2 + UP * 1, # Point 2 (Near Oxygen)\n RIGHT * 2 + UP * 1, # Point 3 (Near Oxides)\n RIGHT * 2 + DOWN * 2, # Point 4\n ORIGIN + DOWN * 3 # Point 5 (Center-bottom)\n ]\n\n # Visualize the path for students (dashed/smooth line)\n path_guide = VMobject(color=YELLOW, stroke_width=2, stroke_opacity=0.5)\n path_guide.set_points_smoothly([wp for wp in waypoints])\n\n # Show the path\n self.play(Create(path_guide), run_time=1.5)\n all_elements.add(path_guide)\n\n # Animate movement between waypoints with specific stopping points\n # We iterate through segments to allow for Wait() pauses at each node\n for i in range(len(waypoints) - 1):\n end_point = waypoints[i + 1]\n\n # Move carbon to the next waypoint\n self.play(\n carbon_group.animate.move_to(end_point),\n run_time=1.5,\n rate_func=smooth\n )\n \n # Specific stopping point pause to emphasize location\n self.wait(0.8)\n\n # =========================================================================\n # Step 5: Simultaneous Fade Out\n # =========================================================================\n # Clean up the scene by fading out all created elements together\n # This ensures proper object lifecycle management and scene reset\n self.play(FadeOut(all_elements), run_time=2)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(label_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(label_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 geometric interpretation of an entire function missing only one value on the complex plane, and how does it compare to a function missing multiple values?", "chosen": "```python\nfrom manim import *\n\nclass PicardsLittleTheorem(Scene):\n def construct(self):\n # Title\n title = Text(\"Picard's Remarkable Mapping\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Simple complex plane\n plane = ComplexPlane().scale(0.7)\n plane_title = Text(\"Complex Plane\", font_size=36).to_edge(UP)\n self.play(Create(plane), Write(plane_title))\n self.wait(1)\n \n # Function missing one value\n concept1 = Text(\"Function Missing One Value\", font_size=36).to_edge(UP)\n missing_point = Dot(RIGHT*2 + UP*2, color=YELLOW)\n eq1 = Text(\"f: C \\rightarrow C\\\\{a}\", font_size=24).next_to(concept1, DOWN)\n \n self.play(\n ReplacementTransform(plane_title, concept1),\n Create(missing_point),\n Write(eq1)\n )\n \n # Show coverage with a blue circle\n coverage = Circle(radius=3, fill_opacity=0.3, color=BLUE).move_to(ORIGIN)\n self.play(Create(coverage))\n self.wait(1)\n \n # Function missing multiple values\n concept2 = Text(\"Function Missing Multiple Values\", font_size=36).to_edge(UP)\n eq2 = Text(\"f: C \\rightarrow C\\\\{a,b,c}\", font_size=24).next_to(concept2, DOWN)\n \n # Additional missing points\n new_points = VGroup(\n Dot(LEFT*2 + UP*2, color=YELLOW),\n Dot(RIGHT*2 + DOWN*2, color=YELLOW),\n Dot(LEFT*2 + DOWN*2, color=YELLOW)\n )\n \n self.play(\n ReplacementTransform(concept1, concept2),\n ReplacementTransform(eq1, eq2),\n FadeOut(missing_point),\n Create(new_points)\n )\n \n # Different coverage\n limited_coverage = Circle(radius=2, fill_opacity=0.3, color=PURPLE).move_to(ORIGIN)\n self.play(Transform(coverage, limited_coverage))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Picard's Little Theorem:\", font_size=36).to_edge(UP)\n insight = Text(\"An entire function missing just one value\\nhas infinite versatility\", \n font_size=24).next_to(conclusion, DOWN)\n \n self.play(\n ReplacementTransform(concept2, conclusion),\n FadeOut(eq2),\n Write(insight),\n FadeOut(new_points),\n FadeOut(coverage)\n )\n self.wait(2)\n \n final_text = Text(\"A pearl of beauty in mathematics\", font_size=36)\n self.play(\n FadeOut(conclusion),\n FadeOut(insight),\n FadeOut(plane),\n Write(final_text)\n )\n self.wait(2)\n self.play(FadeOut(final_text))\n```", "rejected": "```python\nfrom manim import *\n\nclass PicardsLittleTheorem(Scene):\n def construct(self):\n # Title\n title = Text(\"Picard's Remarkable Mapping\", font_size=48)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Simple complex plane\n plane = ComplexPlane().scale(0.7)\n plane_title = Text(\"Complex Plane\", font_size=36).to_edge(UP)\n self.play(Create(plane), Write(plane_title))\n self.wait(1)\n \n # Function missing one value\n concept1 = Text(\"Function Missing One Value\", font_size=36).to_edge(UP)\n missing_point = Dot(RIGHT*2 + UP*2, color=YELLOW)\n eq1 = Text(\"f: C \\rightarrow C\\\\{a}\", font_size=24).next_to(concept1, DOWN)\n \n self.play(\n ReplacementTransform(plane_title, concept1),\n Create(missing_point),\n Write(eq1)\n )\n \n # Show coverage with a blue circle\n coverage = Circle(radius=3, fill_opacity=0.3, color=BBLUE).move_to(ORIGIN)\n self.play(Create(coverage))\n self.wait(1)\n \n # Function missing multiple values\n concept2 = Text(\"Function Missing Multiple Values\", font_size=36).to_edge(UP)\n eq2 = Text(\"f: C \\rightarrow C\\\\{a,b,c}\", font_size=24).next_to(concept2, DOWN)\n \n # Additional missing points\n new_points = VGroup(\n Dot(LEFT*2 + UP*2, color=YELLOW),\n Dot(RIGHT*2 + DOWN*2, color=YELLOW),\n Dot(LEFT*2 + DOWN*2, color=YELLOW)\n )\n \n self.play(\n ReplacementTransform(concept1, concept2),\n ReplacementTransform(eq1, eq2),\n FadeOut(missing_point),\n Create(new_points)\n )\n \n # Different coverage\n limited_coverage = Circle(radius=2, fill_opacity=0.3, color=PURPLE).move_to(ORIGIN)\n self.play(Transform(coverage, limited_coverage))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Picard's Little Theorem:\", font_size=36).to_edge(UP)\n insight = Text(\"An entire function missing just one value\\nhas infinite versatility\", \n font_size=24).next_to(conclusion, DOWN)\n \n self.play(\n ReplacementTransform(concept2, conclusion),\n FadeOut(eq2),\n Write(insight),\n FadeOut(new_points),\n FadeOut(coverage)\n )\n self.wait(2)\n \n final_text = Text(\"A pearl of beauty in mathematics\", font_size=36)\n self.play(\n FadeOut(conclusion),\n FadeOut(insight),\n FadeOut(plane),\n Write(final_text)\n )\n self.wait(2)\n self.play(FadeOut(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visually explains the parts of a DC motor. I want the animation to have labeled components like the rotor, stator, and brushes. Each label should be connected to the corresponding part of the motor with dashed lines for clarity. In the animation, I prefer a simple yet detailed representation of the DC motor. Make sure to use contrasting colors so that each part is distinct and the labels are clear against a white background. Can you provide an animation that meets these specifications?", "chosen": "```python\nfrom manim import *\n\nclass DCMotorExplanation(Scene):\n def construct(self):\n # Set background color to white\n self.camera.background_color = WHITE\n\n # --- Color Palette ---\n COLOR_STATOR_N = RED\n COLOR_STATOR_S = BLUE\n COLOR_ROTOR = GOLD\n COLOR_BRUSHES = BLACK\n COLOR_TEXT = BLACK\n COLOR_LINES = DARK_GREY\n\n # --- 1. Create Stator (Permanent Magnets) ---\n magnet_n = Rectangle(height=3, width=1, color=COLOR_STATOR_N, fill_opacity=0.8)\n magnet_n.move_to(LEFT * 4)\n label_n = Text(\"N\", font_size=40, color=WHITE).move_to(magnet_n.get_center())\n \n magnet_s = Rectangle(height=3, width=1, color=COLOR_STATOR_S, fill_opacity=0.8)\n magnet_s.move_to(RIGHT * 4)\n label_s = Text(\"S\", font_size=40, color=WHITE).move_to(magnet_s.get_center())\n\n stator_group = VGroup(magnet_n, label_n, magnet_s, label_s)\n\n # --- 2. Create Rotor (Armature Coil + Commutator) ---\n coil = Rectangle(height=1.5, width=2.5, color=COLOR_ROTOR, stroke_width=6, fill_opacity=0.2)\n coil.set_fill(COLOR_ROTOR, opacity=0.2)\n \n axle = Line(LEFT * 2, RIGHT * 2, color=GRAY, stroke_width=2)\n \n # Commutator (Split Rings) simplified as two arcs\n commutator_left = Arc(radius=0.3, start_angle=90*DEGREES, angle=180*DEGREES, color=COLOR_ROTOR, stroke_width=8)\n commutator_right = Arc(radius=0.3, start_angle=270*DEGREES, angle=180*DEGREES, color=COLOR_ROTOR, stroke_width=8)\n commutator_group = VGroup(commutator_left, commutator_right).move_to(ORIGIN)\n\n rotor_group = VGroup(coil, axle, commutator_group)\n\n # --- 3. Create Brushes ---\n brush_left = Rectangle(height=0.6, width=0.4, color=COLOR_BRUSHES, fill_opacity=1)\n brush_left.move_to(LEFT * 0.4 + UP * 0.3)\n \n brush_right = Rectangle(height=0.6, width=0.4, color=COLOR_BRUSHES, fill_opacity=1)\n brush_right.move_to(RIGHT * 0.4 + UP * 0.3)\n \n brushes_group = VGroup(brush_left, brush_right)\n\n # --- 4. Create Labels and Dashed Lines ---\n stator_label = Text(\"Stator\", font_size=36, color=COLOR_TEXT).next_to(magnet_n, UP, buff=0.5)\n rotor_label = Text(\"Rotor\", font_size=36, color=COLOR_TEXT).next_to(coil, UP, buff=0.8)\n brushes_label = Text(\"Brushes\", font_size=36, color=COLOR_TEXT).next_to(brushes_group, DOWN, buff=0.5)\n\n line_stator = DashedLine(stator_label.get_bottom(), magnet_n.get_top(), color=COLOR_LINES, stroke_width=2)\n line_rotor = DashedLine(rotor_label.get_bottom(), coil.get_top(), color=COLOR_LINES, stroke_width=2)\n line_brushes = DashedLine(brushes_label.get_top(), brush_left.get_bottom(), color=COLOR_LINES, stroke_width=2)\n\n # --- 5. Animation Sequence ---\n \n # Title\n title = Text(\"DC Motor Components\", font_size=48, color=COLOR_TEXT)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Animate Stator\n self.play(FadeIn(stator_group))\n self.play(Write(stator_label), Create(line_stator))\n self.wait(0.5)\n\n # Animate Rotor\n self.play(FadeIn(rotor_group))\n self.play(Write(rotor_label), Create(line_rotor))\n self.wait(0.5)\n\n # Animate Brushes\n self.play(FadeIn(brushes_group))\n self.play(Write(brushes_label), Create(line_brushes))\n self.wait(1)\n\n # Demonstrate Rotation\n self.play(Rotate(rotor_group, angle=2*PI, about_point=ORIGIN), run_time=3)\n self.wait(2)\n\n# To run this script, use: manim -pql filename.py DCMotorExplanation\n```", "rejected": "```python\nfrom manim import *\n\nclass DCMotorExplanation(Scene):\n def construct(self):\n # Set background color to white\n self.camera.background_color = WHITE\n\n # --- Color Palette ---\n COLOR_STATOR_N = RED\n COLOR_STATOR_S = BBLUE\n COLOR_ROTOR = GOLD\n COLOR_BRUSHES = BLACK\n COLOR_TEXT = BLACK\n COLOR_LINES = DARK_GREY\n\n # --- 1. Create Stator (Permanent Magnets) ---\n magnet_n = Rectangle(height=3, width=1, color=COLOR_STATOR_N, fill_opacity=0.8)\n magnet_n.move_to(LEFT * 4)\n label_n = Text(\"N\", font_size=40, color=WHITE).move_to(magnet_n.get_center())\n \n magnet_s = Rectangle(height=3, width=1, color=COLOR_STATOR_S, fill_opacity=0.8)\n magnet_s.move_to(RIGHT * 4)\n label_s = Text(\"S\", font_size=40, color=WHITE).move_to(magnet_s.get_center())\n\n stator_group = VGroup(magnet_n, label_n, magnet_s, label_s)\n\n # --- 2. Create Rotor (Armature Coil + Commutator) ---\n coil = Rectangle(height=1.5, width=2.5, color=COLOR_ROTOR, stroke_width=6, fill_opacity=0.2)\n coil.set_fill(COLOR_ROTOR, opacity=0.2)\n \n axle = Line(LEFT * 2, RIGHT * 2, color=GRAY, stroke_width=2)\n \n # Commutator (Split Rings) simplified as two arcs\n commutator_left = Arc(radius=0.3, start_angle=90*DEGREES, angle=180*DEGREES, color=COLOR_ROTOR, stroke_width=8)\n commutator_right = Arc(radius=0.3, start_angle=270*DEGREES, angle=180*DEGREES, color=COLOR_ROTOR, stroke_width=8)\n commutator_group = VGroup(commutator_left, commutator_right).move_to(ORIGIN)\n\n rotor_group = VGroup(coil, axle, commutator_group)\n\n # --- 3. Create Brushes ---\n brush_left = Rectangle(height=0.6, width=0.4, color=COLOR_BRUSHES, fill_opacity=1)\n brush_left.move_to(LEFT * 0.4 + UP * 0.3)\n \n brush_right = Rectangle(height=0.6, width=0.4, color=COLOR_BRUSHES, fill_opacity=1)\n brush_right.move_to(RIGHT * 0.4 + UP * 0.3)\n \n brushes_group = VGroup(brush_left, brush_right)\n\n # --- 4. Create Labels and Dashed Lines ---\n stator_label = Text(\"Stator\", font_size=36, color=COLOR_TEXT).next_to(magnet_n, UP, buff=0.5)\n rotor_label = Text(\"Rotor\", font_size=36, color=COLOR_TEXT).next_to(coil, UP, buff=0.8)\n brushes_label = Text(\"Brushes\", font_size=36, color=COLOR_TEXT).next_to(brushes_group, DOWN, buff=0.5)\n\n line_stator = DashedLine(stator_label.get_bottom(), magnet_n.get_top(), color=COLOR_LINES, stroke_width=2)\n line_rotor = DashedLine(rotor_label.get_bottom(), coil.get_top(), color=COLOR_LINES, stroke_width=2)\n line_brushes = DashedLine(brushes_label.get_top(), brush_left.get_bottom(), color=COLOR_LINES, stroke_width=2)\n\n # --- 5. Animation Sequence ---\n \n # Title\n title = Text(\"DC Motor Components\", font_size=48, color=COLOR_TEXT)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Animate Stator\n self.play(FadeIn(stator_group))\n self.play(Write(stator_label), Create(line_stator))\n self.wait(0.5)\n\n # Animate Rotor\n self.play(FadeIn(rotor_group))\n self.play(Write(rotor_label), Create(line_rotor))\n self.wait(0.5)\n\n # Animate Brushes\n self.play(FadeIn(brushes_group))\n self.play(Write(brushes_label), Create(line_brushes))\n self.wait(1)\n\n # Demonstrate Rotation\n self.play(Rotate(rotor_group, angle=2*PI, about_point=ORIGIN), run_time=3)\n self.wait(2)\n\n# To run this script, use: manim -pql filename.py DCMotorExplanation\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 introduces and solves the integral of e to the power of x, detailing each step of the process and highlighting the constant of integration?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass IntegralOfExponential(Scene):\n \"\"\"\n Educational animation demonstrating the indefinite integral of e^x.\n \n This scene visually guides the viewer through:\n 1. Introducing the function f(x) = e^x alongside its graph.\n 2. Setting up the integral problem.\n 3. Recalling the derivative property of e^x to justify the solution.\n 4. Constructing the solution step-by-step.\n 5. Emphasizing the constant of integration (+C) and its mathematical necessity.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduce the base function f(x) = e^x\n # ------------------------------------------------------------------\n # Provide visual context by plotting the exponential function.\n axes = Axes(\n x_range=[-3, 3],\n y_range=[0, 10],\n axis_config={\"include_tip\": True}\n ).scale(0.6).to_edge(LEFT)\n \n graph = axes.plot(lambda x: np.exp(x), x_range=[-3, 2.3], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = e^x\")\n \n # Display the function definition text on the right.\n func_definition = MathTex(\"f(x)\", \"=\", \"e^{x}\").scale(1.2).to_edge(UP).shift(RIGHT * 2)\n \n self.play(Write(func_definition))\n self.play(Create(axes), Create(graph), Write(graph_label), run_time=2)\n self.wait(1) # Pause for recognition\n \n # ------------------------------------------------------------------\n # Step 2: Transition to the Integral Notation\n # ------------------------------------------------------------------\n # Fade out the graph to focus on the calculus algebra.\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label))\n self.play(func_definition.animate.move_to(ORIGIN))\n self.wait(1)\n \n # Display the indefinite integral notation.\n # We separate components to allow for individual animation later.\n integral_expr = MathTex(\"\\\\int\", \"e^{x}\", \"\\\\,\", \"\\\\mathrm{d}x\").scale(1.5)\n integral_expr.move_to(func_definition)\n \n # Transform the function equation into the integral notation.\n self.play(Transform(func_definition, integral_expr))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 3: Justify the Solution via Derivatives\n # ------------------------------------------------------------------\n # Remind the viewer that the derivative of e^x is e^x.\n # This is the core logical step for solving the integral.\n logic_text = Text(\n \"Since the derivative of e^x is e^x,\", \n font_size=24, \n slant=ITALIC\n ).next_to(func_definition, DOWN, buff=1)\n \n logic_text_2 = Text(\n \"the antiderivative is also e^x.\", \n font_size=24, \n slant=ITALIC\n ).next_to(logic_text, DOWN, buff=0.3)\n \n self.play(Write(logic_text))\n self.wait(1)\n self.play(Write(logic_text_2))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # Step 4: Construct the Solution\n # ------------------------------------------------------------------\n # We transform the integral expression into the solution.\n # We isolate the constant 'C' into a separate substring for highlighting.\n solution_text = MathTex(\"e^{x}\", \"+\", \"C\").scale(1.5)\n solution_text.move_to(func_definition)\n \n self.play(\n FadeOut(logic_text), \n FadeOut(logic_text_2), \n Transform(func_definition, solution_text)\n )\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 5: Introduce and Highlight the Constant of Integration\n # ------------------------------------------------------------------\n # This is a critical educational moment. We explicitly highlight + C.\n # func_definition[2] now corresponds to \"C\" based on the MathTex split.\n constant_part = func_definition[2]\n constant_part.set_color(YELLOW)\n \n # Create a surrounding rectangle to box the constant.\n c_box = SurroundingRectangle(constant_part, color=YELLOW, buff=0.1)\n \n # Add a label explicitly naming the constant.\n c_label = Text(\"Constant of Integration\", font_size=24, color=YELLOW)\n c_label.next_to(c_box, DOWN, buff=0.5)\n \n # Animate the color change of C to draw attention.\n self.play(constant_part.animate.set_color(YELLOW))\n self.wait(0.5)\n \n # Draw the box around C and reveal the label.\n self.play(Create(c_box))\n self.play(FadeIn(c_label))\n self.wait(1)\n \n # Explain *why* C is necessary for mathematical completeness.\n explanation = Text(\n \"C represents any constant value, as its derivative is zero.\", \n font_size=20, \n color=GRAY\n ).next_to(c_label, DOWN, buff=0.4)\n \n self.play(Write(explanation))\n self.wait(2) # Emphasize the importance of C\n \n # ------------------------------------------------------------------\n # Step 6: Final Conclusion\n # ------------------------------------------------------------------\n # Fade out auxiliary elements to leave the final equation clear.\n self.play(FadeOut(c_box), FadeOut(c_label), FadeOut(explanation))\n \n # Reset the color of C to match the rest for a clean final look.\n self.play(constant_part.animate.set_color(WHITE))\n \n # Group the final equation and box it to signify completion.\n final_box = SurroundingRectangle(func_definition, color=YELLOW, buff=0.3)\n self.play(Create(final_box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass IntegralOfExponential(Scene):\n \"\"\"\n Educational animation demonstrating the indefinite integral of e^x.\n \n This scene visually guides the viewer through:\n 1. Introducing the function f(x) = e^x alongside its graph.\n 2. Setting up the integral problem.\n 3. Recalling the derivative property of e^x to justify the solution.\n 4. Constructing the solution step-by-step.\n 5. Emphasizing the constant of integration (+C) and its mathematical necessity.\n \"\"\"\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduce the base function f(x) = e^x\n # ------------------------------------------------------------------\n # Provide visual context by plotting the exponential function.\n axes = Axes(label_font_size=24, \n x_range=[-3, 3],\n y_range=[0, 10],\n axis_config={\"include_tip\": True}\n ).scale(0.6).to_edge(LEFT)\n \n graph = axes.plot(lambda x: np.exp(x), x_range=[-3, 2.3], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = e^x\")\n \n # Display the function definition text on the right.\n func_definition = MathTex(\"f(x)\", \"=\", \"e^{x}\").scale(1.2).to_edge(UP).shift(RIGHT * 2)\n \n self.play(Write(func_definition))\n self.play(Create(axes), Create(graph), Write(graph_label), run_time=2)\n self.wait(1) # Pause for recognition\n \n # ------------------------------------------------------------------\n # Step 2: Transition to the Integral Notation\n # ------------------------------------------------------------------\n # Fade out the graph to focus on the calculus algebra.\n self.play(FadeOut(axes), FadeOut(graph), FadeOut(graph_label))\n self.play(func_definition.animate.move_to(ORIGIN))\n self.wait(1)\n \n # Display the indefinite integral notation.\n # We separate components to allow for individual animation later.\n integral_expr = MathTex(\"\\\\int\", \"e^{x}\", \"\\\\,\", \"\\\\mathrm{d}x\").scale(1.5)\n integral_expr.move_to(func_definition)\n \n # Transform the function equation into the integral notation.\n self.play(Transform(func_definition, integral_expr))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 3: Justify the Solution via Derivatives\n # ------------------------------------------------------------------\n # Remind the viewer that the derivative of e^x is e^x.\n # This is the core logical step for solving the integral.\n logic_text = Text(\n \"Since the derivative of e^x is e^x,\", \n font_size=24, \n slant=ITALIC\n ).next_to(func_definition, DOWN, buff=1)\n \n logic_text_2 = Text(\n \"the antiderivative is also e^x.\", \n font_size=24, \n slant=ITALIC\n ).next_to(logic_text, DOWN, buff=0.3)\n \n self.play(Write(logic_text))\n self.wait(1)\n self.play(Write(logic_text_2))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # Step 4: Construct the Solution\n # ------------------------------------------------------------------\n # We transform the integral expression into the solution.\n # We isolate the constant 'C' into a separate substring for highlighting.\n solution_text = MathTex(\"e^{x}\", \"+\", \"C\").scale(1.5)\n solution_text.move_to(func_definition)\n \n self.play(\n FadeOut(logic_text), \n FadeOut(logic_text_2), \n Transform(func_definition, solution_text)\n )\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 5: Introduce and Highlight the Constant of Integration\n # ------------------------------------------------------------------\n # This is a critical educational moment. We explicitly highlight + C.\n # func_definition[2] now corresponds to \"C\" based on the MathTex split.\n constant_part = func_definition[2]\n constant_part.set_color(YELLOW)\n \n # Create a surrounding rectangle to box the constant.\n c_box = SurroundingRectangle(constant_part, color=YELLOW, buff=0.1)\n \n # Add a label explicitly naming the constant.\n c_label = Text(\"Constant of Integration\", font_size=24, color=YELLOW)\n c_label.next_to(c_box, DOWN, buff=0.5)\n \n # Animate the color change of C to draw attention.\n self.play(constant_part.animate.set_color(YELLOW))\n self.wait(0.5)\n \n # Draw the box around C and reveal the label.\n self.play(Create(c_box))\n self.play(FadeIn(c_label))\n self.wait(1)\n \n # Explain *why* C is necessary for mathematical completeness.\n explanation = Text(\n \"C represents any constant value, as its derivative is zero.\", \n font_size=20, \n color=GRAY\n ).next_to(c_label, DOWN, buff=0.4)\n \n self.play(Write(explanation))\n self.wait(2) # Emphasize the importance of C\n \n # ------------------------------------------------------------------\n # Step 6: Final Conclusion\n # ------------------------------------------------------------------\n # Fade out auxiliary elements to leave the final equation clear.\n self.play(FadeOut(c_box), FadeOut(c_label), FadeOut(explanation))\n \n # Reset the color of C to match the rest for a clean final look.\n self.play(constant_part.animate.set_color(WHITE))\n \n # Group the final equation and box it to signify completion.\n final_box = SurroundingRectangle(func_definition, color=YELLOW, buff=0.3)\n self.play(Create(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = 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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # Set background color\n self.camera.background_color = \"#0C1445\" # Dark blue background\n \n # Introduction\n title = Text(\"Unveiling Patterns: Euler's Totient Function\", color=ORANGE).scale(0.8)\n self.play(Write(title))\n self.play(title.animate.to_edge(UP))\n \n # Definition\n definition = Text(\"Euler's Totient Function φ(n) counts numbers\\nless than n that are coprime to n\", color=WHITE).scale(0.6)\n definition.next_to(title, DOWN, buff=0.5)\n self.play(Write(definition))\n self.wait(1)\n \n # Example with n=12\n self.play(FadeOut(definition))\n example_title = Text(\"Example: φ(12)\", color=ORANGE).scale(0.7)\n example_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(example_title))\n \n # Create grid of numbers 1 to 12\n numbers = VGroup()\n coprimes_to_12 = [1, 5, 7, 11] # Numbers coprime to 12\n \n for i in range(1, 13):\n color = ORANGE if i in coprimes_to_12 else WHITE\n number = Text(str(i), color=color).scale(0.6)\n row, col = divmod(i-1, 4)\n number.move_to((col - 1.5) * RIGHT + (row - 0.5) * DOWN)\n numbers.add(number)\n \n numbers.next_to(example_title, DOWN, buff=0.5)\n self.play(Create(numbers))\n \n # Show result\n result = Text(\"φ(12) = 4\", color=ORANGE).scale(0.7)\n result.next_to(numbers, DOWN, buff=0.5)\n self.play(Write(result))\n self.wait(1)\n \n # Clear for formula\n self.play(FadeOut(example_title), FadeOut(numbers), FadeOut(result))\n \n # Show formula\n formula = Text(\"φ(12) = 12 \\times (1-1/2) \\times (1-1/3) = 4\", color=ORANGE).scale(0.6)\n formula.next_to(title, DOWN, buff=1)\n self.play(Write(formula))\n self.wait(1)\n \n # Clear for graph\n self.play(FadeOut(formula))\n \n # Graph title\n graph_title = Text(\"Patterns in φ(n) for n = 1 to 20\", color=ORANGE).scale(0.7)\n graph_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(graph_title))\n \n # Create axes\n axes = Axes(\n x_range=[0, 21, 5],\n y_range=[0, 21, 5],\n axis_config={\"color\": WHITE},\n ).scale(0.7)\n axes.next_to(graph_title, DOWN, buff=0.5)\n \n x_label = Text(\"n\", color=WHITE).scale(0.5)\n x_label.next_to(axes.x_axis.get_end(), RIGHT, buff=0.2)\n \n y_label = Text(\"φ(n)\", color=WHITE).scale(0.5)\n y_label.next_to(axes.y_axis.get_end(), UP, buff=0.2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n \n # Pre-computed φ(n) values for n = 1 to 20\n phi_values = [\n 1, 1, 2, 2, 4, 2, 6, 4, 6, 4, 10, 4, 12, 6, 8, 8, 16, 6, 18, 8\n ]\n \n # Plot points and connect them\n dots = VGroup()\n lines = VGroup()\n \n for n in range(1, 21):\n dot = Dot(axes.c2p(n, phi_values[n-1]), color=ORANGE)\n dots.add(dot)\n \n if n > 1:\n line = Line(\n axes.c2p(n-1, phi_values[n-2]),\n axes.c2p(n, phi_values[n-1]),\n color=ORANGE\n )\n lines.add(line)\n \n self.play(Create(dots), Create(lines))\n \n # Highlight prime numbers\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n \n for p in primes:\n prime_dot = Dot(axes.c2p(p, phi_values[p-1]), color=BLUE, radius=0.1)\n prime_dots.add(prime_dot)\n \n prime_text = Text(\"For prime p, φ(p) = p-1\", color=BLUE).scale(0.6)\n prime_text.to_edge(DOWN, buff=1)\n \n self.play(Write(prime_text), Create(prime_dots))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(graph_title),\n FadeOut(axes),\n FadeOut(dots),\n FadeOut(lines),\n FadeOut(prime_text),\n FadeOut(prime_dots),\n FadeOut(x_label),\n FadeOut(y_label)\n )\n \n conclusion = Text(\n \"Euler's Totient Function reveals beautiful\\npatterns in number theory\",\n color=ORANGE\n ).scale(0.7)\n conclusion.next_to(title, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(title), FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersTotientFunction(Scene):\n def construct(self):\n # Set background color\n self.camera.background_color = \"#0C1445\" # Dark blue background\n \n # Introduction\n title = Text(\"Unveiling Patterns: Euler's Totient Function\", color=ORANGE).scale(0.8)\n self.play(Write(title))\n self.play(title.animate.to_edge(UP))\n \n # Definition\n definition = Text(\"Euler's Totient Function φ(n) counts numbers\\nless than n that are coprime to n\", color=WHITE).scale(0.6)\n definition.next_to(title, DOWN, buff=0.5)\n self.play(Write(definition))\n self.wait(1)\n \n # Example with n=12\n self.play(FadeOut(definition))\n example_title = Text(\"Example: φ(12)\", color=ORANGE).scale(0.7)\n example_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(example_title))\n \n # Create grid of numbers 1 to 12\n numbers = VGroup()\n coprimes_to_12 = [1, 5, 7, 11] # Numbers coprime to 12\n \n for i in range(1, 13):\n color = ORANGE if i in coprimes_to_12 else WHITE\n number = Text(str(i), color=color).scale(0.6)\n row, col = divmod(i-1, 4)\n number.move_to((col - 1.5) * RIGHT + (row - 0.5) * DOWN)\n numbers.add(number)\n \n numbers.next_to(example_title, DOWN, buff=0.5)\n self.play(Create(numbers))\n \n # Show result\n result = Text(\"φ(12) = 4\", color=ORANGE).scale(0.7)\n result.next_to(numbers, DOWN, buff=0.5)\n self.play(Write(result))\n self.wait(1)\n \n # Clear for formula\n self.play(FadeOut(example_title), FadeOut(numbers), FadeOut(result))\n \n # Show formula\n formula = Text(\"φ(12) = 12 \\times (1-1/2) \\times (1-1/3) = 4\", color=ORANGE).scale(0.6)\n formula.next_to(title, DOWN, buff=1)\n self.play(Write(formula))\n self.wait(1)\n \n # Clear for graph\n self.play(FadeOut(formula))\n \n # Graph title\n graph_title = Text(\"Patterns in φ(n) for n = 1 to 20\", color=ORANGE).scale(0.7)\n graph_title.next_to(title, DOWN, buff=0.5)\n self.play(Write(graph_title))\n \n # Create axes\n axes = Axes(\n x_range=[0, 21, 5],\n y_range=[0, 21, 5],\n axis_config={\"color\": WHITE},\n ).scale(0.7)\n axes.next_to(graph_title, DOWN, buff=0.5)\n \n x_label = Text(\"n\", color=WHITE).scale(0.5)\n x_label.next_to(axes.x_axis.get_end(), RIGHT, buff=0.2)\n \n y_label = Text(\"φ(n)\", color=WHITE).scale(0.5)\n y_label.next_to(axes.y_axis.get_end(), UP, buff=0.2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n \n # Pre-computed φ(n) values for n = 1 to 20\n phi_values = [\n 1, 1, 2, 2, 4, 2, 6, 4, 6, 4, 10, 4, 12, 6, 8, 8, 16, 6, 18, 8\n ]\n \n # Plot points and connect them\n dots = VGroup()\n lines = VGroup()\n \n for n in range(1, 21):\n dot = Dot(axes.c2p(n, phi_values[n-1]), color=ORANGE)\n dots.add(dot)\n \n if n > 1:\n line = Line(\n axes.c2p(n-1, phi_values[n-2]),\n axes.c2p(n, phi_values[n-1]),\n color=ORANGE\n )\n lines.add(line)\n \n self.play(Create(dots), Create(lines))\n \n # Highlight prime numbers\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n \n for p in primes:\n prime_dot = Dot(axes.c2p(p, phi_values[p-1]), color=BBLUE, radius=0.1)\n prime_dots.add(prime_dot)\n \n prime_text = Text(\"For prime p, φ(p) = p-1\", color=BLUE).scale(0.6)\n prime_text.to_edge(DOWN, buff=1)\n \n self.play(Write(prime_text), Create(prime_dots))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(graph_title),\n FadeOut(axes),\n FadeOut(dots),\n FadeOut(lines),\n FadeOut(prime_text),\n FadeOut(prime_dots),\n FadeOut(x_label),\n FadeOut(y_label)\n )\n \n conclusion = Text(\n \"Euler's Totient Function reveals beautiful\\npatterns in number theory\",\n color=ORANGE\n ).scale(0.7)\n conclusion.next_to(title, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(title), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'The Riemann Hypothesis' (Exploring the Infinite Mystery of Prime Discoveries through the Riemann Hypothesis): In what ways could we anchor a graphical timeline of prime discovery to the hypothesized critical line?\nVisual style guidance: Adopts a celestial and galaxy theme with a color palette incorporating midnight blues, deep purple, and bursts of bright star-like whites and soft orange hues designed to accentuate the galactic nature of both primes and complexity.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass RiemannHypothesisPrimeTimeline(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Exploring the Infinite Mystery of Prime Discoveries\")\n subtitle = Text(\"through the Riemann Hypothesis\")\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n \n # Create a starry background\n stars = VGroup()\n for _ in range(20):\n star = Dot(radius=0.03, color=WHITE)\n star.move_to([np.random.uniform(-6, 6), np.random.uniform(-3, 3), 0])\n stars.add(star)\n \n # Animation sequence\n self.play(FadeIn(stars))\n self.play(Write(title_group))\n self.wait(1)\n self.play(FadeOut(title_group), FadeOut(stars))\n \n # Key Concept 1: Timeline of primes\n timeline = Line(LEFT * 5, RIGHT * 5)\n timeline_label = Text(\"Timeline of Prime Discoveries\")\n timeline_label.next_to(timeline, UP)\n \n # Create prime numbers along the timeline\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n prime_labels = VGroup()\n \n for i, prime in enumerate(primes):\n x_pos = -5 + (10 * i / (len(primes) - 1))\n dot = Dot(point=[x_pos, 0, 0], color=ORANGE)\n label = Text(str(prime), color=ORANGE)\n label.next_to(dot, DOWN)\n prime_dots.add(dot)\n prime_labels.add(label)\n \n self.play(Create(timeline), Write(timeline_label))\n self.play(Create(prime_dots), Write(prime_labels))\n self.wait(2)\n \n # Key Concept 2: The Riemann Zeta Function and Critical Line\n zeta_eq = MathTex(r\"\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}\")\n critical_line_eq = MathTex(r\"s = \\frac{1}{2} + it\")\n zeta_eq.to_edge(UP)\n critical_line_eq.next_to(zeta_eq, DOWN)\n \n self.play(FadeOut(timeline_label))\n self.play(Write(zeta_eq), Write(critical_line_eq))\n self.wait(1)\n \n # Create a simple representation of the complex plane\n horizontal_line = Line(LEFT * 5, RIGHT * 5)\n vertical_line = Line(DOWN * 3, UP * 3)\n \n # Label the axes\n x_label = Text(\"Re(s)\")\n x_label.next_to(horizontal_line, RIGHT)\n y_label = Text(\"Im(s)\")\n y_label.next_to(vertical_line, UP)\n \n # Draw the critical line\n critical_line = Line(start=[0.5, -3, 0], end=[0.5, 3, 0], color=RED)\n critical_line_label = Text(\"Critical Line\", color=RED)\n critical_line_label.next_to(critical_line, UP)\n \n self.play(\n FadeOut(prime_dots),\n FadeOut(prime_labels),\n FadeOut(timeline),\n Create(horizontal_line),\n Create(vertical_line),\n Write(x_label),\n Write(y_label)\n )\n self.play(Create(critical_line), Write(critical_line_label))\n self.wait(2)\n \n # Key Concept 3: Connecting primes to the critical line\n prime_points = VGroup()\n prime_point_labels = VGroup()\n \n for i, prime in enumerate(primes):\n y_pos = -2.5 + (5 * i / (len(primes) - 1))\n point = Dot(point=[0.5, y_pos, 0], color=ORANGE)\n label = Text(str(prime), color=ORANGE)\n label.next_to(point, RIGHT)\n prime_points.add(point)\n prime_point_labels.add(label)\n \n self.play(Create(prime_points), Write(prime_point_labels))\n \n # Create waves emanating from prime points\n for point in prime_points:\n wave = Circle(radius=0.1, color=YELLOW).move_to(point.get_center())\n self.play(Create(wave), run_time=0.5)\n self.play(wave.animate.scale(3), wave.animate.set_opacity(0), run_time=0.5)\n \n # Conclusion\n conclusion = Text(\"The mystery of primes and the Riemann Hypothesis\")\n conclusion.to_edge(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(conclusion),\n FadeOut(prime_points),\n FadeOut(prime_point_labels),\n FadeOut(critical_line),\n FadeOut(critical_line_label),\n FadeOut(horizontal_line),\n FadeOut(vertical_line),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(zeta_eq),\n FadeOut(critical_line_eq)\n )\n \n # Final constellation of primes\n final_title = Text(\"The Celestial Map of Primes\")\n final_title.to_edge(UP)\n \n # Create stars in a constellation pattern\n constellation = VGroup()\n for i, prime in enumerate(primes):\n angle = 2 * PI * i / len(primes)\n radius = 2\n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n star = Dot(point=[x, y, 0], color=ORANGE)\n constellation.add(star)\n \n self.play(Write(final_title), Create(constellation))\n \n # Connect stars to form a constellation\n connections = VGroup()\n for i in range(len(primes) - 1):\n line = Line(\n constellation[i].get_center(),\n constellation[i+1].get_center(),\n color=WHITE\n )\n connections.add(line)\n \n self.play(Create(connections))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass RiemannHypothesisPrimeTimeline(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Exploring the Infinite Mystery of Prime Discoveries\")\n subtitle = Text(\"through the Riemann Hypothesis\")\n subtitle.next_to(title, DOWN)\n title_group = VGroup(title, subtitle)\n \n # Create a starry background\n stars = VGroup()\n for _ in range(20):\n star = Dot(radius=0.03, color=WHITE)\n star.move_to([np.random.uniform(-6, 6), np.random.uniform(-3, 3), 0])\n stars.add(star)\n \n # Animation sequence\n self.play(FadeIn(stars))\n self.play(Write(title_group))\n self.wait(1)\n self.play(FadeOut(title_group), FadeOut(stars))\n \n # Key Concept 1: Timeline of primes\n timeline = Line(LEFT * 5, RIGHT * 5)\n timeline_label = Text(\"Timeline of Prime Discoveries\")\n timeline_label.next_to(timeline, UP)\n \n # Create prime numbers along the timeline\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n prime_labels = VGroup()\n \n for i, prime in enumerate(primes):\n x_pos = -5 + (10 * i / (len(primes) - 1))\n dot = Dot(point=[x_pos, 0, 0], color=ORANGE)\n label = Text(str(prime), color=ORANGE)\n label.next_to(dot, DOWN)\n prime_dots.add(dot)\n prime_labels.add(label)\n \n self.play(Create(timeline), Write(timeline_label))\n self.play(Create(prime_dots), Write(prime_labels))\n self.wait(2)\n \n # Key Concept 2: The Riemann Zeta Function and Critical Line\n zeta_eq = MathText(r\"\\zeta(s) = \\sum_{n=1}^\\infty \\frac{1}{n^s}\")\n critical_line_eq = MathTex(r\"s = \\frac{1}{2} + it\")\n zeta_eq.to_edge(UP)\n critical_line_eq.next_to(zeta_eq, DOWN)\n \n self.play(FadeOut(timeline_label))\n self.play(Write(zeta_eq), Write(critical_line_eq))\n self.wait(1)\n \n # Create a simple representation of the complex plane\n horizontal_line = Line(LEFT * 5, RIGHT * 5)\n vertical_line = Line(DOWN * 3, UP * 3)\n \n # Label the axes\n x_label = Text(\"Re(s)\")\n x_label.next_to(horizontal_line, RIGHT)\n y_label = Text(\"Im(s)\")\n y_label.next_to(vertical_line, UP)\n \n # Draw the critical line\n critical_line = Line(start=[0.5, -3, 0], end=[0.5, 3, 0], color=RED)\n critical_line_label = Text(\"Critical Line\", color=RED)\n critical_line_label.next_to(critical_line, UP)\n \n self.play(\n FadeOut(prime_dots),\n FadeOut(prime_labels),\n FadeOut(timeline),\n Create(horizontal_line),\n Create(vertical_line),\n Write(x_label),\n Write(y_label)\n )\n self.play(Create(critical_line), Write(critical_line_label))\n self.wait(2)\n \n # Key Concept 3: Connecting primes to the critical line\n prime_points = VGroup()\n prime_point_labels = VGroup()\n \n for i, prime in enumerate(primes):\n y_pos = -2.5 + (5 * i / (len(primes) - 1))\n point = Dot(point=[0.5, y_pos, 0], color=ORANGE)\n label = Text(str(prime), color=ORANGE)\n label.next_to(point, RIGHT)\n prime_points.add(point)\n prime_point_labels.add(label)\n \n self.play(Create(prime_points), Write(prime_point_labels))\n \n # Create waves emanating from prime points\n for point in prime_points:\n wave = Circle(radius=0.1, color=YELLOW).move_to(point.get_center())\n self.play(Create(wave), run_time=0.5)\n self.play(wave.animate.scale(3), wave.animate.set_opacity(0), run_time=0.5)\n \n # Conclusion\n conclusion = Text(\"The mystery of primes and the Riemann Hypothesis\")\n conclusion.to_edge(DOWN)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(conclusion),\n FadeOut(prime_points),\n FadeOut(prime_point_labels),\n FadeOut(critical_line),\n FadeOut(critical_line_label),\n FadeOut(horizontal_line),\n FadeOut(vertical_line),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(zeta_eq),\n FadeOut(critical_line_eq)\n )\n \n # Final constellation of primes\n final_title = Text(\"The Celestial Map of Primes\")\n final_title.to_edge(UP)\n \n # Create stars in a constellation pattern\n constellation = VGroup()\n for i, prime in enumerate(primes):\n angle = 2 * PI * i / len(primes)\n radius = 2\n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n star = Dot(point=[x, y, 0], color=ORANGE)\n constellation.add(star)\n \n self.play(Write(final_title), Create(constellation))\n \n # Connect stars to form a constellation\n connections = VGroup()\n for i in range(len(primes) - 1):\n line = Line(\n constellation[i].get_center(),\n constellation[i+1].get_center(),\n color=WHITE\n )\n connections.add(line)\n \n self.play(Create(connections))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\n\nclass LinearTransformationAnimation(Scene):\n def construct(self):\n # --- Step 1: Initial Setup ---\n # Define the transformation matrix A\n matrix_A = [[2, 1], [1, 3]]\n matrix = Matrix(matrix_A)\n matrix.scale(0.8)\n matrix.to_edge(UP)\n \n # Add the explanatory label\n title = Text(\"Visualize a linear transformation\", font_size=36)\n title.next_to(matrix, UP, buff=0.5)\n \n # Display Matrix and Title\n self.play(Write(title), Write(matrix))\n self.wait(2) # Pause for viewers to read\n \n # --- Step 2: Scene Construction ---\n # Fade out intro to clear space for the grid\n self.play(FadeOut(title), FadeOut(matrix))\n self.wait(1)\n \n # Create the 2D grid (Cartesian plane)\n plane = NumberPlane(\n x_range=(-5, 5, 1),\n y_range=(-5, 5, 1),\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.5\n }\n )\n \n # Define the original vector v = (1, 2)\n v_end = np.array([1, 2, 0])\n \n # Create the yellow arrow for vector v\n vector_v = Arrow(\n start=ORIGIN, \n end=v_end, \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n )\n \n # Label for vector v\n label_v = MathTex(\"v\", color=YELLOW)\n label_v.next_to(vector_v.get_end(), UR, buff=0.1)\n \n # Add plane and vector to scene\n self.play(Create(plane), GrowArrow(vector_v), Write(label_v))\n self.wait(2) # Pause to establish the baseline\n \n # --- Step 3: Transformation Animation ---\n # Manim expects a 3x3 matrix for 2D transformations to handle the Z-axis\n transform_matrix = np.array([\n [2, 1, 0],\n [1, 3, 0],\n [0, 0, 1]\n ])\n \n # Animate the transformation of the plane and vector simultaneously\n self.play(\n plane.animate.apply_matrix(transform_matrix),\n vector_v.animate.apply_matrix(transform_matrix),\n run_time=4, # Slow playback for clarity\n rate_func=linear\n )\n \n # Update the label from \"v\" to \"Av\"\n # The transformed vector lands exactly at (4, 7)\n transformed_v_end = np.array([4, 7, 0])\n label_Av = MathTex(\"Av\", color=YELLOW)\n label_Av.next_to(transformed_v_end, UR, buff=0.1)\n \n self.play(Transform(label_v, label_Av))\n self.wait(2) # Pause to observe the result\n \n # --- Step 4: Conclusion ---\n # Clear all elements from the screen\n self.play(\n FadeOut(plane),\n FadeOut(vector_v),\n FadeOut(label_v)\n )\n self.wait(1)\n \n # Redraw the original matrix A to reinforce the concept\n final_matrix = Matrix(matrix_A)\n final_matrix.scale(1.5)\n final_matrix.move_to(ORIGIN)\n \n final_label = Text(\"A = [[2, 1], [1, 3]]\", font_size=30)\n final_label.next_to(final_matrix, DOWN, buff=0.5)\n \n self.play(Write(final_matrix), Write(final_label))\n self.wait(3) # Final pause\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass LinearTransformationAnimation(Scene):\n def construct(self):\n # --- Step 1: Initial Setup ---\n # Define the transformation matrix A\n matrix_A = [[2, 1], [1, 3]]\n matrix = Matrix(matrix_A)\n matrix.scale(0.8)\n matrix.to_edge(UP)\n \n # Add the explanatory label\n title = Text(\"Visualize a linear transformation\", font_size=36)\n title.next_to(matrix, UP, buff=0.5)\n \n # Display Matrix and Title\n self.play(Write(title), Write(matrix))\n self.wait(2) # Pause for viewers to read\n \n # --- Step 2: Scene Construction ---\n # Fade out intro to clear space for the grid\n self.play(FadeOut(title), FadeOut(matrix))\n self.wait(1)\n \n # Create the 2D grid (Cartesian plane)\n plane = NumberPlane(\n x_range=(-5, 5, 1),\n y_range=(-5, 5, 1),\n background_line_style={\n \"stroke_color\": BLUE_E,\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.5\n }\n )\n \n # Define the original vector v = (1, 2)\n v_end = np.array([1, 2, 0])\n \n # Create the yellow arrow for vector v\n vector_v = Arrow(\n start=ORIGIN, \n end=v_end, \n color=YELLOW, \n buff=0,\n max_tip_length_to_length_ratio=0.1\n )\n \n # Label for vector v\n label_v = MathText(\"v\", color=YELLOW)\n label_v.next_to(vector_v.get_end(), UR, buff=0.1)\n \n # Add plane and vector to scene\n self.play(Create(plane), GrowArrow(vector_v), Write(label_v))\n self.wait(2) # Pause to establish the baseline\n \n # --- Step 3: Transformation Animation ---\n # Manim expects a 3x3 matrix for 2D transformations to handle the Z-axis\n transform_matrix = np.array([\n [2, 1, 0],\n [1, 3, 0],\n [0, 0, 1]\n ])\n \n # Animate the transformation of the plane and vector simultaneously\n self.play(\n plane.animate.apply_matrix(transform_matrix),\n vector_v.animate.apply_matrix(transform_matrix),\n run_time=4, # Slow playback for clarity\n rate_func=linear\n )\n \n # Update the label from \"v\" to \"Av\"\n # The transformed vector lands exactly at (4, 7)\n transformed_v_end = np.array([4, 7, 0])\n label_Av = MathTex(\"Av\", color=YELLOW)\n label_Av.next_to(transformed_v_end, UR, buff=0.1)\n \n self.play(Transform(label_v, label_Av))\n self.wait(2) # Pause to observe the result\n \n # --- Step 4: Conclusion ---\n # Clear all elements from the screen\n self.play(\n FadeOut(plane),\n FadeOut(vector_v),\n FadeOut(label_v)\n )\n self.wait(1)\n \n # Redraw the original matrix A to reinforce the concept\n final_matrix = Matrix(matrix_A)\n final_matrix.scale(1.5)\n final_matrix.move_to(ORIGIN)\n \n final_label = Text(\"A = [[2, 1], [1, 3]]\", font_size=30)\n final_label.next_to(final_matrix, DOWN, buff=0.5)\n \n self.play(Write(final_matrix), Write(final_label))\n self.wait(3) # Final pause\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 brief animation where text transforms into the word \"GrowArrow\" and shifts upwards, followed by an arrow that appears as if it's growing and then suddenly disappears?", "chosen": "```python\nfrom manim import *\n\nclass GrowArrowScene(Scene):\n def construct(self):\n # 1. Text Transformation: Transform initial text into the word \"GrowArrow\"\n initial_text = Text(\"Start\")\n target_text = Text(\"GrowArrow\")\n \n self.play(Write(initial_text))\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 2. Upward Shift: Shift the transformed text upwards\n self.play(target_text.animate.shift(UP * 2))\n \n # 3. Arrow Appearance: Create an arrow and animate it growing\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow))\n \n # 4. Sudden Disappearance: Make the arrow suddenly vanish\n self.play(FadeOut(arrow, run_time=0.1))\n \n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass GrowArrowScene(Scene):\n def construct(self):\n # 1. Text Transformation: Transform initial text into the word \"GrowArrow\"\n initial_text = Text(\"Start\")\n target_text = Text(\"GrowArrow\")\n \n self.play(Write(initial_text))\n self.play(ReplacementTransform(initial_text, target_text))\n \n # 2. Upward Shift: Shift the transformed text upwards\n self.play(target_text.animate.shift(UP * 2))\n \n # 3. Arrow Appearance: Create an arrow and animate it growing\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BBLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow))\n \n # 4. Sudden Disappearance: Make the arrow suddenly vanish\n self.play(FadeOut(arrow, run_time=0.1))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 evaluate a double integral step by step. The double integral I want to focus on is the integration of (x^2 + y^2) over the region bounded by y=-1 to y=1 and x=0 to x=1. The animation should first display the integral, then show the integration with respect to y, replace the solved part with the new expression, and then do the same for the integration with respect to x. After each step, the animation should pause to give viewers time to understand before proceeding. At the final stage, the animation should display the evaluated result of the integral. Can you create such an animation sequence for me?", "chosen": "```python\nfrom manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Initial Integral\n # ------------------------------------------------------------------\n initial_integral = MathTex(\n r\"\\int_{0}^{1} \\int_{-1}^{1} (x^2 + y^2) \\, dy \\, dx\"\n ).scale(1.2)\n\n self.play(Write(initial_integral))\n self.wait(2) # Pause for viewers to read the initial problem\n\n # ------------------------------------------------------------------\n # Step 2: Integrate with Respect to y\n # ------------------------------------------------------------------\n step_label = Text(\"Integrate with respect to y\", font_size=36)\n step_label.to_edge(UP)\n self.play(Write(step_label))\n self.wait(0.5)\n\n # Visually demonstrate the integration step regarding variable y\n antiderivative_y = MathTex(\n r\"\\int_{0}^{1} \\left[ x^2y + \\frac{y^3}{3} \\right]_{-1}^{1} \\, dx\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(initial_integral, antiderivative_y))\n self.wait(1)\n\n # Replace the solved portion with the resulting intermediate expression\n intermediate_expr = MathTex(\n r\"\\int_{0}^{1} \\left( 2x^2 + \\frac{2}{3} \\right) \\, dx\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(antiderivative_y, intermediate_expr))\n self.wait(3) # Pause to allow viewers to process the step\n\n # ------------------------------------------------------------------\n # Step 3: Integrate with Respect to x\n # ------------------------------------------------------------------\n step_label_2 = Text(\"Integrate with respect to x\", font_size=36)\n step_label_2.to_edge(UP)\n self.play(Transform(step_label, step_label_2))\n self.wait(0.5)\n\n # Visually demonstrate the integration step regarding variable x\n antiderivative_x = MathTex(\n r\"\\left[ \\frac{2x^3}{3} + \\frac{2}{3}x \\right]_{0}^{1}\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(intermediate_expr, antiderivative_x))\n self.wait(1)\n\n # Replace the solved portion with the final evaluated result\n final_result = MathTex(\n r\"\\frac{4}{3}\"\n ).scale(1.5)\n\n self.play(ReplacementTransform(antiderivative_x, final_result))\n self.wait(2) # Pause to allow viewers to process the step\n\n # ------------------------------------------------------------------\n # Step 4: Final Result\n # ------------------------------------------------------------------\n final_label = Text(\"Final Result\", font_size=36, color=GREEN)\n final_label.to_edge(UP)\n self.play(Transform(step_label, final_label))\n\n # Highlight the final numerical value of the integral\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n self.play(Create(box), final_result.animate.set_color(GREEN))\n self.wait(3) # Final pause to conclude the animation\n```", "rejected": "```python\nfrom manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Display the Initial Integral\n # ------------------------------------------------------------------\n initial_integral = MathText(\n r\"\\int_{0}^{1} \\int_{-1}^{1} (x^2 + y^2) \\, dy \\, dx\"\n ).scale(1.2)\n\n self.play(Write(initial_integral))\n self.wait(2) # Pause for viewers to read the initial problem\n\n # ------------------------------------------------------------------\n # Step 2: Integrate with Respect to y\n # ------------------------------------------------------------------\n step_label = Text(\"Integrate with respect to y\", font_size=36)\n step_label.to_edge(UP)\n self.play(Write(step_label))\n self.wait(0.5)\n\n # Visually demonstrate the integration step regarding variable y\n antiderivative_y = MathTex(\n r\"\\int_{0}^{1} \\left[ x^2y + \\frac{y^3}{3} \\right]_{-1}^{1} \\, dx\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(initial_integral, antiderivative_y))\n self.wait(1)\n\n # Replace the solved portion with the resulting intermediate expression\n intermediate_expr = MathTex(\n r\"\\int_{0}^{1} \\left( 2x^2 + \\frac{2}{3} \\right) \\, dx\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(antiderivative_y, intermediate_expr))\n self.wait(3) # Pause to allow viewers to process the step\n\n # ------------------------------------------------------------------\n # Step 3: Integrate with Respect to x\n # ------------------------------------------------------------------\n step_label_2 = Text(\"Integrate with respect to x\", font_size=36)\n step_label_2.to_edge(UP)\n self.play(Transform(step_label, step_label_2))\n self.wait(0.5)\n\n # Visually demonstrate the integration step regarding variable x\n antiderivative_x = MathTex(\n r\"\\left[ \\frac{2x^3}{3} + \\frac{2}{3}x \\right]_{0}^{1}\"\n ).scale(1.2)\n\n self.play(ReplacementTransform(intermediate_expr, antiderivative_x))\n self.wait(1)\n\n # Replace the solved portion with the final evaluated result\n final_result = MathTex(\n r\"\\frac{4}{3}\"\n ).scale(1.5)\n\n self.play(ReplacementTransform(antiderivative_x, final_result))\n self.wait(2) # Pause to allow viewers to process the step\n\n # ------------------------------------------------------------------\n # Step 4: Final Result\n # ------------------------------------------------------------------\n final_label = Text(\"Final Result\", font_size=36, color=GREEN)\n final_label.to_edge(UP)\n self.play(Transform(step_label, final_label))\n\n # Highlight the final numerical value of the integral\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n self.play(Create(box), final_result.animate.set_color(GREEN))\n self.wait(3) # Final pause to conclude the animation\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 10-second Manim scene that shows a simple electron excitation in a Bohr-like atom. Animate one electron moving from an inner orbit to an outer orbit and add an arrow for absorbed energy.\n- Act 2: 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 3: Here’s an enhanced version of the animation that retains all the original features while adding significant new elements: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0127(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_electronexcitation()\n self.clear_stage()\n self.act_2_triangletextanimation()\n self.clear_stage()\n self.act_3_enhancedsinewave()\n\n def act_1_electronexcitation(self):\n title = Text(\"Electron Excitation\", font_size=36).to_edge(UP)\n nucleus = Circle(radius=0.48, stroke_color=RED_D, fill_color=RED_E, fill_opacity=0.32)\n shell_inner = Circle(radius=1.25, color=BLUE_C)\n shell_outer = Circle(radius=2.15, color=TEAL_C)\n electron = Dot(shell_inner.point_at_angle(PI / 4), radius=0.08, color=YELLOW)\n static_electron = Dot(shell_outer.point_at_angle(5 * PI / 4), radius=0.08, color=YELLOW)\n energy_arrow = Arrow(LEFT * 3.2 + DOWN * 1.6, LEFT * 1.4 + DOWN * 0.25, color=ORANGE, buff=0)\n energy_text = Text(\"energy in\", font_size=22, color=ORANGE).next_to(energy_arrow, DOWN, buff=0.15)\n self.play(FadeIn(title), FadeIn(nucleus), run_time=1.5)\n self.play(Create(shell_inner), Create(shell_outer), FadeIn(electron), FadeIn(static_electron), run_time=2.5)\n self.play(GrowArrow(energy_arrow), FadeIn(energy_text), run_time=1.5)\n self.play(MoveAlongPath(electron, ArcBetweenPoints(shell_inner.point_at_angle(PI / 4), shell_outer.point_at_angle(PI / 3), angle=-PI / 3)), run_time=3)\n self.play(Indicate(shell_outer, color=TEAL_A), run_time=0.8)\n self.wait(1)\n\n def act_2_triangletextanimation(self):\n triangle = Triangle(color=BLUE, fill_opacity=0.5)\n self.play(Create(triangle))\n \n # Rotate exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI), run_time=1.5)\n \n # Make the triangle disappear from the scene\n self.play(FadeOut(triangle))\n self.wait(0.5)\n\n # --- 2. Text Transformation ---\n # Define initial text positioned lower on the screen\n initial_text = Text(\"Initial Text\", font_size=36).shift(DOWN * 2)\n \n # Define target text positioned higher on the screen\n target_text = Text(\"animate.rotate\", font_size=36).shift(UP * 1)\n \n # Display the initial text\n self.play(Write(initial_text))\n \n # Move the text upwards and transform it into the specific string\n # ReplacementTransform smoothly handles both the position change and content morph\n self.play(ReplacementTransform(initial_text, target_text), run_time=2)\n \n # Brief pause at the end\n self.wait(1)\n\n def act_3_enhancedsinewave(self):\n axes = Axes(\n x_range=[-3.5, 3.5, 1],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"color\": BLUE},\n )\n x_label = axes.get_x_axis_label(\"x\").shift(DOWN * 0.5)\n y_label = axes.get_y_axis_label(\"y\").shift(LEFT * 0.5)\n\n # Animate axes and labels\n self.play(Create(axes), run_time=2)\n self.play(Write(x_label), Write(y_label), run_time=1)\n self.wait(0.5)\n\n # Create sine wave\n sine_graph = axes.plot(lambda x: np.sin(x), color=PURPLE)\n formula = MathTex(\"f(x) = \\\\sin(x)\").to_edge(UP).set_color(YELLOW)\n\n # Draw sine wave with glowing trail\n self.play(Write(formula))\n self.play(\n Create(sine_graph, run_time=3),\n sine_graph.animate.set_stroke(width=8, opacity=0.8).set_glow(1),\n )\n self.wait()\n\n # Transform into discrete points\n dots = VGroup(*[\n Dot(axes.c2p(x, np.sin(x)), color=RED, radius=0.05)\n for x in np.arange(-3.5, 3.5, 0.5)\n ])\n self.play(Transform(sine_graph, dots), run_time=2)\n self.wait(0.5)\n self.play(Transform(dots, sine_graph), run_time=2)\n self.wait()\n\n # Add amplitude marker\n peak = axes.c2p(np.pi/2, 1)\n amplitude_line = DashedLine(\n axes.c2p(np.pi/2, 0),\n peak,\n color=GREEN,\n )\n amplitude_label = MathTex(\"A = 1\").next_to(peak, UP)\n explanation = Tex(\"The sine function oscillates between -1 and 1.\").to_edge(DOWN)\n\n self.play(Create(amplitude_line), Write(amplitude_label))\n self.play(FadeIn(explanation))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0127(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_electronexcitation()\n self.clear_stage()\n self.act_2_triangletextanimation()\n self.clear_stage()\n self.act_3_enhancedsinewave()\n\n def act_1_electronexcitation(self):\n title = Text(\"Electron Excitation\", font_size=36).to_edge(UP)\n nucleus = Circle(radius=0.48, stroke_color=RED_D, fill_color=RED_E, fill_opacity=0.32)\n shell_inner = Circle(radius=1.25, color=BLUE_C)\n shell_outer = Circle(radius=2.15, color=TEAL_C)\n electron = Dot(shell_inner.point_at_angle(PI / 4), radius=0.08, color=YELLOW)\n static_electron = Dot(shell_outer.point_at_angle(5 * PI / 4), radius=0.08, color=YELLOW)\n energy_arrow = Arrow(LEFT * 3.2 + DOWN * 1.6, LEFT * 1.4 + DOWN * 0.25, color=ORANGE, buff=0)\n energy_text = Text(\"energy in\", font_size=22, color=ORANGE).next_to(energy_arrow, DOWN, buff=0.15)\n self.play(FadeIn(title), FadeIn(nucleus), run_time=1.5)\n self.play(Create(shell_inner), Create(shell_outer), FadeIn(electron), FadeIn(static_electron), run_time=2.5)\n self.play(GrowArrow(energy_arrow), FadeIn(energy_text), run_time=1.5)\n self.play(MoveAlongPath(electron, ArcBetweenPoints(shell_inner.point_at_angle(PI / 4), shell_outer.point_at_angle(PI / 3), angle=-PI / 3)), run_time=3)\n self.play(Indicate(shell_outer, color=TEAL_A), run_time=0.8)\n self.wait(1)\n\n def act_2_triangletextanimation(self):\n triangle = Triangle(color=BLUE, fill_opacity=0.5)\n self.play(Create(triangle))\n \n # Rotate exactly 180 degrees (PI radians)\n self.play(Rotate(triangle, angle=PI), run_time=1.5)\n \n # Make the triangle disappear from the scene\n self.play(FadeOut(triangle))\n self.wait(0.5)\n\n # --- 2. Text Transformation ---\n # Define initial text positioned lower on the screen\n initial_text = Text(\"Initial Text\", font_size=36).shift(DOWN * 2)\n \n # Define target text positioned higher on the screen\n target_text = Text(\"animate.rotate\", font_size=36).shift(UP * 1)\n \n # Display the initial text\n self.play(Write(initial_text))\n \n # Move the text upwards and transform it into the specific string\n # ReplacementTransform smoothly handles both the position change and content morph\n self.play(ReplacementTransform(initial_text, target_text), run_time=2)\n \n # Brief pause at the end\n self.wait(1)\n\n def act_3_enhancedsinewave(self):\n axes = Axes(\n x_range=[-3.5, 3.5, 1],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"color\": BLUE},\n )\n x_label = axes.get_x_axis_label(\"x\").shift(DOWN * 0.5)\n y_label = axes.get_y_axis_label(\"y\").shift(LEFT * 0.5)\n\n # Animate axes and labels\n self.play(Create(axes), run_time=2)\n self.play(Write(x_label), Write(y_label), run_time=1)\n self.wait(0.5)\n\n # Create sine wave\n sine_graph = axes.plot(lambda x: np.sin(x), color=PURPLE)\n formula = MathText(\"f(x) = \\\\sin(x)\").to_edge(UP).set_color(YELLOW)\n\n # Draw sine wave with glowing trail\n self.play(Write(formula))\n self.play(\n Create(sine_graph, run_time=3),\n sine_graph.animate.set_stroke(width=8, opacity=0.8).set_glow(1),\n )\n self.wait()\n\n # Transform into discrete points\n dots = VGroup(*[\n Dot(axes.c2p(x, np.sin(x)), color=RED, radius=0.05)\n for x in np.arange(-3.5, 3.5, 0.5)\n ])\n self.play(Transform(sine_graph, dots), run_time=2)\n self.wait(0.5)\n self.play(Transform(dots, sine_graph), run_time=2)\n self.wait()\n\n # Add amplitude marker\n peak = axes.c2p(np.pi/2, 1)\n amplitude_line = DashedLine(\n axes.c2p(np.pi/2, 0),\n peak,\n color=GREEN,\n )\n amplitude_label = MathTex(\"A = 1\").next_to(peak, UP)\n explanation = Tex(\"The sine function oscillates between -1 and 1.\").to_edge(DOWN)\n\n self.play(Create(amplitude_line), Write(amplitude_label))\n self.play(FadeIn(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 demonstrating the concept of homology groups in algebraic topology. Visualize cycles, boundaries, and homology classes, step by step.", "chosen": "```python\nfrom manim import *\n\nclass HomologyGroups(Scene):\n def construct(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```", "rejected": "```python\nfrom manim import *\n\nclass HomologyGroups(Scene):\n def construct(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(BBLUE)\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Arithmetic Logic Instructions (e.g., `ADD R1, R2, R3`):\n- Core Path: Register file read port $\\rightarrow$ ALU operation $\\rightarrow$ Register file write port;\n- Characteristics: Bypasses the data memory and directly updates the destination register using the ALU result.\n\n\nContextual location of this section (from highest level to current):\n# Fundamentals of Single-Cycle Processor Design — Course Notes\n## Data Path Requirements from an Instruction Classification Perspective\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ArithmeticLogicInstruction(Scene):\n\n def construct(self):\n title = Tex('\\\\textbf{Arithmetic Logic Instructions (e.g., ADD R1, R2, R3)}', font_size=40)\n title.to_edge(UP)\n reg_file = Rectangle(width=2, height=3, color=BLUE).shift(LEFT * 4 + UP * 0.5)\n reg_text = Text('Register\\nFile', font_size=24).move_to(reg_file)\n alu = Polygon([-0.8, 1.2, 0], [0.8, 0.5, 0], [0.8, -0.5, 0], [-0.8, -1.2, 0], [-0.8, -0.3, 0], [-0.3, 0, 0], [-0.8, 0.3, 0], color=YELLOW).shift(UP * 0.5)\n alu_text = Text('ALU', font_size=24).move_to(alu).shift(RIGHT * 0.1)\n data_mem = Rectangle(width=2, height=3, color=GRAY).shift(RIGHT * 4 + UP * 0.5)\n dm_text = Text('Data\\nMemory', font_size=24, color=GRAY).move_to(data_mem)\n components = VGroup(reg_file, reg_text, alu, alu_text, data_mem, dm_text)\n rf_out_1 = reg_file.get_right() + UP * 0.6\n rf_out_2 = reg_file.get_right() + DOWN * 0.6\n alu_in_1 = alu.get_left() + UP * 0.6\n alu_in_2 = alu.get_left() + DOWN * 0.6\n arrow_read1 = Arrow(rf_out_1, alu_in_1, buff=0.1, color=GREEN)\n arrow_read2 = Arrow(rf_out_2, alu_in_2, buff=0.1, color=GREEN)\n read_label = Text('Read Ports', font_size=16, color=GREEN).next_to(arrow_read1, UP, buff=0.1)\n alu_out = alu.get_right()\n node1 = alu_out + RIGHT * 0.5\n node2 = node1 + UP * 1.8\n node3 = [reg_file.get_x(), node2[1], 0]\n rf_in = reg_file.get_top()\n path_write = VGroup(Line(alu_out, node1, color=ORANGE), Line(node1, node2, color=ORANGE), Line(node2, node3, color=ORANGE), Arrow(node3, rf_in, buff=0.1, color=ORANGE))\n write_label = Text('Write Port', font_size=16, color=ORANGE).next_to(path_write[2], UP, buff=0.1)\n bypass_line = DashedLine(node1, data_mem.get_left(), color=GRAY)\n cross_dm = Cross(data_mem, stroke_color=RED, stroke_width=6).scale(0.8)\n bypass_label = Text('Bypassed', font_size=16, color=RED).next_to(data_mem, DOWN)\n bullet1 = Tex('$\\\\bullet$ \\\\textbf{Core Path:} Register file read port $\\\\rightarrow$ ALU operation $\\\\rightarrow$ Register file write port')\n bullet2 = Tex('$\\\\bullet$ \\\\textbf{Characteristics:} Bypasses the data memory and directly updates\\\\\\\\the destination register using the ALU result.')\n bullets = VGroup(bullet1, bullet2).arrange(DOWN, aligned_edge=LEFT, buff=0.4).scale(0.7).to_edge(DOWN).shift(UP * 0.2)\n self.play(Write(title))\n self.play(FadeIn(components))\n self.wait(0.5)\n self.play(GrowArrow(arrow_read1), GrowArrow(arrow_read2), FadeIn(read_label))\n self.wait(0.5)\n self.play(Indicate(alu, color=YELLOW, scale_factor=1.1))\n self.wait(0.5)\n self.play(Create(path_write), FadeIn(write_label))\n self.wait(0.5)\n self.play(Write(bullet1))\n self.wait(1)\n self.play(Create(bypass_line))\n self.play(Create(cross_dm), FadeIn(bypass_label))\n self.wait(0.5)\n self.play(Write(bullet2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ArithmeticLogicInstruction(Scene):\n\n def construct(self):\n title = Tex('\\\\textbf{Arithmetic Logic Instructions (e.g., ADD R1, R2, R3)}', font_size=40)\n title.to_edge(UP)\n reg_file = Rectangle(width=2, height=3, color=BBLUE).shift(LEFT * 4 + UP * 0.5)\n reg_text = Text('Register\\nFile', font_size=24).move_to(reg_file)\n alu = Polygon([-0.8, 1.2, 0], [0.8, 0.5, 0], [0.8, -0.5, 0], [-0.8, -1.2, 0], [-0.8, -0.3, 0], [-0.3, 0, 0], [-0.8, 0.3, 0], color=YELLOW).shift(UP * 0.5)\n alu_text = Text('ALU', font_size=24).move_to(alu).shift(RIGHT * 0.1)\n data_mem = Rectangle(width=2, height=3, color=GRAY).shift(RIGHT * 4 + UP * 0.5)\n dm_text = Text('Data\\nMemory', font_size=24, color=GRAY).move_to(data_mem)\n components = VGroup(reg_file, reg_text, alu, alu_text, data_mem, dm_text)\n rf_out_1 = reg_file.get_right() + UP * 0.6\n rf_out_2 = reg_file.get_right() + DOWN * 0.6\n alu_in_1 = alu.get_left() + UP * 0.6\n alu_in_2 = alu.get_left() + DOWN * 0.6\n arrow_read1 = Arrow(rf_out_1, alu_in_1, buff=0.1, color=GREEN)\n arrow_read2 = Arrow(rf_out_2, alu_in_2, buff=0.1, color=GREEN)\n read_label = Text('Read Ports', font_size=16, color=GREEN).next_to(arrow_read1, UP, buff=0.1)\n alu_out = alu.get_right()\n node1 = alu_out + RIGHT * 0.5\n node2 = node1 + UP * 1.8\n node3 = [reg_file.get_x(), node2[1], 0]\n rf_in = reg_file.get_top()\n path_write = VGroup(Line(alu_out, node1, color=ORANGE), Line(node1, node2, color=ORANGE), Line(node2, node3, color=ORANGE), Arrow(node3, rf_in, buff=0.1, color=ORANGE))\n write_label = Text('Write Port', font_size=16, color=ORANGE).next_to(path_write[2], UP, buff=0.1)\n bypass_line = DashedLine(node1, data_mem.get_left(), color=GRAY)\n cross_dm = Cross(data_mem, stroke_color=RED, stroke_width=6).scale(0.8)\n bypass_label = Text('Bypassed', font_size=16, color=RED).next_to(data_mem, DOWN)\n bullet1 = Tex('$\\\\bullet$ \\\\textbf{Core Path:} Register file read port $\\\\rightarrow$ ALU operation $\\\\rightarrow$ Register file write port')\n bullet2 = Tex('$\\\\bullet$ \\\\textbf{Characteristics:} Bypasses the data memory and directly updates\\\\\\\\the destination register using the ALU result.')\n bullets = VGroup(bullet1, bullet2).arrange(DOWN, aligned_edge=LEFT, buff=0.4).scale(0.7).to_edge(DOWN).shift(UP * 0.2)\n self.play(Write(title))\n self.play(FadeIn(components))\n self.wait(0.5)\n self.play(GrowArrow(arrow_read1), GrowArrow(arrow_read2), FadeIn(read_label))\n self.wait(0.5)\n self.play(Indicate(alu, color=YELLOW, scale_factor=1.1))\n self.wait(0.5)\n self.play(Create(path_write), FadeIn(write_label))\n self.wait(0.5)\n self.play(Write(bullet1))\n self.wait(1)\n self.play(Create(bypass_line))\n self.play(Create(cross_dm), FadeIn(bypass_label))\n self.wait(0.5)\n self.play(Write(bullet2))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Loops in Programs\n- In computer operations, \"loop\" is a core **control flow structure**;\n- It allows programs to use a minimal number of code lines to drive the CPU to perform tens of thousands of calculations;\n- One of the essences of programming is that humans define the rules (loop design) while computers handle the tedious repetitive work.\n\n\nThe context location of this section (from highest to current level):\n# Chapter 4 Loop Program Design\n## What is a Loop: Starting with 1+2+...+100\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass LoopsInPrograms(Scene):\n\n def construct(self):\n title = Text('Loops in Programs', 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 blist = BulletedList('Core control flow structure', 'Minimal code lines drive massive CPU calculations', 'Humans design rules, computers handle repetitive work', font_size=32)\n blist.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(blist), run_time=3)\n code_line1 = Text('for i in range(1, 101):', font_size=24)\n code_line2 = Text(' total += i', font_size=24)\n code_group = VGroup(code_line1, code_line2).arrange(DOWN, aligned_edge=LEFT)\n code_box = SurroundingRectangle(code_group, color=BLUE, buff=0.3)\n human_label = Text('Human Rule', font_size=22, color=BLUE).next_to(code_box, UP, buff=0.2)\n code_node = VGroup(code_group, code_box, human_label)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE)\n calc_text = MathTex('1 + 2 + ... + 100', font_size=36)\n calc_box = SurroundingRectangle(calc_text, color=GREEN, buff=0.3)\n computer_label = Text('Computer Repetition', font_size=22, color=GREEN).next_to(calc_box, UP, buff=0.2)\n calc_node = VGroup(calc_text, calc_box, computer_label)\n bottom_group = VGroup(code_node, arrow, calc_node).arrange(RIGHT, buff=0.8)\n bottom_group.next_to(blist, DOWN, buff=1.2)\n self.play(FadeIn(code_node), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=0.8)\n self.play(FadeIn(calc_node), 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 LoopsInPrograms(Scene):\n\n def construct(self):\n title = Text('Loops in Programs', 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 blist = BulletedList('Core control flow structure', 'Minimal code lines drive massive CPU calculations', 'Humans design rules, computers handle repetitive work', font_size=32)\n blist.next_to(title_group, DOWN, buff=0.8)\n self.play(Write(blist), run_time=3)\n code_line1 = Text('for i in range(1, 101):', font_size=24)\n code_line2 = Text(' total += i', font_size=24)\n code_group = VGroup(code_line1, code_line2).arrange(DOWN, aligned_edge=LEFT)\n code_box = SurroundingRectangle(code_group, color=BBLUE, buff=0.3)\n human_label = Text('Human Rule', font_size=22, color=BLUE).next_to(code_box, UP, buff=0.2)\n code_node = VGroup(code_group, code_box, human_label)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE)\n calc_text = MathTex('1 + 2 + ... + 100', font_size=36)\n calc_box = SurroundingRectangle(calc_text, color=GREEN, buff=0.3)\n computer_label = Text('Computer Repetition', font_size=22, color=GREEN).next_to(calc_box, UP, buff=0.2)\n calc_node = VGroup(calc_text, calc_box, computer_label)\n bottom_group = VGroup(code_node, arrow, calc_node).arrange(RIGHT, buff=0.8)\n bottom_group.next_to(blist, DOWN, buff=1.2)\n self.play(FadeIn(code_node), run_time=1.5)\n self.play(GrowArrow(arrow), run_time=0.8)\n self.play(FadeIn(calc_node), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates several positioning techniques on a 2D plane. Firstly, can you show a red dot and then place a green dot to its upper right side? Next, I would like to see an orange square slide up and rightward into a specific position on the plane. After that, can we have a purple circle that moves directly to a chosen location, somewhere towards the bottom left of the plane? Finally, let's introduce three semi-transparent circles—one red, one yellow, and one orange—and have each one line up with the orange square in a different way: the red one aligns to its top, the yellow one to its right side, and the orange one to its top right corner. For the background, I would love to see all of this happening on a grid, like a mathematical coordinate plane.", "chosen": "```python\nfrom manim import *\n\nclass PositioningTechniques(Scene):\n def construct(self):\n # --- 1. Setup Grid & Axes ---\n config.background_color = WHITE\n grid = NumberPlane(\n x_range=(-5, 5, 1),\n y_range=(-5, 5, 1),\n background_line_style={\n \"stroke_color\": \"#D3D3D3\",\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.6\n }\n )\n axes = Axes(\n x_range=(-5, 5),\n y_range=(-5, 5),\n axis_config={\"color\": \"#333333\", \"include_tip\": True}\n )\n self.add(grid, axes)\n\n # --- 2. Initial Placement ---\n red_dot = Dot(color=\"#E63946\", radius=0.2).move_to([-2, -1, 0])\n self.play(FadeIn(red_dot), run_time=1)\n self.wait(1)\n\n green_dot = Dot(color=\"#2A9D8F\", radius=0.2).move_to([1, 2, 0])\n self.play(Create(green_dot), run_time=1)\n self.wait(1)\n\n # --- 3. Sliding Motion (Orange Square) ---\n orange_square = Square(side_length=1.5, color=\"#F4A261\", fill_opacity=0.8)\n orange_square.move_to([-3, -3, 0]) # Start Position\n \n self.play(\n orange_square.animate.move_to([2, -2, 0]),\n run_time=3,\n rate_func=smooth # Ease-in-out equivalent\n )\n self.wait(0.5)\n\n # --- 4. Direct Movement (Purple Circle) ---\n purple_circle = Circle(radius=0.5, color=\"#9D4EDD\", fill_opacity=0.8)\n purple_circle.move_to([0, 0, 0]) # Start from center\n \n self.play(\n purple_circle.animate.move_to([-4, -4, 0]),\n run_time=2,\n rate_func=linear\n )\n self.wait(0.5)\n\n # --- 5. Alignment Sequence ---\n # Semi-transparent circles aligning to the Orange Square at [2, -2]\n # Square side length is 1.5, so half is 0.75\n \n # Red Circle: Align to Top Edge\n align_red = Circle(radius=0.4, color=\"#E63946\", fill_opacity=0.6)\n target_red = [2, -1.25, 0] \n \n # Yellow Circle: Align to Right Edge\n align_yellow = Circle(radius=0.4, color=\"#E9C46A\", fill_opacity=0.6)\n target_yellow = [2.75, -2, 0]\n\n # Orange Circle: Align to Top-Right Corner\n align_orange = Circle(radius=0.4, color=\"#F4A261\", fill_opacity=0.6)\n target_orange = [2.75, -1.25, 0]\n\n self.play(\n FadeIn(align_red),\n align_red.animate.move_to(target_red),\n FadeIn(align_yellow),\n align_yellow.animate.move_to(target_yellow),\n FadeIn(align_orange),\n align_orange.animate.move_to(target_orange),\n run_time=3\n )\n\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PositioningTechniques(Scene):\n def construct(self):\n # --- 1. Setup Grid & Axes ---\n config.background_color = WHITE\n grid = NumberPlane(\n x_range=(-5, 5, 1),\n y_range=(-5, 5, 1),\n background_line_style={\n \"stroke_color\": \"#D3D3D3\",\n \"stroke_width\": 2,\n \"stroke_opacity\": 0.6\n }\n )\n axes = Axes(label_font_size=24, \n x_range=(-5, 5),\n y_range=(-5, 5),\n axis_config={\"color\": \"#333333\", \"include_tip\": True}\n )\n self.add(grid, axes)\n\n # --- 2. Initial Placement ---\n red_dot = Dot(color=\"#E63946\", radius=0.2).move_to([-2, -1, 0])\n self.play(FadeIn(red_dot), run_time=1)\n self.wait(1)\n\n green_dot = Dot(color=\"#2A9D8F\", radius=0.2).move_to([1, 2, 0])\n self.play(Create(green_dot), run_time=1)\n self.wait(1)\n\n # --- 3. Sliding Motion (Orange Square) ---\n orange_square = Square(side_length=1.5, color=\"#F4A261\", fill_opacity=0.8)\n orange_square.move_to([-3, -3, 0]) # Start Position\n \n self.play(\n orange_square.animate.move_to([2, -2, 0]),\n run_time=3,\n rate_func=smooth # Ease-in-out equivalent\n )\n self.wait(0.5)\n\n # --- 4. Direct Movement (Purple Circle) ---\n purple_circle = Circle(radius=0.5, color=\"#9D4EDD\", fill_opacity=0.8)\n purple_circle.move_to([0, 0, 0]) # Start from center\n \n self.play(\n purple_circle.animate.move_to([-4, -4, 0]),\n run_time=2,\n rate_func=linear\n )\n self.wait(0.5)\n\n # --- 5. Alignment Sequence ---\n # Semi-transparent circles aligning to the Orange Square at [2, -2]\n # Square side length is 1.5, so half is 0.75\n \n # Red Circle: Align to Top Edge\n align_red = Circle(radius=0.4, color=\"#E63946\", fill_opacity=0.6)\n target_red = [2, -1.25, 0] \n \n # Yellow Circle: Align to Right Edge\n align_yellow = Circle(radius=0.4, color=\"#E9C46A\", fill_opacity=0.6)\n target_yellow = [2.75, -2, 0]\n\n # Orange Circle: Align to Top-Right Corner\n align_orange = Circle(radius=0.4, color=\"#F4A261\", fill_opacity=0.6)\n target_orange = [2.75, -1.25, 0]\n\n self.play(\n FadeIn(align_red),\n align_red.animate.move_to(target_red),\n FadeIn(align_yellow),\n align_yellow.animate.move_to(target_yellow),\n FadeIn(align_orange),\n align_orange.animate.move_to(target_orange),\n run_time=3\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the definite integral problem ---\n problem_label = Text(\"Calculate the definite integral:\", font_size=36)\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=72)\n problem_group = VGroup(problem_label, problem).arrange(DOWN)\n \n self.play(Write(problem_label))\n self.play(Write(problem))\n self.wait(2)\n\n # Move the problem to the top to make room for the explanation\n self.play(problem_group.animate.to_edge(UP).shift(UP * -0.5))\n\n # --- Step 2: Visually explain the Power Rule ---\n rule_title = Text(\"Power Rule for Integration:\", font_size=32, color=BLUE)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=48)\n rule_group = VGroup(rule_title, power_rule).arrange(DOWN)\n rule_group.next_to(problem_group, DOWN, buff=1)\n\n self.play(Write(rule_title))\n self.play(Write(power_rule))\n self.wait(2)\n\n # --- Step 3: Demonstrate the application of the rule to x^3 ---\n # Highlight that n = 3\n n_val = MathTex(r\"n = 3\", font_size=36, color=YELLOW).next_to(power_rule, RIGHT, buff=1)\n self.play(Write(n_val))\n self.wait(1)\n\n # Transform the general rule into the specific application\n application = MathTex(r\"\\int x^3 \\, dx = \\frac{x^{3+1}}{3+1}\", font_size=48).move_to(power_rule)\n self.play(Transform(power_rule, application), FadeOut(n_val), FadeOut(rule_title))\n self.wait(1)\n\n # Simplify the exponent and denominator\n simplified_rule = MathTex(r\"\\int x^3 \\, dx = \\frac{x^4}{4}\", font_size=48).move_to(power_rule)\n self.play(Transform(power_rule, simplified_rule))\n self.wait(2)\n\n # --- Step 4: Animate the step-by-step integration process ---\n # Transition from the general antiderivative to the definite integral evaluation\n evaluation_step = MathTex(r\"\\int_0^2 x^3 \\, dx = \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=48).move_to(ORIGIN)\n\n self.play(\n FadeOut(power_rule),\n ReplacementTransform(problem.copy(), evaluation_step)\n )\n self.wait(2)\n\n # --- Step 5: Evaluate at the boundaries and reveal numerical calculation ---\n # Show the subtraction of boundaries\n boundary_calc = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=48).next_to(evaluation_step, DOWN, buff=0.8)\n\n self.play(Write(boundary_calc))\n self.wait(2)\n\n # Show numerical expansion\n numerical_expansion = MathTex(r\"= \\frac{16}{4} - 0\", font_size=48).next_to(boundary_calc, DOWN, buff=0.8)\n\n self.play(Write(numerical_expansion))\n self.wait(2)\n\n # --- Conclusion: Display the final numerical answer ---\n final_result = MathTex(r\"= 4\", font_size=60, color=YELLOW).next_to(numerical_expansion, DOWN, buff=0.8)\n\n # Create a box around the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.2)\n\n self.play(Write(final_result))\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup: Clear screen and show just the result\n self.play(\n FadeOut(problem_label),\n FadeOut(problem),\n FadeOut(evaluation_step),\n FadeOut(boundary_calc),\n FadeOut(numerical_expansion)\n )\n self.play(final_result.animate.move_to(ORIGIN).scale(1.5), FadeOut(box))\n \n conclusion_text = Text(\"Final Answer: 4\", font_size=48).next_to(final_result, UP, buff=1)\n self.play(Write(conclusion_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the definite integral problem ---\n problem_label = Text(\"Calculate the definite integral:\", font_size=36)\n problem = MathText(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=72)\n problem_group = VGroup(problem_label, problem).arrange(DOWN)\n \n self.play(Write(problem_label))\n self.play(Write(problem))\n self.wait(2)\n\n # Move the problem to the top to make room for the explanation\n self.play(problem_group.animate.to_edge(UP).shift(UP * -0.5))\n\n # --- Step 2: Visually explain the Power Rule ---\n rule_title = Text(\"Power Rule for Integration:\", font_size=32, color=BLUE)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=48)\n rule_group = VGroup(rule_title, power_rule).arrange(DOWN)\n rule_group.next_to(problem_group, DOWN, buff=1)\n\n self.play(Write(rule_title))\n self.play(Write(power_rule))\n self.wait(2)\n\n # --- Step 3: Demonstrate the application of the rule to x^3 ---\n # Highlight that n = 3\n n_val = MathTex(r\"n = 3\", font_size=36, color=YELLOW).next_to(power_rule, RIGHT, buff=1)\n self.play(Write(n_val))\n self.wait(1)\n\n # Transform the general rule into the specific application\n application = MathTex(r\"\\int x^3 \\, dx = \\frac{x^{3+1}}{3+1}\", font_size=48).move_to(power_rule)\n self.play(Transform(power_rule, application), FadeOut(n_val), FadeOut(rule_title))\n self.wait(1)\n\n # Simplify the exponent and denominator\n simplified_rule = MathTex(r\"\\int x^3 \\, dx = \\frac{x^4}{4}\", font_size=48).move_to(power_rule)\n self.play(Transform(power_rule, simplified_rule))\n self.wait(2)\n\n # --- Step 4: Animate the step-by-step integration process ---\n # Transition from the general antiderivative to the definite integral evaluation\n evaluation_step = MathTex(r\"\\int_0^2 x^3 \\, dx = \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=48).move_to(ORIGIN)\n\n self.play(\n FadeOut(power_rule),\n ReplacementTransform(problem.copy(), evaluation_step)\n )\n self.wait(2)\n\n # --- Step 5: Evaluate at the boundaries and reveal numerical calculation ---\n # Show the subtraction of boundaries\n boundary_calc = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\", font_size=48).next_to(evaluation_step, DOWN, buff=0.8)\n\n self.play(Write(boundary_calc))\n self.wait(2)\n\n # Show numerical expansion\n numerical_expansion = MathTex(r\"= \\frac{16}{4} - 0\", font_size=48).next_to(boundary_calc, DOWN, buff=0.8)\n\n self.play(Write(numerical_expansion))\n self.wait(2)\n\n # --- Conclusion: Display the final numerical answer ---\n final_result = MathTex(r\"= 4\", font_size=60, color=YELLOW).next_to(numerical_expansion, DOWN, buff=0.8)\n\n # Create a box around the final result for emphasis\n box = SurroundingRectangle(final_result, color=WHITE, buff=0.2)\n\n self.play(Write(final_result))\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup: Clear screen and show just the result\n self.play(\n FadeOut(problem_label),\n FadeOut(problem),\n FadeOut(evaluation_step),\n FadeOut(boundary_calc),\n FadeOut(numerical_expansion)\n )\n self.play(final_result.animate.move_to(ORIGIN).scale(1.5), FadeOut(box))\n \n conclusion_text = Text(\"Final Answer: 4\", font_size=48).next_to(final_result, UP, buff=1)\n self.play(Write(conclusion_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Setup Axes and Graph\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).add_coordinates()\n \n # Plot f(x) = x^2 in Blue\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-2, 2])\n \n # 2. Initial State: Display curve and integral equation next to it\n integral_eq = MathTex(r\"\\int_{-2}^{2}\", \"x^2\", \"dx\", font_size=40)\n integral_eq.next_to(axes, RIGHT, buff=0.5)\n \n self.play(Create(axes), Create(graph))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # 3. Animation Sequence\n # Move the integral equation to the top of the screen\n self.play(integral_eq.animate.to_edge(UP))\n self.wait(0.5)\n\n # Shade the area beneath the curve\n area = axes.get_area(graph, x_range=(-2, 2), color=BLUE, opacity=0.4)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Step-by-step calculation (each step replaces the previous one)\n # Step 1: Write the integral\n step1 = MathTex(r\"\\int_{-2}^{2}\", \"x^2\", \"dx\", font_size=40)\n step1.next_to(integral_eq, DOWN, buff=0.6)\n self.play(FadeIn(step1))\n self.wait(1)\n\n # Step 2: Write the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", font_size=40)\n step2.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n\n # Step 3: Evaluate at the boundaries\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\", font_size=40)\n step3.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n\n # Step 4: Simplify the values\n step4 = MathTex(r\"= \\frac{8}{3} - \\left(-\\frac{8}{3}\\right)\", font_size=40)\n step4.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # Step 5: Final Answer\n step5 = MathTex(r\"= \\frac{16}{3}\", font_size=40)\n step5.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step4, step5))\n self.wait(1)\n\n # 4. Final State\n # Clear all content except the final solution\n self.play(\n FadeOut(axes), \n FadeOut(graph), \n FadeOut(area), \n FadeOut(integral_eq)\n )\n self.wait(0.5)\n \n # Re-display the final solution prominently for emphasis\n final_solution = MathTex(r\"\\frac{16}{3}\", font_size=72, color=YELLOW)\n self.play(ReplacementTransform(step5, final_solution.move_to(ORIGIN)))\n self.play(Indicate(final_solution))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # 1. Setup Axes and Graph\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"numbers_to_exclude\": [0]},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).add_coordinates()\n \n # Plot f(x) = x^2 in Blue\n graph = axes.plot(lambda x: x**2, color=BLUE, x_range=[-2, 2])\n \n # 2. Initial State: Display curve and integral equation next to it\n integral_eq = MathText(r\"\\int_{-2}^{2}\", \"x^2\", \"dx\", font_size=40)\n integral_eq.next_to(axes, RIGHT, buff=0.5)\n \n self.play(Create(axes), Create(graph))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # 3. Animation Sequence\n # Move the integral equation to the top of the screen\n self.play(integral_eq.animate.to_edge(UP))\n self.wait(0.5)\n\n # Shade the area beneath the curve\n area = axes.get_area(graph, x_range=(-2, 2), color=BLUE, opacity=0.4)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Step-by-step calculation (each step replaces the previous one)\n # Step 1: Write the integral\n step1 = MathTex(r\"\\int_{-2}^{2}\", \"x^2\", \"dx\", font_size=40)\n step1.next_to(integral_eq, DOWN, buff=0.6)\n self.play(FadeIn(step1))\n self.wait(1)\n\n # Step 2: Write the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\", font_size=40)\n step2.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n\n # Step 3: Evaluate at the boundaries\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{(-2)^3}{3}\", font_size=40)\n step3.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n\n # Step 4: Simplify the values\n step4 = MathTex(r\"= \\frac{8}{3} - \\left(-\\frac{8}{3}\\right)\", font_size=40)\n step4.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step3, step4))\n self.wait(1)\n\n # Step 5: Final Answer\n step5 = MathTex(r\"= \\frac{16}{3}\", font_size=40)\n step5.next_to(integral_eq, DOWN, buff=0.6)\n self.play(ReplacementTransform(step4, step5))\n self.wait(1)\n\n # 4. Final State\n # Clear all content except the final solution\n self.play(\n FadeOut(axes), \n FadeOut(graph), \n FadeOut(area), \n FadeOut(integral_eq)\n )\n self.wait(0.5)\n \n # Re-display the final solution prominently for emphasis\n final_solution = MathTex(r\"\\frac{16}{3}\", font_size=72, color=YELLOW)\n self.play(ReplacementTransform(step5, final_solution.move_to(ORIGIN)))\n self.play(Indicate(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 role does the trace operator play in Sobolev Spaces, and how can we visualize its effect on functions at the boundary of a domain?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass TraceOperatorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Tracing Boundaries\", font_size=32)\n subtitle = Text(\"The Role of the Trace Operator in Sobolev Spaces\", font_size=24)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title, subtitle))\n \n # Create a simplified 2D \"landscape\"\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 2, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Function graph representing our landscape\n def func(x):\n return 0.5 * np.sin(x) + 0.5 * np.cos(2*x)\n \n graph = axes.plot(func, color=BLUE)\n \n # Label for the domain\n domain_label = Text(\"Function over Domain (Ω)\", font_size=24)\n domain_label.to_edge(UP)\n \n # Add everything to the scene\n self.play(Create(axes))\n self.play(Create(graph))\n self.play(Write(domain_label))\n self.wait(1)\n \n # Highlight the boundary\n left_point = Dot(axes.c2p(-3, func(-3)), color=RED)\n right_point = Dot(axes.c2p(3, func(3)), color=RED)\n \n # Create a dashed line representing the boundary\n boundary_line = DashedLine(\n left_point.get_center(), \n right_point.get_center(),\n color=RED\n )\n \n boundary_label = Text(\"Boundary (∂Ω)\", font_size=20, color=RED)\n boundary_label.next_to(boundary_line, DOWN)\n \n self.play(Create(left_point), Create(right_point))\n self.play(Create(boundary_line))\n self.play(Write(boundary_label))\n self.wait(1)\n \n # Introduce the trace operator\n trace_text = Text(\"The Trace Operator\", font_size=28)\n trace_text.to_edge(UP)\n \n self.play(ReplacementTransform(domain_label, trace_text))\n self.wait(1)\n \n # Show the first equation\n eq1 = Text(\"T(u) = u|_boundary\", font_size=28)\n eq1.next_to(trace_text, DOWN, buff=1)\n \n self.play(Write(eq1))\n self.wait(1)\n \n # Visualize the trace operation with a magnifying glass\n magnifier = Circle(radius=0.3, color=YELLOW)\n magnifier.set_fill(YELLOW, opacity=0.2)\n magnifier_handle = Line(\n magnifier.get_bottom(),\n magnifier.get_bottom() + DOWN * 0.5,\n color=YELLOW\n )\n magnifying_glass = VGroup(magnifier, magnifier_handle)\n \n # Position the magnifying glass near the left boundary point\n magnifying_glass.next_to(left_point, UP + LEFT, buff=0.2)\n \n self.play(Create(magnifying_glass))\n self.play(\n magnifying_glass.animate.next_to(right_point, UP + RIGHT, buff=0.2)\n )\n self.wait(1)\n \n # Key insight\n insight_text = Text(\"This extracts boundary values\", font_size=24)\n insight_text.to_edge(DOWN, buff=1)\n \n self.play(Write(insight_text))\n self.wait(1)\n \n # Clean up for next part\n self.play(FadeOut(magnifying_glass, insight_text))\n \n # Show the continuity property\n continuity_text = Text(\"Continuity property:\", font_size=24)\n continuity_text.next_to(eq1, DOWN, buff=0.7)\n \n eq2 = Text(\"||T(u)|| \\le C||u||\", font_size=28)\n eq2.next_to(continuity_text, DOWN, buff=0.5)\n \n self.play(Write(continuity_text))\n self.play(Write(eq2))\n self.wait(2)\n \n # Final clean up - using group fadeout which works in newer manim versions\n cleanup_group = VGroup(\n axes, graph, left_point, right_point, boundary_line, boundary_label,\n trace_text, eq1, continuity_text, eq2\n )\n self.play(FadeOut(cleanup_group))\n \n # Conclusion\n conclusion = Text(\"The trace operator simplifies\", font_size=32)\n conclusion2 = Text(\"boundary value problems\", font_size=32)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.play(Write(conclusion2))\n self.wait(2)\n \n self.play(FadeOut(conclusion, conclusion2))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass TraceOperatorScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Tracing Boundaries\", font_size=32)\n subtitle = Text(\"The Role of the Trace Operator in Sobolev Spaces\", font_size=24)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(title, subtitle))\n \n # Create a simplified 2D \"landscape\"\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 2, 1],\n axis_config={\"color\": BBLUE},\n )\n \n # Function graph representing our landscape\n def func(x):\n return 0.5 * np.sin(x) + 0.5 * np.cos(2*x)\n \n graph = axes.plot(func, color=BLUE)\n \n # Label for the domain\n domain_label = Text(\"Function over Domain (Ω)\", font_size=24)\n domain_label.to_edge(UP)\n \n # Add everything to the scene\n self.play(Create(axes))\n self.play(Create(graph))\n self.play(Write(domain_label))\n self.wait(1)\n \n # Highlight the boundary\n left_point = Dot(axes.c2p(-3, func(-3)), color=RED)\n right_point = Dot(axes.c2p(3, func(3)), color=RED)\n \n # Create a dashed line representing the boundary\n boundary_line = DashedLine(\n left_point.get_center(), \n right_point.get_center(),\n color=RED\n )\n \n boundary_label = Text(\"Boundary (∂Ω)\", font_size=20, color=RED)\n boundary_label.next_to(boundary_line, DOWN)\n \n self.play(Create(left_point), Create(right_point))\n self.play(Create(boundary_line))\n self.play(Write(boundary_label))\n self.wait(1)\n \n # Introduce the trace operator\n trace_text = Text(\"The Trace Operator\", font_size=28)\n trace_text.to_edge(UP)\n \n self.play(ReplacementTransform(domain_label, trace_text))\n self.wait(1)\n \n # Show the first equation\n eq1 = Text(\"T(u) = u|_boundary\", font_size=28)\n eq1.next_to(trace_text, DOWN, buff=1)\n \n self.play(Write(eq1))\n self.wait(1)\n \n # Visualize the trace operation with a magnifying glass\n magnifier = Circle(radius=0.3, color=YELLOW)\n magnifier.set_fill(YELLOW, opacity=0.2)\n magnifier_handle = Line(\n magnifier.get_bottom(),\n magnifier.get_bottom() + DOWN * 0.5,\n color=YELLOW\n )\n magnifying_glass = VGroup(magnifier, magnifier_handle)\n \n # Position the magnifying glass near the left boundary point\n magnifying_glass.next_to(left_point, UP + LEFT, buff=0.2)\n \n self.play(Create(magnifying_glass))\n self.play(\n magnifying_glass.animate.next_to(right_point, UP + RIGHT, buff=0.2)\n )\n self.wait(1)\n \n # Key insight\n insight_text = Text(\"This extracts boundary values\", font_size=24)\n insight_text.to_edge(DOWN, buff=1)\n \n self.play(Write(insight_text))\n self.wait(1)\n \n # Clean up for next part\n self.play(FadeOut(magnifying_glass, insight_text))\n \n # Show the continuity property\n continuity_text = Text(\"Continuity property:\", font_size=24)\n continuity_text.next_to(eq1, DOWN, buff=0.7)\n \n eq2 = Text(\"||T(u)|| \\le C||u||\", font_size=28)\n eq2.next_to(continuity_text, DOWN, buff=0.5)\n \n self.play(Write(continuity_text))\n self.play(Write(eq2))\n self.wait(2)\n \n # Final clean up - using group fadeout which works in newer manim versions\n cleanup_group = VGroup(\n axes, graph, left_point, right_point, boundary_line, boundary_label,\n trace_text, eq1, continuity_text, eq2\n )\n self.play(FadeOut(cleanup_group))\n \n # Conclusion\n conclusion = Text(\"The trace operator simplifies\", font_size=32)\n conclusion2 = Text(\"boundary value problems\", font_size=32)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.play(Write(conclusion2))\n self.wait(2)\n \n self.play(FadeOut(conclusion, conclusion2))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Perfect Numbers' (The Fractal Nature of Perfect Numbers): Can we represent perfect numbers using a fractal pattern arising from their proper divisors?\nVisual style guidance: Adopt a 3Blue1Brown style with smooth transitions, a mix of deep blues and vibrant yellows for number highlights, and white-light grayscales for the fractal lines to maintain an elegant, simple aesthetic.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass PerfectNumbersFractal(Scene):\n def construct(self):\n # Colors - using 3Blue1Brown style colors\n BLUE_DEEP = \"#0C2D48\"\n YELLOW_VIBRANT = \"#FFCB47\"\n \n # Introduction\n title = Text(\"The Fractal Nature of Perfect Numbers\", color=BLUE_DEEP)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Perfect number 6\n eq_6 = Text(\"6 = 1 + 2 + 3\", color=BLUE_DEEP)\n self.play(Write(eq_6))\n self.wait(1)\n \n # Visualize divisors of 6\n center_6 = Dot(color=YELLOW_VIBRANT)\n label_6 = Text(\"6\", color=WHITE).next_to(center_6, UP, buff=0.1)\n \n self.play(FadeOut(eq_6))\n self.play(Create(center_6), Write(label_6))\n \n # Create divisors as dots around center_6\n divisors_6 = VGroup()\n connections_6 = VGroup()\n \n for i, d in enumerate([1, 2, 3]):\n angle = i * TAU/3\n radius = 1.5\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, direction=UP, buff=0.1)\n \n line = Line(center_6.get_center(), dot.get_center(), color=WHITE)\n \n divisors_6.add(VGroup(dot, label))\n connections_6.add(line)\n \n self.play(Create(divisors_6), Create(connections_6))\n self.wait(1)\n \n # Transition to 28\n self.play(\n FadeOut(center_6),\n FadeOut(label_6),\n FadeOut(divisors_6),\n FadeOut(connections_6)\n )\n \n # Perfect number 28\n eq_28 = Text(\"28 = 1 + 2 + 4 + 7 + 14\", color=BLUE_DEEP)\n self.play(Write(eq_28))\n self.wait(1)\n \n # Visualize divisors of 28\n center_28 = Dot(color=YELLOW_VIBRANT)\n label_28 = Text(\"28\", color=WHITE).next_to(center_28, UP, buff=0.1)\n \n self.play(FadeOut(eq_28))\n self.play(Create(center_28), Write(label_28))\n \n # Create divisors as dots around center_28\n divisors_28 = VGroup()\n connections_28 = VGroup()\n \n for i, d in enumerate([1, 2, 4, 7, 14]):\n angle = i * TAU/5\n radius = 1.8\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, direction=RIGHT * np.cos(angle) + UP * np.sin(angle), buff=0.1)\n \n line = Line(center_28.get_center(), dot.get_center(), color=WHITE)\n \n divisors_28.add(VGroup(dot, label))\n connections_28.add(line)\n \n self.play(Create(divisors_28), Create(connections_28))\n self.wait(1)\n \n # Show fractal pattern\n self.play(\n FadeOut(center_28),\n FadeOut(label_28),\n FadeOut(divisors_28),\n FadeOut(connections_28)\n )\n \n fractal_title = Text(\"Fractal Pattern of Perfect Numbers\", color=BLUE_DEEP)\n self.play(Write(fractal_title))\n self.wait(1)\n self.play(fractal_title.animate.scale(0.7).to_edge(UP), FadeOut(title))\n \n # Create a simple fractal-like structure\n root = Dot(color=YELLOW_VIBRANT)\n root_label = Text(\"6\", color=WHITE).next_to(root, UP, buff=0.1)\n \n self.play(Create(root), Write(root_label))\n \n # First level - divisors of 6\n level1 = VGroup()\n level1_connections = VGroup()\n \n for i, d in enumerate([1, 2, 3]):\n angle = PI/6 + i * PI/3\n radius = 1.5\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, UP, buff=0.1)\n \n line = Line(root.get_center(), dot.get_center(), color=WHITE)\n \n level1.add(VGroup(dot, label))\n level1_connections.add(line)\n \n self.play(Create(level1), Create(level1_connections))\n \n # Add 28 as another branch\n node_28 = Dot(color=YELLOW_VIBRANT).shift(DOWN * 1.8)\n label_28 = Text(\"28\", color=WHITE).next_to(node_28, RIGHT, buff=0.1)\n connection_28 = Line(root.get_center(), node_28.get_center(), color=WHITE)\n \n self.play(Create(node_28), Write(label_28), Create(connection_28))\n \n # Add some divisors of 28\n level2 = VGroup()\n level2_connections = VGroup()\n \n for i, d in enumerate([1, 2, 4]):\n angle = PI + i * PI/4\n radius = 1.2\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle) - 1.8 # Offset to position relative to node_28\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, DOWN, buff=0.1)\n \n line = Line(node_28.get_center(), dot.get_center(), color=WHITE)\n \n level2.add(VGroup(dot, label))\n level2_connections.add(line)\n \n self.play(Create(level2), Create(level2_connections))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(root),\n FadeOut(root_label),\n FadeOut(level1),\n FadeOut(level1_connections),\n FadeOut(node_28),\n FadeOut(label_28),\n FadeOut(connection_28),\n FadeOut(level2),\n FadeOut(level2_connections),\n FadeOut(fractal_title)\n )\n \n conclusion = Text(\"Perfect numbers reveal fractal-like patterns\\nthrough their divisor relationships\", color=BLUE_DEEP)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass PerfectNumbersFractal(Scene):\n def construct(self):\n # Colors - using 3Blue1Brown style colors\n BBLUE_DEEP = \"#0C2D48\"\n YELLOW_VIBRANT = \"#FFCB47\"\n \n # Introduction\n title = Text(\"The Fractal Nature of Perfect Numbers\", color=BLUE_DEEP)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.7).to_edge(UP))\n \n # Perfect number 6\n eq_6 = Text(\"6 = 1 + 2 + 3\", color=BLUE_DEEP)\n self.play(Write(eq_6))\n self.wait(1)\n \n # Visualize divisors of 6\n center_6 = Dot(color=YELLOW_VIBRANT)\n label_6 = Text(\"6\", color=WHITE).next_to(center_6, UP, buff=0.1)\n \n self.play(FadeOut(eq_6))\n self.play(Create(center_6), Write(label_6))\n \n # Create divisors as dots around center_6\n divisors_6 = VGroup()\n connections_6 = VGroup()\n \n for i, d in enumerate([1, 2, 3]):\n angle = i * TAU/3\n radius = 1.5\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, direction=UP, buff=0.1)\n \n line = Line(center_6.get_center(), dot.get_center(), color=WHITE)\n \n divisors_6.add(VGroup(dot, label))\n connections_6.add(line)\n \n self.play(Create(divisors_6), Create(connections_6))\n self.wait(1)\n \n # Transition to 28\n self.play(\n FadeOut(center_6),\n FadeOut(label_6),\n FadeOut(divisors_6),\n FadeOut(connections_6)\n )\n \n # Perfect number 28\n eq_28 = Text(\"28 = 1 + 2 + 4 + 7 + 14\", color=BLUE_DEEP)\n self.play(Write(eq_28))\n self.wait(1)\n \n # Visualize divisors of 28\n center_28 = Dot(color=YELLOW_VIBRANT)\n label_28 = Text(\"28\", color=WHITE).next_to(center_28, UP, buff=0.1)\n \n self.play(FadeOut(eq_28))\n self.play(Create(center_28), Write(label_28))\n \n # Create divisors as dots around center_28\n divisors_28 = VGroup()\n connections_28 = VGroup()\n \n for i, d in enumerate([1, 2, 4, 7, 14]):\n angle = i * TAU/5\n radius = 1.8\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, direction=RIGHT * np.cos(angle) + UP * np.sin(angle), buff=0.1)\n \n line = Line(center_28.get_center(), dot.get_center(), color=WHITE)\n \n divisors_28.add(VGroup(dot, label))\n connections_28.add(line)\n \n self.play(Create(divisors_28), Create(connections_28))\n self.wait(1)\n \n # Show fractal pattern\n self.play(\n FadeOut(center_28),\n FadeOut(label_28),\n FadeOut(divisors_28),\n FadeOut(connections_28)\n )\n \n fractal_title = Text(\"Fractal Pattern of Perfect Numbers\", color=BLUE_DEEP)\n self.play(Write(fractal_title))\n self.wait(1)\n self.play(fractal_title.animate.scale(0.7).to_edge(UP), FadeOut(title))\n \n # Create a simple fractal-like structure\n root = Dot(color=YELLOW_VIBRANT)\n root_label = Text(\"6\", color=WHITE).next_to(root, UP, buff=0.1)\n \n self.play(Create(root), Write(root_label))\n \n # First level - divisors of 6\n level1 = VGroup()\n level1_connections = VGroup()\n \n for i, d in enumerate([1, 2, 3]):\n angle = PI/6 + i * PI/3\n radius = 1.5\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle)\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, UP, buff=0.1)\n \n line = Line(root.get_center(), dot.get_center(), color=WHITE)\n \n level1.add(VGroup(dot, label))\n level1_connections.add(line)\n \n self.play(Create(level1), Create(level1_connections))\n \n # Add 28 as another branch\n node_28 = Dot(color=YELLOW_VIBRANT).shift(DOWN * 1.8)\n label_28 = Text(\"28\", color=WHITE).next_to(node_28, RIGHT, buff=0.1)\n connection_28 = Line(root.get_center(), node_28.get_center(), color=WHITE)\n \n self.play(Create(node_28), Write(label_28), Create(connection_28))\n \n # Add some divisors of 28\n level2 = VGroup()\n level2_connections = VGroup()\n \n for i, d in enumerate([1, 2, 4]):\n angle = PI + i * PI/4\n radius = 1.2\n \n x = radius * np.cos(angle)\n y = radius * np.sin(angle) - 1.8 # Offset to position relative to node_28\n \n dot = Dot(color=BLUE_DEEP).shift(RIGHT * x + UP * y)\n label = Text(str(d), color=WHITE).scale(0.7).next_to(dot, DOWN, buff=0.1)\n \n line = Line(node_28.get_center(), dot.get_center(), color=WHITE)\n \n level2.add(VGroup(dot, label))\n level2_connections.add(line)\n \n self.play(Create(level2), Create(level2_connections))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(root),\n FadeOut(root_label),\n FadeOut(level1),\n FadeOut(level1_connections),\n FadeOut(node_28),\n FadeOut(label_28),\n FadeOut(connection_28),\n FadeOut(level2),\n FadeOut(level2_connections),\n FadeOut(fractal_title)\n )\n \n conclusion = Text(\"Perfect numbers reveal fractal-like patterns\\nthrough their divisor relationships\", color=BLUE_DEEP)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visually represents a neural network with three convolutional layers having respective depths of 1, 3, and 5, each with 3 by 3 filter sizes, followed by two fully connected layers with three neurons each, and show a forward pass through this network? The convolutional layers should have their filters spaced appropriately to clearly distinguish each one. Additionally, the entire network should be positioned centrally and the transition between each layer should have a clear spacing.", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n filter_color_1 = BLUE_D\n filter_color_2 = BLUE_B\n filter_color_3 = BLUE_A\n neuron_color = GREEN_E\n connection_color = GRAY\n signal_color = YELLOW\n \n filter_size = 0.6\n neuron_radius = 0.15\n layer_spacing = 2.2\n vert_buff = 0.35\n \n # --- Helper Functions ---\n def create_3x3_filter(color=BLUE_D):\n \"\"\"Creates a 3x3 grid representing a convolutional filter.\"\"\"\n grid = VGroup()\n small_sq_size = filter_size / 3.0\n for i in range(3):\n for j in range(3):\n sq = Square(side_length=small_sq_size)\n sq.set_stroke(WHITE, width=1)\n sq.set_fill(color, opacity=0.6)\n x = j * small_sq_size - filter_size/2 + small_sq_size/2\n y = i * small_sq_size - filter_size/2 + small_sq_size/2\n sq.move_to([x, y, 0])\n grid.add(sq)\n return grid\n\n def create_conv_layer(depth, color):\n \"\"\"Creates a convolutional layer with specified depth (number of filters).\"\"\"\n filters = [create_3x3_filter(color) for _ in range(depth)]\n layer = VGroup(*filters)\n layer.arrange(DOWN, buff=vert_buff)\n return layer\n\n def create_fc_layer(neurons):\n \"\"\"Creates a fully connected layer with specified number of neurons.\"\"\"\n layer = VGroup(*[Circle(radius=neuron_radius) for _ in range(neurons)])\n layer.set_fill(neuron_color, opacity=0.8)\n layer.set_stroke(WHITE, width=2)\n layer.arrange(DOWN, buff=vert_buff)\n return layer\n\n # --- Create Layers ---\n conv1 = create_conv_layer(depth=1, color=filter_color_1)\n conv2 = create_conv_layer(depth=3, color=filter_color_2)\n conv3 = create_conv_layer(depth=5, color=filter_color_3)\n fc1 = create_fc_layer(neurons=3)\n fc2 = create_fc_layer(neurons=3)\n\n layers = [conv1, conv2, conv3, fc1, fc2]\n\n # --- Layout & Positioning ---\n network_group = VGroup(*layers)\n network_group.arrange(RIGHT, buff=layer_spacing)\n network_group.move_to(ORIGIN)\n\n # --- Connections ---\n connections = VGroup()\n \n def get_connections(layer_start, layer_end):\n conns = VGroup()\n for u1 in layer_start:\n for u2 in layer_end:\n line = Line(\n u1.get_center(), \n u2.get_center(), \n stroke_width=1, \n stroke_opacity=0.2, \n color=connection_color\n )\n conns.add(line)\n return conns\n\n for i in range(len(layers) - 1):\n connections.add(get_connections(layers[i], layers[i+1]))\n\n # --- Forward Pass Path ---\n path_points = [layer.get_center() for layer in layers]\n path = VMobject()\n path.set_points_as_corners(path_points)\n signal = Dot(color=signal_color, radius=0.15)\n\n # --- Animation Sequence ---\n # 1. Introduce Network Structure\n self.play(FadeIn(network_group), run_time=1.5)\n self.play(Create(connections), run_time=1.5)\n self.wait(0.5)\n \n # 2. Animate Forward Pass\n self.play(FadeIn(signal))\n self.play(MoveAlongPath(signal, path), run_time=3, rate_func=linear)\n \n # 3. Highlight Activation per Layer\n for layer in layers:\n self.play(\n layer.animate.set_fill(opacity=1.0).set_stroke(width=3, color=WHITE),\n run_time=0.3\n )\n self.play(\n layer.animate.set_fill(opacity=0.6).set_stroke(width=1.5),\n run_time=0.1\n )\n \n self.play(FadeOut(signal), run_time=0.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardPass(Scene):\n def construct(self):\n # --- Configuration ---\n filter_color_1 = BLUE_D\n filter_color_2 = BLUE_B\n filter_color_3 = BLUE_A\n neuron_color = GREEN_E\n connection_color = GRAY\n signal_color = YELLOW\n \n filter_size = 0.6\n neuron_radius = 0.15\n layer_spacing = 2.2\n vert_buff = 0.35\n \n # --- Helper Functions ---\n def create_3x3_filter(color=BLUE_D):\n \"\"\"Creates a 3x3 grid representing a convolutional filter.\"\"\"\n grid = VGroup()\n small_sq_size = filter_size / 3.0\n for i in range(3):\n for j in range(3):\n sq = Square(side_length=small_sq_size)\n sq.set_stroke(WHITE, width=1)\n sq.set_fill(color, opacity=0.6)\n x = j * small_sq_size - filter_size/2 + small_sq_size/2\n y = i * small_sq_size - filter_size/2 + small_sq_size/2\n sq.move_to([x, y, 0])\n grid.add(sq)\n return grid\n\n def create_conv_layer(depth, color):\n \"\"\"Creates a convolutional layer with specified depth (number of filters).\"\"\"\n filters = [create_3x3_filter(color) for _ in range(depth)]\n layer = VGroup(*filters)\n layer.arrange(DOWN, buff=vert_buff)\n return layer\n\n def create_fc_layer(neurons):\n \"\"\"Creates a fully connected layer with specified number of neurons.\"\"\"\n layer = VGroup(*[Circle(radius=neuron_radius) for _ in range(neurons)])\n layer.set_fill(neuron_color, opacity=0.8)\n layer.set_stroke(WHITE, width=2)\n layer.arrange(DOWN, buff=vert_buff)\n return layer\n\n # --- Create Layers ---\n conv1 = create_conv_layer(depth=1, color=filter_color_1)\n conv2 = create_conv_layer(depth=3, color=filter_color_2)\n conv3 = create_conv_layer(depth=5, color=filter_color_3)\n fc1 = create_fc_layer(neurons=3)\n fc2 = create_fc_layer(neurons=3)\n\n layers = [conv1, conv2, conv3, fc1, fc2]\n\n # --- Layout & Positioning ---\n network_group = VGroup(*layers)\n network_group.arrange(RIGHT, buff=layer_spacing)\n network_group.move_to(ORIGIN)\n\n # --- Connections ---\n connections = VGroup()\n \n def get_connections(layer_start, layer_end):\n conns = VGroup()\n for u1 in layer_start:\n for u2 in layer_end:\n line = Line(\n u1.get_center(), \n u2.get_center(), \n stroke_width=1, \n stroke_opacity=0.2, \n color=connection_color\n )\n conns.add(line)\n return conns\n\n for i in range(len(layers) - 1):\n connections.add(get_connections(layers[i], layers[i+1]))\n\n # --- Forward Pass Path ---\n path_points = [layer.get_center() for layer in layers]\n path = VMob()\n path.set_points_as_corners(path_points)\n signal = Dot(color=signal_color, radius=0.15)\n\n # --- Animation Sequence ---\n # 1. Introduce Network Structure\n self.play(FadeIn(network_group), run_time=1.5)\n self.play(Create(connections), run_time=1.5)\n self.wait(0.5)\n \n # 2. Animate Forward Pass\n self.play(FadeIn(signal))\n self.play(MoveAlongPath(signal, path), run_time=3, rate_func=linear)\n \n # 3. Highlight Activation per Layer\n for layer in layers:\n self.play(\n layer.animate.set_fill(opacity=1.0).set_stroke(width=3, color=WHITE),\n run_time=0.3\n )\n self.play(\n layer.animate.set_fill(opacity=0.6).set_stroke(width=1.5),\n run_time=0.1\n )\n \n self.play(FadeOut(signal), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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# Revolutionary Transformation in Marxist Philosophy\n\n### 1. Shift in Philosophical Subject: From \"Abstract Man\" to \"Real Man\"", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MarxistPhilosophy(Scene):\n\n def construct(self):\n title = Text('Revolutionary Transformation in\\nMarxist Philosophy', font_size=48, weight=BOLD, color=YELLOW, line_spacing=1.2).to_edge(UP, buff=1.0)\n section_text = Text('1. Shift in Philosophical Subject:', font_size=36, color=BLUE_B).next_to(title, DOWN, buff=1.2)\n abstract_man = Text('\"Abstract Man\"', font_size=42, color=RED_B)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, stroke_width=6, buff=0.2).scale(1.5)\n real_man = Text('\"Real Man\"', font_size=42, color=GREEN_B)\n transformation_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.8)\n transformation_group.next_to(section_text, DOWN, buff=1.0)\n self.play(Write(title), run_time=2)\n self.wait(0.5)\n self.play(FadeIn(section_text, shift=UP), run_time=1)\n self.wait(0.5)\n self.play(Write(abstract_man), run_time=1)\n self.wait(0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n self.play(Write(real_man), run_time=1)\n self.wait(2)\n self.play(Circumscribe(real_man, color=GREEN_A, time_width=2))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(section_text), FadeOut(transformation_group))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MarxistPhilosophy(Scene):\n\n def construct(self):\n title = Text('Revolutionary Transformation in\\nMarxist Philosophy', font_size=48, weight=BOLD, color=YELLOW, line_spacing=1.2).to_edge(UP, buff=1.0)\n section_text = Text('1. Shift in Philosophical Subject:', font_size=36, color=BBLUE_B).next_to(title, DOWN, buff=1.2)\n abstract_man = Text('\"Abstract Man\"', font_size=42, color=RED_B)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, stroke_width=6, buff=0.2).scale(1.5)\n real_man = Text('\"Real Man\"', font_size=42, color=GREEN_B)\n transformation_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.8)\n transformation_group.next_to(section_text, DOWN, buff=1.0)\n self.play(Write(title), run_time=2)\n self.wait(0.5)\n self.play(FadeIn(section_text, shift=UP), run_time=1)\n self.wait(0.5)\n self.play(Write(abstract_man), run_time=1)\n self.wait(0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n self.play(Write(real_man), run_time=1)\n self.wait(2)\n self.play(Circumscribe(real_man, color=GREEN_A, time_width=2))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(section_text), FadeOut(transformation_group))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 TrigIdentityCorrection(Scene):\n def construct(self):\n # --- Scene 1: Introduction of Error ---\n incorrect_eq = MathTex(r\"\\sin(x) + \\cos(x) = 1\", font_size=60)\n counter_example = MathTex(r\"x = \\frac{\\pi}{4} \\implies \\frac{\\sqrt{2}}{2} + \\frac{\\sqrt{2}}{2} = \\sqrt{2} \\neq 1\", font_size=36)\n counter_example.next_to(incorrect_eq, DOWN, buff=0.5).set_color(RED)\n \n self.play(Write(incorrect_eq))\n self.wait(1)\n \n # Indicate error with shake and cross\n cross = Cross(incorrect_eq, stroke_width=6, color=RED)\n self.play(\n Create(cross),\n incorrect_eq.animate.scale(1.1).set_color(RED), run_time=0.2\n )\n self.play(incorrect_eq.animate.scale(1/1.1), run_time=0.2)\n self.play(Write(counter_example))\n self.wait(2)\n\n # --- Scene 2: Correction & Explanation ---\n correct_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=60)\n correct_eq.move_to(incorrect_eq.get_center())\n identity_text = Text(\"Pythagorean Identity\", color=GREEN, font_size=36).next_to(correct_eq, DOWN)\n \n # Unit Circle Diagram (Simplified)\n unit_circle = Circle(radius=1.5, color=WHITE, stroke_width=2).to_corner(UR)\n circle_label = Text(\"Unit Circle\", font_size=24).next_to(unit_circle, DOWN)\n\n # Morph equation: keep + and = stationary, highlight exponents\n self.play(\n Transform(incorrect_eq, correct_eq),\n FadeOut(cross),\n FadeOut(counter_example),\n TransformFromCopy(incorrect_eq, correct_eq)\n )\n self.play(correct_eq.animate.set_color(GREEN), Write(identity_text))\n self.play(FadeIn(unit_circle), FadeIn(circle_label))\n self.wait(2)\n self.play(FadeOut(unit_circle), FadeOut(circle_label))\n\n # --- Scene 3: Graphical Visualization ---\n axes = Axes(\n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)\n cos_graph = axes.plot(lambda x: np.cos(x), color=ORANGE)\n\n sin_label = MathTex(r\"\\sin(x)\", color=BLUE).next_to(sin_graph, RIGHT)\n cos_label = MathTex(r\"\\cos(x)\", color=ORANGE).next_to(cos_graph, RIGHT)\n\n # Move equation to top\n self.play(correct_eq.animate.to_edge(UP), FadeOut(identity_text))\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sin_graph), Write(sin_label), Create(cos_graph), Write(cos_label))\n \n # Visual indicator that sum varies vs sum of squares is constant\n sum_text = Text(\"Linear sum varies (not constant)\", font_size=28, color=RED).to_edge(DOWN)\n self.play(Write(sum_text))\n self.wait(3)\n\n # --- Scene 4: Final Emphasis ---\n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(sin_graph),\n FadeOut(cos_graph), FadeOut(sin_label), FadeOut(cos_label),\n FadeOut(sum_text), correct_eq.animate.move_to(ORIGIN)\n )\n\n final_text = Text(\"Always True: The power of two makes the identity hold\", color=GREEN, font_size=32).next_to(correct_eq, DOWN)\n self.play(Write(final_text))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass TrigIdentityCorrection(Scene):\n def construct(self):\n # --- Scene 1: Introduction of Error ---\n incorrect_eq = MathTex(r\"\\sin(x) + \\cos(x) = 1\", font_size=60)\n counter_example = MathTex(r\"x = \\frac{\\pi}{4} \\implies \\frac{\\sqrt{2}}{2} + \\frac{\\sqrt{2}}{2} = \\sqrt{2} \\neq 1\", font_size=36)\n counter_example.next_to(incorrect_eq, DOWN, buff=0.5).set_color(RED)\n \n self.play(Write(incorrect_eq))\n self.wait(1)\n \n # Indicate error with shake and cross\n cross = Cross(incorrect_eq, stroke_width=6, color=RED)\n self.play(\n Create(cross),\n incorrect_eq.animate.scale(1.1).set_color(RED), run_time=0.2\n )\n self.play(incorrect_eq.animate.scale(1/1.1), run_time=0.2)\n self.play(Write(counter_example))\n self.wait(2)\n\n # --- Scene 2: Correction & Explanation ---\n correct_eq = MathTex(r\"\\sin^2(x) + \\cos^2(x) = 1\", font_size=60)\n correct_eq.move_to(incorrect_eq.get_center())\n identity_text = Text(\"Pythagorean Identity\", color=GREEN, font_size=36).next_to(correct_eq, DOWN)\n \n # Unit Circle Diagram (Simplified)\n unit_circle = Circle(radius=1.5, color=WHITE, stroke_width=2).to_corner(UR)\n circle_label = Text(\"Unit Circle\", font_size=24).next_to(unit_circle, DOWN)\n\n # Morph equation: keep + and = stationary, highlight exponents\n self.play(\n Transform(incorrect_eq, correct_eq),\n FadeOut(cross),\n FadeOut(counter_example),\n TransformFromCopy(incorrect_eq, correct_eq)\n )\n self.play(correct_eq.animate.set_color(GREEN), Write(identity_text))\n self.play(FadeIn(unit_circle), FadeIn(circle_label))\n self.wait(2)\n self.play(FadeOut(unit_circle), FadeOut(circle_label))\n\n # --- Scene 3: Graphical Visualization ---\n axes = Axes(label_font_size=24, \n x_range=[-2 * PI, 2 * PI, PI],\n y_range=[-1.5, 1.5, 1],\n axis_config={\"include_tip\": True}\n ).shift(DOWN * 1.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n sin_graph = axes.plot(lambda x: np.sin(x), color=BLUE)\n cos_graph = axes.plot(lambda x: np.cos(x), color=ORANGE)\n\n sin_label = MathTex(r\"\\sin(x)\", color=BLUE).next_to(sin_graph, RIGHT)\n cos_label = MathTex(r\"\\cos(x)\", color=ORANGE).next_to(cos_graph, RIGHT)\n\n # Move equation to top\n self.play(correct_eq.animate.to_edge(UP), FadeOut(identity_text))\n\n self.play(Create(axes), Write(labels))\n self.play(Create(sin_graph), Write(sin_label), Create(cos_graph), Write(cos_label))\n \n # Visual indicator that sum varies vs sum of squares is constant\n sum_text = Text(\"Linear sum varies (not constant)\", font_size=28, color=RED).to_edge(DOWN)\n self.play(Write(sum_text))\n self.wait(3)\n\n # --- Scene 4: Final Emphasis ---\n self.play(\n FadeOut(axes), FadeOut(labels), FadeOut(sin_graph),\n FadeOut(cos_graph), FadeOut(sin_label), FadeOut(cos_label),\n FadeOut(sum_text), correct_eq.animate.move_to(ORIGIN)\n )\n\n final_text = Text(\"Always True: The power of two makes the identity hold\", color=GREEN, font_size=32).next_to(correct_eq, DOWN)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 animation scene that displays the product rule formula for derivatives. The equation should be written as: d/dx[f(x)g(x)] = f(x) d/dx g(x) + g(x) d/dx f(x). The equation elements should be split into four \n- Act 2: You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not outp\n- Act 3: Display a square, a circle, a triangle, an arrow, and a star arranged in two rows. Animate the square growing from the center of the screen, the circle expanding outward from its center, the triangle growing upward from ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0404(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_productrulevisualization()\n self.clear_stage()\n self.act_2_performancemetrics()\n self.clear_stage()\n self.act_3_growing()\n\n def act_1_productrulevisualization(self):\n part1 = MathTex(r\"\\frac{d}{dx}[f(x)g(x)]\")\n part2 = MathTex(r\"= f(x) \\frac{d}{dx} g(x)\")\n part3 = MathTex(r\"+\")\n part4 = MathTex(r\"g(x) \\frac{d}{dx} f(x)\")\n\n # Arrange the parts sequentially to form the full equation\n equation_group = VGroup(part1, part2, part3, part4)\n equation_group.arrange(RIGHT, buff=0.2)\n\n # 2. Write Animation\n # Animate these four parts being written onto the screen sequentially\n self.play(Write(part1))\n self.play(Write(part2))\n self.play(Write(part3))\n self.play(Write(part4))\n\n # Timing Constraints: 1-second pause after writing the equation\n self.wait(1)\n\n # 3. Highlighting Logic\n # Create a SurroundingRectangle with a buff of 0.1 units\n # Highlight the first term (Part 2)\n highlight_rect = SurroundingRectangle(part2, buff=0.1, color=YELLOW)\n \n self.play(Create(highlight_rect))\n \n # Timing Constraints: 1-second pause after highlighting the first term\n self.wait(1)\n\n # Transform the rectangle to highlight the second term (Part 4)\n target_rect = SurroundingRectangle(part4, buff=0.1, color=YELLOW)\n self.play(Transform(highlight_rect, target_rect))\n \n # Timing Constraints: 1-second pause after transforming to the second term\n self.wait(1)\n\n def act_2_performancemetrics(self):\n title = Text('Performance Analysis Metrics', 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 data = [['Metric', 'Meaning', 'Optimization Direction'], ['Draw Calls', 'CPU render commands', 'Reduce batches'], ['Vertices', 'Processed vertices', 'LOD, culling'], ['Triangles', 'Processed triangles', 'Simplify geometry'], ['Fill Rate', 'Pixel fill rate', 'Reduce overdraw'], ['Texture Mem', 'Texture memory usage', 'Compress, atlas']]\n rows = VGroup()\n col_x = [-6.0, -2.5, 2.5]\n for i, row_data in enumerate(data):\n row = VGroup()\n for j, text_str in enumerate(row_data):\n color = YELLOW if i == 0 else WHITE\n weight = BOLD if i == 0 else NORMAL\n item = Text(text_str, font_size=24, color=color, weight=weight)\n item.move_to(RIGHT * col_x[j])\n item.align_to(RIGHT * col_x[j], LEFT)\n row.add(item)\n else:\n pass\n row.set_y(-i * 0.7)\n rows.add(row)\n else:\n pass\n rows.set_x(0)\n rows.next_to(title_group, DOWN, buff=0.8)\n header_line = Line(rows[0].get_left(), rows[0].get_right(), color=BLUE).next_to(rows[0], DOWN, buff=0.15)\n table_rect = SurroundingRectangle(rows, color=BLUE_D, buff=0.3)\n self.play(FadeIn(rows[0], shift=DOWN * 0.2), run_time=0.8)\n self.play(Create(header_line), run_time=0.5)\n for i in range(1, len(rows)):\n self.play(FadeIn(rows[i], shift=DOWN * 0.2), run_time=0.4)\n else:\n pass\n self.play(Create(table_rect), run_time=0.8)\n self.wait(1.5)\n\n def act_3_growing(self):\n square = Square()\n circle = Circle()\n triangle = Triangle()\n arrow = Arrow(LEFT, RIGHT)\n star = Star()\n\n VGroup(square, circle, triangle).set_x(0).arrange(buff=1.5).set_y(2)\n VGroup(arrow, star).move_to(DOWN).set_x(0).arrange(buff=1.5).set_y(-2)\n\n self.play(GrowFromPoint(square, ORIGIN))\n self.play(GrowFromCenter(circle))\n self.play(GrowFromEdge(triangle, DOWN))\n self.play(GrowArrow(arrow))\n self.play(SpinInFromNothing(star))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0404(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_productrulevisualization()\n self.clear_stage()\n self.act_2_performancemetrics()\n self.clear_stage()\n self.act_3_growing()\n\n def act_1_productrulevisualization(self):\n part1 = MathText(r\"\\frac{d}{dx}[f(x)g(x)]\")\n part2 = MathTex(r\"= f(x) \\frac{d}{dx} g(x)\")\n part3 = MathTex(r\"+\")\n part4 = MathTex(r\"g(x) \\frac{d}{dx} f(x)\")\n\n # Arrange the parts sequentially to form the full equation\n equation_group = VGroup(part1, part2, part3, part4)\n equation_group.arrange(RIGHT, buff=0.2)\n\n # 2. Write Animation\n # Animate these four parts being written onto the screen sequentially\n self.play(Write(part1))\n self.play(Write(part2))\n self.play(Write(part3))\n self.play(Write(part4))\n\n # Timing Constraints: 1-second pause after writing the equation\n self.wait(1)\n\n # 3. Highlighting Logic\n # Create a SurroundingRectangle with a buff of 0.1 units\n # Highlight the first term (Part 2)\n highlight_rect = SurroundingRectangle(part2, buff=0.1, color=YELLOW)\n \n self.play(Create(highlight_rect))\n \n # Timing Constraints: 1-second pause after highlighting the first term\n self.wait(1)\n\n # Transform the rectangle to highlight the second term (Part 4)\n target_rect = SurroundingRectangle(part4, buff=0.1, color=YELLOW)\n self.play(Transform(highlight_rect, target_rect))\n \n # Timing Constraints: 1-second pause after transforming to the second term\n self.wait(1)\n\n def act_2_performancemetrics(self):\n title = Text('Performance Analysis Metrics', 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 data = [['Metric', 'Meaning', 'Optimization Direction'], ['Draw Calls', 'CPU render commands', 'Reduce batches'], ['Vertices', 'Processed vertices', 'LOD, culling'], ['Triangles', 'Processed triangles', 'Simplify geometry'], ['Fill Rate', 'Pixel fill rate', 'Reduce overdraw'], ['Texture Mem', 'Texture memory usage', 'Compress, atlas']]\n rows = VGroup()\n col_x = [-6.0, -2.5, 2.5]\n for i, row_data in enumerate(data):\n row = VGroup()\n for j, text_str in enumerate(row_data):\n color = YELLOW if i == 0 else WHITE\n weight = BOLD if i == 0 else NORMAL\n item = Text(text_str, font_size=24, color=color, weight=weight)\n item.move_to(RIGHT * col_x[j])\n item.align_to(RIGHT * col_x[j], LEFT)\n row.add(item)\n else:\n pass\n row.set_y(-i * 0.7)\n rows.add(row)\n else:\n pass\n rows.set_x(0)\n rows.next_to(title_group, DOWN, buff=0.8)\n header_line = Line(rows[0].get_left(), rows[0].get_right(), color=BLUE).next_to(rows[0], DOWN, buff=0.15)\n table_rect = SurroundingRectangle(rows, color=BLUE_D, buff=0.3)\n self.play(FadeIn(rows[0], shift=DOWN * 0.2), run_time=0.8)\n self.play(Create(header_line), run_time=0.5)\n for i in range(1, len(rows)):\n self.play(FadeIn(rows[i], shift=DOWN * 0.2), run_time=0.4)\n else:\n pass\n self.play(Create(table_rect), run_time=0.8)\n self.wait(1.5)\n\n def act_3_growing(self):\n square = Square()\n circle = Circle()\n triangle = Triangle()\n arrow = Arrow(LEFT, RIGHT)\n star = Star()\n\n VGroup(square, circle, triangle).set_x(0).arrange(buff=1.5).set_y(2)\n VGroup(arrow, star).move_to(DOWN).set_x(0).arrange(buff=1.5).set_y(-2)\n\n self.play(GrowFromPoint(square, ORIGIN))\n self.play(GrowFromCenter(circle))\n self.play(GrowFromEdge(triangle, DOWN))\n self.play(GrowArrow(arrow))\n self.play(SpinInFromNothing(star))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Individual Fairness: Focusing on Consistent Treatment Among Individuals\nThe core concept of individual fairness is that \"similar individuals should be treated similarly.\" Unlike group fairness, which focuses on macro-level statistics, individual fairness requires that an algorithm provide similar prediction results for two individuals with similar features, unaffected by sensitive attributes.\n\n\nContextual location of this section (from highest to current level):\n# Algorithmic Bias and Fairness - Eliminating \"Digital Discrimination\" in Algorithms\n## Mathematical Definitions and Conflicts of Fairness\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass IndividualFairness(Scene):\n\n def construct(self):\n title = Text('Individual Fairness', font_size=42, weight=BOLD, color=BLUE)\n title.to_edge(UP, buff=0.4)\n quote = Text('\"Similar individuals should be treated similarly.\"', font_size=32, slant=ITALIC)\n quote.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(quote, shift=UP * 0.2))\n self.wait(1)\n visual_y_offset = 0.2\n ind1 = Square(side_length=0.8, color=TEAL, fill_opacity=0.7)\n ind1.move_to(LEFT * 4.5 + UP * (0.7 + visual_y_offset))\n ind2 = Square(side_length=0.8, color=MAROON, fill_opacity=0.7)\n ind2.move_to(LEFT * 4.5 + DOWN * (0.7 - visual_y_offset))\n ind_label = Text('Similar Features\\n(Different Sensitive Attr.)', font_size=20, line_spacing=1)\n ind_label.next_to(VGroup(ind1, ind2), UP, buff=0.3)\n algo_box = RoundedRectangle(corner_radius=0.2, width=2.5, height=2.5, color=WHITE)\n algo_box.move_to(UP * visual_y_offset)\n algo_text = Text('Algorithm', font_size=28)\n algo_text.move_to(algo_box.get_center())\n algo_group = VGroup(algo_box, algo_text)\n out1 = Text('Score: 0.85', font_size=24, color=GREEN)\n out1.move_to(RIGHT * 4.5 + UP * (0.7 + visual_y_offset))\n out2 = Text('Score: 0.84', font_size=24, color=GREEN)\n out2.move_to(RIGHT * 4.5 + DOWN * (0.7 - visual_y_offset))\n out_label = Text('Similar Predictions', font_size=20)\n out_label.next_to(VGroup(out1, out2), UP, buff=0.3)\n approx_sign = MathTex('\\\\approx', font_size=36)\n approx_sign.move_to(VGroup(out1, out2).get_center())\n a1 = Arrow(ind1.get_right(), algo_box.get_left() + UP * 0.7, buff=0.2, max_tip_length_to_length_ratio=0.1)\n a2 = Arrow(ind2.get_right(), algo_box.get_left() + DOWN * 0.7, buff=0.2, max_tip_length_to_length_ratio=0.1)\n a3 = Arrow(algo_box.get_right() + UP * 0.7, out1.get_left(), buff=0.2, max_tip_length_to_length_ratio=0.1)\n a4 = Arrow(algo_box.get_right() + DOWN * 0.7, out2.get_left(), buff=0.2, max_tip_length_to_length_ratio=0.1)\n self.play(FadeIn(ind1, shift=RIGHT * 0.2), FadeIn(ind2, shift=RIGHT * 0.2))\n self.play(Write(ind_label))\n self.wait(0.5)\n self.play(Create(algo_group))\n self.play(GrowArrow(a1), GrowArrow(a2))\n self.wait(0.5)\n self.play(GrowArrow(a3), GrowArrow(a4))\n self.play(Write(out1), Write(out2))\n self.play(Write(out_label))\n self.play(Write(approx_sign))\n self.wait(1)\n b1 = Text('• Unlike group fairness (macro-level), it focuses on individual consistency.', font_size=22)\n b2 = Text('• Requires similar predictions for individuals with similar features.', font_size=22)\n b3 = Text('• Ensures outcomes are unaffected by sensitive attributes.', font_size=22)\n bullets = VGroup(b1, b2, b3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n bullets.to_edge(DOWN, buff=0.6)\n for b in bullets:\n self.play(FadeIn(b, shift=UP * 0.2))\n self.wait(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 IndividualFairness(Scene):\n\n def construct(self):\n title = Text('Individual Fairness', font_size=42, weight=BOLD, color=BLUE)\n title.to_edge(UP, buff=0.4)\n quote = Text('\"Similar individuals should be treated similarly.\"', font_size=32, slant=ITALIC)\n quote.next_to(title, DOWN, buff=0.3)\n self.play(Write(title))\n self.play(FadeIn(quote, shift=UP * 0.2))\n self.wait(1)\n visual_y_offset = 0.2\n ind1 = Square(side_length=0.8, color=TEAL, fill_opacity=0.7)\n ind1.move_to(LEFT * 4.5 + UP * (0.7 + visual_y_offset))\n ind2 = Square(side_length=0.8, color=MAROON, fill_opacity=0.7)\n ind2.move_to(LEFT * 4.5 + DOWN * (0.7 - visual_y_offset))\n ind_label = Text('Similar Features\\n(Different Sensitive Attr.)', font_size=20, line_spacing=1)\n ind_label.next_to(VGroup(ind1, ind2), UP, buff=0.3)\n algo_box = RoundedRectangle(corner_radius=0.2, width=2.5, height=2.5, color=WHITE)\n algo_box.move_to(UP * visual_y_offset)\n algo_text = Text('Algorithm', font_size=28)\n algo_text.move_to(algo_box.get_center())\n algo_group = VGroup(algo_box, algo_text)\n out1 = Text('Score: 0.85', font_size=24, color=GREEN)\n out1.move_to(RIGHT * 4.5 + UP * (0.7 + visual_y_offset))\n out2 = Text('Score: 0.84', font_size=24, color=GREEN)\n out2.move_to(RIGHT * 4.5 + DOWN * (0.7 - visual_y_offset))\n out_label = Text('Similar Predictions', font_size=20)\n out_label.next_to(VGroup(out1, out2), UP, buff=0.3)\n approx_sign = MathText('\\\\approx', font_size=36)\n approx_sign.move_to(VGroup(out1, out2).get_center())\n a1 = Arrow(ind1.get_right(), algo_box.get_left() + UP * 0.7, buff=0.2, max_tip_length_to_length_ratio=0.1)\n a2 = Arrow(ind2.get_right(), algo_box.get_left() + DOWN * 0.7, buff=0.2, max_tip_length_to_length_ratio=0.1)\n a3 = Arrow(algo_box.get_right() + UP * 0.7, out1.get_left(), buff=0.2, max_tip_length_to_length_ratio=0.1)\n a4 = Arrow(algo_box.get_right() + DOWN * 0.7, out2.get_left(), buff=0.2, max_tip_length_to_length_ratio=0.1)\n self.play(FadeIn(ind1, shift=RIGHT * 0.2), FadeIn(ind2, shift=RIGHT * 0.2))\n self.play(Write(ind_label))\n self.wait(0.5)\n self.play(Create(algo_group))\n self.play(GrowArrow(a1), GrowArrow(a2))\n self.wait(0.5)\n self.play(GrowArrow(a3), GrowArrow(a4))\n self.play(Write(out1), Write(out2))\n self.play(Write(out_label))\n self.play(Write(approx_sign))\n self.wait(1)\n b1 = Text('• Unlike group fairness (macro-level), it focuses on individual consistency.', font_size=22)\n b2 = Text('• Requires similar predictions for individuals with similar features.', font_size=22)\n b3 = Text('• Ensures outcomes are unaffected by sensitive attributes.', font_size=22)\n bullets = VGroup(b1, b2, b3).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n bullets.to_edge(DOWN, buff=0.6)\n for b in bullets:\n self.play(FadeIn(b, shift=UP * 0.2))\n self.wait(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Recursive Branch Omissions\n- The function does not return a value or has undefined behavior for certain inputs;\n- Suggest listing all possible parameter values to ensure complete coverage.\n\n\nThe context of this section (from highest to current level):\n# Recursion and Problem Solving - Course Notes\n## Common Recursive Errors and Debugging Approaches\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass RecursiveBranchOmissions(Scene):\n\n def construct(self):\n title = Text('Recursive Branch Omissions', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.0), GrowFromCenter(title_line, run_time=0.6))\n b1 = Text('- Problem: Undefined behavior when inputs hit an unhandled branch.', font_size=24)\n b1.next_to(title_group, DOWN, buff=0.4)\n self.play(FadeIn(b1, shift=RIGHT, run_time=0.8))\n code_str = 'def process(n):\\n if n > 0:\\n return process(n - 1)\\n elif n == 0:\\n return 1\\n # Omitted branch: n < 0'\n code_obj = Text(code_str, font_size=20, line_spacing=1.2)\n code_bg = SurroundingRectangle(code_obj, color=BLUE, fill_color=BLACK, fill_opacity=0.8, buff=0.3)\n code_group = VGroup(code_bg, code_obj)\n domain_title = Text('Input Domain Check', font_size=22, color=YELLOW)\n cond1 = Text('n > 0', font_size=20)\n cond2 = Text('n == 0', font_size=20)\n cond3 = Text('n < 0', font_size=20)\n cond_group = VGroup(cond1, cond2, cond3).arrange(DOWN, buff=0.6)\n box1 = SurroundingRectangle(cond1, color=GREEN, buff=0.15)\n box2 = SurroundingRectangle(cond2, color=GREEN, buff=0.15)\n box3 = SurroundingRectangle(cond3, color=RED, buff=0.15)\n stat1 = Text('Covered', font_size=18, color=GREEN).next_to(box1, RIGHT, buff=0.3)\n stat2 = Text('Covered', font_size=18, color=GREEN).next_to(box2, RIGHT, buff=0.3)\n stat3 = Text('Omitted!', font_size=18, color=RED).next_to(box3, RIGHT, buff=0.3)\n check_items = VGroup(cond_group, box1, box2, box3, stat1, stat2, stat3)\n domain_title.next_to(check_items, UP, buff=0.5)\n check_group = VGroup(domain_title, check_items)\n content_group = VGroup(code_group, check_group).arrange(RIGHT, buff=1.5)\n content_group.next_to(b1, DOWN, buff=0.6)\n self.play(Create(code_bg), Write(code_obj), run_time=2.0)\n self.play(Write(domain_title, run_time=0.8))\n self.play(Write(cond1), Create(box1), Write(stat1), run_time=0.8)\n self.play(Write(cond2), Create(box2), Write(stat2), run_time=0.8)\n self.play(Write(cond3), Create(box3), Write(stat3), run_time=0.8)\n b2 = Text('- Solution: List all parameter ranges to ensure complete coverage.', font_size=24, color=ORANGE)\n b2.next_to(content_group, DOWN, buff=0.6)\n self.play(FadeIn(b2, shift=UP, run_time=0.8))\n self.wait(1.0)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass RecursiveBranchOmissions(Scene):\n\n def construct(self):\n title = Text('Recursive Branch Omissions', font_size=34, color=WHITE, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n title_line = Line(LEFT, RIGHT, color=ORANGE).next_to(title, DOWN, buff=0.1)\n title_line.match_width(title)\n title_group = VGroup(title, title_line)\n self.play(Write(title, run_time=1.0), GrowFromCenter(title_line, run_time=0.6))\n b1 = Text('- Problem: Undefined behavior when inputs hit an unhandled branch.', font_size=24)\n b1.next_to(title_group, DOWN, buff=0.4)\n self.play(FadeIn(b1, shift=RIGHT, run_time=0.8))\n code_str = 'def process(n):\\n if n > 0:\\n return process(n - 1)\\n elif n == 0:\\n return 1\\n # Omitted branch: n < 0'\n code_obj = Text(code_str, font_size=20, line_spacing=1.2)\n code_bg = SurroundingRectangle(code_obj, color=BBLUE, fill_color=BLACK, fill_opacity=0.8, buff=0.3)\n code_group = VGroup(code_bg, code_obj)\n domain_title = Text('Input Domain Check', font_size=22, color=YELLOW)\n cond1 = Text('n > 0', font_size=20)\n cond2 = Text('n == 0', font_size=20)\n cond3 = Text('n < 0', font_size=20)\n cond_group = VGroup(cond1, cond2, cond3).arrange(DOWN, buff=0.6)\n box1 = SurroundingRectangle(cond1, color=GREEN, buff=0.15)\n box2 = SurroundingRectangle(cond2, color=GREEN, buff=0.15)\n box3 = SurroundingRectangle(cond3, color=RED, buff=0.15)\n stat1 = Text('Covered', font_size=18, color=GREEN).next_to(box1, RIGHT, buff=0.3)\n stat2 = Text('Covered', font_size=18, color=GREEN).next_to(box2, RIGHT, buff=0.3)\n stat3 = Text('Omitted!', font_size=18, color=RED).next_to(box3, RIGHT, buff=0.3)\n check_items = VGroup(cond_group, box1, box2, box3, stat1, stat2, stat3)\n domain_title.next_to(check_items, UP, buff=0.5)\n check_group = VGroup(domain_title, check_items)\n content_group = VGroup(code_group, check_group).arrange(RIGHT, buff=1.5)\n content_group.next_to(b1, DOWN, buff=0.6)\n self.play(Create(code_bg), Write(code_obj), run_time=2.0)\n self.play(Write(domain_title, run_time=0.8))\n self.play(Write(cond1), Create(box1), Write(stat1), run_time=0.8)\n self.play(Write(cond2), Create(box2), Write(stat2), run_time=0.8)\n self.play(Write(cond3), Create(box3), Write(stat3), run_time=0.8)\n b2 = Text('- Solution: List all parameter ranges to ensure complete coverage.', font_size=24, color=ORANGE)\n b2.next_to(content_group, DOWN, buff=0.6)\n self.play(FadeIn(b2, shift=UP, run_time=0.8))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 process of solving the integral of x*cos(x^2) with respect to x using the method of integration by substitution? The steps should include the following: First, show the original integral. Next, animate the substitution of u = x^2 and the calculation of du. Then, display the rewritten integral in terms of u. Afterward, show the process of integrating with respect to u to get the antiderivative. Finally, replace u with x^2 to show the result back in terms of x. Include pauses after each step so the viewers have time to understand the material.", "chosen": "```python\nfrom manim import *\n\nclass IntegrationBySubstitution(Scene):\n def construct(self):\n # --- Step 1: Display the original integral ---\n original_integral = MathTex(r\"\\int\", \"x\", r\"\\cos(\", \"x^2\", \")\", \"\\,dx\").scale(1.5)\n step1_label = Text(\"Step 1: Original Integral\", font_size=28).next_to(original_integral, UP, buff=0.5)\n \n self.play(Write(step1_label), Write(original_integral))\n self.wait(2)\n self.play(FadeOut(step1_label))\n\n # --- Step 2: Animate the substitution definition and differential calculation ---\n sub_u = MathTex(\"u\", \"=\", \"x^2\")\n sub_du = MathTex(\"du\", \"=\", \"2x\", \"\\,dx\", r\"\\quad \\Rightarrow \\quad\", r\"\\frac{1}{2}\", \"du\", \"=\", \"x\", \"\\,dx\")\n substitution_group = VGroup(sub_u, sub_du).arrange(DOWN, aligned_edge=LEFT).to_edge(UP)\n \n # Color coding for clarity\n sub_u[0].set_color(BLUE) # u\n sub_u[2].set_color(YELLOW) # x^2\n sub_du[0].set_color(BLUE) # du\n sub_du[2:4].set_color(YELLOW) # 2x dx\n sub_du[5].set_color(BLUE) # 1/2 du\n sub_du[7:9].set_color(YELLOW) # x dx\n\n step2_label = Text(\"Step 2: Define Substitution\", font_size=28).next_to(substitution_group, UP, buff=0.3)\n \n self.play(Write(step2_label), Write(sub_u))\n self.wait(1)\n self.play(Write(sub_du))\n self.wait(2)\n \n # Highlight the parts being substituted in the original integral\n original_integral[1].set_color(YELLOW) # x\n original_integral[3].set_color(YELLOW) # x^2\n original_integral[5].set_color(YELLOW) # dx\n \n self.play(\n original_integral[1].animate.set_color(YELLOW),\n original_integral[3].animate.set_color(YELLOW),\n original_integral[5].animate.set_color(YELLOW),\n run_time=1\n )\n self.wait(1)\n self.play(FadeOut(step2_label))\n\n # --- Step 3: Transform and display the integral in terms of u ---\n u_integral = MathTex(r\"\\frac{1}{2}\", r\"\\int\", r\"\\cos(\", \"u\", \")\", \"\\,du\").scale(1.5)\n u_integral[3].set_color(BLUE) # u\n u_integral[5].set_color(BLUE) # du\n \n step3_label = Text(\"Step 3: Rewrite in terms of u\", font_size=28).next_to(u_integral, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(original_integral, u_integral),\n FadeOut(substitution_group),\n FadeIn(step3_label)\n )\n self.wait(2)\n self.play(FadeOut(step3_label))\n\n # --- Step 4: Animate the integration process to find the antiderivative in terms of u ---\n u_antiderivative = MathTex(r\"\\frac{1}{2}\", r\"\\sin(\", \"u\", \")\", \"+ C\").scale(1.5)\n u_antiderivative[2].set_color(BLUE) # u\n \n step4_label = Text(\"Step 4: Integrate with respect to u\", font_size=28).next_to(u_antiderivative, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(u_integral, u_antiderivative),\n FadeIn(step4_label)\n )\n self.wait(2)\n self.play(FadeOut(step4_label))\n\n # --- Step 5: Substitute x^2 back for u to display the final result in terms of x ---\n final_result = MathTex(r\"\\frac{1}{2}\", r\"\\sin(\", \"x^2\", \")\", \"+ C\").scale(1.5)\n final_result[2].set_color(YELLOW) # x^2\n \n step5_label = Text(\"Step 5: Back-Substitute\", font_size=28).next_to(final_result, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(u_antiderivative, final_result),\n FadeIn(step5_label)\n )\n self.wait(2)\n \n # Final emphasis: Box the result\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.15)\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup\n self.play(FadeOut(step5_label), FadeOut(final_result), FadeOut(box))\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrationBySubstitution(Scene):\n def construct(self):\n # --- Step 1: Display the original integral ---\n original_integral = MathText(r\"\\int\", \"x\", r\"\\cos(\", \"x^2\", \")\", \"\\,dx\").scale(1.5)\n step1_label = Text(\"Step 1: Original Integral\", font_size=28).next_to(original_integral, UP, buff=0.5)\n \n self.play(Write(step1_label), Write(original_integral))\n self.wait(2)\n self.play(FadeOut(step1_label))\n\n # --- Step 2: Animate the substitution definition and differential calculation ---\n sub_u = MathTex(\"u\", \"=\", \"x^2\")\n sub_du = MathTex(\"du\", \"=\", \"2x\", \"\\,dx\", r\"\\quad \\Rightarrow \\quad\", r\"\\frac{1}{2}\", \"du\", \"=\", \"x\", \"\\,dx\")\n substitution_group = VGroup(sub_u, sub_du).arrange(DOWN, aligned_edge=LEFT).to_edge(UP)\n \n # Color coding for clarity\n sub_u[0].set_color(BLUE) # u\n sub_u[2].set_color(YELLOW) # x^2\n sub_du[0].set_color(BLUE) # du\n sub_du[2:4].set_color(YELLOW) # 2x dx\n sub_du[5].set_color(BLUE) # 1/2 du\n sub_du[7:9].set_color(YELLOW) # x dx\n\n step2_label = Text(\"Step 2: Define Substitution\", font_size=28).next_to(substitution_group, UP, buff=0.3)\n \n self.play(Write(step2_label), Write(sub_u))\n self.wait(1)\n self.play(Write(sub_du))\n self.wait(2)\n \n # Highlight the parts being substituted in the original integral\n original_integral[1].set_color(YELLOW) # x\n original_integral[3].set_color(YELLOW) # x^2\n original_integral[5].set_color(YELLOW) # dx\n \n self.play(\n original_integral[1].animate.set_color(YELLOW),\n original_integral[3].animate.set_color(YELLOW),\n original_integral[5].animate.set_color(YELLOW),\n run_time=1\n )\n self.wait(1)\n self.play(FadeOut(step2_label))\n\n # --- Step 3: Transform and display the integral in terms of u ---\n u_integral = MathTex(r\"\\frac{1}{2}\", r\"\\int\", r\"\\cos(\", \"u\", \")\", \"\\,du\").scale(1.5)\n u_integral[3].set_color(BLUE) # u\n u_integral[5].set_color(BLUE) # du\n \n step3_label = Text(\"Step 3: Rewrite in terms of u\", font_size=28).next_to(u_integral, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(original_integral, u_integral),\n FadeOut(substitution_group),\n FadeIn(step3_label)\n )\n self.wait(2)\n self.play(FadeOut(step3_label))\n\n # --- Step 4: Animate the integration process to find the antiderivative in terms of u ---\n u_antiderivative = MathTex(r\"\\frac{1}{2}\", r\"\\sin(\", \"u\", \")\", \"+ C\").scale(1.5)\n u_antiderivative[2].set_color(BLUE) # u\n \n step4_label = Text(\"Step 4: Integrate with respect to u\", font_size=28).next_to(u_antiderivative, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(u_integral, u_antiderivative),\n FadeIn(step4_label)\n )\n self.wait(2)\n self.play(FadeOut(step4_label))\n\n # --- Step 5: Substitute x^2 back for u to display the final result in terms of x ---\n final_result = MathTex(r\"\\frac{1}{2}\", r\"\\sin(\", \"x^2\", \")\", \"+ C\").scale(1.5)\n final_result[2].set_color(YELLOW) # x^2\n \n step5_label = Text(\"Step 5: Back-Substitute\", font_size=28).next_to(final_result, UP, buff=0.5)\n \n self.play(\n ReplacementTransform(u_antiderivative, final_result),\n FadeIn(step5_label)\n )\n self.wait(2)\n \n # Final emphasis: Box the result\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.15)\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup\n self.play(FadeOut(step5_label), FadeOut(final_result), FadeOut(box))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 TransformMatchingJacobianStory(Scene):\n def construct(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 *\n\nclass TransformMatchingJacobianStory(Scene):\n def construct(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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralExplanation(Scene):\n def construct(self):\n # --- Colors ---\n COLOR_FUNC = BLUE\n COLOR_LIMIT = GREEN\n COLOR_RULE = YELLOW\n COLOR_CALC = ORANGE\n COLOR_FINAL = GOLD\n\n # 1. Setup: Display the integral expression\n title = Text(\"Calculating the Definite Integral\", font_size=36).to_edge(UP)\n integral_expr = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=72)\n integral_expr.set_color_by_tex(\"x^3\", COLOR_FUNC)\n integral_expr.set_color_by_tex(\"0\", COLOR_LIMIT)\n integral_expr.set_color_by_tex(\"2\", COLOR_LIMIT)\n \n self.play(Write(title))\n self.play(Write(integral_expr))\n self.wait(1.5)\n\n # 2. Power Rule: Explicitly show the application of the power rule\n rule_label = Text(\"Power Rule:\", font_size=36, color=COLOR_RULE)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40, color=COLOR_RULE)\n rule_group = VGroup(rule_label, power_rule).arrange(RIGHT, buff=0.3)\n rule_group.next_to(integral_expr, DOWN, buff=1)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(2)\n\n # 3. Antiderivative: Display the resulting antiderivative function\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=72)\n antiderivative.set_color_by_tex(\"x^4\", COLOR_FUNC)\n antiderivative.set_color_by_tex(\"0\", COLOR_LIMIT)\n antiderivative.set_color_by_tex(\"2\", COLOR_LIMIT)\n \n self.play(\n ReplacementTransform(integral_expr, antiderivative),\n FadeOut(rule_group)\n )\n self.wait(2)\n\n # 4. Boundary Evaluation: Substitution of upper and lower limits\n evaluation = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=72, color=COLOR_CALC)\n \n self.play(ReplacementTransform(antiderivative, evaluation))\n self.wait(2)\n\n # 5. Calculation: Perform the subtraction visually\n calc_step = MathTex(r\"\\frac{16}{4} - 0\", font_size=72, color=COLOR_CALC)\n \n self.play(ReplacementTransform(evaluation, calc_step))\n self.wait(2)\n\n # 6. Final Answer: Display the final simplified numerical result\n final_answer = MathTex(r\"= 4\", font_size=96, color=COLOR_FINAL)\n final_answer.next_to(calc_step, RIGHT, buff=0.2)\n \n box = SurroundingRectangle(final_answer, color=WHITE, buff=0.3)\n \n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup\n self.play(FadeOut(title), FadeOut(calc_step), FadeOut(final_answer), FadeOut(box))\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralExplanation(Scene):\n def construct(self):\n # --- Colors ---\n COLOR_FUNC = BLUE\n COLOR_LIMIT = GREEN\n COLOR_RULE = YELLOW\n COLOR_CALC = ORANGE\n COLOR_FINAL = GOLD\n\n # 1. Setup: Display the integral expression\n title = Text(\"Calculating the Definite Integral\", font_size=36).to_edge(UP)\n integral_expr = MathText(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=72)\n integral_expr.set_color_by_tex(\"x^3\", COLOR_FUNC)\n integral_expr.set_color_by_tex(\"0\", COLOR_LIMIT)\n integral_expr.set_color_by_tex(\"2\", COLOR_LIMIT)\n \n self.play(Write(title))\n self.play(Write(integral_expr))\n self.wait(1.5)\n\n # 2. Power Rule: Explicitly show the application of the power rule\n rule_label = Text(\"Power Rule:\", font_size=36, color=COLOR_RULE)\n power_rule = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=40, color=COLOR_RULE)\n rule_group = VGroup(rule_label, power_rule).arrange(RIGHT, buff=0.3)\n rule_group.next_to(integral_expr, DOWN, buff=1)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(2)\n\n # 3. Antiderivative: Display the resulting antiderivative function\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=72)\n antiderivative.set_color_by_tex(\"x^4\", COLOR_FUNC)\n antiderivative.set_color_by_tex(\"0\", COLOR_LIMIT)\n antiderivative.set_color_by_tex(\"2\", COLOR_LIMIT)\n \n self.play(\n ReplacementTransform(integral_expr, antiderivative),\n FadeOut(rule_group)\n )\n self.wait(2)\n\n # 4. Boundary Evaluation: Substitution of upper and lower limits\n evaluation = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=72, color=COLOR_CALC)\n \n self.play(ReplacementTransform(antiderivative, evaluation))\n self.wait(2)\n\n # 5. Calculation: Perform the subtraction visually\n calc_step = MathTex(r\"\\frac{16}{4} - 0\", font_size=72, color=COLOR_CALC)\n \n self.play(ReplacementTransform(evaluation, calc_step))\n self.wait(2)\n\n # 6. Final Answer: Display the final simplified numerical result\n final_answer = MathTex(r\"= 4\", font_size=96, color=COLOR_FINAL)\n final_answer.next_to(calc_step, RIGHT, buff=0.2)\n \n box = SurroundingRectangle(final_answer, color=WHITE, buff=0.3)\n \n self.play(Write(final_answer))\n self.play(Create(box))\n self.wait(3)\n\n # Final cleanup\n self.play(FadeOut(title), FadeOut(calc_step), FadeOut(final_answer), FadeOut(box))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 in which a labeled ball bounces inside a rectangular box to represent a particle in a confined space. The ball should have properties of velocity and acceleration, reacting to the edges of the box by changing direction as it hits them. Additionally, display the version number of the animation in the top-right corner. The ball label should match the version number displayed. Later on, introduce more balls with different labels like Greek letters Psi, Alpha, and Lambda. Apply some physics to simulate gravity affecting the balls' vertical movement. Finally, create a smaller, translucent cutout of the scenario, move it to the right, and then fade out all objects except for a Manim banner at the bottom right, which then expands to fill the screen. Can we make the animation background a soft cream color and add a touch of branding with our logo at the end?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ParticleSimulation(Scene):\n def construct(self):\n # --- 1. Scene Setup ---\n self.camera.background_color = \"#FFFDD0\" # Soft cream background\n \n box_width = 6\n box_height = 4\n boundary_box = Rectangle(\n width=box_width, height=box_height, \n color=BLACK, stroke_width=2\n )\n self.add(boundary_box)\n \n # Version display\n version_str = \"v1.0\"\n version_text = Text(f\"Version: {version_str}\", font_size=24, color=BLACK)\n version_text.to_corner(UR, buff=0.5)\n self.add(version_text)\n\n # --- 2. Primary Particle ---\n def create_particle(label, color, pos, velocity, gravity=False):\n ball = Circle(radius=0.3, color=color, fill_opacity=0.9)\n # Use MathTex for Greek letters, Text for standard strings\n lbl = MathTex(label, font_size=20, color=WHITE) if \"\\\\\" in label else Text(label, font_size=20, color=WHITE)\n particle = VGroup(ball, lbl).move_to(pos)\n \n # Physics properties\n particle.velocity = np.array(velocity, dtype=float)\n particle.acceleration = np.array([0, -5.0, 0]) if gravity else np.array([0.0, 0.0, 0.0])\n return particle\n\n primary_particle = create_particle(version_str, BLUE, ORIGIN, [2.5, 2.0, 0])\n self.add(primary_particle)\n\n # --- 3. Physics Updater Logic ---\n def update_physics(mob, dt):\n dt = min(dt, 0.05) # Cap dt to prevent tunneling on lag\n \n # Update velocity and position\n mob.velocity += mob.acceleration * dt\n mob.shift(mob.velocity * dt)\n \n # Get current boundaries and position\n left, right = boundary_box.get_left()[0], boundary_box.get_right()[0]\n bottom, top = boundary_box.get_bottom()[1], boundary_box.get_top()[1]\n pos = mob.get_center()\n radius = mob.width / 2 # Approximate collision radius\n \n # Collision detection and boundary correction\n if pos[0] - radius <= left:\n mob.move_to([left + radius, pos[1], 0])\n mob.velocity[0] *= -1\n elif pos[0] + radius >= right:\n mob.move_to([right - radius, pos[1], 0])\n mob.velocity[0] *= -1\n \n if pos[1] - radius <= bottom:\n mob.move_to([pos[0], bottom + radius, 0])\n mob.velocity[1] *= -1\n elif pos[1] + radius >= top:\n mob.move_to([pos[0], top - radius, 0])\n mob.velocity[1] *= -1\n\n primary_particle.add_updater(update_physics)\n self.wait(3)\n\n # --- 4. Secondary Particles with Gravity ---\n secondary_configs = [\n (r\"\\Psi\", RED, [-2, 1.5, 0], [1.5, 0, 0]),\n (r\"\\alpha\", GREEN, [2, 1, 0], [-1.0, 1.0, 0]),\n (r\"\\lambda\", PURPLE, [0, 1.5, 0], [0.5, -1.0, 0]),\n ]\n \n secondary_particles = VGroup()\n for label, color, pos, vel in secondary_configs:\n p = create_particle(label, color, pos, vel, gravity=True)\n p.add_updater(update_physics)\n secondary_particles.add(p)\n self.play(FadeIn(p), run_time=0.5)\n \n self.wait(3)\n\n # --- 5. Transition: Translucent Cutout ---\n # Group all scenario elements\n scenario_group = VGroup(boundary_box, primary_particle, secondary_particles)\n \n # Stop updaters so the cutout is a static snapshot\n primary_particle.clear_updaters()\n for p in secondary_particles:\n p.clear_updaters()\n \n cutout = scenario_group.copy()\n cutout.scale(0.5).set_opacity(0.5)\n cutout.move_to(scenario_group.get_center())\n self.add(cutout)\n \n # Animate cutout to the right\n self.play(cutout.animate.to_edge(RIGHT, buff=0.5), run_time=2)\n self.wait(1)\n\n # --- 6. Outro: Fade Out & Manim Banner ---\n # Create Manim banner at bottom right\n banner_bg = Rectangle(width=4, height=1.5, color=BLUE_E, fill_opacity=1)\n banner_text = Text(\"Manim Community\", font_size=30, color=WHITE)\n banner = VGroup(banner_bg, banner_text).to_corner(DR, buff=0.5)\n \n # Fade out everything except the banner\n self.play(\n FadeOut(scenario_group),\n FadeOut(cutout),\n FadeOut(version_text),\n FadeIn(banner),\n run_time=1.5\n )\n \n # Expand banner to fill screen\n self.play(banner.animate.scale(10).move_to(ORIGIN), run_time=2)\n \n # --- 7. Branding Logo Placeholder ---\n # Replace 'logo.png' with the actual path to your brand logo file\n # logo = ImageMobject(\"logo.png\").scale(0.5).move_to(ORIGIN)\n # self.play(FadeIn(logo))\n \n # Placeholder shape for demonstration\n logo_placeholder = Star(color=GOLD, fill_opacity=1).scale(0.8).move_to(ORIGIN)\n logo_text = Text(\"BRAND LOGO\", font_size=40, color=WHITE).next_to(logo_placeholder, DOWN)\n logo_group = VGroup(logo_placeholder, logo_text)\n \n self.play(FadeIn(logo_group))\n self.wait(2)\n\n# To run this animation, use: manim -pql filename.py ParticleSimulation\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ParticleSimulation(Scene):\n def construct(self):\n # --- 1. Scene Setup ---\n self.camera.background_color = \"#FFFDD0\" # Soft cream background\n \n box_width = 6\n box_height = 4\n boundary_box = Rectangle(\n width=box_width, height=box_height, \n color=BLACK, stroke_width=2\n )\n self.add(boundary_box)\n \n # Version display\n version_str = \"v1.0\"\n version_text = Text(f\"Version: {version_str}\", font_size=24, color=BLACK)\n version_text.to_corner(UR, buff=0.5)\n self.add(version_text)\n\n # --- 2. Primary Particle ---\n def create_particle(label, color, pos, velocity, gravity=False):\n ball = Circle(radius=0.3, color=color, fill_opacity=0.9)\n # Use MathTex for Greek letters, Text for standard strings\n lbl = MathTex(label, font_size=20, color=WHITE) if \"\\\\\" in label else Text(label, font_size=20, color=WHITE)\n particle = VGroup(ball, lbl).move_to(pos)\n \n # Physics properties\n particle.velocity = np.array(velocity, dtype=float)\n particle.acceleration = np.array([0, -5.0, 0]) if gravity else np.array([0.0, 0.0, 0.0])\n return particle\n\n primary_particle = create_particle(version_str, BBLUE, ORIGIN, [2.5, 2.0, 0])\n self.add(primary_particle)\n\n # --- 3. Physics Updater Logic ---\n def update_physics(mob, dt):\n dt = min(dt, 0.05) # Cap dt to prevent tunneling on lag\n \n # Update velocity and position\n mob.velocity += mob.acceleration * dt\n mob.shift(mob.velocity * dt)\n \n # Get current boundaries and position\n left, right = boundary_box.get_left()[0], boundary_box.get_right()[0]\n bottom, top = boundary_box.get_bottom()[1], boundary_box.get_top()[1]\n pos = mob.get_center()\n radius = mob.width / 2 # Approximate collision radius\n \n # Collision detection and boundary correction\n if pos[0] - radius <= left:\n mob.move_to([left + radius, pos[1], 0])\n mob.velocity[0] *= -1\n elif pos[0] + radius >= right:\n mob.move_to([right - radius, pos[1], 0])\n mob.velocity[0] *= -1\n \n if pos[1] - radius <= bottom:\n mob.move_to([pos[0], bottom + radius, 0])\n mob.velocity[1] *= -1\n elif pos[1] + radius >= top:\n mob.move_to([pos[0], top - radius, 0])\n mob.velocity[1] *= -1\n\n primary_particle.add_updater(update_physics)\n self.wait(3)\n\n # --- 4. Secondary Particles with Gravity ---\n secondary_configs = [\n (r\"\\Psi\", RED, [-2, 1.5, 0], [1.5, 0, 0]),\n (r\"\\alpha\", GREEN, [2, 1, 0], [-1.0, 1.0, 0]),\n (r\"\\lambda\", PURPLE, [0, 1.5, 0], [0.5, -1.0, 0]),\n ]\n \n secondary_particles = VGroup()\n for label, color, pos, vel in secondary_configs:\n p = create_particle(label, color, pos, vel, gravity=True)\n p.add_updater(update_physics)\n secondary_particles.add(p)\n self.play(FadeIn(p), run_time=0.5)\n \n self.wait(3)\n\n # --- 5. Transition: Translucent Cutout ---\n # Group all scenario elements\n scenario_group = VGroup(boundary_box, primary_particle, secondary_particles)\n \n # Stop updaters so the cutout is a static snapshot\n primary_particle.clear_updaters()\n for p in secondary_particles:\n p.clear_updaters()\n \n cutout = scenario_group.copy()\n cutout.scale(0.5).set_opacity(0.5)\n cutout.move_to(scenario_group.get_center())\n self.add(cutout)\n \n # Animate cutout to the right\n self.play(cutout.animate.to_edge(RIGHT, buff=0.5), run_time=2)\n self.wait(1)\n\n # --- 6. Outro: Fade Out & Manim Banner ---\n # Create Manim banner at bottom right\n banner_bg = Rectangle(width=4, height=1.5, color=BLUE_E, fill_opacity=1)\n banner_text = Text(\"Manim Community\", font_size=30, color=WHITE)\n banner = VGroup(banner_bg, banner_text).to_corner(DR, buff=0.5)\n \n # Fade out everything except the banner\n self.play(\n FadeOut(scenario_group),\n FadeOut(cutout),\n FadeOut(version_text),\n FadeIn(banner),\n run_time=1.5\n )\n \n # Expand banner to fill screen\n self.play(banner.animate.scale(10).move_to(ORIGIN), run_time=2)\n \n # --- 7. Branding Logo Placeholder ---\n # Replace 'logo.png' with the actual path to your brand logo file\n # logo = ImageMobject(\"logo.png\").scale(0.5).move_to(ORIGIN)\n # self.play(FadeIn(logo))\n \n # Placeholder shape for demonstration\n logo_placeholder = Star(color=GOLD, fill_opacity=1).scale(0.8).move_to(ORIGIN)\n logo_text = Text(\"BRAND LOGO\", font_size=40, color=WHITE).next_to(logo_placeholder, DOWN)\n logo_group = VGroup(logo_placeholder, logo_text)\n \n self.play(FadeIn(logo_group))\n self.wait(2)\n\n# To run this animation, use: manim -pql filename.py ParticleSimulation\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visualization of nodes with varying intensity levels represent the reachability from a given vertex in a weighted directed graph?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass IlluminatingReachability(Scene):\n def construct(self):\n # Set background color\n self.camera.background_color = \"#0B0028\" # Dark blue/purple\n \n # Title\n title = Text(\"Illuminating Reachability in Graphs\", color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Create a simple graph with 5 nodes\n nodes = {}\n positions = {\n \"A\": [-2, 1, 0],\n \"B\": [0, 2, 0],\n \"C\": [2, 1, 0],\n \"D\": [-1, -1, 0],\n \"E\": [1, -1, 0]\n }\n \n # Create nodes with labels\n for label, pos in positions.items():\n circle = Circle(radius=0.4, color=YELLOW, fill_opacity=0.2)\n circle.move_to(pos)\n text = Text(label, font_size=24).move_to(pos)\n nodes[label] = VGroup(circle, text)\n \n # Create VGroup of all nodes\n graph_nodes = VGroup(*nodes.values())\n self.play(Create(graph_nodes))\n self.wait(1)\n \n # Define edges with weights\n edges_info = [\n (\"A\", \"B\", 2),\n (\"A\", \"D\", 1),\n (\"B\", \"C\", 3),\n (\"B\", \"E\", 2),\n (\"D\", \"E\", 4),\n (\"C\", \"E\", 1)\n ]\n \n # Create edges\n edges = VGroup()\n for start, end, weight in edges_info:\n start_pos = positions[start]\n end_pos = positions[end]\n \n # Create arrow\n arrow = Arrow(\n start=start_pos,\n end=end_pos,\n buff=0.4, # Buffer to account for node radius\n color=WHITE\n )\n \n # Add weight label\n mid_point = (np.array(start_pos) + np.array(end_pos)) / 2\n weight_label = Text(str(weight), font_size=20, color=WHITE).move_to(mid_point)\n \n edges.add(VGroup(arrow, weight_label))\n \n self.play(Create(edges))\n self.wait(1)\n \n # Highlight start node\n start_node_text = Text(\"Starting Node\", color=WHITE, font_size=24)\n start_node_text.next_to(title, DOWN, buff=0.5)\n self.play(Write(start_node_text))\n \n # Highlight node A as the starting point\n self.play(nodes[\"A\"][0].animate.set_color(RED).set_fill(RED, opacity=0.8))\n self.wait(1)\n \n # Display key concept 1\n self.play(FadeOut(start_node_text))\n concept1 = Text(\"Paths and Weights\", color=WHITE, font_size=24)\n concept1.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept1))\n \n # Show the first equation\n eq1 = MathTex(r\"d(i,j) = \\min (w(i, j))\", color=WHITE)\n eq1.next_to(concept1, DOWN, buff=0.5)\n self.play(Write(eq1))\n self.wait(1)\n \n # Display key concept 2\n self.play(FadeOut(concept1), FadeOut(eq1))\n concept2 = Text(\"Visualize as Intensity\", color=WHITE, font_size=24)\n concept2.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept2))\n \n # Show the second equation (simplified)\n eq2 = MathTex(r\"\\text{Intensity}(v) = \\frac{1}{\\text{min path weight}}\", color=WHITE)\n eq2.next_to(concept2, DOWN, buff=0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Define distances from node A to other nodes\n distances = {\n \"A\": 0, # Distance to self is 0\n \"B\": 2, # Direct edge with weight 2\n \"C\": 5, # A->B->C with total weight 2+3=5\n \"D\": 1, # Direct edge with weight 1\n \"E\": 4 # A->D->E with total weight 1+3=4\n }\n \n # Visualize reachability as node intensity\n self.play(FadeOut(concept2), FadeOut(eq2))\n concept3 = Text(\"Building the Reachability Map\", color=WHITE, font_size=24)\n concept3.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept3))\n self.wait(1)\n \n # Calculate max distance for normalization\n max_distance = max(distances.values())\n \n # Animate nodes changing color based on distance\n for node_label, distance in distances.items():\n if node_label == \"A\": # Skip the start node\n continue\n \n # Calculate intensity based on distance - closer nodes are brighter\n intensity = 1 - (distance / max_distance) * 0.8\n \n # Interpolate between dark blue (far) and yellow (close)\n color = interpolate_color(DARK_BLUE, YELLOW, intensity)\n \n # Animate the node color change\n self.play(\n nodes[node_label][0].animate.set_color(color).set_fill(color, opacity=intensity),\n run_time=0.5\n )\n \n self.wait(1)\n \n # Final insight\n self.play(FadeOut(concept3))\n insight = Text(\"Revealing the Pattern\", color=WHITE, font_size=24)\n insight.next_to(title, DOWN, buff=0.5)\n self.play(Write(insight))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(insight))\n conclusion = Text(\"Illuminating Reachability in Graphs\", color=WHITE, font_size=24)\n conclusion.next_to(title, DOWN, buff=0.5)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Fade out everything\n self.play(\n FadeOut(title),\n FadeOut(conclusion),\n FadeOut(graph_nodes),\n FadeOut(edges)\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass IlluminatingReachability(Scene):\n def construct(self):\n # Set background color\n self.camera.background_color = \"#0B0028\" # Dark blue/purple\n \n # Title\n title = Text(\"Illuminating Reachability in Graphs\", color=WHITE)\n title.to_edge(UP)\n self.play(Write(title))\n self.wait(1)\n \n # Create a simple graph with 5 nodes\n nodes = {}\n positions = {\n \"A\": [-2, 1, 0],\n \"B\": [0, 2, 0],\n \"C\": [2, 1, 0],\n \"D\": [-1, -1, 0],\n \"E\": [1, -1, 0]\n }\n \n # Create nodes with labels\n for label, pos in positions.items():\n circle = Circle(radius=0.4, color=YELLOW, fill_opacity=0.2)\n circle.move_to(pos)\n text = Text(label, font_size=24).move_to(pos)\n nodes[label] = VGroup(circle, text)\n \n # Create VGroup of all nodes\n graph_nodes = VGroup(*nodes.values())\n self.play(Create(graph_nodes))\n self.wait(1)\n \n # Define edges with weights\n edges_info = [\n (\"A\", \"B\", 2),\n (\"A\", \"D\", 1),\n (\"B\", \"C\", 3),\n (\"B\", \"E\", 2),\n (\"D\", \"E\", 4),\n (\"C\", \"E\", 1)\n ]\n \n # Create edges\n edges = VGroup()\n for start, end, weight in edges_info:\n start_pos = positions[start]\n end_pos = positions[end]\n \n # Create arrow\n arrow = Arrow(\n start=start_pos,\n end=end_pos,\n buff=0.4, # Buffer to account for node radius\n color=WHITE\n )\n \n # Add weight label\n mid_point = (np.array(start_pos) + np.array(end_pos)) / 2\n weight_label = Text(str(weight), font_size=20, color=WHITE).move_to(mid_point)\n \n edges.add(VGroup(arrow, weight_label))\n \n self.play(Create(edges))\n self.wait(1)\n \n # Highlight start node\n start_node_text = Text(\"Starting Node\", color=WHITE, font_size=24)\n start_node_text.next_to(title, DOWN, buff=0.5)\n self.play(Write(start_node_text))\n \n # Highlight node A as the starting point\n self.play(nodes[\"A\"][0].animate.set_color(RED).set_fill(RED, opacity=0.8))\n self.wait(1)\n \n # Display key concept 1\n self.play(FadeOut(start_node_text))\n concept1 = Text(\"Paths and Weights\", color=WHITE, font_size=24)\n concept1.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept1))\n \n # Show the first equation\n eq1 = MathTex(r\"d(i,j) = \\min (w(i, j))\", color=WHITE)\n eq1.next_to(concept1, DOWN, buff=0.5)\n self.play(Write(eq1))\n self.wait(1)\n \n # Display key concept 2\n self.play(FadeOut(concept1), FadeOut(eq1))\n concept2 = Text(\"Visualize as Intensity\", color=WHITE, font_size=24)\n concept2.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept2))\n \n # Show the second equation (simplified)\n eq2 = MathTex(r\"\\text{Intensity}(v) = \\frac{1}{\\text{min path weight}}\", color=WHITE)\n eq2.next_to(concept2, DOWN, buff=0.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Define distances from node A to other nodes\n distances = {\n \"A\": 0, # Distance to self is 0\n \"B\": 2, # Direct edge with weight 2\n \"C\": 5, # A->B->C with total weight 2+3=5\n \"D\": 1, # Direct edge with weight 1\n \"E\": 4 # A->D->E with total weight 1+3=4\n }\n \n # Visualize reachability as node intensity\n self.play(FadeOut(concept2), FadeOut(eq2))\n concept3 = Text(\"Building the Reachability Map\", color=WHITE, font_size=24)\n concept3.next_to(title, DOWN, buff=0.5)\n self.play(Write(concept3))\n self.wait(1)\n \n # Calculate max distance for normalization\n max_distance = max(distances.values())\n \n # Animate nodes changing color based on distance\n for node_label, distance in distances.items():\n if node_label == \"A\": # Skip the start node\n continue\n \n # Calculate intensity based on distance - closer nodes are brighter\n intensity = 1 - (distance / max_distance) * 0.8\n \n # Interpolate between dark blue (far) and yellow (close)\n color = interpolate_color(DARK_BBLUE, YELLOW, intensity)\n \n # Animate the node color change\n self.play(\n nodes[node_label][0].animate.set_color(color).set_fill(color, opacity=intensity),\n run_time=0.5\n )\n \n self.wait(1)\n \n # Final insight\n self.play(FadeOut(concept3))\n insight = Text(\"Revealing the Pattern\", color=WHITE, font_size=24)\n insight.next_to(title, DOWN, buff=0.5)\n self.play(Write(insight))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(insight))\n conclusion = Text(\"Illuminating Reachability in Graphs\", color=WHITE, font_size=24)\n conclusion.next_to(title, DOWN, buff=0.5)\n self.play(Write(conclusion))\n self.wait(2)\n \n # Fade out everything\n self.play(\n FadeOut(title),\n FadeOut(conclusion),\n FadeOut(graph_nodes),\n FadeOut(edges)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using math visuals that explains the concept of finding the area under a curve, specifically demonstrating how to calculate the integral of x squared from 0 to 1? The video should include the following:\n- Start by displaying the integral of x squared from 0 to 1.\n- Then show a graph with the x-axis ranging from 0 to 1 and the y-axis also ranging from 0 to 1, and plot the curve of x squared on it.\n- Next, shade the area under the curve to represent the integral visually.\n- After that, reveal the solution to the integral as one-third and place it below the integral to show the answer.\n- Contrast the shaded area with a caption that reads \"Area under the curve\" above the graph.\n- Finally, conclude the video by removing all elements from the scene.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Display the Integral\n integral_expr = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\")\n integral_expr.to_corner(UL)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 2. Plot the Graph\n axes = Axes(\n x_range=[0, 1.1, 0.2],\n y_range=[0, 1.1, 0.2],\n x_length=4,\n y_length=4,\n axis_config={\"include_tip\": False, \"include_numbers\": True}\n ).shift(RIGHT * 1.5 + DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n curve = axes.plot(lambda x: x**2, x_range=[0, 1], color=BLUE)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # 3. Shade the Area\n shaded_area = axes.get_area(curve, x_range=[0, 1], color=BLUE, opacity=0.3)\n self.play(FadeIn(shaded_area))\n self.wait(1)\n\n # 4. Reveal the Solution\n solution = MathTex(r\"= \\frac{1}{3}\")\n solution.next_to(integral_expr, DOWN, buff=0.5)\n self.play(Write(solution))\n self.wait(1)\n\n # 5. Add Caption\n caption = Text(\"Area under the curve\", font_size=32)\n caption.next_to(axes, UP, buff=0.5)\n self.play(Write(caption))\n self.wait(2)\n\n # 6. Conclusion\n all_elements = VGroup(integral_expr, solution, axes, labels, curve, shaded_area, caption)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Display the Integral\n integral_expr = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\")\n integral_expr.to_corner(UL)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 2. Plot the Graph\n axes = Axes(\n x_range=[0, 1.1, 0.2],\n y_range=[0, 1.1, 0.2],\n x_length=4,\n y_length=4,\n axis_config={\"include_tip\": False, \"include_numbers\": True}\n ).shift(RIGHT * 1.5 + DOWN * 0.5)\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n curve = axes.plot(lambda x: x**2, x_range=[0, 1], color=BBLUE)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # 3. Shade the Area\n shaded_area = axes.get_area(curve, x_range=[0, 1], color=BLUE, opacity=0.3)\n self.play(FadeIn(shaded_area))\n self.wait(1)\n\n # 4. Reveal the Solution\n solution = MathTex(r\"= \\frac{1}{3}\")\n solution.next_to(integral_expr, DOWN, buff=0.5)\n self.play(Write(solution))\n self.wait(1)\n\n # 5. Add Caption\n caption = Text(\"Area under the curve\", font_size=32)\n caption.next_to(axes, UP, buff=0.5)\n self.play(Write(caption))\n self.wait(2)\n\n # 6. Conclusion\n all_elements = VGroup(integral_expr, solution, axes, labels, curve, shaded_area, caption)\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # --- Configuration ---\n layer_sizes = [4, 7, 2]\n layer_colors = [BLUE, GREEN, RED]\n neuron_radius = 0.2\n layer_spacing = 3.0\n neuron_spacing = 0.8\n \n # --- Create Neurons ---\n neurons = []\n for i, size in enumerate(layer_sizes):\n layer = VGroup()\n for j in range(size):\n neuron = Circle(\n radius=neuron_radius,\n stroke_color=layer_colors[i],\n stroke_width=2,\n fill_color=layer_colors[i],\n fill_opacity=0.3\n )\n layer.add(neuron)\n \n # Arrange neurons vertically within the layer\n layer.arrange(DOWN, buff=neuron_spacing)\n neurons.append(layer)\n \n # Position layers horizontally\n for i, layer in enumerate(neurons):\n layer.move_to(ORIGIN + RIGHT * (i - (len(neurons) - 1) / 2) * layer_spacing)\n \n # --- Create Connections (Weights) ---\n connections = []\n connection_list = []\n \n for i in range(len(neurons) - 1):\n layer_connections = VGroup()\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n line = Line(\n n1.get_right(), \n n2.get_left(), \n stroke_color=WHITE, \n stroke_width=1, \n stroke_opacity=0.4\n )\n layer_connections.add(line)\n connection_list.append(line)\n connections.append(layer_connections)\n \n # Put connections behind neurons\n for conn in connections:\n conn.set_z_index(0)\n for layer in neurons:\n layer.set_z_index(1)\n \n # Group everything and center on screen\n network = VGroup(*neurons, *connections)\n network.move_to(ORIGIN)\n \n # --- 1. Introduce the Network ---\n self.play(Create(connections[0]), Create(connections[1]), run_time=1.5)\n self.play(*[Create(layer) for layer in neurons], run_time=1.5)\n self.wait(0.5)\n \n # --- 2. Simulate Training Epochs ---\n num_epochs = 3\n for epoch in range(num_epochs):\n # --- Forward Pass: Signals propagating forward ---\n for i in range(len(neurons) - 1):\n # Create activation pulses moving between layers\n pulse_animations = []\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n if random.random() > 0.3: # Only some connections fire\n pulse = Dot(n1.get_center(), color=YELLOW, radius=0.06)\n self.add(pulse)\n pulse_animations.append(\n pulse.animate.move_to(n2.get_center()).set_opacity(0)\n )\n \n self.play(\n AnimationGroup(*pulse_animations, lag_ratio=0.02), \n run_time=0.7\n )\n # Clean up pulses\n self.remove(*[obj for obj in self.mobjects if isinstance(obj, Dot)])\n \n # Flash neurons upon receiving signal\n self.play(\n neurons[1].animate.set_fill(BLUE, opacity=0.7).set_stroke(BLUE, width=3),\n neurons[2].animate.set_fill(RED, opacity=0.7).set_stroke(RED, width=3),\n run_time=0.2\n )\n self.play(\n neurons[1].animate.set_fill(GREEN, opacity=0.3).set_stroke(GREEN, width=2),\n neurons[2].animate.set_fill(RED, opacity=0.3).set_stroke(RED, width=2),\n run_time=0.2\n )\n \n # --- Weight Update Visualization ---\n # Determine weight visualization based on learning progress\n progress = (epoch + 1) / num_epochs\n base_color = interpolate_color(GRAY, BLUE, progress)\n base_width = interpolate(1, 4, progress)\n \n # Randomly select some weights to \"update\" (change color/width)\n updated_weights = random.sample(connection_list, k=len(connection_list) // 3)\n \n self.play(*[\n line.animate.set_stroke(color=base_color, width=base_width, opacity=1)\n for line in updated_weights\n ], run_time=0.5)\n \n self.play(*[\n line.animate.set_stroke(color=WHITE, width=1, opacity=0.4)\n for line in updated_weights\n ], run_time=0.5)\n \n # Small pause between epochs\n if epoch < num_epochs - 1:\n self.wait(0.5)\n \n # --- 3. Final State Pause ---\n # Highlight active neurons slightly to show final state\n self.play(*[\n neuron.animate.set_fill(opacity=0.8) \n for layer in neurons for neuron in layer\n ], run_time=1)\n \n # Deliberate pause to observe final state\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport random\n\nclass NeuralNetworkTraining(Scene):\n def construct(self):\n # --- Configuration ---\n layer_sizes = [4, 7, 2]\n layer_colors = [BBLUE, GREEN, RED]\n neuron_radius = 0.2\n layer_spacing = 3.0\n neuron_spacing = 0.8\n \n # --- Create Neurons ---\n neurons = []\n for i, size in enumerate(layer_sizes):\n layer = VGroup()\n for j in range(size):\n neuron = Circle(\n radius=neuron_radius,\n stroke_color=layer_colors[i],\n stroke_width=2,\n fill_color=layer_colors[i],\n fill_opacity=0.3\n )\n layer.add(neuron)\n \n # Arrange neurons vertically within the layer\n layer.arrange(DOWN, buff=neuron_spacing)\n neurons.append(layer)\n \n # Position layers horizontally\n for i, layer in enumerate(neurons):\n layer.move_to(ORIGIN + RIGHT * (i - (len(neurons) - 1) / 2) * layer_spacing)\n \n # --- Create Connections (Weights) ---\n connections = []\n connection_list = []\n \n for i in range(len(neurons) - 1):\n layer_connections = VGroup()\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n line = Line(\n n1.get_right(), \n n2.get_left(), \n stroke_color=WHITE, \n stroke_width=1, \n stroke_opacity=0.4\n )\n layer_connections.add(line)\n connection_list.append(line)\n connections.append(layer_connections)\n \n # Put connections behind neurons\n for conn in connections:\n conn.set_z_index(0)\n for layer in neurons:\n layer.set_z_index(1)\n \n # Group everything and center on screen\n network = VGroup(*neurons, *connections)\n network.move_to(ORIGIN)\n \n # --- 1. Introduce the Network ---\n self.play(Create(connections[0]), Create(connections[1]), run_time=1.5)\n self.play(*[Create(layer) for layer in neurons], run_time=1.5)\n self.wait(0.5)\n \n # --- 2. Simulate Training Epochs ---\n num_epochs = 3\n for epoch in range(num_epochs):\n # --- Forward Pass: Signals propagating forward ---\n for i in range(len(neurons) - 1):\n # Create activation pulses moving between layers\n pulse_animations = []\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n if random.random() > 0.3: # Only some connections fire\n pulse = Dot(n1.get_center(), color=YELLOW, radius=0.06)\n self.add(pulse)\n pulse_animations.append(\n pulse.animate.move_to(n2.get_center()).set_opacity(0)\n )\n \n self.play(\n AnimationGroup(*pulse_animations, lag_ratio=0.02), \n run_time=0.7\n )\n # Clean up pulses\n self.remove(*[obj for obj in self.mobjects if isinstance(obj, Dot)])\n \n # Flash neurons upon receiving signal\n self.play(\n neurons[1].animate.set_fill(BLUE, opacity=0.7).set_stroke(BLUE, width=3),\n neurons[2].animate.set_fill(RED, opacity=0.7).set_stroke(RED, width=3),\n run_time=0.2\n )\n self.play(\n neurons[1].animate.set_fill(GREEN, opacity=0.3).set_stroke(GREEN, width=2),\n neurons[2].animate.set_fill(RED, opacity=0.3).set_stroke(RED, width=2),\n run_time=0.2\n )\n \n # --- Weight Update Visualization ---\n # Determine weight visualization based on learning progress\n progress = (epoch + 1) / num_epochs\n base_color = interpolate_color(GRAY, BLUE, progress)\n base_width = interpolate(1, 4, progress)\n \n # Randomly select some weights to \"update\" (change color/width)\n updated_weights = random.sample(connection_list, k=len(connection_list) // 3)\n \n self.play(*[\n line.animate.set_stroke(color=base_color, width=base_width, opacity=1)\n for line in updated_weights\n ], run_time=0.5)\n \n self.play(*[\n line.animate.set_stroke(color=WHITE, width=1, opacity=0.4)\n for line in updated_weights\n ], run_time=0.5)\n \n # Small pause between epochs\n if epoch < num_epochs - 1:\n self.wait(0.5)\n \n # --- 3. Final State Pause ---\n # Highlight active neurons slightly to show final state\n self.play(*[\n neuron.animate.set_fill(opacity=0.8) \n for layer in neurons for neuron in layer\n ], run_time=1)\n \n # Deliberate pause to observe final state\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 linguistics scene demonstrating the constituent substitution test. Display the sentence 'The curious student solved it', bracket the noun phrase 'The curious student', replace that whole phrase with 'She', and clarify that successful substitution is evidence for constituency rather than absolute proof.", "chosen": "```python\nfrom manim import *\n\nclass ConstituentSubstitution(Scene):\n def construct(self):\n title = Text(\"A constituent behaves like one unit\", font_size=38).to_edge(UP)\n words = [\"The\", \"curious\", \"student\", \"solved\", \"it\"]\n cards = VGroup(*[\n VGroup(\n RoundedRectangle(width=max(1.15, 0.18 * len(word) + 0.7), height=0.7, corner_radius=0.1, color=BLUE_B),\n Text(word, font_size=26),\n )\n for word in words\n ]).arrange(RIGHT, buff=0.12)\n subject = VGroup(*cards[:3])\n predicate = VGroup(*cards[3:])\n brace = Brace(subject, DOWN, color=YELLOW)\n brace_label = Text(\"candidate noun phrase\", font_size=23, color=YELLOW).next_to(brace, DOWN)\n question = Text(\"Can this sequence be replaced as a unit?\", font_size=26).to_edge(DOWN)\n\n self.play(Write(title), LaggedStart(*[FadeIn(card) for card in cards], lag_ratio=0.15))\n self.play(GrowFromCenter(brace), FadeIn(brace_label), FadeIn(question))\n pronoun = VGroup(\n RoundedRectangle(width=1.3, height=0.7, corner_radius=0.1, color=GREEN_B),\n Text(\"She\", font_size=26),\n ).move_to(subject.get_center())\n predicate_target = predicate.copy().next_to(pronoun, RIGHT, buff=0.12)\n self.play(\n FadeOut(brace, brace_label),\n ReplacementTransform(subject, pronoun),\n Transform(predicate, predicate_target),\n FadeOut(question),\n )\n result = Text(\"She solved it\", font_size=30, color=GREEN_B).to_edge(DOWN)\n self.play(FadeIn(result), Circumscribe(VGroup(pronoun, predicate), color=GREEN))\n caveat = Text(\"Substitution supports constituency; it is not proof by itself.\", font_size=23).to_edge(DOWN)\n self.play(ReplacementTransform(result, caveat))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ConstituentSubstitution(Scene):\n def construct(self):\n title = Text(\"A constituent behaves like one unit\", font_size=38).to_edge(UP)\n words = [\"The\", \"curious\", \"student\", \"solved\", \"it\"]\n cards = VGroup(*[\n VGroup(\n RoundedRectangle(width=max(1.15, 0.18 * len(word) + 0.7), height=0.7, corner_radius=0.1, color=BBLUE_B),\n Text(word, font_size=26),\n )\n for word in words\n ]).arrange(RIGHT, buff=0.12)\n subject = VGroup(*cards[:3])\n predicate = VGroup(*cards[3:])\n brace = Brace(subject, DOWN, color=YELLOW)\n brace_label = Text(\"candidate noun phrase\", font_size=23, color=YELLOW).next_to(brace, DOWN)\n question = Text(\"Can this sequence be replaced as a unit?\", font_size=26).to_edge(DOWN)\n\n self.play(Write(title), LaggedStart(*[FadeIn(card) for card in cards], lag_ratio=0.15))\n self.play(GrowFromCenter(brace), FadeIn(brace_label), FadeIn(question))\n pronoun = VGroup(\n RoundedRectangle(width=1.3, height=0.7, corner_radius=0.1, color=GREEN_B),\n Text(\"She\", font_size=26),\n ).move_to(subject.get_center())\n predicate_target = predicate.copy().next_to(pronoun, RIGHT, buff=0.12)\n self.play(\n FadeOut(brace, brace_label),\n ReplacementTransform(subject, pronoun),\n Transform(predicate, predicate_target),\n FadeOut(question),\n )\n result = Text(\"She solved it\", font_size=30, color=GREEN_B).to_edge(DOWN)\n self.play(FadeIn(result), Circumscribe(VGroup(pronoun, predicate), color=GREEN))\n caveat = Text(\"Substitution supports constituency; it is not proof by itself.\", font_size=23).to_edge(DOWN)\n self.play(ReplacementTransform(result, caveat))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 RobustnessToMisspecification(Scene):\n\n def construct(self):\n title = Text('Robustness To Misspecification', font_size=40, color=BLUE)\n subtitle = Text(\"When Models Don't Match Reality\", font_size=24, color=GRAY)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.4)\n self.play(Write(title), FadeIn(subtitle), run_time=2.0)\n self.wait(0.3)\n self.play(FadeOut(title_group))\n ax = Axes(x_range=[-3, 3, 1], y_range=[-1, 10, 2], x_length=5, y_length=3.5, axis_config={'include_tip': False}).shift(LEFT * 2.5)\n data_coords = [(-2.5, 6.2), (-2, 4.3), (-1.5, 2.8), (-1, 1.2), (-0.5, 0.3), (0, 0.1), (0.5, 0.4), (1, 1.3), (1.5, 2.9), (2, 4.1), (2.5, 6.3)]\n dots = VGroup(*[Dot(ax.c2p(x, y), radius=0.06, color=BLUE) for x, y in data_coords])\n linear_line = Line(ax.c2p(-3, -1), ax.c2p(3, 7), color=RED, stroke_width=3)\n linear_label = Text('Linear Model', font_size=20, color=RED).next_to(linear_line.get_end(), RIGHT, buff=0.2)\n true_curve = ax.plot(lambda x: x ** 2, x_range=[-2.5, 2.5], color=GREEN, stroke_width=2)\n true_label = Text('True Pattern', font_size=20, color=GREEN).next_to(ax.c2p(1.8, 3.2), RIGHT, buff=0.2)\n right_panel = VGroup(Text('Reality: Complex', font_size=20, color=GREEN), Text('Model: Linear', font_size=20, color=RED), Text('Result: Misspecified', font_size=20, color=YELLOW)).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n right_panel.next_to(ax, RIGHT, buff=0.5).shift(UP * 0.5)\n scene1 = VGroup(ax, dots, linear_line, linear_label, true_curve, true_label, right_panel)\n self.play(Create(ax), run_time=2.0 * 0.25)\n self.play(FadeIn(dots), run_time=2.0 * 0.25)\n self.play(Create(linear_line), FadeIn(linear_label), run_time=2.0 * 0.25)\n self.play(FadeIn(right_panel), run_time=2.0 * 0.25)\n residuals = VGroup()\n for x, y in data_coords:\n y_model = 4.0 / 3.0 * x + 3\n line = DashedLine(ax.c2p(x, y), ax.c2p(x, y_model), color=YELLOW, stroke_width=1)\n residuals.add(line)\n self.play(Create(residuals), run_time=2.0 * 0.5)\n self.play(Create(true_curve), FadeIn(true_label), run_time=2.0 * 0.5)\n self.wait(0.3)\n methods_title = Text('Building Robust Models', font_size=34, color=BLUE).to_edge(UP, buff=0.5)\n left_col = VGroup(Text('• Robust Loss Functions', font_size=22), Text('• Regularization', font_size=22), Text('• Ensemble Methods', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n right_col = VGroup(Text('• Cross-Validation', font_size=22), Text('• Adversarial Training', font_size=22), Text('• Distributional Tests', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n columns = VGroup(left_col, right_col).arrange(RIGHT, buff=1.5).next_to(methods_title, DOWN, buff=0.6)\n box = SurroundingRectangle(columns, buff=0.3, color=GRAY)\n self.play(FadeOut(scene1), FadeOut(residuals), run_time=0.5)\n self.play(Write(methods_title), run_time=2.0 * 0.3)\n self.play(FadeIn(left_col), FadeIn(right_col), Create(box), run_time=2.0 * 0.7)\n self.wait(0.3)\n testing_title = Text('Testing Under Varying Assumptions', font_size=32, color=BLUE).to_edge(UP, buff=0.5)\n test_items = VGroup(Text('• Sensitivity Analysis', font_size=22), Text('• Distribution Shift Detection', font_size=22), Text('• Bootstrap & Stress Tests', font_size=22), Text('• Out-of-Domain Evaluation', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n test_items.next_to(testing_title, DOWN, buff=0.6)\n test_box = SurroundingRectangle(test_items, buff=0.3, color=GRAY)\n methods_scene = VGroup(methods_title, left_col, right_col, box)\n self.play(FadeOut(methods_scene), run_time=0.5)\n self.play(Write(testing_title), run_time=2.0 * 0.3)\n self.play(FadeIn(test_items), Create(test_box), run_time=2.0 * 0.7)\n self.wait(0.3)\n takeaways_title = Text('Key Takeaways', font_size=34, color=BLUE).to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('1. Misspecification is common and detectable', font_size=22), Text('2. Robust methods protect against wrong assumptions', font_size=22), Text('3. Always test under varied, realistic conditions', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n takeaways.next_to(takeaways_title, DOWN, buff=0.6)\n tw_box = SurroundingRectangle(takeaways, buff=0.3, color=GRAY)\n testing_scene = VGroup(testing_title, test_items, test_box)\n self.play(FadeOut(testing_scene), run_time=0.5)\n self.play(Write(takeaways_title), run_time=2.0 * 0.3)\n self.play(FadeIn(takeaways), Create(tw_box), run_time=2.0 * 0.7)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass RobustnessToMisspecification(Scene):\n\n def construct(self):\n title = Text('Robustness To Misspecification', font_size=40, color=BLUE)\n subtitle = Text(\"When Models Don't Match Reality\", font_size=24, color=GRAY)\n title_group = VGroup(title, subtitle).arrange(DOWN, buff=0.4)\n self.play(Write(title), FadeIn(subtitle), run_time=2.0)\n self.wait(0.3)\n self.play(FadeOut(title_group))\n ax = Axes(label_font_size=24, x_range=[-3, 3, 1], y_range=[-1, 10, 2], x_length=5, y_length=3.5, axis_config={'include_tip': False}).shift(LEFT * 2.5)\n data_coords = [(-2.5, 6.2), (-2, 4.3), (-1.5, 2.8), (-1, 1.2), (-0.5, 0.3), (0, 0.1), (0.5, 0.4), (1, 1.3), (1.5, 2.9), (2, 4.1), (2.5, 6.3)]\n dots = VGroup(*[Dot(ax.c2p(x, y), radius=0.06, color=BLUE) for x, y in data_coords])\n linear_line = Line(ax.c2p(-3, -1), ax.c2p(3, 7), color=RED, stroke_width=3)\n linear_label = Text('Linear Model', font_size=20, color=RED).next_to(linear_line.get_end(), RIGHT, buff=0.2)\n true_curve = ax.plot(lambda x: x ** 2, x_range=[-2.5, 2.5], color=GREEN, stroke_width=2)\n true_label = Text('True Pattern', font_size=20, color=GREEN).next_to(ax.c2p(1.8, 3.2), RIGHT, buff=0.2)\n right_panel = VGroup(Text('Reality: Complex', font_size=20, color=GREEN), Text('Model: Linear', font_size=20, color=RED), Text('Result: Misspecified', font_size=20, color=YELLOW)).arrange(DOWN, buff=0.3, aligned_edge=LEFT)\n right_panel.next_to(ax, RIGHT, buff=0.5).shift(UP * 0.5)\n scene1 = VGroup(ax, dots, linear_line, linear_label, true_curve, true_label, right_panel)\n self.play(Create(ax), run_time=2.0 * 0.25)\n self.play(FadeIn(dots), run_time=2.0 * 0.25)\n self.play(Create(linear_line), FadeIn(linear_label), run_time=2.0 * 0.25)\n self.play(FadeIn(right_panel), run_time=2.0 * 0.25)\n residuals = VGroup()\n for x, y in data_coords:\n y_model = 4.0 / 3.0 * x + 3\n line = DashedLine(ax.c2p(x, y), ax.c2p(x, y_model), color=YELLOW, stroke_width=1)\n residuals.add(line)\n self.play(Create(residuals), run_time=2.0 * 0.5)\n self.play(Create(true_curve), FadeIn(true_label), run_time=2.0 * 0.5)\n self.wait(0.3)\n methods_title = Text('Building Robust Models', font_size=34, color=BLUE).to_edge(UP, buff=0.5)\n left_col = VGroup(Text('• Robust Loss Functions', font_size=22), Text('• Regularization', font_size=22), Text('• Ensemble Methods', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n right_col = VGroup(Text('• Cross-Validation', font_size=22), Text('• Adversarial Training', font_size=22), Text('• Distributional Tests', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n columns = VGroup(left_col, right_col).arrange(RIGHT, buff=1.5).next_to(methods_title, DOWN, buff=0.6)\n box = SurroundingRectangle(columns, buff=0.3, color=GRAY)\n self.play(FadeOut(scene1), FadeOut(residuals), run_time=0.5)\n self.play(Write(methods_title), run_time=2.0 * 0.3)\n self.play(FadeIn(left_col), FadeIn(right_col), Create(box), run_time=2.0 * 0.7)\n self.wait(0.3)\n testing_title = Text('Testing Under Varying Assumptions', font_size=32, color=BLUE).to_edge(UP, buff=0.5)\n test_items = VGroup(Text('• Sensitivity Analysis', font_size=22), Text('• Distribution Shift Detection', font_size=22), Text('• Bootstrap & Stress Tests', font_size=22), Text('• Out-of-Domain Evaluation', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n test_items.next_to(testing_title, DOWN, buff=0.6)\n test_box = SurroundingRectangle(test_items, buff=0.3, color=GRAY)\n methods_scene = VGroup(methods_title, left_col, right_col, box)\n self.play(FadeOut(methods_scene), run_time=0.5)\n self.play(Write(testing_title), run_time=2.0 * 0.3)\n self.play(FadeIn(test_items), Create(test_box), run_time=2.0 * 0.7)\n self.wait(0.3)\n takeaways_title = Text('Key Takeaways', font_size=34, color=BLUE).to_edge(UP, buff=0.5)\n takeaways = VGroup(Text('1. Misspecification is common and detectable', font_size=22), Text('2. Robust methods protect against wrong assumptions', font_size=22), Text('3. Always test under varied, realistic conditions', font_size=22)).arrange(DOWN, buff=0.4, aligned_edge=LEFT)\n takeaways.next_to(takeaways_title, DOWN, buff=0.6)\n tw_box = SurroundingRectangle(takeaways, buff=0.3, color=GRAY)\n testing_scene = VGroup(testing_title, test_items, test_box)\n self.play(FadeOut(testing_scene), run_time=0.5)\n self.play(Write(takeaways_title), run_time=2.0 * 0.3)\n self.play(FadeIn(takeaways), Create(tw_box), run_time=2.0 * 0.7)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a simple three-layer feedforward neural network, with the first layer having 3 neurons, the second layer having 5 neurons, and the third layer also having 3 neurons, using ManimCE?", "chosen": "```python\nfrom manim import *\n\n# Custom definitions for Neural Network components using ManimCE primitives\n# Standard ManimCE does not include built-in high-level Neural Network classes,\n# so these are implemented using core primitives (Circle, Line, VGroup) \n# to ensure the code is fully runnable on any standard installation.\n\nclass Neuron(Circle):\n \"\"\"Represents a single neuron as a colored circle.\"\"\"\n def __init__(self, radius=0.3, color=BLUE, **kwargs):\n super().__init__(radius=radius, color=color, fill_opacity=0.8, **kwargs)\n self.set_stroke(width=2)\n\nclass Layer(VGroup):\n \"\"\"Represents a layer of neurons arranged vertically.\"\"\"\n def __init__(self, n_neurons, neuron_color=BLUE, neuron_spacing=0.8, **kwargs):\n super().__init__(**kwargs)\n neurons = [Neuron(color=neuron_color) for _ in range(n_neurons)]\n self.neurons = VGroup(*neurons).arrange(DOWN, buff=neuron_spacing)\n self.add(self.neurons)\n\nclass FeedForwardNetwork(VGroup):\n \"\"\"\n Represents a complete feedforward neural network.\n Automatically generates neurons and connections based on layer sizes.\n \"\"\"\n def __init__(self, layer_sizes, layer_colors=[BLUE, GREEN, RED], layer_spacing=2.5, **kwargs):\n super().__init__(**kwargs)\n self.layers = VGroup()\n self.connections = VGroup()\n \n # Create Layers\n for i, size in enumerate(layer_sizes):\n color = layer_colors[i] if i < len(layer_colors) else WHITE\n layer = Layer(size, neuron_color=color)\n self.layers.add(layer)\n \n # Arrange Layers horizontally\n self.layers.arrange(RIGHT, buff=layer_spacing)\n self.add(self.layers)\n \n # Create Connections (Weights) between adjacent layers\n for i in range(len(self.layers) - 1):\n current_layer = self.layers[i]\n next_layer = self.layers[i+1]\n for n1 in current_layer.neurons:\n for n2 in next_layer.neurons:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n color=GRAY, \n stroke_width=1, \n stroke_opacity=0.5\n )\n self.connections.add(line)\n \n # Add connections behind neurons\n self.add(self.connections)\n self.connections.set_z_index(0)\n self.layers.set_z_index(1)\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # Title\n title = Text(\"3-Layer Feedforward Neural Network\", font_size=36)\n title.to_edge(UP)\n \n # Define Architecture: Layer 1 (3), Layer 2 (5), Layer 3 (3)\n network = FeedForwardNetwork([3, 5, 3])\n network.scale(0.8).move_to(ORIGIN)\n \n # 1. Animate Title\n self.play(Write(title))\n self.wait(0.5)\n \n # 2. Animate Layer Creation (Neurons appearing one by one)\n for layer in network.layers:\n self.play(FadeIn(layer), run_time=0.8)\n self.wait(0.2)\n \n # 3. Animate Connection Creation (Weights)\n self.play(Create(network.connections), run_time=2)\n self.wait(0.5)\n \n # 4. Add Layer Labels for clarity\n labels = VGroup(\n Text(\"Input Layer\", font_size=24, color=BLUE),\n Text(\"Hidden Layer\", font_size=24, color=GREEN),\n Text(\"Output Layer\", font_size=24, color=RED)\n )\n for i, label in enumerate(labels):\n label.next_to(network.layers[i], DOWN)\n \n self.play(Write(labels), run_time=1)\n self.wait(1)\n \n # 5. Visualize Signal Propagation (Forward Pass)\n # Create a signal dot for each connection to simulate data flow\n signals = VGroup()\n signal_anims = []\n \n for conn in network.connections:\n signal = Dot(radius=0.06, color=YELLOW)\n signal.move_to(conn.get_start())\n signals.add(signal)\n # Animate signal moving along the connection line\n signal_anims.append(MoveAlongPath(signal, conn, run_time=1.5, rate_func=linear))\n \n self.play(*signal_anims, run_time=2)\n \n # 6. Highlight Output Neurons upon signal arrival\n output_neurons = network.layers[2].neurons\n self.play(\n output_neurons.animate.set_color(GOLD),\n run_time=0.5\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\n# Custom definitions for Neural Network components using ManimCE primitives\n# Standard ManimCE does not include built-in high-level Neural Network classes,\n# so these are implemented using core primitives (Circle, Line, VGroup) \n# to ensure the code is fully runnable on any standard installation.\n\nclass Neuron(Circle):\n \"\"\"Represents a single neuron as a colored circle.\"\"\"\n def __init__(self, radius=0.3, color=BBLUE, **kwargs):\n super().__init__(radius=radius, color=color, fill_opacity=0.8, **kwargs)\n self.set_stroke(width=2)\n\nclass Layer(VGroup):\n \"\"\"Represents a layer of neurons arranged vertically.\"\"\"\n def __init__(self, n_neurons, neuron_color=BLUE, neuron_spacing=0.8, **kwargs):\n super().__init__(**kwargs)\n neurons = [Neuron(color=neuron_color) for _ in range(n_neurons)]\n self.neurons = VGroup(*neurons).arrange(DOWN, buff=neuron_spacing)\n self.add(self.neurons)\n\nclass FeedForwardNetwork(VGroup):\n \"\"\"\n Represents a complete feedforward neural network.\n Automatically generates neurons and connections based on layer sizes.\n \"\"\"\n def __init__(self, layer_sizes, layer_colors=[BLUE, GREEN, RED], layer_spacing=2.5, **kwargs):\n super().__init__(**kwargs)\n self.layers = VGroup()\n self.connections = VGroup()\n \n # Create Layers\n for i, size in enumerate(layer_sizes):\n color = layer_colors[i] if i < len(layer_colors) else WHITE\n layer = Layer(size, neuron_color=color)\n self.layers.add(layer)\n \n # Arrange Layers horizontally\n self.layers.arrange(RIGHT, buff=layer_spacing)\n self.add(self.layers)\n \n # Create Connections (Weights) between adjacent layers\n for i in range(len(self.layers) - 1):\n current_layer = self.layers[i]\n next_layer = self.layers[i+1]\n for n1 in current_layer.neurons:\n for n2 in next_layer.neurons:\n line = Line(\n n1.get_center(), \n n2.get_center(), \n color=GRAY, \n stroke_width=1, \n stroke_opacity=0.5\n )\n self.connections.add(line)\n \n # Add connections behind neurons\n self.add(self.connections)\n self.connections.set_z_index(0)\n self.layers.set_z_index(1)\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # Title\n title = Text(\"3-Layer Feedforward Neural Network\", font_size=36)\n title.to_edge(UP)\n \n # Define Architecture: Layer 1 (3), Layer 2 (5), Layer 3 (3)\n network = FeedForwardNetwork([3, 5, 3])\n network.scale(0.8).move_to(ORIGIN)\n \n # 1. Animate Title\n self.play(Write(title))\n self.wait(0.5)\n \n # 2. Animate Layer Creation (Neurons appearing one by one)\n for layer in network.layers:\n self.play(FadeIn(layer), run_time=0.8)\n self.wait(0.2)\n \n # 3. Animate Connection Creation (Weights)\n self.play(Create(network.connections), run_time=2)\n self.wait(0.5)\n \n # 4. Add Layer Labels for clarity\n labels = VGroup(\n Text(\"Input Layer\", font_size=24, color=BLUE),\n Text(\"Hidden Layer\", font_size=24, color=GREEN),\n Text(\"Output Layer\", font_size=24, color=RED)\n )\n for i, label in enumerate(labels):\n label.next_to(network.layers[i], DOWN)\n \n self.play(Write(labels), run_time=1)\n self.wait(1)\n \n # 5. Visualize Signal Propagation (Forward Pass)\n # Create a signal dot for each connection to simulate data flow\n signals = VGroup()\n signal_anims = []\n \n for conn in network.connections:\n signal = Dot(radius=0.06, color=YELLOW)\n signal.move_to(conn.get_start())\n signals.add(signal)\n # Animate signal moving along the connection line\n signal_anims.append(MoveAlongPath(signal, conn, run_time=1.5, rate_func=linear))\n \n self.play(*signal_anims, run_time=2)\n \n # 6. Highlight Output Neurons upon signal arrival\n output_neurons = network.layers[2].neurons\n self.play(\n output_neurons.animate.set_color(GOLD),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Here’s an enhanced version of the animation that retains the original conflicting rotations while adding a dynamic mathematical explanation, color transitions, and a transformation into a circle to visually resolve the c\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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0201(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_conflictingrotationswith()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_conflictingrotationswith(self):\n square = Square(color=RED, fill_opacity=0.8)\n square.scale(1.5)\n \n # Add the square to the scene\n self.add(square)\n \n # Create the rotation animations (clockwise and counterclockwise)\n rotation_cw = Rotate(square, angle=2*PI, rate_func=linear, run_time=3)\n rotation_ccw = Rotate(square, angle=-2*PI, rate_func=linear, run_time=3)\n \n # Create color transition animation\n color_shift = square.animate.set_color(BLUE)\n \n # Start the conflicting rotations and color shift\n self.play(rotation_cw, rotation_ccw, color_shift)\n \n # Add the equation e^{i\\pi} = -1\n equation = MathTex(\"e^{i\\\\pi} = -1\", color=YELLOW)\n equation.next_to(square, DOWN, buff=0.7)\n \n # Fade in the equation\n self.play(Write(equation))\n self.wait(0.5)\n \n # Transform the square into a circle\n circle = Circle(color=BLUE, fill_opacity=0.8)\n circle.scale(1.5)\n \n # Morph square to circle\n self.play(Transform(square, circle))\n \n # Create a pulsing effect on the circle\n pulse_animation = Succession(\n circle.animate.scale(1.2),\n circle.animate.scale(1/1.2),\n run_time=1\n )\n \n # Fade out the equation while pulsing the circle\n self.play(pulse_animation, FadeOut(equation))\n \n # Final pulse\n self.play(pulse_animation)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n\n # Step 2: Create a coordinate system and plot the function with a visible label\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True}\n )\n graph = axes.plot(func, color=BLUE)\n graph_label = MathTex(\"y = x^2\").next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # Step 3: Display the definite integral expression representing the area from x=0 to x=2\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42).to_edge(UR).shift(DOWN * 0.5)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 4: Visually highlight the area under the curve between the specified bounds\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Step 5: Calculate and display the numerical result of the integral\n # The antiderivative of x^2 is x^3/3. Evaluated from 0 to 2 gives 8/3.\n result_expr = MathTex(r\"= \\frac{8}{3}\", font_size=42).next_to(integral_expr, RIGHT)\n self.play(Write(result_expr))\n self.wait(1)\n\n # Step 6: Animate the removal of all elements except the final calculated result\n final_statement = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\frac{8}{3}\").scale(1.5)\n to_remove = VGroup(axes, graph, graph_label, area, integral_expr, result_expr)\n\n self.play(\n FadeOut(to_remove),\n FadeIn(final_statement)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0201(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_conflictingrotationswith()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_conflictingrotationswith(self):\n square = Square(color=RED, fill_opacity=0.8)\n square.scale(1.5)\n \n # Add the square to the scene\n self.add(square)\n \n # Create the rotation animations (clockwise and counterclockwise)\n rotation_cw = Rotate(square, angle=2*PI, rate_func=linear, run_time=3)\n rotation_ccw = Rotate(square, angle=-2*PI, rate_func=linear, run_time=3)\n \n # Create color transition animation\n color_shift = square.animate.set_color(BLUE)\n \n # Start the conflicting rotations and color shift\n self.play(rotation_cw, rotation_ccw, color_shift)\n \n # Add the equation e^{i\\pi} = -1\n equation = MathTex(\"e^{i\\\\pi} = -1\", color=YELLOW)\n equation.next_to(square, DOWN, buff=0.7)\n \n # Fade in the equation\n self.play(Write(equation))\n self.wait(0.5)\n \n # Transform the square into a circle\n circle = Circle(color=BLUE, fill_opacity=0.8)\n circle.scale(1.5)\n \n # Morph square to circle\n self.play(Transform(square, circle))\n \n # Create a pulsing effect on the circle\n pulse_animation = Succession(\n circle.animate.scale(1.2),\n circle.animate.scale(1/1.2),\n run_time=1\n )\n \n # Fade out the equation while pulsing the circle\n self.play(pulse_animation, FadeOut(equation))\n \n # Final pulse\n self.play(pulse_animation)\n\n def act_2_areaundercurve(self):\n func = lambda x: x**2\n\n # Step 2: Create a coordinate system and plot the function with a visible label\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, \"include_numbers\": True}\n )\n graph = axes.plot(func, color=BLUE)\n graph_label = MathTex(\"y = x^2\").next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # Step 3: Display the definite integral expression representing the area from x=0 to x=2\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=42).to_edge(UR).shift(DOWN * 0.5)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # Step 4: Visually highlight the area under the curve between the specified bounds\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # Step 5: Calculate and display the numerical result of the integral\n # The antiderivative of x^2 is x^3/3. Evaluated from 0 to 2 gives 8/3.\n result_expr = MathTex(r\"= \\frac{8}{3}\", font_size=42).next_to(integral_expr, RIGHT)\n self.play(Write(result_expr))\n self.wait(1)\n\n # Step 6: Animate the removal of all elements except the final calculated result\n final_statement = MathTex(r\"\\int_{0}^{2} x^2 \\, dx = \\frac{8}{3}\").scale(1.5)\n to_remove = VGroup(axes, graph, graph_label, area, integral_expr, result_expr)\n\n self.play(\n FadeOut(to_remove),\n FadeIn(final_statement)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\n\nclass AtomicStructure(Scene):\n def construct(self):\n # --- Configuration ---\n NUCLEUS_RADIUS = 0.25\n ELECTRON_RADIUS = 0.1\n ORBIT_RADIUS = 1.5\n ORBIT_SPEED = 2.0 # Radians per second\n NUCLEUS_COLOR = RED\n ELECTRON_COLOR = BLUE\n ORBIT_COLOR = WHITE\n\n # --- Helper Function to Create Atom Components ---\n def create_atom_parts():\n nucleus = Dot(radius=NUCLEUS_RADIUS, color=NUCLEUS_COLOR)\n orbit = Circle(radius=ORBIT_RADIUS, color=ORBIT_COLOR, stroke_opacity=0.5)\n electrons = VGroup()\n # Position 3 electrons equidistantly (120 degrees apart)\n for i in range(3):\n electron = Dot(radius=ELECTRON_RADIUS, color=ELECTRON_COLOR)\n electron.move_to(orbit.point_at_angle(i * 2 * np.pi / 3))\n electrons.add(electron)\n return nucleus, orbit, electrons\n\n # --- Atom 1: Assembly Sequence ---\n nucleus1, orbit1, electrons1 = create_atom_parts()\n atom1 = VGroup(nucleus1, orbit1, electrons1)\n\n # 1. Create Nucleus\n self.play(Create(nucleus1), run_time=1)\n # 2. Create Orbit Path\n self.play(Create(orbit1), run_time=1)\n # 3. Create Electrons\n self.play(FadeIn(electrons1), run_time=1)\n\n # --- Orbital Motion Logic ---\n # ValueTracker ensures continuous, smooth rotation that persists correctly during translations\n angle_tracker = ValueTracker(0)\n self.add_updater(lambda dt: angle_tracker.increment_value(dt * ORBIT_SPEED))\n\n # Assign updaters to electrons so they orbit relative to their specific orbit's center\n for i, electron in enumerate(electrons1):\n electron.add_updater(\n lambda m, o=orbit1, idx=i: m.move_to(\n o.point_at_angle(angle_tracker.get_value() + idx * 2 * np.pi / 3)\n )\n )\n\n # Establish motion visually before moving the atom\n self.wait(2)\n\n # --- Move Atom 1 to Left ---\n self.play(atom1.animate.move_to(LEFT * 3), run_time=2)\n\n # --- Atom 2: Replica Creation ---\n # Create fresh components to ensure updaters bind to the new orbit's center\n nucleus2, orbit2, electrons2 = create_atom_parts()\n atom2 = VGroup(nucleus2, orbit2, electrons2)\n atom2.move_to(ORIGIN)\n\n # Bind orbital motion to the replica's electrons\n for i, electron in enumerate(electrons2):\n electron.add_updater(\n lambda m, o=orbit2, idx=i: m.move_to(\n o.point_at_angle(angle_tracker.get_value() + idx * 2 * np.pi / 3)\n )\n )\n\n # Appear and Move to Right\n self.play(FadeIn(atom2), run_time=1)\n self.play(atom2.animate.move_to(RIGHT * 3), run_time=2)\n\n # --- Conclusion ---\n # Allow a moment to view both atoms\n self.wait(2)\n # Fade out both atoms simultaneously\n self.play(FadeOut(atom1), FadeOut(atom2), run_time=1.5)\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass AtomicStructure(Scene):\n def construct(self):\n # --- Configuration ---\n NUCLEUS_RADIUS = 0.25\n ELECTRON_RADIUS = 0.1\n ORBIT_RADIUS = 1.5\n ORBIT_SPEED = 2.0 # Radians per second\n NUCLEUS_COLOR = RED\n ELECTRON_COLOR = BBLUE\n ORBIT_COLOR = WHITE\n\n # --- Helper Function to Create Atom Components ---\n def create_atom_parts():\n nucleus = Dot(radius=NUCLEUS_RADIUS, color=NUCLEUS_COLOR)\n orbit = Circle(radius=ORBIT_RADIUS, color=ORBIT_COLOR, stroke_opacity=0.5)\n electrons = VGroup()\n # Position 3 electrons equidistantly (120 degrees apart)\n for i in range(3):\n electron = Dot(radius=ELECTRON_RADIUS, color=ELECTRON_COLOR)\n electron.move_to(orbit.point_at_angle(i * 2 * np.pi / 3))\n electrons.add(electron)\n return nucleus, orbit, electrons\n\n # --- Atom 1: Assembly Sequence ---\n nucleus1, orbit1, electrons1 = create_atom_parts()\n atom1 = VGroup(nucleus1, orbit1, electrons1)\n\n # 1. Create Nucleus\n self.play(Create(nucleus1), run_time=1)\n # 2. Create Orbit Path\n self.play(Create(orbit1), run_time=1)\n # 3. Create Electrons\n self.play(FadeIn(electrons1), run_time=1)\n\n # --- Orbital Motion Logic ---\n # ValueTracker ensures continuous, smooth rotation that persists correctly during translations\n angle_tracker = ValueTracker(0)\n self.add_updater(lambda dt: angle_tracker.increment_value(dt * ORBIT_SPEED))\n\n # Assign updaters to electrons so they orbit relative to their specific orbit's center\n for i, electron in enumerate(electrons1):\n electron.add_updater(\n lambda m, o=orbit1, idx=i: m.move_to(\n o.point_at_angle(angle_tracker.get_value() + idx * 2 * np.pi / 3)\n )\n )\n\n # Establish motion visually before moving the atom\n self.wait(2)\n\n # --- Move Atom 1 to Left ---\n self.play(atom1.animate.move_to(LEFT * 3), run_time=2)\n\n # --- Atom 2: Replica Creation ---\n # Create fresh components to ensure updaters bind to the new orbit's center\n nucleus2, orbit2, electrons2 = create_atom_parts()\n atom2 = VGroup(nucleus2, orbit2, electrons2)\n atom2.move_to(ORIGIN)\n\n # Bind orbital motion to the replica's electrons\n for i, electron in enumerate(electrons2):\n electron.add_updater(\n lambda m, o=orbit2, idx=i: m.move_to(\n o.point_at_angle(angle_tracker.get_value() + idx * 2 * np.pi / 3)\n )\n )\n\n # Appear and Move to Right\n self.play(FadeIn(atom2), run_time=1)\n self.play(atom2.animate.move_to(RIGHT * 3), run_time=2)\n\n # --- Conclusion ---\n # Allow a moment to view both atoms\n self.wait(2)\n # Fade out both atoms simultaneously\n self.play(FadeOut(atom1), FadeOut(atom2), run_time=1.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 IntegralPowerRule(Scene):\n def construct(self):\n # --- Visual Representation Setup ---\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=5,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT)\n\n graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^3\")\n\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n\n # --- Math Equations ---\n step1 = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=42)\n step2 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=42)\n step3 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=42)\n step4 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42)\n step5 = MathTex(r\"= \\frac{16}{4} - 0 = 4\", font_size=42)\n\n equations = VGroup(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.to_edge(RIGHT, buff=1.5).shift(UP * 0.5)\n\n # --- Explanatory Texts ---\n texts = VGroup(\n Text(\"Step 1: Set up the integral\", font_size=22, color=GRAY),\n Text(\"Step 2: Apply the Power Rule\", font_size=22, color=GRAY),\n Text(\"Step 3: Simplify the exponent\", font_size=22, color=GRAY),\n Text(\"Step 4: Evaluate at boundaries\", font_size=22, color=GRAY),\n Text(\"Step 5: Final calculation\", font_size=22, color=GRAY)\n ).arrange(DOWN, buff=0.5)\n\n for i in range(len(texts)):\n texts[i].next_to(equations[i], RIGHT, buff=0.3)\n\n # --- Animation Sequence ---\n \n # 1. Introduction: Show the graph and the area\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 2. Step 1: Integral Setup\n self.play(Write(step1), Write(texts[0]))\n self.wait(2)\n\n # 3. Step 2: Application of Power Rule\n self.play(Write(step2), Write(texts[1]))\n self.wait(2)\n\n # 4. Step 3: Simplification\n self.play(Write(step3), Write(texts[2]))\n self.wait(2)\n\n # 5. Step 4: Evaluation\n self.play(Write(step4), Write(texts[3]))\n self.wait(2)\n\n # 6. Step 5: Final Result\n self.play(Write(step5), Write(texts[4]))\n self.wait(2)\n\n # Final flourish: Highlight the final answer\n rect = SurroundingRectangle(step5, color=YELLOW, buff=0.1)\n self.play(Create(rect))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralPowerRule(Scene):\n def construct(self):\n # --- Visual Representation Setup ---\n axes = Axes(\n x_range=[0, 2.5, 0.5],\n y_range=[0, 10, 2],\n x_length=5,\n y_length=5,\n axis_config={\"include_tip\": True}\n ).to_edge(LEFT)\n\n graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=BBLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^3\")\n\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n\n # --- Math Equations ---\n step1 = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\", font_size=42)\n step2 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\", font_size=42)\n step3 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\", font_size=42)\n step4 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42)\n step5 = MathTex(r\"= \\frac{16}{4} - 0 = 4\", font_size=42)\n\n equations = VGroup(step1, step2, step3, step4, step5).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n equations.to_edge(RIGHT, buff=1.5).shift(UP * 0.5)\n\n # --- Explanatory Texts ---\n texts = VGroup(\n Text(\"Step 1: Set up the integral\", font_size=22, color=GRAY),\n Text(\"Step 2: Apply the Power Rule\", font_size=22, color=GRAY),\n Text(\"Step 3: Simplify the exponent\", font_size=22, color=GRAY),\n Text(\"Step 4: Evaluate at boundaries\", font_size=22, color=GRAY),\n Text(\"Step 5: Final calculation\", font_size=22, color=GRAY)\n ).arrange(DOWN, buff=0.5)\n\n for i in range(len(texts)):\n texts[i].next_to(equations[i], RIGHT, buff=0.3)\n\n # --- Animation Sequence ---\n \n # 1. Introduction: Show the graph and the area\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 2. Step 1: Integral Setup\n self.play(Write(step1), Write(texts[0]))\n self.wait(2)\n\n # 3. Step 2: Application of Power Rule\n self.play(Write(step2), Write(texts[1]))\n self.wait(2)\n\n # 4. Step 3: Simplification\n self.play(Write(step3), Write(texts[2]))\n self.wait(2)\n\n # 5. Step 4: Evaluation\n self.play(Write(step4), Write(texts[3]))\n self.wait(2)\n\n # 6. Step 5: Final Result\n self.play(Write(step5), Write(texts[4]))\n self.wait(2)\n\n # Final flourish: Highlight the final answer\n rect = SurroundingRectangle(step5, color=YELLOW, buff=0.1)\n self.play(Create(rect))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### 2. Government Expenditure Multiplier Formula\n\nFocus on fiscal policy: only consider changes in \\(G\\).\n\n- Take the increment (or partial derivative) of the above equation:\n \\[\n \\Delta Y = \\frac{1}{1 - c} \\Delta G\n \\]\n- Therefore, the **government expenditure multiplier** is:\n \\[\n k_G = \\frac{\\Delta Y}{\\Delta G} = \\frac{1}{1 - c}\n \\]\n\n\nThe context of this section (from highest to current level):\n## 3. Derivation of Equilibrium Income and Government Expenditure Multiplier\n### 1. Solve for Equilibrium Income \\(Y\\) (Board Work Derivation)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass GovtExpenditureMultiplier(Scene):\n\n def construct(self):\n self.camera.background_color = '#1e1e1e'\n title = Title('2. Government Expenditure Multiplier Formula', include_underline=True)\n title.set_color(YELLOW)\n self.play(Write(title))\n self.wait(0.5)\n text1 = Tex('Focus on fiscal policy: only consider changes in $G$.', font_size=36)\n text2 = Tex('$\\\\bullet$ Take the increment (or partial derivative) of the above equation:', font_size=36)\n eq1 = MathTex('\\\\Delta Y = \\\\frac{1}{1 - c} \\\\Delta G', font_size=48)\n eq1.set_color(TEAL)\n text3 = Tex('$\\\\bullet$ Therefore, the \\\\textbf{government expenditure multiplier} is:', font_size=36)\n eq2 = MathTex('k_G = \\\\frac{\\\\Delta Y}{\\\\Delta G} = \\\\frac{1}{1 - c}', font_size=48)\n eq2.set_color(GREEN_C)\n content_group = VGroup(text1, text2, eq1, text3, eq2)\n content_group.arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content_group.next_to(title, DOWN, buff=0.5)\n content_group.shift(RIGHT * 0.5)\n eq1.set_x(0)\n eq2.set_x(0)\n self.play(FadeIn(text1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(text2, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq1))\n self.wait(1.5)\n self.play(FadeIn(text3, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq2))\n self.wait(1)\n highlight_box = SurroundingRectangle(eq2, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(2)\n self.play(FadeOut(VGroup(title, content_group, highlight_box)))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass GovtExpenditureMultiplier(Scene):\n\n def construct(self):\n self.camera.background_color = '#1e1e1e'\n title = Title('2. Government Expenditure Multiplier Formula', include_underline=True)\n title.set_color(YELLOW)\n self.play(Write(title))\n self.wait(0.5)\n text1 = Tex('Focus on fiscal policy: only consider changes in $G$.', font_size=36)\n text2 = Tex('$\\\\bullet$ Take the increment (or partial derivative) of the above equation:', font_size=36)\n eq1 = MathText('\\\\Delta Y = \\\\frac{1}{1 - c} \\\\Delta G', font_size=48)\n eq1.set_color(TEAL)\n text3 = Tex('$\\\\bullet$ Therefore, the \\\\textbf{government expenditure multiplier} is:', font_size=36)\n eq2 = MathTex('k_G = \\\\frac{\\\\Delta Y}{\\\\Delta G} = \\\\frac{1}{1 - c}', font_size=48)\n eq2.set_color(GREEN_C)\n content_group = VGroup(text1, text2, eq1, text3, eq2)\n content_group.arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n content_group.next_to(title, DOWN, buff=0.5)\n content_group.shift(RIGHT * 0.5)\n eq1.set_x(0)\n eq2.set_x(0)\n self.play(FadeIn(text1, shift=RIGHT))\n self.wait(1)\n self.play(FadeIn(text2, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq1))\n self.wait(1.5)\n self.play(FadeIn(text3, shift=RIGHT))\n self.wait(1)\n self.play(Write(eq2))\n self.wait(1)\n highlight_box = SurroundingRectangle(eq2, color=YELLOW, buff=0.2, corner_radius=0.1)\n self.play(Create(highlight_box))\n self.wait(2)\n self.play(FadeOut(VGroup(title, content_group, highlight_box)))\n self.wait(0.5)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the concept of Simple Harmonic Motion (SHM), starting with the display of its differential equation, followed by an explanation and introduction of angular frequency, and then showing how the equation is rewritten using angular frequency? Additionally, can you demonstrate the general solution of the equation involving cosine function, explain the meaning of phase difference within the context, and finally clear the scene to focus on the final solution?", "chosen": "```python\nfrom manim import *\n\nclass SHMAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Differential Equation (Physical Form) ---\n # Start with k/m to allow for the rewriting step requested\n eq_physical = MathTex(\n r\"\\frac{d^2 x}{d t^2}\", \"+\", r\"\\frac{k}{m}\", \"x\", \"=\", \"0\"\n )\n eq_physical.scale(1.2)\n title_physical = Text(\"Equation of Motion\", font_size=36)\n title_physical.next_to(eq_physical, UP, buff=0.5)\n\n self.play(Write(title_physical), Write(eq_physical))\n self.wait(1)\n\n # --- Step 2: Angular Frequency Introduction ---\n omega_def = MathTex(r\"\\omega\", \"=\", r\"\\sqrt{\\frac{k}{m}}\")\n omega_def.scale(1.2)\n omega_label = Text(\"Angular Frequency\", font_size=36, color=BLUE)\n VGroup(omega_label, omega_def).arrange(RIGHT, buff=0.5).next_to(eq_physical, DOWN, buff=1.0)\n\n self.play(Write(omega_label), Write(omega_def))\n self.wait(1)\n\n # Highlight the k/m part in the equation to show the upcoming substitution\n physical_term = eq_physical[2] # The \\frac{k}{m} part\n self.play(physical_term.animate.set_color(BLUE))\n self.wait(0.5)\n\n # --- Step 3: Equation Transformation ---\n # Transform the physical equation to the standard SHM form using omega\n eq_standard = MathTex(\n r\"\\frac{d^2 x}{d t^2}\", \"+\", r\"\\omega^2\", \"x\", \"=\", \"0\"\n )\n eq_standard.scale(1.2)\n eq_standard.move_to(eq_physical)\n\n # Use TransformMatchingTex for smooth transition of common parts\n self.play(\n TransformMatchingTex(eq_physical, eq_standard),\n FadeOut(omega_label),\n FadeOut(omega_def)\n )\n self.wait(1)\n\n # Update label for the standard form\n title_standard = Text(\"Standard SHM Equation\", font_size=36, color=BLUE)\n title_standard.next_to(eq_standard, UP, buff=0.5)\n self.play(ReplacementTransform(title_physical, title_standard))\n self.wait(1)\n\n # --- Step 4: General Solution ---\n solution = MathTex(\n \"x\", \"(t)\", \"=\", \"A\", r\"\\cos\", \"(\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\"\n )\n solution.scale(1.2)\n solution.next_to(eq_standard, DOWN, buff=1.0)\n \n # Color coding for clarity\n solution[3].set_color(YELLOW) # A\n solution[6].set_color(BLUE) # omega\n solution[9].set_color(GREEN) # phi\n\n solution_label = Text(\"General Solution\", font_size=36)\n solution_label.next_to(solution, LEFT, buff=0.5)\n\n self.play(Write(solution_label), Write(solution))\n self.wait(1)\n\n # --- Step 5: Phase Difference Explanation ---\n # Create a box explaining phase difference\n phase_box = Rectangle(height=1.5, width=4, color=GREEN)\n phase_text = Text(\"Phase Difference (φ)\\nDetermines initial position\", font_size=24)\n phase_text.move_to(phase_box.get_center())\n phase_group = VGroup(phase_box, phase_text)\n phase_group.next_to(solution, DOWN, buff=1.0)\n\n # Highlight phi in the solution\n phi_term = solution[9]\n self.play(\n phi_term.animate.set_color(GREEN).scale(1.2),\n Write(phase_group)\n )\n self.wait(2)\n\n # --- Step 6: Final Focus ---\n # Clear intermediate elements to focus on the final solution\n self.play(\n FadeOut(title_standard),\n FadeOut(eq_standard),\n FadeOut(solution_label),\n FadeOut(phase_group),\n solution.animate.scale(1.5).move_to(ORIGIN)\n )\n \n # Re-color the solution for final emphasis\n final_solution = MathTex(\n \"x\", \"(t)\", \"=\", \"A\", r\"\\cos\", \"(\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\"\n )\n final_solution.scale(1.5)\n final_solution[3].set_color(YELLOW)\n final_solution[6].set_color(BLUE)\n final_solution[9].set_color(GREEN)\n \n self.play(Transform(solution, final_solution))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass SHMAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Differential Equation (Physical Form) ---\n # Start with k/m to allow for the rewriting step requested\n eq_physical = MathTex(\n r\"\\frac{d^2 x}{d t^2}\", \"+\", r\"\\frac{k}{m}\", \"x\", \"=\", \"0\"\n )\n eq_physical.scale(1.2)\n title_physical = Text(\"Equation of Motion\", font_size=36)\n title_physical.next_to(eq_physical, UP, buff=0.5)\n\n self.play(Write(title_physical), Write(eq_physical))\n self.wait(1)\n\n # --- Step 2: Angular Frequency Introduction ---\n omega_def = MathTex(r\"\\omega\", \"=\", r\"\\sqrt{\\frac{k}{m}}\")\n omega_def.scale(1.2)\n omega_label = Text(\"Angular Frequency\", font_size=36, color=BBLUE)\n VGroup(omega_label, omega_def).arrange(RIGHT, buff=0.5).next_to(eq_physical, DOWN, buff=1.0)\n\n self.play(Write(omega_label), Write(omega_def))\n self.wait(1)\n\n # Highlight the k/m part in the equation to show the upcoming substitution\n physical_term = eq_physical[2] # The \\frac{k}{m} part\n self.play(physical_term.animate.set_color(BLUE))\n self.wait(0.5)\n\n # --- Step 3: Equation Transformation ---\n # Transform the physical equation to the standard SHM form using omega\n eq_standard = MathTex(\n r\"\\frac{d^2 x}{d t^2}\", \"+\", r\"\\omega^2\", \"x\", \"=\", \"0\"\n )\n eq_standard.scale(1.2)\n eq_standard.move_to(eq_physical)\n\n # Use TransformMatchingTex for smooth transition of common parts\n self.play(\n TransformMatchingTex(eq_physical, eq_standard),\n FadeOut(omega_label),\n FadeOut(omega_def)\n )\n self.wait(1)\n\n # Update label for the standard form\n title_standard = Text(\"Standard SHM Equation\", font_size=36, color=BLUE)\n title_standard.next_to(eq_standard, UP, buff=0.5)\n self.play(ReplacementTransform(title_physical, title_standard))\n self.wait(1)\n\n # --- Step 4: General Solution ---\n solution = MathTex(\n \"x\", \"(t)\", \"=\", \"A\", r\"\\cos\", \"(\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\"\n )\n solution.scale(1.2)\n solution.next_to(eq_standard, DOWN, buff=1.0)\n \n # Color coding for clarity\n solution[3].set_color(YELLOW) # A\n solution[6].set_color(BLUE) # omega\n solution[9].set_color(GREEN) # phi\n\n solution_label = Text(\"General Solution\", font_size=36)\n solution_label.next_to(solution, LEFT, buff=0.5)\n\n self.play(Write(solution_label), Write(solution))\n self.wait(1)\n\n # --- Step 5: Phase Difference Explanation ---\n # Create a box explaining phase difference\n phase_box = Rectangle(height=1.5, width=4, color=GREEN)\n phase_text = Text(\"Phase Difference (φ)\\nDetermines initial position\", font_size=24)\n phase_text.move_to(phase_box.get_center())\n phase_group = VGroup(phase_box, phase_text)\n phase_group.next_to(solution, DOWN, buff=1.0)\n\n # Highlight phi in the solution\n phi_term = solution[9]\n self.play(\n phi_term.animate.set_color(GREEN).scale(1.2),\n Write(phase_group)\n )\n self.wait(2)\n\n # --- Step 6: Final Focus ---\n # Clear intermediate elements to focus on the final solution\n self.play(\n FadeOut(title_standard),\n FadeOut(eq_standard),\n FadeOut(solution_label),\n FadeOut(phase_group),\n solution.animate.scale(1.5).move_to(ORIGIN)\n )\n \n # Re-color the solution for final emphasis\n final_solution = MathTex(\n \"x\", \"(t)\", \"=\", \"A\", r\"\\cos\", \"(\", r\"\\omega\", \"t\", \"+\", r\"\\phi\", \")\"\n )\n final_solution.scale(1.5)\n final_solution[3].set_color(YELLOW)\n final_solution[6].set_color(BLUE)\n final_solution[9].set_color(GREEN)\n \n self.play(Transform(solution, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 the formation of an oxygen molecule by showing two oxygen atoms coming together, sharing an electron, creating a bond, and then having the entire molecule shift upwards, shrink in size, rotate, and finally disappear?", "chosen": "```python\nfrom manim import *\n\nclass OxygenBondFormation(Scene):\n def construct(self):\n # --- 1. Scene Setup & Atomic Representation ---\n # Create Oxygen atoms as red circles with labels\n atom_left = Circle(radius=0.6, color=RED, fill_opacity=0.8).shift(LEFT * 3)\n label_left = Text(\"O\", font_size=36, color=WHITE).move_to(atom_left.get_center())\n atom_left.add(label_left)\n \n atom_right = Circle(radius=0.6, color=RED, fill_opacity=0.8).shift(RIGHT * 3)\n label_right = Text(\"O\", font_size=36, color=WHITE).move_to(atom_right.get_center())\n atom_right.add(label_right)\n \n # --- Electron Representation ---\n # Left Atom Electrons\n e_left_nonbond = Dot(color=YELLOW, radius=0.12).move_to(atom_left.get_center() + LEFT * 0.4 + UP * 0.4)\n e_left_bond = Dot(color=YELLOW, radius=0.12).move_to(atom_left.get_center() + RIGHT * 0.4)\n \n # Right Atom Electrons\n e_right_nonbond = Dot(color=YELLOW, radius=0.12).move_to(atom_right.get_center() + RIGHT * 0.4 + UP * 0.4)\n e_right_bond = Dot(color=YELLOW, radius=0.12).move_to(atom_right.get_center() + LEFT * 0.4)\n \n # --- 2. Bond Formation Sequence ---\n # Display atoms and electrons\n self.play(\n FadeIn(atom_left), FadeIn(atom_right),\n FadeIn(e_left_nonbond), FadeIn(e_left_bond),\n FadeIn(e_right_nonbond), FadeIn(e_right_bond)\n )\n self.wait(0.5)\n \n # Define target positions for the bonded state\n bonded_left_pos = LEFT * 0.8\n bonded_right_pos = RIGHT * 0.8\n \n # Animate atoms approaching each other\n self.play(\n atom_left.animate.move_to(bonded_left_pos),\n atom_right.animate.move_to(bonded_right_pos),\n e_left_nonbond.animate.move_to(bonded_left_pos + LEFT * 0.4 + UP * 0.4),\n e_right_nonbond.animate.move_to(bonded_right_pos + RIGHT * 0.4 + UP * 0.4),\n run_time=1.5\n )\n \n # Illustrate sharing of electrons to form the bond\n # Move the inner electrons to the center between the nuclei\n self.play(\n e_left_bond.animate.move_to(ORIGIN + UP * 0.2),\n e_right_bond.animate.move_to(ORIGIN + DOWN * 0.2),\n run_time=1\n )\n \n # Visual representation of the covalent bond\n bond_line = Line(bonded_left_pos, bonded_right_pos, color=WHITE, stroke_width=4)\n self.play(Create(bond_line), run_time=0.5)\n \n # Label the molecule\n o2_label = MathTex(\"O_2\").next_to(bond_line, DOWN, buff=0.5)\n self.play(Write(o2_label))\n self.wait(1)\n \n # --- 3. Transformation Sequence ---\n # Group everything into a single molecule object for collective transformation\n molecule = VGroup(\n atom_left, atom_right, \n e_left_nonbond, e_right_nonbond, \n e_left_bond, e_right_bond, \n bond_line, o2_label\n )\n \n # A. Shift Upwards\n self.play(molecule.animate.shift(UP * 2), run_time=1)\n \n # B. Shrink in Size\n self.play(molecule.animate.scale(0.5), run_time=1)\n \n # C. Rotate\n self.play(molecule.animate.rotate(PI / 2), run_time=1)\n \n # D. Fade Out (Disappear)\n self.play(FadeOut(molecule), run_time=1)\n \n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass OxygenBondFormation(Scene):\n def construct(self):\n # --- 1. Scene Setup & Atomic Representation ---\n # Create Oxygen atoms as red circles with labels\n atom_left = Circle(radius=0.6, color=RED, fill_opacity=0.8).shift(LEFT * 3)\n label_left = Text(\"O\", font_size=36, color=WHITE).move_to(atom_left.get_center())\n atom_left.add(label_left)\n \n atom_right = Circle(radius=0.6, color=RED, fill_opacity=0.8).shift(RIGHT * 3)\n label_right = Text(\"O\", font_size=36, color=WHITE).move_to(atom_right.get_center())\n atom_right.add(label_right)\n \n # --- Electron Representation ---\n # Left Atom Electrons\n e_left_nonbond = Dot(color=YELLOW, radius=0.12).move_to(atom_left.get_center() + LEFT * 0.4 + UP * 0.4)\n e_left_bond = Dot(color=YELLOW, radius=0.12).move_to(atom_left.get_center() + RIGHT * 0.4)\n \n # Right Atom Electrons\n e_right_nonbond = Dot(color=YELLOW, radius=0.12).move_to(atom_right.get_center() + RIGHT * 0.4 + UP * 0.4)\n e_right_bond = Dot(color=YELLOW, radius=0.12).move_to(atom_right.get_center() + LEFT * 0.4)\n \n # --- 2. Bond Formation Sequence ---\n # Display atoms and electrons\n self.play(\n FadeIn(atom_left), FadeIn(atom_right),\n FadeIn(e_left_nonbond), FadeIn(e_left_bond),\n FadeIn(e_right_nonbond), FadeIn(e_right_bond)\n )\n self.wait(0.5)\n \n # Define target positions for the bonded state\n bonded_left_pos = LEFT * 0.8\n bonded_right_pos = RIGHT * 0.8\n \n # Animate atoms approaching each other\n self.play(\n atom_left.animate.move_to(bonded_left_pos),\n atom_right.animate.move_to(bonded_right_pos),\n e_left_nonbond.animate.move_to(bonded_left_pos + LEFT * 0.4 + UP * 0.4),\n e_right_nonbond.animate.move_to(bonded_right_pos + RIGHT * 0.4 + UP * 0.4),\n run_time=1.5\n )\n \n # Illustrate sharing of electrons to form the bond\n # Move the inner electrons to the center between the nuclei\n self.play(\n e_left_bond.animate.move_to(ORIGIN + UP * 0.2),\n e_right_bond.animate.move_to(ORIGIN + DOWN * 0.2),\n run_time=1\n )\n \n # Visual representation of the covalent bond\n bond_line = Line(bonded_left_pos, bonded_right_pos, color=WHITE, stroke_width=4)\n self.play(Create(bond_line), run_time=0.5)\n \n # Label the molecule\n o2_label = MathText(\"O_2\").next_to(bond_line, DOWN, buff=0.5)\n self.play(Write(o2_label))\n self.wait(1)\n \n # --- 3. Transformation Sequence ---\n # Group everything into a single molecule object for collective transformation\n molecule = VGroup(\n atom_left, atom_right, \n e_left_nonbond, e_right_nonbond, \n e_left_bond, e_right_bond, \n bond_line, o2_label\n )\n \n # A. Shift Upwards\n self.play(molecule.animate.shift(UP * 2), run_time=1)\n \n # B. Shrink in Size\n self.play(molecule.animate.scale(0.5), run_time=1)\n \n # C. Rotate\n self.play(molecule.animate.rotate(PI / 2), run_time=1)\n \n # D. Fade Out (Disappear)\n self.play(FadeOut(molecule), run_time=1)\n \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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 do Catalan numbers demonstrate the paths through a grid where backtracking is not allowed?", "chosen": "```python\nfrom manim import *\n\nclass CatalanPathsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Pathways to Understanding: Exploring Catalan Numbers in Grids\", font_size=28)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Introduction\n intro = Text(\"Have you ever navigated a maze and wished\\nthere was a way to trace every path without getting lost?\", font_size=24)\n self.play(Write(intro))\n self.wait(1)\n self.play(FadeOut(intro))\n \n # Create a 2x2 grid\n grid_2x2 = self.create_grid(2)\n self.play(Create(grid_2x2))\n \n # Mark start and end points\n start_point = Dot([-2, -2, 0], color=GREEN)\n end_point = Dot([2, 2, 0], color=RED)\n self.play(Create(start_point), Create(end_point))\n \n # Rule text\n rule_text = Text(\"Rules: Only move up or right, never cross diagonal\", font_size=24)\n rule_text.to_edge(DOWN)\n self.play(Write(rule_text))\n self.wait(1)\n \n # Draw diagonal (boundary)\n diagonal = Line([-2, -2, 0], [2, 2, 0], color=YELLOW)\n self.play(Create(diagonal))\n self.wait(1)\n \n # Show an allowed path (blue)\n path1 = self.create_path([\n [-2, -2, 0], # Bottom left\n [0, -2, 0], # Right\n [2, -2, 0], # Right\n [2, 0, 0], # Up\n [2, 2, 0] # Up\n ], BLUE)\n self.play(Create(path1))\n self.wait(1)\n \n # Show another allowed path (blue)\n path2 = self.create_path([\n [-2, -2, 0], # Bottom left\n [0, -2, 0], # Right\n [0, 0, 0], # Up\n [2, 0, 0], # Right\n [2, 2, 0] # Up\n ], BLUE)\n self.play(FadeOut(path1))\n self.play(Create(path2))\n self.wait(1)\n \n # Show a disallowed path (red)\n path3 = self.create_path([\n [-2, -2, 0], # Bottom left\n [-2, 0, 0], # Up\n [-2, 2, 0], # Up\n [0, 2, 0], # Right\n [2, 2, 0] # Right\n ], RED)\n self.play(FadeOut(path2))\n self.play(Create(path3))\n disallowed_text = Text(\"Disallowed path (crosses diagonal)\", font_size=24)\n disallowed_text.to_edge(DOWN)\n self.play(ReplacementTransform(rule_text, disallowed_text))\n self.wait(1)\n \n # Show the Catalan formula\n formula = MathTex(r\"C_n = \\frac{1}{n+1}\\binom{2n}{n}\")\n formula.to_edge(UP)\n self.play(Write(formula))\n \n # Clean up and prepare for 3x3 grid\n self.play(FadeOut(path3, diagonal, grid_2x2, start_point, end_point, disallowed_text))\n \n # Create a 3x3 grid\n grid_3x3 = self.create_grid(3)\n self.play(Create(grid_3x3))\n \n # Mark start and end points for 3x3\n start_point = Dot([-3, -3, 0], color=GREEN)\n end_point = Dot([3, 3, 0], color=RED)\n self.play(Create(start_point), Create(end_point))\n \n # Show grid paths formula\n paths_formula = MathTex(r\"\\text{Paths through } (n \\times n) \\text{ grid} = C_n\")\n paths_formula.next_to(formula, DOWN)\n self.play(Write(paths_formula))\n self.wait(1)\n \n # Display C_2 = 2 and C_3 = 5\n c_values = Text(\"For n=2: C_2 = 2 paths\\nFor n=3: C_3 = 5 paths\", font_size=24)\n c_values.to_edge(DOWN)\n self.play(Write(c_values))\n self.wait(1)\n \n # Show one example path for 3x3\n path4 = self.create_path([\n [-3, -3, 0], # Bottom left\n [-1, -3, 0], # Right\n [1, -3, 0], # Right\n [3, -3, 0], # Right\n [3, -1, 0], # Up\n [3, 1, 0], # Up\n [3, 3, 0] # Up\n ], BLUE)\n self.play(Create(path4))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(grid_3x3, start_point, end_point, formula, paths_formula, c_values, path4))\n \n conclusion = Text(\"Catalan Numbers teach us about balance and symmetry,\\ncreating a beautiful sense of order.\", font_size=28)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n \n def create_grid(self, n):\n # Create a grid of size n x n\n scale = 2 # Scale factor for grid size\n grid = VGroup()\n \n # Vertical lines\n for i in range(n + 1):\n x = -n * scale / 2 + i * scale\n line = Line([x, -n * scale / 2, 0], [x, n * scale / 2, 0])\n grid.add(line)\n \n # Horizontal lines\n for i in range(n + 1):\n y = -n * scale / 2 + i * scale\n line = Line([-n * scale / 2, y, 0], [n * scale / 2, y, 0])\n grid.add(line)\n \n return grid\n \n def create_path(self, points, color):\n path = VMobject()\n path.set_points_as_corners(points)\n path.set_color(color)\n path.set_stroke(width=3)\n return path\n```", "rejected": "```python\nfrom manim import *\n\nclass CatalanPathsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Pathways to Understanding: Exploring Catalan Numbers in Grids\", font_size=28)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Introduction\n intro = Text(\"Have you ever navigated a maze and wished\\nthere was a way to trace every path without getting lost?\", font_size=24)\n self.play(Write(intro))\n self.wait(1)\n self.play(FadeOut(intro))\n \n # Create a 2x2 grid\n grid_2x2 = self.create_grid(2)\n self.play(Create(grid_2x2))\n \n # Mark start and end points\n start_point = Dot([-2, -2, 0], color=GREEN)\n end_point = Dot([2, 2, 0], color=RED)\n self.play(Create(start_point), Create(end_point))\n \n # Rule text\n rule_text = Text(\"Rules: Only move up or right, never cross diagonal\", font_size=24)\n rule_text.to_edge(DOWN)\n self.play(Write(rule_text))\n self.wait(1)\n \n # Draw diagonal (boundary)\n diagonal = Line([-2, -2, 0], [2, 2, 0], color=YELLOW)\n self.play(Create(diagonal))\n self.wait(1)\n \n # Show an allowed path (blue)\n path1 = self.create_path([\n [-2, -2, 0], # Bottom left\n [0, -2, 0], # Right\n [2, -2, 0], # Right\n [2, 0, 0], # Up\n [2, 2, 0] # Up\n ], BLUE)\n self.play(Create(path1))\n self.wait(1)\n \n # Show another allowed path (blue)\n path2 = self.create_path([\n [-2, -2, 0], # Bottom left\n [0, -2, 0], # Right\n [0, 0, 0], # Up\n [2, 0, 0], # Right\n [2, 2, 0] # Up\n ], BLUE)\n self.play(FadeOut(path1))\n self.play(Create(path2))\n self.wait(1)\n \n # Show a disallowed path (red)\n path3 = self.create_path([\n [-2, -2, 0], # Bottom left\n [-2, 0, 0], # Up\n [-2, 2, 0], # Up\n [0, 2, 0], # Right\n [2, 2, 0] # Right\n ], RED)\n self.play(FadeOut(path2))\n self.play(Create(path3))\n disallowed_text = Text(\"Disallowed path (crosses diagonal)\", font_size=24)\n disallowed_text.to_edge(DOWN)\n self.play(ReplacementTransform(rule_text, disallowed_text))\n self.wait(1)\n \n # Show the Catalan formula\n formula = MathTex(r\"C_n = \\frac{1}{n+1}\\binom{2n}{n}\")\n formula.to_edge(UP)\n self.play(Write(formula))\n \n # Clean up and prepare for 3x3 grid\n self.play(FadeOut(path3, diagonal, grid_2x2, start_point, end_point, disallowed_text))\n \n # Create a 3x3 grid\n grid_3x3 = self.create_grid(3)\n self.play(Create(grid_3x3))\n \n # Mark start and end points for 3x3\n start_point = Dot([-3, -3, 0], color=GREEN)\n end_point = Dot([3, 3, 0], color=RED)\n self.play(Create(start_point), Create(end_point))\n \n # Show grid paths formula\n paths_formula = MathTex(r\"\\text{Paths through } (n \\times n) \\text{ grid} = C_n\")\n paths_formula.next_to(formula, DOWN)\n self.play(Write(paths_formula))\n self.wait(1)\n \n # Display C_2 = 2 and C_3 = 5\n c_values = Text(\"For n=2: C_2 = 2 paths\\nFor n=3: C_3 = 5 paths\", font_size=24)\n c_values.to_edge(DOWN)\n self.play(Write(c_values))\n self.wait(1)\n \n # Show one example path for 3x3\n path4 = self.create_path([\n [-3, -3, 0], # Bottom left\n [-1, -3, 0], # Right\n [1, -3, 0], # Right\n [3, -3, 0], # Right\n [3, -1, 0], # Up\n [3, 1, 0], # Up\n [3, 3, 0] # Up\n ], BLUE)\n self.play(Create(path4))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(grid_3x3, start_point, end_point, formula, paths_formula, c_values, path4))\n \n conclusion = Text(\"Catalan Numbers teach us about balance and symmetry,\\ncreating a beautiful sense of order.\", font_size=28)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n \n def create_grid(self, n):\n # Create a grid of size n x n\n scale = 2 # Scale factor for grid size\n grid = VGroup()\n \n # Vertical lines\n for i in range(n + 1):\n x = -n * scale / 2 + i * scale\n line = Line([x, -n * scale / 2, 0], [x, n * scale / 2, 0])\n grid.add(line)\n \n # Horizontal lines\n for i in range(n + 1):\n y = -n * scale / 2 + i * scale\n line = Line([-n * scale / 2, y, 0], [n * scale / 2, y, 0])\n grid.add(line)\n \n return grid\n \n def create_path(self, points, color):\n path = VMob()\n path.set_points_as_corners(points)\n path.set_color(color)\n path.set_stroke(width=3)\n return path\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does the structure of a finitely generated module change when one of its generators is removed?", "chosen": "```python\nfrom manim import *\n\nclass FinitelyGeneratedModules(Scene):\n def construct(self):\n # Title and introduction\n title = Text(\"Unveiling the Web of Dependencies\", font_size=42)\n subtitle = Text(\"Modules and Their Volatile Generators\", font_size=32)\n subtitle.next_to(title, DOWN)\n \n # Create and display title\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Create a module visualization with three generators\n module_text = Text(\"Module M\", font_size=36)\n module_text.to_edge(UP)\n \n # Create three nodes (generators)\n generators = VGroup()\n x1 = Circle(radius=0.5, color=BLUE).shift(LEFT*2)\n x2 = Circle(radius=0.5, color=GREEN).shift(RIGHT*2)\n x3 = Circle(radius=0.5, color=RED)\n \n # Labels for generators\n x1_label = Text(\"x1\", font_size=24).move_to(x1)\n x2_label = Text(\"x2\", font_size=24).move_to(x2)\n x3_label = Text(\"x3\", font_size=24).move_to(x3)\n \n # Group nodes and labels\n generators.add(x1, x2, x3, x1_label, x2_label, x3_label)\n \n # Create connections (dependencies) between generators\n arrow1 = Arrow(x1.get_right(), x3.get_left(), buff=0.1, color=YELLOW)\n arrow2 = Arrow(x2.get_left(), x3.get_right(), buff=0.1, color=YELLOW)\n \n # Display module and generators\n self.play(Write(module_text))\n self.play(Create(generators))\n self.wait(1)\n \n # Show connections/dependencies\n dependency_text = Text(\"Dependencies between generators\", font_size=28)\n dependency_text.next_to(module_text, DOWN)\n \n self.play(Write(dependency_text))\n self.play(Create(arrow1), Create(arrow2))\n self.wait(1)\n \n # Show equation for x1 in terms of x and y\n eq_x1 = MathTex(r\"x_1 = a_1 \\cdot x + a_2 \\cdot y\").shift(DOWN*1.5)\n self.play(Write(eq_x1))\n self.wait(1)\n \n # Show equation for x3 in terms of x1 and x2\n eq_x3 = MathTex(r\"x_3 = b_1 \\cdot x_1 + b_2 \\cdot x_2\").next_to(eq_x1, DOWN)\n self.play(Write(eq_x3))\n self.wait(1)\n \n # Remove x3 and show restructuring\n removal_text = Text(\"Removing generator x3\", font_size=28)\n removal_text.next_to(module_text, DOWN)\n \n self.play(FadeOut(dependency_text), FadeIn(removal_text))\n self.play(FadeOut(x3), FadeOut(x3_label), FadeOut(arrow1), FadeOut(arrow2), FadeOut(eq_x3))\n self.wait(1)\n \n # Show new module structure\n new_module_text = Text(\"New Module M'\", font_size=36)\n new_module_text.to_edge(UP)\n \n new_eq = MathTex(r\"M' = \\langle x_1, x_2 \\rangle\").next_to(eq_x1, DOWN)\n \n self.play(Transform(module_text, new_module_text), Write(new_eq))\n self.wait(1)\n \n # Move generators closer to show simplified structure\n new_x1_pos = x1.copy().shift(RIGHT)\n new_x2_pos = x2.copy().shift(LEFT)\n \n self.play(\n x1.animate.move_to(new_x1_pos),\n x2.animate.move_to(new_x2_pos),\n x1_label.animate.move_to(new_x1_pos),\n x2_label.animate.move_to(new_x2_pos)\n )\n \n # Show direct connection between x1 and x2\n direct_arrow = Arrow(x1.get_right(), x2.get_left(), buff=0.1, color=GREEN)\n self.play(Create(direct_arrow))\n \n # Key insight\n insight_text = Text(\"Key Insight: Removing a generator reveals the true structure\", font_size=28)\n insight_text.to_edge(DOWN)\n \n self.play(Write(insight_text))\n self.wait(2)\n \n # Fade everything out\n self.play(FadeOut(module_text), FadeOut(generators), \n FadeOut(direct_arrow), FadeOut(new_eq), FadeOut(eq_x1),\n FadeOut(removal_text), FadeOut(insight_text))\n \n # Conclusion\n conclusion = Text(\"The structure of a module changes\\nwhen generators are removed\", font_size=36)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass FinitelyGeneratedModules(Scene):\n def construct(self):\n # Title and introduction\n title = Text(\"Unveiling the Web of Dependencies\", font_size=42)\n subtitle = Text(\"Modules and Their Volatile Generators\", font_size=32)\n subtitle.next_to(title, DOWN)\n \n # Create and display title\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Create a module visualization with three generators\n module_text = Text(\"Module M\", font_size=36)\n module_text.to_edge(UP)\n \n # Create three nodes (generators)\n generators = VGroup()\n x1 = Circle(radius=0.5, color=BLUE).shift(LEFT*2)\n x2 = Circle(radius=0.5, color=GREEN).shift(RIGHT*2)\n x3 = Circle(radius=0.5, color=RED)\n \n # Labels for generators\n x1_label = Text(\"x1\", font_size=24).move_to(x1)\n x2_label = Text(\"x2\", font_size=24).move_to(x2)\n x3_label = Text(\"x3\", font_size=24).move_to(x3)\n \n # Group nodes and labels\n generators.add(x1, x2, x3, x1_label, x2_label, x3_label)\n \n # Create connections (dependencies) between generators\n arrow1 = Arrow(x1.get_right(), x3.get_left(), buff=0.1, color=YELLOW)\n arrow2 = Arrow(x2.get_left(), x3.get_right(), buff=0.1, color=YELLOW)\n \n # Display module and generators\n self.play(Write(module_text))\n self.play(Create(generators))\n self.wait(1)\n \n # Show connections/dependencies\n dependency_text = Text(\"Dependencies between generators\", font_size=28)\n dependency_text.next_to(module_text, DOWN)\n \n self.play(Write(dependency_text))\n self.play(Create(arrow1), Create(arrow2))\n self.wait(1)\n \n # Show equation for x1 in terms of x and y\n eq_x1 = MathText(r\"x_1 = a_1 \\cdot x + a_2 \\cdot y\").shift(DOWN*1.5)\n self.play(Write(eq_x1))\n self.wait(1)\n \n # Show equation for x3 in terms of x1 and x2\n eq_x3 = MathTex(r\"x_3 = b_1 \\cdot x_1 + b_2 \\cdot x_2\").next_to(eq_x1, DOWN)\n self.play(Write(eq_x3))\n self.wait(1)\n \n # Remove x3 and show restructuring\n removal_text = Text(\"Removing generator x3\", font_size=28)\n removal_text.next_to(module_text, DOWN)\n \n self.play(FadeOut(dependency_text), FadeIn(removal_text))\n self.play(FadeOut(x3), FadeOut(x3_label), FadeOut(arrow1), FadeOut(arrow2), FadeOut(eq_x3))\n self.wait(1)\n \n # Show new module structure\n new_module_text = Text(\"New Module M'\", font_size=36)\n new_module_text.to_edge(UP)\n \n new_eq = MathTex(r\"M' = \\langle x_1, x_2 \\rangle\").next_to(eq_x1, DOWN)\n \n self.play(Transform(module_text, new_module_text), Write(new_eq))\n self.wait(1)\n \n # Move generators closer to show simplified structure\n new_x1_pos = x1.copy().shift(RIGHT)\n new_x2_pos = x2.copy().shift(LEFT)\n \n self.play(\n x1.animate.move_to(new_x1_pos),\n x2.animate.move_to(new_x2_pos),\n x1_label.animate.move_to(new_x1_pos),\n x2_label.animate.move_to(new_x2_pos)\n )\n \n # Show direct connection between x1 and x2\n direct_arrow = Arrow(x1.get_right(), x2.get_left(), buff=0.1, color=GREEN)\n self.play(Create(direct_arrow))\n \n # Key insight\n insight_text = Text(\"Key Insight: Removing a generator reveals the true structure\", font_size=28)\n insight_text.to_edge(DOWN)\n \n self.play(Write(insight_text))\n self.wait(2)\n \n # Fade everything out\n self.play(FadeOut(module_text), FadeOut(generators), \n FadeOut(direct_arrow), FadeOut(new_eq), FadeOut(eq_x1),\n FadeOut(removal_text), FadeOut(insight_text))\n \n # Conclusion\n conclusion = Text(\"The structure of a module changes\\nwhen generators are removed\", font_size=36)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 def construct(self):\n # --- Configuration ---\n text_color = BLUE\n equation_color = WHITE\n highlight_color = YELLOW\n \n # --- Step 1: Introduction and Differential Equation ---\n # Guidance text at the top\n guidance_1 = Text(\n \"Solving a First-Order Differential Equation\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n # The initial differential equation\n diff_eq = MathTex(r\"y' - y = 0\", font_size=60, color=equation_color)\n diff_eq.next_to(guidance_1, DOWN, buff=1.5)\n \n self.play(Write(guidance_1))\n self.play(Write(diff_eq))\n self.wait(2)\n\n # --- Step 2: Form the Characteristic Equation ---\n guidance_2 = Text(\n \"Assume y = e^{rx}, leading to the characteristic equation:\",\n font_size=32,\n color=text_color\n ).to_edge(UP)\n \n char_eq = MathTex(r\"r - 1 = 0\", font_size=60, color=equation_color)\n char_eq.next_to(guidance_2, DOWN, buff=1.5)\n \n self.play(Transform(guidance_1, guidance_2))\n self.play(ReplacementTransform(diff_eq, char_eq))\n self.wait(2)\n\n # --- Step 3: Finding the Root ---\n guidance_3 = Text(\n \"Solve for the root r:\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n root_eq = MathTex(r\"r = 1\", font_size=60, color=equation_color)\n root_eq.next_to(guidance_3, DOWN, buff=1.5)\n \n self.play(Transform(guidance_1, guidance_3))\n self.play(ReplacementTransform(char_eq, root_eq))\n self.wait(2)\n\n # --- Step 4: General Solution ---\n guidance_4 = Text(\n \"Write the general solution using r = 1:\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n general_sol = MathTex(r\"y = C e^x\", font_size=60, color=equation_color)\n general_sol.next_to(guidance_4, DOWN, buff=1.5)\n general_sol.set_color_by_tex(\"C\", highlight_color)\n \n constant_note = Text(\n \"where C is an arbitrary constant\",\n font_size=28,\n color=GRAY\n ).next_to(general_sol, DOWN, buff=0.5)\n \n self.play(Transform(guidance_1, guidance_4))\n self.play(ReplacementTransform(root_eq, general_sol))\n self.play(FadeIn(constant_note))\n self.wait(2)\n\n # --- Step 5: Conclusion ---\n guidance_final = Text(\n \"Solution Process Complete\",\n font_size=36,\n color=GREEN\n ).to_edge(UP)\n \n solution_box = SurroundingRectangle(\n VGroup(general_sol, constant_note),\n color=highlight_color,\n buff=0.3\n )\n \n self.play(Transform(guidance_1, guidance_final))\n self.play(Create(solution_box))\n self.wait(3)\n\n# To run this animation:\n# manim -pql script_name.py SolveFirstOrderODE\n```", "rejected": "```python\nfrom manim import *\n\nclass SolveFirstOrderODE(Scene):\n def construct(self):\n # --- Configuration ---\n text_color = BLUE\n equation_color = WHITE\n highlight_color = YELLOW\n \n # --- Step 1: Introduction and Differential Equation ---\n # Guidance text at the top\n guidance_1 = Text(\n \"Solving a First-Order Differential Equation\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n # The initial differential equation\n diff_eq = MathText(r\"y' - y = 0\", font_size=60, color=equation_color)\n diff_eq.next_to(guidance_1, DOWN, buff=1.5)\n \n self.play(Write(guidance_1))\n self.play(Write(diff_eq))\n self.wait(2)\n\n # --- Step 2: Form the Characteristic Equation ---\n guidance_2 = Text(\n \"Assume y = e^{rx}, leading to the characteristic equation:\",\n font_size=32,\n color=text_color\n ).to_edge(UP)\n \n char_eq = MathTex(r\"r - 1 = 0\", font_size=60, color=equation_color)\n char_eq.next_to(guidance_2, DOWN, buff=1.5)\n \n self.play(Transform(guidance_1, guidance_2))\n self.play(ReplacementTransform(diff_eq, char_eq))\n self.wait(2)\n\n # --- Step 3: Finding the Root ---\n guidance_3 = Text(\n \"Solve for the root r:\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n root_eq = MathTex(r\"r = 1\", font_size=60, color=equation_color)\n root_eq.next_to(guidance_3, DOWN, buff=1.5)\n \n self.play(Transform(guidance_1, guidance_3))\n self.play(ReplacementTransform(char_eq, root_eq))\n self.wait(2)\n\n # --- Step 4: General Solution ---\n guidance_4 = Text(\n \"Write the general solution using r = 1:\",\n font_size=36,\n color=text_color\n ).to_edge(UP)\n \n general_sol = MathTex(r\"y = C e^x\", font_size=60, color=equation_color)\n general_sol.next_to(guidance_4, DOWN, buff=1.5)\n general_sol.set_color_by_tex(\"C\", highlight_color)\n \n constant_note = Text(\n \"where C is an arbitrary constant\",\n font_size=28,\n color=GRAY\n ).next_to(general_sol, DOWN, buff=0.5)\n \n self.play(Transform(guidance_1, guidance_4))\n self.play(ReplacementTransform(root_eq, general_sol))\n self.play(FadeIn(constant_note))\n self.wait(2)\n\n # --- Step 5: Conclusion ---\n guidance_final = Text(\n \"Solution Process Complete\",\n font_size=36,\n color=GREEN\n ).to_edge(UP)\n \n solution_box = SurroundingRectangle(\n VGroup(general_sol, constant_note),\n color=highlight_color,\n buff=0.3\n )\n \n self.play(Transform(guidance_1, guidance_final))\n self.play(Create(solution_box))\n self.wait(3)\n\n# To run this animation:\n# manim -pql script_name.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 demonstrates the process of calculating a definite integral. Specifically, it should show the integration of x cubed from 0 to 2. The animation should begin by presenting the integration problem, then explain how to apply the power rule for definite integration. Next, it should show the step-by-step process of integrating x cubed, starting with the application of the power rule and finishing with the evaluation of the integral at the boundaries 0 and 2. Finally, the animation should conclude by clearly showing the numeric solution to the integral. Can you create an animation like this for a classroom setting that helps students understand the concept visually?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # Colors for highlighting\n COLOR_RESULT = GREEN\n \n # 1. Setup Axes and Graph (Geometric Visualization)\n axes = Axes(\n x_range=[0, 2.5, 1],\n y_range=[0, 5, 1],\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 graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"x^3\")\n \n # Area under the curve (to be animated later)\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n \n # 2. The Initial Problem\n title = Text(\"Calculating a Definite Integral\", font_size=36).to_edge(UP)\n problem = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=48).to_edge(RIGHT, buff=1).shift(UP * 3)\n\n self.play(Write(title))\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(Write(problem))\n self.wait(2)\n\n # 3. Explaining the Power Rule\n rule_title = Text(\"The Power Rule:\", font_size=32, color=YELLOW).next_to(problem, DOWN, buff=0.8)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=42).next_to(rule_title, DOWN, buff=0.3)\n\n self.play(Write(rule_title), Write(rule_formula))\n self.wait(3)\n \n # Fade out the general rule to reduce cognitive load and make room for the specific steps\n self.play(FadeOut(rule_title), FadeOut(rule_formula))\n\n # 4. Step-by-Step Integration\n # Step 1: Apply Power Rule\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_0^2\", font_size=42).next_to(problem, DOWN, buff=0.5)\n \n # Step 2: Simplify exponents\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=42).next_to(step1, DOWN, buff=0.5)\n \n # Step 3: Evaluate boundaries (Upper - Lower)\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42).next_to(step2, DOWN, buff=0.5)\n \n # Step 4: Arithmetic\n step4 = MathTex(r\"= \\frac{16}{4} - 0\", font_size=42).next_to(step3, DOWN, buff=0.5)\n \n # Step 5: Final Solution\n step5 = MathTex(r\"= 4\", font_size=48, color=COLOR_RESULT).next_to(step4, DOWN, buff=0.5)\n\n # Animation Sequence for Steps\n # Using Write mimics writing on a whiteboard, allowing students to follow the logic sequentially\n self.play(Write(step1), run_time=2)\n self.wait(1)\n \n self.play(Write(step2), run_time=2)\n self.wait(1)\n \n # As we start evaluating, shade the area to emphasize the geometric meaning of the calculation\n self.play(FadeIn(area), Write(step3), run_time=2)\n self.wait(1)\n \n self.play(Write(step4), run_time=2)\n self.wait(1)\n \n self.play(Write(step5), run_time=2)\n self.wait(2)\n\n # Final highlight: Box the answer\n box = SurroundingRectangle(step5, color=COLOR_RESULT, buff=0.1)\n self.play(Create(box))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralAnimation(Scene):\n def construct(self):\n # Colors for highlighting\n COLOR_RESULT = GREEN\n \n # 1. Setup Axes and Graph (Geometric Visualization)\n axes = Axes(\n x_range=[0, 2.5, 1],\n y_range=[0, 5, 1],\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 graph = axes.plot(lambda x: x**3, x_range=[0, 2], color=BBLUE)\n graph_label = axes.get_graph_label(graph, label=\"x^3\")\n \n # Area under the curve (to be animated later)\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.3)\n \n # 2. The Initial Problem\n title = Text(\"Calculating a Definite Integral\", font_size=36).to_edge(UP)\n problem = MathTex(r\"\\int_0^2 x^3 \\, dx\", font_size=48).to_edge(RIGHT, buff=1).shift(UP * 3)\n\n self.play(Write(title))\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.play(Write(problem))\n self.wait(2)\n\n # 3. Explaining the Power Rule\n rule_title = Text(\"The Power Rule:\", font_size=32, color=YELLOW).next_to(problem, DOWN, buff=0.8)\n rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=42).next_to(rule_title, DOWN, buff=0.3)\n\n self.play(Write(rule_title), Write(rule_formula))\n self.wait(3)\n \n # Fade out the general rule to reduce cognitive load and make room for the specific steps\n self.play(FadeOut(rule_title), FadeOut(rule_formula))\n\n # 4. Step-by-Step Integration\n # Step 1: Apply Power Rule\n step1 = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_0^2\", font_size=42).next_to(problem, DOWN, buff=0.5)\n \n # Step 2: Simplify exponents\n step2 = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_0^2\", font_size=42).next_to(step1, DOWN, buff=0.5)\n \n # Step 3: Evaluate boundaries (Upper - Lower)\n step3 = MathTex(r\"= \\frac{2^4}{4} - \\frac{0^4}{4}\", font_size=42).next_to(step2, DOWN, buff=0.5)\n \n # Step 4: Arithmetic\n step4 = MathTex(r\"= \\frac{16}{4} - 0\", font_size=42).next_to(step3, DOWN, buff=0.5)\n \n # Step 5: Final Solution\n step5 = MathTex(r\"= 4\", font_size=48, color=COLOR_RESULT).next_to(step4, DOWN, buff=0.5)\n\n # Animation Sequence for Steps\n # Using Write mimics writing on a whiteboard, allowing students to follow the logic sequentially\n self.play(Write(step1), run_time=2)\n self.wait(1)\n \n self.play(Write(step2), run_time=2)\n self.wait(1)\n \n # As we start evaluating, shade the area to emphasize the geometric meaning of the calculation\n self.play(FadeIn(area), Write(step3), run_time=2)\n self.wait(1)\n \n self.play(Write(step4), run_time=2)\n self.wait(1)\n \n self.play(Write(step5), run_time=2)\n self.wait(2)\n\n # Final highlight: Box the answer\n box = SurroundingRectangle(step5, color=COLOR_RESULT, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = BBLUE_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # ------------------------------------------------------------------\n # 1. Introduction: Display the equation of the curve (y = x^2)\n # ------------------------------------------------------------------\n func_eq = MathTex(\"y\", \"=\", \"x^2\", font_size=48)\n func_eq.to_edge(UP)\n \n self.play(Write(func_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Goal Statement: Present the objective\n # ------------------------------------------------------------------\n goal_text = Text(\n \"Goal: Calculate the area under the curve\\nfrom x = 1 to x = 3\",\n font_size=36\n )\n goal_text.next_to(func_eq, DOWN, buff=0.5)\n \n self.play(FadeIn(goal_text))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Setup: Show axes, curve, area, and integral symbol\n # ------------------------------------------------------------------\n # Create Axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True, \"font_size\": 24},\n x_axis_config={\"numbers_to_include\": [1, 3]},\n y_axis_config={\"numbers_to_include\": [4, 9]},\n )\n axes.shift(DOWN * 1.5)\n \n # Plot the function y = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE)\n \n # Highlight the area\n area = axes.get_area(curve, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n # Vertical lines for bounds\n line1 = axes.get_vertical_line(axes.input_to_graph_point(1, curve), color=YELLOW)\n line3 = axes.get_vertical_line(axes.input_to_graph_point(3, curve), color=YELLOW)\n\n # Integral Notation\n integral_expr = MathTex(\n r\"\\text{Area} = \\int_{1}^{3}\", \"x^2\", r\"\\, dx\", font_size=42\n )\n integral_expr.next_to(axes, UP, buff=0.5)\n \n # Animate Setup\n self.play(\n FadeOut(goal_text),\n Create(axes),\n Create(curve),\n Write(integral_expr)\n )\n self.play(\n FadeIn(area),\n Create(line1),\n Create(line3)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Calculation Steps: Antiderivative and Evaluation\n # ------------------------------------------------------------------\n # Step 4a: Finding the antiderivative\n antiderivative = MathTex(\n r\"= \\left[ \\frac{1}{3}x^3 \\right]_{1}^{3}\", font_size=42\n )\n antiderivative.next_to(integral_expr, DOWN, buff=0.5)\n \n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 4b: Evaluating at bounds\n evaluation = MathTex(\n r\"= \\frac{1}{3}(3)^3 - \\frac{1}{3}(1)^3\", font_size=42\n )\n evaluation.next_to(antiderivative, DOWN, buff=0.5)\n \n self.play(Write(evaluation))\n self.wait(1)\n\n # Step 4c: Simplification\n simplification = MathTex(\n r\"= \\frac{27}{3} - \\frac{1}{3} = \\frac{26}{3}\", font_size=42\n )\n simplification.next_to(evaluation, DOWN, buff=0.5)\n \n self.play(Write(simplification))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Result: Display the final calculated area value\n # ------------------------------------------------------------------\n result = MathTex(\n r\"\\text{Area} \\approx 8.67\", font_size=48, color=YELLOW\n )\n result.next_to(simplification, DOWN, buff=0.5)\n \n # Highlight the result and update area color\n result_box = SurroundingRectangle(result, color=YELLOW, buff=0.2)\n \n self.play(\n Write(result),\n Create(result_box),\n area.animate.set_color(YELLOW).set_opacity(0.8)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Cleanup: Clear all elements from the screen\n # ------------------------------------------------------------------\n all_elements = VGroup(\n func_eq, axes, curve, area, line1, line3, \n integral_expr, antiderivative, evaluation, \n simplification, result, result_box\n )\n \n self.play(FadeOut(all_elements))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Display the equation of the curve (y = x^2)\n # ------------------------------------------------------------------\n func_eq = MathTex(\"y\", \"=\", \"x^2\", font_size=48)\n func_eq.to_edge(UP)\n \n self.play(Write(func_eq))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Goal Statement: Present the objective\n # ------------------------------------------------------------------\n goal_text = Text(\n \"Goal: Calculate the area under the curve\\nfrom x = 1 to x = 3\",\n font_size=36\n )\n goal_text.next_to(func_eq, DOWN, buff=0.5)\n \n self.play(FadeIn(goal_text))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Setup: Show axes, curve, area, and integral symbol\n # ------------------------------------------------------------------\n # Create Axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n axis_config={\"include_tip\": True, \"font_size\": 24},\n x_axis_config={\"numbers_to_include\": [1, 3]},\n y_axis_config={\"numbers_to_include\": [4, 9]},\n )\n axes.shift(DOWN * 1.5)\n \n # Plot the function y = x^2\n curve = axes.plot(lambda x: x**2, color=BBLUE)\n \n # Highlight the area\n area = axes.get_area(curve, x_range=[1, 3], color=GREEN, opacity=0.5)\n \n # Vertical lines for bounds\n line1 = axes.get_vertical_line(axes.input_to_graph_point(1, curve), color=YELLOW)\n line3 = axes.get_vertical_line(axes.input_to_graph_point(3, curve), color=YELLOW)\n\n # Integral Notation\n integral_expr = MathTex(\n r\"\\text{Area} = \\int_{1}^{3}\", \"x^2\", r\"\\, dx\", font_size=42\n )\n integral_expr.next_to(axes, UP, buff=0.5)\n \n # Animate Setup\n self.play(\n FadeOut(goal_text),\n Create(axes),\n Create(curve),\n Write(integral_expr)\n )\n self.play(\n FadeIn(area),\n Create(line1),\n Create(line3)\n )\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Calculation Steps: Antiderivative and Evaluation\n # ------------------------------------------------------------------\n # Step 4a: Finding the antiderivative\n antiderivative = MathTex(\n r\"= \\left[ \\frac{1}{3}x^3 \\right]_{1}^{3}\", font_size=42\n )\n antiderivative.next_to(integral_expr, DOWN, buff=0.5)\n \n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 4b: Evaluating at bounds\n evaluation = MathTex(\n r\"= \\frac{1}{3}(3)^3 - \\frac{1}{3}(1)^3\", font_size=42\n )\n evaluation.next_to(antiderivative, DOWN, buff=0.5)\n \n self.play(Write(evaluation))\n self.wait(1)\n\n # Step 4c: Simplification\n simplification = MathTex(\n r\"= \\frac{27}{3} - \\frac{1}{3} = \\frac{26}{3}\", font_size=42\n )\n simplification.next_to(evaluation, DOWN, buff=0.5)\n \n self.play(Write(simplification))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Result: Display the final calculated area value\n # ------------------------------------------------------------------\n result = MathTex(\n r\"\\text{Area} \\approx 8.67\", font_size=48, color=YELLOW\n )\n result.next_to(simplification, DOWN, buff=0.5)\n \n # Highlight the result and update area color\n result_box = SurroundingRectangle(result, color=YELLOW, buff=0.2)\n \n self.play(\n Write(result),\n Create(result_box),\n area.animate.set_color(YELLOW).set_opacity(0.8)\n )\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Cleanup: Clear all elements from the screen\n # ------------------------------------------------------------------\n all_elements = VGroup(\n func_eq, axes, curve, area, line1, line3, \n integral_expr, antiderivative, evaluation, \n simplification, result, result_box\n )\n \n self.play(FadeOut(all_elements))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\n\nclass OpeningManim(Scene):\n def construct(self):\n title = Tex(r\"This is some \\LaTeX\")\n basel = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Euclidean Algorithm' (\"Nature's Arithmetic: The Euclidean Algorithm & Natural Spirals\"): In what way does the Euclidean Algorithm mirror patterns found in nature, such as the spirals of a sunflower or the geometry of a snail's shell?\nVisual style guidance: Minimalistic design similar to 3Blue1Brown, using a dark palette contrasted by bright yellows and greens, reminiscent of nature's own contrasting colors – enriching the focus on spirals.", "chosen": "```python\nfrom manim import *\n\nclass EuclideanAlgorithmNature(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Nature's Arithmetic: The Euclidean Algorithm & Natural Spirals\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Introduction - Simple visualization of nature's patterns\n intro_text = Text(\"Patterns in Nature\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Creating a circle to represent a sunflower\n circle = Circle(radius=1.5, color=YELLOW).shift(LEFT*2)\n dot = Dot(point=circle.get_center(), color=YELLOW)\n \n # Creating simple arcs to represent a spiral (like a snail shell)\n arcs = VGroup()\n for i in range(1, 6):\n arc = Arc(radius=i*0.3, start_angle=0, angle=i*PI, color=YELLOW).shift(RIGHT*2)\n arcs.add(arc)\n \n self.play(Create(circle), Create(dot))\n self.play(Create(arcs))\n self.wait(1)\n self.play(FadeOut(circle), FadeOut(dot), FadeOut(arcs))\n \n # Key Concept 1 - Introduction to Euclidean Algorithm\n concept1 = Text(\"The Euclidean Algorithm finds the GCD\", font_size=32)\n self.play(Write(concept1))\n self.wait(1)\n self.play(FadeOut(concept1))\n \n # Key Concept 2 - Example calculation\n example = Text(\"Example: GCD(84, 32)\", font_size=32)\n self.play(Write(example))\n self.wait(1)\n self.play(FadeOut(example))\n \n # Show algorithm steps - calculating GCD of 84 and 32\n eq1 = Text(\"84 = 32 \\times 2 + 20\", font_size=28)\n eq2 = Text(\"32 = 20 \\times 1 + 12\", font_size=28)\n eq3 = Text(\"20 = 12 \\times 1 + 8\", font_size=28)\n eq4 = Text(\"12 = 8 \\times 1 + 4\", font_size=28)\n eq5 = Text(\"8 = 4 \\times 2 + 0\", font_size=28)\n \n equations = VGroup(eq1, eq2, eq3, eq4, eq5).arrange(DOWN, buff=0.3).scale(0.9)\n \n for eq in equations:\n self.play(Write(eq))\n self.wait(0.3)\n \n result = Text(\"Therefore, GCD(84, 32) = 4\", color=YELLOW, font_size=28)\n result.next_to(equations, DOWN, buff=0.5)\n \n self.play(Write(result))\n self.wait(1)\n self.play(FadeOut(equations), FadeOut(result))\n \n # Key Concept 3 - Visual representation\n concept3 = Text(\"The algorithm creates patterns similar to spirals\", font_size=32)\n self.play(Write(concept3))\n self.wait(1)\n self.play(FadeOut(concept3))\n \n # Rectangle spiral visualization - representing the Euclidean Algorithm geometrically\n rect1 = Rectangle(width=4, height=2, color=GREEN)\n rect2 = Rectangle(width=2, height=1, color=YELLOW).next_to(rect1, RIGHT, buff=0)\n rect3 = Rectangle(width=1, height=1, color=RED).next_to(rect2, DOWN, buff=0)\n rect4 = Rectangle(width=1, height=0.5, color=BLUE).next_to(rect3, LEFT, buff=0)\n \n rectangles = VGroup(rect1, rect2, rect3, rect4).center()\n \n for rect in rectangles:\n self.play(Create(rect))\n self.wait(0.3)\n \n self.wait(1)\n self.play(FadeOut(rectangles))\n \n # Key Insight - connecting math to nature\n insight = Text(\"This recursive pattern forms the backbone\\nof many growing patterns in nature\", font_size=28)\n self.play(Write(insight))\n self.wait(1)\n self.play(FadeOut(insight))\n \n # Conclusion - connecting math to nature\n conclusion = Text(\"Mathematics and nature share beautiful patterns\", font_size=32)\n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n \n # Final title\n final = Text(\"Nature's Arithmetic\", color=YELLOW, font_size=40)\n self.play(Write(final))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EuclideanAlgorithmNature(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Nature's Arithmetic: The Euclidean Algorithm & Natural Spirals\", font_size=32)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Introduction - Simple visualization of nature's patterns\n intro_text = Text(\"Patterns in Nature\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Creating a circle to represent a sunflower\n circle = Circle(radius=1.5, color=YELLOW).shift(LEFT*2)\n dot = Dot(point=circle.get_center(), color=YELLOW)\n \n # Creating simple arcs to represent a spiral (like a snail shell)\n arcs = VGroup()\n for i in range(1, 6):\n arc = Arc(radius=i*0.3, start_angle=0, angle=i*PI, color=YELLOW).shift(RIGHT*2)\n arcs.add(arc)\n \n self.play(Create(circle), Create(dot))\n self.play(Create(arcs))\n self.wait(1)\n self.play(FadeOut(circle), FadeOut(dot), FadeOut(arcs))\n \n # Key Concept 1 - Introduction to Euclidean Algorithm\n concept1 = Text(\"The Euclidean Algorithm finds the GCD\", font_size=32)\n self.play(Write(concept1))\n self.wait(1)\n self.play(FadeOut(concept1))\n \n # Key Concept 2 - Example calculation\n example = Text(\"Example: GCD(84, 32)\", font_size=32)\n self.play(Write(example))\n self.wait(1)\n self.play(FadeOut(example))\n \n # Show algorithm steps - calculating GCD of 84 and 32\n eq1 = Text(\"84 = 32 \\times 2 + 20\", font_size=28)\n eq2 = Text(\"32 = 20 \\times 1 + 12\", font_size=28)\n eq3 = Text(\"20 = 12 \\times 1 + 8\", font_size=28)\n eq4 = Text(\"12 = 8 \\times 1 + 4\", font_size=28)\n eq5 = Text(\"8 = 4 \\times 2 + 0\", font_size=28)\n \n equations = VGroup(eq1, eq2, eq3, eq4, eq5).arrange(DOWN, buff=0.3).scale(0.9)\n \n for eq in equations:\n self.play(Write(eq))\n self.wait(0.3)\n \n result = Text(\"Therefore, GCD(84, 32) = 4\", color=YELLOW, font_size=28)\n result.next_to(equations, DOWN, buff=0.5)\n \n self.play(Write(result))\n self.wait(1)\n self.play(FadeOut(equations), FadeOut(result))\n \n # Key Concept 3 - Visual representation\n concept3 = Text(\"The algorithm creates patterns similar to spirals\", font_size=32)\n self.play(Write(concept3))\n self.wait(1)\n self.play(FadeOut(concept3))\n \n # Rectangle spiral visualization - representing the Euclidean Algorithm geometrically\n rect1 = Rectangle(width=4, height=2, color=GREEN)\n rect2 = Rectangle(width=2, height=1, color=YELLOW).next_to(rect1, RIGHT, buff=0)\n rect3 = Rectangle(width=1, height=1, color=RED).next_to(rect2, DOWN, buff=0)\n rect4 = Rectangle(width=1, height=0.5, color=BBLUE).next_to(rect3, LEFT, buff=0)\n \n rectangles = VGroup(rect1, rect2, rect3, rect4).center()\n \n for rect in rectangles:\n self.play(Create(rect))\n self.wait(0.3)\n \n self.wait(1)\n self.play(FadeOut(rectangles))\n \n # Key Insight - connecting math to nature\n insight = Text(\"This recursive pattern forms the backbone\\nof many growing patterns in nature\", font_size=28)\n self.play(Write(insight))\n self.wait(1)\n self.play(FadeOut(insight))\n \n # Conclusion - connecting math to nature\n conclusion = Text(\"Mathematics and nature share beautiful patterns\", font_size=32)\n self.play(Write(conclusion))\n self.wait(1)\n self.play(FadeOut(conclusion))\n \n # Final title\n final = Text(\"Nature's Arithmetic\", color=YELLOW, font_size=40)\n self.play(Write(final))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralExplanation(Scene):\n def construct(self):\n # 1. Problem Statement\n problem = MathTex(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.to_edge(UP)\n self.play(Write(problem))\n self.wait()\n\n # 2. Power Rule Application\n power_rule_text = Text(\"Apply the Power Rule:\", font_size=36).next_to(problem, DOWN, buff=1)\n power_rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36).next_to(power_rule_text, DOWN, buff=0.5)\n \n self.play(Write(power_rule_text), Write(power_rule_formula))\n self.wait(2)\n\n antiderivative_raw = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\").next_to(power_rule_formula, DOWN, buff=1)\n self.play(Write(antiderivative_raw))\n self.wait()\n \n antiderivative_simple = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative_simple.move_to(antiderivative_raw)\n self.play(ReplacementTransform(antiderivative_raw, antiderivative_simple))\n self.wait()\n\n # Clear the rule text and move the antiderivative up to make room\n self.play(\n FadeOut(power_rule_text), \n FadeOut(power_rule_formula), \n antiderivative_simple.animate.next_to(problem, DOWN, buff=0.5)\n )\n self.wait()\n\n # 3. Boundary Evaluation\n evaluation = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n evaluation.next_to(antiderivative_simple, DOWN, buff=0.5)\n self.play(Write(evaluation))\n self.wait()\n\n # 4. Final Calculation\n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n calculation.next_to(evaluation, DOWN, buff=0.5)\n self.play(Write(calculation))\n self.wait()\n\n # 5. Result\n result = MathTex(r\"= 4\")\n result.next_to(calculation, DOWN, buff=0.5)\n result.set_color(YELLOW)\n self.play(Write(result))\n self.play(Indicate(result))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralExplanation(Scene):\n def construct(self):\n # 1. Problem Statement\n problem = MathText(r\"\\int_{0}^{2} x^3 \\, dx\")\n problem.to_edge(UP)\n self.play(Write(problem))\n self.wait()\n\n # 2. Power Rule Application\n power_rule_text = Text(\"Apply the Power Rule:\", font_size=36).next_to(problem, DOWN, buff=1)\n power_rule_formula = MathTex(r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=36).next_to(power_rule_text, DOWN, buff=0.5)\n \n self.play(Write(power_rule_text), Write(power_rule_formula))\n self.wait(2)\n\n antiderivative_raw = MathTex(r\"= \\left[ \\frac{x^{3+1}}{3+1} \\right]_{0}^{2}\").next_to(power_rule_formula, DOWN, buff=1)\n self.play(Write(antiderivative_raw))\n self.wait()\n \n antiderivative_simple = MathTex(r\"= \\left[ \\frac{x^4}{4} \\right]_{0}^{2}\")\n antiderivative_simple.move_to(antiderivative_raw)\n self.play(ReplacementTransform(antiderivative_raw, antiderivative_simple))\n self.wait()\n\n # Clear the rule text and move the antiderivative up to make room\n self.play(\n FadeOut(power_rule_text), \n FadeOut(power_rule_formula), \n antiderivative_simple.animate.next_to(problem, DOWN, buff=0.5)\n )\n self.wait()\n\n # 3. Boundary Evaluation\n evaluation = MathTex(r\"= \\left( \\frac{2^4}{4} \\right) - \\left( \\frac{0^4}{4} \\right)\")\n evaluation.next_to(antiderivative_simple, DOWN, buff=0.5)\n self.play(Write(evaluation))\n self.wait()\n\n # 4. Final Calculation\n calculation = MathTex(r\"= \\frac{16}{4} - 0\")\n calculation.next_to(evaluation, DOWN, buff=0.5)\n self.play(Write(calculation))\n self.wait()\n\n # 5. Result\n result = MathTex(r\"= 4\")\n result.next_to(calculation, DOWN, buff=0.5)\n result.set_color(YELLOW)\n self.play(Write(result))\n self.play(Indicate(result))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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## Ethics, Safety, and Compliance (8 minutes)\n\n### Bias and Fairness\nDiscuss how algorithms may amplify societal biases (such as gender and racial discrimination) and explore ways to introduce fairness constraints during the dataset construction and model evaluation phases.\n\n\nContextual location within the document (from highest to current level):\n# Detailed Outline for Lecture Sixteen of the Introduction to Artificial Intelligence Course (AI Engineering and Course Summary, 90 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BiasAndFairness(Scene):\n\n def construct(self):\n title = Text('Bias and Fairness in AI', 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 box_data = Text('Dataset', font_size=24)\n rect_data = SurroundingRectangle(box_data, color=BLUE, buff=0.3)\n group_data = VGroup(box_data, rect_data)\n box_model = Text('AI Model', font_size=24)\n rect_model = SurroundingRectangle(box_model, color=YELLOW, buff=0.3)\n group_model = VGroup(box_model, rect_model)\n box_out = Text('Decisions', font_size=24)\n rect_out = SurroundingRectangle(box_out, color=RED, buff=0.3)\n group_out = VGroup(box_out, rect_out)\n flow = VGroup(group_data, group_model, group_out).arrange(RIGHT, buff=1.5).shift(UP * 0.5)\n arrow1 = Arrow(group_data.get_right(), group_model.get_left(), buff=0.1)\n arrow2 = Arrow(group_model.get_right(), group_out.get_left(), buff=0.1)\n self.play(FadeIn(group_data), GrowArrow(arrow1), FadeIn(group_model), GrowArrow(arrow2), FadeIn(group_out), run_time=2)\n dots_data = VGroup(*[Dot(color=BLUE) for _ in range(4)], Dot(color=RED)).arrange(RIGHT, buff=0.1)\n dots_data.next_to(group_data, DOWN, buff=0.5)\n dots_out = VGroup(*[Dot(color=BLUE) for _ in range(5)]).arrange(RIGHT, buff=0.1)\n dots_out.next_to(group_out, DOWN, buff=0.5)\n self.play(FadeIn(dots_data), FadeIn(dots_out), run_time=1)\n warning = Text('Algorithms may amplify societal biases (e.g., gender, race)', font_size=24, color=RED)\n warning.to_edge(DOWN, buff=1.2)\n self.play(Write(warning), run_time=1.5)\n self.wait(1)\n dots_data_fair = VGroup(*[Dot(color=BLUE) for _ in range(3)], *[Dot(color=RED) for _ in range(3)]).arrange(RIGHT, buff=0.1)\n dots_data_fair.move_to(dots_data)\n dots_out_fair = VGroup(*[Dot(color=BLUE) for _ in range(3)], *[Dot(color=RED) for _ in range(3)]).arrange(RIGHT, buff=0.1)\n dots_out_fair.move_to(dots_out)\n fair_data_text = Text('+ Fair Construction', font_size=18, color=GREEN).next_to(dots_data_fair, DOWN, buff=0.3)\n fair_eval_text = Text('+ Fairness Evaluation', font_size=18, color=GREEN).next_to(dots_out_fair, DOWN, buff=0.3)\n solution = Text('Introduce fairness constraints in dataset and evaluation phases', font_size=24, color=GREEN)\n solution.move_to(warning)\n self.play(Transform(dots_data, dots_data_fair), Transform(dots_out, dots_out_fair), FadeIn(fair_data_text), FadeIn(fair_eval_text), Transform(warning, solution), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass BiasAndFairness(Scene):\n\n def construct(self):\n title = Text('Bias and Fairness in AI', 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 box_data = Text('Dataset', font_size=24)\n rect_data = SurroundingRectangle(box_data, color=BBLUE, buff=0.3)\n group_data = VGroup(box_data, rect_data)\n box_model = Text('AI Model', font_size=24)\n rect_model = SurroundingRectangle(box_model, color=YELLOW, buff=0.3)\n group_model = VGroup(box_model, rect_model)\n box_out = Text('Decisions', font_size=24)\n rect_out = SurroundingRectangle(box_out, color=RED, buff=0.3)\n group_out = VGroup(box_out, rect_out)\n flow = VGroup(group_data, group_model, group_out).arrange(RIGHT, buff=1.5).shift(UP * 0.5)\n arrow1 = Arrow(group_data.get_right(), group_model.get_left(), buff=0.1)\n arrow2 = Arrow(group_model.get_right(), group_out.get_left(), buff=0.1)\n self.play(FadeIn(group_data), GrowArrow(arrow1), FadeIn(group_model), GrowArrow(arrow2), FadeIn(group_out), run_time=2)\n dots_data = VGroup(*[Dot(color=BLUE) for _ in range(4)], Dot(color=RED)).arrange(RIGHT, buff=0.1)\n dots_data.next_to(group_data, DOWN, buff=0.5)\n dots_out = VGroup(*[Dot(color=BLUE) for _ in range(5)]).arrange(RIGHT, buff=0.1)\n dots_out.next_to(group_out, DOWN, buff=0.5)\n self.play(FadeIn(dots_data), FadeIn(dots_out), run_time=1)\n warning = Text('Algorithms may amplify societal biases (e.g., gender, race)', font_size=24, color=RED)\n warning.to_edge(DOWN, buff=1.2)\n self.play(Write(warning), run_time=1.5)\n self.wait(1)\n dots_data_fair = VGroup(*[Dot(color=BLUE) for _ in range(3)], *[Dot(color=RED) for _ in range(3)]).arrange(RIGHT, buff=0.1)\n dots_data_fair.move_to(dots_data)\n dots_out_fair = VGroup(*[Dot(color=BLUE) for _ in range(3)], *[Dot(color=RED) for _ in range(3)]).arrange(RIGHT, buff=0.1)\n dots_out_fair.move_to(dots_out)\n fair_data_text = Text('+ Fair Construction', font_size=18, color=GREEN).next_to(dots_data_fair, DOWN, buff=0.3)\n fair_eval_text = Text('+ Fairness Evaluation', font_size=18, color=GREEN).next_to(dots_out_fair, DOWN, buff=0.3)\n solution = Text('Introduce fairness constraints in dataset and evaluation phases', font_size=24, color=GREEN)\n solution.move_to(warning)\n self.play(Transform(dots_data, dots_data_fair), Transform(dots_out, dots_out_fair), FadeIn(fair_data_text), FadeIn(fair_eval_text), Transform(warning, solution), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 video animation that demonstrates a basic division operation in a visually engaging way. The animation should have a portrait orientation, suitable for mobile viewing, and last a few seconds. Start with an image that represents the concept of division followed by the equation \"divided by 3 equals 15\", then show an example where this equation is solved by finding the unknown variable 'b', which is highlighted in a distinct color to emphasize its importance. Finally, present the solution to the division problem side by side with the original equation. The background should be comforting to the eyes, and the text and important elements should be clearly visible and highlighted with different colors to enhance learning. The animations between steps should be smooth and quick to maintain the viewer's attention.", "chosen": "```python\nfrom manim import *\n\n# Configure Manim for Portrait Mode (9:16 Aspect Ratio)\nconfig.pixel_width = 1080\nconfig.pixel_height = 1920\nconfig.frame_width = 9\nconfig.frame_height = 16\nconfig.background_color = \"#F0F4F8\" # Comforting soft blue-grey background\n\nclass DivisionAnimation(Scene):\n def construct(self):\n # --- Color Palette ---\n COLOR_TEXT = \"#2D3748\" # Dark Slate\n COLOR_HIGHLIGHT = \"#ED8936\" # Warm Orange for 'b'\n COLOR_SOLUTION = \"#48BB78\" # Soft Green for the solution\n COLOR_ICON = \"#667EEA\" # Soft Blue for visuals\n\n # --- Step 1: Introduction (Division Concept) ---\n # Create a visual representation of division: 45 circles split into 3 groups of 15\n circles = VGroup(*[Circle(radius=0.15, color=COLOR_ICON, fill_opacity=0.8) for _ in range(45)])\n circles.arrange_in_grid(rows=5, cols=9, buff=0.15)\n \n group1 = VGroup(*[circles[i] for i in range(0, 15)])\n group2 = VGroup(*[circles[i] for i in range(15, 30)])\n group3 = VGroup(*[circles[i] for i in range(30, 45)])\n \n # Animate circles appearing, then splitting into 3 distinct groups\n self.play(FadeIn(circles, lag_ratio=0.05), run_time=1.0)\n self.play(\n group1.animate.shift(LEFT * 3),\n group2.animate.shift(UP * 0.5),\n group3.animate.shift(RIGHT * 3),\n run_time=1.2\n )\n self.wait(0.5)\n \n # Fade out visual to make room for the equation\n self.play(FadeOut(circles), run_time=0.5)\n\n # --- Step 2: Equation Display ---\n # \"divided by 3 equals 15\"\n text_eq = Text(\"divided by 3 equals 15\", font_size=48, color=COLOR_TEXT)\n \n self.play(Write(text_eq), run_time=1.0)\n self.wait(0.5)\n\n # --- Step 3: Problem Solving (Introduce and highlight 'b') ---\n # Transform to MathTex for proper mathematical formatting: b / 3 = 15\n math_eq = MathTex(\"b\", \"\\\\div\", \"3\", \"=\", \"15\", font_size=72, color=COLOR_TEXT)\n \n self.play(ReplacementTransform(text_eq, math_eq), run_time=1.0)\n \n # Highlight the unknown variable 'b' in a distinct color\n b_var = math_eq[0]\n self.play(\n b_var.animate.set_color(COLOR_HIGHLIGHT).scale(1.2),\n run_time=0.8\n )\n self.wait(0.5)\n\n # Show the operation to solve for b (multiply both sides by 3)\n operation_text = MathTex(\"b\", \"=\", \"15\", \"\\\\times\", \"3\", font_size=60, color=COLOR_TEXT)\n operation_text.next_to(math_eq, DOWN, buff=1.0)\n operation_text[0].set_color(COLOR_HIGHLIGHT)\n \n self.play(Write(operation_text), run_time=1.0)\n self.wait(0.5)\n\n # --- Step 4: Conclusion (Side-by-Side) ---\n # Create the final solution equation\n solution_eq = MathTex(\"b\", \"=\", \"45\", font_size=72, color=COLOR_TEXT)\n solution_eq[0].set_color(COLOR_HIGHLIGHT)\n solution_eq[2].set_color(COLOR_SOLUTION)\n \n # Clear the operation step and arrange original equation & solution side-by-side\n self.play(FadeOut(operation_text), run_time=0.5)\n \n # Shift original equation to the left\n original_eq = math_eq.copy()\n \n solution_eq.next_to(original_eq, RIGHT, buff=2.0)\n final_layout = VGroup(original_eq, solution_eq)\n final_layout.move_to(ORIGIN)\n\n self.play(\n math_eq.animate.move_to(original_eq.get_center()),\n FadeIn(solution_eq, shift=RIGHT),\n run_time=1.2\n )\n \n # Final emphasis pulse on the solution '45'\n self.play(\n Indicate(solution_eq[2], color=COLOR_SOLUTION, scale_factor=1.3),\n run_time=0.8\n )\n \n self.wait(1.0)\n```", "rejected": "```python\nfrom manim import *\n\n# Configure Manim for Portrait Mode (9:16 Aspect Ratio)\nconfig.pixel_width = 1080\nconfig.pixel_height = 1920\nconfig.frame_width = 9\nconfig.frame_height = 16\nconfig.background_color = \"#F0F4F8\" # Comforting soft blue-grey background\n\nclass DivisionAnimation(Scene):\n def construct(self):\n # --- Color Palette ---\n COLOR_TEXT = \"#2D3748\" # Dark Slate\n COLOR_HIGHLIGHT = \"#ED8936\" # Warm Orange for 'b'\n COLOR_SOLUTION = \"#48BB78\" # Soft Green for the solution\n COLOR_ICON = \"#667EEA\" # Soft Blue for visuals\n\n # --- Step 1: Introduction (Division Concept) ---\n # Create a visual representation of division: 45 circles split into 3 groups of 15\n circles = VGroup(*[Circle(radius=0.15, color=COLOR_ICON, fill_opacity=0.8) for _ in range(45)])\n circles.arrange_in_grid(rows=5, cols=9, buff=0.15)\n \n group1 = VGroup(*[circles[i] for i in range(0, 15)])\n group2 = VGroup(*[circles[i] for i in range(15, 30)])\n group3 = VGroup(*[circles[i] for i in range(30, 45)])\n \n # Animate circles appearing, then splitting into 3 distinct groups\n self.play(FadeIn(circles, lag_ratio=0.05), run_time=1.0)\n self.play(\n group1.animate.shift(LEFT * 3),\n group2.animate.shift(UP * 0.5),\n group3.animate.shift(RIGHT * 3),\n run_time=1.2\n )\n self.wait(0.5)\n \n # Fade out visual to make room for the equation\n self.play(FadeOut(circles), run_time=0.5)\n\n # --- Step 2: Equation Display ---\n # \"divided by 3 equals 15\"\n text_eq = Text(\"divided by 3 equals 15\", font_size=48, color=COLOR_TEXT)\n \n self.play(Write(text_eq), run_time=1.0)\n self.wait(0.5)\n\n # --- Step 3: Problem Solving (Introduce and highlight 'b') ---\n # Transform to MathTex for proper mathematical formatting: b / 3 = 15\n math_eq = MathText(\"b\", \"\\\\div\", \"3\", \"=\", \"15\", font_size=72, color=COLOR_TEXT)\n \n self.play(ReplacementTransform(text_eq, math_eq), run_time=1.0)\n \n # Highlight the unknown variable 'b' in a distinct color\n b_var = math_eq[0]\n self.play(\n b_var.animate.set_color(COLOR_HIGHLIGHT).scale(1.2),\n run_time=0.8\n )\n self.wait(0.5)\n\n # Show the operation to solve for b (multiply both sides by 3)\n operation_text = MathTex(\"b\", \"=\", \"15\", \"\\\\times\", \"3\", font_size=60, color=COLOR_TEXT)\n operation_text.next_to(math_eq, DOWN, buff=1.0)\n operation_text[0].set_color(COLOR_HIGHLIGHT)\n \n self.play(Write(operation_text), run_time=1.0)\n self.wait(0.5)\n\n # --- Step 4: Conclusion (Side-by-Side) ---\n # Create the final solution equation\n solution_eq = MathTex(\"b\", \"=\", \"45\", font_size=72, color=COLOR_TEXT)\n solution_eq[0].set_color(COLOR_HIGHLIGHT)\n solution_eq[2].set_color(COLOR_SOLUTION)\n \n # Clear the operation step and arrange original equation & solution side-by-side\n self.play(FadeOut(operation_text), run_time=0.5)\n \n # Shift original equation to the left\n original_eq = math_eq.copy()\n \n solution_eq.next_to(original_eq, RIGHT, buff=2.0)\n final_layout = VGroup(original_eq, solution_eq)\n final_layout.move_to(ORIGIN)\n\n self.play(\n math_eq.animate.move_to(original_eq.get_center()),\n FadeIn(solution_eq, shift=RIGHT),\n run_time=1.2\n )\n \n # Final emphasis pulse on the solution '45'\n self.play(\n Indicate(solution_eq[2], color=COLOR_SOLUTION, scale_factor=1.3),\n run_time=0.8\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 number line with a downward-pointing arrow (vector) and a label \"x\" above it. The arrow dynamically follows a value tracked by a `ValueTracker`. Initially, the tracker is set to 0, then:\n- Act 2: You are a Manim expert. Please convert the Markdown lecture notes into executable Manim CE v0.19.0 code that displays content in English. The page layout must be clear, with no overlapping elements, and you must not outp\n- Act 3: Here’s an enhanced version of the animation with additional features: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0677(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_valuetrackerexample()\n self.clear_stage()\n self.act_2_waveparticleduality()\n self.clear_stage()\n self.act_3_enhancedshapetransformat()\n\n def act_1_valuetrackerexample(self):\n number_line = NumberLine()\n pointer = Vector(DOWN)\n label = MathTex(\"x\").add_updater(lambda m: m.next_to(pointer, UP))\n\n tracker = ValueTracker(0)\n pointer.add_updater(\n lambda m: m.next_to(\n number_line.n2p(tracker.get_value()),\n UP\n )\n )\n self.add(number_line, pointer,label)\n tracker += 1.5\n self.wait(1)\n tracker -= 4\n self.wait(0.5)\n self.play(tracker.animate.set_value(5))\n self.wait(0.5)\n self.play(tracker.animate.set_value(3))\n self.play(tracker.animate.increment_value(-2))\n self.wait(0.5)\n\n def act_2_waveparticleduality(self):\n title = Text('Birth of Atomic Physics and Origin of Quantum Concepts', font_size=36, color=BLUE)\n title.to_edge(UP, buff=0.6)\n summary_label = Text('Summary', font_size=32, color=LIGHT_GREY)\n duality_text = Text('Wave-Particle Duality', font_size=48, color=YELLOW)\n top_group = VGroup(summary_label, duality_text).arrange(DOWN, buff=0.3)\n arrow = Arrow(start=UP, end=DOWN, color=WHITE, buff=0.1, stroke_width=6)\n desc_line1 = Text('Source of differences in behavior between', font_size=36)\n desc_line2 = MarkupText(\"macroscopic and microscopic worlds\", font_size=36)\n bottom_group = VGroup(desc_line1, desc_line2).arrange(DOWN, buff=0.25)\n content_group = VGroup(top_group, arrow, bottom_group).arrange(DOWN, buff=0.8)\n content_group.next_to(title, DOWN, buff=0.8)\n content_group.move_to(DOWN * 0.2)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(summary_label, shift=UP * 0.3))\n self.play(Write(duality_text))\n self.wait(1)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(FadeIn(desc_line1, shift=UP * 0.3))\n self.play(Write(desc_line2))\n self.wait(1.5)\n emphasis_box = SurroundingRectangle(bottom_group, color=WHITE, buff=0.3, corner_radius=0.2)\n self.play(Create(emphasis_box))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(content_group), FadeOut(emphasis_box))\n self.wait(0.5)\n\n def act_3_enhancedshapetransformat(self):\n circle = Circle(color=YELLOW, fill_opacity=0.8).rotate(-45 * DEGREES)\n triangle = Triangle(color=GREEN, fill_opacity=0.8).rotate(-45 * DEGREES)\n \n # Position shapes\n circle.move_to(LEFT * 2)\n triangle.move_to(RIGHT * 2)\n \n # Group shapes\n shapes = VGroup(circle, triangle)\n \n # Add shapes to scene\n self.play(Create(circle), Create(triangle))\n self.wait(0.5)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.8).move_to(circle.get_center())\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.8).move_to(triangle.get_center())\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Add equation\n equation = MathTex(r\"\\text{Area} = \\pi r^2\").next_to(shapes, DOWN, buff=1)\n equation.scale(0.01) # Start small\n \n self.play(\n equation.animate.scale(1.2),\n FadeIn(equation),\n run_time=1\n )\n self.wait(0.5)\n \n # Rotate shapes and pulse equation\n self.play(\n Rotate(shapes, angle=2 * PI, about_point=ORIGIN),\n equation.animate.scale(1.1).set_color_by_gradient(BLUE, WHITE),\n run_time=2\n )\n self.play(equation.animate.scale(1 / 1.1))\n self.wait(0.5)\n \n # Add title and zoom out\n title = Text(\"Shapes and Their Areas\", font_size=24).to_edge(UP)\n grid = NumberPlane()\n \n self.play(\n FadeIn(title, shift=DOWN),\n Create(grid, run_time=2, lag_ratio=0.1),\n shapes.animate.scale(0.8),\n equation.animate.scale(0.8).shift(UP * 0.5),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0677(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_valuetrackerexample()\n self.clear_stage()\n self.act_2_waveparticleduality()\n self.clear_stage()\n self.act_3_enhancedshapetransformat()\n\n def act_1_valuetrackerexample(self):\n number_line = NumberLine()\n pointer = Vector(DOWN)\n label = MathText(\"x\").add_updater(lambda m: m.next_to(pointer, UP))\n\n tracker = ValueTracker(0)\n pointer.add_updater(\n lambda m: m.next_to(\n number_line.n2p(tracker.get_value()),\n UP\n )\n )\n self.add(number_line, pointer,label)\n tracker += 1.5\n self.wait(1)\n tracker -= 4\n self.wait(0.5)\n self.play(tracker.animate.set_value(5))\n self.wait(0.5)\n self.play(tracker.animate.set_value(3))\n self.play(tracker.animate.increment_value(-2))\n self.wait(0.5)\n\n def act_2_waveparticleduality(self):\n title = Text('Birth of Atomic Physics and Origin of Quantum Concepts', font_size=36, color=BLUE)\n title.to_edge(UP, buff=0.6)\n summary_label = Text('Summary', font_size=32, color=LIGHT_GREY)\n duality_text = Text('Wave-Particle Duality', font_size=48, color=YELLOW)\n top_group = VGroup(summary_label, duality_text).arrange(DOWN, buff=0.3)\n arrow = Arrow(start=UP, end=DOWN, color=WHITE, buff=0.1, stroke_width=6)\n desc_line1 = Text('Source of differences in behavior between', font_size=36)\n desc_line2 = MarkupText(\"macroscopic and microscopic worlds\", font_size=36)\n bottom_group = VGroup(desc_line1, desc_line2).arrange(DOWN, buff=0.25)\n content_group = VGroup(top_group, arrow, bottom_group).arrange(DOWN, buff=0.8)\n content_group.next_to(title, DOWN, buff=0.8)\n content_group.move_to(DOWN * 0.2)\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(summary_label, shift=UP * 0.3))\n self.play(Write(duality_text))\n self.wait(1)\n self.play(GrowArrow(arrow))\n self.wait(0.5)\n self.play(FadeIn(desc_line1, shift=UP * 0.3))\n self.play(Write(desc_line2))\n self.wait(1.5)\n emphasis_box = SurroundingRectangle(bottom_group, color=WHITE, buff=0.3, corner_radius=0.2)\n self.play(Create(emphasis_box))\n self.wait(2)\n self.play(FadeOut(title), FadeOut(content_group), FadeOut(emphasis_box))\n self.wait(0.5)\n\n def act_3_enhancedshapetransformat(self):\n circle = Circle(color=YELLOW, fill_opacity=0.8).rotate(-45 * DEGREES)\n triangle = Triangle(color=GREEN, fill_opacity=0.8).rotate(-45 * DEGREES)\n \n # Position shapes\n circle.move_to(LEFT * 2)\n triangle.move_to(RIGHT * 2)\n \n # Group shapes\n shapes = VGroup(circle, triangle)\n \n # Add shapes to scene\n self.play(Create(circle), Create(triangle))\n self.wait(0.5)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.8).move_to(circle.get_center())\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.8).move_to(triangle.get_center())\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Add equation\n equation = MathTex(r\"\\text{Area} = \\pi r^2\").next_to(shapes, DOWN, buff=1)\n equation.scale(0.01) # Start small\n \n self.play(\n equation.animate.scale(1.2),\n FadeIn(equation),\n run_time=1\n )\n self.wait(0.5)\n \n # Rotate shapes and pulse equation\n self.play(\n Rotate(shapes, angle=2 * PI, about_point=ORIGIN),\n equation.animate.scale(1.1).set_color_by_gradient(BLUE, WHITE),\n run_time=2\n )\n self.play(equation.animate.scale(1 / 1.1))\n self.wait(0.5)\n \n # Add title and zoom out\n title = Text(\"Shapes and Their Areas\", font_size=24).to_edge(UP)\n grid = NumberPlane()\n \n self.play(\n FadeIn(title, shift=DOWN),\n Create(grid, run_time=2, lag_ratio=0.1),\n shapes.animate.scale(0.8),\n equation.animate.scale(0.8).shift(UP * 0.5),\n run_time=2\n )\n self.wait(2)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText('\\\\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates how to find the area under the curve of y = x^2 from x = 0 to x = 2, including both the visual representation of the graph and the integration steps to arrive at the numerical answer?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup the Coordinate System\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the Function y = x^2\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BLUE)\n func_label = axes.get_graph_label(curve, \"y = x^2\", x_val=1.5, direction=UR)\n\n # 3. Highlight the Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add a vertical line at x=2 to clearly mark the boundary\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n line_label = MathTex(\"x=2\").next_to(line_x2, DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\")\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT, buff=1)\n\n # 5. Animation Sequence\n # Draw axes and curve\n self.play(Create(axes), Create(curve), Write(func_label))\n self.wait(1)\n\n # Highlight the area and boundary\n self.play(FadeIn(area), Create(line_x2), Write(line_label))\n self.wait(1)\n\n # Display integration steps sequentially\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup the Coordinate System\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 5, 1],\n x_length=5,\n y_length=4,\n axis_config={\"include_tip\": True},\n ).add_coordinates().to_edge(LEFT, buff=1)\n\n # 2. Plot the Function y = x^2\n curve = axes.plot(lambda x: x**2, x_range=[0, 2], color=BBLUE)\n func_label = axes.get_graph_label(curve, \"y = x^2\", x_val=1.5, direction=UR)\n\n # 3. Highlight the Area Under the Curve\n area = axes.get_area(curve, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add a vertical line at x=2 to clearly mark the boundary\n line_x2 = axes.get_vertical_line(axes.c2p(2, 4), color=YELLOW)\n line_label = MathTex(\"x=2\").next_to(line_x2, DOWN)\n\n # 4. Prepare Integration Steps\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\n step2 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\")\n step3 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\")\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\")\n\n steps = VGroup(step1, step2, step3, step4).arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n steps.to_edge(RIGHT, buff=1)\n\n # 5. Animation Sequence\n # Draw axes and curve\n self.play(Create(axes), Create(curve), Write(func_label))\n self.wait(1)\n\n # Highlight the area and boundary\n self.play(FadeIn(area), Create(line_x2), Write(line_label))\n self.wait(1)\n\n # Display integration steps sequentially\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n\n # Highlight the final result\n box = SurroundingRectangle(step4, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(2)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the concept of the area under a curve as represented in calculus. It should show a simple parabolic function on a graph, and I want to visualize the area between the curve and the x-axis, from a starting point 'a' to an ending point 'b'. Along with the graphical representation, I want to include the integral symbol with the limits 'a' and 'b' as seen in integral calculus. The animation should start by displaying the integral formula at the top of the frame, followed by drawing a blue shaded rectangle that represents the area under the curve, even though the curve itself is not exactly matching the rectangle's shape. Once the area is shaded, I would like the actual curve to be drawn on top. Next to the shaded area, there should be a text annotation that says \"Shaded Area represents A\". I would like this text to be updated later in the animation to \"Area under the curve from a to b\". At the bottom of the rectangle representing the area, I need a couple of braces that label the starting point 'a' and the ending point 'b'. After some time, the animation should clear everything from the screen and conclude with the text \"Visualization Complete!\" appearing in the center. This should be designed for someone with no prior knowledge of ManimCE or animation coding.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n This scene illustrates the concept of the area under a curve in calculus.\n It follows a specific sequence: showing an integral formula, \n approximating the area with a rectangle, drawing the actual curve, \n labeling the area, and marking the limits of integration.\n \"\"\"\n\n def construct(self):\n # ==========================================\n # 1. SETUP: Axes and Function Definition\n # ==========================================\n # Create a coordinate system (Axes) for our graph.\n # x_range and y_range define the visible limits of the graph.\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True}\n ).scale(0.9).shift(DOWN * 0.3)\n \n # Add labels to the axes for clarity\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Display the axes and labels first\n self.play(Create(axes), Write(axis_labels))\n\n # Define the limits of integration (a and b)\n a = 1\n b = 3\n \n # Define the parabolic function: f(x) = 0.5 * x^2\n func = lambda x: 0.5 * x**2\n\n # ==========================================\n # 2. STEP 1: Display Integral Formula\n # ==========================================\n # Create the mathematical text for the integral symbol with limits a and b.\n # MathTex is used for high-quality LaTeX mathematical rendering.\n integral_formula = MathTex(r\"\\int_{a}^{b} f(x) \\, dx\", font_size=40)\n integral_formula.to_edge(UP)\n \n self.play(Write(integral_formula))\n self.wait(1)\n\n # ==========================================\n # 3. STEP 2: Draw Shaded Rectangle\n # ==========================================\n # Calculate coordinates for the rectangle based on axes logic.\n # We use axes.c2p (coordinates to point) to map graph values to screen positions.\n # Bottom-Left corner at (a, 0)\n bl = axes.c2p(a, 0)\n # Top-Right corner at (b, f(b)) - using f(b) ensures the curve fits within it\n tr = axes.c2p(b, func(b))\n \n # Create a rectangle using the calculated corners.\n # We use Polygon to define exact corners for precision.\n shaded_rect = Polygon(\n bl,\n axes.c2p(b, 0),\n tr,\n axes.c2p(a, func(b)),\n color=BLUE,\n fill_opacity=0.5,\n stroke_color=BLUE_B\n )\n \n # Animate the rectangle appearing (drawing the shape and filling it).\n self.play(Create(shaded_rect), FadeIn(shaded_rect))\n self.wait(0.5)\n\n # ==========================================\n # 4. STEP 3: Draw the Parabolic Curve\n # ==========================================\n # Now draw the actual parabolic curve on top of the rectangle.\n # This shows the difference between the rectangular approximation and the true area.\n curve = axes.plot(func, x_range=[0, 3.5], color=YELLOW)\n \n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # ==========================================\n # 5. STEP 4 & 5: Label Area Text\n # ==========================================\n # Initial text explaining the shaded region.\n text_initial = Text(\"Shaded Area represents A\", font_size=24)\n text_initial.next_to(shaded_rect, RIGHT, buff=0.5)\n \n # Updated text with more specific calculus terminology.\n text_updated = Text(\"Area under the curve from a to b\", font_size=24)\n text_updated.move_to(text_initial) # Ensure it appears in the same spot\n\n # Display the initial text.\n self.play(Write(text_initial))\n self.wait(1)\n \n # Transform the text smoothly into the updated version.\n self.play(Transform(text_initial, text_updated))\n self.wait(1)\n\n # ==========================================\n # 6. STEP 6: Label Limits with Braces\n # ==========================================\n # Create a line on the x-axis between a and b to attach the brace to.\n point_a = axes.c2p(a, 0)\n point_b = axes.c2p(b, 0)\n limit_line = Line(point_a, point_b)\n \n # Create a brace below that line.\n brace = Brace(limit_line, direction=DOWN, color=WHITE)\n \n # Create labels for 'a' and 'b'.\n label_a = MathTex(\"a\").next_to(point_a, DOWN, buff=0.5)\n label_b = MathTex(\"b\").next_to(point_b, DOWN, buff=0.5)\n \n # Animate the appearance of the brace and labels.\n self.play(Create(brace), Write(label_a), Write(label_b))\n self.wait(2)\n\n # ==========================================\n # 7. STEP 7: Clear Screen\n # ==========================================\n # Remove all objects from the scene to prepare for the final message.\n # We group all objects to fade them out simultaneously.\n all_elements = VGroup(\n axes, axis_labels, curve, shaded_rect,\n integral_formula, text_initial, \n brace, label_a, label_b\n )\n \n self.play(FadeOut(all_elements))\n self.wait(0.5)\n\n # ==========================================\n # 8. STEP 8: Final Screen\n # ==========================================\n # Display the completion message in the center.\n final_text = Text(\"Visualization Complete!\", font_size=48, color=GREEN)\n \n self.play(Write(final_text))\n self.wait(2)\n\n# ==========================================\n# How to Run This Code\n# ==========================================\n# 1. Install ManimCE: Ensure you have Python installed, then run:\n# pip install manim\n# (Note: You may also need to install LaTeX dependencies for MathTex to render correctly.)\n#\n# 2. Save the File: Save this code into a file named `integral_animation.py`.\n#\n# 3. Render the Animation: Run the following command in your terminal:\n# manim -pql integral_animation.py AreaUnderCurve\n# -p : Opens the video player automatically after rendering.\n# -ql: Renders in low quality (quick for testing). Use -qh for high quality.\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n This scene illustrates the concept of the area under a curve in calculus.\n It follows a specific sequence: showing an integral formula, \n approximating the area with a rectangle, drawing the actual curve, \n labeling the area, and marking the limits of integration.\n \"\"\"\n\n def construct(self):\n # ==========================================\n # 1. SETUP: Axes and Function Definition\n # ==========================================\n # Create a coordinate system (Axes) for our graph.\n # x_range and y_range define the visible limits of the graph.\n axes = Axes(label_font_size=24, \n x_range=[0, 4, 1],\n y_range=[0, 5, 1],\n axis_config={\"include_tip\": True}\n ).scale(0.9).shift(DOWN * 0.3)\n \n # Add labels to the axes for clarity\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n # Display the axes and labels first\n self.play(Create(axes), Write(axis_labels))\n\n # Define the limits of integration (a and b)\n a = 1\n b = 3\n \n # Define the parabolic function: f(x) = 0.5 * x^2\n func = lambda x: 0.5 * x**2\n\n # ==========================================\n # 2. STEP 1: Display Integral Formula\n # ==========================================\n # Create the mathematical text for the integral symbol with limits a and b.\n # MathTex is used for high-quality LaTeX mathematical rendering.\n integral_formula = MathTex(r\"\\int_{a}^{b} f(x) \\, dx\", font_size=40)\n integral_formula.to_edge(UP)\n \n self.play(Write(integral_formula))\n self.wait(1)\n\n # ==========================================\n # 3. STEP 2: Draw Shaded Rectangle\n # ==========================================\n # Calculate coordinates for the rectangle based on axes logic.\n # We use axes.c2p (coordinates to point) to map graph values to screen positions.\n # Bottom-Left corner at (a, 0)\n bl = axes.c2p(a, 0)\n # Top-Right corner at (b, f(b)) - using f(b) ensures the curve fits within it\n tr = axes.c2p(b, func(b))\n \n # Create a rectangle using the calculated corners.\n # We use Polygon to define exact corners for precision.\n shaded_rect = Polygon(\n bl,\n axes.c2p(b, 0),\n tr,\n axes.c2p(a, func(b)),\n color=BLUE,\n fill_opacity=0.5,\n stroke_color=BLUE_B\n )\n \n # Animate the rectangle appearing (drawing the shape and filling it).\n self.play(Create(shaded_rect), FadeIn(shaded_rect))\n self.wait(0.5)\n\n # ==========================================\n # 4. STEP 3: Draw the Parabolic Curve\n # ==========================================\n # Now draw the actual parabolic curve on top of the rectangle.\n # This shows the difference between the rectangular approximation and the true area.\n curve = axes.plot(func, x_range=[0, 3.5], color=YELLOW)\n \n self.play(Create(curve), run_time=2)\n self.wait(1)\n\n # ==========================================\n # 5. STEP 4 & 5: Label Area Text\n # ==========================================\n # Initial text explaining the shaded region.\n text_initial = Text(\"Shaded Area represents A\", font_size=24)\n text_initial.next_to(shaded_rect, RIGHT, buff=0.5)\n \n # Updated text with more specific calculus terminology.\n text_updated = Text(\"Area under the curve from a to b\", font_size=24)\n text_updated.move_to(text_initial) # Ensure it appears in the same spot\n\n # Display the initial text.\n self.play(Write(text_initial))\n self.wait(1)\n \n # Transform the text smoothly into the updated version.\n self.play(Transform(text_initial, text_updated))\n self.wait(1)\n\n # ==========================================\n # 6. STEP 6: Label Limits with Braces\n # ==========================================\n # Create a line on the x-axis between a and b to attach the brace to.\n point_a = axes.c2p(a, 0)\n point_b = axes.c2p(b, 0)\n limit_line = Line(point_a, point_b)\n \n # Create a brace below that line.\n brace = Brace(limit_line, direction=DOWN, color=WHITE)\n \n # Create labels for 'a' and 'b'.\n label_a = MathTex(\"a\").next_to(point_a, DOWN, buff=0.5)\n label_b = MathTex(\"b\").next_to(point_b, DOWN, buff=0.5)\n \n # Animate the appearance of the brace and labels.\n self.play(Create(brace), Write(label_a), Write(label_b))\n self.wait(2)\n\n # ==========================================\n # 7. STEP 7: Clear Screen\n # ==========================================\n # Remove all objects from the scene to prepare for the final message.\n # We group all objects to fade them out simultaneously.\n all_elements = VGroup(\n axes, axis_labels, curve, shaded_rect,\n integral_formula, text_initial, \n brace, label_a, label_b\n )\n \n self.play(FadeOut(all_elements))\n self.wait(0.5)\n\n # ==========================================\n # 8. STEP 8: Final Screen\n # ==========================================\n # Display the completion message in the center.\n final_text = Text(\"Visualization Complete!\", font_size=48, color=GREEN)\n \n self.play(Write(final_text))\n self.wait(2)\n\n# ==========================================\n# How to Run This Code\n# ==========================================\n# 1. Install ManimCE: Ensure you have Python installed, then run:\n# pip install manim\n# (Note: You may also need to install LaTeX dependencies for MathTex to render correctly.)\n#\n# 2. Save the File: Save this code into a file named `integral_animation.py`.\n#\n# 3. Render the Animation: Run the following command in your terminal:\n# manim -pql integral_animation.py AreaUnderCurve\n# -p : Opens the video player automatically after rendering.\n# -ql: Renders in low quality (quick for testing). Use -qh for high quality.\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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\": BBLUE_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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:\n\nThe animation begins by creating a simple blue rectangle (2 units wide, 4 units tall) positioned at (2, -1) on the screen, then expands this basic concept into a comprehensive geometric demonstration. As the rectangle first appears, its edges smoothly animate into view one by one (top, right, bottom, left) with a gentle glow effect. Simultaneously, a coordinate system fades in beneath it, with axes labeled to show its position at (2, -1). The rectangle then transforms into a golden ratio rectangle (approximately 1.618 times taller than wide) while the mathematical formula φ = (1+√5)/2 appears above it, with each term animating sequentially. As this transformation completes, the rectangle divides itself into a square and smaller rectangle to visually demonstrate the golden ratio property, with measurements appearing as animated text. Finally, the original rectangle morphs back into view while the golden ratio elements fade out, completing the cycle and reinforcing the relationship between basic shapes and advanced geometric concepts. Throughout the animation, smooth color transitions and movement guides the viewer's attention between different elements.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass GoldenRatioRectangle(Scene):\n def construct(self):\n # Create initial rectangle\n rect = Rectangle(width=2, height=4, color=BLUE).move_to([2, -1, 0])\n rect.set_fill(BLUE, opacity=0.3)\n \n # Animate edges appearing\n edges = VGroup(\n Line(rect.get_corner(UL), rect.get_corner(UR), color=BLUE_E),\n Line(rect.get_corner(UR), rect.get_corner(DR), color=BLUE_E),\n Line(rect.get_corner(DR), rect.get_corner(DL), color=BLUE_E),\n Line(rect.get_corner(DL), rect.get_corner(UL), color=BLUE_E)\n )\n \n # Create coordinate system\n axes = Axes(\n x_range=[-5, 5, 1],\n y_range=[-3, 3, 1],\n x_length=10,\n y_length=6,\n axis_config={\"color\": WHITE}\n ).add_coordinates()\n \n # Golden ratio formula\n phi_formula = MathTex(r\"\\phi = \\frac{1 + \\sqrt{5}}{2}\", color=GOLD).to_edge(UP)\n \n # Golden rectangle dimensions\n phi = (1 + np.sqrt(5)) / 2\n golden_rect = Rectangle(width=2, height=2*phi, color=GOLD).move_to([2, -1, 0])\n golden_rect.set_fill(GOLD, opacity=0.3)\n \n # Division lines and labels\n square = Rectangle(width=2, height=2, color=BLUE).move_to(\n [2, -1 + (phi - 1), 0]\n )\n small_rect = Rectangle(width=2*(phi-1), height=2, color=GOLD_E).next_to(\n square, RIGHT, buff=0\n )\n division_lines = VGroup(\n DashedLine(square.get_corner(UR), square.get_corner(DR), color=WHITE),\n DashedLine(small_rect.get_corner(UR), small_rect.get_corner(DR), color=WHITE)\n )\n dimensions = VGroup(\n MathTex(\"2\", color=BLUE).next_to(square, LEFT),\n MathTex(\"2\", color=BLUE).next_to(square, UP),\n MathTex(r\"2\\phi - 2\", color=GOLD).next_to(small_rect, UP),\n MathTex(\"2\", color=GOLD).next_to(small_rect, RIGHT)\n )\n \n # Animation sequence\n self.play(Create(edges[0]))\n self.play(Create(edges[1]))\n self.play(Create(edges[2]))\n self.play(Create(edges[3]))\n self.play(FadeIn(rect), FadeOut(edges))\n self.play(FadeIn(axes))\n \n # Transform to golden rectangle\n self.play(Transform(rect, golden_rect))\n self.play(Write(phi_formula))\n \n # Divide into square and rectangle\n self.play(\n rect.animate.set_fill(opacity=0),\n Create(division_lines),\n FadeIn(square),\n FadeIn(small_rect)\n )\n self.play(LaggedStart(*[Write(d) for d in dimensions], lag_ratio=0.2))\n \n # Return to original\n self.play(\n FadeOut(division_lines),\n FadeOut(square),\n FadeOut(small_rect),\n FadeOut(dimensions),\n FadeOut(phi_formula),\n rect.animate.become(\n Rectangle(width=2, height=4, color=BLUE)\n .move_to([2, -1, 0])\n .set_fill(BLUE, opacity=0.3)\n )\n )\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass GoldenRatioRectangle(Scene):\n def construct(self):\n # Create initial rectangle\n rect = Rectangle(width=2, height=4, color=BLUE).move_to([2, -1, 0])\n rect.set_fill(BLUE, opacity=0.3)\n \n # Animate edges appearing\n edges = VGroup(\n Line(rect.get_corner(UL), rect.get_corner(UR), color=BLUE_E),\n Line(rect.get_corner(UR), rect.get_corner(DR), color=BLUE_E),\n Line(rect.get_corner(DR), rect.get_corner(DL), color=BLUE_E),\n Line(rect.get_corner(DL), rect.get_corner(UL), color=BLUE_E)\n )\n \n # Create coordinate system\n axes = Axes(label_font_size=24, \n x_range=[-5, 5, 1],\n y_range=[-3, 3, 1],\n x_length=10,\n y_length=6,\n axis_config={\"color\": WHITE}\n ).add_coordinates()\n \n # Golden ratio formula\n phi_formula = MathTex(r\"\\phi = \\frac{1 + \\sqrt{5}}{2}\", color=GOLD).to_edge(UP)\n \n # Golden rectangle dimensions\n phi = (1 + np.sqrt(5)) / 2\n golden_rect = Rectangle(width=2, height=2*phi, color=GOLD).move_to([2, -1, 0])\n golden_rect.set_fill(GOLD, opacity=0.3)\n \n # Division lines and labels\n square = Rectangle(width=2, height=2, color=BLUE).move_to(\n [2, -1 + (phi - 1), 0]\n )\n small_rect = Rectangle(width=2*(phi-1), height=2, color=GOLD_E).next_to(\n square, RIGHT, buff=0\n )\n division_lines = VGroup(\n DashedLine(square.get_corner(UR), square.get_corner(DR), color=WHITE),\n DashedLine(small_rect.get_corner(UR), small_rect.get_corner(DR), color=WHITE)\n )\n dimensions = VGroup(\n MathTex(\"2\", color=BLUE).next_to(square, LEFT),\n MathTex(\"2\", color=BLUE).next_to(square, UP),\n MathTex(r\"2\\phi - 2\", color=GOLD).next_to(small_rect, UP),\n MathTex(\"2\", color=GOLD).next_to(small_rect, RIGHT)\n )\n \n # Animation sequence\n self.play(Create(edges[0]))\n self.play(Create(edges[1]))\n self.play(Create(edges[2]))\n self.play(Create(edges[3]))\n self.play(FadeIn(rect), FadeOut(edges))\n self.play(FadeIn(axes))\n \n # Transform to golden rectangle\n self.play(Transform(rect, golden_rect))\n self.play(Write(phi_formula))\n \n # Divide into square and rectangle\n self.play(\n rect.animate.set_fill(opacity=0),\n Create(division_lines),\n FadeIn(square),\n FadeIn(small_rect)\n )\n self.play(LaggedStart(*[Write(d) for d in dimensions], lag_ratio=0.2))\n \n # Return to original\n self.play(\n FadeOut(division_lines),\n FadeOut(square),\n FadeOut(small_rect),\n FadeOut(dimensions),\n FadeOut(phi_formula),\n rect.animate.become(\n Rectangle(width=2, height=4, color=BLUE)\n .move_to([2, -1, 0])\n .set_fill(BLUE, opacity=0.3)\n )\n )\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 concept of finding the area under a curve for a quadratic function. Specifically, show the area under the curve y = x^2 from x=0 to x=2. Begin with displaying the coordinate axes and the curve, then highlight the area underneath the curve that we are interested in. Next, introduce the integral notation for this problem and animate it changing into the calculated value of the definite integral. Finish by showing the final numeric result of the area calculation in the center of the screen. Make the axes and the initial curve disappear at the end, leaving only the result displayed. Use different colors to clearly differentiate elements such as the axes, the curve, and the shaded area.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- Style Configuration ---\n config.background_color = \"#1e1e1e\"\n color_axes = \"#708090\"\n color_curve = \"#00ffff\"\n color_area = \"#ffbf00\"\n color_text = WHITE\n color_result = \"#32cd32\"\n\n # --- 1. Initial Setup ---\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": color_axes, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).scale(0.8)\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=color_curve, stroke_width=4)\n equation = MathTex(\"y = x^2\", color=color_text).to_corner(UR)\n\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2)\n self.play(Create(curve), Write(equation), run_time=2)\n self.wait(0.5)\n\n # --- 2. Highlight Area ---\n area = axes.get_area(curve, x_range=(0, 2), color=color_area, opacity=0.4)\n bound_line_0 = axes.get_vertical_line(axes.input_to_graph_point(0, curve), color=WHITE)\n bound_line_2 = axes.get_vertical_line(axes.input_to_graph_point(2, curve), color=WHITE)\n \n area_label = Text(\"Area?\", color=color_text).move_to(axes.coords_to_point(1, 1))\n \n self.play(FadeIn(area), Create(bound_line_0), Create(bound_line_2), run_time=1.5)\n self.play(Write(area_label), run_time=0.5)\n self.wait(0.5)\n\n # --- 3. Integral Notation ---\n self.play(FadeOut(area_label), run_time=0.5)\n \n integral_expr = MathTex(\n r\"\\int_{0}^{2}\", \"x^2\", r\"\\, dx\", \n color=color_text, \n font_size=48\n ).to_edge(RIGHT).shift(UP * 2)\n \n self.play(Write(integral_expr), run_time=1.5)\n # Highlight limits connection\n self.play(\n integral_expr[0][1].animate.set_color(color_area), # 0\n integral_expr[0][2].animate.set_color(color_area), # 2\n run_time=1\n )\n self.wait(0.5)\n\n # --- 4. Calculation Animation ---\n # Move integral to top center for calculation space\n self.play(integral_expr.animate.to_edge(UP).scale(0.8), run_time=1)\n\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", color=color_text, font_size=48)\n step2 = MathTex(r\"\\frac{2^3}{3} - \\frac{0^3}{3}\", color=color_text, font_size=48)\n step3 = MathTex(r\"\\frac{8}{3} - 0\", color=color_text, font_size=48)\n \n step1.next_to(integral_expr, DOWN, buff=0.5)\n step2.next_to(step1, DOWN, buff=0.5)\n step3.next_to(step2, DOWN, buff=0.5)\n\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step3), run_time=1.5)\n self.wait(1)\n\n # --- 5. Final Result ---\n final_result = MathTex(r\"\\frac{8}{3}\", r\"\\approx 2.67\", color=color_result, font_size=72)\n final_result.move_to(ORIGIN)\n \n calculation_group = VGroup(integral_expr, step1, step2, step3)\n \n # --- 6. Cleanup ---\n self.play(\n FadeOut(calculation_group),\n FadeOut(area),\n FadeOut(bound_line_0),\n FadeOut(bound_line_2),\n FadeOut(curve),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(equation),\n Write(final_result),\n run_time=2\n )\n \n # Pulse effect for result\n self.play(\n final_result.animate.scale(1.1),\n rate_func=there_and_back,\n run_time=0.5\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- Style Configuration ---\n config.background_color = \"#1e1e1e\"\n color_axes = \"#708090\"\n color_curve = \"#00ffff\"\n color_area = \"#ffbf00\"\n color_text = WHITE\n color_result = \"#32cd32\"\n\n # --- 1. Initial Setup ---\n axes = Axes(label_font_size=24, \n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"color\": color_axes, \"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).scale(0.8)\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=color_curve, stroke_width=4)\n equation = MathTex(\"y = x^2\", color=color_text).to_corner(UR)\n\n self.play(Create(axes), Write(x_label), Write(y_label), run_time=2)\n self.play(Create(curve), Write(equation), run_time=2)\n self.wait(0.5)\n\n # --- 2. Highlight Area ---\n area = axes.get_area(curve, x_range=(0, 2), color=color_area, opacity=0.4)\n bound_line_0 = axes.get_vertical_line(axes.input_to_graph_point(0, curve), color=WHITE)\n bound_line_2 = axes.get_vertical_line(axes.input_to_graph_point(2, curve), color=WHITE)\n \n area_label = Text(\"Area?\", color=color_text).move_to(axes.coords_to_point(1, 1))\n \n self.play(FadeIn(area), Create(bound_line_0), Create(bound_line_2), run_time=1.5)\n self.play(Write(area_label), run_time=0.5)\n self.wait(0.5)\n\n # --- 3. Integral Notation ---\n self.play(FadeOut(area_label), run_time=0.5)\n \n integral_expr = MathTex(\n r\"\\int_{0}^{2}\", \"x^2\", r\"\\, dx\", \n color=color_text, \n font_size=48\n ).to_edge(RIGHT).shift(UP * 2)\n \n self.play(Write(integral_expr), run_time=1.5)\n # Highlight limits connection\n self.play(\n integral_expr[0][1].animate.set_color(color_area), # 0\n integral_expr[0][2].animate.set_color(color_area), # 2\n run_time=1\n )\n self.wait(0.5)\n\n # --- 4. Calculation Animation ---\n # Move integral to top center for calculation space\n self.play(integral_expr.animate.to_edge(UP).scale(0.8), run_time=1)\n\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", color=color_text, font_size=48)\n step2 = MathTex(r\"\\frac{2^3}{3} - \\frac{0^3}{3}\", color=color_text, font_size=48)\n step3 = MathTex(r\"\\frac{8}{3} - 0\", color=color_text, font_size=48)\n \n step1.next_to(integral_expr, DOWN, buff=0.5)\n step2.next_to(step1, DOWN, buff=0.5)\n step3.next_to(step2, DOWN, buff=0.5)\n\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step3), run_time=1.5)\n self.wait(1)\n\n # --- 5. Final Result ---\n final_result = MathTex(r\"\\frac{8}{3}\", r\"\\approx 2.67\", color=color_result, font_size=72)\n final_result.move_to(ORIGIN)\n \n calculation_group = VGroup(integral_expr, step1, step2, step3)\n \n # --- 6. Cleanup ---\n self.play(\n FadeOut(calculation_group),\n FadeOut(area),\n FadeOut(bound_line_0),\n FadeOut(bound_line_2),\n FadeOut(curve),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label),\n FadeOut(equation),\n Write(final_result),\n run_time=2\n )\n \n # Pulse effect for result\n self.play(\n final_result.animate.scale(1.1),\n rate_func=there_and_back,\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 explaining how to integrate the sine function from 0 to π/2, show the mathematical steps, and conclude with the final result?\n- Act 2: 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 ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0669(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_atomanimation()\n self.clear_stage()\n self.act_2_oxygenmoleculescene()\n\n def act_1_atomanimation(self):\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n\n def act_2_oxygenmoleculescene(self):\n atom_radius = 0.5\n atom_color = RED\n bond_color = WHITE\n\n # Create two distinct red circles representing oxygen atoms\n atom1 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n atom2 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n \n # Position atoms apart initially\n atom1.move_to(LEFT * 3)\n atom2.move_to(RIGHT * 3)\n \n # Animation Sequence: Fade In\n self.play(FadeIn(atom1), FadeIn(atom2))\n \n # Move atoms closer to form the molecule structure\n self.play(\n atom1.animate.move_to(LEFT * 0.6),\n atom2.animate.move_to(RIGHT * 0.6)\n )\n \n # Create a double bond connecting the atoms\n # Lines span the gap between the atom edges, offset vertically for a double bond\n bond_top = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_bottom = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_top.shift(UP * 0.15)\n bond_bottom.shift(DOWN * 0.15)\n bond = VGroup(bond_top, bond_bottom)\n \n # Animate the bond formation\n self.play(Create(bond))\n \n # Group all elements to ensure synchronized transformation\n # Placing bond first ensures atoms render on top of the bond\n molecule = VGroup(bond, atom1, atom2)\n \n # Animation Sequence: Rotation around the central point\n self.play(Rotate(molecule, angle=TAU, about_point=ORIGIN, run_time=2))\n \n # Animation Sequence: Scale up to exactly 2x size\n self.play(molecule.animate.scale(2, scale_stroke=True))\n \n # Animation Sequence: Fade Out\n self.play(FadeOut(molecule))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0669(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_atomanimation()\n self.clear_stage()\n self.act_2_oxygenmoleculescene()\n\n def act_1_atomanimation(self):\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BBLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n\n def act_2_oxygenmoleculescene(self):\n atom_radius = 0.5\n atom_color = RED\n bond_color = WHITE\n\n # Create two distinct red circles representing oxygen atoms\n atom1 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n atom2 = Circle(radius=atom_radius, color=atom_color, fill_opacity=1.0)\n \n # Position atoms apart initially\n atom1.move_to(LEFT * 3)\n atom2.move_to(RIGHT * 3)\n \n # Animation Sequence: Fade In\n self.play(FadeIn(atom1), FadeIn(atom2))\n \n # Move atoms closer to form the molecule structure\n self.play(\n atom1.animate.move_to(LEFT * 0.6),\n atom2.animate.move_to(RIGHT * 0.6)\n )\n \n # Create a double bond connecting the atoms\n # Lines span the gap between the atom edges, offset vertically for a double bond\n bond_top = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_bottom = Line(LEFT * 0.1, RIGHT * 0.1, color=bond_color, stroke_width=5)\n bond_top.shift(UP * 0.15)\n bond_bottom.shift(DOWN * 0.15)\n bond = VGroup(bond_top, bond_bottom)\n \n # Animate the bond formation\n self.play(Create(bond))\n \n # Group all elements to ensure synchronized transformation\n # Placing bond first ensures atoms render on top of the bond\n molecule = VGroup(bond, atom1, atom2)\n \n # Animation Sequence: Rotation around the central point\n self.play(Rotate(molecule, angle=TAU, about_point=ORIGIN, run_time=2))\n \n # Animation Sequence: Scale up to exactly 2x size\n self.play(molecule.animate.scale(2, scale_stroke=True))\n \n # Animation Sequence: Fade Out\n self.play(FadeOut(molecule))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Practical Advice: Avoid Intermediate Fragmentation (Performance and Complexity)\nFragment reassembly consumes receiver resources and increases packet loss risk. Modern protocol stacks typically use Path MTU Discovery (PMTUD) to adjust packet sizes at the source.\n\n## Summary & Homework (5 minutes)\n\n### **Review of This Section**: IPv4 Structure, CIDR/Subnets, DHCP, NAT, MTU\nWe covered the core logic from IP packet structure to address allocation (DHCP), subnet planning (CIDR), and address translation (NAT).\n\n\nContextual location of this part (from highest to current level):\n# Computer Networks Course - Lesson 7 Outline (Network Layer Basics: IPv4, Subnetting, DHCP, and NAT, 90 minutes)\n## IPv4 Fragmentation and MTU (5 minutes)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass NetworkLayerSummary(Scene):\n\n def construct(self):\n title1 = Text('Practical Advice: Avoid Fragmentation', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(title1))\n bullets = VGroup(Text('• Fragment reassembly consumes receiver resources', font_size=28), Text('• Increases overall packet loss risk', font_size=28), Text('• Solution: Path MTU Discovery (PMTUD)', font_size=28, color=YELLOW)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(title1, DOWN, buff=0.5)\n for bullet in bullets:\n self.play(FadeIn(bullet, shift=RIGHT), run_time=0.8)\n else:\n pass\n self.wait(0.5)\n\n def create_node(label, color=WHITE):\n rect = RoundedRectangle(corner_radius=0.2, width=1.5, height=1.0, color=color)\n text = Text(label, font_size=24).move_to(rect.get_center())\n return VGroup(rect, text)\n node_src = create_node('Source', BLUE).shift(LEFT * 4 + DOWN * 1.5)\n node_router = create_node('Router', GREEN).shift(DOWN * 1.5)\n node_dst = create_node('Dest', BLUE).shift(RIGHT * 4 + DOWN * 1.5)\n line1 = Line(node_src.get_right(), node_router.get_left())\n line2 = Line(node_router.get_right(), node_dst.get_left())\n mtu1 = Text('MTU: 1500', font_size=20).next_to(line1, UP, buff=0.1)\n mtu2 = Text('MTU: 1200', font_size=20).next_to(line2, UP, buff=0.1)\n diagram = VGroup(node_src, node_router, node_dst, line1, line2, mtu1, mtu2)\n self.play(FadeIn(diagram))\n self.wait(0.5)\n packet1 = Rectangle(width=0.8, height=0.4, color=ORANGE, fill_opacity=1)\n pkt_text1 = Text('1500', font_size=16, color=BLACK).move_to(packet1)\n pkt_group1 = VGroup(packet1, pkt_text1).next_to(node_src, UP, buff=0.2)\n self.play(FadeIn(pkt_group1))\n self.play(pkt_group1.animate.next_to(node_router, UP, buff=0.2), run_time=1.5)\n cross = Cross(pkt_group1, stroke_color=RED, stroke_width=4)\n self.play(Create(cross))\n self.wait(0.5)\n icmp = Text('ICMP: MTU=1200', font_size=18, color=RED).next_to(node_router, DOWN, buff=0.2)\n self.play(Write(icmp))\n self.play(icmp.animate.next_to(node_src, DOWN, buff=0.2), run_time=1.5)\n self.play(FadeOut(pkt_group1), FadeOut(cross), FadeOut(icmp))\n packet2 = Rectangle(width=0.5, height=0.4, color=ORANGE, fill_opacity=1)\n pkt_text2 = Text('1200', font_size=16, color=BLACK).move_to(packet2)\n pkt_group2 = VGroup(packet2, pkt_text2).next_to(node_src, UP, buff=0.2)\n self.play(FadeIn(pkt_group2))\n self.play(pkt_group2.animate.next_to(node_router, UP, buff=0.2), run_time=1)\n self.play(pkt_group2.animate.next_to(node_dst, UP, buff=0.2), run_time=1)\n self.play(FadeOut(pkt_group2))\n self.wait(1.5)\n self.play(FadeOut(title1), FadeOut(bullets), FadeOut(diagram))\n title2 = Text('Summary & Homework', font_size=40, color=BLUE).to_edge(UP)\n subtitle = Text('Review of This Section', font_size=32, color=YELLOW).next_to(title2, DOWN, buff=0.3)\n self.play(Write(title2), FadeIn(subtitle))\n topics_col1 = VGroup(Text('1. IPv4 Structure', font_size=28), Text('2. CIDR & Subnets', font_size=28), Text('3. DHCP', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n topics_col2 = VGroup(Text('4. NAT', font_size=28), Text('5. MTU & Fragmentation', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n topics = VGroup(topics_col1, topics_col2).arrange(RIGHT, aligned_edge=UP, buff=1.5).next_to(subtitle, DOWN, buff=0.8)\n self.play(FadeIn(topics, shift=UP))\n self.wait(1)\n flow_title = Text('Core Logic Flow:', font_size=28, color=GREEN)\n flow_steps = VGroup(Text('IP Structure', font_size=22), Text('DHCP Allocation', font_size=22), Text('CIDR Subnetting', font_size=22), Text('NAT Translation', font_size=22)).arrange(RIGHT, buff=0.8)\n arrows = VGroup(*[Arrow(flow_steps[i].get_right(), flow_steps[i + 1].get_left(), buff=0.1) for i in range(len(flow_steps) - 1)])\n step_and_arrows = VGroup()\n for i in range(len(flow_steps)):\n step_and_arrows.add(flow_steps[i])\n if i < len(arrows):\n step_and_arrows.add(arrows[i])\n else:\n pass\n else:\n pass\n flow_group = VGroup(flow_title, step_and_arrows).arrange(DOWN, buff=0.6).next_to(topics, DOWN, buff=1.0)\n self.play(Write(flow_title))\n for i in range(len(flow_steps)):\n self.play(FadeIn(flow_steps[i], shift=UP), 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 self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass NetworkLayerSummary(Scene):\n\n def construct(self):\n title1 = Text('Practical Advice: Avoid Fragmentation', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(title1))\n bullets = VGroup(Text('• Fragment reassembly consumes receiver resources', font_size=28), Text('• Increases overall packet loss risk', font_size=28), Text('• Solution: Path MTU Discovery (PMTUD)', font_size=28, color=YELLOW)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(title1, DOWN, buff=0.5)\n for bullet in bullets:\n self.play(FadeIn(bullet, shift=RIGHT), run_time=0.8)\n else:\n pass\n self.wait(0.5)\n\n def create_node(label, color=WHITE):\n rect = RoundRect(corner_radius=0.2, width=1.5, height=1.0, color=color)\n text = Text(label, font_size=24).move_to(rect.get_center())\n return VGroup(rect, text)\n node_src = create_node('Source', BLUE).shift(LEFT * 4 + DOWN * 1.5)\n node_router = create_node('Router', GREEN).shift(DOWN * 1.5)\n node_dst = create_node('Dest', BLUE).shift(RIGHT * 4 + DOWN * 1.5)\n line1 = Line(node_src.get_right(), node_router.get_left())\n line2 = Line(node_router.get_right(), node_dst.get_left())\n mtu1 = Text('MTU: 1500', font_size=20).next_to(line1, UP, buff=0.1)\n mtu2 = Text('MTU: 1200', font_size=20).next_to(line2, UP, buff=0.1)\n diagram = VGroup(node_src, node_router, node_dst, line1, line2, mtu1, mtu2)\n self.play(FadeIn(diagram))\n self.wait(0.5)\n packet1 = Rectangle(width=0.8, height=0.4, color=ORANGE, fill_opacity=1)\n pkt_text1 = Text('1500', font_size=16, color=BLACK).move_to(packet1)\n pkt_group1 = VGroup(packet1, pkt_text1).next_to(node_src, UP, buff=0.2)\n self.play(FadeIn(pkt_group1))\n self.play(pkt_group1.animate.next_to(node_router, UP, buff=0.2), run_time=1.5)\n cross = Cross(pkt_group1, stroke_color=RED, stroke_width=4)\n self.play(Create(cross))\n self.wait(0.5)\n icmp = Text('ICMP: MTU=1200', font_size=18, color=RED).next_to(node_router, DOWN, buff=0.2)\n self.play(Write(icmp))\n self.play(icmp.animate.next_to(node_src, DOWN, buff=0.2), run_time=1.5)\n self.play(FadeOut(pkt_group1), FadeOut(cross), FadeOut(icmp))\n packet2 = Rectangle(width=0.5, height=0.4, color=ORANGE, fill_opacity=1)\n pkt_text2 = Text('1200', font_size=16, color=BLACK).move_to(packet2)\n pkt_group2 = VGroup(packet2, pkt_text2).next_to(node_src, UP, buff=0.2)\n self.play(FadeIn(pkt_group2))\n self.play(pkt_group2.animate.next_to(node_router, UP, buff=0.2), run_time=1)\n self.play(pkt_group2.animate.next_to(node_dst, UP, buff=0.2), run_time=1)\n self.play(FadeOut(pkt_group2))\n self.wait(1.5)\n self.play(FadeOut(title1), FadeOut(bullets), FadeOut(diagram))\n title2 = Text('Summary & Homework', font_size=40, color=BLUE).to_edge(UP)\n subtitle = Text('Review of This Section', font_size=32, color=YELLOW).next_to(title2, DOWN, buff=0.3)\n self.play(Write(title2), FadeIn(subtitle))\n topics_col1 = VGroup(Text('1. IPv4 Structure', font_size=28), Text('2. CIDR & Subnets', font_size=28), Text('3. DHCP', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n topics_col2 = VGroup(Text('4. NAT', font_size=28), Text('5. MTU & Fragmentation', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.4)\n topics = VGroup(topics_col1, topics_col2).arrange(RIGHT, aligned_edge=UP, buff=1.5).next_to(subtitle, DOWN, buff=0.8)\n self.play(FadeIn(topics, shift=UP))\n self.wait(1)\n flow_title = Text('Core Logic Flow:', font_size=28, color=GREEN)\n flow_steps = VGroup(Text('IP Structure', font_size=22), Text('DHCP Allocation', font_size=22), Text('CIDR Subnetting', font_size=22), Text('NAT Translation', font_size=22)).arrange(RIGHT, buff=0.8)\n arrows = VGroup(*[Arrow(flow_steps[i].get_right(), flow_steps[i + 1].get_left(), buff=0.1) for i in range(len(flow_steps) - 1)])\n step_and_arrows = VGroup()\n for i in range(len(flow_steps)):\n step_and_arrows.add(flow_steps[i])\n if i < len(arrows):\n step_and_arrows.add(arrows[i])\n else:\n pass\n else:\n pass\n flow_group = VGroup(flow_title, step_and_arrows).arrange(DOWN, buff=0.6).next_to(topics, DOWN, buff=1.0)\n self.play(Write(flow_title))\n for i in range(len(flow_steps)):\n self.play(FadeIn(flow_steps[i], shift=UP), 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 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Initialization: Display the complete double integral symbolically\n # =====================================================================\n \n # Title and Jacobian note for context\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n jacobian_note = MathTex(\n r\"dx \\, dy \\rightarrow r \\, dr \\, d\\theta\",\n font_size=30,\n color=YELLOW\n )\n jacobian_note.next_to(title, DOWN, buff=0.4)\n \n # Define the initial double integral in polar coordinates.\n # Integral: \\int from 0 to 2\\pi \\int from 0 to 2 of r dr d\\theta \n # Split into substrings for precise highlighting and transformation\n initial_integral = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"\\left(\", r\"\\int_{0}^{2}\", r\"r\", r\"\\, dr\", r\"\\right)\", r\"d\\theta\",\n font_size=48\n )\n initial_integral.next_to(jacobian_note, DOWN, buff=1.0)\n \n # Display initial elements\n self.play(Write(title))\n self.play(FadeIn(jacobian_note))\n self.play(Write(initial_integral))\n self.wait(1.5) # Pause for viewer to observe the setup\n \n # =====================================================================\n # 2. First Integration Phase (Radius)\n # =====================================================================\n \n # Text explanation for the first step\n text_step_1 = Text(\n \"First, integrate with respect to the radius (r).\",\n font_size=28,\n color=BLUE\n )\n text_step_1.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(FadeIn(text_step_1))\n self.wait(1.5) # Pause for reading\n \n # Highlight the inner integral part to focus viewer attention\n inner_integral_part = initial_integral[2:5] # Indices: \\int_{0}^{2}, r, \\, dr\n box = SurroundingRectangle(inner_integral_part, color=BLUE, buff=0.1)\n self.play(Create(box))\n self.wait(1)\n \n # Show the antiderivative step briefly to the side for pedagogical clarity\n # \\int r dr = [1/2 r^2] evaluated from 0 to 2 = 2\n evaluation_step_1 = MathTex(\n r\"\\left[ \\frac{1}{2}r^2 \\right]_{0}^{2} = 2\",\n font_size=30\n )\n evaluation_step_1.next_to(box, RIGHT, buff=0.3)\n \n self.play(Write(evaluation_step_1))\n self.wait(1.5) # Pause to see the antiderivative\n \n # Transform the full equation to the intermediate state\n intermediate_integral = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"2\", r\"\\, d\\theta\",\n font_size=48\n )\n intermediate_integral.move_to(initial_integral)\n \n self.play(\n ReplacementTransform(initial_integral.copy(), intermediate_integral),\n FadeOut(initial_integral),\n FadeOut(box),\n FadeOut(evaluation_step_1)\n )\n self.wait(2.0) # Pause for viewer to understand the intermediate state\n \n # =====================================================================\n # 3. Second Integration Phase (Angle)\n # =====================================================================\n \n # Transition the explanation text\n text_step_2 = Text(\n \"Now, integrate with respect to theta.\",\n font_size=28,\n color=GREEN\n )\n text_step_2.move_to(text_step_1)\n \n self.play(ReplacementTransform(text_step_1, text_step_2))\n self.wait(1.5) # Pause for reading\n \n # Highlight the remaining integral\n outer_box = SurroundingRectangle(intermediate_integral, color=GREEN, buff=0.1)\n self.play(Create(outer_box))\n self.wait(1)\n \n # Show the antiderivative step briefly to the side\n # \\int 2 d\\theta = [2\\theta ] evaluated from 0 to 2\\pi \n evaluation_step_2 = MathTex(\n r\"\\left[ 2\\theta \\right]_{0}^{2\\pi}\",\n font_size=30\n )\n evaluation_step_2.next_to(outer_box, RIGHT, buff=0.3)\n \n self.play(Write(evaluation_step_2))\n self.wait(1.5) # Pause to see the evaluation setup\n \n # Compute and display the final numerical value\n final_result = MathTex(\n r\"4\\pi\",\n font_size=48,\n color=GOLD\n )\n final_result.move_to(intermediate_integral)\n \n self.play(\n ReplacementTransform(intermediate_integral, final_result),\n FadeOut(outer_box),\n FadeOut(evaluation_step_2)\n )\n \n # Emphasize the final answer\n final_label = Text(\"Final Result\", font_size=24, color=GOLD)\n final_label.next_to(final_result, DOWN, buff=0.5)\n self.play(FadeIn(final_label), final_result.animate.scale(1.2))\n \n # =====================================================================\n # 4. Transitions & Flow - Final Pause\n # =====================================================================\n \n self.wait(2.0) # Final pause to allow comprehension of the solution\n \n # Clean up the screen for a smooth finish\n self.play(\n FadeOut(title),\n FadeOut(jacobian_note),\n FadeOut(text_step_2),\n FadeOut(final_result),\n FadeOut(final_label)\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # =====================================================================\n # 1. Initialization: Display the complete double integral symbolically\n # =====================================================================\n \n # Title and Jacobian note for context\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n jacobian_note = MathTex(\n r\"dx \\, dy \\rightarrow r \\, dr \\, d\\theta\",\n font_size=30,\n color=YELLOW\n )\n jacobian_note.next_to(title, DOWN, buff=0.4)\n \n # Define the initial double integral in polar coordinates.\n # Integral: \\int from 0 to 2\\pi \\int from 0 to 2 of r dr d\\theta \n # Split into substrings for precise highlighting and transformation\n initial_integral = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"\\left(\", r\"\\int_{0}^{2}\", r\"r\", r\"\\, dr\", r\"\\right)\", r\"d\\theta\",\n font_size=48\n )\n initial_integral.next_to(jacobian_note, DOWN, buff=1.0)\n \n # Display initial elements\n self.play(Write(title))\n self.play(FadeIn(jacobian_note))\n self.play(Write(initial_integral))\n self.wait(1.5) # Pause for viewer to observe the setup\n \n # =====================================================================\n # 2. First Integration Phase (Radius)\n # =====================================================================\n \n # Text explanation for the first step\n text_step_1 = Text(\n \"First, integrate with respect to the radius (r).\",\n font_size=28,\n color=BBLUE\n )\n text_step_1.next_to(initial_integral, DOWN, buff=0.8)\n \n self.play(FadeIn(text_step_1))\n self.wait(1.5) # Pause for reading\n \n # Highlight the inner integral part to focus viewer attention\n inner_integral_part = initial_integral[2:5] # Indices: \\int_{0}^{2}, r, \\, dr\n box = SurroundingRectangle(inner_integral_part, color=BLUE, buff=0.1)\n self.play(Create(box))\n self.wait(1)\n \n # Show the antiderivative step briefly to the side for pedagogical clarity\n # \\int r dr = [1/2 r^2] evaluated from 0 to 2 = 2\n evaluation_step_1 = MathTex(\n r\"\\left[ \\frac{1}{2}r^2 \\right]_{0}^{2} = 2\",\n font_size=30\n )\n evaluation_step_1.next_to(box, RIGHT, buff=0.3)\n \n self.play(Write(evaluation_step_1))\n self.wait(1.5) # Pause to see the antiderivative\n \n # Transform the full equation to the intermediate state\n intermediate_integral = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"2\", r\"\\, d\\theta\",\n font_size=48\n )\n intermediate_integral.move_to(initial_integral)\n \n self.play(\n ReplacementTransform(initial_integral.copy(), intermediate_integral),\n FadeOut(initial_integral),\n FadeOut(box),\n FadeOut(evaluation_step_1)\n )\n self.wait(2.0) # Pause for viewer to understand the intermediate state\n \n # =====================================================================\n # 3. Second Integration Phase (Angle)\n # =====================================================================\n \n # Transition the explanation text\n text_step_2 = Text(\n \"Now, integrate with respect to theta.\",\n font_size=28,\n color=GREEN\n )\n text_step_2.move_to(text_step_1)\n \n self.play(ReplacementTransform(text_step_1, text_step_2))\n self.wait(1.5) # Pause for reading\n \n # Highlight the remaining integral\n outer_box = SurroundingRectangle(intermediate_integral, color=GREEN, buff=0.1)\n self.play(Create(outer_box))\n self.wait(1)\n \n # Show the antiderivative step briefly to the side\n # \\int 2 d\\theta = [2\\theta ] evaluated from 0 to 2\\pi \n evaluation_step_2 = MathTex(\n r\"\\left[ 2\\theta \\right]_{0}^{2\\pi}\",\n font_size=30\n )\n evaluation_step_2.next_to(outer_box, RIGHT, buff=0.3)\n \n self.play(Write(evaluation_step_2))\n self.wait(1.5) # Pause to see the evaluation setup\n \n # Compute and display the final numerical value\n final_result = MathTex(\n r\"4\\pi\",\n font_size=48,\n color=GOLD\n )\n final_result.move_to(intermediate_integral)\n \n self.play(\n ReplacementTransform(intermediate_integral, final_result),\n FadeOut(outer_box),\n FadeOut(evaluation_step_2)\n )\n \n # Emphasize the final answer\n final_label = Text(\"Final Result\", font_size=24, color=GOLD)\n final_label.next_to(final_result, DOWN, buff=0.5)\n self.play(FadeIn(final_label), final_result.animate.scale(1.2))\n \n # =====================================================================\n # 4. Transitions & Flow - Final Pause\n # =====================================================================\n \n self.wait(2.0) # Final pause to allow comprehension of the solution\n \n # Clean up the screen for a smooth finish\n self.play(\n FadeOut(title),\n FadeOut(jacobian_note),\n FadeOut(text_step_2),\n FadeOut(final_result),\n FadeOut(final_label)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 gradient descent as repeated downhill steps on a loss surface. Use a contour-style basin on the left with a step-by-step path toward the minimum, and a compact loss-vs-iteration chart on the right that drops as the steps progress.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass GradientDescentContourStory(Scene):\n def construct(self):\n title = Text('Gradient Descent Moves Step by Step Toward Lower Loss', font_size=28).to_edge(UP)\n left_frame = RoundedRectangle(corner_radius=0.14, width=5.2, height=4.8, color=GRAY_B).shift(LEFT * 3.2 + DOWN * 0.1)\n right_frame = RoundedRectangle(corner_radius=0.14, width=4.0, height=4.8, color=GRAY_B).shift(RIGHT * 3.35 + DOWN * 0.1)\n basin_center = left_frame.get_center() + RIGHT * 0.25 + DOWN * 0.2\n contours = VGroup(*[\n Ellipse(width=w, height=h, color=BLUE_D, stroke_opacity=0.55).move_to(basin_center)\n for w, h in [(3.8, 2.8), (3.0, 2.15), (2.2, 1.55), (1.45, 0.95)]\n ])\n minimum = Dot(basin_center, color=YELLOW_D, radius=0.08)\n minimum_label = Text('minimum', font_size=18, color=YELLOW_D).next_to(minimum, DOWN, buff=0.14)\n path_points = [\n basin_center + np.array([-1.45, 1.05, 0]),\n basin_center + np.array([-0.95, 0.55, 0]),\n basin_center + np.array([-0.48, 0.18, 0]),\n basin_center + np.array([-0.18, 0.05, 0]),\n ]\n dots = VGroup(*[Dot(point, color=ORANGE, radius=0.07) for point in path_points])\n arrows = VGroup(*[\n Arrow(path_points[i], path_points[i + 1], buff=0.06, color=ORANGE, stroke_width=5)\n for i in range(len(path_points) - 1)\n ])\n axes = Axes(x_range=[0, 4, 1], y_range=[0, 2.6, 0.5], x_length=3.1, y_length=2.7, tips=False).move_to(right_frame.get_center() + DOWN * 0.12)\n loss_curve = VMobject(color=TEAL_D, stroke_width=4)\n loss_curve.set_points_smoothly([\n axes.c2p(0, 2.2),\n axes.c2p(1, 1.35),\n axes.c2p(2, 0.78),\n axes.c2p(3, 0.48),\n ])\n loss_dots = VGroup(*[Dot(axes.c2p(x, y), color=TEAL_D, radius=0.05) for x, y in [(0, 2.2), (1, 1.35), (2, 0.78), (3, 0.48)]])\n axis_labels = VGroup(Text('step', font_size=18, color=WHITE).next_to(axes.x_axis, DOWN, buff=0.12), Text('loss', font_size=18, color=WHITE).next_to(axes.y_axis, LEFT, buff=0.12))\n caption = Text('Each update follows the local slope, and the loss readout falls as the weights approach the basin floor.', font_size=22, 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(left_frame), FadeIn(right_frame), Create(contours), FadeIn(minimum), FadeIn(minimum_label), run_time=2.2)\n self.play(FadeIn(dots[0]), run_time=0.6)\n self.play(LaggedStart(*[GrowArrow(arrow) for arrow in arrows], lag_ratio=0.2), LaggedStart(*[FadeIn(dot) for dot in dots[1:]], lag_ratio=0.2), run_time=2.4)\n self.play(Create(axes), FadeIn(axis_labels), Create(loss_curve), FadeIn(loss_dots), run_time=2.2)\n self.play(FadeIn(caption_group), Indicate(minimum, color=YELLOW_A), run_time=1.6)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass GradientDescentContourStory(Scene):\n def construct(self):\n title = Text('Gradient Descent Moves Step by Step Toward Lower Loss', font_size=28).to_edge(UP)\n left_frame = RoundedRectangle(corner_radius=0.14, width=5.2, height=4.8, color=GRAY_B).shift(LEFT * 3.2 + DOWN * 0.1)\n right_frame = RoundedRectangle(corner_radius=0.14, width=4.0, height=4.8, color=GRAY_B).shift(RIGHT * 3.35 + DOWN * 0.1)\n basin_center = left_frame.get_center() + RIGHT * 0.25 + DOWN * 0.2\n contours = VGroup(*[\n Ellipse(width=w, height=h, color=BLUE_D, stroke_opacity=0.55).move_to(basin_center)\n for w, h in [(3.8, 2.8), (3.0, 2.15), (2.2, 1.55), (1.45, 0.95)]\n ])\n minimum = Dot(basin_center, color=YELLOW_D, radius=0.08)\n minimum_label = Text('minimum', font_size=18, color=YELLOW_D).next_to(minimum, DOWN, buff=0.14)\n path_points = [\n basin_center + np.array([-1.45, 1.05, 0]),\n basin_center + np.array([-0.95, 0.55, 0]),\n basin_center + np.array([-0.48, 0.18, 0]),\n basin_center + np.array([-0.18, 0.05, 0]),\n ]\n dots = VGroup(*[Dot(point, color=ORANGE, radius=0.07) for point in path_points])\n arrows = VGroup(*[\n Arrow(path_points[i], path_points[i + 1], buff=0.06, color=ORANGE, stroke_width=5)\n for i in range(len(path_points) - 1)\n ])\n axes = Axes(label_font_size=24, x_range=[0, 4, 1], y_range=[0, 2.6, 0.5], x_length=3.1, y_length=2.7, tips=False).move_to(right_frame.get_center() + DOWN * 0.12)\n loss_curve = VMobject(color=TEAL_D, stroke_width=4)\n loss_curve.set_points_smoothly([\n axes.c2p(0, 2.2),\n axes.c2p(1, 1.35),\n axes.c2p(2, 0.78),\n axes.c2p(3, 0.48),\n ])\n loss_dots = VGroup(*[Dot(axes.c2p(x, y), color=TEAL_D, radius=0.05) for x, y in [(0, 2.2), (1, 1.35), (2, 0.78), (3, 0.48)]])\n axis_labels = VGroup(Text('step', font_size=18, color=WHITE).next_to(axes.x_axis, DOWN, buff=0.12), Text('loss', font_size=18, color=WHITE).next_to(axes.y_axis, LEFT, buff=0.12))\n caption = Text('Each update follows the local slope, and the loss readout falls as the weights approach the basin floor.', font_size=22, 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(left_frame), FadeIn(right_frame), Create(contours), FadeIn(minimum), FadeIn(minimum_label), run_time=2.2)\n self.play(FadeIn(dots[0]), run_time=0.6)\n self.play(LaggedStart(*[GrowArrow(arrow) for arrow in arrows], lag_ratio=0.2), LaggedStart(*[FadeIn(dot) for dot in dots[1:]], lag_ratio=0.2), run_time=2.4)\n self.play(Create(axes), FadeIn(axis_labels), Create(loss_curve), FadeIn(loss_dots), run_time=2.2)\n self.play(FadeIn(caption_group), Indicate(minimum, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 how to solve a double integral in polar coordinates, specifically the integral of r from r=0 to r=1 and theta from theta=0 to theta=2π? I’d like to see the problem statement first, followed by a step-by-step walkthrough, showing the integration with respect to r first, then with respect to θ, and finally the calculation of the area inside a unit circle expressed by the integral. The explanation for each step should appear at the top of the screen and it should pause briefly on each part to give viewers time to understand before moving on to the next step.", "chosen": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Layout Configuration ---\n header_pos = UP * 3.2\n main_eq_y = 1.0\n graphic_y = -1.8\n\n # --- Introduction ---\n intro_text = Text(\"Double Integral in Polar Coordinates\", font_size=36, color=WHITE)\n intro_text.move_to(header_pos)\n \n # Initial Integral: \\int_{0}^{2\\pi} \\int_{0}^{1} r \\, dr \\, d\\theta\n initial_eq = MathTex(\n r\"\\int_{0}^{2\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r\", \n r\"\\,dr\", \n r\"\\,d\\theta\",\n font_size=48\n )\n initial_eq.move_to(ORIGIN).shift(UP * main_eq_y)\n \n # Visual: Unit Circle\n unit_circle = Circle(radius=1.5, color=BLUE)\n unit_circle.shift(DOWN * graphic_y)\n circle_label = MathTex(\"r=1\", font_size=36).next_to(unit_circle, RIGHT, buff=0.2)\n area_label = Text(\"Area = ?\", font_size=36).next_to(unit_circle, DOWN, buff=0.2)\n \n self.play(Write(intro_text))\n self.play(Write(initial_eq))\n self.play(Create(unit_circle), Write(circle_label), Write(area_label))\n self.wait(2)\n \n # --- Step 1: Inner Integral ---\n step1_text = Text(\"Step 1: Integrate with respect to r\", font_size=36, color=YELLOW)\n step1_text.move_to(header_pos)\n \n self.play(FadeOut(intro_text), FadeIn(step1_text))\n \n # Highlight the inner integral part\n inner_part = VGroup(initial_eq[1], initial_eq[2], initial_eq[3])\n highlight_box = SurroundingRectangle(inner_part, color=YELLOW, buff=0.15)\n self.play(Create(highlight_box))\n self.wait(1)\n \n # Show the calculation for the inner integral\n inner_calc = MathTex(\n r\"\\int_{0}^{1}\", r\"r\", r\"\\,dr\", \n r\"=\", r\"\\left[\\frac{r^2}{2}\\right]_{0}^{1}\", \n r\"=\", r\"\\frac{1}{2}\",\n font_size=42\n )\n inner_calc.next_to(initial_eq, DOWN, buff=0.5)\n self.play(Write(inner_calc))\n self.wait(2)\n \n # Update Equation\n step1_eq = MathTex(\n r\"\\int_{0}^{2\\pi}\", \n r\"\\frac{1}{2}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n step1_eq.move_to(ORIGIN).shift(UP * main_eq_y)\n \n self.play(\n FadeOut(initial_eq), \n FadeIn(step1_eq), \n FadeOut(inner_calc), \n FadeOut(highlight_box)\n )\n self.wait(2)\n \n # --- Step 2: Outer Integral ---\n step2_text = Text(\"Step 2: Integrate with respect to \\theta \", font_size=36, color=GREEN)\n step2_text.move_to(header_pos)\n \n self.play(FadeOut(step1_text), FadeIn(step2_text))\n \n # Highlight the remaining integral\n outer_highlight = SurroundingRectangle(step1_eq, color=GREEN, buff=0.15)\n self.play(Create(outer_highlight))\n self.wait(1)\n \n # Show the calculation for the outer integral\n outer_calc = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"\\frac{1}{2}\", r\"\\,d\\theta\", \n r\"=\", r\"\\left[\\frac{\\theta}{2}\\right]_{0}^{2\\pi}\", \n r\"=\", r\"\\pi\",\n font_size=42\n )\n outer_calc.next_to(step1_eq, DOWN, buff=0.5)\n self.play(Write(outer_calc))\n self.wait(2)\n \n # --- Conclusion ---\n conclusion_text = Text(\"Conclusion: Area of Unit Circle = \\pi \", font_size=36, color=GOLD)\n conclusion_text.move_to(header_pos)\n \n self.play(FadeOut(step2_text), FadeIn(conclusion_text))\n \n final_result = MathTex(r\"\\pi\", font_size=60)\n final_result.move_to(ORIGIN).shift(UP * main_eq_y)\n \n self.play(\n FadeOut(step1_eq), \n FadeIn(final_result), \n FadeOut(outer_calc), \n FadeOut(outer_highlight)\n )\n \n # Fill the circle to represent area\n self.play(unit_circle.animate.set_fill(BLUE, opacity=0.3))\n \n final_area_label = MathTex(\"A = \\pi\", font_size=36).next_to(unit_circle, DOWN, buff=0.2)\n self.play(FadeOut(area_label), FadeIn(final_area_label))\n \n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # --- Layout Configuration ---\n header_pos = UP * 3.2\n main_eq_y = 1.0\n graphic_y = -1.8\n\n # --- Introduction ---\n intro_text = Text(\"Double Integral in Polar Coordinates\", font_size=36, color=WHITE)\n intro_text.move_to(header_pos)\n \n # Initial Integral: \\int_{0}^{2\\pi} \\int_{0}^{1} r \\, dr \\, d\\theta\n initial_eq = MathText(\n r\"\\int_{0}^{2\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r\", \n r\"\\,dr\", \n r\"\\,d\\theta\",\n font_size=48\n )\n initial_eq.move_to(ORIGIN).shift(UP * main_eq_y)\n \n # Visual: Unit Circle\n unit_circle = Circle(radius=1.5, color=BLUE)\n unit_circle.shift(DOWN * graphic_y)\n circle_label = MathTex(\"r=1\", font_size=36).next_to(unit_circle, RIGHT, buff=0.2)\n area_label = Text(\"Area = ?\", font_size=36).next_to(unit_circle, DOWN, buff=0.2)\n \n self.play(Write(intro_text))\n self.play(Write(initial_eq))\n self.play(Create(unit_circle), Write(circle_label), Write(area_label))\n self.wait(2)\n \n # --- Step 1: Inner Integral ---\n step1_text = Text(\"Step 1: Integrate with respect to r\", font_size=36, color=YELLOW)\n step1_text.move_to(header_pos)\n \n self.play(FadeOut(intro_text), FadeIn(step1_text))\n \n # Highlight the inner integral part\n inner_part = VGroup(initial_eq[1], initial_eq[2], initial_eq[3])\n highlight_box = SurroundingRectangle(inner_part, color=YELLOW, buff=0.15)\n self.play(Create(highlight_box))\n self.wait(1)\n \n # Show the calculation for the inner integral\n inner_calc = MathTex(\n r\"\\int_{0}^{1}\", r\"r\", r\"\\,dr\", \n r\"=\", r\"\\left[\\frac{r^2}{2}\\right]_{0}^{1}\", \n r\"=\", r\"\\frac{1}{2}\",\n font_size=42\n )\n inner_calc.next_to(initial_eq, DOWN, buff=0.5)\n self.play(Write(inner_calc))\n self.wait(2)\n \n # Update Equation\n step1_eq = MathTex(\n r\"\\int_{0}^{2\\pi}\", \n r\"\\frac{1}{2}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n step1_eq.move_to(ORIGIN).shift(UP * main_eq_y)\n \n self.play(\n FadeOut(initial_eq), \n FadeIn(step1_eq), \n FadeOut(inner_calc), \n FadeOut(highlight_box)\n )\n self.wait(2)\n \n # --- Step 2: Outer Integral ---\n step2_text = Text(\"Step 2: Integrate with respect to \\theta \", font_size=36, color=GREEN)\n step2_text.move_to(header_pos)\n \n self.play(FadeOut(step1_text), FadeIn(step2_text))\n \n # Highlight the remaining integral\n outer_highlight = SurroundingRectangle(step1_eq, color=GREEN, buff=0.15)\n self.play(Create(outer_highlight))\n self.wait(1)\n \n # Show the calculation for the outer integral\n outer_calc = MathTex(\n r\"\\int_{0}^{2\\pi}\", r\"\\frac{1}{2}\", r\"\\,d\\theta\", \n r\"=\", r\"\\left[\\frac{\\theta}{2}\\right]_{0}^{2\\pi}\", \n r\"=\", r\"\\pi\",\n font_size=42\n )\n outer_calc.next_to(step1_eq, DOWN, buff=0.5)\n self.play(Write(outer_calc))\n self.wait(2)\n \n # --- Conclusion ---\n conclusion_text = Text(\"Conclusion: Area of Unit Circle = \\pi \", font_size=36, color=GOLD)\n conclusion_text.move_to(header_pos)\n \n self.play(FadeOut(step2_text), FadeIn(conclusion_text))\n \n final_result = MathTex(r\"\\pi\", font_size=60)\n final_result.move_to(ORIGIN).shift(UP * main_eq_y)\n \n self.play(\n FadeOut(step1_eq), \n FadeIn(final_result), \n FadeOut(outer_calc), \n FadeOut(outer_highlight)\n )\n \n # Fill the circle to represent area\n self.play(unit_circle.animate.set_fill(BLUE, opacity=0.3))\n \n final_area_label = MathTex(\"A = \\pi\", font_size=36).next_to(unit_circle, DOWN, buff=0.2)\n self.play(FadeOut(area_label), FadeIn(final_area_label))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Pell's Equation' (Symmetric Patterns of Pell's Equation: A Geometric Exploration): How can the solutions to the Pell's Equation be visualized geometrically on a coordinate grid?\nVisual style guidance: The animation embraces a classic, elegant visual style inspired by chalkboard illustrations. The color palette incorporates calming blues, warm whites, and occasional gold highlights to emphasize moments of discovery and insight. The overall mood is educational yet enchanting, allowing the beauty of mathematics to captivate the viewer.", "chosen": "```python\nfrom manim import *\n\nclass PellsEquationGeometric(Scene):\n def construct(self):\n # INTRODUCTION\n title = Text(\"Symmetric Patterns of Pell's Equation\", font_size=36)\n subtitle = Text(\"A Geometric Exploration\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n \n # Display Pell's equation with D=2\n equation = MathTex(\"x^2 - 2y^2 = 1\")\n equation.move_to(ORIGIN)\n \n self.play(FadeOut(title), FadeOut(subtitle))\n self.play(Write(equation))\n self.wait(1)\n \n # Move equation to corner\n self.play(equation.animate.to_corner(UR))\n \n # Create coordinate grid\n grid = NumberPlane(\n x_range=[-5, 5, 1],\n y_range=[-5, 5, 1],\n )\n \n self.play(Create(grid))\n self.wait(1)\n \n # Plot solution points for D=2\n # These solutions satisfy x^2 - 2y^2 = 1\n solutions = [(1, 0), (3, 2)]\n \n # Create dots for solutions\n dots = VGroup()\n for x, y in solutions:\n dot = Dot(grid.c2p(x, y), color=BLUE)\n dots.add(dot)\n \n # Add symmetric solutions\n dots.add(Dot(grid.c2p(x, -y), color=BLUE))\n dots.add(Dot(grid.c2p(-x, y), color=BLUE))\n dots.add(Dot(grid.c2p(-x, -y), color=BLUE))\n \n self.play(Create(dots))\n self.wait(1)\n \n # Draw diagonal line through solutions\n diagonal = Line(grid.c2p(-5, -3.5), grid.c2p(5, 3.5), color=YELLOW)\n self.play(Create(diagonal))\n self.wait(1)\n \n # Connect solution points\n connections = VGroup(\n Line(grid.c2p(1, 0), grid.c2p(3, 2), color=GREEN),\n Line(grid.c2p(1, 0), grid.c2p(3, -2), color=GREEN),\n Line(grid.c2p(-1, 0), grid.c2p(-3, 2), color=GREEN),\n Line(grid.c2p(-1, 0), grid.c2p(-3, -2), color=GREEN)\n )\n \n self.play(Create(connections))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Pell's Equation connects algebra and geometry\", font_size=32)\n \n self.play(FadeOut(grid), FadeOut(equation), FadeOut(dots), \n FadeOut(diagonal), FadeOut(connections))\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n\n# Run with: manim -pql -o video.mp4 script_name.py PellsEquationGeometric\n```", "rejected": "```python\nfrom manim import *\n\nclass PellsEquationGeometric(Scene):\n def construct(self):\n # INTRODUCTION\n title = Text(\"Symmetric Patterns of Pell's Equation\", font_size=36)\n subtitle = Text(\"A Geometric Exploration\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n \n # Display Pell's equation with D=2\n equation = MathText(\"x^2 - 2y^2 = 1\")\n equation.move_to(ORIGIN)\n \n self.play(FadeOut(title), FadeOut(subtitle))\n self.play(Write(equation))\n self.wait(1)\n \n # Move equation to corner\n self.play(equation.animate.to_corner(UR))\n \n # Create coordinate grid\n grid = NumberPlane(\n x_range=[-5, 5, 1],\n y_range=[-5, 5, 1],\n )\n \n self.play(Create(grid))\n self.wait(1)\n \n # Plot solution points for D=2\n # These solutions satisfy x^2 - 2y^2 = 1\n solutions = [(1, 0), (3, 2)]\n \n # Create dots for solutions\n dots = VGroup()\n for x, y in solutions:\n dot = Dot(grid.c2p(x, y), color=BLUE)\n dots.add(dot)\n \n # Add symmetric solutions\n dots.add(Dot(grid.c2p(x, -y), color=BLUE))\n dots.add(Dot(grid.c2p(-x, y), color=BLUE))\n dots.add(Dot(grid.c2p(-x, -y), color=BLUE))\n \n self.play(Create(dots))\n self.wait(1)\n \n # Draw diagonal line through solutions\n diagonal = Line(grid.c2p(-5, -3.5), grid.c2p(5, 3.5), color=YELLOW)\n self.play(Create(diagonal))\n self.wait(1)\n \n # Connect solution points\n connections = VGroup(\n Line(grid.c2p(1, 0), grid.c2p(3, 2), color=GREEN),\n Line(grid.c2p(1, 0), grid.c2p(3, -2), color=GREEN),\n Line(grid.c2p(-1, 0), grid.c2p(-3, 2), color=GREEN),\n Line(grid.c2p(-1, 0), grid.c2p(-3, -2), color=GREEN)\n )\n \n self.play(Create(connections))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Pell's Equation connects algebra and geometry\", font_size=32)\n \n self.play(FadeOut(grid), FadeOut(equation), FadeOut(dots), \n FadeOut(diagonal), FadeOut(connections))\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n\n# Run with: manim -pql -o video.mp4 script_name.py PellsEquationGeometric\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 by drawing a horizontal green line centered on the screen, just like the original. However, as the line shifts downward, a new feature is introduced: a coordinate system fades in, with labeled x and y axes, providing context for the movement. Simultaneously, a mathematical formula appears above the line, dynamically rendering the transformation as \\( y = y - 2 \\), illustrating the downward shift in algebraic terms. The line then smoothly morphs into a parabola, \\( y = x^2 - 2 \\), demonstrating how the original linear transformation relates to a more complex function. Throughout the animation, explanatory text appears in stages, first describing the translation (\"Shifting the line downward by 2 units\") and then the transformation (\"Now mapping the line to a parabola\"). The scene concludes with all elements fading out elegantly, leaving only the parabola briefly before the screen clears. This enhanced version not only preserves the original motion but also adds mathematical depth, visual context, and educational clarity.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedLineShift(Scene):\n def construct(self):\n # Create initial line\n line = Line(start=LEFT*3, end=RIGHT*3, color=GREEN).shift(UP)\n \n # Create coordinate axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-4, 4, 1],\n x_length=7,\n y_length=7,\n axis_config={\"color\": BLUE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n axes_group = VGroup(axes, axes_labels)\n axes_group.set_opacity(0)\n \n # Create formula for shift\n shift_formula = MathTex(\"y = y - 2\", color=YELLOW).to_edge(UP)\n shift_formula.set_opacity(0)\n \n # Create explanatory text\n shift_text = Text(\"Shifting the line downward by 2 units\", font_size=24).to_edge(DOWN)\n transform_text = Text(\"Now mapping the line to a parabola\", font_size=24).to_edge(DOWN)\n shift_text.set_opacity(0)\n transform_text.set_opacity(0)\n \n # Create parabola\n parabola = axes.plot(lambda x: x**2 - 2, color=RED)\n parabola.set_opacity(0)\n \n # Animation sequence\n self.play(Create(line))\n self.wait(0.5)\n \n # Fade in axes and formula\n self.play(\n line.animate.shift(DOWN*2),\n axes_group.animate.set_opacity(1),\n shift_formula.animate.set_opacity(1),\n FadeIn(shift_text),\n run_time=2\n )\n self.wait(1)\n \n # Transform line to parabola\n self.play(\n FadeOut(line),\n FadeOut(shift_text),\n FadeIn(transform_text),\n parabola.animate.set_opacity(1),\n run_time=2\n )\n self.wait(1)\n \n # Fade out everything except parabola\n self.play(\n FadeOut(axes_group),\n FadeOut(shift_formula),\n FadeOut(transform_text),\n run_time=1\n )\n self.wait(0.5)\n \n # Fade out parabola\n self.play(FadeOut(parabola))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedLineShift(Scene):\n def construct(self):\n # Create initial line\n line = Line(start=LEFT*3, end=RIGHT*3, color=GREEN).shift(UP)\n \n # Create coordinate axes\n axes = Axes(\n x_range=[-4, 4, 1],\n y_range=[-4, 4, 1],\n x_length=7,\n y_length=7,\n axis_config={\"color\": BBLUE},\n x_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n y_axis_config={\"numbers_to_include\": range(-4, 5, 1)},\n )\n axes_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n axes_group = VGroup(axes, axes_labels)\n axes_group.set_opacity(0)\n \n # Create formula for shift\n shift_formula = MathTex(\"y = y - 2\", color=YELLOW).to_edge(UP)\n shift_formula.set_opacity(0)\n \n # Create explanatory text\n shift_text = Text(\"Shifting the line downward by 2 units\", font_size=24).to_edge(DOWN)\n transform_text = Text(\"Now mapping the line to a parabola\", font_size=24).to_edge(DOWN)\n shift_text.set_opacity(0)\n transform_text.set_opacity(0)\n \n # Create parabola\n parabola = axes.plot(lambda x: x**2 - 2, color=RED)\n parabola.set_opacity(0)\n \n # Animation sequence\n self.play(Create(line))\n self.wait(0.5)\n \n # Fade in axes and formula\n self.play(\n line.animate.shift(DOWN*2),\n axes_group.animate.set_opacity(1),\n shift_formula.animate.set_opacity(1),\n FadeIn(shift_text),\n run_time=2\n )\n self.wait(1)\n \n # Transform line to parabola\n self.play(\n FadeOut(line),\n FadeOut(shift_text),\n FadeIn(transform_text),\n parabola.animate.set_opacity(1),\n run_time=2\n )\n self.wait(1)\n \n # Fade out everything except parabola\n self.play(\n FadeOut(axes_group),\n FadeOut(shift_formula),\n FadeOut(transform_text),\n run_time=1\n )\n self.wait(0.5)\n \n # Fade out parabola\n self.play(FadeOut(parabola))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 demonstrates how to calculate the area under the graph of the function x squared from 0 to 2. Please include the following steps: \n\n1. Display a set of blue axes with an x-range from 0 to 3 and a y-range from 0 to 4, with the axes measuring 5 units along the x-axis and 3 units along the y-axis.\n2. Plot the function x squared on these axes, coloring the graph green, and label the graph with its equation.\n3. Highlight the area under the graph from 0 to 2 using a yellow color with some transparency.\n4. Write out the integral expression that represents the area under the graph using proper mathematical notation.\n5. Transition the integral expression to its antiderivative evaluated between 0 and 2.\n6. Show the final calculation step with the numerical result of the integral, which should be 8/3.\n7. Add that numerical result at the bottom as a conclusion statement, stating \"The area under x squared from 0 to 2 is 8/3,\" and ensure this statement is placed effectively at the bottom of the screen.\n8. After showing all the previous steps, clear the screen.\n9. Lastly, display only the final numerical integral value as a separate and clear concluding message.\n\nThe animation should be paced with pauses after each major step to allow the viewer some time to understand the content.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderXSquared(Scene):\n def construct(self):\n # 1. Axes Setup\n # Blue axes with x-range [0, 3], y-range [0, 4], physical dimensions 5x3\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 4, 1],\n x_length=5,\n y_length=3,\n axis_config={\"color\": BLUE}\n )\n self.play(Create(axes))\n self.wait(1)\n\n # 2. Function Plot\n # Plot f(x) = x^2 in green and label it\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^2\", x_val=2, direction=UR)\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Highlight\n # Highlight area under curve from x=0 to x=2 in yellow with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Integral Expression\n # Display the definite integral expression\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 5. Antiderivative Transition\n # Animate transition to the antiderivative evaluated between limits\n antiderivative_expr = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").to_edge(UP)\n self.play(ReplacementTransform(integral_expr, antiderivative_expr))\n self.wait(1)\n\n # 6. Calculation Step\n # Show the final calculation step yielding 8/3\n calculation_expr = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3} = \\frac{8}{3}\").next_to(antiderivative_expr, DOWN)\n self.play(Write(calculation_expr))\n self.wait(1)\n\n # 7. Conclusion Statement\n # Display text at the bottom of the screen\n text_part = Text(\"The area under x squared from 0 to 2 is \").to_edge(DOWN)\n math_part = MathTex(r\"\\frac{8}{3}\").next_to(text_part, RIGHT)\n conclusion = VGroup(text_part, math_part)\n self.play(Write(conclusion))\n self.wait(2)\n\n # 8. Screen Clear\n # Clear all objects from the screen\n self.play(FadeOut(*self.mobjects))\n self.wait(1)\n\n # 9. Final Value\n # Display only the final numerical integral value clearly\n final_value = MathTex(r\"\\frac{8}{3}\").scale(2)\n self.play(Write(final_value))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderXSquared(Scene):\n def construct(self):\n # 1. Axes Setup\n # Blue axes with x-range [0, 3], y-range [0, 4], physical dimensions 5x3\n axes = Axes(\n x_range=[0, 3, 1],\n y_range=[0, 4, 1],\n x_length=5,\n y_length=3,\n axis_config={\"color\": BLUE}\n )\n self.play(Create(axes))\n self.wait(1)\n\n # 2. Function Plot\n # Plot f(x) = x^2 in green and label it\n graph = axes.plot(lambda x: x**2, color=GREEN)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = x^2\", x_val=2, direction=UR)\n self.play(Create(graph), Write(graph_label))\n self.wait(1)\n\n # 3. Area Highlight\n # Highlight area under curve from x=0 to x=2 in yellow with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=YELLOW, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Integral Expression\n # Display the definite integral expression\n integral_expr = MathText(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 5. Antiderivative Transition\n # Animate transition to the antiderivative evaluated between limits\n antiderivative_expr = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").to_edge(UP)\n self.play(ReplacementTransform(integral_expr, antiderivative_expr))\n self.wait(1)\n\n # 6. Calculation Step\n # Show the final calculation step yielding 8/3\n calculation_expr = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3} = \\frac{8}{3}\").next_to(antiderivative_expr, DOWN)\n self.play(Write(calculation_expr))\n self.wait(1)\n\n # 7. Conclusion Statement\n # Display text at the bottom of the screen\n text_part = Text(\"The area under x squared from 0 to 2 is \").to_edge(DOWN)\n math_part = MathTex(r\"\\frac{8}{3}\").next_to(text_part, RIGHT)\n conclusion = VGroup(text_part, math_part)\n self.play(Write(conclusion))\n self.wait(2)\n\n # 8. Screen Clear\n # Clear all objects from the screen\n self.play(FadeOut(*self.mobjects))\n self.wait(1)\n\n # 9. Final Value\n # Display only the final numerical integral value clearly\n final_value = MathTex(r\"\\frac{8}{3}\").scale(2)\n self.play(Write(final_value))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the actual sine wave on these axes. At the top of the scene, add the text \"Sine wave approximation with polynomials.\" After showing the sine wave, draw a green polynomial curve that approximates the sine wave. Could you then place a red dot at the point where the angle is pi on the sine curve? Finally, from that red dot, draw a dashed yellow vertical line straight down to the x-axis. Please pause briefly after each step so that I can see each part clearly.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineApproximation(Scene):\n def construct(self):\n # 1. Coordinate System\n # Create axes spanning 0 to 10 on x-axis and -2 to 2 on y-axis\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": True}\n ).center()\n \n self.play(Create(axes))\n self.wait()\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\").to_edge(UP)\n self.play(Write(title))\n self.wait()\n\n # 3. Sine Wave\n # Plot the actual sine wave on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n self.play(Create(sine_curve))\n self.wait()\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series)\n # sin(x) \\approx x - x^3/3! + x^5/5!\n poly_curve = axes.plot(\n lambda x: x - (x**3)/6 + (x**5)/120, \n color=GREEN\n )\n self.play(Create(poly_curve))\n self.wait()\n\n # 5. Specific Point\n # Place a red dot on the sine curve at x = \\pi \n point_x = np.pi\n point_y = np.sin(point_x)\n dot = Dot(axes.c2p(point_x, point_y), color=RED)\n self.play(FadeIn(dot))\n self.wait()\n\n # 6. Vertical Line\n # Draw a dashed yellow vertical line from the red dot to the x-axis\n # Note: At x=\\pi , sin(x)=0, so the line's start and end points are the same,\n # but the logic is implemented as requested.\n vertical_line = DashedLine(\n start=dot.get_center(), \n end=axes.c2p(point_x, 0), \n color=YELLOW\n )\n self.play(Create(vertical_line))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass SineApproximation(Scene):\n def construct(self):\n # 1. Coordinate System\n # Create axes spanning 0 to 10 on x-axis and -2 to 2 on y-axis\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n x_length=10,\n y_length=4,\n axis_config={\"include_tip\": True}\n ).center()\n \n self.play(Create(axes))\n self.wait()\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\").to_edge(UP)\n self.play(Write(title))\n self.wait()\n\n # 3. Sine Wave\n # Plot the actual sine wave on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BBLUE)\n self.play(Create(sine_curve))\n self.wait()\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series)\n # sin(x) \\approx x - x^3/3! + x^5/5!\n poly_curve = axes.plot(\n lambda x: x - (x**3)/6 + (x**5)/120, \n color=GREEN\n )\n self.play(Create(poly_curve))\n self.wait()\n\n # 5. Specific Point\n # Place a red dot on the sine curve at x = \\pi \n point_x = np.pi\n point_y = np.sin(point_x)\n dot = Dot(axes.c2p(point_x, point_y), color=RED)\n self.play(FadeIn(dot))\n self.wait()\n\n # 6. Vertical Line\n # Draw a dashed yellow vertical line from the red dot to the x-axis\n # Note: At x=\\pi , sin(x)=0, so the line's start and end points are the same,\n # but the logic is implemented as requested.\n vertical_line = DashedLine(\n start=dot.get_center(), \n end=axes.c2p(point_x, 0), \n color=YELLOW\n )\n self.play(Create(vertical_line))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Diophantine Equations' (The Mystery of x³ + y³ + z³ = k: Where Math Meets Art): In what way can the equation x³ + y³ + z³ = k illustrate the limitations and challenges of finding integer solutions?\nVisual style guidance: The visual style is sophisticated and elegant, utilizing a color palette with deep blues, golden highlights, and accents of red, green, and blue for clarity in distinguishing integer solution points. The overall style is reminiscent of abstract art, with smooth animations that flow seamlessly.", "chosen": "```python\nfrom manim import *\n\nclass DiophantineEquationsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Mystery of x^3 + y^3 + z^3 = k\", font_size=36)\n subtitle = Text(\"Where Math Meets Art\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Introduction\n intro_text = Text(\"Diophantine Equations\", font_size=36)\n equation = Text(\"x^3 + y^3 + z^3 = k\", font_size=40, color=BLUE)\n equation.next_to(intro_text, DOWN, buff=0.5)\n \n # Display introduction and main equation\n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Move equation to top for the rest of the presentation\n equation_top = equation.copy().to_edge(UP)\n self.play(ReplacementTransform(equation, equation_top))\n equation = equation_top\n \n # Key Concept 1: Mathematical Puzzle\n concept1 = Text(\"A Perplexing Mathematical Puzzle\", font_size=32)\n concept1.next_to(equation, DOWN)\n \n self.play(Write(concept1))\n self.wait(1)\n \n # Create a grid of dots to represent integer points\n dots = VGroup()\n for x in range(-2, 3):\n for y in range(-2, 3):\n dot = Dot([x, y, 0], color=BLUE)\n dots.add(dot)\n \n self.play(FadeIn(dots))\n self.wait(1)\n \n # Key Concept 2: Solutions as Points\n concept2 = Text(\"Solutions as Points in Space\", font_size=32)\n concept2.next_to(equation, DOWN)\n \n self.play(FadeOut(concept1))\n self.play(Write(concept2))\n \n # Highlight specific points as solutions\n solution_dots = VGroup(\n Dot([1, 1, 0], color=YELLOW, radius=0.1),\n Dot([2, -1, 0], color=YELLOW, radius=0.1),\n Dot([-1, -1, 0], color=YELLOW, radius=0.1)\n )\n \n self.play(FadeIn(solution_dots))\n self.wait(1)\n \n # Key Concept 3: Limitations and Challenges\n concept3 = Text(\"Limitations and Challenges\", font_size=32)\n concept3.next_to(equation, DOWN)\n \n self.play(FadeOut(concept2))\n self.play(Write(concept3))\n \n # Example of a k value with solutions\n k_text = Text(\"k = 3: Solutions exist\", font_size=28)\n k_text.to_edge(DOWN, buff=1)\n \n self.play(Write(k_text))\n self.wait(1)\n \n # Clean up for conclusion\n self.play(\n FadeOut(dots),\n FadeOut(solution_dots),\n FadeOut(k_text),\n FadeOut(concept3)\n )\n \n # Move equation back to center for conclusion\n equation_center = Text(\"x^3 + y^3 + z^3 = k\", font_size=40, color=GOLD).center()\n self.play(ReplacementTransform(equation, equation_center))\n equation = equation_center\n \n # Conclusion\n conclusion_text = Text(\"The dance between numbers continues...\", font_size=32)\n conclusion_text.next_to(equation, DOWN, buff=0.5)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(equation), FadeOut(conclusion_text))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass DiophantineEquationsScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Mystery of x^3 + y^3 + z^3 = k\", font_size=36)\n subtitle = Text(\"Where Math Meets Art\", font_size=28)\n subtitle.next_to(title, DOWN)\n \n # Display title and subtitle\n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Introduction\n intro_text = Text(\"Diophantine Equations\", font_size=36)\n equation = Text(\"x^3 + y^3 + z^3 = k\", font_size=40, color=BBLUE)\n equation.next_to(intro_text, DOWN, buff=0.5)\n \n # Display introduction and main equation\n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Write(equation))\n self.wait(1)\n self.play(FadeOut(intro_text))\n \n # Move equation to top for the rest of the presentation\n equation_top = equation.copy().to_edge(UP)\n self.play(ReplacementTransform(equation, equation_top))\n equation = equation_top\n \n # Key Concept 1: Mathematical Puzzle\n concept1 = Text(\"A Perplexing Mathematical Puzzle\", font_size=32)\n concept1.next_to(equation, DOWN)\n \n self.play(Write(concept1))\n self.wait(1)\n \n # Create a grid of dots to represent integer points\n dots = VGroup()\n for x in range(-2, 3):\n for y in range(-2, 3):\n dot = Dot([x, y, 0], color=BLUE)\n dots.add(dot)\n \n self.play(FadeIn(dots))\n self.wait(1)\n \n # Key Concept 2: Solutions as Points\n concept2 = Text(\"Solutions as Points in Space\", font_size=32)\n concept2.next_to(equation, DOWN)\n \n self.play(FadeOut(concept1))\n self.play(Write(concept2))\n \n # Highlight specific points as solutions\n solution_dots = VGroup(\n Dot([1, 1, 0], color=YELLOW, radius=0.1),\n Dot([2, -1, 0], color=YELLOW, radius=0.1),\n Dot([-1, -1, 0], color=YELLOW, radius=0.1)\n )\n \n self.play(FadeIn(solution_dots))\n self.wait(1)\n \n # Key Concept 3: Limitations and Challenges\n concept3 = Text(\"Limitations and Challenges\", font_size=32)\n concept3.next_to(equation, DOWN)\n \n self.play(FadeOut(concept2))\n self.play(Write(concept3))\n \n # Example of a k value with solutions\n k_text = Text(\"k = 3: Solutions exist\", font_size=28)\n k_text.to_edge(DOWN, buff=1)\n \n self.play(Write(k_text))\n self.wait(1)\n \n # Clean up for conclusion\n self.play(\n FadeOut(dots),\n FadeOut(solution_dots),\n FadeOut(k_text),\n FadeOut(concept3)\n )\n \n # Move equation back to center for conclusion\n equation_center = Text(\"x^3 + y^3 + z^3 = k\", font_size=40, color=GOLD).center()\n self.play(ReplacementTransform(equation, equation_center))\n equation = equation_center\n \n # Conclusion\n conclusion_text = Text(\"The dance between numbers continues...\", font_size=32)\n conclusion_text.next_to(equation, DOWN, buff=0.5)\n \n self.play(Write(conclusion_text))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(equation), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 hexagon while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n\nThe animation begins with a yellow regular hexagon appearing at the center of the screen, as in the original script. Then, the hexagon smoothly transforms into a circle of the same radius, illustrating the relationship between polygons and their circumscribed circles. Simultaneously, the formula for the side length of a regular hexagon, \\( s = r \\) (since all sides are equal to the radius), fades in below the shape, accompanied by explanatory text that reads \"A regular hexagon's side length equals its radius.\" The hexagon then divides into six equilateral triangles, each rotating outward to visually demonstrate the hexagon's symmetry and internal angles. Finally, the triangles reassemble into the original hexagon, while the formula and text fade out, leaving the hexagon as the focal point. This enhanced animation not only displays the hexagon but also educates the viewer about its geometric properties through dynamic transformations and clear annotations.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedHexagonScene(Scene):\n def construct(self):\n # Create a regular hexagon\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 *\n\nclass EnhancedHexagonScene(Scene):\n def construct(self):\n # Create a regular hexagon\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 = MathText(\"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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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. Scene Setup: Initialize standard coordinate system\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 20, 5],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).add_coordinates()\n\n # 2. Function Definition: Define quadratic function f(x) = x^2\n func = lambda x: x**2\n curve = axes.plot(func, x_range=[0, 4.5], color=YELLOW)\n\n # Display the axes and the plotted curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 3. Shade the region under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=(0, 4), color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Add a text label displaying the function's equation near the curve\n eq_label = MathTex(\"f(x) = x^2\", font_size=36).next_to(curve, UR, buff=0.5)\n self.play(Write(eq_label))\n self.wait(1)\n\n # 5. Display explanatory text stating what the shaded area represents\n info_text = Text(\n \"The shaded area represents\\nthe integral from 0 to 4\",\n font_size=24\n ).to_edge(DOWN)\n self.play(Write(info_text))\n self.wait(2)\n\n # 6. Animate replacement of the function equation with the definite integral formula\n integral_formula = MathTex(r\"\\int_{0}^{4} x^2 \\, dx\", font_size=36).move_to(eq_label)\n self.play(ReplacementTransform(eq_label, integral_formula))\n self.wait(2)\n\n # 7. Calculate and display the exact numerical value of the area\n # Integral calculation: \\int (0 to 4) x^2 dx = [x^3/3] from 0 to 4 = 64/3\n result_value = MathTex(r\"= \\frac{64}{3} \\approx 21.33\", font_size=36, color=GREEN)\n result_value.next_to(integral_formula, RIGHT, buff=0.5)\n \n # Remove explanatory text to reduce clutter\n self.play(FadeOut(info_text))\n self.play(Write(result_value))\n self.wait(2)\n\n # 8. Clear all elements except the final solution value\n to_remove = VGroup(axes, curve, area, integral_formula)\n final_solution = VGroup(integral_formula, result_value)\n \n self.play(FadeOut(to_remove))\n \n # Center and enlarge the solution for final emphasis\n self.play(final_solution.animate.move_to(ORIGIN).scale(1.5))\n \n # 9. Hold the final solution on screen briefly before ending\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Scene Setup: Initialize standard coordinate system\n axes = Axes(label_font_size=24, \n x_range=[0, 5, 1],\n y_range=[0, 20, 5],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n ).add_coordinates()\n\n # 2. Function Definition: Define quadratic function f(x) = x^2\n func = lambda x: x**2\n curve = axes.plot(func, x_range=[0, 4.5], color=YELLOW)\n\n # Display the axes and the plotted curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 3. Shade the region under the curve between x=0 and x=4\n area = axes.get_area(curve, x_range=(0, 4), color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Add a text label displaying the function's equation near the curve\n eq_label = MathTex(\"f(x) = x^2\", font_size=36).next_to(curve, UR, buff=0.5)\n self.play(Write(eq_label))\n self.wait(1)\n\n # 5. Display explanatory text stating what the shaded area represents\n info_text = Text(\n \"The shaded area represents\\nthe integral from 0 to 4\",\n font_size=24\n ).to_edge(DOWN)\n self.play(Write(info_text))\n self.wait(2)\n\n # 6. Animate replacement of the function equation with the definite integral formula\n integral_formula = MathTex(r\"\\int_{0}^{4} x^2 \\, dx\", font_size=36).move_to(eq_label)\n self.play(ReplacementTransform(eq_label, integral_formula))\n self.wait(2)\n\n # 7. Calculate and display the exact numerical value of the area\n # Integral calculation: \\int (0 to 4) x^2 dx = [x^3/3] from 0 to 4 = 64/3\n result_value = MathTex(r\"= \\frac{64}{3} \\approx 21.33\", font_size=36, color=GREEN)\n result_value.next_to(integral_formula, RIGHT, buff=0.5)\n \n # Remove explanatory text to reduce clutter\n self.play(FadeOut(info_text))\n self.play(Write(result_value))\n self.wait(2)\n\n # 8. Clear all elements except the final solution value\n to_remove = VGroup(axes, curve, area, integral_formula)\n final_solution = VGroup(integral_formula, result_value)\n \n self.play(FadeOut(to_remove))\n \n # Center and enlarge the solution for final emphasis\n self.play(final_solution.animate.move_to(ORIGIN).scale(1.5))\n \n # 9. Hold the final solution on screen briefly before ending\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 orbital phase by comparing two p orbitals at different orientations. Show colored lobes, rotate one orientation into another, and mention that sign and orientation matter.", "chosen": "```python\nfrom manim import *\n\nclass OrbitalPhaseRotation(Scene):\n def construct(self):\n title = Text(\"Orbital Phase and Orientation\", font_size=34).to_edge(UP)\n left_orbital = VGroup(\n Ellipse(width=1.2, height=2.1, stroke_color=BLUE_D, fill_color=BLUE_C, fill_opacity=0.32).shift(UP * 1.1),\n Ellipse(width=1.2, height=2.1, stroke_color=RED_D, fill_color=RED_C, fill_opacity=0.32).shift(DOWN * 1.1),\n DashedLine(LEFT * 1.6, RIGHT * 1.6, color=GRAY_C),\n ).move_to(LEFT * 3.1)\n right_orbital = left_orbital.copy().rotate(PI / 2).move_to(RIGHT * 3.1)\n left_label = Text(\"vertical orientation\", font_size=22).next_to(left_orbital, DOWN)\n right_label = Text(\"horizontal orientation\", font_size=22).next_to(right_orbital, DOWN)\n plus_minus = VGroup(\n MathTex(\"+\", color=BLUE_D).move_to(left_orbital[0]),\n MathTex(\"-\", color=RED_D).move_to(left_orbital[1]),\n MathTex(\"+\", color=BLUE_D).move_to(right_orbital[0]),\n MathTex(\"-\", color=RED_D).move_to(right_orbital[1]),\n )\n arrow = CurvedArrow(left_orbital.get_right() + RIGHT * 0.2, right_orbital.get_left() + LEFT * 0.2, angle=-PI / 2, color=YELLOW_D)\n caption = VGroup(\n Text(\"The sign pattern stays paired to the lobe orientation.\", font_size=24),\n Text(\"Rotation changes the direction of overlap in bonding pictures.\", font_size=22, color=GRAY_C),\n ).arrange(DOWN, buff=0.16).to_edge(DOWN)\n self.play(FadeIn(title), FadeIn(left_orbital), FadeIn(left_label), FadeIn(plus_minus[:2]), run_time=3)\n self.play(Create(arrow), TransformFromCopy(left_orbital, right_orbital), FadeIn(right_label), FadeIn(plus_minus[2:]), run_time=5)\n self.play(Rotate(right_orbital, angle=PI / 2), plus_minus[2:].animate.rotate(PI / 2, about_point=right_orbital.get_center()), run_time=4)\n self.play(FadeIn(caption), Indicate(left_orbital, color=BLUE_A), Indicate(right_orbital, color=GREEN_A), run_time=4)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass OrbitalPhaseRotation(Scene):\n def construct(self):\n title = Text(\"Orbital Phase and Orientation\", font_size=34).to_edge(UP)\n left_orbital = VGroup(\n Ellipse(width=1.2, height=2.1, stroke_color=BLUE_D, fill_color=BLUE_C, fill_opacity=0.32).shift(UP * 1.1),\n Ellipse(width=1.2, height=2.1, stroke_color=RED_D, fill_color=RED_C, fill_opacity=0.32).shift(DOWN * 1.1),\n DashedLine(LEFT * 1.6, RIGHT * 1.6, color=GRAY_C),\n ).move_to(LEFT * 3.1)\n right_orbital = left_orbital.copy().rotate(PI / 2).move_to(RIGHT * 3.1)\n left_label = Text(\"vertical orientation\", font_size=22).next_to(left_orbital, DOWN)\n right_label = Text(\"horizontal orientation\", font_size=22).next_to(right_orbital, DOWN)\n plus_minus = VGroup(\n MathText(\"+\", color=BLUE_D).move_to(left_orbital[0]),\n MathTex(\"-\", color=RED_D).move_to(left_orbital[1]),\n MathTex(\"+\", color=BLUE_D).move_to(right_orbital[0]),\n MathTex(\"-\", color=RED_D).move_to(right_orbital[1]),\n )\n arrow = CurvedArrow(left_orbital.get_right() + RIGHT * 0.2, right_orbital.get_left() + LEFT * 0.2, angle=-PI / 2, color=YELLOW_D)\n caption = VGroup(\n Text(\"The sign pattern stays paired to the lobe orientation.\", font_size=24),\n Text(\"Rotation changes the direction of overlap in bonding pictures.\", font_size=22, color=GRAY_C),\n ).arrange(DOWN, buff=0.16).to_edge(DOWN)\n self.play(FadeIn(title), FadeIn(left_orbital), FadeIn(left_label), FadeIn(plus_minus[:2]), run_time=3)\n self.play(Create(arrow), TransformFromCopy(left_orbital, right_orbital), FadeIn(right_label), FadeIn(plus_minus[2:]), run_time=5)\n self.play(Rotate(right_orbital, angle=PI / 2), plus_minus[2:].animate.rotate(PI / 2, about_point=right_orbital.get_center()), run_time=4)\n self.play(FadeIn(caption), Indicate(left_orbital, color=BLUE_A), Indicate(right_orbital, color=GREEN_A), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 walks through the steps of calculating a basic definite integral of x^2 from 0 to 1, including writing out the problem, using the power rule for integration, evaluating the limits, and presenting the simplified final solution, all accompanied by relevant explanations and pauses between each step for clarity?", "chosen": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # Color configuration for pedagogical clarity\n COLOR_FUNC = BLUE\n COLOR_LIMITS = RED\n COLOR_RESULT = GREEN\n COLOR_TEXT = WHITE\n\n # --- Step 1: Problem Statement ---\n # Voiceover: \"Let's calculate the definite integral of x squared from 0 to 1.\"\n title = Text(\"Definite Integral Calculation\", font_size=36)\n title.to_edge(UP)\n \n problem = MathTex(r\"\\int_{0}^{1}\", \"x^2\", r\"\\, dx\").scale(1.5)\n problem.set_color_by_tex(\"x^2\", COLOR_FUNC)\n problem.set_color_by_tex(\"0\", COLOR_LIMITS)\n problem.set_color_by_tex(\"1\", COLOR_LIMITS)\n \n explanation_1 = Text(\"Step 1: Identify the integral problem.\", font_size=24, color=COLOR_TEXT)\n explanation_1.next_to(problem, DOWN, buff=0.5)\n\n self.play(Write(title))\n self.wait(0.5)\n self.play(Write(problem), Write(explanation_1))\n self.wait(2)\n self.play(FadeOut(explanation_1))\n\n # --- Step 2: Integration Rule ---\n # Voiceover: \"Using the Power Rule, the antiderivative of x squared is x cubed over 3.\"\n rule_text = Text(\"Step 2: Apply Power Rule: \\int xⁿ dx = xⁿ⁺¹/(n+1)\", font_size=24, color=COLOR_TEXT)\n rule_text.next_to(problem, DOWN, buff=0.5)\n \n antiderivative = MathTex(r\"\\left[\", r\"\\frac{x^3}{3}\", r\"\\right]_{0}^{1}\").scale(1.5)\n antiderivative.set_color_by_tex(\"x^3\", COLOR_FUNC)\n antiderivative.set_color_by_tex(\"0\", COLOR_LIMITS)\n antiderivative.set_color_by_tex(\"1\", COLOR_LIMITS)\n \n self.play(Write(rule_text))\n self.wait(1)\n self.play(TransformMatchingTex(problem, antiderivative), FadeOut(rule_text))\n self.wait(2)\n\n # --- Step 3: Evaluation ---\n # Voiceover: \"Evaluate at the upper limit 1 and subtract the value at the lower limit 0.\"\n eval_text = Text(\"Step 3: Substitute upper and lower limits.\", font_size=24, color=COLOR_TEXT)\n eval_text.next_to(antiderivative, DOWN, buff=0.5)\n \n substitution = MathTex(r\"\\left(\", r\"\\frac{1^3}{3}\", r\"\\right)\", \"-\", r\"\\left(\", r\"\\frac{0^3}{3}\", r\"\\right)\").scale(1.5)\n substitution.set_color_by_tex(\"1\", COLOR_LIMITS)\n substitution.set_color_by_tex(\"0\", COLOR_LIMITS)\n \n self.play(Write(eval_text))\n self.wait(1)\n self.play(TransformMatchingTex(antiderivative, substitution), FadeOut(eval_text))\n self.wait(2)\n\n # --- Step 4: Final Solution ---\n # Voiceover: \"Simplifying gives us the final result: one third.\"\n solution_text = Text(\"Step 4: Simplify to find the final result.\", font_size=24, color=COLOR_TEXT)\n solution_text.next_to(substitution, DOWN, buff=0.5)\n \n final_result = MathTex(r\"\\frac{1}{3}\").scale(1.5)\n final_result.set_color(COLOR_RESULT)\n \n self.play(Write(solution_text))\n self.wait(1)\n self.play(TransformMatchingTex(substitution, final_result), FadeOut(solution_text))\n self.wait(1)\n \n # Highlight final result\n box = SurroundingRectangle(final_result, color=COLOR_RESULT, buff=0.3)\n self.play(Create(box), Indicate(final_result))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralCalculation(Scene):\n def construct(self):\n # Color configuration for pedagogical clarity\n COLOR_FUNC = BBLUE\n COLOR_LIMITS = RED\n COLOR_RESULT = GREEN\n COLOR_TEXT = WHITE\n\n # --- Step 1: Problem Statement ---\n # Voiceover: \"Let's calculate the definite integral of x squared from 0 to 1.\"\n title = Text(\"Definite Integral Calculation\", font_size=36)\n title.to_edge(UP)\n \n problem = MathTex(r\"\\int_{0}^{1}\", \"x^2\", r\"\\, dx\").scale(1.5)\n problem.set_color_by_tex(\"x^2\", COLOR_FUNC)\n problem.set_color_by_tex(\"0\", COLOR_LIMITS)\n problem.set_color_by_tex(\"1\", COLOR_LIMITS)\n \n explanation_1 = Text(\"Step 1: Identify the integral problem.\", font_size=24, color=COLOR_TEXT)\n explanation_1.next_to(problem, DOWN, buff=0.5)\n\n self.play(Write(title))\n self.wait(0.5)\n self.play(Write(problem), Write(explanation_1))\n self.wait(2)\n self.play(FadeOut(explanation_1))\n\n # --- Step 2: Integration Rule ---\n # Voiceover: \"Using the Power Rule, the antiderivative of x squared is x cubed over 3.\"\n rule_text = Text(\"Step 2: Apply Power Rule: \\int xⁿ dx = xⁿ⁺¹/(n+1)\", font_size=24, color=COLOR_TEXT)\n rule_text.next_to(problem, DOWN, buff=0.5)\n \n antiderivative = MathTex(r\"\\left[\", r\"\\frac{x^3}{3}\", r\"\\right]_{0}^{1}\").scale(1.5)\n antiderivative.set_color_by_tex(\"x^3\", COLOR_FUNC)\n antiderivative.set_color_by_tex(\"0\", COLOR_LIMITS)\n antiderivative.set_color_by_tex(\"1\", COLOR_LIMITS)\n \n self.play(Write(rule_text))\n self.wait(1)\n self.play(TransformMatchingTex(problem, antiderivative), FadeOut(rule_text))\n self.wait(2)\n\n # --- Step 3: Evaluation ---\n # Voiceover: \"Evaluate at the upper limit 1 and subtract the value at the lower limit 0.\"\n eval_text = Text(\"Step 3: Substitute upper and lower limits.\", font_size=24, color=COLOR_TEXT)\n eval_text.next_to(antiderivative, DOWN, buff=0.5)\n \n substitution = MathTex(r\"\\left(\", r\"\\frac{1^3}{3}\", r\"\\right)\", \"-\", r\"\\left(\", r\"\\frac{0^3}{3}\", r\"\\right)\").scale(1.5)\n substitution.set_color_by_tex(\"1\", COLOR_LIMITS)\n substitution.set_color_by_tex(\"0\", COLOR_LIMITS)\n \n self.play(Write(eval_text))\n self.wait(1)\n self.play(TransformMatchingTex(antiderivative, substitution), FadeOut(eval_text))\n self.wait(2)\n\n # --- Step 4: Final Solution ---\n # Voiceover: \"Simplifying gives us the final result: one third.\"\n solution_text = Text(\"Step 4: Simplify to find the final result.\", font_size=24, color=COLOR_TEXT)\n solution_text.next_to(substitution, DOWN, buff=0.5)\n \n final_result = MathTex(r\"\\frac{1}{3}\").scale(1.5)\n final_result.set_color(COLOR_RESULT)\n \n self.play(Write(solution_text))\n self.wait(1)\n self.play(TransformMatchingTex(substitution, final_result), FadeOut(solution_text))\n self.wait(1)\n \n # Highlight final result\n box = SurroundingRectangle(final_result, color=COLOR_RESULT, buff=0.3)\n self.play(Create(box), Indicate(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a series of educational science animations using the ManimCE library. Firstly, can you make a grid showing a collection of hydrogen atom symbols, with alternating isotopes of hydrogen denoting Deuterium for every other row, where the isotopes differ by having 'D' with the subscript '2' and regular hydrogen having 'H' with the subscript '1'? The grid should have 5 rows and 7 columns, with each atom represented by a different colored circle and with the symbol inside, and the animation should introduce the grid of atoms on the screen.\n\nSecondly, can you create an animation of an electron depicted as a yellow circle, transitioning between energy levels? We'd like the electron to move along a semi-circular path above and below its initial position, kind of like it's jumping up to a higher energy state and then falling back down.\n\nLastly, I am interested in an animation showing a single proton. It has to be a red circle with the label 'p+' to indicate a proton. It should fade into view, then move upwards and afterwards move back down, as if it's oscillating up and down along the vertical axis.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass HydrogenIsotopeGrid(Scene):\n def construct(self):\n rows, cols = 5, 7\n x_spacing, y_spacing = 1.2, 1.2\n grid_group = VGroup()\n \n for r in range(rows):\n for c in range(cols):\n # Alternate isotopes by row\n if r % 2 == 0:\n label = MathTex(\"H_1\", font_size=36)\n color = BLUE_C\n else:\n label = MathTex(\"D_2\", font_size=36)\n color = TEAL\n \n # Create atom as a colored circle with a symbol\n atom_circle = Circle(radius=0.5, color=color, fill_opacity=0.8)\n label.move_to(atom_circle.get_center())\n atom = VGroup(atom_circle, label)\n \n # Calculate centered grid position\n x_pos = (c - (cols - 1) / 2) * x_spacing\n y_pos = ((rows - 1) / 2 - r) * y_spacing\n atom.move_to([x_pos, y_pos, 0])\n \n grid_group.add(atom)\n \n # Animation: Introduce the grid\n self.play(FadeIn(grid_group, shift=UP), run_time=2)\n self.wait(1)\n\nclass ElectronEnergyTransition(Scene):\n def construct(self):\n # Contextual energy levels\n n1 = Circle(radius=1, color=GRAY).set_stroke(opacity=0.5)\n n2 = Circle(radius=2, color=GRAY).set_stroke(opacity=0.5)\n self.add(n1, n2)\n \n # Electron represented as a yellow circle\n electron = Circle(radius=0.15, color=YELLOW, fill_opacity=1)\n electron.move_to(n1.point_at_angle(0))\n self.add(electron)\n \n # Define parametric paths for vertical semi-circular jumps\n # Excitation: semi-circle from ground state to higher energy level\n def path_up(alpha):\n angle = PI * alpha\n x = np.sin(angle) * 1.0\n y = 1.0 - np.cos(angle)\n return np.array([x, y, 0])\n \n # Relaxation: semi-circle from higher energy level back to ground state\n def path_down(alpha):\n angle = PI * alpha\n x = -np.sin(angle) * 1.0\n y = 2.0 - (1.0 - np.cos(angle))\n return np.array([x, y, 0])\n\n path_obj_up = ParametricFunction(path_up, t_range=[0, 1], color=WHITE, stroke_opacity=0)\n path_obj_down = ParametricFunction(path_down, t_range=[0, 1], color=WHITE, stroke_opacity=0)\n \n # Animation Sequence\n self.play(MoveAlongPath(electron, path_obj_up), run_time=1.5, rate_func=smooth)\n self.wait(0.5)\n self.play(MoveAlongPath(electron, path_obj_down), run_time=1.5, rate_func=smooth)\n self.wait(1)\n\nclass ProtonOscillation(Scene):\n def construct(self):\n # Depict proton as a red circle labeled 'p+'\n proton_circle = Circle(radius=0.4, color=RED, fill_opacity=0.8)\n proton_label = MathTex(\"p^+\", font_size=48, color=WHITE)\n proton_label.move_to(proton_circle.get_center())\n proton = VGroup(proton_circle, proton_label)\n proton.move_to(ORIGIN)\n \n # Animation Sequence\n # 1. Fade the proton into view\n self.play(FadeIn(proton), run_time=1)\n self.wait(0.5)\n \n # 2. Move it upwards along the vertical axis\n shift_distance = 2.0\n self.play(proton.animate.shift(UP * shift_distance), run_time=1.5, rate_func=smooth)\n self.wait(0.5)\n \n # 3. Move it back downwards to original position (oscillation)\n self.play(proton.animate.shift(DOWN * shift_distance), run_time=1.5, rate_func=smooth)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass HydrogenIsotopeGrid(Scene):\n def construct(self):\n rows, cols = 5, 7\n x_spacing, y_spacing = 1.2, 1.2\n grid_group = VGroup()\n \n for r in range(rows):\n for c in range(cols):\n # Alternate isotopes by row\n if r % 2 == 0:\n label = MathTex(\"H_1\", font_size=36)\n color = BBLUE_C\n else:\n label = MathTex(\"D_2\", font_size=36)\n color = TEAL\n \n # Create atom as a colored circle with a symbol\n atom_circle = Circle(radius=0.5, color=color, fill_opacity=0.8)\n label.move_to(atom_circle.get_center())\n atom = VGroup(atom_circle, label)\n \n # Calculate centered grid position\n x_pos = (c - (cols - 1) / 2) * x_spacing\n y_pos = ((rows - 1) / 2 - r) * y_spacing\n atom.move_to([x_pos, y_pos, 0])\n \n grid_group.add(atom)\n \n # Animation: Introduce the grid\n self.play(FadeIn(grid_group, shift=UP), run_time=2)\n self.wait(1)\n\nclass ElectronEnergyTransition(Scene):\n def construct(self):\n # Contextual energy levels\n n1 = Circle(radius=1, color=GRAY).set_stroke(opacity=0.5)\n n2 = Circle(radius=2, color=GRAY).set_stroke(opacity=0.5)\n self.add(n1, n2)\n \n # Electron represented as a yellow circle\n electron = Circle(radius=0.15, color=YELLOW, fill_opacity=1)\n electron.move_to(n1.point_at_angle(0))\n self.add(electron)\n \n # Define parametric paths for vertical semi-circular jumps\n # Excitation: semi-circle from ground state to higher energy level\n def path_up(alpha):\n angle = PI * alpha\n x = np.sin(angle) * 1.0\n y = 1.0 - np.cos(angle)\n return np.array([x, y, 0])\n \n # Relaxation: semi-circle from higher energy level back to ground state\n def path_down(alpha):\n angle = PI * alpha\n x = -np.sin(angle) * 1.0\n y = 2.0 - (1.0 - np.cos(angle))\n return np.array([x, y, 0])\n\n path_obj_up = ParametricFunction(path_up, t_range=[0, 1], color=WHITE, stroke_opacity=0)\n path_obj_down = ParametricFunction(path_down, t_range=[0, 1], color=WHITE, stroke_opacity=0)\n \n # Animation Sequence\n self.play(MoveAlongPath(electron, path_obj_up), run_time=1.5, rate_func=smooth)\n self.wait(0.5)\n self.play(MoveAlongPath(electron, path_obj_down), run_time=1.5, rate_func=smooth)\n self.wait(1)\n\nclass ProtonOscillation(Scene):\n def construct(self):\n # Depict proton as a red circle labeled 'p+'\n proton_circle = Circle(radius=0.4, color=RED, fill_opacity=0.8)\n proton_label = MathTex(\"p^+\", font_size=48, color=WHITE)\n proton_label.move_to(proton_circle.get_center())\n proton = VGroup(proton_circle, proton_label)\n proton.move_to(ORIGIN)\n \n # Animation Sequence\n # 1. Fade the proton into view\n self.play(FadeIn(proton), run_time=1)\n self.wait(0.5)\n \n # 2. Move it upwards along the vertical axis\n shift_distance = 2.0\n self.play(proton.animate.shift(UP * shift_distance), run_time=1.5, rate_func=smooth)\n self.wait(0.5)\n \n # 3. Move it back downwards to original position (oscillation)\n self.play(proton.animate.shift(DOWN * shift_distance), run_time=1.5, rate_func=smooth)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 how to calculate the area under the curve of y = x^2 from x = 0 to x = 2? I'd like to see a coordinate system with labeled axes and the curve graphed in green. Then, can you show the area under the curve shaded in green with a lower opacity, and have an integral symbol with the limits and the function appear in the upper right corner? Following that, display the result of the integral as a calculation next to the integral symbol, first showing the formula for the antiderivative evaluated at the boundaries, and then the final numerical answer. The process should unfold step-by-step with the mathematical expressions written out as they would be on a blackboard, and each step should remain on screen for a couple of seconds before moving to the next.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup Coordinate System\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_exclude\": [0],\n },\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the function y = x^2 in Green\n curve = axes.plot(lambda x: x**2, color=GREEN, x_range=[0, 2.5])\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\", x_val=2.2, direction=UR)\n\n # 3. Define the Shaded Area under the curve (Green with lower opacity)\n area = axes.get_area(\n curve, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.3\n )\n\n # 4. Prepare Mathematical Expressions\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\")\n step1_expr = MathTex(r\"=\\left[\\frac{x^3}{3}\\right]_{0}^{2}\")\n step2_expr = MathTex(r\"=\\frac{2^3}{3} - \\frac{0^3}{3}\")\n step3_expr = MathTex(r\"=\\frac{8}{3}\")\n\n # Group and position the calculation steps in the upper right corner\n calc_group = VGroup(integral_expr, step1_expr, step2_expr, step3_expr)\n calc_group.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n calc_group.to_corner(UR, buff=1.0)\n\n # --- Animation Sequence ---\n\n # Step 1: Introduce axes and the green curve\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(2)\n\n # Step 2: Reveal the shaded area\n self.play(FadeIn(area))\n self.wait(2)\n\n # Step 3: Display the integral notation\n self.play(Write(integral_expr))\n self.wait(2)\n\n # Step 4: Show calculation steps sequentially\n \n # Display the antiderivative evaluated at the boundaries\n self.play(Write(step1_expr))\n self.wait(2)\n\n # Display the substitution of the boundaries\n self.play(Write(step2_expr))\n self.wait(2)\n\n # Reveal the final numerical answer\n self.play(Write(step3_expr))\n self.wait(2)\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=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n axis_config={\n \"include_tip\": True,\n \"numbers_to_exclude\": [0],\n },\n x_axis_config={\"numbers_to_include\": [1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n ).add_coordinates()\n \n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Plot the function y = x^2 in Green\n curve = axes.plot(lambda x: x**2, color=GREEN, x_range=[0, 2.5])\n curve_label = axes.get_graph_label(curve, label=\"y = x^2\", x_val=2.2, direction=UR)\n\n # 3. Define the Shaded Area under the curve (Green with lower opacity)\n area = axes.get_area(\n curve, \n x_range=[0, 2], \n color=GREEN, \n opacity=0.3\n )\n\n # 4. Prepare Mathematical Expressions\n integral_expr = MathText(r\"\\int_{0}^{2} x^2 \\, dx\")\n step1_expr = MathTex(r\"=\\left[\\frac{x^3}{3}\\right]_{0}^{2}\")\n step2_expr = MathTex(r\"=\\frac{2^3}{3} - \\frac{0^3}{3}\")\n step3_expr = MathTex(r\"=\\frac{8}{3}\")\n\n # Group and position the calculation steps in the upper right corner\n calc_group = VGroup(integral_expr, step1_expr, step2_expr, step3_expr)\n calc_group.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n calc_group.to_corner(UR, buff=1.0)\n\n # --- Animation Sequence ---\n\n # Step 1: Introduce axes and the green curve\n self.play(Create(axes), Write(labels))\n self.play(Create(curve), Write(curve_label))\n self.wait(2)\n\n # Step 2: Reveal the shaded area\n self.play(FadeIn(area))\n self.wait(2)\n\n # Step 3: Display the integral notation\n self.play(Write(integral_expr))\n self.wait(2)\n\n # Step 4: Show calculation steps sequentially\n \n # Display the antiderivative evaluated at the boundaries\n self.play(Write(step1_expr))\n self.wait(2)\n\n # Display the substitution of the boundaries\n self.play(Write(step2_expr))\n self.wait(2)\n\n # Reveal the final numerical answer\n self.play(Write(step3_expr))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralPowerRule(Scene):\n \"\"\"\n Educational animation demonstrating the evaluation of the definite integral\n of x^3 from 0 to 2 using the power rule for integration.\n \n To run this animation:\n 1. Save this code in a file named 'integral_animation.py'.\n 2. Run the command: manim -pql integral_animation.py DefiniteIntegralPowerRule\n \"\"\"\n def construct(self):\n # ----------------------------------------------------------------------\n # Step 1: Introduction & Problem Statement\n # ----------------------------------------------------------------------\n # Create a title for context\n title = Text(\"Evaluating a Definite Integral\", font_size=36).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Define the original integral expression: \\int _0^2 x^3 dx\n # Color the limits to help students track them during substitution\n original_integral = MathTex(r\"\\int_0^2 x^3 \\, dx\").scale(1.5)\n original_integral.set_color_by_tex(\"0\", BLUE)\n original_integral.set_color_by_tex(\"2\", GREEN)\n original_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(original_integral))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # Step 2: Apply the Power Rule for Integration\n # ----------------------------------------------------------------------\n # Display the rule being applied\n rule_hint = MathTex(r\"\\text{Power Rule: } \\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=28, color=YELLOW)\n rule_hint.next_to(original_integral, DOWN, buff=0.5)\n self.play(Write(rule_hint))\n self.wait(1)\n\n # Define the antiderivative expression: [x^4 / 4]_0^2\n # n=3, so n+1=4. We divide by 4. Maintain color coding for limits.\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^2\").scale(1.5)\n antiderivative.set_color_by_tex(\"0\", BLUE)\n antiderivative.set_color_by_tex(\"2\", GREEN)\n antiderivative.move_to(original_integral)\n\n # Transform the integral into the antiderivative notation\n self.play(TransformMatchingTex(original_integral, antiderivative))\n self.wait(1)\n self.play(FadeOut(rule_hint))\n\n # ----------------------------------------------------------------------\n # Step 3: Substitute the Limits of Integration\n # ----------------------------------------------------------------------\n # Display hint for the Fundamental Theorem of Calculus step\n subst_hint = Text(\"Substitute limits: F(b) - F(a)\", font_size=24, color=BLUE)\n subst_hint.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(subst_hint))\n self.wait(1)\n\n # Define the substitution expression: (2^4 / 4) - (0^4 / 4)\n substitution = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\").scale(1.5)\n substitution.set_color_by_tex(\"0\", BLUE)\n substitution.set_color_by_tex(\"2\", GREEN)\n substitution.move_to(antiderivative)\n\n # Animate the substitution of limits\n self.play(TransformMatchingTex(antiderivative, substitution))\n self.wait(1)\n self.play(FadeOut(subst_hint))\n\n # ----------------------------------------------------------------------\n # Step 4: Simplify the Arithmetic\n # ----------------------------------------------------------------------\n # Calculate 2^4 = 16 and 0^4 = 0\n simplified_arithmetic = MathTex(r\"\\frac{16}{4} - 0\").scale(1.5)\n simplified_arithmetic.move_to(substitution)\n\n # Transform to show the calculated powers\n self.play(TransformMatchingTex(substitution, simplified_arithmetic))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # Step 5: Final Result\n # ----------------------------------------------------------------------\n # Calculate 16/4 = 4\n final_result = MathTex(r\"4\").scale(2).set_color(YELLOW)\n final_result.move_to(simplified_arithmetic)\n\n # Transform to the final numerical answer\n self.play(TransformMatchingTex(simplified_arithmetic, final_result))\n \n # Add a box around the result to emphasize it\n box = SurroundingRectangle(final_result, color=GREEN, buff=0.3)\n self.play(Create(box))\n \n # Hold the final scene for observation\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralPowerRule(Scene):\n \"\"\"\n Educational animation demonstrating the evaluation of the definite integral\n of x^3 from 0 to 2 using the power rule for integration.\n \n To run this animation:\n 1. Save this code in a file named 'integral_animation.py'.\n 2. Run the command: manim -pql integral_animation.py DefiniteIntegralPowerRule\n \"\"\"\n def construct(self):\n # ----------------------------------------------------------------------\n # Step 1: Introduction & Problem Statement\n # ----------------------------------------------------------------------\n # Create a title for context\n title = Text(\"Evaluating a Definite Integral\", font_size=36).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Define the original integral expression: \\int _0^2 x^3 dx\n # Color the limits to help students track them during substitution\n original_integral = MathText(r\"\\int_0^2 x^3 \\, dx\").scale(1.5)\n original_integral.set_color_by_tex(\"0\", BLUE)\n original_integral.set_color_by_tex(\"2\", GREEN)\n original_integral.next_to(title, DOWN, buff=1)\n \n self.play(Write(original_integral))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # Step 2: Apply the Power Rule for Integration\n # ----------------------------------------------------------------------\n # Display the rule being applied\n rule_hint = MathTex(r\"\\text{Power Rule: } \\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", font_size=28, color=YELLOW)\n rule_hint.next_to(original_integral, DOWN, buff=0.5)\n self.play(Write(rule_hint))\n self.wait(1)\n\n # Define the antiderivative expression: [x^4 / 4]_0^2\n # n=3, so n+1=4. We divide by 4. Maintain color coding for limits.\n antiderivative = MathTex(r\"\\left[ \\frac{x^4}{4} \\right]_0^2\").scale(1.5)\n antiderivative.set_color_by_tex(\"0\", BLUE)\n antiderivative.set_color_by_tex(\"2\", GREEN)\n antiderivative.move_to(original_integral)\n\n # Transform the integral into the antiderivative notation\n self.play(TransformMatchingTex(original_integral, antiderivative))\n self.wait(1)\n self.play(FadeOut(rule_hint))\n\n # ----------------------------------------------------------------------\n # Step 3: Substitute the Limits of Integration\n # ----------------------------------------------------------------------\n # Display hint for the Fundamental Theorem of Calculus step\n subst_hint = Text(\"Substitute limits: F(b) - F(a)\", font_size=24, color=BLUE)\n subst_hint.next_to(antiderivative, DOWN, buff=0.5)\n self.play(Write(subst_hint))\n self.wait(1)\n\n # Define the substitution expression: (2^4 / 4) - (0^4 / 4)\n substitution = MathTex(r\"\\frac{2^4}{4} - \\frac{0^4}{4}\").scale(1.5)\n substitution.set_color_by_tex(\"0\", BLUE)\n substitution.set_color_by_tex(\"2\", GREEN)\n substitution.move_to(antiderivative)\n\n # Animate the substitution of limits\n self.play(TransformMatchingTex(antiderivative, substitution))\n self.wait(1)\n self.play(FadeOut(subst_hint))\n\n # ----------------------------------------------------------------------\n # Step 4: Simplify the Arithmetic\n # ----------------------------------------------------------------------\n # Calculate 2^4 = 16 and 0^4 = 0\n simplified_arithmetic = MathTex(r\"\\frac{16}{4} - 0\").scale(1.5)\n simplified_arithmetic.move_to(substitution)\n\n # Transform to show the calculated powers\n self.play(TransformMatchingTex(substitution, simplified_arithmetic))\n self.wait(1)\n\n # ----------------------------------------------------------------------\n # Step 5: Final Result\n # ----------------------------------------------------------------------\n # Calculate 16/4 = 4\n final_result = MathTex(r\"4\").scale(2).set_color(YELLOW)\n final_result.move_to(simplified_arithmetic)\n\n # Transform to the final numerical answer\n self.play(TransformMatchingTex(simplified_arithmetic, final_result))\n \n # Add a box around the result to emphasize it\n box = SurroundingRectangle(final_result, color=GREEN, buff=0.3)\n self.play(Create(box))\n \n # Hold the final scene for observation\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visual appeal: \n\nThe animation begins by transforming the existing text into \"ShowSubmobjectsOneByOne\" at the top of the screen. Below it, three circles appear sequentially using `ShowSubmobjectsOneByOne`, positioned in a triangular formation (one above and two below). After all circles are visible, a new feature is introduced: a mathematical formula (e.g., \\( VGroup = \\{C_1, C_2, C_3\\} \\)) fades in beside the circles, explaining the concept of a `VGroup` as a container for multiple objects. The circles then pulse gently (using `Succession` with `ScaleInPlace` animations) to emphasize their grouping before finally being unmade in reverse order. Additionally, a brief explanatory text (\"Objects appear one by one, then vanish\") appears at the bottom, fading in and out to reinforce the animation's purpose. This enhanced version maintains the original structure while adding educational context and dynamic visual feedback.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedShowSubmobjects(Scene):\n def construct(self):\n # Title transformation\n title = Text(\"ShowSubmobjectsOneByOne\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create three circles in a triangular formation\n circle1 = Circle(color=BLUE).shift(UP)\n circle2 = Circle(color=RED).shift(DOWN + LEFT)\n circle3 = Circle(color=GREEN).shift(DOWN + RIGHT)\n circles = VGroup(circle1, circle2, circle3)\n\n # Show circles one by one\n self.play(ShowSubmobjectsOneByOne(circles))\n self.wait(0.5)\n\n # Display VGroup formula\n formula = MathTex(\"VGroup = \\\\{C_1, C_2, C_3\\\\}\").next_to(circles, RIGHT)\n self.play(FadeIn(formula))\n self.wait(1)\n\n # Pulse circles to emphasize grouping\n self.play(\n Succession(\n *[ScaleInPlace(circle, 1.2) for circle in circles],\n lag_ratio=0.2\n )\n )\n self.wait(0.5)\n\n # Add explanatory text\n explanation = Text(\"Objects appear one by one, then vanish\").to_edge(DOWN)\n self.play(FadeIn(explanation))\n self.wait(1)\n self.play(FadeOut(explanation))\n\n # Unmake circles in reverse order\n self.play(Uncreate(circles[::-1]))\n self.wait(0.5)\n\n # Fade out remaining elements\n self.play(FadeOut(title), FadeOut(formula))\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShowSubmobjects(Scene):\n def construct(self):\n # Title transformation\n title = Text(\"ShowSubmobjectsOneByOne\").to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # Create three circles in a triangular formation\n circle1 = Circle(color=BLUE).shift(UP)\n circle2 = Circle(color=RED).shift(DOWN + LEFT)\n circle3 = Circle(color=GREEN).shift(DOWN + RIGHT)\n circles = VGroup(circle1, circle2, circle3)\n\n # Show circles one by one\n self.play(ShowSubmobjectsOneByOne(circles))\n self.wait(0.5)\n\n # Display VGroup formula\n formula = MathText(\"VGroup = \\\\{C_1, C_2, C_3\\\\}\").next_to(circles, RIGHT)\n self.play(FadeIn(formula))\n self.wait(1)\n\n # Pulse circles to emphasize grouping\n self.play(\n Succession(\n *[ScaleInPlace(circle, 1.2) for circle in circles],\n lag_ratio=0.2\n )\n )\n self.wait(0.5)\n\n # Add explanatory text\n explanation = Text(\"Objects appear one by one, then vanish\").to_edge(DOWN)\n self.play(FadeIn(explanation))\n self.wait(1)\n self.play(FadeOut(explanation))\n\n # Unmake circles in reverse order\n self.play(Uncreate(circles[::-1]))\n self.wait(0.5)\n\n # Fade out remaining elements\n self.play(FadeOut(title), FadeOut(formula))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Cell Stores a Set of Non-Terminals\nEach cell is a set (Set) that may contain zero, one, or multiple non-terminals.\n\n\nThe context location of this section (from highest to current level):\n# Converting Context-Free Grammars to Standard Form and Solving Algorithmically\n## Table Structure of the CYK Algorithm\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CYKCellStructure(Scene):\n\n def construct(self):\n title = Text('Table Structure of the CYK Algorithm', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n subtitle = Text('Cell Stores a Set of Non-Terminals', font_size=32, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title), FadeIn(subtitle))\n table = VGroup()\n n = 5\n for i in range(n):\n row = VGroup(*[Square(side_length=0.9) for _ in range(n - i)])\n row.arrange(RIGHT, buff=0)\n table.add(row)\n else:\n pass\n table.arrange(DOWN, buff=0)\n for i in range(1, n):\n table[i].align_to(table[0], LEFT)\n else:\n pass\n table.move_to(LEFT * 3.5 + DOWN * 0.5)\n self.play(Create(table), run_time=2)\n target_cell = table[2][1]\n highlight = target_cell.copy().set_color(YELLOW).set_fill(YELLOW, opacity=0.3)\n self.play(FadeIn(highlight))\n explanation = Paragraph('Each cell is a Set that may contain', 'zero, one, or multiple non-terminals.', font_size=28, alignment='left')\n explanation.next_to(table, RIGHT, buff=1.2).align_to(table, UP).shift(DOWN * 0.2)\n self.play(Write(explanation))\n ex_zero = MathTex('\\\\emptyset \\\\quad \\\\text{(Zero non-terminals)}', font_size=32)\n ex_one = MathTex('\\\\{A\\\\} \\\\quad \\\\text{(One non-terminal)}', font_size=32)\n ex_multi = MathTex('\\\\{A, B, C\\\\} \\\\quad \\\\text{(Multiple)}', font_size=32)\n examples = VGroup(ex_zero, ex_one, ex_multi).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n examples.next_to(explanation, DOWN, buff=0.8).align_to(explanation, LEFT)\n arrow = Arrow(start=target_cell.get_right() + RIGHT * 0.1, end=examples.get_left() + LEFT * 0.3, buff=0.1, color=YELLOW)\n self.play(GrowArrow(arrow))\n cell_content = MathTex('\\\\emptyset', font_size=36, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_zero), Write(cell_content))\n self.wait(1)\n cell_content_one = MathTex('\\\\{A\\\\}', font_size=32, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_one), Transform(cell_content, cell_content_one))\n self.wait(1)\n cell_content_multi = MathTex('\\\\{A, B\\\\}', font_size=26, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_multi), Transform(cell_content, cell_content_multi))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CYKCellStructure(Scene):\n\n def construct(self):\n title = Text('Table Structure of the CYK Algorithm', font_size=40, weight=BOLD)\n title.to_edge(UP, buff=0.4)\n subtitle = Text('Cell Stores a Set of Non-Terminals', font_size=32, color=BLUE)\n subtitle.next_to(title, DOWN, buff=0.2)\n self.play(Write(title), FadeIn(subtitle))\n table = VGroup()\n n = 5\n for i in range(n):\n row = VGroup(*[Square(side_length=0.9) for _ in range(n - i)])\n row.arrange(RIGHT, buff=0)\n table.add(row)\n else:\n pass\n table.arrange(DOWN, buff=0)\n for i in range(1, n):\n table[i].align_to(table[0], LEFT)\n else:\n pass\n table.move_to(LEFT * 3.5 + DOWN * 0.5)\n self.play(Create(table), run_time=2)\n target_cell = table[2][1]\n highlight = target_cell.copy().set_color(YELLOW).set_fill(YELLOW, opacity=0.3)\n self.play(FadeIn(highlight))\n explanation = Paragraph('Each cell is a Set that may contain', 'zero, one, or multiple non-terminals.', font_size=28, alignment='left')\n explanation.next_to(table, RIGHT, buff=1.2).align_to(table, UP).shift(DOWN * 0.2)\n self.play(Write(explanation))\n ex_zero = MathText('\\\\emptyset \\\\quad \\\\text{(Zero non-terminals)}', font_size=32)\n ex_one = MathTex('\\\\{A\\\\} \\\\quad \\\\text{(One non-terminal)}', font_size=32)\n ex_multi = MathTex('\\\\{A, B, C\\\\} \\\\quad \\\\text{(Multiple)}', font_size=32)\n examples = VGroup(ex_zero, ex_one, ex_multi).arrange(DOWN, aligned_edge=LEFT, buff=0.6)\n examples.next_to(explanation, DOWN, buff=0.8).align_to(explanation, LEFT)\n arrow = Arrow(start=target_cell.get_right() + RIGHT * 0.1, end=examples.get_left() + LEFT * 0.3, buff=0.1, color=YELLOW)\n self.play(GrowArrow(arrow))\n cell_content = MathTex('\\\\emptyset', font_size=36, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_zero), Write(cell_content))\n self.wait(1)\n cell_content_one = MathTex('\\\\{A\\\\}', font_size=32, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_one), Transform(cell_content, cell_content_one))\n self.wait(1)\n cell_content_multi = MathTex('\\\\{A, B\\\\}', font_size=26, color=YELLOW).move_to(target_cell.get_center())\n self.play(FadeIn(ex_multi), Transform(cell_content, cell_content_multi))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 magic squares be extended to include negative numbers, and how does this affect their properties and potential configurations?", "chosen": "```python\nfrom manim import *\n\nclass NegativeMagicSquares(Scene):\n def construct(self):\n # Title\n title = Text(\"Unveiling Negative Magic: Extending Magic Squares\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Create the classic 3x3 magic square\n square = VGroup()\n square_size = 0.8\n for i in range(3):\n for j in range(3):\n box = Square(side_length=square_size)\n box.move_to([j*square_size, -i*square_size, 0])\n square.add(box)\n \n square.move_to(ORIGIN)\n \n # Add numbers to the classic magic square (Lo Shu)\n magic_nums = [4, 9, 2, 3, 5, 7, 8, 1, 6]\n num_texts = []\n for i, num in enumerate(magic_nums):\n num_text = Text(str(num), font_size=30)\n num_text.move_to(square[i].get_center())\n num_texts.append(num_text)\n \n # Show the classic magic square with numbers\n self.play(Create(square))\n self.play(*[Write(nt) for nt in num_texts])\n \n # Show the sum = 15 equation\n magic_sum = Text(\"Sum = 15\", font_size=32)\n magic_sum.to_edge(DOWN)\n self.play(Write(magic_sum))\n self.wait(1)\n \n # Highlight first row to show sum of 15\n row1 = VGroup(square[0], square[1], square[2])\n self.play(row1.animate.set_color(BLUE), run_time=0.8)\n row1_calc = Text(\"4 + 9 + 2 = 15\", font_size=28)\n row1_calc.to_edge(UP)\n self.play(Write(row1_calc))\n self.wait(1)\n self.play(FadeOut(row1_calc))\n self.play(row1.animate.set_color(WHITE), run_time=0.5)\n \n # Transition to negative magic square\n transition = Text(\"What if we subtract 5 from each cell?\", font_size=32)\n self.play(ReplacementTransform(magic_sum, transition))\n self.wait(1)\n self.play(FadeOut(transition))\n \n # Create a new magic square by subtracting 5 from each cell\n neg_magic_nums = [num - 5 for num in magic_nums] # [-1,4,-3, -2,0,2, 3,-4,1]\n neg_num_texts = []\n \n # Animate the transition from classic to negative magic square\n animations = []\n for i, (old_num, new_num) in enumerate(zip(num_texts, neg_magic_nums)):\n color = RED if new_num < 0 else (WHITE if new_num == 0 else GREEN)\n new_text = Text(str(new_num), font_size=30, color=color)\n new_text.move_to(old_num.get_center())\n neg_num_texts.append(new_text)\n animations.append(ReplacementTransform(old_num, new_text))\n \n self.play(*animations, run_time=1.5)\n \n # Show the new magic sum equation\n new_magic_sum = Text(\"Sum = 0\", font_size=32)\n new_magic_sum.to_edge(DOWN)\n self.play(Write(new_magic_sum))\n self.wait(1)\n \n # Highlight first row to show sum of 0\n self.play(row1.animate.set_color(BLUE), run_time=0.8)\n row1_calc = Text(\"-1 + 4 + (-3) = 0\", font_size=28)\n row1_calc.to_edge(UP)\n self.play(Write(row1_calc))\n self.wait(1)\n self.play(FadeOut(row1_calc))\n self.play(row1.animate.set_color(WHITE), run_time=0.5)\n \n # Conclusion\n self.play(FadeOut(new_magic_sum), FadeOut(square), *[FadeOut(nt) for nt in neg_num_texts])\n \n conclusion = Text(\"Negative numbers expand the possibilities\\nof magic squares!\", 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 NegativeMagicSquares(Scene):\n def construct(self):\n # Title\n title = Text(\"Unveiling Negative Magic: Extending Magic Squares\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Create the classic 3x3 magic square\n square = VGroup()\n square_size = 0.8\n for i in range(3):\n for j in range(3):\n box = Square(side_length=square_size)\n box.move_to([j*square_size, -i*square_size, 0])\n square.add(box)\n \n square.move_to(ORIGIN)\n \n # Add numbers to the classic magic square (Lo Shu)\n magic_nums = [4, 9, 2, 3, 5, 7, 8, 1, 6]\n num_texts = []\n for i, num in enumerate(magic_nums):\n num_text = Text(str(num), font_size=30)\n num_text.move_to(square[i].get_center())\n num_texts.append(num_text)\n \n # Show the classic magic square with numbers\n self.play(Create(square))\n self.play(*[Write(nt) for nt in num_texts])\n \n # Show the sum = 15 equation\n magic_sum = Text(\"Sum = 15\", font_size=32)\n magic_sum.to_edge(DOWN)\n self.play(Write(magic_sum))\n self.wait(1)\n \n # Highlight first row to show sum of 15\n row1 = VGroup(square[0], square[1], square[2])\n self.play(row1.animate.set_color(BBLUE), run_time=0.8)\n row1_calc = Text(\"4 + 9 + 2 = 15\", font_size=28)\n row1_calc.to_edge(UP)\n self.play(Write(row1_calc))\n self.wait(1)\n self.play(FadeOut(row1_calc))\n self.play(row1.animate.set_color(WHITE), run_time=0.5)\n \n # Transition to negative magic square\n transition = Text(\"What if we subtract 5 from each cell?\", font_size=32)\n self.play(ReplacementTransform(magic_sum, transition))\n self.wait(1)\n self.play(FadeOut(transition))\n \n # Create a new magic square by subtracting 5 from each cell\n neg_magic_nums = [num - 5 for num in magic_nums] # [-1,4,-3, -2,0,2, 3,-4,1]\n neg_num_texts = []\n \n # Animate the transition from classic to negative magic square\n animations = []\n for i, (old_num, new_num) in enumerate(zip(num_texts, neg_magic_nums)):\n color = RED if new_num < 0 else (WHITE if new_num == 0 else GREEN)\n new_text = Text(str(new_num), font_size=30, color=color)\n new_text.move_to(old_num.get_center())\n neg_num_texts.append(new_text)\n animations.append(ReplacementTransform(old_num, new_text))\n \n self.play(*animations, run_time=1.5)\n \n # Show the new magic sum equation\n new_magic_sum = Text(\"Sum = 0\", font_size=32)\n new_magic_sum.to_edge(DOWN)\n self.play(Write(new_magic_sum))\n self.wait(1)\n \n # Highlight first row to show sum of 0\n self.play(row1.animate.set_color(BLUE), run_time=0.8)\n row1_calc = Text(\"-1 + 4 + (-3) = 0\", font_size=28)\n row1_calc.to_edge(UP)\n self.play(Write(row1_calc))\n self.wait(1)\n self.play(FadeOut(row1_calc))\n self.play(row1.animate.set_color(WHITE), run_time=0.5)\n \n # Conclusion\n self.play(FadeOut(new_magic_sum), FadeOut(square), *[FadeOut(nt) for nt in neg_num_texts])\n \n conclusion = Text(\"Negative numbers expand the possibilities\\nof magic squares!\", 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 how to find the area under the curve of f(x) = x^2 from x=0 to x=2, including the integration steps and the final solution?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ==========================================\n # 1. Setup: Axes and Function Plot\n # ==========================================\n # Create a coordinate system with clear ranges to accommodate f(x) = x^2\n # x ranges from -1 to 3 to provide context around the [0, 2] interval\n # y ranges from -1 to 5 since the maximum value is 2^2 = 4\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).shift(LEFT * 3) # Shift left to make room for equations on the right\n\n # Add axis labels for clarity\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Define the function f(x) = x^2 and plot it\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2])\n func_label = MathTex(\"f(x) = x^2\").to_corner(UL)\n\n # ==========================================\n # 2. Visualizing the Area\n # ==========================================\n # Create the shaded region under the curve from x=0 to x=2\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # Draw vertical boundary lines at x=0 and x=2\n bound_line_start = axes.get_vertical_line(\n axes.input_to_graph_point(0, curve), color=WHITE\n )\n bound_line_end = axes.get_vertical_line(\n axes.input_to_graph_point(2, curve), color=WHITE\n )\n\n # Mark the upper bound coordinate point (2, 4)\n dot = Dot(axes.c2p(2, 4), color=RED)\n dot_label = MathTex(\"(2, 4)\").next_to(dot, UR, buff=0.1)\n\n # ==========================================\n # 3. Step-by-Step Integration Logic\n # ==========================================\n # We break down the Fundamental Theorem of Calculus into clear steps\n\n # Step 1: The Integral Setup\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\\\n .scale(0.9).to_edge(RIGHT).shift(UP * 2)\n\n # Step 2: Finding the Antiderivative (Power Rule)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\\\n .scale(0.9).next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Step 3: Evaluation at Bounds\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\\\n .scale(0.9).next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Step 4: Final Solution\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW)\\\n .scale(1.0).next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Highlight the final answer with a box\n solution_box = SurroundingRectangle(step4, color=GREEN, buff=0.1)\n\n # ==========================================\n # 4. Animation Sequence\n # ==========================================\n\n # Introduce the coordinate system and function\n self.play(Create(axes), Write(axis_labels), run_time=1.5)\n self.play(Create(curve), Write(func_label), run_time=1.5)\n self.wait(0.5)\n\n # Highlight the specific region of integration\n self.play(Create(bound_line_start), Create(bound_line_end), run_time=1)\n self.play(FadeIn(dot), Write(dot_label), run_time=1)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # Animate the solution steps sequentially to guide learning\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n\n self.play(Write(step3), run_time=1.5)\n self.wait(0.5)\n\n # Highlight the final result prominently\n self.play(Write(step4), run_time=1.5)\n self.play(Create(solution_box), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ==========================================\n # 1. Setup: Axes and Function Plot\n # ==========================================\n # Create a coordinate system with clear ranges to accommodate f(x) = x^2\n # x ranges from -1 to 3 to provide context around the [0, 2] interval\n # y ranges from -1 to 5 since the maximum value is 2^2 = 4\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n ).shift(LEFT * 3) # Shift left to make room for equations on the right\n\n # Add axis labels for clarity\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n\n # Define the function f(x) = x^2 and plot it\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2])\n func_label = MathText(\"f(x) = x^2\").to_corner(UL)\n\n # ==========================================\n # 2. Visualizing the Area\n # ==========================================\n # Create the shaded region under the curve from x=0 to x=2\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n\n # Draw vertical boundary lines at x=0 and x=2\n bound_line_start = axes.get_vertical_line(\n axes.input_to_graph_point(0, curve), color=WHITE\n )\n bound_line_end = axes.get_vertical_line(\n axes.input_to_graph_point(2, curve), color=WHITE\n )\n\n # Mark the upper bound coordinate point (2, 4)\n dot = Dot(axes.c2p(2, 4), color=RED)\n dot_label = MathTex(\"(2, 4)\").next_to(dot, UR, buff=0.1)\n\n # ==========================================\n # 3. Step-by-Step Integration Logic\n # ==========================================\n # We break down the Fundamental Theorem of Calculus into clear steps\n\n # Step 1: The Integral Setup\n step1 = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\")\\\n .scale(0.9).to_edge(RIGHT).shift(UP * 2)\n\n # Step 2: Finding the Antiderivative (Power Rule)\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\\\n .scale(0.9).next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Step 3: Evaluation at Bounds\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\\\n .scale(0.9).next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Step 4: Final Solution\n step4 = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=YELLOW)\\\n .scale(1.0).next_to(step3, DOWN, buff=0.5, aligned_edge=LEFT)\n\n # Highlight the final answer with a box\n solution_box = SurroundingRectangle(step4, color=GREEN, buff=0.1)\n\n # ==========================================\n # 4. Animation Sequence\n # ==========================================\n\n # Introduce the coordinate system and function\n self.play(Create(axes), Write(axis_labels), run_time=1.5)\n self.play(Create(curve), Write(func_label), run_time=1.5)\n self.wait(0.5)\n\n # Highlight the specific region of integration\n self.play(Create(bound_line_start), Create(bound_line_end), run_time=1)\n self.play(FadeIn(dot), Write(dot_label), run_time=1)\n self.play(FadeIn(area), run_time=1.5)\n self.wait(0.5)\n\n # Animate the solution steps sequentially to guide learning\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n\n self.play(Write(step3), run_time=1.5)\n self.wait(0.5)\n\n # Highlight the final result prominently\n self.play(Write(step4), run_time=1.5)\n self.play(Create(solution_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0018(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_equilibriumincomederivat()\n self.clear_stage()\n self.act_2_frameboxanimation()\n\n def act_1_equilibriumincomederivat(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\n def act_2_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```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0018(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_equilibriumincomederivat()\n self.clear_stage()\n self.act_2_frameboxanimation()\n\n def act_1_equilibriumincomederivat(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=BBLUE)\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\n def act_2_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 video intro using animation where the title \"Welcome to Manim\" appears at the top, followed by a series of geometric shapes—a yellow square, a green circle, and a blue triangle—appea\n- Act 2: Here’s the enhanced animation instruction, which retains the original red circle while adding a dynamic transformation, explanatory text, and a mathematical formula to deepen the viewer's understanding:\n- Act 3: I would like to create an educational chemistry animation that visually represents an electrochemical concept. The animation should start with a 3x3 grid of lithium ions to demonstrate the initial state of a battery's el", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0191(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_introscene()\n self.clear_stage()\n self.act_2_circletosquarewithmath()\n self.clear_stage()\n self.act_3_areaundercurveexample()\n\n def act_1_introscene(self):\n title = Text(\"Welcome to Manim\", font_size=48).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Shape Sequence\n # Define the geometric shapes with their specified colors\n square = Square(color=YELLOW)\n circle = Circle(color=GREEN)\n triangle = Triangle(color=BLUE)\n\n # Group the shapes and arrange them horizontally from left to right\n shapes = VGroup(square, circle, triangle)\n shapes.arrange(RIGHT, buff=0.5)\n shapes.next_to(title, DOWN, buff=1.5)\n\n # Animate the shapes appearing one by one from left to right\n self.play(Create(square))\n self.play(Create(circle))\n self.play(Create(triangle))\n self.wait(0.5)\n\n # 3. Transformation\n # Create a dot at the center of the shapes to serve as the morph target\n dot = Dot().move_to(shapes.get_center())\n\n # Simultaneously morph the group of shapes into the single dot\n self.play(ReplacementTransform(shapes, dot))\n self.wait(0.5)\n\n # 4. Conclusion\n # Create the final text and position it directly below the dot\n final_text = Text(\"Let's learn Manim!\", font_size=36).next_to(dot, DOWN, buff=0.5)\n\n # Transform the dot into the concluding text\n self.play(ReplacementTransform(dot, final_text))\n self.wait(1)\n\n def act_2_circletosquarewithmath(self):\n circle = Circle(radius=2, color=RED, fill_opacity=0.5)\n circle_label = Tex(\"Unit Circle (r = 2)\", color=BLUE).next_to(circle, DOWN)\n\n # Show circle and label\n self.play(Create(circle), Write(circle_label))\n self.wait(1)\n\n # Prepare the area formulas\n formula1 = MathTex(\"A = \\\\pi r^2 = \\\\pi (2)^2 = 4\\\\pi\").to_edge(UP)\n formula2 = MathTex(\"\\\\text{For equal area: } s^2 = 4\\\\pi \\\\rightarrow s = 2\\\\sqrt{\\\\pi}\").next_to(formula1, DOWN)\n\n # Show formulas\n self.play(Write(formula1))\n self.wait(0.5)\n self.play(Write(formula2))\n self.wait(1)\n\n # Create the square with equal area\n side_length = 2 * np.sqrt(PI)\n square = Square(side_length=side_length, color=GREEN, fill_opacity=0.5)\n square.move_to(circle.get_center())\n\n # Transform circle to square\n self.play(Transform(circle, square), circle.animate.set_color(GREEN))\n self.wait(1)\n\n # Show side length measurement\n measurement = DoubleArrow(\n start=square.get_corner(DL),\n end=square.get_corner(DR),\n buff=0,\n color=YELLOW\n )\n side_label = MathTex(\"2\\\\sqrt{\\\\pi}\", color=YELLOW).next_to(measurement, DOWN)\n\n self.play(Create(measurement), Write(side_label))\n self.wait(2)\n\n # Move both shapes and formulas to final positions\n circle_copy = Circle(radius=2, color=RED, fill_opacity=0.5).shift(LEFT*3)\n square_copy = Square(side_length=side_length, color=GREEN, fill_opacity=0.5).shift(RIGHT*3)\n formulas = VGroup(formula1, formula2).to_edge(DOWN)\n\n self.play(\n Transform(circle, circle_copy),\n Transform(square, square_copy),\n FadeOut(measurement),\n FadeOut(side_label),\n FadeOut(circle_label),\n formulas.animate.to_edge(DOWN)\n )\n self.wait(2)\n\n def act_3_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0191(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_introscene()\n self.clear_stage()\n self.act_2_circletosquarewithmath()\n self.clear_stage()\n self.act_3_areaundercurveexample()\n\n def act_1_introscene(self):\n title = Text(\"Welcome to Manim\", font_size=48).to_edge(UP)\n self.play(Write(title))\n self.wait(0.5)\n\n # 2. Shape Sequence\n # Define the geometric shapes with their specified colors\n square = Square(color=YELLOW)\n circle = Circle(color=GREEN)\n triangle = Triangle(color=BLUE)\n\n # Group the shapes and arrange them horizontally from left to right\n shapes = VGroup(square, circle, triangle)\n shapes.arrange(RIGHT, buff=0.5)\n shapes.next_to(title, DOWN, buff=1.5)\n\n # Animate the shapes appearing one by one from left to right\n self.play(Create(square))\n self.play(Create(circle))\n self.play(Create(triangle))\n self.wait(0.5)\n\n # 3. Transformation\n # Create a dot at the center of the shapes to serve as the morph target\n dot = Dot().move_to(shapes.get_center())\n\n # Simultaneously morph the group of shapes into the single dot\n self.play(ReplacementTransform(shapes, dot))\n self.wait(0.5)\n\n # 4. Conclusion\n # Create the final text and position it directly below the dot\n final_text = Text(\"Let's learn Manim!\", font_size=36).next_to(dot, DOWN, buff=0.5)\n\n # Transform the dot into the concluding text\n self.play(ReplacementTransform(dot, final_text))\n self.wait(1)\n\n def act_2_circletosquarewithmath(self):\n circle = Circle(radius=2, color=RED, fill_opacity=0.5)\n circle_label = Tex(\"Unit Circle (r = 2)\", color=BLUE).next_to(circle, DOWN)\n\n # Show circle and label\n self.play(Create(circle), Write(circle_label))\n self.wait(1)\n\n # Prepare the area formulas\n formula1 = MathText(\"A = \\\\pi r^2 = \\\\pi (2)^2 = 4\\\\pi\").to_edge(UP)\n formula2 = MathTex(\"\\\\text{For equal area: } s^2 = 4\\\\pi \\\\rightarrow s = 2\\\\sqrt{\\\\pi}\").next_to(formula1, DOWN)\n\n # Show formulas\n self.play(Write(formula1))\n self.wait(0.5)\n self.play(Write(formula2))\n self.wait(1)\n\n # Create the square with equal area\n side_length = 2 * np.sqrt(PI)\n square = Square(side_length=side_length, color=GREEN, fill_opacity=0.5)\n square.move_to(circle.get_center())\n\n # Transform circle to square\n self.play(Transform(circle, square), circle.animate.set_color(GREEN))\n self.wait(1)\n\n # Show side length measurement\n measurement = DoubleArrow(\n start=square.get_corner(DL),\n end=square.get_corner(DR),\n buff=0,\n color=YELLOW\n )\n side_label = MathTex(\"2\\\\sqrt{\\\\pi}\", color=YELLOW).next_to(measurement, DOWN)\n\n self.play(Create(measurement), Write(side_label))\n self.wait(2)\n\n # Move both shapes and formulas to final positions\n circle_copy = Circle(radius=2, color=RED, fill_opacity=0.5).shift(LEFT*3)\n square_copy = Square(side_length=side_length, color=GREEN, fill_opacity=0.5).shift(RIGHT*3)\n formulas = VGroup(formula1, formula2).to_edge(DOWN)\n\n self.play(\n Transform(circle, circle_copy),\n Transform(square, square_copy),\n FadeOut(measurement),\n FadeOut(side_label),\n FadeOut(circle_label),\n formulas.animate.to_edge(DOWN)\n )\n self.wait(2)\n\n def act_3_areaundercurveexample(self):\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using a graphical representation to explain the concept of the area under a curve. First, show a graph of a simple quadratic function, such as y = x^2, and highlight the area under the curve from x = 0 to x = 2. Then, add a label to the curve mentioning its equation. After that, overlay textual explanation indicating that this is the area under the curve. Finally, clear the animation to only keep the text explanation on the screen for further emphasis. Make sure the entire sequence is paced with pauses so that a viewer can follow along easily.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Graph Initialization: Plot the simple quadratic function y = x^2\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 )\n \n curve = axes.plot(lambda x: x**2, color=BLUE)\n \n # Animate creation of axes and curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 2. Area Highlighting: Visually highlight the area under the curve from x = 0 to x = 2\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=YELLOW,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 3. Labeling: Add a text label to the curve explicitly stating its equation\n eq_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n \n self.play(Write(eq_label))\n self.wait(1)\n\n # 4. Explanation Overlay: Overlay a textual explanation indicating the meaning of the region\n explanation = Text(\n \"This shaded region represents the\\n'area under the curve'\",\n font_size=32,\n line_spacing=1,\n t2c={\"'area under the curve'\": YELLOW}\n ).to_edge(DOWN)\n \n self.play(Write(explanation))\n self.wait(2)\n\n # 5. Final Emphasis: Clear all graphical elements, leaving only the text explanation\n graphics_group = VGroup(axes, curve, area, eq_label)\n self.play(FadeOut(graphics_group))\n \n # Move the remaining text to the center for final emphasis\n self.play(explanation.animate.center())\n self.wait(2)\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 # 1. Graph Initialization: Plot the simple quadratic function y = x^2\n axes = Axes(label_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 )\n \n curve = axes.plot(lambda x: x**2, color=BLUE)\n \n # Animate creation of axes and curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 2. Area Highlighting: Visually highlight the area under the curve from x = 0 to x = 2\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=YELLOW,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 3. Labeling: Add a text label to the curve explicitly stating its equation\n eq_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n \n self.play(Write(eq_label))\n self.wait(1)\n\n # 4. Explanation Overlay: Overlay a textual explanation indicating the meaning of the region\n explanation = Text(\n \"This shaded region represents the\\n'area under the curve'\",\n font_size=32,\n line_spacing=1,\n t2c={\"'area under the curve'\": YELLOW}\n ).to_edge(DOWN)\n \n self.play(Write(explanation))\n self.wait(2)\n\n # 5. Final Emphasis: Clear all graphical elements, leaving only the text explanation\n graphics_group = VGroup(axes, curve, area, eq_label)\n self.play(FadeOut(graphics_group))\n \n # Move the remaining text to the center for final emphasis\n self.play(explanation.animate.center())\n self.wait(2)\n\n# To render this animation, use the command:\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 chemistry animation that visually represents an electrochemical concept. The animation should start with a 3x3 grid of lithium ions to demonstrate the initial state of a battery's electrode. Then, it should transition to a single layer of carbon atoms to represent another electrode. Additionally, I want to include separate animations of an oxygen molecule and a metallic element, cobalt, symbolizing their interactions in the chemical process; have them appear one by one on opposite sides of the screen. \n\nFurthermore, animate the oxygen molecule moving in a triangular path to depict some sort of molecular motion or reaction pathway, showing the dynamic nature of the chemical processes within a battery. Please make sure the elements and ions are correctly labeled with their chemical symbols and charges, make it visually clear, and ensure that the animation runs smoothly and is visually engaging for students learning about chemistry.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Set up axes\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Set up axes\n axes = Axes(\n x_range=[0, 5, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BBLUE},\n )\n \n # Displaying the integral problem\n integral = MathTex(r\"\\int_{0}^{2} (x^2) \\,dx\")\n integral.to_edge(UP)\n self.play(Write(integral))\n self.wait(1)\n\n # Graph function\n graph = axes.plot(lambda x: x**2, color=WHITE)\n graph_label = axes.get_graph_label(graph, label='x^2')\n\n # Display graph\n self.play(Create(axes), Create(graph), FadeIn(graph_label))\n self.wait(1)\n\n # Highlight the area under the curve\n area = axes.get_area(graph, x_range=(0, 2), color=GREEN, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # Calculate the area\n solution = MathTex(r\"=\\frac{{(2)^3}}{3} - \\frac{{(0)^3}}{3}\")\n solution.to_edge(DOWN)\n self.play(ReplacementTransform(integral.copy(), solution))\n self.wait(2)\n\n # Simplify the solution\n final_solution = MathTex(r\"=\\frac{8}{3}\")\n final_solution.next_to(solution, DOWN)\n self.play(Write(final_solution))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_solution))\n self.wait(1)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 evaluate a double integral step by step. The double integral I want to focus on is the integration of (x^2 + y^2) over the region bounded by y=-1 to y=1 and x=0 to x=1. The animation should first display the integral, then show the integration with respect to y, replace the solved part with the new expression, and then do the same for the integration with respect to x. After each step, the animation should pause to give viewers time to understand before proceeding. At the final stage, the animation should display the evaluated result of the integral. Can you create such an animation sequence for me?", "chosen": "```python\nfrom manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # Define colors to track variables during integration steps\n COLOR_Y = BLUE # Highlights inner integration (y)\n COLOR_X = GREEN # Highlights outer integration (x)\n COLOR_RESULT = GOLD\n \n # ---------------------------------------------------------\n # Step 1: Display the original double integral\n # ---------------------------------------------------------\n # Integral: \\int _0^1 \\int _-1^1 (x^2 + y^2) dy dx\n original_integral = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\int_{-1}^{1}\", \n r\"(x^2 + y^2)\", \n r\"\\, dy\", \n r\"\\, dx\"\n ).scale(1.2)\n \n # Highlight the inner differential 'dy' to indicate the first step\n original_integral[3].set_color(COLOR_Y) \n \n self.play(Write(original_integral))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 2: Integrate with respect to y (Inner Integral)\n # ---------------------------------------------------------\n # Show the antiderivative of the inner part: [x^2y + y^3/3] from -1 to 1\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\left[ x^2y + \\frac{y^3}{3} \\right]_{-1}^{1}\", \n r\"\\, dx\"\n ).scale(1.2)\n \n # Color coding for clarity\n inner_antiderivative[0].set_color(COLOR_X) # Outer integral\n inner_antiderivative[1].set_color(COLOR_Y) # Inner evaluation\n inner_antiderivative[2].set_color(COLOR_X) # Outer differential\n \n self.play(ReplacementTransform(original_integral, inner_antiderivative))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 3: Evaluate inner bounds and simplify\n # ---------------------------------------------------------\n # Substitute y = 1 and y = -1\n # Calculation: (x^2(1) + 1/3) - (x^2(-1) - 1/3) = 2x^2 + 2/3\n # Resulting Single Integral: \\int _0^1 (2x^2 + 2/3) dx\n single_integral = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\left( 2x^2 + \\frac{2}{3} \\right)\", \n r\"\\, dx\"\n ).scale(1.2)\n \n single_integral[0].set_color(COLOR_X)\n single_integral[1].set_color(COLOR_X)\n single_integral[2].set_color(COLOR_X)\n \n self.play(ReplacementTransform(inner_antiderivative, single_integral))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 4: Integrate with respect to x (Outer Integral)\n # ---------------------------------------------------------\n # Show the antiderivative of the outer part: [2x^3/3 + 2x/3] from 0 to 1\n outer_antiderivative = MathTex(\n r\"\\left[ \\frac{2x^3}{3} + \\frac{2}{3}x \\right]_{0}^{1}\"\n ).scale(1.2)\n outer_antiderivative.set_color(COLOR_X)\n \n self.play(ReplacementTransform(single_integral, outer_antiderivative))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 5: Display Final Result\n # ---------------------------------------------------------\n # Calculation: (2/3 + 2/3) - 0 = 4/3\n final_result = MathTex(r\"\\frac{4}{3}\").scale(1.5)\n final_result.set_color(COLOR_RESULT)\n \n self.play(ReplacementTransform(outer_antiderivative, final_result))\n \n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n\n# To run this animation, save the code as 'double_integral.py' \n# and run the command: manim -pql double_integral.py DoubleIntegralEvaluation\n```", "rejected": "```python\nfrom manim import *\n\nclass DoubleIntegralEvaluation(Scene):\n def construct(self):\n # Define colors to track variables during integration steps\n COLOR_Y = BBLUE # Highlights inner integration (y)\n COLOR_X = GREEN # Highlights outer integration (x)\n COLOR_RESULT = GOLD\n \n # ---------------------------------------------------------\n # Step 1: Display the original double integral\n # ---------------------------------------------------------\n # Integral: \\int _0^1 \\int _-1^1 (x^2 + y^2) dy dx\n original_integral = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\int_{-1}^{1}\", \n r\"(x^2 + y^2)\", \n r\"\\, dy\", \n r\"\\, dx\"\n ).scale(1.2)\n \n # Highlight the inner differential 'dy' to indicate the first step\n original_integral[3].set_color(COLOR_Y) \n \n self.play(Write(original_integral))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 2: Integrate with respect to y (Inner Integral)\n # ---------------------------------------------------------\n # Show the antiderivative of the inner part: [x^2y + y^3/3] from -1 to 1\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\left[ x^2y + \\frac{y^3}{3} \\right]_{-1}^{1}\", \n r\"\\, dx\"\n ).scale(1.2)\n \n # Color coding for clarity\n inner_antiderivative[0].set_color(COLOR_X) # Outer integral\n inner_antiderivative[1].set_color(COLOR_Y) # Inner evaluation\n inner_antiderivative[2].set_color(COLOR_X) # Outer differential\n \n self.play(ReplacementTransform(original_integral, inner_antiderivative))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 3: Evaluate inner bounds and simplify\n # ---------------------------------------------------------\n # Substitute y = 1 and y = -1\n # Calculation: (x^2(1) + 1/3) - (x^2(-1) - 1/3) = 2x^2 + 2/3\n # Resulting Single Integral: \\int _0^1 (2x^2 + 2/3) dx\n single_integral = MathTex(\n r\"\\int_{0}^{1}\", \n r\"\\left( 2x^2 + \\frac{2}{3} \\right)\", \n r\"\\, dx\"\n ).scale(1.2)\n \n single_integral[0].set_color(COLOR_X)\n single_integral[1].set_color(COLOR_X)\n single_integral[2].set_color(COLOR_X)\n \n self.play(ReplacementTransform(inner_antiderivative, single_integral))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 4: Integrate with respect to x (Outer Integral)\n # ---------------------------------------------------------\n # Show the antiderivative of the outer part: [2x^3/3 + 2x/3] from 0 to 1\n outer_antiderivative = MathTex(\n r\"\\left[ \\frac{2x^3}{3} + \\frac{2}{3}x \\right]_{0}^{1}\"\n ).scale(1.2)\n outer_antiderivative.set_color(COLOR_X)\n \n self.play(ReplacementTransform(single_integral, outer_antiderivative))\n self.wait(2)\n \n # ---------------------------------------------------------\n # Step 5: Display Final Result\n # ---------------------------------------------------------\n # Calculation: (2/3 + 2/3) - 0 = 4/3\n final_result = MathTex(r\"\\frac{4}{3}\").scale(1.5)\n final_result.set_color(COLOR_RESULT)\n \n self.play(ReplacementTransform(outer_antiderivative, final_result))\n \n # Highlight the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.2)\n self.play(Create(box))\n self.wait(3)\n\n# To run this animation, save the code as 'double_integral.py' \n# and run the command: manim -pql double_integral.py DoubleIntegralEvaluation\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does the symmetry of a domain impact the structure and properties of its Bergman Kernel?", "chosen": "```python\nfrom manim import *\n\nclass BergmanKernelSymmetry(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Unlocking the Symmetries of Bergman Kernels\").scale(0.8)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Symmetric domain in complex plane\n plane = NumberPlane().scale(0.7)\n circle = Circle(radius=1.5)\n domain_text = Text(\"Symmetric Domain\").scale(0.6).to_edge(UP)\n \n self.play(Create(plane))\n self.play(Create(circle))\n self.play(Write(domain_text))\n \n # Spin the circle to showcase symmetry\n self.play(Rotate(circle, angle=PI, run_time=2))\n self.wait(0.5)\n \n # Transition to Bergman Kernel\n self.play(\n FadeOut(domain_text), \n FadeOut(plane),\n circle.animate.scale(0.7).to_edge(LEFT)\n )\n \n # Introduce Bergman Kernel\n kernel_title = Text(\"Bergman Kernel\").scale(0.8).to_edge(UP)\n self.play(Write(kernel_title))\n \n # Display kernel equation\n kernel_eq = MathTex(\n r\"K_w(z) = \\sum_{n=0}^{\\infty} \\phi_n(z) \\overline{\\phi_n(w)}\",\n ).scale(0.7).next_to(kernel_title, DOWN, buff=0.5)\n \n self.play(Write(kernel_eq))\n self.wait(1)\n \n # Display unit disk equation (simplified)\n unit_disk_eq = MathTex(\n r\"K(z,z) = \\frac{1}{\\pi (1 - |z|^2)^2}\",\n ).scale(0.6).next_to(kernel_eq, DOWN, buff=0.5)\n \n unit_disk_label = Text(\"For the unit disk\").scale(0.4).next_to(unit_disk_eq, RIGHT)\n \n self.play(Write(unit_disk_eq))\n self.play(Write(unit_disk_label))\n self.wait(1)\n \n # Compare with another symmetric domain\n self.play(FadeOut(kernel_eq, unit_disk_eq, unit_disk_label))\n \n # Create an ellipse as another symmetric domain\n ellipse = Ellipse(width=3, height=1.5).scale(0.6).next_to(circle, RIGHT, buff=2)\n \n self.play(Create(ellipse))\n self.wait(0.5)\n \n # Show grid representations for kernels (simplified visualization)\n circle_dots = VGroup()\n for i in range(-3, 4, 2):\n for j in range(-3, 4, 2):\n if i*i + j*j <= 9: # Simplified condition\n dot = Dot(circle.get_center() + 0.2*i*RIGHT + 0.2*j*UP, radius=0.05)\n circle_dots.add(dot)\n \n ellipse_dots = VGroup()\n for i in range(-4, 5, 2):\n for j in range(-2, 3, 2):\n if (i*i/16) + (j*j/4) <= 1: # Simplified ellipse condition\n dot = Dot(ellipse.get_center() + 0.2*i*RIGHT + 0.2*j*UP, radius=0.05)\n ellipse_dots.add(dot)\n \n self.play(FadeIn(circle_dots), FadeIn(ellipse_dots))\n \n symmetry_text = Text(\"Symmetry creates structure\").scale(0.6).to_edge(UP)\n self.play(FadeOut(kernel_title), Write(symmetry_text))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(circle, ellipse, circle_dots, ellipse_dots, symmetry_text)\n )\n \n conclusion = Text(\"Symmetry simplifies the Bergman Kernel\").scale(0.7)\n self.play(Write(conclusion))\n self.wait(1)\n \n final_text = Text(\"Mathematical harmony in complex analysis\").scale(0.5).next_to(conclusion, DOWN)\n self.play(Write(final_text))\n self.wait(2)\n \n self.play(FadeOut(conclusion, final_text))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass BergmanKernelSymmetry(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Unlocking the Symmetries of Bergman Kernels\").scale(0.8)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Symmetric domain in complex plane\n plane = NumberPlane().scale(0.7)\n circle = Circle(radius=1.5)\n domain_text = Text(\"Symmetric Domain\").scale(0.6).to_edge(UP)\n \n self.play(Create(plane))\n self.play(Create(circle))\n self.play(Write(domain_text))\n \n # Spin the circle to showcase symmetry\n self.play(Rotate(circle, angle=PI, run_time=2))\n self.wait(0.5)\n \n # Transition to Bergman Kernel\n self.play(\n FadeOut(domain_text), \n FadeOut(plane),\n circle.animate.scale(0.7).to_edge(LEFT)\n )\n \n # Introduce Bergman Kernel\n kernel_title = Text(\"Bergman Kernel\").scale(0.8).to_edge(UP)\n self.play(Write(kernel_title))\n \n # Display kernel equation\n kernel_eq = MathText(\n r\"K_w(z) = \\sum_{n=0}^{\\infty} \\phi_n(z) \\overline{\\phi_n(w)}\",\n ).scale(0.7).next_to(kernel_title, DOWN, buff=0.5)\n \n self.play(Write(kernel_eq))\n self.wait(1)\n \n # Display unit disk equation (simplified)\n unit_disk_eq = MathTex(\n r\"K(z,z) = \\frac{1}{\\pi (1 - |z|^2)^2}\",\n ).scale(0.6).next_to(kernel_eq, DOWN, buff=0.5)\n \n unit_disk_label = Text(\"For the unit disk\").scale(0.4).next_to(unit_disk_eq, RIGHT)\n \n self.play(Write(unit_disk_eq))\n self.play(Write(unit_disk_label))\n self.wait(1)\n \n # Compare with another symmetric domain\n self.play(FadeOut(kernel_eq, unit_disk_eq, unit_disk_label))\n \n # Create an ellipse as another symmetric domain\n ellipse = Ellipse(width=3, height=1.5).scale(0.6).next_to(circle, RIGHT, buff=2)\n \n self.play(Create(ellipse))\n self.wait(0.5)\n \n # Show grid representations for kernels (simplified visualization)\n circle_dots = VGroup()\n for i in range(-3, 4, 2):\n for j in range(-3, 4, 2):\n if i*i + j*j <= 9: # Simplified condition\n dot = Dot(circle.get_center() + 0.2*i*RIGHT + 0.2*j*UP, radius=0.05)\n circle_dots.add(dot)\n \n ellipse_dots = VGroup()\n for i in range(-4, 5, 2):\n for j in range(-2, 3, 2):\n if (i*i/16) + (j*j/4) <= 1: # Simplified ellipse condition\n dot = Dot(ellipse.get_center() + 0.2*i*RIGHT + 0.2*j*UP, radius=0.05)\n ellipse_dots.add(dot)\n \n self.play(FadeIn(circle_dots), FadeIn(ellipse_dots))\n \n symmetry_text = Text(\"Symmetry creates structure\").scale(0.6).to_edge(UP)\n self.play(FadeOut(kernel_title), Write(symmetry_text))\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(circle, ellipse, circle_dots, ellipse_dots, symmetry_text)\n )\n \n conclusion = Text(\"Symmetry simplifies the Bergman Kernel\").scale(0.7)\n self.play(Write(conclusion))\n self.wait(1)\n \n final_text = Text(\"Mathematical harmony in complex analysis\").scale(0.5).next_to(conclusion, DOWN)\n self.play(Write(final_text))\n self.wait(2)\n \n self.play(FadeOut(conclusion, 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 AreaUnderCurve(Scene):\n def construct(self):\n # 1. Axes Setup\n # Create axes with appropriate ranges for x=[0,2] and y=[0,4], colored blue\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 self.play(Create(axes), run_time=1.5)\n\n # 2. Formula Display\n # Show the integral formula at the top of the screen\n integral_formula = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=48)\n integral_formula.to_edge(UP)\n self.play(Write(integral_formula), run_time=1)\n\n # 3. Graph Plotting\n # Plot f(x) = x^2 in white and label it\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=WHITE)\n graph_label = MathTex(r\"f(x) = x^2\", font_size=36).next_to(graph, UR, buff=0.2)\n self.play(Create(graph), Write(graph_label), run_time=2)\n\n # 4. Area Highlighting\n # Highlight the area under the graph between x=0 and x=2 in green with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area), run_time=1)\n self.wait(0.5)\n\n # 5. Calculation Display\n # Show step-by-step calculation directly below the integral formula\n \n # Step 1: Antiderivative rule\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step1.next_to(integral_formula, DOWN, buff=0.5)\n \n # Step 2: Substitution of bounds\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n step2.next_to(step1, DOWN, buff=0.3)\n \n # Animate the calculation steps\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n\n # 6. Simplification\n # Simplify to reveal the final numerical value\n final_result = MathTex(r\"= \\frac{8}{3}\", font_size=48)\n final_result.next_to(step2, DOWN, buff=0.3)\n self.play(Write(final_result), run_time=1)\n self.wait(1)\n\n # 7. Conclusion\n # Clear all elements except the simplified result\n elements_to_remove = VGroup(\n axes, graph, graph_label, area, \n integral_formula, step1, step2\n )\n self.play(FadeOut(elements_to_remove), run_time=1.5)\n \n # Move result to center for emphasis and keep it displayed\n self.play(final_result.animate.move_to(ORIGIN).scale(1.5), run_time=1)\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Axes Setup\n # Create axes with appropriate ranges for x=[0,2] and y=[0,4], colored blue\n axes = Axes(\n x_range=[-0.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n axis_config={\"color\": BBLUE},\n tips=False\n )\n self.play(Create(axes), run_time=1.5)\n\n # 2. Formula Display\n # Show the integral formula at the top of the screen\n integral_formula = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\", font_size=48)\n integral_formula.to_edge(UP)\n self.play(Write(integral_formula), run_time=1)\n\n # 3. Graph Plotting\n # Plot f(x) = x^2 in white and label it\n graph = axes.plot(lambda x: x**2, x_range=[0, 2], color=WHITE)\n graph_label = MathTex(r\"f(x) = x^2\", font_size=36).next_to(graph, UR, buff=0.2)\n self.play(Create(graph), Write(graph_label), run_time=2)\n\n # 4. Area Highlighting\n # Highlight the area under the graph between x=0 and x=2 in green with transparency\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n self.play(FadeIn(area), run_time=1)\n self.wait(0.5)\n\n # 5. Calculation Display\n # Show step-by-step calculation directly below the integral formula\n \n # Step 1: Antiderivative rule\n step1 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\", font_size=42)\n step1.next_to(integral_formula, DOWN, buff=0.5)\n \n # Step 2: Substitution of bounds\n step2 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\", font_size=42)\n step2.next_to(step1, DOWN, buff=0.3)\n \n # Animate the calculation steps\n self.play(Write(step1), run_time=1.5)\n self.wait(0.5)\n self.play(Write(step2), run_time=1.5)\n self.wait(0.5)\n\n # 6. Simplification\n # Simplify to reveal the final numerical value\n final_result = MathTex(r\"= \\frac{8}{3}\", font_size=48)\n final_result.next_to(step2, DOWN, buff=0.3)\n self.play(Write(final_result), run_time=1)\n self.wait(1)\n\n # 7. Conclusion\n # Clear all elements except the simplified result\n elements_to_remove = VGroup(\n axes, graph, graph_label, area, \n integral_formula, step1, step2\n )\n self.play(FadeOut(elements_to_remove), run_time=1.5)\n \n # Move result to center for emphasis and keep it displayed\n self.play(final_result.animate.move_to(ORIGIN).scale(1.5), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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# Instruction Set and Assembly View - Course Notes", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass InstructionSetAssembly(Scene):\n\n def construct(self):\n self.show_title()\n self.show_abstraction_layers()\n self.show_cpu_registers()\n self.show_instruction_anatomy()\n self.show_summary()\n\n def show_title(self):\n title = Text('Instruction Set and Assembly View', font_size=48, weight=BOLD)\n subtitle = Text('Course Notes', font_size=36, color=BLUE)\n group = VGroup(title, subtitle).arrange(DOWN, buff=0.5)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(2)\n self.play(FadeOut(group))\n\n def show_abstraction_layers(self):\n header = Text('Abstraction Layers', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n c_text = Text('High-Level Language (C)', font_size=24)\n c_code = Text('int a = b + c;', font_size=28, font='Monospace', color=YELLOW)\n layer1 = VGroup(c_text, c_code).arrange(DOWN, buff=0.2)\n asm_text = Text('Assembly Language', font_size=24)\n asm_code = Text('addq %rbx, %rax', font_size=28, font='Monospace', color=GREEN)\n layer2 = VGroup(asm_text, asm_code).arrange(DOWN, buff=0.2)\n bin_text = Text('Machine Code', font_size=24)\n bin_code = Text('01001000 00000001 11011000', font_size=28, font='Monospace', color=RED)\n layer3 = VGroup(bin_text, bin_code).arrange(DOWN, buff=0.2)\n layers = VGroup(layer1, layer2, layer3).arrange(DOWN, buff=1.0)\n layers.next_to(header, DOWN, buff=0.5)\n arrow1 = Arrow(layer1.get_bottom(), layer2.get_top(), buff=0.1, color=WHITE)\n arrow2 = Arrow(layer2.get_bottom(), layer3.get_top(), buff=0.1, color=WHITE)\n self.play(FadeIn(layer1, shift=DOWN))\n self.play(GrowArrow(arrow1))\n self.play(FadeIn(layer2, shift=DOWN))\n self.play(GrowArrow(arrow2))\n self.play(FadeIn(layer3, shift=DOWN))\n self.wait(2)\n self.play(FadeOut(layers), FadeOut(arrow1), FadeOut(arrow2), FadeOut(header))\n\n def show_cpu_registers(self):\n header = Text('CPU Registers (x86-64)', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n regs = ['%rax', '%rbx', '%rcx', '%rdx', '%rsi', '%rdi']\n reg_group = VGroup()\n for r in regs:\n box = Rectangle(width=3, height=0.8, color=WHITE)\n label = Text(r, font_size=28, font='Monospace', color=YELLOW).move_to(box.get_center())\n reg_group.add(VGroup(box, label))\n else:\n pass\n reg_group.arrange_in_grid(rows=3, cols=2, buff=0.5)\n reg_group.next_to(header, DOWN, buff=1.0)\n self.play(LaggedStart(*[FadeIn(rg, shift=UP) for rg in reg_group], lag_ratio=0.15))\n self.wait(2)\n self.play(FadeOut(reg_group), FadeOut(header))\n\n def show_instruction_anatomy(self):\n header = Text('Anatomy of an Assembly Instruction', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n p1 = Text('addq', font_size=48, font='Monospace', color=YELLOW)\n p2 = Text('%rbx', font_size=48, font='Monospace', color=GREEN)\n p3 = Text(',', font_size=48, font='Monospace')\n p4 = Text('%rax', font_size=48, font='Monospace', color=RED)\n inst_group = VGroup(p1, p2, p3, p4).arrange(RIGHT, buff=0.3).move_to(ORIGIN)\n self.play(FadeIn(inst_group))\n l1 = Text('Opcode', font_size=24, color=YELLOW).next_to(p1, DOWN, buff=1)\n a1 = Arrow(l1.get_top(), p1.get_bottom(), color=YELLOW, buff=0.1)\n l2 = Text('Source Operand', font_size=24, color=GREEN).next_to(p2, UP, buff=1)\n a2 = Arrow(l2.get_bottom(), p2.get_top(), color=GREEN, buff=0.1)\n l3 = Text('Destination Operand', font_size=24, color=RED).next_to(p4, DOWN, buff=1)\n a3 = Arrow(l3.get_top(), p4.get_bottom(), color=RED, buff=0.1)\n self.play(Write(l1), GrowArrow(a1))\n self.wait(1)\n self.play(Write(l2), GrowArrow(a2))\n self.wait(1)\n self.play(Write(l3), GrowArrow(a3))\n self.wait(3)\n self.play(FadeOut(inst_group), FadeOut(l1), FadeOut(l2), FadeOut(l3), FadeOut(a1), FadeOut(a2), FadeOut(a3), FadeOut(header))\n\n def show_summary(self):\n summary_title = Text('Summary', font_size=48, color=BLUE).to_edge(UP)\n pts = VGroup(Text('1. Compilers translate High-Level Code to Assembly.', font_size=28), Text('2. Assemblers convert Assembly to Machine Code.', font_size=28), Text('3. Instructions consist of Opcodes and Operands.', font_size=28), Text('4. Registers provide fast, temporary storage for the CPU.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.6).center()\n self.play(Write(summary_title))\n self.play(LaggedStart(*[FadeIn(p, shift=RIGHT) for p in pts], lag_ratio=0.4))\n self.wait(4)\n self.play(FadeOut(summary_title), FadeOut(pts))\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass InstructionSetAssembly(Scene):\n\n def construct(self):\n self.show_title()\n self.show_abstraction_layers()\n self.show_cpu_registers()\n self.show_instruction_anatomy()\n self.show_summary()\n\n def show_title(self):\n title = Text('Instruction Set and Assembly View', font_size=48, weight=BOLD)\n subtitle = Text('Course Notes', font_size=36, color=BBLUE)\n group = VGroup(title, subtitle).arrange(DOWN, buff=0.5)\n self.play(Write(title))\n self.play(FadeIn(subtitle, shift=UP))\n self.wait(2)\n self.play(FadeOut(group))\n\n def show_abstraction_layers(self):\n header = Text('Abstraction Layers', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n c_text = Text('High-Level Language (C)', font_size=24)\n c_code = Text('int a = b + c;', font_size=28, font='Monospace', color=YELLOW)\n layer1 = VGroup(c_text, c_code).arrange(DOWN, buff=0.2)\n asm_text = Text('Assembly Language', font_size=24)\n asm_code = Text('addq %rbx, %rax', font_size=28, font='Monospace', color=GREEN)\n layer2 = VGroup(asm_text, asm_code).arrange(DOWN, buff=0.2)\n bin_text = Text('Machine Code', font_size=24)\n bin_code = Text('01001000 00000001 11011000', font_size=28, font='Monospace', color=RED)\n layer3 = VGroup(bin_text, bin_code).arrange(DOWN, buff=0.2)\n layers = VGroup(layer1, layer2, layer3).arrange(DOWN, buff=1.0)\n layers.next_to(header, DOWN, buff=0.5)\n arrow1 = Arrow(layer1.get_bottom(), layer2.get_top(), buff=0.1, color=WHITE)\n arrow2 = Arrow(layer2.get_bottom(), layer3.get_top(), buff=0.1, color=WHITE)\n self.play(FadeIn(layer1, shift=DOWN))\n self.play(GrowArrow(arrow1))\n self.play(FadeIn(layer2, shift=DOWN))\n self.play(GrowArrow(arrow2))\n self.play(FadeIn(layer3, shift=DOWN))\n self.wait(2)\n self.play(FadeOut(layers), FadeOut(arrow1), FadeOut(arrow2), FadeOut(header))\n\n def show_cpu_registers(self):\n header = Text('CPU Registers (x86-64)', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n regs = ['%rax', '%rbx', '%rcx', '%rdx', '%rsi', '%rdi']\n reg_group = VGroup()\n for r in regs:\n box = Rectangle(width=3, height=0.8, color=WHITE)\n label = Text(r, font_size=28, font='Monospace', color=YELLOW).move_to(box.get_center())\n reg_group.add(VGroup(box, label))\n else:\n pass\n reg_group.arrange_in_grid(rows=3, cols=2, buff=0.5)\n reg_group.next_to(header, DOWN, buff=1.0)\n self.play(LaggedStart(*[FadeIn(rg, shift=UP) for rg in reg_group], lag_ratio=0.15))\n self.wait(2)\n self.play(FadeOut(reg_group), FadeOut(header))\n\n def show_instruction_anatomy(self):\n header = Text('Anatomy of an Assembly Instruction', font_size=40, color=BLUE).to_edge(UP)\n self.play(Write(header))\n p1 = Text('addq', font_size=48, font='Monospace', color=YELLOW)\n p2 = Text('%rbx', font_size=48, font='Monospace', color=GREEN)\n p3 = Text(',', font_size=48, font='Monospace')\n p4 = Text('%rax', font_size=48, font='Monospace', color=RED)\n inst_group = VGroup(p1, p2, p3, p4).arrange(RIGHT, buff=0.3).move_to(ORIGIN)\n self.play(FadeIn(inst_group))\n l1 = Text('Opcode', font_size=24, color=YELLOW).next_to(p1, DOWN, buff=1)\n a1 = Arrow(l1.get_top(), p1.get_bottom(), color=YELLOW, buff=0.1)\n l2 = Text('Source Operand', font_size=24, color=GREEN).next_to(p2, UP, buff=1)\n a2 = Arrow(l2.get_bottom(), p2.get_top(), color=GREEN, buff=0.1)\n l3 = Text('Destination Operand', font_size=24, color=RED).next_to(p4, DOWN, buff=1)\n a3 = Arrow(l3.get_top(), p4.get_bottom(), color=RED, buff=0.1)\n self.play(Write(l1), GrowArrow(a1))\n self.wait(1)\n self.play(Write(l2), GrowArrow(a2))\n self.wait(1)\n self.play(Write(l3), GrowArrow(a3))\n self.wait(3)\n self.play(FadeOut(inst_group), FadeOut(l1), FadeOut(l2), FadeOut(l3), FadeOut(a1), FadeOut(a2), FadeOut(a3), FadeOut(header))\n\n def show_summary(self):\n summary_title = Text('Summary', font_size=48, color=BLUE).to_edge(UP)\n pts = VGroup(Text('1. Compilers translate High-Level Code to Assembly.', font_size=28), Text('2. Assemblers convert Assembly to Machine Code.', font_size=28), Text('3. Instructions consist of Opcodes and Operands.', font_size=28), Text('4. Registers provide fast, temporary storage for the CPU.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.6).center()\n self.play(Write(summary_title))\n self.play(LaggedStart(*[FadeIn(p, shift=RIGHT) for p in pts], lag_ratio=0.4))\n self.wait(4)\n self.play(FadeOut(summary_title), FadeOut(pts))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starts with the text \"Let's learn about quadratic functions!\" then transitions to showing the general quadratic formula \"f(x) = ax^2 + bx + c\"? After that, could you replace it with a specific example of a quadratic function, say \"f(x) = 2x^2 - 3x + 1\", and graph this specific function? Lastly, can you highlight the vertex of the parabola and conclude with showing the formula to find the vertex of a quadratic function?", "chosen": "```python\nfrom manim import *\n\nclass QuadraticFunctionLesson(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction\n # Display the introductory text clearly\n # ------------------------------------------------------------------\n intro_text = Text(\"Let's learn about quadratic functions!\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n\n # ------------------------------------------------------------------\n # 2. General Formula\n # Transition smoothly to the general quadratic formula\n # Splitting strings helps Manim match parts during Transform\n # ------------------------------------------------------------------\n general_formula = MathTex(\n \"f(x)\", \"=\", \"ax^2\", \"+\", \"bx\", \"+\", \"c\", \n font_size=48\n )\n self.play(Write(general_formula))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Specific Example\n # Replace general formula with f(x) = 2x^2 - 3x + 1\n # ------------------------------------------------------------------\n specific_formula = MathTex(\n \"f(x)\", \"=\", \"2x^2\", \"-\", \"3x\", \"+\", \"1\", \n font_size=48\n )\n # TransformMatchingTex provides a smooth transition between formulas\n self.play(TransformMatchingTex(general_formula, specific_formula))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Graphing\n # Move the formula to the top to make space for the graph\n # ------------------------------------------------------------------\n self.play(specific_formula.animate.to_edge(UP))\n \n # Create axes with appropriate ranges for the function\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 4, 1],\n x_length=6,\n y_length=4,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n \n # Define the specific quadratic function mathematically\n def quadratic_func(x):\n return 2 * x**2 - 3 * x + 1\n \n # Plot the function on the axes\n graph = axes.plot(quadratic_func, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = 2x^2 - 3x + 1\", x_val=2.5, direction=UR)\n \n # Animate the creation of the axes and the graph\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Vertex Highlighting\n # Calculate vertex mathematically: x = -b/(2a), y = f(x)\n # For 2x^2 - 3x + 1: a=2, b=-3 -> x = 3/4 = 0.75\n # Vertex y = f(0.75) = 2(0.75)^2 - 3(0.75) + 1 = -0.125\n # ------------------------------------------------------------------\n a, b, c = 2, -3, 1\n vertex_x = -b / (2 * a) # 0.75\n vertex_y = quadratic_func(vertex_x) # -0.125\n \n # Create a red dot at the vertex position using axes coordinate mapping (c2p)\n vertex_dot = Dot(axes.c2p(vertex_x, vertex_y), color=RED)\n vertex_label = MathTex(\"(0.75, -0.125)\", font_size=30).next_to(vertex_dot, UR)\n \n # Highlight the vertex\n self.play(Create(vertex_dot), Write(vertex_label))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Conclusion\n # Display the formula used to find the vertex x-coordinate\n # ------------------------------------------------------------------\n conclusion_text = Text(\"To find the x-coordinate of the vertex:\", font_size=32).to_edge(DOWN).shift(UP)\n vertex_formula = MathTex(\"x\", \"=\", \"-\\\\frac{b}{2a}\", font_size=48, color=YELLOW).next_to(conclusion_text, DOWN)\n \n self.play(FadeOut(vertex_label), Write(conclusion_text), Write(vertex_formula))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py QuadraticFunctionLesson\n```", "rejected": "```python\nfrom manim import *\n\nclass QuadraticFunctionLesson(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction\n # Display the introductory text clearly\n # ------------------------------------------------------------------\n intro_text = Text(\"Let's learn about quadratic functions!\", font_size=36)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n\n # ------------------------------------------------------------------\n # 2. General Formula\n # Transition smoothly to the general quadratic formula\n # Splitting strings helps Manim match parts during Transform\n # ------------------------------------------------------------------\n general_formula = MathTex(\n \"f(x)\", \"=\", \"ax^2\", \"+\", \"bx\", \"+\", \"c\", \n font_size=48\n )\n self.play(Write(general_formula))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Specific Example\n # Replace general formula with f(x) = 2x^2 - 3x + 1\n # ------------------------------------------------------------------\n specific_formula = MathTex(\n \"f(x)\", \"=\", \"2x^2\", \"-\", \"3x\", \"+\", \"1\", \n font_size=48\n )\n # TransformMatchingTex provides a smooth transition between formulas\n self.play(TransformMatchingTex(general_formula, specific_formula))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Graphing\n # Move the formula to the top to make space for the graph\n # ------------------------------------------------------------------\n self.play(specific_formula.animate.to_edge(UP))\n \n # Create axes with appropriate ranges for the function\n axes = Axes(label_font_size=24, \n x_range=[-1, 3, 1],\n y_range=[-1, 4, 1],\n x_length=6,\n y_length=4,\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n )\n \n # Define the specific quadratic function mathematically\n def quadratic_func(x):\n return 2 * x**2 - 3 * x + 1\n \n # Plot the function on the axes\n graph = axes.plot(quadratic_func, color=BLUE)\n graph_label = axes.get_graph_label(graph, label=\"f(x) = 2x^2 - 3x + 1\", x_val=2.5, direction=UR)\n \n # Animate the creation of the axes and the graph\n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Vertex Highlighting\n # Calculate vertex mathematically: x = -b/(2a), y = f(x)\n # For 2x^2 - 3x + 1: a=2, b=-3 -> x = 3/4 = 0.75\n # Vertex y = f(0.75) = 2(0.75)^2 - 3(0.75) + 1 = -0.125\n # ------------------------------------------------------------------\n a, b, c = 2, -3, 1\n vertex_x = -b / (2 * a) # 0.75\n vertex_y = quadratic_func(vertex_x) # -0.125\n \n # Create a red dot at the vertex position using axes coordinate mapping (c2p)\n vertex_dot = Dot(axes.c2p(vertex_x, vertex_y), color=RED)\n vertex_label = MathTex(\"(0.75, -0.125)\", font_size=30).next_to(vertex_dot, UR)\n \n # Highlight the vertex\n self.play(Create(vertex_dot), Write(vertex_label))\n self.wait(2)\n\n # ------------------------------------------------------------------\n # 6. Conclusion\n # Display the formula used to find the vertex x-coordinate\n # ------------------------------------------------------------------\n conclusion_text = Text(\"To find the x-coordinate of the vertex:\", font_size=32).to_edge(DOWN).shift(UP)\n vertex_formula = MathTex(\"x\", \"=\", \"-\\\\frac{b}{2a}\", font_size=48, color=YELLOW).next_to(conclusion_text, DOWN)\n \n self.play(FadeOut(vertex_label), Write(conclusion_text), Write(vertex_formula))\n self.wait(3)\n\n# To run this animation, use the command:\n# manim -pql filename.py QuadraticFunctionLesson\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 an animation that demonstrates the approximation of a sine wave using a simple polynomial. Start by showing a coordinate system that spans from 0 to 10 on the x-axis and -2 to 2 on the y-axis. Then plot the \n- Act 2: 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: Here’s an enhanced version of the animation that retains all the original features while adding significant new elements: ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0463(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_sineapproximation()\n self.clear_stage()\n self.act_2_circumscribeanimation()\n self.clear_stage()\n self.act_3_enhancedrectangleanimati()\n\n def act_1_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n )\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Create(axes), Write(title))\n\n # 3. Sine Wave Plot\n # Plot the actual sine wave function on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n self.play(Create(sine_curve))\n # Constraint: Pause briefly after this step to allow the viewer to observe the curve\n self.wait(2)\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series approximation)\n # P(x) = x - x^3/3! + x^5/5!\n polynomial_curve = axes.plot(\n lambda x: x - x**3/6 + x**5/120, \n color=GREEN,\n x_range=[0, 3.5] # Limit range so it stays within the y-axis bounds for visibility\n )\n self.play(Create(polynomial_curve))\n # Constraint: Pause briefly after this step\n self.wait(2)\n\n # 5. Specific Point Marker\n # Place a red dot exactly at the point on the sine curve where x = pi\n x_val = np.pi\n y_val = np.sin(x_val)\n point_on_sine = axes.c2p(x_val, y_val)\n red_dot = Dot(point_on_sine, color=RED)\n self.play(FadeIn(red_dot))\n\n # 6. Projection Line\n # From the red dot, draw a dashed yellow vertical line straight down to the x-axis\n projection_line = DashedLine(\n start=point_on_sine,\n end=axes.c2p(x_val, 0),\n color=YELLOW\n )\n self.play(Create(projection_line))\n \n # Final pause to observe the complete scene\n self.wait(3)\n\n def act_2_circumscribeanimation(self):\n intro_text = Text(\"Circumscribe\", font_size=36)\n intro_text.to_edge(DOWN)\n \n # Animate the text appearing and moving upwards\n self.play(Write(intro_text))\n self.play(intro_text.animate.shift(UP * 3))\n \n # Fade out intro text before the main animation begins\n self.play(FadeOut(intro_text))\n\n # --- 2. Main Animation Sequence ---\n # Display the text \"Look Here\"\n main_text = Text(\"Look Here\", font_size=48)\n self.play(Write(main_text))\n \n # Draw a rectangle that automatically adjusts its size to fit the text\n # SurroundingRectangle dynamically calculates the bounding box\n rect = SurroundingRectangle(main_text, color=YELLOW, buff=0.2)\n self.play(Create(rect))\n \n # Transform the rectangle into a circle that continues to highlight the text\n # Calculate the radius from the center to a corner of the rectangle to ensure full coverage\n circle_radius = np.linalg.norm(rect.get_critical_point(UL) - rect.get_center())\n circle = Circle(radius=circle_radius, color=YELLOW).move_to(main_text)\n \n self.play(ReplacementTransform(rect, circle))\n self.wait(0.5)\n \n # Animate the text and the highlighter disappearing from the screen\n self.play(FadeOut(main_text), FadeOut(circle))\n\n def act_3_enhancedrectangleanimati(self):\n rect = Rectangle(width=3, height=4, color=ORANGE)\n \n # Animate the rectangle fading in while rotating\n self.play(\n Create(rect),\n Rotate(rect, angle=2*PI, rate_func=linear),\n run_time=2\n )\n self.wait(0.5)\n \n # Split the rectangle into four smaller rectangles\n colors = [BLUE, GREEN, RED, PURPLE]\n small_rects = VGroup(*[\n Rectangle(width=1.5, height=2, color=color).move_to(\n rect.get_center() + np.array([dx, dy, 0])\n )\n for color, (dx, dy) in zip(\n colors,\n [(-0.75, 1), (0.75, 1), (-0.75, -1), (0.75, -1)]\n )\n ])\n \n # Transform the original rectangle into the four smaller ones\n self.play(\n Transform(rect, small_rects),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Show the area formula\n formula = MathTex(\n r\"\\text{Area} = \\text{width} \\times \\text{height} = 3 \\times 4 = 12\",\n font_size=36\n ).next_to(small_rects, DOWN, buff=1)\n \n # Fade in the formula with a bounce effect\n self.play(\n Write(formula),\n formula.animate.scale(1.2).set_color(YELLOW),\n run_time=1\n )\n self.play(\n formula.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show the original rectangle as a faint outline\n ghost_rect = rect.copy().set_fill(opacity=0).set_stroke(ORANGE, opacity=0.3)\n self.add(ghost_rect)\n self.wait(1)\n \n # Fade out all elements in sequence\n self.play(\n FadeOut(small_rects),\n FadeOut(formula),\n FadeOut(ghost_rect),\n run_time=1.5\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0463(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_sineapproximation()\n self.clear_stage()\n self.act_2_circumscribeanimation()\n self.clear_stage()\n self.act_3_enhancedrectangleanimati()\n\n def act_1_sineapproximation(self):\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_tip\": True}\n )\n\n # 2. Title\n # Display the text at the top of the scene\n title = Text(\"Sine wave approximation with polynomials.\", font_size=36)\n title.to_edge(UP)\n \n self.play(Create(axes), Write(title))\n\n # 3. Sine Wave Plot\n # Plot the actual sine wave function on the defined axes\n sine_curve = axes.plot(lambda x: np.sin(x), color=BLUE)\n self.play(Create(sine_curve))\n # Constraint: Pause briefly after this step to allow the viewer to observe the curve\n self.wait(2)\n\n # 4. Polynomial Approximation\n # Draw a green polynomial curve (5th order Taylor series approximation)\n # P(x) = x - x^3/3! + x^5/5!\n polynomial_curve = axes.plot(\n lambda x: x - x**3/6 + x**5/120, \n color=GREEN,\n x_range=[0, 3.5] # Limit range so it stays within the y-axis bounds for visibility\n )\n self.play(Create(polynomial_curve))\n # Constraint: Pause briefly after this step\n self.wait(2)\n\n # 5. Specific Point Marker\n # Place a red dot exactly at the point on the sine curve where x = pi\n x_val = np.pi\n y_val = np.sin(x_val)\n point_on_sine = axes.c2p(x_val, y_val)\n red_dot = Dot(point_on_sine, color=RED)\n self.play(FadeIn(red_dot))\n\n # 6. Projection Line\n # From the red dot, draw a dashed yellow vertical line straight down to the x-axis\n projection_line = DashedLine(\n start=point_on_sine,\n end=axes.c2p(x_val, 0),\n color=YELLOW\n )\n self.play(Create(projection_line))\n \n # Final pause to observe the complete scene\n self.wait(3)\n\n def act_2_circumscribeanimation(self):\n intro_text = Text(\"Circumscribe\", font_size=36)\n intro_text.to_edge(DOWN)\n \n # Animate the text appearing and moving upwards\n self.play(Write(intro_text))\n self.play(intro_text.animate.shift(UP * 3))\n \n # Fade out intro text before the main animation begins\n self.play(FadeOut(intro_text))\n\n # --- 2. Main Animation Sequence ---\n # Display the text \"Look Here\"\n main_text = Text(\"Look Here\", font_size=48)\n self.play(Write(main_text))\n \n # Draw a rectangle that automatically adjusts its size to fit the text\n # SurroundingRectangle dynamically calculates the bounding box\n rect = SurroundingRectangle(main_text, color=YELLOW, buff=0.2)\n self.play(Create(rect))\n \n # Transform the rectangle into a circle that continues to highlight the text\n # Calculate the radius from the center to a corner of the rectangle to ensure full coverage\n circle_radius = np.linalg.norm(rect.get_critical_point(UL) - rect.get_center())\n circle = Circle(radius=circle_radius, color=YELLOW).move_to(main_text)\n \n self.play(ReplacementTransform(rect, circle))\n self.wait(0.5)\n \n # Animate the text and the highlighter disappearing from the screen\n self.play(FadeOut(main_text), FadeOut(circle))\n\n def act_3_enhancedrectangleanimati(self):\n rect = Rectangle(width=3, height=4, color=ORANGE)\n \n # Animate the rectangle fading in while rotating\n self.play(\n Create(rect),\n Rotate(rect, angle=2*PI, rate_func=linear),\n run_time=2\n )\n self.wait(0.5)\n \n # Split the rectangle into four smaller rectangles\n colors = [BLUE, GREEN, RED, PURPLE]\n small_rects = VGroup(*[\n Rectangle(width=1.5, height=2, color=color).move_to(\n rect.get_center() + np.array([dx, dy, 0])\n )\n for color, (dx, dy) in zip(\n colors,\n [(-0.75, 1), (0.75, 1), (-0.75, -1), (0.75, -1)]\n )\n ])\n \n # Transform the original rectangle into the four smaller ones\n self.play(\n Transform(rect, small_rects),\n run_time=1.5\n )\n self.wait(0.5)\n \n # Show the area formula\n formula = MathText(\n r\"\\text{Area} = \\text{width} \\times \\text{height} = 3 \\times 4 = 12\",\n font_size=36\n ).next_to(small_rects, DOWN, buff=1)\n \n # Fade in the formula with a bounce effect\n self.play(\n Write(formula),\n formula.animate.scale(1.2).set_color(YELLOW),\n run_time=1\n )\n self.play(\n formula.animate.scale(1/1.2),\n run_time=0.5\n )\n \n # Show the original rectangle as a faint outline\n ghost_rect = rect.copy().set_fill(opacity=0).set_stroke(ORANGE, opacity=0.3)\n self.add(ghost_rect)\n self.wait(1)\n \n # Fade out all elements in sequence\n self.play(\n FadeOut(small_rects),\n FadeOut(formula),\n FadeOut(ghost_rect),\n run_time=1.5\n )\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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\nIn this advanced version, the animation will not only transform a triangle into a circle while rotating it but will also visually demonstrate the mathematical relationship between the two shapes by dynamically displaying the area formulas for both. The scene begins with a blue triangle appearing on the screen, accompanied by the text \"Area = (base × height)/2\" fading in below it. As the triangle rotates 90 degrees (π/2 radians) clockwise, it simultaneously morphs into a red circle, with the transformation smoothly interpolating the vertices into a continuous curve. During this transition, the area formula text seamlessly transforms into \"Area = πr²,\" where the radius (r) is derived from the original triangle’s height for continuity. To reinforce the connection, a radius line appears in the circle, labeled with its length, and a brief highlight effect emphasizes the formulas. Finally, the circle pulses gently to draw attention, and a concluding text fades in, summarizing the transformation: \"A triangle can be smoothly deformed into a circle while preserving area.\" This enriched animation provides both visual and analytical insight into geometric transformations.", "chosen": "```python\nfrom manim import *\n\nclass TriangleToCircleWithArea(Scene):\n def construct(self):\n # Create triangle\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```", "rejected": "```python\nfrom manim import *\n\nclass TriangleToCircleWithArea(Scene):\n def construct(self):\n # Create triangle\n triangle = Polygon(\n [-2, -1, 0], [2, -1, 0], [0, 1, 0],\n color=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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_0184(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_orthogonalityscene()\n self.clear_stage()\n self.act_2_quickshapesequence()\n self.clear_stage()\n self.act_3_integralanimation()\n\n def act_1_orthogonalityscene(self):\n title = Text(\"Orthogonality in Linear Algebra\")\n title.scale(1.2)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Orthogonal vectors\n vector_a = Vector([2, 1], color=BLUE)\n vector_b = Vector([1, -2], color=RED)\n vector_a_label = MathTex(\"\\\\mathbf{a}\", color=BLUE).next_to(vector_a, UP, buff=0.2)\n vector_b_label = MathTex(\"\\\\mathbf{b}\", color=RED).next_to(vector_b, LEFT, buff=0.2)\n self.play(Create(vector_a), Create(vector_a_label))\n self.play(Create(vector_b), Create(vector_b_label))\n self.wait(2)\n\n # Orthogonal subspace\n subspace_plane = Rectangle(width=4, height=1, color=GREEN, fill_opacity=0.3)\n subspace_label = Text(\"Orthogonal Subspace\", color=GREEN).next_to(subspace_plane, LEFT)\n subspace_label.scale(0.5)\n self.play(Create(subspace_plane), Write(subspace_label))\n self.wait(2)\n\n # Projection of vector_a onto subspace\n projection_arrow = Arrow(UP, DOWN, color=YELLOW)\n projection_arrow.next_to(vector_a, DOWN, buff=0.1)\n projection_label = Text(\"Projection\", color=YELLOW).next_to(projection_arrow, RIGHT, buff=0.2)\n self.play(Create(projection_arrow), Write(projection_label))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Orthogonality plays a crucial role in linear algebra, \\ninfluencing vector spaces and projections.\")\n conclusion.scale(0.7)\n conclusion.next_to(vector_b, DOWN, buff=0.5)\n self.play(Write(conclusion))\n self.wait(3)\n\n # Fade out all objects\n self.play(\n FadeOut(title),\n FadeOut(vector_a),\n FadeOut(vector_b),\n FadeOut(vector_a_label),\n FadeOut(vector_b_label),\n FadeOut(subspace_plane),\n FadeOut(subspace_label),\n FadeOut(projection_arrow),\n FadeOut(projection_label),\n FadeOut(conclusion),\n )\n\n def act_2_quickshapesequence(self):\n text = Text(\"Animation Start\", font_size=36).shift(DOWN * 2)\n self.play(Write(text), text.animate.shift(UP * 4), run_time=0.75)\n\n # 2. Appearance: A circle appears on the screen\n circle = Circle(radius=1.0, color=BLUE)\n self.play(Create(circle), run_time=0.5)\n\n # 3. Pause: Insert a brief pause immediately after the circle appears\n self.wait(0.3)\n\n # Store the original center position for the final return step\n original_position = circle.get_center()\n\n # 4. Transformation: The circle transforms into a red square\n square = Square(side_length=2.0, color=RED, fill_color=RED, fill_opacity=1.0)\n self.play(ReplacementTransform(circle, square), run_time=0.5)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN * 2 + RIGHT * 2), run_time=0.75)\n\n # 6. Shift & Rotate: The square shifts further right and rotates slightly\n self.play(square.animate.shift(RIGHT * 1).rotate(30 * DEGREES), run_time=0.75)\n\n # 7. Pause: Insert a brief pause immediately after the rotation\n self.wait(0.3)\n\n # 8. Reversion: The square reverts back to a circle\n final_circle = Circle(radius=1.0, color=BLUE)\n self.play(ReplacementTransform(square, final_circle), run_time=0.5)\n\n # 9. Return: The circle returns to its original position\n self.play(final_circle.animate.move_to(original_position), run_time=0.75)\n\n def act_3_integralanimation(self):\n func_text = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0184(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_orthogonalityscene()\n self.clear_stage()\n self.act_2_quickshapesequence()\n self.clear_stage()\n self.act_3_integralanimation()\n\n def act_1_orthogonalityscene(self):\n title = Text(\"Orthogonality in Linear Algebra\")\n title.scale(1.2)\n title.to_edge(UP)\n self.play(Write(title))\n\n # Orthogonal vectors\n vector_a = Vector([2, 1], color=BBLUE)\n vector_b = Vector([1, -2], color=RED)\n vector_a_label = MathTex(\"\\\\mathbf{a}\", color=BLUE).next_to(vector_a, UP, buff=0.2)\n vector_b_label = MathTex(\"\\\\mathbf{b}\", color=RED).next_to(vector_b, LEFT, buff=0.2)\n self.play(Create(vector_a), Create(vector_a_label))\n self.play(Create(vector_b), Create(vector_b_label))\n self.wait(2)\n\n # Orthogonal subspace\n subspace_plane = Rectangle(width=4, height=1, color=GREEN, fill_opacity=0.3)\n subspace_label = Text(\"Orthogonal Subspace\", color=GREEN).next_to(subspace_plane, LEFT)\n subspace_label.scale(0.5)\n self.play(Create(subspace_plane), Write(subspace_label))\n self.wait(2)\n\n # Projection of vector_a onto subspace\n projection_arrow = Arrow(UP, DOWN, color=YELLOW)\n projection_arrow.next_to(vector_a, DOWN, buff=0.1)\n projection_label = Text(\"Projection\", color=YELLOW).next_to(projection_arrow, RIGHT, buff=0.2)\n self.play(Create(projection_arrow), Write(projection_label))\n self.wait(2)\n\n # Conclusion\n conclusion = Text(\"Orthogonality plays a crucial role in linear algebra, \\ninfluencing vector spaces and projections.\")\n conclusion.scale(0.7)\n conclusion.next_to(vector_b, DOWN, buff=0.5)\n self.play(Write(conclusion))\n self.wait(3)\n\n # Fade out all objects\n self.play(\n FadeOut(title),\n FadeOut(vector_a),\n FadeOut(vector_b),\n FadeOut(vector_a_label),\n FadeOut(vector_b_label),\n FadeOut(subspace_plane),\n FadeOut(subspace_label),\n FadeOut(projection_arrow),\n FadeOut(projection_label),\n FadeOut(conclusion),\n )\n\n def act_2_quickshapesequence(self):\n text = Text(\"Animation Start\", font_size=36).shift(DOWN * 2)\n self.play(Write(text), text.animate.shift(UP * 4), run_time=0.75)\n\n # 2. Appearance: A circle appears on the screen\n circle = Circle(radius=1.0, color=BLUE)\n self.play(Create(circle), run_time=0.5)\n\n # 3. Pause: Insert a brief pause immediately after the circle appears\n self.wait(0.3)\n\n # Store the original center position for the final return step\n original_position = circle.get_center()\n\n # 4. Transformation: The circle transforms into a red square\n square = Square(side_length=2.0, color=RED, fill_color=RED, fill_opacity=1.0)\n self.play(ReplacementTransform(circle, square), run_time=0.5)\n\n # 5. Movement: The red square moves downwards and to the right\n self.play(square.animate.shift(DOWN * 2 + RIGHT * 2), run_time=0.75)\n\n # 6. Shift & Rotate: The square shifts further right and rotates slightly\n self.play(square.animate.shift(RIGHT * 1).rotate(30 * DEGREES), run_time=0.75)\n\n # 7. Pause: Insert a brief pause immediately after the rotation\n self.wait(0.3)\n\n # 8. Reversion: The square reverts back to a circle\n final_circle = Circle(radius=1.0, color=BLUE)\n self.play(ReplacementTransform(square, final_circle), run_time=0.5)\n\n # 9. Return: The circle returns to its original position\n self.play(final_circle.animate.move_to(original_position), run_time=0.75)\n\n def act_3_integralanimation(self):\n func_text = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 simple water molecule which consists of two hydrogen atoms and one oxygen atom, with each atom represented as a colored circle. The oxygen atom should be larger and colored blue to stand out as the central element, while the hydrogen atoms should be smaller and white. There should be lines connecting the hydrogen atoms to the oxygen atom to represent the chemical bonds. Additionally, I want each atom to be labeled with its respective chemical symbol, 'O' for oxygen and 'H' for hydrogen, directly on the atoms. Once constructed, I want the molecule to increase in size to become more noticeable and then rotate around in the scene to be viewed from different angles. Can you create an animation like this, and end with the molecule on screen long enough to make an impression?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaterMoleculeScene(ThreeDScene):\n def construct(self):\n # --- Molecular Parameters ---\n oxygen_radius = 0.6\n hydrogen_radius = 0.3\n bond_length = 1.2\n bond_angle_degrees = 104.5\n \n # --- Colors ---\n oxygen_color = BLUE\n hydrogen_color = WHITE\n oxygen_label_color = WHITE\n hydrogen_label_color = BLACK\n \n # --- Create Oxygen Atom ---\n oxygen = Circle(radius=oxygen_radius, color=oxygen_color, fill_opacity=1)\n label_o = Text(\"O\", color=oxygen_label_color, weight=BOLD, font_size=36)\n label_o.move_to(oxygen.get_center())\n oxygen_group = VGroup(oxygen, label_o)\n \n # --- Create Hydrogen Atoms ---\n # Calculate positions based on the bent molecular geometry of H2O\n half_angle = bond_angle_degrees / 2 * DEGREES\n h1_pos = np.array([bond_length * np.sin(half_angle), -bond_length * np.cos(half_angle), 0])\n h2_pos = np.array([-bond_length * np.sin(half_angle), -bond_length * np.cos(half_angle), 0])\n \n hydrogen1 = Circle(radius=hydrogen_radius, color=hydrogen_color, fill_opacity=1)\n hydrogen1.move_to(h1_pos)\n label_h1 = Text(\"H\", color=hydrogen_label_color, weight=BOLD, font_size=24)\n label_h1.move_to(hydrogen1.get_center())\n h1_group = VGroup(hydrogen1, label_h1)\n \n hydrogen2 = Circle(radius=hydrogen_radius, color=hydrogen_color, fill_opacity=1)\n hydrogen2.move_to(h2_pos)\n label_h2 = Text(\"H\", color=hydrogen_label_color, weight=BOLD, font_size=24)\n label_h2.move_to(hydrogen2.get_center())\n h2_group = VGroup(hydrogen2, label_h2)\n \n # --- Create Chemical Bonds ---\n bond1 = Line(oxygen.get_center(), hydrogen1.get_center(), color=GRAY, stroke_width=6)\n bond2 = Line(oxygen.get_center(), hydrogen2.get_center(), color=GRAY, stroke_width=6)\n \n # --- Group Molecule Components ---\n # Order ensures bonds are rendered behind atoms and labels\n molecule = VGroup(bond1, bond2, oxygen_group, h1_group, h2_group)\n \n # --- Animation Sequence ---\n \n # 1. Construct the static molecule structure\n self.play(Create(bond1), Create(bond2), run_time=1)\n self.play(\n FadeIn(oxygen_group),\n FadeIn(h1_group),\n FadeIn(h2_group),\n run_time=1\n )\n self.wait(0.5)\n \n # 2. Animate a scaling effect (increase in size)\n self.play(molecule.animate.scale(1.5), run_time=1.5)\n self.wait(0.5)\n \n # 3. Animate a 3D rotation to view from different angles\n self.set_camera_orientation(phi=0, theta=0)\n \n # Rotate the molecule around the X-axis to show depth\n self.play(\n Rotate(molecule, angle=PI / 2, axis=RIGHT, about_point=ORIGIN),\n run_time=2\n )\n \n # Move the camera to a 3D isometric perspective\n self.move_camera(phi=75 * DEGREES, theta=-45 * DEGREES, run_time=2)\n \n # Rotate the molecule around the Z-axis for a full view\n self.play(\n Rotate(molecule, angle=PI, axis=OUT, about_point=ORIGIN),\n run_time=2\n )\n \n # 4. Conclude with a pause to leave a lasting impression\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass WaterMoleculeScene(ThreeDScene):\n def construct(self):\n # --- Molecular Parameters ---\n oxygen_radius = 0.6\n hydrogen_radius = 0.3\n bond_length = 1.2\n bond_angle_degrees = 104.5\n \n # --- Colors ---\n oxygen_color = BBLUE\n hydrogen_color = WHITE\n oxygen_label_color = WHITE\n hydrogen_label_color = BLACK\n \n # --- Create Oxygen Atom ---\n oxygen = Circle(radius=oxygen_radius, color=oxygen_color, fill_opacity=1)\n label_o = Text(\"O\", color=oxygen_label_color, weight=BOLD, font_size=36)\n label_o.move_to(oxygen.get_center())\n oxygen_group = VGroup(oxygen, label_o)\n \n # --- Create Hydrogen Atoms ---\n # Calculate positions based on the bent molecular geometry of H2O\n half_angle = bond_angle_degrees / 2 * DEGREES\n h1_pos = np.array([bond_length * np.sin(half_angle), -bond_length * np.cos(half_angle), 0])\n h2_pos = np.array([-bond_length * np.sin(half_angle), -bond_length * np.cos(half_angle), 0])\n \n hydrogen1 = Circle(radius=hydrogen_radius, color=hydrogen_color, fill_opacity=1)\n hydrogen1.move_to(h1_pos)\n label_h1 = Text(\"H\", color=hydrogen_label_color, weight=BOLD, font_size=24)\n label_h1.move_to(hydrogen1.get_center())\n h1_group = VGroup(hydrogen1, label_h1)\n \n hydrogen2 = Circle(radius=hydrogen_radius, color=hydrogen_color, fill_opacity=1)\n hydrogen2.move_to(h2_pos)\n label_h2 = Text(\"H\", color=hydrogen_label_color, weight=BOLD, font_size=24)\n label_h2.move_to(hydrogen2.get_center())\n h2_group = VGroup(hydrogen2, label_h2)\n \n # --- Create Chemical Bonds ---\n bond1 = Line(oxygen.get_center(), hydrogen1.get_center(), color=GRAY, stroke_width=6)\n bond2 = Line(oxygen.get_center(), hydrogen2.get_center(), color=GRAY, stroke_width=6)\n \n # --- Group Molecule Components ---\n # Order ensures bonds are rendered behind atoms and labels\n molecule = VGroup(bond1, bond2, oxygen_group, h1_group, h2_group)\n \n # --- Animation Sequence ---\n \n # 1. Construct the static molecule structure\n self.play(Create(bond1), Create(bond2), run_time=1)\n self.play(\n FadeIn(oxygen_group),\n FadeIn(h1_group),\n FadeIn(h2_group),\n run_time=1\n )\n self.wait(0.5)\n \n # 2. Animate a scaling effect (increase in size)\n self.play(molecule.animate.scale(1.5), run_time=1.5)\n self.wait(0.5)\n \n # 3. Animate a 3D rotation to view from different angles\n self.set_camera_orientation(phi=0, theta=0)\n \n # Rotate the molecule around the X-axis to show depth\n self.play(\n Rotate(molecule, angle=PI / 2, axis=RIGHT, about_point=ORIGIN),\n run_time=2\n )\n \n # Move the camera to a 3D isometric perspective\n self.move_camera(phi=75 * DEGREES, theta=-45 * DEGREES, run_time=2)\n \n # Rotate the molecule around the Z-axis for a full view\n self.play(\n Rotate(molecule, angle=PI, axis=OUT, about_point=ORIGIN),\n run_time=2\n )\n \n # 4. Conclude with a pause to leave a lasting impression\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the concept of the one-dimensional wave equation using math formulas. Start with the wave equation itself, then provide a brief explanation that this represents a one-dimensional wave equation. Next, show an important aspect of seeking solutions for this wave equation where the solutions take the form of two functions, one moving forward and one moving backward in time. Transition to the general form of the wave solution that combines these two functions. Lastly, mention that in the case of harmonic waves, these functions could be sine or cosine. Allow brief pauses between each step to let viewers digest the information, and clear the screen towards the end before presenting the final wave solution one more time for emphasis.", "chosen": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\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 )\n wave_eq.to_edge(UP)\n \n self.play(Write(wave_eq))\n self.wait(1)\n\n # --- Step 2: Provide Context ---\n context_text = Text(\n \"The One-Dimensional Wave Equation\",\n font_size=36,\n color=GRAY_B\n )\n context_text.next_to(wave_eq, DOWN)\n \n self.play(FadeIn(context_text))\n self.wait(1.5)\n\n # --- Step 3: Illustrate Solution Components ---\n # Define the two traveling wave components with distinct colors\n func_forward = MathTex(r\"f(x - ct)\", color=BLUE, font_size=42)\n arrow_forward = Arrow(start=LEFT, end=RIGHT, color=BLUE, buff=0.5)\n group_forward = VGroup(func_forward, arrow_forward).arrange(RIGHT)\n label_forward = Text(\"Forward Propagation\", font_size=24, color=BLUE)\n component_forward = VGroup(group_forward, label_forward).arrange(DOWN)\n\n func_backward = MathTex(r\"g(x + ct)\", color=GREEN, font_size=42)\n arrow_backward = Arrow(start=RIGHT, end=LEFT, color=GREEN, buff=0.5)\n group_backward = VGroup(func_backward, arrow_backward).arrange(RIGHT)\n label_backward = Text(\"Backward Propagation\", font_size=24, color=GREEN)\n component_backward = VGroup(group_backward, label_backward).arrange(DOWN)\n\n # Position components side by side\n components = VGroup(component_forward, component_backward).arrange(RIGHT, buff=1.5)\n components.next_to(context_text, DOWN)\n\n self.play(\n FadeOut(context_text),\n FadeIn(component_forward),\n FadeIn(component_backward)\n )\n self.wait(2)\n\n # --- Step 4: Show General Solution ---\n general_solution = MathTex(\n r\"u(x, t) = f(x - ct) + g(x + ct)\",\n font_size=48\n )\n general_solution.move_to(ORIGIN)\n\n # Highlight the terms in the general solution to match previous colors\n general_solution.set_color_by_tex(\"f(x - ct)\", BLUE)\n general_solution.set_color_by_tex(\"g(x + ct)\", GREEN)\n\n self.play(\n FadeOut(components),\n FadeOut(wave_eq),\n Write(general_solution)\n )\n self.wait(2)\n\n # --- Step 5: Harmonic Case ---\n harmonic_text = Text(\n \"For harmonic waves, these functions can be\",\n font_size=28\n )\n harmonic_equation = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t) + B \\cos(kx + \\omega t)\",\n font_size=36\n )\n harmonic_group = VGroup(harmonic_text, harmonic_equation).arrange(DOWN, buff=0.5)\n harmonic_group.next_to(general_solution, DOWN, buff=1)\n\n self.play(FadeIn(harmonic_group))\n self.wait(2)\n\n # --- Clear the Screen ---\n self.play(\n FadeOut(general_solution),\n FadeOut(harmonic_group)\n )\n self.wait(0.5)\n\n # --- Re-display Final Wave Solution ---\n final_solution = MathTex(\n r\"u(x, t) = f(x - ct) + g(x + ct)\",\n font_size=60\n )\n final_solution.set_color(YELLOW)\n final_solution.set_color_by_tex(\"f(x - ct)\", BLUE)\n final_solution.set_color_by_tex(\"g(x + ct)\", GREEN)\n\n final_label = Text(\n \"General Solution\",\n font_size=36,\n color=YELLOW\n )\n final_label.next_to(final_solution, DOWN)\n final_group = VGroup(final_solution, final_label)\n\n self.play(Write(final_group))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass WaveEquationAnimation(Scene):\n def construct(self):\n # --- Step 1: Display the Equation ---\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 )\n wave_eq.to_edge(UP)\n \n self.play(Write(wave_eq))\n self.wait(1)\n\n # --- Step 2: Provide Context ---\n context_text = Text(\n \"The One-Dimensional Wave Equation\",\n font_size=36,\n color=GRAY_B\n )\n context_text.next_to(wave_eq, DOWN)\n \n self.play(FadeIn(context_text))\n self.wait(1.5)\n\n # --- Step 3: Illustrate Solution Components ---\n # Define the two traveling wave components with distinct colors\n func_forward = MathTex(r\"f(x - ct)\", color=BBLUE, font_size=42)\n arrow_forward = Arrow(start=LEFT, end=RIGHT, color=BLUE, buff=0.5)\n group_forward = VGroup(func_forward, arrow_forward).arrange(RIGHT)\n label_forward = Text(\"Forward Propagation\", font_size=24, color=BLUE)\n component_forward = VGroup(group_forward, label_forward).arrange(DOWN)\n\n func_backward = MathTex(r\"g(x + ct)\", color=GREEN, font_size=42)\n arrow_backward = Arrow(start=RIGHT, end=LEFT, color=GREEN, buff=0.5)\n group_backward = VGroup(func_backward, arrow_backward).arrange(RIGHT)\n label_backward = Text(\"Backward Propagation\", font_size=24, color=GREEN)\n component_backward = VGroup(group_backward, label_backward).arrange(DOWN)\n\n # Position components side by side\n components = VGroup(component_forward, component_backward).arrange(RIGHT, buff=1.5)\n components.next_to(context_text, DOWN)\n\n self.play(\n FadeOut(context_text),\n FadeIn(component_forward),\n FadeIn(component_backward)\n )\n self.wait(2)\n\n # --- Step 4: Show General Solution ---\n general_solution = MathTex(\n r\"u(x, t) = f(x - ct) + g(x + ct)\",\n font_size=48\n )\n general_solution.move_to(ORIGIN)\n\n # Highlight the terms in the general solution to match previous colors\n general_solution.set_color_by_tex(\"f(x - ct)\", BLUE)\n general_solution.set_color_by_tex(\"g(x + ct)\", GREEN)\n\n self.play(\n FadeOut(components),\n FadeOut(wave_eq),\n Write(general_solution)\n )\n self.wait(2)\n\n # --- Step 5: Harmonic Case ---\n harmonic_text = Text(\n \"For harmonic waves, these functions can be\",\n font_size=28\n )\n harmonic_equation = MathTex(\n r\"u(x, t) = A \\sin(kx - \\omega t) + B \\cos(kx + \\omega t)\",\n font_size=36\n )\n harmonic_group = VGroup(harmonic_text, harmonic_equation).arrange(DOWN, buff=0.5)\n harmonic_group.next_to(general_solution, DOWN, buff=1)\n\n self.play(FadeIn(harmonic_group))\n self.wait(2)\n\n # --- Clear the Screen ---\n self.play(\n FadeOut(general_solution),\n FadeOut(harmonic_group)\n )\n self.wait(0.5)\n\n # --- Re-display Final Wave Solution ---\n final_solution = MathTex(\n r\"u(x, t) = f(x - ct) + g(x + ct)\",\n font_size=60\n )\n final_solution.set_color(YELLOW)\n final_solution.set_color_by_tex(\"f(x - ct)\", BLUE)\n final_solution.set_color_by_tex(\"g(x + ct)\", GREEN)\n\n final_label = Text(\n \"General Solution\",\n font_size=36,\n color=YELLOW\n )\n final_label.next_to(final_solution, DOWN)\n final_group = VGroup(final_solution, final_label)\n\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 in which you graph the function y=x^2 using an x and y axes range from 0 to 4, highlight the area under the curve from x=0 to x=2, label the curve with its equation, display a statement at the top that says \"Area under y=x^2 from x=0 to x=2\", and conclude the animation with a lower-thirds text that states \"Area is 8/3\"? Additionally, please make sure the axes are colored blue and the graph of the function is green.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Coordinate System\n # Range 0 to 4 for both axes, rendered in blue\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 4, 1],\n axis_config={\"color\": BLUE},\n )\n \n # 2. Function Graph\n # Plot y = x^2 in green\n graph = axes.plot(lambda x: x**2, color=GREEN, x_range=[0, 2])\n \n # Label attached directly to the curve\n label = MathTex(\"y = x^2\", color=GREEN).next_to(graph, UR, buff=0.2)\n \n # 3. Area Highlight\n # Highlight area under the curve from x=0 to x=2\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # 4. Text Elements\n # Top Statement\n top_text = Text(\"Area under y=x^2 from x=0 to x=2\", font_size=36).to_edge(UP)\n \n # Conclusion Lower-thirds Banner\n conclusion_text = Text(\"Area is 8/3\", font_size=36, color=WHITE)\n banner_rect = Rectangle(\n width=conclusion_text.width + 1, \n height=conclusion_text.height + 0.5, \n fill_color=BLACK, \n fill_opacity=0.8, \n stroke_width=0\n ).move_to(conclusion_text)\n conclusion_banner = VGroup(banner_rect, conclusion_text).to_edge(DOWN, buff=1.0)\n \n # Animation Sequence\n self.play(Create(axes))\n self.play(Write(top_text))\n self.wait(1)\n \n self.play(Create(graph), Write(label), run_time=2)\n self.wait(1)\n \n self.play(FadeIn(area))\n self.wait(1)\n \n self.play(FadeIn(conclusion_banner))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Coordinate System\n # Range 0 to 4 for both axes, rendered in blue\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 # 2. Function Graph\n # Plot y = x^2 in green\n graph = axes.plot(lambda x: x**2, color=GREEN, x_range=[0, 2])\n \n # Label attached directly to the curve\n label = MathTex(\"y = x^2\", color=GREEN).next_to(graph, UR, buff=0.2)\n \n # 3. Area Highlight\n # Highlight area under the curve from x=0 to x=2\n area = axes.get_area(graph, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # 4. Text Elements\n # Top Statement\n top_text = Text(\"Area under y=x^2 from x=0 to x=2\", font_size=36).to_edge(UP)\n \n # Conclusion Lower-thirds Banner\n conclusion_text = Text(\"Area is 8/3\", font_size=36, color=WHITE)\n banner_rect = Rectangle(\n width=conclusion_text.width + 1, \n height=conclusion_text.height + 0.5, \n fill_color=BLACK, \n fill_opacity=0.8, \n stroke_width=0\n ).move_to(conclusion_text)\n conclusion_banner = VGroup(banner_rect, conclusion_text).to_edge(DOWN, buff=1.0)\n \n # Animation Sequence\n self.play(Create(axes))\n self.play(Write(top_text))\n self.wait(1)\n \n self.play(Create(graph), Write(label), run_time=2)\n self.wait(1)\n \n self.play(FadeIn(area))\n self.wait(1)\n \n self.play(FadeIn(conclusion_banner))\n self.wait(3)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 create a short animation video using 2D shapes, where a circle transforms into a square. The video should start with a circle appearing on screen, then after a moment, the circle should seamlessly morph i\n- Act 2: I would like to create an educational animation that visually explains how to integrate the function e raised to the power of 2x with respect to x. The animation should start by displaying the integration problem, follow", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0144(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_shapetransformation()\n self.clear_stage()\n self.act_2_integrateexp()\n\n def act_1_shapetransformation(self):\n circle = Circle(radius=1.5, color=WHITE)\n self.play(Create(circle))\n self.wait(0.5)\n\n # 2. Morph: Circle seamlessly transforms into a square\n square = Square(side_length=3, color=WHITE)\n self.play(ReplacementTransform(circle, square))\n self.wait(0.5)\n\n # 3. Style Change: Change color to blue and apply transparency\n self.play(\n square.animate.set_fill(BLUE, opacity=0.5)\n .set_stroke(BLUE, opacity=0.8)\n )\n self.wait(0.5)\n\n # 4. Rotation: Rotate the square by 45 degrees\n self.play(Rotate(square, angle=45 * DEGREES))\n self.wait(0.5)\n\n # 5. Cleanup & Text: Clear shapes and display final phrase\n self.play(FadeOut(square))\n \n text = Text(\"Transformation complete!\", font_size=42)\n self.play(Write(text))\n self.wait(2)\n\n def act_2_integrateexp(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. Brief written explanation\n # Note: Correcting \"reverse power rule\" to \"reverse chain rule\" for mathematical accuracy\n explanation = Tex(\n \"We use the reverse chain rule (u-substitution) \\\\\\\\ \"\n \"to integrate this function.\"\n )\n explanation.scale(0.8)\n explanation.next_to(problem, DOWN, buff=1)\n \n self.play(Write(explanation))\n self.wait(3)\n\n # 3. Transform the function into its integrated form\n result = MathTex(r\"\\frac{1}{2}e^{2x} + C\")\n result.scale(1.5)\n \n self.play(\n ReplacementTransform(problem, result),\n FadeOut(explanation)\n )\n self.wait(3)\n\n # 4. Clear the screen\n self.clear()\n self.wait(1)\n\n # 5. Present the final integrated function once more\n final_result = MathTex(\n r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x} + C\"\n )\n final_result.scale(1.5)\n final_result.set_color(YELLOW)\n \n # Adding a surrounding box to emphasize the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n \n self.play(Write(final_result))\n self.play(Create(box))\n self.wait(4)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0144(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_shapetransformation()\n self.clear_stage()\n self.act_2_integrateexp()\n\n def act_1_shapetransformation(self):\n circle = Circle(radius=1.5, color=WHITE)\n self.play(Create(circle))\n self.wait(0.5)\n\n # 2. Morph: Circle seamlessly transforms into a square\n square = Square(side_length=3, color=WHITE)\n self.play(ReplacementTransform(circle, square))\n self.wait(0.5)\n\n # 3. Style Change: Change color to blue and apply transparency\n self.play(\n square.animate.set_fill(BBLUE, opacity=0.5)\n .set_stroke(BLUE, opacity=0.8)\n )\n self.wait(0.5)\n\n # 4. Rotation: Rotate the square by 45 degrees\n self.play(Rotate(square, angle=45 * DEGREES))\n self.wait(0.5)\n\n # 5. Cleanup & Text: Clear shapes and display final phrase\n self.play(FadeOut(square))\n \n text = Text(\"Transformation complete!\", font_size=42)\n self.play(Write(text))\n self.wait(2)\n\n def act_2_integrateexp(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. Brief written explanation\n # Note: Correcting \"reverse power rule\" to \"reverse chain rule\" for mathematical accuracy\n explanation = Tex(\n \"We use the reverse chain rule (u-substitution) \\\\\\\\ \"\n \"to integrate this function.\"\n )\n explanation.scale(0.8)\n explanation.next_to(problem, DOWN, buff=1)\n \n self.play(Write(explanation))\n self.wait(3)\n\n # 3. Transform the function into its integrated form\n result = MathTex(r\"\\frac{1}{2}e^{2x} + C\")\n result.scale(1.5)\n \n self.play(\n ReplacementTransform(problem, result),\n FadeOut(explanation)\n )\n self.wait(3)\n\n # 4. Clear the screen\n self.clear()\n self.wait(1)\n\n # 5. Present the final integrated function once more\n final_result = MathTex(\n r\"\\int e^{2x} \\, dx = \\frac{1}{2}e^{2x} + C\"\n )\n final_result.scale(1.5)\n final_result.set_color(YELLOW)\n \n # Adding a surrounding box to emphasize the final answer\n box = SurroundingRectangle(final_result, color=YELLOW, buff=0.3)\n \n self.play(Write(final_result))\n self.play(Create(box))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visualization of a simple neural network with four layers, where each layer is represented by a rectangle. Could you create a video where these layers are stacked vertically with some space between them, and label each one as \"Layer 1,\" \"Layer 2,\" etc.? Additionally, I want animated arrows that connect the bottom of one layer to the top of the next to represent the connections in the network. After the whole network is shown, can you animate a small blue bar moving through each layer to signify the activation process within the neural network? I'm looking for the animation to be clean, with everything centered, and have the activations in each layer appear in sequence rather than all at once.", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n n_layers = 4\n layer_width = 4.0\n layer_height = 1.0\n layer_spacing = 1.5\n signal_color = BLUE\n\n # --- 1. Create Layers and Labels ---\n layers = VGroup()\n for i in range(n_layers):\n # Create the layer rectangle\n rect = Rectangle(\n width=layer_width,\n height=layer_height,\n color=WHITE,\n fill_opacity=0.1,\n stroke_width=2\n )\n \n # Create the label positioned above the rectangle\n label = Text(f\"Layer {i+1}\", font_size=24, color=WHITE)\n label.next_to(rect, UP, buff=0.2)\n \n # Group rectangle and label so they move as one unit\n layer_group = VGroup(rect, label)\n layers.add(layer_group)\n\n # Arrange layers vertically with consistent spacing\n layers.arrange(DOWN, buff=layer_spacing)\n\n # --- 2. Create Connection Arrows ---\n arrows = VGroup()\n for i in range(n_layers - 1):\n # Connect the bottom of the current layer rectangle to the top of the next\n start_point = layers[i][0].get_bottom()\n end_point = layers[i+1][0].get_top()\n \n arrow = Arrow(\n start_point,\n end_point,\n buff=0.1,\n color=GRAY,\n stroke_width=2\n )\n arrows.add(arrow)\n\n # Center the entire composition on screen\n network_group = VGroup(layers, arrows)\n network_group.center()\n\n # --- 3. Animation Sequence ---\n \n # Fade in layers and labels\n self.play(Create(layers), run_time=1.5)\n \n # Animate arrows appearing one by one\n for arrow in arrows:\n self.play(GrowArrow(arrow), run_time=0.5)\n \n self.wait(1)\n\n # --- 4. Activation Animation ---\n # Create the activation bar (a thin blue rectangle)\n activation_bar = Rectangle(\n width=layer_width * 0.9, # Slightly narrower than the layer\n height=0.2,\n color=signal_color,\n fill_opacity=1,\n stroke_width=0\n )\n\n # Initialize the bar at the top of the first layer\n activation_bar.move_to(layers[0][0].get_top())\n self.play(FadeIn(activation_bar), run_time=0.5)\n\n # Sequence the bar moving through each layer\n for i in range(n_layers):\n current_rect = layers[i][0]\n \n # Move bar from top of layer to bottom of layer\n self.play(\n activation_bar.animate.move_to(current_rect.get_bottom()),\n run_time=0.8,\n rate_func=linear\n )\n \n # If it's not the last layer, move the bar to the top of the next layer\n if i < n_layers - 1:\n next_rect = layers[i+1][0]\n self.play(\n activation_bar.animate.move_to(next_rect.get_top()),\n run_time=0.4,\n rate_func=linear\n )\n\n self.wait(2)\n\n# To run this code, use:\n# manim -pql filename.py NeuralNetworkVisualization\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkVisualization(Scene):\n def construct(self):\n # --- Configuration ---\n n_layers = 4\n layer_width = 4.0\n layer_height = 1.0\n layer_spacing = 1.5\n signal_color = BBLUE\n\n # --- 1. Create Layers and Labels ---\n layers = VGroup()\n for i in range(n_layers):\n # Create the layer rectangle\n rect = Rectangle(\n width=layer_width,\n height=layer_height,\n color=WHITE,\n fill_opacity=0.1,\n stroke_width=2\n )\n \n # Create the label positioned above the rectangle\n label = Text(f\"Layer {i+1}\", font_size=24, color=WHITE)\n label.next_to(rect, UP, buff=0.2)\n \n # Group rectangle and label so they move as one unit\n layer_group = VGroup(rect, label)\n layers.add(layer_group)\n\n # Arrange layers vertically with consistent spacing\n layers.arrange(DOWN, buff=layer_spacing)\n\n # --- 2. Create Connection Arrows ---\n arrows = VGroup()\n for i in range(n_layers - 1):\n # Connect the bottom of the current layer rectangle to the top of the next\n start_point = layers[i][0].get_bottom()\n end_point = layers[i+1][0].get_top()\n \n arrow = Arrow(\n start_point,\n end_point,\n buff=0.1,\n color=GRAY,\n stroke_width=2\n )\n arrows.add(arrow)\n\n # Center the entire composition on screen\n network_group = VGroup(layers, arrows)\n network_group.center()\n\n # --- 3. Animation Sequence ---\n \n # Fade in layers and labels\n self.play(Create(layers), run_time=1.5)\n \n # Animate arrows appearing one by one\n for arrow in arrows:\n self.play(GrowArrow(arrow), run_time=0.5)\n \n self.wait(1)\n\n # --- 4. Activation Animation ---\n # Create the activation bar (a thin blue rectangle)\n activation_bar = Rectangle(\n width=layer_width * 0.9, # Slightly narrower than the layer\n height=0.2,\n color=signal_color,\n fill_opacity=1,\n stroke_width=0\n )\n\n # Initialize the bar at the top of the first layer\n activation_bar.move_to(layers[0][0].get_top())\n self.play(FadeIn(activation_bar), run_time=0.5)\n\n # Sequence the bar moving through each layer\n for i in range(n_layers):\n current_rect = layers[i][0]\n \n # Move bar from top of layer to bottom of layer\n self.play(\n activation_bar.animate.move_to(current_rect.get_bottom()),\n run_time=0.8,\n rate_func=linear\n )\n \n # If it's not the last layer, move the bar to the top of the next layer\n if i < n_layers - 1:\n next_rect = layers[i+1][0]\n self.play(\n activation_bar.animate.move_to(next_rect.get_top()),\n run_time=0.4,\n rate_func=linear\n )\n\n self.wait(2)\n\n# To run this code, use:\n# manim -pql filename.py NeuralNetworkVisualization\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # 1. Initialization: Draw Axes, Parabola, and Integral Equation\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n )\n \n curve = axes.plot(lambda x: x**2, x_range=[-2.5, 2.5], color=BLUE)\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\", x_val=2, direction=UR)\n \n integral_eq = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\").next_to(curve, UR, buff=1)\n \n self.play(Create(axes), Create(curve), Write(curve_label))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # 2. Transition: Move equation to the top of the screen\n self.play(\n integral_eq.animate.to_edge(UP),\n FadeOut(curve_label)\n )\n self.wait(1)\n\n # 3. Shading: Animate the area under the curve in blue\n area = axes.get_area(curve, x_range=[-2, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # 4. Calculation Steps: Step-by-step integration\n # Define the mathematical steps\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\")\n step2 = MathTex(r\"\\left( \\frac{2^3}{3} \\right) - \\left( \\frac{(-2)^3}{3} \\right)\")\n step3 = MathTex(r\"\\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\")\n step4 = MathTex(r\"\\frac{16}{3}\")\n \n # Position the first step below the integral equation\n step1.next_to(integral_eq, DOWN, buff=0.5)\n \n # Animate each step replacing the previous one\n self.play(Write(step1))\n self.wait(1)\n \n step2.move_to(step1)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n step3.move_to(step2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n step4.move_to(step3)\n self.play(ReplacementTransform(step3, step4))\n self.wait(2)\n\n # 5. Conclusion: Clear scene and emphasize the final solution\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(integral_eq)\n )\n \n # Re-display and highlight the final solution\n self.play(\n step4.animate.move_to(ORIGIN).scale(1.5).set_color(BLUE)\n )\n self.play(Indicate(step4))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderParabola(Scene):\n def construct(self):\n # 1. Initialization: Draw Axes, Parabola, and Integral Equation\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, 2]},\n )\n \n curve = axes.plot(lambda x: x**2, x_range=[-2.5, 2.5], color=BBLUE)\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\", x_val=2, direction=UR)\n \n integral_eq = MathTex(r\"\\int_{-2}^{2} x^2 \\, dx\").next_to(curve, UR, buff=1)\n \n self.play(Create(axes), Create(curve), Write(curve_label))\n self.play(Write(integral_eq))\n self.wait(1)\n\n # 2. Transition: Move equation to the top of the screen\n self.play(\n integral_eq.animate.to_edge(UP),\n FadeOut(curve_label)\n )\n self.wait(1)\n\n # 3. Shading: Animate the area under the curve in blue\n area = axes.get_area(curve, x_range=[-2, 2], color=BLUE, opacity=0.5)\n self.play(FadeIn(area))\n self.wait(2)\n\n # 4. Calculation Steps: Step-by-step integration\n # Define the mathematical steps\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_{-2}^{2}\")\n step2 = MathTex(r\"\\left( \\frac{2^3}{3} \\right) - \\left( \\frac{(-2)^3}{3} \\right)\")\n step3 = MathTex(r\"\\frac{8}{3} - \\left( -\\frac{8}{3} \\right)\")\n step4 = MathTex(r\"\\frac{16}{3}\")\n \n # Position the first step below the integral equation\n step1.next_to(integral_eq, DOWN, buff=0.5)\n \n # Animate each step replacing the previous one\n self.play(Write(step1))\n self.wait(1)\n \n step2.move_to(step1)\n self.play(ReplacementTransform(step1, step2))\n self.wait(1)\n \n step3.move_to(step2)\n self.play(ReplacementTransform(step2, step3))\n self.wait(1)\n \n step4.move_to(step3)\n self.play(ReplacementTransform(step3, step4))\n self.wait(2)\n\n # 5. Conclusion: Clear scene and emphasize the final solution\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(area),\n FadeOut(integral_eq)\n )\n \n # Re-display and highlight the final solution\n self.play(\n step4.animate.move_to(ORIGIN).scale(1.5).set_color(BLUE)\n )\n self.play(Indicate(step4))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Log-based File Systems and Metadata Consistency\nA system crash can lead to inconsistencies in file system metadata, such as directory trees and free block bitmaps. Log-based file systems (Journaling FS) write the operations to a log area before modifying the metadata. Upon reboot after a crash, consistency can be quickly restored by replaying the log, avoiding the lengthy full-disk scan process of traditional `fsck`.\n\n\nThe context of this section (from highest to current level):\n# Operating System Overview (Supplement)\n## File Systems: Naming, Directories, and Consistency Guarantees\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass JournalingFileSystem(Scene):\n\n def construct(self):\n title = Text('Journaling File Systems', 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('System crash corrupts metadata', 'Log operations before modifying', 'Replay log on reboot to restore', 'Avoids lengthy full-disk fsck', font_size=28)\n bullets.to_edge(LEFT, buff=0.8)\n bullets.shift(UP * 0.5)\n mem_text = Text('Memory Cache', font_size=24)\n mem_box = SurroundingRectangle(mem_text, color=BLUE, buff=0.25)\n mem_group = VGroup(mem_text, mem_box)\n mem_group.move_to(RIGHT * 3.5 + UP * 1.5)\n log_text = Text('Log Area (Journal)', font_size=24)\n log_box = SurroundingRectangle(log_text, color=YELLOW, buff=0.25)\n log_group = VGroup(log_text, log_box)\n log_group.move_to(RIGHT * 3.5)\n disk_text = Text('Disk Metadata', font_size=24)\n disk_box = SurroundingRectangle(disk_text, color=GREEN, buff=0.25)\n disk_group = VGroup(disk_text, disk_box)\n disk_group.move_to(RIGHT * 3.5 + DOWN * 1.5)\n arrow1 = Arrow(mem_group.get_bottom(), log_group.get_top(), buff=0.1, color=WHITE)\n arrow2 = Arrow(log_group.get_bottom(), disk_group.get_top(), buff=0.1, color=WHITE)\n act1 = Text('1. Write Log', font_size=18, color=YELLOW).next_to(arrow1, RIGHT, buff=0.2)\n act2 = Text('2. Update Metadata', font_size=18, color=GREEN).next_to(arrow2, RIGHT, buff=0.2)\n self.play(FadeIn(bullets[0]), run_time=1)\n self.play(FadeIn(mem_group), FadeIn(log_group), FadeIn(disk_group), run_time=1.5)\n self.play(FadeIn(bullets[1]), run_time=1)\n self.play(GrowArrow(arrow1), Write(act1), run_time=1)\n self.play(GrowArrow(arrow2), Write(act2), run_time=1)\n self.play(FadeIn(bullets[2]), run_time=1)\n replay_box = SurroundingRectangle(log_group, color=RED, buff=0.1)\n self.play(Create(replay_box), run_time=0.8)\n self.play(FadeOut(replay_box), run_time=0.5)\n self.play(FadeIn(bullets[3]), run_time=1)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass JournalingFileSystem(Scene):\n\n def construct(self):\n title = Text('Journaling File Systems', 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('System crash corrupts metadata', 'Log operations before modifying', 'Replay log on reboot to restore', 'Avoids lengthy full-disk fsck', font_size=28)\n bullets.to_edge(LEFT, buff=0.8)\n bullets.shift(UP * 0.5)\n mem_text = Text('Memory Cache', font_size=24)\n mem_box = SurroundingRectangle(mem_text, color=BBLUE, buff=0.25)\n mem_group = VGroup(mem_text, mem_box)\n mem_group.move_to(RIGHT * 3.5 + UP * 1.5)\n log_text = Text('Log Area (Journal)', font_size=24)\n log_box = SurroundingRectangle(log_text, color=YELLOW, buff=0.25)\n log_group = VGroup(log_text, log_box)\n log_group.move_to(RIGHT * 3.5)\n disk_text = Text('Disk Metadata', font_size=24)\n disk_box = SurroundingRectangle(disk_text, color=GREEN, buff=0.25)\n disk_group = VGroup(disk_text, disk_box)\n disk_group.move_to(RIGHT * 3.5 + DOWN * 1.5)\n arrow1 = Arrow(mem_group.get_bottom(), log_group.get_top(), buff=0.1, color=WHITE)\n arrow2 = Arrow(log_group.get_bottom(), disk_group.get_top(), buff=0.1, color=WHITE)\n act1 = Text('1. Write Log', font_size=18, color=YELLOW).next_to(arrow1, RIGHT, buff=0.2)\n act2 = Text('2. Update Metadata', font_size=18, color=GREEN).next_to(arrow2, RIGHT, buff=0.2)\n self.play(FadeIn(bullets[0]), run_time=1)\n self.play(FadeIn(mem_group), FadeIn(log_group), FadeIn(disk_group), run_time=1.5)\n self.play(FadeIn(bullets[1]), run_time=1)\n self.play(GrowArrow(arrow1), Write(act1), run_time=1)\n self.play(GrowArrow(arrow2), Write(act2), run_time=1)\n self.play(FadeIn(bullets[2]), run_time=1)\n replay_box = SurroundingRectangle(log_group, color=RED, buff=0.1)\n self.play(Create(replay_box), run_time=0.8)\n self.play(FadeOut(replay_box), run_time=0.5)\n self.play(FadeIn(bullets[3]), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- 1. Problem Display ---\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=60)\n \n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n\n # --- 2. Power Rule Application ---\n # Introduce the general power rule\n rule_label = Text(\"Power Rule:\", font_size=30, color=BLUE).to_edge(LEFT, buff=1).shift(UP * 1.5)\n power_rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=BLUE\n ).next_to(rule_label, DOWN, buff=0.3)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(1)\n\n # Apply rule to the specific problem: x^2 -> x^(2+1)/(2+1)\n step1 = MathTex(\n r\"\\int_{1}^{3} x^2 \\, dx = \\left[ \\frac{x^{2+1}}{2+1} \\right]_{1}^{3}\", \n font_size=50\n ).move_to(problem)\n\n self.play(Transform(problem, step1))\n self.wait(1)\n\n # Simplify the antiderivative\n step2 = MathTex(\n r\"\\int_{1}^{3} x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", \n font_size=50\n ).move_to(problem)\n\n self.play(Transform(problem, step2))\n self.wait(1)\n \n # Fade out the rule now that it's applied\n self.play(FadeOut(rule_label), FadeOut(power_rule))\n\n # --- 3. Boundary Evaluation ---\n eval_label = Text(\"Evaluate at Boundaries\", font_size=30, color=GREEN).to_edge(UP)\n self.play(ReplacementTransform(title, eval_label))\n \n # Show substitution: F(3) - F(1)\n substitution = MathTex(\n r\"\\frac{3^3}{3} - \\frac{1^3}{3}\", \n font_size=50\n ).next_to(problem, DOWN, buff=0.5)\n\n self.play(Write(substitution))\n self.wait(1)\n\n # --- 4. Simplification ---\n # Step 1: Calculate powers\n simplification1 = MathTex(\n r\"\\frac{27}{3} - \\frac{1}{3}\", \n font_size=50\n ).move_to(substitution)\n\n self.play(Transform(substitution, simplification1))\n self.wait(1)\n\n # Step 2: Final subtraction\n simplification2 = MathTex(\n r\"\\frac{26}{3}\", \n font_size=50\n ).move_to(substitution)\n\n self.play(Transform(substitution, simplification2))\n self.wait(1)\n\n # --- Final Result Highlight ---\n final_box = SurroundingRectangle(substitution, color=YELLOW, buff=0.2)\n final_text = Text(\"Final Answer\", font_size=30, color=YELLOW).next_to(final_box, UP)\n\n self.play(Create(final_box), Write(final_text))\n self.wait(2)\n \n # Clean up and center the final result\n self.play(\n FadeOut(problem), \n FadeOut(eval_label), \n FadeOut(final_text), \n FadeOut(final_box)\n )\n self.play(substitution.animate.center().scale(1.5))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass DefiniteIntegralSolution(Scene):\n def construct(self):\n # --- 1. Problem Display ---\n title = Text(\"Evaluating a Definite Integral\", font_size=40).to_edge(UP)\n problem = MathText(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=60)\n \n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n\n # --- 2. Power Rule Application ---\n # Introduce the general power rule\n rule_label = Text(\"Power Rule:\", font_size=30, color=BLUE).to_edge(LEFT, buff=1).shift(UP * 1.5)\n power_rule = MathTex(\n r\"\\int x^n \\, dx = \\frac{x^{n+1}}{n+1}\", \n font_size=40, \n color=BLUE\n ).next_to(rule_label, DOWN, buff=0.3)\n \n self.play(Write(rule_label), Write(power_rule))\n self.wait(1)\n\n # Apply rule to the specific problem: x^2 -> x^(2+1)/(2+1)\n step1 = MathTex(\n r\"\\int_{1}^{3} x^2 \\, dx = \\left[ \\frac{x^{2+1}}{2+1} \\right]_{1}^{3}\", \n font_size=50\n ).move_to(problem)\n\n self.play(Transform(problem, step1))\n self.wait(1)\n\n # Simplify the antiderivative\n step2 = MathTex(\n r\"\\int_{1}^{3} x^2 \\, dx = \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", \n font_size=50\n ).move_to(problem)\n\n self.play(Transform(problem, step2))\n self.wait(1)\n \n # Fade out the rule now that it's applied\n self.play(FadeOut(rule_label), FadeOut(power_rule))\n\n # --- 3. Boundary Evaluation ---\n eval_label = Text(\"Evaluate at Boundaries\", font_size=30, color=GREEN).to_edge(UP)\n self.play(ReplacementTransform(title, eval_label))\n \n # Show substitution: F(3) - F(1)\n substitution = MathTex(\n r\"\\frac{3^3}{3} - \\frac{1^3}{3}\", \n font_size=50\n ).next_to(problem, DOWN, buff=0.5)\n\n self.play(Write(substitution))\n self.wait(1)\n\n # --- 4. Simplification ---\n # Step 1: Calculate powers\n simplification1 = MathTex(\n r\"\\frac{27}{3} - \\frac{1}{3}\", \n font_size=50\n ).move_to(substitution)\n\n self.play(Transform(substitution, simplification1))\n self.wait(1)\n\n # Step 2: Final subtraction\n simplification2 = MathTex(\n r\"\\frac{26}{3}\", \n font_size=50\n ).move_to(substitution)\n\n self.play(Transform(substitution, simplification2))\n self.wait(1)\n\n # --- Final Result Highlight ---\n final_box = SurroundingRectangle(substitution, color=YELLOW, buff=0.2)\n final_text = Text(\"Final Answer\", font_size=30, color=YELLOW).next_to(final_box, UP)\n\n self.play(Create(final_box), Write(final_text))\n self.wait(2)\n \n # Clean up and center the final result\n self.play(\n FadeOut(problem), \n FadeOut(eval_label), \n FadeOut(final_text), \n FadeOut(final_box)\n )\n self.play(substitution.animate.center().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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 math animation that visually explains the concept of finding the area under a curve using definite integration. The animation should start by displaying the integral of x squared from 0 to 3. Then, there should be a highlight around the x squared function to emphasize it. Following this, I'd like the animation to include a sentence that mentions the definite integral represents the area under the curve. Next, the animation should show the process of integrating x squared from 0 to 3, step by step, and end by calculating the exact area value numerically. After the calculation is complete, clear everything away and just show the final numerical answer. Can this all be done in an animated sequence that's easy to follow and educational?", "chosen": "```python\nfrom manim import *\n\nclass IntegralAreaExplanation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Axes, Graph, Area, and Integral Expression\n # ------------------------------------------------------------------\n # Create coordinate axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_axis_config={\"numbers_to_include\": [0, 3]},\n y_axis_config={\"numbers_to_include\": [0, 9]},\n axis_config={\"include_numbers\": True},\n ).shift(DOWN * 1.5)\n\n # Plot the function y = x^2 and visualize the area under the curve\n graph = axes.plot(lambda x: x**2, x_range=[0, 3], color=BLUE)\n area = axes.get_area(graph, x_range=[0, 3], color=GREEN, opacity=0.5)\n\n # Create the integral expression\n # Splitting the string ensures we can target 'x^2' specifically at index 1\n integral_expr = MathTex(r\"\\int_0^3\", \"x^2\", r\"\\, dx\", font_size=48)\n integral_expr.to_edge(UP)\n\n # Animate initial elements\n self.play(Create(axes), Create(graph), run_time=2)\n self.play(FadeIn(area), run_time=1)\n self.play(Write(integral_expr), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Highlight: Emphasize the x^2 function\n # ------------------------------------------------------------------\n highlight_box = SurroundingRectangle(integral_expr[1], color=YELLOW, buff=0.1)\n self.play(Create(highlight_box), run_time=1)\n self.wait(1)\n self.play(FadeOut(highlight_box), run_time=0.5)\n\n # ------------------------------------------------------------------\n # 3. Concept Explanation\n # ------------------------------------------------------------------\n explanation_text = Text(\n \"The definite integral represents\\nthe area under the curve.\",\n font_size=36,\n color=WHITE\n ).next_to(integral_expr, DOWN, buff=0.5)\n \n self.play(Write(explanation_text), run_time=2)\n self.wait(2)\n self.play(FadeOut(explanation_text), run_time=1)\n\n # ------------------------------------------------------------------\n # 4. Step-by-Step Integration\n # ------------------------------------------------------------------\n # Step 1: Find Antiderivative\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_0^3\", font_size=48)\n step1.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step1), run_time=2)\n self.wait(1)\n\n # Step 2: Evaluate at Bounds\n step2 = MathTex(r\"\\frac{3^3}{3} - \\frac{0^3}{3}\", font_size=48)\n step2.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step2), run_time=2)\n self.wait(1)\n\n # Step 3: Simplify\n step3 = MathTex(r\"9 - 0\", font_size=48)\n step3.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step3), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Numerical Calculation: Final Result\n # ------------------------------------------------------------------\n final_answer = MathTex(\"9\", font_size=60, color=GOLD)\n final_answer.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, final_answer), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Cleanup\n # ------------------------------------------------------------------\n # Remove axes, graph, and area, keeping only the result\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area),\n run_time=1.5\n )\n\n # Emphasize the final result in the center\n self.play(integral_expr.animate.scale(1.5).move_to(ORIGIN), run_time=1)\n self.wait(2)\n\n# Instructions to Run:\n# 1. Save the code in a file named `integral_animation.py`.\n# 2. Ensure ManimCE is installed (`pip install manim`).\n# 3. Run the following command in your terminal:\n# manim -pql integral_animation.py IntegralAreaExplanation\n# (Use -qm or -qh for medium or high quality)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralAreaExplanation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Initial Display: Axes, Graph, Area, and Integral Expression\n # ------------------------------------------------------------------\n # Create coordinate axes\n axes = Axes(\n x_range=[0, 4, 1],\n y_range=[0, 10, 2],\n x_axis_config={\"numbers_to_include\": [0, 3]},\n y_axis_config={\"numbers_to_include\": [0, 9]},\n axis_config={\"include_numbers\": True},\n ).shift(DOWN * 1.5)\n\n # Plot the function y = x^2 and visualize the area under the curve\n graph = axes.plot(lambda x: x**2, x_range=[0, 3], color=BLUE)\n area = axes.get_area(graph, x_range=[0, 3], color=GREEN, opacity=0.5)\n\n # Create the integral expression\n # Splitting the string ensures we can target 'x^2' specifically at index 1\n integral_expr = MathText(r\"\\int_0^3\", \"x^2\", r\"\\, dx\", font_size=48)\n integral_expr.to_edge(UP)\n\n # Animate initial elements\n self.play(Create(axes), Create(graph), run_time=2)\n self.play(FadeIn(area), run_time=1)\n self.play(Write(integral_expr), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 2. Highlight: Emphasize the x^2 function\n # ------------------------------------------------------------------\n highlight_box = SurroundingRectangle(integral_expr[1], color=YELLOW, buff=0.1)\n self.play(Create(highlight_box), run_time=1)\n self.wait(1)\n self.play(FadeOut(highlight_box), run_time=0.5)\n\n # ------------------------------------------------------------------\n # 3. Concept Explanation\n # ------------------------------------------------------------------\n explanation_text = Text(\n \"The definite integral represents\\nthe area under the curve.\",\n font_size=36,\n color=WHITE\n ).next_to(integral_expr, DOWN, buff=0.5)\n \n self.play(Write(explanation_text), run_time=2)\n self.wait(2)\n self.play(FadeOut(explanation_text), run_time=1)\n\n # ------------------------------------------------------------------\n # 4. Step-by-Step Integration\n # ------------------------------------------------------------------\n # Step 1: Find Antiderivative\n step1 = MathTex(r\"\\left[ \\frac{x^3}{3} \\right]_0^3\", font_size=48)\n step1.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step1), run_time=2)\n self.wait(1)\n\n # Step 2: Evaluate at Bounds\n step2 = MathTex(r\"\\frac{3^3}{3} - \\frac{0^3}{3}\", font_size=48)\n step2.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step2), run_time=2)\n self.wait(1)\n\n # Step 3: Simplify\n step3 = MathTex(r\"9 - 0\", font_size=48)\n step3.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, step3), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 5. Numerical Calculation: Final Result\n # ------------------------------------------------------------------\n final_answer = MathTex(\"9\", font_size=60, color=GOLD)\n final_answer.move_to(integral_expr.get_center())\n self.play(Transform(integral_expr, final_answer), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Cleanup\n # ------------------------------------------------------------------\n # Remove axes, graph, and area, keeping only the result\n self.play(\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area),\n run_time=1.5\n )\n\n # Emphasize the final result in the center\n self.play(integral_expr.animate.scale(1.5).move_to(ORIGIN), run_time=1)\n self.wait(2)\n\n# Instructions to Run:\n# 1. Save the code in a file named `integral_animation.py`.\n# 2. Ensure ManimCE is installed (`pip install manim`).\n# 3. Run the following command in your terminal:\n# manim -pql integral_animation.py IntegralAreaExplanation\n# (Use -qm or -qh for medium or high quality)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Please create an educational animation using a graphical representation to explain the concept of the area under a curve. First, show a graph of a simple quadratic function, such as y = x^2, and highlight the area under ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0000(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_movingframeboxes()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_movingframeboxes(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Stack them vertically with spacing\n text_group = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n \n # Display the text objects\n self.play(Write(text_group))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n # Create surrounding rectangles for each text with specific colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initially surround the first text with a blue rectangle\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Replace blue rectangle with green rectangle surrounding the second text\n self.play(ReplacementTransform(rect1, rect2))\n self.wait(0.5)\n\n # Replace green rectangle with red rectangle surrounding the third text\n self.play(ReplacementTransform(rect2, rect3))\n self.wait(0.5)\n\n # 3. Final Movement\n # Add an updater to the red rectangle to ensure it continuously tracks \n # text3's position and dimensions during the animation.\n rect3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n\n # Animate the text moving upwards; the rectangle will follow due to the updater\n self.play(\n text3.animate.shift(UP * 3), \n run_time=3, \n rate_func=smooth\n )\n\n # Clean up updaters and end the animation\n rect3.clear_updaters()\n self.wait(0.5)\n\n def act_2_areaundercurve(self):\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 )\n \n curve = axes.plot(lambda x: x**2, color=BLUE)\n \n # Animate creation of axes and curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 2. Area Highlighting: Visually highlight the area under the curve from x = 0 to x = 2\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=YELLOW,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 3. Labeling: Add a text label to the curve explicitly stating its equation\n eq_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n \n self.play(Write(eq_label))\n self.wait(1)\n\n # 4. Explanation Overlay: Overlay a textual explanation indicating the meaning of the region\n explanation = Text(\n \"This shaded region represents the\\n'area under the curve'\",\n font_size=32,\n line_spacing=1,\n t2c={\"'area under the curve'\": YELLOW}\n ).to_edge(DOWN)\n \n self.play(Write(explanation))\n self.wait(2)\n\n # 5. Final Emphasis: Clear all graphical elements, leaving only the text explanation\n graphics_group = VGroup(axes, curve, area, eq_label)\n self.play(FadeOut(graphics_group))\n \n # Move the remaining text to the center for final emphasis\n self.play(explanation.animate.center())\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0000(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_movingframeboxes()\n self.clear_stage()\n self.act_2_areaundercurve()\n\n def act_1_movingframeboxes(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Stack them vertically with spacing\n text_group = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n \n # Display the text objects\n self.play(Write(text_group))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n # Create surrounding rectangles for each text with specific colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initially surround the first text with a blue rectangle\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Replace blue rectangle with green rectangle surrounding the second text\n self.play(ReplacementTransform(rect1, rect2))\n self.wait(0.5)\n\n # Replace green rectangle with red rectangle surrounding the third text\n self.play(ReplacementTransform(rect2, rect3))\n self.wait(0.5)\n\n # 3. Final Movement\n # Add an updater to the red rectangle to ensure it continuously tracks \n # text3's position and dimensions during the animation.\n rect3.add_updater(lambda m: m.become(SurroundingRectangle(text3, color=RED, buff=0.1)))\n\n # Animate the text moving upwards; the rectangle will follow due to the updater\n self.play(\n text3.animate.shift(UP * 3), \n run_time=3, \n rate_func=smooth\n )\n\n # Clean up updaters and end the animation\n rect3.clear_updaters()\n self.wait(0.5)\n\n def act_2_areaundercurve(self):\n axes = Axes(label_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 )\n \n curve = axes.plot(lambda x: x**2, color=BLUE)\n \n # Animate creation of axes and curve\n self.play(Create(axes), Create(curve))\n self.wait(1)\n\n # 2. Area Highlighting: Visually highlight the area under the curve from x = 0 to x = 2\n area = axes.get_area(\n curve,\n x_range=[0, 2],\n color=YELLOW,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 3. Labeling: Add a text label to the curve explicitly stating its equation\n eq_label = MathTex(\"y = x^2\").next_to(curve, UR, buff=0.1)\n \n self.play(Write(eq_label))\n self.wait(1)\n\n # 4. Explanation Overlay: Overlay a textual explanation indicating the meaning of the region\n explanation = Text(\n \"This shaded region represents the\\n'area under the curve'\",\n font_size=32,\n line_spacing=1,\n t2c={\"'area under the curve'\": YELLOW}\n ).to_edge(DOWN)\n \n self.play(Write(explanation))\n self.wait(2)\n\n # 5. Final Emphasis: Clear all graphical elements, leaving only the text explanation\n graphics_group = VGroup(axes, curve, area, eq_label)\n self.play(FadeOut(graphics_group))\n \n # Move the remaining text to the center for final emphasis\n self.play(explanation.animate.center())\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visually explains the parts of a DC motor. I want the animation to have labeled components like the rotor, stator, and brushes. Each label should be connected to the corresponding part of the motor with dashed lines for clarity. In the animation, I prefer a simple yet detailed representation of the DC motor. Make sure to use contrasting colors so that each part is distinct and the labels are clear against a white background. Can you provide an animation that meets these specifications?", "chosen": "```python\nfrom manim import *\n\n# Set the background color to white for high-contrast visibility\nconfig.background_color = WHITE\n\nclass DCMotorComponents(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Define Colors and Styles\n # ------------------------------------------------------------------\n # High-contrast colors suitable for a white background\n stator_color_n = RED_D\n stator_color_s = BLUE_D\n rotor_color = GOLD_D\n brush_color = BLACK\n commutator_color = ORANGE\n label_color = BLACK\n line_color = DARK_GREY\n\n # ------------------------------------------------------------------\n # 2. Construct the Stator (Permanent Magnets)\n # ------------------------------------------------------------------\n # Represented as two rectangular blocks on the left and right\n magnet_width = 1.5\n magnet_height = 4.0\n gap_width = 3.0\n\n north_pole = Rectangle(\n width=magnet_width,\n height=magnet_height,\n color=stator_color_n,\n fill_opacity=0.8\n )\n north_pole.shift(LEFT * (gap_width / 2 + magnet_width / 2))\n\n south_pole = Rectangle(\n width=magnet_width,\n height=magnet_height,\n color=stator_color_s,\n fill_opacity=0.8\n )\n south_pole.shift(RIGHT * (gap_width / 2 + magnet_width / 2))\n\n # Add N and S labels inside the magnets for detail\n label_n = Text(\"N\", color=WHITE, font_size=36, weight=BOLD).move_to(north_pole)\n label_s = Text(\"S\", color=WHITE, font_size=36, weight=BOLD).move_to(south_pole)\n\n stator = VGroup(north_pole, south_pole, label_n, label_s)\n\n # ------------------------------------------------------------------\n # 3. Construct the Rotor (Armature Coil)\n # ------------------------------------------------------------------\n # Represented as a rectangular loop in the center\n coil_width = 2.0\n coil_height = 3.0\n rotor_core = Rectangle(\n width=coil_width,\n height=coil_height,\n color=rotor_color,\n fill_opacity=0.5,\n stroke_width=4\n )\n # Add an axle line through the center for visual clarity\n axle = Line(LEFT * 2.5, RIGHT * 2.5, color=GRAY, stroke_width=2)\n rotor_group = VGroup(rotor_core, axle)\n\n # ------------------------------------------------------------------\n # 4. Construct Commutator and Brushes\n # ------------------------------------------------------------------\n # Commutator: Split rings near the center axle\n commutator_radius = 0.4\n comm_left = Arc(\n radius=commutator_radius,\n start_angle=90 * DEGREES,\n angle=180 * DEGREES,\n color=commutator_color,\n stroke_width=6\n )\n comm_right = Arc(\n radius=commutator_radius,\n start_angle=270 * DEGREES,\n angle=180 * DEGREES,\n color=commutator_color,\n stroke_width=6\n )\n commutator = VGroup(comm_left, comm_right).move_to(ORIGIN)\n\n # Brushes: Stationary contacts touching the commutator\n brush_width = 0.2\n brush_height = 0.6\n top_brush = Rectangle(\n width=brush_width,\n height=brush_height,\n color=brush_color,\n fill_opacity=1\n )\n top_brush.next_to(commutator, UP, buff=0)\n\n bottom_brush = Rectangle(\n width=brush_width,\n height=brush_height,\n color=brush_color,\n fill_opacity=1\n )\n bottom_brush.next_to(commutator, DOWN, buff=0)\n\n brushes_group = VGroup(top_brush, bottom_brush)\n\n # ------------------------------------------------------------------\n # 5. Create Labels and Connectors\n # ------------------------------------------------------------------\n def create_annotation(text_str, target, direction, buff=1.5):\n \"\"\"Helper to create a label and a dashed line connector.\"\"\"\n label = Text(text_str, color=label_color, font_size=24, weight=BOLD)\n label.next_to(target, direction, buff=buff)\n # Draw a dashed line from the label to the nearest edge of the target\n line = DashedLine(\n start=label.get_edge_center(direction * -1),\n end=target.get_boundary_point(label.get_center()),\n color=line_color,\n dash_length=0.1\n )\n return VGroup(label, line)\n\n # Generate annotations for each part\n stator_annotation = create_annotation(\"Stator (Magnets)\", north_pole, LEFT)\n rotor_annotation = create_annotation(\"Rotor (Armature)\", rotor_core, UP)\n commutator_annotation = create_annotation(\"Commutator\", comm_left, DOWN)\n brush_annotation = create_annotation(\"Brushes\", top_brush, RIGHT)\n\n # ------------------------------------------------------------------\n # 6. Animation Sequence\n # ------------------------------------------------------------------\n # Step 1: Introduce the Stator\n self.play(Create(stator), run_time=1.5)\n self.play(FadeIn(stator_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 2: Introduce the Rotor\n self.play(Create(rotor_group), run_time=1.5)\n self.play(FadeIn(rotor_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 3: Introduce Commutator\n self.play(Create(commutator), run_time=1.5)\n self.play(FadeIn(commutator_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 4: Introduce Brushes\n self.play(Create(brushes_group), run_time=1.5)\n self.play(FadeIn(brush_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 5: Demonstrate Rotation to indicate the rotor's function\n # Group the rotor and commutator to rotate them as one unit\n rotating_assembly = VGroup(rotor_group, commutator)\n self.play(\n Rotate(rotating_assembly, angle=2 * PI, about_point=ORIGIN),\n run_time=4,\n rate_func=linear\n )\n\n # Final hold\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\n# Set the background color to white for high-contrast visibility\nconfig.background_color = WHITE\n\nclass DCMotorComponents(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Define Colors and Styles\n # ------------------------------------------------------------------\n # High-contrast colors suitable for a white background\n stator_color_n = RED_D\n stator_color_s = BBLUE_D\n rotor_color = GOLD_D\n brush_color = BLACK\n commutator_color = ORANGE\n label_color = BLACK\n line_color = DARK_GREY\n\n # ------------------------------------------------------------------\n # 2. Construct the Stator (Permanent Magnets)\n # ------------------------------------------------------------------\n # Represented as two rectangular blocks on the left and right\n magnet_width = 1.5\n magnet_height = 4.0\n gap_width = 3.0\n\n north_pole = Rectangle(\n width=magnet_width,\n height=magnet_height,\n color=stator_color_n,\n fill_opacity=0.8\n )\n north_pole.shift(LEFT * (gap_width / 2 + magnet_width / 2))\n\n south_pole = Rectangle(\n width=magnet_width,\n height=magnet_height,\n color=stator_color_s,\n fill_opacity=0.8\n )\n south_pole.shift(RIGHT * (gap_width / 2 + magnet_width / 2))\n\n # Add N and S labels inside the magnets for detail\n label_n = Text(\"N\", color=WHITE, font_size=36, weight=BOLD).move_to(north_pole)\n label_s = Text(\"S\", color=WHITE, font_size=36, weight=BOLD).move_to(south_pole)\n\n stator = VGroup(north_pole, south_pole, label_n, label_s)\n\n # ------------------------------------------------------------------\n # 3. Construct the Rotor (Armature Coil)\n # ------------------------------------------------------------------\n # Represented as a rectangular loop in the center\n coil_width = 2.0\n coil_height = 3.0\n rotor_core = Rectangle(\n width=coil_width,\n height=coil_height,\n color=rotor_color,\n fill_opacity=0.5,\n stroke_width=4\n )\n # Add an axle line through the center for visual clarity\n axle = Line(LEFT * 2.5, RIGHT * 2.5, color=GRAY, stroke_width=2)\n rotor_group = VGroup(rotor_core, axle)\n\n # ------------------------------------------------------------------\n # 4. Construct Commutator and Brushes\n # ------------------------------------------------------------------\n # Commutator: Split rings near the center axle\n commutator_radius = 0.4\n comm_left = Arc(\n radius=commutator_radius,\n start_angle=90 * DEGREES,\n angle=180 * DEGREES,\n color=commutator_color,\n stroke_width=6\n )\n comm_right = Arc(\n radius=commutator_radius,\n start_angle=270 * DEGREES,\n angle=180 * DEGREES,\n color=commutator_color,\n stroke_width=6\n )\n commutator = VGroup(comm_left, comm_right).move_to(ORIGIN)\n\n # Brushes: Stationary contacts touching the commutator\n brush_width = 0.2\n brush_height = 0.6\n top_brush = Rectangle(\n width=brush_width,\n height=brush_height,\n color=brush_color,\n fill_opacity=1\n )\n top_brush.next_to(commutator, UP, buff=0)\n\n bottom_brush = Rectangle(\n width=brush_width,\n height=brush_height,\n color=brush_color,\n fill_opacity=1\n )\n bottom_brush.next_to(commutator, DOWN, buff=0)\n\n brushes_group = VGroup(top_brush, bottom_brush)\n\n # ------------------------------------------------------------------\n # 5. Create Labels and Connectors\n # ------------------------------------------------------------------\n def create_annotation(text_str, target, direction, buff=1.5):\n \"\"\"Helper to create a label and a dashed line connector.\"\"\"\n label = Text(text_str, color=label_color, font_size=24, weight=BOLD)\n label.next_to(target, direction, buff=buff)\n # Draw a dashed line from the label to the nearest edge of the target\n line = DashedLine(\n start=label.get_edge_center(direction * -1),\n end=target.get_boundary_point(label.get_center()),\n color=line_color,\n dash_length=0.1\n )\n return VGroup(label, line)\n\n # Generate annotations for each part\n stator_annotation = create_annotation(\"Stator (Magnets)\", north_pole, LEFT)\n rotor_annotation = create_annotation(\"Rotor (Armature)\", rotor_core, UP)\n commutator_annotation = create_annotation(\"Commutator\", comm_left, DOWN)\n brush_annotation = create_annotation(\"Brushes\", top_brush, RIGHT)\n\n # ------------------------------------------------------------------\n # 6. Animation Sequence\n # ------------------------------------------------------------------\n # Step 1: Introduce the Stator\n self.play(Create(stator), run_time=1.5)\n self.play(FadeIn(stator_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 2: Introduce the Rotor\n self.play(Create(rotor_group), run_time=1.5)\n self.play(FadeIn(rotor_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 3: Introduce Commutator\n self.play(Create(commutator), run_time=1.5)\n self.play(FadeIn(commutator_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 4: Introduce Brushes\n self.play(Create(brushes_group), run_time=1.5)\n self.play(FadeIn(brush_annotation), run_time=1)\n self.wait(0.5)\n\n # Step 5: Demonstrate Rotation to indicate the rotor's function\n # Group the rotor and commutator to rotate them as one unit\n rotating_assembly = VGroup(rotor_group, commutator)\n self.play(\n Rotate(rotating_assembly, angle=2 * PI, about_point=ORIGIN),\n run_time=4,\n rate_func=linear\n )\n\n # Final hold\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Initialization\n # ---------------------------------------------------------\n # Create axes with appropriate ranges and shift left to make room for equations\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_exclude\": [0]},\n ).add_coordinates().shift(LEFT * 2.5)\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 the function y = x^2\n graph = axes.plot(lambda x: x**2, color=YELLOW, x_range=[0, 2])\n\n # Animate the creation of the coordinate system and graph\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Area Highlighting\n # ---------------------------------------------------------\n # Highlight the region under the curve from x=0 to x=2\n area = axes.get_area(\n graph,\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n \n # Label the area\n area_label = Text(\"Area under the curve\", font_size=28, color=BLUE)\n area_label.next_to(area, DOWN, buff=0.5)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(2)\n self.play(FadeOut(area_label))\n\n # ---------------------------------------------------------\n # 3. Step-by-Step Calculation\n # ---------------------------------------------------------\n # Prepare the calculation steps using MathTex for professional notation\n # Step 1: Setup the integral\n step1 = MathTex(r\"A = \\int_{0}^{2} x^2 \\, dx\")\n \n # Step 2: Find the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n \n # Step 3: Apply limits of integration\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n \n # Step 4: Simplify the expression\n step4 = MathTex(r\"= \\frac{8}{3} - 0\")\n \n # Step 5: Final calculation\n step5 = MathTex(r\"= \\frac{8}{3}\", color=GREEN, font_size=48)\n\n # Arrange equations vertically and position them to the right\n equations = VGroup(step1, step2, step3, step4, step5).arrange(\n DOWN, \n aligned_edge=LEFT, \n buff=0.4\n )\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 1.5)\n\n # Animate each step of the derivation\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n \n self.play(Write(step5))\n \n # ---------------------------------------------------------\n # 4. Final Result\n # ---------------------------------------------------------\n # Emphasize the final result with a surrounding box and scaling\n box = SurroundingRectangle(step5, color=GREEN, buff=0.2, corner_radius=0.1)\n \n self.play(Create(box))\n self.play(step5.animate.scale(1.2))\n \n # Hold the final frame to allow absorption of the result\n self.wait(4)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql script_name.py AreaUnderCurve\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # 1. Graph Initialization\n # ---------------------------------------------------------\n # Create axes with appropriate ranges and shift left to make room for equations\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"include_numbers\": True},\n x_axis_config={\"numbers_to_exclude\": [0]},\n ).add_coordinates().shift(LEFT * 2.5)\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 the function y = x^2\n graph = axes.plot(lambda x: x**2, color=YELLOW, x_range=[0, 2])\n\n # Animate the creation of the coordinate system and graph\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 2. Area Highlighting\n # ---------------------------------------------------------\n # Highlight the region under the curve from x=0 to x=2\n area = axes.get_area(\n graph,\n x_range=[0, 2],\n color=BLUE,\n opacity=0.5\n )\n \n # Label the area\n area_label = Text(\"Area under the curve\", font_size=28, color=BLUE)\n area_label.next_to(area, DOWN, buff=0.5)\n\n self.play(FadeIn(area), Write(area_label))\n self.wait(2)\n self.play(FadeOut(area_label))\n\n # ---------------------------------------------------------\n # 3. Step-by-Step Calculation\n # ---------------------------------------------------------\n # Prepare the calculation steps using MathTex for professional notation\n # Step 1: Setup the integral\n step1 = MathText(r\"A = \\int_{0}^{2} x^2 \\, dx\")\n \n # Step 2: Find the antiderivative\n step2 = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\")\n \n # Step 3: Apply limits of integration\n step3 = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\")\n \n # Step 4: Simplify the expression\n step4 = MathTex(r\"= \\frac{8}{3} - 0\")\n \n # Step 5: Final calculation\n step5 = MathTex(r\"= \\frac{8}{3}\", color=GREEN, font_size=48)\n\n # Arrange equations vertically and position them to the right\n equations = VGroup(step1, step2, step3, step4, step5).arrange(\n DOWN, \n aligned_edge=LEFT, \n buff=0.4\n )\n equations.next_to(axes, RIGHT, buff=1.5).shift(UP * 1.5)\n\n # Animate each step of the derivation\n self.play(Write(step1))\n self.wait(1)\n \n self.play(Write(step2))\n self.wait(1)\n \n self.play(Write(step3))\n self.wait(1)\n \n self.play(Write(step4))\n self.wait(1)\n \n self.play(Write(step5))\n \n # ---------------------------------------------------------\n # 4. Final Result\n # ---------------------------------------------------------\n # Emphasize the final result with a surrounding box and scaling\n box = SurroundingRectangle(step5, color=GREEN, buff=0.2, corner_radius=0.1)\n \n self.play(Create(box))\n self.play(step5.animate.scale(1.2))\n \n # Hold the final frame to allow absorption of the result\n self.wait(4)\n\n# To run this animation, use the following command in your terminal:\n# manim -pql script_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 studying analytic geometry and want a dynamic construction of parabola, ellipse, and hyperbola.\nAnimate the focus–directrix definitions and show how parameter changes yield the standard forms y^2=4ax, x^2/a^2+y^2/b^2=1, and x^2/a^2−y^2/b^2=1.\nInclude the cone-slice interpretation or alternative definitions, and highlight eccentricity and focal properties as the shapes morph.", "chosen": "```python\nfrom manim import *\nimport math\n\nclass ConicSectionsScene(Scene):\n\n def construct(self):\n title = Text('Analytic Geometry of Conic Sections', font_size=40)\n title.to_edge(UP, buff=0.3)\n self.play(FadeIn(title), run_time=2.0 * 0.4)\n projectile = ParametricFunction(lambda t: [2 * t - 3, -0.4 * (2 * t - 3) ** 2 + 2, 0], t_range=[0, 3], color=YELLOW)\n self.play(Create(projectile), run_time=2.0 * 0.6)\n self.wait(2.0)\n self.play(FadeOut(projectile), run_time=0.5)\n circle_label = Text('Circle', font_size=36).next_to(title, DOWN, buff=0.4)\n circ = Circle(radius=1.5, color=BLUE).shift(LEFT * 2)\n center_dot = Dot(LEFT * 2, color=WHITE)\n radius_arrow = Arrow(LEFT * 2, LEFT * 2 + 1.5 * RIGHT, buff=0, color=WHITE)\n circle_eq = MathTex('(x-h)^2 + (y-k)^2 = r^2', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(circle_label), Create(circ), FadeIn(center_dot), run_time=2.0 * 0.5)\n self.play(GrowArrow(radius_arrow), FadeIn(circle_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(circle_label), FadeOut(circ), FadeOut(center_dot), FadeOut(radius_arrow), FadeOut(circle_eq))\n parab_label = Text('Parabola', font_size=36).next_to(title, DOWN, buff=0.4)\n parabola = ParametricFunction(lambda t: [t, 0.3 * (t - 1) ** 2 + 0.2, 0], t_range=[-2, 3], color=GREEN).shift(LEFT * 2)\n vertex_dot = Dot([-1, 0.2, 0], color=RED)\n parab_eq = MathTex('y = a(x-h)^2 + k', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(parab_label), Create(parabola), run_time=2.0 * 0.5)\n self.play(FadeIn(vertex_dot), FadeIn(parab_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(parab_label), FadeOut(parabola), FadeOut(vertex_dot), FadeOut(parab_eq))\n ellipse_label = Text('Ellipse', font_size=36).next_to(title, DOWN, buff=0.4)\n ellipse = ParametricFunction(lambda t: [2 * math.cos(t), 1.2 * math.sin(t), 0], t_range=[0, 2 * PI], color=PURPLE).shift(LEFT * 2)\n center_ellipse = Dot(LEFT * 2, color=WHITE)\n major_axis = DashedLine(LEFT * 2 + 2 * LEFT, LEFT * 2 + 2 * RIGHT, color=GRAY)\n minor_axis = DashedLine(LEFT * 2 + 1.2 * DOWN, LEFT * 2 + 1.2 * UP, color=GRAY)\n ellipse_eq = MathTex('\\\\frac{(x-h)^2}{a^2} + \\\\frac{(y-k)^2}{b^2} = 1', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(ellipse_label), Create(ellipse), FadeIn(center_ellipse), run_time=2.0 * 0.5)\n self.play(Create(major_axis), Create(minor_axis), FadeIn(ellipse_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(ellipse_label), FadeOut(ellipse), FadeOut(center_ellipse), FadeOut(major_axis), FadeOut(minor_axis), FadeOut(ellipse_eq))\n hyper_label = Text('Hyperbola', font_size=36).next_to(title, DOWN, buff=0.4)\n a_val = 1.5\n b_val = 1.0\n t_max = 1.2\n right_branch = ParametricFunction(lambda t: [a_val * math.cosh(t), b_val * math.sinh(t), 0], t_range=[-t_max, t_max], color=ORANGE).shift(LEFT * 2)\n left_branch = ParametricFunction(lambda t: [-a_val * math.cosh(t), b_val * math.sinh(t), 0], t_range=[-t_max, t_max], color=ORANGE).shift(LEFT * 2)\n asymptote1 = DashedLine([-4.5, -5 / 3, 0], [0.5, 5 / 3, 0], color=GRAY)\n asymptote2 = DashedLine([-4.5, 5 / 3, 0], [0.5, -5 / 3, 0], color=GRAY)\n hyper_eq = MathTex('\\\\frac{(x-h)^2}{a^2} - \\\\frac{(y-k)^2}{b^2} = 1', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(hyper_label), Create(right_branch), Create(left_branch), run_time=2.0 * 0.5)\n self.play(FadeIn(asymptote1), FadeIn(asymptote2), FadeIn(hyper_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(hyper_label), FadeOut(right_branch), FadeOut(left_branch), FadeOut(asymptote1), FadeOut(asymptote2), FadeOut(hyper_eq))\n summary_title = Text('Summary of Standard Forms', font_size=38).next_to(title, DOWN, buff=0.5)\n c_eq = MathTex('(x-h)^2 + (y-k)^2 = r^2', font_size=30)\n p_eq = MathTex('y = a(x-h)^2 + k', font_size=30)\n e_eq = MathTex('\\\\frac{(x-h)^2}{a^2} + \\\\frac{(y-k)^2}{b^2} = 1', font_size=30)\n h_eq = MathTex('\\\\frac{(x-h)^2}{a^2} - \\\\frac{(y-k)^2}{b^2} = 1', font_size=30)\n left_col = VGroup(c_eq, e_eq).arrange(DOWN, buff=0.6)\n right_col = VGroup(p_eq, h_eq).arrange(DOWN, buff=0.6)\n summary_group = VGroup(left_col, right_col).arrange(RIGHT, buff=1.5)\n summary_group.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeIn(summary_title), run_time=2.0 * 0.2)\n self.play(FadeIn(summary_group), run_time=2.0 * 0.5)\n self.wait(2.0 * 0.3)\n self.wait(0.5)\n self.play(FadeOut(summary_title), FadeOut(summary_group), FadeOut(title))\n```", "rejected": "```python\nfrom manim import *\nimport math\n\nclass ConicSectionsScene(Scene):\n\n def construct(self):\n title = Text('Analytic Geometry of Conic Sections', font_size=40)\n title.to_edge(UP, buff=0.3)\n self.play(FadeIn(title), run_time=2.0 * 0.4)\n projectile = ParametricFunction(lambda t: [2 * t - 3, -0.4 * (2 * t - 3) ** 2 + 2, 0], t_range=[0, 3], color=YELLOW)\n self.play(Create(projectile), run_time=2.0 * 0.6)\n self.wait(2.0)\n self.play(FadeOut(projectile), run_time=0.5)\n circle_label = Text('Circle', font_size=36).next_to(title, DOWN, buff=0.4)\n circ = Circle(radius=1.5, color=BLUE).shift(LEFT * 2)\n center_dot = Dot(LEFT * 2, color=WHITE)\n radius_arrow = Arrow(LEFT * 2, LEFT * 2 + 1.5 * RIGHT, buff=0, color=WHITE)\n circle_eq = MathText('(x-h)^2 + (y-k)^2 = r^2', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(circle_label), Create(circ), FadeIn(center_dot), run_time=2.0 * 0.5)\n self.play(GrowArrow(radius_arrow), FadeIn(circle_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(circle_label), FadeOut(circ), FadeOut(center_dot), FadeOut(radius_arrow), FadeOut(circle_eq))\n parab_label = Text('Parabola', font_size=36).next_to(title, DOWN, buff=0.4)\n parabola = ParametricFunction(lambda t: [t, 0.3 * (t - 1) ** 2 + 0.2, 0], t_range=[-2, 3], color=GREEN).shift(LEFT * 2)\n vertex_dot = Dot([-1, 0.2, 0], color=RED)\n parab_eq = MathTex('y = a(x-h)^2 + k', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(parab_label), Create(parabola), run_time=2.0 * 0.5)\n self.play(FadeIn(vertex_dot), FadeIn(parab_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(parab_label), FadeOut(parabola), FadeOut(vertex_dot), FadeOut(parab_eq))\n ellipse_label = Text('Ellipse', font_size=36).next_to(title, DOWN, buff=0.4)\n ellipse = ParametricFunction(lambda t: [2 * math.cos(t), 1.2 * math.sin(t), 0], t_range=[0, 2 * PI], color=PURPLE).shift(LEFT * 2)\n center_ellipse = Dot(LEFT * 2, color=WHITE)\n major_axis = DashedLine(LEFT * 2 + 2 * LEFT, LEFT * 2 + 2 * RIGHT, color=GRAY)\n minor_axis = DashedLine(LEFT * 2 + 1.2 * DOWN, LEFT * 2 + 1.2 * UP, color=GRAY)\n ellipse_eq = MathTex('\\\\frac{(x-h)^2}{a^2} + \\\\frac{(y-k)^2}{b^2} = 1', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(ellipse_label), Create(ellipse), FadeIn(center_ellipse), run_time=2.0 * 0.5)\n self.play(Create(major_axis), Create(minor_axis), FadeIn(ellipse_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(ellipse_label), FadeOut(ellipse), FadeOut(center_ellipse), FadeOut(major_axis), FadeOut(minor_axis), FadeOut(ellipse_eq))\n hyper_label = Text('Hyperbola', font_size=36).next_to(title, DOWN, buff=0.4)\n a_val = 1.5\n b_val = 1.0\n t_max = 1.2\n right_branch = ParametricFunction(lambda t: [a_val * math.cosh(t), b_val * math.sinh(t), 0], t_range=[-t_max, t_max], color=ORANGE).shift(LEFT * 2)\n left_branch = ParametricFunction(lambda t: [-a_val * math.cosh(t), b_val * math.sinh(t), 0], t_range=[-t_max, t_max], color=ORANGE).shift(LEFT * 2)\n asymptote1 = DashedLine([-4.5, -5 / 3, 0], [0.5, 5 / 3, 0], color=GRAY)\n asymptote2 = DashedLine([-4.5, 5 / 3, 0], [0.5, -5 / 3, 0], color=GRAY)\n hyper_eq = MathTex('\\\\frac{(x-h)^2}{a^2} - \\\\frac{(y-k)^2}{b^2} = 1', font_size=34).to_edge(RIGHT).shift(LEFT * 0.8)\n self.play(FadeIn(hyper_label), Create(right_branch), Create(left_branch), run_time=2.0 * 0.5)\n self.play(FadeIn(asymptote1), FadeIn(asymptote2), FadeIn(hyper_eq), run_time=2.0 * 0.5)\n self.wait(0.5)\n self.play(FadeOut(hyper_label), FadeOut(right_branch), FadeOut(left_branch), FadeOut(asymptote1), FadeOut(asymptote2), FadeOut(hyper_eq))\n summary_title = Text('Summary of Standard Forms', font_size=38).next_to(title, DOWN, buff=0.5)\n c_eq = MathTex('(x-h)^2 + (y-k)^2 = r^2', font_size=30)\n p_eq = MathTex('y = a(x-h)^2 + k', font_size=30)\n e_eq = MathTex('\\\\frac{(x-h)^2}{a^2} + \\\\frac{(y-k)^2}{b^2} = 1', font_size=30)\n h_eq = MathTex('\\\\frac{(x-h)^2}{a^2} - \\\\frac{(y-k)^2}{b^2} = 1', font_size=30)\n left_col = VGroup(c_eq, e_eq).arrange(DOWN, buff=0.6)\n right_col = VGroup(p_eq, h_eq).arrange(DOWN, buff=0.6)\n summary_group = VGroup(left_col, right_col).arrange(RIGHT, buff=1.5)\n summary_group.next_to(summary_title, DOWN, buff=0.5)\n self.play(FadeIn(summary_title), run_time=2.0 * 0.2)\n self.play(FadeIn(summary_group), run_time=2.0 * 0.5)\n self.wait(2.0 * 0.3)\n self.wait(0.5)\n self.play(FadeOut(summary_title), FadeOut(summary_group), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates the process of integrating the exponential function e raised to the power of 2x with respect to x, including the steps involved in solving the integral, and a reminder to include the constant of integration, with each step accompanied by explanations?", "chosen": "```python\nfrom manim import *\n\nclass IntegrateExponential(Scene):\n def construct(self):\n # Color configuration\n color_func = BLUE\n color_var = YELLOW\n color_const = RED\n color_step = BLUE_B\n\n # --- Step 1: Title and Problem Statement ---\n title = Text(\"Integrating the Exponential Function\", font_size=40).to_edge(UP)\n problem = MathTex(r\"\\int\", \"e^{2x}\", r\"\\,\", \"dx\", font_size=60)\n problem.next_to(title, DOWN, buff=0.5)\n problem[1].set_color(color_func)\n problem[3].set_color(color_var)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Strategy Explanation (u-Substitution) ---\n strategy_text = Text(\"Strategy: u-Substitution\", color=color_step, font_size=36)\n strategy_text.next_to(problem, DOWN, buff=0.5)\n\n u_def = MathTex(r\"u\", \"=\", \"2x\", font_size=45)\n u_def.next_to(strategy_text, DOWN, buff=0.3)\n u_def[0].set_color(color_var)\n\n self.play(Write(strategy_text))\n self.play(Write(u_def))\n self.wait(1)\n\n # --- Step 3: Differentiating to find dx ---\n diff_step = MathTex(\n r\"du\", \"=\", r\"2\\,dx\", r\"\\quad \\Rightarrow \\quad dx\", r\"=\", r\"\\frac{1}{2}\\,du\", \n font_size=45\n )\n diff_step.next_to(u_def, DOWN, buff=0.3)\n diff_step[0].set_color(color_var)\n diff_step[5].set_color(color_var)\n\n explanation_diff = Text(\n \"Solve for dx to substitute into the integral\", \n color=GRAY, font_size=28\n )\n explanation_diff.next_to(diff_step, DOWN, buff=0.3)\n\n self.play(Write(diff_step))\n self.play(Write(explanation_diff))\n self.wait(2)\n\n # --- Step 4: Performing the Substitution ---\n # Clear upper text to focus on the transformation of the integral\n self.play(\n FadeOut(title),\n FadeOut(strategy_text),\n FadeOut(u_def),\n FadeOut(diff_step),\n FadeOut(explanation_diff),\n problem.animate.scale(0.8).to_edge(UP)\n )\n\n substituted_integral = MathTex(\n r\"\\int\", \"e^{u}\", r\"\\cdot\", r\"\\frac{1}{2}\", r\"\\,\", \"du\", font_size=50\n )\n substituted_integral.next_to(problem, DOWN, buff=0.5)\n substituted_integral[1].set_color(color_func)\n substituted_integral[5].set_color(color_var)\n\n note_sub = Text(\"Substitute u and dx\", color=GREEN, font_size=30)\n note_sub.next_to(substituted_integral, LEFT, buff=0.5)\n\n self.play(Write(substituted_integral))\n self.play(Write(note_sub))\n self.wait(1.5)\n self.play(FadeOut(note_sub))\n\n # --- Step 5: Integration and Constant of Integration ---\n integrated = MathTex(r\"=\", r\"\\frac{1}{2}\", \"e^{u}\", \"+\", \"C\", font_size=50)\n integrated.next_to(substituted_integral, DOWN, buff=0.5)\n integrated[2].set_color(color_func)\n integrated[4].set_color(color_const)\n\n rule_note = Text(\"\\int e^u du = e^u\", color=GRAY, font_size=30)\n rule_note.next_to(integrated, LEFT, buff=0.5)\n\n c_reminder = Text(\"Always include + C\", color=color_const, font_size=30)\n c_reminder.next_to(integrated, RIGHT, buff=0.5)\n\n self.play(Write(integrated))\n self.play(Write(rule_note))\n self.play(Write(c_reminder))\n self.wait(2)\n\n # Clean up notes before final step\n self.play(FadeOut(rule_note), FadeOut(c_reminder), FadeOut(substituted_integral))\n\n # --- Step 6: Back-Substitution and Final Result ---\n final_result = MathTex(r\"=\", r\"\\frac{1}{2}\", \"e^{2x}\", \"+\", \"C\", font_size=60)\n final_result.next_to(integrated, DOWN, buff=0.5)\n final_result[2].set_color(color_func)\n final_result[4].set_color(color_const)\n\n back_sub_note = Text(\"Substitute back u = 2x\", color=GREEN, font_size=30)\n back_sub_note.next_to(final_result, LEFT, buff=0.5)\n\n self.play(ReplacementTransform(integrated, final_result))\n self.play(Write(back_sub_note))\n self.wait(1)\n\n # --- Step 7: Final Highlight ---\n # Draw a box around the final result and emphasize the constant of integration\n box = SurroundingRectangle(final_result, color=BLUE, buff=0.3)\n \n c_box = SurroundingRectangle(final_result[4], color=color_const, buff=0.1)\n final_c_reminder = Text(\n \"Don't forget the constant of integration!\", \n font_size=28, color=color_const\n ).next_to(c_box, DOWN, buff=0.3)\n\n final_label = Text(\"Solution\", color=BLUE, font_size=30).next_to(box, UP)\n\n self.play(Create(box))\n self.play(Write(final_label))\n self.play(Create(c_box), Write(final_c_reminder))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegrateExponential(Scene):\n def construct(self):\n # Color configuration\n color_func = BBLUE\n color_var = YELLOW\n color_const = RED\n color_step = BLUE_B\n\n # --- Step 1: Title and Problem Statement ---\n title = Text(\"Integrating the Exponential Function\", font_size=40).to_edge(UP)\n problem = MathTex(r\"\\int\", \"e^{2x}\", r\"\\,\", \"dx\", font_size=60)\n problem.next_to(title, DOWN, buff=0.5)\n problem[1].set_color(color_func)\n problem[3].set_color(color_var)\n\n self.play(Write(title))\n self.play(Write(problem))\n self.wait(1)\n\n # --- Step 2: Strategy Explanation (u-Substitution) ---\n strategy_text = Text(\"Strategy: u-Substitution\", color=color_step, font_size=36)\n strategy_text.next_to(problem, DOWN, buff=0.5)\n\n u_def = MathTex(r\"u\", \"=\", \"2x\", font_size=45)\n u_def.next_to(strategy_text, DOWN, buff=0.3)\n u_def[0].set_color(color_var)\n\n self.play(Write(strategy_text))\n self.play(Write(u_def))\n self.wait(1)\n\n # --- Step 3: Differentiating to find dx ---\n diff_step = MathTex(\n r\"du\", \"=\", r\"2\\,dx\", r\"\\quad \\Rightarrow \\quad dx\", r\"=\", r\"\\frac{1}{2}\\,du\", \n font_size=45\n )\n diff_step.next_to(u_def, DOWN, buff=0.3)\n diff_step[0].set_color(color_var)\n diff_step[5].set_color(color_var)\n\n explanation_diff = Text(\n \"Solve for dx to substitute into the integral\", \n color=GRAY, font_size=28\n )\n explanation_diff.next_to(diff_step, DOWN, buff=0.3)\n\n self.play(Write(diff_step))\n self.play(Write(explanation_diff))\n self.wait(2)\n\n # --- Step 4: Performing the Substitution ---\n # Clear upper text to focus on the transformation of the integral\n self.play(\n FadeOut(title),\n FadeOut(strategy_text),\n FadeOut(u_def),\n FadeOut(diff_step),\n FadeOut(explanation_diff),\n problem.animate.scale(0.8).to_edge(UP)\n )\n\n substituted_integral = MathTex(\n r\"\\int\", \"e^{u}\", r\"\\cdot\", r\"\\frac{1}{2}\", r\"\\,\", \"du\", font_size=50\n )\n substituted_integral.next_to(problem, DOWN, buff=0.5)\n substituted_integral[1].set_color(color_func)\n substituted_integral[5].set_color(color_var)\n\n note_sub = Text(\"Substitute u and dx\", color=GREEN, font_size=30)\n note_sub.next_to(substituted_integral, LEFT, buff=0.5)\n\n self.play(Write(substituted_integral))\n self.play(Write(note_sub))\n self.wait(1.5)\n self.play(FadeOut(note_sub))\n\n # --- Step 5: Integration and Constant of Integration ---\n integrated = MathTex(r\"=\", r\"\\frac{1}{2}\", \"e^{u}\", \"+\", \"C\", font_size=50)\n integrated.next_to(substituted_integral, DOWN, buff=0.5)\n integrated[2].set_color(color_func)\n integrated[4].set_color(color_const)\n\n rule_note = Text(\"\\int e^u du = e^u\", color=GRAY, font_size=30)\n rule_note.next_to(integrated, LEFT, buff=0.5)\n\n c_reminder = Text(\"Always include + C\", color=color_const, font_size=30)\n c_reminder.next_to(integrated, RIGHT, buff=0.5)\n\n self.play(Write(integrated))\n self.play(Write(rule_note))\n self.play(Write(c_reminder))\n self.wait(2)\n\n # Clean up notes before final step\n self.play(FadeOut(rule_note), FadeOut(c_reminder), FadeOut(substituted_integral))\n\n # --- Step 6: Back-Substitution and Final Result ---\n final_result = MathTex(r\"=\", r\"\\frac{1}{2}\", \"e^{2x}\", \"+\", \"C\", font_size=60)\n final_result.next_to(integrated, DOWN, buff=0.5)\n final_result[2].set_color(color_func)\n final_result[4].set_color(color_const)\n\n back_sub_note = Text(\"Substitute back u = 2x\", color=GREEN, font_size=30)\n back_sub_note.next_to(final_result, LEFT, buff=0.5)\n\n self.play(ReplacementTransform(integrated, final_result))\n self.play(Write(back_sub_note))\n self.wait(1)\n\n # --- Step 7: Final Highlight ---\n # Draw a box around the final result and emphasize the constant of integration\n box = SurroundingRectangle(final_result, color=BLUE, buff=0.3)\n \n c_box = SurroundingRectangle(final_result[4], color=color_const, buff=0.1)\n final_c_reminder = Text(\n \"Don't forget the constant of integration!\", \n font_size=28, color=color_const\n ).next_to(c_box, DOWN, buff=0.3)\n\n final_label = Text(\"Solution\", color=BLUE, font_size=30).next_to(box, UP)\n\n self.play(Create(box))\n self.play(Write(final_label))\n self.play(Create(c_box), Write(final_c_reminder))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 instruction, which retains all original features while adding explanatory text, a dynamic energy diagram, and a smoother transformation sequence:\n\nThe animation begins by constructing a molecule group (oxygen, electron, metal, positive, and negative ions) with each component appearing sequentially via `Create`, followed by a collective `FadeIn`. As the molecule forms, explanatory labels (e.g., \"Oxygen,\" \"Metal Ion\") fade in beside each element, and a dynamic energy level diagram rises in the background, showing electron energy states as arrows transitioning between levels. The molecule then transforms into a 3x3 metal oxide grid via `ReplacementTransform`, with a shimmer effect highlighting the lattice structure. Next, the grid morphs into a carbon structure (`carbon_grid`), accompanied by a subtitle explaining the allotropic transformation. The scaled-down grid moves to the upper-left corner, while an electron orbits along a predefined path (`electron_path`), leaving a glowing trail and triggering real-time updates to the energy diagram to reflect its movement. Finally, the animation pauses to display a concluding equation (e.g., \"Metal + O₂ → Metal Oxide\") that fades in beneath the structures, tying the visual concepts to chemical principles. The entire sequence is rendered with smooth transitions and coordinated timing.", "chosen": "```python\nfrom manim import *\n\nclass RedoxReactionAnimation(Scene):\n def construct(self):\n # Create molecule components\n oxygen = Circle(radius=0.5, color=BLUE).shift(LEFT*2)\n electron = Dot(radius=0.1, color=YELLOW).next_to(oxygen, RIGHT, buff=0.3)\n metal = Square(side_length=0.7, color=RED).shift(RIGHT*2)\n positive_ion = Circle(radius=0.4, color=RED, fill_opacity=0.5).shift(UP*2)\n negative_ion = Circle(radius=0.4, color=BLUE, fill_opacity=0.5).shift(DOWN*2)\n \n # Create labels\n oxygen_label = Tex(\"Oxygen\").next_to(oxygen, DOWN)\n electron_label = Tex(\"Electron\").next_to(electron, UP)\n metal_label = Tex(\"Metal Ion\").next_to(metal, DOWN)\n positive_label = Tex(\"$+$ Ion\").next_to(positive_ion, RIGHT)\n negative_label = Tex(\"$-$ Ion\").next_to(negative_ion, RIGHT)\n \n # Create energy diagram\n energy_levels = VGroup(\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(UP*1),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(UP*0.5),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(DOWN*0.5),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(DOWN*1)\n )\n energy_label = Tex(\"Energy Levels\").next_to(energy_levels, LEFT)\n \n # Create electron transitions\n transition1 = Arrow(UP*0.5, UP*1, color=YELLOW, buff=0.1)\n transition2 = Arrow(DOWN*0.5, DOWN*1, color=YELLOW, buff=0.1)\n \n # Animate molecule formation\n self.play(Create(oxygen), Create(metal))\n self.play(Create(electron))\n self.play(FadeIn(positive_ion), FadeIn(negative_ion))\n self.play(\n FadeIn(oxygen_label),\n FadeIn(electron_label),\n FadeIn(metal_label),\n FadeIn(positive_label),\n FadeIn(negative_label)\n )\n \n # Show energy diagram\n self.play(\n FadeIn(energy_levels),\n FadeIn(energy_label),\n GrowArrow(transition1),\n GrowArrow(transition2)\n )\n self.wait(1)\n \n # Create metal oxide grid\n grid = VGroup(*[Square(side_length=0.5, color=RED, fill_opacity=0.7) for _ in range(9)])\n grid.arrange_in_grid(rows=3, cols=3, buff=0.1)\n \n # Transform molecule to grid\n self.play(\n ReplacementTransform(VGroup(oxygen, electron, metal, positive_ion, negative_ion), grid),\n FadeOut(oxygen_label),\n FadeOut(electron_label),\n FadeOut(metal_label),\n FadeOut(positive_label),\n FadeOut(negative_label),\n FadeOut(energy_levels),\n FadeOut(energy_label),\n FadeOut(transition1),\n FadeOut(transition2)\n )\n \n # Add shimmer effect\n for square in grid:\n self.play(square.animate.set_fill(opacity=1), run_time=0.1)\n self.play(square.animate.set_fill(opacity=0.7), run_time=0.1)\n \n # Create carbon grid\n carbon_grid = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.7) for _ in range(9)])\n carbon_grid.arrange_in_grid(rows=3, cols=3, buff=0.3)\n carbon_label = Tex(\"Carbon Allotrope\").next_to(carbon_grid, DOWN)\n \n # Transform to carbon structure\n self.play(\n ReplacementTransform(grid, carbon_grid),\n FadeIn(carbon_label)\n )\n self.wait(1)\n \n # Move grid to corner and create electron path\n self.play(\n carbon_grid.animate.scale(0.5).to_corner(UL),\n carbon_label.animate.scale(0.5).next_to(carbon_grid, DOWN, buff=0.1),\n run_time=2\n )\n \n # Create electron path\n electron_path = Circle(radius=1.5, color=YELLOW).shift(RIGHT*1)\n electron_dot = Dot(radius=0.1, color=YELLOW).move_to(electron_path.point_from_proportion(0))\n \n # Animate electron movement\n self.play(\n MoveAlongPath(electron_dot, electron_path, rate_func=linear, run_time=4),\n Create(electron_path, run_time=4)\n )\n \n # Show final equation\n equation = Tex(\"Metal + O$_2$ $\\\\rightarrow$ Metal Oxide\").shift(DOWN*2)\n self.play(FadeIn(equation))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass RedoxReactionAnimation(Scene):\n def construct(self):\n # Create molecule components\n oxygen = Circle(radius=0.5, color=BBLUE).shift(LEFT*2)\n electron = Dot(radius=0.1, color=YELLOW).next_to(oxygen, RIGHT, buff=0.3)\n metal = Square(side_length=0.7, color=RED).shift(RIGHT*2)\n positive_ion = Circle(radius=0.4, color=RED, fill_opacity=0.5).shift(UP*2)\n negative_ion = Circle(radius=0.4, color=BLUE, fill_opacity=0.5).shift(DOWN*2)\n \n # Create labels\n oxygen_label = Tex(\"Oxygen\").next_to(oxygen, DOWN)\n electron_label = Tex(\"Electron\").next_to(electron, UP)\n metal_label = Tex(\"Metal Ion\").next_to(metal, DOWN)\n positive_label = Tex(\"$+$ Ion\").next_to(positive_ion, RIGHT)\n negative_label = Tex(\"$-$ Ion\").next_to(negative_ion, RIGHT)\n \n # Create energy diagram\n energy_levels = VGroup(\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(UP*1),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(UP*0.5),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(DOWN*0.5),\n Line(LEFT*3, RIGHT*3, color=WHITE).shift(DOWN*1)\n )\n energy_label = Tex(\"Energy Levels\").next_to(energy_levels, LEFT)\n \n # Create electron transitions\n transition1 = Arrow(UP*0.5, UP*1, color=YELLOW, buff=0.1)\n transition2 = Arrow(DOWN*0.5, DOWN*1, color=YELLOW, buff=0.1)\n \n # Animate molecule formation\n self.play(Create(oxygen), Create(metal))\n self.play(Create(electron))\n self.play(FadeIn(positive_ion), FadeIn(negative_ion))\n self.play(\n FadeIn(oxygen_label),\n FadeIn(electron_label),\n FadeIn(metal_label),\n FadeIn(positive_label),\n FadeIn(negative_label)\n )\n \n # Show energy diagram\n self.play(\n FadeIn(energy_levels),\n FadeIn(energy_label),\n GrowArrow(transition1),\n GrowArrow(transition2)\n )\n self.wait(1)\n \n # Create metal oxide grid\n grid = VGroup(*[Square(side_length=0.5, color=RED, fill_opacity=0.7) for _ in range(9)])\n grid.arrange_in_grid(rows=3, cols=3, buff=0.1)\n \n # Transform molecule to grid\n self.play(\n ReplacementTransform(VGroup(oxygen, electron, metal, positive_ion, negative_ion), grid),\n FadeOut(oxygen_label),\n FadeOut(electron_label),\n FadeOut(metal_label),\n FadeOut(positive_label),\n FadeOut(negative_label),\n FadeOut(energy_levels),\n FadeOut(energy_label),\n FadeOut(transition1),\n FadeOut(transition2)\n )\n \n # Add shimmer effect\n for square in grid:\n self.play(square.animate.set_fill(opacity=1), run_time=0.1)\n self.play(square.animate.set_fill(opacity=0.7), run_time=0.1)\n \n # Create carbon grid\n carbon_grid = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.7) for _ in range(9)])\n carbon_grid.arrange_in_grid(rows=3, cols=3, buff=0.3)\n carbon_label = Tex(\"Carbon Allotrope\").next_to(carbon_grid, DOWN)\n \n # Transform to carbon structure\n self.play(\n ReplacementTransform(grid, carbon_grid),\n FadeIn(carbon_label)\n )\n self.wait(1)\n \n # Move grid to corner and create electron path\n self.play(\n carbon_grid.animate.scale(0.5).to_corner(UL),\n carbon_label.animate.scale(0.5).next_to(carbon_grid, DOWN, buff=0.1),\n run_time=2\n )\n \n # Create electron path\n electron_path = Circle(radius=1.5, color=YELLOW).shift(RIGHT*1)\n electron_dot = Dot(radius=0.1, color=YELLOW).move_to(electron_path.point_from_proportion(0))\n \n # Animate electron movement\n self.play(\n MoveAlongPath(electron_dot, electron_path, rate_func=linear, run_time=4),\n Create(electron_path, run_time=4)\n )\n \n # Show final equation\n equation = Tex(\"Metal + O$_2$ $\\\\rightarrow$ Metal Oxide\").shift(DOWN*2)\n self.play(FadeIn(equation))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\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 *\nimport numpy as np\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=BBLUE_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 convolutional receptive fields and want to visualize how the receptive field grows with depth like a binary tree. Show two leaves starting at a base input and progressively merging to larger regions as depth increases, with the field illustrated as colored cones. Include an animation of dilation stepping and annotate the effective receptive field size at each depth.", "chosen": "```python\nfrom manim import *\n\ndef make_grid(rows, cols, size):\n group = VGroup()\n for _ in range(rows * cols):\n s = Square(side_length=size)\n s.set_stroke(WHITE, opacity=0.8, width=1)\n s.set_fill(BLACK, opacity=1)\n group.add(s)\n group.arrange_in_grid(rows, cols, buff=0)\n return group\n\nclass ConvolutionalReceptiveFields(Scene):\n\n def construct(self):\n title = Text('Convolutional Receptive Fields', font_size=40)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title), run_time=2.0)\n input_grid = make_grid(5, 5, 0.25)\n input_grid.move_to([-3.5, 0.5, 0])\n input_label = Text('Input Image\\n5x5', font_size=20).next_to(input_grid, DOWN, buff=0.3)\n self.play(FadeIn(input_grid), Write(input_label), run_time=2.0)\n layer1_grid = make_grid(3, 3, 0.25)\n layer1_grid.move_to([0, 0.5, 0])\n layer1_label = Text('Layer 1\\n3x3', font_size=20).next_to(layer1_grid, DOWN, buff=0.3)\n arrow1 = Arrow(input_grid.get_right(), layer1_grid.get_left(), buff=0.1, color=BLUE)\n layer1_grid[4].set_fill(GREEN, opacity=0.8)\n self.play(FadeIn(layer1_grid), Write(layer1_label), Create(arrow1), run_time=2.0)\n rf1_rect = Rectangle(width=0.75, height=0.75, color=YELLOW)\n rf1_rect.move_to(input_grid.get_center())\n rf1_rect.set_stroke(YELLOW, width=3)\n rf1_label = Text('3x3', font_size=18, color=YELLOW).next_to(rf1_rect, UP, buff=0.1)\n self.play(FadeIn(rf1_rect), Write(rf1_label), run_time=2.0)\n layer2_grid = make_grid(1, 1, 0.25)\n layer2_grid.move_to([3.5, 0.5, 0])\n layer2_label = Text('Layer 2\\n1x1', font_size=20).next_to(layer2_grid, DOWN, buff=0.3)\n arrow2 = Arrow(layer1_grid.get_right(), layer2_grid.get_left(), buff=0.1, color=BLUE)\n layer2_grid[0].set_fill(BLUE, opacity=0.9)\n self.play(FadeIn(layer2_grid), Write(layer2_label), Create(arrow2), run_time=2.0)\n rf2_l1_rect = Rectangle(width=0.75, height=0.75, color=GREEN)\n rf2_l1_rect.move_to(layer1_grid.get_center())\n rf2_l1_rect.set_stroke(GREEN, width=3)\n rf2_l1_label = Text('RF in L1', font_size=16, color=GREEN).next_to(rf2_l1_rect, UP, buff=0.1)\n rf2_input_rect = Rectangle(width=1.25, height=1.25, color=RED)\n rf2_input_rect.move_to(input_grid.get_center())\n rf2_input_rect.set_stroke(RED, width=3)\n rf2_input_label = Text('5x5', font_size=18, color=RED).next_to(rf2_input_rect, UP, buff=0.1)\n self.play(FadeIn(rf2_l1_rect), Write(rf2_l1_label), FadeIn(rf2_input_rect), Write(rf2_input_label), run_time=2.0)\n summary = Text('Depth increases receptive field size', font_size=28, color=WHITE)\n summary.move_to([0, -1.5, 0])\n self.play(Write(summary), run_time=2.0)\n everything = VGroup(title, input_grid, input_label, layer1_grid, layer1_label, layer2_grid, layer2_label, arrow1, arrow2, rf1_rect, rf1_label, rf2_l1_rect, rf2_l1_label, rf2_input_rect, rf2_input_label, summary)\n outcomes = VGroup(Text('• Explain receptive fields in CNNs', font_size=24), Text('• Visualize layer-by-layer expansion', font_size=24), Text('• Understand depth for recognition', font_size=24))\n outcomes.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n outcomes.move_to([0, 0, 0])\n self.play(FadeOut(everything), run_time=2.0 * 0.3)\n self.play(Write(outcomes), run_time=2.0 * 0.7)\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\ndef make_grid(rows, cols, size):\n group = VGroup()\n for _ in range(rows * cols):\n s = Square(side_length=size)\n s.set_stroke(WHITE, opacity=0.8, width=1)\n s.set_fill(BLACK, opacity=1)\n group.add(s)\n group.arrange_in_grid(rows, cols, buff=0)\n return group\n\nclass ConvolutionalReceptiveFields(Scene):\n\n def construct(self):\n title = Text('Convolutional Receptive Fields', font_size=40)\n title.to_edge(UP, buff=0.4)\n self.play(Write(title), run_time=2.0)\n input_grid = make_grid(5, 5, 0.25)\n input_grid.move_to([-3.5, 0.5, 0])\n input_label = Text('Input Image\\n5x5', font_size=20).next_to(input_grid, DOWN, buff=0.3)\n self.play(FadeIn(input_grid), Write(input_label), run_time=2.0)\n layer1_grid = make_grid(3, 3, 0.25)\n layer1_grid.move_to([0, 0.5, 0])\n layer1_label = Text('Layer 1\\n3x3', font_size=20).next_to(layer1_grid, DOWN, buff=0.3)\n arrow1 = Arrow(input_grid.get_right(), layer1_grid.get_left(), buff=0.1, color=BBLUE)\n layer1_grid[4].set_fill(GREEN, opacity=0.8)\n self.play(FadeIn(layer1_grid), Write(layer1_label), Create(arrow1), run_time=2.0)\n rf1_rect = Rectangle(width=0.75, height=0.75, color=YELLOW)\n rf1_rect.move_to(input_grid.get_center())\n rf1_rect.set_stroke(YELLOW, width=3)\n rf1_label = Text('3x3', font_size=18, color=YELLOW).next_to(rf1_rect, UP, buff=0.1)\n self.play(FadeIn(rf1_rect), Write(rf1_label), run_time=2.0)\n layer2_grid = make_grid(1, 1, 0.25)\n layer2_grid.move_to([3.5, 0.5, 0])\n layer2_label = Text('Layer 2\\n1x1', font_size=20).next_to(layer2_grid, DOWN, buff=0.3)\n arrow2 = Arrow(layer1_grid.get_right(), layer2_grid.get_left(), buff=0.1, color=BLUE)\n layer2_grid[0].set_fill(BLUE, opacity=0.9)\n self.play(FadeIn(layer2_grid), Write(layer2_label), Create(arrow2), run_time=2.0)\n rf2_l1_rect = Rectangle(width=0.75, height=0.75, color=GREEN)\n rf2_l1_rect.move_to(layer1_grid.get_center())\n rf2_l1_rect.set_stroke(GREEN, width=3)\n rf2_l1_label = Text('RF in L1', font_size=16, color=GREEN).next_to(rf2_l1_rect, UP, buff=0.1)\n rf2_input_rect = Rectangle(width=1.25, height=1.25, color=RED)\n rf2_input_rect.move_to(input_grid.get_center())\n rf2_input_rect.set_stroke(RED, width=3)\n rf2_input_label = Text('5x5', font_size=18, color=RED).next_to(rf2_input_rect, UP, buff=0.1)\n self.play(FadeIn(rf2_l1_rect), Write(rf2_l1_label), FadeIn(rf2_input_rect), Write(rf2_input_label), run_time=2.0)\n summary = Text('Depth increases receptive field size', font_size=28, color=WHITE)\n summary.move_to([0, -1.5, 0])\n self.play(Write(summary), run_time=2.0)\n everything = VGroup(title, input_grid, input_label, layer1_grid, layer1_label, layer2_grid, layer2_label, arrow1, arrow2, rf1_rect, rf1_label, rf2_l1_rect, rf2_l1_label, rf2_input_rect, rf2_input_label, summary)\n outcomes = VGroup(Text('• Explain receptive fields in CNNs', font_size=24), Text('• Visualize layer-by-layer expansion', font_size=24), Text('• Understand depth for recognition', font_size=24))\n outcomes.arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n outcomes.move_to([0, 0, 0])\n self.play(FadeOut(everything), run_time=2.0 * 0.3)\n self.play(Write(outcomes), run_time=2.0 * 0.7)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Differences Between Hierarchical Clustering and Partitioning Clustering\nPartitioning clustering (such as K-means) seeks a single flat partition, whereas hierarchical clustering provides a multi-resolution clustering view, allowing observation of the data at different granularities.\n\n## Types of Hierarchical Clustering\n\n### Bottom-Up Agglomerative Hierarchical Clustering\nThe most commonly used strategy (AGNES) starts with each point as its own cluster and iteratively merges the most similar clusters until a stopping condition is met.\n\n\nThe context of this section (from highest level to current):\n# Hierarchical Clustering and Density-Based Clustering (DBSCAN)\n## Introduction to Hierarchical Clustering\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass HierarchicalClustering(Scene):\n\n def construct(self):\n title = Title('Hierarchical vs Partitioning Clustering', font_size=40)\n self.play(Write(title))\n diff_text = VGroup(Text('Partitioning (e.g., K-means): Seeks a single flat partition.', font_size=28), Text('Hierarchical: Provides a multi-resolution clustering view.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(diff_text, shift=DOWN))\n self.wait(1)\n part_label = Text('Partitioning', font_size=28, color=BLUE).move_to(LEFT * 3.5 + UP * 0.5)\n hier_label = Text('Hierarchical', font_size=28, color=GREEN).move_to(RIGHT * 3.5 + UP * 0.5)\n self.play(Write(part_label), Write(hier_label))\n p_dots_A = VGroup(Dot([-4.5, -1.5, 0]), Dot([-4.0, -2.0, 0]), Dot([-4.0, -1.0, 0]))\n p_dots_B = VGroup(Dot([-2.5, -1.5, 0]), Dot([-3.0, -2.0, 0]), Dot([-3.0, -1.0, 0]))\n p_rect_A = SurroundingRectangle(p_dots_A, color=BLUE, corner_radius=0.3, buff=0.2)\n p_rect_B = SurroundingRectangle(p_dots_B, color=BLUE, corner_radius=0.3, buff=0.2)\n self.play(FadeIn(p_dots_A), FadeIn(p_dots_B))\n self.play(Create(p_rect_A), Create(p_rect_B))\n h_dots = VGroup(Dot([2.5, -1.0, 0]), Dot([3.0, -2.0, 0]), Dot([3.5, -1.0, 0]), Dot([4.5, -1.5, 0]))\n h_rect_1 = SurroundingRectangle(VGroup(h_dots[0], h_dots[2]), color=GREEN, corner_radius=0.2, buff=0.15)\n h_rect_2 = SurroundingRectangle(VGroup(h_rect_1, h_dots[1]), color=YELLOW, corner_radius=0.3, buff=0.2)\n h_rect_3 = SurroundingRectangle(VGroup(h_rect_2, h_dots[3]), color=RED, corner_radius=0.4, buff=0.2)\n self.play(FadeIn(h_dots))\n self.play(Create(h_rect_1))\n self.play(Create(h_rect_2))\n self.play(Create(h_rect_3))\n self.wait(2)\n self.play(FadeOut(diff_text), FadeOut(part_label), FadeOut(hier_label), FadeOut(p_dots_A), FadeOut(p_dots_B), FadeOut(p_rect_A), FadeOut(p_rect_B), FadeOut(h_dots), FadeOut(h_rect_1), FadeOut(h_rect_2), FadeOut(h_rect_3))\n agnes_subtitle = Text('Bottom-Up Agglomerative (AGNES)', font_size=32, color=ORANGE).next_to(title, DOWN, buff=0.5)\n agnes_desc = VGroup(Text('1. Starts with each point as its own cluster.', font_size=28), Text('2. Iteratively merges the most similar clusters.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(agnes_subtitle, DOWN, buff=0.4)\n self.play(Write(agnes_subtitle))\n self.play(FadeIn(agnes_desc, shift=DOWN))\n self.wait(1)\n d1, d2 = ([-2.5, -1.5, 0], [-2.0, -2.0, 0])\n d3, d4 = ([1.5, -1.5, 0], [2.5, -1.5, 0])\n d5 = [2.0, -2.5, 0]\n dots = VGroup(Dot(d1), Dot(d2), Dot(d3), Dot(d4), Dot(d5))\n self.play(FadeIn(dots))\n step_text = Text('Initialization: Each point is a cluster', font_size=24, color=WHITE).to_edge(DOWN, buff=0.5)\n self.play(Write(step_text))\n c_rects = VGroup(*[SurroundingRectangle(d, color=WHITE, corner_radius=0.1, buff=0.1) for d in dots])\n self.play(Create(c_rects))\n self.wait(1)\n step_text_2 = Text('Merge 1: Closest pair', font_size=24, color=GREEN).to_edge(DOWN, buff=0.5)\n m1_rect = SurroundingRectangle(VGroup(dots[0], dots[1]), color=GREEN, corner_radius=0.2, buff=0.2)\n self.play(Transform(step_text, step_text_2))\n self.play(ReplacementTransform(VGroup(c_rects[0], c_rects[1]), m1_rect))\n self.wait(1)\n step_text_3 = Text('Merge 2: Next closest pair', font_size=24, color=YELLOW).to_edge(DOWN, buff=0.5)\n m2_rect = SurroundingRectangle(VGroup(dots[2], dots[3]), color=YELLOW, corner_radius=0.2, buff=0.2)\n self.play(Transform(step_text, step_text_3))\n self.play(ReplacementTransform(VGroup(c_rects[2], c_rects[3]), m2_rect))\n self.wait(1)\n step_text_4 = Text('Merge 3: Cluster with nearest point', font_size=24, color=ORANGE).to_edge(DOWN, buff=0.5)\n m3_rect = SurroundingRectangle(VGroup(m2_rect, dots[4]), color=ORANGE, corner_radius=0.3, buff=0.2)\n self.play(Transform(step_text, step_text_4))\n self.play(ReplacementTransform(VGroup(m2_rect, c_rects[4]), m3_rect))\n self.wait(1)\n step_text_5 = Text('Merge 4: Final stopping condition met', font_size=24, color=RED).to_edge(DOWN, buff=0.5)\n m4_rect = SurroundingRectangle(VGroup(m1_rect, m3_rect), color=RED, corner_radius=0.4, buff=0.3)\n self.play(Transform(step_text, step_text_5))\n self.play(ReplacementTransform(VGroup(m1_rect, m3_rect), m4_rect))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass HierarchicalClustering(Scene):\n\n def construct(self):\n title = Title('Hierarchical vs Partitioning Clustering', font_size=40)\n self.play(Write(title))\n diff_text = VGroup(Text('Partitioning (e.g., K-means): Seeks a single flat partition.', font_size=28), Text('Hierarchical: Provides a multi-resolution clustering view.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(title, DOWN, buff=0.5)\n self.play(FadeIn(diff_text, shift=DOWN))\n self.wait(1)\n part_label = Text('Partitioning', font_size=28, color=BBLUE).move_to(LEFT * 3.5 + UP * 0.5)\n hier_label = Text('Hierarchical', font_size=28, color=GREEN).move_to(RIGHT * 3.5 + UP * 0.5)\n self.play(Write(part_label), Write(hier_label))\n p_dots_A = VGroup(Dot([-4.5, -1.5, 0]), Dot([-4.0, -2.0, 0]), Dot([-4.0, -1.0, 0]))\n p_dots_B = VGroup(Dot([-2.5, -1.5, 0]), Dot([-3.0, -2.0, 0]), Dot([-3.0, -1.0, 0]))\n p_rect_A = SurroundingRectangle(p_dots_A, color=BLUE, corner_radius=0.3, buff=0.2)\n p_rect_B = SurroundingRectangle(p_dots_B, color=BLUE, corner_radius=0.3, buff=0.2)\n self.play(FadeIn(p_dots_A), FadeIn(p_dots_B))\n self.play(Create(p_rect_A), Create(p_rect_B))\n h_dots = VGroup(Dot([2.5, -1.0, 0]), Dot([3.0, -2.0, 0]), Dot([3.5, -1.0, 0]), Dot([4.5, -1.5, 0]))\n h_rect_1 = SurroundingRectangle(VGroup(h_dots[0], h_dots[2]), color=GREEN, corner_radius=0.2, buff=0.15)\n h_rect_2 = SurroundingRectangle(VGroup(h_rect_1, h_dots[1]), color=YELLOW, corner_radius=0.3, buff=0.2)\n h_rect_3 = SurroundingRectangle(VGroup(h_rect_2, h_dots[3]), color=RED, corner_radius=0.4, buff=0.2)\n self.play(FadeIn(h_dots))\n self.play(Create(h_rect_1))\n self.play(Create(h_rect_2))\n self.play(Create(h_rect_3))\n self.wait(2)\n self.play(FadeOut(diff_text), FadeOut(part_label), FadeOut(hier_label), FadeOut(p_dots_A), FadeOut(p_dots_B), FadeOut(p_rect_A), FadeOut(p_rect_B), FadeOut(h_dots), FadeOut(h_rect_1), FadeOut(h_rect_2), FadeOut(h_rect_3))\n agnes_subtitle = Text('Bottom-Up Agglomerative (AGNES)', font_size=32, color=ORANGE).next_to(title, DOWN, buff=0.5)\n agnes_desc = VGroup(Text('1. Starts with each point as its own cluster.', font_size=28), Text('2. Iteratively merges the most similar clusters.', font_size=28)).arrange(DOWN, aligned_edge=LEFT, buff=0.3).next_to(agnes_subtitle, DOWN, buff=0.4)\n self.play(Write(agnes_subtitle))\n self.play(FadeIn(agnes_desc, shift=DOWN))\n self.wait(1)\n d1, d2 = ([-2.5, -1.5, 0], [-2.0, -2.0, 0])\n d3, d4 = ([1.5, -1.5, 0], [2.5, -1.5, 0])\n d5 = [2.0, -2.5, 0]\n dots = VGroup(Dot(d1), Dot(d2), Dot(d3), Dot(d4), Dot(d5))\n self.play(FadeIn(dots))\n step_text = Text('Initialization: Each point is a cluster', font_size=24, color=WHITE).to_edge(DOWN, buff=0.5)\n self.play(Write(step_text))\n c_rects = VGroup(*[SurroundingRectangle(d, color=WHITE, corner_radius=0.1, buff=0.1) for d in dots])\n self.play(Create(c_rects))\n self.wait(1)\n step_text_2 = Text('Merge 1: Closest pair', font_size=24, color=GREEN).to_edge(DOWN, buff=0.5)\n m1_rect = SurroundingRectangle(VGroup(dots[0], dots[1]), color=GREEN, corner_radius=0.2, buff=0.2)\n self.play(Transform(step_text, step_text_2))\n self.play(ReplacementTransform(VGroup(c_rects[0], c_rects[1]), m1_rect))\n self.wait(1)\n step_text_3 = Text('Merge 2: Next closest pair', font_size=24, color=YELLOW).to_edge(DOWN, buff=0.5)\n m2_rect = SurroundingRectangle(VGroup(dots[2], dots[3]), color=YELLOW, corner_radius=0.2, buff=0.2)\n self.play(Transform(step_text, step_text_3))\n self.play(ReplacementTransform(VGroup(c_rects[2], c_rects[3]), m2_rect))\n self.wait(1)\n step_text_4 = Text('Merge 3: Cluster with nearest point', font_size=24, color=ORANGE).to_edge(DOWN, buff=0.5)\n m3_rect = SurroundingRectangle(VGroup(m2_rect, dots[4]), color=ORANGE, corner_radius=0.3, buff=0.2)\n self.play(Transform(step_text, step_text_4))\n self.play(ReplacementTransform(VGroup(m2_rect, c_rects[4]), m3_rect))\n self.wait(1)\n step_text_5 = Text('Merge 4: Final stopping condition met', font_size=24, color=RED).to_edge(DOWN, buff=0.5)\n m4_rect = SurroundingRectangle(VGroup(m1_rect, m3_rect), color=RED, corner_radius=0.4, buff=0.3)\n self.play(Transform(step_text, step_text_5))\n self.play(ReplacementTransform(VGroup(m1_rect, m3_rect), m4_rect))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 # --- Step 1: Display Function ---\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"color\": GREY},\n )\n curve = axes.plot(lambda x: x**2, color=BLUE)\n graph_label = axes.get_graph_label(curve, label='f(x) = x^2', x_val=-1, direction=UP)\n \n self.play(Create(axes), Create(curve), Write(graph_label))\n self.wait(1)\n\n # --- Step 2: Show Integral Formula ---\n integral_formula = MathTex(\"A = \\\\int_{a}^{b} x^2 \\\\, dx\", font_size=48)\n integral_formula.to_edge(UP)\n self.play(Write(integral_formula))\n self.wait(1)\n\n # --- Step 3: Visualize Area (x=0 to x=2) ---\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n label_a = MathTex(\"a=0\", font_size=36).next_to(axes.c2p(0, 0), DOWN)\n label_b = MathTex(\"b=2\", font_size=36).next_to(axes.c2p(2, 0), DOWN)\n \n self.play(FadeIn(area), Write(label_a), Write(label_b))\n self.wait(2)\n\n # --- Step 4: Illustrate Integration (Antiderivative) ---\n antiderivative = MathTex(\"A = \\\\left[ \\\\frac{1}{3}x^3 \\\\right]_{a}^{b}\", font_size=48)\n antiderivative.to_edge(UP)\n self.play(ReplacementTransform(integral_formula, antiderivative))\n self.wait(1)\n\n # --- Step 5: Substitute Limits ---\n substitution = MathTex(\"A = \\\\frac{1}{3}(b^3 - a^3)\", font_size=48)\n substitution.to_edge(UP)\n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(2)\n\n # --- Step 6: Final Formula Display ---\n # Keep the substitution formula static for a moment to reinforce the symbolic form\n self.wait(2)\n\n # --- Step 7: Emphasis Phase (Clear & Show Numerical Answer) ---\n # Calculate specific value for a=0, b=2 -> 8/3\n final_answer = MathTex(\"A = \\\\frac{8}{3}\", font_size=72, color=YELLOW)\n \n self.clear() # Clear all previous elements to isolate the result\n self.play(Write(final_answer))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderQuadratic(Scene):\n def construct(self):\n # --- Step 1: Display Function ---\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n axis_config={\"include_tip\": True, \"color\": GREY},\n )\n curve = axes.plot(lambda x: x**2, color=BBLUE)\n graph_label = axes.get_graph_label(curve, label='f(x) = x^2', x_val=-1, direction=UP)\n \n self.play(Create(axes), Create(curve), Write(graph_label))\n self.wait(1)\n\n # --- Step 2: Show Integral Formula ---\n integral_formula = MathTex(\"A = \\\\int_{a}^{b} x^2 \\\\, dx\", font_size=48)\n integral_formula.to_edge(UP)\n self.play(Write(integral_formula))\n self.wait(1)\n\n # --- Step 3: Visualize Area (x=0 to x=2) ---\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n label_a = MathTex(\"a=0\", font_size=36).next_to(axes.c2p(0, 0), DOWN)\n label_b = MathTex(\"b=2\", font_size=36).next_to(axes.c2p(2, 0), DOWN)\n \n self.play(FadeIn(area), Write(label_a), Write(label_b))\n self.wait(2)\n\n # --- Step 4: Illustrate Integration (Antiderivative) ---\n antiderivative = MathTex(\"A = \\\\left[ \\\\frac{1}{3}x^3 \\\\right]_{a}^{b}\", font_size=48)\n antiderivative.to_edge(UP)\n self.play(ReplacementTransform(integral_formula, antiderivative))\n self.wait(1)\n\n # --- Step 5: Substitute Limits ---\n substitution = MathTex(\"A = \\\\frac{1}{3}(b^3 - a^3)\", font_size=48)\n substitution.to_edge(UP)\n self.play(ReplacementTransform(antiderivative, substitution))\n self.wait(2)\n\n # --- Step 6: Final Formula Display ---\n # Keep the substitution formula static for a moment to reinforce the symbolic form\n self.wait(2)\n\n # --- Step 7: Emphasis Phase (Clear & Show Numerical Answer) ---\n # Calculate specific value for a=0, b=2 -> 8/3\n final_answer = MathTex(\"A = \\\\frac{8}{3}\", font_size=72, color=YELLOW)\n \n self.clear() # Clear all previous elements to isolate the result\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'The Riemann Hypothesis' (Exploring the Hidden Structures in the Riemann Hypothesis): How does the mapping of the critical strip illustrate shifts in the prime-counting function?\nVisual style guidance: A vibrant mix of blues, purples, and greens; ethereal and immersion-inducing. Utilize a blend of 3D and 2D animations with smooth transitions to emphasize the intricate beauty of connections.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass RiemannHypothesisScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Riemann Hypothesis\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Critical strip visualization\n strip = Rectangle(height=4, width=1, color=BLUE)\n strip_label = Text(\"Critical Strip\", font_size=24).next_to(strip, UP)\n \n self.play(Create(strip), Write(strip_label))\n self.wait(1)\n \n # Critical line\n line = Line(start=strip.get_bottom() + UP * 0.2, end=strip.get_top() - UP * 0.2, color=YELLOW)\n line_label = Text(\"Re(s) = 1/2\", font_size=20).next_to(line, RIGHT)\n \n self.play(Create(line), Write(line_label))\n self.wait(1)\n \n # Add dots representing zeros\n dots = VGroup()\n for i in range(5):\n y_pos = -1.5 + i * 0.75 # Spaced out vertically\n dot = Dot(np.array([0, y_pos, 0]), color=RED)\n dots.add(dot)\n \n self.play(Create(dots))\n self.wait(1)\n \n # Equation\n eq = Text(\"ζ(s) = sum of 1/n^s\", font_size=28).to_edge(UP)\n self.play(Write(eq))\n self.wait(1)\n \n # Clear the strip visualization\n self.play(\n FadeOut(strip),\n FadeOut(strip_label),\n FadeOut(line),\n FadeOut(line_label),\n FadeOut(dots)\n )\n \n # Prime numbers on a line\n number_line = Line(LEFT * 4, RIGHT * 4, color=WHITE)\n number_line.shift(DOWN)\n \n # Add some number labels\n labels = VGroup()\n for i in range(0, 21, 5): # 0, 5, 10, 15, 20\n label = Text(str(i), font_size=16)\n x_pos = -4 + (i / 20) * 8 # Map from 0-20 to -4 to 4\n label.next_to(np.array([x_pos, -1, 0]), DOWN)\n labels.add(label)\n \n self.play(Create(number_line), Create(labels))\n self.wait(1)\n \n # Prime dots\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n \n for prime in primes:\n x_pos = -4 + (prime / 20) * 8\n dot = Dot(np.array([x_pos, -1, 0]), color=RED)\n prime_dots.add(dot)\n \n self.play(Create(prime_dots))\n self.wait(1)\n \n # Prime counting function\n eq2 = Text(\"\\pi (x) counts primes up to x\", font_size=24)\n eq2.next_to(eq, DOWN)\n \n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Zeros of ζ(s) influence prime distribution\", font_size=28)\n conclusion.to_edge(DOWN, buff=1.5)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(eq),\n FadeOut(eq2),\n FadeOut(number_line),\n FadeOut(labels),\n FadeOut(prime_dots),\n FadeOut(conclusion)\n )\n \n # Final title\n final_title = Text(\"Exploring the Riemann Hypothesis\", font_size=35)\n self.play(Write(final_title))\n self.wait(2)\n self.play(FadeOut(final_title))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass RiemannHypothesisScene(Scene):\n def construct(self):\n # Title\n title = Text(\"The Riemann Hypothesis\", font_size=40)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Critical strip visualization\n strip = Rectangle(height=4, width=1, color=BBLUE)\n strip_label = Text(\"Critical Strip\", font_size=24).next_to(strip, UP)\n \n self.play(Create(strip), Write(strip_label))\n self.wait(1)\n \n # Critical line\n line = Line(start=strip.get_bottom() + UP * 0.2, end=strip.get_top() - UP * 0.2, color=YELLOW)\n line_label = Text(\"Re(s) = 1/2\", font_size=20).next_to(line, RIGHT)\n \n self.play(Create(line), Write(line_label))\n self.wait(1)\n \n # Add dots representing zeros\n dots = VGroup()\n for i in range(5):\n y_pos = -1.5 + i * 0.75 # Spaced out vertically\n dot = Dot(np.array([0, y_pos, 0]), color=RED)\n dots.add(dot)\n \n self.play(Create(dots))\n self.wait(1)\n \n # Equation\n eq = Text(\"ζ(s) = sum of 1/n^s\", font_size=28).to_edge(UP)\n self.play(Write(eq))\n self.wait(1)\n \n # Clear the strip visualization\n self.play(\n FadeOut(strip),\n FadeOut(strip_label),\n FadeOut(line),\n FadeOut(line_label),\n FadeOut(dots)\n )\n \n # Prime numbers on a line\n number_line = Line(LEFT * 4, RIGHT * 4, color=WHITE)\n number_line.shift(DOWN)\n \n # Add some number labels\n labels = VGroup()\n for i in range(0, 21, 5): # 0, 5, 10, 15, 20\n label = Text(str(i), font_size=16)\n x_pos = -4 + (i / 20) * 8 # Map from 0-20 to -4 to 4\n label.next_to(np.array([x_pos, -1, 0]), DOWN)\n labels.add(label)\n \n self.play(Create(number_line), Create(labels))\n self.wait(1)\n \n # Prime dots\n primes = [2, 3, 5, 7, 11, 13, 17, 19]\n prime_dots = VGroup()\n \n for prime in primes:\n x_pos = -4 + (prime / 20) * 8\n dot = Dot(np.array([x_pos, -1, 0]), color=RED)\n prime_dots.add(dot)\n \n self.play(Create(prime_dots))\n self.wait(1)\n \n # Prime counting function\n eq2 = Text(\"\\pi (x) counts primes up to x\", font_size=24)\n eq2.next_to(eq, DOWN)\n \n self.play(Write(eq2))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"Zeros of ζ(s) influence prime distribution\", font_size=28)\n conclusion.to_edge(DOWN, buff=1.5)\n \n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(\n FadeOut(eq),\n FadeOut(eq2),\n FadeOut(number_line),\n FadeOut(labels),\n FadeOut(prime_dots),\n FadeOut(conclusion)\n )\n \n # Final title\n final_title = Text(\"Exploring the Riemann Hypothesis\", font_size=35)\n self.play(Write(final_title))\n self.wait(2)\n self.play(FadeOut(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 where a sentence appears on screen one letter at a time. First, the sentence \"Here is a text\" should be displayed gradually, with each character popping into view sequentially. After the whole sentence is visible, I want to replace the text with a new sentence, \"AddTextLetterByLetter,\" which will also appear letter by letter. Once that's done, I'd like to change that sentence to \"RemoveTextLetterByLetter,\" but this time I want the removal of the sentence to be animated with each letter disappearing one after another, effectively reversing the process of the text appearing. Can you provide a visual representation of this sequence?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Displaying the integral\n integral = MathTex(r\"\\int_0^3 x^2 \\, dx\")\n self.play(Write(integral))\n self.wait(1)\n\n # Setting up the visualization of the area under the curve\n axes = Axes(\n x_range=[0, 4], 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,3), color=GREY, opacity=0.5)\n\n # Show the axes and graph with shaded area\n self.play(Create(axes), Create(graph), FadeIn(area))\n self.wait(1)\n\n # Calculation step\n calculation = MathTex(r\"= \\frac{1}{3} x^3 \\Big|_0^3\")\n self.play(ReplacementTransform(integral.copy(), calculation))\n self.wait(1)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{1}{3} (3)^3 - 0\")\n self.play(Transform(calculation, final_solution))\n self.wait(1)\n\n # Conclusion, show the area equals final integral value\n conclusion_text = Text(\"Area under the curve is equal to the integral value\", font_size=24).to_edge(UP)\n final_value = MathTex(r\"= 9\").next_to(conclusion_text, DOWN)\n self.play(Write(conclusion_text), ReplacementTransform(final_solution.copy(), final_value))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(final_value))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurveExample(Scene):\n def construct(self):\n # Displaying the integral\n integral = MathText(r\"\\int_0^3 x^2 \\, dx\")\n self.play(Write(integral))\n self.wait(1)\n\n # Setting up the visualization of the area under the curve\n axes = Axes(\n x_range=[0, 4], 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,3), color=GREY, opacity=0.5)\n\n # Show the axes and graph with shaded area\n self.play(Create(axes), Create(graph), FadeIn(area))\n self.wait(1)\n\n # Calculation step\n calculation = MathTex(r\"= \\frac{1}{3} x^3 \\Big|_0^3\")\n self.play(ReplacementTransform(integral.copy(), calculation))\n self.wait(1)\n\n # Final solution\n final_solution = MathTex(r\"= \\frac{1}{3} (3)^3 - 0\")\n self.play(Transform(calculation, final_solution))\n self.wait(1)\n\n # Conclusion, show the area equals final integral value\n conclusion_text = Text(\"Area under the curve is equal to the integral value\", font_size=24).to_edge(UP)\n final_value = MathTex(r\"= 9\").next_to(conclusion_text, DOWN)\n self.play(Write(conclusion_text), ReplacementTransform(final_solution.copy(), final_value))\n self.wait(2)\n\n # Clear the scene\n self.clear()\n self.wait(1)\n self.play(Write(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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: Can you create an educational animation explaining how to integrate the sine function from 0 to π/2, show the mathematical steps, and conclude with the final result?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0462(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_mapdefinition()\n self.clear_stage()\n self.act_2_atomanimation()\n\n def act_1_mapdefinition(self):\n context_group = VGroup(Text('Introduction to Keypoints and Pose Estimation', font_size=24, color=GRAY), Text('Keypoint Evaluation Metrics', font_size=20, color=LIGHT_GRAY)).arrange(DOWN, buff=0.1)\n context_group.to_edge(UP)\n title = Text('Definition of mAP in Keypoint Tasks', font_size=36, color=BLUE)\n title.next_to(context_group, DOWN, buff=0.8)\n bullet = Paragraph('• The AP calculated at different thresholds based on OKS', ' (Object Keypoint Similarity) is a core metric for mainstream', ' datasets like COCO.', font_size=30, alignment='left')\n bullet.next_to(title, DOWN, buff=0.8)\n formula = MathTex('mAP = \\\\frac{1}{|T|} \\\\sum_{t \\\\in T} AP^{OKS=t}', font_size=44)\n formula.next_to(bullet, DOWN, buff=0.8)\n thresholds = MathTex('T = \\\\{0.50, 0.55, 0.60, \\\\dots, 0.95\\\\}', font_size=36, color=YELLOW)\n thresholds.next_to(formula, DOWN, buff=0.5)\n self.play(FadeIn(context_group, shift=DOWN * 0.5))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Write(formula))\n self.wait(0.5)\n self.play(FadeIn(thresholds, shift=UP * 0.5))\n coco_box = SurroundingRectangle(thresholds, color=GREEN, buff=0.2)\n coco_text = Text('COCO Standard', font_size=24, color=GREEN)\n coco_text.next_to(coco_box, RIGHT, buff=0.3)\n self.play(Create(coco_box), Write(coco_text))\n self.wait(3)\n\n def act_2_atomanimation(self):\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0462(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_mapdefinition()\n self.clear_stage()\n self.act_2_atomanimation()\n\n def act_1_mapdefinition(self):\n context_group = VGroup(Text('Introduction to Keypoints and Pose Estimation', font_size=24, color=GRAY), Text('Keypoint Evaluation Metrics', font_size=20, color=LIGHT_GRAY)).arrange(DOWN, buff=0.1)\n context_group.to_edge(UP)\n title = Text('Definition of mAP in Keypoint Tasks', font_size=36, color=BLUE)\n title.next_to(context_group, DOWN, buff=0.8)\n bullet = Paragraph('• The AP calculated at different thresholds based on OKS', ' (Object Keypoint Similarity) is a core metric for mainstream', ' datasets like COCO.', font_size=30, alignment='left')\n bullet.next_to(title, DOWN, buff=0.8)\n formula = MathText('mAP = \\\\frac{1}{|T|} \\\\sum_{t \\\\in T} AP^{OKS=t}', font_size=44)\n formula.next_to(bullet, DOWN, buff=0.8)\n thresholds = MathTex('T = \\\\{0.50, 0.55, 0.60, \\\\dots, 0.95\\\\}', font_size=36, color=YELLOW)\n thresholds.next_to(formula, DOWN, buff=0.5)\n self.play(FadeIn(context_group, shift=DOWN * 0.5))\n self.play(Write(title))\n self.wait(0.5)\n self.play(FadeIn(bullet, shift=RIGHT * 0.5))\n self.wait(1)\n self.play(Write(formula))\n self.wait(0.5)\n self.play(FadeIn(thresholds, shift=UP * 0.5))\n coco_box = SurroundingRectangle(thresholds, color=GREEN, buff=0.2)\n coco_text = Text('COCO Standard', font_size=24, color=GREEN)\n coco_text.next_to(coco_box, RIGHT, buff=0.3)\n self.play(Create(coco_box), Write(coco_text))\n self.wait(3)\n\n def act_2_atomanimation(self):\n nucleus = Dot(radius=0.2, color=RED)\n electron_orbit = Circle(radius=0.5)\n electron_orbit.set_stroke(WHITE, 2)\n electrons = VGroup(*[Dot(radius=0.05, color=BLUE).move_to(electron_orbit.point_from_proportion(i/3)) for i in range(3)])\n \n atom = VGroup(nucleus, electron_orbit, electrons)\n \n # Show creation of the atom\n self.play(FadeIn(nucleus), Create(electron_orbit), FadeIn(electrons))\n \n # Animate electrons\n electron_animations = [\n Rotate(electron, about_point=nucleus.get_center(), angle=2*PI, run_time=4, rate_func=linear)\n for electron in electrons\n ]\n self.play(*electron_animations, rate_func=linear)\n \n # Move atom to the side\n self.play(atom.animate.to_edge(LEFT))\n \n # Create another atom and move it to the opposite side\n second_atom = atom.copy()\n self.add(second_atom)\n self.play(second_atom.animate.to_edge(RIGHT))\n \n # Fade out everything\n self.play(FadeOut(VGroup(atom, second_atom)))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visualize the transformation of a matrix under Cartan Decomposition when applying the Lie algebra to a symmetric space?", "chosen": "```python\nfrom manim import *\n\nclass CartanDecompositionScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling the Symmetric Spaces\", font_size=36)\n subtitle = Text(\"Cartan Decomposition Made Visual\", font_size=28)\n subtitle.next_to(title, DOWN, buff=0.3)\n title_group = VGroup(title, subtitle).to_edge(UP)\n \n self.play(Write(title), Write(subtitle))\n self.wait(1)\n \n # Introduction - Visualize matrix transformation\n intro_text = Text(\"Matrices in symmetric spaces\", font_size=28)\n intro_text.next_to(title_group, DOWN, buff=0.7)\n \n # Matrix representation\n matrix = Square(side_length=2, color=BLUE)\n matrix_label = Text(\"A\", font_size=36).move_to(matrix)\n \n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Create(matrix), Write(matrix_label))\n self.wait(1)\n \n # First equation - Cartan Decomposition\n eq1 = Text(\"A = H + N + D\", font_size=36)\n eq1.to_edge(DOWN, buff=1.5)\n self.play(Write(eq1))\n self.wait(1)\n \n # Decompose the matrix\n h_comp = Square(side_length=1, color=GREEN).move_to(2.5*LEFT)\n h_label = Text(\"H\", font_size=28).move_to(h_comp)\n h_label.set_color(GREEN)\n \n n_comp = Square(side_length=1, color=YELLOW).move_to(ORIGIN)\n n_label = Text(\"N\", font_size=28).move_to(n_comp)\n n_label.set_color(YELLOW)\n \n d_comp = Square(side_length=1, color=RED).move_to(2.5*RIGHT)\n d_label = Text(\"D\", font_size=28).move_to(d_comp)\n d_label.set_color(RED)\n \n # Animate matrix splitting into components\n self.play(\n FadeOut(matrix),\n FadeOut(matrix_label)\n )\n \n self.play(\n Create(h_comp),\n Create(n_comp),\n Create(d_comp)\n )\n \n self.play(\n Write(h_label),\n Write(n_label),\n Write(d_label)\n )\n self.wait(1.5)\n \n # Second equation - Exponential transformation\n self.play(\n FadeOut(h_comp),\n FadeOut(n_comp),\n FadeOut(d_comp),\n FadeOut(h_label),\n FadeOut(n_label),\n FadeOut(d_label),\n FadeOut(eq1),\n FadeOut(intro_text)\n )\n \n transform_text = Text(\"Transformation through exponentials\", font_size=28)\n transform_text.next_to(title_group, DOWN, buff=0.7)\n self.play(Write(transform_text))\n self.wait(1)\n \n eq2 = Text(\"M = exp(tH) * exp(U) * exp(S)\", font_size=32) # Changed · to * for compatibility\n eq2.to_edge(DOWN, buff=1.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Visual representation of transformation\n start = Circle(radius=1, color=GREEN).move_to(3*LEFT)\n start_label = Text(\"exp(tH)\", font_size=24).next_to(start, DOWN)\n start_label.set_color(GREEN)\n \n arrow1 = Arrow(start.get_right(), start.get_right() + RIGHT*2, buff=0.2)\n \n middle = Square(side_length=1.5, color=YELLOW).move_to(ORIGIN)\n middle_label = Text(\"exp(U)\", font_size=24).next_to(middle, DOWN)\n middle_label.set_color(YELLOW)\n \n arrow2 = Arrow(middle.get_right(), middle.get_right() + RIGHT*2, buff=0.2)\n \n # Using a properly oriented triangle for better display\n end = Triangle(color=BLUE).scale(1).move_to(3*RIGHT)\n end_label = Text(\"exp(S)\", font_size=24).next_to(end, DOWN)\n end_label.set_color(BLUE)\n \n # Animate the transformation sequence\n self.play(Create(start))\n self.play(Write(start_label))\n self.wait(0.5)\n \n self.play(Create(arrow1))\n self.wait(0.5)\n \n self.play(Create(middle))\n self.play(Write(middle_label))\n self.wait(0.5)\n \n self.play(Create(arrow2))\n self.wait(0.5)\n \n self.play(Create(end))\n self.play(Write(end_label))\n self.wait(1.5)\n \n # Conclusion\n self.play(\n FadeOut(start),\n FadeOut(start_label),\n FadeOut(middle),\n FadeOut(middle_label),\n FadeOut(end),\n FadeOut(end_label),\n FadeOut(arrow1),\n FadeOut(arrow2),\n FadeOut(eq2),\n FadeOut(transform_text)\n )\n \n conclusion = Text(\"Cartan Decomposition reveals symmetric structures\", font_size=28)\n conclusion.next_to(title_group, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n \n final_message = Text(\"Thank you for watching!\", font_size=32)\n final_message.move_to(ORIGIN)\n self.play(FadeOut(title), FadeOut(subtitle), FadeOut(conclusion), Write(final_message))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass CartanDecompositionScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling the Symmetric Spaces\", font_size=36)\n subtitle = Text(\"Cartan Decomposition Made Visual\", font_size=28)\n subtitle.next_to(title, DOWN, buff=0.3)\n title_group = VGroup(title, subtitle).to_edge(UP)\n \n self.play(Write(title), Write(subtitle))\n self.wait(1)\n \n # Introduction - Visualize matrix transformation\n intro_text = Text(\"Matrices in symmetric spaces\", font_size=28)\n intro_text.next_to(title_group, DOWN, buff=0.7)\n \n # Matrix representation\n matrix = Square(side_length=2, color=BBLUE)\n matrix_label = Text(\"A\", font_size=36).move_to(matrix)\n \n self.play(Write(intro_text))\n self.wait(0.5)\n self.play(Create(matrix), Write(matrix_label))\n self.wait(1)\n \n # First equation - Cartan Decomposition\n eq1 = Text(\"A = H + N + D\", font_size=36)\n eq1.to_edge(DOWN, buff=1.5)\n self.play(Write(eq1))\n self.wait(1)\n \n # Decompose the matrix\n h_comp = Square(side_length=1, color=GREEN).move_to(2.5*LEFT)\n h_label = Text(\"H\", font_size=28).move_to(h_comp)\n h_label.set_color(GREEN)\n \n n_comp = Square(side_length=1, color=YELLOW).move_to(ORIGIN)\n n_label = Text(\"N\", font_size=28).move_to(n_comp)\n n_label.set_color(YELLOW)\n \n d_comp = Square(side_length=1, color=RED).move_to(2.5*RIGHT)\n d_label = Text(\"D\", font_size=28).move_to(d_comp)\n d_label.set_color(RED)\n \n # Animate matrix splitting into components\n self.play(\n FadeOut(matrix),\n FadeOut(matrix_label)\n )\n \n self.play(\n Create(h_comp),\n Create(n_comp),\n Create(d_comp)\n )\n \n self.play(\n Write(h_label),\n Write(n_label),\n Write(d_label)\n )\n self.wait(1.5)\n \n # Second equation - Exponential transformation\n self.play(\n FadeOut(h_comp),\n FadeOut(n_comp),\n FadeOut(d_comp),\n FadeOut(h_label),\n FadeOut(n_label),\n FadeOut(d_label),\n FadeOut(eq1),\n FadeOut(intro_text)\n )\n \n transform_text = Text(\"Transformation through exponentials\", font_size=28)\n transform_text.next_to(title_group, DOWN, buff=0.7)\n self.play(Write(transform_text))\n self.wait(1)\n \n eq2 = Text(\"M = exp(tH) * exp(U) * exp(S)\", font_size=32) # Changed · to * for compatibility\n eq2.to_edge(DOWN, buff=1.5)\n self.play(Write(eq2))\n self.wait(1)\n \n # Visual representation of transformation\n start = Circle(radius=1, color=GREEN).move_to(3*LEFT)\n start_label = Text(\"exp(tH)\", font_size=24).next_to(start, DOWN)\n start_label.set_color(GREEN)\n \n arrow1 = Arrow(start.get_right(), start.get_right() + RIGHT*2, buff=0.2)\n \n middle = Square(side_length=1.5, color=YELLOW).move_to(ORIGIN)\n middle_label = Text(\"exp(U)\", font_size=24).next_to(middle, DOWN)\n middle_label.set_color(YELLOW)\n \n arrow2 = Arrow(middle.get_right(), middle.get_right() + RIGHT*2, buff=0.2)\n \n # Using a properly oriented triangle for better display\n end = Triangle(color=BLUE).scale(1).move_to(3*RIGHT)\n end_label = Text(\"exp(S)\", font_size=24).next_to(end, DOWN)\n end_label.set_color(BLUE)\n \n # Animate the transformation sequence\n self.play(Create(start))\n self.play(Write(start_label))\n self.wait(0.5)\n \n self.play(Create(arrow1))\n self.wait(0.5)\n \n self.play(Create(middle))\n self.play(Write(middle_label))\n self.wait(0.5)\n \n self.play(Create(arrow2))\n self.wait(0.5)\n \n self.play(Create(end))\n self.play(Write(end_label))\n self.wait(1.5)\n \n # Conclusion\n self.play(\n FadeOut(start),\n FadeOut(start_label),\n FadeOut(middle),\n FadeOut(middle_label),\n FadeOut(end),\n FadeOut(end_label),\n FadeOut(arrow1),\n FadeOut(arrow2),\n FadeOut(eq2),\n FadeOut(transform_text)\n )\n \n conclusion = Text(\"Cartan Decomposition reveals symmetric structures\", font_size=28)\n conclusion.next_to(title_group, DOWN, buff=1)\n self.play(Write(conclusion))\n self.wait(2)\n \n final_message = Text(\"Thank you for watching!\", font_size=32)\n final_message.move_to(ORIGIN)\n self.play(FadeOut(title), FadeOut(subtitle), FadeOut(conclusion), Write(final_message))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 screen, and then both the text and the square disappear?", "chosen": "```python\nfrom manim import *\n\nclass ScaleToFitAnimation(Scene):\n def construct(self):\n # --- Step 1: Text Transformation ---\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```", "rejected": "```python\nfrom manim import *\n\nclass ScaleToFitAnimation(Scene):\n def construct(self):\n # --- Step 1: Text Transformation ---\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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 an enhanced version of the animation that includes all original features while adding significant new elements:\n\nThe enhanced animation begins by constructing the original neural network with four layers (two convolutional, one max pooling, and another convolutional) centered on screen, but now introduces a dynamic title (\"Convolutional Neural Network Visualization\") that fades in at the top of the screen as the network appears. As the forward pass animation plays, each layer's activation is accompanied by a floating annotation that briefly displays the layer's dimensions and operation type (e.g., \"3x3 Conv, 6 filters\") in a callout box near the layer. During the max pooling operation, the animation visually demonstrates the pooling process by zooming in on a 2x2 region, highlighting how it selects the maximum value before continuing the forward pass. Finally, after the forward pass completes, the network smoothly transforms into a simplified flowchart version that appears beside an animated mathematical formula (∂L/∂W = δ * â) representing the backpropagation gradient calculation, with arrows indicating the flow of gradients backward through the network, creating a comprehensive visualization of both forward and backward passes in a single cohesive animation.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedNeuralNetwork(Scene):\n def construct(self):\n # Title animation\n title = Text(\"Convolutional Neural Network Visualization\", font_size=24).to_edge(UP)\n self.play(FadeIn(title))\n self.wait(0.5)\n\n # Create layers\n input_layer = Square(side_length=1.5, fill_color=BLUE, fill_opacity=0.7, stroke_width=2)\n conv1 = Square(side_length=1.5, fill_color=RED, fill_opacity=0.7, stroke_width=2)\n pool = Square(side_length=1.5, fill_color=GREEN, fill_opacity=0.7, stroke_width=2)\n conv2 = Square(side_length=1.5, fill_color=RED, fill_opacity=0.7, stroke_width=2)\n output_layer = Square(side_length=1.5, fill_color=BLUE, fill_opacity=0.7, stroke_width=2)\n\n # Position layers\n layers = VGroup(input_layer, conv1, pool, conv2, output_layer).arrange(RIGHT, buff=1.5)\n layers.move_to(ORIGIN)\n\n # Draw layers\n self.play(*[Create(layer) for layer in layers])\n self.wait(0.5)\n\n # Layer labels\n input_label = Text(\"Input\", font_size=18).next_to(input_layer, DOWN)\n conv1_label = Text(\"Conv1\", font_size=18).next_to(conv1, DOWN)\n pool_label = Text(\"MaxPool\", font_size=18).next_to(pool, DOWN)\n conv2_label = Text(\"Conv2\", font_size=18).next_to(conv2, DOWN)\n output_label = Text(\"Output\", font_size=18).next_to(output_layer, DOWN)\n\n self.play(*[Write(label) for label in [input_label, conv1_label, pool_label, conv2_label, output_label]])\n self.wait(0.5)\n\n # Forward pass animation\n arrows = []\n for i in range(len(layers)-1):\n arrow = Arrow(layers[i].get_right(), layers[i+1].get_left(), buff=0.2)\n arrows.append(arrow)\n self.play(Create(arrow))\n \n # Show layer info annotation\n if i == 0:\n info = Text(\"3x3 Conv\\n6 filters\", font_size=16)\n elif i == 1:\n info = Text(\"2x2 MaxPool\\nstride 2\", font_size=16)\n elif i == 2:\n info = Text(\"3x3 Conv\\n16 filters\", font_size=16)\n \n info.next_to(layers[i+1], UP, buff=0.5)\n self.play(FadeIn(info))\n self.wait(0.5)\n self.play(FadeOut(info))\n \n # Special animation for pooling layer\n if i == 1:\n zoom_rect = SurroundingRectangle(layers[i], color=YELLOW, buff=0.1)\n self.play(Create(zoom_rect))\n self.wait(0.3)\n \n # Create a small grid inside the pool layer\n grid = VGroup()\n for x in np.linspace(-0.6, 0.6, 3):\n for y in np.linspace(-0.6, 0.6, 3):\n dot = Dot(point=[x, y, 0], color=WHITE, radius=0.05)\n grid.add(dot)\n grid.move_to(layers[i].get_center())\n \n self.play(Transform(zoom_rect, SurroundingRectangle(grid, color=YELLOW, buff=0.1)))\n self.play(FadeIn(grid))\n self.wait(0.5)\n \n # Highlight max pooling operation\n highlight = VGroup(grid[0], grid[1], grid[3], grid[4])\n highlight_box = SurroundingRectangle(highlight, color=RED, buff=0.1)\n self.play(Create(highlight_box))\n self.wait(0.5)\n \n max_dot = grid[4].copy().set_color(RED).scale(1.5)\n self.play(Transform(grid[4].copy(), max_dot))\n self.wait(0.5)\n \n self.play(FadeOut(highlight_box), FadeOut(max_dot), FadeOut(grid), \n FadeOut(zoom_rect))\n \n self.wait(1)\n\n # Transform to simplified version\n simplified_layers = VGroup(\n Rectangle(height=1, width=2, fill_color=BLUE, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=RED, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=GREEN, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=RED, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=BLUE, fill_opacity=0.7)\n ).arrange(RIGHT, buff=1).scale(0.7).to_edge(LEFT)\n\n self.play(Transform(layers, simplified_layers),\n *[FadeOut(arrow) for arrow in arrows],\n *[FadeOut(label) for label in [input_label, conv1_label, pool_label, conv2_label, output_label]])\n \n # Add backpropagation formula\n formula = MathTex(r\"\\frac{\\partial L}{\\partial W} = \\delta \\cdot \\hat{a}\").scale(1.2)\n formula.next_to(simplified_layers, RIGHT, buff=1.5)\n \n self.play(Write(formula))\n self.wait(1)\n \n # Show backward pass arrows\n backward_arrows = []\n for i in range(len(simplified_layers)-1, 0, -1):\n arrow = Arrow(\n simplified_layers[i].get_left(), \n simplified_layers[i-1].get_right(), \n buff=0.2, \n color=YELLOW\n )\n backward_arrows.append(arrow)\n self.play(Create(arrow))\n self.wait(0.3)\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedNeuralNetwork(Scene):\n def construct(self):\n # Title animation\n title = Text(\"Convolutional Neural Network Visualization\", font_size=24).to_edge(UP)\n self.play(FadeIn(title))\n self.wait(0.5)\n\n # Create layers\n input_layer = Square(side_length=1.5, fill_color=BBLUE, fill_opacity=0.7, stroke_width=2)\n conv1 = Square(side_length=1.5, fill_color=RED, fill_opacity=0.7, stroke_width=2)\n pool = Square(side_length=1.5, fill_color=GREEN, fill_opacity=0.7, stroke_width=2)\n conv2 = Square(side_length=1.5, fill_color=RED, fill_opacity=0.7, stroke_width=2)\n output_layer = Square(side_length=1.5, fill_color=BLUE, fill_opacity=0.7, stroke_width=2)\n\n # Position layers\n layers = VGroup(input_layer, conv1, pool, conv2, output_layer).arrange(RIGHT, buff=1.5)\n layers.move_to(ORIGIN)\n\n # Draw layers\n self.play(*[Create(layer) for layer in layers])\n self.wait(0.5)\n\n # Layer labels\n input_label = Text(\"Input\", font_size=18).next_to(input_layer, DOWN)\n conv1_label = Text(\"Conv1\", font_size=18).next_to(conv1, DOWN)\n pool_label = Text(\"MaxPool\", font_size=18).next_to(pool, DOWN)\n conv2_label = Text(\"Conv2\", font_size=18).next_to(conv2, DOWN)\n output_label = Text(\"Output\", font_size=18).next_to(output_layer, DOWN)\n\n self.play(*[Write(label) for label in [input_label, conv1_label, pool_label, conv2_label, output_label]])\n self.wait(0.5)\n\n # Forward pass animation\n arrows = []\n for i in range(len(layers)-1):\n arrow = Arrow(layers[i].get_right(), layers[i+1].get_left(), buff=0.2)\n arrows.append(arrow)\n self.play(Create(arrow))\n \n # Show layer info annotation\n if i == 0:\n info = Text(\"3x3 Conv\\n6 filters\", font_size=16)\n elif i == 1:\n info = Text(\"2x2 MaxPool\\nstride 2\", font_size=16)\n elif i == 2:\n info = Text(\"3x3 Conv\\n16 filters\", font_size=16)\n \n info.next_to(layers[i+1], UP, buff=0.5)\n self.play(FadeIn(info))\n self.wait(0.5)\n self.play(FadeOut(info))\n \n # Special animation for pooling layer\n if i == 1:\n zoom_rect = SurroundingRectangle(layers[i], color=YELLOW, buff=0.1)\n self.play(Create(zoom_rect))\n self.wait(0.3)\n \n # Create a small grid inside the pool layer\n grid = VGroup()\n for x in np.linspace(-0.6, 0.6, 3):\n for y in np.linspace(-0.6, 0.6, 3):\n dot = Dot(point=[x, y, 0], color=WHITE, radius=0.05)\n grid.add(dot)\n grid.move_to(layers[i].get_center())\n \n self.play(Transform(zoom_rect, SurroundingRectangle(grid, color=YELLOW, buff=0.1)))\n self.play(FadeIn(grid))\n self.wait(0.5)\n \n # Highlight max pooling operation\n highlight = VGroup(grid[0], grid[1], grid[3], grid[4])\n highlight_box = SurroundingRectangle(highlight, color=RED, buff=0.1)\n self.play(Create(highlight_box))\n self.wait(0.5)\n \n max_dot = grid[4].copy().set_color(RED).scale(1.5)\n self.play(Transform(grid[4].copy(), max_dot))\n self.wait(0.5)\n \n self.play(FadeOut(highlight_box), FadeOut(max_dot), FadeOut(grid), \n FadeOut(zoom_rect))\n \n self.wait(1)\n\n # Transform to simplified version\n simplified_layers = VGroup(\n Rectangle(height=1, width=2, fill_color=BLUE, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=RED, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=GREEN, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=RED, fill_opacity=0.7),\n Rectangle(height=1, width=2, fill_color=BLUE, fill_opacity=0.7)\n ).arrange(RIGHT, buff=1).scale(0.7).to_edge(LEFT)\n\n self.play(Transform(layers, simplified_layers),\n *[FadeOut(arrow) for arrow in arrows],\n *[FadeOut(label) for label in [input_label, conv1_label, pool_label, conv2_label, output_label]])\n \n # Add backpropagation formula\n formula = MathTex(r\"\\frac{\\partial L}{\\partial W} = \\delta \\cdot \\hat{a}\").scale(1.2)\n formula.next_to(simplified_layers, RIGHT, buff=1.5)\n \n self.play(Write(formula))\n self.wait(1)\n \n # Show backward pass arrows\n backward_arrows = []\n for i in range(len(simplified_layers)-1, 0, -1):\n arrow = Arrow(\n simplified_layers[i].get_left(), \n simplified_layers[i-1].get_right(), \n buff=0.2, \n color=YELLOW\n )\n backward_arrows.append(arrow)\n self.play(Create(arrow))\n self.wait(0.3)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 do invariants help in solving the orbit counting problem in combinatorial settings?", "chosen": "```python\nfrom manim import *\n\nclass InvariantTheoryScene(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Unraveling the Beauty of Invariant Theory\", font_size=36)\n subtitle = Text(\"Orbit Counting Simplified\", font_size=28).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(subtitle), title.animate.to_edge(UP).scale(0.7))\n \n # Explaining Invariants\n invariant_text = Text(\"Invariants: Properties unchanged by group actions\", font_size=28)\n self.play(Write(invariant_text), run_time=2)\n self.wait(1)\n self.play(invariant_text.animate.shift(UP))\n \n # Visual demonstration with shapes\n square = Square(side_length=1, color=BLUE).shift(LEFT*2)\n triangle = Triangle(color=ORANGE).shift(RIGHT*2)\n \n inv_label1 = Text(\"Invariant\", font_size=16).next_to(square, DOWN)\n inv_label2 = Text(\"Invariant\", font_size=16).next_to(triangle, DOWN)\n \n self.play(Create(square), Create(triangle), run_time=1)\n self.play(Write(inv_label1), Write(inv_label2), run_time=1)\n \n # Show transformations while invariants remain\n self.play(\n Rotate(square, PI),\n triangle.animate.flip(),\n run_time=2\n )\n self.wait(1)\n \n # Clear for orbit visualization\n self.play(\n FadeOut(square), FadeOut(triangle),\n FadeOut(inv_label1), FadeOut(inv_label2),\n FadeOut(invariant_text), FadeOut(title)\n )\n \n # Orbit visualization\n orbit_text = Text(\"Group actions create orbits\", font_size=32).to_edge(UP)\n self.play(Write(orbit_text), run_time=1)\n \n # Create a simple orbit visualization\n circle = Circle(radius=1.5, color=WHITE)\n dots = VGroup(*[Dot(circle.point_at_angle(i*PI/3), color=BLUE) for i in range(6)])\n \n self.play(Create(circle), run_time=1)\n self.play(Create(dots), run_time=1)\n \n # Show group action by rotation\n self.play(Rotate(dots, angle=PI/3, about_point=ORIGIN), run_time=2)\n self.wait(1)\n \n # The orbit-counting formula\n self.play(\n FadeOut(circle),\n FadeOut(dots)\n )\n \n formula = MathTex(r\"|X/G| = \\frac{1}{|G|} \\sum_{g \\in G} |X^g|\")\n formula_text = Text(\"Orbit-Counting Theorem\", font_size=24).next_to(formula, DOWN)\n \n self.play(Write(formula), run_time=2)\n self.play(Write(formula_text), run_time=1)\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(formula),\n FadeOut(formula_text),\n FadeOut(orbit_text)\n )\n \n conclusion = Text(\"Invariants: Key to Simplifying Orbit Counting\", font_size=32)\n self.play(Write(conclusion), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass InvariantTheoryScene(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Unraveling the Beauty of Invariant Theory\", font_size=36)\n subtitle = Text(\"Orbit Counting Simplified\", font_size=28).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(subtitle), title.animate.to_edge(UP).scale(0.7))\n \n # Explaining Invariants\n invariant_text = Text(\"Invariants: Properties unchanged by group actions\", font_size=28)\n self.play(Write(invariant_text), run_time=2)\n self.wait(1)\n self.play(invariant_text.animate.shift(UP))\n \n # Visual demonstration with shapes\n square = Square(side_length=1, color=BLUE).shift(LEFT*2)\n triangle = Triangle(color=ORANGE).shift(RIGHT*2)\n \n inv_label1 = Text(\"Invariant\", font_size=16).next_to(square, DOWN)\n inv_label2 = Text(\"Invariant\", font_size=16).next_to(triangle, DOWN)\n \n self.play(Create(square), Create(triangle), run_time=1)\n self.play(Write(inv_label1), Write(inv_label2), run_time=1)\n \n # Show transformations while invariants remain\n self.play(\n Rotate(square, PI),\n triangle.animate.flip(),\n run_time=2\n )\n self.wait(1)\n \n # Clear for orbit visualization\n self.play(\n FadeOut(square), FadeOut(triangle),\n FadeOut(inv_label1), FadeOut(inv_label2),\n FadeOut(invariant_text), FadeOut(title)\n )\n \n # Orbit visualization\n orbit_text = Text(\"Group actions create orbits\", font_size=32).to_edge(UP)\n self.play(Write(orbit_text), run_time=1)\n \n # Create a simple orbit visualization\n circle = Circle(radius=1.5, color=WHITE)\n dots = VGroup(*[Dot(circle.point_at_angle(i*PI/3), color=BLUE) for i in range(6)])\n \n self.play(Create(circle), run_time=1)\n self.play(Create(dots), run_time=1)\n \n # Show group action by rotation\n self.play(Rotate(dots, angle=PI/3, about_point=ORIGIN), run_time=2)\n self.wait(1)\n \n # The orbit-counting formula\n self.play(\n FadeOut(circle),\n FadeOut(dots)\n )\n \n formula = MathText(r\"|X/G| = \\frac{1}{|G|} \\sum_{g \\in G} |X^g|\")\n formula_text = Text(\"Orbit-Counting Theorem\", font_size=24).next_to(formula, DOWN)\n \n self.play(Write(formula), run_time=2)\n self.play(Write(formula_text), run_time=1)\n self.wait(1)\n \n # Conclusion\n self.play(\n FadeOut(formula),\n FadeOut(formula_text),\n FadeOut(orbit_text)\n )\n \n conclusion = Text(\"Invariants: Key to Simplifying Orbit Counting\", font_size=32)\n self.play(Write(conclusion), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Manim scene explaining hash collisions with linear probing. Use a seven-slot table and insert keys 18, 25, and 32, which share the same initial hash slot. Animate the collisions and successive probes so the viewer sees why lookup must follow the same probe sequence.", "chosen": "```python\nfrom manim import *\n\nclass LinearProbingCollision(Scene):\n def construct(self):\n title = Text(\"Linear probing resolves a collision by checking the next slot\", font_size=33).to_edge(UP)\n rule = Text(\"h(k) = k mod 7\", font_size=26, color=BLUE_B).next_to(title, DOWN)\n slots = VGroup(*[\n Square(side_length=0.85, color=GRAY_B) for _ in range(7)\n ]).arrange(RIGHT, buff=0.08).shift(DOWN * 0.25)\n indices = VGroup(*[\n Text(str(index), font_size=20).next_to(slot, DOWN, buff=0.12)\n for index, slot in enumerate(slots)\n ])\n keys = VGroup(*[\n VGroup(\n RoundedRectangle(width=1.0, height=0.55, corner_radius=0.1, color=TEAL_B),\n Text(str(value), font_size=24),\n )\n for value in (18, 25, 32)\n ]).arrange(RIGHT, buff=0.5).shift(UP * 1.25)\n captions = [\n Text(\"18 hashes to slot 4\", font_size=24),\n Text(\"25 also hashes to 4: occupied, so probe slot 5\", font_size=24),\n Text(\"32 probes 4, then 5, and lands in slot 6\", font_size=24),\n ]\n for caption in captions:\n caption.to_edge(DOWN)\n\n self.play(Write(title), FadeIn(rule), Create(slots), FadeIn(indices), FadeIn(keys))\n stored = []\n first = Text(\"18\", font_size=24).move_to(slots[4])\n self.play(FadeIn(captions[0]), TransformFromCopy(keys[0], first), Circumscribe(slots[4]))\n stored.append(first)\n\n second = Text(\"25\", font_size=24).move_to(slots[5])\n self.play(ReplacementTransform(captions[0], captions[1]), Indicate(slots[4], color=RED))\n self.play(TransformFromCopy(keys[1], second), Circumscribe(slots[5]))\n stored.append(second)\n\n third = Text(\"32\", font_size=24).move_to(slots[6])\n self.play(ReplacementTransform(captions[1], captions[2]))\n self.play(Indicate(slots[4], color=RED), Indicate(slots[5], color=RED))\n self.play(TransformFromCopy(keys[2], third), Circumscribe(slots[6]))\n lookup = Text(\"Lookup repeats this same probe sequence.\", font_size=25, color=YELLOW).to_edge(DOWN)\n self.play(ReplacementTransform(captions[2], lookup))\n self.play(LaggedStart(*[Indicate(slots[index], color=YELLOW) for index in (4, 5, 6)], lag_ratio=0.4))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass LinearProbingCollision(Scene):\n def construct(self):\n title = Text(\"Linear probing resolves a collision by checking the next slot\", font_size=33).to_edge(UP)\n rule = Text(\"h(k) = k mod 7\", font_size=26, color=BLUE_B).next_to(title, DOWN)\n slots = VGroup(*[\n Square(side_length=0.85, color=GRAY_B) for _ in range(7)\n ]).arrange(RIGHT, buff=0.08).shift(DOWN * 0.25)\n indices = VGroup(*[\n Text(str(index), font_size=20).next_to(slot, DOWN, buff=0.12)\n for index, slot in enumerate(slots)\n ])\n keys = VGroup(*[\n VGroup(\n RoundRect(width=1.0, height=0.55, corner_radius=0.1, color=TEAL_B),\n Text(str(value), font_size=24),\n )\n for value in (18, 25, 32)\n ]).arrange(RIGHT, buff=0.5).shift(UP * 1.25)\n captions = [\n Text(\"18 hashes to slot 4\", font_size=24),\n Text(\"25 also hashes to 4: occupied, so probe slot 5\", font_size=24),\n Text(\"32 probes 4, then 5, and lands in slot 6\", font_size=24),\n ]\n for caption in captions:\n caption.to_edge(DOWN)\n\n self.play(Write(title), FadeIn(rule), Create(slots), FadeIn(indices), FadeIn(keys))\n stored = []\n first = Text(\"18\", font_size=24).move_to(slots[4])\n self.play(FadeIn(captions[0]), TransformFromCopy(keys[0], first), Circumscribe(slots[4]))\n stored.append(first)\n\n second = Text(\"25\", font_size=24).move_to(slots[5])\n self.play(ReplacementTransform(captions[0], captions[1]), Indicate(slots[4], color=RED))\n self.play(TransformFromCopy(keys[1], second), Circumscribe(slots[5]))\n stored.append(second)\n\n third = Text(\"32\", font_size=24).move_to(slots[6])\n self.play(ReplacementTransform(captions[1], captions[2]))\n self.play(Indicate(slots[4], color=RED), Indicate(slots[5], color=RED))\n self.play(TransformFromCopy(keys[2], third), Circumscribe(slots[6]))\n lookup = Text(\"Lookup repeats this same probe sequence.\", font_size=25, color=YELLOW).to_edge(DOWN)\n self.play(ReplacementTransform(captions[2], lookup))\n self.play(LaggedStart(*[Indicate(slots[index], color=YELLOW) for index in (4, 5, 6)], lag_ratio=0.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does Gaussian curvature influence the shape of a surface in four-dimensional spaces compared to three-dimensional spaces?", "chosen": "```python\nfrom manim import *\n\nclass GaussianCurvatureIn4D(Scene):\n def construct(self):\n # Title and introduction\n title = Text(\"Curvature Beyond Dimensions: Bending in 4D\", font_size=24)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n\n # Explaining 3D curvature\n intro_text = Text(\"How does a surface bend in 3D?\", font_size=20)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n\n # Visualization of a 2D surface (paper)\n paper = Rectangle(height=2, width=3, color=BLUE, fill_opacity=0.5)\n self.play(Create(paper))\n self.wait(1)\n \n # Transform to a sphere (positive curvature)\n sphere_text = Text(\"Sphere: Positive Curvature\", font_size=16).to_edge(DOWN)\n curved_shape = Circle(radius=1.5, color=BLUE, fill_opacity=0.5)\n self.play(Write(sphere_text))\n self.play(Transform(paper, curved_shape))\n self.wait(1.5)\n self.play(FadeOut(sphere_text))\n \n # Transform to a \"saddle\" representation (negative curvature)\n saddle_text = Text(\"Saddle: Negative Curvature\", font_size=16).to_edge(DOWN)\n \n # Simple representation of a saddle using crossed lines\n line1 = Line(start=[-1.5, -1.5, 0], end=[1.5, 1.5, 0], color=BLUE)\n line2 = Line(start=[-1.5, 1.5, 0], end=[1.5, -1.5, 0], color=BLUE)\n saddle = VGroup(line1, line2)\n \n self.play(Write(saddle_text))\n self.play(Transform(paper, saddle))\n self.wait(1.5)\n self.play(FadeOut(saddle_text))\n\n # Introducing Gaussian curvature in 3D\n curvature_text = Text(\"In 3D, Gaussian curvature measures how a surface bends\", font_size=18)\n self.play(Write(curvature_text))\n self.wait(1.5)\n self.play(FadeOut(curvature_text))\n self.play(FadeOut(paper))\n\n # Showing the equation for Gaussian curvature\n equation = MathTex(r\"K = \\frac{det\\, II}{det\\, I}\")\n self.play(Write(equation))\n self.wait(1.5)\n self.play(FadeOut(equation))\n\n # Transition to 4D\n fourD_text = Text(\"What about in 4D?\", font_size=20)\n self.play(Write(fourD_text))\n self.wait(1)\n self.play(FadeOut(fourD_text))\n\n # 4D metric equation\n metric = MathTex(r\"ds^2 = dx^2 + dy^2 + dz^2 + dw^2\")\n self.play(Write(metric))\n self.wait(1.5)\n self.play(FadeOut(metric))\n\n # Visualization for 4D\n four_d_text = Text(\"Visualizing 4D projection\", font_size=18)\n self.play(Write(four_d_text))\n self.wait(1)\n self.play(FadeOut(four_d_text))\n \n # Using squares to represent dimensions\n square_3d = Square(side_length=2, color=BLUE, fill_opacity=0.5)\n self.play(Create(square_3d))\n self.wait(1)\n \n # Create a representation of 4D with nested squares\n inner_square = Square(side_length=1.5, color=PURPLE, fill_opacity=0.4)\n inner_square.shift(0.25*UP + 0.25*RIGHT)\n square_4d = VGroup(\n square_3d.copy().set_opacity(0.3),\n inner_square\n )\n \n transform_text = Text(\"Adding a 4th dimension\", font_size=16).to_edge(DOWN)\n self.play(Write(transform_text))\n self.play(Transform(square_3d, square_4d))\n self.wait(1.5)\n self.play(FadeOut(transform_text))\n \n # Rotating to suggest higher-dimensional movement\n rotation_text = Text(\"Rotating in 4D space\", font_size=16).to_edge(DOWN)\n self.play(Write(rotation_text))\n self.play(Rotate(square_3d, angle=PI/2, rate_func=smooth))\n self.wait(1)\n self.play(FadeOut(rotation_text))\n \n # Final insight\n conclusion = Text(\"Gaussian curvature influences shape across dimensions!\", font_size=18)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(square_3d))\n\n # Final title\n final_title = Text(\"Curvature Beyond Dimensions: Bending in 4D\", font_size=24)\n self.play(Write(final_title))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass GaussianCurvatureIn4D(Scene):\n def construct(self):\n # Title and introduction\n title = Text(\"Curvature Beyond Dimensions: Bending in 4D\", font_size=24)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n\n # Explaining 3D curvature\n intro_text = Text(\"How does a surface bend in 3D?\", font_size=20)\n self.play(Write(intro_text))\n self.wait(1)\n self.play(FadeOut(intro_text))\n\n # Visualization of a 2D surface (paper)\n paper = Rectangle(height=2, width=3, color=BBLUE, fill_opacity=0.5)\n self.play(Create(paper))\n self.wait(1)\n \n # Transform to a sphere (positive curvature)\n sphere_text = Text(\"Sphere: Positive Curvature\", font_size=16).to_edge(DOWN)\n curved_shape = Circle(radius=1.5, color=BLUE, fill_opacity=0.5)\n self.play(Write(sphere_text))\n self.play(Transform(paper, curved_shape))\n self.wait(1.5)\n self.play(FadeOut(sphere_text))\n \n # Transform to a \"saddle\" representation (negative curvature)\n saddle_text = Text(\"Saddle: Negative Curvature\", font_size=16).to_edge(DOWN)\n \n # Simple representation of a saddle using crossed lines\n line1 = Line(start=[-1.5, -1.5, 0], end=[1.5, 1.5, 0], color=BLUE)\n line2 = Line(start=[-1.5, 1.5, 0], end=[1.5, -1.5, 0], color=BLUE)\n saddle = VGroup(line1, line2)\n \n self.play(Write(saddle_text))\n self.play(Transform(paper, saddle))\n self.wait(1.5)\n self.play(FadeOut(saddle_text))\n\n # Introducing Gaussian curvature in 3D\n curvature_text = Text(\"In 3D, Gaussian curvature measures how a surface bends\", font_size=18)\n self.play(Write(curvature_text))\n self.wait(1.5)\n self.play(FadeOut(curvature_text))\n self.play(FadeOut(paper))\n\n # Showing the equation for Gaussian curvature\n equation = MathTex(r\"K = \\frac{det\\, II}{det\\, I}\")\n self.play(Write(equation))\n self.wait(1.5)\n self.play(FadeOut(equation))\n\n # Transition to 4D\n fourD_text = Text(\"What about in 4D?\", font_size=20)\n self.play(Write(fourD_text))\n self.wait(1)\n self.play(FadeOut(fourD_text))\n\n # 4D metric equation\n metric = MathTex(r\"ds^2 = dx^2 + dy^2 + dz^2 + dw^2\")\n self.play(Write(metric))\n self.wait(1.5)\n self.play(FadeOut(metric))\n\n # Visualization for 4D\n four_d_text = Text(\"Visualizing 4D projection\", font_size=18)\n self.play(Write(four_d_text))\n self.wait(1)\n self.play(FadeOut(four_d_text))\n \n # Using squares to represent dimensions\n square_3d = Square(side_length=2, color=BLUE, fill_opacity=0.5)\n self.play(Create(square_3d))\n self.wait(1)\n \n # Create a representation of 4D with nested squares\n inner_square = Square(side_length=1.5, color=PURPLE, fill_opacity=0.4)\n inner_square.shift(0.25*UP + 0.25*RIGHT)\n square_4d = VGroup(\n square_3d.copy().set_opacity(0.3),\n inner_square\n )\n \n transform_text = Text(\"Adding a 4th dimension\", font_size=16).to_edge(DOWN)\n self.play(Write(transform_text))\n self.play(Transform(square_3d, square_4d))\n self.wait(1.5)\n self.play(FadeOut(transform_text))\n \n # Rotating to suggest higher-dimensional movement\n rotation_text = Text(\"Rotating in 4D space\", font_size=16).to_edge(DOWN)\n self.play(Write(rotation_text))\n self.play(Rotate(square_3d, angle=PI/2, rate_func=smooth))\n self.wait(1)\n self.play(FadeOut(rotation_text))\n \n # Final insight\n conclusion = Text(\"Gaussian curvature influences shape across dimensions!\", font_size=18)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(square_3d))\n\n # Final title\n final_title = Text(\"Curvature Beyond Dimensions: Bending in 4D\", font_size=24)\n self.play(Write(final_title))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial shapes\n circle = Circle(color=BLUE, fill_opacity=0.5).shift(LEFT * 2)\n triangle = Triangle(color=RED, fill_opacity=0.5).shift(RIGHT * 2)\n \n # Fade in shapes\n self.play(FadeIn(circle), FadeIn(triangle))\n self.wait(1)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.5).shift(LEFT * 2)\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.5).shift(RIGHT * 2)\n \n # Add formula\n formula = MathTex(\"V - E + F = 2\").to_edge(DOWN)\n explanation = Text(\"Euler's formula\", font_size=24).next_to(formula, UP)\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n Write(formula),\n Write(explanation)\n )\n self.wait(1)\n \n # Rotate shapes with angle counter\n angle_text = Text(\"Rotation angle: 0°\", font_size=24).to_edge(UP)\n self.play(Write(angle_text))\n \n for angle in range(0, 360, 10):\n new_angle_text = Text(f\"Rotation angle: {angle}°\", font_size=24).to_edge(UP)\n self.play(\n square.animate.rotate(angle * DEGREES),\n pentagon.animate.rotate(-angle * DEGREES),\n Transform(angle_text, new_angle_text),\n run_time=0.1\n )\n \n # Merge into hexagon\n hexagon = RegularPolygon(6, color=PURPLE, fill_opacity=0.5)\n gradient_hexagon = hexagon.copy().set_color_by_gradient(TEAL, PINK)\n \n self.play(\n ReplacementTransform(square, hexagon),\n ReplacementTransform(pentagon, hexagon),\n FadeOut(angle_text)\n )\n self.play(Transform(hexagon, gradient_hexagon))\n \n # Pulse hexagon\n self.play(\n hexagon.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=2\n )\n \n # Fade out hexagon, keep formula\n self.play(FadeOut(hexagon))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeTransformation(Scene):\n def construct(self):\n # Create initial shapes\n circle = Circle(color=BLUE, fill_opacity=0.5).shift(LEFT * 2)\n triangle = Triangle(color=RED, fill_opacity=0.5).shift(RIGHT * 2)\n \n # Fade in shapes\n self.play(FadeIn(circle), FadeIn(triangle))\n self.wait(1)\n \n # Transform shapes\n square = Square(color=BLUE, fill_opacity=0.5).shift(LEFT * 2)\n pentagon = RegularPolygon(5, color=RED, fill_opacity=0.5).shift(RIGHT * 2)\n \n # Add formula\n formula = MathText(\"V - E + F = 2\").to_edge(DOWN)\n explanation = Text(\"Euler's formula\", font_size=24).next_to(formula, UP)\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n Write(formula),\n Write(explanation)\n )\n self.wait(1)\n \n # Rotate shapes with angle counter\n angle_text = Text(\"Rotation angle: 0°\", font_size=24).to_edge(UP)\n self.play(Write(angle_text))\n \n for angle in range(0, 360, 10):\n new_angle_text = Text(f\"Rotation angle: {angle}°\", font_size=24).to_edge(UP)\n self.play(\n square.animate.rotate(angle * DEGREES),\n pentagon.animate.rotate(-angle * DEGREES),\n Transform(angle_text, new_angle_text),\n run_time=0.1\n )\n \n # Merge into hexagon\n hexagon = RegularPolygon(6, color=PURPLE, fill_opacity=0.5)\n gradient_hexagon = hexagon.copy().set_color_by_gradient(TEAL, PINK)\n \n self.play(\n ReplacementTransform(square, hexagon),\n ReplacementTransform(pentagon, hexagon),\n FadeOut(angle_text)\n )\n self.play(Transform(hexagon, gradient_hexagon))\n \n # Pulse hexagon\n self.play(\n hexagon.animate.scale(1.2),\n rate_func=there_and_back,\n run_time=2\n )\n \n # Fade out hexagon, keep formula\n self.play(FadeOut(hexagon))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 deriva\n- Act 2: 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_0420(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_derivativeexplanation()\n self.clear_stage()\n self.act_2_pointwithtrace()\n\n def act_1_derivativeexplanation(self):\n axes = Axes(\n x_range=[-2, 2, 1], y_range=[0, 4, 1], \n axis_config={\"include_tip\": True}\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n func = axes.plot(lambda x: x**2, color=BLUE)\n func_label = axes.get_graph_label(func, x_val=1.5, direction=UR)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(func), Write(func_label))\n self.wait(3) # Pause for processing\n\n # 2. Derivative Graph\n deriv_func = axes.plot(lambda x: 2*x, color=RED)\n deriv_label = axes.get_graph_label(deriv_func, x_val=1.5, direction=UR)\n \n self.play(Create(deriv_func), Write(deriv_label))\n self.wait(3) # Pause for processing\n\n # 3. Tangent Line at x = 1\n # Point (1, 1), Slope = 2\n dot = Dot(axes.c2p(1, 1), color=YELLOW)\n tangent = TangentLine(func, 1, color=GREEN, length=4)\n \n self.play(FadeIn(dot), Create(tangent))\n self.wait(4) # Pause for processing\n\n # 4. Explanation Text\n explanation = Text(\n \"The tangent line represents the derivative of the function at this point.\", \n font_size=24, \n color=WHITE\n ).shift(UP * 2 + RIGHT * 1)\n \n # Add a small arrow pointing to the tangent line\n arrow = Arrow(start=explanation.get_bottom(), end=axes.c2p(1, 1), color=WHITE)\n\n self.play(Write(explanation), GrowArrow(arrow))\n self.wait(5)\n\n def act_2_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_0420(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_derivativeexplanation()\n self.clear_stage()\n self.act_2_pointwithtrace()\n\n def act_1_derivativeexplanation(self):\n axes = Axes(\n x_range=[-2, 2, 1], y_range=[0, 4, 1], \n axis_config={\"include_tip\": True}\n )\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"f(x)\")\n \n func = axes.plot(lambda x: x**2, color=BBLUE)\n func_label = axes.get_graph_label(func, x_val=1.5, direction=UR)\n \n self.play(Create(axes), Write(labels))\n self.play(Create(func), Write(func_label))\n self.wait(3) # Pause for processing\n\n # 2. Derivative Graph\n deriv_func = axes.plot(lambda x: 2*x, color=RED)\n deriv_label = axes.get_graph_label(deriv_func, x_val=1.5, direction=UR)\n \n self.play(Create(deriv_func), Write(deriv_label))\n self.wait(3) # Pause for processing\n\n # 3. Tangent Line at x = 1\n # Point (1, 1), Slope = 2\n dot = Dot(axes.c2p(1, 1), color=YELLOW)\n tangent = TangentLine(func, 1, color=GREEN, length=4)\n \n self.play(FadeIn(dot), Create(tangent))\n self.wait(4) # Pause for processing\n\n # 4. Explanation Text\n explanation = Text(\n \"The tangent line represents the derivative of the function at this point.\", \n font_size=24, \n color=WHITE\n ).shift(UP * 2 + RIGHT * 1)\n \n # Add a small arrow pointing to the tangent line\n arrow = Arrow(start=explanation.get_bottom(), end=axes.c2p(1, 1), color=WHITE)\n\n self.play(Write(explanation), GrowArrow(arrow))\n self.wait(5)\n\n def act_2_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 begins by writing Euler's formula \"e^(ix) = cos(x) + i*sin(x)\" on the screen. Following this, can you display a sentence above explaining that Euler's formula relates complex exponentials to trigonometric functions? Then visually transform the formula to show just the real part \"cos(x) = Re{e^(ix)}\" and after a short pause, to its imaginary part \"sin(x) = Im{e^(ix)}\". Next, can the animation morph Euler's formula into its polar form representation \"e^(iθ) = cos(θ) + i*sin(θ)\"? Afterwards, I want to see a point on a circle that represents the polar form of complex numbers, along with a dashed line from the center to the point, and a small arc indicating the angle θ. Could this be accompanied by a label for θ? Finally, clear the animation and conclude by showing Euler's formula again on the screen. I would like pauses between the steps to give viewers enough time to understand each part.", "chosen": "```python\nfrom manim import *\n\nclass EulersFormulaAnimation(Scene):\n def construct(self):\n # Step 1: Write the initial formula\n formula = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\")\n self.play(Write(formula))\n self.wait(2)\n\n # Step 2: Display explanatory sentence above the formula\n explanation = Tex(\"Euler's formula relates complex exponentials to trigonometric functions\")\n explanation.next_to(formula, UP, buff=0.5)\n self.play(Write(explanation))\n self.wait(3)\n\n # Step 3: Transform the formula to isolate the real part\n real_part = MathTex(\"\\\\cos(x)\", \"=\", \"\\\\text{Re}\\\\{e^{ix}\\\\}\")\n self.play(ReplacementTransform(formula, real_part))\n self.wait(2)\n\n # Step 4: Pause briefly, then transform to the imaginary part\n imag_part = MathTex(\"\\\\sin(x)\", \"=\", \"\\\\text{Im}\\\\{e^{ix}\\\\}\")\n self.play(ReplacementTransform(real_part, imag_part))\n self.wait(2)\n\n # Step 5: Morph the equation into its polar form using theta\n polar_form = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i\", \"\\\\sin(\\\\theta)\")\n self.play(ReplacementTransform(imag_part, polar_form))\n self.wait(2)\n\n # Step 6: Visualize the complex plane\n # Move equation and explanation to make room for the circle\n self.play(\n polar_form.animate.to_edge(UP, buff=1.0),\n explanation.animate.shift(UP * 0.5)\n )\n \n # Draw a unit circle\n circle = Circle(radius=1.5, color=BLUE)\n \n # Define angle theta for visualization (e.g., 60 degrees)\n theta_val = PI / 3\n \n # Plot a point on the circle representing the complex number\n point = Dot(circle.point_at_angle(theta_val), color=YELLOW)\n \n # Draw a dashed line from the center to the point\n line = DashedLine(ORIGIN, point.get_center(), color=WHITE)\n \n # Draw a small arc indicating the angle theta\n arc = Arc(radius=0.5, start_angle=0, angle=theta_val, color=GREEN)\n \n # Add a label for theta\n theta_label = MathTex(\"\\\\theta\").scale(0.7)\n theta_label.next_to(arc, RIGHT, buff=0.1).shift(UP * 0.1)\n \n # Group visual elements\n plane_group = VGroup(circle, point, line, arc, theta_label)\n \n # Animate the creation of the complex plane visualization\n self.play(Create(circle), GrowFromCenter(point), Create(line), Create(arc), Write(theta_label))\n self.wait(3)\n\n # Step 7: Clear the screen (fade out all objects)\n all_objects = VGroup(polar_form, explanation, plane_group)\n self.play(FadeOut(all_objects))\n self.wait(1)\n\n # Step 8: Conclude by showing Euler's formula again\n final_formula = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\")\n self.play(Write(final_formula))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EulersFormulaAnimation(Scene):\n def construct(self):\n # Step 1: Write the initial formula\n formula = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\")\n self.play(Write(formula))\n self.wait(2)\n\n # Step 2: Display explanatory sentence above the formula\n explanation = Tex(\"Euler's formula relates complex exponentials to trigonometric functions\")\n explanation.next_to(formula, UP, buff=0.5)\n self.play(Write(explanation))\n self.wait(3)\n\n # Step 3: Transform the formula to isolate the real part\n real_part = MathTex(\"\\\\cos(x)\", \"=\", \"\\\\text{Re}\\\\{e^{ix}\\\\}\")\n self.play(ReplacementTransform(formula, real_part))\n self.wait(2)\n\n # Step 4: Pause briefly, then transform to the imaginary part\n imag_part = MathTex(\"\\\\sin(x)\", \"=\", \"\\\\text{Im}\\\\{e^{ix}\\\\}\")\n self.play(ReplacementTransform(real_part, imag_part))\n self.wait(2)\n\n # Step 5: Morph the equation into its polar form using theta\n polar_form = MathTex(\"e^{i\\\\theta}\", \"=\", \"\\\\cos(\\\\theta)\", \"+\", \"i\", \"\\\\sin(\\\\theta)\")\n self.play(ReplacementTransform(imag_part, polar_form))\n self.wait(2)\n\n # Step 6: Visualize the complex plane\n # Move equation and explanation to make room for the circle\n self.play(\n polar_form.animate.to_edge(UP, buff=1.0),\n explanation.animate.shift(UP * 0.5)\n )\n \n # Draw a unit circle\n circle = Circle(radius=1.5, color=BBLUE)\n \n # Define angle theta for visualization (e.g., 60 degrees)\n theta_val = PI / 3\n \n # Plot a point on the circle representing the complex number\n point = Dot(circle.point_at_angle(theta_val), color=YELLOW)\n \n # Draw a dashed line from the center to the point\n line = DashedLine(ORIGIN, point.get_center(), color=WHITE)\n \n # Draw a small arc indicating the angle theta\n arc = Arc(radius=0.5, start_angle=0, angle=theta_val, color=GREEN)\n \n # Add a label for theta\n theta_label = MathTex(\"\\\\theta\").scale(0.7)\n theta_label.next_to(arc, RIGHT, buff=0.1).shift(UP * 0.1)\n \n # Group visual elements\n plane_group = VGroup(circle, point, line, arc, theta_label)\n \n # Animate the creation of the complex plane visualization\n self.play(Create(circle), GrowFromCenter(point), Create(line), Create(arc), Write(theta_label))\n self.wait(3)\n\n # Step 7: Clear the screen (fade out all objects)\n all_objects = VGroup(polar_form, explanation, plane_group)\n self.play(FadeOut(all_objects))\n self.wait(1)\n\n # Step 8: Conclude by showing Euler's formula again\n final_formula = MathTex(\"e^{ix}\", \"=\", \"\\\\cos(x)\", \"+\", \"i\", \"\\\\sin(x)\")\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 concept of finding the area under a curve, specifically the graph of f(x) = x^2, between the points x=0 and x=2? The animation should begin by displaying the coordinate axes with labeled x and y-axes, followed by plotting the curve f(x) = x^2. After the graph is shown, illustrate the actual area under the curve from 0 to 2 by shading it. Then, bring in the integral notation for the area we're considering at the top of the screen. Finally, step through the calculation of this definite integral, showing how to find the numerical value of the area under the curve, and then fade all elements out at the end of the animation.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize the coordinate system\n # Define axes with appropriate ranges to clearly visualize x=0 to x=2\n axes = Axes(\n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True}\n ).add_coordinates()\n \n # Add labels 'x' and 'y' to the axes\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Display Axes\n self.play(Create(axes), Write(labels))\n self.wait(1)\n\n # 3. Plot the curve f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\", x_val=2.3, direction=UR)\n \n self.play(Create(curve), Write(curve_label), run_time=2)\n self.wait(1)\n\n # 4. Shading: Animate the shading of the region under the curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines for visual clarity\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY)\n \n self.play(FadeIn(line_start), FadeIn(line_end))\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n\n # 5. Notation: Display the definite integral at the top of the screen\n integral_text = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\", color=YELLOW).to_edge(UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # 6. Calculation: Step through the mathematical derivation\n # Step 1: Antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\").next_to(integral_text, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step1))\n self.wait(2)\n \n # Step 2: Evaluation at bounds\n step2 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\").next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(2)\n \n # Step 3: Final Result\n step3 = MathTex(r\"= \\frac{8}{3} - 0 = \\frac{8}{3} \\approx 2.67\").next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(3)\n\n # 7. Conclusion: Fade out all visual elements\n all_elements = VGroup(\n axes, labels, curve, curve_label, area, \n line_start, line_end, integral_text, step1, step2, step3\n )\n self.play(FadeOut(all_elements), run_time=2)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize the coordinate system\n # Define axes with appropriate ranges to clearly visualize x=0 to x=2\n axes = Axes(label_font_size=24, \n x_range=[-0.5, 3, 1],\n y_range=[-0.5, 5, 1],\n x_length=7,\n y_length=5,\n axis_config={\"include_tip\": True, \"include_numbers\": True}\n ).add_coordinates()\n \n # Add labels 'x' and 'y' to the axes\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n\n # 2. Display Axes\n self.play(Create(axes), Write(labels))\n self.wait(1)\n\n # 3. Plot the curve f(x) = x^2\n curve = axes.plot(lambda x: x**2, color=BLUE, x_range=[0, 2.5])\n curve_label = axes.get_graph_label(curve, label=\"f(x) = x^2\", x_val=2.3, direction=UR)\n \n self.play(Create(curve), Write(curve_label), run_time=2)\n self.wait(1)\n\n # 4. Shading: Animate the shading of the region under the curve\n area = axes.get_area(curve, x_range=[0, 2], color=GREEN, opacity=0.5)\n \n # Add vertical boundary lines for visual clarity\n line_start = axes.get_vertical_line(axes.c2p(0, 0), color=GRAY)\n line_end = axes.get_vertical_line(axes.c2p(2, 4), color=GRAY)\n \n self.play(FadeIn(line_start), FadeIn(line_end))\n self.play(FadeIn(area), run_time=2)\n self.wait(1)\n\n # 5. Notation: Display the definite integral at the top of the screen\n integral_text = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\", color=YELLOW).to_edge(UP)\n self.play(Write(integral_text))\n self.wait(2)\n\n # 6. Calculation: Step through the mathematical derivation\n # Step 1: Antiderivative\n step1 = MathTex(r\"= \\left[ \\frac{1}{3}x^3 \\right]_{0}^{2}\").next_to(integral_text, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step1))\n self.wait(2)\n \n # Step 2: Evaluation at bounds\n step2 = MathTex(r\"= \\frac{1}{3}(2)^3 - \\frac{1}{3}(0)^3\").next_to(step1, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step2))\n self.wait(2)\n \n # Step 3: Final Result\n step3 = MathTex(r\"= \\frac{8}{3} - 0 = \\frac{8}{3} \\approx 2.67\").next_to(step2, DOWN, buff=0.5, aligned_edge=LEFT)\n self.play(Write(step3))\n self.wait(3)\n\n # 7. Conclusion: Fade out all visual elements\n all_elements = VGroup(\n axes, labels, curve, curve_label, area, \n line_start, line_end, integral_text, step1, step2, step3\n )\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 from -3 to 3 on the x-axis and -5 to 5 on the y-axis. The function should be represented by a green curve. \n\nOnce the graph of the function is drawn, a yellow dashed vertical line should appear at x=1, going from the x-axis up to the graph. Close to the graph, there should be a green label with the function's equation, 'x^2'.\n\nAfterwards, I'd like the video to show the purple curve of the derivative of this function. The presentation should allow some time to observe each element as it is created: first the axes with the function, then the label and the vertical line, and finally the derivative. Each step should have a couple of seconds of pause for the viewer to take in the information before moving on to the next element.", "chosen": "```python\nfrom manim import *\n\nclass QuadraticDerivativeScene(Scene):\n def construct(self):\n # 1. Initial Scene: Axes and Function\n # Define blue axes with specified ranges\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[-5, 5, 1],\n axis_config={\"color\": BLUE},\n tips=False\n )\n \n # Plot f(x) = x^2 as a green curve\n func = axes.plot(lambda x: x**2, color=GREEN)\n \n # Animate elements sequentially for clarity\n self.play(Create(axes), run_time=2)\n self.play(Create(func), run_time=2)\n \n # Pause for observation\n self.wait(3)\n \n # 2. Annotation Phase\n # Yellow dashed vertical line from (1, 0) to the curve at (1, 1)\n vertical_line = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, 1), \n color=YELLOW\n )\n \n # Green label near the curve\n label = MathTex(\"x^2\", color=GREEN).next_to(func, UR, buff=0.1)\n \n # Annotate with appropriate pacing\n self.play(Create(vertical_line), run_time=1)\n self.play(Write(label), run_time=1)\n \n # Pause for observation\n self.wait(3)\n \n # 3. Derivative Visualization\n # Draw the derivative f'(x) = 2x as a purple curve\n derivative = axes.plot(lambda x: 2*x, color=PURPLE)\n \n # Animate derivative appearance\n self.play(Create(derivative), run_time=2)\n \n # Final pause to observe relationship\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass QuadraticDerivativeScene(Scene):\n def construct(self):\n # 1. Initial Scene: Axes and Function\n # Define blue axes with specified ranges\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=False\n )\n \n # Plot f(x) = x^2 as a green curve\n func = axes.plot(lambda x: x**2, color=GREEN)\n \n # Animate elements sequentially for clarity\n self.play(Create(axes), run_time=2)\n self.play(Create(func), run_time=2)\n \n # Pause for observation\n self.wait(3)\n \n # 2. Annotation Phase\n # Yellow dashed vertical line from (1, 0) to the curve at (1, 1)\n vertical_line = DashedLine(\n start=axes.c2p(1, 0), \n end=axes.c2p(1, 1), \n color=YELLOW\n )\n \n # Green label near the curve\n label = MathTex(\"x^2\", color=GREEN).next_to(func, UR, buff=0.1)\n \n # Annotate with appropriate pacing\n self.play(Create(vertical_line), run_time=1)\n self.play(Write(label), run_time=1)\n \n # Pause for observation\n self.wait(3)\n \n # 3. Derivative Visualization\n # Draw the derivative f'(x) = 2x as a purple curve\n derivative = axes.plot(lambda x: 2*x, color=PURPLE)\n \n # Animate derivative appearance\n self.play(Create(derivative), run_time=2)\n \n # Final pause to observe relationship\n self.wait(3)\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 concept of a Möbius strip challenge our understanding of 2-dimensional manifolds with boundary?", "chosen": "```python\nfrom manim import *\n\nclass MobiusStripScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Twisting Perceptions: Möbius Strips\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Regular strip\n strip_text = Text(\"A regular strip has two sides\", font_size=30)\n self.play(Write(strip_text))\n self.wait(1)\n self.play(strip_text.animate.to_edge(UP))\n \n regular_strip = Rectangle(height=0.8, width=3, color=BLUE)\n self.play(Create(regular_strip))\n self.wait(1)\n \n # Add side labels to regular strip\n side1 = Text(\"Side 1\", font_size=20, color=BLUE_B).next_to(regular_strip, UP, buff=0.2)\n side2 = Text(\"Side 2\", font_size=20, color=BLUE_D).next_to(regular_strip, DOWN, buff=0.2)\n self.play(Write(side1), Write(side2))\n self.wait(1)\n \n # Twist to create Möbius strip\n self.play(FadeOut(side1), FadeOut(side2))\n twist_text = Text(\"With a half twist...\", font_size=30)\n twist_text.next_to(strip_text, DOWN)\n self.play(Write(twist_text))\n \n # Simple twist animation\n self.play(regular_strip.animate.rotate(PI).set_color(RED))\n self.wait(1)\n \n # Transform to circle as simplified Möbius strip\n mobius_strip = Circle(radius=1.8, color=RED)\n self.play(\n ReplacementTransform(regular_strip, mobius_strip),\n FadeOut(strip_text),\n FadeOut(twist_text)\n )\n \n mobius_text = Text(\"A Möbius strip has only one side\", font_size=30)\n mobius_text.to_edge(UP)\n self.play(Write(mobius_text))\n self.wait(1)\n \n # Demonstrate one continuous side\n paint_text = Text(\"Painting the entire surface...\", font_size=24)\n paint_text.to_edge(DOWN)\n self.play(Write(paint_text))\n \n # Create a dot to represent the brush\n dot = Dot(color=YELLOW).move_to(mobius_strip.point_from_proportion(0))\n self.play(Create(dot))\n \n # Animate the dot moving around the Möbius strip\n self.play(MoveAlongPath(dot, mobius_strip), run_time=2)\n self.wait(1)\n \n # Side-by-side comparison\n self.play(\n FadeOut(paint_text),\n FadeOut(dot),\n mobius_strip.animate.scale(0.6).to_edge(RIGHT),\n FadeOut(mobius_text)\n )\n \n compare_text = Text(\"Regular vs. Möbius\", font_size=30)\n compare_text.to_edge(UP)\n self.play(Write(compare_text))\n \n # Create a regular strip on the left\n reg_strip = Rectangle(height=0.8, width=3, color=BLUE).scale(0.6).to_edge(LEFT)\n self.play(Create(reg_strip))\n \n # Add labels\n reg_label = Text(\"2 sides, 2 edges\", font_size=20).next_to(reg_strip, DOWN)\n mob_label = Text(\"1 side, 1 edge\", font_size=20).next_to(mobius_strip, DOWN)\n \n self.play(Write(reg_label), Write(mob_label))\n self.wait(2)\n \n # Clean up and show equation\n self.play(\n FadeOut(mobius_strip),\n FadeOut(reg_strip),\n FadeOut(reg_label),\n FadeOut(mob_label),\n FadeOut(compare_text)\n )\n \n equation = MathTex(r\"X^2 + Y^2 + Z^2 = 0\")\n eq_text = Text(\"Mathematical representation\", font_size=30)\n eq_text.to_edge(UP)\n \n self.play(Write(eq_text), Write(equation))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(eq_text), FadeOut(equation))\n \n conclusion = Text(\"Möbius strips challenge our understanding\\nof 2D manifolds with boundary\", font_size=30)\n self.play(Write(conclusion))\n self.wait(2)\n \n final_title = Text(\"Twisting Perceptions\", font_size=36)\n self.play(ReplacementTransform(conclusion, final_title))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass MobiusStripScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Twisting Perceptions: Möbius Strips\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Regular strip\n strip_text = Text(\"A regular strip has two sides\", font_size=30)\n self.play(Write(strip_text))\n self.wait(1)\n self.play(strip_text.animate.to_edge(UP))\n \n regular_strip = Rectangle(height=0.8, width=3, color=BBLUE)\n self.play(Create(regular_strip))\n self.wait(1)\n \n # Add side labels to regular strip\n side1 = Text(\"Side 1\", font_size=20, color=BLUE_B).next_to(regular_strip, UP, buff=0.2)\n side2 = Text(\"Side 2\", font_size=20, color=BLUE_D).next_to(regular_strip, DOWN, buff=0.2)\n self.play(Write(side1), Write(side2))\n self.wait(1)\n \n # Twist to create Möbius strip\n self.play(FadeOut(side1), FadeOut(side2))\n twist_text = Text(\"With a half twist...\", font_size=30)\n twist_text.next_to(strip_text, DOWN)\n self.play(Write(twist_text))\n \n # Simple twist animation\n self.play(regular_strip.animate.rotate(PI).set_color(RED))\n self.wait(1)\n \n # Transform to circle as simplified Möbius strip\n mobius_strip = Circle(radius=1.8, color=RED)\n self.play(\n ReplacementTransform(regular_strip, mobius_strip),\n FadeOut(strip_text),\n FadeOut(twist_text)\n )\n \n mobius_text = Text(\"A Möbius strip has only one side\", font_size=30)\n mobius_text.to_edge(UP)\n self.play(Write(mobius_text))\n self.wait(1)\n \n # Demonstrate one continuous side\n paint_text = Text(\"Painting the entire surface...\", font_size=24)\n paint_text.to_edge(DOWN)\n self.play(Write(paint_text))\n \n # Create a dot to represent the brush\n dot = Dot(color=YELLOW).move_to(mobius_strip.point_from_proportion(0))\n self.play(Create(dot))\n \n # Animate the dot moving around the Möbius strip\n self.play(MoveAlongPath(dot, mobius_strip), run_time=2)\n self.wait(1)\n \n # Side-by-side comparison\n self.play(\n FadeOut(paint_text),\n FadeOut(dot),\n mobius_strip.animate.scale(0.6).to_edge(RIGHT),\n FadeOut(mobius_text)\n )\n \n compare_text = Text(\"Regular vs. Möbius\", font_size=30)\n compare_text.to_edge(UP)\n self.play(Write(compare_text))\n \n # Create a regular strip on the left\n reg_strip = Rectangle(height=0.8, width=3, color=BLUE).scale(0.6).to_edge(LEFT)\n self.play(Create(reg_strip))\n \n # Add labels\n reg_label = Text(\"2 sides, 2 edges\", font_size=20).next_to(reg_strip, DOWN)\n mob_label = Text(\"1 side, 1 edge\", font_size=20).next_to(mobius_strip, DOWN)\n \n self.play(Write(reg_label), Write(mob_label))\n self.wait(2)\n \n # Clean up and show equation\n self.play(\n FadeOut(mobius_strip),\n FadeOut(reg_strip),\n FadeOut(reg_label),\n FadeOut(mob_label),\n FadeOut(compare_text)\n )\n \n equation = MathTex(r\"X^2 + Y^2 + Z^2 = 0\")\n eq_text = Text(\"Mathematical representation\", font_size=30)\n eq_text.to_edge(UP)\n \n self.play(Write(eq_text), Write(equation))\n self.wait(1)\n \n # Conclusion\n self.play(FadeOut(eq_text), FadeOut(equation))\n \n conclusion = Text(\"Möbius strips challenge our understanding\\nof 2D manifolds with boundary\", font_size=30)\n self.play(Write(conclusion))\n self.wait(2)\n \n final_title = Text(\"Twisting Perceptions\", font_size=36)\n self.play(ReplacementTransform(conclusion, final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 we graphically demonstrate the impact of 'cheap talk' messages on players' beliefs and strategies within a signaling game?", "chosen": "```python\nfrom manim import *\n\nclass SignalingGamesScene(Scene):\n def construct(self):\n # Title sequence\n title = Text(\"Decoding the Dance of Deception\", font_size=32)\n subtitle = Text(\"Game Theory and Cheap Talk\", font_size=24).next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(VGroup(title, subtitle)))\n \n # Element 1: Showing the Sender and Receiver with a signal arrow\n sender = Circle(radius=0.5, color=BLUE).shift(LEFT*3) # Sender represented as blue circle\n receiver = Circle(radius=0.5, color=GOLD).shift(RIGHT*3) # Receiver as gold circle\n \n sender_label = Text(\"Sender\", font_size=20).next_to(sender, DOWN)\n receiver_label = Text(\"Receiver\", font_size=20).next_to(receiver, DOWN)\n \n arrow = Arrow(sender.get_right(), receiver.get_left(), color=WHITE) # Signal arrow\n message = Text(\"Cheap Talk\", font_size=16).next_to(arrow, UP)\n \n self.play(Create(sender), Create(receiver))\n self.play(Write(sender_label), Write(receiver_label))\n self.play(Create(arrow), Write(message))\n self.wait(1)\n \n # Element 2: Information Asymmetry - showing what each player knows\n info_text = Text(\"Information Asymmetry\", font_size=24).to_edge(UP)\n sender_info = Text(\"Knows True State\", font_size=16).next_to(sender, UP)\n receiver_info = Text(\"Initial Belief: 0.3\", font_size=16).next_to(receiver, UP)\n \n self.play(Write(info_text))\n self.play(Write(sender_info), Write(receiver_info))\n self.wait(1)\n \n # Element 3: Bayesian Belief Update - showing how beliefs change\n update_text = Text(\"Bayesian Belief Update\", font_size=24).to_edge(UP)\n updated_belief = Text(\"Updated Belief: 0.7\", font_size=16).next_to(receiver, UP)\n \n # Bayes' rule equation\n bayes_eq = MathTex(r\"P(A|B) = \\frac{P(B|A)P(A)}{P(B)}\", font_size=32).shift(DOWN*2)\n \n self.play(ReplacementTransform(info_text, update_text))\n self.play(Write(bayes_eq))\n self.play(ReplacementTransform(receiver_info, updated_belief))\n self.wait(2)\n \n # Element 4: Strategic Decision Making based on updated beliefs\n decision_text = Text(\"Strategic Decision Making\", font_size=24).to_edge(UP)\n \n # Belief update equation\n update_eq = MathTex(r\"P_{new} = P_{prior} + P(signal) \\cdot (1 - P_{prior})\", font_size=28).shift(DOWN*2)\n \n self.play(ReplacementTransform(update_text, decision_text))\n self.play(ReplacementTransform(bayes_eq, update_eq))\n self.wait(2)\n \n # Conclusion: summarizing the impact of cheap talk on strategies\n conclusion = Text(\"Cheap talk influences beliefs and strategies\", font_size=28)\n \n # Group all elements to fade out together\n elements_to_fade = VGroup(\n sender, receiver, sender_label, receiver_label, arrow, message,\n sender_info, updated_belief, update_eq, decision_text\n )\n \n self.play(FadeOut(elements_to_fade))\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(conclusion))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass SignalingGamesScene(Scene):\n def construct(self):\n # Title sequence\n title = Text(\"Decoding the Dance of Deception\", font_size=32)\n subtitle = Text(\"Game Theory and Cheap Talk\", font_size=24).next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(Write(subtitle))\n self.wait(1)\n self.play(FadeOut(VGroup(title, subtitle)))\n \n # Element 1: Showing the Sender and Receiver with a signal arrow\n sender = Circle(radius=0.5, color=BLUE).shift(LEFT*3) # Sender represented as blue circle\n receiver = Circle(radius=0.5, color=GOLD).shift(RIGHT*3) # Receiver as gold circle\n \n sender_label = Text(\"Sender\", font_size=20).next_to(sender, DOWN)\n receiver_label = Text(\"Receiver\", font_size=20).next_to(receiver, DOWN)\n \n arrow = Arrow(sender.get_right(), receiver.get_left(), color=WHITE) # Signal arrow\n message = Text(\"Cheap Talk\", font_size=16).next_to(arrow, UP)\n \n self.play(Create(sender), Create(receiver))\n self.play(Write(sender_label), Write(receiver_label))\n self.play(Create(arrow), Write(message))\n self.wait(1)\n \n # Element 2: Information Asymmetry - showing what each player knows\n info_text = Text(\"Information Asymmetry\", font_size=24).to_edge(UP)\n sender_info = Text(\"Knows True State\", font_size=16).next_to(sender, UP)\n receiver_info = Text(\"Initial Belief: 0.3\", font_size=16).next_to(receiver, UP)\n \n self.play(Write(info_text))\n self.play(Write(sender_info), Write(receiver_info))\n self.wait(1)\n \n # Element 3: Bayesian Belief Update - showing how beliefs change\n update_text = Text(\"Bayesian Belief Update\", font_size=24).to_edge(UP)\n updated_belief = Text(\"Updated Belief: 0.7\", font_size=16).next_to(receiver, UP)\n \n # Bayes' rule equation\n bayes_eq = MathText(r\"P(A|B) = \\frac{P(B|A)P(A)}{P(B)}\", font_size=32).shift(DOWN*2)\n \n self.play(ReplacementTransform(info_text, update_text))\n self.play(Write(bayes_eq))\n self.play(ReplacementTransform(receiver_info, updated_belief))\n self.wait(2)\n \n # Element 4: Strategic Decision Making based on updated beliefs\n decision_text = Text(\"Strategic Decision Making\", font_size=24).to_edge(UP)\n \n # Belief update equation\n update_eq = MathTex(r\"P_{new} = P_{prior} + P(signal) \\cdot (1 - P_{prior})\", font_size=28).shift(DOWN*2)\n \n self.play(ReplacementTransform(update_text, decision_text))\n self.play(ReplacementTransform(bayes_eq, update_eq))\n self.wait(2)\n \n # Conclusion: summarizing the impact of cheap talk on strategies\n conclusion = Text(\"Cheap talk influences beliefs and strategies\", font_size=28)\n \n # Group all elements to fade out together\n elements_to_fade = VGroup(\n sender, receiver, sender_label, receiver_label, arrow, message,\n sender_info, updated_belief, update_eq, decision_text\n )\n \n self.play(FadeOut(elements_to_fade))\n self.play(Write(conclusion))\n self.wait(2)\n \n # Final fade out\n self.play(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 to calculate the area under the curve y=x^2 from x=1 to x=3. Can we start by presenting the integral problem on the screen, followed by a step-by-step explanation that includes setting up the integral, performing the integration, and explaining the process of evaluating the integral at the upper and lower bounds? Finally, can we show the final solution, clear the scene, and then conclude by highlighting the final solution again?", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Display the integral problem statement\n # ------------------------------------------------------------------\n title = Text(\"Area Under the Curve\", font_size=40)\n title.to_edge(UP)\n \n problem_context = MathTex(\n r\"\\text{Calculate the area under } y = x^2 \\text{ from } x=1 \\text{ to } x=3\", \n font_size=36\n )\n problem_context.next_to(title, DOWN, buff=0.5)\n \n integral_problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=60)\n integral_problem.next_to(problem_context, DOWN, buff=1)\n \n self.play(Write(title), Write(problem_context))\n self.play(Write(integral_problem))\n self.wait(1.5)\n \n # ------------------------------------------------------------------\n # 2. Step-by-Step Explanation\n # ------------------------------------------------------------------\n \n # Step 2a: Find the antiderivative\n step1_label = Text(\"Step 1: Find the Antiderivative\", font_size=30, color=BLUE)\n step1_label.next_to(integral_problem, DOWN, buff=0.8)\n \n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", font_size=60)\n antiderivative.next_to(step1_label, DOWN, buff=0.5)\n antiderivative.align_to(integral_problem, LEFT)\n \n self.play(Write(step1_label))\n self.play(Write(antiderivative))\n self.wait(1.5)\n \n # Step 2b: Evaluate at upper and lower bounds\n step2_label = Text(\"Step 2: Evaluate at Upper and Lower Bounds\", font_size=30, color=GREEN)\n step2_label.next_to(antiderivative, DOWN, buff=0.8)\n \n evaluation = MathTex(\n r\"= \\left( \\frac{3^3}{3} \\right) - \\left( \\frac{1^3}{3} \\right)\", \n font_size=60\n )\n evaluation.next_to(step2_label, DOWN, buff=0.5)\n evaluation.align_to(integral_problem, LEFT)\n \n self.play(Write(step2_label))\n self.play(Write(evaluation))\n self.wait(1.5)\n \n # Step 2c: Simplify the arithmetic\n step3_label = Text(\"Step 3: Simplify\", font_size=30, color=YELLOW)\n step3_label.next_to(evaluation, DOWN, buff=0.8)\n \n arithmetic = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=60)\n arithmetic.next_to(step3_label, DOWN, buff=0.5)\n arithmetic.align_to(integral_problem, LEFT)\n \n self.play(Write(step3_label))\n self.play(Write(arithmetic))\n self.wait(1.5)\n \n # ------------------------------------------------------------------\n # 3. Solution Presentation: Reveal the final calculated solution\n # ------------------------------------------------------------------\n final_solution_step = MathTex(r\"= \\frac{26}{3}\", font_size=60, color=YELLOW)\n final_solution_step.next_to(arithmetic, DOWN, buff=0.5)\n final_solution_step.align_to(integral_problem, LEFT)\n \n solution_box = SurroundingRectangle(final_solution_step, color=YELLOW, buff=0.2)\n \n self.play(Write(final_solution_step))\n self.play(Create(solution_box))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 4. Transition: Clear the scene completely\n # ------------------------------------------------------------------\n self.play(\n FadeOut(title), FadeOut(problem_context), FadeOut(integral_problem),\n FadeOut(step1_label), FadeOut(antiderivative),\n FadeOut(step2_label), FadeOut(evaluation),\n FadeOut(step3_label), FadeOut(arithmetic),\n FadeOut(final_solution_step), FadeOut(solution_box)\n )\n self.clear()\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 5. Conclusion: Re-introduce and highlight the final solution\n # ------------------------------------------------------------------\n conclusion_title = Text(\"Final Result\", font_size=50, color=GREEN)\n conclusion_title.to_edge(UP)\n \n final_highlight = MathTex(r\"\\int_{1}^{3} x^2 \\, dx = \\frac{26}{3}\", font_size=80, color=GOLD)\n final_highlight.move_to(ORIGIN)\n \n highlight_box = SurroundingRectangle(final_highlight, color=GOLD, buff=0.3, stroke_width=3)\n \n self.play(Write(conclusion_title))\n self.play(Write(final_highlight))\n self.play(Create(highlight_box))\n self.play(Indicate(final_highlight))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Introduction: Display the integral problem statement\n # ------------------------------------------------------------------\n title = Text(\"Area Under the Curve\", font_size=40)\n title.to_edge(UP)\n \n problem_context = MathText(\n r\"\\text{Calculate the area under } y = x^2 \\text{ from } x=1 \\text{ to } x=3\", \n font_size=36\n )\n problem_context.next_to(title, DOWN, buff=0.5)\n \n integral_problem = MathTex(r\"\\int_{1}^{3} x^2 \\, dx\", font_size=60)\n integral_problem.next_to(problem_context, DOWN, buff=1)\n \n self.play(Write(title), Write(problem_context))\n self.play(Write(integral_problem))\n self.wait(1.5)\n \n # ------------------------------------------------------------------\n # 2. Step-by-Step Explanation\n # ------------------------------------------------------------------\n \n # Step 2a: Find the antiderivative\n step1_label = Text(\"Step 1: Find the Antiderivative\", font_size=30, color=BLUE)\n step1_label.next_to(integral_problem, DOWN, buff=0.8)\n \n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{1}^{3}\", font_size=60)\n antiderivative.next_to(step1_label, DOWN, buff=0.5)\n antiderivative.align_to(integral_problem, LEFT)\n \n self.play(Write(step1_label))\n self.play(Write(antiderivative))\n self.wait(1.5)\n \n # Step 2b: Evaluate at upper and lower bounds\n step2_label = Text(\"Step 2: Evaluate at Upper and Lower Bounds\", font_size=30, color=GREEN)\n step2_label.next_to(antiderivative, DOWN, buff=0.8)\n \n evaluation = MathTex(\n r\"= \\left( \\frac{3^3}{3} \\right) - \\left( \\frac{1^3}{3} \\right)\", \n font_size=60\n )\n evaluation.next_to(step2_label, DOWN, buff=0.5)\n evaluation.align_to(integral_problem, LEFT)\n \n self.play(Write(step2_label))\n self.play(Write(evaluation))\n self.wait(1.5)\n \n # Step 2c: Simplify the arithmetic\n step3_label = Text(\"Step 3: Simplify\", font_size=30, color=YELLOW)\n step3_label.next_to(evaluation, DOWN, buff=0.8)\n \n arithmetic = MathTex(r\"= \\frac{27}{3} - \\frac{1}{3}\", font_size=60)\n arithmetic.next_to(step3_label, DOWN, buff=0.5)\n arithmetic.align_to(integral_problem, LEFT)\n \n self.play(Write(step3_label))\n self.play(Write(arithmetic))\n self.wait(1.5)\n \n # ------------------------------------------------------------------\n # 3. Solution Presentation: Reveal the final calculated solution\n # ------------------------------------------------------------------\n final_solution_step = MathTex(r\"= \\frac{26}{3}\", font_size=60, color=YELLOW)\n final_solution_step.next_to(arithmetic, DOWN, buff=0.5)\n final_solution_step.align_to(integral_problem, LEFT)\n \n solution_box = SurroundingRectangle(final_solution_step, color=YELLOW, buff=0.2)\n \n self.play(Write(final_solution_step))\n self.play(Create(solution_box))\n self.wait(2)\n \n # ------------------------------------------------------------------\n # 4. Transition: Clear the scene completely\n # ------------------------------------------------------------------\n self.play(\n FadeOut(title), FadeOut(problem_context), FadeOut(integral_problem),\n FadeOut(step1_label), FadeOut(antiderivative),\n FadeOut(step2_label), FadeOut(evaluation),\n FadeOut(step3_label), FadeOut(arithmetic),\n FadeOut(final_solution_step), FadeOut(solution_box)\n )\n self.clear()\n self.wait(1)\n \n # ------------------------------------------------------------------\n # 5. Conclusion: Re-introduce and highlight the final solution\n # ------------------------------------------------------------------\n conclusion_title = Text(\"Final Result\", font_size=50, color=GREEN)\n conclusion_title.to_edge(UP)\n \n final_highlight = MathTex(r\"\\int_{1}^{3} x^2 \\, dx = \\frac{26}{3}\", font_size=80, color=GOLD)\n final_highlight.move_to(ORIGIN)\n \n highlight_box = SurroundingRectangle(final_highlight, color=GOLD, buff=0.3, stroke_width=3)\n \n self.play(Write(conclusion_title))\n self.play(Write(final_highlight))\n self.play(Create(highlight_box))\n self.play(Indicate(final_highlight))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 creating a circle and a triangle, which are then grouped together and rotated by -45 degrees as in the original script. To make the animation more engaging, the circle and triangle now appear sequentially—first the circle grows from a point (using `Create`), then the triangle is drawn vertex by vertex (using `DrawBorderThenFill`). After the rotation, a new feature is introduced: the shapes transform into a square and a pentagon, respectively, using smooth morphing animations (`Transform`). Simultaneously, a mathematical formula appears below the shapes, displaying the rotation angle in radians (π/4) alongside the degree value (-45°), with the text fading in gracefully. Finally, the entire group pulses with a color change (from blue to green) to emphasize the transformation, and a caption reading \"Rotation and Transformation\" slides in from the bottom of the screen, completing the scene with a polished touch. This version retains the original rotation while adding visual storytelling, mathematical context, and dynamic transformations.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedRotationAndTransformation(Scene):\n def construct(self):\n # Create circle and triangle\n circle = Circle(radius=1, color=BLUE)\n triangle = Triangle(color=RED).scale(0.5)\n \n # Animate the circle and triangle appearing\n self.play(Create(circle))\n self.play(DrawBorderThenFill(triangle))\n self.wait(0.5)\n \n # Group and rotate\n group = VGroup(circle, triangle)\n group.shift(LEFT * 2)\n self.play(Rotate(group, angle=-45 * DEGREES, about_point=group.get_center()))\n self.wait(0.5)\n \n # Transform shapes into square and pentagon\n square = Square(color=GREEN).scale(0.7)\n pentagon = RegularPolygon(5, color=YELLOW).scale(0.5)\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n )\n self.wait(0.5)\n \n # Display rotation formula\n formula = MathTex(\n r\"\\theta = -\\frac{\\pi}{4} \\, \\text{rad} \\, (-45^\\circ)\",\n color=WHITE\n ).next_to(group, DOWN, buff=1)\n \n self.play(FadeIn(formula))\n self.wait(0.5)\n \n # Pulse the group with color change\n self.play(\n group.animate.set_color(ORANGE),\n rate_func=there_and_back,\n run_time=2\n )\n self.wait(0.5)\n \n # Slide in caption\n caption = Text(\"Rotation and Transformation\", color=WHITE).to_edge(DOWN)\n self.play(\n caption.animate.shift(UP * 1.5),\n run_time=1.5\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedRotationAndTransformation(Scene):\n def construct(self):\n # Create circle and triangle\n circle = Circle(radius=1, color=BBLUE)\n triangle = Triangle(color=RED).scale(0.5)\n \n # Animate the circle and triangle appearing\n self.play(Create(circle))\n self.play(DrawBorderThenFill(triangle))\n self.wait(0.5)\n \n # Group and rotate\n group = VGroup(circle, triangle)\n group.shift(LEFT * 2)\n self.play(Rotate(group, angle=-45 * DEGREES, about_point=group.get_center()))\n self.wait(0.5)\n \n # Transform shapes into square and pentagon\n square = Square(color=GREEN).scale(0.7)\n pentagon = RegularPolygon(5, color=YELLOW).scale(0.5)\n \n self.play(\n Transform(circle, square),\n Transform(triangle, pentagon),\n )\n self.wait(0.5)\n \n # Display rotation formula\n formula = MathTex(\n r\"\\theta = -\\frac{\\pi}{4} \\, \\text{rad} \\, (-45^\\circ)\",\n color=WHITE\n ).next_to(group, DOWN, buff=1)\n \n self.play(FadeIn(formula))\n self.wait(0.5)\n \n # Pulse the group with color change\n self.play(\n group.animate.set_color(ORANGE),\n rate_func=there_and_back,\n run_time=2\n )\n self.wait(0.5)\n \n # Slide in caption\n caption = Text(\"Rotation and Transformation\", color=WHITE).to_edge(DOWN)\n self.play(\n caption.animate.shift(UP * 1.5),\n 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 that visually demonstrates electron movement in a metal oxide grid. The grid should be alternating between metal atoms and oxygen atoms. The electron should then follow a complex path across this grid, making several turns while being clearly highlighted. After the electron completes its journey, all elements should fade out to end the animation. Can we show this process in a clear and visually appealing way?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass MetalOxideElectronTransport(Scene):\n def construct(self):\n # Set a dark background for better visibility of the electron\n self.camera.background_color = \"#1a1a1a\"\n\n # --- 1. Grid Construction ---\n rows = 6\n cols = 6\n spacing = 0.8\n \n metal_atoms = VGroup()\n oxygen_atoms = VGroup()\n labels = VGroup()\n grid_positions = {}\n\n # Generate alternating metal and oxygen atoms\n for i in range(rows):\n for j in range(cols):\n # Calculate position centered around the origin\n x = (j - (cols - 1) / 2) * spacing\n y = ((rows - 1) / 2 - i) * spacing\n pos = np.array([x, y, 0])\n grid_positions[(i, j)] = pos\n \n # Alternating pattern based on indices\n if (i + j) % 2 == 0:\n atom = Circle(radius=0.18, color=BLUE_E, fill_opacity=1)\n label = Text(\"M\", font_size=14, color=WHITE)\n metal_atoms.add(atom)\n else:\n atom = Circle(radius=0.18, color=RED_E, fill_opacity=1)\n label = Text(\"O\", font_size=14, color=WHITE)\n oxygen_atoms.add(atom)\n \n atom.move_to(pos)\n label.move_to(pos)\n labels.add(label)\n\n grid_group = VGroup(metal_atoms, oxygen_atoms, labels)\n \n # Animate grid appearance\n self.play(FadeIn(grid_group), run_time=1.5)\n self.wait(0.5)\n\n # --- 2. Path Definition ---\n # Define a complex, multi-turn path weaving through the lattice\n path_indices = [\n (0, 0), (0, 1), (1, 1), (1, 2), (2, 2), \n (2, 1), (3, 1), (3, 2), (4, 2), (4, 3), \n (3, 3), (3, 4), (4, 4), (4, 5), (5, 5)\n ]\n \n # Convert grid indices to world coordinates\n path_points = [grid_positions[idx] for idx in path_indices]\n\n # Create a smooth VMobject path\n path_line = VMobject(color=YELLOW, stroke_opacity=0.3)\n path_line.set_points_smoothly(path_points)\n\n # --- 3. Electron Setup & Highlighting ---\n # Create the electron with a glow effect for clear highlighting\n electron_glow = Dot(radius=0.15, color=YELLOW_A, fill_opacity=0.5)\n electron = Dot(radius=0.08, color=YELLOW, fill_opacity=1)\n electron_group = VGroup(electron_glow, electron)\n electron_group.move_to(path_points[0])\n\n # Show the path faintly before movement\n self.play(Create(path_line), run_time=1)\n self.play(FadeIn(electron_group), run_time=0.5)\n\n # --- 4. Electron Animation ---\n # Animate the electron moving along the complex path\n self.play(\n MoveAlongPath(electron_group, path_line),\n run_time=5,\n rate_func=smooth\n )\n\n # Highlight the final position briefly with a pulse\n self.play(\n electron_glow.animate.scale(1.5).set_opacity(0.8),\n run_time=0.3\n )\n self.play(\n electron_glow.animate.scale(1/1.5).set_opacity(0.5),\n run_time=0.3\n )\n self.wait(0.5)\n\n # --- 5. Conclusion ---\n # Fade out all elements smoothly\n self.play(\n FadeOut(grid_group),\n FadeOut(path_line),\n FadeOut(electron_group),\n run_time=1.5\n )\n \n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass MetalOxideElectronTransport(Scene):\n def construct(self):\n # Set a dark background for better visibility of the electron\n self.camera.background_color = \"#1a1a1a\"\n\n # --- 1. Grid Construction ---\n rows = 6\n cols = 6\n spacing = 0.8\n \n metal_atoms = VGroup()\n oxygen_atoms = VGroup()\n labels = VGroup()\n grid_positions = {}\n\n # Generate alternating metal and oxygen atoms\n for i in range(rows):\n for j in range(cols):\n # Calculate position centered around the origin\n x = (j - (cols - 1) / 2) * spacing\n y = ((rows - 1) / 2 - i) * spacing\n pos = np.array([x, y, 0])\n grid_positions[(i, j)] = pos\n \n # Alternating pattern based on indices\n if (i + j) % 2 == 0:\n atom = Circle(radius=0.18, color=BLUE_E, fill_opacity=1)\n label = Text(\"M\", font_size=14, color=WHITE)\n metal_atoms.add(atom)\n else:\n atom = Circle(radius=0.18, color=RED_E, fill_opacity=1)\n label = Text(\"O\", font_size=14, color=WHITE)\n oxygen_atoms.add(atom)\n \n atom.move_to(pos)\n label.move_to(pos)\n labels.add(label)\n\n grid_group = VGroup(metal_atoms, oxygen_atoms, labels)\n \n # Animate grid appearance\n self.play(FadeIn(grid_group), run_time=1.5)\n self.wait(0.5)\n\n # --- 2. Path Definition ---\n # Define a complex, multi-turn path weaving through the lattice\n path_indices = [\n (0, 0), (0, 1), (1, 1), (1, 2), (2, 2), \n (2, 1), (3, 1), (3, 2), (4, 2), (4, 3), \n (3, 3), (3, 4), (4, 4), (4, 5), (5, 5)\n ]\n \n # Convert grid indices to world coordinates\n path_points = [grid_positions[idx] for idx in path_indices]\n\n # Create a smooth VMobject path\n path_line = VMob(color=YELLOW, stroke_opacity=0.3)\n path_line.set_points_smoothly(path_points)\n\n # --- 3. Electron Setup & Highlighting ---\n # Create the electron with a glow effect for clear highlighting\n electron_glow = Dot(radius=0.15, color=YELLOW_A, fill_opacity=0.5)\n electron = Dot(radius=0.08, color=YELLOW, fill_opacity=1)\n electron_group = VGroup(electron_glow, electron)\n electron_group.move_to(path_points[0])\n\n # Show the path faintly before movement\n self.play(Create(path_line), run_time=1)\n self.play(FadeIn(electron_group), run_time=0.5)\n\n # --- 4. Electron Animation ---\n # Animate the electron moving along the complex path\n self.play(\n MoveAlongPath(electron_group, path_line),\n run_time=5,\n rate_func=smooth\n )\n\n # Highlight the final position briefly with a pulse\n self.play(\n electron_glow.animate.scale(1.5).set_opacity(0.8),\n run_time=0.3\n )\n self.play(\n electron_glow.animate.scale(1/1.5).set_opacity(0.5),\n run_time=0.3\n )\n self.wait(0.5)\n\n # --- 5. Conclusion ---\n # Fade out all elements smoothly\n self.play(\n FadeOut(grid_group),\n FadeOut(path_line),\n FadeOut(electron_group),\n run_time=1.5\n )\n \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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Characteristic' (The Marvel of Euler's Characteristic in Subdividing Polyhedrons): How does the Euler characteristic of a polyhedron change when edges are continuously subdivided?\nVisual style guidance: A blend of grayscale minimalist aesthetic, using smooth animations to convey refinement. Accent colors of blue and gold highlight key mathematical components, while gentle piano music adds a reflective undertone.", "chosen": "```python\nfrom manim import *\n\nclass EulerCharacteristic(Scene):\n def construct(self):\n # Set background color to grayscale\n self.camera.background_color = \"#333333\"\n \n # Introduction\n title = Text(\"The Marvel of Euler's Characteristic\", color=BLUE)\n subtitle = Text(\"in Subdividing Polyhedrons\", color=BLUE, font_size=24)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Element 1: Create a simple 2D representation of a cube\n square = Square(side_length=3, color=BLUE)\n diag1 = Line(square.get_corner(UL), square.get_corner(DR), color=BLUE)\n diag2 = Line(square.get_corner(UR), square.get_corner(DL), color=BLUE)\n \n # Add dots for vertices\n vertices = VGroup(*[Dot(p, color=YELLOW) for p in [\n square.get_corner(UL), square.get_corner(UR),\n square.get_corner(DL), square.get_corner(DR)\n ]])\n \n cube_title = Text(\"A Cube:\", font_size=24, color=BLUE).to_edge(UP)\n \n self.play(Write(cube_title))\n self.play(Create(square))\n self.play(Create(diag1), Create(diag2))\n self.play(Create(vertices))\n self.wait(1)\n \n # Element 2: Show the Euler characteristic equation\n v_label = Text(\"V = 8\", color=YELLOW).to_edge(LEFT)\n e_label = Text(\"E = 12\", color=GREEN).next_to(v_label, DOWN)\n f_label = Text(\"F = 6\", color=RED).next_to(e_label, DOWN)\n \n self.play(Write(v_label), Write(e_label), Write(f_label))\n \n euler_eq = Text(\"V - E + F = 2\", color=BLUE).to_edge(RIGHT)\n euler_calc = Text(\"8 - 12 + 6 = 2\", color=GOLD).next_to(euler_eq, DOWN)\n \n self.play(Write(euler_eq))\n self.play(Write(euler_calc))\n self.wait(1)\n \n # Element 3: Subdivide an edge\n self.play(FadeOut(cube_title))\n \n subdiv_title = Text(\"Subdividing an Edge:\", font_size=24, color=BLUE).to_edge(UP)\n self.play(Write(subdiv_title))\n \n # Add a new vertex on an edge\n new_vertex = Dot(square.get_top(), color=YELLOW)\n self.play(FadeIn(new_vertex))\n self.wait(1)\n \n # Element 4: Update the counts\n subdiv_text = Text(\"Add 1 vertex and 1 edge\", font_size=20).next_to(subdiv_title, DOWN)\n self.play(Write(subdiv_text))\n \n new_v_label = Text(\"V = 9\", color=YELLOW).to_edge(LEFT)\n new_e_label = Text(\"E = 13\", color=GREEN).next_to(new_v_label, DOWN)\n \n self.play(\n Transform(v_label, new_v_label),\n Transform(e_label, new_e_label)\n )\n self.wait(1)\n \n # Element 5: Show the new Euler calculation\n new_euler_calc = Text(\"9 - 13 + 6 = 2\", color=GOLD).next_to(euler_eq, DOWN)\n \n self.play(Transform(euler_calc, new_euler_calc))\n self.wait(1)\n \n # Key Insight - Euler characteristic's invariance\n self.play(\n FadeOut(subdiv_title),\n FadeOut(subdiv_text)\n )\n \n insight = Text(\"The Euler characteristic remains unchanged!\", color=GOLD, font_size=24)\n insight.to_edge(UP)\n \n self.play(Write(insight))\n self.wait(1)\n \n # Element 6: Conclusion\n self.play(\n FadeOut(square),\n FadeOut(diag1),\n FadeOut(diag2),\n FadeOut(vertices),\n FadeOut(v_label),\n FadeOut(e_label),\n FadeOut(f_label),\n FadeOut(new_vertex),\n FadeOut(euler_eq),\n FadeOut(euler_calc),\n FadeOut(insight)\n )\n \n conclusion = Text(\"Complexity may change,\\nbut the Euler characteristic remains constant.\", \n font_size=28, color=BLUE)\n \n self.play(Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass EulerCharacteristic(Scene):\n def construct(self):\n # Set background color to grayscale\n self.camera.background_color = \"#333333\"\n \n # Introduction\n title = Text(\"The Marvel of Euler's Characteristic\", color=BBLUE)\n subtitle = Text(\"in Subdividing Polyhedrons\", color=BLUE, font_size=24)\n subtitle.next_to(title, DOWN)\n \n self.play(Write(title))\n self.play(FadeIn(subtitle))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle))\n \n # Element 1: Create a simple 2D representation of a cube\n square = Square(side_length=3, color=BLUE)\n diag1 = Line(square.get_corner(UL), square.get_corner(DR), color=BLUE)\n diag2 = Line(square.get_corner(UR), square.get_corner(DL), color=BLUE)\n \n # Add dots for vertices\n vertices = VGroup(*[Dot(p, color=YELLOW) for p in [\n square.get_corner(UL), square.get_corner(UR),\n square.get_corner(DL), square.get_corner(DR)\n ]])\n \n cube_title = Text(\"A Cube:\", font_size=24, color=BLUE).to_edge(UP)\n \n self.play(Write(cube_title))\n self.play(Create(square))\n self.play(Create(diag1), Create(diag2))\n self.play(Create(vertices))\n self.wait(1)\n \n # Element 2: Show the Euler characteristic equation\n v_label = Text(\"V = 8\", color=YELLOW).to_edge(LEFT)\n e_label = Text(\"E = 12\", color=GREEN).next_to(v_label, DOWN)\n f_label = Text(\"F = 6\", color=RED).next_to(e_label, DOWN)\n \n self.play(Write(v_label), Write(e_label), Write(f_label))\n \n euler_eq = Text(\"V - E + F = 2\", color=BLUE).to_edge(RIGHT)\n euler_calc = Text(\"8 - 12 + 6 = 2\", color=GOLD).next_to(euler_eq, DOWN)\n \n self.play(Write(euler_eq))\n self.play(Write(euler_calc))\n self.wait(1)\n \n # Element 3: Subdivide an edge\n self.play(FadeOut(cube_title))\n \n subdiv_title = Text(\"Subdividing an Edge:\", font_size=24, color=BLUE).to_edge(UP)\n self.play(Write(subdiv_title))\n \n # Add a new vertex on an edge\n new_vertex = Dot(square.get_top(), color=YELLOW)\n self.play(FadeIn(new_vertex))\n self.wait(1)\n \n # Element 4: Update the counts\n subdiv_text = Text(\"Add 1 vertex and 1 edge\", font_size=20).next_to(subdiv_title, DOWN)\n self.play(Write(subdiv_text))\n \n new_v_label = Text(\"V = 9\", color=YELLOW).to_edge(LEFT)\n new_e_label = Text(\"E = 13\", color=GREEN).next_to(new_v_label, DOWN)\n \n self.play(\n Transform(v_label, new_v_label),\n Transform(e_label, new_e_label)\n )\n self.wait(1)\n \n # Element 5: Show the new Euler calculation\n new_euler_calc = Text(\"9 - 13 + 6 = 2\", color=GOLD).next_to(euler_eq, DOWN)\n \n self.play(Transform(euler_calc, new_euler_calc))\n self.wait(1)\n \n # Key Insight - Euler characteristic's invariance\n self.play(\n FadeOut(subdiv_title),\n FadeOut(subdiv_text)\n )\n \n insight = Text(\"The Euler characteristic remains unchanged!\", color=GOLD, font_size=24)\n insight.to_edge(UP)\n \n self.play(Write(insight))\n self.wait(1)\n \n # Element 6: Conclusion\n self.play(\n FadeOut(square),\n FadeOut(diag1),\n FadeOut(diag2),\n FadeOut(vertices),\n FadeOut(v_label),\n FadeOut(e_label),\n FadeOut(f_label),\n FadeOut(new_vertex),\n FadeOut(euler_eq),\n FadeOut(euler_calc),\n FadeOut(insight)\n )\n \n conclusion = Text(\"Complexity may change,\\nbut the Euler characteristic remains constant.\", \n font_size=28, color=BLUE)\n \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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 with the dots starting semi-transparent, becoming fully opaque, and then fading out as they form the square? I'd like to see the effect of the square first disintegrating and then assembling back from these dots, with about 200 dots being used in the process, and the whole animation running across four seconds.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # Display the graph\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```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # Display the graph\n axes = Axes(label_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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling Singularities: The Argument Principle\")\n title.scale(0.7)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a complex plane (just axes)\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-3, 3],\n ).scale(0.8)\n \n # Add axis labels\n x_label = Text(\"Re(z)\", font_size=24).next_to(axes.x_axis, RIGHT)\n y_label = Text(\"Im(z)\", font_size=24).next_to(axes.y_axis, UP)\n \n self.play(Create(axes))\n self.play(Write(x_label), Write(y_label))\n \n # Create a contour with muted blue color\n contour = Circle(radius=1.5, color=BLUE_C)\n self.play(Create(contour))\n \n # Add singularities with vibrant colors\n zero = Dot(RIGHT * 0.5 + UP * 0.5, color=YELLOW)\n zero_label = Text(\"Zero\", font_size=24).next_to(zero, UR, buff=0.1)\n \n # Add a double zero to demonstrate multiplicity\n double_zero = Dot(RIGHT * 0.8 + DOWN * 0.3, color=YELLOW_A)\n double_zero_label = Text(\"Double Zero\", font_size=20).next_to(double_zero, RIGHT, buff=0.1)\n \n pole = Dot(LEFT * 0.5 + DOWN * 0.5, color=RED)\n pole_label = Text(\"Pole\", font_size=24).next_to(pole, DL, buff=0.1)\n \n self.play(Create(zero), Write(zero_label))\n self.play(Create(double_zero), Write(double_zero_label))\n self.play(Create(pole), Write(pole_label))\n \n # Show positive direction with an arrow\n arrow = Arrow(RIGHT * 1.5, RIGHT * 1.5 + UP * 0.5, buff=0, color=GREEN)\n self.play(Create(arrow))\n \n # Simple form of the Argument Principle\n eq1 = Text(\"N - P = Winding Number\", font_size=32)\n eq1.next_to(title, DOWN, buff=0.5)\n self.play(Write(eq1))\n \n # Show the mathematical form\n eq2 = Text(\"\\Delta arg = ∮(f'(z)/f(z))dz\", font_size=28)\n eq2.next_to(eq1, DOWN, buff=0.3)\n self.play(Write(eq2))\n \n # Explanation\n explanation = Text(\"This reveals both presence and nature of singularities\", font_size=24)\n explanation.next_to(eq2, DOWN, buff=0.5)\n self.play(Write(explanation))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ArgumentPrinciple(Scene):\n def construct(self):\n # Title\n title = Text(\"Unraveling Singularities: The Argument Principle\")\n title.scale(0.7)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a complex plane (just axes)\n axes = Axes(\n x_range=[-3, 3],\n y_range=[-3, 3],\n ).scale(0.8)\n \n # Add axis labels\n x_label = Text(\"Re(z)\", font_size=24).next_to(axes.x_axis, RIGHT)\n y_label = Text(\"Im(z)\", font_size=24).next_to(axes.y_axis, UP)\n \n self.play(Create(axes))\n self.play(Write(x_label), Write(y_label))\n \n # Create a contour with muted blue color\n contour = Circle(radius=1.5, color=BBLUE_C)\n self.play(Create(contour))\n \n # Add singularities with vibrant colors\n zero = Dot(RIGHT * 0.5 + UP * 0.5, color=YELLOW)\n zero_label = Text(\"Zero\", font_size=24).next_to(zero, UR, buff=0.1)\n \n # Add a double zero to demonstrate multiplicity\n double_zero = Dot(RIGHT * 0.8 + DOWN * 0.3, color=YELLOW_A)\n double_zero_label = Text(\"Double Zero\", font_size=20).next_to(double_zero, RIGHT, buff=0.1)\n \n pole = Dot(LEFT * 0.5 + DOWN * 0.5, color=RED)\n pole_label = Text(\"Pole\", font_size=24).next_to(pole, DL, buff=0.1)\n \n self.play(Create(zero), Write(zero_label))\n self.play(Create(double_zero), Write(double_zero_label))\n self.play(Create(pole), Write(pole_label))\n \n # Show positive direction with an arrow\n arrow = Arrow(RIGHT * 1.5, RIGHT * 1.5 + UP * 0.5, buff=0, color=GREEN)\n self.play(Create(arrow))\n \n # Simple form of the Argument Principle\n eq1 = Text(\"N - P = Winding Number\", font_size=32)\n eq1.next_to(title, DOWN, buff=0.5)\n self.play(Write(eq1))\n \n # Show the mathematical form\n eq2 = Text(\"\\Delta arg = ∮(f'(z)/f(z))dz\", font_size=28)\n eq2.next_to(eq1, DOWN, buff=0.3)\n self.play(Write(eq2))\n \n # Explanation\n explanation = Text(\"This reveals both presence and nature of singularities\", font_size=24)\n explanation.next_to(eq2, DOWN, buff=0.5)\n self.play(Write(explanation))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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'd like to create an animation where a text element transitions into another text that says \"animate.match_width\" and moves upwards, followed by a square changing its width to match the width of a larger circle, with bo\n- Act 2: 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\n- Act 3: How can I create an animation that starts with a semi-transparent red triangle, then transitions into a semi-transparent yellow square, followed by a brief highlight of the square before it disappears?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0278(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_matchwidthanimation()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n self.clear_stage()\n self.act_3_shapetransitionscene()\n\n def act_1_matchwidthanimation(self):\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\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\n def act_3_shapetransitionscene(self):\n triangle = Triangle()\n triangle.set_fill(RED, opacity=0.5)\n triangle.set_stroke(RED, width=2)\n\n # 2. Target Object: Semi-transparent yellow square\n square = Square()\n square.set_fill(YELLOW, opacity=0.5)\n square.set_stroke(YELLOW, width=2)\n\n # Show the triangle\n self.play(FadeIn(triangle))\n self.wait(0.5)\n\n # 3. Transformation: Morph the triangle into the square\n # ReplacementTransform interpolates points and colors, replacing the original mobject\n self.play(ReplacementTransform(triangle, square), run_time=1.5)\n self.wait(0.2)\n\n # 4. Highlight Effect: A brief scale pulse and flash\n # Scale up and down quickly to create a \"pop\" effect\n self.play(\n square.animate.scale(1.2), \n run_time=0.15, \n rate_func=there_and_back\n )\n # Add a flash for extra visual emphasis\n self.play(Flash(square, color=YELLOW, line_length=0.3, flash_radius=0.5))\n self.wait(0.5)\n\n # 5. Disappearance: Fade out the square\n self.play(FadeOut(square))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0278(Scene):\n def clear_stage(self):\n if self.mobjects:\n self.play(*[FadeOut(m) for m in self.mobjects], run_time=0.8)\n self.wait(0.4)\n\n def construct(self):\n self.act_1_matchwidthanimation()\n self.clear_stage()\n self.act_2_necessarysufficientsets()\n self.clear_stage()\n self.act_3_shapetransitionscene()\n\n def act_1_matchwidthanimation(self):\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\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\n def act_3_shapetransitionscene(self):\n triangle = Triangle()\n triangle.set_fill(RED, opacity=0.5)\n triangle.set_stroke(RED, width=2)\n\n # 2. Target Object: Semi-transparent yellow square\n square = Square()\n square.set_fill(YELLOW, opacity=0.5)\n square.set_stroke(YELLOW, width=2)\n\n # Show the triangle\n self.play(FadeIn(triangle))\n self.wait(0.5)\n\n # 3. Transformation: Morph the triangle into the square\n # ReplacementTransform interpolates points and colors, replacing the original mobject\n self.play(ReplacementTransform(triangle, square), run_time=1.5)\n self.wait(0.2)\n\n # 4. Highlight Effect: A brief scale pulse and flash\n # Scale up and down quickly to create a \"pop\" effect\n self.play(\n square.animate.scale(1.2), \n run_time=0.15, \n rate_func=there_and_back\n )\n # Add a flash for extra visual emphasis\n self.play(Flash(square, color=YELLOW, line_length=0.3, flash_radius=0.5))\n self.wait(0.5)\n\n # 5. Disappearance: Fade out the square\n self.play(FadeOut(square))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 screen units and percentages of the screen dimensions in the context of computer graphics. Could you provide an animation that includes a grid as a reference, and then sequentially displays rectangles of increasing width, each representing a different percentage of the screen's width? Each rectangle should be a different color to clearly distinguish them, and also partially transparent so I can see how they overlap if they do. Finally, is it possible to place a dot at a precise location measured in pixels from the center of the screen, for example, 150 pixels up and to the right?", "chosen": "```python\nfrom manim import *\n\nclass ScreenUnitsAndPercentages(Scene):\n def construct(self):\n # 1. Reference Grid\n # Display a grid to serve as a visual reference for the screen space.\n grid = NumberPlane(\n x_range=(-config.frame_width / 2, config.frame_width / 2, 1),\n y_range=(-config.frame_height / 2, config.frame_height / 2, 1),\n background_line_style={\n \"stroke_color\": GREY_B,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n self.play(Create(grid), run_time=1)\n self.wait(0.5)\n\n # 2. Percentage Rectangles\n # Sequentially display rectangles of increasing width representing percentages\n percentages = [0.25, 0.50, 0.75, 1.00]\n colors = [RED, BLUE, GREEN, YELLOW]\n screen_width = config.frame_width\n \n for i, percent in enumerate(percentages):\n # Calculate width based on percentage of the total screen width\n rect_width = screen_width * percent\n \n rect = Rectangle(\n width=rect_width,\n height=1.5,\n stroke_color=colors[i],\n stroke_width=2,\n fill_color=colors[i],\n fill_opacity=0.4 # Partial transparency to visualize overlaps\n )\n rect.move_to(ORIGIN)\n \n # Shift slightly vertically to allow visual comparison of widths\n # while still demonstrating overlap and centering\n rect.shift(DOWN * (i * 0.4))\n \n # Label for educational context\n label = Text(f\"{int(percent * 100)}% Screen Width\", font_size=24, color=WHITE)\n label.next_to(rect, UP, buff=0.2)\n \n # Animate creation\n self.play(Create(rect), Write(label), run_time=1)\n self.wait(0.5)\n \n # Fade out label to reduce clutter while keeping rectangle for overlap visualization\n self.play(FadeOut(label), run_time=0.5)\n\n self.wait(1)\n\n # 3. Precise Dot Placement\n # Place a dot at a specific location measured in pixels relative to the screen center\n # Specific Coordinates: 150 pixels up and 150 pixels to the right from the center\n \n # Convert pixels to Manim units accurately\n # Formula: units = pixels * (frame_height_units / pixel_height_total)\n pixels_offset = 150\n units_per_pixel = config.frame_height / config.pixel_height\n unit_offset = pixels_offset * units_per_pixel\n \n dot_position = [unit_offset, unit_offset, 0]\n \n dot = Dot(point=dot_position, color=WHITE, radius=0.15)\n \n # Visual aids for coordinate measurement\n h_line = DashedLine(start=ORIGIN, end=[unit_offset, 0, 0], color=WHITE)\n v_line = DashedLine(start=[unit_offset, 0, 0], end=dot_position, color=WHITE)\n \n # Create labels to explain the coordinate conversion\n pixel_label = Text(f\"Offset: {pixels_offset}px Right, {pixels_offset}px Up\", font_size=20, color=WHITE)\n pixel_label.next_to(dot, UR, buff=0.1)\n \n unit_label = Text(f\"Units: ({unit_offset:.2f}, {unit_offset:.2f})\", font_size=20, color=WHITE)\n unit_label.next_to(pixel_label, DOWN, buff=0.1)\n \n # Animate the dot placement and visual aids\n self.play(\n Create(h_line),\n Create(v_line),\n GrowFromCenter(dot),\n Write(pixel_label),\n Write(unit_label),\n run_time=1.5\n )\n self.play(Indicate(dot))\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass ScreenUnitsAndPercentages(Scene):\n def construct(self):\n # 1. Reference Grid\n # Display a grid to serve as a visual reference for the screen space.\n grid = NumberPlane(\n x_range=(-config.frame_width / 2, config.frame_width / 2, 1),\n y_range=(-config.frame_height / 2, config.frame_height / 2, 1),\n background_line_style={\n \"stroke_color\": GREY_B,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.5\n }\n )\n self.play(Create(grid), run_time=1)\n self.wait(0.5)\n\n # 2. Percentage Rectangles\n # Sequentially display rectangles of increasing width representing percentages\n percentages = [0.25, 0.50, 0.75, 1.00]\n colors = [RED, BBLUE, GREEN, YELLOW]\n screen_width = config.frame_width\n \n for i, percent in enumerate(percentages):\n # Calculate width based on percentage of the total screen width\n rect_width = screen_width * percent\n \n rect = Rectangle(\n width=rect_width,\n height=1.5,\n stroke_color=colors[i],\n stroke_width=2,\n fill_color=colors[i],\n fill_opacity=0.4 # Partial transparency to visualize overlaps\n )\n rect.move_to(ORIGIN)\n \n # Shift slightly vertically to allow visual comparison of widths\n # while still demonstrating overlap and centering\n rect.shift(DOWN * (i * 0.4))\n \n # Label for educational context\n label = Text(f\"{int(percent * 100)}% Screen Width\", font_size=24, color=WHITE)\n label.next_to(rect, UP, buff=0.2)\n \n # Animate creation\n self.play(Create(rect), Write(label), run_time=1)\n self.wait(0.5)\n \n # Fade out label to reduce clutter while keeping rectangle for overlap visualization\n self.play(FadeOut(label), run_time=0.5)\n\n self.wait(1)\n\n # 3. Precise Dot Placement\n # Place a dot at a specific location measured in pixels relative to the screen center\n # Specific Coordinates: 150 pixels up and 150 pixels to the right from the center\n \n # Convert pixels to Manim units accurately\n # Formula: units = pixels * (frame_height_units / pixel_height_total)\n pixels_offset = 150\n units_per_pixel = config.frame_height / config.pixel_height\n unit_offset = pixels_offset * units_per_pixel\n \n dot_position = [unit_offset, unit_offset, 0]\n \n dot = Dot(point=dot_position, color=WHITE, radius=0.15)\n \n # Visual aids for coordinate measurement\n h_line = DashedLine(start=ORIGIN, end=[unit_offset, 0, 0], color=WHITE)\n v_line = DashedLine(start=[unit_offset, 0, 0], end=dot_position, color=WHITE)\n \n # Create labels to explain the coordinate conversion\n pixel_label = Text(f\"Offset: {pixels_offset}px Right, {pixels_offset}px Up\", font_size=20, color=WHITE)\n pixel_label.next_to(dot, UR, buff=0.1)\n \n unit_label = Text(f\"Units: ({unit_offset:.2f}, {unit_offset:.2f})\", font_size=20, color=WHITE)\n unit_label.next_to(pixel_label, DOWN, buff=0.1)\n \n # Animate the dot placement and visual aids\n self.play(\n Create(h_line),\n Create(v_line),\n GrowFromCenter(dot),\n Write(pixel_label),\n Write(unit_label),\n run_time=1.5\n )\n self.play(Indicate(dot))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 now it will smoothly transform into a right triangle by adding two additional lines that complete the shape - a vertical line from (1,1) to (1,-1) in blue and a horizontal line from (1,-1) to (-1,-1) in red, with all three lines appearing sequentially through a creative drawing animation. As the triangle forms, the Pythagorean theorem (a² + b² = c²) will fade in above it, with each term color-coded to match its corresponding side (blue for a, red for b, and green for c). The animation will then highlight each side of the triangle while pulsing its matching term in the equation, followed by the entire triangle rotating 360 degrees around its center point. Finally, the triangle will morph into a square of equal area while the equation transforms to demonstrate the area relationship, concluding with all elements fading out in a coordinated sequence. This enhanced version maintains the original line while adding geometric transformations, mathematical context, color coordination, and multiple synchronized animations to create a more educational and visually engaging presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedPythagorean(Scene):\n def construct(self):\n # Create the diagonal line (hypotenuse)\n diagonal = Line(start=[1, 1, 0], end=[-1, -1, 0], color=GREEN)\n \n # Create the vertical and horizontal lines\n vertical = Line(start=[1, 1, 0], end=[1, -1, 0], color=BLUE)\n horizontal = Line(start=[1, -1, 0], end=[-1, -1, 0], color=RED)\n \n # Animate the lines appearing sequentially\n self.play(Create(diagonal))\n self.play(Create(vertical))\n self.play(Create(horizontal))\n self.wait(0.5)\n \n # Create the Pythagorean theorem text with color coding\n theorem = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.2)\n theorem[0].set_color(BLUE) # a^2\n theorem[2].set_color(RED) # b^2\n theorem[4].set_color(GREEN) # c^2\n theorem.next_to(diagonal, UP, buff=1.5)\n \n # Fade in the theorem\n self.play(FadeIn(theorem))\n self.wait(0.5)\n \n # Highlight each side and pulse corresponding term\n for i, (side, term_idx) in enumerate(zip(\n [vertical, horizontal, diagonal],\n [0, 2, 4]\n )):\n highlight = side.copy().set_stroke(width=10, opacity=0.7)\n self.play(\n Create(highlight),\n theorem[term_idx].animate.scale(1.5),\n run_time=0.7\n )\n self.play(\n FadeOut(highlight),\n theorem[term_idx].animate.scale(1/1.5),\n run_time=0.7\n )\n \n # Rotate the triangle 360 degrees\n triangle_group = VGroup(diagonal, vertical, horizontal)\n self.play(\n Rotate(triangle_group, angle=2*PI, about_point=triangle_group.get_center()),\n run_time=3\n )\n self.wait(0.5)\n \n # Morph triangle into square of equal area\n square = Square(side_length=2, color=PURPLE).move_to(triangle_group.get_center())\n area_eq = MathTex(\"\\\\text{Area} = \\\\frac{1}{2}ab\").next_to(theorem, DOWN)\n \n self.play(\n Transform(triangle_group, square),\n Transform(theorem, area_eq),\n run_time=2\n )\n self.wait(1)\n \n # Fade out all elements\n self.play(\n FadeOut(triangle_group),\n FadeOut(theorem),\n run_time=1\n )\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedPythagorean(Scene):\n def construct(self):\n # Create the diagonal line (hypotenuse)\n diagonal = Line(start=[1, 1, 0], end=[-1, -1, 0], color=GREEN)\n \n # Create the vertical and horizontal lines\n vertical = Line(start=[1, 1, 0], end=[1, -1, 0], color=BLUE)\n horizontal = Line(start=[1, -1, 0], end=[-1, -1, 0], color=RED)\n \n # Animate the lines appearing sequentially\n self.play(Create(diagonal))\n self.play(Create(vertical))\n self.play(Create(horizontal))\n self.wait(0.5)\n \n # Create the Pythagorean theorem text with color coding\n theorem = MathText(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\").scale(1.2)\n theorem[0].set_color(BLUE) # a^2\n theorem[2].set_color(RED) # b^2\n theorem[4].set_color(GREEN) # c^2\n theorem.next_to(diagonal, UP, buff=1.5)\n \n # Fade in the theorem\n self.play(FadeIn(theorem))\n self.wait(0.5)\n \n # Highlight each side and pulse corresponding term\n for i, (side, term_idx) in enumerate(zip(\n [vertical, horizontal, diagonal],\n [0, 2, 4]\n )):\n highlight = side.copy().set_stroke(width=10, opacity=0.7)\n self.play(\n Create(highlight),\n theorem[term_idx].animate.scale(1.5),\n run_time=0.7\n )\n self.play(\n FadeOut(highlight),\n theorem[term_idx].animate.scale(1/1.5),\n run_time=0.7\n )\n \n # Rotate the triangle 360 degrees\n triangle_group = VGroup(diagonal, vertical, horizontal)\n self.play(\n Rotate(triangle_group, angle=2*PI, about_point=triangle_group.get_center()),\n run_time=3\n )\n self.wait(0.5)\n \n # Morph triangle into square of equal area\n square = Square(side_length=2, color=PURPLE).move_to(triangle_group.get_center())\n area_eq = MathTex(\"\\\\text{Area} = \\\\frac{1}{2}ab\").next_to(theorem, DOWN)\n \n self.play(\n Transform(triangle_group, square),\n Transform(theorem, area_eq),\n run_time=2\n )\n self.wait(1)\n \n # Fade out all elements\n self.play(\n FadeOut(triangle_group),\n FadeOut(theorem),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using Manim that shows a visual representation of a Variational Autoencoder (VAE) neural network architecture. I'd like to see how the data flows through an image input layer, several feedforward layers, an embedding layer that represents the bottleneck of the VAE, and then back through feedforward layers to an image output layer. The animation should illustrate the forward pass of data through the network. Additionally, I would like the animation to display a snippet of the code that creates the network, with syntax highlighting to make it easy to read. Also, ensure that the whole neural network is centered and scaled appropriately on the screen and that the animation runs smoothly for an audience to follow along. If possible, include an actual image file for the input and output layers of the network.", "chosen": "```python\nfrom manim import *\n\nclass ChemicalBonds(Scene):\n def construct(self):\n # Create a water molecule representation with bonds\n oxygen_atom = Circle(radius=0.5, color=BLUE).set_fill(BLUE, opacity=1)\n hydrogen_atom1 = Circle(radius=0.25, color=WHITE).set_fill(WHITE, opacity=1)\n hydrogen_atom2 = Circle(radius=0.25, color=WHITE).set_fill(WHITE, opacity=1)\n\n bond1 = Line(start=oxygen_atom.get_right(), end=hydrogen_atom1.get_left())\n bond2 = Line(start=oxygen_atom.get_left(), end=hydrogen_atom2.get_left())\n\n water_molecule = VGroup(\n oxygen_atom, \n hydrogen_atom1.next_to(oxygen_atom, RIGHT, buff=0.5), \n hydrogen_atom2.next_to(oxygen_atom, LEFT, buff=0.5),\n bond1, \n bond2\n )\n\n # Create labels for the atoms\n oxygen_label = Text(\"O\", color=WHITE).move_to(oxygen_atom.get_center())\n hydrogen_label1 = Text(\"H\", color=BLACK).move_to(hydrogen_atom1.get_center())\n hydrogen_label2 = Text(\"H\", color=BLACK).move_to(hydrogen_atom2.get_center())\n\n # Combine the molecule and the labels\n molecule_with_labels = VGroup(water_molecule, oxygen_label, hydrogen_label1, hydrogen_label2)\n\n # Animate the construction of the water molecule\n self.play(Create(oxygen_atom))\n self.play(Create(hydrogen_atom1), Create(hydrogen_atom2))\n self.play(Create(bond1), Create(bond2))\n self.play(FadeIn(oxygen_label), FadeIn(hydrogen_label1), FadeIn(hydrogen_label2))\n\n # Scale up the molecule to focus on it\n self.play(molecule_with_labels.animate.scale(2))\n\n # Rotate the molecule within the scene\n self.play(Rotate(molecule_with_labels, angle=2 * PI))\n\n self.wait(2) # Pause to admire our water molecule before ending the scene.\n```", "rejected": "```python\nfrom manim import *\n\nclass ChemicalBonds(Scene):\n def construct(self):\n # Create a water molecule representation with bonds\n oxygen_atom = Circle(radius=0.5, color=BBLUE).set_fill(BLUE, opacity=1)\n hydrogen_atom1 = Circle(radius=0.25, color=WHITE).set_fill(WHITE, opacity=1)\n hydrogen_atom2 = Circle(radius=0.25, color=WHITE).set_fill(WHITE, opacity=1)\n\n bond1 = Line(start=oxygen_atom.get_right(), end=hydrogen_atom1.get_left())\n bond2 = Line(start=oxygen_atom.get_left(), end=hydrogen_atom2.get_left())\n\n water_molecule = VGroup(\n oxygen_atom, \n hydrogen_atom1.next_to(oxygen_atom, RIGHT, buff=0.5), \n hydrogen_atom2.next_to(oxygen_atom, LEFT, buff=0.5),\n bond1, \n bond2\n )\n\n # Create labels for the atoms\n oxygen_label = Text(\"O\", color=WHITE).move_to(oxygen_atom.get_center())\n hydrogen_label1 = Text(\"H\", color=BLACK).move_to(hydrogen_atom1.get_center())\n hydrogen_label2 = Text(\"H\", color=BLACK).move_to(hydrogen_atom2.get_center())\n\n # Combine the molecule and the labels\n molecule_with_labels = VGroup(water_molecule, oxygen_label, hydrogen_label1, hydrogen_label2)\n\n # Animate the construction of the water molecule\n self.play(Create(oxygen_atom))\n self.play(Create(hydrogen_atom1), Create(hydrogen_atom2))\n self.play(Create(bond1), Create(bond2))\n self.play(FadeIn(oxygen_label), FadeIn(hydrogen_label1), FadeIn(hydrogen_label2))\n\n # Scale up the molecule to focus on it\n self.play(molecule_with_labels.animate.scale(2))\n\n # Rotate the molecule within the scene\n self.play(Rotate(molecule_with_labels, angle=2 * PI))\n\n self.wait(2) # Pause to admire our water molecule before ending the scene.\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 square (side length 2) and a circle (radius 1) appearing simultaneously at the center of the screen. The shapes are then grouped into a `VGroup` and rotated counterclockwise by 30 degrees. To enhance the animation, the square smoothly transforms into a golden rectangle (with the golden ratio proportions) while the circle morphs into an ellipse, maintaining the same area. As this transformation occurs, a mathematical formula appears below the shapes, dynamically rendering the equation for the golden ratio: \\( \\phi = \\frac{1 + \\sqrt{5}}{2} \\). The text fades in with a slight upward motion for emphasis. Finally, the entire group pulses gently with a color shift from white to a soft gold, reinforcing the golden ratio theme, before coming to rest in its final transformed state. The animation concludes with all elements remaining on screen, providing a clear visual and mathematical representation of the concepts.", "chosen": "```python\nfrom manim import *\nimport math\n\nclass GoldenRatioTransformation(Scene):\n def construct(self):\n # Create initial shapes\n square = Square(side_length=2, color=WHITE)\n circle = Circle(radius=1, color=WHITE)\n \n # Group and position them\n group = VGroup(square, circle)\n group.move_to(ORIGIN)\n \n # Rotate the group\n self.play(Create(square), Create(circle))\n self.play(group.animate.rotate(30 * DEGREES))\n \n # Define golden ratio proportions\n phi = (1 + math.sqrt(5)) / 2\n golden_rect = Rectangle(\n width=2 * phi,\n height=2,\n color=GOLD\n )\n golden_rect.move_to(square.get_center())\n \n # Transform square to golden rectangle\n self.play(Transform(square, golden_rect))\n \n # Transform circle to ellipse (same area)\n ellipse = Ellipse(\n width=2 * math.sqrt(phi),\n height=2 / math.sqrt(phi),\n color=GOLD\n )\n ellipse.move_to(circle.get_center())\n self.play(Transform(circle, ellipse))\n \n # Display golden ratio formula\n formula = MathTex(\n r\"\\phi = \\frac{1 + \\sqrt{5}}{2}\",\n color=GOLD\n )\n formula.next_to(group, DOWN, buff=1)\n \n self.play(\n Write(formula),\n formula.animate.shift(UP * 0.2),\n run_time=1.5\n )\n \n # Pulse effect with color shift\n self.play(\n group.animate.set_color(GOLD),\n formula.animate.set_color(GOLD),\n rate_func=there_and_back,\n run_time=2\n )\n \n # Keep everything on screen\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nimport math\n\nclass GoldenRatioTransformation(Scene):\n def construct(self):\n # Create initial shapes\n square = Square(side_length=2, color=WHITE)\n circle = Circle(radius=1, color=WHITE)\n \n # Group and position them\n group = VGroup(square, circle)\n group.move_to(ORIGIN)\n \n # Rotate the group\n self.play(Create(square), Create(circle))\n self.play(group.animate.rotate(30 * DEGREES))\n \n # Define golden ratio proportions\n phi = (1 + math.sqrt(5)) / 2\n golden_rect = Rectangle(\n width=2 * phi,\n height=2,\n color=GOLD\n )\n golden_rect.move_to(square.get_center())\n \n # Transform square to golden rectangle\n self.play(Transform(square, golden_rect))\n \n # Transform circle to ellipse (same area)\n ellipse = Ellipse(\n width=2 * math.sqrt(phi),\n height=2 / math.sqrt(phi),\n color=GOLD\n )\n ellipse.move_to(circle.get_center())\n self.play(Transform(circle, ellipse))\n \n # Display golden ratio formula\n formula = MathText(\n r\"\\phi = \\frac{1 + \\sqrt{5}}{2}\",\n color=GOLD\n )\n formula.next_to(group, DOWN, buff=1)\n \n self.play(\n Write(formula),\n formula.animate.shift(UP * 0.2),\n run_time=1.5\n )\n \n # Pulse effect with color shift\n self.play(\n group.animate.set_color(GOLD),\n formula.animate.set_color(GOLD),\n rate_func=there_and_back,\n run_time=2\n )\n \n # Keep everything on screen\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visually demonstrates Prim's algorithm for finding a minimum spanning tree on a graph. The graph should be circular with seven vertices connected by a selection of edges. The animation should start by showing the complete graph with all vertices and edges, and then proceed to apply Prim's algorithm, progressively highlighting the edges that create the minimum spanning tree using dashed blue lines. The animation should also include a label stating \"Minimum Spanning Tree (Prim's Algorithm)\" above the graph. After the algorithm has finished running, the video should conclude by fading out both the graph and the label.", "chosen": "```python\nfrom manim import *\nimport numpy as np\nimport heapq\n\nclass PrimsAlgorithm(Scene):\n def construct(self):\n # --- Configuration ---\n n_vertices = 7\n radius = 2.5\n \n # --- Create Vertices ---\n layout = {}\n vertices_mobjects = VGroup()\n vertex_labels = VGroup()\n \n for i in range(n_vertices):\n angle = i * 2 * np.pi / n_vertices - np.pi / 2\n pos = np.array([radius * np.cos(angle), radius * np.sin(angle), 0])\n layout[i] = pos\n \n dot = Dot(pos, color=WHITE, radius=0.2)\n label = Text(str(i), font_size=24).move_to(pos)\n \n vertices_mobjects.add(dot)\n vertex_labels.add(label)\n\n # --- Define Edges (u, v, weight) ---\n edges_data = [\n (0, 1, 4), (1, 2, 3), (2, 3, 5), (3, 4, 2), \n (4, 5, 6), (5, 6, 1), (6, 0, 7), \n (0, 2, 8), (1, 3, 9), (3, 5, 10)\n ]\n\n edge_lines = VGroup()\n weight_labels = VGroup()\n edges_dict = {}\n\n for u, v, w in edges_data:\n start_pos = layout[u]\n end_pos = layout[v]\n \n line = Line(start_pos, end_pos, color=GRAY, stroke_width=2)\n edge_lines.add(line)\n \n mid_point = (start_pos + end_pos) / 2\n direction = end_pos - start_pos\n normal = np.array([-direction[1], direction[0], 0])\n if np.linalg.norm(normal) > 0:\n normal = normal / np.linalg.norm(normal)\n mid_point += normal * 0.25\n \n weight_text = Text(str(w), font_size=20, color=YELLOW).move_to(mid_point)\n weight_labels.add(weight_text)\n \n key = tuple(sorted((u, v)))\n edges_dict[key] = {'line': line, 'weight': w, 'start': start_pos, 'end': end_pos}\n\n # --- Title ---\n title = Text(\"Minimum Spanning Tree (Prim's Algorithm)\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n \n # Start: Display the complete graph and title\n self.play(Write(title))\n self.play(FadeIn(vertices_mobjects), FadeIn(vertex_labels))\n self.play(Create(edge_lines), FadeIn(weight_labels))\n self.wait(1)\n\n # Process: Prim's Algorithm using a priority queue\n adj = {i: [] for i in range(n_vertices)}\n for u, v, w in edges_data:\n adj[u].append((w, v))\n adj[v].append((w, u))\n\n visited = set([0])\n mst_lines = VGroup()\n pq = []\n \n for weight, neighbor in adj[0]:\n heapq.heappush(pq, (weight, 0, neighbor))\n\n while len(visited) < n_vertices and pq:\n weight, u, v = heapq.heappop(pq)\n \n if v in visited:\n continue\n \n visited.add(v)\n \n # Highlighting: Progressively highlight the selected MST edge using a dashed blue line\n key = tuple(sorted((u, v)))\n data = edges_dict[key]\n mst_line = DashedLine(\n data['start'], \n data['end'], \n color=BLUE, \n dash_length=0.1,\n stroke_width=4\n )\n mst_lines.add(mst_line)\n \n self.play(Create(mst_line), run_time=0.8)\n self.wait(0.5)\n \n for next_weight, neighbor in adj[v]:\n if neighbor not in visited:\n heapq.heappush(pq, (next_weight, v, neighbor))\n\n self.wait(1)\n\n # Conclusion: Fade out both the graph and the label\n everything = VGroup(\n title, \n vertices_mobjects, \n vertex_labels, \n edge_lines, \n weight_labels, \n mst_lines\n )\n self.play(FadeOut(everything))\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\nimport heapq\n\nclass PrimsAlgorithm(Scene):\n def construct(self):\n # --- Configuration ---\n n_vertices = 7\n radius = 2.5\n \n # --- Create Vertices ---\n layout = {}\n vertices_mobjects = VGroup()\n vertex_labels = VGroup()\n \n for i in range(n_vertices):\n angle = i * 2 * np.pi / n_vertices - np.pi / 2\n pos = np.array([radius * np.cos(angle), radius * np.sin(angle), 0])\n layout[i] = pos\n \n dot = Dot(pos, color=WHITE, radius=0.2)\n label = Text(str(i), font_size=24).move_to(pos)\n \n vertices_mobjects.add(dot)\n vertex_labels.add(label)\n\n # --- Define Edges (u, v, weight) ---\n edges_data = [\n (0, 1, 4), (1, 2, 3), (2, 3, 5), (3, 4, 2), \n (4, 5, 6), (5, 6, 1), (6, 0, 7), \n (0, 2, 8), (1, 3, 9), (3, 5, 10)\n ]\n\n edge_lines = VGroup()\n weight_labels = VGroup()\n edges_dict = {}\n\n for u, v, w in edges_data:\n start_pos = layout[u]\n end_pos = layout[v]\n \n line = Line(start_pos, end_pos, color=GRAY, stroke_width=2)\n edge_lines.add(line)\n \n mid_point = (start_pos + end_pos) / 2\n direction = end_pos - start_pos\n normal = np.array([-direction[1], direction[0], 0])\n if np.linalg.norm(normal) > 0:\n normal = normal / np.linalg.norm(normal)\n mid_point += normal * 0.25\n \n weight_text = Text(str(w), font_size=20, color=YELLOW).move_to(mid_point)\n weight_labels.add(weight_text)\n \n key = tuple(sorted((u, v)))\n edges_dict[key] = {'line': line, 'weight': w, 'start': start_pos, 'end': end_pos}\n\n # --- Title ---\n title = Text(\"Minimum Spanning Tree (Prim's Algorithm)\", font_size=36).to_edge(UP)\n\n # --- Animation Sequence ---\n \n # Start: Display the complete graph and title\n self.play(Write(title))\n self.play(FadeIn(vertices_mobjects), FadeIn(vertex_labels))\n self.play(Create(edge_lines), FadeIn(weight_labels))\n self.wait(1)\n\n # Process: Prim's Algorithm using a priority queue\n adj = {i: [] for i in range(n_vertices)}\n for u, v, w in edges_data:\n adj[u].append((w, v))\n adj[v].append((w, u))\n\n visited = set([0])\n mst_lines = VGroup()\n pq = []\n \n for weight, neighbor in adj[0]:\n heapq.heappush(pq, (weight, 0, neighbor))\n\n while len(visited) < n_vertices and pq:\n weight, u, v = heapq.heappop(pq)\n \n if v in visited:\n continue\n \n visited.add(v)\n \n # Highlighting: Progressively highlight the selected MST edge using a dashed blue line\n key = tuple(sorted((u, v)))\n data = edges_dict[key]\n mst_line = DashedLine(\n data['start'], \n data['end'], \n color=BBLUE, \n dash_length=0.1,\n stroke_width=4\n )\n mst_lines.add(mst_line)\n \n self.play(Create(mst_line), run_time=0.8)\n self.wait(0.5)\n \n for next_weight, neighbor in adj[v]:\n if neighbor not in visited:\n heapq.heappush(pq, (next_weight, v, neighbor))\n\n self.wait(1)\n\n # Conclusion: Fade out both the graph and the label\n everything = VGroup(\n title, \n vertices_mobjects, \n vertex_labels, \n edge_lines, \n weight_labels, \n mst_lines\n )\n self.play(FadeOut(everything))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 you employ conditional probability to forecast weather patterns with a dynamic visualization of historical data?", "chosen": "```python\nfrom manim import *\n\nclass ConditionalProbabilityWeather(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Predicting Storms\", color=WHITE)\n subtitle = Text(\"Using Conditional Probability\", color=WHITE)\n subtitle.next_to(title, DOWN)\n \n # Simple weather icons\n cloud = Circle(radius=0.5, color=LIGHT_GRAY, fill_opacity=0.8).shift(LEFT*2)\n sun = Circle(radius=0.3, color=YELLOW, fill_opacity=1).shift(RIGHT*2)\n \n # Display introduction\n self.play(Write(title))\n self.play(Write(subtitle))\n self.play(Create(cloud), Create(sun))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle), FadeOut(cloud), FadeOut(sun))\n \n # Key Concept 1: Lunch analogy\n concept1 = Text(\"Key Concept 1: The Lunch Analogy\", color=WHITE)\n concept1.to_edge(UP)\n \n # Simple food icons\n pasta = Circle(radius=0.3, color=YELLOW, fill_opacity=0.5).shift(LEFT*2)\n pasta_label = Text(\"Pasta\", color=WHITE).next_to(pasta, DOWN)\n \n sandwich = Square(side_length=0.6, color=GREEN, fill_opacity=0.5).shift(RIGHT*2)\n sandwich_label = Text(\"Sandwich\", color=WHITE).next_to(sandwich, DOWN)\n \n arrow = Arrow(pasta.get_right(), sandwich.get_left(), color=WHITE)\n prob = Text(\"70%\", color=BLUE).next_to(arrow, UP)\n \n # Display Key Concept 1\n self.play(Write(concept1))\n self.play(Create(pasta), Write(pasta_label))\n self.play(Create(sandwich), Write(sandwich_label))\n self.play(Create(arrow), Write(prob))\n self.wait(1)\n self.play(\n FadeOut(concept1), FadeOut(pasta), FadeOut(pasta_label),\n FadeOut(sandwich), FadeOut(sandwich_label), FadeOut(arrow), FadeOut(prob)\n )\n \n # Key Concept 2: Conditional probability in weather\n concept2 = Text(\"Key Concept 2: Weather Probability\", color=WHITE)\n concept2.to_edge(UP)\n \n # Weather icons\n cloud2 = Circle(radius=0.5, color=LIGHT_GRAY, fill_opacity=0.8).shift(LEFT*2)\n cloud_label = Text(\"Cloudy Morning\", color=WHITE).next_to(cloud2, DOWN)\n \n rain = Circle(radius=0.5, color=BLUE, fill_opacity=0.5).shift(RIGHT*2)\n rain_label = Text(\"Rain Later\", color=WHITE).next_to(rain, DOWN)\n \n weather_arrow = Arrow(cloud2.get_right(), rain.get_left(), color=WHITE)\n weather_prob = Text(\"70%\", color=BLUE).next_to(weather_arrow, UP)\n \n # Display Key Concept 2\n self.play(Write(concept2))\n self.play(Create(cloud2), Write(cloud_label))\n self.play(Create(rain), Write(rain_label))\n self.play(Create(weather_arrow), Write(weather_prob))\n self.wait(1)\n self.play(\n FadeOut(concept2), FadeOut(cloud2), FadeOut(cloud_label),\n FadeOut(rain), FadeOut(rain_label), FadeOut(weather_arrow), FadeOut(weather_prob)\n )\n \n # Key Concept 3: Historical data\n concept3 = Text(\"Key Concept 3: Historical Data\", color=WHITE)\n concept3.to_edge(UP)\n \n # Simple bar chart\n bars = VGroup()\n bar_heights = [1, 2, 1.5, 2.5, 1.8]\n for i, height in enumerate(bar_heights):\n bar = Rectangle(height=height, width=0.6, fill_opacity=0.8, color=BLUE)\n bar.move_to(i*0.8*RIGHT - 1.6*LEFT + height/2*UP)\n bars.add(bar)\n \n data_label = Text(\"Weather History\", color=WHITE).next_to(bars, DOWN)\n \n # Display Key Concept 3\n self.play(Write(concept3))\n self.play(Create(bars), Write(data_label))\n self.wait(1)\n self.play(FadeOut(concept3), FadeOut(bars), FadeOut(data_label))\n \n # Key Insight\n insight = Text(\"Key Insight: Dynamic Probabilities\", color=WHITE)\n insight.to_edge(UP)\n \n # Simple map with changing probabilities\n map_outline = Rectangle(height=3, width=5, color=WHITE)\n \n # Probability labels\n prob_labels = VGroup()\n positions = [UP+LEFT, UP+RIGHT, DOWN+LEFT, DOWN+RIGHT]\n values = [\"30%\", \"60%\", \"45%\", \"75%\"]\n colors = [BLUE, BLUE, BLUE, BLUE]\n \n for pos, val, col in zip(positions, values, colors):\n prob_label = Text(val, color=col)\n prob_label.move_to(map_outline.get_center() + pos)\n prob_labels.add(prob_label)\n \n # Display Key Insight\n self.play(Write(insight))\n self.play(Create(map_outline))\n for label in prob_labels:\n self.play(Write(label), run_time=0.5)\n self.wait(1)\n self.play(FadeOut(insight), FadeOut(map_outline), FadeOut(prob_labels))\n \n # Conclusion with equation\n conclusion = Text(\"Conclusion\", color=WHITE)\n conclusion.to_edge(UP)\n \n # The main equation\n equation = MathTex(r\"P(A|B) = \\frac{P(A \\cap B)}{P(B)}\")\n equation.scale(1.5)\n \n # Display Conclusion\n self.play(Write(conclusion))\n self.play(Write(equation))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(conclusion), FadeOut(equation))\n \n # Final title\n final_title = Text(\"Predicting Storms with Conditional Probability\", color=WHITE)\n self.play(Write(final_title))\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass ConditionalProbabilityWeather(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Predicting Storms\", color=WHITE)\n subtitle = Text(\"Using Conditional Probability\", color=WHITE)\n subtitle.next_to(title, DOWN)\n \n # Simple weather icons\n cloud = Circle(radius=0.5, color=LIGHT_GRAY, fill_opacity=0.8).shift(LEFT*2)\n sun = Circle(radius=0.3, color=YELLOW, fill_opacity=1).shift(RIGHT*2)\n \n # Display introduction\n self.play(Write(title))\n self.play(Write(subtitle))\n self.play(Create(cloud), Create(sun))\n self.wait(1)\n self.play(FadeOut(title), FadeOut(subtitle), FadeOut(cloud), FadeOut(sun))\n \n # Key Concept 1: Lunch analogy\n concept1 = Text(\"Key Concept 1: The Lunch Analogy\", color=WHITE)\n concept1.to_edge(UP)\n \n # Simple food icons\n pasta = Circle(radius=0.3, color=YELLOW, fill_opacity=0.5).shift(LEFT*2)\n pasta_label = Text(\"Pasta\", color=WHITE).next_to(pasta, DOWN)\n \n sandwich = Square(side_length=0.6, color=GREEN, fill_opacity=0.5).shift(RIGHT*2)\n sandwich_label = Text(\"Sandwich\", color=WHITE).next_to(sandwich, DOWN)\n \n arrow = Arrow(pasta.get_right(), sandwich.get_left(), color=WHITE)\n prob = Text(\"70%\", color=BLUE).next_to(arrow, UP)\n \n # Display Key Concept 1\n self.play(Write(concept1))\n self.play(Create(pasta), Write(pasta_label))\n self.play(Create(sandwich), Write(sandwich_label))\n self.play(Create(arrow), Write(prob))\n self.wait(1)\n self.play(\n FadeOut(concept1), FadeOut(pasta), FadeOut(pasta_label),\n FadeOut(sandwich), FadeOut(sandwich_label), FadeOut(arrow), FadeOut(prob)\n )\n \n # Key Concept 2: Conditional probability in weather\n concept2 = Text(\"Key Concept 2: Weather Probability\", color=WHITE)\n concept2.to_edge(UP)\n \n # Weather icons\n cloud2 = Circle(radius=0.5, color=LIGHT_GRAY, fill_opacity=0.8).shift(LEFT*2)\n cloud_label = Text(\"Cloudy Morning\", color=WHITE).next_to(cloud2, DOWN)\n \n rain = Circle(radius=0.5, color=BLUE, fill_opacity=0.5).shift(RIGHT*2)\n rain_label = Text(\"Rain Later\", color=WHITE).next_to(rain, DOWN)\n \n weather_arrow = Arrow(cloud2.get_right(), rain.get_left(), color=WHITE)\n weather_prob = Text(\"70%\", color=BLUE).next_to(weather_arrow, UP)\n \n # Display Key Concept 2\n self.play(Write(concept2))\n self.play(Create(cloud2), Write(cloud_label))\n self.play(Create(rain), Write(rain_label))\n self.play(Create(weather_arrow), Write(weather_prob))\n self.wait(1)\n self.play(\n FadeOut(concept2), FadeOut(cloud2), FadeOut(cloud_label),\n FadeOut(rain), FadeOut(rain_label), FadeOut(weather_arrow), FadeOut(weather_prob)\n )\n \n # Key Concept 3: Historical data\n concept3 = Text(\"Key Concept 3: Historical Data\", color=WHITE)\n concept3.to_edge(UP)\n \n # Simple bar chart\n bars = VGroup()\n bar_heights = [1, 2, 1.5, 2.5, 1.8]\n for i, height in enumerate(bar_heights):\n bar = Rectangle(height=height, width=0.6, fill_opacity=0.8, color=BLUE)\n bar.move_to(i*0.8*RIGHT - 1.6*LEFT + height/2*UP)\n bars.add(bar)\n \n data_label = Text(\"Weather History\", color=WHITE).next_to(bars, DOWN)\n \n # Display Key Concept 3\n self.play(Write(concept3))\n self.play(Create(bars), Write(data_label))\n self.wait(1)\n self.play(FadeOut(concept3), FadeOut(bars), FadeOut(data_label))\n \n # Key Insight\n insight = Text(\"Key Insight: Dynamic Probabilities\", color=WHITE)\n insight.to_edge(UP)\n \n # Simple map with changing probabilities\n map_outline = Rectangle(height=3, width=5, color=WHITE)\n \n # Probability labels\n prob_labels = VGroup()\n positions = [UP+LEFT, UP+RIGHT, DOWN+LEFT, DOWN+RIGHT]\n values = [\"30%\", \"60%\", \"45%\", \"75%\"]\n colors = [BLUE, BLUE, BLUE, BLUE]\n \n for pos, val, col in zip(positions, values, colors):\n prob_label = Text(val, color=col)\n prob_label.move_to(map_outline.get_center() + pos)\n prob_labels.add(prob_label)\n \n # Display Key Insight\n self.play(Write(insight))\n self.play(Create(map_outline))\n for label in prob_labels:\n self.play(Write(label), run_time=0.5)\n self.wait(1)\n self.play(FadeOut(insight), FadeOut(map_outline), FadeOut(prob_labels))\n \n # Conclusion with equation\n conclusion = Text(\"Conclusion\", color=WHITE)\n conclusion.to_edge(UP)\n \n # The main equation\n equation = MathText(r\"P(A|B) = \\frac{P(A \\cap B)}{P(B)}\")\n equation.scale(1.5)\n \n # Display Conclusion\n self.play(Write(conclusion))\n self.play(Write(equation))\n self.wait(2)\n \n # Final fade out\n self.play(FadeOut(conclusion), FadeOut(equation))\n \n # Final title\n final_title = Text(\"Predicting Storms with Conditional Probability\", color=WHITE)\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE, 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 topological changes occur when a 2-dimensional simplicial complex is embedded into a 3-dimensional space?", "chosen": "```python\nfrom manim import *\n\nclass SimplicialComplexAnimation(Scene):\n def construct(self):\n # Set background color similar to 3Blue1Brown style\n self.camera.background_color = \"#1F1F3F\"\n \n # Title\n title = Text(\"Exploring the 3D World of Simplicial Complexes\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple 2D simplicial complex - two connected triangles\n t1 = Polygon([-1, -1, 0], [1, -1, 0], [0, 1, 0], color=BLUE)\n t2 = Polygon([1, -1, 0], [2, 0, 0], [0, 1, 0], color=BLUE)\n \n complex_2d = VGroup(t1, t2)\n complex_2d.scale(0.8)\n complex_2d.move_to(LEFT * 3)\n \n label_2d = Text(\"2D Complex\", font_size=24)\n label_2d.next_to(complex_2d, DOWN)\n \n self.play(Create(complex_2d), Write(label_2d))\n self.wait(1)\n \n # Create a transformed version to represent the 3D embedding\n complex_3d = complex_2d.copy()\n complex_3d.move_to(RIGHT * 3)\n \n # Apply transformation to simulate 3D perspective\n matrix = [[0.8, 0.3, 0], [0.2, 0.9, 0], [0, 0, 1]]\n complex_3d.apply_matrix(matrix)\n \n # Add some shading to enhance 3D effect\n for triangle in complex_3d:\n triangle.set_fill(BLUE, opacity=0.7)\n \n label_3d = Text(\"3D Embedding\", font_size=24)\n label_3d.next_to(complex_3d, DOWN)\n \n arrow = Arrow(LEFT * 1, RIGHT * 1)\n \n self.play(\n Create(complex_3d),\n Write(label_3d),\n Create(arrow)\n )\n self.wait(1)\n \n # Highlight a topological feature\n hole = Circle(radius=0.3, color=YELLOW)\n hole.move_to(complex_3d[0].get_center())\n \n feature_text = Text(\"New topological features\", font_size=28)\n feature_text.move_to(DOWN * 2)\n \n self.play(Write(feature_text), Create(hole))\n self.wait(1)\n \n # Show Euler characteristic\n euler_eq = MathTex(r\"\\chi = V - E + F\", font_size=36)\n euler_eq.next_to(feature_text, DOWN)\n \n self.play(Write(euler_eq))\n self.wait(2)\n \n # Homology groups briefly\n self.play(FadeOut(euler_eq))\n homology_eq = MathTex(r\"H_0, H_1, H_2\", font_size=36)\n homology_eq.next_to(feature_text, DOWN)\n \n self.play(Write(homology_eq))\n self.wait(2)\n \n # Conclusion\n self.play(\n FadeOut(complex_2d),\n FadeOut(complex_3d),\n FadeOut(label_2d),\n FadeOut(label_3d),\n FadeOut(arrow),\n FadeOut(hole),\n FadeOut(feature_text),\n FadeOut(homology_eq),\n FadeOut(title)\n )\n \n conclusion = Text(\"Topological changes when embedding\\n2D simplicial complexes in 3D\", font_size=36)\n self.play(Write(conclusion))\n self.wait(2)\n self.play(FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\n\nclass SimplicialComplexAnimation(Scene):\n def construct(self):\n # Set background color similar to 3Blue1Brown style\n self.camera.background_color = \"#1F1F3F\"\n \n # Title\n title = Text(\"Exploring the 3D World of Simplicial Complexes\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Create a simple 2D simplicial complex - two connected triangles\n t1 = Polygon([-1, -1, 0], [1, -1, 0], [0, 1, 0], color=BBLUE)\n t2 = Polygon([1, -1, 0], [2, 0, 0], [0, 1, 0], color=BLUE)\n \n complex_2d = VGroup(t1, t2)\n complex_2d.scale(0.8)\n complex_2d.move_to(LEFT * 3)\n \n label_2d = Text(\"2D Complex\", font_size=24)\n label_2d.next_to(complex_2d, DOWN)\n \n self.play(Create(complex_2d), Write(label_2d))\n self.wait(1)\n \n # Create a transformed version to represent the 3D embedding\n complex_3d = complex_2d.copy()\n complex_3d.move_to(RIGHT * 3)\n \n # Apply transformation to simulate 3D perspective\n matrix = [[0.8, 0.3, 0], [0.2, 0.9, 0], [0, 0, 1]]\n complex_3d.apply_matrix(matrix)\n \n # Add some shading to enhance 3D effect\n for triangle in complex_3d:\n triangle.set_fill(BLUE, opacity=0.7)\n \n label_3d = Text(\"3D Embedding\", font_size=24)\n label_3d.next_to(complex_3d, DOWN)\n \n arrow = Arrow(LEFT * 1, RIGHT * 1)\n \n self.play(\n Create(complex_3d),\n Write(label_3d),\n Create(arrow)\n )\n self.wait(1)\n \n # Highlight a topological feature\n hole = Circle(radius=0.3, color=YELLOW)\n hole.move_to(complex_3d[0].get_center())\n \n feature_text = Text(\"New topological features\", font_size=28)\n feature_text.move_to(DOWN * 2)\n \n self.play(Write(feature_text), Create(hole))\n self.wait(1)\n \n # Show Euler characteristic\n euler_eq = MathTex(r\"\\chi = V - E + F\", font_size=36)\n euler_eq.next_to(feature_text, DOWN)\n \n self.play(Write(euler_eq))\n self.wait(2)\n \n # Homology groups briefly\n self.play(FadeOut(euler_eq))\n homology_eq = MathTex(r\"H_0, H_1, H_2\", font_size=36)\n homology_eq.next_to(feature_text, DOWN)\n \n self.play(Write(homology_eq))\n self.wait(2)\n \n # Conclusion\n self.play(\n FadeOut(complex_2d),\n FadeOut(complex_3d),\n FadeOut(label_2d),\n FadeOut(label_3d),\n FadeOut(arrow),\n FadeOut(hole),\n FadeOut(feature_text),\n FadeOut(homology_eq),\n FadeOut(title)\n )\n \n conclusion = Text(\"Topological changes when embedding\\n2D simplicial complexes in 3D\", font_size=36)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 *\nimport numpy as np\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BLUE, buff=0.25)\n m1 = VGroup(m1_text, m1_box).move_to(LEFT * 3.5 + UP * 1.5)\n gt1 = MathText('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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 to solve a double integral in polar coordinates. The specific problem should be the integral from 0 to pi with respect to theta and from 0 to 1 with respect to r of the function r dr dθ. The animation should start by showing the integral equation and then proceed step by step. First, show the integration with respect to r with appropriate text explaining that we are integrating r first. Then, display the result of this first integration before moving on to integrate with respect to theta, again with explanatory text. Lastly, present the final solution to the integral. Each step should be clearly written out and transitions between steps should give viewers enough time to follow along. Can you create an animation like that?", "chosen": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduction\n # Display the title and the full integral equation\n # ------------------------------------------------------------------\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n # Define the initial integral: \\int ₀^\\pi \\int ₀¹ r dr d\\theta \n # Splitting parts for color coding and clear transformations\n integral = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r\", \n r\"\\,dr\", \n r\"\\,d\\theta\",\n font_size=48\n )\n integral.next_to(title, DOWN, buff=1)\n \n # Color coding for clarity\n integral[2].set_color(BLUE) # r (integrand)\n integral[3].set_color(BLUE) # dr\n integral[4].set_color(GREEN) # d\\theta \n \n self.play(Write(title))\n self.play(Write(integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 2: First Integration (with respect to r)\n # ------------------------------------------------------------------\n step1_text = Text(\"Step 1: Integrate with respect to r\", font_size=30, color=BLUE)\n step1_text.next_to(integral, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Show the antiderivative of r -> r^2 / 2\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\left[ \\frac{r^2}{2} \\right]_{0}^{1}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n inner_antiderivative.next_to(title, DOWN, buff=1)\n inner_antiderivative[1].set_color(BLUE) # Highlight the evaluation part\n inner_antiderivative[2].set_color(GREEN)\n \n self.play(TransformMatchingTex(integral, inner_antiderivative))\n self.wait(1)\n \n # Evaluate the limits for r: (1^2/2) - (0^2/2) = 1/2\n inner_result = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\frac{1}{2}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n inner_result.next_to(title, DOWN, buff=1)\n inner_result[1].set_color(YELLOW) # Highlight the constant result\n inner_result[2].set_color(GREEN)\n \n explanation_eval = Text(\"Evaluate limits: r = 0 to 1\", font_size=24)\n explanation_eval.next_to(inner_antiderivative, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(inner_antiderivative, inner_result), Write(explanation_eval))\n self.wait(1)\n self.play(FadeOut(step1_text), FadeOut(explanation_eval))\n \n # ------------------------------------------------------------------\n # Step 3: Second Integration (with respect to \\theta )\n # ------------------------------------------------------------------\n step2_text = Text(\"Step 2: Integrate with respect to \\theta \", font_size=30, color=GREEN)\n step2_text.next_to(inner_result, DOWN, buff=0.5)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Show the antiderivative of 1/2 d\\theta -> \\theta /2\n outer_antiderivative = MathTex(\n r\"\\left[ \\frac{\\theta}{2} \\right]_{0}^{\\pi}\",\n font_size=48\n )\n outer_antiderivative.next_to(title, DOWN, buff=1)\n outer_antiderivative.set_color(GREEN)\n \n self.play(TransformMatchingTex(inner_result, outer_antiderivative))\n self.wait(1)\n \n # Evaluate the limits for \\theta : (\\pi /2) - (0/2) = \\pi /2\n final_solution = MathTex(\n r\"\\frac{\\pi}{2}\",\n font_size=60\n )\n final_solution.next_to(title, DOWN, buff=1)\n final_solution.set_color(GOLD)\n \n explanation_final = Text(\"Evaluate limits: \\theta = 0 to \\pi \", font_size=24)\n explanation_final.next_to(outer_antiderivative, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(outer_antiderivative, final_solution), Write(explanation_final))\n self.wait(1)\n self.play(FadeOut(step2_text), FadeOut(explanation_final))\n \n # ------------------------------------------------------------------\n # Step 4: Conclusion\n # Present the final numerical solution clearly\n # ------------------------------------------------------------------\n conclusion_box = SurroundingRectangle(final_solution, color=WHITE, buff=0.3)\n conclusion_text = Text(\"Final Solution\", font_size=30)\n conclusion_text.next_to(conclusion_box, DOWN, buff=0.2)\n \n self.play(Create(conclusion_box), Write(conclusion_text))\n self.wait(2)\n \n # Fade out everything for a clean finish\n self.play(FadeOut(title), FadeOut(final_solution), FadeOut(conclusion_box), FadeOut(conclusion_text))\n```", "rejected": "```python\nfrom manim import *\n\nclass DoubleIntegralPolar(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # Step 1: Introduction\n # Display the title and the full integral equation\n # ------------------------------------------------------------------\n title = Text(\"Double Integral in Polar Coordinates\", font_size=36)\n title.to_edge(UP)\n \n # Define the initial integral: \\int ₀^\\pi \\int ₀¹ r dr d\\theta \n # Splitting parts for color coding and clear transformations\n integral = MathText(\n r\"\\int_{0}^{\\pi}\", \n r\"\\int_{0}^{1}\", \n r\"r\", \n r\"\\,dr\", \n r\"\\,d\\theta\",\n font_size=48\n )\n integral.next_to(title, DOWN, buff=1)\n \n # Color coding for clarity\n integral[2].set_color(BLUE) # r (integrand)\n integral[3].set_color(BLUE) # dr\n integral[4].set_color(GREEN) # d\\theta \n \n self.play(Write(title))\n self.play(Write(integral))\n self.wait(1)\n \n # ------------------------------------------------------------------\n # Step 2: First Integration (with respect to r)\n # ------------------------------------------------------------------\n step1_text = Text(\"Step 1: Integrate with respect to r\", font_size=30, color=BLUE)\n step1_text.next_to(integral, DOWN, buff=0.5)\n \n self.play(Write(step1_text))\n self.wait(1)\n \n # Show the antiderivative of r -> r^2 / 2\n inner_antiderivative = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\left[ \\frac{r^2}{2} \\right]_{0}^{1}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n inner_antiderivative.next_to(title, DOWN, buff=1)\n inner_antiderivative[1].set_color(BLUE) # Highlight the evaluation part\n inner_antiderivative[2].set_color(GREEN)\n \n self.play(TransformMatchingTex(integral, inner_antiderivative))\n self.wait(1)\n \n # Evaluate the limits for r: (1^2/2) - (0^2/2) = 1/2\n inner_result = MathTex(\n r\"\\int_{0}^{\\pi}\", \n r\"\\frac{1}{2}\", \n r\"\\,d\\theta\",\n font_size=48\n )\n inner_result.next_to(title, DOWN, buff=1)\n inner_result[1].set_color(YELLOW) # Highlight the constant result\n inner_result[2].set_color(GREEN)\n \n explanation_eval = Text(\"Evaluate limits: r = 0 to 1\", font_size=24)\n explanation_eval.next_to(inner_antiderivative, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(inner_antiderivative, inner_result), Write(explanation_eval))\n self.wait(1)\n self.play(FadeOut(step1_text), FadeOut(explanation_eval))\n \n # ------------------------------------------------------------------\n # Step 3: Second Integration (with respect to \\theta )\n # ------------------------------------------------------------------\n step2_text = Text(\"Step 2: Integrate with respect to \\theta \", font_size=30, color=GREEN)\n step2_text.next_to(inner_result, DOWN, buff=0.5)\n \n self.play(Write(step2_text))\n self.wait(1)\n \n # Show the antiderivative of 1/2 d\\theta -> \\theta /2\n outer_antiderivative = MathTex(\n r\"\\left[ \\frac{\\theta}{2} \\right]_{0}^{\\pi}\",\n font_size=48\n )\n outer_antiderivative.next_to(title, DOWN, buff=1)\n outer_antiderivative.set_color(GREEN)\n \n self.play(TransformMatchingTex(inner_result, outer_antiderivative))\n self.wait(1)\n \n # Evaluate the limits for \\theta : (\\pi /2) - (0/2) = \\pi /2\n final_solution = MathTex(\n r\"\\frac{\\pi}{2}\",\n font_size=60\n )\n final_solution.next_to(title, DOWN, buff=1)\n final_solution.set_color(GOLD)\n \n explanation_final = Text(\"Evaluate limits: \\theta = 0 to \\pi \", font_size=24)\n explanation_final.next_to(outer_antiderivative, DOWN, buff=0.5)\n \n self.play(TransformMatchingTex(outer_antiderivative, final_solution), Write(explanation_final))\n self.wait(1)\n self.play(FadeOut(step2_text), FadeOut(explanation_final))\n \n # ------------------------------------------------------------------\n # Step 4: Conclusion\n # Present the final numerical solution clearly\n # ------------------------------------------------------------------\n conclusion_box = SurroundingRectangle(final_solution, color=WHITE, buff=0.3)\n conclusion_text = Text(\"Final Solution\", font_size=30)\n conclusion_text.next_to(conclusion_box, DOWN, buff=0.2)\n \n self.play(Create(conclusion_box), Write(conclusion_text))\n self.wait(2)\n \n # Fade out everything for a clean finish\n self.play(FadeOut(title), FadeOut(final_solution), FadeOut(conclusion_box), FadeOut(conclusion_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 does Gödel's incompleteness expose the limitations of mathematical models in representing reality?", "chosen": "```python\nfrom manim import *\n\nclass GodelIncompletenessScene(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Unveiling the Limits: Gödel's Incompleteness and Reality\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.5).to_edge(UP))\n \n # Introduction - Visualizing a library of mathematical models\n intro_text = Text(\"Imagine a vast library of mathematical models...\", font_size=24)\n intro_text.next_to(title, DOWN, buff=1)\n \n # Create a row of rectangles to represent books\n books = VGroup()\n for i in range(5):\n book = Rectangle(height=1.5, width=0.3, color=GREEN)\n book.shift(RIGHT * (i - 2) * 0.8)\n books.add(book)\n books.next_to(intro_text, DOWN, buff=0.5)\n \n self.play(Write(intro_text))\n self.play(Create(books))\n self.wait(1)\n self.play(FadeOut(intro_text), FadeOut(books))\n \n # Key Concept 1 - Visualizing incompleteness as a puzzle with missing pieces\n concept1_text = Text(\"Some truths cannot be proven within the system\", font_size=24)\n concept1_text.next_to(title, DOWN, buff=1)\n \n # Create a 3x3 grid of squares with the center piece missing\n puzzle = VGroup()\n for i in range(3):\n for j in range(3):\n if (i, j) != (1, 1): # Leave out the middle piece\n piece = Square(side_length=0.7, color=BLUE)\n piece.move_to([(j-1)*0.8, (1-i)*0.8, 0])\n puzzle.add(piece)\n \n # Create a red square to represent the \"unprovable truth\"\n missing_piece = Square(side_length=0.7, color=RED)\n missing_piece.set_fill(RED, opacity=0.5)\n missing_piece.move_to([0, 0, 0])\n missing_label = Text(\"Unprovable Truth\", font_size=16)\n missing_label.next_to(missing_piece, DOWN)\n \n # Show Einstein's equation as an example of a mathematical model\n # Using simple text to avoid latex issues\n equation1 = Text(\"E = mc^2\", font_size=32)\n equation1.next_to(puzzle, DOWN, buff=1)\n \n self.play(Write(concept1_text))\n self.play(Create(puzzle), Create(missing_piece), Write(missing_label))\n self.play(Write(equation1))\n self.wait(1)\n self.play(FadeOut(concept1_text), FadeOut(puzzle), \n FadeOut(missing_piece), FadeOut(missing_label), FadeOut(equation1))\n \n # Key Concept 2 - Gap between mathematical models and reality using a Venn diagram\n concept2_text = Text(\"Gap between mathematical models and reality\", font_size=24)\n concept2_text.next_to(title, DOWN, buff=1)\n \n # Create two circles to represent mathematical models and reality\n circle1 = Circle(radius=1.5, color=BLUE)\n circle1.set_fill(BLUE, opacity=0.3)\n circle2 = Circle(radius=1.5, color=GREEN)\n circle2.set_fill(GREEN, opacity=0.3)\n circle2.shift(RIGHT * 1.5)\n \n # Label the circles\n circle1_label = Text(\"Mathematical Models\", font_size=18)\n circle1_label.next_to(circle1, UP)\n \n circle2_label = Text(\"Reality\", font_size=18)\n circle2_label.next_to(circle2, UP)\n \n # Highlight the gap between the circles to represent Gödel's truths\n gap_highlight = Ellipse(width=1.0, height=0.8, color=RED)\n gap_highlight.set_fill(RED, opacity=0.5)\n gap_highlight.move_to([1.5, 0, 0])\n gap_label = Text(\"Gödel's Truths\", font_size=16)\n gap_label.next_to(gap_highlight, DOWN)\n \n self.play(Write(concept2_text))\n self.play(Create(circle1), Create(circle2))\n self.play(Write(circle1_label), Write(circle2_label))\n self.play(Create(gap_highlight), Write(gap_label))\n self.wait(1)\n \n # Key Concept 3 - Inherent limitations of all models\n concept3_text = Text(\"All models have inherent limitations\", font_size=24)\n concept3_text.next_to(title, DOWN, buff=1)\n \n # Show Newton's equation as another example of a mathematical model\n equation2 = Text(\"F = ma\", font_size=32)\n equation2.next_to(gap_label, DOWN, buff=1)\n \n # Use FadeOut and FadeIn instead of ReplacementTransform to avoid glitches\n self.play(FadeOut(concept2_text))\n self.play(FadeIn(concept3_text))\n self.play(Write(equation2))\n self.wait(1)\n \n # Conclusion - Reflecting on the limitations of mathematical models\n conclusion_text = Text(\"Mathematical models are just pieces of a larger puzzle\", font_size=24)\n conclusion_text.next_to(title, DOWN, buff=1)\n \n final_text = Text(\"Acknowledging limitations is as important as celebrating power\", font_size=18)\n final_text.to_edge(DOWN, buff=0.8)\n \n # Use FadeOut and FadeIn instead of ReplacementTransform\n self.play(FadeOut(concept3_text))\n self.play(FadeIn(conclusion_text))\n self.play(Write(final_text))\n self.wait(2)\n \n # Fade out all elements to end the animation\n self.play(FadeOut(VGroup(\n title, circle1, circle2, circle1_label, circle2_label, \n gap_highlight, gap_label, conclusion_text, final_text, equation2\n )))\n```", "rejected": "```python\nfrom manim import *\n\nclass GodelIncompletenessScene(Scene):\n def construct(self):\n # Title of the animation\n title = Text(\"Unveiling the Limits: Gödel's Incompleteness and Reality\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.scale(0.5).to_edge(UP))\n \n # Introduction - Visualizing a library of mathematical models\n intro_text = Text(\"Imagine a vast library of mathematical models...\", font_size=24)\n intro_text.next_to(title, DOWN, buff=1)\n \n # Create a row of rectangles to represent books\n books = VGroup()\n for i in range(5):\n book = Rectangle(height=1.5, width=0.3, color=GREEN)\n book.shift(RIGHT * (i - 2) * 0.8)\n books.add(book)\n books.next_to(intro_text, DOWN, buff=0.5)\n \n self.play(Write(intro_text))\n self.play(Create(books))\n self.wait(1)\n self.play(FadeOut(intro_text), FadeOut(books))\n \n # Key Concept 1 - Visualizing incompleteness as a puzzle with missing pieces\n concept1_text = Text(\"Some truths cannot be proven within the system\", font_size=24)\n concept1_text.next_to(title, DOWN, buff=1)\n \n # Create a 3x3 grid of squares with the center piece missing\n puzzle = VGroup()\n for i in range(3):\n for j in range(3):\n if (i, j) != (1, 1): # Leave out the middle piece\n piece = Square(side_length=0.7, color=BBLUE)\n piece.move_to([(j-1)*0.8, (1-i)*0.8, 0])\n puzzle.add(piece)\n \n # Create a red square to represent the \"unprovable truth\"\n missing_piece = Square(side_length=0.7, color=RED)\n missing_piece.set_fill(RED, opacity=0.5)\n missing_piece.move_to([0, 0, 0])\n missing_label = Text(\"Unprovable Truth\", font_size=16)\n missing_label.next_to(missing_piece, DOWN)\n \n # Show Einstein's equation as an example of a mathematical model\n # Using simple text to avoid latex issues\n equation1 = Text(\"E = mc^2\", font_size=32)\n equation1.next_to(puzzle, DOWN, buff=1)\n \n self.play(Write(concept1_text))\n self.play(Create(puzzle), Create(missing_piece), Write(missing_label))\n self.play(Write(equation1))\n self.wait(1)\n self.play(FadeOut(concept1_text), FadeOut(puzzle), \n FadeOut(missing_piece), FadeOut(missing_label), FadeOut(equation1))\n \n # Key Concept 2 - Gap between mathematical models and reality using a Venn diagram\n concept2_text = Text(\"Gap between mathematical models and reality\", font_size=24)\n concept2_text.next_to(title, DOWN, buff=1)\n \n # Create two circles to represent mathematical models and reality\n circle1 = Circle(radius=1.5, color=BLUE)\n circle1.set_fill(BLUE, opacity=0.3)\n circle2 = Circle(radius=1.5, color=GREEN)\n circle2.set_fill(GREEN, opacity=0.3)\n circle2.shift(RIGHT * 1.5)\n \n # Label the circles\n circle1_label = Text(\"Mathematical Models\", font_size=18)\n circle1_label.next_to(circle1, UP)\n \n circle2_label = Text(\"Reality\", font_size=18)\n circle2_label.next_to(circle2, UP)\n \n # Highlight the gap between the circles to represent Gödel's truths\n gap_highlight = Ellipse(width=1.0, height=0.8, color=RED)\n gap_highlight.set_fill(RED, opacity=0.5)\n gap_highlight.move_to([1.5, 0, 0])\n gap_label = Text(\"Gödel's Truths\", font_size=16)\n gap_label.next_to(gap_highlight, DOWN)\n \n self.play(Write(concept2_text))\n self.play(Create(circle1), Create(circle2))\n self.play(Write(circle1_label), Write(circle2_label))\n self.play(Create(gap_highlight), Write(gap_label))\n self.wait(1)\n \n # Key Concept 3 - Inherent limitations of all models\n concept3_text = Text(\"All models have inherent limitations\", font_size=24)\n concept3_text.next_to(title, DOWN, buff=1)\n \n # Show Newton's equation as another example of a mathematical model\n equation2 = Text(\"F = ma\", font_size=32)\n equation2.next_to(gap_label, DOWN, buff=1)\n \n # Use FadeOut and FadeIn instead of ReplacementTransform to avoid glitches\n self.play(FadeOut(concept2_text))\n self.play(FadeIn(concept3_text))\n self.play(Write(equation2))\n self.wait(1)\n \n # Conclusion - Reflecting on the limitations of mathematical models\n conclusion_text = Text(\"Mathematical models are just pieces of a larger puzzle\", font_size=24)\n conclusion_text.next_to(title, DOWN, buff=1)\n \n final_text = Text(\"Acknowledging limitations is as important as celebrating power\", font_size=18)\n final_text.to_edge(DOWN, buff=0.8)\n \n # Use FadeOut and FadeIn instead of ReplacementTransform\n self.play(FadeOut(concept3_text))\n self.play(FadeIn(conclusion_text))\n self.play(Write(final_text))\n self.wait(2)\n \n # Fade out all elements to end the animation\n self.play(FadeOut(VGroup(\n title, circle1, circle2, circle1_label, circle2_label, \n gap_highlight, gap_label, conclusion_text, final_text, equation2\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 3: Create an educational ManimCE animation on 'Cryptographic Key Exchange' (The Beauty Behind Cryptographic Key Efficiency): What graphical methods could be employed to compare the efficiency of elliptic curve cryptography ", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0794(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_frameboxscene()\n self.clear_stage()\n self.act_2_integralvisualization()\n self.clear_stage()\n self.act_3_cryptokeyefficiencyscene()\n\n def act_1_frameboxscene(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange texts vertically with spacing\n texts_group = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n self.play(Write(texts_group))\n self.wait(1)\n\n # 2. Step 1: Draw a blue rectangle around the first text\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n self.play(Create(rect1))\n\n # 3. Step 2: Pause briefly\n self.wait(0.5)\n\n # 4. Step 3: Replace the blue rectangle with a green rectangle around the second text\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n # ReplacementTransform cleanly morphs rect1 into rect2\n self.play(ReplacementTransform(rect1, rect2))\n\n # 5. Step 4: Pause briefly\n self.wait(0.5)\n\n # 6. Step 5: Draw a red rectangle around the third text\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n self.play(Create(rect3))\n\n # 7. Step 6: Animate the red rectangle moving upwards while tracking the text\n # Group text3 and rect3 to ensure they move perfectly in sync\n moving_group = VGroup(text3, rect3)\n \n self.play(\n moving_group.animate.shift(UP * 2), \n run_time=2, \n rate_func=smooth\n )\n\n # 8. End: Conclude the animation\n self.wait()\n\n def act_2_integralvisualization(self):\n func_title = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Plot Graph\n # Set up axes and plot the function for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True}\n )\n curve = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n \n self.play(Create(axes), Create(curve))\n self.wait(0.5)\n\n # 3. Highlight Area & Add Label\n # Define the area under the curve between x=0 and x=1\n area = axes.get_area(curve, x_range=[0, 1])\n \n # 4. Fill and Gradient\n # Apply a blue-to-green gradient with partial transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_opacity(0.5)\n \n # Add the integral notation label below the graph\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n \n self.play(FadeIn(area), Write(integral_label))\n self.wait(0.5)\n\n # 5. Calculate and Transform\n # Define the exact calculated value\n result_value = MathTex(r\"\\frac{1}{3}\")\n \n # Animate the transformation from the integral notation to the value\n self.play(ReplacementTransform(integral_label, result_value))\n \n # Move the solution to the bottom of the screen\n self.play(result_value.animate.to_edge(DOWN))\n self.wait(0.5)\n\n # 6. Final Display\n # Group all elements except the final solution\n elements_to_remove = VGroup(func_title, axes, curve, area)\n \n # Fade out everything else\n self.play(FadeOut(elements_to_remove))\n \n # Center the result for the final brief moment\n self.play(result_value.animate.move_to(ORIGIN))\n self.wait(2)\n\n def act_3_cryptokeyefficiencyscene(self):\n title = Text(\"The Beauty Behind Cryptographic Key Efficiency\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Show the question\n question = Text(\"How can we visually demonstrate the efficiency of ECC compared to RSA?\", \n font_size=24, color=BLUE)\n self.play(Write(question))\n self.wait(1)\n self.play(FadeOut(question))\n \n # Visualize RSA vs ECC key sizes with bars\n rsa_bar = Rectangle(height=4, width=1.5, color=RED, fill_opacity=0.8).move_to(LEFT * 2)\n rsa_label = Text(\"RSA\\n2048 bits\", font_size=24).next_to(rsa_bar, DOWN)\n \n ecc_bar = Rectangle(height=0.5, width=1.5, color=BLUE, fill_opacity=0.8).move_to(RIGHT * 2)\n ecc_label = Text(\"ECC\\n256 bits\", font_size=24).next_to(ecc_bar, DOWN)\n \n self.play(Create(rsa_bar), Write(rsa_label))\n self.wait(0.5)\n self.play(Create(ecc_bar), Write(ecc_label))\n self.wait(1)\n \n # Simple equation showing the security levels\n rsa_equation = Text(\"RSA Security Level = 2048 bits\", font_size=24)\n ecc_equation = Text(\"ECC Security Level = 256 bits\", font_size=24)\n equations = VGroup(rsa_equation, ecc_equation).arrange(DOWN, buff=0.5)\n \n self.play(FadeOut(rsa_bar), FadeOut(rsa_label), FadeOut(ecc_bar), FadeOut(ecc_label))\n self.play(Write(equations))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"ECC: Doing more with less\", font_size=36, color=GREEN)\n self.play(FadeOut(equations))\n self.play(Write(conclusion))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0794(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_frameboxscene()\n self.clear_stage()\n self.act_2_integralvisualization()\n self.clear_stage()\n self.act_3_cryptokeyefficiencyscene()\n\n def act_1_frameboxscene(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange texts vertically with spacing\n texts_group = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n self.play(Write(texts_group))\n self.wait(1)\n\n # 2. Step 1: Draw a blue rectangle around the first text\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n self.play(Create(rect1))\n\n # 3. Step 2: Pause briefly\n self.wait(0.5)\n\n # 4. Step 3: Replace the blue rectangle with a green rectangle around the second text\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n # ReplacementTransform cleanly morphs rect1 into rect2\n self.play(ReplacementTransform(rect1, rect2))\n\n # 5. Step 4: Pause briefly\n self.wait(0.5)\n\n # 6. Step 5: Draw a red rectangle around the third text\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n self.play(Create(rect3))\n\n # 7. Step 6: Animate the red rectangle moving upwards while tracking the text\n # Group text3 and rect3 to ensure they move perfectly in sync\n moving_group = VGroup(text3, rect3)\n \n self.play(\n moving_group.animate.shift(UP * 2), \n run_time=2, \n rate_func=smooth\n )\n\n # 8. End: Conclude the animation\n self.wait()\n\n def act_2_integralvisualization(self):\n func_title = MathText(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_title))\n self.wait(0.5)\n\n # 2. Plot Graph\n # Set up axes and plot the function for x in [-2, 2]\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-0.5, 5, 1],\n axis_config={\"include_tip\": True}\n )\n curve = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n \n self.play(Create(axes), Create(curve))\n self.wait(0.5)\n\n # 3. Highlight Area & Add Label\n # Define the area under the curve between x=0 and x=1\n area = axes.get_area(curve, x_range=[0, 1])\n \n # 4. Fill and Gradient\n # Apply a blue-to-green gradient with partial transparency\n area.set_color_by_gradient(BLUE, GREEN)\n area.set_opacity(0.5)\n \n # Add the integral notation label below the graph\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN, buff=0.5)\n \n self.play(FadeIn(area), Write(integral_label))\n self.wait(0.5)\n\n # 5. Calculate and Transform\n # Define the exact calculated value\n result_value = MathTex(r\"\\frac{1}{3}\")\n \n # Animate the transformation from the integral notation to the value\n self.play(ReplacementTransform(integral_label, result_value))\n \n # Move the solution to the bottom of the screen\n self.play(result_value.animate.to_edge(DOWN))\n self.wait(0.5)\n\n # 6. Final Display\n # Group all elements except the final solution\n elements_to_remove = VGroup(func_title, axes, curve, area)\n \n # Fade out everything else\n self.play(FadeOut(elements_to_remove))\n \n # Center the result for the final brief moment\n self.play(result_value.animate.move_to(ORIGIN))\n self.wait(2)\n\n def act_3_cryptokeyefficiencyscene(self):\n title = Text(\"The Beauty Behind Cryptographic Key Efficiency\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Show the question\n question = Text(\"How can we visually demonstrate the efficiency of ECC compared to RSA?\", \n font_size=24, color=BLUE)\n self.play(Write(question))\n self.wait(1)\n self.play(FadeOut(question))\n \n # Visualize RSA vs ECC key sizes with bars\n rsa_bar = Rectangle(height=4, width=1.5, color=RED, fill_opacity=0.8).move_to(LEFT * 2)\n rsa_label = Text(\"RSA\\n2048 bits\", font_size=24).next_to(rsa_bar, DOWN)\n \n ecc_bar = Rectangle(height=0.5, width=1.5, color=BLUE, fill_opacity=0.8).move_to(RIGHT * 2)\n ecc_label = Text(\"ECC\\n256 bits\", font_size=24).next_to(ecc_bar, DOWN)\n \n self.play(Create(rsa_bar), Write(rsa_label))\n self.wait(0.5)\n self.play(Create(ecc_bar), Write(ecc_label))\n self.wait(1)\n \n # Simple equation showing the security levels\n rsa_equation = Text(\"RSA Security Level = 2048 bits\", font_size=24)\n ecc_equation = Text(\"ECC Security Level = 256 bits\", font_size=24)\n equations = VGroup(rsa_equation, ecc_equation).arrange(DOWN, buff=0.5)\n \n self.play(FadeOut(rsa_bar), FadeOut(rsa_label), FadeOut(ecc_bar), FadeOut(ecc_label))\n self.play(Write(equations))\n self.wait(1)\n \n # Conclusion\n conclusion = Text(\"ECC: Doing more with less\", font_size=36, color=GREEN)\n self.play(FadeOut(equations))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 please create an educational animation that visually explains how to calculate the area under the curve of the function f(x) = x^2 from x=1 to x=3 by showing the integral on screen, performing the integration step by step, and displaying the final answer, along with explanatory text at each step of the process?", "chosen": "```python\nfrom manim import *\n\nclass FourierSeriesExample(Scene):\n def construct(self):\n # Displaying the function\n function_text = MathTex(r\"f(x) = x^2\", font_size=36)\n self.play(Write(function_text))\n self.wait(1)\n\n # Explanation for Fourier series decomposition\n explanation1 = Text(\"Decompose using Fourier series:\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Fourier series formula\n fourier_series = MathTex(r\"f(x) \\sim a_0 + \\sum_{n=1}^\\infty \\left( a_n\\cos(2\\pi nx) + b_n\\sin(2\\pi nx) \\right)\")\n self.play(Transform(function_text, fourier_series))\n self.wait(3)\n\n # Explanation for calculating coefficients\n explanation2 = Text(\"Calculate coefficients a_n and b_n\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Coefficients for a specific n\n coefficients = MathTex(r\"a_n = ???\", r\"\\quad\", r\"b_n = ???\", font_size=36)\n self.play(Write(coefficients))\n self.wait(3)\n\n # First few terms of the series\n first_terms = MathTex(r\"f(x) \\sim a_0 + a_1\\cos(2\\pi x) + b_1\\sin(2\\pi x) + \\ldots\", font_size=36)\n self.play(ReplacementTransform(fourier_series, first_terms))\n self.wait(2)\n\n # Explanation for approximation\n explanation3 = Text(\"This is an approximation for the Fourier series\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation3))\n self.wait(2)\n\n # Clear scene and display a graph\n self.clear()\n self.wait(1)\n\n # Graph of the function\n graph_axes = Axes(x_range=[-3, 3], y_range=[-1, 9])\n graph = graph_axes.plot(lambda x: x**2, color=WHITE)\n graph_label = graph_axes.get_graph_label(graph, label='x^2')\n\n # Display the graph\n self.play(Create(graph_axes), Create(graph), Write(graph_label))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass FourierSeriesExample(Scene):\n def construct(self):\n # Displaying the function\n function_text = MathText(r\"f(x) = x^2\", font_size=36)\n self.play(Write(function_text))\n self.wait(1)\n\n # Explanation for Fourier series decomposition\n explanation1 = Text(\"Decompose using Fourier series:\", font_size=24).to_edge(UP)\n self.play(Write(explanation1))\n self.wait(2)\n\n # Fourier series formula\n fourier_series = MathTex(r\"f(x) \\sim a_0 + \\sum_{n=1}^\\infty \\left( a_n\\cos(2\\pi nx) + b_n\\sin(2\\pi nx) \\right)\")\n self.play(Transform(function_text, fourier_series))\n self.wait(3)\n\n # Explanation for calculating coefficients\n explanation2 = Text(\"Calculate coefficients a_n and b_n\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation2))\n self.wait(2)\n\n # Coefficients for a specific n\n coefficients = MathTex(r\"a_n = ???\", r\"\\quad\", r\"b_n = ???\", font_size=36)\n self.play(Write(coefficients))\n self.wait(3)\n\n # First few terms of the series\n first_terms = MathTex(r\"f(x) \\sim a_0 + a_1\\cos(2\\pi x) + b_1\\sin(2\\pi x) + \\ldots\", font_size=36)\n self.play(ReplacementTransform(fourier_series, first_terms))\n self.wait(2)\n\n # Explanation for approximation\n explanation3 = Text(\"This is an approximation for the Fourier series\", font_size=24).to_edge(UP)\n self.play(Transform(explanation1, explanation3))\n self.wait(2)\n\n # Clear scene and display a graph\n self.clear()\n self.wait(1)\n\n # Graph of the function\n graph_axes = Axes(x_range=[-3, 3], y_range=[-1, 9])\n graph = graph_axes.plot(lambda x: x**2, color=WHITE)\n graph_label = graph_axes.get_graph_label(graph, label='x^2')\n\n # Display the graph\n self.play(Create(graph_axes), Create(graph), Write(graph_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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. Function Display ---\n # Write the function f(x) = x^2 at the top of the screen\n func_text = MathTex(r\"f(x) = x^2\", font_size=48)\n func_text.to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Graph Plotting ---\n # Create axes accommodating x in [-2, 2] and y up to 4\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n )\n \n # Plot the function x^2 within the specified domain\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n self.play(Create(axes), Write(axis_labels), Create(graph))\n self.wait(1)\n\n # --- 3 & 5. Area Indication with Gradient Fill ---\n # Highlight the area under the curve between x=0 and x=1\n # Fill with a gradient from blue to green with partial transparency\n area = axes.get_area(graph, x_range=[0, 1])\n area.set_fill(color=[BLUE, GREEN], opacity=0.5)\n area.set_stroke(width=0) # Remove border for a cleaner gradient look\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 4. Labeling ---\n # Add the integral label below the graph\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\", font_size=36)\n integral_label.next_to(axes, DOWN, buff=0.5)\n self.play(Write(integral_label))\n self.wait(1)\n\n # --- 6. Value Transformation ---\n # Transform the integral expression into the calculated value (1/3)\n result_value = MathTex(r\"\\frac{1}{3}\", font_size=36)\n result_value.move_to(integral_label)\n \n self.play(ReplacementTransform(integral_label, result_value))\n \n # Move the solution to the bottom of the screen\n self.play(result_value.animate.to_edge(DOWN, buff=1))\n self.wait(1)\n\n # --- 7. Final Scene ---\n # Clear the screen and display only the final solution\n everything_else = VGroup(func_text, axes, axis_labels, graph, area)\n self.play(FadeOut(everything_else))\n \n # Center the final solution for emphasis\n self.play(result_value.animate.move_to(ORIGIN).scale(2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralAnimation(Scene):\n def construct(self):\n # --- 1. Function Display ---\n # Write the function f(x) = x^2 at the top of the screen\n func_text = MathTex(r\"f(x) = x^2\", font_size=48)\n func_text.to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # --- 2. Graph Plotting ---\n # Create axes accommodating x in [-2, 2] and y up to 4\n axes = Axes(label_font_size=24, \n x_range=[-2.5, 2.5, 1],\n y_range=[-0.5, 4.5, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [-2, -1, 1, 2]},\n y_axis_config={\"numbers_to_include\": [1, 2, 3, 4]},\n )\n \n # Plot the function x^2 within the specified domain\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n axis_labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n self.play(Create(axes), Write(axis_labels), Create(graph))\n self.wait(1)\n\n # --- 3 & 5. Area Indication with Gradient Fill ---\n # Highlight the area under the curve between x=0 and x=1\n # Fill with a gradient from blue to green with partial transparency\n area = axes.get_area(graph, x_range=[0, 1])\n area.set_fill(color=[BLUE, GREEN], opacity=0.5)\n area.set_stroke(width=0) # Remove border for a cleaner gradient look\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # --- 4. Labeling ---\n # Add the integral label below the graph\n integral_label = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\", font_size=36)\n integral_label.next_to(axes, DOWN, buff=0.5)\n self.play(Write(integral_label))\n self.wait(1)\n\n # --- 6. Value Transformation ---\n # Transform the integral expression into the calculated value (1/3)\n result_value = MathTex(r\"\\frac{1}{3}\", font_size=36)\n result_value.move_to(integral_label)\n \n self.play(ReplacementTransform(integral_label, result_value))\n \n # Move the solution to the bottom of the screen\n self.play(result_value.animate.to_edge(DOWN, buff=1))\n self.wait(1)\n\n # --- 7. Final Scene ---\n # Clear the screen and display only the final solution\n everything_else = VGroup(func_text, axes, axis_labels, graph, area)\n self.play(FadeOut(everything_else))\n \n # Center the final solution for emphasis\n self.play(result_value.animate.move_to(ORIGIN).scale(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 visual representations of the polar integration process and step-by-step explanations:\n\nThe animation begins by displaying the double integral problem in polar coordinates, with the equation appearing smoothly via Write(). As the inner integral explanation text appears at the top, a polar grid (Axes) fades in behind the equation, with a highlighted sector (AnnularSector) animating to show the region of integration (0≤r≤1). When transforming to the inner integral solution, the r² term pulses to draw attention while the polar grid's radial lines animate to demonstrate the integration along r. For the outer integral phase, the explanation text updates and the polar grid's circular lines animate to visualize integration along θ, with the sector sweeping through 2π radians. The final solution appears with a surrounding circle (Circle) that morphs into the area value text, while simultaneously the numerical result (2π/3) appears below with its decimal approximation (≈2.094). Throughout, color coding (red for r-integration, blue for θ-integration) maintains visual consistency, and subtle arrows highlight which part of the equation is being addressed at each step, creating a comprehensive visual explanation of polar double integration.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # Colors\n R_COLOR = RED\n THETA_COLOR = BLUE\n HIGHLIGHT_COLOR = YELLOW\n\n # Equation setup\n equation = MathTex(\n r\"\\int_0^{2\\pi} \\int_0^1 r^2 \\, dr \\, d\\theta\",\n font_size=48\n )\n equation.to_edge(UP)\n\n # Explanation texts\n inner_explanation = Text(\n \"Inner Integral: Integrate r^2 with respect to r from 0 to 1\",\n font_size=24,\n color=R_COLOR\n )\n inner_explanation.next_to(equation, DOWN, buff=0.5)\n\n outer_explanation = Text(\n \"Outer Integral: Integrate result with respect to \\theta from 0 to 2\\pi \",\n font_size=24,\n color=THETA_COLOR\n )\n\n # Polar grid\n polar_axes = PolarPlane(\n radius_max=1.5,\n azimuth_units=\"PI radians\",\n size=6,\n azimuth_label_font_size=24\n )\n polar_axes.shift(DOWN * 0.5)\n\n # Integration region\n sector = AnnularSector(\n inner_radius=0,\n outer_radius=1,\n angle=2*PI,\n start_angle=0,\n fill_color=BLUE_E,\n fill_opacity=0.3,\n stroke_width=0\n )\n sector.move_to(polar_axes.get_origin())\n\n # Solution parts\n inner_solution = MathTex(\n r\"\\int_0^{2\\pi} \\left[ \\frac{r^3}{3} \\right]_0^1 d\\theta\",\n font_size=48\n )\n inner_solution.move_to(equation)\n\n evaluated_inner = MathTex(\n r\"\\int_0^{2\\pi} \\frac{1}{3} d\\theta\",\n font_size=48\n )\n evaluated_inner.move_to(equation)\n\n final_solution = MathTex(\n r\"\\left[ \\frac{\\theta}{3} \\right]_0^{2\\pi} = \\frac{2\\pi}{3}\",\n font_size=48\n )\n final_solution.move_to(equation)\n\n numerical_result = MathTex(\n r\"\\approx 2.094\",\n font_size=36,\n color=GREEN\n )\n numerical_result.next_to(final_solution, DOWN, buff=0.3)\n\n # Animation arrows\n inner_arrow = Arrow(\n inner_explanation.get_top(),\n equation[0][4:7].get_bottom(),\n color=R_COLOR,\n buff=0.1\n )\n outer_arrow = Arrow(\n outer_explanation.get_top(),\n equation[0][0:3].get_bottom(),\n color=THETA_COLOR,\n buff=0.1\n )\n\n # Animation sequence\n self.play(Write(equation))\n self.wait()\n\n # Inner integral explanation\n self.play(\n Write(inner_explanation),\n FadeIn(polar_axes),\n Create(sector)\n )\n self.play(Create(inner_arrow))\n self.wait()\n\n # Highlight r^2 term\n r_squared = equation[0][4:7]\n self.play(\n r_squared.animate.set_color(HIGHLIGHT_COLOR),\n Flash(r_squared, color=HIGHLIGHT_COLOR)\n )\n self.wait()\n\n # Show integration along r\n for r in np.linspace(0, 1, 10):\n radius_line = Line(\n polar_axes.get_origin(),\n polar_axes.polar_to_point(r, 0),\n color=R_COLOR,\n stroke_width=4\n )\n self.play(\n Create(radius_line),\n run_time=0.1\n )\n self.remove(radius_line)\n\n # Transform to inner solution\n self.play(\n TransformMatchingTex(equation, inner_solution),\n FadeOut(inner_arrow)\n )\n self.wait()\n\n # Evaluate inner integral\n self.play(TransformMatchingTex(inner_solution, evaluated_inner))\n self.wait()\n\n # Outer integral explanation\n outer_explanation.move_to(inner_explanation)\n self.play(\n ReplacementTransform(inner_explanation, outer_explanation),\n Create(outer_arrow)\n )\n self.wait()\n\n # Show integration along \\theta \n for theta in np.linspace(0, 2*PI, 20):\n angle_line = Line(\n polar_axes.get_origin(),\n polar_axes.polar_to_point(1, theta),\n color=THETA_COLOR,\n stroke_width=4\n )\n self.play(\n Create(angle_line),\n run_time=0.1\n )\n self.remove(angle_line)\n\n # Evaluate outer integral\n self.play(\n TransformMatchingTex(evaluated_inner, final_solution),\n FadeOut(outer_arrow),\n FadeOut(outer_explanation)\n )\n self.wait()\n\n # Show numerical result\n self.play(Write(numerical_result))\n \n # Final highlight\n circle = Circle(radius=0.5, color=GREEN)\n circle.move_to(final_solution)\n self.play(\n Create(circle),\n final_solution.animate.set_color(GREEN)\n )\n self.play(FadeOut(circle))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass PolarDoubleIntegral(Scene):\n def construct(self):\n # Colors\n R_COLOR = RED\n THETA_COLOR = BBLUE\n HIGHLIGHT_COLOR = YELLOW\n\n # Equation setup\n equation = MathTex(\n r\"\\int_0^{2\\pi} \\int_0^1 r^2 \\, dr \\, d\\theta\",\n font_size=48\n )\n equation.to_edge(UP)\n\n # Explanation texts\n inner_explanation = Text(\n \"Inner Integral: Integrate r^2 with respect to r from 0 to 1\",\n font_size=24,\n color=R_COLOR\n )\n inner_explanation.next_to(equation, DOWN, buff=0.5)\n\n outer_explanation = Text(\n \"Outer Integral: Integrate result with respect to \\theta from 0 to 2\\pi \",\n font_size=24,\n color=THETA_COLOR\n )\n\n # Polar grid\n polar_axes = PolarPlane(\n radius_max=1.5,\n azimuth_units=\"PI radians\",\n size=6,\n azimuth_label_font_size=24\n )\n polar_axes.shift(DOWN * 0.5)\n\n # Integration region\n sector = AnnularSector(\n inner_radius=0,\n outer_radius=1,\n angle=2*PI,\n start_angle=0,\n fill_color=BLUE_E,\n fill_opacity=0.3,\n stroke_width=0\n )\n sector.move_to(polar_axes.get_origin())\n\n # Solution parts\n inner_solution = MathTex(\n r\"\\int_0^{2\\pi} \\left[ \\frac{r^3}{3} \\right]_0^1 d\\theta\",\n font_size=48\n )\n inner_solution.move_to(equation)\n\n evaluated_inner = MathTex(\n r\"\\int_0^{2\\pi} \\frac{1}{3} d\\theta\",\n font_size=48\n )\n evaluated_inner.move_to(equation)\n\n final_solution = MathTex(\n r\"\\left[ \\frac{\\theta}{3} \\right]_0^{2\\pi} = \\frac{2\\pi}{3}\",\n font_size=48\n )\n final_solution.move_to(equation)\n\n numerical_result = MathTex(\n r\"\\approx 2.094\",\n font_size=36,\n color=GREEN\n )\n numerical_result.next_to(final_solution, DOWN, buff=0.3)\n\n # Animation arrows\n inner_arrow = Arrow(\n inner_explanation.get_top(),\n equation[0][4:7].get_bottom(),\n color=R_COLOR,\n buff=0.1\n )\n outer_arrow = Arrow(\n outer_explanation.get_top(),\n equation[0][0:3].get_bottom(),\n color=THETA_COLOR,\n buff=0.1\n )\n\n # Animation sequence\n self.play(Write(equation))\n self.wait()\n\n # Inner integral explanation\n self.play(\n Write(inner_explanation),\n FadeIn(polar_axes),\n Create(sector)\n )\n self.play(Create(inner_arrow))\n self.wait()\n\n # Highlight r^2 term\n r_squared = equation[0][4:7]\n self.play(\n r_squared.animate.set_color(HIGHLIGHT_COLOR),\n Flash(r_squared, color=HIGHLIGHT_COLOR)\n )\n self.wait()\n\n # Show integration along r\n for r in np.linspace(0, 1, 10):\n radius_line = Line(\n polar_axes.get_origin(),\n polar_axes.polar_to_point(r, 0),\n color=R_COLOR,\n stroke_width=4\n )\n self.play(\n Create(radius_line),\n run_time=0.1\n )\n self.remove(radius_line)\n\n # Transform to inner solution\n self.play(\n TransformMatchingTex(equation, inner_solution),\n FadeOut(inner_arrow)\n )\n self.wait()\n\n # Evaluate inner integral\n self.play(TransformMatchingTex(inner_solution, evaluated_inner))\n self.wait()\n\n # Outer integral explanation\n outer_explanation.move_to(inner_explanation)\n self.play(\n ReplacementTransform(inner_explanation, outer_explanation),\n Create(outer_arrow)\n )\n self.wait()\n\n # Show integration along \\theta \n for theta in np.linspace(0, 2*PI, 20):\n angle_line = Line(\n polar_axes.get_origin(),\n polar_axes.polar_to_point(1, theta),\n color=THETA_COLOR,\n stroke_width=4\n )\n self.play(\n Create(angle_line),\n run_time=0.1\n )\n self.remove(angle_line)\n\n # Evaluate outer integral\n self.play(\n TransformMatchingTex(evaluated_inner, final_solution),\n FadeOut(outer_arrow),\n FadeOut(outer_explanation)\n )\n self.wait()\n\n # Show numerical result\n self.play(Write(numerical_result))\n \n # Final highlight\n circle = Circle(radius=0.5, color=GREEN)\n circle.move_to(final_solution)\n self.play(\n Create(circle),\n final_solution.animate.set_color(GREEN)\n )\n self.play(FadeOut(circle))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 where first, a hydrogen ion (a red circle labeled H+) fades in, moves upwards, and then fades out. After that, show a blue electron (a small blue circle labeled e-) moving along a squared path, going through each corner and then reversing back to the start with a pause in the middle of the movement.", "chosen": "```python\nfrom manim import *\n\nclass IonElectronScene(Scene):\n def construct(self):\n # ==========================================\n # 1. Hydrogen Ion Sequence\n # ==========================================\n # Create a red circle for the Hydrogen ion\n h_ion_circle = Circle(radius=0.5, color=RED, fill_opacity=0.8)\n \n # Create the label using MathTex for scientific accuracy\n h_label = MathTex(\"H^+\", font_size=36, color=WHITE)\n h_label.move_to(h_ion_circle.get_center())\n \n # Group the circle and label to animate them together\n h_ion = VGroup(h_ion_circle, h_label)\n h_ion.move_to(ORIGIN)\n \n # Fade in the ion\n self.play(FadeIn(h_ion))\n self.wait(0.5)\n \n # Move the ion upwards\n self.play(h_ion.animate.shift(UP * 3), run_time=1.5)\n self.wait(0.5)\n \n # Fade the ion out\n self.play(FadeOut(h_ion))\n self.wait(0.5)\n \n # ==========================================\n # 2. Electron Sequence\n # ==========================================\n # Create a small blue circle for the electron\n e_circle = Circle(radius=0.25, color=BLUE, fill_opacity=0.9)\n \n # Create the label\n e_label = MathTex(\"e^-\", font_size=24, color=WHITE)\n e_label.move_to(e_circle.get_center())\n \n # Group the circle and label\n electron = VGroup(e_circle, e_label)\n \n # Define the square path vertices\n square_path = Square(side_length=4).shift(DOWN * 1.5)\n vertices = square_path.get_vertices()\n v0, v1, v2, v3 = vertices\n \n # Position electron at the starting corner (v0)\n electron.move_to(v0)\n self.play(FadeIn(electron))\n \n # Define path segments to allow for a pause at the midpoint\n # Outward Journey Part 1: v0 -> v1 -> v2 (Visits first intermediate corners)\n path_out_1 = VMobject().set_points_as_corners([v0, v1, v2])\n \n # Outward Journey Part 2: v2 -> v3 (Visits final corner)\n path_out_2 = VMobject().set_points_as_corners([v2, v3])\n \n # Return Journey: v3 -> v2 -> v1 -> v0 (Reverse path to start)\n path_back = VMobject().set_points_as_corners([v3, v2, v1, v0])\n \n # Animate Outward Part 1\n self.play(MoveAlongPath(electron, path_out_1, rate_func=linear), run_time=2)\n \n # Pause at the midpoint (Corner v2)\n self.wait(1)\n \n # Animate Outward Part 2 (Complete visiting all corners)\n self.play(MoveAlongPath(electron, path_out_2, rate_func=linear), run_time=1)\n \n # Reverse the path to return to the starting position\n self.play(MoveAlongPath(electron, path_back, rate_func=linear), run_time=3)\n \n # Final hold and fade out\n self.wait(1)\n self.play(FadeOut(electron))\n```", "rejected": "```python\nfrom manim import *\n\nclass IonElectronScene(Scene):\n def construct(self):\n # ==========================================\n # 1. Hydrogen Ion Sequence\n # ==========================================\n # Create a red circle for the Hydrogen ion\n h_ion_circle = Circle(radius=0.5, color=RED, fill_opacity=0.8)\n \n # Create the label using MathTex for scientific accuracy\n h_label = MathTex(\"H^+\", font_size=36, color=WHITE)\n h_label.move_to(h_ion_circle.get_center())\n \n # Group the circle and label to animate them together\n h_ion = VGroup(h_ion_circle, h_label)\n h_ion.move_to(ORIGIN)\n \n # Fade in the ion\n self.play(FadeIn(h_ion))\n self.wait(0.5)\n \n # Move the ion upwards\n self.play(h_ion.animate.shift(UP * 3), run_time=1.5)\n self.wait(0.5)\n \n # Fade the ion out\n self.play(FadeOut(h_ion))\n self.wait(0.5)\n \n # ==========================================\n # 2. Electron Sequence\n # ==========================================\n # Create a small blue circle for the electron\n e_circle = Circle(radius=0.25, color=BLUE, fill_opacity=0.9)\n \n # Create the label\n e_label = MathTex(\"e^-\", font_size=24, color=WHITE)\n e_label.move_to(e_circle.get_center())\n \n # Group the circle and label\n electron = VGroup(e_circle, e_label)\n \n # Define the square path vertices\n square_path = Square(side_length=4).shift(DOWN * 1.5)\n vertices = square_path.get_vertices()\n v0, v1, v2, v3 = vertices\n \n # Position electron at the starting corner (v0)\n electron.move_to(v0)\n self.play(FadeIn(electron))\n \n # Define path segments to allow for a pause at the midpoint\n # Outward Journey Part 1: v0 -> v1 -> v2 (Visits first intermediate corners)\n path_out_1 = VMob().set_points_as_corners([v0, v1, v2])\n \n # Outward Journey Part 2: v2 -> v3 (Visits final corner)\n path_out_2 = VMobject().set_points_as_corners([v2, v3])\n \n # Return Journey: v3 -> v2 -> v1 -> v0 (Reverse path to start)\n path_back = VMobject().set_points_as_corners([v3, v2, v1, v0])\n \n # Animate Outward Part 1\n self.play(MoveAlongPath(electron, path_out_1, rate_func=linear), run_time=2)\n \n # Pause at the midpoint (Corner v2)\n self.wait(1)\n \n # Animate Outward Part 2 (Complete visiting all corners)\n self.play(MoveAlongPath(electron, path_out_2, rate_func=linear), run_time=1)\n \n # Reverse the path to return to the starting position\n self.play(MoveAlongPath(electron, path_back, rate_func=linear), run_time=3)\n \n # Final hold and fade out\n self.wait(1)\n self.play(FadeOut(electron))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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# Data Warehouse\n\nThis chapter delves into the core concepts and architecture of data warehouses, focusing on the theory and practical methods of dimensional modeling, and elaborately explaining the design and implementation of ETL processes, aiming to help learners build a comprehensive knowledge system of data warehouses.\n\n\n## Course Objectives\n### Understanding the Basic Concepts and Architecture of Data Warehouses\nBe able to accurately articulate the definition of a data warehouse, its four key features, and its differences from traditional operational databases (OLTP), and understand the positioning and layered architecture of data warehouses in enterprise decision support systems.", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DataWarehouseLecture(Scene):\n\n def construct(self):\n self.show_title_and_intro()\n self.clear_scene()\n self.show_course_objectives()\n\n def show_title_and_intro(self):\n title = Text('Data Warehouse', font_size=64, weight=BOLD)\n title.set_color_by_gradient(BLUE, TEAL)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP, buff=1.0))\n intro_lines = VGroup(Text('This chapter delves into:', font_size=36, color=WHITE, weight=BOLD), Text('• Core concepts and architecture of data warehouses', font_size=32, t2c={'Core concepts': YELLOW, 'architecture': YELLOW}), Text('• Theory and practical methods of dimensional modeling', font_size=32, t2c={'dimensional modeling': YELLOW}), Text('• Design and implementation of ETL processes', font_size=32, t2c={'ETL processes': YELLOW}), Text('• Building a comprehensive knowledge system', font_size=32, t2c={'knowledge system': YELLOW}))\n intro_lines.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n intro_lines.next_to(title, DOWN, buff=1.0)\n self.play(FadeIn(intro_lines[0], shift=DOWN))\n for i in range(1, len(intro_lines)):\n self.play(FadeIn(intro_lines[i], shift=RIGHT), run_time=0.6)\n else:\n pass\n self.wait(3)\n\n def clear_scene(self):\n self.play(FadeOut(Group(*self.mobjects)))\n self.wait(0.5)\n\n def show_course_objectives(self):\n section_title = Text('Course Objectives', font_size=54, weight=BOLD, color=BLUE)\n section_title.to_edge(UP, buff=0.8)\n self.play(Write(section_title))\n subsection = Text('Understanding Basic Concepts and Architecture', font_size=36, color=TEAL)\n subsection.next_to(section_title, DOWN, buff=0.5)\n self.play(FadeIn(subsection, shift=UP))\n self.wait(0.5)\n objectives = VGroup(Text('1. Articulate the definition of a Data Warehouse', font_size=28, t2c={'definition': YELLOW}), Text('2. Identify the Four Key Features of a data warehouse', font_size=28, t2c={'Four Key Features': YELLOW}), Text('3. Differentiate from traditional operational databases (OLTP)', font_size=28, t2c={'OLTP': YELLOW, 'operational databases': YELLOW}), Text('4. Understand its positioning in Enterprise Decision Support Systems', font_size=28, t2c={'Decision Support Systems': YELLOW}), Text('5. Comprehend the Layered Architecture of data warehouses', font_size=28, t2c={'Layered Architecture': YELLOW}))\n objectives.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n objectives.next_to(subsection, DOWN, buff=0.8)\n box = SurroundingRectangle(objectives, color=BLUE_E, buff=0.5, corner_radius=0.2)\n for obj in objectives:\n self.play(FadeIn(obj, shift=RIGHT), run_time=0.6)\n else:\n pass\n self.play(Create(box))\n self.wait(4)\n self.play(FadeOut(Group(*self.mobjects)))\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass DataWarehouseLecture(Scene):\n\n def construct(self):\n self.show_title_and_intro()\n self.clear_scene()\n self.show_course_objectives()\n\n def show_title_and_intro(self):\n title = Text('Data Warehouse', font_size=64, weight=BOLD)\n title.set_color_by_gradient(BBLUE, TEAL)\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP, buff=1.0))\n intro_lines = VGroup(Text('This chapter delves into:', font_size=36, color=WHITE, weight=BOLD), Text('• Core concepts and architecture of data warehouses', font_size=32, t2c={'Core concepts': YELLOW, 'architecture': YELLOW}), Text('• Theory and practical methods of dimensional modeling', font_size=32, t2c={'dimensional modeling': YELLOW}), Text('• Design and implementation of ETL processes', font_size=32, t2c={'ETL processes': YELLOW}), Text('• Building a comprehensive knowledge system', font_size=32, t2c={'knowledge system': YELLOW}))\n intro_lines.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n intro_lines.next_to(title, DOWN, buff=1.0)\n self.play(FadeIn(intro_lines[0], shift=DOWN))\n for i in range(1, len(intro_lines)):\n self.play(FadeIn(intro_lines[i], shift=RIGHT), run_time=0.6)\n else:\n pass\n self.wait(3)\n\n def clear_scene(self):\n self.play(FadeOut(Group(*self.mobjects)))\n self.wait(0.5)\n\n def show_course_objectives(self):\n section_title = Text('Course Objectives', font_size=54, weight=BOLD, color=BLUE)\n section_title.to_edge(UP, buff=0.8)\n self.play(Write(section_title))\n subsection = Text('Understanding Basic Concepts and Architecture', font_size=36, color=TEAL)\n subsection.next_to(section_title, DOWN, buff=0.5)\n self.play(FadeIn(subsection, shift=UP))\n self.wait(0.5)\n objectives = VGroup(Text('1. Articulate the definition of a Data Warehouse', font_size=28, t2c={'definition': YELLOW}), Text('2. Identify the Four Key Features of a data warehouse', font_size=28, t2c={'Four Key Features': YELLOW}), Text('3. Differentiate from traditional operational databases (OLTP)', font_size=28, t2c={'OLTP': YELLOW, 'operational databases': YELLOW}), Text('4. Understand its positioning in Enterprise Decision Support Systems', font_size=28, t2c={'Decision Support Systems': YELLOW}), Text('5. Comprehend the Layered Architecture of data warehouses', font_size=28, t2c={'Layered Architecture': YELLOW}))\n objectives.arrange(DOWN, aligned_edge=LEFT, buff=0.5)\n objectives.next_to(subsection, DOWN, buff=0.8)\n box = SurroundingRectangle(objectives, color=BLUE_E, buff=0.5, corner_radius=0.2)\n for obj in objectives:\n self.play(FadeIn(obj, shift=RIGHT), run_time=0.6)\n else:\n pass\n self.play(Create(box))\n self.wait(4)\n self.play(FadeOut(Group(*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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 presenting the matrix \\(\\begin{pmatrix} 1 & 2 \\\\ 3 & 4 \\end{pmatrix}\\) with a smooth `Write` effect. Next, a title (\"Determinant of the Matrix\") appears at the top, followed by the determinant formula \\(\\text{det} = 1 \\cdot 4 - 2 \\cdot 3\\) transforming from a copy of the matrix. The formula then morphs into the computed value \\(\\text{det} = -2\\), with a visual highlight (e.g., a surrounding box or color change) to emphasize the result. The scene transitions to eigenvalues, replacing the title with \"Eigenvalues of the Matrix,\" and the characteristic polynomial \\(\\lambda^2 - 5\\lambda + (-2) = 0\\) appears with a step-by-step derivation (e.g., expanding trace and determinant terms). The polynomial then simplifies into its roots, \\(\\lambda = 2\\) and \\(\\lambda = 3\\), displayed side by side with arrows pointing to each eigenvalue for clarity. Finally, the scene clears, and a concluding message (\"Eigenvalues are 2 and 3\") appears in yellow, accompanied by a visual representation of the eigenvectors as arrows scaling along the matrix’s transformation axes, reinforcing the geometric interpretation of eigenvalues. The entire sequence is paced with smooth transitions and explanatory annotations to improve understanding.", "chosen": "```python\nfrom manim import *\n\nclass MatrixDeterminantAndEigenvalues(Scene):\n def construct(self):\n # Initial matrix\n matrix = Matrix([[1, 2], [3, 4]])\n matrix_title = Text(\"Determinant of the Matrix\").to_edge(UP)\n \n # Write matrix and title\n self.play(Write(matrix))\n self.wait(0.5)\n self.play(Write(matrix_title))\n self.wait(1)\n \n # Determinant formula\n det_formula = MathTex(r\"\\text{det} = 1 \\cdot 4 - 2 \\cdot 3\").next_to(matrix, DOWN)\n self.play(Transform(matrix.copy(), det_formula))\n self.wait(1)\n \n # Compute determinant\n det_value = MathTex(r\"\\text{det} = -2\").next_to(matrix, DOWN)\n box = SurroundingRectangle(det_value, color=YELLOW)\n self.play(Transform(det_formula, det_value), Create(box))\n self.wait(1)\n \n # Transition to eigenvalues\n new_title = Text(\"Eigenvalues of the Matrix\").to_edge(UP)\n self.play(\n ReplacementTransform(matrix_title, new_title),\n FadeOut(matrix),\n FadeOut(det_formula),\n FadeOut(box)\n )\n \n # Characteristic polynomial\n char_poly = MathTex(r\"\\lambda^2 - 5\\lambda + (-2) = 0\").scale(1.2)\n self.play(Write(char_poly))\n self.wait(1)\n \n # Roots of the polynomial\n roots = MathTex(r\"\\lambda = 2\", r\"\\quad \\text{and} \\quad\", r\"\\lambda = 3\").scale(1.2)\n roots.next_to(char_poly, DOWN, buff=1)\n arrow1 = Arrow(char_poly.get_bottom(), roots[0].get_top(), buff=0.2)\n arrow2 = Arrow(char_poly.get_bottom(), roots[2].get_top(), buff=0.2)\n \n self.play(\n Write(roots),\n GrowArrow(arrow1),\n GrowArrow(arrow2)\n )\n self.wait(1)\n \n # Clear and show conclusion\n conclusion = Text(\"Eigenvalues are 2 and 3\", color=YELLOW).scale(1.2)\n self.play(\n FadeOut(new_title),\n FadeOut(char_poly),\n FadeOut(roots),\n FadeOut(arrow1),\n FadeOut(arrow2),\n )\n self.play(Write(conclusion))\n self.wait(1)\n \n # Visualize eigenvectors\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 axes.to_edge(DOWN)\n \n vec1 = Vector([2, 1], color=RED).shift(axes.c2p(0, 0))\n vec2 = Vector([1, -1], color=BLUE).shift(axes.c2p(0, 0))\n \n self.play(\n FadeIn(axes),\n GrowArrow(vec1),\n GrowArrow(vec2)\n )\n self.wait(2)\n \n # Scale eigenvectors\n scaled_vec1 = Vector([4, 2], color=RED).shift(axes.c2p(0, 0))\n scaled_vec2 = Vector([3, -3], color=BLUE).shift(axes.c2p(0, 0))\n \n self.play(\n Transform(vec1, scaled_vec1),\n Transform(vec2, scaled_vec2),\n run_time=2\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass MatrixDeterminantAndEigenvalues(Scene):\n def construct(self):\n # Initial matrix\n matrix = Matrix([[1, 2], [3, 4]])\n matrix_title = Text(\"Determinant of the Matrix\").to_edge(UP)\n \n # Write matrix and title\n self.play(Write(matrix))\n self.wait(0.5)\n self.play(Write(matrix_title))\n self.wait(1)\n \n # Determinant formula\n det_formula = MathTex(r\"\\text{det} = 1 \\cdot 4 - 2 \\cdot 3\").next_to(matrix, DOWN)\n self.play(Transform(matrix.copy(), det_formula))\n self.wait(1)\n \n # Compute determinant\n det_value = MathTex(r\"\\text{det} = -2\").next_to(matrix, DOWN)\n box = SurroundingRectangle(det_value, color=YELLOW)\n self.play(Transform(det_formula, det_value), Create(box))\n self.wait(1)\n \n # Transition to eigenvalues\n new_title = Text(\"Eigenvalues of the Matrix\").to_edge(UP)\n self.play(\n ReplacementTransform(matrix_title, new_title),\n FadeOut(matrix),\n FadeOut(det_formula),\n FadeOut(box)\n )\n \n # Characteristic polynomial\n char_poly = MathTex(r\"\\lambda^2 - 5\\lambda + (-2) = 0\").scale(1.2)\n self.play(Write(char_poly))\n self.wait(1)\n \n # Roots of the polynomial\n roots = MathTex(r\"\\lambda = 2\", r\"\\quad \\text{and} \\quad\", r\"\\lambda = 3\").scale(1.2)\n roots.next_to(char_poly, DOWN, buff=1)\n arrow1 = Arrow(char_poly.get_bottom(), roots[0].get_top(), buff=0.2)\n arrow2 = Arrow(char_poly.get_bottom(), roots[2].get_top(), buff=0.2)\n \n self.play(\n Write(roots),\n GrowArrow(arrow1),\n GrowArrow(arrow2)\n )\n self.wait(1)\n \n # Clear and show conclusion\n conclusion = Text(\"Eigenvalues are 2 and 3\", color=YELLOW).scale(1.2)\n self.play(\n FadeOut(new_title),\n FadeOut(char_poly),\n FadeOut(roots),\n FadeOut(arrow1),\n FadeOut(arrow2),\n )\n self.play(Write(conclusion))\n self.wait(1)\n \n # Visualize eigenvectors\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 axes.to_edge(DOWN)\n \n vec1 = Vector([2, 1], color=RED).shift(axes.c2p(0, 0))\n vec2 = Vector([1, -1], color=BBLUE).shift(axes.c2p(0, 0))\n \n self.play(\n FadeIn(axes),\n GrowArrow(vec1),\n GrowArrow(vec2)\n )\n self.wait(2)\n \n # Scale eigenvectors\n scaled_vec1 = Vector([4, 2], color=RED).shift(axes.c2p(0, 0))\n scaled_vec2 = Vector([3, -3], color=BLUE).shift(axes.c2p(0, 0))\n \n self.play(\n Transform(vec1, scaled_vec1),\n Transform(vec2, scaled_vec2),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(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=BBLUE).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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 chemistry animation using Manim that shows a simplified chemical structure with both oxygen and metal elements arranged in a grid pattern? Also, include an electron moving in a complex path around this grid, some lithium ions placed to the side and below the grid, and have everything fade out at the end. The animation should start with the title 'Chemical Structure Example' at the top of the screen.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemicalStructureAnimation(Scene):\n def construct(self):\n \"\"\"\n Educational animation representing a simplified 2D metal-oxide lattice\n with intercalated lithium ions and a delocalized electron trajectory.\n \"\"\"\n \n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n # Display the animation title at the top edge of the frame\n title = Text(\"Chemical Structure Example\", font_size=40, weight=BOLD)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Structure (Metal-Oxide Lattice)\n # ------------------------------------------------------------------\n # Generate a 3x3 grid representing a crystalline lattice.\n # Blue circles represent metal cations, Red circles represent oxygen anions.\n # Bonds are drawn between adjacent atoms to illustrate the structural framework.\n atoms = VGroup()\n labels = VGroup()\n bonds = VGroup()\n \n grid_size = 3\n spacing = 1.2\n atom_radius = 0.3\n \n # Create atoms and their corresponding labels\n for row in range(grid_size):\n for col in range(grid_size):\n # Alternate between Metal and Oxygen to simulate a simple binary lattice\n is_metal = (row + col) % 2 == 0\n color = BLUE if is_metal else RED\n label_text = \"M\" if is_metal else \"O\"\n \n # Calculate grid position centered at the origin\n pos = np.array([(col - 1) * spacing, (row - 1) * spacing, 0])\n \n atom = Circle(radius=atom_radius, color=color, fill_opacity=0.8, stroke_width=2)\n atom.move_to(pos)\n label = Text(label_text, font_size=24, weight=BOLD).move_to(atom.get_center())\n \n atoms.add(atom)\n labels.add(label)\n \n # Create bonds between horizontally and vertically adjacent atoms\n for i in range(len(atoms)):\n for j in range(i + 1, len(atoms)):\n dist = np.linalg.norm(atoms[i].get_center() - atoms[j].get_center())\n if np.isclose(dist, spacing):\n bond = Line(atoms[i].get_center(), atoms[j].get_center(), color=GRAY, stroke_width=2)\n bonds.add(bond)\n \n grid_group = VGroup(bonds, atoms, labels)\n self.play(Create(bonds), FadeIn(atoms), Write(labels), run_time=2)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Ion Placement (Lithium Intercalation Sites)\n # ------------------------------------------------------------------\n # Position Lithium ions (Li+) specifically to the side and below the main grid.\n # This represents Li+ ions situated at interstitial sites or within the electrolyte,\n # common in battery cathode visualizations.\n li_ions = VGroup()\n li_positions_side = [RIGHT * 3.5 + UP * 0.5, RIGHT * 3.5 + DOWN * 0.5]\n li_positions_below = [DOWN * 3.5 + LEFT * 0.5, DOWN * 3.5 + RIGHT * 0.5]\n \n for pos in li_positions_side + li_positions_below:\n ion_circle = Circle(radius=atom_radius * 0.6, color=YELLOW, fill_opacity=0.9)\n ion_circle.move_to(pos)\n ion_label = Tex(r\"$\\text{Li}^+$\", font_size=24).next_to(ion_circle, RIGHT, buff=0.1)\n li_ions.add(VGroup(ion_circle, ion_label))\n \n self.play(FadeIn(li_ions), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Electron Animation (Delocalized Trajectory)\n # ------------------------------------------------------------------\n # Animate an electron moving along a complex, non-linear path around the grid.\n # The Lissajous-like curve simulates a delocalized electron wavefunction\n # or conduction electron moving through the lattice.\n electron = Dot(radius=0.1, color=YELLOW)\n \n # Define a Lissajous curve centered on the lattice\n path = ParametricFunction(\n lambda t: np.array([\n 1.5 * np.sin(t + PI / 4),\n 1.5 * np.sin(2 * t),\n 0\n ]),\n t_range=[0, 2 * PI],\n color=YELLOW,\n stroke_opacity=0.5\n )\n path.move_to(grid_group.get_center())\n \n # Move the electron along the defined parametric path\n self.add(electron)\n self.play(MoveAlongPath(electron, path), run_time=4, rate_func=linear)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 5. Conclusion (Fade-out)\n # ------------------------------------------------------------------\n # Execute a fade-out effect for all elements to conclude the animation\n all_elements = VGroup(title, grid_group, li_ions, electron, path)\n self.play(FadeOut(all_elements), run_time=2)\n\n# To run this animation using Manim Community Edition:\n# manim -pql scene_file.py ChemicalStructureAnimation\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemicalStructureAnimation(Scene):\n def construct(self):\n \"\"\"\n Educational animation representing a simplified 2D metal-oxide lattice\n with intercalated lithium ions and a delocalized electron trajectory.\n \"\"\"\n \n # ------------------------------------------------------------------\n # 1. Title Sequence\n # ------------------------------------------------------------------\n # Display the animation title at the top edge of the frame\n title = Text(\"Chemical Structure Example\", font_size=40, weight=BOLD)\n title.to_edge(UP)\n self.play(Write(title), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Structure (Metal-Oxide Lattice)\n # ------------------------------------------------------------------\n # Generate a 3x3 grid representing a crystalline lattice.\n # Blue circles represent metal cations, Red circles represent oxygen anions.\n # Bonds are drawn between adjacent atoms to illustrate the structural framework.\n atoms = VGroup()\n labels = VGroup()\n bonds = VGroup()\n \n grid_size = 3\n spacing = 1.2\n atom_radius = 0.3\n \n # Create atoms and their corresponding labels\n for row in range(grid_size):\n for col in range(grid_size):\n # Alternate between Metal and Oxygen to simulate a simple binary lattice\n is_metal = (row + col) % 2 == 0\n color = BBLUE if is_metal else RED\n label_text = \"M\" if is_metal else \"O\"\n \n # Calculate grid position centered at the origin\n pos = np.array([(col - 1) * spacing, (row - 1) * spacing, 0])\n \n atom = Circle(radius=atom_radius, color=color, fill_opacity=0.8, stroke_width=2)\n atom.move_to(pos)\n label = Text(label_text, font_size=24, weight=BOLD).move_to(atom.get_center())\n \n atoms.add(atom)\n labels.add(label)\n \n # Create bonds between horizontally and vertically adjacent atoms\n for i in range(len(atoms)):\n for j in range(i + 1, len(atoms)):\n dist = np.linalg.norm(atoms[i].get_center() - atoms[j].get_center())\n if np.isclose(dist, spacing):\n bond = Line(atoms[i].get_center(), atoms[j].get_center(), color=GRAY, stroke_width=2)\n bonds.add(bond)\n \n grid_group = VGroup(bonds, atoms, labels)\n self.play(Create(bonds), FadeIn(atoms), Write(labels), run_time=2)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 3. Ion Placement (Lithium Intercalation Sites)\n # ------------------------------------------------------------------\n # Position Lithium ions (Li+) specifically to the side and below the main grid.\n # This represents Li+ ions situated at interstitial sites or within the electrolyte,\n # common in battery cathode visualizations.\n li_ions = VGroup()\n li_positions_side = [RIGHT * 3.5 + UP * 0.5, RIGHT * 3.5 + DOWN * 0.5]\n li_positions_below = [DOWN * 3.5 + LEFT * 0.5, DOWN * 3.5 + RIGHT * 0.5]\n \n for pos in li_positions_side + li_positions_below:\n ion_circle = Circle(radius=atom_radius * 0.6, color=YELLOW, fill_opacity=0.9)\n ion_circle.move_to(pos)\n ion_label = Tex(r\"$\\text{Li}^+$\", font_size=24).next_to(ion_circle, RIGHT, buff=0.1)\n li_ions.add(VGroup(ion_circle, ion_label))\n \n self.play(FadeIn(li_ions), run_time=1.5)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Electron Animation (Delocalized Trajectory)\n # ------------------------------------------------------------------\n # Animate an electron moving along a complex, non-linear path around the grid.\n # The Lissajous-like curve simulates a delocalized electron wavefunction\n # or conduction electron moving through the lattice.\n electron = Dot(radius=0.1, color=YELLOW)\n \n # Define a Lissajous curve centered on the lattice\n path = ParametricFunction(\n lambda t: np.array([\n 1.5 * np.sin(t + PI / 4),\n 1.5 * np.sin(2 * t),\n 0\n ]),\n t_range=[0, 2 * PI],\n color=YELLOW,\n stroke_opacity=0.5\n )\n path.move_to(grid_group.get_center())\n \n # Move the electron along the defined parametric path\n self.add(electron)\n self.play(MoveAlongPath(electron, path), run_time=4, rate_func=linear)\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 5. Conclusion (Fade-out)\n # ------------------------------------------------------------------\n # Execute a fade-out effect for all elements to conclude the animation\n all_elements = VGroup(title, grid_group, li_ions, electron, path)\n self.play(FadeOut(all_elements), run_time=2)\n\n# To run this animation using Manim Community Edition:\n# manim -pql scene_file.py ChemicalStructureAnimation\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(\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 = MathText(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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 *\nimport numpy as np\n\nclass EulersFormula(Scene):\n def construct(self):\n # 1. Title Display\n title = Text(\"Euler's Formula\", font_size=48)\n self.play(Write(title))\n self.play(title.animate.to_edge(UP))\n self.wait(0.5)\n\n # 2. Formula Introduction\n formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=40)\n self.play(Write(formula))\n self.wait(1)\n self.play(FadeOut(formula))\n\n # 3. Complex Plane Visualization\n # Create Complex Plane\n plane = ComplexPlane(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_numbers\": False, \"include_tip\": True}\n )\n \n # Unit Circle\n unit_circle = Circle(radius=1, color=BLUE, stroke_width=2)\n unit_circle.move_to(plane.get_origin())\n \n # Value Tracker for Theta\n theta = ValueTracker(0)\n \n # Line segment (vector) from origin to the point on the circle\n vector = always_redraw(lambda: \n Line(\n start=plane.get_origin(),\n end=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=YELLOW\n )\n )\n \n # Distinct dot at the end of the line segment\n dot = always_redraw(lambda: \n Dot(\n point=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=RED,\n radius=0.08\n )\n )\n \n # Arc to represent the angle theta\n arc = always_redraw(lambda: \n Arc(\n radius=0.3,\n start_angle=0,\n angle=theta.get_value(),\n color=GREEN,\n arc_center=plane.get_origin()\n )\n )\n \n # Trace path to demonstrate how the expression traces out the unit circle\n trace = TracedPath(\n dot.get_center,\n stroke_color=WHITE,\n stroke_width=2,\n stroke_opacity=0.8\n )\n \n # Add elements to scene\n self.play(Create(plane), Create(unit_circle))\n self.add(trace, vector, dot, arc)\n \n # Animate theta from 0 to 2PI (TAU) to complete exactly one full rotation\n self.play(\n theta.animate.set_value(TAU),\n run_time=4,\n rate_func=linear\n )\n self.wait(0.5)\n \n # 4. Completion and Cleanup\n # Briefly clear the screen (fade out or remove all elements)\n self.play(\n FadeOut(plane), \n FadeOut(unit_circle), \n FadeOut(trace), \n FadeOut(vector), \n FadeOut(dot), \n FadeOut(arc), \n FadeOut(title)\n )\n self.wait(0.5)\n \n # 5. Conclusion\n # Re-display only the Euler's Formula equation\n final_formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=48)\n self.play(Write(final_formula))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EulersFormula(Scene):\n def construct(self):\n # 1. Title Display\n title = Text(\"Euler's Formula\", font_size=48)\n self.play(Write(title))\n self.play(title.animate.to_edge(UP))\n self.wait(0.5)\n\n # 2. Formula Introduction\n formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=40)\n self.play(Write(formula))\n self.wait(1)\n self.play(FadeOut(formula))\n\n # 3. Complex Plane Visualization\n # Create Complex Plane\n plane = ComplexPlane(\n x_range=[-2, 2, 1],\n y_range=[-2, 2, 1],\n axis_config={\"include_numbers\": False, \"include_tip\": True}\n )\n \n # Unit Circle\n unit_circle = Circle(radius=1, color=BBLUE, stroke_width=2)\n unit_circle.move_to(plane.get_origin())\n \n # Value Tracker for Theta\n theta = ValueTracker(0)\n \n # Line segment (vector) from origin to the point on the circle\n vector = always_redraw(lambda: \n Line(\n start=plane.get_origin(),\n end=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=YELLOW\n )\n )\n \n # Distinct dot at the end of the line segment\n dot = always_redraw(lambda: \n Dot(\n point=plane.c2p(np.cos(theta.get_value()), np.sin(theta.get_value())),\n color=RED,\n radius=0.08\n )\n )\n \n # Arc to represent the angle theta\n arc = always_redraw(lambda: \n Arc(\n radius=0.3,\n start_angle=0,\n angle=theta.get_value(),\n color=GREEN,\n arc_center=plane.get_origin()\n )\n )\n \n # Trace path to demonstrate how the expression traces out the unit circle\n trace = TracedPath(\n dot.get_center,\n stroke_color=WHITE,\n stroke_width=2,\n stroke_opacity=0.8\n )\n \n # Add elements to scene\n self.play(Create(plane), Create(unit_circle))\n self.add(trace, vector, dot, arc)\n \n # Animate theta from 0 to 2PI (TAU) to complete exactly one full rotation\n self.play(\n theta.animate.set_value(TAU),\n run_time=4,\n rate_func=linear\n )\n self.wait(0.5)\n \n # 4. Completion and Cleanup\n # Briefly clear the screen (fade out or remove all elements)\n self.play(\n FadeOut(plane), \n FadeOut(unit_circle), \n FadeOut(trace), \n FadeOut(vector), \n FadeOut(dot), \n FadeOut(arc), \n FadeOut(title)\n )\n self.wait(0.5)\n \n # 5. Conclusion\n # Re-display only the Euler's Formula equation\n final_formula = MathTex(r\"e^{i\\theta} = \\cos(\\theta) + i\\sin(\\theta)\", font_size=48)\n self.play(Write(final_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 situation does an adaptive quadrature method outperform a uniform grid approach significantly?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass AdaptiveQuadrature(Scene):\n def construct(self):\n # Set colors (blue and green with gold for adaptive)\n function_color = GREEN\n uniform_color = BLUE\n adaptive_color = GOLD\n \n # Title\n title = Text(\"The Power of Adaptive Quadrature\", font_size=32)\n title.to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n \n # Set up axes\n axes = Axes(\n x_range=[0, 4],\n y_range=[0, 2],\n ).scale(0.7)\n axes.center()\n \n # Define a function with a sharp spike - ideal for showing adaptive advantage\n def func(x):\n return np.exp(-0.5 * (x - 1)**2) + 0.8 * np.exp(-8 * (x - 3)**2)\n \n # Plot the function\n graph = axes.plot(lambda x: func(x), color=function_color)\n \n graph_label = Text(\"Function with irregular behavior\", font_size=20)\n graph_label.next_to(axes, DOWN)\n \n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n \n # Show uniform grid approach (equal spacing)\n uniform_rects = VGroup()\n x_min, x_max = 0, 4\n num_uniform = 8\n dx_uniform = (x_max - x_min) / num_uniform\n \n for i in range(num_uniform):\n x = x_min + i * dx_uniform\n height = func(x)\n rect = Rectangle(\n width=dx_uniform,\n height=height,\n fill_color=uniform_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + dx_uniform/2, height/2), aligned_edge=ORIGIN)\n uniform_rects.add(rect)\n \n uniform_label = Text(\"Uniform Grid: Equal spacing everywhere\", \n font_size=20, color=uniform_color)\n uniform_label.next_to(graph_label, DOWN)\n \n self.play(FadeIn(uniform_rects), Write(uniform_label))\n self.wait(1)\n \n # Clear uniform grid and show adaptive approach\n self.play(FadeOut(uniform_rects), FadeOut(uniform_label))\n \n # Adaptive approach - fewer rectangles in smooth areas, more near the spike\n adaptive_rects = VGroup()\n \n # Fewer rectangles in smoother regions\n for i in range(3):\n x = 0 + i * (2/3)\n height = func(x)\n rect = Rectangle(\n width=2/3,\n height=height,\n fill_color=adaptive_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + (2/3)/2, height/2), aligned_edge=ORIGIN)\n adaptive_rects.add(rect)\n \n # More rectangles near the spike\n for i in range(8):\n x = 2 + i * (2/8)\n height = func(x)\n rect = Rectangle(\n width=2/8,\n height=height,\n fill_color=adaptive_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + (2/8)/2, height/2), aligned_edge=ORIGIN)\n adaptive_rects.add(rect)\n \n adaptive_label = Text(\"Adaptive Quadrature: Focus on complex areas\", \n font_size=20, color=adaptive_color)\n adaptive_label.next_to(graph_label, DOWN)\n \n self.play(FadeIn(adaptive_rects), Write(adaptive_label))\n self.wait(2)\n \n # Show conclusion\n conclusion = Text(\n \"Adaptive quadrature excels with irregular functions\",\n font_size=24,\n color=YELLOW\n )\n conclusion.next_to(title, DOWN, buff=0.5)\n \n self.play(\n FadeOut(adaptive_rects),\n FadeOut(adaptive_label),\n FadeOut(graph_label),\n FadeOut(graph),\n FadeOut(axes),\n Write(conclusion)\n )\n self.wait(2)\n \n # End animation\n self.play(FadeOut(title), FadeOut(conclusion))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass AdaptiveQuadrature(Scene):\n def construct(self):\n # Set colors (blue and green with gold for adaptive)\n function_color = GREEN\n uniform_color = BLUE\n adaptive_color = GOLD\n \n # Title\n title = Text(\"The Power of Adaptive Quadrature\", font_size=32)\n title.to_edge(UP)\n \n self.play(Write(title))\n self.wait(1)\n \n # Set up axes\n axes = Axes(label_font_size=24, \n x_range=[0, 4],\n y_range=[0, 2],\n ).scale(0.7)\n axes.center()\n \n # Define a function with a sharp spike - ideal for showing adaptive advantage\n def func(x):\n return np.exp(-0.5 * (x - 1)**2) + 0.8 * np.exp(-8 * (x - 3)**2)\n \n # Plot the function\n graph = axes.plot(lambda x: func(x), color=function_color)\n \n graph_label = Text(\"Function with irregular behavior\", font_size=20)\n graph_label.next_to(axes, DOWN)\n \n self.play(Create(axes), Create(graph), Write(graph_label))\n self.wait(1)\n \n # Show uniform grid approach (equal spacing)\n uniform_rects = VGroup()\n x_min, x_max = 0, 4\n num_uniform = 8\n dx_uniform = (x_max - x_min) / num_uniform\n \n for i in range(num_uniform):\n x = x_min + i * dx_uniform\n height = func(x)\n rect = Rectangle(\n width=dx_uniform,\n height=height,\n fill_color=uniform_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + dx_uniform/2, height/2), aligned_edge=ORIGIN)\n uniform_rects.add(rect)\n \n uniform_label = Text(\"Uniform Grid: Equal spacing everywhere\", \n font_size=20, color=uniform_color)\n uniform_label.next_to(graph_label, DOWN)\n \n self.play(FadeIn(uniform_rects), Write(uniform_label))\n self.wait(1)\n \n # Clear uniform grid and show adaptive approach\n self.play(FadeOut(uniform_rects), FadeOut(uniform_label))\n \n # Adaptive approach - fewer rectangles in smooth areas, more near the spike\n adaptive_rects = VGroup()\n \n # Fewer rectangles in smoother regions\n for i in range(3):\n x = 0 + i * (2/3)\n height = func(x)\n rect = Rectangle(\n width=2/3,\n height=height,\n fill_color=adaptive_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + (2/3)/2, height/2), aligned_edge=ORIGIN)\n adaptive_rects.add(rect)\n \n # More rectangles near the spike\n for i in range(8):\n x = 2 + i * (2/8)\n height = func(x)\n rect = Rectangle(\n width=2/8,\n height=height,\n fill_color=adaptive_color,\n fill_opacity=0.4,\n stroke_width=1\n )\n rect.move_to(axes.c2p(x + (2/8)/2, height/2), aligned_edge=ORIGIN)\n adaptive_rects.add(rect)\n \n adaptive_label = Text(\"Adaptive Quadrature: Focus on complex areas\", \n font_size=20, color=adaptive_color)\n adaptive_label.next_to(graph_label, DOWN)\n \n self.play(FadeIn(adaptive_rects), Write(adaptive_label))\n self.wait(2)\n \n # Show conclusion\n conclusion = Text(\n \"Adaptive quadrature excels with irregular functions\",\n font_size=24,\n color=YELLOW\n )\n conclusion.next_to(title, DOWN, buff=0.5)\n \n self.play(\n FadeOut(adaptive_rects),\n FadeOut(adaptive_label),\n FadeOut(graph_label),\n FadeOut(graph),\n FadeOut(axes),\n Write(conclusion)\n )\n self.wait(2)\n \n # End animation\n self.play(FadeOut(title), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 an undergrad course on deep learning and want a step-by-step visualization of a forward pass through an MLP with BatchNorm.\nVisualize each intermediate tensor (x, z1, a1, bn_out, out) and label them with explicit variable names; show shapes too.\nInclude brief commentary on where normalization acts and how statistics move through the network.", "chosen": "```python\nfrom manim import *\n\nclass MLPForwardPass(Scene):\n\n def construct(self):\n title = Text('MLP Forward Pass with BatchNorm', font_size=32)\n title.to_edge(UP, buff=0.3)\n self.play(Write(title), run_time=2.0)\n input_neurons = VGroup(*[Circle(radius=0.2, color=BLUE, fill_opacity=0.2) for _ in range(3)])\n input_neurons.arrange(DOWN, buff=0.5)\n input_neurons.shift(LEFT * 3.2)\n hidden_neurons = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.2) for _ in range(4)])\n hidden_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.shift(LEFT * 0.2)\n output_neurons = VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=0.2) for _ in range(2)])\n output_neurons.arrange(DOWN, buff=0.5)\n output_neurons.shift(RIGHT * 2.8)\n input_to_hidden = VGroup()\n for i in input_neurons:\n for h in hidden_neurons:\n input_to_hidden.add(Line(i.get_right(), h.get_left(), stroke_width=1, color=GREY_B))\n hidden_to_output = VGroup()\n for h in hidden_neurons:\n for o in output_neurons:\n hidden_to_output.add(Line(h.get_right(), o.get_left(), stroke_width=1, color=GREY_B))\n input_label = Text('Input', font_size=18).next_to(input_neurons, LEFT, buff=0.2)\n hidden_label = Text('Hidden', font_size=18).next_to(hidden_neurons, UP, buff=0.2)\n output_label = Text('Output', font_size=18).next_to(output_neurons, RIGHT, buff=0.2)\n bn_box = Rectangle(width=1.6, height=0.5, color=YELLOW, fill_opacity=0.15)\n bn_box.next_to(hidden_neurons, DOWN, buff=0.25)\n bn_text = Text('BatchNorm', font_size=16, color=YELLOW).move_to(bn_box.get_center())\n arch_group = VGroup(input_neurons, hidden_neurons, output_neurons, input_to_hidden, hidden_to_output, input_label, hidden_label, output_label, bn_box, bn_text)\n self.play(Create(input_to_hidden), Create(hidden_to_output), run_time=2.0 * 0.3)\n self.play(Create(input_neurons), Create(hidden_neurons), Create(output_neurons), run_time=2.0 * 0.3)\n self.play(Write(input_label), Write(hidden_label), Write(output_label), Create(bn_box), Write(bn_text), run_time=2.0 * 0.4)\n flow_dot = Dot(color=WHITE, radius=0.08).move_to(input_neurons[1].get_center())\n self.play(FadeIn(flow_dot), run_time=0.4)\n self.play(flow_dot.animate.move_to(hidden_neurons[1].get_center()), run_time=0.8)\n self.play(flow_dot.animate.move_to(output_neurons[0].get_center()), run_time=0.8)\n self.play(FadeOut(flow_dot), run_time=0.4)\n std_eq = MathTex('z = W \\\\cdot x + b', font_size=30)\n std_eq.to_edge(DOWN, buff=0.5)\n self.play(Write(std_eq), run_time=2.0)\n bn_eq = MathTex(\"x_i' = \\\\frac{x_i - \\\\mu}{\\\\sqrt{\\\\sigma^2 + \\\\varepsilon}}\", font_size=30)\n bn_eq.shift(UP * 0.5)\n self.play(FadeOut(std_eq), FadeIn(bn_eq), run_time=2.0)\n updated_eq = MathTex(\"y = W \\\\cdot x' + b\", font_size=30)\n updated_eq.shift(DOWN * 0.5)\n self.play(Write(updated_eq), run_time=2.0)\n benefits_title = Text('Key Benefits', font_size=28, color=YELLOW)\n benefits_title.to_edge(UP, buff=0.3)\n b1 = Text('• Faster training', font_size=20)\n b2 = Text('• Higher learning rates', font_size=20)\n b3 = Text('• Reduced covariate shift', font_size=20)\n b4 = Text('• Better generalization', font_size=20)\n left_col = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n right_col = VGroup(b3, b4).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n benefits = VGroup(left_col, right_col).arrange(RIGHT, buff=1.0)\n benefits.shift(DOWN * 0.5)\n self.play(FadeOut(title, arch_group, bn_eq, updated_eq), FadeIn(benefits_title), run_time=2.0 * 0.3)\n self.play(FadeIn(benefits), run_time=2.0 * 0.7)\n final = Text('Normalize first. Then transform.', font_size=26, color=GREEN)\n final.next_to(benefits, DOWN, buff=0.5)\n self.play(Write(final), run_time=2.0)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass MLPForwardPass(Scene):\n\n def construct(self):\n title = Text('MLP Forward Pass with BatchNorm', font_size=32)\n title.to_edge(UP, buff=0.3)\n self.play(Write(title), run_time=2.0)\n input_neurons = VGroup(*[Circle(radius=0.2, color=BLUE, fill_opacity=0.2) for _ in range(3)])\n input_neurons.arrange(DOWN, buff=0.5)\n input_neurons.shift(LEFT * 3.2)\n hidden_neurons = VGroup(*[Circle(radius=0.2, color=GREEN, fill_opacity=0.2) for _ in range(4)])\n hidden_neurons.arrange(DOWN, buff=0.4)\n hidden_neurons.shift(LEFT * 0.2)\n output_neurons = VGroup(*[Circle(radius=0.2, color=RED, fill_opacity=0.2) for _ in range(2)])\n output_neurons.arrange(DOWN, buff=0.5)\n output_neurons.shift(RIGHT * 2.8)\n input_to_hidden = VGroup()\n for i in input_neurons:\n for h in hidden_neurons:\n input_to_hidden.add(Line(i.get_right(), h.get_left(), stroke_width=1, color=GREY_B))\n hidden_to_output = VGroup()\n for h in hidden_neurons:\n for o in output_neurons:\n hidden_to_output.add(Line(h.get_right(), o.get_left(), stroke_width=1, color=GREY_B))\n input_label = Text('Input', font_size=18).next_to(input_neurons, LEFT, buff=0.2)\n hidden_label = Text('Hidden', font_size=18).next_to(hidden_neurons, UP, buff=0.2)\n output_label = Text('Output', font_size=18).next_to(output_neurons, RIGHT, buff=0.2)\n bn_box = Rectangle(width=1.6, height=0.5, color=YELLOW, fill_opacity=0.15)\n bn_box.next_to(hidden_neurons, DOWN, buff=0.25)\n bn_text = Text('BatchNorm', font_size=16, color=YELLOW).move_to(bn_box.get_center())\n arch_group = VGroup(input_neurons, hidden_neurons, output_neurons, input_to_hidden, hidden_to_output, input_label, hidden_label, output_label, bn_box, bn_text)\n self.play(Create(input_to_hidden), Create(hidden_to_output), run_time=2.0 * 0.3)\n self.play(Create(input_neurons), Create(hidden_neurons), Create(output_neurons), run_time=2.0 * 0.3)\n self.play(Write(input_label), Write(hidden_label), Write(output_label), Create(bn_box), Write(bn_text), run_time=2.0 * 0.4)\n flow_dot = Dot(color=WHITE, radius=0.08).move_to(input_neurons[1].get_center())\n self.play(FadeIn(flow_dot), run_time=0.4)\n self.play(flow_dot.animate.move_to(hidden_neurons[1].get_center()), run_time=0.8)\n self.play(flow_dot.animate.move_to(output_neurons[0].get_center()), run_time=0.8)\n self.play(FadeOut(flow_dot), run_time=0.4)\n std_eq = MathText('z = W \\\\cdot x + b', font_size=30)\n std_eq.to_edge(DOWN, buff=0.5)\n self.play(Write(std_eq), run_time=2.0)\n bn_eq = MathTex(\"x_i' = \\\\frac{x_i - \\\\mu}{\\\\sqrt{\\\\sigma^2 + \\\\varepsilon}}\", font_size=30)\n bn_eq.shift(UP * 0.5)\n self.play(FadeOut(std_eq), FadeIn(bn_eq), run_time=2.0)\n updated_eq = MathTex(\"y = W \\\\cdot x' + b\", font_size=30)\n updated_eq.shift(DOWN * 0.5)\n self.play(Write(updated_eq), run_time=2.0)\n benefits_title = Text('Key Benefits', font_size=28, color=YELLOW)\n benefits_title.to_edge(UP, buff=0.3)\n b1 = Text('• Faster training', font_size=20)\n b2 = Text('• Higher learning rates', font_size=20)\n b3 = Text('• Reduced covariate shift', font_size=20)\n b4 = Text('• Better generalization', font_size=20)\n left_col = VGroup(b1, b2).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n right_col = VGroup(b3, b4).arrange(DOWN, aligned_edge=LEFT, buff=0.3)\n benefits = VGroup(left_col, right_col).arrange(RIGHT, buff=1.0)\n benefits.shift(DOWN * 0.5)\n self.play(FadeOut(title, arch_group, bn_eq, updated_eq), FadeIn(benefits_title), run_time=2.0 * 0.3)\n self.play(FadeIn(benefits), run_time=2.0 * 0.7)\n final = Text('Normalize first. Then transform.', font_size=26, color=GREEN)\n final.next_to(benefits, DOWN, buff=0.5)\n self.play(Write(final), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 that visually represents the forward propagation process in a simple neural network with three layers, where the first layer has three neurons, the second layer has five neurons, and the third layer has three neurons again, using a Python library for creating animations?", "chosen": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardProp(Scene):\n def construct(self):\n # Configuration\n self.camera.background_color = \"#1e1e1e\"\n layer_sizes = [3, 5, 3]\n layer_colors = [BLUE, GREEN, RED]\n neuron_radius = 0.25\n layer_spacing = 3.5\n neuron_spacing = 0.8\n \n layers = []\n neurons = []\n layer_connections = []\n\n # 1. Create Neurons\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n neuron_layer = []\n x_pos = (i - 1) * layer_spacing\n start_y = (size - 1) * neuron_spacing / 2\n \n for j in range(size):\n neuron = Circle(\n radius=neuron_radius,\n color=layer_colors[i],\n fill_opacity=0.3,\n stroke_width=2\n )\n neuron.move_to([x_pos, start_y - j * neuron_spacing, 0])\n layer_group.add(neuron)\n neuron_layer.append(neuron)\n \n layers.append(layer_group)\n neurons.append(neuron_layer)\n\n # 2. Create Connections\n for i in range(len(neurons) - 1):\n connections = VGroup()\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n line = Line(\n n1.get_center(),\n n2.get_center(),\n stroke_width=1,\n color=WHITE,\n stroke_opacity=0.3\n )\n connections.add(line)\n layer_connections.append(connections)\n\n # 3. Create Labels\n labels = VGroup(\n Text(\"Input Layer\", font_size=24, color=layer_colors[0]),\n Text(\"Hidden Layer\", font_size=24, color=layer_colors[1]),\n Text(\"Output Layer\", font_size=24, color=layer_colors[2])\n )\n for i, label in enumerate(labels):\n label.next_to(layers[i], DOWN, buff=0.5)\n\n # --- Animation Sequence ---\n\n # Animate Structure Creation\n self.play(\n LaggedStart(*[Create(layer) for layer in layers], lag_ratio=0.2),\n LaggedStart(*[Create(conn) for conn in layer_connections], lag_ratio=0.1),\n Write(labels),\n run_time=2.5\n )\n self.wait(0.5)\n\n # --- Forward Propagation Visualization ---\n\n # Helper function to create and animate signal pulses between layers\n def propagate_signals(start_layer_idx, end_layer_idx, color=YELLOW):\n pulses = VGroup()\n animations = []\n start_neurons = neurons[start_layer_idx]\n end_neurons = neurons[end_layer_idx]\n \n for n1 in start_neurons:\n for n2 in end_neurons:\n dot = Dot(radius=0.06, color=color)\n dot.move_to(n1.get_center())\n path = Line(n1.get_center(), n2.get_center())\n pulses.add(dot)\n animations.append(MoveAlongPath(dot, path, run_time=1.5, rate_func=linear))\n \n self.add(pulses)\n self.play(LaggedStart(*animations, lag_ratio=0.05), run_time=2)\n self.remove(pulses)\n\n # Step 1: Input -> Hidden\n self.play(\n *[n.animate.set_fill(opacity=1.0, color=layer_colors[0]) for n in neurons[0]],\n run_time=0.5\n )\n propagate_signals(0, 1)\n self.play(\n layers[1].animate.set_fill(opacity=1.0),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Step 2: Hidden -> Output\n propagate_signals(1, 2)\n self.play(\n layers[2].animate.set_fill(opacity=1.0),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Final Highlight\n output_text = Text(\"Output Generated\", font_size=30, color=WHITE)\n output_text.next_to(layers[2], UP, buff=0.5)\n self.play(FadeIn(output_text, shift=UP))\n self.wait(1)\n self.play(FadeOut(output_text))\n \n # Hold final state\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass NeuralNetworkForwardProp(Scene):\n def construct(self):\n # Configuration\n self.camera.background_color = \"#1e1e1e\"\n layer_sizes = [3, 5, 3]\n layer_colors = [BBLUE, GREEN, RED]\n neuron_radius = 0.25\n layer_spacing = 3.5\n neuron_spacing = 0.8\n \n layers = []\n neurons = []\n layer_connections = []\n\n # 1. Create Neurons\n for i, size in enumerate(layer_sizes):\n layer_group = VGroup()\n neuron_layer = []\n x_pos = (i - 1) * layer_spacing\n start_y = (size - 1) * neuron_spacing / 2\n \n for j in range(size):\n neuron = Circle(\n radius=neuron_radius,\n color=layer_colors[i],\n fill_opacity=0.3,\n stroke_width=2\n )\n neuron.move_to([x_pos, start_y - j * neuron_spacing, 0])\n layer_group.add(neuron)\n neuron_layer.append(neuron)\n \n layers.append(layer_group)\n neurons.append(neuron_layer)\n\n # 2. Create Connections\n for i in range(len(neurons) - 1):\n connections = VGroup()\n for n1 in neurons[i]:\n for n2 in neurons[i + 1]:\n line = Line(\n n1.get_center(),\n n2.get_center(),\n stroke_width=1,\n color=WHITE,\n stroke_opacity=0.3\n )\n connections.add(line)\n layer_connections.append(connections)\n\n # 3. Create Labels\n labels = VGroup(\n Text(\"Input Layer\", font_size=24, color=layer_colors[0]),\n Text(\"Hidden Layer\", font_size=24, color=layer_colors[1]),\n Text(\"Output Layer\", font_size=24, color=layer_colors[2])\n )\n for i, label in enumerate(labels):\n label.next_to(layers[i], DOWN, buff=0.5)\n\n # --- Animation Sequence ---\n\n # Animate Structure Creation\n self.play(\n LaggedStart(*[Create(layer) for layer in layers], lag_ratio=0.2),\n LaggedStart(*[Create(conn) for conn in layer_connections], lag_ratio=0.1),\n Write(labels),\n run_time=2.5\n )\n self.wait(0.5)\n\n # --- Forward Propagation Visualization ---\n\n # Helper function to create and animate signal pulses between layers\n def propagate_signals(start_layer_idx, end_layer_idx, color=YELLOW):\n pulses = VGroup()\n animations = []\n start_neurons = neurons[start_layer_idx]\n end_neurons = neurons[end_layer_idx]\n \n for n1 in start_neurons:\n for n2 in end_neurons:\n dot = Dot(radius=0.06, color=color)\n dot.move_to(n1.get_center())\n path = Line(n1.get_center(), n2.get_center())\n pulses.add(dot)\n animations.append(MoveAlongPath(dot, path, run_time=1.5, rate_func=linear))\n \n self.add(pulses)\n self.play(LaggedStart(*animations, lag_ratio=0.05), run_time=2)\n self.remove(pulses)\n\n # Step 1: Input -> Hidden\n self.play(\n *[n.animate.set_fill(opacity=1.0, color=layer_colors[0]) for n in neurons[0]],\n run_time=0.5\n )\n propagate_signals(0, 1)\n self.play(\n layers[1].animate.set_fill(opacity=1.0),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Step 2: Hidden -> Output\n propagate_signals(1, 2)\n self.play(\n layers[2].animate.set_fill(opacity=1.0),\n run_time=0.5\n )\n self.wait(0.5)\n\n # Final Highlight\n output_text = Text(\"Output Generated\", font_size=30, color=WHITE)\n output_text.next_to(layers[2], UP, buff=0.5)\n self.play(FadeIn(output_text, shift=UP))\n self.wait(1)\n self.play(FadeOut(output_text))\n \n # Hold final state\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrating the step-by-step process of solving a triple integral. Start by showing the integral of the function xyz over the unit cube with limits from 0 to 1 for all variables. Then gradually integrate with respect to z, y, and finally x, each time updating the visual with the new integral expression after evaluating the previous variable. In between each step, have a short written explanation appear at the top saying which variable we're integrating with respect to next. After the final integration, display the numeric answer on the screen. Once the solution is shown, clear the screen momentarily before showing the final answer again. Can you create this animation in a smooth and understandable manner for teaching calculus students?", "chosen": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Configuration ---\n explanation_pos = UP * 3\n math_pos = ORIGIN\n \n color_x = RED\n color_y = GREEN\n color_z = BLUE\n\n # 1. Initial State\n # Display the full triple integral expression with color-coded variables\n initial_expr = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1\", \"x\", \"y\", \"z\", r\"\\, dz \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n initial_expr[1].set_color(color_x)\n initial_expr[2].set_color(color_y)\n initial_expr[3].set_color(color_z)\n \n self.play(Write(initial_expr))\n self.wait(2)\n\n # --- Step 1: Integrate w.r.t z ---\n step1_text = Text(\"Integrating with respect to z\", font_size=32, color=color_z).move_to(explanation_pos)\n \n # Highlight the variable being integrated\n self.play(initial_expr[3].animate.set_color(YELLOW).scale(1.1))\n self.play(Write(step1_text))\n self.play(initial_expr[3].animate.set_color(color_z).scale(1/1.1))\n \n # Intermediate step: showing the antiderivative and limits for z\n step1_eval = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{1}{2}xyz^2 \\right]_0^1 \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n # Result of the first integration\n step1_result = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}xy \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(initial_expr, step1_eval))\n self.wait(2)\n self.play(ReplacementTransform(step1_eval, step1_result))\n self.wait(2)\n\n # --- Step 2: Integrate w.r.t y ---\n step2_text = Text(\"Integrating with respect to y\", font_size=32, color=color_y).move_to(explanation_pos)\n \n # Intermediate step: showing the antiderivative and limits for y\n step2_eval = MathTex(\n r\"\\int_0^1 \\left[ \\frac{1}{4}xy^2 \\right]_0^1 \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n # Result of the second integration\n step2_result = MathTex(\n r\"\\int_0^1 \\frac{1}{4}x \\, dx\", \n font_size=48\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(step1_text, 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\n # --- Step 3: Integrate w.r.t x ---\n step3_text = Text(\"Integrating with respect to x\", font_size=32, color=color_x).move_to(explanation_pos)\n \n # Intermediate step: showing the antiderivative and limits for x\n step3_eval = MathTex(\n r\"\\left[ \\frac{1}{8}x^2 \\right]_0^1\", \n font_size=48\n ).move_to(math_pos)\n \n # Final numeric result\n final_result = MathTex(\n r\"\\frac{1}{8}\", \n font_size=60, \n color=YELLOW\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(step2_text, step3_text))\n self.play(ReplacementTransform(step2_result, step3_eval))\n self.wait(2)\n self.play(ReplacementTransform(step3_eval, final_result))\n self.wait(3)\n\n # --- Final Reveal ---\n # Clear the screen momentarily\n self.play(\n FadeOut(step3_text),\n FadeOut(final_result),\n run_time=1\n )\n self.wait(0.5)\n\n # Display the final numeric answer prominently\n final_reveal = MathTex(\n r\"\\text{Final Answer: } \\frac{1}{8}\", \n font_size=72, \n color=YELLOW\n ).move_to(ORIGIN)\n \n self.play(Write(final_reveal))\n self.play(Indicate(final_reveal))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass TripleIntegralSolution(Scene):\n def construct(self):\n # --- Configuration ---\n explanation_pos = UP * 3\n math_pos = ORIGIN\n \n color_x = RED\n color_y = GREEN\n color_z = BBLUE\n\n # 1. Initial State\n # Display the full triple integral expression with color-coded variables\n initial_expr = MathTex(\n r\"\\int_0^1 \\int_0^1 \\int_0^1\", \"x\", \"y\", \"z\", r\"\\, dz \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n initial_expr[1].set_color(color_x)\n initial_expr[2].set_color(color_y)\n initial_expr[3].set_color(color_z)\n \n self.play(Write(initial_expr))\n self.wait(2)\n\n # --- Step 1: Integrate w.r.t z ---\n step1_text = Text(\"Integrating with respect to z\", font_size=32, color=color_z).move_to(explanation_pos)\n \n # Highlight the variable being integrated\n self.play(initial_expr[3].animate.set_color(YELLOW).scale(1.1))\n self.play(Write(step1_text))\n self.play(initial_expr[3].animate.set_color(color_z).scale(1/1.1))\n \n # Intermediate step: showing the antiderivative and limits for z\n step1_eval = MathTex(\n r\"\\int_0^1 \\int_0^1 \\left[ \\frac{1}{2}xyz^2 \\right]_0^1 \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n # Result of the first integration\n step1_result = MathTex(\n r\"\\int_0^1 \\int_0^1 \\frac{1}{2}xy \\, dy \\, dx\", \n font_size=48\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(initial_expr, step1_eval))\n self.wait(2)\n self.play(ReplacementTransform(step1_eval, step1_result))\n self.wait(2)\n\n # --- Step 2: Integrate w.r.t y ---\n step2_text = Text(\"Integrating with respect to y\", font_size=32, color=color_y).move_to(explanation_pos)\n \n # Intermediate step: showing the antiderivative and limits for y\n step2_eval = MathTex(\n r\"\\int_0^1 \\left[ \\frac{1}{4}xy^2 \\right]_0^1 \\, dx\", \n font_size=48\n ).move_to(math_pos)\n \n # Result of the second integration\n step2_result = MathTex(\n r\"\\int_0^1 \\frac{1}{4}x \\, dx\", \n font_size=48\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(step1_text, 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\n # --- Step 3: Integrate w.r.t x ---\n step3_text = Text(\"Integrating with respect to x\", font_size=32, color=color_x).move_to(explanation_pos)\n \n # Intermediate step: showing the antiderivative and limits for x\n step3_eval = MathTex(\n r\"\\left[ \\frac{1}{8}x^2 \\right]_0^1\", \n font_size=48\n ).move_to(math_pos)\n \n # Final numeric result\n final_result = MathTex(\n r\"\\frac{1}{8}\", \n font_size=60, \n color=YELLOW\n ).move_to(math_pos)\n\n self.play(ReplacementTransform(step2_text, step3_text))\n self.play(ReplacementTransform(step2_result, step3_eval))\n self.wait(2)\n self.play(ReplacementTransform(step3_eval, final_result))\n self.wait(3)\n\n # --- Final Reveal ---\n # Clear the screen momentarily\n self.play(\n FadeOut(step3_text),\n FadeOut(final_result),\n run_time=1\n )\n self.wait(0.5)\n\n # Display the final numeric answer prominently\n final_reveal = MathTex(\n r\"\\text{Final Answer: } \\frac{1}{8}\", \n font_size=72, \n color=YELLOW\n ).move_to(ORIGIN)\n \n self.play(Write(final_reveal))\n self.play(Indicate(final_reveal))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 begins by smoothly transforming the initial text into the word \"FocusOn\" positioned at the top of the screen, while simultaneously fading in a colorful grid background that subtly pulses to draw attention. As the text transformation completes, the word \"Here!\" appears at the center with a gentle glow effect, upon which the FocusOn animation creates a dynamic, multi-colored circular ripple effect that expands outward. Simultaneously, a related mathematical formula (F(x) = e^(-x²) representing a focus function) materializes below the main text, with each component elegantly fading in and being highlighted in sequence. The \"Here!\" text then transforms into an animated magnifying glass icon that zooms in on the formula, while explanatory text appears to the side explaining the focus concept in physics and mathematics. Finally, all elements gracefully fade out while the original grid background transforms into a graph of the focus function, creating a cohesive visual narrative that connects the animation's components through both visual effects and mathematical context. The entire sequence maintains the original's clean transitions while adding educational depth and visual sophistication.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedFocusAnimation(Scene):\n def construct(self):\n # Create initial text and grid background\n initial_text = Text(\"Focus\").scale(1.5)\n final_text = Text(\"FocusOn\").scale(1.5).to_edge(UP)\n grid = NumberPlane(\n x_range=(-7, 7),\n y_range=(-4, 4),\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n ).fade(0.5)\n \n # Add pulsing effect to grid\n grid_pulse = always_redraw(lambda: grid.copy().set_stroke(opacity=0.7).scale(1.05))\n \n # Create main elements\n here_text = Text(\"Here!\", color=YELLOW).scale(1.8)\n formula = MathTex(\"F(x) = e^{-x^2}\").scale(1.5).next_to(final_text, DOWN, buff=1)\n formula.set_color_by_tex(\"F\", BLUE)\n formula.set_color_by_tex(\"e\", GREEN)\n formula.set_color_by_tex(\"-x^2\", RED)\n \n # Create magnifying glass\n magnifying_glass = VGroup(\n Circle(radius=0.5, color=WHITE),\n Line(ORIGIN, RIGHT*0.7).rotate(-PI/4).shift(LEFT*0.35 + UP*0.35)\n )\n \n # Create explanatory text\n explanation = VGroup(\n Text(\"Focus in Physics:\", color=BLUE),\n Text(\"- Concentration of energy\", color=WHITE, font_size=24),\n Text(\"- Point of convergence\", color=WHITE, font_size=24),\n Text(\"\"),\n Text(\"Mathematically:\", color=GREEN),\n Text(\"- Gaussian function\", color=WHITE, font_size=24),\n Text(\"- Describes distribution\", color=WHITE, font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT).scale(0.6).to_edge(RIGHT)\n \n # Create graph of the function\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[0, 1.2, 0.2],\n axis_config={\"color\": BLUE},\n ).scale(0.7).to_edge(DOWN)\n graph = axes.plot(lambda x: np.exp(-x**2), color=YELLOW)\n \n # Animation sequence\n self.play(Write(initial_text))\n self.play(\n Transform(initial_text, final_text),\n FadeIn(grid),\n FadeIn(grid_pulse),\n run_time=2\n )\n self.play(\n Flash(here_text, line_length=0.3, num_lines=12, color=YELLOW),\n FadeIn(here_text, scale=0.5),\n run_time=1.5\n )\n \n # Ripple effect\n circles = VGroup()\n colors = [BLUE, GREEN, YELLOW, RED]\n for i in range(4):\n circle = Circle(radius=0.1, color=colors[i], fill_opacity=0.2)\n circle.surround(here_text, buffer_factor=1.5)\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles]),\n run_time=2\n )\n self.play(\n circles.animate.scale(3).set_opacity(0),\n run_time=2\n )\n \n # Formula animation\n self.play(\n FadeIn(formula[0][:2]), # F(\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][2]), # x\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][3:5]), # ) =\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][5]), # e\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][6:]), # ^(-x^2)\n run_time=0.5\n )\n \n # Transform Here! to magnifying glass\n self.play(\n Transform(here_text, magnifying_glass),\n run_time=1.5\n )\n \n # Zoom effect on formula\n self.play(\n magnifying_glass.animate.next_to(formula, UP, buff=0.2),\n formula.animate.scale(1.3).set_color(WHITE),\n run_time=1.5\n )\n \n # Add explanation\n self.play(\n LaggedStart(*[FadeIn(line) for line in explanation]),\n run_time=2\n )\n \n # Fade out elements\n self.play(\n FadeOut(initial_text),\n FadeOut(magnifying_glass),\n FadeOut(formula),\n FadeOut(explanation),\n FadeOut(grid_pulse),\n grid.animate.set_stroke(opacity=0.2),\n run_time=2\n )\n \n # Show graph\n self.play(\n Create(axes),\n run_time=1\n )\n self.play(\n Create(graph),\n run_time=2\n )\n \n # Final fade out\n self.play(\n FadeOut(grid),\n FadeOut(axes),\n FadeOut(graph),\n run_time=2\n )\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass EnhancedFocusAnimation(Scene):\n def construct(self):\n # Create initial text and grid background\n initial_text = Text(\"Focus\").scale(1.5)\n final_text = Text(\"FocusOn\").scale(1.5).to_edge(UP)\n grid = NumberPlane(\n x_range=(-7, 7),\n y_range=(-4, 4),\n background_line_style={\n \"stroke_color\": TEAL,\n \"stroke_width\": 1,\n \"stroke_opacity\": 0.3\n }\n ).fade(0.5)\n \n # Add pulsing effect to grid\n grid_pulse = always_redraw(lambda: grid.copy().set_stroke(opacity=0.7).scale(1.05))\n \n # Create main elements\n here_text = Text(\"Here!\", color=YELLOW).scale(1.8)\n formula = MathText(\"F(x) = e^{-x^2}\").scale(1.5).next_to(final_text, DOWN, buff=1)\n formula.set_color_by_tex(\"F\", BLUE)\n formula.set_color_by_tex(\"e\", GREEN)\n formula.set_color_by_tex(\"-x^2\", RED)\n \n # Create magnifying glass\n magnifying_glass = VGroup(\n Circle(radius=0.5, color=WHITE),\n Line(ORIGIN, RIGHT*0.7).rotate(-PI/4).shift(LEFT*0.35 + UP*0.35)\n )\n \n # Create explanatory text\n explanation = VGroup(\n Text(\"Focus in Physics:\", color=BLUE),\n Text(\"- Concentration of energy\", color=WHITE, font_size=24),\n Text(\"- Point of convergence\", color=WHITE, font_size=24),\n Text(\"\"),\n Text(\"Mathematically:\", color=GREEN),\n Text(\"- Gaussian function\", color=WHITE, font_size=24),\n Text(\"- Describes distribution\", color=WHITE, font_size=24)\n ).arrange(DOWN, aligned_edge=LEFT).scale(0.6).to_edge(RIGHT)\n \n # Create graph of the function\n axes = Axes(\n x_range=[-3, 3, 1],\n y_range=[0, 1.2, 0.2],\n axis_config={\"color\": BLUE},\n ).scale(0.7).to_edge(DOWN)\n graph = axes.plot(lambda x: np.exp(-x**2), color=YELLOW)\n \n # Animation sequence\n self.play(Write(initial_text))\n self.play(\n Transform(initial_text, final_text),\n FadeIn(grid),\n FadeIn(grid_pulse),\n run_time=2\n )\n self.play(\n Flash(here_text, line_length=0.3, num_lines=12, color=YELLOW),\n FadeIn(here_text, scale=0.5),\n run_time=1.5\n )\n \n # Ripple effect\n circles = VGroup()\n colors = [BLUE, GREEN, YELLOW, RED]\n for i in range(4):\n circle = Circle(radius=0.1, color=colors[i], fill_opacity=0.2)\n circle.surround(here_text, buffer_factor=1.5)\n circles.add(circle)\n \n self.play(\n LaggedStart(*[Create(circle) for circle in circles]),\n run_time=2\n )\n self.play(\n circles.animate.scale(3).set_opacity(0),\n run_time=2\n )\n \n # Formula animation\n self.play(\n FadeIn(formula[0][:2]), # F(\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][2]), # x\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][3:5]), # ) =\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][5]), # e\n run_time=0.5\n )\n self.play(\n FadeIn(formula[0][6:]), # ^(-x^2)\n run_time=0.5\n )\n \n # Transform Here! to magnifying glass\n self.play(\n Transform(here_text, magnifying_glass),\n run_time=1.5\n )\n \n # Zoom effect on formula\n self.play(\n magnifying_glass.animate.next_to(formula, UP, buff=0.2),\n formula.animate.scale(1.3).set_color(WHITE),\n run_time=1.5\n )\n \n # Add explanation\n self.play(\n LaggedStart(*[FadeIn(line) for line in explanation]),\n run_time=2\n )\n \n # Fade out elements\n self.play(\n FadeOut(initial_text),\n FadeOut(magnifying_glass),\n FadeOut(formula),\n FadeOut(explanation),\n FadeOut(grid_pulse),\n grid.animate.set_stroke(opacity=0.2),\n run_time=2\n )\n \n # Show graph\n self.play(\n Create(axes),\n run_time=1\n )\n self.play(\n Create(graph),\n run_time=2\n )\n \n # Final fade out\n self.play(\n FadeOut(grid),\n FadeOut(axes),\n FadeOut(graph),\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 smoothly drawing a blue circle at the center of the screen, followed by the sequential appearance of a red equilateral triangle positioned around the circle. The circle and triangle are then grouped together and slowly rotate 360 degrees as a single unit, demonstrating their combined transformation. As they rotate, a mathematical formula (A = πr² for the circle and A = (√3/4)s² for the triangle) fades in below them, explaining how to calculate their respective areas. The shapes then separate, with the circle scaling up while the triangle morphs into a square, illustrating geometric transformation. Finally, text labels appear identifying each shape (\"Circle\" and \"Triangle → Square\"), and the animation concludes with all elements pulsing gently to emphasize their properties. This enhanced version maintains the original grouping and display of shapes while adding rotational movement, mathematical context, shape morphing, and explanatory text to create a more educational and visually engaging presentation.", "chosen": "```python\nfrom manim import *\n\nclass EnhancedShapeAnimation(Scene):\n def construct(self):\n # Create circle\n circle = Circle(color=BLUE, radius=1.5)\n circle.move_to(ORIGIN)\n \n # Create triangle\n triangle = Triangle(color=RED).scale(0.8)\n triangle.move_to(ORIGIN + 2.5 * RIGHT)\n \n # Animate drawing circle\n self.play(Create(circle), run_time=2)\n self.wait(0.5)\n \n # Animate drawing triangle\n self.play(Create(triangle), run_time=2)\n self.wait(0.5)\n \n # Group shapes\n group = VGroup(circle, triangle)\n \n # Rotate group\n self.play(Rotate(group, angle=2*PI, about_point=ORIGIN), run_time=4)\n self.wait(0.5)\n \n # Show formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n triangle_formula = MathTex(\"A = \\\\frac{\\\\sqrt{3}}{4}s^2\").next_to(triangle, DOWN)\n \n self.play(\n FadeIn(circle_formula),\n FadeIn(triangle_formula),\n run_time=2\n )\n self.wait(1)\n \n # Separate shapes and transform\n self.play(\n group.animate.scale(1.2),\n run_time=1.5\n )\n \n # Morph triangle to square\n square = Square(color=GREEN).scale(0.8)\n square.move_to(triangle.get_center())\n \n self.play(\n Transform(triangle, square),\n run_time=2\n )\n self.wait(0.5)\n \n # Add labels\n circle_label = Text(\"Circle\").next_to(circle, UP)\n square_label = Text(\"Triangle \\rightarrow Square\").next_to(square, UP)\n \n self.play(\n Write(circle_label),\n Write(square_label),\n run_time=2\n )\n self.wait(1)\n \n # Pulsing effect\n self.play(\n circle.animate.scale(1.1),\n triangle.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.1),\n triangle.animate.scale(1/1.1),\n run_time=0.5\n )\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass EnhancedShapeAnimation(Scene):\n def construct(self):\n # Create circle\n circle = Circle(color=BBLUE, radius=1.5)\n circle.move_to(ORIGIN)\n \n # Create triangle\n triangle = Triangle(color=RED).scale(0.8)\n triangle.move_to(ORIGIN + 2.5 * RIGHT)\n \n # Animate drawing circle\n self.play(Create(circle), run_time=2)\n self.wait(0.5)\n \n # Animate drawing triangle\n self.play(Create(triangle), run_time=2)\n self.wait(0.5)\n \n # Group shapes\n group = VGroup(circle, triangle)\n \n # Rotate group\n self.play(Rotate(group, angle=2*PI, about_point=ORIGIN), run_time=4)\n self.wait(0.5)\n \n # Show formulas\n circle_formula = MathTex(\"A = \\\\pi r^2\").next_to(circle, DOWN)\n triangle_formula = MathTex(\"A = \\\\frac{\\\\sqrt{3}}{4}s^2\").next_to(triangle, DOWN)\n \n self.play(\n FadeIn(circle_formula),\n FadeIn(triangle_formula),\n run_time=2\n )\n self.wait(1)\n \n # Separate shapes and transform\n self.play(\n group.animate.scale(1.2),\n run_time=1.5\n )\n \n # Morph triangle to square\n square = Square(color=GREEN).scale(0.8)\n square.move_to(triangle.get_center())\n \n self.play(\n Transform(triangle, square),\n run_time=2\n )\n self.wait(0.5)\n \n # Add labels\n circle_label = Text(\"Circle\").next_to(circle, UP)\n square_label = Text(\"Triangle \\rightarrow Square\").next_to(square, UP)\n \n self.play(\n Write(circle_label),\n Write(square_label),\n run_time=2\n )\n self.wait(1)\n \n # Pulsing effect\n self.play(\n circle.animate.scale(1.1),\n triangle.animate.scale(1.1),\n run_time=0.5\n )\n self.play(\n circle.animate.scale(1/1.1),\n triangle.animate.scale(1/1.1),\n run_time=0.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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. Introduction: Write the function f(x) = x^2 at the top of the screen\n func_text = MathTex(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\n )\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass IntegralAnimation(Scene):\n def construct(self):\n # 1. Introduction: Write the function f(x) = x^2 at the top of the screen\n func_text = MathText(r\"f(x) = x^2\").to_edge(UP)\n self.play(Write(func_text))\n self.wait(1)\n\n # 2. Plotting: Plot the graph of the function for x ranging from -2 to 2\n axes = Axes(\n x_range=[-2.5, 2.5, 1],\n y_range=[0, 4.5, 1],\n axis_config={\"include_tip\": True}\n )\n graph = axes.plot(lambda x: x**2, x_range=[-2, 2], color=YELLOW)\n self.play(Create(axes), Create(graph))\n self.wait(1)\n\n # 3. Area Indication & 5. Filling: \n # Indicate area under the curve between x=0 and x=1\n # Fill with a gradient transitioning from blue to green, maintaining partial transparency\n area = axes.get_area(graph, x_range=[0, 1], fill_opacity=0.5)\n area.set_color_by_gradient(BLUE, GREEN)\n self.play(FadeIn(area))\n self.wait(1)\n\n # 4. Labeling: Add a label showing the integral of x^2 from 0 to 1 positioned below the graph\n integral_text = MathTex(r\"\\int_{0}^{1} x^2 \\, dx\").next_to(axes, DOWN)\n self.play(Write(integral_text))\n self.wait(1)\n\n # 6. Transformation: Animate the transformation of the integral label into the exact calculated value (1/3)\n result_text = MathTex(r\"\\frac{1}{3}\").move_to(integral_text)\n self.play(ReplacementTransform(integral_text, result_text))\n self.wait(1)\n\n # 7. Final Placement: Move this solution value to the bottom of the screen\n self.play(result_text.animate.to_edge(DOWN, buff=1.0))\n self.wait(1)\n\n # 8. Conclusion: Clear the screen and display only the final solution for a brief moment\n self.play(\n FadeOut(func_text),\n FadeOut(axes),\n FadeOut(graph),\n FadeOut(area)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Examples of Common Mistakes\n- **Mathematical Consecutive Writing Error**: Continuous inequalities in mathematics cannot be directly translated into C++ code.\n - Incorrect approach:\n ```cpp\n if (0 < x < 10) // Logical error!\n ```\n *Explanation*: First, `0 < x` is evaluated to `0` or `1`, which is then compared to `10`, resulting in a constant true.\n - Correct approach:\n ```cpp\n if (0 < x && x < 10) // Must use logical AND to connect two independent conditions\n ```\n- **Lack of Logical Operator Associativity**:\n - Incorrect approach: `!a > 5` (First, `!a` is evaluated to `0` or `1`, then compared to `> 5`, resulting in a constant false);\n - Correct approach: `!(a > 5)`.\n\n\nThe context of this section (from highest to current level):\n# Chapter 3 Branching Program Design\n## Logical Expressions and Logical Operators\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CommonMistakes(Scene):\n\n def construct(self):\n title = Title('Examples of Common Mistakes')\n self.play(Write(title))\n self.wait(1)\n heading1 = Text('1. Mathematical Consecutive Writing Error', font_size=32, color=BLUE_C)\n heading1.next_to(title, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n self.play(Write(heading1))\n wrong_label1 = Text('Incorrect:', font_size=28, color=RED_C)\n wrong_code1 = Text('if (0 < x < 10)', font_size=28, color=YELLOW_C)\n wrong_group1 = VGroup(wrong_label1, wrong_code1).arrange(RIGHT, buff=0.3)\n wrong_group1.next_to(heading1, DOWN, buff=0.4).align_to(heading1, LEFT).shift(RIGHT * 0.5)\n self.play(FadeIn(wrong_group1))\n self.wait(1)\n eq1 = MathTex('0 < x', '< 10', font_size=40)\n eq1.next_to(wrong_group1, DOWN, buff=0.6).align_to(wrong_group1, LEFT)\n self.play(Write(eq1))\n brace1 = Brace(eq1[0], DOWN, color=GRAY)\n brace_text1 = brace1.get_text('Evaluates to 0 or 1').scale(0.7)\n self.play(GrowFromCenter(brace1), FadeIn(brace_text1))\n self.wait(1.5)\n eq1_step2 = MathTex('\\\\{0, 1\\\\}', '< 10', font_size=40)\n eq1_step2.move_to(eq1, aligned_edge=LEFT)\n self.play(ReplacementTransform(eq1[0], eq1_step2[0]), ReplacementTransform(eq1[1], eq1_step2[1]), FadeOut(brace1), FadeOut(brace_text1))\n result_text1 = Text('Always True! (Logical Error)', font_size=24, color=RED_A)\n result_text1.next_to(eq1_step2, RIGHT, buff=0.5)\n self.play(Write(result_text1))\n self.wait(1.5)\n correct_label1 = Text('Correct:', font_size=28, color=GREEN_C)\n correct_code1 = Text('if (0 < x && x < 10)', font_size=28, color=YELLOW_C)\n correct_group1 = VGroup(correct_label1, correct_code1).arrange(RIGHT, buff=0.3)\n correct_group1.next_to(eq1_step2, DOWN, buff=0.8).align_to(wrong_group1, LEFT)\n self.play(FadeIn(correct_group1))\n self.wait(3)\n self.play(FadeOut(heading1), FadeOut(wrong_group1), FadeOut(eq1_step2), FadeOut(result_text1), FadeOut(correct_group1))\n heading2 = Text('2. Lack of Logical Operator Associativity', font_size=32, color=BLUE_C)\n heading2.next_to(title, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n self.play(Write(heading2))\n wrong_label2 = Text('Incorrect:', font_size=28, color=RED_C)\n wrong_code2 = Text('!a > 5', font_size=28, color=YELLOW_C)\n wrong_group2 = VGroup(wrong_label2, wrong_code2).arrange(RIGHT, buff=0.3)\n wrong_group2.next_to(heading2, DOWN, buff=0.4).align_to(heading2, LEFT).shift(RIGHT * 0.5)\n self.play(FadeIn(wrong_group2))\n self.wait(1)\n eq2 = MathTex('!a', '> 5', font_size=40)\n eq2.next_to(wrong_group2, DOWN, buff=0.6).align_to(wrong_group2, LEFT)\n self.play(Write(eq2))\n brace2 = Brace(eq2[0], DOWN, color=GRAY)\n brace_text2 = brace2.get_text('Evaluates to 0 or 1').scale(0.7)\n self.play(GrowFromCenter(brace2), FadeIn(brace_text2))\n self.wait(1.5)\n eq2_step2 = MathTex('\\\\{0, 1\\\\}', '> 5', font_size=40)\n eq2_step2.move_to(eq2, aligned_edge=LEFT)\n self.play(ReplacementTransform(eq2[0], eq2_step2[0]), ReplacementTransform(eq2[1], eq2_step2[1]), FadeOut(brace2), FadeOut(brace_text2))\n result_text2 = Text('Always False!', font_size=24, color=RED_A)\n result_text2.next_to(eq2_step2, RIGHT, buff=0.5)\n self.play(Write(result_text2))\n self.wait(1.5)\n correct_label2 = Text('Correct:', font_size=28, color=GREEN_C)\n correct_code2 = Text('!(a > 5)', font_size=28, color=YELLOW_C)\n correct_group2 = VGroup(correct_label2, correct_code2).arrange(RIGHT, buff=0.3)\n correct_group2.next_to(eq2_step2, DOWN, buff=0.8).align_to(wrong_group2, LEFT)\n self.play(FadeIn(correct_group2))\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass CommonMistakes(Scene):\n\n def construct(self):\n title = Title('Examples of Common Mistakes')\n self.play(Write(title))\n self.wait(1)\n heading1 = Text('1. Mathematical Consecutive Writing Error', font_size=32, color=BBLUE_C)\n heading1.next_to(title, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n self.play(Write(heading1))\n wrong_label1 = Text('Incorrect:', font_size=28, color=RED_C)\n wrong_code1 = Text('if (0 < x < 10)', font_size=28, color=YELLOW_C)\n wrong_group1 = VGroup(wrong_label1, wrong_code1).arrange(RIGHT, buff=0.3)\n wrong_group1.next_to(heading1, DOWN, buff=0.4).align_to(heading1, LEFT).shift(RIGHT * 0.5)\n self.play(FadeIn(wrong_group1))\n self.wait(1)\n eq1 = MathTex('0 < x', '< 10', font_size=40)\n eq1.next_to(wrong_group1, DOWN, buff=0.6).align_to(wrong_group1, LEFT)\n self.play(Write(eq1))\n brace1 = Brace(eq1[0], DOWN, color=GRAY)\n brace_text1 = brace1.get_text('Evaluates to 0 or 1').scale(0.7)\n self.play(GrowFromCenter(brace1), FadeIn(brace_text1))\n self.wait(1.5)\n eq1_step2 = MathTex('\\\\{0, 1\\\\}', '< 10', font_size=40)\n eq1_step2.move_to(eq1, aligned_edge=LEFT)\n self.play(ReplacementTransform(eq1[0], eq1_step2[0]), ReplacementTransform(eq1[1], eq1_step2[1]), FadeOut(brace1), FadeOut(brace_text1))\n result_text1 = Text('Always True! (Logical Error)', font_size=24, color=RED_A)\n result_text1.next_to(eq1_step2, RIGHT, buff=0.5)\n self.play(Write(result_text1))\n self.wait(1.5)\n correct_label1 = Text('Correct:', font_size=28, color=GREEN_C)\n correct_code1 = Text('if (0 < x && x < 10)', font_size=28, color=YELLOW_C)\n correct_group1 = VGroup(correct_label1, correct_code1).arrange(RIGHT, buff=0.3)\n correct_group1.next_to(eq1_step2, DOWN, buff=0.8).align_to(wrong_group1, LEFT)\n self.play(FadeIn(correct_group1))\n self.wait(3)\n self.play(FadeOut(heading1), FadeOut(wrong_group1), FadeOut(eq1_step2), FadeOut(result_text1), FadeOut(correct_group1))\n heading2 = Text('2. Lack of Logical Operator Associativity', font_size=32, color=BLUE_C)\n heading2.next_to(title, DOWN, buff=0.5).to_edge(LEFT, buff=1)\n self.play(Write(heading2))\n wrong_label2 = Text('Incorrect:', font_size=28, color=RED_C)\n wrong_code2 = Text('!a > 5', font_size=28, color=YELLOW_C)\n wrong_group2 = VGroup(wrong_label2, wrong_code2).arrange(RIGHT, buff=0.3)\n wrong_group2.next_to(heading2, DOWN, buff=0.4).align_to(heading2, LEFT).shift(RIGHT * 0.5)\n self.play(FadeIn(wrong_group2))\n self.wait(1)\n eq2 = MathTex('!a', '> 5', font_size=40)\n eq2.next_to(wrong_group2, DOWN, buff=0.6).align_to(wrong_group2, LEFT)\n self.play(Write(eq2))\n brace2 = Brace(eq2[0], DOWN, color=GRAY)\n brace_text2 = brace2.get_text('Evaluates to 0 or 1').scale(0.7)\n self.play(GrowFromCenter(brace2), FadeIn(brace_text2))\n self.wait(1.5)\n eq2_step2 = MathTex('\\\\{0, 1\\\\}', '> 5', font_size=40)\n eq2_step2.move_to(eq2, aligned_edge=LEFT)\n self.play(ReplacementTransform(eq2[0], eq2_step2[0]), ReplacementTransform(eq2[1], eq2_step2[1]), FadeOut(brace2), FadeOut(brace_text2))\n result_text2 = Text('Always False!', font_size=24, color=RED_A)\n result_text2.next_to(eq2_step2, RIGHT, buff=0.5)\n self.play(Write(result_text2))\n self.wait(1.5)\n correct_label2 = Text('Correct:', font_size=28, color=GREEN_C)\n correct_code2 = Text('!(a > 5)', font_size=28, color=YELLOW_C)\n correct_group2 = VGroup(correct_label2, correct_code2).arrange(RIGHT, buff=0.3)\n correct_group2.next_to(eq2_step2, DOWN, buff=0.8).align_to(wrong_group2, LEFT)\n self.play(FadeIn(correct_group2))\n self.wait(3)\n self.play(FadeOut(Group(*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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a Manim math scene that displays the product rule and moves a surrounding highlight box from one derivative term to the other.", "chosen": "```python\nfrom manim import *\n\nclass MovingFrameBox(Scene):\n def construct(self):\n text=MathTex(\n \"\\\\frac{d}{dx}f(x)g(x)=\",\"f(x)\\\\frac{d}{dx}g(x)\",\"+\",\n \"g(x)\\\\frac{d}{dx}f(x)\"\n )\n self.play(Write(text))\n framebox1 = SurroundingRectangle(text[1], buff = .1)\n framebox2 = SurroundingRectangle(text[3], buff = .1)\n self.play(\n Create(framebox1),\n )\n self.wait()\n self.play(\n ReplacementTransform(framebox1,framebox2),\n )\n self.wait()\n```", "rejected": "```python\nfrom manim import *\n\nclass MovingFrameBox(Scene):\n def construct(self):\n text=MathText(\n \"\\\\frac{d}{dx}f(x)g(x)=\",\"f(x)\\\\frac{d}{dx}g(x)\",\"+\",\n \"g(x)\\\\frac{d}{dx}f(x)\"\n )\n self.play(Write(text))\n framebox1 = SurroundingRectangle(text[1], buff = .1)\n framebox2 = SurroundingRectangle(text[3], buff = .1)\n self.play(\n Create(framebox1),\n )\n self.wait()\n self.play(\n ReplacementTransform(framebox1,framebox2),\n )\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using Manim that introduces the concept of prime factors? I'd like the animation to include a title \"Fatores Primos\" at the top, and below that, show the number 60 broken down into its prime factors (2, 2, 3, and 5) with each prime factor highlighted in a different color. Additionally, can you add an annotation below the factors with the words \"Fatores Primos\" and include a brace emphasizing the group of prime factors? Make sure the background is a pleasant off-white and the text colors are easy on the eyes, with the prime factors standing out.", "chosen": "```python\nfrom manim import *\n\nclass PrimeFactorsScene(Scene):\n def construct(self):\n # 1. Scene Setup: Pleasant off-white background\n self.camera.background_color = \"#F5F5F5\"\n\n # Define eye-friendly colors\n text_color = \"#333333\" # Dark charcoal for soft contrast\n symbol_color = \"#555555\" # Medium gray for multiplication symbols\n\n # 2. Title: \"Fatores Primos\" at the top\n title = Text(\n \"Fatores Primos\", \n font_size=48, \n color=text_color\n )\n title.to_edge(UP)\n\n # 3. Factorization Visualization\n # Initial number\n number_60 = MathTex(\"60\", font_size=72, color=text_color)\n number_60.move_to(ORIGIN)\n\n # Prime factors: 2, 2, 3, 5\n # Assign distinct, eye-friendly colors to each prime factor instance\n factor_2a = MathTex(\"2\", font_size=72, color=\"#4C72B0\") # Blue\n times_1 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_2b = MathTex(\"2\", font_size=72, color=\"#55A34E\") # Green\n times_2 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_3 = MathTex(\"3\", font_size=72, color=\"#DD8452\") # Orange\n times_3 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_5 = MathTex(\"5\", font_size=72, color=\"#C44E52\") # Red\n\n # Group and arrange the factors\n factors_group = VGroup(\n factor_2a, times_1, factor_2b, times_2, \n factor_3, times_3, factor_5\n )\n factors_group.arrange(RIGHT, buff=0.4)\n factors_group.move_to(ORIGIN)\n\n # 4. Annotation: Brace and label below the factors\n brace = Brace(factors_group, DOWN, color=symbol_color)\n annotation = Text(\n \"Fatores Primos\", \n font_size=36, \n color=text_color\n )\n annotation.next_to(brace, DOWN, buff=0.2)\n\n # --- Animation Sequence ---\n \n # Display Title\n self.play(Write(title))\n self.wait(0.5)\n\n # Show the number 60\n self.play(Write(number_60))\n self.wait(1)\n\n # Animate the breakdown of 60 into its prime factors\n self.play(\n ReplacementTransform(number_60, factors_group),\n run_time=1.5\n )\n self.wait(1)\n\n # Optional emphasis: pulse the prime factors\n prime_factors = [factor_2a, factor_2b, factor_3, factor_5]\n self.play(\n *[factor.animate.scale(1.1) for factor in prime_factors],\n run_time=0.5\n )\n self.play(\n *[factor.animate.scale(1 / 1.1) for factor in prime_factors],\n run_time=0.5\n )\n\n # Draw the brace and annotation\n self.play(\n GrowFromCenter(brace),\n Write(annotation),\n run_time=1.5\n )\n\n # Final pause to let the viewer absorb the information\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass PrimeFactorsScene(Scene):\n def construct(self):\n # 1. Scene Setup: Pleasant off-white background\n self.camera.background_color = \"#F5F5F5\"\n\n # Define eye-friendly colors\n text_color = \"#333333\" # Dark charcoal for soft contrast\n symbol_color = \"#555555\" # Medium gray for multiplication symbols\n\n # 2. Title: \"Fatores Primos\" at the top\n title = Text(\n \"Fatores Primos\", \n font_size=48, \n color=text_color\n )\n title.to_edge(UP)\n\n # 3. Factorization Visualization\n # Initial number\n number_60 = MathText(\"60\", font_size=72, color=text_color)\n number_60.move_to(ORIGIN)\n\n # Prime factors: 2, 2, 3, 5\n # Assign distinct, eye-friendly colors to each prime factor instance\n factor_2a = MathTex(\"2\", font_size=72, color=\"#4C72B0\") # Blue\n times_1 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_2b = MathTex(\"2\", font_size=72, color=\"#55A34E\") # Green\n times_2 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_3 = MathTex(\"3\", font_size=72, color=\"#DD8452\") # Orange\n times_3 = MathTex(\"\\\\times\", font_size=72, color=symbol_color)\n factor_5 = MathTex(\"5\", font_size=72, color=\"#C44E52\") # Red\n\n # Group and arrange the factors\n factors_group = VGroup(\n factor_2a, times_1, factor_2b, times_2, \n factor_3, times_3, factor_5\n )\n factors_group.arrange(RIGHT, buff=0.4)\n factors_group.move_to(ORIGIN)\n\n # 4. Annotation: Brace and label below the factors\n brace = Brace(factors_group, DOWN, color=symbol_color)\n annotation = Text(\n \"Fatores Primos\", \n font_size=36, \n color=text_color\n )\n annotation.next_to(brace, DOWN, buff=0.2)\n\n # --- Animation Sequence ---\n \n # Display Title\n self.play(Write(title))\n self.wait(0.5)\n\n # Show the number 60\n self.play(Write(number_60))\n self.wait(1)\n\n # Animate the breakdown of 60 into its prime factors\n self.play(\n ReplacementTransform(number_60, factors_group),\n run_time=1.5\n )\n self.wait(1)\n\n # Optional emphasis: pulse the prime factors\n prime_factors = [factor_2a, factor_2b, factor_3, factor_5]\n self.play(\n *[factor.animate.scale(1.1) for factor in prime_factors],\n run_time=0.5\n )\n self.play(\n *[factor.animate.scale(1 / 1.1) for factor in prime_factors],\n run_time=0.5\n )\n\n # Draw the brace and annotation\n self.play(\n GrowFromCenter(brace),\n Write(annotation),\n run_time=1.5\n )\n\n # Final pause to let the viewer absorb the information\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Pythagorean theorem by showing a right triangle with sides labeled 'a', 'b', and 'c' where 'c' is the hypotenuse? Alongside each side of the triangle, display a square with side lengths equal to the corresponding sides of the triangle, with the areas 'a^2', 'b^2', and 'c^2' labeled inside the squares. Finally, present the theorem's formula 'a^2 + b^2 = c^2' at the bottom of the screen and then clear everything after a short pause.", "chosen": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # 1. Draw the Triangle (3-4-5 right triangle for clear integer ratios)\n A = ORIGIN\n B = RIGHT * 3\n C = UP * 4\n \n triangle = Polygon(A, B, C, color=WHITE, stroke_width=4)\n \n # Define sides for square placement\n side_a = Line(A, B) # Base\n side_b = Line(B, C) # Height\n side_c = Line(C, A) # Hypotenuse\n \n # Label and color-code sides\n label_a = MathTex(\"a\", color=BLUE).next_to(side_a, DOWN, buff=0.2)\n label_b = MathTex(\"b\", color=GREEN).next_to(side_b, RIGHT, buff=0.2)\n label_c = MathTex(\"c\", color=ORANGE).next_to(side_c, LEFT, buff=0.2)\n \n self.play(Create(triangle), Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # 2. Add Squares\n # Square on side 'a' (Base)\n square_a = Square(side_length=3, color=BLUE, fill_opacity=0.3)\n square_a.next_to(side_a, DOWN, buff=0)\n square_a.align_to(side_a, LEFT)\n \n # Square on side 'b' (Height)\n square_b = Square(side_length=4, color=GREEN, fill_opacity=0.3)\n square_b.next_to(side_b, RIGHT, buff=0)\n square_b.align_to(side_b, DOWN)\n \n # Square on side 'c' (Hypotenuse)\n square_c = Square(side_length=5, color=ORANGE, fill_opacity=0.3)\n square_c.move_to(midpoint(C, A))\n square_c.rotate(side_c.get_angle() + PI/2)\n \n self.play(Create(square_a), Create(square_b), Create(square_c), run_time=2)\n self.wait(1)\n \n # 3. Label Areas\n area_a = MathTex(\"a^2\", color=WHITE).move_to(square_a.get_center())\n area_b = MathTex(\"b^2\", color=WHITE).move_to(square_b.get_center())\n area_c = MathTex(\"c^2\", color=WHITE).move_to(square_c.get_center())\n \n self.play(Write(area_a), Write(area_b), Write(area_c), run_time=1.5)\n self.wait(2)\n \n # 4. Show Formula\n formula = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=48)\n formula[0].set_color(BLUE)\n formula[2].set_color(GREEN)\n formula[4].set_color(ORANGE)\n formula.to_edge(DOWN, buff=1)\n \n box = SurroundingRectangle(formula, color=WHITE, buff=0.3)\n \n self.play(Write(formula), Create(box))\n self.wait(3)\n \n # 5. Clear Screen\n all_elements = VGroup(\n triangle, label_a, label_b, label_c,\n square_a, square_b, square_c,\n area_a, area_b, area_c,\n formula, box\n )\n self.play(FadeOut(all_elements))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # 1. Draw the Triangle (3-4-5 right triangle for clear integer ratios)\n A = ORIGIN\n B = RIGHT * 3\n C = UP * 4\n \n triangle = Polygon(A, B, C, color=WHITE, stroke_width=4)\n \n # Define sides for square placement\n side_a = Line(A, B) # Base\n side_b = Line(B, C) # Height\n side_c = Line(C, A) # Hypotenuse\n \n # Label and color-code sides\n label_a = MathText(\"a\", color=BLUE).next_to(side_a, DOWN, buff=0.2)\n label_b = MathTex(\"b\", color=GREEN).next_to(side_b, RIGHT, buff=0.2)\n label_c = MathTex(\"c\", color=ORANGE).next_to(side_c, LEFT, buff=0.2)\n \n self.play(Create(triangle), Write(label_a), Write(label_b), Write(label_c))\n self.wait(1)\n \n # 2. Add Squares\n # Square on side 'a' (Base)\n square_a = Square(side_length=3, color=BLUE, fill_opacity=0.3)\n square_a.next_to(side_a, DOWN, buff=0)\n square_a.align_to(side_a, LEFT)\n \n # Square on side 'b' (Height)\n square_b = Square(side_length=4, color=GREEN, fill_opacity=0.3)\n square_b.next_to(side_b, RIGHT, buff=0)\n square_b.align_to(side_b, DOWN)\n \n # Square on side 'c' (Hypotenuse)\n square_c = Square(side_length=5, color=ORANGE, fill_opacity=0.3)\n square_c.move_to(midpoint(C, A))\n square_c.rotate(side_c.get_angle() + PI/2)\n \n self.play(Create(square_a), Create(square_b), Create(square_c), run_time=2)\n self.wait(1)\n \n # 3. Label Areas\n area_a = MathTex(\"a^2\", color=WHITE).move_to(square_a.get_center())\n area_b = MathTex(\"b^2\", color=WHITE).move_to(square_b.get_center())\n area_c = MathTex(\"c^2\", color=WHITE).move_to(square_c.get_center())\n \n self.play(Write(area_a), Write(area_b), Write(area_c), run_time=1.5)\n self.wait(2)\n \n # 4. Show Formula\n formula = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=48)\n formula[0].set_color(BLUE)\n formula[2].set_color(GREEN)\n formula[4].set_color(ORANGE)\n formula.to_edge(DOWN, buff=1)\n \n box = SurroundingRectangle(formula, color=WHITE, buff=0.3)\n \n self.play(Write(formula), Create(box))\n self.wait(3)\n \n # 5. Clear Screen\n all_elements = VGroup(\n triangle, label_a, label_b, label_c,\n square_a, square_b, square_c,\n area_a, area_b, area_c,\n formula, box\n )\n self.play(FadeOut(all_elements))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 chemistry animation that visually represents an electrochemical concept. The animation should start with a 3x3 grid of lithium ions to demonstrate the initial state of a battery's electrode. Then, it should transition to a single layer of carbon atoms to represent another electrode. Additionally, I want to include separate animations of an oxygen molecule and a metallic element, cobalt, symbolizing their interactions in the chemical process; have them appear one by one on opposite sides of the screen. \n\nFurthermore, animate the oxygen molecule moving in a triangular path to depict some sort of molecular motion or reaction pathway, showing the dynamic nature of the chemical processes within a battery. Please make sure the elements and ions are correctly labeled with their chemical symbols and charges, make it visually clear, and ensure that the animation runs smoothly and is visually engaging for students learning about chemistry.", "chosen": "```python\nfrom manim import *\n\nclass ElectrochemicalConcept(Scene):\n \"\"\"\n Educational animation representing electrochemical concepts:\n - Lithium ion grid (Initial state)\n - Carbon electrode layer\n - Oxygen and Cobalt interactions\n - Molecular motion of Oxygen\n \"\"\"\n\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Colors and Constants\n # ------------------------------------------------------------------\n COLOR_LI = GREY\n COLOR_C = LIGHT_GREY # Light grey for visibility against black background\n COLOR_O = RED\n COLOR_CO = DARK_GREY\n \n ATOM_RADIUS = 0.4\n\n # ------------------------------------------------------------------\n # 2. Create Lithium Ion Grid (3x3)\n # ------------------------------------------------------------------\n li_ions = VGroup()\n for i in range(3):\n for j in range(3):\n # Create the ion circle\n ion = Circle(radius=ATOM_RADIUS, color=COLOR_LI, fill_opacity=0.8)\n # Create the label with correct charge superscript\n label = MathTex(\"Li^+\", color=BLACK).scale(0.8)\n # Group circle and label\n ion_group = VGroup(ion, label)\n # Position in a 3x3 grid\n ion_group.move_to([j * 1.2 - 1.2, i * 1.2 - 1.2, 0])\n li_ions.add(ion_group)\n \n # Title for initial state\n title_li = Text(\"Lithium Electrode (Anode)\", font_size=24).to_edge(UP)\n\n # ------------------------------------------------------------------\n # 3. Create Carbon Electrode Layer\n # ------------------------------------------------------------------\n # Representing a single layer (graphene-like hexagonal arrangement)\n carbon_layer = VGroup()\n c_positions = [\n [0, 0, 0],\n [1, 0.5, 0],\n [-1, 0.5, 0],\n [1, -0.5, 0],\n [-1, -0.5, 0],\n [2, 0, 0],\n [-2, 0, 0]\n ]\n for pos in c_positions:\n atom = Circle(radius=ATOM_RADIUS, color=COLOR_C, fill_opacity=1.0)\n atom.move_to(pos)\n atom.set_stroke(color=BLACK, width=2)\n label = MathTex(\"C\", color=BLACK).scale(0.6).move_to(pos)\n carbon_layer.add(atom, label)\n \n carbon_layer.move_to(li_ions.get_center())\n \n title_c = Text(\"Carbon Electrode (Cathode)\", font_size=24).to_edge(UP)\n\n # ------------------------------------------------------------------\n # 4. Create Oxygen Molecule (O2)\n # ------------------------------------------------------------------\n o_atom1 = Circle(radius=0.35, color=COLOR_O, fill_opacity=0.9)\n o_atom2 = Circle(radius=0.35, color=COLOR_O, fill_opacity=0.9)\n o_bond = Line(start=o_atom1.get_center(), end=o_atom2.get_center(), color=COLOR_O, stroke_width=4)\n \n # Position atoms relative to each other\n o_atom1.move_to(LEFT * 0.5)\n o_atom2.move_to(RIGHT * 0.5)\n o_bond.put_start_and_end_on(o_atom1.get_center(), o_atom2.get_center())\n \n o2_label = MathTex(\"O_2\", color=WHITE).scale(0.8).next_to(o_atom1, DOWN, buff=0.2)\n oxygen_molecule = VGroup(o_atom1, o_atom2, o_bond, o2_label)\n oxygen_molecule.move_to(LEFT * 5) # Start off-screen left\n\n # ------------------------------------------------------------------\n # 5. Create Cobalt Element (Co)\n # ------------------------------------------------------------------\n co_atom = Circle(radius=0.4, color=COLOR_CO, fill_opacity=0.9)\n co_atom.set_stroke(color=WHITE, width=2)\n co_label = MathTex(\"Co\", color=WHITE).scale(0.8).next_to(co_atom, DOWN, buff=0.2)\n cobalt_element = VGroup(co_atom, co_label)\n cobalt_element.move_to(RIGHT * 5) # Start off-screen right\n\n # ------------------------------------------------------------------\n # 6. Define Triangular Path for Oxygen\n # ------------------------------------------------------------------\n # Define vertices for the triangle path (will be moved to O2's position later)\n triangle_path = Polygon(\n [0, 1, 0],\n [-1.5, -1, 0],\n [1.5, -1, 0],\n color=WHITE,\n stroke_opacity=0.3,\n stroke_width=2\n )\n\n # ------------------------------------------------------------------\n # 7. Animation Sequence\n # ------------------------------------------------------------------\n \n # Step 1: Show Lithium Grid\n self.play(Write(title_li))\n self.play(LaggedStartMap(FadeIn, li_ions, lag_ratio=0.1))\n self.wait(1)\n \n # Step 2: Transition to Carbon Layer\n self.play(FadeOut(title_li), FadeIn(title_c))\n self.play(FadeOut(li_ions), FadeIn(carbon_layer))\n self.wait(1)\n \n # Step 3: Introduce Oxygen and Cobalt on opposite sides\n # Oxygen enters from Left\n self.play(oxygen_molecule.animate.move_to(LEFT * 3))\n self.wait(0.5)\n \n # Cobalt enters from Right\n self.play(cobalt_element.animate.move_to(RIGHT * 3))\n self.wait(1)\n \n # Step 4: Animate Oxygen Molecular Motion (Triangular Path)\n # Center the path around the oxygen molecule's current position\n triangle_path.move_to(oxygen_molecule.get_center())\n \n # Show the path faintly to guide the student's eye\n self.play(Create(triangle_path))\n \n # Move the oxygen molecule along the path\n self.play(\n MoveAlongPath(oxygen_molecule, triangle_path),\n run_time=4,\n rate_func=linear\n )\n \n # Final hold to let students observe the final state\n self.wait(2)\n \n # Fade out everything cleanly\n self.play(FadeOut(VGroup(title_c, carbon_layer, oxygen_molecule, cobalt_element, triangle_path)))\n\n# To run this code, use:\n# manim -pql filename.py ElectrochemicalConcept\n```", "rejected": "```python\nfrom manim import *\n\nclass ElectrochemicalConcept(Scene):\n \"\"\"\n Educational animation representing electrochemical concepts:\n - Lithium ion grid (Initial state)\n - Carbon electrode layer\n - Oxygen and Cobalt interactions\n - Molecular motion of Oxygen\n \"\"\"\n\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Setup Colors and Constants\n # ------------------------------------------------------------------\n COLOR_LI = GREY\n COLOR_C = LIGHT_GREY # Light grey for visibility against black background\n COLOR_O = RED\n COLOR_CO = DARK_GREY\n \n ATOM_RADIUS = 0.4\n\n # ------------------------------------------------------------------\n # 2. Create Lithium Ion Grid (3x3)\n # ------------------------------------------------------------------\n li_ions = VGroup()\n for i in range(3):\n for j in range(3):\n # Create the ion circle\n ion = Circle(radius=ATOM_RADIUS, color=COLOR_LI, fill_opacity=0.8)\n # Create the label with correct charge superscript\n label = MathText(\"Li^+\", color=BLACK).scale(0.8)\n # Group circle and label\n ion_group = VGroup(ion, label)\n # Position in a 3x3 grid\n ion_group.move_to([j * 1.2 - 1.2, i * 1.2 - 1.2, 0])\n li_ions.add(ion_group)\n \n # Title for initial state\n title_li = Text(\"Lithium Electrode (Anode)\", font_size=24).to_edge(UP)\n\n # ------------------------------------------------------------------\n # 3. Create Carbon Electrode Layer\n # ------------------------------------------------------------------\n # Representing a single layer (graphene-like hexagonal arrangement)\n carbon_layer = VGroup()\n c_positions = [\n [0, 0, 0],\n [1, 0.5, 0],\n [-1, 0.5, 0],\n [1, -0.5, 0],\n [-1, -0.5, 0],\n [2, 0, 0],\n [-2, 0, 0]\n ]\n for pos in c_positions:\n atom = Circle(radius=ATOM_RADIUS, color=COLOR_C, fill_opacity=1.0)\n atom.move_to(pos)\n atom.set_stroke(color=BLACK, width=2)\n label = MathTex(\"C\", color=BLACK).scale(0.6).move_to(pos)\n carbon_layer.add(atom, label)\n \n carbon_layer.move_to(li_ions.get_center())\n \n title_c = Text(\"Carbon Electrode (Cathode)\", font_size=24).to_edge(UP)\n\n # ------------------------------------------------------------------\n # 4. Create Oxygen Molecule (O2)\n # ------------------------------------------------------------------\n o_atom1 = Circle(radius=0.35, color=COLOR_O, fill_opacity=0.9)\n o_atom2 = Circle(radius=0.35, color=COLOR_O, fill_opacity=0.9)\n o_bond = Line(start=o_atom1.get_center(), end=o_atom2.get_center(), color=COLOR_O, stroke_width=4)\n \n # Position atoms relative to each other\n o_atom1.move_to(LEFT * 0.5)\n o_atom2.move_to(RIGHT * 0.5)\n o_bond.put_start_and_end_on(o_atom1.get_center(), o_atom2.get_center())\n \n o2_label = MathTex(\"O_2\", color=WHITE).scale(0.8).next_to(o_atom1, DOWN, buff=0.2)\n oxygen_molecule = VGroup(o_atom1, o_atom2, o_bond, o2_label)\n oxygen_molecule.move_to(LEFT * 5) # Start off-screen left\n\n # ------------------------------------------------------------------\n # 5. Create Cobalt Element (Co)\n # ------------------------------------------------------------------\n co_atom = Circle(radius=0.4, color=COLOR_CO, fill_opacity=0.9)\n co_atom.set_stroke(color=WHITE, width=2)\n co_label = MathTex(\"Co\", color=WHITE).scale(0.8).next_to(co_atom, DOWN, buff=0.2)\n cobalt_element = VGroup(co_atom, co_label)\n cobalt_element.move_to(RIGHT * 5) # Start off-screen right\n\n # ------------------------------------------------------------------\n # 6. Define Triangular Path for Oxygen\n # ------------------------------------------------------------------\n # Define vertices for the triangle path (will be moved to O2's position later)\n triangle_path = Polygon(\n [0, 1, 0],\n [-1.5, -1, 0],\n [1.5, -1, 0],\n color=WHITE,\n stroke_opacity=0.3,\n stroke_width=2\n )\n\n # ------------------------------------------------------------------\n # 7. Animation Sequence\n # ------------------------------------------------------------------\n \n # Step 1: Show Lithium Grid\n self.play(Write(title_li))\n self.play(LaggedStartMap(FadeIn, li_ions, lag_ratio=0.1))\n self.wait(1)\n \n # Step 2: Transition to Carbon Layer\n self.play(FadeOut(title_li), FadeIn(title_c))\n self.play(FadeOut(li_ions), FadeIn(carbon_layer))\n self.wait(1)\n \n # Step 3: Introduce Oxygen and Cobalt on opposite sides\n # Oxygen enters from Left\n self.play(oxygen_molecule.animate.move_to(LEFT * 3))\n self.wait(0.5)\n \n # Cobalt enters from Right\n self.play(cobalt_element.animate.move_to(RIGHT * 3))\n self.wait(1)\n \n # Step 4: Animate Oxygen Molecular Motion (Triangular Path)\n # Center the path around the oxygen molecule's current position\n triangle_path.move_to(oxygen_molecule.get_center())\n \n # Show the path faintly to guide the student's eye\n self.play(Create(triangle_path))\n \n # Move the oxygen molecule along the path\n self.play(\n MoveAlongPath(oxygen_molecule, triangle_path),\n run_time=4,\n rate_func=linear\n )\n \n # Final hold to let students observe the final state\n self.wait(2)\n \n # Fade out everything cleanly\n self.play(FadeOut(VGroup(title_c, carbon_layer, oxygen_molecule, cobalt_element, triangle_path)))\n\n# To run this code, use:\n# manim -pql filename.py ElectrochemicalConcept\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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### Process Creation on Windows and Other Systems\n- Windows uses `CreateProcess`, which has complex parameters and completes both creation and loading in one step;\n- Although it does not separate fork and exec like Unix systems, it still involves the creation of a Process Control Block (PCB), allocation of address space, and program loading at the lower level.\n\n## Overview of Inter-Process Communication (IPC)\n\n### Why IPC is Needed\nA bridge to break isolation:\n- Processes have independent address spaces and cannot directly read or write each other's memory;\n- Requires the operating system to provide a common buffer or mechanism for data exchange.\n\n\nThe context of this section (from highest to current level):\n# Fundamentals of Processes and Threads - Course Notes\n## Process Creation and Termination (Conceptual Level)\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ProcessCreationAndIPC(Scene):\n\n def construct(self):\n title_win = Text('Process Creation: Windows vs Unix', font_size=40, weight=BOLD)\n title_win.to_edge(UP)\n self.play(Write(title_win))\n unix_text = Text('Unix Systems', font_size=30, color=BLUE)\n unix_flow = VGroup(Text('fork()', font_size=24), Arrow(start=LEFT, end=RIGHT, buff=0.1, max_tip_length_to_length_ratio=0.15), Text('exec()', font_size=24)).arrange(RIGHT)\n unix_group = VGroup(unix_text, unix_flow).arrange(DOWN, aligned_edge=LEFT)\n win_text = Text('Windows Systems', font_size=30, color=BLUE)\n win_flow = Text('CreateProcess()', font_size=24, color=YELLOW)\n win_desc = Text('- Complex parameters\\n- Completes creation & loading in 1 step', font_size=20, line_spacing=1.5)\n win_group = VGroup(win_text, win_flow, win_desc).arrange(DOWN, aligned_edge=LEFT)\n comparison = VGroup(unix_group, win_group).arrange(RIGHT, buff=1.5, aligned_edge=UP)\n comparison.next_to(title_win, DOWN, buff=1)\n self.play(FadeIn(unix_group, shift=RIGHT))\n self.play(FadeIn(win_group, shift=LEFT))\n self.wait(2)\n underlying_title = Text('Underlying Steps (Both Systems):', font_size=28, color=GREEN)\n steps = VGroup(Text('1. Create PCB', font_size=24), Text('2. Allocate Address Space', font_size=24), Text('3. Load Program', font_size=24)).arrange(RIGHT, buff=0.8)\n underlying_box = SurroundingRectangle(steps, color=GREEN, corner_radius=0.2, buff=0.3)\n underlying_group = VGroup(underlying_title, steps, underlying_box).arrange(DOWN, buff=0.4)\n underlying_group.next_to(comparison, DOWN, buff=1)\n self.play(Write(underlying_title))\n self.play(FadeIn(steps, shift=UP), Create(underlying_box))\n self.wait(3)\n self.play(FadeOut(title_win), FadeOut(comparison), FadeOut(underlying_group))\n title_ipc = Text('Overview of Inter-Process Communication (IPC)', font_size=40, weight=BOLD)\n title_ipc.to_edge(UP)\n self.play(Write(title_ipc))\n why_ipc = Text('Why is IPC Needed?', font_size=32, color=YELLOW)\n why_ipc.next_to(title_ipc, DOWN, buff=0.5)\n self.play(FadeIn(why_ipc))\n proc_a = VGroup(Rectangle(width=2.5, height=1.5, color=BLUE, fill_opacity=0.1), Text('Process A', font_size=24))\n proc_b = VGroup(Rectangle(width=2.5, height=1.5, color=RED, fill_opacity=0.1), Text('Process B', font_size=24))\n procs = VGroup(proc_a, proc_b).arrange(RIGHT, buff=4)\n procs.next_to(why_ipc, DOWN, buff=1)\n self.play(Create(proc_a), Create(proc_b))\n isolation_text = Text('Independent Address Spaces\\n(No direct memory read/write)', font_size=20, color=LIGHT_GREY)\n isolation_text.move_to(procs)\n cross = Cross(stroke_width=6).scale(0.4)\n cross.move_to(procs).shift(UP * 0.5)\n isolation_text.next_to(cross, DOWN, buff=0.2)\n self.play(Create(cross))\n self.play(Write(isolation_text))\n self.wait(2)\n self.play(FadeOut(isolation_text), FadeOut(cross))\n os_box = VGroup(Rectangle(width=5, height=1.5, color=GREEN, fill_opacity=0.2), Text('OS Common Buffer / Mechanism', font_size=22))\n os_box.next_to(procs, DOWN, buff=1)\n arrow_a = Arrow(proc_a.get_bottom(), os_box.get_top() + LEFT * 1.5, color=YELLOW, buff=0.1)\n arrow_b = Arrow(os_box.get_top() + RIGHT * 1.5, proc_b.get_bottom(), color=YELLOW, buff=0.1)\n bridge_text = Text('A bridge to break isolation', font_size=24, color=GREEN)\n bridge_text.next_to(os_box, DOWN, buff=0.3)\n self.play(Create(os_box), Write(bridge_text))\n self.play(GrowArrow(arrow_a))\n self.play(GrowArrow(arrow_b))\n data_packet = Circle(radius=0.15, color=YELLOW, fill_opacity=1)\n data_packet.move_to(proc_a.get_bottom())\n self.play(data_packet.animate.move_to(os_box.get_top() + LEFT * 1.5), run_time=1)\n self.play(data_packet.animate.move_to(os_box.get_top() + RIGHT * 1.5), run_time=1)\n self.play(data_packet.animate.move_to(proc_b.get_bottom()), run_time=1)\n self.play(FadeOut(data_packet))\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass ProcessCreationAndIPC(Scene):\n\n def construct(self):\n title_win = Text('Process Creation: Windows vs Unix', font_size=40, weight=BOLD)\n title_win.to_edge(UP)\n self.play(Write(title_win))\n unix_text = Text('Unix Systems', font_size=30, color=BBLUE)\n unix_flow = VGroup(Text('fork()', font_size=24), Arrow(start=LEFT, end=RIGHT, buff=0.1, max_tip_length_to_length_ratio=0.15), Text('exec()', font_size=24)).arrange(RIGHT)\n unix_group = VGroup(unix_text, unix_flow).arrange(DOWN, aligned_edge=LEFT)\n win_text = Text('Windows Systems', font_size=30, color=BLUE)\n win_flow = Text('CreateProcess()', font_size=24, color=YELLOW)\n win_desc = Text('- Complex parameters\\n- Completes creation & loading in 1 step', font_size=20, line_spacing=1.5)\n win_group = VGroup(win_text, win_flow, win_desc).arrange(DOWN, aligned_edge=LEFT)\n comparison = VGroup(unix_group, win_group).arrange(RIGHT, buff=1.5, aligned_edge=UP)\n comparison.next_to(title_win, DOWN, buff=1)\n self.play(FadeIn(unix_group, shift=RIGHT))\n self.play(FadeIn(win_group, shift=LEFT))\n self.wait(2)\n underlying_title = Text('Underlying Steps (Both Systems):', font_size=28, color=GREEN)\n steps = VGroup(Text('1. Create PCB', font_size=24), Text('2. Allocate Address Space', font_size=24), Text('3. Load Program', font_size=24)).arrange(RIGHT, buff=0.8)\n underlying_box = SurroundingRectangle(steps, color=GREEN, corner_radius=0.2, buff=0.3)\n underlying_group = VGroup(underlying_title, steps, underlying_box).arrange(DOWN, buff=0.4)\n underlying_group.next_to(comparison, DOWN, buff=1)\n self.play(Write(underlying_title))\n self.play(FadeIn(steps, shift=UP), Create(underlying_box))\n self.wait(3)\n self.play(FadeOut(title_win), FadeOut(comparison), FadeOut(underlying_group))\n title_ipc = Text('Overview of Inter-Process Communication (IPC)', font_size=40, weight=BOLD)\n title_ipc.to_edge(UP)\n self.play(Write(title_ipc))\n why_ipc = Text('Why is IPC Needed?', font_size=32, color=YELLOW)\n why_ipc.next_to(title_ipc, DOWN, buff=0.5)\n self.play(FadeIn(why_ipc))\n proc_a = VGroup(Rectangle(width=2.5, height=1.5, color=BLUE, fill_opacity=0.1), Text('Process A', font_size=24))\n proc_b = VGroup(Rectangle(width=2.5, height=1.5, color=RED, fill_opacity=0.1), Text('Process B', font_size=24))\n procs = VGroup(proc_a, proc_b).arrange(RIGHT, buff=4)\n procs.next_to(why_ipc, DOWN, buff=1)\n self.play(Create(proc_a), Create(proc_b))\n isolation_text = Text('Independent Address Spaces\\n(No direct memory read/write)', font_size=20, color=LIGHT_GREY)\n isolation_text.move_to(procs)\n cross = Cross(stroke_width=6).scale(0.4)\n cross.move_to(procs).shift(UP * 0.5)\n isolation_text.next_to(cross, DOWN, buff=0.2)\n self.play(Create(cross))\n self.play(Write(isolation_text))\n self.wait(2)\n self.play(FadeOut(isolation_text), FadeOut(cross))\n os_box = VGroup(Rectangle(width=5, height=1.5, color=GREEN, fill_opacity=0.2), Text('OS Common Buffer / Mechanism', font_size=22))\n os_box.next_to(procs, DOWN, buff=1)\n arrow_a = Arrow(proc_a.get_bottom(), os_box.get_top() + LEFT * 1.5, color=YELLOW, buff=0.1)\n arrow_b = Arrow(os_box.get_top() + RIGHT * 1.5, proc_b.get_bottom(), color=YELLOW, buff=0.1)\n bridge_text = Text('A bridge to break isolation', font_size=24, color=GREEN)\n bridge_text.next_to(os_box, DOWN, buff=0.3)\n self.play(Create(os_box), Write(bridge_text))\n self.play(GrowArrow(arrow_a))\n self.play(GrowArrow(arrow_b))\n data_packet = Circle(radius=0.15, color=YELLOW, fill_opacity=1)\n data_packet.move_to(proc_a.get_bottom())\n self.play(data_packet.animate.move_to(os_box.get_top() + LEFT * 1.5), run_time=1)\n self.play(data_packet.animate.move_to(os_box.get_top() + RIGHT * 1.5), run_time=1)\n self.play(data_packet.animate.move_to(proc_b.get_bottom()), run_time=1)\n self.play(FadeOut(data_packet))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 using Manim which visually demonstrates the Pythagorean Theorem, starting by writing out the equation a^2 + b^2 = c^2, then showing a right-angled triangle and labeling its sides as 'a,' 'b,' and 'c'? Afterwards, I would like to see squares being constructed on each of these sides, followed by visual proof that the area of the square on the 'c' side is equal to the sum of the areas of the squares on sides 'a' and 'b.' To conclude the demonstration, could you showcase a sentence stating \"This illustrates the Pythagorean Theorem\" and end the animation with the theorem equation shown once more?", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Equation Introduction\n # ------------------------------------------------------------------\n title = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=60)\n self.play(Write(title), run_time=2)\n self.wait(1)\n self.play(FadeOut(title), shift=UP * 3)\n\n # ------------------------------------------------------------------\n # 2. Triangle Visualization\n # ------------------------------------------------------------------\n # Define vertices for a 3-4-5 right triangle (Right angle at Origin)\n A = ORIGIN\n B = 3 * RIGHT # Side 'a' (horizontal)\n C = 4 * UP # Side 'b' (vertical)\n \n triangle = Polygon(A, B, C, color=WHITE)\n \n # Labels for sides\n label_a = MathTex(\"a\", font_size=36).next_to(Line(A, B), DOWN, buff=0.2)\n label_b = MathTex(\"b\", font_size=36).next_to(Line(A, C), LEFT, buff=0.2)\n label_c = MathTex(\"c\", font_size=36).next_to(Line(B, C), UR, buff=0.2)\n \n # Right angle marker\n right_angle = RightAngle(Line(A, B), Line(A, C), length=0.4, color=GRAY)\n \n self.play(Create(triangle), Create(right_angle), run_time=2)\n self.play(Write(label_a), Write(label_b), Write(label_c), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Square Construction\n # ------------------------------------------------------------------\n # Square on side a (length 3, extends downward)\n square_a = Polygon(\n A, B, B + DOWN * 3, A + DOWN * 3,\n color=BLUE, fill_opacity=0.3, stroke_width=2\n )\n \n # Square on side b (length 4, extends leftward)\n square_b = Polygon(\n A, C, C + LEFT * 4, A + LEFT * 4,\n color=GREEN, fill_opacity=0.3, stroke_width=2\n )\n \n # Square on side c (Hypotenuse, length 5)\n # Vector BC = C - B = [-3, 4, 0]. Perpendicular outward vector = [4, 3, 0] (magnitude 5)\n v_perp = np.array([4, 3, 0])\n square_c = Polygon(\n B, C, C + v_perp, B + v_perp,\n color=RED, fill_opacity=0.3, stroke_width=2\n )\n \n self.play(Create(square_a), Create(square_b), run_time=1.5)\n self.play(Create(square_c), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Visual Proof\n # ------------------------------------------------------------------\n # Display Areas using the 3-4-5 integer areas for concrete proof\n area_a = MathTex(\"a^2\", \"=\", \"3^2\", \"=\", \"9\", font_size=30, color=BLUE)\n area_a.move_to(square_a.get_center())\n \n area_b = MathTex(\"b^2\", \"=\", \"4^2\", \"=\", \"16\", font_size=30, color=GREEN)\n area_b.move_to(square_b.get_center())\n \n area_c = MathTex(\"c^2\", \"=\", \"5^2\", \"=\", \"25\", font_size=30, color=RED)\n area_c.move_to(square_c.get_center())\n \n self.play(Write(area_a), Write(area_b), run_time=1.5)\n self.wait(0.5)\n self.play(Write(area_c), run_time=1.5)\n \n # Show the sum relationship\n equation_proof = MathTex(\"9\", \"+\", \"16\", \"=\", \"25\", font_size=45)\n equation_proof.to_edge(DOWN)\n \n self.play(Write(equation_proof), run_time=1.5)\n \n # Highlight the squares to reinforce the connection\n self.play(\n square_a.animate.set_fill(opacity=0.8),\n square_b.animate.set_fill(opacity=0.8),\n run_time=0.5\n )\n self.play(\n square_c.animate.set_fill(opacity=0.8),\n Flash(square_c, color=RED, flash_radius=0.5),\n run_time=0.5\n )\n self.wait(1)\n \n # Clean up proof text and reset opacity\n self.play(\n FadeOut(area_a), FadeOut(area_b), FadeOut(area_c), \n FadeOut(equation_proof),\n square_a.animate.set_fill(opacity=0.3),\n square_b.animate.set_fill(opacity=0.3),\n square_c.animate.set_fill(opacity=0.3),\n run_time=1\n )\n\n # ------------------------------------------------------------------\n # 5. Conclusion Text\n # ------------------------------------------------------------------\n conclusion = Text(\"This illustrates the Pythagorean Theorem\", font_size=36)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Equation\n # ------------------------------------------------------------------\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=72, color=YELLOW)\n \n # Fade out geometry to emphasize the final equation\n self.play(\n *[FadeOut(mob) for mob in [\n triangle, right_angle, square_a, square_b, square_c, \n label_a, label_b, label_c, conclusion\n ]],\n Write(final_eq),\n run_time=2\n )\n \n self.play(Indicate(final_eq))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass PythagoreanTheorem(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Equation Introduction\n # ------------------------------------------------------------------\n title = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=60)\n self.play(Write(title), run_time=2)\n self.wait(1)\n self.play(FadeOut(title), shift=UP * 3)\n\n # ------------------------------------------------------------------\n # 2. Triangle Visualization\n # ------------------------------------------------------------------\n # Define vertices for a 3-4-5 right triangle (Right angle at Origin)\n A = ORIGIN\n B = 3 * RIGHT # Side 'a' (horizontal)\n C = 4 * UP # Side 'b' (vertical)\n \n triangle = Polygon(A, B, C, color=WHITE)\n \n # Labels for sides\n label_a = MathTex(\"a\", font_size=36).next_to(Line(A, B), DOWN, buff=0.2)\n label_b = MathTex(\"b\", font_size=36).next_to(Line(A, C), LEFT, buff=0.2)\n label_c = MathTex(\"c\", font_size=36).next_to(Line(B, C), UR, buff=0.2)\n \n # Right angle marker\n right_angle = RightAngle(Line(A, B), Line(A, C), length=0.4, color=GRAY)\n \n self.play(Create(triangle), Create(right_angle), run_time=2)\n self.play(Write(label_a), Write(label_b), Write(label_c), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Square Construction\n # ------------------------------------------------------------------\n # Square on side a (length 3, extends downward)\n square_a = Polygon(\n A, B, B + DOWN * 3, A + DOWN * 3,\n color=BBLUE, fill_opacity=0.3, stroke_width=2\n )\n \n # Square on side b (length 4, extends leftward)\n square_b = Polygon(\n A, C, C + LEFT * 4, A + LEFT * 4,\n color=GREEN, fill_opacity=0.3, stroke_width=2\n )\n \n # Square on side c (Hypotenuse, length 5)\n # Vector BC = C - B = [-3, 4, 0]. Perpendicular outward vector = [4, 3, 0] (magnitude 5)\n v_perp = np.array([4, 3, 0])\n square_c = Polygon(\n B, C, C + v_perp, B + v_perp,\n color=RED, fill_opacity=0.3, stroke_width=2\n )\n \n self.play(Create(square_a), Create(square_b), run_time=1.5)\n self.play(Create(square_c), run_time=1.5)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 4. Visual Proof\n # ------------------------------------------------------------------\n # Display Areas using the 3-4-5 integer areas for concrete proof\n area_a = MathTex(\"a^2\", \"=\", \"3^2\", \"=\", \"9\", font_size=30, color=BLUE)\n area_a.move_to(square_a.get_center())\n \n area_b = MathTex(\"b^2\", \"=\", \"4^2\", \"=\", \"16\", font_size=30, color=GREEN)\n area_b.move_to(square_b.get_center())\n \n area_c = MathTex(\"c^2\", \"=\", \"5^2\", \"=\", \"25\", font_size=30, color=RED)\n area_c.move_to(square_c.get_center())\n \n self.play(Write(area_a), Write(area_b), run_time=1.5)\n self.wait(0.5)\n self.play(Write(area_c), run_time=1.5)\n \n # Show the sum relationship\n equation_proof = MathTex(\"9\", \"+\", \"16\", \"=\", \"25\", font_size=45)\n equation_proof.to_edge(DOWN)\n \n self.play(Write(equation_proof), run_time=1.5)\n \n # Highlight the squares to reinforce the connection\n self.play(\n square_a.animate.set_fill(opacity=0.8),\n square_b.animate.set_fill(opacity=0.8),\n run_time=0.5\n )\n self.play(\n square_c.animate.set_fill(opacity=0.8),\n Flash(square_c, color=RED, flash_radius=0.5),\n run_time=0.5\n )\n self.wait(1)\n \n # Clean up proof text and reset opacity\n self.play(\n FadeOut(area_a), FadeOut(area_b), FadeOut(area_c), \n FadeOut(equation_proof),\n square_a.animate.set_fill(opacity=0.3),\n square_b.animate.set_fill(opacity=0.3),\n square_c.animate.set_fill(opacity=0.3),\n run_time=1\n )\n\n # ------------------------------------------------------------------\n # 5. Conclusion Text\n # ------------------------------------------------------------------\n conclusion = Text(\"This illustrates the Pythagorean Theorem\", font_size=36)\n conclusion.to_edge(DOWN)\n self.play(Write(conclusion), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 6. Final Equation\n # ------------------------------------------------------------------\n final_eq = MathTex(\"a^2\", \"+\", \"b^2\", \"=\", \"c^2\", font_size=72, color=YELLOW)\n \n # Fade out geometry to emphasize the final equation\n self.play(\n *[FadeOut(mob) for mob in [\n triangle, right_angle, square_a, square_b, square_c, \n label_a, label_b, label_c, conclusion\n ]],\n Write(final_eq),\n run_time=2\n )\n \n self.play(Indicate(final_eq))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 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 set of axes, and include a label for the curve. Afterward, display the integral expression for the area under the curve and highlight the actual area under the graph between those two points. Once the area is highlighted, show the calculated result of the integral. Finally, clear everything else away and leave only the final result of the integration on the screen.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize the Manim scene and define the function f(x) = x^2\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[-1, 3])\n\n # 2. Visualization: Plot the function on a coordinate system with labeled axes and a label for the curve\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n curve_label = MathTex(\"y = x^2\").next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(curve_label))\n self.wait(1)\n\n # 3. Integral Expression: Display the mathematical expression for the definite integral from 0 to 2\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 4. Highlighting: Visually highlight the area under the curve between x = 0 and x = 2\n area = axes.get_area(\n graph,\n x_range=[0, 2],\n color=GREEN,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 5. Calculation: Reveal the calculated numerical result of the integral\n result_expr = MathTex(r\"= \\frac{8}{3}\").next_to(integral_expr, RIGHT)\n self.play(Write(result_expr))\n self.wait(1)\n\n # 6. Conclusion: Clear all elements except the final integration result, leaving it centered on the screen\n visual_elements = VGroup(axes, x_label, y_label, graph, curve_label, area)\n final_equation = VGroup(integral_expr, result_expr)\n\n self.play(\n FadeOut(visual_elements),\n final_equation.animate.move_to(ORIGIN).scale(1.5)\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # 1. Setup: Initialize the Manim scene and define the function f(x) = x^2\n axes = Axes(\n x_range=[-1, 3, 1],\n y_range=[-1, 5, 1],\n x_length=6,\n y_length=6,\n x_axis_config={\"numbers_to_include\": [0, 2]},\n y_axis_config={\"numbers_to_include\": [4]},\n axis_config={\"include_tip\": True},\n ).add_coordinates()\n\n func = lambda x: x**2\n graph = axes.plot(func, color=BLUE, x_range=[-1, 3])\n\n # 2. Visualization: Plot the function on a coordinate system with labeled axes and a label for the curve\n x_label = axes.get_x_axis_label(\"x\")\n y_label = axes.get_y_axis_label(\"y\")\n curve_label = MathText(\"y = x^2\").next_to(graph, UR, buff=0.5)\n\n self.play(Create(axes), Write(x_label), Write(y_label))\n self.play(Create(graph), Write(curve_label))\n self.wait(1)\n\n # 3. Integral Expression: Display the mathematical expression for the definite integral from 0 to 2\n integral_expr = MathTex(r\"\\int_{0}^{2} x^2 \\, dx\").to_edge(UP)\n self.play(Write(integral_expr))\n self.wait(1)\n\n # 4. Highlighting: Visually highlight the area under the curve between x = 0 and x = 2\n area = axes.get_area(\n graph,\n x_range=[0, 2],\n color=GREEN,\n opacity=0.5\n )\n \n self.play(FadeIn(area))\n self.wait(1)\n\n # 5. Calculation: Reveal the calculated numerical result of the integral\n result_expr = MathTex(r\"= \\frac{8}{3}\").next_to(integral_expr, RIGHT)\n self.play(Write(result_expr))\n self.wait(1)\n\n # 6. Conclusion: Clear all elements except the final integration result, leaving it centered on the screen\n visual_elements = VGroup(axes, x_label, y_label, graph, curve_label, area)\n final_equation = VGroup(integral_expr, result_expr)\n\n self.play(\n FadeOut(visual_elements),\n final_equation.animate.move_to(ORIGIN).scale(1.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 would Simpson's Paradox manifest in an animated scatter plot displaying temporal changes in a dataset?", "chosen": "```python\nfrom manim import *\n\nclass SimpsonsParadoxScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Simpson's Paradox: The Hidden Trend with Time\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Setup axes\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n x_length=6,\n y_length=6,\n axis_config={\"include_tip\": False}\n )\n x_label = Text(\"Time (Years)\", font_size=24).next_to(axes, DOWN)\n y_label = Text(\"Admission Rate (%)\", font_size=24).next_to(axes, LEFT).rotate(PI/2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n \n # Department A data - increasing trend\n dept_a_data = [(1, 8), (3, 8.2), (5, 8.4), (7, 8.6), (9, 8.8)]\n dept_a_dots = VGroup(*[Dot(axes.c2p(x, y), color=BLUE) for x, y in dept_a_data])\n dept_a_label = Text(\"Department A\", font_size=24, color=BLUE).next_to(axes, UP).shift(LEFT * 2)\n \n # Department B data - also increasing trend\n dept_b_data = [(1, 4), (3, 4.5), (5, 5), (7, 5.5), (9, 6)]\n dept_b_dots = VGroup(*[Dot(axes.c2p(x, y), color=RED) for x, y in dept_b_data])\n dept_b_label = Text(\"Department B\", font_size=24, color=RED).next_to(axes, UP).shift(RIGHT * 2)\n \n # Display departments\n self.play(Create(dept_a_dots), Write(dept_a_label))\n self.wait(0.5)\n self.play(Create(dept_b_dots), Write(dept_b_label))\n self.wait(1)\n \n # Create trend lines\n dept_a_line = Line(\n start=axes.c2p(dept_a_data[0][0], dept_a_data[0][1]),\n end=axes.c2p(dept_a_data[-1][0], dept_a_data[-1][1]),\n color=BLUE\n )\n dept_b_line = Line(\n start=axes.c2p(dept_b_data[0][0], dept_b_data[0][1]),\n end=axes.c2p(dept_b_data[-1][0], dept_b_data[-1][1]),\n color=RED\n )\n \n # Show individual trend lines\n self.play(Create(dept_a_line))\n self.play(Create(dept_b_line))\n \n narration = Text(\"Both departments show increasing trends\", font_size=28)\n narration.to_edge(UP)\n self.play(Write(narration))\n self.wait(2)\n self.play(FadeOut(narration))\n \n # Now show combined data with decreasing trend\n combined_data = [(1, 7.5), (3, 7), (5, 6.5), (7, 6), (9, 5.5)]\n combined_dots = VGroup(*[Dot(axes.c2p(x, y), color=PURPLE) for x, y in combined_data])\n combined_line = Line(\n start=axes.c2p(combined_data[0][0], combined_data[0][1]),\n end=axes.c2p(combined_data[-1][0], combined_data[-1][1]),\n color=PURPLE\n )\n combined_label = Text(\"Combined Data\", font_size=24, color=PURPLE).next_to(axes, UP)\n \n self.play(\n FadeOut(dept_a_label),\n FadeOut(dept_b_label),\n dept_a_dots.animate.set_opacity(0.3),\n dept_b_dots.animate.set_opacity(0.3),\n dept_a_line.animate.set_opacity(0.3),\n dept_b_line.animate.set_opacity(0.3)\n )\n \n self.play(Create(combined_dots), Write(combined_label))\n self.wait(0.5)\n self.play(Create(combined_line))\n \n narration2 = Text(\"But the combined data shows a decreasing trend!\", font_size=28)\n narration2.to_edge(UP)\n self.play(Write(narration2))\n self.wait(2)\n \n # Highlight the paradox\n self.play(\n FadeOut(narration2),\n dept_a_dots.animate.set_opacity(1),\n dept_b_dots.animate.set_opacity(1),\n dept_a_line.animate.set_opacity(1),\n dept_b_line.animate.set_opacity(1),\n FadeIn(dept_a_label),\n FadeIn(dept_b_label)\n )\n \n paradox_text = Text(\"This is Simpson's Paradox!\", font_size=32, color=YELLOW)\n paradox_text.to_edge(UP)\n self.play(Write(paradox_text))\n self.wait(1)\n \n # Show trend rate equation - with fixed MathTex formatting\n equation = MathTex(r\"\\text{Trend rate} = \\frac{\\Delta y}{\\Delta x}\")\n equation.scale(1.2) # Scale instead of font_size\n equation.to_edge(DOWN)\n self.play(Write(equation))\n self.wait(2)\n \n # Clean up and conclusion\n self.play(\n FadeOut(paradox_text),\n FadeOut(equation),\n FadeOut(dept_a_dots),\n FadeOut(dept_b_dots),\n FadeOut(combined_dots),\n FadeOut(dept_a_line),\n FadeOut(dept_b_line),\n FadeOut(combined_line),\n FadeOut(dept_a_label),\n FadeOut(dept_b_label),\n FadeOut(combined_label),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label)\n )\n \n conclusion = Text(\"Remember to look deeper into your data\", font_size=36)\n conclusion2 = Text(\"Aggregated insights may conceal crucial nuances\", font_size=28)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.play(Write(conclusion2))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(conclusion2))\n```", "rejected": "```python\nfrom manim import *\n\nclass SimpsonsParadoxScene(Scene):\n def construct(self):\n # Title\n title = Text(\"Simpson's Paradox: The Hidden Trend with Time\", font_size=36)\n self.play(Write(title))\n self.wait(1)\n self.play(FadeOut(title))\n \n # Setup axes\n axes = Axes(\n x_range=[0, 10, 1],\n y_range=[0, 10, 1],\n x_length=6,\n y_length=6,\n axis_config={\"include_tip\": False}\n )\n x_label = Text(\"Time (Years)\", font_size=24).next_to(axes, DOWN)\n y_label = Text(\"Admission Rate (%)\", font_size=24).next_to(axes, LEFT).rotate(PI/2)\n \n self.play(Create(axes), Write(x_label), Write(y_label))\n self.wait(1)\n \n # Department A data - increasing trend\n dept_a_data = [(1, 8), (3, 8.2), (5, 8.4), (7, 8.6), (9, 8.8)]\n dept_a_dots = VGroup(*[Dot(axes.c2p(x, y), color=BBLUE) for x, y in dept_a_data])\n dept_a_label = Text(\"Department A\", font_size=24, color=BLUE).next_to(axes, UP).shift(LEFT * 2)\n \n # Department B data - also increasing trend\n dept_b_data = [(1, 4), (3, 4.5), (5, 5), (7, 5.5), (9, 6)]\n dept_b_dots = VGroup(*[Dot(axes.c2p(x, y), color=RED) for x, y in dept_b_data])\n dept_b_label = Text(\"Department B\", font_size=24, color=RED).next_to(axes, UP).shift(RIGHT * 2)\n \n # Display departments\n self.play(Create(dept_a_dots), Write(dept_a_label))\n self.wait(0.5)\n self.play(Create(dept_b_dots), Write(dept_b_label))\n self.wait(1)\n \n # Create trend lines\n dept_a_line = Line(\n start=axes.c2p(dept_a_data[0][0], dept_a_data[0][1]),\n end=axes.c2p(dept_a_data[-1][0], dept_a_data[-1][1]),\n color=BLUE\n )\n dept_b_line = Line(\n start=axes.c2p(dept_b_data[0][0], dept_b_data[0][1]),\n end=axes.c2p(dept_b_data[-1][0], dept_b_data[-1][1]),\n color=RED\n )\n \n # Show individual trend lines\n self.play(Create(dept_a_line))\n self.play(Create(dept_b_line))\n \n narration = Text(\"Both departments show increasing trends\", font_size=28)\n narration.to_edge(UP)\n self.play(Write(narration))\n self.wait(2)\n self.play(FadeOut(narration))\n \n # Now show combined data with decreasing trend\n combined_data = [(1, 7.5), (3, 7), (5, 6.5), (7, 6), (9, 5.5)]\n combined_dots = VGroup(*[Dot(axes.c2p(x, y), color=PURPLE) for x, y in combined_data])\n combined_line = Line(\n start=axes.c2p(combined_data[0][0], combined_data[0][1]),\n end=axes.c2p(combined_data[-1][0], combined_data[-1][1]),\n color=PURPLE\n )\n combined_label = Text(\"Combined Data\", font_size=24, color=PURPLE).next_to(axes, UP)\n \n self.play(\n FadeOut(dept_a_label),\n FadeOut(dept_b_label),\n dept_a_dots.animate.set_opacity(0.3),\n dept_b_dots.animate.set_opacity(0.3),\n dept_a_line.animate.set_opacity(0.3),\n dept_b_line.animate.set_opacity(0.3)\n )\n \n self.play(Create(combined_dots), Write(combined_label))\n self.wait(0.5)\n self.play(Create(combined_line))\n \n narration2 = Text(\"But the combined data shows a decreasing trend!\", font_size=28)\n narration2.to_edge(UP)\n self.play(Write(narration2))\n self.wait(2)\n \n # Highlight the paradox\n self.play(\n FadeOut(narration2),\n dept_a_dots.animate.set_opacity(1),\n dept_b_dots.animate.set_opacity(1),\n dept_a_line.animate.set_opacity(1),\n dept_b_line.animate.set_opacity(1),\n FadeIn(dept_a_label),\n FadeIn(dept_b_label)\n )\n \n paradox_text = Text(\"This is Simpson's Paradox!\", font_size=32, color=YELLOW)\n paradox_text.to_edge(UP)\n self.play(Write(paradox_text))\n self.wait(1)\n \n # Show trend rate equation - with fixed MathTex formatting\n equation = MathTex(r\"\\text{Trend rate} = \\frac{\\Delta y}{\\Delta x}\")\n equation.scale(1.2) # Scale instead of font_size\n equation.to_edge(DOWN)\n self.play(Write(equation))\n self.wait(2)\n \n # Clean up and conclusion\n self.play(\n FadeOut(paradox_text),\n FadeOut(equation),\n FadeOut(dept_a_dots),\n FadeOut(dept_b_dots),\n FadeOut(combined_dots),\n FadeOut(dept_a_line),\n FadeOut(dept_b_line),\n FadeOut(combined_line),\n FadeOut(dept_a_label),\n FadeOut(dept_b_label),\n FadeOut(combined_label),\n FadeOut(axes),\n FadeOut(x_label),\n FadeOut(y_label)\n )\n \n conclusion = Text(\"Remember to look deeper into your data\", font_size=36)\n conclusion2 = Text(\"Aggregated insights may conceal crucial nuances\", font_size=28)\n conclusion2.next_to(conclusion, DOWN)\n \n self.play(Write(conclusion))\n self.play(Write(conclusion2))\n self.wait(2)\n self.play(FadeOut(conclusion), FadeOut(conclusion2))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 = MathText(\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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 have an educational animation that visually walks me through the problem and solution of the harmonic oscillator ordinary differential equation (ODE). The animation should start by writing the ODE y'' + ω\n- Act 2: 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 3: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0433(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_harmonicoscillatorsoluti()\n self.clear_stage()\n self.act_2_frameboxanimation()\n self.clear_stage()\n self.act_3_animatedboundaryscene()\n\n def act_1_harmonicoscillatorsoluti(self):\n ode = MathTex(\"y'' + \\\\omega^2 y = 0\")\n self.play(Write(ode))\n self.wait(2)\n\n # --- Step 2: Introduce Characteristic Equation ---\n instruction_1 = Text(\"Form the characteristic equation\", font_size=30)\n instruction_1.next_to(ode, UP, buff=0.8)\n self.play(FadeIn(instruction_1, shift=UP))\n self.wait(1)\n\n # --- Step 3: Transform Equation ---\n char_eq = MathTex(\"r^2 + \\\\omega^2 = 0\")\n char_eq.move_to(ode.get_center())\n \n self.play(\n ReplacementTransform(ode, char_eq),\n instruction_1.animate.set_color(GRAY)\n )\n self.wait(2)\n\n # --- Step 4: Solve for Roots ---\n instruction_2 = Text(\"Solve for r\", font_size=30)\n instruction_2.move_to(instruction_1.get_center())\n \n self.play(\n Transform(instruction_1, instruction_2),\n char_eq.animate.shift(UP * 0.5)\n )\n self.wait(1)\n\n roots = MathTex(\"r = \\\\pm i\\\\omega\")\n roots.next_to(char_eq, DOWN, buff=0.8)\n \n self.play(Write(roots))\n self.wait(2)\n\n # --- Step 5: Present General Solution ---\n self.play(\n FadeOut(instruction_1),\n FadeOut(char_eq),\n FadeOut(roots)\n )\n self.wait(0.5)\n \n gen_sol_text = Text(\"General solution of the harmonic oscillator\", font_size=30)\n gen_sol_eq = MathTex(\"y = C_1 \\\\cos(\\\\omega x) + C_2 \\\\sin(\\\\omega x)\")\n \n gen_sol_group = VGroup(gen_sol_text, gen_sol_eq).arrange(DOWN, buff=0.5)\n gen_sol_group.move_to(ORIGIN)\n\n self.play(Write(gen_sol_text))\n self.play(Write(gen_sol_eq))\n self.wait(3)\n\n # --- Step 6: Conclusion ---\n self.play(FadeOut(gen_sol_group))\n self.wait(1)\n \n conclusion = Text(\"End of the demonstration\")\n self.play(Write(conclusion))\n self.wait(2)\n\n def act_2_frameboxanimation(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange them vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n # Create surrounding rectangles for each text with specified colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initial State: Display texts and highlight the first text with a blue rectangle\n self.play(Write(texts))\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Transition 1: Replace blue rectangle with green rectangle highlighting the second text\n self.play(Transform(rect1, rect2))\n self.wait(0.5)\n\n # Transition 2: Replace green rectangle with red rectangle highlighting the third text\n self.play(Transform(rect1, rect3))\n self.wait(0.5)\n\n # Final Movement: Red rectangle moves upwards, following the text \"FrameBoxes\"\n # Define an updater to ensure the rectangle tracks the text's position precisely\n def follow_text(mob):\n mob.move_to(text3)\n\n rect1.add_updater(follow_text)\n \n # Animate the text moving upwards; the rectangle will follow due to the updater\n self.play(text3.animate.shift(UP * 2), run_time=2)\n \n # Clean up updater\n rect1.remove_updater(follow_text)\n\n def act_3_animatedboundaryscene(self):\n start_text = Text(\"Start\")\n target_text = Text(\"AnimatedBoundary\")\n \n self.play(Write(start_text))\n self.play(ReplacementTransform(start_text, target_text))\n # Move the transformed text towards the top of the screen\n self.play(target_text.animate.to_edge(UP))\n \n # 2. Circle Appearance\n # Create a circle that appears immediately after the text moves\n circle = Circle(radius=2, stroke_width=10)\n self.play(Create(circle))\n \n # 3. Colorful Boundary\n # Define the colors to cycle through\n colors = [RED, GREEN, BLUE]\n \n # Updater function to cycle colors quickly based on the scene's time\n # The multiplier (8) controls the speed of the color cycling\n def update_color(mob):\n index = int(self.time * 8) % len(colors)\n mob.set_stroke(colors[index], width=10)\n \n circle.add_updater(update_color)\n \n # Display the cycling boundary for a short duration\n self.wait(2)\n \n # 4. Disappearance\n # Remove the updater before fading out to ensure a clean animation\n circle.remove_updater(update_color)\n self.play(FadeOut(circle), FadeOut(target_text))\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0433(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_harmonicoscillatorsoluti()\n self.clear_stage()\n self.act_2_frameboxanimation()\n self.clear_stage()\n self.act_3_animatedboundaryscene()\n\n def act_1_harmonicoscillatorsoluti(self):\n ode = MathText(\"y'' + \\\\omega^2 y = 0\")\n self.play(Write(ode))\n self.wait(2)\n\n # --- Step 2: Introduce Characteristic Equation ---\n instruction_1 = Text(\"Form the characteristic equation\", font_size=30)\n instruction_1.next_to(ode, UP, buff=0.8)\n self.play(FadeIn(instruction_1, shift=UP))\n self.wait(1)\n\n # --- Step 3: Transform Equation ---\n char_eq = MathTex(\"r^2 + \\\\omega^2 = 0\")\n char_eq.move_to(ode.get_center())\n \n self.play(\n ReplacementTransform(ode, char_eq),\n instruction_1.animate.set_color(GRAY)\n )\n self.wait(2)\n\n # --- Step 4: Solve for Roots ---\n instruction_2 = Text(\"Solve for r\", font_size=30)\n instruction_2.move_to(instruction_1.get_center())\n \n self.play(\n Transform(instruction_1, instruction_2),\n char_eq.animate.shift(UP * 0.5)\n )\n self.wait(1)\n\n roots = MathTex(\"r = \\\\pm i\\\\omega\")\n roots.next_to(char_eq, DOWN, buff=0.8)\n \n self.play(Write(roots))\n self.wait(2)\n\n # --- Step 5: Present General Solution ---\n self.play(\n FadeOut(instruction_1),\n FadeOut(char_eq),\n FadeOut(roots)\n )\n self.wait(0.5)\n \n gen_sol_text = Text(\"General solution of the harmonic oscillator\", font_size=30)\n gen_sol_eq = MathTex(\"y = C_1 \\\\cos(\\\\omega x) + C_2 \\\\sin(\\\\omega x)\")\n \n gen_sol_group = VGroup(gen_sol_text, gen_sol_eq).arrange(DOWN, buff=0.5)\n gen_sol_group.move_to(ORIGIN)\n\n self.play(Write(gen_sol_text))\n self.play(Write(gen_sol_eq))\n self.wait(3)\n\n # --- Step 6: Conclusion ---\n self.play(FadeOut(gen_sol_group))\n self.wait(1)\n \n conclusion = Text(\"End of the demonstration\")\n self.play(Write(conclusion))\n self.wait(2)\n\n def act_2_frameboxanimation(self):\n text1 = Text(\"This is a sample\")\n text2 = Text(\"of moving\")\n text3 = Text(\"FrameBoxes\")\n\n # Arrange them vertically with consistent spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.5)\n\n # Create surrounding rectangles for each text with specified colors\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n\n # Initial State: Display texts and highlight the first text with a blue rectangle\n self.play(Write(texts))\n self.play(Create(rect1))\n self.wait(0.5)\n\n # Transition 1: Replace blue rectangle with green rectangle highlighting the second text\n self.play(Transform(rect1, rect2))\n self.wait(0.5)\n\n # Transition 2: Replace green rectangle with red rectangle highlighting the third text\n self.play(Transform(rect1, rect3))\n self.wait(0.5)\n\n # Final Movement: Red rectangle moves upwards, following the text \"FrameBoxes\"\n # Define an updater to ensure the rectangle tracks the text's position precisely\n def follow_text(mob):\n mob.move_to(text3)\n\n rect1.add_updater(follow_text)\n \n # Animate the text moving upwards; the rectangle will follow due to the updater\n self.play(text3.animate.shift(UP * 2), run_time=2)\n \n # Clean up updater\n rect1.remove_updater(follow_text)\n\n def act_3_animatedboundaryscene(self):\n start_text = Text(\"Start\")\n target_text = Text(\"AnimatedBoundary\")\n \n self.play(Write(start_text))\n self.play(ReplacementTransform(start_text, target_text))\n # Move the transformed text towards the top of the screen\n self.play(target_text.animate.to_edge(UP))\n \n # 2. Circle Appearance\n # Create a circle that appears immediately after the text moves\n circle = Circle(radius=2, stroke_width=10)\n self.play(Create(circle))\n \n # 3. Colorful Boundary\n # Define the colors to cycle through\n colors = [RED, GREEN, BLUE]\n \n # Updater function to cycle colors quickly based on the scene's time\n # The multiplier (8) controls the speed of the color cycling\n def update_color(mob):\n index = int(self.time * 8) % len(colors)\n mob.set_stroke(colors[index], width=10)\n \n circle.add_updater(update_color)\n \n # Display the cycling boundary for a short duration\n self.wait(2)\n \n # 4. Disappearance\n # Remove the updater before fading out to ensure a clean animation\n circle.remove_updater(update_color)\n self.play(FadeOut(circle), FadeOut(target_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 finding the area under a curve? In the animation, please show a graph of a quadratic function, let's say f(x) = 0.1(x - 3)^2 + 1, and highlight the region between x=1 and x=5 to represent the area under the curve between those points. Then, can you display the bounds of the integral for the area as text on the screen, followed by the integral expression? After that, replace it with the approximate numerical result of the integral. Once the calculation is shown, clear everything and display the final result again for emphasis.", "chosen": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n An educational animation illustrating the concept of finding the area \n under a quadratic curve using integration.\n \"\"\"\n def construct(self):\n # --- 1. Graph Setup ---\n # Define axes with appropriate ranges to fit the function and bounds\n axes = Axes(\n x_range=[0, 6, 1],\n y_range=[0, 3, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 3, 5]},\n y_axis_config={\"numbers_to_include\": [1, 2]},\n ).add_coordinates()\n\n # Define the quadratic function: f(x) = 0.1(x - 3)^2 + 1\n def func(x):\n return 0.1 * (x - 3)**2 + 1\n\n # Plot the curve and create its label\n curve = axes.plot(func, x_range=[0, 6], color=BLUE)\n curve_label = axes.get_graph_label(curve, label=MathTex(r\"f(x) = 0.1(x-3)^2 + 1\"))\n\n # --- 2. Area Highlighting ---\n # Highlight the region under the curve between x=1 and x=5\n area = axes.get_area(curve, x_range=[1, 5], color=GREEN, opacity=0.5)\n \n # Vertical lines to mark the bounds for visual clarity\n line_1 = axes.get_vertical_line(axes.c2p(1, func(1)), color=GRAY)\n line_5 = axes.get_vertical_line(axes.c2p(5, func(5)), color=GRAY)\n\n # Animate the creation of axes, graph, and label\n self.play(Create(axes), Create(curve), Write(curve_label))\n self.wait(1)\n\n # Highlight the area and bounds\n self.play(FadeIn(area), Create(line_1), Create(line_5))\n self.wait(1)\n\n # --- 3. Text Sequence ---\n # Position the text at the top of the screen\n text_pos = UP * 2.5\n\n # Step 3a: Display the integration bounds as text\n bounds_text = MathTex(r\"\\text{Bounds: } x = 1 \\text{ to } x = 5\").move_to(text_pos)\n self.play(Write(bounds_text))\n self.wait(1)\n\n # Step 3b: Replace bounds with the formal integral expression\n integral_expr = MathTex(\n r\"\\int_{1}^{5} \\left( 0.1(x - 3)^{{2}} + 1 \\right) \\, dx\",\n color=YELLOW\n ).move_to(text_pos)\n \n self.play(ReplacementTransform(bounds_text, integral_expr))\n self.wait(1)\n\n # Step 3c: Replace expression with the approximate numerical result\n # Calculation: [0.1 * (x-3)^3 / 3 + x] from 1 to 5 \\approx 4.53\n result_text = MathTex(r\"\\approx 4.53\", color=GREEN).move_to(text_pos).scale(1.5)\n \n self.play(ReplacementTransform(integral_expr, result_text))\n self.wait(1)\n\n # --- 4. Final Emphasis ---\n # Clear all previous elements from the screen\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(area),\n FadeOut(line_1),\n FadeOut(line_5),\n FadeOut(result_text)\n )\n\n # Display the final numerical result again for emphasis (larger and centered)\n final_result = MathTex(r\"\\text{Area} \\approx 4.53\", font_size=72, color=GREEN)\n \n self.play(Write(final_result))\n self.play(Indicate(final_result))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n \"\"\"\n An educational animation illustrating the concept of finding the area \n under a quadratic curve using integration.\n \"\"\"\n def construct(self):\n # --- 1. Graph Setup ---\n # Define axes with appropriate ranges to fit the function and bounds\n axes = Axes(\n x_range=[0, 6, 1],\n y_range=[0, 3, 1],\n axis_config={\"include_tip\": True},\n x_axis_config={\"numbers_to_include\": [1, 3, 5]},\n y_axis_config={\"numbers_to_include\": [1, 2]},\n ).add_coordinates()\n\n # Define the quadratic function: f(x) = 0.1(x - 3)^2 + 1\n def func(x):\n return 0.1 * (x - 3)**2 + 1\n\n # Plot the curve and create its label\n curve = axes.plot(func, x_range=[0, 6], color=BBLUE)\n curve_label = axes.get_graph_label(curve, label=MathTex(r\"f(x) = 0.1(x-3)^2 + 1\"))\n\n # --- 2. Area Highlighting ---\n # Highlight the region under the curve between x=1 and x=5\n area = axes.get_area(curve, x_range=[1, 5], color=GREEN, opacity=0.5)\n \n # Vertical lines to mark the bounds for visual clarity\n line_1 = axes.get_vertical_line(axes.c2p(1, func(1)), color=GRAY)\n line_5 = axes.get_vertical_line(axes.c2p(5, func(5)), color=GRAY)\n\n # Animate the creation of axes, graph, and label\n self.play(Create(axes), Create(curve), Write(curve_label))\n self.wait(1)\n\n # Highlight the area and bounds\n self.play(FadeIn(area), Create(line_1), Create(line_5))\n self.wait(1)\n\n # --- 3. Text Sequence ---\n # Position the text at the top of the screen\n text_pos = UP * 2.5\n\n # Step 3a: Display the integration bounds as text\n bounds_text = MathTex(r\"\\text{Bounds: } x = 1 \\text{ to } x = 5\").move_to(text_pos)\n self.play(Write(bounds_text))\n self.wait(1)\n\n # Step 3b: Replace bounds with the formal integral expression\n integral_expr = MathTex(\n r\"\\int_{1}^{5} \\left( 0.1(x - 3)^{{2}} + 1 \\right) \\, dx\",\n color=YELLOW\n ).move_to(text_pos)\n \n self.play(ReplacementTransform(bounds_text, integral_expr))\n self.wait(1)\n\n # Step 3c: Replace expression with the approximate numerical result\n # Calculation: [0.1 * (x-3)^3 / 3 + x] from 1 to 5 \\approx 4.53\n result_text = MathTex(r\"\\approx 4.53\", color=GREEN).move_to(text_pos).scale(1.5)\n \n self.play(ReplacementTransform(integral_expr, result_text))\n self.wait(1)\n\n # --- 4. Final Emphasis ---\n # Clear all previous elements from the screen\n self.play(\n FadeOut(axes),\n FadeOut(curve),\n FadeOut(curve_label),\n FadeOut(area),\n FadeOut(line_1),\n FadeOut(line_5),\n FadeOut(result_text)\n )\n\n # Display the final numerical result again for emphasis (larger and centered)\n final_result = MathTex(r\"\\text{Area} \\approx 4.53\", font_size=72, color=GREEN)\n \n self.play(Write(final_result))\n self.play(Indicate(final_result))\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Initialization\n # ---------------------------------------------------------\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 ).shift(LEFT * 3) # Shift left to make room for equations\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: x**2, color=YELLOW, x_range=[0, 2.5])\n graph_label = axes.get_graph_label(graph, label=MathTex(\"y = x^2\"), x_val=2.2, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # 2. Area Highlighting\n # ---------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add boundary lines for clarity\n v_line_0 = axes.get_vertical_line(axes.input_to_graph_point(0, graph), color=WHITE)\n v_line_2 = axes.get_vertical_line(axes.input_to_graph_point(2, graph), color=WHITE)\n\n self.play(FadeIn(area), Create(v_line_0), Create(v_line_2))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # 3. Textual Context\n # ---------------------------------------------------------\n context_text = Text(\"Area under the curve\", font_size=30).to_edge(RIGHT).shift(UP * 2)\n \n self.play(Write(context_text))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 4. Step-by-Step Calculation\n # ---------------------------------------------------------\n # Step 4a: Integral Setup\n integral_setup = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\").next_to(context_text, DOWN, buff=0.5)\n self.play(Write(integral_setup))\n self.wait(1)\n\n # Step 4b: Antiderivative\n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(integral_setup, DOWN, buff=0.3)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 4c: Apply Limits\n evaluation = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(antiderivative, DOWN, buff=0.3)\n self.play(Write(evaluation))\n self.wait(1)\n\n # Step 4d: Simplification\n simplification = MathTex(r\"= \\frac{8}{3} - 0\").next_to(evaluation, DOWN, buff=0.3)\n self.play(Write(simplification))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 5. Final Result\n # ---------------------------------------------------------\n final_result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=GREEN, font_size=40).next_to(simplification, DOWN, buff=0.5)\n \n self.play(Write(final_result))\n \n # Emphasize the final result\n final_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.1)\n self.play(Create(final_box), final_result.animate.scale(1.1))\n \n # Hold the final scene static to allow viewer absorption\n self.wait(3)\n```", "rejected": "```python\nfrom manim import *\n\nclass AreaUnderCurve(Scene):\n def construct(self):\n # ---------------------------------------------------------\n # 1. Graph Initialization\n # ---------------------------------------------------------\n axes = Axes(label_font_size=24, \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 ).shift(LEFT * 3) # Shift left to make room for equations\n\n labels = axes.get_axis_labels(x_label=\"x\", y_label=\"y\")\n \n graph = axes.plot(lambda x: x**2, color=YELLOW, x_range=[0, 2.5])\n graph_label = axes.get_graph_label(graph, label=MathTex(\"y = x^2\"), x_val=2.2, direction=UR)\n\n self.play(Create(axes), Write(labels))\n self.play(Create(graph), Write(graph_label))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # 2. Area Highlighting\n # ---------------------------------------------------------\n area = axes.get_area(graph, x_range=[0, 2], color=BLUE, opacity=0.5)\n \n # Add boundary lines for clarity\n v_line_0 = axes.get_vertical_line(axes.input_to_graph_point(0, graph), color=WHITE)\n v_line_2 = axes.get_vertical_line(axes.input_to_graph_point(2, graph), color=WHITE)\n\n self.play(FadeIn(area), Create(v_line_0), Create(v_line_2))\n self.wait(0.5)\n\n # ---------------------------------------------------------\n # 3. Textual Context\n # ---------------------------------------------------------\n context_text = Text(\"Area under the curve\", font_size=30).to_edge(RIGHT).shift(UP * 2)\n \n self.play(Write(context_text))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 4. Step-by-Step Calculation\n # ---------------------------------------------------------\n # Step 4a: Integral Setup\n integral_setup = MathTex(r\"\\text{Area} = \\int_{0}^{2} x^2 \\, dx\").next_to(context_text, DOWN, buff=0.5)\n self.play(Write(integral_setup))\n self.wait(1)\n\n # Step 4b: Antiderivative\n antiderivative = MathTex(r\"= \\left[ \\frac{x^3}{3} \\right]_{0}^{2}\").next_to(integral_setup, DOWN, buff=0.3)\n self.play(Write(antiderivative))\n self.wait(1)\n\n # Step 4c: Apply Limits\n evaluation = MathTex(r\"= \\frac{2^3}{3} - \\frac{0^3}{3}\").next_to(antiderivative, DOWN, buff=0.3)\n self.play(Write(evaluation))\n self.wait(1)\n\n # Step 4d: Simplification\n simplification = MathTex(r\"= \\frac{8}{3} - 0\").next_to(evaluation, DOWN, buff=0.3)\n self.play(Write(simplification))\n self.wait(1)\n\n # ---------------------------------------------------------\n # 5. Final Result\n # ---------------------------------------------------------\n final_result = MathTex(r\"= \\frac{8}{3} \\approx 2.67\", color=GREEN, font_size=40).next_to(simplification, DOWN, buff=0.5)\n \n self.play(Write(final_result))\n \n # Emphasize the final result\n final_box = SurroundingRectangle(final_result, color=YELLOW, buff=0.1)\n self.play(Create(final_box), final_result.animate.scale(1.1))\n \n # Hold the final scene static to allow viewer absorption\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a brief animation where text transforms into the word \"GrowArrow\" and shifts upwards, followed by an arrow that appears as if it's growing and then suddenly disappears?\n- Act 2: 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", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0663(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_growarrowanimation()\n self.clear_stage()\n self.act_2_frameboxanimation()\n\n def act_1_growarrowanimation(self):\n initial_text = Text(\"Initializing...\", font_size=48)\n target_text = Text(\"GrowArrow\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n self.wait(0.2)\n\n # 2. Upward Shift\n # Immediately shift the transformed text upwards to make room\n self.play(target_text.animate.shift(UP * 2))\n\n # 3. Arrow Growth\n # Create an arrow and animate it growing from tail to head\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n\n # 4. Sudden Disappearance\n # Make the arrow disappear suddenly with a very short duration\n self.play(FadeOut(arrow, run_time=0.1))\n \n self.wait(1)\n\n def act_2_frameboxanimation(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 # Arrange them vertically with spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n \n # Display the texts on screen\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n \n # Step A: Draw a blue rectangle around the first text\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n self.play(Create(rect1))\n self.wait(1)\n\n # Step B: Remove blue rectangle and draw green around the second text\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n self.play(FadeOut(rect1), Create(rect2))\n self.wait(1)\n\n # Step C: Remove green rectangle and draw red around the third text\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n self.play(FadeOut(rect2), Create(rect3))\n self.wait(1)\n\n # 3. Final Movement\n # Group the red rectangle and the third text to ensure the \n # rectangle tracks the text perfectly while moving upwards.\n final_group = VGroup(text3, rect3)\n \n # Animate the group moving upwards\n self.play(\n final_group.animate.shift(UP * 3), \n run_time=3, \n rate_func=smooth\n )\n \n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\n\nclass MultiActMasterpiece_0663(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_growarrowanimation()\n self.clear_stage()\n self.act_2_frameboxanimation()\n\n def act_1_growarrowanimation(self):\n initial_text = Text(\"Initializing...\", font_size=48)\n target_text = Text(\"GrowArrow\", font_size=48)\n \n self.play(Write(initial_text))\n self.wait(0.5)\n self.play(ReplacementTransform(initial_text, target_text))\n self.wait(0.2)\n\n # 2. Upward Shift\n # Immediately shift the transformed text upwards to make room\n self.play(target_text.animate.shift(UP * 2))\n\n # 3. Arrow Growth\n # Create an arrow and animate it growing from tail to head\n arrow = Arrow(start=ORIGIN, end=UP * 2, color=BBLUE, buff=0)\n arrow.next_to(target_text, DOWN, buff=0.5)\n self.play(GrowArrow(arrow), run_time=1)\n self.wait(0.5)\n\n # 4. Sudden Disappearance\n # Make the arrow disappear suddenly with a very short duration\n self.play(FadeOut(arrow, run_time=0.1))\n \n self.wait(1)\n\n def act_2_frameboxanimation(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 # Arrange them vertically with spacing\n texts = VGroup(text1, text2, text3).arrange(DOWN, buff=0.8)\n \n # Display the texts on screen\n self.play(Write(texts))\n self.wait(0.5)\n\n # 2. Highlighting Sequence\n \n # Step A: Draw a blue rectangle around the first text\n rect1 = SurroundingRectangle(text1, color=BLUE, buff=0.1)\n self.play(Create(rect1))\n self.wait(1)\n\n # Step B: Remove blue rectangle and draw green around the second text\n rect2 = SurroundingRectangle(text2, color=GREEN, buff=0.1)\n self.play(FadeOut(rect1), Create(rect2))\n self.wait(1)\n\n # Step C: Remove green rectangle and draw red around the third text\n rect3 = SurroundingRectangle(text3, color=RED, buff=0.1)\n self.play(FadeOut(rect2), Create(rect3))\n self.wait(1)\n\n # 3. Final Movement\n # Group the red rectangle and the third text to ensure the \n # rectangle tracks the text perfectly while moving upwards.\n final_group = VGroup(text3, rect3)\n \n # Animate the group moving upwards\n self.play(\n final_group.animate.shift(UP * 3), \n run_time=3, \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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 Idea of the FP Tree\nCompress frequent itemsets by sharing prefix paths, trading space for time, and significantly reducing storage requirements.\n\n\nThe context of this section (from highest to current level):\n# Association Rule Mining\n## Introduction to the FP-Growth Algorithm\n", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass FPTreeBasicIdea(Scene):\n\n def construct(self):\n title = Title('Association Rule Mining')\n subtitle = Text('FP-Growth Algorithm: Basic Idea of the FP Tree', font_size=28, color=BLUE)\n subtitle.next_to(title, DOWN)\n self.play(Write(title), FadeIn(subtitle))\n blist = BulletedList('Compress frequent itemsets\\nby sharing prefix paths', 'Trading space for time', 'Significantly reducing\\nstorage requirements', font_size=28)\n blist.to_edge(LEFT, buff=0.5).shift(UP * 0.5)\n trans_title = Text('Example Transactions:', font_size=28, color=BLUE)\n trans_title.next_to(blist, DOWN, buff=0.8).align_to(blist, LEFT)\n t1 = Text('1: A, B', font_size=24).next_to(trans_title, DOWN).align_to(trans_title, LEFT)\n t2 = Text('2: A, C', font_size=24).next_to(t1, DOWN).align_to(t1, LEFT)\n t3 = Text('3: A', font_size=24).next_to(t2, DOWN).align_to(t2, LEFT)\n transactions = VGroup(trans_title, t1, t2, t3)\n\n def create_node(text, pos, color=WHITE):\n circle = Circle(radius=0.4, color=color, fill_opacity=0.2)\n circle.move_to(pos)\n label = Text(text, font_size=20).move_to(pos)\n return VGroup(circle, label)\n root_pos = [3.5, 1.5, 0]\n a_pos = [3.5, 0, 0]\n b_pos = [2.0, -1.5, 0]\n c_pos = [5.0, -1.5, 0]\n root = create_node('null', root_pos, color=GRAY)\n node_a = create_node('A:3', a_pos, color=YELLOW)\n node_b = create_node('B:1', b_pos, color=GREEN)\n node_c = create_node('C:1', c_pos, color=RED)\n edge_root_a = Line(root[0].get_bottom(), node_a[0].get_top(), buff=0.05)\n edge_a_b = Line(node_a[0].get_bottom(), node_b[0].get_top(), buff=0.05)\n edge_a_c = Line(node_a[0].get_bottom(), node_c[0].get_top(), buff=0.05)\n self.play(FadeIn(blist[0]))\n self.play(Write(transactions))\n self.play(FadeIn(root))\n self.play(Indicate(t1, color=YELLOW))\n self.play(FadeIn(node_a), Create(edge_root_a))\n self.play(FadeIn(node_b), Create(edge_a_b))\n self.play(Indicate(t2, color=YELLOW))\n self.play(Indicate(node_a, color=YELLOW))\n self.play(FadeIn(node_c), Create(edge_a_c))\n self.play(Indicate(t3, color=YELLOW))\n self.play(Indicate(node_a, color=YELLOW))\n highlight_box = SurroundingRectangle(node_a, color=ORANGE, buff=0.1)\n highlight_text = Text('Shared Prefix', font_size=20, color=ORANGE).next_to(highlight_box, RIGHT)\n self.play(Create(highlight_box), Write(highlight_text))\n self.play(FadeIn(blist[1]), FadeIn(blist[2]))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass FPTreeBasicIdea(Scene):\n\n def construct(self):\n title = Title('Association Rule Mining')\n subtitle = Text('FP-Growth Algorithm: Basic Idea of the FP Tree', font_size=28, color=BBLUE)\n subtitle.next_to(title, DOWN)\n self.play(Write(title), FadeIn(subtitle))\n blist = BulletedList('Compress frequent itemsets\\nby sharing prefix paths', 'Trading space for time', 'Significantly reducing\\nstorage requirements', font_size=28)\n blist.to_edge(LEFT, buff=0.5).shift(UP * 0.5)\n trans_title = Text('Example Transactions:', font_size=28, color=BLUE)\n trans_title.next_to(blist, DOWN, buff=0.8).align_to(blist, LEFT)\n t1 = Text('1: A, B', font_size=24).next_to(trans_title, DOWN).align_to(trans_title, LEFT)\n t2 = Text('2: A, C', font_size=24).next_to(t1, DOWN).align_to(t1, LEFT)\n t3 = Text('3: A', font_size=24).next_to(t2, DOWN).align_to(t2, LEFT)\n transactions = VGroup(trans_title, t1, t2, t3)\n\n def create_node(text, pos, color=WHITE):\n circle = Circle(radius=0.4, color=color, fill_opacity=0.2)\n circle.move_to(pos)\n label = Text(text, font_size=20).move_to(pos)\n return VGroup(circle, label)\n root_pos = [3.5, 1.5, 0]\n a_pos = [3.5, 0, 0]\n b_pos = [2.0, -1.5, 0]\n c_pos = [5.0, -1.5, 0]\n root = create_node('null', root_pos, color=GRAY)\n node_a = create_node('A:3', a_pos, color=YELLOW)\n node_b = create_node('B:1', b_pos, color=GREEN)\n node_c = create_node('C:1', c_pos, color=RED)\n edge_root_a = Line(root[0].get_bottom(), node_a[0].get_top(), buff=0.05)\n edge_a_b = Line(node_a[0].get_bottom(), node_b[0].get_top(), buff=0.05)\n edge_a_c = Line(node_a[0].get_bottom(), node_c[0].get_top(), buff=0.05)\n self.play(FadeIn(blist[0]))\n self.play(Write(transactions))\n self.play(FadeIn(root))\n self.play(Indicate(t1, color=YELLOW))\n self.play(FadeIn(node_a), Create(edge_root_a))\n self.play(FadeIn(node_b), Create(edge_a_b))\n self.play(Indicate(t2, color=YELLOW))\n self.play(Indicate(node_a, color=YELLOW))\n self.play(FadeIn(node_c), Create(edge_a_c))\n self.play(Indicate(t3, color=YELLOW))\n self.play(Indicate(node_a, color=YELLOW))\n highlight_box = SurroundingRectangle(node_a, color=ORANGE, buff=0.1)\n highlight_text = Text('Shared Prefix', font_size=20, color=ORANGE).next_to(highlight_box, RIGHT)\n self.play(Create(highlight_box), Write(highlight_text))\n self.play(FadeIn(blist[1]), FadeIn(blist[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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 a series of educational science animations using the ManimCE library. Firstly, can you make a grid showing a collection of hydrogen atom symbols, with alternating isotopes of hydrogen denoting Deuterium for every other row, where the isotopes differ by having 'D' with the subscript '2' and regular hydrogen having 'H' with the subscript '1'? The grid should have 5 rows and 7 columns, with each atom represented by a different colored circle and with the symbol inside, and the animation should introduce the grid of atoms on the screen.\n\nSecondly, can you create an animation of an electron depicted as a yellow circle, transitioning between energy levels? We'd like the electron to move along a semi-circular path above and below its initial position, kind of like it's jumping up to a higher energy state and then falling back down.\n\nLastly, I am interested in an animation showing a single proton. It has to be a red circle with the label 'p+' to indicate a proton. It should fade into view, then move upwards and afterwards move back down, as if it's oscillating up and down along the vertical axis.", "chosen": "```python\nfrom manim import *\n\nclass HydrogenGridScene(Scene):\n def construct(self):\n # Grid configuration\n rows = 5\n cols = 7\n \n # Generate 35 distinct colors for each atom\n colors = color_gradient([BLUE, GREEN, YELLOW, RED, PURPLE, TEAL], rows * cols)\n \n atoms = VGroup()\n \n for r in range(rows):\n for c in range(cols):\n # Alternating isotopes for every other row\n if r % 2 == 0:\n label = MathTex(\"H_1\", color=WHITE) # Regular Hydrogen\n else:\n label = MathTex(\"D_2\", color=WHITE) # Deuterium\n \n # Create a uniquely colored circle for the atom\n atom_color = colors[r * cols + c]\n circle = Circle(radius=0.4, color=atom_color, fill_opacity=0.8)\n circle.set_fill(atom_color)\n \n # Group and scale label\n label.scale(0.8)\n atom = VGroup(circle, label)\n \n atoms.add(atom)\n \n # Arrange the atoms in a 5x7 grid and center\n atoms.arrange_in_grid(rows=rows, cols=cols, buff=0.4)\n atoms.center()\n \n # Animate grid introduction\n self.play(LaggedStart(*[FadeIn(atom, shift=UP * 0.5) for atom in atoms], lag_ratio=0.05))\n self.wait(2)\n\nclass ElectronTransitionScene(Scene):\n def construct(self):\n # Energy levels for context\n level_1 = DashedLine(LEFT * 3, RIGHT * 3, color=WHITE, stroke_opacity=0.3).shift(DOWN * 1)\n level_2 = DashedLine(LEFT * 3, RIGHT * 3, color=WHITE, stroke_opacity=0.3).shift(UP * 1)\n level1_label = Text(\"n=1\", font_size=24).next_to(level_1, LEFT)\n level2_label = Text(\"n=2\", font_size=24).next_to(level_2, LEFT)\n \n self.add(level_1, level_2, level1_label, level2_label)\n \n # Electron as a yellow circle\n electron = Circle(radius=0.2, color=YELLOW, fill_opacity=1.0)\n start_pos = DOWN * 1\n electron.move_to(start_pos)\n self.add(electron)\n \n # Define semi-circular paths for the transition\n # Upward path: Right semi-circle from level 1 to level 2\n path_up = Arc(start_angle=-PI/2, angle=PI, radius=1.0, color=YELLOW, stroke_opacity=0.5)\n # Downward path: Left semi-circle from level 2 back to level 1\n path_down = Arc(start_angle=PI/2, angle=PI, radius=1.0, color=YELLOW, stroke_opacity=0.5)\n \n self.add(path_up, path_down)\n \n # Animate excitation (jump to higher energy state)\n self.play(MoveAlongPath(electron, path_up), run_time=1.5)\n self.wait(0.5)\n \n # Animate relaxation (fall back to initial state)\n self.play(MoveAlongPath(electron, path_down), run_time=1.5)\n self.wait(1)\n\nclass ProtonOscillationScene(Scene):\n def construct(self):\n # Proton representation: red circle with 'p+' label\n proton_circle = Circle(radius=0.5, color=RED, fill_opacity=0.8)\n proton_circle.set_fill(RED)\n proton_label = MathTex(\"p^+\", color=WHITE)\n \n proton = VGroup(proton_circle, proton_label)\n proton.move_to(ORIGIN)\n \n # Animation 1: Fade into view\n self.play(FadeIn(proton), run_time=1)\n self.wait(0.5)\n \n # Animation 2: Move upwards\n self.play(proton.animate.shift(UP * 2), run_time=1.5, rate_func=smooth)\n self.wait(0.2)\n \n # Animation 3: Move back down (oscillating along vertical axis)\n self.play(proton.animate.shift(DOWN * 2), run_time=1.5, rate_func=smooth)\n self.wait(1)\n```", "rejected": "```python\nfrom manim import *\n\nclass HydrogenGridScene(Scene):\n def construct(self):\n # Grid configuration\n rows = 5\n cols = 7\n \n # Generate 35 distinct colors for each atom\n colors = color_gradient([BLUE, GREEN, YELLOW, RED, PURPLE, TEAL], rows * cols)\n \n atoms = VGroup()\n \n for r in range(rows):\n for c in range(cols):\n # Alternating isotopes for every other row\n if r % 2 == 0:\n label = MathText(\"H_1\", color=WHITE) # Regular Hydrogen\n else:\n label = MathTex(\"D_2\", color=WHITE) # Deuterium\n \n # Create a uniquely colored circle for the atom\n atom_color = colors[r * cols + c]\n circle = Circle(radius=0.4, color=atom_color, fill_opacity=0.8)\n circle.set_fill(atom_color)\n \n # Group and scale label\n label.scale(0.8)\n atom = VGroup(circle, label)\n \n atoms.add(atom)\n \n # Arrange the atoms in a 5x7 grid and center\n atoms.arrange_in_grid(rows=rows, cols=cols, buff=0.4)\n atoms.center()\n \n # Animate grid introduction\n self.play(LaggedStart(*[FadeIn(atom, shift=UP * 0.5) for atom in atoms], lag_ratio=0.05))\n self.wait(2)\n\nclass ElectronTransitionScene(Scene):\n def construct(self):\n # Energy levels for context\n level_1 = DashedLine(LEFT * 3, RIGHT * 3, color=WHITE, stroke_opacity=0.3).shift(DOWN * 1)\n level_2 = DashedLine(LEFT * 3, RIGHT * 3, color=WHITE, stroke_opacity=0.3).shift(UP * 1)\n level1_label = Text(\"n=1\", font_size=24).next_to(level_1, LEFT)\n level2_label = Text(\"n=2\", font_size=24).next_to(level_2, LEFT)\n \n self.add(level_1, level_2, level1_label, level2_label)\n \n # Electron as a yellow circle\n electron = Circle(radius=0.2, color=YELLOW, fill_opacity=1.0)\n start_pos = DOWN * 1\n electron.move_to(start_pos)\n self.add(electron)\n \n # Define semi-circular paths for the transition\n # Upward path: Right semi-circle from level 1 to level 2\n path_up = Arc(start_angle=-PI/2, angle=PI, radius=1.0, color=YELLOW, stroke_opacity=0.5)\n # Downward path: Left semi-circle from level 2 back to level 1\n path_down = Arc(start_angle=PI/2, angle=PI, radius=1.0, color=YELLOW, stroke_opacity=0.5)\n \n self.add(path_up, path_down)\n \n # Animate excitation (jump to higher energy state)\n self.play(MoveAlongPath(electron, path_up), run_time=1.5)\n self.wait(0.5)\n \n # Animate relaxation (fall back to initial state)\n self.play(MoveAlongPath(electron, path_down), run_time=1.5)\n self.wait(1)\n\nclass ProtonOscillationScene(Scene):\n def construct(self):\n # Proton representation: red circle with 'p+' label\n proton_circle = Circle(radius=0.5, color=RED, fill_opacity=0.8)\n proton_circle.set_fill(RED)\n proton_label = MathTex(\"p^+\", color=WHITE)\n \n proton = VGroup(proton_circle, proton_label)\n proton.move_to(ORIGIN)\n \n # Animation 1: Fade into view\n self.play(FadeIn(proton), run_time=1)\n self.wait(0.5)\n \n # Animation 2: Move upwards\n self.play(proton.animate.shift(UP * 2), run_time=1.5, rate_func=smooth)\n self.wait(0.2)\n \n # Animation 3: Move back down (oscillating along vertical axis)\n self.play(proton.animate.shift(DOWN * 2), run_time=1.5, rate_func=smooth)\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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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# Revolutionary Transformation of Marxist Philosophy\n\n# Revolutionary Transformation of Marxist Philosophy\n\n### 1. Shift in Philosophical Subject: From Abstract Man to Real Man", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MarxistPhilosophy(Scene):\n\n def construct(self):\n title = VGroup(Text('Revolutionary Transformation', font_size=48, weight=BOLD), Text('of Marxist Philosophy', font_size=48, weight=BOLD)).arrange(DOWN)\n self.play(FadeIn(title, shift=UP))\n self.wait(1)\n self.play(title.animate.scale(0.8).to_edge(UP, buff=0.6))\n point_1_title = Text('1. Shift in Philosophical Subject:', font_size=36, color=BLUE)\n point_1_desc = Text('From Abstract Man to Real Man', font_size=36, color=YELLOW)\n point_1 = VGroup(point_1_title, point_1_desc).arrange(DOWN, buff=0.4)\n point_1.next_to(title, DOWN, buff=1.0)\n self.play(Write(point_1_title))\n self.play(FadeIn(point_1_desc, shift=UP))\n self.wait(1)\n abstract_man = Text('Abstract Man', font_size=40, color=RED)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1).scale(1.5)\n real_man = Text('Real Man', font_size=40, color=GREEN)\n shift_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.6)\n shift_group.next_to(point_1, DOWN, buff=1.2)\n self.play(Write(abstract_man))\n self.play(GrowArrow(arrow))\n self.play(Write(real_man))\n self.wait(3)\n self.play(FadeOut(Group(*self.mobjects)))\n self.wait(0.5)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass MarxistPhilosophy(Scene):\n\n def construct(self):\n title = VGroup(Text('Revolutionary Transformation', font_size=48, weight=BOLD), Text('of Marxist Philosophy', font_size=48, weight=BOLD)).arrange(DOWN)\n self.play(FadeIn(title, shift=UP))\n self.wait(1)\n self.play(title.animate.scale(0.8).to_edge(UP, buff=0.6))\n point_1_title = Text('1. Shift in Philosophical Subject:', font_size=36, color=BBLUE)\n point_1_desc = Text('From Abstract Man to Real Man', font_size=36, color=YELLOW)\n point_1 = VGroup(point_1_title, point_1_desc).arrange(DOWN, buff=0.4)\n point_1.next_to(title, DOWN, buff=1.0)\n self.play(Write(point_1_title))\n self.play(FadeIn(point_1_desc, shift=UP))\n self.wait(1)\n abstract_man = Text('Abstract Man', font_size=40, color=RED)\n arrow = Arrow(start=LEFT, end=RIGHT, color=WHITE, buff=0.1).scale(1.5)\n real_man = Text('Real Man', font_size=40, color=GREEN)\n shift_group = VGroup(abstract_man, arrow, real_man).arrange(RIGHT, buff=0.6)\n shift_group.next_to(point_1, DOWN, buff=1.2)\n self.play(Write(abstract_man))\n self.play(GrowArrow(arrow))\n self.play(Write(real_man))\n self.wait(3)\n self.play(FadeOut(Group(*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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 'Torus Topology' (Topology Unraveled: The Secrets of the Torus): How does the genus of a torus influence its Euler characteristic, and what implications does this have in topology?\nVisual style guidance: Visual style should be smooth, dynamic, and colorful, resembling an artistic and almost dreamlike depiction of shapes. Use a soft palette with blues, greens, and reds to maintain focus and emphasize the kinetic and flowing nature of transformations.", "chosen": "```python\nfrom manim import *\n\nclass TorusTopology(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Topology Unraveled: The Secrets of the Torus\")\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Element 1: Torus visualization (simplified 2D representation)\n torus = VGroup(\n Circle(radius=1.5, color=BLUE), # Outer circle\n Circle(radius=0.7, color=WHITE).set_fill(BLACK, opacity=1) # Inner hole\n )\n torus_label = Text(\"Torus: Genus = 1\").scale(0.7).next_to(torus, DOWN)\n \n self.play(Create(torus))\n self.play(Write(torus_label))\n self.wait(1)\n \n # Element 2: Compare sphere and torus to show genus difference\n self.play(\n torus.animate.scale(0.7).shift(RIGHT * 3),\n torus_label.animate.next_to(torus.get_center() + RIGHT * 3 + DOWN * 1.2)\n )\n \n sphere = Circle(radius=1, color=GREEN).scale(0.7).shift(LEFT * 3)\n sphere_label = Text(\"Sphere: Genus = 0\").scale(0.7).next_to(sphere, DOWN)\n \n self.play(Create(sphere), Write(sphere_label))\n self.wait(1)\n \n # Element 3: Introduce Euler characteristic\n euler_title = Text(\"Euler Characteristic\")\n self.play(\n FadeOut(torus),\n FadeOut(torus_label),\n FadeOut(sphere),\n FadeOut(sphere_label),\n Transform(title, euler_title.to_edge(UP))\n )\n \n # Show the Euler characteristic formula\n euler_formula = MathTex(r\"\\chi(S) = V - E + F\")\n self.play(Write(euler_formula))\n self.wait(1)\n \n # Show that the Euler characteristic of a torus is 0\n torus_euler = MathTex(r\"\\chi(Torus) = 0\")\n self.play(\n euler_formula.animate.shift(UP),\n Write(torus_euler.shift(DOWN))\n )\n self.wait(1)\n \n # Show relationship between genus and Euler characteristic\n genus_title = Text(\"Genus and Euler Characteristic\")\n genus_formula = MathTex(r\"\\chi(S) = 2 - 2g\") # Formula connecting genus and Euler characteristic\n \n self.play(\n FadeOut(euler_formula),\n FadeOut(torus_euler),\n Transform(title, genus_title.to_edge(UP))\n )\n \n self.play(Write(genus_formula))\n self.wait(1)\n \n # Conclusion with key insight\n insight_title = Text(\"Key Insight\")\n insight = Text(\"As genus increases, Euler characteristic decreases\").scale(0.7)\n \n self.play(\n FadeOut(genus_formula),\n Transform(title, insight_title.to_edge(UP))\n )\n \n self.play(Write(insight))\n self.wait(1)\n \n # Final message\n final = Text(\"Thank you for exploring topology with us!\").scale(0.7)\n self.play(\n FadeOut(insight),\n FadeOut(title),\n Write(final)\n )\n self.wait(1)\n self.play(FadeOut(final))\n```", "rejected": "```python\nfrom manim import *\n\nclass TorusTopology(Scene):\n def construct(self):\n # Introduction\n title = Text(\"Topology Unraveled: The Secrets of the Torus\")\n self.play(Write(title))\n self.wait(1)\n self.play(title.animate.to_edge(UP))\n \n # Element 1: Torus visualization (simplified 2D representation)\n torus = VGroup(\n Circle(radius=1.5, color=BLUE), # Outer circle\n Circle(radius=0.7, color=WHITE).set_fill(BLACK, opacity=1) # Inner hole\n )\n torus_label = Text(\"Torus: Genus = 1\").scale(0.7).next_to(torus, DOWN)\n \n self.play(Create(torus))\n self.play(Write(torus_label))\n self.wait(1)\n \n # Element 2: Compare sphere and torus to show genus difference\n self.play(\n torus.animate.scale(0.7).shift(RIGHT * 3),\n torus_label.animate.next_to(torus.get_center() + RIGHT * 3 + DOWN * 1.2)\n )\n \n sphere = Circle(radius=1, color=GREEN).scale(0.7).shift(LEFT * 3)\n sphere_label = Text(\"Sphere: Genus = 0\").scale(0.7).next_to(sphere, DOWN)\n \n self.play(Create(sphere), Write(sphere_label))\n self.wait(1)\n \n # Element 3: Introduce Euler characteristic\n euler_title = Text(\"Euler Characteristic\")\n self.play(\n FadeOut(torus),\n FadeOut(torus_label),\n FadeOut(sphere),\n FadeOut(sphere_label),\n Transform(title, euler_title.to_edge(UP))\n )\n \n # Show the Euler characteristic formula\n euler_formula = MathText(r\"\\chi(S) = V - E + F\")\n self.play(Write(euler_formula))\n self.wait(1)\n \n # Show that the Euler characteristic of a torus is 0\n torus_euler = MathTex(r\"\\chi(Torus) = 0\")\n self.play(\n euler_formula.animate.shift(UP),\n Write(torus_euler.shift(DOWN))\n )\n self.wait(1)\n \n # Show relationship between genus and Euler characteristic\n genus_title = Text(\"Genus and Euler Characteristic\")\n genus_formula = MathTex(r\"\\chi(S) = 2 - 2g\") # Formula connecting genus and Euler characteristic\n \n self.play(\n FadeOut(euler_formula),\n FadeOut(torus_euler),\n Transform(title, genus_title.to_edge(UP))\n )\n \n self.play(Write(genus_formula))\n self.wait(1)\n \n # Conclusion with key insight\n insight_title = Text(\"Key Insight\")\n insight = Text(\"As genus increases, Euler characteristic decreases\").scale(0.7)\n \n self.play(\n FadeOut(genus_formula),\n Transform(title, insight_title.to_edge(UP))\n )\n \n self.play(Write(insight))\n self.wait(1)\n \n # Final message\n final = Text(\"Thank you for exploring topology with us!\").scale(0.7)\n self.play(\n FadeOut(insight),\n FadeOut(title),\n Write(final)\n )\n self.wait(1)\n self.play(FadeOut(final))\n```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 illustrates basic chemistry concepts for my students. Can you show the transformation of an electron into an oxygen atom, then show a grid formation of metal oxides, followed by the appearance of a single carbon atom? After that, I want the carbon atom to move along a complex path with specific stopping points. To wrap up, all the elements and compounds should fade out together.", "chosen": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Transformation: Electron into Oxygen Atom\n # ------------------------------------------------------------------\n electron = Dot(radius=0.15, color=YELLOW)\n electron_label = Tex(r\"$e^-$\", font_size=24).next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n\n oxygen_circle = Circle(radius=0.6, color=RED, fill_opacity=0.9)\n oxygen_label = Tex(\"O\", color=WHITE, font_size=36).move_to(oxygen_circle.get_center())\n oxygen_group = VGroup(oxygen_circle, oxygen_label)\n oxygen_group.move_to(electron.get_center())\n\n self.play(FadeIn(electron_group))\n self.wait(0.5)\n\n self.play(ReplacementTransform(electron_group, oxygen_group), run_time=1.5)\n self.wait(0.5)\n\n # Move oxygen aside to make room for the grid\n self.play(oxygen_group.animate.to_edge(LEFT, buff=1))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Formation: Metal Oxides (crystal lattice pattern)\n # ------------------------------------------------------------------\n oxide_grid = VGroup()\n rows, cols = 3, 3\n spacing = 1.2\n\n for i in range(rows):\n for j in range(cols):\n is_metal = (i + j) % 2 == 0\n color = GREY if is_metal else RED\n label = \"M\" if is_metal else \"O\"\n\n atom = Circle(radius=0.35, color=color, fill_opacity=0.85)\n atom_label = Tex(label, color=WHITE, font_size=24).move_to(atom.get_center())\n atom_group = VGroup(atom, atom_label)\n atom_group.move_to([\n j * spacing - (cols - 1) * spacing / 2,\n i * spacing - (rows - 1) * spacing / 2,\n 0\n ])\n oxide_grid.add(atom_group)\n\n self.play(LaggedStartMap(FadeIn, oxide_grid, lag_ratio=0.1), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Carbon Appearance\n # ------------------------------------------------------------------\n carbon_circle = Circle(radius=0.6, color=DARK_GREY, fill_opacity=1)\n carbon_label = Tex(\"C\", color=WHITE, font_size=36).move_to(carbon_circle.get_center())\n carbon_group = VGroup(carbon_circle, carbon_label)\n carbon_group.move_to(LEFT * 4 + UP * 2)\n\n self.play(FadeIn(carbon_group))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Complex Path with Stopping Points\n # ------------------------------------------------------------------\n waypoints = [\n LEFT * 4 + UP * 2,\n LEFT * 2 + UP * 3,\n RIGHT * 1 + UP * 2,\n RIGHT * 3 + UP * 3,\n RIGHT * 4 + DOWN * 1,\n ]\n\n # Visualize the path as a smooth dashed curve\n path_line = VMobject()\n path_line.set_points_smoothly([np.array(p) for p in waypoints])\n path_line.set_stroke(color=YELLOW, width=2, opacity=0.4)\n path_line.set_dash_pattern((0.3, 0.3))\n\n self.play(Create(path_line), run_time=1)\n\n # Animate carbon along the path with pauses at each waypoint\n for i in range(1, len(waypoints)):\n self.play(\n carbon_group.animate.move_to(waypoints[i]),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(0.8)\n\n # ------------------------------------------------------------------\n # 5. Fade Out\n # ------------------------------------------------------------------\n all_elements = VGroup(oxygen_group, oxide_grid, carbon_group, path_line)\n self.play(FadeOut(all_elements), run_time=1.5)\n self.wait()\n```", "rejected": "```python\nfrom manim import *\nimport numpy as np\n\nclass ChemistryAnimation(Scene):\n def construct(self):\n # ------------------------------------------------------------------\n # 1. Transformation: Electron into Oxygen Atom\n # ------------------------------------------------------------------\n electron = Dot(radius=0.15, color=YELLOW)\n electron_label = Tex(r\"$e^-$\", font_size=24).next_to(electron, DOWN, buff=0.1)\n electron_group = VGroup(electron, electron_label)\n\n oxygen_circle = Circle(radius=0.6, color=RED, fill_opacity=0.9)\n oxygen_label = Tex(\"O\", color=WHITE, font_size=36).move_to(oxygen_circle.get_center())\n oxygen_group = VGroup(oxygen_circle, oxygen_label)\n oxygen_group.move_to(electron.get_center())\n\n self.play(FadeIn(electron_group))\n self.wait(0.5)\n\n self.play(ReplacementTransform(electron_group, oxygen_group), run_time=1.5)\n self.wait(0.5)\n\n # Move oxygen aside to make room for the grid\n self.play(oxygen_group.animate.to_edge(LEFT, buff=1))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 2. Grid Formation: Metal Oxides (crystal lattice pattern)\n # ------------------------------------------------------------------\n oxide_grid = VGroup()\n rows, cols = 3, 3\n spacing = 1.2\n\n for i in range(rows):\n for j in range(cols):\n is_metal = (i + j) % 2 == 0\n color = GREY if is_metal else RED\n label = \"M\" if is_metal else \"O\"\n\n atom = Circle(radius=0.35, color=color, fill_opacity=0.85)\n atom_label = Tex(label, color=WHITE, font_size=24).move_to(atom.get_center())\n atom_group = VGroup(atom, atom_label)\n atom_group.move_to([\n j * spacing - (cols - 1) * spacing / 2,\n i * spacing - (rows - 1) * spacing / 2,\n 0\n ])\n oxide_grid.add(atom_group)\n\n self.play(LaggedStartMap(FadeIn, oxide_grid, lag_ratio=0.1), run_time=2)\n self.wait(1)\n\n # ------------------------------------------------------------------\n # 3. Carbon Appearance\n # ------------------------------------------------------------------\n carbon_circle = Circle(radius=0.6, color=DARK_GREY, fill_opacity=1)\n carbon_label = Tex(\"C\", color=WHITE, font_size=36).move_to(carbon_circle.get_center())\n carbon_group = VGroup(carbon_circle, carbon_label)\n carbon_group.move_to(LEFT * 4 + UP * 2)\n\n self.play(FadeIn(carbon_group))\n self.wait(0.5)\n\n # ------------------------------------------------------------------\n # 4. Complex Path with Stopping Points\n # ------------------------------------------------------------------\n waypoints = [\n LEFT * 4 + UP * 2,\n LEFT * 2 + UP * 3,\n RIGHT * 1 + UP * 2,\n RIGHT * 3 + UP * 3,\n RIGHT * 4 + DOWN * 1,\n ]\n\n # Visualize the path as a smooth dashed curve\n path_line = VMob()\n path_line.set_points_smoothly([np.array(p) for p in waypoints])\n path_line.set_stroke(color=YELLOW, width=2, opacity=0.4)\n path_line.set_dash_pattern((0.3, 0.3))\n\n self.play(Create(path_line), run_time=1)\n\n # Animate carbon along the path with pauses at each waypoint\n for i in range(1, len(waypoints)):\n self.play(\n carbon_group.animate.move_to(waypoints[i]),\n run_time=1.5,\n rate_func=smooth\n )\n self.wait(0.8)\n\n # ------------------------------------------------------------------\n # 5. Fade Out\n # ------------------------------------------------------------------\n all_elements = VGroup(oxygen_group, oxide_grid, carbon_group, path_line)\n self.play(FadeOut(all_elements), 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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(label_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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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## 50. Feature Maps and Changes Between Layers", "chosen": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass FeatureMapsChanges(Scene):\n\n def construct(self):\n title = Text('Feature Maps and Changes Between Layers', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title))\n\n def create_tensor(w, h, c, color, offset=0.1):\n tensor = VGroup()\n for i in range(c):\n rect = Rectangle(width=w, height=h, color=color, fill_opacity=0.6, stroke_width=1.5)\n rect.shift(RIGHT * offset * i + UP * offset * i)\n tensor.add(rect)\n else:\n pass\n tensor.move_to(ORIGIN)\n return tensor\n input_tensor = create_tensor(2.2, 2.2, 3, BLUE, offset=0.15)\n input_tensor.move_to(LEFT * 4.5)\n input_label = MathTex('64 \\\\times 64 \\\\times 3', font_size=22)\n input_label.next_to(input_tensor, DOWN, buff=0.6)\n input_name = Text('Input Image', font_size=20, color=BLUE)\n input_name.next_to(input_label, DOWN, buff=0.2)\n input_group = VGroup(input_tensor, input_label, input_name)\n arrow1 = Arrow(start=LEFT * 2.8, end=LEFT * 1.2, buff=0, color=WHITE)\n conv_label = Text('Convolution', font_size=18).next_to(arrow1, UP, buff=0.15)\n kernel_label = MathTex('3 \\\\times 3 \\\\text{ kernel}', font_size=18).next_to(arrow1, DOWN, buff=0.15)\n arrow1_group = VGroup(arrow1, conv_label, kernel_label)\n fm1_tensor = create_tensor(1.6, 1.6, 8, ORANGE, offset=0.08)\n fm1_tensor.move_to(ORIGIN)\n fm1_label = MathTex('62 \\\\times 62 \\\\times 64', font_size=22)\n fm1_label.next_to(fm1_tensor, DOWN, buff=0.6)\n fm1_name = Text('Feature Map 1', font_size=20, color=ORANGE)\n fm1_name.next_to(fm1_label, DOWN, buff=0.2)\n fm1_group = VGroup(fm1_tensor, fm1_label, fm1_name)\n arrow2 = Arrow(start=RIGHT * 1.2, end=RIGHT * 2.8, buff=0, color=WHITE)\n pool_label = Text('Max Pooling', font_size=18).next_to(arrow2, UP, buff=0.15)\n stride_label = MathTex('2 \\\\times 2 \\\\text{ stride}', font_size=18).next_to(arrow2, DOWN, buff=0.15)\n arrow2_group = VGroup(arrow2, pool_label, stride_label)\n fm2_tensor = create_tensor(1.0, 1.0, 8, RED, offset=0.08)\n fm2_tensor.move_to(RIGHT * 4.5)\n fm2_label = MathTex('31 \\\\times 31 \\\\times 64', font_size=22)\n fm2_label.next_to(fm2_tensor, DOWN, buff=0.6)\n fm2_name = Text('Feature Map 2', font_size=20, color=RED)\n fm2_name.next_to(fm2_label, DOWN, buff=0.2)\n fm2_group = VGroup(fm2_tensor, fm2_label, fm2_name)\n self.play(FadeIn(input_group, shift=UP * 0.5))\n self.wait(0.5)\n front_rect = input_tensor[-1]\n kernel_box = Square(side_length=0.4, color=YELLOW, stroke_width=2.5)\n kernel_box.move_to(front_rect.get_corner(UL) + RIGHT * 0.2 + DOWN * 0.2)\n self.play(FadeIn(kernel_box))\n self.play(kernel_box.animate.move_to(front_rect.get_corner(UR) + LEFT * 0.2 + DOWN * 0.2), run_time=1.5, rate_func=linear)\n self.play(FadeOut(kernel_box), GrowArrow(arrow1), FadeIn(conv_label), FadeIn(kernel_label))\n self.play(FadeIn(fm1_group, shift=UP * 0.5))\n self.wait(0.5)\n self.play(GrowArrow(arrow2), FadeIn(pool_label), FadeIn(stride_label))\n self.play(FadeIn(fm2_group, shift=UP * 0.5))\n self.wait(0.5)\n self.play(Indicate(input_label, color=YELLOW, scale_factor=1.2))\n self.play(Indicate(fm1_label, color=YELLOW, scale_factor=1.2))\n self.play(Indicate(fm2_label, color=YELLOW, scale_factor=1.2))\n self.wait(2)\n```", "rejected": "```python\nfrom manim import *\nfrom manim import config\nText.set_default(font='SimHei')\n\nclass FeatureMapsChanges(Scene):\n\n def construct(self):\n title = Text('Feature Maps and Changes Between Layers', font_size=36, weight=BOLD)\n title.to_edge(UP, buff=0.5)\n self.play(Write(title))\n\n def create_tensor(w, h, c, color, offset=0.1):\n tensor = VGroup()\n for i in range(c):\n rect = Rectangle(width=w, height=h, color=color, fill_opacity=0.6, stroke_width=1.5)\n rect.shift(RIGHT * offset * i + UP * offset * i)\n tensor.add(rect)\n else:\n pass\n tensor.move_to(ORIGIN)\n return tensor\n input_tensor = create_tensor(2.2, 2.2, 3, BLUE, offset=0.15)\n input_tensor.move_to(LEFT * 4.5)\n input_label = MathText('64 \\\\times 64 \\\\times 3', font_size=22)\n input_label.next_to(input_tensor, DOWN, buff=0.6)\n input_name = Text('Input Image', font_size=20, color=BLUE)\n input_name.next_to(input_label, DOWN, buff=0.2)\n input_group = VGroup(input_tensor, input_label, input_name)\n arrow1 = Arrow(start=LEFT * 2.8, end=LEFT * 1.2, buff=0, color=WHITE)\n conv_label = Text('Convolution', font_size=18).next_to(arrow1, UP, buff=0.15)\n kernel_label = MathTex('3 \\\\times 3 \\\\text{ kernel}', font_size=18).next_to(arrow1, DOWN, buff=0.15)\n arrow1_group = VGroup(arrow1, conv_label, kernel_label)\n fm1_tensor = create_tensor(1.6, 1.6, 8, ORANGE, offset=0.08)\n fm1_tensor.move_to(ORIGIN)\n fm1_label = MathTex('62 \\\\times 62 \\\\times 64', font_size=22)\n fm1_label.next_to(fm1_tensor, DOWN, buff=0.6)\n fm1_name = Text('Feature Map 1', font_size=20, color=ORANGE)\n fm1_name.next_to(fm1_label, DOWN, buff=0.2)\n fm1_group = VGroup(fm1_tensor, fm1_label, fm1_name)\n arrow2 = Arrow(start=RIGHT * 1.2, end=RIGHT * 2.8, buff=0, color=WHITE)\n pool_label = Text('Max Pooling', font_size=18).next_to(arrow2, UP, buff=0.15)\n stride_label = MathTex('2 \\\\times 2 \\\\text{ stride}', font_size=18).next_to(arrow2, DOWN, buff=0.15)\n arrow2_group = VGroup(arrow2, pool_label, stride_label)\n fm2_tensor = create_tensor(1.0, 1.0, 8, RED, offset=0.08)\n fm2_tensor.move_to(RIGHT * 4.5)\n fm2_label = MathTex('31 \\\\times 31 \\\\times 64', font_size=22)\n fm2_label.next_to(fm2_tensor, DOWN, buff=0.6)\n fm2_name = Text('Feature Map 2', font_size=20, color=RED)\n fm2_name.next_to(fm2_label, DOWN, buff=0.2)\n fm2_group = VGroup(fm2_tensor, fm2_label, fm2_name)\n self.play(FadeIn(input_group, shift=UP * 0.5))\n self.wait(0.5)\n front_rect = input_tensor[-1]\n kernel_box = Square(side_length=0.4, color=YELLOW, stroke_width=2.5)\n kernel_box.move_to(front_rect.get_corner(UL) + RIGHT * 0.2 + DOWN * 0.2)\n self.play(FadeIn(kernel_box))\n self.play(kernel_box.animate.move_to(front_rect.get_corner(UR) + LEFT * 0.2 + DOWN * 0.2), run_time=1.5, rate_func=linear)\n self.play(FadeOut(kernel_box), GrowArrow(arrow1), FadeIn(conv_label), FadeIn(kernel_label))\n self.play(FadeIn(fm1_group, shift=UP * 0.5))\n self.wait(0.5)\n self.play(GrowArrow(arrow2), FadeIn(pool_label), FadeIn(stride_label))\n self.play(FadeIn(fm2_group, shift=UP * 0.5))\n self.wait(0.5)\n self.play(Indicate(input_label, color=YELLOW, scale_factor=1.2))\n self.play(Indicate(fm1_label, color=YELLOW, scale_factor=1.2))\n self.play(Indicate(fm2_label, color=YELLOW, scale_factor=1.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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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 starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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```"} {"system": "You are an elite Manim Community Edition (ManimCE v0.19+) developer who creates visually rich, deeply animative 3Blue1Brown-style mathematical animations.\nFollow these strict rules in every script:\n1. Output ONLY a single complete, runnable Python code block starting with `from manim import *`, `import numpy as np`, and `import math`. Never truncate code or leave incomplete indentation.\n2. Use ONLY real ManimCE v0.19+ symbols & APIs:\n - Use `MathTex` or `Text` (NEVER `MathText`), `RoundedRectangle` (NEVER `RoundRect`), `VMobject` (NEVER `VMob`), `always_redraw` (NEVER `AlwaysUpToCondition`), `FadeOut(*self.mobjects)` (NEVER `FullScreenCover`).\n - Unpack lists when creating `VGroup(*items)` (NEVER pass a raw Python list `VGroup(items)`).\n - Pass `x_axis_config={...}` / `y_axis_config={...}` inside `Axes(...)` (NEVER call `axes.set_x_axis_config()`).\n - NEVER pass `label_font_size`, `font_size`, `max_points_per_line`, or `max_length_ratio` directly to `Axes`/`NumberLine`/`VMobject`; NEVER access `axes.y_max`/`axes.x_max` (use `axes.y_range[1]`); NEVER use `target_position` in `Transform`; NEVER call `self.set_zoom(...)`; NEVER use `BBLUE`; NEVER `Transform` a bare `Mobject()` (use `VMobject`/`VGroup`).\n3. Make every scene highly animative: use geometric Mobjects (`Axes`, `NumberPlane`, `VGroup`, `Arrow`, `Brace`, `SurroundingRectangle`, `RoundedRectangle`, `Circle`, `Square`, `Dot`), smooth dynamic animations (`Create`, `ReplacementTransform`, `FadeTransform`, `LaggedStart`, `AnimationGroup`, `Indicate`, `Circumscribe`, `ValueTracker`, `always_redraw`), and explicit `run_time` and `self.wait()` pacing.\n4. For multi-concept or long videos, structure the Scene into clean modular helper methods (`self.act_1_...()`, `self.clear_stage()`, `self.act_2_...()`) and always fade out previous act Mobjects 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=BBLUE_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```"}