summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives')
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py85
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py103
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py107
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gifbin0 -> 1421988 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gifbin0 -> 1946515 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gifbin0 -> 6070951 bytes
6 files changed, 295 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py
new file mode 100644
index 0000000..677d821
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py
@@ -0,0 +1,85 @@
+from manimlib.imports import *
+
+class GeomRepresen(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ -0.25*3*3*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/4,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.7,
+ resolution=(15, 32)).scale(1)
+
+ parabola_curve = ParametricFunction(
+ lambda u : np.array([
+ u,
+ -u,
+ -0.5*(u*u)+2
+ ]),color=PINK,t_min=-1.5,t_max=1.5,
+ )
+
+ circle = Circle(radius = 2.22 , color = BLACK, fill_color = BLUE_C, fill_opacity= 0.3, stroke_width=0.1)
+
+ plane = Polygon(np.array([2.5,-2.5,0]),np.array([-2.5,2.5,0]),np.array([-2.5,2.5,2.5]),np.array([2.5,-2.5,2.5]),np.array([2.5,-2.5,0]), color = BLACK, fill_color = PINK, fill_opacity= 0.2, stroke_width=0.1)
+
+ line = DashedLine(np.array([1,-1,0]), np.array([1,-1,1.5]), color = YELLOW_C)
+
+ tangent_line = Line(np.array([1.5,-1.5,1]), np.array([0.5,-0.5,2]), color = RED_C)
+
+ vector = Arrow(np.array([1,-1,0]), np.array([0.5,-0.5,0]), buff=0.01, color = GREEN_C)
+
+ dot1 =Sphere(radius=0.08).move_to(np.array([1,-1,0])).set_fill(YELLOW_C)
+ dot2 =Sphere(radius=0.08).move_to(np.array([1,-1,1.5])).set_fill(YELLOW_C)
+
+ dot1_lab = TextMobject(r"$P_0$").scale(0.6).move_to(np.array([1,-1,1.8])).set_color(RED_C)
+ dot2_lab = TextMobject(r"$(x_0,y_0)$").scale(0.6).move_to(np.array([1.6,-1,0])).set_color(PURPLE)
+ vector_lab = TextMobject(r"$\hat{u}$").scale(0.8).move_to(np.array([1.2,-0.5,0])).set_color(GREEN_C)
+ domain_lab = TextMobject(r"$D$").scale(0.6).move_to(np.array([1,1,0])).set_color(GREEN_C)
+ func_lab = TextMobject(r"$z = f(x,y)$").scale(0.6).move_to(1*UP + 2.8*RIGHT).set_color(BLUE_C)
+ directional_deriv_lab = TextMobject(r"Slope = $D_{\hat{u}}f(x_0,y_0)$").scale(0.6).move_to(2.2*UP + 1.5*RIGHT).set_color(YELLOW_C)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.set_camera_orientation(phi=65 * DEGREES, theta = 20*DEGREES)
+
+ self.play(ShowCreation(paraboloid))
+ self.add_fixed_in_frame_mobjects(func_lab)
+ self.wait()
+
+ #self.play(ShowCreation(circle))
+ self.bring_to_front(circle)
+ self.wait()
+ self.add_fixed_orientation_mobjects(domain_lab)
+ self.wait()
+
+ self.play(ShowCreation(plane), ShowCreation(parabola_curve))
+ self.play(ShowCreation(dot1), GrowArrow(line), ShowCreation(dot2))
+ self.add_fixed_orientation_mobjects(dot1_lab)
+ self.wait()
+ self.add_fixed_orientation_mobjects(dot2_lab)
+ self.wait()
+
+ self.play(ShowCreation(tangent_line))
+ self.add_fixed_in_frame_mobjects(directional_deriv_lab)
+ self.wait()
+
+ self.play(GrowArrow(vector))
+ self.add_fixed_orientation_mobjects(vector_lab)
+ self.wait()
+
+
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.wait(3)
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py
new file mode 100644
index 0000000..e9fef50
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py
@@ -0,0 +1,103 @@
+from manimlib.imports import *
+
+class Gradient(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+
+ quadrant = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*np.cos(u)
+ ]),u_min=0,u_max=PI/3,v_min=0,v_max=PI/2,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ quadrant_curve = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*np.cos(u)
+ ]),u_min=34*DEGREES,u_max=38*DEGREES,v_min=0,v_max=PI/2,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+
+
+ dot1 =Sphere(radius=0.05).move_to(np.array([1,1,0])).set_fill(YELLOW_C)
+ dot2 =Sphere(radius=0.05).move_to(np.array([1,1,1.732])).set_fill(YELLOW_C)
+
+ dot1_line = DashedLine(np.array([1,1,1.732]), np.array([0,2,2]), color = WHITE)
+ dot1_lab = TextMobject(r"$P_0(x_0,y_0,z_0)$").move_to(np.array([0,2.1,2.2])).set_color(YELLOW_C).scale(0.6)
+ #dot2_line = Line(np.array([0.8,0.8,0]), np.array([1,0.6,0]), color = PINK)
+
+ positive_vector = Arrow(np.array([1,1,0]), np.array([0.5,0.5,0]), buff=0.001, color = BLUE_C)
+ positive_gradient = Arrow(np.array([1,1,1.732]), np.array([0.5,0.5,1.9362]), buff=0.001, color = BLUE_C)
+ positive_gradient_lab = TextMobject(r"$\nabla f$").move_to(np.array([0.5,0.3,0])).set_color(BLUE_C).scale(0.5)
+
+ negative_vector = Arrow(np.array([1,1,0]), np.array([1.5,1.5,0]), buff=0.001, color = RED_C)
+ negative_gradient = Arrow(np.array([1,1,1.732]), np.array([1.5,1.5,1.322]), buff=0.001, color = RED_C)
+ negative_gradient_lab = TextMobject(r"$-\nabla f$").move_to(np.array([1.6,1.6,0])).set_color(RED_C).scale(0.5)
+
+ positive_vector_line = DashedLine(np.array([0.8,0.8,0]), np.array([1,-2,0]), color = WHITE)
+ positive_vector_lab = TextMobject(r"Most Rapid increase in $f$").move_to(np.array([1.6,-3.6,0])).set_color(BLUE_C).scale(0.6)
+ negative_vector_line = DashedLine(np.array([1.2,1.2,0]), np.array([3,-1.5,0]), color = WHITE)
+ negative_vector_lab = TextMobject(r"Most Rapid decrease in $f$").move_to(np.array([3.6,-3,0])).set_color(RED_C).scale(0.6)
+
+
+
+ line1 = DashedLine(np.array([0.5,0.5,0]), np.array([0.5,0.5,1.9362]), color = BLUE_C)
+ line2 = DashedLine(np.array([1,1,0]), np.array([1,1,1.732]), color = YELLOW_C)
+ line3 = DashedLine(np.array([1.5,1.5,0]), np.array([1.5,1.5,1.322]), color = RED_C)
+
+ curve_vector1 = Arrow(np.array([1,1,0]), np.array([1.5,0.5,0]), buff=0.001, color = YELLOW_C)
+ curve_vector2 = Arrow(np.array([1,1,0]), np.array([0.5,1.5,0]), buff=0.001, color = YELLOW_C)
+
+ curve_vector1_line = DashedLine(np.array([1.2,0.8,0]), np.array([1,2.5,0]), color = WHITE)
+ curve_vector2_line = DashedLine(np.array([0.8,1.2,0]), np.array([1,2.5,0]), color = WHITE)
+ curve_vector_lab = TextMobject(r"Zero Change in $f$").move_to(np.array([0.7,3.6,0])).set_color(PINK).scale(0.6)
+
+ #square = Square(side_length = 0.5).rotate(45*DEGREES).move_to(np.array([1.025,0.975,0]))
+ line_x = Line(np.array([0.8,0.8,0]), np.array([1,0.6,0]), color = PINK)
+ line_y = Line(np.array([1.2,0.8,0]), np.array([1,0.6,0]), color = PINK)
+
+ ninety_degree = VGroup(line_x, line_y)
+
+ self.set_camera_orientation(phi=60* DEGREES, theta = 20*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(quadrant))
+ self.wait()
+ self.play(ShowCreation(dot1), ShowCreation(dot2))
+ self.wait()
+ self.play(GrowArrow(positive_vector), GrowArrow(positive_gradient))
+ self.wait()
+ self.play(GrowArrow(negative_vector), GrowArrow(negative_gradient))
+ self.wait()
+ self.play(GrowArrow(line1), GrowArrow(line2), GrowArrow(line3))
+ self.wait()
+ self.play(ShowCreation(quadrant_curve))
+ self.wait()
+ self.play(GrowArrow(curve_vector1), GrowArrow(curve_vector2), ShowCreation(ninety_degree))
+ self.wait()
+ self.play(GrowArrow(dot1_line))
+ self.add_fixed_orientation_mobjects(dot1_lab)
+ self.wait()
+ self.play(GrowArrow(curve_vector1_line), GrowArrow(curve_vector2_line))
+ self.add_fixed_orientation_mobjects(curve_vector_lab)
+ self.wait()
+ self.add_fixed_orientation_mobjects(positive_gradient_lab, negative_gradient_lab)
+ self.wait()
+ self.play(GrowArrow(positive_vector_line), GrowArrow(negative_vector_line))
+ self.add_fixed_orientation_mobjects(positive_vector_lab, negative_vector_lab)
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.wait(3) \ No newline at end of file
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py
new file mode 100644
index 0000000..a3b88e5
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py
@@ -0,0 +1,107 @@
+from manimlib.imports import *
+
+class GradientLevelCurves(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ -u*u+2
+ ]),u_min=-1.414,u_max=1.414,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ plane_0 = Polygon(np.array([2,-2,0]),np.array([2,2,0]),np.array([-2,2,0]),np.array([-2,-2,0]),np.array([2,-2,0]), color = BLUE_E, fill_color = BLUE_E, fill_opacity = 0.3)
+ plane_0_lab = TextMobject("C = 0").move_to(0.4*UP+3.2*RIGHT).set_color(BLUE_E).scale(0.6)
+ circle_0 = Circle(radius = 1.414 , color = BLUE_E)
+ circle_0_lab = TextMobject("0").move_to(1.1*DOWN+1.1*RIGHT).set_color(BLUE_E).scale(0.6)
+
+ plane_0_5 = Polygon(np.array([2,-2,0.5]),np.array([2,2,0.5]),np.array([-2,2,0.5]),np.array([-2,-2,0.5]),np.array([2,-2,0.5]), color = GREEN_C, fill_color = GREEN_C, fill_opacity = 0.3)
+ plane_0_5_lab = TextMobject("C = 0.5").move_to(0.8*UP+3.4*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5 = Circle(radius = 1.224 , color = GREEN_C)
+ circle_0_5_lab = TextMobject("0.5").move_to(0.9*DOWN+0.9*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5_copy = circle_0_5.copy().move_to(np.array([0,0,0.5]))
+
+ plane_1 = Polygon(np.array([2,-2,1]),np.array([2,2,1]),np.array([-2,2,1]),np.array([-2,-2,1]),np.array([2,-2,1]), color = YELLOW_C, fill_color = YELLOW_C, fill_opacity = 0.3)
+ plane_1_lab = TextMobject("C = 1").move_to(1.2*UP+3.3*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1 = Circle(radius = 1 , color = YELLOW_C)
+ circle_1_lab = TextMobject("1").move_to(0.7*DOWN+0.7*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1_copy = circle_1.copy().move_to(np.array([0,0,1]))
+
+ plane_1_5 = Polygon(np.array([2,-2,1.5]),np.array([2,2,1.5]),np.array([-2,2,1.5]),np.array([-2,-2,1.5]),np.array([2,-2,1.5]), color = ORANGE, fill_color = ORANGE, fill_opacity = 0.3)
+ plane_1_5_lab = TextMobject("C = 1.5").move_to(1.7*UP+3.4*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5 = Circle(radius = 0.707 , color = ORANGE)
+ circle_1_5_lab = TextMobject("1.5").move_to(0.5*DOWN+0.5*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5_copy = circle_1_5.copy().move_to(np.array([0,0,1.5]))
+
+ plane_2 = Polygon(np.array([2,-2,2]),np.array([2,2,2]),np.array([-2,2,2]),np.array([-2,-2,2]),np.array([2,-2,2]), color = RED_C, fill_color = RED_C, fill_opacity = 0.3)
+ plane_2_lab = TextMobject("C = 2").move_to(2.1*UP+3.3*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2 = Dot().set_fill(RED_C)
+ circle_2_lab = TextMobject("2").move_to(0.2*DOWN+0.2*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2_copy = dot_2.copy().move_to(np.array([0,0,2]))
+
+ vector1 = Arrow(np.array([0.99,-0.99,0]), np.array([0.865,-0.865,0.5]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient1 = Arrow(np.array([0.99,-0.99,0]), np.array([0.865,-0.865,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector2 = Arrow(np.array([0.865,-0.865,0.5]), np.array([0.707,-0.707,1]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient2 = Arrow(np.array([0.865,-0.865,0]), np.array([0.707,-0.707,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector3 = Arrow(np.array([0.707,-0.707,1]), np.array([0.499,-0.499,1.5]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient3 = Arrow(np.array([0.707,-0.707,0]), np.array([0.499,-0.499,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector4 = Arrow(np.array([0.499,-0.499,1.5]), np.array([0,0,2]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient4 = Arrow(np.array([0.499,-0.499,0]), np.array([0,0,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=45 * DEGREES, theta = -20*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(Write(paraboloid))
+ self.wait()
+ self.play(ShowCreation(plane_0), ShowCreation(circle_0))
+ self.add_fixed_in_frame_mobjects(plane_0_lab)
+ self.wait()
+ self.play(ShowCreation(plane_0_5), ShowCreation(circle_0_5_copy), ShowCreation(circle_0_5))
+ self.add_fixed_in_frame_mobjects(plane_0_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1), ShowCreation(circle_1_copy), ShowCreation(circle_1))
+ self.add_fixed_in_frame_mobjects(plane_1_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1_5), ShowCreation(circle_1_5_copy), ShowCreation(circle_1_5))
+ self.add_fixed_in_frame_mobjects(plane_1_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_2), ShowCreation(dot_2_copy), ShowCreation(dot_2))
+ self.add_fixed_in_frame_mobjects(plane_2_lab)
+ self.wait()
+ self.move_camera(phi=60 * DEGREES, theta = 30*DEGREES,run_time=3)
+ self.play(FadeOut(plane_0), FadeOut(plane_0_lab), FadeOut(plane_0_5), FadeOut(plane_0_5_lab), FadeOut(plane_1), FadeOut(plane_1_lab), FadeOut(plane_1_5), FadeOut(plane_1_5_lab), FadeOut(plane_2), FadeOut(plane_2_lab))
+ self.play(FadeOut(circle_0_5_copy), FadeOut(circle_1_copy), FadeOut(circle_1_5_copy), FadeOut(dot_2_copy))
+
+ self.move_camera(phi=45 * DEGREES, theta = -20*DEGREES,run_time=3)
+ self.play(Write(vector1), Write(gradient1))
+ self.wait()
+ self.play(Write(vector2), Write(gradient2))
+ self.wait()
+ self.play(Write(vector3), Write(gradient3))
+ self.wait()
+ self.play(Write(vector4), Write(gradient4))
+ self.wait()
+ self.move_camera(phi=0 * DEGREES, theta = 0*DEGREES,run_time=3)
+ self.play(FadeOut(paraboloid))
+ self.play(FadeOut(vector1), FadeOut(vector2), FadeOut(vector3), FadeOut(vector4))
+ self.wait()
+ self.add_fixed_in_frame_mobjects(circle_0_lab, circle_0_5_lab, circle_1_lab, circle_1_5_lab,circle_2_lab)
+ self.wait(4)
+ \ No newline at end of file
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif
new file mode 100644
index 0000000..39305d5
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif
new file mode 100644
index 0000000..d96f330
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif
new file mode 100644
index 0000000..f1bf06a
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif
Binary files differ