summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/approximations-and-optimizations
diff options
context:
space:
mode:
authorVaishnavi2020-06-24 04:50:58 +0530
committerGitHub2020-06-24 04:50:58 +0530
commit9c6d394101ad89681ef497cd0667fa23e6f3d168 (patch)
tree3a31ae0898b7b83fe1c576d71addcec65ad8a218 /FSF-2020/calculus-of-several-variables/approximations-and-optimizations
parent91f4e736577c6a4bf1f17b5eded2942905a0573d (diff)
downloadFSF-mathematics-python-code-archive-9c6d394101ad89681ef497cd0667fa23e6f3d168.tar.gz
FSF-mathematics-python-code-archive-9c6d394101ad89681ef497cd0667fa23e6f3d168.tar.bz2
FSF-mathematics-python-code-archive-9c6d394101ad89681ef497cd0667fa23e6f3d168.zip
Rename FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py to FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/approximations-and-optimizations')
-rw-r--r--FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
new file mode 100644
index 0000000..e674113
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
@@ -0,0 +1,73 @@
+from manimlib.imports import*
+
+#---- tangent plane to minima of the function
+class firstScene(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes()
+ label_x = TextMobject("$x$").shift([5.5,-0.5,0]) #---- x axis
+ label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5) #---- y axis
+
+ #---- parabola: f(x,y) = x**2 + y**2
+ parabola = 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_E,GREEN_D,GREEN_C,GREEN_B], resolution = (20, 20)).scale(1)
+
+ d = Dot(np.array([0,0,0]), color = '#800000') # ---- critical point
+
+ tangent_plane = Rectangle(fill_color = '#C0C0C0', fill_opacity = 0.3).move_to(ORIGIN).fade(0.7) # ----tangent plane
+
+ parabola_text = TextMobject("Minimum with horizontal tangent plane").scale(0.7).to_corner(UL)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = 45 * DEGREES)
+ self.begin_ambient_camera_rotation(rate = 0.2)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.add_fixed_in_frame_mobjects(parabola_text)
+ self.wait(1)
+ self.play(Write(parabola))
+ self.play(ShowCreation(d))
+ self.wait(1)
+ self.play(ShowCreation(tangent_plane))
+ self.wait(2)
+ self.play(FadeOut(parabola_text),FadeOut(parabola),FadeOut(tangent_plane),FadeOut(d),FadeOut(label_x),FadeOut(label_y),FadeOut(axes))
+
+
+#---- tangent plane to maxima of the function
+class secondScene(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes()
+ label_x = TextMobject("$x$").shift([5.5,-0.5,0]) #---- x axis
+ label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5) #---- y axis
+
+ #----parabola: g(x,y) = -x**2-y**2
+ parabola = 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 = [BLUE_E,BLUE_D,BLUE_C,BLUE_B], resolution = (20, 20)).scale(1)
+
+ d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point
+
+ tangent_plane = Rectangle(fill_color = '#C0C0C0',fill_opacity = 0.3).move_to(ORIGIN).fade(0.7) #---- tangent plane
+
+ parabola_text = TextMobject("Maximum with horizontal tangent plane").scale(0.7).to_corner(UL)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = 45 * DEGREES)
+ self.begin_ambient_camera_rotation(rate = 0.2)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.add_fixed_in_frame_mobjects(parabola_text)
+ self.wait(1)
+ self.play(Write(parabola))
+ self.play(ShowCreation(d))
+ self.wait(1)
+ self.play(ShowCreation(tangent_plane))
+ self.wait(2)