diff options
author | nishanpoojary | 2020-07-01 11:58:37 +0530 |
---|---|---|
committer | GitHub | 2020-07-01 11:58:37 +0530 |
commit | 7a741fe759201d54ff29a450e0f70bea96cd6504 (patch) | |
tree | aba782d39f8bc01e868a9e7ef9d544f9a338ca46 /FSF-2020/calculus-of-several-variables | |
parent | ac83cc7b152273a6f6bd823028e7dec75a6f9fd1 (diff) | |
download | FSF-mathematics-python-code-archive-7a741fe759201d54ff29a450e0f70bea96cd6504.tar.gz FSF-mathematics-python-code-archive-7a741fe759201d54ff29a450e0f70bea96cd6504.tar.bz2 FSF-mathematics-python-code-archive-7a741fe759201d54ff29a450e0f70bea96cd6504.zip |
Added partial-derivatives folder
Diffstat (limited to 'FSF-2020/calculus-of-several-variables')
16 files changed, 1133 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py new file mode 100644 index 0000000..3d35c97 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py @@ -0,0 +1,88 @@ +from manimlib.imports import *
+
+class GasLaw(Scene):
+ def construct(self):
+ gas_law = TextMobject(r"$P$", r"$V$", r"=", r"$n$", r"$R$", r"$T$").scale(1.5)
+ gas_law[0].set_color(BLUE_C)
+ gas_law[1].set_color(GREEN_C)
+ gas_law[3].set_color(RED_C)
+ gas_law[4].set_color(ORANGE)
+ gas_law[5].set_color(YELLOW_C)
+
+ gas_law_trans = TexMobject("V", "=", "{n", "R", "T", "\\over", "P}").scale(1.5)
+ gas_law_trans[0].set_color(GREEN_C)
+ gas_law_trans[2].set_color(RED_C)
+ gas_law_trans[3].set_color(ORANGE)
+ gas_law_trans[4].set_color(YELLOW_C)
+ gas_law_trans[6].set_color(BLUE_C)
+
+ gas_law_func = TexMobject("V", "=", "f(", "n", ",", "T", ",", "P", ")").scale(1.5)
+ gas_law_func[0].set_color(GREEN_C)
+ gas_law_func[2].set_color(ORANGE)
+ gas_law_func[3].set_color(RED_C)
+ gas_law_func[5].set_color(YELLOW_C)
+ gas_law_func[7].set_color(BLUE_C)
+ gas_law_func[8].set_color(ORANGE)
+
+ partial_gas_law_func = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "{\\partial", "\\over", "\\partial", "P}", "f(", r"n", ",", r"T", ",", r"P", r")").scale(1.5)
+ partial_gas_law_func.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_func.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_func[1].set_color(GREEN_C)
+ partial_gas_law_func[10].set_color(ORANGE)
+ partial_gas_law_func[11].set_color(RED_C)
+ partial_gas_law_func[13].set_color(YELLOW_C)
+ partial_gas_law_func[15].set_color(BLUE_C)
+ partial_gas_law_func[16].set_color(ORANGE)
+
+ partial_gas_law_trans = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "{\\partial", "\\over", "\\partial", "P}", "{n", "R", "T", "\\over", "P}").scale(1.5)
+ partial_gas_law_trans.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans[1].set_color(GREEN_C)
+ partial_gas_law_trans[10].set_color(RED_C)
+ partial_gas_law_trans[11].set_color(ORANGE)
+ partial_gas_law_trans[12].set_color(YELLOW_C)
+
+ partial_gas_law_trans2 = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "n", "R", "T", "{\\partial", "\\over", "\\partial", "P}", "P^{-1}",).scale(1.5)
+ partial_gas_law_trans2.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans2.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans2[1].set_color(GREEN_C)
+ partial_gas_law_trans2[6].set_color(RED_C)
+ partial_gas_law_trans2[7].set_color(ORANGE)
+ partial_gas_law_trans2[8].set_color(YELLOW_C)
+ partial_gas_law_trans2[-1].set_color(BLUE_C)
+
+ partial_gas_law_trans3 = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "n", "R", "T", "P^{-2}",).scale(1.5)
+ partial_gas_law_trans3.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans3.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans3[1].set_color(GREEN_C)
+ partial_gas_law_trans3[6].set_color(RED_C)
+ partial_gas_law_trans3[7].set_color(ORANGE)
+ partial_gas_law_trans3[8].set_color(YELLOW_C)
+ partial_gas_law_trans3[9].set_color(BLUE_C)
+
+ framebox = SurroundingRectangle(partial_gas_law_trans3, color = PURPLE, buff = 0.3)
+
+
+
+ self.play(Write(gas_law))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_func))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_func))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans2))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans3))
+ self.wait()
+ self.play(ShowCreation(framebox))
+ self.wait()
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py new file mode 100644 index 0000000..bfb7687 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py @@ -0,0 +1,122 @@ +from manimlib.imports import *
+
+class Hill(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ function = ParametricSurface(
+ lambda u, v: np.array([
+ 1.2*np.sin(u)*np.cos(v),
+ 1.2*np.sin(u)*np.sin(v),
+ -1.2*1.2*np.sin(u)*np.sin(u)*(1+0.5*np.sin(v)*np.sin(v))+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ func_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ 2 - u*u
+ ]),color=RED_E,t_min=-1.2,t_max=1.2,
+ )
+
+ func_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ 2 - 1.5*u*u
+ ]),color=PINK,t_min=-1.2,t_max=1.2,
+ )
+
+ self.set_camera_orientation(phi=60 * 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(ShowCreation(function))
+ self.wait()
+
+ self.move_camera(phi=60 * DEGREES, theta = 45*DEGREES)
+ #self.play(ShowCreation(func_x))
+
+ text_x = TextMobject("Slope of the hill along", r"$x$", "axis", color = YELLOW_C).scale(0.6).move_to(2.7*UP + 3.5*RIGHT)
+ text_x[1].set_color(PINK)
+
+
+ slope_text_x = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_x[0].set_color(BLUE_E)
+ slope_text_x.set_color_by_tex("\\partial",YELLOW_C)
+ slope_text_x.set_color_by_tex("f",RED_E)
+ slope_text_x[5].set_color(PINK)
+
+ self.add_fixed_in_frame_mobjects(text_x, slope_text_x)
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),func_x,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(func_x),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,func_x,scale=1.5)
+ )
+ )
+
+ self.add(vector_x,dot_x)
+
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ #self.move_camera(phi=60 * DEGREES, theta = 0*DEGREES)
+ self.play(FadeOut(vector_x), FadeOut(dot_x), FadeOut(func_x), FadeOut(text_x), FadeOut(slope_text_x))
+
+ text_y = TextMobject("Slope of the hill along", r"$y$", "axis", color = YELLOW_C).scale(0.6).move_to(2.7*UP + 3.5*RIGHT)
+ text_y[1].set_color(RED_C)
+
+
+ slope_text_y = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_y[0].set_color(BLUE_E)
+ slope_text_y.set_color_by_tex("\\partial",YELLOW_C)
+ slope_text_y.set_color_by_tex("f",PINK)
+ slope_text_y[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text_y, slope_text_y)
+
+ dot_y = Dot().rotate(PI/2).set_color(BLUE_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),func_y,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(func_y),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,func_y,scale=1.5)
+ )
+ )
+
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+ self.play(FadeOut(vector_y), FadeOut(dot_y), FadeOut(func_y), FadeOut(text_y), FadeOut(slope_text_y))
+ self.wait(2)
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = ORANGE, buff=0)
+ return vector
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py new file mode 100644 index 0000000..a25ca56 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py @@ -0,0 +1,218 @@ +from manimlib.imports import *
+
+class PartialDeriv(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy1 = paraboloid.copy()
+ paraboloid_copy2 = paraboloid.copy()
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_x_copy = paraboloid_x.copy()
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ parabola1 =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ -(u*u) + 2
+ ]),color="#006400",t_min=-2,t_max=2,
+ )
+ parabola2 =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ -(u*u) + 2
+ ]),color=BLUE_C,t_min=-2,t_max=2,
+ )
+
+ plane1 = Polygon(np.array([-2.2,0,-2.5]),np.array([2.2,0,-2.5]),np.array([2.2,0,2.5]),np.array([-2.2,0,2.5]),np.array([-2.2,0,-2.5]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane1_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(2*UP + 3.3*RIGHT)
+
+ plane2 = Polygon(np.array([0,-2.2,-2.5]),np.array([0,2.2,-2.5]),np.array([0,2.2,2.5]),np.array([0,-2.2,2.5]),np.array([0,-2.2,-2.5]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane2_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(2*UP + 3.2*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = YELLOW_C).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(PINK)
+
+ dot1 =Sphere(radius=0.08).move_to(np.array([-1,0,1]))
+ dot1.set_fill(RED)
+ line1 = Line(np.array([-1.55, 0,0]), np.array([-0.4, 0,2.2]), color = RED)
+ lab_x = TextMobject(r"$f(x_0,y_0)$", color = RED).scale(0.7)
+ para_lab_x = TextMobject(r"$f(x,y_0)$", color = "#006400").scale(0.7)
+ tangent_line_x = TextMobject("Tangent Line", color = RED_C, buff = 0.4).scale(0.6).move_to(np.array([1.7*RIGHT +1.8*UP]))
+
+
+ text1 = TextMobject(r"$\frac{\partial f}{\partial x}\vert_{(x_0,y_0)} = \frac{d}{dx}$", r"$f(x,y_0)$", r"$\vert_{x=x_0}$").scale(0.6)
+ brace1 = Brace(text1[1], DOWN, buff = SMALL_BUFF, color = GREEN)
+ t1 = brace1.get_text("Just depends on x")
+ t1.scale(0.6)
+ t1.set_color(GREEN)
+
+
+ dot2 =Sphere(radius=0.08).move_to(np.array([0,1,1]))
+ dot2.set_fill(RED)
+ line2 = Line(np.array([0, 1.55,0]), np.array([0, 0.4,2.2]), color = RED)
+ lab_y = TextMobject(r"$f(x_0,y_0)$", color = RED).scale(0.7)
+ para_lab_y = TextMobject(r"$f(x_0,y)$", color = BLUE_C).scale(0.7)
+ tangent_line_y = TextMobject("Tangent Line", color = RED_C, buff = 0.4).scale(0.6).move_to(np.array([1.7*RIGHT +1.8*UP]))
+
+ text2 = TextMobject(r"$\frac{\partial f}{\partial y}\vert_{(x_0,y_0)} = \frac{d}{dy}$", r"$f(x_0,y)$", r"$\vert_{y=y_0}$").scale(0.6)
+ brace2 = Brace(text2[1], DOWN, buff = SMALL_BUFF, color = GREEN)
+ t2 = brace2.get_text("Just depends on y")
+ t2.scale(0.6)
+ t2.set_color(GREEN)
+
+ text3 = TextMobject(r"$= \lim_{h \to 0} \frac{f(x_0+h,y_0) - f(x_0,y_0)}{h}$").scale(0.6)
+
+ dot3 =Sphere(radius=0.08).move_to(np.array([-1.22,0,0.5]))
+ dot3.set_fill(YELLOW_C)
+ line3 = Line(np.array([-1.44,0,0]), np.array([-0.6,0,2.2]), color = YELLOW_C)
+ lab_line3 = TextMobject(r"$f(x_0+h,y_0)$", color = YELLOW_C).scale(0.7)
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=80 * DEGREES, theta = 20*DEGREES)
+ #self.begin_ambient_camera_rotation(rate=0.3)
+
+
+ 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(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ #self.add_fixed_orientation_mobjects(axis[2])
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=110*DEGREES)
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES)
+
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane1_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+
+ lab_x.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_x.move_to(np.array([1.3*LEFT +1.6*UP]))
+ self.wait()
+ self.play(FadeOut(plane1), FadeOut(plane1_text))
+ self.play(ShowCreation(parabola1))
+ self.add_fixed_in_frame_mobjects(para_lab_x)
+ self.play(ShowCreation(dot1))
+ self.add_fixed_in_frame_mobjects(lab_x)
+ #self.play(ShowCreation(dot1))
+ self.wait()
+ self.play(ShowCreation(line1))
+ self.add_fixed_in_frame_mobjects(tangent_line_x)
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(text1, brace1, t1)
+ grp1 = VGroup(text1, brace1, t1)
+ grp1.move_to(3*UP+3*RIGHT)
+ self.play(Write(text1),GrowFromCenter(brace1), FadeIn(t1))
+ self.wait()
+ self.play(FadeOut(parabola1), FadeOut(line1), FadeOut(lab_x), FadeOut(para_lab_x), FadeOut(dot1), FadeOut(tangent_line_x),FadeOut(grp1))
+
+
+
+
+ #self.move_camera(phi=80* DEGREES,theta=20*DEGREES)
+
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy1))
+ self.wait()
+ self.play(ShowCreation(plane2))
+ self.add_fixed_in_frame_mobjects(plane2_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy1, paraboloid_y))
+
+ lab_y.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_y.move_to(np.array([1.3*LEFT +1.6*UP]))
+ self.wait()
+ self.play(FadeOut(plane2), FadeOut(plane2_text))
+ self.play(ShowCreation(parabola2))
+ self.add_fixed_in_frame_mobjects(para_lab_y)
+ self.play(ShowCreation(dot2))
+ self.add_fixed_in_frame_mobjects(lab_y)
+ self.wait()
+ self.play(ShowCreation(line2))
+ self.add_fixed_in_frame_mobjects(tangent_line_y)
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(text2, brace2, t2)
+ grp2 = VGroup(text2, brace2, t2)
+ grp2.move_to(3*UP+3*RIGHT)
+ self.play(Write(text2),GrowFromCenter(brace2), FadeIn(t2))
+ self.wait()
+ self.play(FadeOut(parabola2), FadeOut(line2), FadeOut(lab_y), FadeOut(para_lab_y), FadeOut(dot2), FadeOut(tangent_line_y), FadeOut(grp2))
+ self.wait()
+
+
+ #self.move_camera(phi=80* DEGREES,theta=105*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy2))
+ self.wait()
+
+
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane1_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy2, paraboloid_x_copy))
+
+ lab_x.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_x.move_to(np.array([1.3*LEFT +1.6*UP]))
+ lab_line3.move_to(np.array([2.4*RIGHT +0.5*UP]))
+ self.wait()
+ self.play(FadeOut(plane1), FadeOut(plane1_text))
+ self.play(ShowCreation(parabola1))
+ self.add_fixed_in_frame_mobjects(para_lab_x)
+ self.play(ShowCreation(dot1))
+ self.add_fixed_in_frame_mobjects(lab_x)
+ self.play(ShowCreation(dot3))
+ self.add_fixed_in_frame_mobjects(lab_line3)
+ self.wait()
+ self.play(ShowCreation(line1))
+ self.add_fixed_in_frame_mobjects(tangent_line_x)
+ self.play(ShowCreation(line3))
+ self.wait()
+
+
+ self.add_fixed_in_frame_mobjects(text1,text3)
+ text1.move_to(3*UP+3*RIGHT)
+ text3.next_to(text1, DOWN)
+ self.play(Write(text1),Write(text3))
+ self.wait()
+ self.play(FadeOut(parabola1), FadeOut(line1), FadeOut(lab_x), FadeOut(line3), FadeOut(lab_line3), FadeOut(para_lab_x), FadeOut(dot1), FadeOut(dot3), FadeOut(tangent_line_x), FadeOut(text1), FadeOut(text3))
+ self.wait()
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py new file mode 100644 index 0000000..5712a62 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py @@ -0,0 +1,246 @@ +from manimlib.imports import *
+
+class PartialDerivX(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy = paraboloid.copy()
+
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+
+ parabola =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ -(u*u) + 2
+ ]),color="#006400",t_min=-2,t_max=2,
+ )
+
+ plane = Polygon(np.array([-2.2,0,-2.5]),np.array([2.2,0,-2.5]),np.array([2.2,0,2.5]),np.array([-2.2,0,2.5]),np.array([-2.2,0,-2.5]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(2*UP + 3*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = PINK).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ line = Line(np.array([-2,0,0]), np.array([2,0,0]), color = RED_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(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=95*DEGREES)
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES)
+ self.play(ShowCreation(plane))
+ self.add_fixed_in_frame_mobjects(plane_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+ self.play(FadeOut(plane), FadeOut(plane_text))
+ self.play(ShowCreation(parabola), ShowCreation(line))
+
+ text1 = TextMobject("Moving small", r"$dx$", r"steps").scale(0.6).move_to(3*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, BLUE, PURPLE)
+
+ text2 = TextMobject("Observing change in function, keeping", r"$y$", r"constant").scale(0.6).move_to(2.6*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ slope_text = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text[0].set_color(BLUE_E)
+ slope_text.set_color_by_tex("\\partial",PINK)
+ slope_text.set_color_by_tex("f","#006400")
+ slope_text[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text1, text2)
+ self.wait()
+ self.add_fixed_in_frame_mobjects(slope_text)
+ #add_fixed_orientation_mobjects
+
+
+ dot = Dot().rotate(PI/2).set_color(RED_C)
+ alpha = ValueTracker(0)
+ vector = self.get_tangent_vector(alpha.get_value(),parabola,scale=1.5)
+ dot.add_updater(lambda m: m.move_to(vector.get_center()))
+ self.play(
+ ShowCreation(parabola),
+ GrowFromCenter(dot),
+ GrowArrow(vector)
+ )
+ vector.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha.get_value()%1,parabola,scale=1.5)
+ )
+ )
+ self.add(vector,dot)
+ self.play(alpha.increment_value, 1, run_time=10, rate_func=linear)
+ self.wait()
+
+
+ '''
+ for i in np.arange(-2,2,0.2):
+ self.play(ReplacementTransform(Line(np.array([i,0,0]), np.array([i,0,-i*i + 2]), color = GREEN_C), Line(np.array([i+0.2,0,0]), np.array([i+0.2,0,-(i+0.2)**2 + 2]), color = GREEN_C)))
+ #self.wait()
+ '''
+
+ self.wait()
+ self.play(FadeOut(parabola), FadeOut(line), FadeOut(vector), FadeOut(dot), FadeOut(text1), FadeOut(text2), FadeOut(slope_text),FadeOut(surface_eqn))
+
+ #self.move_camera(phi=80* DEGREES,theta= 0*DEGREES)
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy))
+ self.wait()
+
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = BLUE_E, buff=0)
+ return vector
+
+
+class PartialDerivY(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy = paraboloid.copy()
+
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+
+ parabola =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ -(u*u) + 2
+ ]),color=YELLOW_C,t_min=-2,t_max=2,
+ )
+
+ plane = Polygon(np.array([0,-2.2,-2.5]),np.array([0,2.2,-2.5]),np.array([0,2.2,2.5]),np.array([0,-2.2,2.5]),np.array([0,-2.2,-2.5]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(2*UP + 3*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = PINK).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ line = Line(np.array([0,-2,0]), np.array([0,2,0]), color = RED_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(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 45*DEGREES)
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=5*DEGREES)
+ self.play(ShowCreation(plane))
+ self.add_fixed_in_frame_mobjects(plane_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_y))
+ self.play(FadeOut(plane), FadeOut(plane_text))
+ self.play(ShowCreation(parabola), ShowCreation(line))
+
+ text1 = TextMobject("Moving small", r"$dy$", r"steps").scale(0.6).move_to(3*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, BLUE, PURPLE)
+
+ text2 = TextMobject("Observing change in function, keeping", r"$x$", r"constant").scale(0.6).move_to(2.6*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ slope_text = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "y}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text[0].set_color("#006400")
+ slope_text.set_color_by_tex("\\partial",PINK)
+ slope_text.set_color_by_tex("f",YELLOW_C)
+ slope_text[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text1, text2)
+ self.wait()
+ self.add_fixed_in_frame_mobjects(slope_text)
+
+ dot = Dot().rotate(PI/2).set_color(RED_C)
+ alpha = ValueTracker(0)
+ vector = self.get_tangent_vector(alpha.get_value(),parabola,scale=1.5)
+ dot.add_updater(lambda m: m.move_to(vector.get_center()))
+ self.play(
+ ShowCreation(parabola),
+ GrowFromCenter(dot),
+ GrowArrow(vector)
+ )
+ vector.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha.get_value()%1,parabola,scale=1.5)
+ )
+ )
+ self.add(vector,dot)
+ self.play(alpha.increment_value, 1, run_time=10, rate_func=linear)
+ self.wait()
+
+ '''
+ for i in np.arange(-2,2,0.2):
+ self.play(ReplacementTransform(Line(np.array([0,i,0]), np.array([0,i,-i*i + 2]), color = BLUE_C), Line(np.array([0,i+0.2,0]), np.array([0,i+0.2,-(i+0.2)**2 + 2]), color = BLUE_C)))
+ #self.wait()
+ '''
+
+
+ self.wait()
+ self.play(FadeOut(parabola), FadeOut(line), FadeOut(vector), FadeOut(dot), FadeOut(text1), FadeOut(text2), FadeOut(slope_text),FadeOut(surface_eqn))
+
+ #self.move_camera(phi=80* DEGREES,theta= 90*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy))
+ self.wait()
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = "#006400", buff=0)
+ return vector
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py new file mode 100644 index 0000000..7bbb9a7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py @@ -0,0 +1,227 @@ +from manimlib.imports import *
+
+class MaximaMinima(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy1 = paraboloid.copy()
+ paraboloid_copy2 = paraboloid.copy()
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=PI/2,v_max=3*PI/2, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ parabola_x_out =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ (u*u )*np.exp(1-u*u)
+ ]),color=RED_E,t_min=-3.5,t_max=3.5,
+ )
+
+ parabola_y_out =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ (3*u*u)*np.exp(1-u*u)
+ ]),color=PINK,t_min=-3.5,t_max=3.5,
+ )
+
+ plane1 = Polygon(np.array([-3.5,0,-3]),np.array([3.5,0,-3]),np.array([3.5,0,3]),np.array([-3.5,0,3]),np.array([-3.5,0,-3]), color = RED_C, fill_color = RED_C, fill_opacity = 0.2)
+ plane_text_x = TextMobject(r"$y = 0$", color = RED_C).move_to(2*UP + 4.5*RIGHT)
+
+ plane2 = Polygon(np.array([0,-3.5,-3]),np.array([0,3.5,-3]),np.array([0,3.5,3]),np.array([0,-3.5,3]),np.array([0,-3.5,-3]), color = PINK, fill_color = PINK, fill_opacity = 0.2)
+ plane_text_y = TextMobject(r"$x = 0$", color = PINK).move_to(2*UP + 4.5*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = (x^2 + 3y^2)e^{(1 - x^2 - y^2)}$", color = YELLOW_C).scale(0.6).move_to(np.array([3.5*LEFT +3.5*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 45*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(paraboloid))
+
+
+ #self.move_camera(phi=60 * DEGREES, theta = 45*DEGREES,run_time=3)
+
+
+ plane_x = Polygon(np.array([-3.5,2,-3]),np.array([3.5,2,-3]),np.array([3.5,2,3]),np.array([-3.5,2,3]),np.array([-3.5,2,-3]), color = YELLOW_C, fill_color = YELLOW_A, fill_opacity = 0.2)
+
+ plane_y = Polygon(np.array([2,-3.5,-3]),np.array([2,3.5,-3]),np.array([2,3.5,3]),np.array([2,-3.5,3]),np.array([2,-3.5,-3]), color = GREEN_C, fill_color = GREEN_A, fill_opacity = 0.2)
+
+ text_x = TextMobject(r"$x$", "is fixed on this" ,"plane").scale(0.7).to_corner(UL)
+ text_y = TextMobject(r"$y$", "is fixed on this" ,"plane").scale(0.7).to_corner(UR)
+
+ text_x[0].set_color(RED_C)
+ text_y[0].set_color(PINK)
+ text_x[1].set_color(BLUE_C)
+ text_y[1].set_color(BLUE_C)
+ text_x[2].set_color(GREEN_C)
+ text_y[2].set_color(YELLOW_C)
+
+ self.add_fixed_in_frame_mobjects(text_x, text_y)
+
+ for i in range(2,-4,-1):
+
+ parabola_x =ParametricFunction(lambda u : np.array([u,i,(u*u + 3*i*i)*np.exp(1- u*u - i*i)]),color=RED_C,t_min=-3.5,t_max=3.5,)
+
+ parabola_y =ParametricFunction(lambda u : np.array([i,u,(i*i + 3*u*u)*np.exp(1- u*u - i*i)]),color=PINK,t_min=-3.5,t_max=3.5,)
+
+ if(i==2):
+ self.play(ShowCreation(plane_x), ShowCreation(plane_y))
+ parabola_copy_x = parabola_x.copy()
+ parabola_copy_y = parabola_y.copy()
+
+
+ self.play(ShowCreation(parabola_copy_x), ShowCreation(parabola_copy_y))
+ self.wait()
+ self.play(FadeOut(parabola_copy_x), FadeOut(parabola_copy_y))
+
+ else:
+ self.play(ApplyMethod(plane_x.move_to, np.array([0,i,0])),ReplacementTransform(parabola_copy_x, parabola_x),ApplyMethod(plane_y.move_to, np.array([i,0,0])),ReplacementTransform(parabola_copy_y, parabola_y))
+ self.play(FadeOut(parabola_x), FadeOut(parabola_y))
+ self.wait()
+
+ parabola_copy_x = parabola_x.copy()
+ parabola_copy_y = parabola_y.copy()
+
+ self.play(FadeOut(plane_x), FadeOut(plane_y), FadeOut(text_x), FadeOut(text_y))
+
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+
+ self.move_camera(phi=80 * DEGREES, theta = 95*DEGREES)
+
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane_text_x)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+ self.play(FadeOut(plane1), FadeOut(plane_text_x))
+
+ line_x = Line(np.array([-3.5,0,0]), np.array([3.5,0,0]), color = YELLOW_E)
+
+ self.play(ShowCreation(parabola_x_out), ShowCreation(line_x))
+
+ slope_text_x = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_x[0].set_color(ORANGE)
+ slope_text_x.set_color_by_tex("\\partial",GREEN_E)
+ slope_text_x.set_color_by_tex("f",RED_E)
+ slope_text_x[5].set_color(YELLOW_E)
+
+ self.add_fixed_in_frame_mobjects(slope_text_x)
+
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),parabola_x_out,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(parabola_x_out),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,parabola_x_out,scale=1.5)
+ )
+ )
+ self.add(vector_x,dot_x)
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+ self.play(FadeOut(parabola_x_out), FadeOut(line_x), FadeOut(vector_x), FadeOut(dot_x), FadeOut(slope_text_x))
+
+ self.move_camera(phi=80* DEGREES,theta= 5*DEGREES)
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy1))
+ self.wait()
+
+
+
+ self.play(ShowCreation(plane2))
+ self.add_fixed_in_frame_mobjects(plane_text_y)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy1, paraboloid_y))
+ self.play(FadeOut(plane2), FadeOut(plane_text_y))
+
+ line_y = Line(np.array([0,-3.5,0]), np.array([0,3.5,0]), color = GREEN_E)
+
+ self.play(ShowCreation(parabola_y_out), ShowCreation(line_y))
+
+ slope_text_y = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "y}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_y[0].set_color(ORANGE)
+ slope_text_y.set_color_by_tex("\\partial",YELLOW_E)
+ slope_text_y.set_color_by_tex("f",PINK)
+ slope_text_y[5].set_color(GREEN_E)
+
+ self.add_fixed_in_frame_mobjects(slope_text_y)
+
+
+ dot_y = Dot().rotate(PI/2).set_color(GREEN_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),parabola_y_out,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(parabola_y_out),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,parabola_y_out,scale=1.5)
+ )
+ )
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+ self.play(FadeOut(parabola_y_out), FadeOut(line_y), FadeOut(vector_y), FadeOut(dot_y), FadeOut(slope_text_y))
+
+ self.move_camera(phi=60* DEGREES,theta= 45*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy2))
+ self.wait()
+
+
+
+
+
+
+
+
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector , coord_i + unit_vector, color = ORANGE, buff=0)
+ return vector
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py new file mode 100644 index 0000000..b79f77c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py @@ -0,0 +1,64 @@ +from manimlib.imports import *
+
+class ClariantRule(Scene):
+ def construct(self):
+ derivatives = TextMobject(r"$cos(x)y^3$",r"$-sin(x)y^3$", r"$3cos(x)y^2$", r"$-cos(x)y^3$", r"$-3sin(x)y^2$", r"$-3sin(x)y^2$", r"$6cos(x)y$")
+
+ partial_derivatives = TextMobject(r"$\frac{\partial}{\partial x}$", r"$\frac{\partial}{\partial y}$")
+
+
+ derivatives[0].move_to(2*UP).set_color(PURPLE)
+ derivatives[1].move_to(3*LEFT).set_color(YELLOW_C)
+ derivatives[2].move_to(3*RIGHT).set_color(BLUE_C)
+
+ arrrow_1 = Arrow(derivatives[0].get_bottom(), derivatives[1].get_top())
+ arrrow_1_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_1_lab.move_to(2.5*LEFT+ 1.3*UP)
+
+ arrrow_2 = Arrow(derivatives[0].get_bottom(), derivatives[2].get_top())
+ arrrow_2_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_2_lab.move_to(2.5*RIGHT+ 1.3*UP)
+
+ self.play(Write(derivatives[0]))
+ self.play(GrowArrow(arrrow_1), GrowArrow(arrrow_2), Write(arrrow_1_lab), Write(arrrow_2_lab))
+
+ self.play(Write(derivatives[1]))
+ self.play(Write(derivatives[2]))
+
+ derivatives[3].move_to(2*DOWN + 4.5*LEFT).set_color(GREEN_C)
+ derivatives[4].move_to(2*DOWN + 1.5*LEFT).set_color(PINK)
+ derivatives[5].move_to(2*DOWN + 1.5*RIGHT).set_color(PINK)
+ derivatives[6].move_to(2*DOWN + 4.5*RIGHT).set_color(ORANGE)
+
+ arrrow_3 = Arrow(derivatives[1].get_bottom(), derivatives[3].get_top())
+ arrrow_3_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_3_lab.move_to(4.3*LEFT+ 0.8*DOWN)
+
+ arrrow_4 = Arrow(derivatives[1].get_bottom(), derivatives[4].get_top())
+ arrrow_4_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_4_lab.move_to(1.6*LEFT+ 0.8*DOWN)
+
+ arrrow_5 = Arrow(derivatives[2].get_bottom(), derivatives[5].get_top())
+ arrrow_5_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_5_lab.move_to(1.6*RIGHT+ 0.8*DOWN)
+
+ arrrow_6 = Arrow(derivatives[2].get_bottom(), derivatives[6].get_top())
+ arrrow_6_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_6_lab.move_to(4.3*RIGHT+ 0.8*DOWN)
+
+ self.play(GrowArrow(arrrow_3), GrowArrow(arrrow_4), Write(arrrow_3_lab), Write(arrrow_4_lab))
+ self.play(Write(derivatives[3]), Write(derivatives[4]))
+
+ self.play(GrowArrow(arrrow_5), GrowArrow(arrrow_6), Write(arrrow_5_lab), Write(arrrow_6_lab))
+ self.play(Write(derivatives[5]), Write(derivatives[6]))
+
+ brace1 = Brace(derivatives[4:6], DOWN, buff = SMALL_BUFF, color = RED_C)
+ brace_t1 = brace1.get_text("Mixed partial derivatives are the same!")
+ brace_t1.set_color(RED_C)
+
+ self.play(GrowFromCenter(brace1), FadeIn(brace_t1))
+
+ self.wait()
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py new file mode 100644 index 0000000..313c6cd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py @@ -0,0 +1,108 @@ +from manimlib.imports import *
+
+class ClariantRule(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ function = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+
+ function_copy1 = function.copy()
+ function_copy2 = function.copy()
+
+ func_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ -1,
+ (u*u )*np.exp(1-u*u)
+ ]),color=RED_E,t_min=-3.5,t_max=3.5,
+ )
+
+ func_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ (3*u*u)*np.exp(1-u*u)
+ ]),color=PINK,t_min=-3.5,t_max=3.5,
+ )
+
+ plane_x = Polygon(np.array([-3.5,-1,-3]),np.array([3.5,-1,-3]),np.array([3.5,-1,3]),np.array([-3.5,-1,3]),np.array([-3.5,-1,-3]), color = YELLOW_E, fill_color = YELLOW_B, fill_opacity = 0.1)
+ plane_text_x = TextMobject(r"$y = -1$", color = YELLOW_C).move_to(np.array([5,0,2.7])).scale(0.7)
+
+ plane_y = Polygon(np.array([0,-3.5,-3]),np.array([0,3.5,-3]),np.array([0,3.5,3]),np.array([0,-3.5,3]),np.array([0,-3.5,-3]), color = GREEN_E, fill_color = GREEN_B, fill_opacity = 0.1)
+ plane_text_y = TextMobject(r"$x = 0$", color = GREEN_C).move_to(np.array([0,4,2.7])).scale(0.7)
+
+ surface_eqn = TextMobject("Surface", r"$z = (x^2 + 3y^2)e^{(1 - x^2 - y^2)}$", color = YELLOW_C).scale(0.6).move_to(np.array([4.6*LEFT+3.5*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 45*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(function))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+
+ self.play(ShowCreation(plane_x), ShowCreation(plane_y))
+ self.add_fixed_orientation_mobjects(plane_text_x, plane_text_y)
+
+ self.play(ShowCreation(func_x), ShowCreation(func_y))
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),func_x,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(func_x),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,func_x,scale=1.5)
+ )
+ )
+ dot_y = Dot().rotate(PI/2).set_color(GREEN_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),func_y,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(func_y),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,func_y,scale=1.5)
+ )
+ )
+ self.add(vector_x,dot_x)
+
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py new file mode 100644 index 0000000..f50d2d1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py @@ -0,0 +1,60 @@ +from manimlib.imports import *
+
+class ChainRule(Scene):
+ def construct(self):
+
+ chain_rule = TextMobject(r"$\frac{dw}{dt}$", r"=", r"$\frac{\partial w}{\partial x}$", r"$\frac{dx}{dt}$", r"+", r"$\frac{\partial w}{\partial y}$", r"$\frac{dy}{dt}$").move_to(4*RIGHT).scale(0.8)
+
+ chain_rule[0].set_color(ORANGE)
+ chain_rule[2].set_color(GREEN_C)
+ chain_rule[3].set_color(RED_C)
+ chain_rule[5].set_color(YELLOW_C)
+ chain_rule[6].set_color(BLUE_C)
+
+ functions = TextMobject(r"$w =f(x,y)$",r"$x$", r"$y$", r"$t$")
+
+ functions[0].move_to(3.3*UP+1*LEFT).set_color(ORANGE)
+ functions[1].move_to(3.3*LEFT).set_color(PURPLE)
+ functions[2].move_to(1.3*RIGHT).set_color(PURPLE)
+ functions[3].move_to(3.3*DOWN+1*LEFT).set_color(WHITE)
+
+ partial_derivatives = TextMobject(r"$\frac{\partial w}{\partial x}$", r"$\frac{\partial w}{\partial y}$")
+
+ partial_derivatives[0].move_to(1.5*UP+3*LEFT).set_color(GREEN_C)
+ partial_derivatives[1].move_to(1.5*UP+1*RIGHT).set_color(YELLOW_C)
+
+ derivatives = TextMobject(r"$\frac{dx}{dt}$", r"$\frac{dy}{dt}$")
+
+ derivatives[0].move_to(1.5*DOWN+3*LEFT).set_color(RED_C)
+ derivatives[1].move_to(1.5*DOWN+1*RIGHT).set_color(BLUE_C)
+
+ line_f_x = Line(np.array([-1,3,0]), np.array([-3,0,0]), color = BLUE_C)
+ line_f_y = Line(np.array([-1,3,0]), np.array([1,0,0]), color = BLUE_C)
+ line_x_t = Line(np.array([-3,0,0]), np.array([-1,-3,0]), color = BLUE_C)
+ line_y_t = Line(np.array([1,0,0]), np.array([-1,-3,0]), color = BLUE_C)
+
+ dot_f = Dot().shift(np.array([-1,3,0])).set_color(BLUE_C)
+ dot_x = Dot().shift(np.array([-3,0,0])).set_color(BLUE_C)
+ dot_y = Dot().shift(np.array([1,0,0])).set_color(BLUE_C)
+ dot_t = Dot().shift(np.array([-1,-3,0])).set_color(BLUE_C)
+
+ variables = TextMobject("Dependent Variable","Intermediate Variables", "Dependent Variable").set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE).scale(0.7)
+ variables[0].move_to(3.3*UP+3.5*RIGHT)
+ variables[1].move_to(3.5*RIGHT)
+ variables[2].move_to(3.3*DOWN+3.5*RIGHT)
+
+ self.play(ShowCreation(dot_f), Write(functions[0]))
+ self.play(ShowCreation(dot_x), ShowCreation(line_f_x), Write(functions[1]), ShowCreation(dot_y), ShowCreation(line_f_y), Write(functions[2]))
+ self.play(Write(partial_derivatives[0]), Write(partial_derivatives[1]))
+ self.wait()
+
+ self.play(ShowCreation(dot_t), ShowCreation(line_x_t), ShowCreation(line_y_t), Write(functions[3]))
+ self.play(Write(derivatives[0]), Write(derivatives[1]))
+ self.wait()
+
+ self.play(Write(variables[0]), Write(variables[1]), Write(variables[2]))
+
+ self.play(FadeOut(variables))
+ self.play(Write(chain_rule))
+ self.wait()
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif Binary files differnew file mode 100644 index 0000000..560a7c0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif Binary files differnew file mode 100644 index 0000000..f4c3f49 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif Binary files differnew file mode 100644 index 0000000..e0e42db --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif Binary files differnew file mode 100644 index 0000000..30682cb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif Binary files differnew file mode 100644 index 0000000..aa74437 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif Binary files differnew file mode 100644 index 0000000..8377827 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif Binary files differnew file mode 100644 index 0000000..ecef499 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif Binary files differnew file mode 100644 index 0000000..596b08d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif |