summaryrefslogtreecommitdiff
path: root/FSF-2020/approximations-and-optimizations/Critical Points
diff options
context:
space:
mode:
authorVaishnavi2020-05-25 23:25:16 +0530
committerGitHub2020-05-25 23:25:16 +0530
commit7f48f12dccac8b709a4e5cf77267d189d828e816 (patch)
treef11ae833ec4dd5ef39153dce6920676628be1816 /FSF-2020/approximations-and-optimizations/Critical Points
parent9ddec26eb2dfbc1b0a9d595d43e36727b7431304 (diff)
downloadFSF-mathematics-python-code-archive-7f48f12dccac8b709a4e5cf77267d189d828e816.tar.gz
FSF-mathematics-python-code-archive-7f48f12dccac8b709a4e5cf77267d189d828e816.tar.bz2
FSF-mathematics-python-code-archive-7f48f12dccac8b709a4e5cf77267d189d828e816.zip
Create types_of_cp.py
Diffstat (limited to 'FSF-2020/approximations-and-optimizations/Critical Points')
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py b/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py
new file mode 100644
index 0000000..49f083f
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py
@@ -0,0 +1,69 @@
+from manimlib.imports import *
+
+class TypescpAnimation(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ r_text = TextMobject("Relative Maxima at ORIGIN",color ='#87CEFA')
+ f_text = TextMobject("$f(x,y) = -x^2-y^2$").to_corner(UL)
+
+ #----graph of first function f(x,y) = -x**2-y**2
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2-v**2
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [YELLOW_D, YELLOW_E],
+ resolution = (20, 20)).scale(1)
+
+ r2_text = TextMobject("Saddle Point at ORIGIN",color ='#87CEFA')
+ f2_text = TextMobject("$f(x,y) = -x^2+y^2$").to_corner(UL)
+
+ #----graph of second function f(x,y) = -x**2+y**2
+ f2 = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2+v**2
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [RED_D, RED_E],
+ resolution = (20, 20)).scale(1)
+
+ r3_text = TextMobject("Relative Minima at ORIGIN",color ='#87CEFA')
+ f3_text = TextMobject("$f(x,y) = x^2+y^2$").to_corner(UL)
+
+ #----graph of third function f(x,y) = x**2+y**2
+ f3 = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ u**2+v**2
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [GREEN_D, GREEN_E],
+ resolution = (20, 20)).scale(1)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = -45 * DEGREES )
+
+ self.add_fixed_in_frame_mobjects(r_text)
+ self.wait(1)
+ self.play(FadeOut(r_text))
+ self.add(axes)
+ self.play(Write(f))
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(f),FadeOut(f_text))
+
+ self.add_fixed_in_frame_mobjects(r2_text)
+ self.wait(1)
+ self.play(FadeOut(r2_text))
+ self.add(axes)
+ self.play(Write(f2))
+ self.add_fixed_in_frame_mobjects(f2_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(f2),FadeOut(f2_text))
+
+ self.add_fixed_in_frame_mobjects(r3_text)
+ self.wait(1)
+ self.play(FadeOut(r3_text))
+ self.add(axes)
+ self.play(Write(f3))
+ self.add_fixed_in_frame_mobjects(f3_text)
+ self.wait(2)