summaryrefslogtreecommitdiff
path: root/FSF-2020
diff options
context:
space:
mode:
authorVaishnavi2020-06-24 00:44:44 +0530
committerGitHub2020-06-24 00:44:44 +0530
commit6e5e6936f498a12a514371060916691495cf8c20 (patch)
tree16216ccc8f3137093741eff65a113b9cd767c9d3 /FSF-2020
parentad1c0e62ba7ff5bb9612a8fd674005a26e3fd80b (diff)
downloadFSF-mathematics-python-code-archive-6e5e6936f498a12a514371060916691495cf8c20.tar.gz
FSF-mathematics-python-code-archive-6e5e6936f498a12a514371060916691495cf8c20.tar.bz2
FSF-mathematics-python-code-archive-6e5e6936f498a12a514371060916691495cf8c20.zip
Update file3_Tangent_plane_at_extrema_of_a_function.py
Diffstat (limited to 'FSF-2020')
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py82
1 files changed, 51 insertions, 31 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
index b066d04..e674113 100644
--- a/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py
@@ -1,53 +1,73 @@
from manimlib.imports import*
-class TangentPlane(ThreeDScene):
+#---- 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: x**2+y**2
- parabola1 = ParametricSurface(
+ #---- 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)
+ ]),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)
- #----parabola: -x**2-y**2
- parabola2 = 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)
-
- self.set_camera_orientation(phi=75 * DEGREES)
- self.begin_ambient_camera_rotation(rate=0.2)
-
- d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point
- r = Rectangle(fill_color= '#C0C0C0',fill_opacity = 0.3).move_to(ORIGIN).fade(0.7) #----tangent plane
+ d = Dot(np.array([0,0,0]), color = '#800000') # ---- critical point
- parabola1_text = TextMobject("Maximum with horizontal tangent plane").scale(0.7).to_corner(UL)
+ tangent_plane = Rectangle(fill_color = '#C0C0C0', fill_opacity = 0.3).move_to(ORIGIN).fade(0.7) # ----tangent plane
- parabola2_text = TextMobject("Minimum with horizontal tangent plane").scale(0.7).to_corner(UL)
+ 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_fixed_in_frame_mobjects(parabola2_text)
+ self.add(label_x)
+ self.add(label_y)
+ self.add_fixed_in_frame_mobjects(parabola_text)
self.wait(1)
- self.play(Write(parabola1))
+ self.play(Write(parabola))
self.play(ShowCreation(d))
self.wait(1)
- self.play(ShowCreation(r))
+ self.play(ShowCreation(tangent_plane))
self.wait(2)
- self.play(FadeOut(parabola2_text),FadeOut(parabola1),FadeOut(r),FadeOut(d))
+ 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
- self.wait(1)
- self.add_fixed_in_frame_mobjects(parabola1_text)
- self.wait(1)
- self.play(Write(parabola2))
+ #----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(r))
- self.wait(1)
+ self.play(ShowCreation(tangent_plane))
+ self.wait(2)