Continued Fractions in Manim #4280
Unanswered
electrineer1
asked this question in
Q&A
Replies: 2 comments
-
sorry, but I don't understand what you want to animate here or how you want to present the result. Come over to Discord for a better discussion environment then here on Github. For just "displaying the continuous fraction" that's quite simple: class contfrac(Scene):
def construct(self):
eqn = MathTex(r"""
f(z) = z + \frac{1}{-z+\frac{1}{z+\frac{1}{-z+\frac{1}{z+\frac{1}{-z}}}}}
""")
self.add(eqn) |
Beta Was this translation helpful? Give feedback.
0 replies
-
If you just want to show numerical results, perhaps you already know that Python can natively calculate with complex numbers? class contfrac(Scene):
def construct(self):
eqn = MathTex(r"""
f(z) = z + \frac{1}{-z+\frac{1}{z+\frac{1}{-z+\frac{1}{z+\frac{1}{-z}}}}}
""")
self.add(eqn.to_edge(UP, buff=0))
def cf(z):
return z + 1/(-z+1/(z+1/(-z+1/(z+1/(-z)))))
valstr = ""
for z in [-1, -1j, +1j, +1, 1+1j, 1-1j]:
try:
valstr += rf"f({z}) &={np.abs(cf(z)):.07f}\\"
except:
valstr += rf"f({z}) &=\text{{NaN}}\\"
valstex = MathTex(valstr)
self.add(valstex.to_edge(DOWN,buff=0)) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, can anyone provide tips on how a continued fraction could be displayed in manim? For example, I'd like to create the fraction f(z) = z + 1/(-z+1/(z+1/(-z+1/(z+1/(-z))))) where z is a complex variable whose magnitude and argument I would adjust during the animation. I would show the absolute magnitude of the result, so |f(z)|.
Beta Was this translation helpful? Give feedback.
All reactions