summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPurusharth Saxena2020-06-24 04:01:44 +0530
committerGitHub2020-06-24 04:01:44 +0530
commited86b5f6d84efe35cea6b63b4f7d6afce8cde4b7 (patch)
treeb26baa056886770477105fca507791420cc31a7f
parentf0525bb9d03e413f0d0c8314945c2231ef95a54e (diff)
parentada683cd4827f2b996998a10ed5c967b7945d530 (diff)
downloadFSF-mathematics-python-code-archive-ed86b5f6d84efe35cea6b63b4f7d6afce8cde4b7.tar.gz
FSF-mathematics-python-code-archive-ed86b5f6d84efe35cea6b63b4f7d6afce8cde4b7.tar.bz2
FSF-mathematics-python-code-archive-ed86b5f6d84efe35cea6b63b4f7d6afce8cde4b7.zip
Merge pull request #20 from vnb09/fsf_tasks
Fsf tasks
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/README.md32
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gifbin0 -> 8077401 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py77
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gifbin0 -> 2552938 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py88
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gifbin0 -> 2198637 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py73
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.gifbin0 -> 3864765 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.py134
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).gifbin0 -> 1522415 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).py29
-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
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gifbin0 -> 3166332 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.py78
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file2_Degenerate_Hessian_Matrix.py52
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file3_Nondegenerate_Hessian_Matrix.py145
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gifbin0 -> 1150777 bytes
-rw-r--r--FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py120
22 files changed, 1004 insertions, 0 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/README.md b/FSF-2020/approximations-and-optimizations/Critical-Points/README.md
new file mode 100644
index 0000000..f0747bb
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/README.md
@@ -0,0 +1,32 @@
+<h1><div align=”center”><b>SubTopic: Critical Points</b></h1></div>
+<br/></br>
+
+<tab>file1_Critical_Point_of_a_function
+
+![file1_Critical_Point_of_a_function](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif?raw=true)
+<br/></br>
+<br/></br>
+
+<tab>file2_Traces_and_Tangent
+
+![file2_Traces_and_Tangent](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif?raw=true)
+<br/></br>
+<br/></br>
+
+<tab>file3_Tangent_plane_at_extrema_of_a_function
+
+![file3_Tangent_plane_at_extrema_of_a_function](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif?raw=true)
+<br/></br>
+<br/></br>
+
+<tab>file4_Types_of_critical_points
+
+![file4_Types_of_critical_points](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.gif?raw=true)
+<br/></br>
+<br/></br>
+
+<tab>file5_f(x,y)=(y-x)(1-2x-3y)
+
+![file5_f(x,y)=(y-x)(1-2x-3y)](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x%2Cy)%3D(y-x)(1-2x-3y).gif?raw=true)
+<br/></br>
+<br/></br>
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif b/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif
new file mode 100644
index 0000000..ca3989c
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py
new file mode 100644
index 0000000..e8cb08d
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py
@@ -0,0 +1,77 @@
+from manimlib.imports import*
+import math as m
+
+#---- case 1: parial derivatives exist at critical point 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
+
+ #---- f(x,y) = e^(-10x^2-10y^2)
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ m.exp(-10*u**2-10*v**2)
+ ]),u_min = -1, u_max = 1, v_min = -1, v_max = 1, checkerboard_colors = [TEAL_E,TEAL_D,TEAL_C,TEAL_B]).fade(0.6).scale(3.5).shift([0,0,1.5])
+
+ l1 = Line([0,0,3.75],[0,0,0],color = '#800000')
+
+ d = Dot([0,0,3.75],color = '#800000') #---- critical point
+
+ d_text = TextMobject("$\\frac{\\partial f}{\\partial x}=\\frac{\\partial f}{\\partial y} = 0$").scale(0.8).to_corner(UL)
+
+ f_text = TextMobject("Critical Point ",color = YELLOW).shift(3.4*UP).scale(0.5)
+
+ self.set_camera_orientation(phi = 45*DEGREES, theta = 40*DEGREES)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.add_fixed_in_frame_mobjects(d_text)
+ self.begin_ambient_camera_rotation(rate = 0.2)
+ self.play(Write(surface))
+ self.wait(1)
+ self.play(Write(l1))
+ self.play(Write(d))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(3)
+ self.play(FadeOut(f_text),FadeOut(surface),FadeOut(axes),FadeOut(d_text),FadeOut(d),FadeOut(l1),FadeOut(label_x),FadeOut(label_y))
+
+
+#---- case 2: parial derivatives do not exist at critical point 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
+
+ #---- g(x,y)= |x|+|y|
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ abs(u)+abs(v)
+ ]),u_min = -1.5, u_max = 1.5, v_min = -1.5, v_max = 1.5, checkerboard_colors = [TEAL_E,TEAL_D,TEAL_C,TEAL_B])
+
+ d2 = Dot([0,0,0],color = '#800000') #---- critical point
+
+ d2_text = TextMobject("$\\frac{\\partial f}{\\partial x}$ and/or $\\frac{\\partial f}{\\partial y}$ does not exist").scale(0.7).to_corner(UL)
+
+ g_text = TextMobject("Critical Point",color = YELLOW).shift(1.2*RIGHT).scale(0.6)
+
+ self.set_camera_orientation(phi = 60*DEGREES, theta = 40*DEGREES)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.add_fixed_in_frame_mobjects(d2_text)
+ self.begin_ambient_camera_rotation(rate = 0.2)
+ self.wait(1)
+ self.play(Write(surface2))
+ self.wait(1)
+ self.play(Write(d2))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(g_text)
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif
new file mode 100644
index 0000000..84acf2e
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py
new file mode 100644
index 0000000..4b020e1
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py
@@ -0,0 +1,88 @@
+from manimlib.imports import*
+import math as m
+
+#---- tangent to the trace with x constant
+class firstScene(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes().scale(1)
+ label_x = TextMobject("$x$").shift([5.8,-0.5,0])
+ label_y = TextMobject("$y$").shift([-0.5,-5.6,0]).rotate(-4.5)
+
+ #---- graph of f(x,y) = -x^2-y^2
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2-v**2
+ ]),u_min=-1,u_max=1, v_min=-1,v_max=1,checkerboard_colors=[PURPLE_C,PURPLE_D,PURPLE_E,PURPLE_B]).scale(1.5).shift([0,0,2]).rotate(0.2)
+
+ #---- curve(trace) along y axis
+ curve = ParametricSurface(
+ lambda u, v: np.array([
+ u*0.4,
+ v,
+ -v**2
+ ]),v_min =-1 , v_max =1 , u_min = -0.1, u_max = 0.1).scale(1.6).shift([0.02,0.1,2.3]).set_color("#800000").rotate(0.1)
+
+ d = Dot(color =YELLOW).shift([-0.05,-0.2,2.3]) #---- critical point
+
+ x_text = TextMobject("Tangent to the trace with $x$ constant at critical point").shift(3*RIGHT+2*UP).scale(0.5).to_corner(UL)
+
+ tangent_line = Line([-0.05,-1.5,2.3],[-0.05,1.5,2.3],color = '#228B22')
+
+ self.add(axes)
+ self.set_camera_orientation(phi = 40 * DEGREES, theta = 55 * DEGREES)
+ self.begin_ambient_camera_rotation(rate = 0.1)
+ self.add(label_x)
+ self.add(label_y)
+ self.play(Write(surface))
+ self.add_fixed_in_frame_mobjects(x_text)
+ self.add(curve)
+ self.wait(1)
+ self.play(Write(tangent_line),Write(d))
+ self.wait(1)
+
+
+
+#---- tangent to the trace with y constant
+class secondScene(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes().scale(1)
+ label_x = TextMobject("$x$").shift([5.8,-0.5,0])
+ label_y = TextMobject("$y$").shift([-0.5,-5.6,0]).rotate(-4.5)
+
+ #---- graph of f(x,y) = -x^2-y^2
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2-v**2
+ ]),u_min = -1, u_max = 1, v_min = -1, v_max = 1, checkerboard_colors = [PURPLE_B,PURPLE_C,PURPLE_D,PURPLE_E]).scale(1.5).shift([0,0,2]).rotate(0.2)
+
+ #---- curve(trace) along x axis
+ curve = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v*0.4,
+ -u**2
+ ]),v_min = -0.1, v_max = 0.1, u_min = -1, u_max = 1).scale(1.6).shift([0.07,0.1,2.3]).set_color("#800000")
+
+ d = Dot(color = YELLOW).shift([0,-0.2,2.3]) #---- critical point
+
+ tangent_line = Line(color = '#228B22').scale(1).shift([0,-0.2,2.3]).rotate(m.radians(190),LEFT)
+
+ y_text = TextMobject("Tangent to the trace with $y$ constant at critical point").shift(3*RIGHT+2*UP).scale(0.5).to_corner(UL)
+
+ self.add(axes)
+ self.set_camera_orientation(phi = 40 * DEGREES, theta = 55 * DEGREES)
+ self.add(label_x)
+ self.add(label_y)
+ self.begin_ambient_camera_rotation(rate = 0.1)
+ self.play(Write(surface))
+ self.add_fixed_in_frame_mobjects(y_text)
+ self.add(curve)
+ self.wait(1.5)
+ self.play(Write(tangent_line),Write(d))
+ self.wait(0.5)
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif b/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif
new file mode 100644
index 0000000..14fb318
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif
Binary files differ
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
new file mode 100644
index 0000000..e674113
--- /dev/null
+++ b/FSF-2020/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)
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.gif b/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.gif
new file mode 100644
index 0000000..91e7084
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.py b/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.py
new file mode 100644
index 0000000..656fb68
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file4_Types_of_critical_points.py
@@ -0,0 +1,134 @@
+from manimlib.imports import*
+
+
+#---- Relative Maxima
+class firstScene(ThreeDScene):
+ def construct(self):
+
+ r_text = TextMobject("Relative Maximum at ORIGIN",color ='#87CEFA')
+
+ 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
+
+ #----graph of the function f(x,y) = -x**2-y**2
+ surface = 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]).scale(1.5).shift([0,0,-0.51]).fade(0.3)
+
+ f_text = TextMobject("$f(x,y) = -x^2-y^2$").to_corner(UL)
+
+ d = Dot(color = "#800000").shift([0,0,0]) #---- critical point
+
+ 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.begin_ambient_camera_rotation(rate = 0.1)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.play(Write(surface),Write(d))
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(surface),FadeOut(f_text),FadeOut(d),FadeOut(label_x),FadeOut(label_y))
+
+
+#---- Relative Minima
+class secondScene(ThreeDScene):
+ def construct(self):
+
+ r2_text = TextMobject("Relative Minimum at ORIGIN",color ='#87CEFA')
+
+ 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
+
+ #----graph of the function g(x,y) = x**2+y**2
+ surface = 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 =[TEAL_B,TEAL_C,TEAL_D,TEAL_E]).scale(1.5).shift([0,0,0.55]).fade(0.1)
+
+ d = Dot(color = "#800000").shift([0,0,0]) #---- critical point
+
+ g_text = TextMobject("$f(x,y) = x^2+y^2$").to_corner(UL)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = 45 * DEGREES)
+ self.add_fixed_in_frame_mobjects(r2_text)
+ self.wait(1)
+ self.play(FadeOut(r2_text))
+ self.begin_ambient_camera_rotation(rate = 0.1)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.play(Write(surface),Write(d))
+ self.add_fixed_in_frame_mobjects(g_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(surface),FadeOut(g_text),FadeOut(d),FadeOut(label_x),FadeOut(label_y))
+
+
+
+#---- Saddle Point
+class thirdScene(ThreeDScene):
+ def construct(self):
+
+ r3_text = TextMobject("Saddle Point", color = '#87CEFA')
+
+ 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
+
+ #---- graph of function h(x,y) = -x^2 + y^2
+ surface = 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 = [PURPLE_B,PURPLE_C,PURPLE_D,PURPLE_E]).scale(1.5).shift([0,0,0])
+
+ #---- curve(trace) along x axis
+ curve_x = ParametricSurface(
+ lambda u, v: np.array([
+ u*0.4,
+ v,
+ v**2
+ ]),v_min = -1, v_max = 1, u_min = -0.2, u_max = 0.2).shift([0,0,0.34]).scale(1.5).set_color("#800000")
+
+ #---- curve(trace) along y axis
+ curve_y = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v*0.4,
+ -u**2
+ ]),v_min = -0.2, v_max = 0.2, u_min = -1, u_max = 1).scale(1.6).shift([0,0,-0.1]).set_color("#800000")
+
+ d = Dot(color = GREEN).shift([0,0,0.1]) #---- critical point
+
+ h_text = TextMobject("$f(x,y) = -x^2+y^2$").to_corner(UL)
+
+ self.add_fixed_in_frame_mobjects(r3_text)
+ self.wait(1)
+ self.set_camera_orientation(phi = 50 * DEGREES,theta = 45 * DEGREES)
+ self.play(FadeOut(r3_text))
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.begin_ambient_camera_rotation(rate = 0.3)
+ self.add_fixed_in_frame_mobjects(h_text)
+ self.play(Write(surface))
+ self.wait(1)
+ self.add(curve_y)
+ self.add(d)
+ self.wait(1)
+ self.play(FadeOut(curve_y))
+ self.wait(1)
+ self.add(curve_x)
+ self.wait(1)
+ self.add(d)
+ self.wait(1)
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).gif b/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).gif
new file mode 100644
index 0000000..4bc92f8
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).py b/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).py
new file mode 100644
index 0000000..41c3b61
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical-Points/file5_f(x,y)=(y-x)(1-2x-3y).py
@@ -0,0 +1,29 @@
+from manimlib.imports import*
+
+#---- visualization of the function
+class ExampleAnimation(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
+
+ #---- f(x,y) = (y-x)(1-2x-3y)
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ (v-u)*(1-2*u-3*v)
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [PURPLE_B,PURPLE_C,PURPLE_D, PURPLE_E]).scale(1).fade(0.2).shift([0.2,0.2,0])
+
+ f_text = TextMobject("$f(x,y) = (y-x)(1-2x-3y)$").to_corner(UL)
+
+ self.set_camera_orientation(phi = 60 * DEGREES, theta = 75 * DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(1)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.wait(1)
+ self.play(Write(f))
+ self.wait(4)
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)
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif
new file mode 100644
index 0000000..3471e4d
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.py b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.py
new file mode 100644
index 0000000..84052cc
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.py
@@ -0,0 +1,78 @@
+from manimlib.imports import*
+
+#---- graphs of second-order partial derivatives of a function
+class SurfacesAnimation(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes()
+ x_label = TextMobject('$x$').shift([5,0.5,0]) #---- x axis
+ y_label = TextMobject('$y$').shift([0.5,4,0]).rotate(-4.5) #---- y axis
+
+ #---- surface of function: f(x,y) = (x^2+y^2)^2
+ surface_f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ ((u**2)+(v**2))**2
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[GREEN_D, GREEN_E]).scale(1)
+
+ #---- surface of second-order partial derivative f_xx
+ surface_fxx = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ (3*u**2)+(v**2)
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[YELLOW_D, YELLOW_E]).shift([0,0,0]).scale(0.6)
+
+ #---- surface of second-order partial derivative f_yy
+ surface_fyy = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ (u**2)+(3*v**2)
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[PURPLE_D, PURPLE_E]).scale(0.6).shift([0,0,0])
+
+ #---- surface of second-order partial derivative f_xy = f_yx
+ surface_fxy = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ 8*u*v
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[TEAL_D, TEAL_E]).scale(0.6)
+
+ f_text= TextMobject("$f(x,y) = (x^2+y^2)^2$",color = GREEN).scale(0.7).to_corner(UL)
+
+ fxx_text= TextMobject("$f_{xx} = 12x^2+4y^2$ (Concavity along x axis)",color = YELLOW).scale(0.5).to_corner(UL)
+
+ fyy_text= TextMobject("$f_{yy} = 4x^2+12y^2$(Concavity along y axis)",color = PURPLE).scale(0.5).to_corner(UL)
+
+ fxy_text= TextMobject("$f_{xy} = f_{yx} = 8xy$ (Twisting of the function)",color = TEAL).scale(0.5).to_corner(UL)
+
+
+ self.set_camera_orientation(phi = 40 * DEGREES, theta = 45 * DEGREES)
+ self.begin_ambient_camera_rotation(rate = 0.1)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.add(axes)
+ self.add(x_label)
+ self.add(y_label)
+ self.wait(1)
+ self.play(Write(surface_f))
+ self.wait(2)
+ self.play(FadeOut(f_text))
+
+
+ self.play(ReplacementTransform(surface_f,surface_fxx))
+
+ self.add_fixed_in_frame_mobjects(fxx_text)
+ self.wait(2)
+ self.play(FadeOut(fxx_text))
+
+ self.play(ReplacementTransform(surface_fxx,surface_fyy))
+ self.add_fixed_in_frame_mobjects(fyy_text)
+ self.wait(2)
+ self.play(FadeOut(fyy_text))
+
+ self.play(ReplacementTransform(surface_fyy,surface_fxy))
+ self.move_camera(phi = 35 * DEGREES, theta = 80 * DEGREES)
+ self.add_fixed_in_frame_mobjects(fxy_text)
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file2_Degenerate_Hessian_Matrix.py b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file2_Degenerate_Hessian_Matrix.py
new file mode 100644
index 0000000..c1e3516
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file2_Degenerate_Hessian_Matrix.py
@@ -0,0 +1,52 @@
+from manimlib.imports import*
+
+class firstscene(Scene):
+ def construct(self):
+
+ h_text = TextMobject("Degenerate Hessian Matrix", color = RED).scale(1).shift(UP)
+
+
+ f_text = TextMobject("$f(x,y) = 2x^3+y^3$", color = TEAL).scale(1).to_corner(UL)
+ c_text = TextMobject("Critical Point: $(0,0)$", color = TEAL).scale(1).next_to(f_text).shift(DOWN+4.3*LEFT)
+ m_text = TextMobject("\\begin{equation*} D_2(x,y)= \\begin{vmatrix} 12x\\space & 0\\space \\\\ 0 & 6y \\end{vmatrix} \\end{equation*}",color = YELLOW)
+ d_text = TextMobject("\\begin{equation*} D_2(0,0)= \\begin{vmatrix} 0 \\space & 0\\space \\\\ 0 & 0 \\end{vmatrix} \\end{equation*}",color = PURPLE)
+
+
+ t_text = TextMobject("$D_2 = 0$(Inconclusive)", color = TEAL).scale(1).shift(2*DOWN)
+
+ self.play(ShowCreation(h_text))
+ self.wait(1)
+ self.play(FadeOut(h_text))
+ self.wait(1)
+ self.play(ShowCreation(f_text))
+ self.wait(1)
+ self.play(ShowCreation(c_text))
+ self.wait(1)
+ self.play(ShowCreation(m_text))
+ self.wait(2)
+ self.play(ReplacementTransform(m_text,d_text))
+ self.wait(1)
+ self.play(ShowCreation(t_text))
+ self.wait(2)
+
+
+class SecondScene(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ (2*u**3)+v**3
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[TEAL_C,YELLOW_D,BLUE_E],
+ resolution=(20, 20)).scale(1)
+
+ self.set_camera_orientation(phi=25 * DEGREES,theta = 80*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.1)
+
+ f_text = TextMobject("$f(x,y) = 2x^3+y^3$",color = ORANGE).shift(2*DOWN+2*RIGHT).scale(0.8)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.add(axes)
+ self.play(Write(f))
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file3_Nondegenerate_Hessian_Matrix.py b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file3_Nondegenerate_Hessian_Matrix.py
new file mode 100644
index 0000000..3056842
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file3_Nondegenerate_Hessian_Matrix.py
@@ -0,0 +1,145 @@
+from manimlib.imports import*
+
+class firstScene(Scene):
+ def construct(self):
+
+ e_text = TextMobject("Case 3: One positive and one negative eigenvalue", color = YELLOW).scale(1).shift(3*UP+1*LEFT)
+ f_text = TextMobject("$f(x,y) = x^2-2y^2-2x$").scale(0.8).next_to(e_text).shift(6*LEFT+DOWN)
+ c_text = TextMobject("Critical Point: $(1,0)$").scale(0.8).next_to(f_text).shift(DOWN+4*LEFT)
+ d_text = TextMobject("\\begin{equation*} D_2(1,0)= \\begin{vmatrix} 2 \\space & 0\\space \\\\ 0 & -4 \\end{vmatrix} \\end{equation*}",color = GREEN).scale(0.9)
+
+ t_text = TextMobject("$D_2 = -8<0$ (Saddle Point)", color = BLUE).scale(0.9).shift(2*DOWN)
+
+ self.play(ShowCreation(e_text))
+ self.wait(1)
+ self.play(ShowCreation(f_text))
+ self.wait(1)
+ self.play(ShowCreation(c_text))
+ self.wait(1)
+ self.play(ShowCreation(d_text))
+ self.wait(1)
+ self.play(ShowCreation(t_text))
+ self.wait(2)
+
+class SaddlePoint(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ u**2-2*v**2-2*u
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[RED_C,PURPLE_D,YELLOW_E],
+ resolution=(20, 20)).scale(1)
+
+ self.set_camera_orientation(phi=35 * DEGREES,theta=80*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.4)
+
+ f_text = TextMobject("$f(x,y) = x^2-2y^2-2x$",color = GREEN).shift(2*DOWN+2*RIGHT).scale(0.8)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.add(axes)
+ self.play(Write(f))
+ self.wait(3)
+
+
+class secondScene(Scene):
+ def construct(self):
+
+ h_text = TextMobject("NonDegenerate Hessian Matrix", color = GREEN).scale(1).shift(UP)
+ e_text = TextMobject("Case 1: Two positive eigenvalues", color = PINK).scale(1).shift(3*UP+2*LEFT)
+ f_text = TextMobject("$f(x,y) = 2x^2+3y^2-2yx$",color = TEAL).scale(0.8).next_to(e_text).shift(6*LEFT+DOWN)
+ c_text = TextMobject("Critical Point: $(0,0)$",color = TEAL).scale(0.8).next_to(f_text).shift(DOWN+4.5*LEFT)
+ d_text = TextMobject("\\begin{equation*} D_2(0,0)= \\begin{vmatrix} 4 \\space & -2\\space \\\\ -2 & 6 \\end{vmatrix} \\end{equation*}",color = PINK).scale(0.9)
+
+ t_text = TextMobject("$D_2 = 20>0$ (Relative Maxima or Relative Minima)", color = YELLOW).scale(0.9).shift(1*DOWN)
+ tm_text = TextMobject("$D_1 = \\frac{\\partial^2 f}{\\partial x^2} =4 >0$ (Relative Minima)", color = YELLOW).scale(0.9).shift(2*DOWN)
+
+
+ self.play(ShowCreation(h_text))
+ self.wait(1)
+ self.play(FadeOut(h_text))
+ self.wait(1)
+ self.play(ShowCreation(e_text))
+ self.wait(1)
+ self.play(ShowCreation(f_text))
+ self.wait(1)
+ self.play(ShowCreation(c_text))
+ self.wait(1)
+ self.play(ShowCreation(d_text))
+ self.wait(1)
+ self.play(ShowCreation(t_text))
+ self.wait(1)
+ self.play(ShowCreation(tm_text))
+ self.wait(2)
+ self.play(FadeOut(e_text),FadeOut(f_text),FadeOut(c_text),FadeOut(d_text),FadeOut(t_text),FadeOut(tm_text))
+
+class Minima(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ 2*u**2+3*v**2-2*v*u
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[BLUE_C,YELLOW_D,GREEN_E],
+ resolution=(20, 20)).scale(1)
+
+ self.set_camera_orientation(phi=10 * DEGREES,theta=90*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.2)
+
+ f_text = TextMobject("$f(x,y) = 2x^2+3y^2-2yx$",color = PURPLE).shift(2*DOWN+3*RIGHT).scale(0.8)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.add(axes)
+ self.play(Write(f))
+ self.wait(2)
+
+
+class thirdScene(Scene):
+ def construct(self):
+
+
+ e_text = TextMobject("Case 2: Two negative eigenvalues", color = RED).scale(1).shift(3*UP+2*LEFT)
+ f_text = TextMobject("$f(x,y) = -x^2-4y^2$",color = BLUE).scale(0.8).next_to(e_text).shift(6*LEFT+DOWN)
+ c_text = TextMobject("Critical Point: $(0,0)$",color = BLUE).scale(0.8).next_to(f_text).shift(DOWN+3.8*LEFT)
+ d_text = TextMobject("\\begin{equation*} D_2(0,0)= \\begin{vmatrix} -2 \\space & 0\\space \\\\ 0 & -8 \\end{vmatrix} \\end{equation*}",color = TEAL).scale(0.9)
+
+ t_text = TextMobject("$D_2 = 16>0$ (Relative Maxima or Relative Minima)" ).scale(0.9).shift(1*DOWN)
+ tm_text = TextMobject("$D_1 = \\frac{\\partial^2 f}{\\partial x^2} =-2 <0$ (Relative Maxima)").scale(0.9).shift(2*DOWN)
+
+
+ self.play(ShowCreation(e_text))
+ self.wait(1)
+ self.play(ShowCreation(f_text))
+ self.wait(1)
+ self.play(ShowCreation(c_text))
+ self.wait(1)
+ self.play(ShowCreation(d_text))
+ self.wait(1)
+ self.play(ShowCreation(t_text))
+ self.wait(1)
+ self.play(ShowCreation(tm_text))
+ self.wait(2)
+ self.play(FadeOut(e_text),FadeOut(f_text),FadeOut(c_text),FadeOut(d_text),FadeOut(t_text),FadeOut(tm_text))
+
+
+class Maxima(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2-4*v**2
+ ]),v_min=-1,v_max=1,u_min=-1,u_max=1,checkerboard_colors=[BLUE_C,PURPLE_D,TEAL_E],
+ resolution=(20, 20)).scale(1)
+
+ self.set_camera_orientation(phi=75 * DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.4)
+
+ f_text = TextMobject("$f(x,y) = -x^2-4y^2$",color = YELLOW).shift(2*DOWN+3*RIGHT).scale(0.8)
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.add(axes)
+ self.play(Write(f))
+ self.wait(1)
+ self.move_camera(phi=30*DEGREES,theta=45*DEGREES,run_time=5)
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif
new file mode 100644
index 0000000..129fedc
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif
Binary files differ
diff --git a/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py
new file mode 100644
index 0000000..d3084e2
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py
@@ -0,0 +1,120 @@
+from manimlib.imports import*
+
+#---- contour diagram animation
+class ContourDiagram(ThreeDScene):
+ def construct(self):
+
+ heading = TextMobject("CONTOUR DIAGRAM", color = YELLOW).scale(1)
+
+ 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
+
+ #---- surface of a paraboloid
+ surface = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(v)*u,
+ np.sin(v)*u,
+ u**2
+ ]),v_min = -2, v_max = 2, u_min = -2, u_max = 2, checkerboard_colors = [GREEN_B,GREEN_C,GREEN_D,GREEN_E]).shift([0,0,0]).scale(0.5)
+
+ #---- first contour projection
+ contour1 = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(TAU * v),
+ np.sin(TAU * v),
+ 2*(1 - 2.5*u)
+ ])).fade(0.5).scale(0.21).shift([0,0,1.01])
+
+ #---- first contour line
+ c_1 = Circle(color = BLUE).scale(0.21).shift([0,0,0]).rotate(0.1,DOWN)
+
+ #-------------------------------------------------
+
+ #---- second contour projection
+ contour2 = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(TAU * v),
+ np.sin(TAU * v),
+ 2*(1 - 1.6*u)
+ ])).fade(0.5).scale(0.41).shift([0,0,0.3]).set_color(RED)
+
+ #---- second contour line
+ c_2 = Circle(color = RED).scale(0.41).shift([0,0,0]).rotate(0.1,DOWN)
+
+ #-------------------------------------------------
+
+ #---- third contour projection
+ contour3 = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(TAU * v),
+ np.sin(TAU * v),
+ 2*(1 - 1.5*u)
+ ])).fade(0.5).scale(0.61).shift([0,0,0.4]).set_color(YELLOW)
+
+ #---- third contour line
+ c_3 = Circle(color = YELLOW).scale(0.61).shift([0,0,0])
+
+ #-------------------------------------------------
+
+ #---- fourth contour projection
+ contour4 = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(TAU * v),
+ np.sin(TAU * v),
+ 2*(1 - 1.5*u)
+ ])).fade(0.7).scale(0.81).shift([0,0,0.7]).set_color(PINK)
+
+ #---- fourth contour line
+ c_4 = Circle(color = PINK).scale(0.81).shift([0,0,0])
+
+ #-------------------------------------------------
+
+ #---- fifth contour projection
+ contour5 = ParametricSurface(
+ lambda u, v: np.array([
+ np.cos(TAU * v),
+ np.sin(TAU * v),
+ 2*(1 - 1.5*u)
+ ])).fade(0.7).scale(1.01).shift([0,0,1]).set_color(PURPLE)
+
+ #---- fifth contour line
+ c_5 = Circle(color = PURPLE).scale(1.01).shift([0,0,0])
+
+ c_text= TextMobject("Contour Lines").scale(0.5).shift(2*DOWN)
+ s = Square().scale(1.3)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = 10 * DEGREES)
+ self.add_fixed_in_frame_mobjects(heading)
+ self.wait(1)
+ self.play(FadeOut(heading))
+ self.wait(1)
+ self.add(axes)
+ self.add(label_x)
+ self.add(label_y)
+ self.play(Write(surface))
+ self.wait(1)
+ self.add(contour1)
+ self.wait(1)
+ self.play(Write(c_1))
+ self.play(ReplacementTransform(contour1,contour2))
+ self.wait(1)
+ self.play(Write(c_2))
+ self.play(ReplacementTransform(contour2,contour3))
+ self.wait(1)
+ self.play(Write(c_3))
+ self.play(ReplacementTransform(contour3,contour4))
+ self.wait(1)
+ self.play(Write(c_4))
+ self.play(ReplacementTransform(contour4,contour5))
+ self.wait(1)
+ self.play(Write(c_5))
+ self.wait(1)
+ self.play(FadeOut(contour5),FadeOut(axes),FadeOut(label_x),FadeOut(label_y),FadeOut(surface),FadeOut(contour5),FadeOut(contour4),FadeOut(contour3),FadeOut(contour2),FadeOut(contour1))
+ self.wait(1)
+ self.move_camera(phi=0 * DEGREES,theta= 90*DEGREES)
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(c_text)
+ self.wait(1)
+ self.play(ShowCreation(s),FadeOut(c_text))
+ self.wait(1)