Location>code7788 >text

manim learning by doing - the complex plane

Popularity:936 ℃/2024-10-23 10:18:56

what is calledArgand plane, is a two-dimensional coordinate system for geometrically representing complex scenes, where the horizontal axis represents the real part and the vertical axis represents the imaginary part.

Each point corresponds to a unique complex number and vice versa, and this representation allows operations such as addition and multiplication of complex numbers to be understood by visualizing graphical transformations.

ComplexPlanebeManimlibrary for processingArgand planeThe class.

It not only provides a standard Cartesian coordinate system, but is also optimized especially for complex number operations, making the visualization of complex numbers and their transformations more intuitive.

pass (a bill or inspection etc)ComplexPlaneWe can easily plot complex points and vectors as well as perform complex transformations such as rotation and scaling.

This post will introduceManimhit the nail on the headComplexPlaneobjects as well as some common usage examples.

1. Main parameters

ComplexPlaneInherited from the previous introductionNumberPlane

ComplexPlanehas no parameters specific to itself, andNumberPlaneThe parameters are the same.

Parameter name typology clarification
x_range Sequence[float] the plane of right angleshorizontal coordinate axisRange, Interval
y_range Sequence[float] the plane of right anglesvertical coordinate axisRange, Interval
x_length float Right Angle Plane Width
y_length float Right Angle Plane Height
background_line_style dict Right Angle Plane Background Gridline Style
faded_line_style dict Fade gridline style for secondary background gridlines
faded_line_ratio int Define the ratio of the fade gridlines to the background gridlines
make_smooth_after_applying_functions bool Whether smoothing is performed after applying the function

2. Main approaches

cap (a poem)NumberPlaneSame.ComplexPlaneThe coordinate system is also includedCoordinateSystemmethod provided by the class

However, in the complex plane, I use the following 3 methods more often:

name (of a thing) clarification
add_coordinates Adding scale values to the axes of the complex plane
n2p(number_to_point) Get the position of this complex number in the complex plane from the complex number
p2n(point_to_number) Obtain the corresponding complex number from the position in the complex plane

3. Examples of use

The following example demonstrates the complex planeComplexPlaneA variety of functions, including grids and axes in the complex plane, labeling and displaying complex points, images of functions in the complex plane, and animation of complex transformations.

have sb do sthComplexPlanebecomes a powerful tool for us to demonstrate the concepts and properties of complex numbers.

3.1 Grids and axes

Creating a complex planeComplexPlaneThe grid lines and axes are drawn, and the extent of the real part is set.[-5, 5]Scope of the imaginary part[-4, 4], and finally add scale values to the axes.

plane = ComplexPlane(
    x_range=[-5, 5],
    y_range=[-4, 4],
    x_length=6,
    y_length=4,
)

# Plus scale values
plane.add_coordinates()

3.2 Marking of plural points

Add 2 complex points to the complex plane coordinates and then add labels to both points to show their complex values.

# Create a complex plane
plane = ComplexPlane(
    
    y_range=[-5, 5], )
)
plane.add_coordinates()

# Add complex points
d1 = Dot(plane.n2p(3 + 2j))
d2 = Dot(plane.n2p(-4 - 2j))

3.3 Complex number operations

Add two points to the complex plane, then compute the result of adding these two complex numbers and animate the computation on the complex plane.

# Create a complex plane
plane = ComplexPlane(
    
    y_range=[-1, 8],
)
plane.add_coordinates()

# Initial two points
d1 = Dot(plane.n2p(2 + 1j))
d2 = Dot(plane.n2p(2 + 4j))

# Points after summing
d3 = Dot(plane.n2p(4 + 5j))

3.4 Complex number transformations

Finally, it is the complex point that undergoes a functional transformation to show the new position in the complex plane.

The example starts with an initial 4 points, then after a transformation by the function $ f(x)=2^x $, shows their transformed positions.

which uses theComplexPlaneThe main methodology of the Committee on Economic, Social and Cultural Rightsn2pcap (a poem)p2n

# Create a complex plane
plane = ComplexPlane(
    
    y_range=[-5, 5], )
)
plane.add_coordinates()

d1 = LabeledDot(
    label=MathTex("1"),
    point=plane.n2p(2 + 1j), )
)
d2 = LabeledDot(
    label=MathTex("2"),
    point=plane.n2p(2 + 3j), )
)
d3 = LabeledDot(
    label=MathTex("3"),
    point=plane.n2p(-2 - 2j), )
)
d4 = LabeledDot(
    label=MathTex("4"),
    point=plane.n2p(-3 + 2j), )
)
(d1, d2, d3, d4)

# Position of the transformed point
pd1 = np.exp2(plane.p2n(d1.get_center()))
pd2 = np.exp2(plane.p2n(d2.get_center()))
pd3 = np.exp2(plane.p2n(d3.get_center()))
pd4 = np.exp2(plane.p2n(d4.get_center()))

4. Annexes

The code in the article is just an extract of the key parts, the complete code is shared on a web disk (complex_plane.py),

Download at.Full Code (Access code: 6872)