summaryrefslogtreecommitdiff
path: root/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations')
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gifbin0 -> 827096 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py50
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py34
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file3_non_differentiable_function.py30
-rw-r--r--FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_critical_points.py62
5 files changed, 176 insertions, 0 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif
new file mode 100644
index 0000000..2b8bf5f
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py
new file mode 100644
index 0000000..4c17f90
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py
@@ -0,0 +1,50 @@
+from manimlib.imports import*
+
+#---- tangent plane is parallel to the surface of the funtion at a point
+class firstScene(ThreeDScene):
+ def construct(self):
+
+ s1_text=TextMobject("Suppose, the point $(x,y)$ lies on the surface of the function.").scale(0.5).shift(2*UP)
+ s2_text=TextMobject("When zooming on that point, the surface would appear more and more like a plane.").scale(0.5).shift(1*UP)
+ s3_text=TextMobject("This plane is called the tangent plane.").scale(0.5)
+
+ #---- graph of 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_B,YELLOW_C,YELLOW_D, YELLOW_E]).shift([0,0,0]).scale(1)
+
+
+ d = Dot([0,0,0],color = '#800000') #---- critical point
+
+ r = Rectangle(color = PURPLE,fill_opacity=0.2).shift([0.1,0,0]).scale(0.3) #---- tangent plane
+
+ s = 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_B,YELLOW_C,YELLOW_D, YELLOW_E]).shift([0,0,0]).scale(3.5)
+
+ d2 = Dot([0,0,2.5],color = '#800000') #---- changing position of critical point
+
+ r2 = Rectangle(color = PURPLE,fill_opacity=0.5).shift([0.1,0,2.5]).scale(0.3) #---- changing position of tangent plane
+
+ self.set_camera_orientation(phi = 50 * DEGREES, theta = 45 * DEGREES)
+ self.add_fixed_in_frame_mobjects(s1_text)
+ self.add_fixed_in_frame_mobjects(s2_text)
+ self.add_fixed_in_frame_mobjects(s3_text)
+ self.wait(2)
+ self.play(FadeOut(s1_text))
+ self.play(FadeOut(s2_text))
+ self.play(FadeOut(s3_text))
+ self.wait(1)
+ self.play(Write(f))
+ self.play(Write(d))
+ self.play(Write(r))
+ self.wait(2)
+ self.play(ReplacementTransform(f,s),ReplacementTransform(d,d2),ReplacementTransform(r,r2))
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
new file mode 100644
index 0000000..984db16
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py
@@ -0,0 +1,34 @@
+from manimlib.imports import*
+
+class TangenttoSurface(ThreeDScene):
+
+ def construct(self):
+ axes = ThreeDAxes()
+
+ #----f(x,y): x**2+y**2
+ p = 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_C,GREEN_D],
+ resolution = (20, 20)).scale(1)
+ self.set_camera_orientation(phi = 75*DEGREES)
+
+ h_text = TextMobject("The graph tends to coincide with its tangent plane").scale(0.5).to_corner(UL)
+ d = Dot([0,0,0],color ='#800000') #----critical point
+ r = Rectangle(height = 2,breadth = 1,color = YELLOW).scale(0.5) #----tangent plane to critical point
+ line1 = DashedLine(color=RED).shift(4*UP+1.3*RIGHT).rotate(1.571,UP).scale(1.2)
+ line2 = DashedLine(color=RED).shift(4*UP-1.3*RIGHT).rotate(1.571,UP).scale(1.2)
+
+ r2 = Rectangle(height = 2, breadth = 1,color = GREEN, fill_opacity=0.3).scale(0.5)
+
+ self.add(axes)
+ self.play(Write(r))
+ self.play(Write(p),Write(d))
+ self.play(ShowCreation(line1),ShowCreation(line2))
+ self.wait(2)
+
+ self.play(FadeOut(line1),FadeOut(line2),ReplacementTransform(p,r2))
+ self.add_fixed_in_frame_mobjects(h_text)
+ self.wait(1)
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file3_non_differentiable_function.py b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file3_non_differentiable_function.py
new file mode 100644
index 0000000..13bd73e
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file3_non_differentiable_function.py
@@ -0,0 +1,30 @@
+from manimlib.imports import*
+import math
+
+#---- tangent plane does not exists for f(x,y): sqrt(x**2+y**2) at origin
+
+class TangenttoSurface(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ #----f(x,y): sqrt(x**2+y**2)
+ p = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ math.sqrt(u**2+v**2)
+ ]),v_min = -1,v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [RED_C,TEAL_D],
+ resolution = (20, 20)).scale(1)
+
+ self.set_camera_orientation(phi = 75 * DEGREES)
+
+ d = Dot([0,0,0],color = '#800000') #----critical point
+ d_text = TextMobject("$(0,0)$").scale(0.5).shift(0.2*DOWN)
+ f_text = TextMobject("$f$ is not differentiable at origin").scale(0.5).to_corner(UL)
+
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.add(axes)
+ self.play(Write(p),Write(d))
+ self.add_fixed_in_frame_mobjects(d_text)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_critical_points.py b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_critical_points.py
new file mode 100644
index 0000000..d129213
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_critical_points.py
@@ -0,0 +1,62 @@
+from manimlib.imports import*
+
+class TangenttoSurface(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ #----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)
+ f_text = TextMobject("Tangent plane at relative maxima").to_corner(UL).scale(0.5)
+
+ #----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)
+ f2_text = TextMobject("Tangent plane at saddle point").to_corner(UL).scale(0.5)
+
+ #----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)
+ f3_text = TextMobject("Tangent plane at relative minima").to_corner(UL).scale(0.5)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = -45 * DEGREES )
+ d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point
+
+ r = Rectangle(height = 2,breadth = 1,color = PURPLE).scale(0.5)
+
+ self.begin_ambient_camera_rotation(rate = 0.3)
+ self.add(axes)
+ self.play(Write(f),Write(d))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.play(ShowCreation(r))
+ self.wait(1)
+ self.play(FadeOut(r),FadeOut(f),FadeOut(d),FadeOut(f_text))
+ self.wait(1)
+ self.play(Write(f2),Write(d))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(f2_text)
+ self.play(ShowCreation(r))
+ self.wait(1)
+ self.play(FadeOut(r),FadeOut(f2),FadeOut(d),FadeOut(f2_text))
+ self.wait(1)
+ self.play(Write(f3),Write(d))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(f3_text)
+ self.play(ShowCreation(r))
+ self.wait(1)