Write an incredibly high quality manimCE script
Rate quality
Private research annotation
Sign in to add a private research label or note.
- User
Write an incredibly high quality manimCE script
Assistant
Sign in to add a private research label or note.
Write an incredibly high quality manimCE script
from manimce import *
class FourierSeries(Scene):
def construct(self):
# Define the function to visualize
func = lambda x: np.sin(x) + 0.5 * np.sin(3 * x) + 0.25 * np.sin(5 * x)
# Create the graph
graph = FunctionGraph(func, x_range=[-3*PI, 3*PI], color=BLUE)
self.play(Create(graph), run_time=2)
# Define the number of harmonics to use
num_harmonics = 5
# Create the circle and dot animations
circles = VGroup(*[Circle(radius=1, color=YELLOW) for _ in range(num_harmonics)])
dots = VGroup(*[Dot(radius=0.05, color=RED) for _ in range(num_harmonics)])
# Set the initial positions of the circles and dots
for i, circle in enumerate(circles):
angle = (i+1) * PI / 2
circle.move_to(np.array([2 + i, 0, 0]))
dots[i].move_to(circle.get_center())
# Create the lines representing the radius of the circles
lines = VGroup(*[Line(start=circle.get_center(), end=dots[i].get_center(), color=GREEN) for i, circle in enumerate(circles)])
# Create the function representing the sum of the harmonics
def harmonic_sum(x):
sum = 0
for i in range(num_harmonics):
angle = (i+1) * x
sum += np.sin(angle) / (i+1)
return sum
graph_sum = FunctionGraph(harmonic_sum, x_range=[-3*PI, 3*PI], color=PURPLE)
# Animate the circles, dots, and lines
self.play(FadeIn(circles))
self.play(FadeIn(dots))
self.play(FadeIn(lines))
# Animate the rotation of the circles and dots
for i in range(num_harmonics):
self.play(Rotate(circles[i], angle=2*PI, about_point=circles[i].get_center(), rate_func=linear, run_time=4))
self.play(MoveAlongPath(dots[i], circles[i]), run_time=4)
# Animate the creation of the sum function graph
self.play(Create(graph_sum), run_time=2)
# Highlight the difference between the original function and the sum
self.play(FadeOut(graph_sum))
self.play(FadeOut(circles), FadeOut(dots), FadeOut(lines))
self.play(Create(graph_sum), run_time=1)
self.play(FadeOut(graph), run_time=1)
# Show the final approximation
self.wait(2)
# Add a text label
label = Tex("Fourier Series Approximation").scale(0.7)
label.to_corner(UR)
self.play(FadeIn(label))
self.wait(2)
Explanation:
This script uses ManimCE to create an animation demonstrating the concept of Fourier series. Here's a breakdown:
Import Libraries:
from manimce import * imports all the necessary functionalities from the ManimCE library.Scene Definition:
class FourierSeries(Scene): defines a new scene named "FourierSeries" where the animation will occur.Construct Method:
def construct(self): is the main method within the scene that contains the animation instructions.Function Definition:
func = lambda x: np.sin(x) + 0.5 * np.sin(3 * x) + 0.25 * np.sin(5 * x) defines the function we want to approximate using Fourier series.Graph Creation:
graph = FunctionGraph(func, x_range=[-3*PI, 3*PI], color=BLUE) creates the graph of the function.self.play(Create(graph), run_time=2) animates the creation of the graph.Harmonics Setup:
num_harmonics = 5 sets the number of harmonics to be used in the approximation.Circle and Dot Animations:
circles = VGroup(*[Circle(radius=1, color=YELLOW) for _ in range(num_harmonics)]) creates a group of circles representing the harmonics.dots = VGroup(*[Dot(radius=0.05, color=RED) for _ in range(num_harmonics)]) creates a group of dots representing the rotating points on the circles.Harmonic Sum Function:
def harmonic_sum(x): ... defines a function that calculates the sum of the harmonics at a given x value.Sum Graph Creation:
graph_sum = FunctionGraph(harmonic_sum, x_range=[-3*PI, 3*PI], color=PURPLE) creates the graph of the sum function.Animation Sequence:
This script combines various animation techniques, colors, and labels to create a visually appealing and informative explanation of Fourier series.
“Write an incredibly high quality manimCE script.” Conversation with gemini-1.5-flash-api-0514, from the LMArena Human Preference 100K dataset. The Chat Archive, 2026. https://thechatarchive.com/c/01m850h340wd2nhpygszwgd4ed
Not yet included in a published release.