diff options
257 files changed, 10256 insertions, 370 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/example.py b/FSF-2020/approximations-and-optimizations/Critical Points/example.py deleted file mode 100644 index 3a41be7..0000000 --- a/FSF-2020/approximations-and-optimizations/Critical Points/example.py +++ /dev/null @@ -1,32 +0,0 @@ -from manimlib.imports import* - -class ExampleAnimation(ThreeDScene): - def construct(self): - axes = ThreeDAxes() - - f_text = TextMobject("$f(x,y) = (y-x)(1-2x-3y)$").to_corner(UL) - d = Dot(np.array([0,0,0]), color = '#800000') #---- Critical Point - d_text = TextMobject("$(0.2,0.2)$",color = '#DC143C').scale(0.5).shift(0.2*UP) #----x = 0.2, y = 0.2 - r_text=TextMobject("Critical Point",color = '#00FFFF').shift(0.3*DOWN).scale(0.6) - - #----f(x,y) = (y-x)(1-2x-3y) - f = 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_D, PURPLE_E], - resolution=(20, 20)).scale(1) - - self.set_camera_orientation(phi = 75 * DEGREES) - self.begin_ambient_camera_rotation(rate=0.5) - - self.add_fixed_in_frame_mobjects(f_text) - self.wait(1) - self.add(axes) - self.play(Write(f),Write(d)) - self.wait(1) - self.add_fixed_in_frame_mobjects(d_text) - self.wait(1) - self.add_fixed_in_frame_mobjects(r_text) - self.wait(3) diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py b/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py deleted file mode 100644 index 27354ef..0000000 --- a/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py +++ /dev/null @@ -1,30 +0,0 @@ -from manimlib.imports import* - -class MotivationAnimation(Scene): - def construct(self): - - r = Rectangle(height = 7,breadth = 2,color = BLUE, fill_opacity = 0.3).scale(0.6) #----metal strip - b = Brace(r,UP) - r_text = TextMobject("$x$ metres",color = YELLOW).shift(3*UP) - m_text = TextMobject("Metal Strip").shift(3*DOWN) - a = Arc(radius=2).rotate(1).shift(LEFT+0.5*UP) - a2 = Arc(radius=2).rotate(5).shift(0.7*LEFT+0.9*UP).scale(0.2) - START = [1,0,0] - END = [0,3,0] - l = Line(START,END,color = RED).shift(0.9*DOWN) - a2_text = TextMobject("$\\theta$",color = PINK).shift(1.6*UP+0.4*RIGHT) - - group1 = VGroup(r_text,b,a,l,a2,a2_text) - f_text = TextMobject("$A = f(x,\\theta)$").shift(2*DOWN) - - ring = Annulus(inner_radius = 0.7, outer_radius = 1, color = BLUE) #--bent metal strip - - self.play(Write(r)) - self.wait(1) - self.play(ShowCreation(m_text)) - self.wait(1) - self.play(Write(group1)) - self.wait(2) - self.play(FadeOut(group1)) - self.wait(1) - self.play(ReplacementTransform(r,ring),ShowCreation(f_text)) diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py b/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py deleted file mode 100644 index 7c82aa9..0000000 --- a/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py +++ /dev/null @@ -1,55 +0,0 @@ -from manimlib.imports import* - -class TheoremAnimation(ThreeDScene): - def construct(self): - - axes = ThreeDAxes() - - #----parabola: x**2+y**2 - parabola1 = 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_E], - resolution = (20, 20)).scale(1) - - #----parabola: -x**2-y**2 - parabola2 = ParametricSurface( - lambda u, v: np.array([ - u, - v, - -u**2-v**2 - ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [PURPLE_E,PURPLE_E], - resolution = (20, 20)).scale(1) - - self.set_camera_orientation(phi = 75 * DEGREES) - self.begin_ambient_camera_rotation(rate = 0.4) - - d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point - r = Rectangle(fill_color = '#C0C0C0',fill_opacity = 0.3).move_to(ORIGIN) #----tangent plane - - parabola1_text = TextMobject("Maximum with horizontal tangent plane").scale(0.7).to_corner(UL) - - parabola2_text = TextMobject("Minimum with horizontal tangent plane").scale(0.7).to_corner(UL) - - self.add(axes) - self.add_fixed_in_frame_mobjects(parabola2_text) - self.wait(1) - self.play(Write(parabola1)) - self.wait(1) - self.play(ShowCreation(d)) - self.wait(1) - self.play(ShowCreation(r)) - self.wait(2) - self.play(FadeOut(parabola2_text),FadeOut(parabola1),FadeOut(r),FadeOut(d)) - - self.wait(1) - self.add_fixed_in_frame_mobjects(parabola1_text) - self.wait(1) - self.play(Write(parabola2)) - self.wait(1) - self.play(ShowCreation(d)) - self.wait(1) - self.play(ShowCreation(r)) - self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/README.md new file mode 100644 index 0000000..857d298 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/README.md @@ -0,0 +1,38 @@ +<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/calculus-of-several-variables/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/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file4_Relative_Maximum_and_Relative_Minimum + +![file4_Relative_Maxima_and_Relative_Minima](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file5_Saddle_Point + +![file5_Saddle_Point](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file6_f(x,y)=(y-x)(1-2x-3y) + +![file6_f(x,y)=(y-x)(1-2x-3y)](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x%2Cy)%3D(y-x)(1-2x-3y).gif?raw=true) +<br/></br> +<br/></br> diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif Binary files differnew file mode 100644 index 0000000..ca3989c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file1_Critical_Point_of_a_function.py new file mode 100644 index 0000000..e8cb08d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif Binary files differnew file mode 100644 index 0000000..84acf2e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file2_Traces_and_Tangent.py new file mode 100644 index 0000000..4b020e1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif Binary files differnew file mode 100644 index 0000000..14fb318 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file3_Tangent_plane_at_extrema_of_a_function.py b/FSF-2020/calculus-of-several-variables/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/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.gif Binary files differnew file mode 100644 index 0000000..6b93359 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.py new file mode 100644 index 0000000..3bd810d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file4_Relative_Maximum_and_Relative_Minimum.py @@ -0,0 +1,51 @@ +from manimlib.imports import* +import math as m + +#---- locating extrema of a funtion using critical points +class Extrema(ThreeDScene): + def construct(self): + + h_text = TextMobject("Relative Maximum and Relative Minimum",color = GREEN) + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + #---- f(x,y) = 5(x+y)e^(-x^2-y^2) + surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + 5*(u+v)*m.exp(-u**2-v**2) + ]),u_min = -PI, u_max = PI, v_min = -PI, v_max = PI).set_color(TEAL).shift([0,0,0]).fade(0.4) + + d1 = Dot(color = YELLOW).shift([0.5,0.5,3.02]) #---- critical point for maxima + l1 = Line([0.5,0.5,0.1],[0.5,0.5,3],color = YELLOW) + + d2 = Dot(color = YELLOW).shift([-1.15,0,-2.98]) #---- critical point for minima + l2 = Line([-1.15,0,0],[-1.15,0,-2.98],color = YELLOW) + + max_text = TextMobject("Relative Maximum").shift(3.1*UP+1.5*RIGHT).scale(0.5) + min_text = TextMobject("Relative Minimum").shift(3.1*DOWN+1.5*LEFT).scale(0.5) + + self.add_fixed_in_frame_mobjects(h_text) + self.wait(1) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) + self.set_camera_orientation(phi = 100*DEGREES, theta = -40*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(surface)) + self.wait(1) + self.play(Write(l1),Write(d1)) + self.add_fixed_in_frame_mobjects(max_text) + self.wait(1) + self.play(Write(l2),Write(d2)) + self.add_fixed_in_frame_mobjects(min_text) + self.wait(1) + self.wait(1) + self.play(FadeOut(l1),FadeOut(d1),FadeOut(l2),FadeOut(d2),FadeOut(max_text),FadeOut(min_text)) + self.begin_ambient_camera_rotation(rate = 0.3) + self.wait(3) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.gif Binary files differnew file mode 100644 index 0000000..7300f3a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.py new file mode 100644 index 0000000..67dbb18 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file5_Saddle_Point.py @@ -0,0 +1,71 @@ +from manimlib.imports import* +import math as m + +#---- saddle point of a function +class SaddlePoint(ThreeDScene): + def construct(self): + + h_text = TextMobject("Saddle Point",color = GREEN) + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + #---- 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 = [BLUE_B,BLUE_C,BLUE_D,BLUE_E]).shift([0,0,0]).scale(3) + + #---- curve(trace) along y axis + curve_x = ParametricSurface( + lambda u, v: np.array([ + u*0.1, + v, + v**2 + ]),v_min = -1, v_max = 1, u_min = -0.2, u_max = 0.2).shift([0,0,-2]).scale(3.1).set_color("#800000").rotate(m.radians(180),UP) + + x_text = TextMobject("A dip at critical point along x axis").scale(0.5).to_corner(UL) + + #---- curve(trace) along x axis + curve_y = ParametricSurface( + lambda u, v: np.array([ + u, + v*0.1, + -u**2 + ]),v_min = -0.2, v_max = 0.2, u_min = -1, u_max = 1).scale(3).shift([0.1,0,2.2]).set_color("#800000").rotate(m.radians(182),DOWN) + + y_text = TextMobject("A peak at critical point along y axis").scale(0.5).to_corner(UL) + + d = Dot(color = YELLOW).shift([0,-0.22,0]) #---- critical point(saddle point) + + self.add_fixed_in_frame_mobjects(h_text) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) + self.set_camera_orientation(phi = 75*DEGREES, theta = 40*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(surface)) + self.wait(1) + self.move_camera(phi = 45*DEGREES, theta = 70*DEGREES) + self.add(curve_y) + self.play(Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(x_text) + self.wait(1) + self.wait(1) + self.play(FadeOut(curve_y),FadeOut(d),FadeOut(x_text)) + self.wait(1) + self.move_camera(phi = 40*DEGREES, theta = 30*DEGREES) + self.add(curve_x) + self.play(Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(y_text) + self.begin_ambient_camera_rotation(rate = 0.3) + self.wait(3) + self.play(FadeOut(curve_x),FadeOut(d),FadeOut(y_text)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x,y)=(y-x)(1-2x-3y).gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x,y)=(y-x)(1-2x-3y).gif Binary files differnew file mode 100644 index 0000000..4bc92f8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x,y)=(y-x)(1-2x-3y).gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x,y)=(y-x)(1-2x-3y).py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_f(x,y)=(y-x)(1-2x-3y).py new file mode 100644 index 0000000..41c3b61 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical-Points/file6_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/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif Binary files differnew file mode 100644 index 0000000..9d64d50 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py new file mode 100644 index 0000000..da17aac --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x,y)=k.py @@ -0,0 +1,57 @@ +from manimlib.imports import* +import math as m + +#---- optimizing funtion f(x,y) w.r.t to g(x,y) +class ConstrainedExtrema(ThreeDScene): + def construct(self): + axes = ThreeDAxes().fade(0.4) + label_x = TextMobject("$x$").shift([5.5,-0.5,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u**2+v**2+u**3-v**3 + ]),u_min=-0.5,u_max=0.5, v_min=-0.5,v_max=0.5).scale(5).shift([0,1,2.5]).set_color(TEAL).fade(0.4) + + c = Circle().set_color('#FF00FF').shift([-0.4,0,1.5]).rotate(1.9,UP).scale(0.7) + + minima = Dot(color = '#4169E1').shift([-0.5,0.5,1]).rotate(1.571,UP) + maxima = Dot(color = '#4169E1').shift([0.1,0,2.2]).rotate(1.571,UP) + + l1 = DashedLine([-0.5,0.5,0.9],[-0.5,0.5,0],color = '#F08080') + l2 = DashedLine([0.1,0,2.1],[0.1,0,0],color = '#F08080') + + c2 = Circle(fill_opacity= 0.5).shift([-0.3,0.2,0]).scale(0.4) + + minima_refl = Dot(color = '#4682B4').shift([-0.5,0.5,0]).rotate(1.571,UP) + maxima_refl = Dot(color = '#4682B4').shift([0.1,0,0]).rotate(1.571,UP) + + max_text = TextMobject("maximum over $g(x,y)=k$",color = '#FFA074').shift([-1.7,0,0]).scale(0.5).shift(2.2*UP) + min_text = TextMobject("minimum over $g(x,y)=k$",color = '#FFA074').shift([2.5,0.5,1]).scale(0.5).shift(0.5*UP) + label_f = TextMobject("$z=f(x,y)$",color = '#8A2BE2').scale(0.5).shift(3*UP+3*RIGHT) + label_g = TextMobject("$g(x,y)=k$",color = '#8A2BE2').scale(0.5).shift(2*RIGHT) + + self.add(axes) + self.add(label_x) + self.add(label_y) + self.set_camera_orientation(phi=75*DEGREES,theta=45*DEGREES) + self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(label_f) + self.wait(2) + self.play(Write(c)) + self.wait(1) + self.play(Write(maxima)) + self.add_fixed_in_frame_mobjects(max_text) + self.wait(1) + self.play(Write(minima)) + self.add_fixed_in_frame_mobjects(min_text) + self.wait(1) + self.play(ShowCreation(l1),ShowCreation(l2)) + self.play(Write(c2)) + self.add_fixed_in_frame_mobjects(label_g) + self.wait(1) + self.play(Write(maxima_refl)) + self.play(Write(minima_refl)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.py new file mode 100644 index 0000000..2c2a9de --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Geometric_Proof.py @@ -0,0 +1,90 @@ +from manimlib.imports import* + +#---- visualization of geometric proof of Lagrange multiplier +class GeometricProof(ThreeDScene): + def construct(self): + axes = ThreeDAxes().scale(0.7).rotate(math.radians(180)) + label_x = TextMobject("$x$").shift(4*RIGHT).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift(3.2*DOWN+0.2*RIGHT).rotate(math.radians(180)).fade(0.4) #---- y axis + + surface = ParametricSurface( + lambda u, v: np.array([ + 1*np.sin(u)*np.cos(v), + 1*np.sin(u)*np.sin(v), + -1*np.sin(u)*np.sin(u)+2 + ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[GREEN_C, GREEN_E]).scale(1).shift([-1.5,-1.5,0]) + + d = Dot([-2,-2.55,0],color = '#800000') + a_df = Arrow(color = '#00FFFF').rotate(-2).shift(3.2*DOWN+2.3*LEFT) #---- f parallel to g at maxima + a_dg = Arrow(color = '#FF00FF').scale(0.8).shift(3.2*DOWN+2.3*LEFT).rotate(-2) #---- g parallel to f at maxima + + b_dg = Arrow(color = '#00FFFF').rotate(1.1).shift(0.82*LEFT+0.15*UP) #---- g parallel to f at minima + b_df = Arrow(color = '#FF00FF').scale(0.6).rotate(-2).shift(1.43*LEFT+1.1*DOWN) #---- f parallel to g at minima + + + qd = Dot(color = '#800000').shift(1.2*LEFT+0.6*DOWN) + + #---- level curves + l1 = Line([-1,-3.1,0],[-4,-3.1,0],color = PINK).rotate(-0.3).fade(0.6) + l2 = Line([-0.9,-2.9,0],[-4,-2.9,0],color = PINK).rotate(-0.3).fade(0.6) + l3= Line([-0.8,-2.7,0],[-4,-2.7,0],color = PINK).rotate(-0.3).fade(0.6) + l4= Line([-0.7,-2.45,0],[-4,-2.45,0],color = PINK).rotate(-0.3).fade(0.6) + l5= Line([-0.6,-2.2,0],[-4,-2.25,0],color = PINK).rotate(-0.3).fade(0.6) + l6 = Line([-0.5,-2,0],[-4,-2,0],color = PINK).rotate(-0.3).fade(0.6) + l7 = Line([-0.4,-1.8,0],[-4,-1.8,0],color = PINK).rotate(-0.3).fade(0.6) + l8 = Line([-0.3,-1.6,0],[-4,-1.6,0],color = PINK).rotate(-0.3).fade(0.6) + l9= Line([-0.2,-1.4,0],[-4,-1.4,0],color = PINK).rotate(-0.3).fade(0.6) + l10= Line([-0.1,-1.2,0],[-4,-1.2,0],color = PINK).rotate(-0.3).fade(0.6) + l11 = Line([-0,-1,0],[-4,-1,0],color = PINK).rotate(-0.3).fade(0.6) + l12 = Line([-0,-0.8,0],[-4,-0.8,0],color = PINK).rotate(-0.3).fade(0.6) + l13= Line([-0,-0.55,0],[-4,-0.55,0],color = PINK).rotate(-0.3).fade(0.6) + l14= Line([-0,-0.35,0],[-4,-0.35,0],color = PINK).rotate(-0.3).fade(0.6) + l15= Line([-0.,-0.15,0],[-4,-0.15,0],color = PINK).rotate(-0.3).fade(0.6) + + rel_text = TextMobject("$\\nabla f = \\lambda \\nabla g$",color = TEAL).shift([3,3.2,0]).scale(0.5) + + f_text = TextMobject("$\\nabla f$",color = '#800000').shift([1,1,0]).scale(0.5) + g_text = TextMobject("$\\nabla g$").shift([1.2,-0.8,0]).scale(0.5) + + p_text= TextMobject("$P$").shift([1.8,2.6,0]).scale(0.5) + + #---- labelling of level curves + l1_text = TextMobject("$w=$ 17").rotate(math.radians(180)).scale(0.4).shift(2.7*DOWN+4.36*LEFT) + l2_text = TextMobject("$w=$ 16").rotate(math.radians(180)).scale(0.4).shift(2.46*DOWN+4.36*LEFT) + l3_text = TextMobject("$w=$ 15").rotate(math.radians(180)).scale(0.4).shift(2.2*DOWN+4.36*LEFT) + l4_text = TextMobject("$w=$ 14").rotate(math.radians(180)).scale(0.4).shift(1.97*DOWN+4.36*LEFT) + l5_text = TextMobject("$w=$ 13").rotate(math.radians(180)).scale(0.4).shift(1.74*DOWN+4.36*LEFT) + l6_text = TextMobject("$w=$ 12").rotate(math.radians(180)).scale(0.4).shift(1.5*DOWN+4.36*LEFT) + l7_text = TextMobject("$w=$ 11").rotate(math.radians(180)).scale(0.4).shift(1.26*DOWN+4.36*LEFT) + l8_text = TextMobject("$w=$ 10").rotate(math.radians(180)).scale(0.4).shift(1.05*DOWN+4.36*LEFT) + l9_text = TextMobject("$w=$ 9").rotate(math.radians(180)).scale(0.4).shift(0.8*DOWN+4.32*LEFT) + l10_text = TextMobject("$w=$ 8").rotate(math.radians(180)).scale(0.4).shift(0.6*DOWN+4.32*LEFT) + l11_text = TextMobject("$w=$ 7").rotate(math.radians(180)).scale(0.4).shift(0.4*DOWN+4.32*LEFT) + l12_text = TextMobject("$w=$ 6").rotate(math.radians(180)).scale(0.4).shift(0.2*DOWN+4.32*LEFT) + l13_text = TextMobject("$w=$ 5").rotate(math.radians(180)).scale(0.4).shift(-0.02*DOWN+4.32*LEFT) + l14_text = TextMobject("$w=$ 4").rotate(math.radians(180)).scale(0.4).shift(-0.23*DOWN+4.32*LEFT) + l15_text = TextMobject("$w=$ 3").rotate(math.radians(180)).scale(0.4).shift(-0.44*DOWN+4.32*LEFT) + + level_Curve = VGroup(l1,l1_text,l2,l2_text,l3,l3_text,l4,l4_text,l5,l5_text,l6,l6_text,l7,l7_text,l8,l8_text,l9,l9_text,l10,l10_text,l11,l11_text,l12,l12_text,l13,l13_text,l14,l14_text,l15,l15_text) + + self.set_camera_orientation(phi=0 * DEGREES, theta = 90*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(surface)) + self.wait(1) + self.play(ShowCreation(level_Curve)) + self.wait(1) + self.play(ShowCreation(a_df),ShowCreation(a_dg),Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(rel_text) + self.add_fixed_in_frame_mobjects(p_text) + self.wait(1) + self.play(Write(qd)) + self.wait(1) + self.play(ShowCreation(b_df)) + self.add_fixed_in_frame_mobjects(f_text) + self.wait(1) + self.play(ShowCreation(b_dg)) + self.add_fixed_in_frame_mobjects(g_text) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.gif Binary files differnew file mode 100644 index 0000000..9602283 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.py new file mode 100644 index 0000000..bf75dd8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Optimizing_function_w.r.t_one_constraint.py @@ -0,0 +1,29 @@ +from manimlib.imports import* + +class firstScene(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + cylinder = ParametricSurface( + lambda u, v: np.array([ + np.cos(TAU * v), + np.sin(TAU * v), + 2 * (u) + ]),checkerboard_colors=[YELLOW_C,YELLOW_D,YELLOW_E] + ).fade(0.4) #Resolution of the surfaces + + plane = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u+v + ]),checkerboard_colors=[TEAL_C,TEAL_D,TEAL_E] + ).scale(2.5) + self.add(axes) + self.set_camera_orientation(phi=75*DEGREES,theta=45*DEGREES) + self.play(Write(cylinder)) + self.play(Write(plane)) + self.wait(1) + self.begin_ambient_camera_rotation(rate=0.7) + self.wait(5) + self.move_camera(phi=35*DEGREES,theta=-45*DEGREES) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif Binary files differnew file mode 100644 index 0000000..2b8bf5f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.py new file mode 100644 index 0000000..4c17f90 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.gif Binary files differnew file mode 100644 index 0000000..d23405d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py new file mode 100644 index 0000000..d1ecf8c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py @@ -0,0 +1,74 @@ +from manimlib.imports import* + +#---- tangent plane is parallel to the x-y plane +class MaximaScene(ThreeDScene): + def construct(self): + + axes = ThreeDAxes().scale(1.2) + label_x= TextMobject("$x$").shift([5.4,-0.5,0]) #---- x axis + label_y= TextMobject("$y$").shift([-0.5,5.2,0]).rotate(-4.5) #---- y axis + + #---- graph of the function + s = ParametricSurface( + lambda u, v: np.array([ + 1.5*np.cos(u)*np.cos(v), + 1.5*np.cos(u)*np.sin(v), + 1.5*np.sin(u) + ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI,checkerboard_colors=[BLUE_B,BLUE_C,BLUE_D,BLUE_E]).scale(1.5).shift([-0.8,0.5,1.5]) + + d1 = Dot([0.2,2.01,2.24],color = '#800000').rotate(1.1,LEFT) #---- point(x_0,y_0) + d1_copy = Dot([1.1,2.2,-0.45],color = '#800000') #---- projection of point(x_0,y_0) on x-y plane + d1_text = TextMobject("$(x_0,y_0)$",color = "#8B0000").scale(0.4).shift(1.3*RIGHT+1.1*UP) + + d2 = Dot([1.1,2.2,2.7],color = '#800000').rotate(1,LEFT) #---- point(x,y) + d2_copy = Dot([0.1,1.95,0.4],color = '#800000') #---- projection of point(x,y) on x-y plane + d2_text = TextMobject("$(x,y)$",color = "#8B0000").scale(0.4).shift(0.6*RIGHT+0.8*UP) + + t_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(1,LEFT).shift([1.1,2.5,2.9]) #---- tangent plane + + t_text= TextMobject("Tangent Plane",color = RED).scale(0.5).shift(0.3*RIGHT+1.3*UP).rotate(math.radians(5),LEFT) + + l1 = Line([1.1,2.2,2.6],[1.1,2.2,-0.45]).fade(0.2) + l2 = Line([0.1,1.95,2.05],[0.1,1.95,0.4]).fade(0.2) + + a1 = Line([0.1,1.95,0.4],[1.1,2.2,-0.45],color ="#00FF7F") + a_x = Line([0.1,1.95,0.4],[1.7,1.95,0.4],color ="#9400D3") + a_y = Line([0.1,1.95,0.4],[0.1,2.75,0.4],color ="#8B4513") + a2 = Line([1.7,1.95,0.4],[1.7,2.75,0.4]) + a3 = Line([0.1,2.75,0.4],[1.7,2.75,0.4]) + + #---- transition of tangent plane + + t2_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(1,LEFT).shift([1.1,2.5,2]) + t3_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(math.radians(180),LEFT).shift([1.1,2.5,2]) + t4_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.4).rotate(math.radians(180),LEFT).shift([0.9,2.35,0.4]) + + #------------------------------------------- + self.set_camera_orientation(phi = 50 * DEGREES, theta = 45 * DEGREES) + self.wait(1) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(s)) + self.wait(1) + self.play(Write(d1)) + self.add_fixed_in_frame_mobjects(d1_text) + self.play(ShowCreation(t_plane)) + self.add_fixed_in_frame_mobjects(t_text) + self.wait(1) + self.play(FadeOut(t_text),Write(d2)) + self.add_fixed_in_frame_mobjects(d2_text) + self.wait(1) + self.play(Write(l1),Write(l2)) + self.play(Write(d2_copy),Write(d1_copy)) + self.wait(1) + self.play(Write(a1),Write(a_x),Write(a_y)) + self.wait(1) + self.play(Write(a2),Write(a3)) + self.wait(1) + self.play(ReplacementTransform(t_plane,t2_plane)) + self.wait(1) + self.play(ReplacementTransform(t2_plane,t3_plane)) + self.wait(1) + self.play(ReplacementTransform(t3_plane,t4_plane)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.gif Binary files differnew file mode 100644 index 0000000..7581a33 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.py new file mode 100644 index 0000000..79d0948 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.py @@ -0,0 +1,47 @@ +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().rotate(2.3) + axes2 = ThreeDAxes().scale(2).rotate(2.3).shift([0,0,1.3]) + + #----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) + + #----size increased of f(x,y): sqrt(x**2+y**2) + p2 = 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(3).shift([0,0,0]) + + self.set_camera_orientation(phi = 75 * DEGREES,theta = 40*DEGREES) + + d = Dot([0,0,0],color = '#800000') #---- critical point + d2 = Dot([0,0,1.5],color = '#800000').scale(2) #---- size increased of critical point + + f_text = TextMobject("$f$ is not differentiable at origin,because the surface").scale(0.5).to_corner(UL) + f2_text = TextMobject("is not flat when zoomed in at the origin.").scale(0.5).to_corner(UL).shift(0.5*DOWN) + + self.add(axes) + self.wait(1) + self.play(Write(p),Write(d)) + self.wait(1) + self.move_camera(phi = 50 * DEGREES,theta = 40*DEGREES) + self.wait(1) + self.play(ReplacementTransform(axes,axes2),ReplacementTransform(p,p2),ReplacementTransform(d,d2)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + self.add_fixed_in_frame_mobjects(f2_text) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_extrema_and_saddle_point.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_extrema_and_saddle_point.gif Binary files differnew file mode 100644 index 0000000..cfe054b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent plane_at_extrema_and_saddle_point.gif diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.py index f9055e6..d129213 100644 --- a/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.py @@ -1,12 +1,9 @@ -from manimlib.imports import * +from manimlib.imports import* -class TypescpAnimation(ThreeDScene): +class TangenttoSurface(ThreeDScene): def construct(self): - axes = ThreeDAxes() + axes = ThreeDAxes() - r_text = TextMobject("Relative Maximum at ORIGIN",color ='#87CEFA') - f_text = TextMobject("$f(x,y) = -x^2-y^2$").to_corner(UL) - #----graph of first function f(x,y) = -x**2-y**2 f = ParametricSurface( lambda u, v: np.array([ @@ -15,9 +12,7 @@ class TypescpAnimation(ThreeDScene): -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) - - r2_text = TextMobject("Saddle Point at ORIGIN",color ='#87CEFA') - f2_text = TextMobject("$f(x,y) = -x^2+y^2$").to_corner(UL) + 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( @@ -27,9 +22,7 @@ class TypescpAnimation(ThreeDScene): -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) - - r3_text = TextMobject("Relative Minimum at ORIGIN",color ='#87CEFA') - f3_text = TextMobject("$f(x,y) = x^2+y^2$").to_corner(UL) + 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( @@ -39,32 +32,31 @@ class TypescpAnimation(ThreeDScene): 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 + d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point - self.add_fixed_in_frame_mobjects(r_text) - self.wait(1) - self.play(FadeOut(r_text)) + 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.wait(2) - self.play(FadeOut(axes),FadeOut(f),FadeOut(f_text),FadeOut(d)) - - self.add_fixed_in_frame_mobjects(r2_text) + self.play(ShowCreation(r)) + self.wait(1) + self.play(FadeOut(r),FadeOut(f),FadeOut(d),FadeOut(f_text)) self.wait(1) - self.play(FadeOut(r2_text)) - self.add(axes) self.play(Write(f2),Write(d)) + self.wait(1) self.add_fixed_in_frame_mobjects(f2_text) - self.wait(2) - self.play(FadeOut(axes),FadeOut(f2),FadeOut(f2_text),FadeOut(d)) - - self.add_fixed_in_frame_mobjects(r3_text) + self.play(ShowCreation(r)) + self.wait(1) + self.play(FadeOut(r),FadeOut(f2),FadeOut(d),FadeOut(f2_text)) self.wait(1) - self.play(FadeOut(r3_text)) - self.add(axes) self.play(Write(f3),Write(d)) + self.wait(1) self.add_fixed_in_frame_mobjects(f3_text) - self.wait(2) + self.play(ShowCreation(r)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/README.md new file mode 100644 index 0000000..96b32bf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/README.md @@ -0,0 +1,27 @@ +<h1><div align=”center”><b>SubTopic: The Second Derivative Test</b></h1></div> +<br/></br> + +<tab>file1_Second_order_partial_derivatives + +![file1_Second_order_partial_derivatives](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file2_Nondegenerate_Hessian_Matrix + +![file2_Nondegenerate_Hessian_Matrix](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file3_Degenerate_Hessian_Matrix + +![file3_Degenerate_Hessian_Matrix](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file4_Contour_Diagram + +![file4_Contour_Diagram](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif?raw=true) +<br/></br> +<br/></br> + diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif Binary files differnew file mode 100644 index 0000000..3471e4d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file1_Second_order_partial_derivatives.py b/FSF-2020/calculus-of-several-variables/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/calculus-of-several-variables/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/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.gif Binary files differnew file mode 100644 index 0000000..0d58b4f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.py new file mode 100644 index 0000000..32c1559 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file2_Nondegenerate_Hessian_Matrix.py @@ -0,0 +1,158 @@ +from manimlib.imports import* +import math as m + +class Minima(ThreeDScene): + def construct(self): + + heading = TextMobject("Nondegenerate Hessian Matrix",color = BLUE) + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + h_text = TextMobject("Case 1: $\\frac{\\partial^2 f}{\\partial x^2}>0$ and $\\frac{\\partial^2 f}{\\partial y^2}>0$").scale(1) + + #---- determiniant of Hessian Matrix + hessian_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + -0.5*m.exp(-u**2-v**2) + ]),u_min = -PI, u_max = PI, v_min = -PI, v_max =PI).set_color(TEAL).shift([0,0,0]).scale(1).fade(0.2) + + det_text= TextMobject("$det \\hspace{1mm} H = (\\frac{\\partial^2 f}{\\partial x^2})(\\frac{\\partial^2 f}{\\partial y^2})-(\\frac{\\partial^2 f}{\\partial x \\partial y})^2 $").to_corner(UL).scale(0.7) + + #---- function f(x,y) + f_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u**2+v**2 + ]),u_min = -1.3, u_max = 1.3, v_min = -1.3, v_max = 1.3).set_color(TEAL).shift([0,0,-0.5]) + + f_text= TextMobject("surface of the function").to_corner(UL).scale(0.8) + + d = Dot(color = "#800000").shift([0,0,-0.52]) #---- critical point + + self.set_camera_orientation(phi = 75*DEGREES, theta = 40*DEGREES) + self.add_fixed_in_frame_mobjects(heading) + self.wait(1) + self.play(FadeOut(heading)) + self.wait(1) + self.add_fixed_in_frame_mobjects(h_text) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(hessian_surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(det_text) + self.move_camera(phi = 90*DEGREES, theta= 60*DEGREES) + self.play(Write(d)) + self.wait(1) + self.play(FadeOut(det_text),ReplacementTransform(hessian_surface,f_surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + self.wait(1) + self.play(FadeOut(f_text),FadeOut(f_surface),FadeOut(axes),FadeOut(label_x),FadeOut(label_y),FadeOut(d)) + +class Maxima(ThreeDScene): + def construct(self): + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + h_text = TextMobject("Case 2: $\\frac{\\partial^2 f}{\\partial x^2}<0$ and $\\frac{\\partial^2 f}{\\partial y^2}<0$").scale(1) + + #---- determiniant of Hessian Matrix + hessian_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + 0.5*m.exp(-u**2-v**2) + ]),u_min = -PI, u_max = PI, v_min = -PI, v_max =PI).set_color(TEAL).shift([0,0,0]).scale(1).fade(0.2) + + det_text= TextMobject("$det \\hspace{1mm} H = (\\frac{\\partial^2 f}{\\partial x^2})(\\frac{\\partial^2 f}{\\partial y^2})-(\\frac{\\partial^2 f}{\\partial x \\partial y})^2 $").to_corner(UL).scale(0.7) + + #---- function g(x,y) + g_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + -u**2-v**2 + ]),u_min = -1.3, u_max = 1.3, v_min = -1.3, v_max = 1.3).set_color(TEAL).shift([0,0,0.5]) + + g_text= TextMobject("surface of the function").to_corner(UL).scale(0.8) + + d = Dot(color = "#800000").shift([0,0,0.5]) #---- critical point + + self.set_camera_orientation(phi = 75*DEGREES, theta = 40*DEGREES) + self.add_fixed_in_frame_mobjects(h_text) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(hessian_surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(det_text) + self.play(Write(d)) + self.wait(1) + self.play(FadeOut(det_text),ReplacementTransform(hessian_surface,g_surface)) + self.wait(1) + self.add_fixed_in_frame_mobjects(g_text) + self.wait(1) + self.play(FadeOut(g_text),FadeOut(g_surface),FadeOut(axes),FadeOut(label_x),FadeOut(label_y),FadeOut(d)) + +class SaddlePoint(ThreeDScene): + def construct(self): + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + h_text = TextMobject("Case 3: $\\frac{\\partial^2 f}{\\partial x^2}$ and $\\frac{\\partial^2 f}{\\partial y^2}$ have opposite signs").scale(1) + + #---- determiniant of Hessian Matrix + hessian_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + m.exp(0.5*u**2-0.5*v**2) + ]),u_min = -1.2, u_max = 1.2, v_min = -2.5, v_max = 2.5).set_color(TEAL).shift([0,0,-1]).scale(1).fade(0.2) + + det_text= TextMobject("$det \\hspace{1mm} H = (\\frac{\\partial^2 f}{\\partial x^2})(\\frac{\\partial^2 f}{\\partial y^2})-(\\frac{\\partial^2 f}{\\partial x \\partial y})^2 $").to_corner(UL).scale(0.7) + + #---- function p(x,y) + p_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).set_color(TEAL).shift([0,0,0]).scale(2) + + p_text= TextMobject("surface of the function").to_corner(UL).scale(0.8) + + d = Dot(color = "#800000").shift([0,0,0]) #---- critical point + + self.set_camera_orientation(phi = 80*DEGREES, theta = 60*DEGREES) + self.add_fixed_in_frame_mobjects(h_text) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.play(Write(hessian_surface)) + self.play(Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(det_text) + self.wait(2) + self.play(FadeOut(det_text),ReplacementTransform(hessian_surface,p_surface)) + self.add_fixed_in_frame_mobjects(p_text) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.gif Binary files differnew file mode 100644 index 0000000..5aae300 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.py new file mode 100644 index 0000000..9310553 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file3_Degenerate_Hessian_Matrix.py @@ -0,0 +1,45 @@ +from manimlib.imports import* +import math as m + +class DegenerateHessian(ThreeDScene): + def construct(self): + + heading = TextMobject("Degenerate Hessian Matrix",color = BLUE) + + h_text = TextMobject("For $det \\hspace{1mm} H = 0$, the surface of the function at the critical point would be flat.").scale(0.7) + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]) #---- x axis + label_y = TextMobject("$y$").shift([-0.3,5.5,0]).rotate(-4.5) #---- y axis + + #---- function f(x,y) + f_surface = ParametricSurface( + lambda u, v: np.array([ + u, + v, + -u**4-v**4 + ]),u_min = -0.8, u_max = 0.8, v_min = -0.8, v_max = 0.8).set_color(TEAL).shift([0,0,-0.5]).scale(2) + + f_text= TextMobject("surface of the function").to_corner(UL).scale(0.5) + + d = Dot(color = "#800000").shift([0,0,-0.5]) #---- critical point + plane = Square(color = YELLOW,fill_opacity= 0.2).shift([0,0,-0.5]).scale(1.3) + + self.set_camera_orientation(phi = 70*DEGREES, theta = 45*DEGREES) + self.add_fixed_in_frame_mobjects(heading) + self.wait(1) + self.play(FadeOut(heading)) + self.add_fixed_in_frame_mobjects(h_text) + self.wait(2) + self.play(FadeOut(h_text)) + self.wait(1) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(f_surface)) + self.add_fixed_in_frame_mobjects(f_text) + self.wait(1) + self.play(Write(d)) + self.wait(1) + self.play(Write(plane)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif Binary files differnew file mode 100644 index 0000000..41068e2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The-Second-Derivative-Test/file4_Contour_Diagram.py new file mode 100644 index 0000000..d3084e2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/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) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/README.md new file mode 100644 index 0000000..ce4da11 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/README.md @@ -0,0 +1,34 @@ +<h1><div align=”center”><b>SubTopic: Total Differential</b></h1></div> +<br/></br> + +<tab>file1_Visualization_of_dz + +![file1_Visualization_of_dz](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file2_Differentials + +![file2_Differentials](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.gif?raw=true) + +<br/></br> +<br/></br> + +<tab>file3_Total_differential_of_z + +![file3_Total_differential_of_z](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file4_total_differential_change + +![file4_total_differential_change](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file5_Total_differential_approximation + + ![file5_Total_differential_approximation](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.gif?raw=true) + +<br/></br> +<br/></br> diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.gif Binary files differnew file mode 100644 index 0000000..2e148af --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.py new file mode 100644 index 0000000..1fdd0b9 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file1_Visualization_of_dz.py @@ -0,0 +1,59 @@ +from manimlib.imports import* + +#---- visualization of total differential dz between two points lying on the surface of the function +class differentialdz(ThreeDScene): + + def construct(self): + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.5,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + #---- surface of the funtion f(x,y) + 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).set_color("#FF69B4").fade(0.6).scale(2).shift(3*UP+1*LEFT) + + d = Dot([1.4,1.75,1],color = '#00FFFF').rotate(1.571,UP) #---- point on the surface + d2 = Dot([2,2,1],color = '#00FFFF').rotate(1.571,UP) #---- point on the surface + + p1 = TextMobject("$P_1$",color ='#ADFF2F').scale(0.6).shift(2*RIGHT+1*UP) + p2 = TextMobject("$P_2$",color = '#ADFF2F').scale(0.6).shift(2.6*RIGHT+0.9*UP) + + l = DashedLine(color = '#800000').rotate(1.571,UP).scale(1).shift(1.7*UP+1.6*RIGHT) + l2 = DashedLine(color = '#800000').rotate(1.571,UP).scale(0.8).shift(2.26*UP+1.2*RIGHT) + + l_text = TextMobject("$(x_1,y_1)$",color = '#ADFF2F').scale(0.6).shift(2*RIGHT+1.6*DOWN) + l2_text = TextMobject("$(x_2,y_2)$",color = '#ADFF2F').scale(0.6).shift(2.7*RIGHT+1.2*DOWN) + + a = Arrow(color = '#FFFACD').scale(0.7).rotate(1.38,RIGHT).shift(2.5*LEFT+3.1*UP) + + a_text = TextMobject("$dz$",color='#800000').scale(0.5).shift(2.3*RIGHT+0.5*UP) + + plane = Rectangle(color = '#E6E6FA',fill_opacity = 1).scale(3).shift(1*RIGHT+3*UP).fade(0.9) + + label = TextMobject("$z = f(x,y)$").scale(0.6).shift(3.5*RIGHT+1.8*UP) + + self.set_camera_orientation(phi=75*DEGREES,theta=-10*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.play(Write(plane)) + self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(label) + self.wait(1) + self.play(ShowCreation(l),ShowCreation(l2),Write(d),Write(d2)) + self.wait(1) + self.add_fixed_in_frame_mobjects(p1) + self.add_fixed_in_frame_mobjects(p2) + self.wait(1) + self.add_fixed_in_frame_mobjects(l_text) + self.add_fixed_in_frame_mobjects(l2_text) + self.play(ShowCreation(a)) + self.wait(1) + self.add_fixed_in_frame_mobjects(a_text) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.gif Binary files differnew file mode 100644 index 0000000..6baf271 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.py new file mode 100644 index 0000000..1025210 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file2_Differentials.py @@ -0,0 +1,77 @@ +from manimlib.imports import* + +#---- visualization of the differentials along the axes +class differentials(ThreeDScene): + def construct(self): + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + 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).set_color("#FF69B4").shift([0,2.5,0.3]).scale(1.2) #----surface z = f(x,y) + + + + plane = Rectangle(color = '#E6E6FA',fill_opacity = 1).scale(3).shift(-1*RIGHT+3*UP).fade(0.9) + + d = Dot([1,2,1],color = '#9400D3').rotate(1.571,UP) + d2 = Dot([2,2.9,1],color = '#9400D3').rotate(1.571,UP) + + p1 = TextMobject("$P_1$",color ='#ADFF2F').scale(0.6).shift(2*RIGHT+1*UP) + p2 = TextMobject("$P_2$",color = '#ADFF2F').scale(0.6).shift(2.6*RIGHT+0.4*UP) + + + l1 = DashedLine(color = '#00BFFF').scale(1.6).shift(3.5*UP+3.25*LEFT).rotate(1.571) + l2 = DashedLine(color = '#00BFFF').scale(1).shift(4*UP+2*LEFT).rotate(1.571) + + label_dz= TextMobject("$dz$").scale(0.4).shift(5.3*RIGHT+0.4*UP) + + + l3 = Line(color = '#FFDAB9').scale(0.8).shift(1.95*UP+0.7*RIGHT).rotate(1.571,DOWN).fade(0.2) + l4 = Line(color = '#FFDAB9').scale(0.6).shift(2.86*UP+0.9*RIGHT).rotate(1.571,DOWN).fade(0.2) + + line_y1 = DashedLine(color = '#00BFFF').scale(1.3).shift(0.82*UP+3.25*RIGHT).rotate(1.571) + line_y2 = DashedLine(color = '#00BFFF').scale(1.7).shift(1.2*UP+2.8*RIGHT).rotate(1.571) + + label_dy= TextMobject("$dy$").scale(0.6).shift(3*RIGHT+0.8*DOWN).rotate(math.radians(90)) + + line_x1 = DashedLine(color = '#00BFFF').scale(1.5).shift(2.2*UP+1.6*RIGHT).rotate(1.571,RIGHT) + line_x2 = DashedLine(color = '#00BFFF').scale(1.2).shift(2.9*UP+1.6*RIGHT).rotate(1.571,RIGHT) + + label_dx= TextMobject("$dx$").scale(0.4).shift(-0.4*UP+2.5*RIGHT) + + label = TextMobject("$f(x,y)$").scale(0.6).shift(4*RIGHT+3*UP) + + + self.set_camera_orientation(phi=75*DEGREES,theta=10*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.play(Write(plane)) + self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(label) + self.wait(1) + self.play(Write(d),Write(d2)) + self.add_fixed_in_frame_mobjects(p1) + self.add_fixed_in_frame_mobjects(p2) + self.wait(1) + self.play(Write(l1)) + self.play(Write(l2)) + self.add_fixed_in_frame_mobjects(label_dz) + self.wait(1) + self.play(Write(l3)) + self.play(Write(l4)) + self.wait(1) + self.play(Write(line_y1)) + self.play(Write(line_y2)) + self.play(ShowCreation(label_dy)) + self.wait(1) + self.play(Write(line_x1)) + self.play(Write(line_x2)) + self.add_fixed_in_frame_mobjects(label_dx) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.gif Binary files differnew file mode 100644 index 0000000..a54d2da --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.py new file mode 100644 index 0000000..b8d6f96 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file3_Total_differential_of_z.py @@ -0,0 +1,100 @@ +from manimlib.imports import* + +#---- visualization of total differential definition +class totaldifferential(ThreeDScene): + def construct(self): + axes = ThreeDAxes().fade(0.5) + 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).set_color("#FF69B4").fade(0.6).shift([1,0.8,1.5]).scale(2) + + plane = Rectangle(color = '#E6E6FA',fill_opacity = 1).scale(3).shift(-1*RIGHT+3*UP).fade(0.9) + label_x = TextMobject("$x$").shift(5*RIGHT+0.4*DOWN).rotate(1.571) + label_y = TextMobject("$y$").shift(0.3*DOWN+5.6*RIGHT).scale(0.5) + label_z = TextMobject("$z$").shift(3.5*UP+0.2*LEFT).scale(0.5) + + s1 = Square(color = '#00FF00',fill_opacity=0.4).shift([1,1,0]) + s2 = Square(color = '#00FF00',fill_opacity=0.4).shift([1,1,3]).scale(0.95) + + l1 = Line([2,0,3],[2,0,0],color = '#FFFACD') + l2 = Line([0,2,3],[0,2,0],color = '#FFFACD') + l3 = Line([2,1.95,3],[2,2,0],color = '#FFFACD') + + d1 = Dot([2,0,1.5],color = '#FFD700').rotate(1.571,UP) + d1_text = TextMobject("$P1$").scale(0.4).shift(1.2*LEFT+1.1*UP) + + d2 = Dot([0,2,3],color = '#FFD700').rotate(1.571,UP) + d2_text = TextMobject("$P2$").scale(0.4).shift(2.3*RIGHT+3.1*UP) + + d3 = Dot([2,2,2],color = '#FFD700').rotate(1.571,UP) + d3_text = TextMobject("$Q$").scale(0.4).shift([1.6,-1,0]+2.5*UP) + + s3 = Square().shift([1,1,1.5]).scale(0.95) + s4 = Square().shift([1,1,2]).scale(0.95) + + m1_line = DashedLine([2,0,1.5],[2,2,2],color = '#87CEEB') + m2_line = DashedLine([2,2,2],[0,2,3],color = '#87CEEB') + + dx_line = Line([2,2,0],[4,2,0],color = '#00FF7F') + dy_line = Line([2,2,0],[2,4,0],color = '#00FF7F') + + dx = DashedLine([3.5,0,0],[3.5,2,0],color = '#87CEEB') + dy = DashedLine([0,3.5,0],[2,3.5,0],color = '#87CEEB') + + dx_text = TextMobject("$dx$").scale(0.8).shift([4,1,0]).rotate(1.571) + dy_text = TextMobject("$dy$").scale(0.8).shift([1,3.8,0]).rotate(math.radians(180)) + + parx_line = Line([0,2,1.5],[0,5,1.5],color = '#00FF7F') + parm_line = Line([0,2,2],[0,5,2],color = '#00FF7F') + pary_line = Line([0,2.1,3],[0,5,3],color = '#00FF7F') + + delx = DashedLine([0,4,2],[0,4,1.5],color = '#F0F8FF') + dely = DashedLine([0,4,3],[0,4,2],color = '#FAEBD7') + + dely_text = TextMobject("$\\frac{\\partial z}{\\partial y}dy$").shift(4.6*RIGHT+2.3*UP).scale(0.4) + delx_text = TextMobject("$\\frac{\\partial z}{\\partial x}dx$").shift(4.6*RIGHT+1.4*UP).scale(0.4) + + + self.set_camera_orientation(phi=75*DEGREES,theta=20*DEGREES) + self.add(axes) + self.play(Write(plane)) + self.play(ShowCreation(label_x)) + self.add_fixed_in_frame_mobjects(label_y) + self.add_fixed_in_frame_mobjects(label_z) + self.wait(1) + self.play(Write(surface)) + self.play(ShowCreation(d1)) + self.add_fixed_in_frame_mobjects(d1_text) + self.play(ShowCreation(d2)) + self.add_fixed_in_frame_mobjects(d2_text) + self.wait(1) + self.play(Write(s2)) + self.wait(1) + self.play(Write(l1),Write(l2),Write(l3)) + self.wait(1) + self.play(Write(s1)) + self.wait(1) + self.play(FadeOut(surface)) + self.play(ShowCreation(d3)) + self.add_fixed_in_frame_mobjects(d3_text) + self.play(ShowCreation(m1_line)) + self.play(ShowCreation(m2_line)) + self.wait(1) + self.play(ShowCreation(dx_line),ShowCreation(dx),ShowCreation(dx_text)) + self.wait(1) + self.play(ShowCreation(dy_line),ShowCreation(dy),ShowCreation(dy_text)) + self.wait(2) + self.play(Write(s3)) + self.play(Write(s4)) + self.wait(1) + self.play(ShowCreation(parx_line),ShowCreation(parm_line),ShowCreation(pary_line)) + self.wait(1) + self.play(ShowCreation(dely)) + self.add_fixed_in_frame_mobjects(dely_text) + self.wait(1) + self.play(ShowCreation(delx)) + self.add_fixed_in_frame_mobjects(delx_text) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.gif Binary files differnew file mode 100644 index 0000000..f2227a8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.py new file mode 100644 index 0000000..78e41a2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file4_total_differential_change.py @@ -0,0 +1,54 @@ +from manimlib.imports import* + + +class firstScene(ThreeDScene): + + def construct(self): + + axes = ThreeDAxes() + + s = Rectangle(color = '#F08080',fill_opacity=1).fade(0.7).shift(1.9*UP+5*LEFT).scale(0.9)#----surface z = f(x,y) + + s2= Rectangle(color = '#F08080',fill_opacity=1).fade(0.7).shift(2.4*UP+3.1*RIGHT).scale(0.6) #----reflection of the surface on the x-y plane + + l1 = DashedLine(color = '#AFEEEE').rotate(1.571,UP).scale(1).shift(1.53*UP+1.5*RIGHT) + l2 = DashedLine(color = '#AFEEEE').rotate(1.571,UP).scale(1).shift(2.9*UP+1.4*RIGHT) + l3 = DashedLine(color = '#AFEEEE').rotate(1.571,UP).scale(1).shift(1.5*UP-1.6*RIGHT) + l4 = DashedLine(color = '#AFEEEE').rotate(1.571,UP).scale(1).shift(2.9*UP-1.75*RIGHT) + + + l1_text = TextMobject("$(x+\\triangle x,y)$").shift(RIGHT+1.7*DOWN).scale(0.4) + l2_text = TextMobject("$(x+\\triangle x,y+\\triangle y)$").shift(3*RIGHT+1.8*DOWN).scale(0.4) + l3_text = TextMobject("$f(x,y)$").shift(1.6*RIGHT+1.5*UP).scale(0.4) + l4_text = TextMobject("$(x,y+\\triangle y)$").shift(3.5*RIGHT+0.7*DOWN).scale(0.4) + + label_x = TextMobject("$x$").shift(5*RIGHT+0.4*DOWN) + label_y = TextMobject("$y$").shift(5*UP-0.6*RIGHT) + + self.add(axes) + self.set_camera_orientation(phi=75*DEGREES,theta=10*DEGREES) + self.wait(1) + self.play(ShowCreation(label_x),ShowCreation(label_y)) + self.play(Write(s)) + self.wait(1) + self.add_fixed_in_frame_mobjects(l3_text) + self.wait(1) + self.play(Write(l3)) + self.wait(1) + self.play(Write(l1)) + self.add_fixed_in_frame_mobjects(l1_text) + self.wait(1) + self.play(Write(l2)) + self.add_fixed_in_frame_mobjects(l2_text) + self.wait(1) + self.play(Write(l4)) + self.add_fixed_in_frame_mobjects(l4_text) + self.wait(1) + self.play(Write(s2)) + self.wait(1) + + + + + + diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.gif Binary files differnew file mode 100644 index 0000000..ebbf240 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.py new file mode 100644 index 0000000..e7b39bb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Total-Differential/file5_Total_differential_approximation.py @@ -0,0 +1,52 @@ +from manimlib.imports import* + +#---- approximation value of function between two points using total differentials +class approximation(ThreeDScene): + + def construct(self): + + axes = ThreeDAxes() + label_x = TextMobject("$x$").shift([5.5,-0.3,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([-0.5,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + surface = ParametricSurface( + lambda u, v: np.array([ + np.sin(u), + v, + -u**2-v + ]),u_min=-1,u_max=1, v_min=-1,v_max=1).set_color("#00008B").scale(2).shift(3.8*UP+2*LEFT) + + d = Dot([1.4,1.75,1],color = '#00FFFF').rotate(1.571,UP) + d2 = Dot([2,2,1],color = '#00FFFF').rotate(1.571,UP) + + l = DashedLine(color = '#800000').rotate(1.571,UP).scale(1).shift(1.7*UP+1.6*RIGHT) + l2 = DashedLine(color = '#800000').rotate(1.571,UP).scale(0.8).shift(2.26*UP+1.2*RIGHT) + + l_text = TextMobject("$(x_1,y_1)$",color = '#ADFF2F').scale(0.6).shift(2*RIGHT+1.6*DOWN) + l2_text = TextMobject("$(x_2,y_2)$",color = '#ADFF2F').scale(0.6).shift(2.7*RIGHT+1.2*DOWN) + + plane = Rectangle(color = '#E6E6FA',fill_opacity = 1).scale(3).shift(1*RIGHT+3*UP).fade(0.9) + + tangentplane = Rectangle(color = '#E6E6FA',fill_opacity = 1).scale(1.1).shift(2*LEFT+3.4*UP).fade(0.5).rotate(0.8,RIGHT) + tangentplane_text = TextMobject("Tangent Plane").scale(0.4).shift(3*RIGHT+1*UP) + + label = TextMobject("$z = f(x,y)$").scale(0.6).shift(4*RIGHT+3*UP) + + self.set_camera_orientation(phi=75*DEGREES,theta=-10*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.play(Write(plane)) + self.wait(1) + self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(label) + self.wait(1.5) + self.play(ShowCreation(l),ShowCreation(l2),Write(d),Write(d2)) + self.wait(1) + self.add_fixed_in_frame_mobjects(l_text) + self.add_fixed_in_frame_mobjects(l2_text) + self.wait(1) + self.play(Write(tangentplane)) + self.add_fixed_in_frame_mobjects(tangentplane_text) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/README.md index e69de29..b46936b 100644 --- a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/README.md +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/README.md @@ -0,0 +1,9 @@ +This repository contains the codes written by [Saarth Deshpande](https://github.com/saarthdeshpande) during the course of FOSSEE Summer Fellowship 2020 under the FLOSS: Mathematics using Python. + +__Sub-topics covered__: +* Equations of Planes and Lines +* General Parametric Curves +* Space Curves (an Intro to Coordinates in 3D) +* Velocity and Differentiability +* Finding Arc Length and Curvature +* TNB Frame and Serret-Frenet Formulae diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/README.md new file mode 100644 index 0000000..a2f71d7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/README.md @@ -0,0 +1,8 @@ +**file1_simple_visualization.py** <br> +![file1_simple_visualization.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif) + +**file2_circle_curvature.py** <br> +![file2_circle_curvature.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif) + +**file4_different_curvature_single_curve.py** <br> +![file4_different_curvature_single_curve.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif Binary files differnew file mode 100644 index 0000000..858a8de --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py new file mode 100644 index 0000000..7ab8908 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_simple_visualization.py @@ -0,0 +1,69 @@ +from manimlib.imports import * + +class randomcurve(GraphScene): + CONFIG = { + "x_min": -4, + "x_max": 6, + "y_min": -6, + "y_max": 10, + "graph_origin": ORIGIN + } + def construct(self): + intro = TextMobject('Consider the following curve.') + mid = TextMobject(r'Notice how the direction of the unit tangent vectors\\changes with respect to the arc length.') + outro = TextMobject(r'The rate of change of unit tangents with \\ respect to the arc length $ds$ is called curvature.\\Mathematically, curvature $ = k = \left|{\frac{dT}{ds}}\right|$') + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + tgt1 = Arrow((-2.2*XTD,-0.5*YTD,0),(-1*XTD,1,0)) + tgt2 = Arrow((-1.2*XTD, 1.93*YTD,0),(0*XTD,1.6,0)).scale(1.2) + tgt3 = Arrow((-0.3*XTD,3*YTD, 0), (1.5*XTD, 3*YTD,0)) + tgt4 = Arrow((1.4*XTD, 2*YTD,0),(2.4*XTD, 1*YTD,0)).scale(2.8) + tgt5 = Arrow((2.4*XTD, 0, 0), (3.8*XTD,-2*YTD, 0)).scale(1.2).shift(0.26*RIGHT) + tgt6 = Arrow((3.8*XTD,-1*YTD, 0), (4.8*XTD, -1*YTD, 0)).scale(2.8).shift(0.26*RIGHT) + tgt7 = Arrow((5.3*XTD, 0, 0),(6.3*XTD,1,0)).shift(0.35*LEFT+0.1*DOWN).scale(1.3) + + dot1 = Dot(tgt1.get_start(), color = RED) + dot2 = Dot(tgt2.get_start(), color = RED) + dot3 = Dot(tgt3.get_start(), color = RED) + dot4 = Dot(tgt4.get_start(), color = RED) + dot5 = Dot(tgt5.get_start(), color = RED) + dot6 = Dot(tgt6.get_start(), color = RED) + dot7 = Dot(tgt7.get_start(), color = RED) + + dots = VGroup(*[dot1, dot2, dot3, dot4, dot5, dot6, dot7]) + + ds = CurvedArrow((-4, 2, 0), (tgt1.get_start() + tgt2.get_start()) / 2, color = YELLOW) + ds_text = TextMobject(r'$ds$').next_to(ds, UP, buff = 0.1).shift(1.3*LEFT) + + self.setup_axes(hideaxes=True) + graphobj = self.get_graph(self.curve) + self.play(FadeIn(intro)) + self.wait(2) + self.play(FadeOut(intro)) + self.setup_axes(hideaxes=False) + self.play(ShowCreation(graphobj), FadeIn(dots), FadeIn(ds), FadeIn(ds_text)) + self.wait(1) + self.play(FadeOut(self.axes), FadeOut(graphobj),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) + self.wait(2) + self.play(FadeOut(mid)) + self.play(FadeIn(self.axes), FadeIn(graphobj), FadeIn(dots)) + + + + tangents = [tgt1, tgt2, tgt3, tgt4, tgt5, tgt6, tgt7] + for tangent in tangents: + self.play(ShowCreation(tangent), run_time = 0.2) + self.wait(1) + tangents = VGroup(*tangents) + self.play(FadeOut(self.axes), FadeOut(graphobj), FadeOut(tangents), FadeOut(dots)) + self.wait(1) + self.play(FadeIn(outro)) + self.wait(2) + self.play(FadeOut(outro)) + self.wait(1) + + + def curve(self, x): + return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif Binary files differnew file mode 100644 index 0000000..989a3b7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py new file mode 100644 index 0000000..232ac41 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_circle_curvature.py @@ -0,0 +1,27 @@ +from manimlib.imports import * + +class circleC(GraphScene): + CONFIG = { + "x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN, + "x_axis_width": 12, + "y_axis_height": 12 + } + def construct(self): + epiphany = TextMobject(r'Driving a vehicle on which of \\ the two paths would be easier?').scale(0.6).shift(3.5*LEFT + 3*UP) + outro = TextMobject(r'The larger path, due to its \\ smaller curvature, since $k = \frac{1}{R}$.').scale(0.6).shift(3.7*LEFT + 3*UP) + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + circle = Circle(radius = 2, color = BLUE) + circle2 = Circle(radius = 3, color = GREEN_E) + + self.setup_axes(hideaxes=True) + self.play(FadeIn(self.axes), Write(circle, run_time = 2), FadeIn(epiphany)) + self.play(Write(circle2, run_time = 3)) + self.play(ReplacementTransform(epiphany, outro)) + self.wait(2) + self.play(FadeOut(VGroup(*[self.axes, circle, circle2, epiphany, outro]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_intuition.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_intuition.gif Binary files differnew file mode 100644 index 0000000..0d6fdcf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_intuition.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif Binary files differnew file mode 100644 index 0000000..3b78b5f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py new file mode 100644 index 0000000..d71adda --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_different_curvature_single_curve.py @@ -0,0 +1,56 @@ +from manimlib.imports import * + +class GR(GraphScene): + CONFIG = { + "x_axis_label": "", + "y_axis_label": "", + "x_min": -4, + "x_max": 6, + "y_min": -6, + "y_max": 10, + "graph_origin": ORIGIN + } + + def construct(self): + + self.setup_axes() + def curve(x): + return 3 - (3653*x**2)/5292 + (2477*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (17*x**6)/63504 + + graph = FunctionGraph(curve, x_min=-3, x_max=6, stroke_width = 2, color = BLUE) + + tracker = ValueTracker(-3) + + text = TextMobject(r'The curvature at point $P_{1}$ is \\ lesser than that at point $P_{2}$: \\ as $\kappa = \frac{1}{R}$').shift(3.2*RIGHT+3*UP).scale(0.6) + + dot1 = Dot((0,3,0), color = YELLOW) + dot1label = TextMobject(r'$P_{1}$').next_to(dot1, UP+RIGHT, buff = 0.1) + dot2 = Dot((4,-1, 0), color = YELLOW) + dot2label = TextMobject(r'$P_{2}$').next_to(dot2, DOWN, buff = 0.1) + dots = VGroup(*[dot1, dot2, dot1label, dot2label]) + + def get_tangent_line(): + line = Line( + ORIGIN, 2 * RIGHT, + color=RED, + stroke_width=4, + ) + dx = 0.0001 + + x = tracker.get_value() + p0 = np.array([x-dx,curve(x-dx),0]) + p1 = np.array([x, curve(x), 0]) + p2 = np.array([x + dx, curve(x + dx), 0]) + + angle = angle_of_vector(p2 - p1) + line.rotate(angle) + line.move_to(p0) + return line + + line = always_redraw(get_tangent_line) + + self.add(graph,line, dots, text) + self.wait(1.2) + self.play(tracker.set_value, 6, rate_func=smooth, run_time=13) + self.play(FadeOut(VGroup(*[graph, self.axes, line, dots, text]))) + self.wait() diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/README.md new file mode 100644 index 0000000..29d2f6a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/README.md @@ -0,0 +1,14 @@ +**file1_line_eqn.py**<br> +![file1_line_eqn.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.gif) + +**file2_point_normal_form_plane.py**<br> +![file2_point_normal_form_plane.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.gif) + +**file3_intercept_form_plane.py**<br> +![file3_intercept_form_plane.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.gif) + +**file4_3d_plane.py**<br> +![file4_3d_plane.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.gif) + +**file5_vector_form_line.py**<br> +![file5_vector_form_line.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.gif Binary files differnew file mode 100644 index 0000000..a8a301a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.py new file mode 100644 index 0000000..402775b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file1_line_eqn.py @@ -0,0 +1,26 @@ +from manimlib.imports import * + +class three(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + self.set_camera_orientation(phi=14.25* DEGREES,theta=0*DEGREES,distance=8) + self.play(FadeIn(axes)) + + plane = ParametricSurface( + lambda u,v: np.array([ + 6, + 8*v, + 3*u + ]), u_min = -0.8, u_max = 0.8, fill_opacity = 0.4).rotate(45*DEGREES).move_to(ORIGIN).shift(RIGHT+UP) + d2text = TextMobject(r'$\mathbb{R}^{2}: y = mx + c$').shift(3*LEFT + 2*UP).rotate(np.pi/2) + d3text = TextMobject(r'$\mathbb{R}^{3}: y = mx + c$').shift(4*RIGHT+3*UP) + self.play(FadeIn(plane), FadeIn(d2text)) + self.wait(3) + self.play(FadeOut(d2text)) + self.move_camera(phi = 60*DEGREES, theta=45*DEGREES,run_time=3) + self.begin_ambient_camera_rotation(rate=0.02) + self.add_fixed_in_frame_mobjects(d3text) + self.play(FadeIn(d3text)) + self.wait(3) + self.play(FadeOut(d3text), FadeOut(plane), FadeOut(axes)) + self.wait() diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.gif Binary files differnew file mode 100644 index 0000000..e651be0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.py new file mode 100644 index 0000000..122a9ff --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file2_point_normal_form_plane.py @@ -0,0 +1,39 @@ +from manimlib.imports import * + +class pointnormal(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + normal = Arrow((0,-0.15,-0.25), (-3,0,3), color = YELLOW) + plane1 = Polygon(np.array([1,0,2]),np.array([-1,2.5,1]),np.array([-3,2,1]),np.array([-1,-1,2]), color = GREEN_E, fill_color = WHITE, fill_opacity=0.5) + plane2 = Polygon(np.array([1,0,2]),np.array([-1,2.5,1]),np.array([-3,2,1]),np.array([-1,-1,2]), color = BLUE, fill_color = WHITE, fill_opacity=0.3) + normalLabel = TextMobject(r'$\overrightarrow{n}$').shift((2,2.5,0)) + pointLabel = TextMobject(r'$P$').shift((2,1.2,0)) + xlabel = TextMobject(r'$x$').shift(4.5*LEFT + 1.7*DOWN) + ylabel = TextMobject(r'$y$').shift(4.5*RIGHT + 1.8*DOWN) + zlabel = TextMobject(r'$z$').shift(3.3*UP+0.5*RIGHT) + + normaltext = TextMobject(r'Consider an arbitrary \\ normal vector $\overrightarrow{n}$').scale(0.6).shift(2*UP + 2.5*LEFT) + planetext = TextMobject(r'A single vector is normal \\ to infinitely many planes.').scale(0.6).shift(2*UP + 2.5*LEFT) + pointtext = TextMobject(r'Given a fixed point $P$, \\ a plane is obtained as:').scale(0.6).shift(2*UP + 2.5*LEFT) + + point = Dot(color = RED).shift((1.6,1.3,0)) + self.play(FadeIn(axes)) + self.add_fixed_in_frame_mobjects(xlabel, ylabel, zlabel) + self.wait(1) + self.play(FadeIn(normal)) + self.add_fixed_in_frame_mobjects(normalLabel, normaltext) + self.play(FadeIn(normaltext)) + self.wait(2) + self.add_fixed_in_frame_mobjects(planetext) + self.play(ReplacementTransform(normaltext, planetext), run_time=0.01) + self.play(MoveAlongPath(plane1, normal), run_time = 6) + self.add_fixed_in_frame_mobjects(pointtext) + self.play(ReplacementTransform(planetext, pointtext)) + self.add_fixed_in_frame_mobjects(point, pointLabel) + self.wait(1) + self.play(Transform(plane1, plane2)) + self.wait(2) + self.play(FadeOut(axes), FadeOut(plane2), FadeOut(plane1), FadeOut(point), FadeOut(pointLabel), FadeOut(normal), FadeOut(normalLabel), FadeOut(planetext), FadeOut(pointtext), FadeOut(normaltext), FadeOut(VGroup(*[xlabel, ylabel, zlabel]))) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.gif Binary files differnew file mode 100644 index 0000000..a8b7d75 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.py new file mode 100644 index 0000000..258ac3c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file3_intercept_form_plane.py @@ -0,0 +1,29 @@ +from manimlib.imports import * + +class pointnormal(ThreeDScene): + def construct(self): + axes = ThreeDAxes(x_min = 0, y_min = 0, z_min = 0) + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + + plane1 = Polygon(np.array([2,-3,2.5]),np.array([-1.45,2,2.5]),np.array([-0.5,4.5,-0.1]),np.array([3.5,-1,-0.2]), fill_color = WHITE, fill_opacity=0.3) + + xlabel = TextMobject(r'$x$').shift(5*LEFT + 1.5*DOWN) + ylabel = TextMobject(r'$y$').shift(5*RIGHT + 1.5*DOWN) + zlabel = TextMobject(r'$z$').shift(3.3*UP + 0.5*LEFT) + + zintercept = Dot().shift(2.5*UP) + zinterceptlabel = TextMobject(r'$(0,0,c\prime)$').shift(2.8*UP + RIGHT).scale(0.7) + + yintercept = Dot().shift(3.7*RIGHT + 0.925*DOWN) + yinterceptlabel = TextMobject(r'$(0,b\prime ,0)$').shift(3.7*RIGHT+1.5*DOWN).scale(0.7) + + xintercept = Dot().shift(2.9*LEFT + 0.75*DOWN) + xinterceptlabel = TextMobject(r'$(a\prime ,0,0)$').shift(3*LEFT+1.3*DOWN).scale(0.7) + + self.play(FadeIn(axes), FadeIn(plane1)) + self.add_fixed_in_frame_mobjects(xlabel, ylabel, zlabel, zintercept, zinterceptlabel, yintercept, yinterceptlabel, xintercept, xinterceptlabel) + self.wait(2) + self.remove(zintercept, zinterceptlabel, yintercept, yinterceptlabel, xintercept, xinterceptlabel, xlabel, ylabel, zlabel) + self.begin_ambient_camera_rotation(rate=0.5) + self.wait(5) + self.play(FadeOut(axes), FadeOut(plane1)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.gif Binary files differnew file mode 100644 index 0000000..b4c259e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.py new file mode 100644 index 0000000..26ad825 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file4_3d_plane.py @@ -0,0 +1,49 @@ +from manimlib.imports import * + +class pointnormal(ThreeDScene): + CONFIG = { + 'x_axis_label': '$x$', + 'y_axis_label': '$y$' + } + def construct(self): + axes = ThreeDAxes() + axes.add(axes.get_axis_labels()) + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + + plane = Polygon( + np.array([2,0,2.7]), + np.array([0,0,0.4]), + np.array([-3.2,0,0.55]), + np.array([-3,-2,2.5]), + fill_color = WHITE, fill_opacity = 0.25) + + normal = Arrow((0.25,2,0), (1.5,3.5,0)) + normalLabel = TextMobject(r'$\overrightarrow{n}$').shift((1.5,2.8,0)) + + point = Dot(color = RED).shift((1.6,1.3,0)) + pointLabel = TextMobject(r'$P_{0}$').shift((2,1.2,0)) + + point2 = Dot(color = RED).shift((-0.2,1.8,0)) + point2Label = TextMobject(r'$P$').shift((-0.3,2,0)) + + arrow1 = Arrow((0,-0.25,-0.2), (-2.55,0,1), color = YELLOW).set_stroke(width=3) + arrow2 = Arrow((0,0,-0.25), (0.3,0,2), color = YELLOW).set_stroke(width=3) + res = Arrow((1.8,1.23,0),(-0.35,1.85,0), color = BLUE).set_stroke(width=3) + + arrow1label = TextMobject(r'$\overrightarrow{r_{0}}$').next_to(arrow2, UP).shift(RIGHT + 0.16*DOWN).scale(0.7) + arrow2label = TextMobject(r'$\overrightarrow{r}$').next_to(arrow2, UP).shift(0.7*LEFT).scale(0.7) + reslabel = TextMobject(r'$\overrightarrow{r} - \overrightarrow{r_{0}}$').next_to(arrow2, UP).shift(0.7*RIGHT + 1.2*UP).scale(0.7) + + self.play(FadeIn(axes), FadeIn(plane)) + self.wait(1) + self.add_fixed_in_frame_mobjects(normal, normalLabel) + self.wait(1) + self.add_fixed_in_frame_mobjects(point, pointLabel) + self.add_fixed_in_frame_mobjects(point2, point2Label) + self.play(Write(arrow1), Write(arrow2)) + self.add_fixed_in_frame_mobjects(arrow2label, arrow1label) + self.wait(1) + self.add_fixed_in_frame_mobjects(res, reslabel) + self.play(Write(res), FadeIn(reslabel)) + self.wait(1) + self.play(FadeOut(axes), FadeOut(plane), FadeOut(point), FadeOut(pointLabel), FadeOut(normal), FadeOut(normalLabel), FadeOut(point2), FadeOut(point2Label), FadeOut(arrow1label), FadeOut(arrow2label), FadeOut(reslabel), FadeOut(arrow1), FadeOut(arrow2), FadeOut(res))
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.gif Binary files differnew file mode 100644 index 0000000..b6fdb51 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.py new file mode 100644 index 0000000..e25c4eb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/equations-of-planes-and-lines/file5_vector_form_line.py @@ -0,0 +1,47 @@ +from manimlib.imports import * + +class line_(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + xlabel = TextMobject(r'$x$').shift(4.5*LEFT + 1.7*DOWN) + ylabel = TextMobject(r'$y$').shift(4.5*RIGHT + 1.8*DOWN) + zlabel = TextMobject(r'$z$').shift(3.3*UP+0.5*RIGHT) + + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + pointLabel = TextMobject(r'$P$').shift((2.28,2.12,0)).scale(0.7) + point = Dot(color = RED).shift((1.95,1.9,0)) + + vlabel = TextMobject(r'$\overrightarrow{v}$').shift((0.5,1.3,0)).scale(0.7) + + inf_text = TextMobject(r'Infinitely many lines pass \\ through a single point.').scale(0.6).shift(2*UP + 2.5*LEFT) + pointtext = TextMobject(r'Given a direction vector $\overrightarrow{v}$, \\ a line is obtained as:').scale(0.6).shift(2*UP + 2.5*LEFT) + + + line = Line((0.7,0.7,0), (2,3,0)).shift(0.06*UP+0.6*RIGHT) + v = Vector((0.8,1,0), color = GREEN_E) + #finalLine = Line((-1.56,0,0.5),(-4,0,2.42), color = YELLOW) + finalLine = Line((1,0.8,0),(3,3,0), color = YELLOW).shift(0.05*LEFT) + self.play(FadeIn(axes)) + self.add_fixed_in_frame_mobjects(zlabel, ylabel, xlabel) + self.wait(1) + self.add_fixed_in_frame_mobjects(point, pointLabel) + self.wait(1) + self.add_fixed_in_frame_mobjects(inf_text) + self.wait(1) + self.add_fixed_in_frame_mobjects(line) + + for i in range(9): + self.play(ApplyMethod(line.rotate, -np.pi/12), run_time = 0.7) + if i == 8: + self.add_fixed_in_frame_mobjects(pointtext) + self.play(ReplacementTransform(inf_text, pointtext)) + self.add_fixed_in_frame_mobjects(v, vlabel) + # if i == 13: + # self.add_fixed_in_frame_mobjects(pointtext) + + self.add_fixed_in_frame_mobjects(finalLine) + self.play(FadeIn(finalLine)) + self.play(Transform(line, finalLine), run_time = 4) + #self.play(FadeOut(line), FadeIn(finalLine)) + self.wait(1.5) + self.play(FadeOut(VGroup(*[axes, xlabel, ylabel, zlabel, finalLine, v, vlabel, point, pointLabel, pointtext, line]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/README.md new file mode 100644 index 0000000..8a47a0e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/README.md @@ -0,0 +1,11 @@ +**file1_parametric_circle..py** <br> +![file1_parametric_circle.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.gif) + +**file2_cycloid_manim.py** <br> +![file2_cycloid_manim.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.gif) + +**file3_brachistochrone.py** <br> +![file3_brachistochrone.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.gif) + +**file4_helix_visualization.py** <br> +![file4_helix_visualization.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.gif Binary files differnew file mode 100644 index 0000000..732b6bb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.py new file mode 100644 index 0000000..40b5150 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.py @@ -0,0 +1,78 @@ +from manimlib.imports import * + +class parametricCircle(ThreeDScene, GraphScene): + def construct(self): + self.x_min = -5 + self.y_min = -5 + self.graph_origin = ORIGIN + self.x_max = 5 + self.y_max = 5 + self.x_axis_label = "" + self.y_axis_label = "" + self.x_axis_width = 10 + self.y_axis_height = 10 + + axes = [] + + self.setup_axes() + self.axes.scale(0.5).shift(3*LEFT) + axes.append(self.axes) + self.setup_axes() + self.axes.scale(0.3).shift(3*RIGHT + 2*UP) + axes.append(self.axes) + self.setup_axes() + self.axes.scale(0.3).shift(3*RIGHT + 2*DOWN) + axes.append(self.axes) + + axes = VGroup(*axes) + t_value = ValueTracker(-3.14) + t_tex = DecimalNumber(t_value.get_value()).add_updater(lambda v: v.set_value(t_value.get_value())) + t_label = TexMobject("t = ") + group = VGroup(t_tex,t_label).shift(3*DOWN) + t_label.next_to(t_tex,LEFT, buff=0.2,aligned_edge=t_label.get_bottom()) + + asint_text = TextMobject(r'$x = a\sin{t}$').scale(0.7).shift(4*RIGHT + 3*UP) + xlabel1 = TextMobject(r'$x$').shift(3.3*RIGHT + 3.7*UP).scale(0.7) + tlabel1 = TextMobject(r'$t$').shift(4.8*RIGHT + 2*UP).scale(0.7) + up_text = VGroup(*[asint_text, xlabel1, tlabel1]) + asint = ParametricFunction( + lambda t: np.array([ + t, + np.sin(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = GREEN_E + ).shift(3*RIGHT + 2*UP).scale(0.4) + + acost_text = TextMobject(r'$y = a\cos{t}$').scale(0.7).shift(4*RIGHT + DOWN) + ylabel1 = TextMobject(r'$y$').shift(3.3*RIGHT+0.3*DOWN).scale(0.7) + tlabel2 = TextMobject(r'$t$').shift(4.8*RIGHT + 2*DOWN).scale(0.7) + down_text = VGroup(*[acost_text, ylabel1, tlabel2]) + acost = ParametricFunction( + lambda t: np.array([ + t, + np.cos(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = BLUE + ).shift(3*RIGHT + 2*DOWN).scale(0.4) + + up_dot = Dot(color = RED) + down_dot = Dot(color = RED) + circle_dot = Dot(color = RED) + + ylabel2 = TextMobject(r'$y$').scale(0.7).shift(3*UP + 3*LEFT) + xlabel2 = TextMobject(r'$x$').scale(0.7) + ellipse_text = TextMobject(r'$x = a\sin{t}$ \\ $y = a\cos{t}$').scale(0.7).shift(2*UP + 1.3*LEFT) + main_text = VGroup(*[xlabel2, ylabel2, ellipse_text]) + circle = ParametricFunction( + lambda t: np.array([ + np.cos(t), + np.sin(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = WHITE + ).shift(3*LEFT) + self.play(FadeIn(axes), FadeIn(asint), FadeIn(acost), FadeIn(circle), FadeIn(up_text), FadeIn(down_text), FadeIn(main_text), FadeIn(group)) + self.wait(1) + self.play(MoveAlongPath(up_dot, asint, run_time = 7), MoveAlongPath(down_dot, acost, run_time = 7), MoveAlongPath(circle_dot, circle, run_time = 7), t_value.set_value,3.14, rate_func=linear, run_time=7) + self.wait(1) + self.play(FadeOut(VGroup(*[axes, asint, acost, circle, up_text, down_text, main_text, up_dot, down_dot, circle_dot, group]))) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid.gif Binary files differnew file mode 100644 index 0000000..39656de --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.gif Binary files differnew file mode 100644 index 0000000..e68b841 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py new file mode 100644 index 0000000..7b6c0d1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file2_cycloid_manim.py @@ -0,0 +1,46 @@ +from manimlib.imports import * + +t_offset = 0 +c_t = 0 + +class cycloid(Scene): + def construct(self): + + cycl = ParametricFunction( + lambda t: np.array([ + t - np.sin(t), + 1 - np.cos(t), + 0 + ]), t_min = -2.75*np.pi, t_max = 3*np.pi, color = BLUE + ).shift(0.73*RIGHT) + wheel_radius = 1 + wheel_function_path = lambda x : 0 + wheel_radius + + line = FunctionGraph(lambda x : 0, color = BLACK) + wheel_path = FunctionGraph(wheel_function_path) + + velocity_factor = 0.25 + frame_rate = self.camera.frame_rate + self.dt = 1 / frame_rate + + wheel = Circle(color = BLACK, radius = 1) + dot = Dot(radius = 0.16, color = RED) + #dot.move_to(wheel.get_arc_center() + np.array([0,2,0])) + + def update_dot(mob,dt): + global t_offset,c_t + if dt == 0 and c_t == 0: + rate= - velocity_factor * self.dt + c_t += 1 + else: + rate = - dt*velocity_factor + if dt > 0: + c_t = 0 + mob.move_to(wheel.point_from_proportion(((t_offset + rate))%1)) + t_offset += rate + #self.add(mob.copy()) + + #dot.move_to(wheel.get_arc_center() + np.array([0,2,0])) + dot.add_updater(update_dot) + self.add(wheel,dot, line, cycl) + self.play(MoveAlongPath(wheel, wheel_path, run_time = 9, rate_func = linear)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.gif Binary files differnew file mode 100644 index 0000000..8daf4c0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.py new file mode 100644 index 0000000..633e500 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file3_brachistochrone.py @@ -0,0 +1,13 @@ +from manimlib.imports import * + +class brachistochrone(Scene): + def construct(self): + curve = ParametricFunction( + lambda t: np.array([ + 0.5*(t - np.sin(t)), + 0.5*(1 - np.cos(t)), + 0 + ]), t_max = np.pi + ).scale(5).rotate(540*DEGREES) + dot = Dot(color = RED, radius = 0.2) + self.play(FadeIn(curve), MoveAlongPath(dot, curve, run_time = 2)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.gif Binary files differnew file mode 100644 index 0000000..16d2509 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.py new file mode 100644 index 0000000..eddd3fe --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file4_helix_visualization.py @@ -0,0 +1,31 @@ +from manimlib.imports import * + +class helix_(ThreeDScene): + CONFIG = { + "x_min": -6, + "x_max": 6, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN + } + def construct(self): + axes = ThreeDAxes() + helix = ParametricFunction( + lambda t: np.array([ + 1.5*np.cos(TAU*t), + 1.5*np.sin(TAU*t), + 2*t + ]), t_min = -1, t_max = 2, color = RED + ) + cylinder = ParametricSurface( + lambda u, v: np.array([ + 1.5*np.cos(TAU*v), + 1.5*np.sin(TAU*v), + 2*u + ]), u_min = -1, u_max = 2, fill_opacity = -.4, fill_color = WHITE, color = WHITE + ) + self.set_camera_orientation(phi=60* DEGREES,theta=45*DEGREES) + self.play(FadeIn(axes), FadeIn(cylinder), ShowCreation(helix, run_time = 4)) + self.begin_ambient_camera_rotation(rate=0.5) + self.wait(5) + self.play(FadeOut(axes),FadeOut(helix), FadeOut(cylinder)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/README.md new file mode 100644 index 0000000..42f5df1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/README.md @@ -0,0 +1,11 @@ +**file1_parametric_ellipse.py** <br> +![file1_parametric_ellipse.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.gif) + +**file2_parametric_helix.py** <br> +![file2_parametric_helix.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.gif) + +**file3_circletosphere.py** <br> +![file3_circletosphere.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.gif) + +**file4_cone.py** <br> +![file4_cone.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.gif Binary files differnew file mode 100644 index 0000000..90c0349 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.py new file mode 100644 index 0000000..1ce29d7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file1_parametric_ellipse.py @@ -0,0 +1,78 @@ +from manimlib.imports import * + +class parametricEllipse(ThreeDScene, GraphScene): + def construct(self): + self.x_min = -5 + self.y_min = -5 + self.graph_origin = ORIGIN + self.x_max = 5 + self.y_max = 5 + self.x_axis_label = "" + self.y_axis_label = "" + self.x_axis_width = 10 + self.y_axis_height = 10 + + axes = [] + + self.setup_axes() + self.axes.scale(0.5).shift(3*LEFT) + axes.append(self.axes) + self.setup_axes() + self.axes.scale(0.3).shift(3*RIGHT + 2*UP) + axes.append(self.axes) + self.setup_axes() + self.axes.scale(0.3).shift(3*RIGHT + 2*DOWN) + axes.append(self.axes) + + axes = VGroup(*axes) + t_value = ValueTracker(-3.14) + t_tex = DecimalNumber(t_value.get_value()).add_updater(lambda v: v.set_value(t_value.get_value())) + t_label = TexMobject("t = ") + group = VGroup(t_tex,t_label).shift(3*DOWN) + t_label.next_to(t_tex,LEFT, buff=0.2,aligned_edge=t_label.get_bottom()) + + asint_text = TextMobject(r'$x = a\sin{t}$').scale(0.7).shift(4*RIGHT + 3*UP) + xlabel1 = TextMobject(r'$x$').shift(3.3*RIGHT + 3.7*UP).scale(0.7) + tlabel1 = TextMobject(r'$t$').shift(4.8*RIGHT + 2*UP).scale(0.7) + up_text = VGroup(*[asint_text, xlabel1, tlabel1]) + asint = ParametricFunction( + lambda t: np.array([ + t, + np.sin(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = GREEN_E + ).shift(3*RIGHT + 2*UP).scale(0.4) + + bcost_text = TextMobject(r'$y = b\cos{t}$').scale(0.7).shift(4*RIGHT + DOWN) + ylabel1 = TextMobject(r'$y$').shift(3.3*RIGHT+0.3*DOWN).scale(0.7) + tlabel2 = TextMobject(r'$t$').shift(4.8*RIGHT + 2*DOWN).scale(0.7) + down_text = VGroup(*[bcost_text, ylabel1, tlabel2]) + bcost = ParametricFunction( + lambda t: np.array([ + t, + 1.5*np.cos(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = BLUE + ).shift(3*RIGHT + 2*DOWN).scale(0.4) + + up_dot = Dot(color = RED) + down_dot = Dot(color = RED) + ellipse_dot = Dot(color = RED) + + ylabel2 = TextMobject(r'$y$').scale(0.7).shift(3*UP + 3*LEFT) + xlabel2 = TextMobject(r'$x$').scale(0.7) + ellipse_text = TextMobject(r'$x = a\sin{t}$ \\ $y = b\cos{t}$').scale(0.7).shift(2*UP + 1.3*LEFT) + main_text = VGroup(*[xlabel2, ylabel2, ellipse_text]) + ellipse = ParametricFunction( + lambda t: np.array([ + 1.5*np.cos(t), + np.sin(t), + 0 + ]), t_min = -np.pi, t_max = np.pi, color = WHITE + ).shift(3*LEFT) + self.play(FadeIn(axes), FadeIn(asint), FadeIn(bcost), FadeIn(ellipse), FadeIn(up_text), FadeIn(down_text), FadeIn(main_text), FadeIn(group)) + self.wait(1) + self.play(MoveAlongPath(up_dot, asint, run_time = 7), MoveAlongPath(down_dot, bcost, run_time = 7), MoveAlongPath(ellipse_dot, ellipse, run_time = 7), t_value.set_value,3.14, rate_func=linear, run_time=7) + self.wait(1) + self.play(FadeOut(VGroup(*[axes, asint, bcost, ellipse, up_text, down_text, main_text, up_dot, down_dot, ellipse_dot, group]))) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.gif Binary files differnew file mode 100644 index 0000000..4f349b1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.py new file mode 100644 index 0000000..3791752 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file2_parametric_helix.py @@ -0,0 +1,91 @@ +from manimlib.imports import * + +class parametricHelix(ThreeDScene, GraphScene): + def construct(self): + self.x_min = -5 + self.y_min = -4 + self.graph_origin = ORIGIN + self.x_max = 5 + self.y_max = 4 + self.x_axis_label = "" + self.y_axis_label = "" + self.x_axis_width = 10 + self.y_axis_height = 7.5 + ax1 = ThreeDAxes().scale(0.65).shift(2.6*RIGHT+DOWN+np.array([0,0,0.5])) + axes_group = [] + + self.setup_axes() + self.axes.shift(3*RIGHT + 2*UP).scale(0.3) + axes_group.append(self.axes) + + self.setup_axes() + self.axes.shift(3*RIGHT + 2*DOWN).scale(0.3) + axes_group.append(self.axes) + + axes_group = VGroup(*axes_group) + + asint_text = TextMobject(r'$x = a\sin{t}$').scale(0.7).shift(4*RIGHT + 3*UP) + xlabel1 = TextMobject(r'$x$').shift(3.3*RIGHT + 3.7*UP).scale(0.7) + tlabel1 = TextMobject(r'$t$').shift(5*RIGHT + 2*UP).scale(0.7) + up_text = VGroup(*[asint_text, xlabel1, tlabel1]) + asint = ParametricFunction( + lambda t: np.array([ + t, + np.sin(t), + 0 + ]), t_min = -4*np.pi, t_max = 4*np.pi, color = GREEN_E + ).shift(3*RIGHT + 2*UP).scale(0.12) + + acost_text = TextMobject(r'$y = a\cos{t}$').scale(0.7).shift(4*RIGHT + DOWN) + ylabel1 = TextMobject(r'$y$').shift(3.3*RIGHT+0.3*DOWN).scale(0.7) + tlabel2 = TextMobject(r'$t$').shift(5*RIGHT + 2*DOWN).scale(0.7) + down_text = VGroup(*[acost_text, ylabel1, tlabel2]) + acost = ParametricFunction( + lambda t: np.array([ + t, + np.cos(t), + 0 + ]), t_min = -4*np.pi, t_max = 4*np.pi, color = BLUE + ).shift(3*RIGHT + 2*DOWN).scale(0.12) + + up_dot = Dot(color = RED).scale(0.6) + down_dot = Dot(color = RED).scale(0.6) + helix_dot = Dot(radius = 0.16, color = RED) + + zlabel = TextMobject(r'$z$').scale(0.7).shift(3*UP + 2.8*LEFT) + ylabel2 = TextMobject(r'$y$').scale(0.7).shift(0.3*DOWN+0.15*RIGHT) + xlabel2 = TextMobject(r'$x$').scale(0.7).shift(0.5*DOWN + 6.4*LEFT) + helix_text = TextMobject(r'$x = a\sin{t}$ \\ $y = a\cos{t}$ \\ $z = ct$').scale(0.7).shift(2.3*UP + 1.3*LEFT) + main_text = VGroup(*[xlabel2, ylabel2, zlabel, helix_text]) + helix = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -2*np.pi/3, t_max = 1.8*np.pi/3, color = WHITE + ).shift(ax1.get_center()) + + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + + t_tracker = ValueTracker(-12.56) + t=t_tracker.get_value + + t_label = TexMobject( + "t = ",color=WHITE + ).next_to(helix_text,DOWN, buff=0.2).scale(0.6) + + t_text = always_redraw( + lambda: DecimalNumber( + t(), + color=WHITE, + ).next_to(t_label, RIGHT, buff=0.2) + ).scale(0.6) + + group = VGroup(t_text,t_label).scale(1.5).move_to(ORIGIN).shift(2*DOWN) + self.add_fixed_in_frame_mobjects(axes_group, main_text, up_text, down_text, acost, asint) + self.play(FadeIn(ax1), FadeIn(axes_group), FadeIn(asint), FadeIn(acost), FadeIn(helix), FadeIn(up_text), FadeIn(down_text), FadeIn(main_text)) + #self.begin_ambient_camera_rotation(rate = 0.06) + self.add_fixed_in_frame_mobjects(up_dot, down_dot, group) + self.play(MoveAlongPath(up_dot, asint, run_time = 8), MoveAlongPath(down_dot, acost, run_time = 8), MoveAlongPath(helix_dot, helix, run_time = 8), t_tracker.set_value,12.56, rate_func=linear, run_time=8) + self.play(FadeOut(VGroup(*[ax1, axes_group, asint, acost, helix, up_text, down_text, main_text, up_dot, down_dot, helix_dot, group]))) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.gif Binary files differnew file mode 100644 index 0000000..d6a8afc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.py new file mode 100644 index 0000000..6c0e810 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file3_circletosphere.py @@ -0,0 +1,45 @@ +from manimlib.imports import * + +class sphere(GraphScene, ThreeDScene): + CONFIG = { + 'x_min': -10, + 'x_max': 10, + 'y_min': -10, + 'y_max': 10, + 'graph_origin': ORIGIN, + "x_axis_width": 10, + "y_axis_height": 10, + } + def construct(self): + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + circleeqn = TextMobject(r'Hence, $x^{2} + y^{2} = 2(r^{2} - u^{2})$') + plottext = TextMobject(r'$x = \sqrt{r^{2} - u^{2}}cos\theta$ \\ $y = \sqrt{r^{2} - u^{2}}sin\theta$').shift(2*UP + 3*RIGHT) + + + self.setup_axes() + self.play(FadeIn(self.axes), FadeIn(plottext)) + + dots = [] + for t in range(19): + dot = Dot().shift((3*XTD*np.cos(t), 3*YTD*np.sin(t),0)) + dots.append(dot) + self.play(FadeIn(dot), run_time = 0.2) + dots = VGroup(*dots) + circle = Circle(radius = 3*XTD).set_color(WHITE).set_stroke(width = 10) + self.play(FadeIn(circle), FadeOut(dots), FadeOut(plottext)) + self.wait(2) + + + axes = ThreeDAxes(**self.CONFIG) + sph = Sphere(radius = 3).scale(0.5) + text2 = TextMobject(r'Setting $u = 3$,\\$z = u$').shift(4*YTD*UP + 5*XTD*RIGHT) + + self.play(Transform(self.axes,axes), ReplacementTransform(circle, sph)) + self.add(text2) + self.wait(2) + self.remove(text2) + self.move_camera(phi = 60*DEGREES, theta=45*DEGREES,run_time=5) + self.begin_ambient_camera_rotation(rate=0.03) + self.play(FadeOut(axes), FadeOut(sph), FadeOut(self.axes)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.gif Binary files differnew file mode 100644 index 0000000..b126d20 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.py new file mode 100644 index 0000000..e6ae1c6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/space-curves/file4_cone.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class cone(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + eqn = TextMobject(r'$z^{2} = x^{2} + y^{2}$') + + conecurve = ParametricFunction( + lambda t: np.array([ + t*np.cos(TAU*t), + t*np.sin(TAU*t), + t + ]), t_min = -2.6, t_max = 2.6 + ).scale(0.85) + + conesurface = ParametricSurface( + lambda u,v: np.array([ + 3*np.sin(u)*np.cos(TAU*v), + 3*np.sin(u)*np.sin(TAU*v), + 2.7*u + ]), u_min = -1 + ).scale(0.85) + + self.play(FadeIn(eqn)) + self.wait(2) + self.play(FadeOut(eqn)) + self.set_camera_orientation(phi = 75*DEGREES, theta=50*DEGREES) + self.play(FadeIn(axes), ShowCreation(conecurve, run_time = 3)) + self.play(FadeOut(conecurve), FadeIn(conesurface)) + self.begin_ambient_camera_rotation(rate=0.03) + self.wait(2) + self.play(FadeOut(axes), FadeOut(conesurface)) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/README.md new file mode 100644 index 0000000..34885b2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/README.md @@ -0,0 +1,2 @@ +**file2_tnb_frame_manim.py** <br> +![file2_tnb_frame_manim.py](https://github.com/saarthdeshpande/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_prescribed_plane.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_prescribed_plane.gif Binary files differnew file mode 100644 index 0000000..c8668e3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_prescribed_plane.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame.gif Binary files differnew file mode 100644 index 0000000..097652f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.gif Binary files differnew file mode 100644 index 0000000..784b6a6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.py new file mode 100644 index 0000000..ee5e717 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_frame_manim.py @@ -0,0 +1,125 @@ +from manimlib.imports import * + +class tnb(ThreeDScene): + def construct(self): + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + + t = TextMobject(r'T', color = YELLOW) + n = TextMobject(r'N', color = BLUE).next_to(t, RIGHT, buff=0) + b = TextMobject(r'B', color = GREEN_E).next_to(n, RIGHT, buff=0) + frame = TextMobject(r'Frame').next_to(b, RIGHT, buff=0.2) + + text = VGroup(*[t,n,b,frame]).move_to(ORIGIN).shift(3*UP) + + helix1 = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -2*np.pi/3, t_max = -1.638*np.pi/3, color = WHITE + ) + + helix2 = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -1.638*np.pi/3, t_max = -1.33*np.pi/3, color = WHITE + ) + + helix3 = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -1.33*np.pi/3, t_max = -np.pi/3, color = WHITE + ) + + helix4 = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -np.pi/3, t_max = -1.3*np.pi/6, color = WHITE + ) + + helix5 = ParametricFunction( + lambda t: np.array([ + np.cos(TAU*t), + np.sin(TAU*t), + 0.4*t + ]), t_min = -1.3*np.pi/6, t_max = 0, color = WHITE + ) + + helix_dot = Dot(radius = 0.16, color = RED) + + dot0 = Dot(np.array([np.cos(-2*np.pi/3), np.sin(-2*np.pi/3), -0.8*np.pi/3]), radius = 0.16, color=RED).shift(np.array([4.65,0,-0.8])) + tgt0 = Arrow((0,0,0), (1,2,0), color = YELLOW).shift(dot0.get_center() - np.array([0.04,0.2,0])) + nm0 = Arrow((0,0,0), (-2,1,0), color = BLUE).shift(dot0.get_center() + np.array([0.3,0,0])) + bnm0 = Arrow((0,0,0), (0,2,0), color = GREEN_E).shift(6.1*LEFT + 3*DOWN) + plane0 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot0.get_center() + np.array([-0.35, 0.85, 0])).scale(1.2).rotate(65*DEGREES) + point0 = VGroup(*[dot0, tgt0, nm0, bnm0, plane0]).scale(0.8).shift(np.array([1,0,0])) + + dot1 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([0,0.2,0]), radius = 0.16, color=RED) + tgt1 = Arrow((0,0,0), (-2,-0.55,0), color = YELLOW).shift(dot1.get_center() + np.array([0.18,0.04,0])) + nm1 = Arrow((0,0,0), (0.4,-2,0), color = BLUE).shift(dot1.get_center() + np.array([0,0.26,0])) + bnm1 = Arrow((0,0,0), (0,2,0), color=GREEN_E).shift(3.68*RIGHT+2.48*DOWN) + plane1 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot1.get_center() + np.array([-0.4, -0.6, 0])).rotate(13*DEGREES).scale(1.2) + point1 = VGroup(*[dot1, tgt1, nm1, plane1]).scale(0.8).shift(np.array([1,6.25,0])) + + dot2 = Dot(np.array([np.cos(-np.pi/6), np.sin(-np.pi/6), -0.2*np.pi/3]) - np.array([1.9,0,0]), radius=0.16,color=RED) + tgt2 = Arrow((0,0,0), (1,-2,0), color = YELLOW).shift(dot2.get_center() + np.array([-0.2,0.2,0])) + nm2 = Arrow((0,0,0), (2,1,0), color = BLUE).shift(dot2.get_center() + np.array([-0.2,-0.06,0])) + bnm2 = Arrow((0,0,0), (0,2,0), color=GREEN_E).shift(0.4*RIGHT + 0.16*DOWN) + plane2 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot2.get_center() + np.array([0.92, -0.5, 0])).rotate(23*DEGREES).scale(1.2) + point2 = VGroup(*[dot2, tgt2, nm2, bnm2, plane2]) + + helix = VGroup(*[helix1, helix2, helix3, helix4, helix5]) + self.add_fixed_in_frame_mobjects(text) + self.play(FadeIn(helix), FadeIn(text)) + self.play(ApplyMethod(helix.scale, 4)) + self.add_fixed_in_frame_mobjects(bnm0) + self.play(FadeIn(point0), MoveAlongPath(helix_dot, helix1, run_time=5)) + + self.add_fixed_in_frame_mobjects(bnm1) + self.play(ApplyMethod(point0.set_color, GRAY), FadeIn(point1)) + self.play(MoveAlongPath(helix_dot, helix2, run_time = 5)) + + self.add_fixed_in_frame_mobjects(bnm2) + self.play(ApplyMethod(point1.set_color, GRAY), ApplyMethod(bnm1.set_color, GRAY), FadeIn(point2)) + self.play(MoveAlongPath(helix_dot, helix3, run_time=5)) + + dot3 = Dot(np.array([np.cos(-np.pi/3), np.sin(-np.pi/3), -0.4*np.pi/3]) + np.array([3.3,-0.25,0]), radius = 0.16, color=RED) + tgt3 = Arrow((0,0,0), (0,2,0), color = YELLOW).shift(helix_dot.get_center() - np.array([-0.05,0.2,0])) + nm3 = Arrow((0,0,0), (-2,0,0), color = BLUE).shift(helix_dot.get_center() + np.array([0.25,0,0])) + bnm3 = Arrow((0,0,0), (0,2,0), color = GREEN_E).shift(3.87*LEFT + 1.24*DOWN) + plane3 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(helix_dot.get_center() + np.array([-0.5, 0.62, 0])) + point3 = VGroup(*[dot3, tgt3, nm3, bnm3, plane3]).shift(np.array([0,0,0])) + + dot4 = Dot(np.array([np.cos(-np.pi/12), np.sin(-np.pi/12), -0.1*np.pi/3]) + np.array([-3.4,3.4,0]), radius = 0.16, color=RED) + tgt4 = Arrow((0,0,0), (-2,-0.85,0), color = YELLOW).shift(dot4.get_center() - np.array([-0.05,0,0])) + nm4 = Arrow((0,0,0), (0.8,-2,0), color = BLUE).shift(dot4.get_center() + np.array([-0.1,0.25,0])) + bnm4 = Arrow((0,0,0), (0,2,0), color = GREEN_E).shift(4.03*RIGHT + 0.5*DOWN) + plane4 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot4.get_center() + np.array([-0.4,-1,0])).rotate(22*DEGREES).scale(1.2) + point4 = VGroup(*[dot4, tgt4, nm4, bnm4, plane4]) + + dot5 = Dot((1,0,0) + np.array([2.3,-1,1])) + tgt5 = Arrow((0,0,0), (0,2,0), color = YELLOW).shift(dot5.get_center() - np.array([-0.05,0.2,0])) + nm5 = Arrow((0,0,0), (-2,0,0), color = BLUE).shift(dot5.get_center() + np.array([0.25,0,0])) + bnm5 = Arrow((0,0,0), (0,2,0), color = GREEN_E).shift(3.34*LEFT+0.3*UP) + plane5 = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).shift(dot5.get_center() + np.array([-0.5,0.5,0])) + point5 = VGroup(*[tgt5, nm5, bnm5, plane5]) + + self.add_fixed_in_frame_mobjects(bnm3) + self.play(ApplyMethod(point2.set_color, GRAY), FadeIn(point3)) + self.play(MoveAlongPath(helix_dot, helix4, run_time=5)) + + self.add_fixed_in_frame_mobjects(bnm4) + self.play(ApplyMethod(point3.set_color, GRAY), FadeIn(point4)) + self.play(MoveAlongPath(helix_dot, helix5, run_time=5)) + + self.add_fixed_in_frame_mobjects(bnm5) + self.play(ApplyMethod(point4.set_color, GRAY), FadeIn(point5)) + self.wait(2) + + self.play(FadeOut(VGroup(*[helix, bnm1, point0, point1, point2, point3, point4, point5, helix_dot]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md new file mode 100644 index 0000000..bc571c6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md @@ -0,0 +1,2 @@ +**file2_tangent_space_curve.py** <br> +![file2_tangent_space_curve.py](https://raw.githubusercontent.com/saarthdeshpande/FSF-mathematics-python-code-archive/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file1_smooth_curves.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file1_smooth_curves.gif Binary files differnew file mode 100644 index 0000000..5801796 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file1_smooth_curves.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif Binary files differnew file mode 100644 index 0000000..06ed70f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py new file mode 100644 index 0000000..67c675e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_tangent_space_curve.py @@ -0,0 +1,22 @@ +from manimlib.imports import * + +class tangent(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + self.set_camera_orientation(phi = 125*DEGREES, theta = 135*DEGREES) + h = ParametricFunction( + lambda t: np.array([ + 4*(t**3) + 5, + t**2 + 2*(t**4), + -2*np.log(2*t) + ]), t_min = -3, t_max = 1.18 + ).shift(5*LEFT) + tgtR = Line((4,3,-2*np.log(2)), (19.5, 16, -4.772588), color=YELLOW) + tgtL =Line((4,3,-2*np.log(2)), (-11.5, -10, 2), color=YELLOW) + dot = Dot((4,3,-2*np.log(2)), color=RED, radius=0.08) + self.play(FadeIn(axes),FadeIn(h), FadeIn(dot)) + self.begin_ambient_camera_rotation(rate=0.4) + self.wait(2) + self.play(FadeIn(tgtL), FadeIn(tgtR)) + self.wait(5) + self.play(FadeOut(axes), FadeOut(h), FadeOut(dot), FadeOut(tgtL), FadeOut(tgtR)) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index a321caf..4de6c1d 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -1 +1,13 @@ FSF2020--Somnath Pandit
+
+# **Topics:**
+
+## Double Integral
+
+## Fubini's Theorem
+
+## Line Integrals
+
+## Fundamental Theorem of Line integrals
+
+## Vector Fields
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md new file mode 100644 index 0000000..5fa2146 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md @@ -0,0 +1,21 @@ +**file1_area_under_func** +![file1_area_under_func](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif) + +**file2_volume_under_surface** +![file2_volume_under_surface](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif) + +**file3_y_limit_dependent_on_x** +![file3_y_limit_dependent_on_x](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif) + +**file4_non_rect_region** +![file4_non_rect_region](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif) + +**file5_elementary_area** +![file5_elementary_area](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif) + +**file6_doing_integration** +![file6_doing_integration](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif) + +**file7_int_process_of_example** +![file7_int_process_of_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif) + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif Binary files differindex 223218b..223218b 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py index 773840c..773840c 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif Binary files differnew file mode 100644 index 0000000..1455573 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py new file mode 100644 index 0000000..38d41c6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py @@ -0,0 +1,349 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 7, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 5, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT + 5*LEFT, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 2+y/4+np.sin(x) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(distance=35, + phi=80 * DEGREES, + theta=-100 * DEGREES, + ) + + fn_text=TextMobject( + "$z=f(x,y)$", + color=PINK, + stroke_width=1.5 + ) + self.add_fixed_in_frame_mobjects(fn_text) + fn_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + riemann_sum_text=TextMobject( + r"The volume approximated as\\ sum of cuboids", + color=BLUE, + stroke_width=1.5 + ) + riemann_sum_text.to_corner(UR,buff=.2) + + R=TextMobject("R").set_color(BLACK).scale(3) + R.move_to(self.axes.input_plane,IN) + self.add(R) + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.8, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.06) + self.play(Write(surface)) + # self.add(surface) + + self.get_lines() + self.wait(1) + self.add_fixed_in_frame_mobjects(riemann_sum_text) + self.play(Write(riemann_sum_text)) + + cuboids1=self.show_the_riemmann_sum( + lambda x,y : np.array([x,y,self.Func(x,y)]), + fill_opacity=1, + dl=.5, + start_color=BLUE, + end_color=BLUE_E, + ) + self.play(ShowCreation(cuboids1),run_time=5) + self.play(FadeOut(surface)) + + cuboids2=self.show_the_riemmann_sum( + lambda x,y : np.array([x,y,self.Func(x,y)]), + fill_opacity=1, + dl=.25, + start_color=BLUE, + end_color=BLUE_E, + ) + self.play(ReplacementTransform( + cuboids1, + cuboids2 + )) + + cuboids3=self.show_the_riemmann_sum( + lambda x,y : np.array([x,y,self.Func(x,y)]), + fill_opacity=1, + dl=.1, + start_color=BLUE, + end_color=BLUE_E, + stroke_width=.1, + ) + self.play( + FadeOut(cuboids2), + ShowCreation(cuboids3), + ) + + self.wait(3) + + + + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"#9CDCEB")) + + labels=[ + (axes.a,0,0), + (axes.b,0,0), + (0,axes.d,0), + (0,axes.c,0) + ] + self.region_corners[-1]=self.region_corners[0] + for start , end in zip(labels,self.region_corners): + lines.add(self.draw_lines(start,end,"WHITE")) + + # self.add(lines) + self.play(ShowCreation(lines)) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + + def show_the_riemmann_sum( + self, + surface, + x_min=None, + x_max=None, + y_min=None, + y_max=None, + dl=.5, + stroke_width=.5, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + ): + x_min = x_min if x_min is not None else self.axes.a + x_max = x_max if x_max is not None else self.axes.b + y_min = y_min if y_min is not None else self.axes.c + y_max = y_max if y_max is not None else self.axes.d + + if start_color is None: + start_color = BLUE + if end_color is None: + end_color = BLUE + + cuboids = VGroup() + x_range = np.arange(x_min, x_max, dl) + y_range = np.arange(y_min, y_max, dl) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + for y in y_range: + sample_base = np.array([x ,y ,0]) + sample_base_dl = np.array([x + dl, y + dl,0]) + sample_input = np.array([x +0.5*dl, y +0.5*dl,0]) + + base_point = self.axes.c2p(*sample_base) + base_dx_point = self.axes.c2p(*sample_base_dl) + + surface_val= surface(*sample_input[:2]) + surface_point = self.axes.c2p(*surface_val) + + points = VGroup(*list(map(VectorizedPoint, [ + base_point, + surface_point, + base_dx_point + ]))) + + # self.add(points) + cuboid = Prism(dimensions=[dl,dl,surface_val[-1]]) + cuboid.replace(points, stretch=True) + + cuboid.set_fill(color, opacity=fill_opacity) + cuboid.set_stroke(stroke_color, width=stroke_width) + cuboids.add(cuboid) + + return cuboids + + +#------------------------------------------------------- + #customize 3d axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, RIGHT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.5, + fill_color=TEAL, + stroke_width=0, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("a", axes.a), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c), + ("d", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1.5) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + z_label.next_to(axes.z_axis.get_zenith(), RIGHT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif Binary files differnew file mode 100644 index 0000000..dcfacb6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py index 4894ebf..f755495 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py @@ -29,7 +29,7 @@ class YlimitXdependent(GraphScene): line_eqn=TextMobject("2x+y=2").move_to(self.graph_origin+.8*X+Y).rotate(np.arctan(-2)) self.line=line - caption=TextMobject(r"See the value of $y$ \\ is changing with $x$").move_to(self.graph_origin+1.2*X+1.8*Y) + caption=TextMobject(r"The value of $y$ is\\ changing with $x$").move_to(self.graph_origin+1.2*X+1.8*Y) self.play(ShowCreation(line),Write(line_eqn)) # self.show_area() self.show_rects() diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif Binary files differindex c8e7c8c..c8e7c8c 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py index 793a000..793a000 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif Binary files differindex 5c9ac03..5c9ac03 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py index 362b6f8..362b6f8 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif Binary files differnew file mode 100644 index 0000000..7a9271b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py new file mode 100644 index 0000000..5a8cec0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py @@ -0,0 +1,355 @@ +from manimlib.imports import * + +class IntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 7, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 4, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 2+y/4+np.cos(x/1.4) + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.camera.frame_center.shift(axes.c2p(3,4,1.7)) + self.set_camera_orientation(distance=35, + phi= 80 * DEGREES, + theta= -80 * DEGREES, + gamma = 0 * DEGREES + ) + + fn_text=TextMobject("$z=f(x,y)$").set_color(PINK) + self.add_fixed_in_frame_mobjects(fn_text) + + + R=TextMobject("R").set_color(BLACK).scale(3) + R.move_to(axes.input_plane,IN) + self.add(R) + + # get the surface + surface= self.get_surface( + axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=.65, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + fn_text.next_to(surface,UP,buff=MED_LARGE_BUFF) + slice_curve=(self.get_y_slice_graph( + axes,self.Func,5,color=YELLOW)) + + + self.begin_ambient_camera_rotation(rate=0.08) + # self.play(Write(surface)) + self.add(surface) + + self.get_lines() + + self.show_process(axes) + + self.wait(3) + + + + def show_process(self,axes): + y_tracker = ValueTracker(axes.c) + self.y_tracker=y_tracker + y=y_tracker.get_value + + graph = always_redraw( + lambda: self.get_y_slice_graph( + axes, self.Func, y(), + stroke_color=YELLOW, + stroke_width=4, + ) + ) + graph.suspend_updating() + + + plane = always_redraw(lambda: Polygon( + *[ + axes.c2p(x,y(),self.Func(x,y())) + for x in np.arange(axes.a,axes.b,0.01) + ], + *[ + axes.c2p(x, y(), 0) + for x in [ axes.b, axes.a,] + ], + stroke_width=2, + fill_color=BLUE_D, + fill_opacity=.4, + )) + + plane_side1 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.a,y,self.Func(axes.a,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.a, y, 0) + for y in [ y(),axes.c, ] + ], + stroke_width=2.5, + fill_color=BLUE_C, + fill_opacity=.2, + )) + plane_side2 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.b,y,self.Func(axes.b,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.b, y, 0) + for y in [y(),axes.c,] + ], + stroke_width=2.5, + fill_color=BLUE_E, + fill_opacity=.45, + )) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + self.play(Write(VGroup(graph,plane)),run_time=2) + self.add(plane.copy(),plane_side1,plane_side2) + + + plane_side1.resume_updating() + plane_side2.resume_updating() + + self.move_camera( + distance=30, + phi= 85 * DEGREES, + theta= -10 * DEGREES, + run_time=1.5 + ) + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + + + def get_y_slice_graph(self, axes, func, y, **kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": axes.a, + "t_max": axes.b, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda x: axes.c2p( + x, y, func(x, y) + ), + **config, + ) + return slice_curve + + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"RED")) + + labels=[ + (axes.a,0,0), + (axes.b,0,0), + (0,axes.d,0), + (0,axes.c,0) + ] + self.region_corners[-1]=self.region_corners[0] + for start , end in zip(labels, + self.region_corners): + lines.add(self.draw_lines(start,end,"WHITE")) + self.add(lines) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + +#------------------------------------------------------------ + #customize 3d axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, RIGHT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.5, + fill_color=TEAL, + stroke_width=0, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("a", axes.a), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c), + ("d", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1.5) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + z_label.next_to(axes.z_axis.get_zenith(), RIGHT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif Binary files differnew file mode 100644 index 0000000..9fbdde8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py new file mode 100644 index 0000000..f733761 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py @@ -0,0 +1,366 @@ +from manimlib.imports import * + +class IntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 5, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 3, + "a":0 ,"b":4 , "c":0 , "d":6, + "axes_shift":1.5*IN+2*LEFT+4*DOWN, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 2*(1+(x+y)/10) + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + self.set_camera_orientation(#distance=35, + phi=60 * DEGREES, + theta=10 * DEGREES, + ) + + fn_text=TextMobject("$z=(1+x+y)$").set_color(PINK) + self.add_fixed_in_frame_mobjects(fn_text) + fn_text.to_edge(TOP,buff=.1) + self.fn_text=fn_text + + R=TextMobject("R").set_color(BLACK).scale(3).rotate(PI/2) + R.move_to(axes.input_plane,IN) + self.add(R) + + #get the surface + surface= self.get_surface( + axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.75, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + slice_curve=(self.get_y_slice_graph( + axes,self.Func,5,color=YELLOW)) + + + self.begin_ambient_camera_rotation(rate=0.04) + # self.play(Write(surface)) + self.add(surface) + + self.get_lines() + + self.show_process(axes) + + self.wait() + + + + def show_process(self,axes): + y_tracker = ValueTracker(axes.c) + self.y_tracker=y_tracker + y=y_tracker.get_value + graph = always_redraw( + lambda: self.get_y_slice_graph( + axes, self.Func, y(), + stroke_color=YELLOW, + stroke_width=4, + ) + ) + graph.suspend_updating() + + plane = always_redraw(lambda: Polygon( + *[ + axes.c2p(x,y(),self.Func(x,y())) + for x in np.arange(axes.a,axes.b,0.01) + ], + *[ + axes.c2p(x, y(), 0) + for x in [ axes.b, axes.a,] + ], + stroke_width=0, + fill_color=BLUE_E, + fill_opacity=.65, + )) + plane_side1 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.a,y,self.Func(axes.a,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.a, y, 0) + for y in [ y(),axes.c, ] + ], + stroke_width=2.5, + fill_color=BLUE_C, + fill_opacity=.2, + )) + plane_side2 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.b,y,self.Func(axes.b,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.b, y, 0) + for y in [y(),axes.c,] + ], + stroke_width=2.5, + fill_color=BLUE_E, + fill_opacity=.45, + )) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + first_x_text=TextMobject("First the $x$ integration..",color=YELLOW) + first_x_text.to_corner(UR,buff=1.1) + + x_func=TextMobject("$\\frac 3 2 + y$",color=BLUE) + '''x_func.next_to(self.fn_text,DOWN) + x_func.align_to(self.fn_text,LEFT)''' + x_func.to_edge(LEFT,buff=1) + + then_y_text=TextMobject("Then the $y$ integration..",color=YELLOW) + then_y_text.to_corner(UR,buff=1.1) + + self.add_fixed_in_frame_mobjects(first_x_text) + self.play(Write(first_x_text)) + self.add_fixed_in_frame_mobjects(x_func) + self.play( + Write(VGroup(graph,plane,x_func)), + run_time=3 + ) + + self.wait() + self.remove(first_x_text) + self.add_fixed_in_frame_mobjects(then_y_text) + self.play(Write(then_y_text)) + self.add(plane.copy(),plane_side1,plane_side2) + graph.resume_updating() + plane.resume_updating() + plane_side1.resume_updating() + plane_side2.resume_updating() + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + + graph.suspend_updating() + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + + def get_y_slice_graph(self, axes, func, y, **kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": axes.a, + "t_max": axes.b, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda x: axes.c2p( + x, y, func(x, y) + ), + **config, + ) + return slice_curve + + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"RED")) + + labels=[ + (axes.a,0,0), + (axes.b,0,0), + (0,axes.d,0), + (0,axes.c,0) + ] + self.region_corners[-1]=self.region_corners[0] + for start , end in zip(labels, + self.region_corners): + lines.add(self.draw_lines(start,end,"WHITE")) + self.add(lines) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + +#------------------------------------------------------------ + #customize 3d axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=TEAL, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + + ("1", axes.b), + ] + tex_vals_y=[ + + ("2", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif Binary files differdeleted file mode 100644 index ae23a7b..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif +++ /dev/null diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif Binary files differdeleted file mode 100644 index a2bfd9d..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif +++ /dev/null diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md new file mode 100644 index 0000000..c1c6e8e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md @@ -0,0 +1,14 @@ + +**file1_surface1** +![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) + +**file2_surface2** +![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) + +**file3_iteration_methods** +![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) + +**file4_curvy_limits** +![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif Binary files differindex 8c9fa0a..8c9fa0a 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py index a590a53..a590a53 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif Binary files differnew file mode 100644 index 0000000..37c4b1d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py index c998f3b..3160fdb 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py @@ -63,7 +63,7 @@ class SurfacesAnimation(ThreeDScene): surface.set_style( fill_opacity=.5, fill_color=BLUE_E, - stroke_width=0.2, + stroke_width=0.4, stroke_color=WHITE, ) #get boundary curves @@ -85,17 +85,18 @@ class SurfacesAnimation(ThreeDScene): self.add(c1,c2,c1_label,c2_label) - self.begin_ambient_camera_rotation(rate=0.4) + self.begin_ambient_camera_rotation(rate=0.24) self.get_region(self.axes,c1,c2) self.play(Write(surface)) self.get_lines() - self.wait(1) + self.wait(3.5) self.stop_ambient_camera_rotation() + self.wait(.5) self.move_camera( distance=20, phi=10 * DEGREES, theta=80 * DEGREES, - run_time=2.5 + run_time=3 ) self.wait(2) @@ -128,7 +129,7 @@ class SurfacesAnimation(ThreeDScene): R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) R.move_to(region,IN+RIGHT) - self.play(Write(region)) + self.play(ShowCreation(region)) self.add(R) def get_surface(self,axes, func, **kwargs): @@ -279,8 +280,11 @@ class SurfacesAnimation(ThreeDScene): axes.z_axis.label = z_label for axis in axes: axis.add(axis.label) - return axes + return axes #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif Binary files differnew file mode 100644 index 0000000..2e507f9 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py new file mode 100644 index 0000000..55f91d3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py @@ -0,0 +1,226 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + # self.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.5, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_y_int,DOWN,buff=.5 + ).align_to( + caption_y_int,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + rects=self.get_rects() + + self.play(Write(caption_y_int)) + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + int_lim,RIGHT,buff=0)) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT)) + + self.show_area() + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + + def show_area(self): + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def get_rects(self): + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + return rects + + def show_integral_values_at_different_x(self): + rects=self.rects + rect = rects[len(rects)*1//10] + dx_brace = Brace(rect, DOWN, buff = 0) + dx_label = dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_group = VGroup(dx_brace,dx_label) + rp=int(len(rects)/10) + rects_subset = self.rects[4*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dx_brace_group.next_to, rect, DOWN, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif Binary files differnew file mode 100644 index 0000000..4e1611b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py new file mode 100644 index 0000000..ad78a0b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py @@ -0,0 +1,429 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + self.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_limit,DOWN,buff=.5 + ).align_to( + caption_limit,LEFT + ) + self.int_lim=int_lim + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + + self.play(Write(caption_limit)) + self.get_rects() + self.show_integral_values_at_different_x() + self.wait(1) + self.integral_setup(int_lim,first_y=True) + + + self.another_method_scene() + self.remove(self.area) + self.wait() + + c1_eqn_y=self.get_graph_label( + curve1, + label="x=\sqrt y", + x_val=.6, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + c2_eqn_y=self.get_graph_label( + curve2, + label="x=y", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.play( + ReplacementTransform(c1_eqn,c1_eqn_y), + ReplacementTransform(c2_eqn,c2_eqn_y) + ) + self.get_rects(base_y=True) + self.show_integral_values_at_different_y() + self.wait(1) + + int_lim_y=int_lim.copy() + int_lim_y.next_to(int_lim,DOWN) + self.int_lim_y=int_lim_y + equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) + self.add(equal) + + self.integral_setup(int_lim_y,first_y=False) + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + def another_method_scene(self): + text=TextMobject(r"The other method\\ of iteration") + text.next_to(self.curve1,UP,buff=-1) + self.play(GrowFromCenter(text)) + self.wait(2) + self.play(LaggedStart(FadeOut(text),lag_ratio=2)) + + def integral_setup(self,ref_object,first_y=True): + if first_y: + area=self.get_area() + self.area=area + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + ref_object,RIGHT,buff=0) + ) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT), + ShowCreation(area), + Write(self.int_lim),run_time=4 + ) + else: + area=self.get_area(base_y=True) + self.area=area + self.play( + FadeOut(self.y_brace_group), + Rotate(self.x_int,PI/2) + ) + self.play(ApplyMethod( + self.x_int.next_to, + ref_object,RIGHT,buff=0) + ) + self.play(ApplyMethod( + self.dy_label.next_to, + self.x_int,RIGHT), + ShowCreation(area), + Write(self.int_lim_y),run_time=4 + ) + + def get_area(self,base_y=False): + if base_y: + area = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_area = area + else: + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.area = area + + # self.transform_between_riemann_rects(self.rects,area) + return area + + def get_rects(self,base_y=False): + if base_y: + rects = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_rects=rects + else: + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.rects=rects + # self.transform_between_riemann_rects(self.area,rects) + + return rects + + def show_integral_values_at_different_x(self): + rects=self.rects + rect = rects[len(rects)*1//10] + dx_brace = Brace(rect, DOWN, buff = 0) + dx_label = dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_group = VGroup(dx_brace,dx_label) + rp=int(len(rects)/20) + rects_subset = rects[6*rp:7*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dx_brace_group.next_to, rect, DOWN, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + def show_integral_values_at_different_y(self): + rects=self.y_rects + rect = rects[len(rects)*1//10] + dy_brace = Brace(rect, LEFT, buff = 0) + dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_group = VGroup(dy_brace,dy_label) + rp=int(len(rects)/20) + rects_subset = rects[5*rp:6*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, DOWN, buff =.1) + x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) + x_int.next_to(brace, DOWN, SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dy_brace_group.next_to, rect, LEFT, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_x_int, x_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(x_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_x_int = x_int + + x_int = last_x_int + y_brace = last_brace + self.y_brace_group=VGroup(y_brace,dy_brace,rect) + self.x_int=x_int + self.dy_label=dy_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + def bounded_riemann_rectangles_y( + self, + graph1, + graph2, + y_min=None, + y_max=None, + dy=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + y_min = y_min if y_min is not None else self.y_min + y_max = y_max if y_max is not None else self.y_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + y_range = np.arange(y_min, y_max, dy) + colors = color_gradient([start_color, end_color], len(y_range)) + for y, color in zip(y_range, colors): + if input_sample_type == "left": + sample_input = y + elif input_sample_type == "right": + sample_input = y + dy + elif input_sample_type == "center": + sample_input = y + 0.5 * dy + else: + raise Exception("Invalid input sample type") + graph1_point = self.coords_to_point( + graph1(sample_input),sample_input + ) + dy_input=sample_input + width_scale_factor * dy + graph1_point_dy= self.coords_to_point( + graph1(dy_input),dy_input + ) + graph2_point = self.coords_to_point( + graph2(sample_input),sample_input + ) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dy, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif Binary files differnew file mode 100644 index 0000000..b0620e5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py new file mode 100644 index 0000000..46134a7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py @@ -0,0 +1,102 @@ +from manimlib.imports import * + +class CurvyRegion(GraphScene): + CONFIG = { + "x_min": 0, + "x_max": 8, + "y_min": 0, + "y_max": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "x_labeled_nums": np.arange(0, 9,2), + "y_labeled_nums": np.arange(0, 7,2), + "x_axis_width": 6, + "y_axis_height": 6, + } + + def construct(self): + XD = self.x_axis_width/(self.x_max- self.x_min) + YD = self.y_axis_height/(self.y_max- self.y_min) + self.X=XD*RIGHT ;self.Y=YD*UP + + sin_curve_points=[self.graph_origin+(2+.5*np.sin(2*y),y,0) + for y in np.arange(1,5,.005)] + + cos_curve_points=[self.graph_origin+( + 5+.5*np.cos(2*y),y,0) + for y in np.arange(1,5,.005)] + cos_curve_points.reverse() + + region=Polygon( + *sin_curve_points+cos_curve_points, + color=YELLOW, + stroke_width=1, + fill_color=BLUE_E, + fill_opacity=.75 + ) + + line=Line((1,0,0),(1,6,0),color=RED) + line.move_to(self.graph_origin+2.5*self.X,DOWN) + self.line=line + self.setup_axes(animate = False) + + self.add(region) + self.wait() + self.first_y_int_scene() + self.try_x_first_scene() + + + def first_y_int_scene(self): + talk=TextMobject(r"For doing the $y$ integration\\ first we need to set\\ proper $y$ limts").to_corner(UR,buff=LARGE_BUFF) + problem=TextMobject(r"But here we get\\ more than two $y$ values\\ for a single $x$ value" ).to_corner(UR,buff=LARGE_BUFF) + int_y=TextMobject("$$\\int_?^? dy$$").next_to(problem,DOWN,buff=.5) + + self.play(Write(talk)) + self.play(FadeIn(self.line)) + self.wait(2) + self.play(ReplacementTransform(talk,problem)) + self.play( + ApplyMethod(self.line.shift,3.7*self.X), + run_time=4 + ) + self.wait() + self.play(Write(int_y)) + self.wait(3) + self.play(FadeOut(VGroup(problem,int_y,self.line))) + + def try_x_first_scene(self): + try_text=TextMobject(r"But if we try to integrate\\ along $x$ first ...." ).to_corner(UR,buff=LARGE_BUFF) + good_limits=TextMobject(r"For one $y$ value we get\\ only \textbf{two} $x$ values $\dots$").to_corner(UR,buff=LARGE_BUFF) + limit_values= TextMobject(r"one Lower limit\\ one Upper limit ").next_to(good_limits,DOWN,buff=.5) + int_x=TextMobject("$$\\int_{f(y)}^{g(y)} dx$$").next_to(limit_values,DOWN) + + self.setup_line() + self.play(Write(try_text)) + self.play(FadeIn(self.line)) + self.wait() + self.play(ReplacementTransform(try_text,good_limits)) + self.wait() + self.play( + ApplyMethod(self.line.shift,3*self.Y), + run_time=4 + ) + self.play(Write(limit_values)) + self.wait() + self.show_functions() + self.play(Write(int_x)) + self.wait(3) + + def setup_line(self): + line=self.line.rotate(PI/2) + line.move_to(self.graph_origin+.5*self.X+1.5*self.Y,LEFT) + self.line=line + + def show_functions(self): + fy=TextMobject("$$f(y)$$") + gy=TextMobject("$$g(y)$$") + fy.move_to(self.graph_origin+2*self.X+3.3*self.Y) + gy.move_to(self.graph_origin+7*self.X+2*self.Y) + self.play(FadeIn(VGroup(fy,gy))) + + + #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif Binary files differdeleted file mode 100644 index ac13f21..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif +++ /dev/null diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md new file mode 100644 index 0000000..aa8c7f8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md @@ -0,0 +1,9 @@ +**file1_grad_of_scalar_function** +![file1_grad_of_scalar_function](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif) + +**file2_line_int_independent_of_path** +![file2_line_int_independent_of_path](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif) + +**file3_line_int_example** +![file3_line_int_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif) + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif Binary files differnew file mode 100644 index 0000000..5a6e102 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py new file mode 100644 index 0000000..c9f479c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py @@ -0,0 +1,308 @@ +from manimlib.imports import * + +class GradOfScalar(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "z_min": 0, + "z_max": 3, + "a":-3 ,"b": 3, "c":-3 , "d":3, + "axes_shift": ORIGIN+IN, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_vector_field_config": { + "delta_x": 1, + "delta_y": 1, + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "min_magnitude": 0, + "max_magnitude": 2, + "colors": [TEAL,GREEN,GREEN,GREEN,YELLOW,RED], + "length_func": lambda norm : norm*np.exp(-.38*norm)/2, + "opacity": 1.0, + "vector_config": { + "stroke_width":8 + }, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [BLUE_E], + "stroke_width": .5, + "stroke_color": WHITE, + "stroke_opacity": 0.75, + }, + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=70 * DEGREES, + theta=-135 * DEGREES, + ) + + scalar_fn_text=TexMobject("f(x,y,z)=","xy").set_color(BLUE) + scalar_fn_text.to_corner(UR,buff=.6) + + operator=TexMobject("\\vec\\nabla").next_to( + scalar_fn_text,LEFT,buff=.2 + ).set_color(GOLD) + grad_text=TexMobject(r"\dfrac{\partial f}{\partial x} \hat i+\dfrac{\partial f}{\partial y} \hat j+\dfrac{\partial f}{\partial z} \hat k").set_color(GOLD) + grad_text.next_to(scalar_fn_text,DOWN).scale(.9) + + VGroup(grad_text[0][1],grad_text[0][9],grad_text[0][17]).set_color(BLUE) + VGroup(grad_text[0][5:8],grad_text[0][13:16],grad_text[0][21:23]).set_color(WHITE) + + vector_field_text=TexMobject("\\vec F=y\hat i+x\hat j").set_color_by_gradient(*self.default_vector_field_config["colors"]) + vector_field_text.next_to(scalar_fn_text,DOWN) + + + #always generate the scalar field first + s_field1=self.get_scalar_field( + func= lambda u ,v : u*v/7 + ) + v_field1=self.get_vector_field( + lambda v: np.array([ + v[1], + v[0], + 0, + ]), + on_surface=True, + ) + + self.add_fixed_in_frame_mobjects(scalar_fn_text) + + self.begin_ambient_camera_rotation(rate=.2) + self.play(Write(s_field1)) + self.wait(1) + self.stop_ambient_camera_rotation() + + self.add_fixed_in_frame_mobjects(operator) + self.play(Write(operator),FadeOut(scalar_fn_text[1])) + self.add_fixed_in_frame_mobjects(grad_text) + self.play(Write(grad_text)) + self.wait(2) + + self.play(FadeOut(grad_text)) + self.add_fixed_in_frame_mobjects(vector_field_text) + show_vec_field=[ + FadeIn(v_field1), + Write(vector_field_text), + ] + + self.begin_ambient_camera_rotation(rate=.2) + self.move_camera( + # distance=20, + phi=60 * DEGREES, + added_anims=show_vec_field, + run_time=4.5 + ) + + self.wait(2) + self.stop_ambient_camera_rotation() + + fadeout= [FadeOut(s_field1)] + self.move_camera( + # distance=20, + phi=0 * DEGREES, + theta=-90 * DEGREES, + added_anims=fadeout, + run_time=2 + ) + self.wait(2) + + + + + + def get_scalar_field(self,func,**kwargs): + surface= self.get_surface( + lambda x , y: + func(x,y), + ) + + self.surface_points=self.get_points(func) + return surface + + def get_points(self,func): + axes=self.axes + dn=.5 + x_vals=np.arange(axes.a,axes.b,dn) + y_vals=np.arange(axes.c,axes.d,dn) + points=[] + for x_val in x_vals: + for y_val in y_vals: + points+=[axes.c2p(x_val,y_val,func(x_val,y_val)+.05)] + return points + + def get_vector_field(self,func,on_surface=True,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + self.vector_field=vector_field + + if on_surface: + vector_field=self.get_vectors_on_surface() + + return vector_field + + + + def get_vectors_on_surface(self): + config = dict() + config.update(self.default_vector_field_config["vector_config"]) + vectors_on_surface = VGroup(*[ + self.vector_field.get_vector(point,**config) + for point in self.surface_points + ]) + + return vectors_on_surface + + + def get_surface(self, func, **kwargs): + axes=self.axes + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + 2*(axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + + +#------------------------------------------------------- + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + self.axes=axes + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + -90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + + ("1", axes.b), + ("-1", axes.a), + ] + tex_vals_y=[ + + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + # label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif Binary files differnew file mode 100644 index 0000000..29c6d02 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py new file mode 100644 index 0000000..b9597b6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py @@ -0,0 +1,174 @@ +from manimlib.imports import * + + +class LineIntegration(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "axes_color":BLACK, + "graph_origin": ORIGIN+1.2*DOWN, + "x_axis_width": 10, + "y_axis_height": 10 , + "x_axis_label": "", + "y_axis_label": "", + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .6, + "delta_y": .6, + "min_magnitude": 0, + "max_magnitude": .5, + "colors": [GREEN,BLUE,BLUE,TEAL], + "length_func": lambda norm : .45*sigmoid(norm), + "opacity": .75, + "vector_config": { + "stroke_width":1.5 + }, + }, + + "a": .45,"b": 2, + "path_color": PURPLE + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + + + vector_field=self.get_vector_field( + lambda v: np.array([ + v[1]-self.graph_origin[1], + v[0]-self.graph_origin[0], + 0, + ]) + ) + vector_field_text=TexMobject( + "\\vec F(x,y)","=y\hat i+x\hat j", + stroke_width=1.5 + ).to_edge(TOP,buff=.2) + + vector_field_text[0][0:2].set_color(TEAL) + + grad_f=TexMobject( + "\\vec\\nabla f(x,y)", + stroke_width=1.5 + ) + grad_f[0][2].set_color(LIGHT_BROWN) + grad_f.move_to(vector_field_text[0]) + + self.add(vector_field,) + self.play(Write(vector_field_text)) + self.wait() + self.play( + ReplacementTransform( + vector_field_text[0],grad_f + ) + ) + self.get_endpoints_of_curve() + self.wait(.6) + vector_field.set_fill(opacity=.4) + self.show_line_integral() + self.wait(2) + + + + + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + self.vector_field= vector_field + + return vector_field + + + + def get_endpoints_of_curve(self): + points=[[-3,0],[2,2]] + point_labels= ["P_i","P_f"] + for point,label in zip(points,point_labels): + dot=Dot(self.coords_to_point(*point)).set_color(RED) + dot_label=TexMobject(label) + dot_label.next_to(dot,DR,buff=.2) + self.play(FadeIn(VGroup(dot,dot_label))) + self.wait(.2) + + self.end_points=points + + def show_line_integral(self): + int_text=TexMobject( + r"\int_{P_i}^{P_f}\vec F \cdot d\vec r", + stroke_width=1.5, + ).scale(1.2) + int_text[0][0].set_color(self.path_color) + int_text[0][5:7].set_color(TEAL) + int_text.to_edge(RIGHT+UP,buff=1) + + int_value= TexMobject(r"=f(P_i)-f(P_f)", + stroke_width=1.5 + ).next_to(int_text,DOWN) + VGroup(int_value[0][1], + int_value[0][7] + ).set_color(LIGHT_BROWN) + + path_indepent_text=TextMobject( + r"Value of the Line Integral is\\ independent of Path",color=GOLD,stroke_width=2,).to_corner(DR,buff=1) + + path_indepent_text[0][-4:].set_color(self.path_color) + + + self.play(Write(VGroup( + int_text,int_value + )), + run_time=2 + ) + self.wait(1.5) + + + self.show_path([[0,1],[-1,2],[1,3]]) + self.play(Indicate(int_value)) + self.play(Uncreate(self.path)) + + self.show_path([[0,1]]) + self.play(Indicate(int_value)) + self.play(Uncreate(self.path)) + + self.show_path([[-1,1],[-1,-2],[-5,0],[-2,3.5],[1,1]]) + self.play(Indicate(int_value),run_time=2) + self.wait(.6) + + self.play(Write(path_indepent_text)) + + + + def show_path(self,points): + points=[self.end_points[0]]+points+[self.end_points[1]] + + path= VMobject() + path.set_points_smoothly([ + self.coords_to_point(*point) + for point in points + ]) + path.set_color(self.path_color) + self.play(ShowCreation(path),run_time=1.5) + + self.path=path + + + + + +#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif Binary files differnew file mode 100644 index 0000000..20ed081 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py new file mode 100644 index 0000000..71506a3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py @@ -0,0 +1,149 @@ +from manimlib.imports import * + + +class LineIntegration(GraphScene): + CONFIG = { + "x_min" : -1, + "x_max" : 2, + "y_min" : -1, + "y_max" : 2, + "graph_origin": ORIGIN+3*LEFT+1.5*DOWN, + "x_axis_width": 10, + "y_axis_height": 10 , + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "min_magnitude": 0, + "max_magnitude": .5, + "colors": [GREEN,BLUE,BLUE,TEAL], + "length_func": lambda norm : .4*sigmoid(norm), + "opacity": .75, + "vector_config": { + "stroke_width":2 + }, + }, + + "a": .45,"b": 2, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + + + vector_field=self.get_vector_field( + lambda v: np.array([ + v[1]-self.graph_origin[1], + v[0]-self.graph_origin[0], + 0, + ]) + ) + vector_field_text=TexMobject( + "\\vec F=y\hat i+x\hat j", + stroke_width=2 + ).to_corner(UR,buff=.75).scale(1.2) + + vector_field_text[0][0:3].set_color(TEAL), + self.add(vector_field,) + self.play(Write(vector_field_text)) + self.wait() + self.get_endpoints_of_curve() + self.wait(.6) + self.play( + vector_field_text.shift,5*LEFT, + + ) + vector_field.set_fill(opacity=.2) + self.show_line_integral() + self.wait(2) + + + + + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + self.vector_field= vector_field + + return vector_field + + + + def get_endpoints_of_curve(self): + points=[[1,1],[0,0]] + point_labels= ["(1,1)","(0,0)"] + for point,label in zip(points,point_labels): + dot=Dot(self.coords_to_point(*point)).set_color(RED) + dot_label=TexMobject(label) + dot_label.next_to(dot,DR) + self.add(dot,dot_label) + self.end_points=points + + def show_line_integral(self): + int_text=TexMobject( + "\\int_\\text{\\textbf{path}}\\vec F \\cdot d\\vec r= 1", + color=BLUE, + stroke_width=1.5 + ).scale(1.2) + int_text[0][0].set_color(RED_C) + int_text[0][5:7].set_color(TEAL) + int_text.to_edge(RIGHT+UP,buff=1) + + close_int=TexMobject("O").set_color(RED).scale(1.3) + close_int.move_to(int_text[0][0],OUT) + close_int_val=TexMobject("0",color=BLUE).scale(1.4) + close_int_val.move_to(int_text[0][-1],OUT) + + self.play(Write(int_text)) + + + self.show_method([[0,1]]) + self.play(Indicate(int_text)) + self.wait() + + self.show_method([[1,0]]) + self.play(Indicate(int_text)) + self.wait() + self.remove(int_text[0][-1]) + self.add(close_int) + + for i in range(2): + self.play(self.paths[i].rotate,PI) + self.play(Indicate(close_int)) + self.play(Write(close_int_val)) + self.wait() + + + def show_method(self,points): + points=points+self.end_points + paths=[] + for i in range(-1,len(points)-2): + path=Arrow( + self.coords_to_point(*points[i]), + self.coords_to_point(*points[i+1]), + buff=0 + ).set_color(BLUE) + paths+=VGroup(path) + self.play(GrowArrow(path),run_time=1.5) + + self.paths=paths + + + + + +#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md new file mode 100644 index 0000000..17077b6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -0,0 +1,14 @@ +**file1_scalar_line_int_as_sum** +![file1_scalar_line_int_as_sum](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif) + +**file2_scalar_line_integral** +![file2_scalar_line_integral](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif) + + +**file3_vector_line_int_as_sum** +![file3_vector_line_int_as_sum](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif) + + + +**file4_helix** +![file4_helix](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif Binary files differnew file mode 100644 index 0000000..1984b08 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py new file mode 100644 index 0000000..e3f3574 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py @@ -0,0 +1,227 @@ +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "x_axis_width": 10, + "y_axis_height": 6 , + "x_tick_frequency": 2, + "y_tick_frequency": 2, + "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), + "a": 1 ,"b": 9, "n": 15, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{path of intgration}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + self.construct_equation() + self.wait(2) + + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$f(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$f(x,y)$",ORANGE) + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.wait() + self.position_of_point_irrelevent() + self.multiply_with_function(dots) + + + + def multiply_with_function(self,dots): + index=-(len(self.points)//3) + dot=dots[index] + + + multiply_text=TexMobject("f(x_i,y_i)", "\\text{ is multiplied with }","\\Delta s_i") + multiply_text.set_color_by_tex_to_color_map({ + "f(x_i,y_i)":ORANGE , "\\Delta s_i": BLUE + }) + multiply_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$f(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR) + + sum_up_text=TextMobject("and "," summed ", "for all i' s") + sum_up_text.set_color_by_tex("summed",PURPLE) + sum_up_text.next_to(multiply_text,DOWN) + + dot.set_color(ORANGE).scale(1.2) + + self.play(FadeIn(VGroup( + point_coord,dot + ))) + self.play(Write(self.evaluate_text)) + self.play(Write(func_val)) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in dots ] + ))) + self.wait(2) + self.remove(point_coord) + self.get_ds(dots,index) + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(FadeOut(VGroup( + self.ds_brace, + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + func_val, RIGHT,buff=.2 + )) + self.play(Write(sum_up_text)) + + self.func_val=func_val + self.sum_text_group=VGroup(multiply_text,sum_up_text) + + def position_of_point_irrelevent(self): + pass + + + + def get_ds(self,dots,index): + p1= dots[index] + p2= dots[index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE) + sum_eqn.move_to(self.graph_origin+7*self.X+4*self.Y) + + line_integral_text=TextMobject("The Value of the line integral is").next_to(self.sum_text_group,IN) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup(self.func_val,self.ds_brace_label) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(self.sum_text_group)) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif Binary files differnew file mode 100644 index 0000000..71c97d6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py new file mode 100644 index 0000000..996ead1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py @@ -0,0 +1,421 @@ +from manimlib.imports import * + +class LineIntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -4, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": 0, + "z_max": 4, + "a":-3 ,"b": 3, "c":0 , "d":3.5, + "axes_shift":3*IN, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.2, + "stroke_color": WHITE, + "stroke_opacity": 0.75, + }, + "Func": lambda x,y: 1+x**2*y/15 + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=65 * DEGREES, + theta=-65 * DEGREES, + ) + + fn_text=TextMobject("$z=2+x^2y$").set_color(BLUE) + fn_text.to_corner(UR,buff=.8).shift(DOWN) + + #get the surface + surface= self.get_surface( + lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.5, + fill_color=BLUE_D, + stroke_width=0.5, + stroke_color=WHITE, + ) + + + # self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(fn_text) + self.play(Write(surface),Write(fn_text)) + self.get_line_of_int() + self.begin_ambient_camera_rotation(rate=-0.035) + self.get_field_values_on_line() + self.wait(1.5) + self.area=self.get_area() + area_text=TextMobject("Line"," Integral in the",r" scalar field\\"," means this" ,"area") + area_text.set_color_by_tex_to_color_map({ + "Line": PINK, "scalar":BLUE, "area":TEAL_A + }) + area_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + self.remove(self.values_on_line_text) + self.add_fixed_in_frame_mobjects(area_text) + self.play(Write(area_text)) + self.play(Write(self.area),run_time=2) + self.play(FadeOut(VGroup(surface,fn_text))) + self.wait() + + self.stop_ambient_camera_rotation() + # self.get_lines() + + self.remove(axes,surface) + self.trasform_to_graphs() + self.wait(2) + + + + + def get_line_of_int(self): + line_of_int_text=TextMobject(r"Line of integration is\\","$\\vec r(t)=\cos(t)\hat x+\sin(t)\hat y$") + line_of_int_text[1].set_color(PINK) + line_of_int_text.to_edge(TOP,buff=SMALL_BUFF) + + + line_of_int=(self.get_curve( + self.Func,on_surface=False + )) + line_of_int.set_style( + stroke_width=5, + stroke_color=PINK, + ) + + self.add_fixed_in_frame_mobjects(line_of_int_text) + self.play(Write(line_of_int_text)) + self.wait() + self.play(ShowCreation(line_of_int),run_time=3) + # self.add(line_of_int) + + self.line_of_int=line_of_int + self.line_of_int_text=line_of_int_text + + def get_field_values_on_line(self): + self.remove(self.line_of_int_text) + + values_on_line_text=TextMobject("Values"," of"," function","on the ","line") + values_on_line_text.set_color_by_tex_to_color_map({ + "Values":YELLOW, "function":BLUE,"line":PINK + }) + values_on_line_text.to_edge(TOP,buff=SMALL_BUFF) + + values_on_surface=(self.get_curve( + self.Func,on_surface=True + )) + values_on_surface.set_style( + stroke_width=5, + stroke_color=YELLOW, + ) + + self.add_fixed_in_frame_mobjects(values_on_line_text) + self.play(Write(values_on_line_text)) + # self.wait() + self.play(ShowCreation(values_on_surface),run_time=3) + # self.add(values_on_surface) + + self.values_on_surface=values_on_surface + self.values_on_line_text=values_on_line_text + + + def trasform_to_graphs(self): + on_surface_graph=(self.get_graph( + self.Func,on_surface=True + )) + on_surface_graph.set_style( + stroke_width=5, + stroke_color=YELLOW, + ) + + line_graph=(self.get_graph( + self.Func,on_surface=False + )) + line_graph.set_style( + stroke_width=5, + stroke_color=PINK, + ) + + self.on_surface_graph=on_surface_graph + self.line_graph=line_graph + graph_area=self.get_area(graph=True) + + into_graph=[ + ReplacementTransform( + self.values_on_surface, + on_surface_graph + ), + ReplacementTransform( + self.line_of_int, + line_graph + ), + ReplacementTransform( + self.area, + graph_area + ), + ] + + self.move_camera( + # distance=20, + phi=90 * DEGREES, + theta=-90 * DEGREES, + added_anims=into_graph, + run_time=2 + ) + + def get_area(self,graph=False): + axes=self.axes + if graph: + on_surface=self.on_surface_graph + on_base=self.line_graph + else: + on_surface=self.values_on_surface + on_base=self.line_of_int + area =Polygon( + *[ + on_surface.get_point_from_function(t) + for t in np.arange(0,PI,0.01) + ], + *[ + on_base.get_point_from_function(t) + for t in np.arange(PI,0,-0.01) + ], + stroke_width=0, + fill_color=TEAL_A, + fill_opacity=.6, + ) + + return area + + def get_curve(self,func,on_surface=False ,**kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": 0, + "t_max": PI, + }) + config.update(kwargs) + r=abs(self.axes.a) + curve=ParametricFunction( + lambda t: self.axes.c2p( + r*np.cos(t), + r*np.sin(t), + func(r*np.cos(t), r*np.sin(t))*bool(on_surface) + ), + **config, + ) + return curve + + + def get_surface(self, func, **kwargs): + axes=self.axes + config = { + "u_min": axes.a-.2, + "u_max": axes.b+.2, + "v_min": axes.c-.1, + "v_max": axes.d, + "resolution": ( + 2*(axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_graph(self,func,on_surface=False ,**kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": 0, + "t_max": PI, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda t: self.axes.c2p( + 4*np.cos(t), + 0, + 2+func(3*np.cos(t), 3*np.sin(t))*bool(on_surface) + ), + **config, + ) + return slice_curve + + def get_lines(self): + pass + axes = self.axes + labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), + axes.y_axis.n2p(axes.d)] + + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"PINK")) + + for start , end in zip(labels, + self.region_corners): + # lines.add(self.draw_lines(start,end,"BLUE")) + # print (start,end) + pass + # self.play(ShowCreation(lines)) + self.add(lines) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + self.axes=axes + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + -90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + lambda x, t: 0 + ) + '''input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + )''' + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + + ("1", axes.b), + ("-1", axes.a), + ] + tex_vals_y=[ + + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + # label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit.FSF2020_Line_Integrals + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif Binary files differnew file mode 100644 index 0000000..46b35bc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py new file mode 100644 index 0000000..78294cc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py @@ -0,0 +1,326 @@ +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "x_axis_width": 10, + "y_axis_height": 6 , + "x_tick_frequency": 2, + "y_tick_frequency": 2, + "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), + "a": 1 ,"b": 9, "n": 15, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{path of intgration}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.get_vector_field() + + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + + self.wait(2) + + + def get_vector_field(self): + func = lambda v: np.array([ + v[0], # x + -v[1], # y + 0 # z + ]) + vector_field= VectorField( + func, + delta_x=1, + delta_y=1, + colors=[GREEN_A,GREEN_C], + length_func= lambda norm: .8*sigmoid(norm), + vector_config={ + "stroke_width": 2 + } + ) + + self.vector_field= vector_field + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$\\vec F(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$\\vec F(x,y)$",ORANGE) + + multiply_text=TextMobject("...is multiplied with ","$\\Delta s_i$") + multiply_text.set_color_by_tex("\\Delta s_i", BLUE) + multiply_text.next_to(at_any_points_text,DOWN) + + + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + self.multiply_text=multiply_text + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.dots=dots + + self.wait() + self.show_the_dot_product() + self.multiply_with_ds() + self.construct_equation() + + + def show_the_dot_product(self): + index=-(len(self.points)//3) + self.index=index + + dot=self.dots[index] + + + dot_prod_text=TextMobject("Dot Product of", "$\\vec F(x_i,y_i)$", "and","$\\vec T(x_i,y_i)$") + dot_prod_text.set_color_by_tex_to_color_map({ + "\\vec F(x_i,y_i)":ORANGE , + "\\vec T(x_i,y_i)": "#DC75CD" , + }) + dot_prod_text.to_edge(TOP,buff=SMALL_BUFF) + + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$\\vec F(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR).scale(.8) + + self.dot_prod_text=dot_prod_text + self.func_val=func_val + + dot.set_color(ORANGE).scale(1.2) + + + self.play(FadeIn(VGroup(point_coord,dot))) + self.play(Write(self.evaluate_text)) + self.wait(1) + self.play(FadeOut(self.vector_field)) + self.get_vector_and_tangent() + self.dot_product() + + + self.wait(2) + self.remove(point_coord) + + + def get_vector_and_tangent(self): + dot=self.dots[self.index] + self.show_specific_vectors(dot) + self.play(Write(self.func_val)) + self.wait(1) + self.show_tangent(dot) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in self.dots ] + ))) + + + def show_specific_vectors(self,dots): + for dot in dots: + vector=self.vector_field.get_vector(dot.get_center()) + vector.set_color(ORANGE) + + self.play(Write(vector),run_time=.2) + + + def show_tangent(self,dot): + tangent_sym=TextMobject("$\\vec T(x_i,y_i)$",color="#DC75CD").scale(.8) + x=dot.get_center() + angle=self.angle_of_tangent( + self.point_to_coords(x)[0], + self.curve, + dx=0.01 + ) + vect = Vector().rotate(angle,about_point=x) + vect.set_color("#DC75CD") + tangent=vect.next_to(x,DR,buff=0) + tangent_sym.next_to(tangent,DOWN,buff=.1) + self.play(Write(VGroup(tangent,tangent_sym))) + + self.tangent_sym=tangent_sym + + def dot_product(self): + + dot_sym=Dot().next_to(self.func_val,RIGHT) + + self.play(FadeOut(VGroup( + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(self.dot_prod_text)) + self.play( + FadeIn(dot_sym), + ApplyMethod( + self.tangent_sym.next_to, + dot_sym, RIGHT + )) + + self.dot_sym=dot_sym + + def multiply_with_ds(self): + self.get_ds() + + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(Write(self.multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + self.tangent_sym, RIGHT,buff=.15 + )) + + + + def get_ds(self): + p1= self.dots[self.index] + p2= self.dots[self.index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_up_text=TextMobject("and"," summed ", "for all i' s") + sum_up_text.set_color_by_tex("summed",PURPLE_A) + sum_up_text.next_to(self.multiply_text,DOWN,buff=MED_SMALL_BUFF) + sum_up_text.shift(LEFT) + + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE_A) + sum_eqn.move_to(self.graph_origin+6.5*self.X+4*self.Y) + + line_integral_text=TextMobject("The Value of the"," line ","integral is").to_edge(TOP,buff=MED_SMALL_BUFF) + line_integral_text.set_color_by_tex("line",BLUE_C) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup( + self.func_val, + self.dot_sym, + self.tangent_sym, + self.ds_brace_label + ) + + + self.play(Write(sum_up_text)) + self.show_specific_vectors(self.dots) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(VGroup( + self.dot_prod_text, + self.multiply_text, + sum_up_text + ))) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif Binary files differnew file mode 100644 index 0000000..ceedb1f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py new file mode 100644 index 0000000..50aeb33 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py @@ -0,0 +1,245 @@ +from manimlib.imports import * + +class ParametricCurve(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 3, + "y_min": 0, + "y_max": 3, + "z_min": 0, + "z_max": 4, + "a":0 ,"b": 2, "c":0 , "d":2, + "axes_shift":2*IN+1.4*RIGHT+1.4*DOWN, + "x_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + }, + + } + + + def construct(self): + + self.setup_axes() + + self.set_camera_orientation( + distance=25, + phi=60 * DEGREES, + theta=40 * DEGREES, + ) + + label=TextMobject("Helix",color=PURPLE).scale(1.6) + label.to_corner(UR,buff=2) + self.add_fixed_in_frame_mobjects(label) + + helix=self.get_helix( + radius=1.5, + t_min= 0, + t_max= 4*PI, + color=PURPLE + ) + parameter_label=TextMobject( + "Parametric equation: ", + color=TEAL + ).next_to(label,DOWN,buff=.3 + ) + parametric_eqn=TextMobject( + "$x=\cos$ (","t", + r")\\$y=\sin $(","t", + r")\\$z$=","t" + ).next_to(parameter_label,DOWN,buff=.1) + parametric_eqn.set_color_by_tex("t",RED) + self.parametric_eqn=parametric_eqn + + parametriztion=VGroup( + parameter_label, + parametric_eqn + ) + + + self.play(ShowCreation(helix),run_time=2) + self.begin_ambient_camera_rotation(.1) + self.wait(1) + self.add_fixed_in_frame_mobjects(parametriztion) + self.play(Write(parametriztion)) + self.wait(1) + self.stop_ambient_camera_rotation() + self.move_camera( + distance=20, + phi=85 * DEGREES, + # theta=-90 * DEGREES, + run_time=3 + ) + scale_axes=VGroup(self.axes,helix).scale(1.2) + self.show_the_parameter() + self.wait(2) + + + + def get_helix(self,radius=1, **kwargs): + config = { + "t_min": 0, + "t_max": 2*PI, + } + config.update(kwargs) + helix= ParametricFunction( + lambda t : self.axes.c2p( + radius*np.cos(t), + radius*np.sin(t), + t/4 + ), + **config + ) + + self.helix=helix + return helix + + def show_the_parameter(self): + t_tracker = ValueTracker(0) + t=t_tracker.get_value + + t_label = TexMobject( + "t = ",color=RED + ).next_to(self.parametric_eqn,DL,buff=.85) + + t_text = always_redraw( + lambda: DecimalNumber( + t(), + color=GOLD, + ).next_to(t_label, RIGHT, MED_SMALL_BUFF) + ) + t_text.suspend_updating() + + dot = Sphere( + radius= 1.5*DEFAULT_DOT_RADIUS, + stroke_width= 1, + fill_opacity= 1.0, + ) + dot.set_color(GOLD) + dot.add_updater(lambda v: v.move_to( + self.helix.get_point_from_function(PI*t()) + )) + + pi = TexMobject( + "\\pi ", + color=GOLD, + ).next_to(t_text,RIGHT,buff=-.3) + + group = VGroup(t_text,t_label,pi).scale(1.5) + + self.wait(1) + self.add_fixed_in_frame_mobjects(group) + t_text.resume_updating() + self.play(FadeIn(group)) + self.add(dot) + self.play( + t_tracker.set_value,2, + rate_func=linear, + run_time=5 + ) + + +#-------------------------------------------------------- + + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=1.5) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("1", axes.b), + ] + tex_vals_y=[ + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + #uploaded by Somnath Pandit.FSF2020_Line_integrals + + + + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/README.md b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/README.md diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/README.md b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/README.md new file mode 100644 index 0000000..0af7aa1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/README.md @@ -0,0 +1,8 @@ +**file1_flux_through_sphere.py** +![file1_flux_through_sphere](file1_flux_through_sphere.gif) +**file2_mobius_strip.py** +![file2_mobius_strip](file2_mobius_strip.gif) +**file3_normal_vector.py** +![file3_normal_vector](file3_normal_vector.gif) +**file4_cube_surface.py** +![file4_cube_surface](file4_cube_surface.gif) diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.gif Binary files differnew file mode 100644 index 0000000..43327bf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.py new file mode 100644 index 0000000..e07715e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_sphere.py @@ -0,0 +1,50 @@ +from manimlib.imports import * +class fluxsphere(ThreeDScene): + + + def construct(self): + s = Sphere(checkerboard_colors=[BLUE_D,BLUE_D]) + s.scale(2.3) + + n = VGroup( + *[self.n(*self.func(u, v)) + for u in np.arange(0, PI, 0.4) + for v in np.arange(0, TAU, 0.8)] + ) + + + + self.move_camera(0.8 * PI / 2, -0.45 * PI) + self.play(Write(s)) + # self.play(Write(f)) + self.play(ShowCreation(n), run_time=4) + # self.add(n) + self.begin_ambient_camera_rotation(rate=0.1) + self.wait(5) + + + def func(self, u, v): + return [ + np.cos(v) * np.sin(u), + np.sin(v) * np.sin(u), + np.cos(u) + ] + + def vect(self, x, y, z): + return np.array([ + x, y, z + ]) + + def n(self, x, y, z): + vect = np.array([ + x, + y, + z + ]) + + mag = math.sqrt(vect[0] ** 2 + vect[1] ** 2 + vect[2] ** 2) + v = Vector( + (1.5/mag) * vect, + color=RED_B, + stroke_width=4).shift(2*x * RIGHT + 2*y * UP + 2*z * OUT) + return v diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.gif Binary files differnew file mode 100644 index 0000000..9623046 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.py new file mode 100644 index 0000000..31b1990 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file2_mobius_strip.py @@ -0,0 +1,81 @@ +from manimlib.imports import * + +class Mobius(ThreeDScene): + def construct(self): + axes=ThreeDAxes() + + + + R=2.5 + + + mobius = ParametricSurface( + lambda u, v: np.array([ + (R+u*np.cos(v/2))*np.cos(v), + (R+u*np.cos(v/2))*np.sin( v), + u*np.sin(v/2) + ]), + u_min = -0.5, u_max = 0.5, v_min = 0, v_max = 2*PI, + + resolution=(6, 32)).fade(0.5) #Resolution of the surfaces + circle=Circle(radius=2.5, color=BLUE) + + + + mobius.rotate(PI/2, axis=RIGHT) + mobius.rotate(PI/2, axis=OUT) + # # mobius.shift(RIGHT+OUT+DOWN) + + + + + + along = ParametricSurface( + lambda u, v: np.array([ + (R+u*np.cos(v/2))*np.cos(v), + (R+u*np.cos(v/2))*np.sin(v), + 0 + ]), + u_min = -0.5, u_max = 0.5, v_min = 0, v_max = 2*PI, + + resolution=(6, 32)).fade(0.5) #Resolution of the surfaces + circle=Circle(radius=2.5, color=BLUE) + + + + + + + + + + + + + + + + + + + + + + + + self.set_camera_orientation(phi=75 * DEGREES,theta=-75*DEGREES) + + self.play(Write(mobius)) + + self.wait(1) + self.begin_ambient_camera_rotation(rate=0.65) + + self.wait(10) + self.stop_ambient_camera_rotation() + self.wait(1) + + + + + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.gif Binary files differnew file mode 100644 index 0000000..a8f2990 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.py new file mode 100644 index 0000000..a959210 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file3_normal_vector.py @@ -0,0 +1,47 @@ +from manimlib.imports import * +class S(ThreeDScene): + def construct(self): + axes=ThreeDAxes() + + sphere=Sphere(radius=2,checkerboard_colors=[BLUE_C,BLUE_B],fill_opacity=0.75) + + + v1=Vector(color=YELLOW,buff=5) + v1.rotate(PI/4,axis=DOWN) + v1.shift(1.5*RIGHT+1.5*OUT) + + v2=Vector(color=RED,buff=5) + v2.rotate(PI/4,axis=DOWN) + v2.rotate(PI,axis=DOWN) + v2.shift(0.77*RIGHT+0.77*OUT) + + + + + n1=TextMobject(r"$\vec{n}$",color=YELLOW) + n2=TextMobject(r"$-\vec{n}$",color= RED) + n1.rotate(PI/2,axis=RIGHT) + n1.shift(2*RIGHT+2*OUT) + n2.rotate(PI/2,axis=RIGHT) + n2.shift(0.42*RIGHT+0.42*OUT) + + + + self.set_camera_orientation(phi=75 * DEGREES,theta=-45*DEGREES) + # self.add(mobius) + # self.play(ShowCreation(axes)) + self.play(ShowCreation(axes)) + # self.play(ShowCreation(vg)) + self.play(ShowCreation(sphere)) + self.wait(0.7) + self.play(ShowCreation(v1, run_time=2)) + self.play(ShowCreation(n1)) + self.wait(1) + self.begin_ambient_camera_rotation(rate=0.65) + self.wait(2) + self.play(ShowCreation(v2, run_time=3)) + self.wait(3) + self.play(ShowCreation(n2)) + + self.stop_ambient_camera_rotation() + self.wait(1.2) diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.gif Binary files differnew file mode 100644 index 0000000..c6101cf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.py new file mode 100644 index 0000000..9301a00 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.py @@ -0,0 +1,228 @@ +from manimlib.imports import* + + + +class cuber(ThreeDScene): + def construct(self): + + axes=ThreeDAxes() + cube=Cube() + # cube.scale(1) + cube.shift(RIGHT+DOWN+OUT) + + + + sq3=Square(color=RED, fill_opacity=0.85) + sq3.rotate(PI/2, axis=UP) + sq3.shift(DOWN+OUT+2*RIGHT) + + x=TextMobject("x") + y=TextMobject("y") + z=TextMobject("z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + v1=Vector(color=YELLOW,buff=15) + v1.rotate(PI/4,axis=RIGHT) + v1.shift(2*RIGHT+1*DOWN+1*OUT) + + + n1=TextMobject(r"$\vec{n}$",color=YELLOW) + n1.scale(0.8) + n1.rotate(PI/2,axis=RIGHT) + n1.shift(3*RIGHT+1.3*OUT+DOWN) + + spaceloc = [[0,0,2],[1,0,2],[-1,0,2],[2,0,2],[-2,0,2],[3,0,2],[-3,0,2], + [0,1,2],[1,1,2],[-1,1,2],[2,1,2],[-2,1,2],[3,1,2],[-3,1,2], + [0,-1,2],[1,-1,2],[-1,-1,2],[2,-1,2],[-2,-1,2],[3,-1,2],[-3,-1,2], + [0,2,2],[1,2,2],[-1,2,2],[2,2,2],[-2,2,2],[3,2,2],[-3,2,2], + [0,-2,2],[1,-2,2],[-1,-2,2],[2,-2,2],[-2,-2,2],[3,-2,2],[-3,-2,2], + [0,3,2],[1,3,2],[-1,3,2],[2,3,2],[-2,3,2],[3,3,2],[-3,3,2], + [0,3,2],[1,3,2],[-1,3,2],[2,3,2],[-2,3,2],[3,3,2],[-3,3,2], + [0,4,2],[1,4,2],[-1,4,2],[2,4,2],[-2,4,2],[3,4,2],[-3,4,2], + [0,4,2],[1,4,2],[-1,4,2],[2,4,2],[-2,4,2],[3,4,2],[-3,4,2], + [0,5,2],[1,5,2],[-1,5,2],[2,5,2],[-2,5,2],[3,5,2],[-3,5,2], + [0,5,2],[1,5,2],[-1,5,2],[2,5,2],[-2,5,2],[3,5,2],[-3,5,2], + [0,6,2],[1,6,2],[-1,6,2],[2,6,2],[-2,6,2],[3,6,2],[-3,6,2], + [0,1.5,2],[1,1.5,2],[-1,1.5,2],[2,1.5,2],[-2,1.5,2],[3,1.5,2],[-3,1.5,2], + [0,3,2],[1,3,2],[-1,3,2],[2,3,2],[-2,3,2],[3,3,2],[-3,3,2]] + + + veclist1=[Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E)] + + + + + + [veclist1[i].rotate(PI/4,axis=RIGHT) for i in range(10,30,1)] + [veclist1[i].rotate(PI/4,axis=RIGHT) for i in range(40,80,2)] + [veclist1[i].rotate(PI/6,axis=OUT) for i in range(98)] + [veclist1[i].rotate(PI/8,axis=DOWN) for i in range(98)] + vectorfield1=VGroup(*veclist1) + [veclist1[i].shift(spaceloc[i]) for i in range(98)] + + + + + veclist2=[Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E), + Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E),Vector(color=GOLD_E)] + + + + + + [veclist2[i].rotate(PI/4,axis=RIGHT) for i in range(10,30,1)] + [veclist2[i].rotate(PI/4,axis=RIGHT) for i in range(40,80,2)] + [veclist2[i].rotate(PI/6,axis=OUT) for i in range(98)] + [veclist2[i].rotate(PI/8,axis=DOWN) for i in range(98)] + vectorfield2=VGroup(*veclist2) + [veclist2[i].shift(spaceloc[i]) for i in range(98)] + + + + veclist3=[Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector()] + + + + + + [veclist3[i].rotate(PI/4,axis=RIGHT) for i in range(10,30,1)] + [veclist3[i].rotate(PI/4,axis=RIGHT) for i in range(40,80,2)] + [veclist3[i].rotate(PI/6,axis=OUT) for i in range(98)] + [veclist3[i].rotate(PI/8,axis=DOWN) for i in range(98)] + vectorfield3=VGroup(*veclist3) + [veclist3[i].shift(spaceloc[i]) for i in range(98)] + + + + + veclist4=[Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector(), + Vector(color=RED),Vector(color=GREEN),Vector(color=BLUE),Vector(color=PINK),Vector(color=MAROON),Vector(color=GREEN),Vector()] + + + + + + [veclist4[i].rotate(PI/4,axis=RIGHT) for i in range(10,30,1)] + [veclist4[i].rotate(PI/4,axis=RIGHT) for i in range(40,80,2)] + [veclist4[i].rotate(PI/6,axis=OUT) for i in range(98)] + [veclist4[i].rotate(PI/8,axis=DOWN) for i in range(98)] + vectorfield4=VGroup(*veclist4) + [veclist4[i].shift(spaceloc[i]) for i in range(98)] + + + vectorfield1.shift(1.5*DOWN) + vectorfield2.shift(IN+1.5*DOWN) + vectorfield3.shift(2*IN+1.5*DOWN) + vectorfield4.shift(3*IN+1.5*DOWN) + + vectors=[vectorfield1,vectorfield2,vectorfield3,vectorfield4] + vectorfield=VGroup(*vectors) + vectorfield.scale(1.25) + + fv=[Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE), + Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE), + Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE), + Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE),Vector(color=ORANGE), + ] + + spaceloc2 = [[1.5,0.5,0.5],[1.5,1,0.5],[1.5,1.5,0.5],[1.5,2,0.5], + [1.5,0.5,1],[1.5,1,1],[1.5,1.5,1],[1.5,2,1], + [1.5,0.5,1.5],[1.5,1,1.5],[1.5,1.5,1.5],[1.5,2,1.5], + [1.5,0.5,2],[1.5,1,2],[1.5,1.5,2],[1.5,2,2]] + + [fv[i].rotate(PI/4,axis=RIGHT) for i in range(1)] + [fv[i].rotate(PI/6,axis=OUT) for i in range(16)] + [fv[i].rotate(PI/8,axis=DOWN) for i in range(16)] + [fv[i].shift(spaceloc2[i]) for i in range(16)] + fvfield=VGroup(*fv) + fvfield.shift(0.5*IN+2*DOWN) + + flux=TextMobject("Flux through one side of the cube").set_color(ORANGE) + flux.shift(3*UP+1.5*LEFT) + + + + + + self.set_camera_orientation(phi=70 * DEGREES,theta=-75*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.play(ShowCreation(vectorfield)) + self.add(fvfield) + self.begin_ambient_camera_rotation(rate=0.01) + + self.play(ShowCreation(cube, run_time=1)) + + self.wait(1) + self.play(ShowCreation(sq3)) + self.wait(1) + self.play(FadeOut(cube)) + self.play(FadeOut(vectorfield)) + self.add_fixed_in_frame_mobjects(flux) + # self.play(ShowCreation(flux)) + self.wait(1) + self.play(ShowCreation(v1),ShowCreation(n1)) + self.wait(6) + # self.stop_ambient_camera_rotation() + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/strokes-theorem/README.md b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/strokes-theorem/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/strokes-theorem/README.md diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/README.md b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/README.md new file mode 100644 index 0000000..a1de8b5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/README.md @@ -0,0 +1,10 @@ +**file1_projection.py** +![file1_projection](projection.gif) +**file2_cube.py** +![file2_cube](cube.gif) +**file3_cube_sideC.py** +![file3_cube_sideC](sideC.gif) +**file4_pauseandponder.py** +![file4_pauseandponder](pauseandponder.gif) +**file5_surface.py** +![file5_surface](file5_surface.gif) diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/cube.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/cube.gif Binary files differnew file mode 100644 index 0000000..2035d7a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/cube.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file1_projection.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file1_projection.py new file mode 100644 index 0000000..2d6f067 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file1_projection.py @@ -0,0 +1,89 @@ +from manimlib.imports import * + +class Surface(ThreeDScene): + + def construct(self): + axes=ThreeDAxes() + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + + + para_hyp = ParametricSurface( + lambda u, v: np.array([ + u, + v, + 2+u/4+np.sin(v) + ]),v_min=-3,v_max=-0.4,u_min=-1,u_max=1, + resolution=(15, 32)).scale(1) + para_hyp.scale(0.3) + para_hyp.shift(1.2*RIGHT + 0.2*OUT + 0.4*DOWN) + para_hyp.rotate(PI,axis=RIGHT) + para_hyp.scale(2.5) + # para_hyp.rotate(PI/3.2,axis=OUT) + para_hyp2= ParametricSurface( + lambda u, v: np.array([ + u, + v, + 2+u/4+np.sin(v) + ]),v_min=-3,v_max=-0.4,u_min=-1,u_max=1, + resolution=(15, 32)).scale(1) + para_hyp2.scale(0.3) + para_hyp2.shift(1.2*RIGHT + 0.2*OUT + 0.4*DOWN) + para_hyp2.rotate(PI,axis=RIGHT) + para_hyp2.scale(2.5) + + rec=Rectangle(height=2.11, width=1.58, color=RED, fill_opacity=0.66) + rec.shift(1.3*RIGHT + 2.295*DOWN) + # rec.scale(2.5) + + + l1=DashedLine(start=0.5*RIGHT+1.1*DOWN+1.55*OUT,end=0.5*RIGHT+1.1*DOWN) + l2=DashedLine(start=2.1*RIGHT+1.1*DOWN+1.25*OUT,end=2.1*RIGHT+1.1*DOWN) + l3=DashedLine(start=2.1*RIGHT+3.4*DOWN+1.6*OUT,end=2.1*RIGHT+3.4*DOWN) + l4=DashedLine(start=0.5*RIGHT+3.4*DOWN+2*OUT,end=0.5*RIGHT+3.4*DOWN) + l=VGroup(l1,l2,l3,l4) + + + + s=TextMobject("S",tex_to_color_map={"S": YELLOW}) + s.rotate(PI/4,axis=RIGHT) + s.rotate(PI/15,axis=OUT) + s.shift(RIGHT + 2*OUT + 1.5*DOWN) + d=TextMobject("D",tex_to_color_map={"D": YELLOW}) + d.scale(0.85) + d.shift(1.26*RIGHT + 2.45*DOWN) + + + + + + self.set_camera_orientation(phi=75 * DEGREES,theta=-60*DEGREES) + self.begin_ambient_camera_rotation(rate=-0.02) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.wait(1.3) + self.play(ShowCreation(para_hyp)) + self.play(ShowCreation(s)) + self.add(para_hyp2) + self.play(Transform(para_hyp,rec),run_time=2) + self.play(ShowCreation(d)) + + self.wait(3) + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file2_cube.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file2_cube.py new file mode 100644 index 0000000..2a094c8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file2_cube.py @@ -0,0 +1,75 @@ +from manimlib.imports import* +class cuber(ThreeDScene): + + def construct(self): + + axes=ThreeDAxes() + cube=Cube(color=RED) + # cube.scale(1) + cube.shift(RIGHT+DOWN+OUT) + + sq1=Square(side_length=2,color=RED, fill_opacity=0.5) + sq1.shift(RIGHT+DOWN) + # sq1.scale(1.2) + sq2=Square(color=YELLOW, fill_opacity=0.5) + sq2.rotate(PI/2,axis=RIGHT) + sq2.shift(RIGHT+OUT) + + sq3=Square(color=GREEN , fill_opacity=0.5) + sq3.rotate(PI/2, axis=UP) + sq3.shift(DOWN+OUT) + + a=TextMobject("side A",tex_to_color_map={"side A": BLACK}) + b=TextMobject("side B",tex_to_color_map={"side B": BLACK}) + c=TextMobject("side C",tex_to_color_map={"side C": BLACK}) + a.rotate(PI/2, axis=RIGHT) + a.shift(RIGHT+OUT+2*DOWN) + b.rotate(PI/2, axis=OUT) + b.rotate(PI/2, axis=UP) + b.shift(2*RIGHT+DOWN+OUT) + c.shift(RIGHT+DOWN+2*OUT) + c.rotate(PI/4, axis=OUT) + + + axes=ThreeDAxes() + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + + + + self.set_camera_orientation(phi=75 * DEGREES,theta=-67*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.play(ShowCreation(cube)) + self.begin_ambient_camera_rotation(rate=0.04) + self.wait(0.7) + self.play(ShowCreation(sq1)) + self.play(ShowCreation(sq2)) + + self.play(ShowCreation(sq3)) + self.wait(0.6) + self.play(ShowCreation(a)) + + self.play(ShowCreation(b)) + self.move_camera(phi=60*DEGREES,run_time=1) + self.play(ShowCreation(c)) + self.wait(1) + self.wait(2) + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file3_cube_sideC.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file3_cube_sideC.py new file mode 100644 index 0000000..0e6fdaa --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file3_cube_sideC.py @@ -0,0 +1,96 @@ +from manimlib.imports import* + + + +class cuber(ThreeDScene): + + def construct(self): + + axes=ThreeDAxes() + cube=Cube(color=RED) + # cube.scale(1) + cube.shift(RIGHT+DOWN+OUT) + + sq1=Square(side_length=1.95,color=BLUE, fill_opacity=1) + sq1.shift(RIGHT+DOWN+2*OUT) + # sq1.scale(1.2) + + sq12=Square(side_length=1.95,color=BLUE, fill_opacity=1) + sq12.shift(RIGHT+DOWN+2*OUT) + + sq2=Square(side_length=1.95,color=RED, fill_opacity=0.6) + sq2.shift(RIGHT+DOWN) + + sq2w=Square(side_length=1.95,color=WHITE, fill_opacity=0.9) + sq2w.shift(RIGHT+DOWN) + + + c=TextMobject("side C",tex_to_color_map={"side C": BLACK}) + + dxdy=TextMobject(r"$dxdy$",tex_to_color_map={r"$dxdy$": WHITE}) + dxdy.scale(0.7) + dxdy.rotate(PI/2, axis=RIGHT) + dxdy.rotate(PI/7, axis=OUT) + dxdy.shift(0.85*RIGHT+0.65*DOWN) + + + + c.shift(RIGHT+DOWN+2*OUT) + c.rotate(PI/4, axis=OUT) + + + + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + v=Vector(color=YELLOW) + # v.scale(2) + v.rotate(PI/2,axis=DOWN) + v.shift(0.4*RIGHT+0.9*DOWN+2.5*OUT) + + + + + + + self.set_camera_orientation(phi=60 * DEGREES,theta=-67*DEGREES) + self.begin_ambient_camera_rotation(rate=0.008) + self.add(axes) + self.add(axis_label) + + self.add(cube) + # self.move_camera(phi=150*DEGREES,theta=-45*DEGREES, run_time=3) + self.wait(1.2) + self.add(sq1) + self.add(sq12) + self.play(ShowCreation(c)) + self.wait(0.7) + self.play(FadeOut(cube)) + self.wait(0.7) + # self.move_camera(phi=75*DEGREES,run_time=2) + self.play(ShowCreation(v)) + self.wait(1) + self.play(Transform(sq1,sq2)) + self.wait(0.7) + self.play(ApplyMethod(sq2w.scale, 0.08)) + self.play(ShowCreation(dxdy)) + self.wait(2) + + + + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file4_pauseandponder.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file4_pauseandponder.py new file mode 100644 index 0000000..a8b5070 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file4_pauseandponder.py @@ -0,0 +1,77 @@ +from manimlib.imports import * + +class Surface(ThreeDScene): + def construct(self): + axes=ThreeDAxes() + cylinder = ParametricSurface( + lambda u, v: np.array([ + np.cos(TAU * v), + v, + u + ]), + resolution=(6, 32)).fade(0.5) #Resolution of the surfaces + + + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + cylinder.rotate(PI/2, axis=RIGHT) + cylinder.shift(2*RIGHT+OUT+DOWN) + cylinder.scale(1.5) + + self.set_camera_orientation(phi=75 * DEGREES,theta=-85*DEGREES) + self.begin_ambient_camera_rotation(rate=0.1) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.play(ShowCreation(cylinder)) + # self.wait(0.7) + + + + self.wait(2) + self.stop_ambient_camera_rotation() + self.wait(0.7) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file5_surface.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file5_surface.gif Binary files differnew file mode 100644 index 0000000..27dcac8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file5_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file5_surface.py index a794f46..3c2e145 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/file5_surface.py @@ -1,6 +1,6 @@ from manimlib.imports import * -class SurfacesAnimation(ThreeDScene): +class Surf(ThreeDScene): CONFIG = { "axes_config": { @@ -10,7 +10,7 @@ class SurfacesAnimation(ThreeDScene): "y_max": 8, "z_min": 0, "z_max": 6, - "a":1 ,"b": 6, "c":2 , "d":6, + "a":2 ,"b": 6, "c":1 , "d":6, "axes_shift":-3*OUT + 5*LEFT, "x_axis_config": { "tick_frequency": 1, @@ -49,11 +49,11 @@ class SurfacesAnimation(ThreeDScene): theta=-80 * DEGREES, ) - fn_text=TextMobject("$z=f(x,y)$").set_color(PINK) + fn_text=TextMobject("$S$").set_color(BLUE) self.add_fixed_in_frame_mobjects(fn_text) fn_text.to_edge(TOP,buff=MED_SMALL_BUFF) - R=TextMobject("R").set_color(BLACK).scale(3) + R=TextMobject("D").set_color(BLACK).scale(3) R.move_to(self.axes.input_plane,IN) self.add(R) @@ -64,26 +64,28 @@ class SurfacesAnimation(ThreeDScene): ) surface.set_style( fill_opacity=0.8, - fill_color=PINK, + fill_color=YELLOW, stroke_width=0.8, stroke_color=WHITE, ) - self.begin_ambient_camera_rotation(rate=0.07) + self.begin_ambient_camera_rotation(rate=0.05) self.play(Write(surface)) # self.play(LaggedStart(ShowCreation(surface))) self.get_lines() # self.play(FadeIn(self.axes.input_plane)) - self.wait(3) + self.wait(2) + self.stop_ambient_camera_rotation() + self.wait(1) def get_surface(self,axes, func, **kwargs): config = { - "u_min": axes.a, - "u_max": axes.b, - "v_min": axes.c, - "v_max": axes.d, + "u_min": axes.c, + "u_max": axes.d, + "v_min": axes.a, + "v_max": axes.b, "resolution": ( (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, @@ -112,7 +114,7 @@ class SurfacesAnimation(ThreeDScene): lines=VGroup() for start , end in zip(surface_corners, self.region_corners): - lines.add(self.draw_lines(start,end,"RED")) + lines.add(self.draw_lines(start,end,"WHITE")) for start , end in zip(labels, self.region_corners): @@ -153,7 +155,7 @@ class SurfacesAnimation(ThreeDScene): # Add xy-plane input_plane = self.get_surface( - axes, lambda x, t: 0 + axes, lambda x, t: 1e-5 ) input_plane.set_style( fill_opacity=0.5, @@ -214,23 +216,22 @@ class SurfacesAnimation(ThreeDScene): return axes def add_axes_labels(self, axes): - x_label = TexMobject("x") + x_label = TexMobject("X") x_label.next_to(axes.x_axis.get_end(), RIGHT) axes.x_axis.label = x_label - y_label = TextMobject("y") + y_label = TextMobject("Y") y_label.rotate(90 * DEGREES, OUT) y_label.next_to(axes.y_axis.get_end(), UP) axes.y_axis.label = y_label - z_label = TextMobject("z") + z_label = TextMobject("Z") z_label.rotate(90 * DEGREES, RIGHT) z_label.next_to(axes.z_axis.get_zenith(), RIGHT) axes.z_axis.label = z_label for axis in axes: axis.add(axis.label) return axes + ######Code_by_Somnath_Pandit_https://github.com/panditsomnath10016git######### - -#uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/pauseandponder.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/pauseandponder.gif Binary files differnew file mode 100644 index 0000000..4308c60 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/pauseandponder.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/projection.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/projection.gif Binary files differnew file mode 100644 index 0000000..c0ca611 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/projection.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/sideC.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/sideC.gif Binary files differnew file mode 100644 index 0000000..17b72ff --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/surface-integrals/sideC.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/README.md b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/README.md new file mode 100644 index 0000000..2166a79 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/README.md @@ -0,0 +1,6 @@ +**file1_3D_crossproduct.py** +![file1_3D_crossproduct](file1_3D_crossproduct.gif) +**file2_cylindrical_coordinates.py** +![file2_cylindrical_coordinates](file2_cylindrical_coordinates.gif) +**file2_spherical_coordinates.py** +![file2_spherical_coordinates](file2_spherical_coordinates.gif) diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.gif Binary files differnew file mode 100644 index 0000000..9bde5a1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.py new file mode 100644 index 0000000..6720e7e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file1_3D_crossproduct.py @@ -0,0 +1,120 @@ +from manimlib.imports import* + + + +class TripleBox(ThreeDScene): + + def construct(self): + + axes=ThreeDAxes() + cube=Cube(fill_color=RED,fill_opacity=0.5) + cube.scale(0.5) + cube.shift(0.5*RIGHT+0.5*DOWN+0.5*OUT) + cube.shift(2*RIGHT+2*DOWN+1*OUT) + + + + x=TextMobject("x") + y=TextMobject("y") + z=TextMobject("z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + + a=TextMobject("a") + b=TextMobject("b") + c=TextMobject("c") + d=TextMobject("d") + e=TextMobject("e") + f=TextMobject("f") + + + + a.rotate(PI/2, axis=RIGHT) + a.rotate(PI/2, axis=OUT) + a.shift(2*DOWN+0.3*OUT+0.3*LEFT) + + b.rotate(PI/2, axis=RIGHT) + b.rotate(PI/2, axis=OUT) + b.shift(3*DOWN+0.3*OUT+0.3*LEFT) + + + c.rotate(PI/2, axis=RIGHT) + c.shift(2*RIGHT+0.3*OUT) + + d.rotate(PI/2, axis=RIGHT) + d.shift(3*RIGHT+0.3*OUT) + + + e.rotate(PI/2, axis=RIGHT) + e.rotate(PI/4, axis=OUT) + e.shift(1*OUT+0.3*DOWN+0.2*LEFT) + + + f.rotate(PI/2, axis=RIGHT) + f.rotate(PI/4, axis=OUT) + f.shift(2*OUT+0.3*DOWN+0.2*LEFT) + + + + rec1=Rectangle(height=1, width=8,color=RED, fill_color=RED_C, fill_opacity=0.40) + rec1.shift(2.5*DOWN+4*RIGHT) + + rec2=Rectangle(height=1, width=14,color=RED, fill_color=RED_C, fill_opacity=0.40) + rec2.rotate(PI/2, axis=OUT) + rec2.shift(7*DOWN+2.5*RIGHT) + + + sq=Square(color=RED,fill_opacity=60,side_length=1) + sq.shift(2.5*RIGHT+2.5*DOWN) + + + + self.set_camera_orientation(phi=70 * DEGREES,theta=-70*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.begin_ambient_camera_rotation(rate=0.04) + self.play(ShowCreation(a),ShowCreation(b)) + self.wait(0.5) + self.play(ShowCreation(rec1)) + self.play(ShowCreation(c),ShowCreation(d)) + self.play(ShowCreation(rec2)) + self.add(sq) + self.wait(0.5) + + self.play(FadeOut(rec1),FadeOut(rec2)) + self.wait(1) + + self.play(ShowCreation(e),ShowCreation(f)) + self.wait(0.5) + self.play(ApplyMethod(sq.shift, 1*OUT)) + self.wait(0.5) + self.play(Transform(sq,cube)) + + + self.wait(0.5) + + + + self.wait(0.5) + + + + + self.wait(3) + self.stop_ambient_camera_rotation() + self.wait(1.5) + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.gif Binary files differnew file mode 100644 index 0000000..e913750 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.py new file mode 100644 index 0000000..d441dc0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_cylindrical_coordinates.py @@ -0,0 +1,164 @@ +from manimlib.imports import* +class Cy(ThreeDScene): + + def construct(self): + + axes=ThreeDAxes() + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + + + + + x1=TextMobject("$x_{1}$") + y1=TextMobject("$y_{1}$") + z1=TextMobject("$z_{1}$") + + + + + x1.rotate(PI/2, axis=RIGHT) + x1.rotate(PI/2, axis=OUT) + x1.shift(2*DOWN+0.3*OUT+0.3*LEFT) + + y1.rotate(PI/2, axis=RIGHT) + y1.shift(2*RIGHT+0.3*OUT) + + z1.rotate(PI/2, axis=RIGHT) + z1.rotate(PI/4, axis=OUT) + z1.shift(2*OUT+0.3*DOWN+0.2*LEFT) + + + d1=Dot(color=RED,radius=0.05) + d2=Dot(color=RED,radius=0.05) + d3=Dot(color=RED,radius=0.05) + + + d1.shift(2*DOWN) + d1.rotate(PI/2,axis=UP) + + d2.rotate(PI/2, axis=RIGHT) + d2.shift(2*RIGHT) + + d3.rotate(PI/2, axis=RIGHT) + d3.rotate(PI/4, axis=OUT) + d3.shift(2*OUT) + + + + l1=DashedLine(color=RED) + l1.scale(5) + l1.shift(2*DOWN+5*RIGHT) + + l2=DashedLine(color=RED) + l2.scale(5) + l2.rotate(PI/2, axis=IN) + l2.shift(2*RIGHT+5*DOWN) + + l3=DashedLine(color=RED) + l3.scale(5) + l3.rotate(PI/4,axis=IN) + l3.shift(2*OUT+4*RIGHT+4*DOWN) + + point=Sphere(radius=0.02, checkerboard_colors=[BLUE,BLUE]) + point.shift(2*RIGHT+2*DOWN) + + proj=Line() + proj.scale(1.414) + proj.rotate(PI/4,axis=IN) + proj.shift(1*RIGHT+1*DOWN) + + + projl=DashedLine() + projl.rotate(PI/2, axis=DOWN) + projl.shift(1*OUT+2*RIGHT+2*DOWN) + + p=TextMobject("$P(x,y,z)$") + p.scale(0.6) + p.rotate(PI/2, axis=RIGHT) + p.rotate(PI/9, axis=OUT) + p.shift(2.9*RIGHT+2.5*DOWN+2.3*OUT) + + rho=TextMobject(r"$\rho$",tex_to_color_map={r"$\rho$": YELLOW}) + rho.rotate(PI/2, axis=RIGHT) + rho.shift(1.5*RIGHT+1.36*DOWN+0.2*OUT) + + + + + carrow=CurvedArrow(start_point=1*DOWN, end_point=0.5*RIGHT+0.5*DOWN) + + + phi=TextMobject(r"$\phi$",tex_to_color_map={"$\phi$": YELLOW}) + phi.scale(0.93) + phi.rotate(PI/2, axis=RIGHT) + phi.shift(0.3*RIGHT+1.3*DOWN) + + + + + + + + + + + self.set_camera_orientation(phi=70 * DEGREES,theta=-15*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.begin_ambient_camera_rotation(rate=-0.1) + + self.play(ShowCreation(x1),ShowCreation(d1)) + self.wait(0.5) + self.play(ShowCreation(l1)) + self.wait(1) + self.play(ShowCreation(y1),ShowCreation(d2)) + self.wait(0.5) + self.play(ShowCreation(l2)) + self.wait(1) + self.add(point) + self.wait(0.5) + self.play(FadeOut(l1),FadeOut(l2)) + self.wait(0.5) + self.play(ShowCreation(proj)) + self.wait(0.64) + self.stop_ambient_camera_rotation() + self.play(ShowCreation(rho)) + self.wait(1) + + self.play(ShowCreation(z1),ShowCreation(d3)) + self.wait(0.5) + self.play(ShowCreation(l3)) + self.wait(1) + self.play(ApplyMethod(point.shift, 2*OUT), ShowCreation(projl)) + self.play(FadeOut(l3)) + self.play(ShowCreation(p),FadeOut(projl)) + self.wait(0.5) + # self.play(ShowCreation(vec)) + + + + + + self.wait(1) + self.play(ShowCreation(carrow),ShowCreation(phi)) + + self.wait(5) + + diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.gif Binary files differnew file mode 100644 index 0000000..6dc8b17 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.py new file mode 100644 index 0000000..7dcc81a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/triple-integrals/file2_spherical_coordinates.py @@ -0,0 +1,159 @@ +from manimlib.imports import* +class Sp(ThreeDScene): + + def construct(self): + + axes=ThreeDAxes() + x=TextMobject("X") + y=TextMobject("Y") + z=TextMobject("Z") + + x.rotate(PI/2, axis=RIGHT) + x.rotate(PI/4,axis=OUT) + x.shift(5.8*DOWN) + + y.rotate(PI/2, axis=RIGHT) + y.rotate(PI/8,axis=OUT) + y.shift(5.8*RIGHT) + + z.rotate(PI/2, axis=RIGHT) + z.rotate(PI/5,axis=OUT) + z.shift(3.2*OUT+0.4*LEFT) + axis_label=VGroup(x,y,z) + + + + + + + + x1=TextMobject("$x_{1}$") + y1=TextMobject("$y_{1}$") + z1=TextMobject("$z_{1}$") + + + + + x1.rotate(PI/2, axis=RIGHT) + x1.rotate(PI/2, axis=OUT) + x1.shift(2*DOWN+0.3*OUT+0.3*LEFT) + + y1.rotate(PI/2, axis=RIGHT) + y1.shift(2*RIGHT+0.3*OUT) + + z1.rotate(PI/2, axis=RIGHT) + z1.rotate(PI/4, axis=OUT) + z1.shift(2*OUT+0.3*DOWN+0.2*LEFT) + + + d1=Dot(color=RED,radius=0.05) + d2=Dot(color=RED,radius=0.05) + d3=Dot(color=RED,radius=0.05) + + + d1.shift(2*DOWN) + d1.rotate(PI/2,axis=UP) + + d2.rotate(PI/2, axis=RIGHT) + d2.shift(2*RIGHT) + + d3.rotate(PI/2, axis=RIGHT) + d3.rotate(PI/4, axis=OUT) + d3.shift(2*OUT) + + + + l1=DashedLine(color=RED) + l1.scale(5) + l1.shift(2*DOWN+5*RIGHT) + + l2=DashedLine(color=RED) + l2.scale(5) + l2.rotate(PI/2, axis=IN) + l2.shift(2*RIGHT+5*DOWN) + + l3=DashedLine(color=RED) + l3.scale(5) + l3.rotate(PI/4,axis=IN) + l3.shift(2*OUT+4*RIGHT+4*DOWN) + + point=Sphere(radius=0.02, checkerboard_colors=[RED,RED]) + + + proj=DashedLine(color=RED_C) + proj.scale(1.414) + proj.rotate(PI/4,axis=IN) + proj.shift(1*RIGHT+1*DOWN) + + + projl=DashedLine() + projl.rotate(PI/2, axis=UP) + projl.shift(1*OUT+2*RIGHT+2*DOWN) + + p=TextMobject("$P(x,y,z)$") + p.scale(0.6) + p.rotate(PI/2, axis=RIGHT) + p.rotate(PI/9, axis=OUT) + p.shift(2.65*RIGHT+2.5*DOWN+2.3*OUT) + + rho=TextMobject(r"$\rho$",tex_to_color_map={r"$\rho$": YELLOW}) + rho.rotate(PI/2, axis=RIGHT) + rho.shift(1.45*RIGHT+1.9*DOWN+1.94*OUT) + + + + + + carrow=ArcBetweenPoints(start=1*DOWN, end=0.5*RIGHT+0.5*DOWN) + carrow2=ArcBetweenPoints(start=0.5*RIGHT+0.5*DOWN+0.5*OUT, end=0.4*OUT) + # carrow2.rotate(PI/2, axis=LEFT) + # carrow2.rotate(PI/2, axis=UP) + + theta=TextMobject(r"$\theta$",tex_to_color_map={r"$\theta$": YELLOW}) + theta.shift((0.75*OUT+0.2*RIGHT)) + theta.rotate(PI/2,axis=RIGHT) + theta.scale(0.9) + + + + + phi=TextMobject(r"$\phi$",tex_to_color_map={"$\phi$": YELLOW}) + phi.scale(0.93) + phi.rotate(PI/2, axis=RIGHT) + phi.shift(0.42*RIGHT+1.3*DOWN) + + + + + + + + + + + self.set_camera_orientation(phi=70 * DEGREES,theta=-85*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.begin_ambient_camera_rotation(rate=0.009) + self.wait(1) + self.add(point) + self.play(ApplyMethod(point.shift, 2*RIGHT+2*DOWN+2*OUT)) + self.wait(0.5) + self.play(ShowCreation(p)) + self.wait(0.5) + self.play(ShowCreation(vec),ShowCreation(rho)) + self.wait(1.5) + self.play(ApplyMethod(point.shift,2*IN), ShowCreation(projl)) + self.wait(1) + self.play(ShowCreation(proj)) + self.wait(1.2) + self.play(ShowCreation(carrow)) + self.wait(0.64) + self.play(ShowCreation(phi)) + self.wait(1.3) + self.play(ShowCreation(carrow2)) + self.wait(0.5) + self.play(ShowCreation(theta)) + self.wait(3) + + + diff --git a/FSF-2020/calculus/intro-to-calculus/README.md b/FSF-2020/calculus/intro-to-calculus/README.md index e69de29..a417361 100644 --- a/FSF-2020/calculus/intro-to-calculus/README.md +++ b/FSF-2020/calculus/intro-to-calculus/README.md @@ -0,0 +1,8 @@ +Contributor: Aryan Singh
+Subtopics covered
+ - When do limits exist?
+ - How Fast am I going?-An intro to derivatives
+ - Infinte sums in a nutshell(Riemann integrals)
+ - Fundamental Theorem of calculus
+ - Volume and surface area of Gabriel's Horn
+ - Infinite sequences and series
diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md new file mode 100644 index 0000000..c5d8389 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md @@ -0,0 +1,17 @@ +### Dividing a tone into its constituents +![GIF1](gifs/file1.gif) + +### Colors Analogy +![GIF2](gifs/file2a.gif) + +### Applying the same on Graphs +![GIF3](gifs/file2b.gif) + +### Fourier series for non-periodic functions +![GIF4](gifs/file3.gif) + +### Fourier Series of Square pulse +![GIF5](gifs/file4.gif) + +### Coins Analogy +![GIF6](gifs/file5.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif Binary files differnew file mode 100644 index 0000000..d4dc9d7 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file1.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif Binary files differnew file mode 100644 index 0000000..8f83bc4 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2a.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif Binary files differnew file mode 100644 index 0000000..d68c405 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file2b.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif Binary files differnew file mode 100644 index 0000000..533368b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file3.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif Binary files differnew file mode 100644 index 0000000..36cd61b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file4.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif Binary files differnew file mode 100644 index 0000000..9757bd6 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file5.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py new file mode 100644 index 0000000..39db6d8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py @@ -0,0 +1,90 @@ +from manimlib.imports import* +import numpy as np + +# def func(t,n): +# s=0 +# for i in range(1,n+1): +# s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) +# return s + + +class intro(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 6, + "y_min": -5, + "y_max": 5, + "graph_origin": 10.5*LEFT, + "axes_color": BLUE, + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def func(self,t,n1,n2): + s=0 + for i in range(n1,n2+1): + s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) + return s + + def construct(self): + image=ImageMobject('image.png').shift(5.5*LEFT+2.5*UP).scale(1.5) + self.play(ShowCreation(image)) + + self.setup_axes(scalee=1) + + mainGraphs=[ + self.get_graph(lambda x:self.func(x,2,7),x_max=2,x_min=-2).shift(9.3*RIGHT+3*UP).set_color([ORANGE,GREEN_B,RED_E,YELLOW_E,RED_D,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,3,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([GREEN_B,ORANGE,RED_D,YELLOW_E,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,4,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([GREEN_B,YELLOW_E,ORANGE,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,5,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([YELLOW_E,GREEN_B,YELLOW_D]).scale(1.4), + self.get_graph(lambda x:self.func(x,6,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP).set_color([YELLOW_D,GREEN_B]).scale(1.4), + self.get_graph(lambda x:self.func(x,7,7),x_max=2,x_min=-2,color=GREEN_B).shift(10.8*RIGHT+3*UP).scale(1.4), + ] + self.play(ApplyMethod(mainGraphs[0].shift,1.5*RIGHT)) + + graph1=self.get_graph(lambda x:self.func(x,2,2),x_max=2,x_min=-2,color=RED_E).shift(10.8*RIGHT+3*UP).scale(1.5) + graph2=self.get_graph(lambda x:self.func(x,3,3),x_max=2,x_min=-2,color=RED_D).shift(10.8*RIGHT+3*UP).scale(1.5) + graph3=self.get_graph(lambda x:self.func(x,4,4),x_max=2,x_min=-2,color=ORANGE).shift(10.8*RIGHT+3*UP).scale(1.5) + graph4=self.get_graph(lambda x:self.func(x,5,5),x_max=2,x_min=-2,color=YELLOW_E).shift(10.8*RIGHT+3*UP).scale(1.5) + graph5=self.get_graph(lambda x:self.func(x,6,6),x_max=2,x_min=-2,color=YELLOW_D).shift(10.8*RIGHT+3*UP).scale(1.5) + + coeff=[ + TextMobject("$\\frac { -1 }{ \pi } sin(4\pi t)$").scale(0.5).shift(DOWN+4.6*RIGHT+3*UP).set_color(RED_E), + TextMobject("$\\frac { 2 }{ 3\pi } sin(6\pi t)$").scale(0.5).shift(2*DOWN+4.6*RIGHT+3*UP).set_color(RED_D), + TextMobject("$\\frac { -1 }{ 2\pi } sin(8\pi t)$").scale(0.5).shift(3*DOWN+4.6*RIGHT+3*UP).set_color(ORANGE), + TextMobject("$\\frac { 2 }{ 5\pi } sin(10\pi t)$").scale(0.5).shift(4*DOWN+4.6*RIGHT+3*UP).set_color(YELLOW_E), + TextMobject("$\\frac { -1 }{ 3\pi } sin(12\pi t)$").scale(0.5).shift(5*DOWN+4.6*RIGHT+3*UP).set_color(YELLOW_D), + TextMobject("$\\frac { 2 }{ 7\pi } sin(14\pi t)$").scale(0.5).shift(6*DOWN+4.6*RIGHT+3*UP).set_color(GREEN_B) + ] + + self.wait(0.6) + self.play(ApplyMethod(graph1.shift,1*DOWN),ReplacementTransform(mainGraphs[0],mainGraphs[1])) + self.play(Write(coeff[0])) + self.play(ApplyMethod(graph2.shift,2*DOWN),ReplacementTransform(mainGraphs[1],mainGraphs[2])) + self.play(Write(coeff[1])) + self.play(ApplyMethod(graph3.shift,3*DOWN),ReplacementTransform(mainGraphs[2],mainGraphs[3])) + self.play(Write(coeff[2])) + self.play(ApplyMethod(graph4.shift,4*DOWN),ReplacementTransform(mainGraphs[3],mainGraphs[4])) + self.play(Write(coeff[3])) + self.play(ApplyMethod(graph5.shift,5*DOWN),ReplacementTransform(mainGraphs[4],mainGraphs[5])) + self.play(Write(coeff[4])) + self.play(ApplyMethod(mainGraphs[5].shift,6*DOWN)) + self.play(Write(coeff[5])) + + pluses=[TextMobject("+"),TextMobject("+"),TextMobject("+"),TextMobject("+"),TextMobject("+")] + for t in pluses: + t.scale(0.5).shift((2.2-1.5*pluses.index(t))*LEFT) + + finalGraph=self.get_graph(lambda x:self.func(x,2,7),x_max=2,x_min=-2).shift(10.8*RIGHT+3*UP) + finalGraph.set_color([GREEN_B,YELLOW_D,YELLOW_E,ORANGE,RED_D,RED_E]) + finalGroup=VGroup(graph1,graph2,graph3,graph4,graph5,mainGraphs[5]) + self.play(ReplacementTransform(finalGroup,finalGraph)) + self.play(ApplyMethod(coeff[0].scale,0.7),ApplyMethod(coeff[1].scale,0.7),ApplyMethod(coeff[2].scale,0.7),ApplyMethod(coeff[3].scale,0.7),ApplyMethod(coeff[4].scale,0.7),ApplyMethod(coeff[5].scale,0.7)) + #self.play(ApplyMethod(coeff[0].shift,7*LEFT+1.6*DOWN),ApplyMethod(coeff[1].shift,5.5*LEFT+0.8*DOWN),ApplyMethod(coeff[2].shift,4*LEFT),ApplyMethod(coeff[3].shift,2.5*LEFT+0.8*UP),ApplyMethod(coeff[4].shift,LEFT+1.6*UP),ApplyMethod(coeff[5].shift,0.5*RIGHT+2.4*DOWN)) + self.play(ApplyMethod(coeff[0].shift,7.6*LEFT+2*DOWN),ApplyMethod(coeff[1].shift,6.1*LEFT+DOWN),ApplyMethod(coeff[2].shift,4.6*LEFT),ApplyMethod(coeff[3].shift,3.1*LEFT+UP),ApplyMethod(coeff[4].shift,1.6*LEFT+2*UP),ApplyMethod(coeff[5].shift,0.1*LEFT+3*UP)) + equal=TextMobject("=").scale(1.5).shift(1.5*UP) + self.play(Write(equal)) + self.play(Write(pluses[0]),Write(pluses[1]),Write(pluses[2]),Write(pluses[3]),Write(pluses[4])) + group=VGroup(pluses[0],pluses[1],pluses[2],pluses[3],pluses[4],coeff[0],coeff[1],coeff[2],coeff[3],coeff[4],coeff[5]) + self.play(ApplyMethod(group.scale,1.5)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py new file mode 100644 index 0000000..8f3706b --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py @@ -0,0 +1,165 @@ +from manimlib.imports import* +import numpy as np + +def func(t,n1,n2): + s=0 + for i in range(n1,n2+1): + s+=((-2/(i*np.pi))*((-1)**i)*np.sin(2*np.pi*i*t)) + return s + +class divideColors(GraphScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -1, + "y_max": 1, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "x_labeled_nums": range(-1, 2, 1), + "x_axis_width": 3, + "y_axis_height": 2 + } + def construct(self): + text1a=TextMobject("Consider dividing a","mixture of colors") + text1b=TextMobject("into its","components") + text1a.scale(0.8) + text1b.scale(0.8) + text1a.shift(UP) + text1b.shift(0.3*UP) + text1a.set_color_by_tex_to_color_map({"mixture of colors":[GREEN,RED,BLUE,YELLOW]}) + text1b.set_color_by_tex_to_color_map({"components":GREEN}) + self.play(Write(text1a)) + self.play(FadeIn(text1b)) + self.wait(0.8) + + self.play(FadeOut(text1a),FadeOut(text1b)) + + mainCircle=Circle(radius=1.4,color=BLACK,fill_color=[PURPLE_E,PURPLE_D,RED_B,ORANGE,YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + self.play(ShowCreation(mainCircle)) + self.wait(1) + mainCirclea=Circle(radius=1.4,color=BLACK,fill_color=[RED_B,ORANGE,YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + mainCircleb=Circle(radius=1.4,color=BLACK,fill_color=[YELLOW_B,YELLOW_D,GREEN_A,GREEN_C],fill_opacity=0.8) + mainCirclec=Circle(radius=1.4,color=BLACK,fill_color=[GREEN_A,GREEN_C],fill_opacity=0.8) + mainCircled=Circle(radius=1.4,color=BLACK,fill_color=[],fill_opacity=0.8) + + c1=Circle(radius=0.5,color=PURPLE_E,fill_color=PURPLE_E,fill_opacity=0.8) + c2=Circle(radius=0.5,color=PURPLE_D,fill_color=PURPLE_D,fill_opacity=0.8) + c3=Circle(radius=0.5,color=RED_D,fill_color=RED_B,fill_opacity=0.8) + c4=Circle(radius=0.5,color=ORANGE,fill_color=ORANGE,fill_opacity=0.8) + c5=Circle(radius=0.5,color=YELLOW_B,fill_color=YELLOW_B,fill_opacity=0.8) + c6=Circle(radius=0.5,color=YELLOW_D,fill_color=YELLOW_D,fill_opacity=0.8) + c7=Circle(radius=0.5,color=GREEN_A,fill_color=GREEN_A,fill_opacity=0.8) + c8=Circle(radius=0.5,color=GREEN_C,fill_color=GREEN_C,fill_opacity=0.8) + + self.play(ApplyMethod(c1.shift,3*UP+LEFT),ApplyMethod(c2.shift,3*UP+RIGHT),ReplacementTransform(mainCircle,mainCirclea)) + self.wait(0.8) + + self.play(ApplyMethod(c3.shift,UP+3*LEFT),ApplyMethod(c4.shift,DOWN+3*LEFT),ReplacementTransform(mainCirclea,mainCircleb)) + self.wait(0.8) + + self.play(ApplyMethod(c5.shift,3*DOWN+LEFT),ApplyMethod(c6.shift,3*DOWN+RIGHT),ReplacementTransform(mainCircleb,mainCirclec)) + self.wait(0.8) + + self.play(ApplyMethod(c7.shift,3*RIGHT+UP),ApplyMethod(c8.shift,3*RIGHT+DOWN),ReplacementTransform(mainCirclec,mainCircled)) + self.wait(1) + + text2=TextMobject("Similarly,").scale(0.8).shift(UP).set_color(RED) + + self.play(FadeOut(c1),FadeOut(c2),FadeOut(c3),FadeOut(c4),FadeOut(c5),FadeOut(c6),FadeOut(c7),FadeOut(c8)) + self.play(Write(text2)) + self.wait(0.8) + self.play(FadeOut(text2)) + + + coeff=[ + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=1 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ \pi } sin(2\pi t)$").scale(0.3).shift(RIGHT+UP+4*LEFT+UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=2 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ \pi } sin(4\pi t)$").scale(0.3).shift(RIGHT+UP+4*RIGHT+UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=3 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ 3\pi } sin(6\pi t)$").scale(0.3).shift(RIGHT+UP+4*LEFT+2*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=4 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ 2\pi } sin(8\pi t)$").scale(0.3).shift(RIGHT+UP+4*RIGHT+2*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=5 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { 2 }{ 5\pi } sin(10\pi t)$").scale(0.3).shift(RIGHT+UP+2.5*UP), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=6 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + TextMobject("$\\frac { -1 }{ 3\pi } sin(12\pi t)$").scale(0.3).shift(RIGHT+UP+2.5*DOWN), + TextMobject("$\\frac { -2 }{ \pi } \sum _{ n=7 }^{ 24 }{ \\frac { { -1 }^{ n } }{ n } sin(2\pi nt) }$").scale(0.2).shift(RIGHT+UP), + ] + + axes=[] + self.setup_axes(scalee=1) + axes.append(self.axes) + graphs=[self.get_graph(lambda x:func(x,1,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GREEN_E,GREEN_C,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,2,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GREEN_C,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,3,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GOLD_E,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,4,24),x_min=-1,x_max=1).set_color([DARK_BROWN,GOLD_C,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,5,24),x_min=-1,x_max=1).set_color([DARK_BROWN,ORANGE,RED_C]), + self.get_graph(lambda x:func(x,6,24),x_min=-1,x_max=1).set_color([DARK_BROWN,RED_C]), + self.get_graph(lambda x:func(x,7,24),x_min=-1,x_max=1).set_color(DARK_BROWN) + ] + #self.y_axis_label="$\\frac { 2 }{ \pi } sin(2\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph1=self.get_graph(lambda x:func(x,1,1),x_min=-1,x_max=1,color=GREEN_E) + #self.y_axis_label="$\\frac { -1 }{ \pi } sin(4\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph2=self.get_graph(lambda x:func(x,2,2),x_min=-1,x_max=1,color=GREEN_C) + #self.y_axis_label="$\\frac { 2 }{ 3\pi } sin(6\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph3=self.get_graph(lambda x:func(x,3,3),x_min=-1,x_max=1,color=GOLD_E) + #self.y_axis_label="$\\frac { -1 }{ 2\pi } sin(8\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph4=self.get_graph(lambda x:func(x,4,4),x_min=-1,x_max=1,color=GOLD_C) + #self.y_axis_label="$\\frac { 2 }{ 5\pi } sin(10\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph5=self.get_graph(lambda x:func(x,5,5),x_min=-1,x_max=1,color=ORANGE) + #self.y_axis_label="$\\frac { -1 }{ 3\pi } sin(12\pi t)$" + self.setup_axes(scalee=1) + axes.append(self.axes) + graph6=self.get_graph(lambda x:func(x,6,6),x_min=-1,x_max=1,color=RED_C) + + groups=[VGroup(axes[1],graph1),VGroup(axes[2],graph2),VGroup(axes[3],graph3),VGroup(axes[4],graph4), + VGroup(axes[5],graph5),VGroup(axes[6],graph6)] + + self.play(ShowCreation(graphs[0])) + self.play(Write(coeff[0])) + self.wait(1) + # self.play(ApplyMethod(axes[0].scale,0.4),ApplyMethod(graphs[0].scale,0.4),ApplyMethod(axes[1].scale,0.4), + # ApplyMethod(axes[2].scale,0.4),ApplyMethod(axes[3].scale,0.4), + # ApplyMethod(axes[4].scale,0.4),ApplyMethod(axes[5].scale,0.4),ApplyMethod(axes[6].scale,0.4)) + self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(groups[0].shift,4*LEFT+UP),ReplacementTransform(coeff[0],coeff[2]),FadeIn(coeff[1])) + self.play(ReplacementTransform(graphs[1],graphs[2]),ApplyMethod(groups[1].shift,4*RIGHT+UP),ReplacementTransform(coeff[2],coeff[4]),FadeIn(coeff[3])) + self.play(ReplacementTransform(graphs[2],graphs[3]),ApplyMethod(groups[2].shift,4*LEFT+2*DOWN),ReplacementTransform(coeff[4],coeff[6]),FadeIn(coeff[5])) + self.play(ReplacementTransform(graphs[3],graphs[4]),ApplyMethod(groups[3].shift,4*RIGHT+2*DOWN),ReplacementTransform(coeff[6],coeff[8]),FadeIn(coeff[7])) + self.play(ReplacementTransform(graphs[4],graphs[5]),ApplyMethod(groups[4].shift,2.5*UP),ReplacementTransform(coeff[8],coeff[10]),FadeIn(coeff[9])) + self.play(ReplacementTransform(graphs[5],graphs[6]),ApplyMethod(groups[5].shift,2.5*DOWN),ReplacementTransform(coeff[10],coeff[12]),FadeIn(coeff[11])) + + # self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(groups[0].shift,3*LEFT)) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + # self.play(ReplacementTransform(graphs[0],graphs[1]),) + + + + self.wait(2) + # self.play(ReplacementTransform(function,const)) + # self.play(ShowCreation(sinx),ShowCreation(cosx)) + # self.play(ShowCreation(sin2x),ShowCreation(cos2x)) + # self.play(ShowCreation(sin3x),ShowCreation(cos3x)) + # self.play(ShowCreation(sin4x),ShowCreation(cos4x)) + # sintext=TextMobject("Infinite","sines").shift(5*RIGHT).set_color_by_tex_to_color_map({"Infinite":[YELLOW,RED],"sines":BLUE}) + # costext=TextMobject("Infinite","cosines").shift(5*LEFT).set_color_by_tex_to_color_map({"Infinite":[YELLOW,RED],"cosines":BLUE}) + # sintext.scale(0.6) + # costext.scale(0.6) + # self.play(FadeIn(sintext),FadeIn(costext)) + # self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py new file mode 100644 index 0000000..f23e54f --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py @@ -0,0 +1,133 @@ +from manimlib.imports import * +import numpy as np + +class compare(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 6, + "y_min": -5, + "y_max": 5, + "y_axis_label":"$\\frac { { x }^{ 2 } }{ 2 } $", + "graph_origin": ORIGIN, + "axes_color": BLUE, + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def returnPairLines(self,left,right,y_each_unit): + lineLeft=DashedLine(start=(0,5*y_each_unit,0),end=(0,-5*y_each_unit,0)).shift(left) + lineRight=DashedLine(start=(0,5*y_each_unit,0),end=(0,-5*y_each_unit,0)).shift(right) + return lineLeft,lineRight + + def resultFunc(self,x,n,l): + s=(l**2)/6 + for n in range(1,n+1): + s+=(2*((-1)**n))*((l**2)*np.cos(n*np.pi*x/l))*(1/((np.pi**2)*(n**2))) + return s + + def returnPartFunction(self,left,right): + return self.get_graph(lambda x:(x**2)/2,x_min=left,x_max=right,color=RED) + + def returnPartResult(self,l,n): + return self.get_graph(lambda x:self.resultFunc(x,n,l),x_min=-3,x_max=3,color=RED) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + axes=[] + self.setup_axes(animate=True,scalee=1) + axes.append(self.axes) + partFunction1=self.returnPartFunction(-1,1).shift(4*LEFT) + partFunction2=self.returnPartFunction(-2,2).shift(4*LEFT) + functionText=TextMobject("$\\frac { { x }^{ 2 } }{ 2 } $") + function=self.get_graph(lambda x:(x**2)/2,x_min=-3,x_max=3,color=GREEN) + text1=TextMobject("Non-Periodic function").scale(0.5).shift(3*DOWN+3*RIGHT).set_color(RED) + self.play(ShowCreation(function)) + self.play(FadeIn(text1)) + self.wait(1) + self.play(FadeOut(text1)) + self.play(ApplyMethod(axes[0].shift,4*LEFT),ApplyMethod(function.shift,4*LEFT)) + text2=TextMobject("For a","given","interval of $x$,").scale(0.5).shift(2.5*RIGHT+UP).set_color_by_tex_to_color_map({"given":YELLOW,"interval of $x$,":BLUE}) + text3=TextMobject("We can get the","Fourier Series","of that","particular part!").scale(0.4).shift(2.5*RIGHT+0.5*UP).set_color_by_tex_to_color_map({"particular part!":YELLOW,"Fourier Series":RED}) + self.play(Write(text2)) + left,right=self.returnPairLines((4+x_each_unit)*LEFT,(4-x_each_unit)*LEFT,y_each_unit) + self.play(ShowCreation(left),ShowCreation(right)) + self.play(Write(text3)) + self.wait(0.5) + self.play(FadeOut(text2),FadeOut(text3)) + self.graph_origin=3.5*RIGHT + self.y_axis_label="$\\frac { { l }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ \infty }{ \\frac { 2{ (-1) }^{ n }{ l }^{ 2 }cos(\\frac { n\pi x }{ l } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$" + self.setup_axes(animate=True,scalee=1) + axes.append(self.axes) + coeffResult=[ + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 1 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 3 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 5 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 7 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 9 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 11 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW), + TextMobject("$\\frac { { 1 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 13 }{ \\frac { 2{ (-1) }^{ n }{ 1 }^{ 2 }cos(\\frac { n\pi x }{ 1 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+UP).set_color(YELLOW) + ] + result1a=self.returnPartResult(1,1) + result1b=self.returnPartResult(1,3) + result1c=self.returnPartResult(1,5) + result1d=self.returnPartResult(1,7) + result1e=self.returnPartResult(1,9) + result1f=self.returnPartResult(1,11) + result1g=self.returnPartResult(1,13) + self.play(ApplyMethod(partFunction1.shift,0.2*UP)) + self.wait(0.5) + self.play(ReplacementTransform(partFunction1,result1a),Write(coeffResult[0])) + self.play(ReplacementTransform(result1a,result1b),ReplacementTransform(coeffResult[0],coeffResult[1])) + self.play(ReplacementTransform(result1b,result1c),ReplacementTransform(coeffResult[1],coeffResult[2])) + self.play(ReplacementTransform(result1c,result1d),ReplacementTransform(coeffResult[2],coeffResult[3])) + self.play(ReplacementTransform(result1d,result1e),ReplacementTransform(coeffResult[3],coeffResult[4])) + self.play(ReplacementTransform(result1e,result1f),ReplacementTransform(coeffResult[4],coeffResult[5])) + self.play(ReplacementTransform(result1f,result1g),ReplacementTransform(coeffResult[5],coeffResult[6])) + + text4=TextMobject("Here the","obtained function","will always be","periodic","with period equal to the chosen interval").scale(0.4).shift(3.3*DOWN).set_color_by_tex_to_color_map({"obtained function":YELLOW,"periodic":RED}) + self.play(Write(text4)) + + self.wait(0.8) + + self.play(FadeOut(text4)) + text5=TextMobject("As we","increase","the","interval of $x$,").scale(0.5).shift(3*DOWN).set_color_by_tex_to_color_map({"increase":RED,"interval of $x$,":YELLOW}) + text6=TextMobject("We get","approximation","for","higher intervals!").scale(0.5).shift(3.5*DOWN).set_color_by_tex_to_color_map({"approximation":GREEN,"higher intervals!":YELLOW}) + self.play(Write(text5)) + self.play(Write(text6)) + result2=self.returnPartResult(1.5,20) + result3=self.returnPartResult(2,20) + result4=self.returnPartResult(2.5,20) + result5=self.returnPartResult(3,20) + finalCoeff=coeffResult[6] + coeffResult=[ + TextMobject("$\\frac { { 1.5 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 1.5 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 2.5 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2.5 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + TextMobject("$\\frac { { 3 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 3 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP).set_color(YELLOW), + ] + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result1g,result2),ReplacementTransform(finalCoeff,coeffResult[0])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result2,result3),ReplacementTransform(coeffResult[0],coeffResult[1])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result3,result4),ReplacementTransform(coeffResult[1],coeffResult[2])) + self.play(ApplyMethod(left.shift,LEFT*x_each_unit*0.5),ApplyMethod(right.shift,RIGHT*x_each_unit*0.5),ReplacementTransform(result4,result5),ReplacementTransform(coeffResult[2],coeffResult[3])) + + + # coeffResult=[ + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 1 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } }$").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 4 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 10 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # TextMobject("$\\frac { { 2 }^{ 2 } }{ 6 } +\sum _{ n=1 }^{ 20 }{ \\frac { 2{ (-1) }^{ n }{ 2 }^{ 2 }cos(\\frac { n\pi x }{ 2 } ) }{ { \pi }^{ 2 }{ n }^{ 2 } } } $").scale(0.3).shift(4.5*RIGHT+1.5*UP), + # ] + # result2a=self.returnPartResult(2,1) + # result2b=self.returnPartResult(2,4) + # result2c=self.returnPartResult(2,10) + # result2d=self.returnPartResult(2,20) + + # self.play(ReplacementTransform(partFunction2,result2a),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2a,result2b),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2b,result2c),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.play(ReplacementTransform(result2c,result2d),ReplacementTransform(coeffResult[0],coeffResult[1])) + # self.wait(0.5) + + + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py new file mode 100644 index 0000000..5d33fbe --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py @@ -0,0 +1,92 @@ +from manimlib.imports import * +import numpy as np + +def returnSum(k,x): + summ=0 + for i in range(1,k+1,2): + summ+=((np.sin(2*np.pi*i*x))/i) + return summ + +def returnFunc(self,k): + graph=self.get_graph(lambda x:(4/np.pi)*returnSum(k,x),color=WHITE,x_max=1,x_min=-1) + return graph + +class fourierSeries(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "x_axis_width": 13, + "y_min": -3, + "y_max": 3, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$x$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "x_labeled_nums": range(-2, 3, 1), + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + equation=TextMobject("$f(x)=\\frac { 4 }{ \pi } \sum _{ k=1,3,5.. }^{ \infty }{ \\frac { 1 }{ k } \sin { 2\pi kx } }$").shift(5*RIGHT+3*UP).set_color(RED).scale(0.4) + self.add(equation) + self.setup_axes(animate=True) + line1=Line(start=(-x_each_unit,y_each_unit,0),end=(-(1/2)*x_each_unit,y_each_unit,0),color=RED) + line2=Line(start=(-(1/2)*x_each_unit,y_each_unit,0),end=(-(1/2)*x_each_unit,-y_each_unit,0),color=RED) + line3=Line(start=(-(1/2)*x_each_unit,-y_each_unit,0),end=(0,-y_each_unit,0),color=RED) + line4=Line(start=(0,-y_each_unit,0),end=(0,y_each_unit,0),color=RED) + line5=Line(start=(0,y_each_unit,0),end=((1/2)*x_each_unit,y_each_unit,0),color=RED) + line6=Line(start=((1/2)*x_each_unit,y_each_unit,0),end=((1/2)*x_each_unit,-y_each_unit,0),color=RED) + line7=Line(start=((1/2)*x_each_unit,-y_each_unit,0),end=(x_each_unit,-y_each_unit,0),color=RED) + self.play(ShowCreation(line1)) + self.play(ShowCreation(line2)) + self.play(ShowCreation(line3)) + self.play(ShowCreation(line4)) + self.play(ShowCreation(line5)) + self.play(ShowCreation(line6)) + self.play(ShowCreation(line7)) + self.wait(0.5) + + labels=[ + TextMobject("$f_{ k=1 }(x)$"), + TextMobject("$f_{ k=3 }(x)$"), + TextMobject("$f_{ k=5 }(x)$"), + TextMobject("$f_{ k=7 }(x)$"), + TextMobject("$f_{ k=9 }(x)$"), + TextMobject("$f_{ k=11 }(x)$"), + TextMobject("$f_{ k=13 }(x)$"), + TextMobject("$f_{ k=15 }(x)$"), + TextMobject("$f_{ k=17 }(x)$"), + TextMobject("$f_{ k=19 }(x)$"), + TextMobject("$f_{ k=85 }(x)$") + ] + p=0 + for i in range(1,20,2): + if(i==1): + graphInitial=returnFunc(self,1) + label=labels[p].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(ShowCreation(graphInitial),Write(labels[0])) + old=graphInitial + oldLabel=label + else: + graph=returnFunc(self,i) + graphLabel=labels[p].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(ReplacementTransform(old,graph),ReplacementTransform(oldLabel,graphLabel)) + old=graph + oldLabel=graphLabel + p+=1 + graphFinal=returnFunc(self,85) + labelFinal=labels[10].scale(0.5).shift(y_each_unit*1.5*UP+RIGHT*x_each_unit*0.3) + self.play(FadeOut(old),FadeOut(oldLabel)) + self.play(ShowCreation(graphFinal),Write(labelFinal)) + self.wait(1) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 2.25,self.camera_frame.move_to, y_each_unit*UP+RIGHT*x_each_unit*0.3) + self.wait(1) + self.play(self.camera_frame.set_width,14,self.camera_frame.move_to,0) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py new file mode 100644 index 0000000..10ee889 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video5_CoinsAnalogy.py @@ -0,0 +1,225 @@ +from manimlib.imports import* +import math +import numpy as np + +class coinsAnalogy(Scene): + def construct(self): + text1=TextMobject("Consider we have","Rs 39").shift(2*UP).scale(0.75).set_color_by_tex_to_color_map({"Rs 39":[YELLOW,PURPLE]}) + text2=TextMobject("and we want to represent them only in terms of","Rs 2","and","Rs 5").shift(UP).scale(0.6).set_color_by_tex_to_color_map({"Rs 2":YELLOW,"Rs 5":PURPLE}) + text3=TextMobject("How many","Rs 2 coins","and","Rs 5 coins","do","we need?").scale(0.8).set_color_by_tex_to_color_map({"Rs 2 coins":YELLOW,"Rs 5 coins":PURPLE,"we need?":RED}) + text4=TextMobject("We","perform","the following!").scale(0.75).shift(DOWN).set_color_by_tex_to_color_map({"perform":GREEN}) + + self.play(FadeIn(text1)) + self.wait(0.6) + self.play(Write(text2)) + self.wait(0.5) + self.play(Write(text3)) + self.wait(0.7) + self.play(FadeIn(text4)) + self.wait(1) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3),FadeOut(text4)) + + g1=self.group("Rs 39") + g1.shift(3*LEFT+0.75*UP) + l1=self.line() + l1.shift(4*LEFT) + f1=self.fiveGroup() + t1=self.twoGroup() + f1.shift(3.5*LEFT+0.7*DOWN) + andT=TextMobject("and").next_to(f1,buff=-0.1).scale(0.3) + t1.next_to(andT,buff=0.2) + equal1=TextMobject("$=$") + equal1.next_to(l1,buff=0.2) + + self.play(ShowCreation(g1)) + self.play(ShowCreation(l1)) + self.play(ShowCreation(f1),Write(andT),ShowCreation(t1)) + self.play(ShowCreation(equal1)) + self.wait(0.6) + + f2=self.fiveGroup().next_to(equal1,buff=0.4) + multiple1=TextMobject("$X7$","$\quad +$").next_to(f2,buff=0.2).set_color_by_tex_to_color_map({"$X7$":PURPLE}) + l2=self.line().next_to(multiple1,buff=0.4) + g2=self.group("Rs 4").shift(2.75*RIGHT+0.75*UP) + t2=self.twoGroup().shift(2.75*RIGHT+0.7*DOWN) + + self.play(ShowCreation(f2)) + self.play(ShowCreation(multiple1)) + self.play(ShowCreation(g2)) + self.play(ShowCreation(l2)) + self.play(ShowCreation(t2)) + self.wait(1) + + tempGrup=VGroup(g2,l2,t2) + + t3=self.twoGroup().next_to(multiple1,buff=0.4) + multiple2=TextMobject("$X2$").next_to(t3,buff=0.2).set_color_by_tex_to_color_map({"$X2$":YELLOW}) + + self.play(ReplacementTransform(tempGrup,t3)) + self.play(Write(multiple2)) + self.wait(2) + + def line(self): + l=Line(start=[0,0,0],end=[2,0,0]) + return l + + def twoGroup(self): + two=Circle(radius=0.25,color=BLACK,fill_color=YELLOW,fill_opacity=0.7) + twoText=TextMobject("Rs 2").scale(0.25).set_color(BLACK) + twoGrup=VGroup(two,twoText) + return twoGrup + + def fiveGroup(self): + five=Circle(radius=0.35,color=BLACK,fill_color=PURPLE,fill_opacity=0.7) + fiveText=TextMobject("Rs 5").scale(0.3).set_color(BLACK) + fiveGrup=VGroup(five,fiveText) + return fiveGrup + + def group(self,money): + coins=[ + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.75), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.8), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.7), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.75), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.8), + Circle(radius=0.35,color=GREY,fill_color=GREY,fill_opacity=0.7) + ] + coinsText=TextMobject(money).set_color(BLACK) + coinsText.scale(0.35) + + coins[1].shift(0.2*RIGHT+0.2*UP) + coins[2].shift(0.2*RIGHT+0.1*DOWN) + coins[3].shift(0.2*DOWN) + coins[4].shift(0.2*UP+0.2*LEFT) + coins[5].shift(0.2*LEFT+0.1*LEFT) + + coinsGrup=VGroup(coins[0],coins[1],coins[2],coins[3],coins[4],coins[5],coinsText) + return coinsGrup + +class divideFunction(GraphScene): + CONFIG = { + "x_min": -6, + "x_max": 6, + "y_min": -300, + "y_max": 300, + "x_tick_frequency": 2, + "y_tick_frequency": 300, + "graph_origin": 3*LEFT+1.5*UP+6*LEFT, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "x_labeled_nums": [-6,0,6], + "y_labeled_nums": [-300,0,300], + "x_axis_width": 1.5, + "y_axis_height": 1 + } + def line(self): + l=Line(start=[0,0,0],end=[2,0,0]) + return l + def construct(self): + text1=TextMobject("Similarly,").scale(0.8).shift(UP).set_color(RED) + text2=TextMobject("To find the amount of","each frequency","present in","$f(x)$").scale(0.6).set_color_by_tex_to_color_map({"each frequency":[YELLOW,RED],"$f(x)$":RED}) + text3=TextMobject("We","perform","the following!").scale(0.7).shift(DOWN).set_color_by_tex_to_color_map({"perform":GREEN}) + + self.play(FadeIn(text1)) + self.wait(0.6) + self.play(Write(text2)) + self.wait(0.7) + self.play(FadeIn(text3)) + + self.wait(1) + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3)) + + boxUP=Square(side_length=1.7,fill_color=BLUE_C,fill_opacity=0.5,color=BLACK).shift(3*LEFT+UP) + boxDOWN=Square(side_length=1.7,fill_color=BLUE_C,fill_opacity=0.5,color=BLACK).shift(3*LEFT+DOWN) + + axes=[] + self.graph_origin=10*LEFT+1.5*UP + self.setup_axes(scalee=1) + axes.append(self.axes) + fx=self.get_graph(lambda x:math.pow(x,3)-math.pow(x,2)+x-2,x_min=-2*math.pi,x_max=2*math.pi,color=RED).shift(7*RIGHT+0.5*DOWN) + + l=self.line().shift(4*LEFT) + + self.graph_origin=10*LEFT+1.5*DOWN + self.y_min=-2 + self.y_max=1 + self.y_tick_frequency=1 + self.y_labeled_nums=[-1,0,1] + self.setup_axes(scalee=1) + axes.append(self.axes) + sinx=self.get_graph(lambda x:np.sin(x),x_min=-2*math.pi,x_max=2*math.pi,color=PURPLE_C).shift(7*RIGHT+0.5*UP) + + equal=TextMobject("$=$").next_to(l,buff=0.3) + result1=TextMobject("Amount of").scale(0.6).next_to(equal,buff=0.3) + boxRIGHT=Square(side_length=1.7,fill_color=GOLD_B,fill_opacity=0.5,color=BLACK).next_to(result1,buff=0.2) + self.graph_origin=10*LEFT + sinxResult=self.get_graph(lambda x:np.sin(x),color=PURPLE_C).next_to(result1,buff=0.3) + axes.append(self.axes) + result2=TextMobject("in","$f(x)$").scale(0.6).next_to(sinxResult,buff=0.2).set_color_by_tex_to_color_map({"$f(x)$":RED}) + + self.play(FadeIn(boxUP)) + self.play(ShowCreation(fx)) + self.play(ShowCreation(l)) + self.play(FadeIn(boxDOWN)) + self.play(ShowCreation(sinx)) + self.wait(0.4) + self.play(Write(equal)) + self.play(Write(result1)) + self.play(FadeIn(boxRIGHT)) + self.play(ShowCreation(sinxResult)) + self.play(Write(result2)) + aText1=TextMobject("and").scale(0.65).shift(4*RIGHT+2*DOWN).set_color(GREEN) + self.play(Write(aText1)) + self.wait(0.7) + + self.graph_origin=10*LEFT + cos4x=self.get_graph(lambda x:np.cos(4*x),color=PURPLE_A).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cos4xResult=self.get_graph(lambda x:np.cos(4*x),color=PURPLE_A).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(sinx,cos4x),ReplacementTransform(sinxResult,cos4xResult)) + self.wait(0.7) + + soText=TextMobject("And so on..!").scale(0.65).shift(4*RIGHT+2*DOWN).set_color(GREEN) + self.play(ReplacementTransform(aText1,soText)) + + self.graph_origin=10*LEFT + cosx=self.get_graph(lambda x:np.cos(x),color=GREEN_E).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cosxResult=self.get_graph(lambda x:np.cos(x),color=GREEN_E).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cos4x,cosx),ReplacementTransform(cos4xResult,cosxResult)) + + self.graph_origin=10*LEFT + cos3x=self.get_graph(lambda x:np.cos(3*x),color=GREEN_C).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + cos3xResult=self.get_graph(lambda x:np.cos(3*x),color=GREEN_C).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cosx,cos3x),ReplacementTransform(cosxResult,cos3xResult)) + + self.graph_origin=10*LEFT + const=self.get_graph(lambda x:1,color=YELLOW_B).shift(7*RIGHT+0.5*UP) + axes.append(self.axes) + self.graph_origin=10*LEFT + constResult=self.get_graph(lambda x:1,color=YELLOW_B).next_to(result1,buff=0.3) + axes.append(self.axes) + self.play(ReplacementTransform(cos3x,const),ReplacementTransform(cos3xResult,constResult)) + + self.wait(1) + + self.play(FadeOut(soText),FadeOut(const),FadeOut(constResult),FadeOut(l),FadeOut(equal),FadeOut(result1),FadeOut(result2),FadeOut(fx),FadeOut(boxRIGHT),FadeOut(boxUP),FadeOut(boxDOWN)) + + finalFormula1=TexMobject(r"Therefore,",r"F(s)",r"=",r"\int _{ -\infty }^{ \infty }",r"{f(t)",r"\over",r"sines",r"\enspace and \enspace",r"cosines}",r"dt }").scale(0.7).set_color_by_tex_to_color_map({"F(s)":RED,"sines":BLUE,"cosines}":YELLOW,"{f(t)":GREEN}) + finalFormula2=TexMobject(r"F(s)",r"=",r"\int _{ -\infty }^{ \infty }",r"{f(t)",r"\over",r"{ e }^",r"{ i\theta }}",r"dt }").set_color_by_tex_to_color_map({"F(s)":RED,"{f(t)":GREEN}) + subFinalFormula=TextMobject("where","$\\theta =2\pi st$").scale(0.5).shift(DOWN+2*RIGHT).set_color_by_tex_to_color_map({"$\\theta =2\pi st$":RED}) + + self.play(Write(finalFormula1)) + self.wait(1) + self.play(ReplacementTransform(finalFormula1,finalFormula2)) + self.play(Write(subFinalFormula)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md new file mode 100644 index 0000000..d4cd8bc --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/README.md @@ -0,0 +1,21 @@ +### Basic Intuition +![GIF1](gifs/basicIntuition.gif) + +### Solving D.E.intuition +![GIF2](gifs/solvingDEintuition.gif) + +### Unit Step Function +#### Part1 +![GIF3](gifs/unitStepFunction.gif) +#### Part2 +![GIF4](gifs/UnitStepFunctionExample.gif) +#### Part3 +![GIF5](gifs/LtransformUnitStepFunction.gif) + +### Dirac Delta Function +#### Part1 +![GIF6](gifs/DiracFunction.gif) +#### Part2 +![GIF7](gifs/DiracFunctionFormation.gif) +#### Part3 +![GIF8](gifs/LtransformDiracFunction.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py new file mode 100644 index 0000000..7a37ae8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file1_laplaceTransformBasic.py @@ -0,0 +1,67 @@ +from manimlib.imports import * +import pylatex + +class depict(Scene): + def construct(self): + square=Square(side_length=2,fill_color=GREEN,fill_opacity=0.7) + inputText=TextMobject("$t$") + squareText=TextMobject("$f$") + outputText=TextMobject("$f($","$t$","$)$") + + inputText.scale(0.8) + outputText.scale(0.8) + inputText.shift(2.1*LEFT) + outputText.shift(1.5*RIGHT) + squareText.scale(1.2) + + outputText.set_color_by_tex_to_color_map({"$t$":RED}) + + self.play(ShowCreation(square)) + self.play(FadeIn(squareText)) + self.add(inputText) + self.wait(0.5) + self.play(ApplyMethod(inputText.shift,0.9*RIGHT)) + self.play(FadeOut(inputText),FadeIn(outputText)) + self.play(ApplyMethod(outputText.shift,1.5*RIGHT)) + self.wait(1) + + fOutGroup=VGroup(outputText,square,squareText) + self.play(ApplyMethod(fOutGroup.scale,0.6)) + self.play(ApplyMethod(fOutGroup.shift,5*LEFT)) + self.wait(0.8) + laplaceSquare=Square(side_length=3,fill_color=BLUE,fill_opacity=0.6) + laplaceText=TextMobject("$\mathscr{L}$") + outText=TextMobject("$F($","$s$","$)$") + outText.scale(0.8) + outText.set_color_by_tex_to_color_map({"$s$":RED}) + laplaceText.scale(1.5) + outText.shift(2*RIGHT) + self.play(ShowCreation(laplaceSquare)) + self.play(FadeIn(laplaceText)) + self.wait(0.5) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.play(FadeOut(outputText),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,2*RIGHT)) + self.wait(1) + + updatedOutputText=TextMobject("$f($","$t$","$)$") + updatedOutputText.shift(2.5*LEFT) + updatedOutputText.set_color_by_tex_to_color_map({"$t$":RED}) + updatedInputText=TextMobject("$t$") + updatedInputText.shift(6*LEFT) + updatedInputText.scale(0.7) + updatedOutputText.scale(0.7) + + self.play(FadeIn(updatedInputText),FadeIn(updatedOutputText)) + self.wait(0.5) + + timeText=TextMobject("Time Domain") + frequencyText=TextMobject("Frequency Domain") + timeText.set_color(RED) + frequencyText.set_color(RED) + timeText.scale(0.35) + frequencyText.scale(0.35) + timeText.shift(2.5*LEFT+0.5*DOWN) + frequencyText.shift(4*RIGHT+0.5*DOWN) + self.play(Write(frequencyText),Write(timeText)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py new file mode 100644 index 0000000..33e9173 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file2_differentialEqSimplification.py @@ -0,0 +1,78 @@ +from manimlib.imports import * +import pylatex + +class scene(Scene): + def construct(self): + normalSq=Square(side_length=2,fill_color=BLUE,fill_opacity=0.6) + normalSqText=TextMobject("$\mathscr{L}$") + inputText=TextMobject("$f($","$y'(t)$","$)$") + outputText=TextMobject("$F($","$s$","$)$") + + inputText.scale(0.7) + outputText.scale(0.7) + inputText.shift(2.5*LEFT) + outputText.shift(1.7*RIGHT) + normalSq.scale(1.2) + + inputText.set_color_by_tex_to_color_map({"$y'(t)$":RED}) + outputText.set_color_by_tex_to_color_map({"$s$":RED}) + + self.play(ShowCreation(normalSq)) + self.play(FadeIn(normalSqText)) + self.add(inputText) + self.wait(0.5) + self.play(ApplyMethod(inputText.shift,0.7*RIGHT)) + self.play(FadeOut(inputText),FadeIn(outputText)) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.wait(1) + + group1=VGroup(outputText,normalSq,normalSqText) + self.play(ApplyMethod(group1.scale,0.6)) + self.play(ApplyMethod(group1.shift,4.7*LEFT)) + self.wait(0.6) + + inverseSq=Square(side_length=3,fill_color=GREEN,fill_opacity=0.6) + inverseSqText=TextMobject("$\mathscr{L}^{ -1 }$") + outText=TextMobject("$f($","$y(t)$","$)$") + inverseSqText.scale(0.7) + outText.scale(0.7) + outText.set_color_by_tex_to_color_map({"$y(t)$":RED}) + self.play(ShowCreation(inverseSq)) + self.play(FadeIn(inverseSqText)) + self.wait(0.5) + outText.shift(2*RIGHT) + self.play(ApplyMethod(outputText.shift,RIGHT)) + self.play(FadeOut(outputText),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,2*RIGHT)) + self.wait(1) + + updatedOutputText=TextMobject("$F($","$s$","$)$") + updatedOutputText.shift(2.5*LEFT) + updatedInputText=TextMobject("$f($","$y'(t)$","$)$") + updatedInputText.shift(6*LEFT) + updatedInputText.scale(0.7) + updatedOutputText.scale(0.7) + updatedOutputText.set_color_by_tex_to_color_map({"$s$":RED}) + updatedInputText.set_color_by_tex_to_color_map({"$y'(t)$":RED}) + + self.play(FadeIn(updatedInputText),FadeIn(updatedOutputText)) + self.wait(0.5) + + deText=TextMobject("Differential Equation") + deinterTexta=TextMobject("Transformed D.E") + deinterTextb=TextMobject("(Easy to simplify)!") + deOutText=TextMobject("Solution of D.E") + deText.set_color(RED) + deinterTexta.set_color(RED) + deOutText.set_color(RED) + deinterTextb.set_color(PURPLE_C) + deText.scale(0.35) + deinterTexta.scale(0.35) + deinterTextb.scale(0.35) + deOutText.scale(0.35) + deText.shift(6*LEFT+0.5*DOWN) + deinterTexta.shift(2.6*LEFT+0.5*DOWN) + deinterTextb.shift(2.6*LEFT+0.8*DOWN) + deOutText.shift(4*RIGHT+0.5*DOWN) + self.play(Write(deText),Write(deinterTexta),Write(deinterTextb),Write(deOutText)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py new file mode 100644 index 0000000..53c5f14 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file3_unitStepFunction.py @@ -0,0 +1,168 @@ +from manimlib.imports import * +import math +import pylatex + +class intro(GraphScene,Scene): + CONFIG = { + "x_min": -8, + "x_max": 8, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$\mu_{c}(t)$", + "exclude_zero_label": True, + "y_axis_height":4, + "x_axis_width":7 + } + def setup(self): + GraphScene.setup(self) + Scene.setup(self) + def construct(self): + introText=TextMobject("Unit","Step","Function") + introText.set_color_by_tex_to_color_map({"Unit":BLUE,"Step":YELLOW}) + introText.scale(0.8) + self.play(Write(introText)) + self.wait(0.5) + self.play(ApplyMethod(introText.shift,3*UP)) + formulaa=TextMobject("$\mu _{ c }(t)=0\quad$","$t<c$") + formulab=TextMobject("$\mu _{ c }(t)=1\quad$","$t\ge c$") + formulaa.set_color_by_tex_to_color_map({"$t<c$":RED}) + formulab.set_color_by_tex_to_color_map({"$t\ge c$":RED}) + formulaa.scale(0.8) + formulab.scale(0.8) + formulab.shift(0.5*DOWN) + self.play(FadeIn(formulaa),FadeIn(formulab)) + self.wait(1) + + self.play(FadeOut(formulaa),FadeOut(formulab)) + + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + self.setup_axes(animate=True) + self.wait(0.8) + + c=TextMobject("c") + c.scale(0.5) + c.set_color(RED) + c.shift(self.graph_origin+3*x_each_unit*RIGHT+y_each_unit*0.4*DOWN) + self.play(Write(c)) + smallCircle=Circle(radius=0.03,fill_color=WHITE,color=WHITE) + smallCircle.shift(self.graph_origin+3*x_each_unit*RIGHT) + downLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*3*x_each_unit,color=BLUE) + upLine=Line(start=self.graph_origin+3*x_each_unit*RIGHT+y_each_unit*UP,end=self.graph_origin+8*x_each_unit*RIGHT+y_each_unit*UP,color=BLUE) + + self.play(Write(downLine)) + self.play(Write(smallCircle)) + self.play(Write(upLine)) + self.wait(1.5) + self.play(FadeOut(self.axes),FadeOut(smallCircle),FadeOut(c),FadeOut(upLine),FadeOut(downLine),FadeOut(introText)) + self.wait(0.5) + + +class example(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 8, + "y_min": -4, + "y_max": 5, + "graph_origin": ORIGIN+LEFT+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "exclude_zero_label": True, + "y_axis_height":4, + "x_axis_width":6 + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + text1=TextMobject("Consider the","formation","of","following graph!"," (a part of $f(t))$") + text1.set_color_by_tex_to_color_map({"following graph!":BLUE,"formation":YELLOW}) + text1.scale(0.6) + ft=TextMobject("$f(t)$") + ftminusc=TextMobject("$f(t-c)$") + final=TextMobject("$\mu_{c}(t)f(t-c)$") + ft.set_color(PURPLE_C) + ftminusc.set_color(PURPLE_C) + final.set_color(PURPLE_C) + c=TextMobject("c") + c.scale(0.5) + c.set_color(RED) + c.shift(self.graph_origin+RIGHT*x_each_unit*3+DOWN*y_each_unit*0.5) + ft.scale(0.5) + ftminusc.scale(0.5) + final.scale(0.5) + + self.play(Write(text1)) + self.play(ApplyMethod(text1.shift,3*UP)) + + self.setup_axes(animate=True) + y=self.get_graph(lambda x:(math.pow((x-3),3)/3)-math.pow((x-3),2)-(x-3)+3,x_min=3,x_max=7,color=RED) + f=self.get_graph(lambda x:(math.pow(x,3)/3)-math.pow(x,2)-x+3,x_min=-2,x_max=4,color=RED) + yFull=self.get_graph(lambda x:(math.pow((x-3),3)/3)-math.pow((x-3),2)-(x-3)+3,x_min=1,x_max=7,color=RED) + + self.play(Write(c)) + self.play(ShowCreation(y)) + self.wait(1) + self.play(FadeOut(self.axes),FadeOut(y),FadeOut(c)) + + belowText1=TextMobject("Consider its","normal form",", $f(t)$") + belowText1.set_color_by_tex_to_color_map({"normal form":BLUE}) + belowText2=TextMobject("Shift it to","x=c") + belowText2.set_color_by_tex_to_color_map({"x=c":RED}) + belowText3a=TextMobject("Now to remove the","left part","of","$c$,") + belowText3a.set_color_by_tex_to_color_map({"left part":YELLOW,"$c$,":YELLOW}) + belowText3b=TextMobject("multiply it with the","unit step function",", $\mu_{c}(t)$") + belowText3b.set_color_by_tex_to_color_map({"unit step function":BLUE}) + belowText1.scale(0.4) + belowText2.scale(0.4) + belowText3a.scale(0.4) + belowText3b.scale(0.4) + belowText1.shift(2.7*DOWN+4*RIGHT) + belowText2.shift(2.7*DOWN+4*RIGHT) + belowText3a.shift(2.7*DOWN+4*RIGHT) + belowText3b.shift(3.1*DOWN+4*RIGHT) + self.setup_axes(animate=True) + self.play(Write(belowText1)) + self.play(ShowCreation(f)) + ft.shift(1.5*RIGHT+UP*0.8) + self.play(FadeIn(ft)) + self.play(ReplacementTransform(belowText1,belowText2)) + ftminusc.shift(3.5*RIGHT+UP*0.8) + self.play(ReplacementTransform(f,yFull),ReplacementTransform(ft,ftminusc),Write(c)) + self.wait(1) + + self.play(ReplacementTransform(belowText2,belowText3a)) + self.play(Write(belowText3b)) + final.shift(3.7*RIGHT+UP*0.8) + self.play(ReplacementTransform(ftminusc,final),ReplacementTransform(yFull,y)) + + finalText=TextMobject("We got our required Graph!") + finalText.scale(0.55) + finalText.shift(2.7*DOWN+4*RIGHT) + self.play(FadeOut(belowText3b),ReplacementTransform(belowText3a,finalText)) + self.wait(1.5) + + self.play(FadeOut(finalText),FadeOut(text1)) + + graphGrup=VGroup(self.axes,c,final,y) + self.play(ApplyMethod(graphGrup.scale,0.45)) + box=Square(side_length=2,fill_color=BLUE,fill_opacity=0.7) + boxtext=TextMobject("$\mathscr{L}$") + boxtext.scale(0.8) + self.play(ApplyMethod(graphGrup.shift,5.5*LEFT+UP)) + self.play(ShowCreation(box),Write(boxtext)) + outText=TextMobject("${ e }^{ -cs }F(s)$") + outText.set_color(GREEN) + outText.scale(0.65) + outText.shift(2*RIGHT) + self.play(ApplyMethod(graphGrup.shift,2*RIGHT)) + self.play(FadeOut(graphGrup),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,RIGHT)) + self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py new file mode 100644 index 0000000..0c7f8e4 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file4_diracBasic.py @@ -0,0 +1,61 @@ +from manimlib.imports import * +import math +import pylatex + +class intro(GraphScene,Scene): + CONFIG = { + "x_min": -9, + "x_max": 9, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN+DOWN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$x$", + "y_axis_label": "$\delta (x)$", + "y_axis_height":4, + "x_axis_width":7 + } + def setup(self): + GraphScene.setup(self) + Scene.setup(self) + def construct(self): + introText=TextMobject("Dirac","Delta","Function") + introText.set_color_by_tex_to_color_map({"Dirac":BLUE,"Delta":YELLOW}) + introText.scale(0.8) + self.play(Write(introText)) + self.wait(0.5) + self.play(ApplyMethod(introText.shift,3*UP)) + formulaa=TextMobject("$\delta (x)=\infty$","$x=0$") + formulab=TextMobject("$\delta (x)=0$","$x\\neq 0$") + formulaa.set_color_by_tex_to_color_map({"$x=0$":RED}) + formulab.set_color_by_tex_to_color_map({"$x\\neq 0$":RED}) + formulaa.scale(0.8) + formulab.scale(0.8) + formulab.shift(0.5*DOWN) + self.play(FadeIn(formulaa),FadeIn(formulab)) + self.wait(1) + + self.play(FadeOut(formulaa),FadeOut(formulab)) + + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + self.setup_axes(animate=True) + self.wait(0.8) + + functionUpLine=Line(start=self.graph_origin,end=self.graph_origin+UP*y_each_unit*5,color=RED) + functionDownLine=Line(start=self.graph_origin+UP*y_each_unit*5,end=self.graph_origin,color=RED) + functinLeftLine=Line(start=self.graph_origin+LEFT*x_each_unit*9,end=self.graph_origin,color=RED) + functionRightLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*x_each_unit*9,color=RED) + functionUpLine.shift(0.02*LEFT) + functionRightLine.shift(0.02*RIGHT) + + self.play(ShowCreation(functinLeftLine)) + self.play(ShowCreation(functionUpLine)) + self.play(ShowCreation(functionDownLine)) + self.play(ShowCreation(functionRightLine)) + self.wait(1.5) + + self.play(FadeOut(self.axes),FadeOut(introText),FadeOut(functinLeftLine),FadeOut(functionRightLine),FadeOut(functionUpLine),FadeOut(functionDownLine)) + self.wait(0.5) diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py new file mode 100644 index 0000000..565a7cb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/file5_formationDiracDeltaFunction.py @@ -0,0 +1,142 @@ +from manimlib.imports import * +import math +import pylatex + +def func(x,t): + if(x>-t and x<t): + return 1/(2*t) + else: + return 0 + + +class formation(GraphScene): + CONFIG = { + "x_min": -7, + "x_max": 7, + "y_min": -2, + "y_max": 2, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": GREEN, + "x_axis_label": "$t$", + "y_axis_label": "$y$", + "y_labeled_nums":range(-2,3), + "y_axis_height":4, + "x_axis_width":7 + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + text1=TextMobject("Consider the","following function's graph!") + text1.set_color_by_tex_to_color_map({"following function's graph!":BLUE}) + text1.scale(0.6) + + equation1=TextMobject("$\delta _{ \\tau }(t)=\\frac { 1 }{ 2\\tau } \quad$","$-\\tau <t<\\tau$") + equation2=TextMobject("$\delta _{ \\tau }(t)=0\quad \quad$","$t\in (-\infty ,-\\tau ]\cup [\\tau ,\infty )$") + equation1.scale(0.7) + equation2.scale(0.7) + equation1.shift(0.2*UP) + equation2.shift(0.4*DOWN+RIGHT*0.8) + equation1.set_color_by_tex_to_color_map({"$-\\tau <t<\\tau$":RED}) + equation2.set_color_by_tex_to_color_map({"$t\in (-\infty ,-\\tau ]\cup [\\tau ,\infty )$":RED}) + + self.play(Write(text1)) + self.play(ApplyMethod(text1.shift,3*UP)) + self.play(Write(equation1)) + self.play(Write(equation2)) + self.wait(1) + + self.play(FadeOut(equation1),FadeOut(equation2)) + self.wait(0.5) + + pointes1=TextMobject("$-\\tau$") + pointes2=TextMobject("$\\tau$") + pointes1.set_color(RED) + pointes2.set_color(RED) + pointes1.scale(0.65) + pointes2.scale(0.65) + + bottomText1=TextMobject("Here","$\int _{ -\infty }^{ \infty }{ \delta _{ \\tau }(t)dt }$","=","$1$") + bottomText2=TextMobject("Now as","$\\tau \\rightarrow 0$") + bottomText3=TextMobject("We get our","Dirac Function!") + bottomText4=TextMobject("i.e.","$\lim _{ \\tau \\rightarrow 0 }{ \delta _{ \\tau }(t)}$","$=$","$\delta (t)$") + textFinal=TextMobject("Area=1") + bottomText1.set_color_by_tex_to_color_map({"$\int _{ -\infty }^{ \infty }{ \delta _{ \\tau }(t)dt }$":BLUE,"$1$":YELLOW}) + textFinal.set_color(PURPLE_B) + bottomText2.set_color_by_tex_to_color_map({"$\\tau \\rightarrow 0$":YELLOW}) + bottomText3.set_color_by_tex_to_color_map({"Dirac Function!":RED}) + bottomText4.set_color_by_tex_to_color_map({"$\lim _{ \\tau \\rightarrow 0 }{ \delta _{ \\tau }(t)}$":BLUE,"$\delta (t)$":YELLOW}) + + bottomText1.scale(0.6) + bottomText2.scale(0.6) + bottomText3.scale(0.6) + bottomText4.scale(0.6) + textFinal.scale(0.9) + + bottomText1.shift(4*RIGHT+3*DOWN) + bottomText2.shift(4*RIGHT+3*DOWN) + bottomText3.shift(4*RIGHT+3*DOWN) + bottomText4.shift(4*RIGHT+3*DOWN) + textFinal.shift(5*RIGHT+2*UP) + + self.setup_axes(animate=True) + + graphs=[ + self.get_graph(lambda x:func(x,3),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,2),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,1),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.5),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.3),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.15),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.05),x_min=-7,x_max=7,color=RED), + self.get_graph(lambda x:func(x,0.01),x_min=-7,x_max=7,color=RED) + ] + pointes1.shift(self.graph_origin+3*LEFT*x_each_unit+0.4*DOWN*y_each_unit) + pointes2.shift(self.graph_origin+3*RIGHT*x_each_unit+0.4*DOWN*y_each_unit) + + functionUpLine=Line(start=self.graph_origin,end=self.graph_origin+UP*y_each_unit*2,color=RED) + functionDownLine=Line(start=self.graph_origin+UP*y_each_unit*2,end=self.graph_origin,color=RED) + functinLeftLine=Line(start=self.graph_origin+LEFT*x_each_unit*7,end=self.graph_origin,color=RED) + functionRightLine=Line(start=self.graph_origin,end=self.graph_origin+RIGHT*x_each_unit*7,color=RED) + functionUpLine.shift(0.02*LEFT) + functionRightLine.shift(0.02*RIGHT) + + self.play(Write(pointes1),Write(pointes2),ShowCreation(graphs[0])) + self.play(Write(bottomText1)) + self.wait(0.7) + + self.play(ReplacementTransform(bottomText1,bottomText2),Write(textFinal)) + self.wait(0.5) + self.play(ReplacementTransform(graphs[0],graphs[1]),ApplyMethod(pointes2.shift,LEFT*x_each_unit),ApplyMethod(pointes1.shift,RIGHT*x_each_unit)) + self.play(ReplacementTransform(graphs[1],graphs[2]),ApplyMethod(pointes2.shift,LEFT*x_each_unit),ApplyMethod(pointes1.shift,RIGHT*x_each_unit)) + self.wait(0.5) + self.play(ReplacementTransform(graphs[2],graphs[3]),FadeOut(pointes1),FadeOut(pointes2)) + self.play(ReplacementTransform(graphs[3],graphs[4])) + self.wait(1) + self.play(ReplacementTransform(bottomText2,bottomText3)) + self.wait(1) + self.play(FadeOut(graphs[4]),ReplacementTransform(bottomText3,bottomText4)) + self.wait(0.5) + self.play(ShowCreation(functinLeftLine)) + self.play(ShowCreation(functionUpLine)) + self.play(ShowCreation(functionDownLine)) + self.play(ShowCreation(functionRightLine)) + self.wait(2) + + self.play(FadeOut(bottomText4),FadeOut(textFinal)) + graphGrup=VGroup(self.axes,functinLeftLine,functionDownLine,functionRightLine,functionUpLine) + self.play(ApplyMethod(graphGrup.scale,0.5)) + box=Square(side_length=2,fill_color=BLUE,fill_opacity=0.6) + boxtext=TextMobject("$\mathscr{L}$") + boxtext.scale(0.8) + self.play(ApplyMethod(graphGrup.shift,4.9*LEFT)) + self.play(ShowCreation(box),Write(boxtext)) + outText=TextMobject("$f(0)$") + outText.set_color(GREEN) + outText.scale(0.65) + outText.shift(1.5*RIGHT) + self.play(ApplyMethod(graphGrup.shift,2*RIGHT)) + self.play(FadeOut(graphGrup),FadeIn(outText)) + self.play(ApplyMethod(outText.shift,RIGHT)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif Binary files differnew file mode 100644 index 0000000..cb62ed2 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif Binary files differnew file mode 100644 index 0000000..23acbe9 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/DiracFunctionFormation.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif Binary files differnew file mode 100644 index 0000000..b1d50b5 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformDiracFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif Binary files differnew file mode 100644 index 0000000..ccbd791 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/LtransformUnitStepFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif Binary files differnew file mode 100644 index 0000000..2b1c38f --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/UnitStepFunctionExample.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif Binary files differnew file mode 100644 index 0000000..3b974bb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/basicIntuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif Binary files differnew file mode 100644 index 0000000..9883a8c --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/solvingDEintuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif Binary files differnew file mode 100644 index 0000000..16757e1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Laplace Transformations/gifs/unitStepFunction.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf b/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf Binary files differindex 04ed6d5..9fc409b 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf +++ b/FSF-2020/calculus/series-and-transformations/Power Series/PowerSeriesQuestions.pdf diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/README.md b/FSF-2020/calculus/series-and-transformations/Power Series/README.md new file mode 100644 index 0000000..6885837 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/README.md @@ -0,0 +1,14 @@ +#### Convergence Intuition +![GIF1a](gifs/file1_convergence_Intuition.gif) + +#### Convergence Intuition +![GIF1b](gifs/file1a_convergence_Intuition.gif) + +#### Convergence of a function +![GIF2](gifs/file2_convergence_of_a_function.gif) + +#### Radius and IntervalOfConvergence +![GIF3](gifs/file3_radius_and_intervalOfConvergence.gif) + +#### Uniform Convergence +![GIF4](gifs/file4_UniformConvergence.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif Binary files differnew file mode 100644 index 0000000..292d19d --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1_convergence_Intuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif Binary files differnew file mode 100644 index 0000000..287cbd1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file1a_convergence_Intuition.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif Binary files differnew file mode 100644 index 0000000..78d6014 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file2_convergence_of_a_function.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif Binary files differnew file mode 100644 index 0000000..a45c75e --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file3_radius_and_intervalOfConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif Binary files differnew file mode 100644 index 0000000..7b635d7 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4_UniformConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script1.py b/FSF-2020/calculus/series-and-transformations/Power Series/script1.py deleted file mode 100644 index 28eb07c..0000000 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script1.py +++ /dev/null @@ -1,128 +0,0 @@ -from manimlib.imports import * - - -def formFormula(coeff_list,variable_list): - coeff_list=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - variable_list=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - coeff_list[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - coeff_list[i].set_color(GOLD_A) - variable_list[i].next_to(coeff_list[i],buff=0.1) - if i!=2: - coeff_list[i+1].next_to(variable_list[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variable_list[2]) - expansion=VGroup(coeff_list[0],coeff_list[1],coeff_list[2],variable_list[0],variable_list[1],variable_list[2],dots) - expansion.scale(0.7) - return expansion - -class pieChart(Scene): - def construct(self): - circle1=Circle(radius=3,color=BLUE) - powerText=TextMobject("Power Series") - powerText.scale(0.8) - self.play(FadeIn(powerText)) - self.play(ShowCreation(circle1)) - self.wait(1) - - powerGroup=VGroup(circle1,powerText) - - self.play(ApplyMethod(powerGroup.scale,0.5)) - self.play(ApplyMethod(powerGroup.move_to,2.2*UP)) - self.wait(0.5) - expansion_power_coeff=[] - variables_power=[] - expansion_power=formFormula(expansion_power_coeff,variables_power) - self.play(ReplacementTransform(powerText,expansion_power)) - self.wait(1) - - circle2=Circle(radius=1.5) - circle2.shift(2.2*UP) - expansion_geo_coeff=[0]*3 - variables_geo=[0]*3 - arrow1_2=Line(start=0.7*UP,end=2.5*LEFT) - expansion_geo_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - for i in range(0,3): - expansion_geo_coeff[i].set_color(GOLD_A) - variables_geo=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - expansion_geo_coeff[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - variables_geo[i].next_to(expansion_geo_coeff[i],buff=0.1) - if i!=2: - expansion_geo_coeff[i+1].next_to(variables_geo[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variables_geo[2]) - expansion_geo=VGroup(expansion_geo_coeff[0],expansion_geo_coeff[1],expansion_geo_coeff[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) - expansion_geo.scale(0.7) - - self.play(ApplyMethod(circle2.shift,4*LEFT+2.5*DOWN),ApplyMethod(expansion_geo.shift,4*LEFT+2.5*DOWN)) - self.add(arrow1_2) - self.wait(1) - - ones=[TextMobject("1"),TextMobject("1"),TextMobject("1")] - for i in range(0,3): - ones[i].set_color(GOLD_A) - ones[0].shift(0.3*DOWN,5*LEFT) - ones[1].next_to(ones[0],buff=0.5) - ones[2].next_to(ones[1],buff=0.7) - self.play(ReplacementTransform(expansion_geo_coeff[0],ones[0]),ReplacementTransform(expansion_geo_coeff[1],ones[1]),ReplacementTransform(expansion_geo_coeff[2],ones[2])) - self.wait(1) - expansion_geo=VGroup(ones[0],ones[1],ones[2],variables_geo[0],variables_geo[1],variables_geo[2],dots) - - expansion_geo_final=TextMobject("$1+x+{ x }^{ 2 }..$") - expansion_geo_final.scale(0.8) - expansion_geo_final.shift(0.3*DOWN+4*LEFT) - self.play(ReplacementTransform(expansion_geo,expansion_geo_final)) - self.wait(1) - - circle3=Circle(radius=1.5,color=GREEN) - circle3.shift(2.2*UP) - expansion_taylor_coeff=[0]*3 - variables_taylor=[0]*3 - arrow1_3=Line(start=0.7*UP,end=DOWN*0.3) - expansion_taylor_coeff=[TextMobject("${ a }_{ 0 }$"),TextMobject("${ a }_{ 1 }$"),TextMobject("${ a }_{ 2 }$")] - for i in range(0,3): - expansion_taylor_coeff[i].set_color(GOLD_A) - variables_taylor=[TextMobject("+"),TextMobject("${ x }$+"),TextMobject("${ x }^{ 2 }$")] - expansion_taylor_coeff[0].shift(2.2*UP+1.6*LEFT) - for i in range(0,3): - variables_taylor[i].next_to(expansion_taylor_coeff[i],buff=0.1) - if i!=2: - expansion_taylor_coeff[i+1].next_to(variables_taylor[i],buff=0.1) - dots=TextMobject("...") - dots.next_to(variables_taylor[2]) - expansion_taylor=VGroup(expansion_taylor_coeff[0],expansion_taylor_coeff[1],expansion_taylor_coeff[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) - expansion_taylor.scale(0.7) - - self.play(ApplyMethod(circle3.shift,4*DOWN),ApplyMethod(expansion_taylor.shift,4*DOWN)) - self.add(arrow1_3) - self.wait(1) - - differentials=[TextMobject("$f(0)$"),TextMobject("${ f'\left( 0 \\right) }$"),TextMobject("$\\frac { f''\left( 0 \\right) }{ 2! }$")] - for i in range(0,3): - differentials[i].set_color(GOLD_A) - differentials[0].shift(1.8*DOWN+1.15*LEFT) - differentials[1].shift(1.8*DOWN+0.45*LEFT) - differentials[2].shift(1.8*DOWN+0.45*RIGHT) - differentials[0].scale(0.35) - differentials[1].scale(0.35) - differentials[2].scale(0.35) - self.play(ReplacementTransform(expansion_taylor_coeff[0],differentials[0]),ReplacementTransform(expansion_taylor_coeff[1],differentials[1]),ReplacementTransform(expansion_taylor_coeff[2],differentials[2])) - self.wait(2) - expansion_taylor_final=VGroup(differentials[0],differentials[1],differentials[2],variables_taylor[0],variables_taylor[1],variables_taylor[2],dots) - - self.play(FadeOut(expansion_geo_final),FadeOut(expansion_taylor_final)) - geoText=TextMobject("Geometric Series") - geoText.scale(0.7) - geoText.shift(4*LEFT+0.3*DOWN) - taylorText=TextMobject("Taylor Series") - taylorText.scale(0.7) - taylorText.shift(1.8*DOWN) - self.play(FadeIn(geoText),FadeIn(taylorText)) - self.wait(1) - - soOntext=TextMobject("So on..!") - soOntext.shift(4*RIGHT) - soOntext.scale(0.8) - self.play(FadeIn(soOntext)) - self.wait(2) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script2.py b/FSF-2020/calculus/series-and-transformations/Power Series/video1_convergence_Intuition.py index 72356c6..66f48f9 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script2.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video1_convergence_Intuition.py @@ -11,23 +11,36 @@ class convergence(Scene): self.play(ApplyMethod(originalFormula.shift,2.7*UP)) self.wait(1) - terms=["$a_{ 0 }$","$a_{ 1 }x$","$a_{ 2 }x^{ 2 }$","$a_{ 3 }x^{ 3 }$","$a_{ 4 }x^{ 4 }$","$a_{ 5 }x^{ 5 }$","$a_{ 6 }x^{ 6 }$","$a_{ 7 }x^{ 7 }$","$a_{ 8 }x^{ 8 }$","$a_{ 9 }x^{ 9 }$","$a_{ 10 }x^{ 10 }$","$a_{ 11 }x^{ 11 }$"] + colors=[PURPLE_E,PURPLE_D,MAROON_D,RED_E,RED_D,RED_C,ORANGE,YELLOW_E,YELLOW_D,YELLOW_B] + terms=["$a_{ 0 }$","$a_{ 1 }x$","$a_{ 2 }x^{ 2 }$","$a_{ 3 }x^{ 3 }$","$a_{ 4 }x^{ 4 }$","$a_{ 5 }x^{ 5 }$","$a_{ 6 }x^{ 6 }$","$a_{ 7 }x^{ 7 }$","$a_{ 8 }x^{ 8 }$","$a_{ 9 }x^{ 9 }$"] termsTogetherString="+".join(terms) - termsTogether=TextMobject(termsTogetherString+"...") + #termsTogether=TextMobject(termsTogetherString+"...") + termsTogether=TextMobject("$a_{ 0 }$","+","$a_{ 1 }x$","+","$a_{ 2 }x^{ 2 }$","+","$a_{ 3 }x^{ 3 }$","+","$a_{ 4 }x^{ 4 }$","+","$a_{ 5 }x^{ 5 }$","+","$a_{ 6 }x^{ 6 }$","+","$a_{ 7 }x^{ 7 }$","+","$a_{ 8 }x^{ 8 }$","+","$a_{ 9 }x^{ 9 }$","+..") + termsTogether.set_color_by_tex_to_color_map({"$a_{ 0 }$":colors[0], + "$a_{ 1 }x$":colors[1], + "$a_{ 2 }x^{ 2 }$":colors[2], + "$a_{ 3 }x^{ 3 }$":colors[3], + "$a_{ 4 }x^{ 4 }$":colors[4], + "$a_{ 5 }x^{ 5 }$":colors[5], + "$a_{ 6 }x^{ 6 }$":colors[6], + "$a_{ 7 }x^{ 7 }$":colors[7], + "$a_{ 8 }x^{ 8 }$":colors[8], + "$a_{ 9 }x^{ 9 }$":colors[9]}) termsTogether.scale(0.8) termsTogether.shift(2.7*UP) self.play(ReplacementTransform(originalFormula,termsTogether)) self.wait(1) - termMobjectRect=[0]*12 - termMobject=TextMobject(terms[0]) + termMobjectRect=[0]*10 + termMobject=TextMobject(terms[0]).set_color(colors[0]) termMobject.shift(2.7*UP+6.2*LEFT) - for i in range(1,13): + for i in range(1,11): termMobjectOld=termMobject termMobjectOld.scale(0.8) - if(i<12): + if(i<10): termMobject=TextMobject(terms[i]) - termMobject.next_to(termMobjectOld) + termMobject.set_color(colors[i]) + termMobject.next_to(termMobjectOld,buff=0.5) if(i==1): rectDefine=TextMobject("Here","each rectangle","represents the","value of the term") rectDefine.set_color_by_tex_to_color_map({"each rectangle":BLUE,"value of the term":YELLOW}) @@ -50,7 +63,7 @@ class convergence(Scene): self.play(ReplacementTransform(ratio,inequality)) self.wait(1) #self.play(ApplyMethod(termMobjectOld.move_to,(2-0.3*i)*DOWN+RIGHT*0.2*i)) - termMobjectRect[i-1]=Rectangle(height=0.1,width=(5-0.4*i)) + termMobjectRect[i-1]=Rectangle(height=0.1,width=(4.2-0.4*i),color=colors[i-1]) termMobjectRect[i-1].move_to((2-0.2*i)*DOWN+RIGHT*0.2*i) #rectangles[p] = termMobjectRect #p+=1 @@ -58,8 +71,8 @@ class convergence(Scene): uparrow=TextMobject("$\\uparrow$") uparrow.set_color(GREEN) - uparrow.scale(6) - uparrow.shift(4*RIGHT+0.5*DOWN) + uparrow.scale(5) + uparrow.shift(4*RIGHT+0.7*DOWN) self.play(ShowCreation(uparrow)) self.wait(1) @@ -72,9 +85,9 @@ class convergence(Scene): self.play(FadeOut(converges),FadeOut(uparrow),FadeOut(inequality)) self.wait(0.5) - rect=VGroup(termMobjectRect[0],termMobjectRect[1],termMobjectRect[2],termMobjectRect[3],termMobjectRect[4],termMobjectRect[5],termMobjectRect[6],termMobjectRect[7],termMobjectRect[8],termMobjectRect[9],termMobjectRect[10],termMobjectRect[11]) + rect=VGroup(termMobjectRect[0],termMobjectRect[1],termMobjectRect[2],termMobjectRect[3],termMobjectRect[4],termMobjectRect[5],termMobjectRect[6],termMobjectRect[7],termMobjectRect[8],termMobjectRect[9]) self.play(ApplyMethod(rect.scale,0.2)) - for i in range(0,12): + for i in range(0,10): self.play(ApplyMethod(termMobjectRect[i].shift,i*0.04*DOWN+(11-(3-0.11*i)*i)*LEFT*0.3)) func=TextMobject("$\\approx$","$f(x)$") func.set_color_by_tex_to_color_map({"$f(x)$":RED}) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script3.py b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_of_a_function.py index f710f42..19b8b8b 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script3.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video2_convergence_of_a_function.py @@ -69,10 +69,10 @@ class graphScene(GraphScene): eqText[i].scale(0.6) eqText[i].set_color(BLUE) eqText[i].shift(ORIGIN+UP*2*y_each_unit+RIGHT*3.3*x_each_unit) - eqTextTerm=TextMobject("And so on..!") - eqTextTerm.set_color(BLUE) - eqTextTerm.scale(0.6) - eqTextTerm.shift(ORIGIN+UP*2*y_each_unit+3*RIGHT*x_each_unit) + # eqTextTerm=TextMobject("And so on..!") + # eqTextTerm.set_color(BLUE) + # eqTextTerm.scale(0.6) + # eqTextTerm.shift(ORIGIN+UP*2*y_each_unit+3*RIGHT*x_each_unit) equation1 = self.get_graph(lambda x : 1,color = RED,x_min = -8,x_max=8) equation2 = self.get_graph(lambda x : 1-math.pow(x,2),color = RED,x_min = -1.7,x_max=1.7) equation3 = self.get_graph(lambda x : 1-math.pow(x,2)+math.pow(x,4),color = RED,x_min = -1.6,x_max=1.6) @@ -106,7 +106,7 @@ class graphScene(GraphScene): self.play(ReplacementTransform(equation3,equation4),ReplacementTransform(eqText[2],eqText[3])) self.wait(0.3) self.play(FadeOut(eqText[3])) - self.play(FadeIn(eqTextTerm)) + #self.play(FadeIn(eqTextTerm)) self.play(Write(textBtwAnim1),Write(textBtwAnim2)) self.play(FadeIn(textBtwAnim3)) self.play(ReplacementTransform(equation4,equation5)) @@ -122,7 +122,7 @@ class graphScene(GraphScene): self.play(ReplacementTransform(equation9,equation10)) self.wait(1) - self.play(FadeOut(textBtwAnim1),FadeOut(textBtwAnim2),FadeOut(textBtwAnim3),FadeOut(equation10),FadeOut(eqTextTerm)) + self.play(FadeOut(textBtwAnim1),FadeOut(textBtwAnim2),FadeOut(textBtwAnim3),FadeOut(equation10)) self.wait(1) convergeLine=Line(start=ORIGIN+x_each_unit*LEFT,end=ORIGIN+x_each_unit*RIGHT,color=WHITE) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script4.py b/FSF-2020/calculus/series-and-transformations/Power Series/video3_radius_and_intervalOfConvergence.py index 412d20c..f35fea8 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script4.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video3_radius_and_intervalOfConvergence.py @@ -3,7 +3,7 @@ import math class intro(Scene): def construct(self): - introText1=TextMobject("Consider the","above","example..") + introText1=TextMobject("Consider the example","above",) introText1.scale(0.8) introText1.set_color_by_tex_to_color_map({"above":YELLOW}) self.play(Write(introText1)) @@ -24,12 +24,13 @@ class graphScene(GraphScene,MovingCameraScene): "x_labeled_nums": range(-1, 2, 1), "y_labeled_nums": range(0,2,1), "y_axis_height":7, - "x_axis_width":7 + "x_axis_width":7, } def setup(self): GraphScene.setup(self) MovingCameraScene.setup(self) + def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) @@ -74,15 +75,14 @@ class graphScene(GraphScene,MovingCameraScene): radiusText=TextMobject("Radius of convergence") radiusText.scale(0.14) radiusText.shift(ORIGIN+RIGHT*x_each_unit*0.45+DOWN*y_each_unit*0.2) - + #self.activate_zooming(animate=True) self.play(Write(radiusText)) self.wait(0.6) self.camera_frame.save_state() - self.camera_frame.set_width(5.5) - self.play(self.camera_frame.move_to, ORIGIN) + self.play(self.camera_frame.set_width,5.5) self.wait(1) - self.camera_frame.set_width(14) + self.play(self.camera_frame.set_width,14) self.wait(1.3) self.play(FadeOut(radiusText),FadeOut(circle),FadeOut(movingPoint)) @@ -101,8 +101,13 @@ class graphScene(GraphScene,MovingCameraScene): self.wait(0.6) self.camera_frame.save_state() - self.camera_frame.set_width(5.5) - self.play(self.camera_frame.move_to, ORIGIN) + self.play(self.camera_frame.set_width,5.5) self.wait(1) - self.camera_frame.set_width(14) - self.wait(1.5) + self.play(self.camera_frame.set_width,14) + self.wait(1.3) + # self.camera_frame.save_state() + # self.camera_frame.set_width(5.5) + # self.play(self.camera_frame.move_to, ORIGIN) + # self.wait(1) + # self.camera_frame.set_width(14) + # self.wait(1.5) diff --git a/FSF-2020/calculus/series-and-transformations/Power Series/script5.py b/FSF-2020/calculus/series-and-transformations/Power Series/video4_UniformConvergence.py index e9681aa..1f3e26c 100644 --- a/FSF-2020/calculus/series-and-transformations/Power Series/script5.py +++ b/FSF-2020/calculus/series-and-transformations/Power Series/video4_UniformConvergence.py @@ -3,19 +3,19 @@ import math class uniformlyConvergent(Scene): def construct(self): - introText1=TextMobject("Again consider the","above","example") + #introText1=TextMobject("Again consider the","above","example") introText2=TextMobject("Let","$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$","and","x=0.5 $\in$(-1,1)") introText3=TextMobject("Lets analyse..","!") - introText1.scale(0.8) + #introText1.scale(0.8) introText2.scale(0.7) introText3.scale(0.9) introText3.shift(DOWN) - introText1.set_color_by_tex_to_color_map({"above":YELLOW}) + #introText1.set_color_by_tex_to_color_map({"above":YELLOW}) introText2.set_color_by_tex_to_color_map({"$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$":BLUE,"x=0.5 $\in$(-1,1)":YELLOW}) introText3.set_color_by_tex_to_color_map({"!":GREEN}) - self.play(Write(introText1)) - self.wait(0.5) - self.play(FadeOut(introText1)) + #self.play(Write(introText1)) + #self.wait(0.5) + #self.play(FadeOut(introText1)) self.play(Write(introText2)) self.play(FadeIn(introText3)) self.wait(2) @@ -45,7 +45,7 @@ def makeLines(x,numPoints,x_each_unit,y_each_unit): lines[i]=Line(start=ORIGIN+RIGHT*x_each_unit*i+UP*y_each_unit*y,end=ORIGIN+RIGHT*x_each_unit*(i+1)+UP*y_each_unit*y_next,color=RED) return lines -class graphScene(GraphScene,MovingCameraScene): +class graphScene(GraphScene,ZoomedScene): CONFIG = { "x_min": -6, "x_max": 6, @@ -58,12 +58,15 @@ class graphScene(GraphScene,MovingCameraScene): "y_axis_label": "$f(\\frac{1}{2})_k$", "exclude_zero_label": True, "x_axis_width":7, - "y_axis_height":7 + "y_axis_height":7, + "zoomed_camera_frame_starting_position": 0.5*UP+0.5*RIGHT, + "zoom_factor": 0.4, } def setup(self): GraphScene.setup(self) - MovingCameraScene.setup(self) + #MovingCameraScene.setup(self) + ZoomedScene.setup(self) def construct(self): @@ -87,6 +90,14 @@ class graphScene(GraphScene,MovingCameraScene): makeSeries(0.5,points,x_each_unit,y_each_unit) lines=makeLines(0.5,6,x_each_unit,y_each_unit) + func1=TextMobject("$g(x)=\\frac { 1 }{ 1+{ x }^{ 2 } }$") + func2=TextMobject("x=0.5 $\in$(-1,1)") + func1.scale(0.4) + func2.scale(0.4) + func1.shift(5.3*LEFT+3.3*UP) + func2.shift(5.3*LEFT+2.9*UP) + self.add(func1) + self.add(func2) self.add(sequence) self.add(formula) @@ -95,22 +106,26 @@ class graphScene(GraphScene,MovingCameraScene): self.add(fLineText) for p in points: self.add(p) + self.setup() + self.activate_zooming(animate=True) for p in range(0,5): self.play(Write(lines[p])) - self.wait(0.5) - self.camera_frame.save_state() - self.camera_frame.set_width(0.6) - self.play(self.camera_frame.move_to, points[0]) - self.wait(0.4) - self.play(self.camera_frame.move_to, points[1]) - self.wait(0.4) - self.play(self.camera_frame.move_to, points[2]) - self.wait(0.3) - self.play(self.camera_frame.move_to, points[3]) - self.wait(1) - self.play(self.camera_frame.move_to,ORIGIN) - self.camera_frame.set_width(14) + # self.wait(0.5) + # self.camera_frame.save_state() + # self.camera_frame.set_width(0.6) + # self.play(self.camera_frame.move_to, points[0]) + # self.wait(0.4) + # self.play(self.camera_frame.move_to, points[1]) + # self.wait(0.4) + # self.play(self.camera_frame.move_to, points[2]) + # self.wait(0.3) + # self.play(self.camera_frame.move_to, points[3]) + # self.wait(1) + # self.play(self.camera_frame.move_to,ORIGIN) + # self.camera_frame.set_width(14) + self.wait(1) + self.get_zoomed_display_pop_out_animation() explanation1=TextMobject("Since the series","converges","to") explanation1.set_color_by_tex_to_color_map({"converges":YELLOW}) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md b/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md new file mode 100644 index 0000000..ce3b088 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/README.md @@ -0,0 +1,11 @@ +#### Example of Taylors expansion +![GIF1](gifs/file1_Example_TaylorExpansion.gif) + +#### Taylor Series GeneralForm +![GIF2](gifs/file2_TaylorExpansionGeneralForm.gif) + +#### Radius Of Convergence +![GIF3](gifs/file3_radiusOfConvergence.gif) + +#### Divergence of a Remainder +![GIF4](gifs/file4_DivergentRemainder.gif) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf b/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf Binary files differindex 2096f52..46d46e1 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/TaylorSeriesQuestions.pdf diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif Binary files differnew file mode 100644 index 0000000..4272d84 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file1_Example_TaylorExpansion.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif Binary files differnew file mode 100644 index 0000000..e6d9171 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2_TaylorExpansionGeneralForm.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif Binary files differnew file mode 100644 index 0000000..9e53cfb --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file3_radiusOfConvergence.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif Binary files differnew file mode 100644 index 0000000..0bc8b65 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file4_DivergentRemainder.gif diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script1.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video1_Example_TaylorExpansion.py index e83eff8..b132811 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script1.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video1_Example_TaylorExpansion.py @@ -31,7 +31,7 @@ class intro(Scene): self.wait(0.7) self.play(FadeOut(equation),FadeOut(text)) -class graphScene(GraphScene): +class graphScene(GraphScene,MovingCameraScene): CONFIG = { "x_min": -8, "x_max": 8, @@ -45,10 +45,25 @@ class graphScene(GraphScene): "exclude_zero_label": True, "x_labeled_nums": range(-8, 8, 1), } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(0.55) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("$a=0$") + text.scale(0.55) + + equation.shift(3.39*UP+5*LEFT) + text.shift(2.9*UP+5*LEFT) + + self.add(equation) + self.add(text) + generalized_eq_coeff=[] variables_eq=[] eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) @@ -58,7 +73,7 @@ class graphScene(GraphScene): trTextGrup.scale(0.5) trTextGrup.to_corner(UP+RIGHT) self.play(Write(trTextGrup)) - self.setup_axes(animate=True) + self.setup_axes(animate=True,scalee=1) fx=TextMobject("${ e }^{ -x^{ 2 } }$") fx.scale(0.5) @@ -66,18 +81,21 @@ class graphScene(GraphScene): mainfunction=self.get_graph(lambda x:math.exp(-1*pow(x,2)),color=RED,x_min=-8,x_max=8) self.play(ShowCreation(mainfunction)) self.play(FadeIn(fx)) - self.wait(1.4) + self.wait(1) coeff=[TextMobject("$1$"),TextMobject("$f'(x)$"),TextMobject("$\\frac { f''(x) }{ 2! } $")] coeff[0].shift(3.39*UP+4.88*RIGHT) coeff[0].scale(0.5) - coeff[1].shift(3.39*UP+5.3*RIGHT) + coeff[1].shift(3.39*UP+5.4*RIGHT) coeff[1].scale(0.275) - coeff[2].shift(3.39*UP+5.98*RIGHT) + coeff[2].shift(3.39*UP+6*RIGHT) coeff[2].scale(0.28) for obj in coeff: obj.set_color(GOLD_A) + group=VGroup(coeff[0],coeff[1],coeff[2]) + + #group.shift(2*LEFT+2*DOWN) firstApprox=[self.get_graph(lambda x:1,color=BLUE)] secondApprox=[self.get_graph(lambda x:1,color=BLUE), @@ -124,16 +142,44 @@ class graphScene(GraphScene): bottomText8.scale(0.5) bottomText1.shift(4.5*RIGHT+2.5*DOWN) - bottomText2.shift(4.5*RIGHT+2.5*DOWN) - bottomText3.shift(4.5*RIGHT+2.5*DOWN) - bottomText4.shift(4.5*RIGHT+2.5*DOWN) - bottomText5.shift(4.5*RIGHT+2.5*DOWN) - bottomText6.shift(4.5*RIGHT+2.5*DOWN) - bottomText7.shift(4.5*RIGHT+2.5*DOWN) - bottomText8.shift(4.5*RIGHT+2.5*DOWN) + # bottomText2.shift(4.5*RIGHT+2.5*DOWN) + # bottomText3.shift(4.5*RIGHT+2.5*DOWN) + # bottomText4.shift(4.5*RIGHT+2.5*DOWN) + # bottomText5.shift(4.5*RIGHT+2.5*DOWN) + # bottomText6.shift(4.5*RIGHT+2.5*DOWN) + # bottomText7.shift(4.5*RIGHT+2.5*DOWN) + # bottomText8.shift(4.5*RIGHT+2.5*DOWN) + bottomText2.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText3.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText4.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText5.shift(3*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText6.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText7.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText8.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + + bottomText2.scale(0.7) + bottomText3.scale(0.7) + bottomText4.scale(0.7) + bottomText5.scale(0.7) + bottomText6.scale(0.7) + bottomText7.scale(0.7) + bottomText8.scale(0.7) self.play(Write(bottomText1)) - self.wait(1) + self.wait(0.8) + #self.activate_zooming(animate=True) + self.camera_frame.save_state() + group.move_to(4*y_each_unit*UP+4.6*RIGHT*x_each_unit).scale(0.7) + self.play(self.camera_frame.set_width, 8, + self.camera_frame.move_to, x_each_unit*UP, + ApplyMethod(trTextGrup.move_to,4*y_each_unit*UP+4.1*RIGHT*x_each_unit), + ApplyMethod(bottomText1.move_to,3.4*RIGHT*x_each_unit+2.5*DOWN*y_each_unit), + ApplyMethod(equation.shift,1.39*DOWN+2*RIGHT), + ApplyMethod(text.shift,1.39*DOWN+2*RIGHT),) + self.play(ApplyMethod(text.scale,0.5),ApplyMethod(equation.scale,0.5),ApplyMethod(bottomText1.scale,0.6),ApplyMethod(trTextGrup.scale,0.7)) + self.play(ApplyMethod(text.shift,0.3*UP)) + self.wait(0.6) + self.play(ShowCreation(firstApprox[0]),ReplacementTransform(bottomText1,bottomText2)) #change coeff in tn(x) self.play(ReplacementTransform(generalized_eq_coeff[0],coeff[0])) @@ -170,10 +216,12 @@ class graphScene(GraphScene): self.wait(2) textFinal=TextMobject("And so on..!") - textFinal.scale(0.7) - textFinal.shift(4.5*RIGHT+2.5*DOWN) + textFinal.scale(0.35) + textFinal.shift(3.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) self.play(ReplacementTransform(bottomText8,textFinal)) - self.wait(2.5) + self.wait(1) + self.play(FadeOut(equation),FadeOut(text)) + self.play(self.camera_frame.set_width, 15) finalFormula=TextMobject("Hence","$T_{ n }(x)$","=","$f(0)+f'(0)x+\\frac { f''(0) }{ 2! }x^2+..+\\frac { { f }^{ n }(0) }{ n! } { x }^{ n }$") finalFormula.scale(0.8) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script2.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video2_TaylorExpansionGeneralForm.py index b5d0a53..c177ab4 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script2.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video2_TaylorExpansionGeneralForm.py @@ -59,6 +59,18 @@ class graphScene(GraphScene): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") + equation.scale(0.55) + equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) + text=TextMobject("$a=1$") + text.scale(0.55) + equation.shift(3.39*UP+5*LEFT) + text.shift(3*UP+5*LEFT) + + self.add(equation) + self.add(text) + + generalized_eq_coeff=[] variables_eq=[] eq,generalized_eq_coeff=formFormula(generalized_eq_coeff,variables_eq) diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script3.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video3_radiusOfConvergence.py index a2870d4..52f07bb 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script3.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video3_radiusOfConvergence.py @@ -2,7 +2,7 @@ from manimlib.imports import* import math -class graphScene(GraphScene): +class graphScene(GraphScene,MovingCameraScene): CONFIG = { "x_min": -8, "x_max": 8, @@ -16,12 +16,15 @@ class graphScene(GraphScene): "exclude_zero_label": True, "x_labeled_nums": range(-8, 8, 1), } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) def construct(self): x_each_unit = self.x_axis_width / (self.x_max - self.x_min) y_each_unit = self.y_axis_height / (self.y_max - self.y_min) - self.setup_axes(animate=True) + self.setup_axes(animate=True,scalee=1) lnx=self.get_graph(lambda x:math.log2(x),color=RED,x_min=0.01,x_max=8) @@ -98,14 +101,23 @@ class graphScene(GraphScene): circle=Circle(radius=ORIGIN+x_each_unit*2,color=PURPLE_E) circle.shift(ORIGIN+RIGHT*x_each_unit*2) - radiusLine=Line(start=ORIGIN+x_each_unit*RIGHT*2,end=ORIGIN+x_each_unit*4*RIGHT,color=PURPLE_E) + radiusLine=Line(start=ORIGIN+x_each_unit*RIGHT*2,end=ORIGIN+x_each_unit*2*RIGHT+y_each_unit*3*UP,color=PURPLE_E) radius=TextMobject("$R$") radius.set_color(RED) radius.scale(0.5) - radius.shift(ORIGIN+RIGHT*x_each_unit*2.45+DOWN*y_each_unit*0.6) + radius.shift(ORIGIN+RIGHT*x_each_unit*2.45+UP*y_each_unit*2.2) + rText=TextMobject("R",":","Radius of Convergence").scale(0.3).shift(x_each_unit*RIGHT*2+UP*y_each_unit*3.3).set_color_by_tex_to_color_map({"R":RED,"Radius of Convergence":YELLOW}) self.play(FadeOut(equations[6]),Write(circle)) self.wait(0.6) self.play(Write(radiusLine)) self.play(FadeIn(radius)) - self.wait(2)
\ No newline at end of file + self.wait(0.7) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 8, + self.camera_frame.move_to, y_each_unit*UP+x_each_unit*2*RIGHT) + self.play(Write(rText)) + self.wait(1) + self.play(self.camera_frame.set_width, 15, + self.camera_frame.move_to,0) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Taylor Series/script4.py b/FSF-2020/calculus/series-and-transformations/Taylor Series/video4_DivergentRemainder.py index 1f41c97..1f41c97 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script4.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video4_DivergentRemainder.py diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md b/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md new file mode 100644 index 0000000..c626bdf --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/README.md @@ -0,0 +1,9 @@ +#### Sampling +![GIF1](gifs/file1.gif) + +#### Z Transform of a delta function +![GIF2](gifs/file2.gif) + +#### Region of convergence +![GIF3](gifs/file3.gif) + diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif Binary files differnew file mode 100644 index 0000000..d21aa59 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file1.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif Binary files differnew file mode 100644 index 0000000..203be8d --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file2.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif Binary files differnew file mode 100644 index 0000000..0f100f1 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/gifs/file3.gif diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py new file mode 100644 index 0000000..47615e3 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video1_Sampling.py @@ -0,0 +1,81 @@ +from manimlib.imports import * +import math + +def func(x): + return math.pow(x,3)-2*math.pow(x,2)-x+3 + +class graphScene(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "y_min": -4, + "y_max": 4, + "x_tick_frequency": 0.2, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$f(t)$", + "exclude_zero_label": True, + "x_labeled_nums": range(-3, 4, 1), + "y_axis_height": 5, + "x_axis_width": 9, + } + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + fx=TextMobject("$f(t) = { t }^{ 3 }{ -2t }^{ 2 }-t+3$").set_color(RED).to_corner(UP+RIGHT).scale(0.4) + self.setup_axes(animate=True,scalee=1) + function=self.get_graph(lambda x:math.pow(x,3)-2*math.pow(x,2)-x+3,color=RED,x_min=-1,x_max=2) + functionArea=self.get_riemann_rectangles(function,x_min=-1,x_max=2,dx=0.01,start_color=GREEN,end_color=YELLOW,stroke_color=GREEN,fill_opacity=0.8) + functionDot=Dot(point=self.graph_origin,radius=0.065,color=WHITE) + aboveText1=TextMobject("Continuous","Time Function").shift(4*RIGHT+2*UP).scale(0.4).set_color_by_tex_to_color_map({"Continuous":YELLOW,"Time Function":BLUE}) + aboveText2=TextMobject("Discrete","Time Function").shift(4*RIGHT+2*UP).scale(0.4).set_color_by_tex_to_color_map({"Time Function":BLUE,"Discrete":YELLOW}) + + bottomText1=TextMobject("Instead of considering the","function","over the","entire $t$,").shift(4.5*RIGHT+3*DOWN).scale(0.4).set_color_by_tex_to_color_map({"entire $t$,":RED,"function":YELLOW}) + bottomText2=TextMobject("We consider only at","certain $t$").shift(4.5*RIGHT+3*DOWN).scale(0.4).set_color_by_tex_to_color_map({"certain $t$":RED}) + + self.play(ShowCreation(function),Write(fx),FadeIn(aboveText1)) + self.wait(0.7) + self.play(Write(bottomText1)) + self.play(ShowCreation(functionArea),MoveAlongPath(functionDot,function)) + self.wait(0.7) + self.play(FadeOut(bottomText1)) + self.play(Write(bottomText2),FadeOut(aboveText1)) + + dots=[Dot(radius=0.05) for i in range(10)] + dotShifts=[-1,-0.7,-0.4,0,0.3,0.6,1,1.3,1.6,2] + lines=[] + for x in dotShifts: + lines.append(Line(start=(x*x_each_unit,func(x)*y_each_unit,0),end=(x*x_each_unit,0,0),color=GREEN)) + for i in range(10): + dots[i].shift(ORIGIN+RIGHT*x_each_unit*dotShifts[i]+y_each_unit*UP*func(dotShifts[i])) + updatedGraph=VGroup(dots[0], + dots[1], + dots[2], + dots[3], + dots[4], + dots[5], + dots[6], + dots[7], + dots[8], + dots[9]) + updatedGraph1=VGroup( + lines[0], + lines[1], + lines[2], + lines[3], + lines[4], + lines[5], + lines[6], + lines[7], + lines[8], + lines[9]) + + self.play(FadeOut(functionDot)) + self.play(FadeOut(function),FadeIn(updatedGraph)) + self.play(FadeOut(functionArea),FadeIn(updatedGraph1)) + self.play(FadeOut(bottomText2),FadeIn(aboveText2)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py new file mode 100644 index 0000000..3063aa6 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video2_ZTransformOfDelta.py @@ -0,0 +1,121 @@ +from manimlib.imports import * +import numpy as np +import math + +class deltaTransformation(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 3, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$t$", + "y_axis_label": "$f(t)$", + "x_labeled_nums": range(-3, 4, 1), + # "y_axis_height": 4, + # "x_axis_width": 6, + } + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + self.setup_axes(animate=True,scalee=0.8) + function=TextMobject("$f(t) = 2{ \delta }_{ 0 }(t)+3{ \delta }_{ 1 }(t)+4{ \delta }_{ 2 }(t)$").scale(0.4).shift(5*RIGHT+3*UP).set_color(RED) + self.play(FadeIn(function)) + twoDGraph=[ + Line(start=(0,0,0),end=(0,2*y_each_unit,0),color=GREEN), + Line(start=(1*x_each_unit,0,0),end=(x_each_unit,3*y_each_unit,0),color=GREEN), + Line(start=(2*x_each_unit,0,0),end=(2*x_each_unit,4*y_each_unit,0),color=GREEN) + ] + groupGraph=VGroup(twoDGraph[1],twoDGraph[2],self.axes,twoDGraph[0]) + self.play(Write(twoDGraph[0]),ShowCreation(twoDGraph[1]),ShowCreation(twoDGraph[2])) + self.wait(1.2) + self.play(ApplyMethod(groupGraph.scale,0.7)) + self.play(ApplyMethod(groupGraph.shift,5*LEFT),ApplyMethod(function.move_to,5*LEFT+3*UP)) + self.graph_origin=2*RIGHT+2.5*DOWN + self.x_axis_width=6 + self.x_axis_label="$|z|$" + self.y_axis_label="$|F(t)|$" + self.x_min=-3 + self.x_max=6 + self.y_min=-1 + self.y_max=7 + self.x_labeled_nums=range(-3,7,1) + self.setup_axes(animate=True,scalee=0.6) + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + rightSideGraphs=[ + self.get_graph(lambda x:2,x_min=0,x_max=6,color=GREEN), + self.get_graph(lambda x:2+3/x,x_min=0.6,x_max=6,color=GREEN), + self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=6,color=GREEN) + ] + graphCoeff=[ + TextMobject("$2$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit*2+DOWN*y_each_unit*0.5).set_color(RED), + TextMobject("$2+\\frac { 3 }{ |z| }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3+UP*y_each_unit*2).set_color(RED), + TextMobject("$2+\\frac { 3 }{ |z| } +\\frac { 4 }{ { |z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3.5+UP*y_each_unit*2).set_color(RED) + ] + self.play(ReplacementTransform(twoDGraph[0],rightSideGraphs[0]),FadeIn(graphCoeff[0])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[0]),ReplacementTransform(twoDGraph[1],rightSideGraphs[1]),ReplacementTransform(graphCoeff[0],graphCoeff[1])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[1]),ReplacementTransform(twoDGraph[2],rightSideGraphs[2]),ReplacementTransform(graphCoeff[1],graphCoeff[2])) + + self.wait(2) + + +class graphCont(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 6, + "y_min": -1, + "y_max": 7, + "graph_origin": 2*RIGHT+2.5*DOWN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$|z|$", + "y_axis_label": "$|F(t)|$", + "exclude_zero_label": True, + "x_labeled_nums": range(-3, 7, 1), + "x_axis_width": 6, + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + coeff=TextMobject("$2+\\frac { 3 }{ |z| } +\\frac { 4 }{ { |z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*3.5+UP*y_each_unit*2).set_color(RED) + self.setup_axes(scalee=0.6) + graph=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=6,color=GREEN) + xAxis=self.get_graph(lambda x:0,x_min=1.24,x_max=6).shift(3*LEFT) + self.add(graph) + self.add(coeff) + self.play(ApplyMethod((self.axes).shift,3*LEFT),ApplyMethod(coeff.shift,3*LEFT),ApplyMethod(graph.shift,3*LEFT)) + topText=TextMobject("Here we get","output","for","any value of $|z|$").scale(0.4).shift(3*UP+3*RIGHT).set_color_by_tex_to_color_map({"output":YELLOW,"any value of $|z|$":BLUE}) + topText1=TextMobject("Except for $|z|=0$").scale(0.7).shift(2.5*UP+3*RIGHT).set_color(RED) + dot1=Dot(color=WHITE,radius=0.06) + dot2=Dot(color=WHITE,radius=0.06) + self.play(Write(topText)) + self.play(MoveAlongPath(dot1,graph),MoveAlongPath(dot2,xAxis),run_time=2) + self.play(Write(topText1)) + self.play(FadeOut(dot1),FadeOut(dot2)) + self.wait(0.5) + path=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=1.24,x_max=0.8) + path1=self.get_graph(lambda x:0,x_min=1.24,x_max=0.8) + graphUpdated=self.get_graph(lambda x:2+(3/x)+(4/x**2),x_min=0.8,x_max=6,color=GREEN) + self.camera_frame.save_state() + self.play(FadeOut(graph),Write(graphUpdated)) + self.play(self.camera_frame.set_width, 30, + MoveAlongPath(dot1,path),MoveAlongPath(dot2,path1),run_time=2) + self.wait(1) + + self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(graphUpdated),FadeIn(graph),self.camera_frame.set_width,15) + self.wait(1) + + + + + diff --git a/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py b/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py new file mode 100644 index 0000000..bdfd8b3 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Z-Transform/video3_RegionOfConvergence.py @@ -0,0 +1,144 @@ +from manimlib.imports import * +import numpy as np +import math + +class graph1(GraphScene): + CONFIG = { + "x_min": -3, + "x_max": 5, + "y_min": -1, + "y_max": 1, + "graph_origin": ORIGIN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$n$", + "y_axis_label": "$x(n)$", + "x_labeled_nums": range(-3, 6, 1), + "y_axis_height": 7, + "y_tick_frequency": 0.1, + } + def func(self,x,n): + summ=0 + for i in range(n+1): + summ+=(1/(math.pow(x,i))) + return summ + + def finalFunc(self,x): + if(x!=0): + return 1/(1-(1/(2*x))) + + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + self.setup_axes(animate=True,scalee=0.8) + function=TextMobject("$X(t)=\sum _{ n=0 }^{ \infty }{ { (0.5) }^{ n }{ z }^{ -n } }$").scale(0.4).shift(5*RIGHT+3*UP).set_color(RED) + self.play(FadeIn(function)) + twoDGraph=[] + for i in range(5): + twoDGraph.append(Line(start=(i*x_each_unit,0,0),end=(i*x_each_unit,math.pow(0.5,i)*y_each_unit,0),color=GREEN)) + + groupGraph=VGroup(self.axes,twoDGraph[0],twoDGraph[1],twoDGraph[2],twoDGraph[3],twoDGraph[4]) + self.play(Write(twoDGraph[0]),ShowCreation(twoDGraph[1]),ShowCreation(twoDGraph[2]),ShowCreation(twoDGraph[3]),ShowCreation(twoDGraph[4])) + self.wait(1.2) + + self.play(ApplyMethod(groupGraph.scale,0.7)) + self.play(ApplyMethod(groupGraph.shift,6*LEFT),ApplyMethod(function.move_to,5*LEFT+3*UP)) + + someText1=TextMobject("Since it is a","summation","of","infinite terms",", it might").shift(2*RIGHT+2*UP).scale(0.5).set_color_by_tex_to_color_map({"summation":YELLOW,"infinite terms":BLUE}) + someText2=TextMobject("Converge","or","Diverge").shift(2*RIGHT+0.5*DOWN+2*UP).scale(0.7).set_color_by_tex_to_color_map({"Converge":GREEN,"Diverge":RED}) + someText3=TextMobject("depending upon","$|z|$").shift(2*RIGHT+UP).scale(0.5).set_color_by_tex_to_color_map({"$|z|$":YELLOW}) + self.play(Write(someText1)) + self.play(FadeIn(someText2)) + self.play(Write(someText3)) + self.wait(1) + self.play(FadeOut(someText1),FadeOut(someText2),FadeOut(someText3)) + + self.graph_origin=2*RIGHT+DOWN + self.x_axis_width=6 + self.y_axis_height=5 + self.y_tick_frequency=1 + self.x_axis_label="$|z|$" + self.y_axis_label="$|X(n)|$" + self.x_min=-3 + self.x_max=5 + self.y_min=-1 + self.y_max=5 + self.x_labeled_nums=range(-3,6,1) + self.setup_axes(animate=True,scalee=0.6) + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + rightSideGraphs=[] + xmins=[0,0.25,0.65,0.9,1] + for i in range(5): + rightSideGraphs.append(self.get_graph(lambda x:self.func(x,i),x_min=xmins[i],x_max=5,color=GREEN)) + rightSideGraphs.append(self.get_graph(lambda x:1/(1-(1/(2*x))),x_min=0.63,x_max=5,color=GREEN)) + + graphCoeff=[ + TextMobject("$1$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+0.65*UP*y_each_unit*2+DOWN*y_each_unit*0.5).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { 2|z| }^{ 2 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { (2|z|) }^{ 2 } } +\\frac { 1 }{ { (2|z|) }^{ 3 } }$").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$1+\\frac { 1 }{ 2|z| } +\\frac { 1 }{ { (2|z|) }^{ 2 } } +\\frac { 1 }{ { (2|z|) }^{ 3 } } +\\frac { 1 }{ (2|z|)^{ 4 } } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED), + TextMobject("$\\frac { 1 }{ (1-\\frac { 1 }{ 2z } ) } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED) + ] + + self.play(ReplacementTransform(twoDGraph[0],rightSideGraphs[0]),FadeIn(graphCoeff[0])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[0]),ReplacementTransform(twoDGraph[1],rightSideGraphs[1]),ReplacementTransform(graphCoeff[0],graphCoeff[1])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[1]),ReplacementTransform(twoDGraph[2],rightSideGraphs[2]),ReplacementTransform(graphCoeff[1],graphCoeff[2])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[2]),ReplacementTransform(twoDGraph[3],rightSideGraphs[3]),ReplacementTransform(graphCoeff[2],graphCoeff[3])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[3]),ReplacementTransform(twoDGraph[4],rightSideGraphs[4]),ReplacementTransform(graphCoeff[3],graphCoeff[4])) + self.wait(0.5) + self.play(FadeOut(rightSideGraphs[4]),ShowCreation(rightSideGraphs[5]),ReplacementTransform(graphCoeff[4],graphCoeff[5])) + + self.wait(2) + # #self.play(FadeOut(self.axes),FadeOut(function),FadeOut(twoDGraph[0]),FadeOut(twoDGraph[1]),FadeOut(twoDGraph[2])) + + +class graphCont(GraphScene,MovingCameraScene): + CONFIG = { + "x_min": -3, + "x_max": 5, + "y_min": -1, + "y_max": 5, + "graph_origin": 2*RIGHT+DOWN, + "function_color": RED, + "axes_color": BLUE, + "x_axis_label": "$|z|$", + "y_axis_label": "$|X(n)|$", + "x_labeled_nums": range(-3, 6, 1), + "x_axis_width": 6, + "y_axis_height": 5 + } + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + + def construct(self): + x_each_unit = self.x_axis_width / (self.x_max - self.x_min) + y_each_unit = self.y_axis_height / (self.y_max - self.y_min) + + coeff=TextMobject("$\\frac { 1 }{ (1-\\frac { 1 }{ 2z } ) } $").scale(0.4).shift(self.graph_origin+x_each_unit*RIGHT*2+UP*y_each_unit).set_color(RED) + self.setup_axes(scalee=0.6) + graph=self.get_graph(lambda x:1/(1-(1/(2*x))),x_min=0.63,x_max=5,color=GREEN) + + self.add(graph) + self.add(coeff) + + self.play(ApplyMethod((self.axes).shift,3*LEFT),ApplyMethod(coeff.shift,3*LEFT),ApplyMethod(graph.shift,3*LEFT)) + self.wait(1) + + dashLine=DashedLine(start=self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT,end=self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT+y_each_unit*UP*5,color=YELLOW) + pt=TextMobject("0.5").scale(0.3).shift(self.graph_origin+3*LEFT+0.5*x_each_unit*RIGHT+DOWN*y_each_unit*0.3) + self.play(Write(dashLine)) + self.play(Write(pt)) + self.wait(0.6) + rectRegion=Rectangle(height=y_each_unit*5,width=x_each_unit*5,fill_color=WHITE,fill_opacity=0.3,opacity=0.3,color=BLACK).shift(1.6*RIGHT*x_each_unit+0.5*DOWN*y_each_unit+1.5*UP) + self.play(ShowCreation(rectRegion)) + text=TextMobject("Region Of Convergence!").scale(0.4).shift(4.6*RIGHT+1.5*UP).set_color(GREEN) + self.play(FadeIn(text)) + self.wait(2) diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt new file mode 100644 index 0000000..cae98ce --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file.txt @@ -0,0 +1,3 @@ +file 'text.mp4' +file 'LinearTransformation.mp4' +file 'NonLinearTransformation.mp4' diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file1_transformations.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file1_transformations.py new file mode 100644 index 0000000..677f890 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file1_transformations.py @@ -0,0 +1,45 @@ +from manimlib.imports import * + +class text(Scene): + def construct(self): + text1 = TextMobject("For a grid, undergoing a linear transformation, all it's straight lines") + text1.scale(0.9) + text2 = TextMobject("must either remain straight lines or sends to a point in the grid formed") + text2.scale(0.9) + text1.move_to(ORIGIN+UP) + text2.move_to(ORIGIN) + self.play(Write(text1)) + self.play(Write(text2)) + self.wait() + self.play(FadeOut(text1),FadeOut(text2)) + +class LinearTransformation(LinearTransformationScene): + CONFIG = { + "basis_vector_stroke_width": 3, + "leave_ghost_vectors": True, + } + + def construct(self): + self.setup() + matrix = [[0.866,-0.5],[0.5,0.866]] + self.apply_matrix(matrix) + text = TextMobject("This is a Linear","Trasformation") + text[0].move_to(DOWN+4*LEFT) + text[1].move_to(1.5*DOWN+4*LEFT) + text.add_background_rectangle() + self.play(Write(text)) + self.wait() + +class NonLinearTransformation(Scene): + def construct(self): + grid = NumberPlane() + self.play(ShowCreation(grid),run_time =2) + NonLinearTrans = lambda coordinates : coordinates + np.array([np.sin(coordinates[1]),np.sin(coordinates[0]),0,]) + grid.prepare_for_nonlinear_transform() + self.play(grid.apply_function,NonLinearTrans) + text = TextMobject("While, this is not a","Linear Trasformation") + text[0].move_to(DOWN+4*LEFT) + text[1].move_to(1.5*DOWN+4*LEFT) + text.add_background_rectangle() + self.play(Write(text)) + self.wait()
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file1_Understand_Linear_Transformations_visually.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py index 577032d..577032d 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file1_Understand_Linear_Transformations_visually.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_Understand_Linear_Transformations_visually.py diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file2_Uniform_Scaling.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py index a7856a5..a7856a5 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file2_Uniform_Scaling.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_Uniform_Scaling.py diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file3_Horizontal_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py index 91f098e..91f098e 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file3_Horizontal_Shear.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear.py diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file3_Horizontal_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif Binary files differindex 9bef1b6..9bef1b6 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file3_Horizontal_Shear_gif.gif +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Horizontal_Shear_gif.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file4_Vertical_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py index 718e4e0..718e4e0 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file4_Vertical_Shear.py +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear.py diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file4_Vertical_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif Binary files differindex 7ca323f..7ca323f 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/file4_Vertical_Shear_gif.gif +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Vertical_Shear_gif.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py new file mode 100755 index 0000000..01a0cef --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_linear_transformation.py @@ -0,0 +1,27 @@ +from manimlib.imports import *
+class LinearTrans(LinearTransformationScene,MovingCameraScene):
+ CONFIG = {
+ "basis_vector_stroke_width": 1,
+ "leave_ghost_vectors": True,
+ }
+
+ def setup(self):
+ LinearTransformationScene.setup(self)
+ MovingCameraScene.setup(self)
+
+ def construct(self):
+ self.setup()
+ self.camera_frame.save_state()
+ self.play(self.camera_frame.set_width, 7)
+ matrix = [[0.866,-0.5],[0.5,0.866]]
+ self.apply_matrix(matrix)
+ arc1 = Arc(radius = 0.25,angle=TAU/12)
+ arc2 = Arc(radius = 0.25,angle=TAU/12,start_angle=TAU/4)
+ text1 = TextMobject(r"$\theta$")
+ text1.scale(0.5)
+ text1.move_to(0.5*UP+0.125*LEFT)
+ text2 = TextMobject(r"$\theta$")
+ text2.scale(0.5)
+ text2.move_to(0.5*RIGHT+0.125*UP)
+ self.play(ShowCreation(arc1),ShowCreation(arc2),Write(text1),Write(text2),run_time=1)
+ self.wait()
diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py new file mode 100755 index 0000000..b400f93 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file1_orthogonal.py @@ -0,0 +1,34 @@ +from manimlib.imports import *
+
+class Orthogonal(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+ self.play(ShowCreation(axes))
+ self.move_camera(phi=30*DEGREES,theta=-45*DEGREES,run_time=3)
+ line1 = Line(start = ORIGIN,end = -3*LEFT)
+ line1.set_color(DARK_BLUE)
+ tip1 = Polygon(-LEFT,-0.8*LEFT-0.2*DOWN,-0.8*LEFT-0.2*UP)
+ tip1.move_to(-3*LEFT)
+ tip1.set_opacity(1)
+ tip1.set_fill(DARK_BLUE)
+ tip1.set_color(DARK_BLUE)
+
+ arrow2 = Line(start = ORIGIN,end = -3*UP)
+ arrow2.set_color(DARK_BLUE)
+ tip2 = Polygon(DOWN,0.8*DOWN-0.2*RIGHT,0.8*DOWN-0.2*LEFT)
+ tip2.move_to(3*DOWN)
+ tip2.set_opacity(1)
+ tip2.set_fill(DARK_BLUE)
+ tip2.set_color(DARK_BLUE)
+ arrow2.set_color(DARK_BLUE)
+
+ arrow3 = Line(start = ORIGIN,end = [0,0,3])
+ arrow3.set_color(DARK_BLUE)
+ tip3 = Polygon([0,0,3],[0,0,2.8]-0.2*RIGHT,[0,0,2.8]-0.2*LEFT)
+ tip3.set_opacity(1)
+ tip3.set_fill(DARK_BLUE)
+ tip3.set_color(DARK_BLUE)
+
+ self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), ShowCreation(arrow3), ShowCreation(tip3))
+
+ self.wait()
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py new file mode 100644 index 0000000..0a28f22 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal Basis/file2_OrthonormalBasis.py @@ -0,0 +1,82 @@ +from manimlib.imports import * +class OrthonormalBasis(GraphScene): + CONFIG = { + "x_min" : -6, + "x_max" : 6, + "y_min" : -4, + "y_max" : 4, + "graph_origin" : ORIGIN , +} + + def construct(self): + self.setup_axes(animate=True) + + XTD = self.x_axis_width/(self.x_max-self.x_min) + YTD = self.y_axis_height/(self.y_max-self.y_min) + + arrow1 = Arrow(start = ORIGIN,end = 0.707*YTD*UP+0.707*XTD*RIGHT) + arrow1.scale(2.25) + arrow1.set_color(DARK_BLUE) + + arrow2 = Arrow(start = ORIGIN,end = 0.707*YTD*UP+0.707*XTD*LEFT) + arrow2.scale(2.25) + arrow2.set_color(DARK_BLUE) + + square = Polygon(UP*0.4*YTD,0.2*(YTD*UP+XTD*RIGHT),ORIGIN,0.2*(YTD*UP+XTD*LEFT)) + square.set_color(DARK_BLUE) + self.play(ShowCreation(arrow2), ShowCreation(arrow1), ShowCreation(square)) + + ortho = TextMobject("Orthonormal Vectors") + ortho.scale(0.75) + ortho.move_to(DOWN+3*RIGHT) + self.play(Write(ortho)) + self.wait() + self.play(FadeOut(ortho)) + + arrow3 = Arrow(start = ORIGIN,end = YTD*3*UP+XTD*LEFT) + arrow3.scale(1.25) + arrow3.set_color(GOLD_E) + self.play(ShowCreation(arrow3)) + + arrow4 = Arrow(start = ORIGIN,end = YTD*UP+XTD*RIGHT) + arrow4.scale(1.8) + arrow4.set_color(GOLD_A) + + arrow5 = Arrow(start = ORIGIN,end = 2*YTD*UP-2*XTD*RIGHT) + arrow5.scale(1.3) + arrow5.set_color(GOLD_A) + + self.play(ShowCreation(arrow5), ShowCreation(arrow4)) + + self.wait() + + self.play(FadeOut(arrow1), FadeOut(arrow2), FadeOut(square)) + + self.wait() + + text1 = TextMobject(r"$<v,v_1> v_1$") + text1.move_to(UP+2*RIGHT) + text1.scale(0.75) + text2 = TextMobject(r"$<v,v_2> v_2$") + text2.move_to(UP+3*LEFT) + text2.scale(0.75) + + text3 = TextMobject("v") + text3.move_to(YTD*3.5*UP+XTD*1.5*LEFT) + + self.play(Write(text1), Write(text2), Write(text3)) + self.wait() + + line1 = DashedLine(start = YTD*UP+XTD*RIGHT, end = YTD*3*UP+XTD*1*LEFT) + line2 = DashedLine(start = YTD*2*UP+XTD*2*LEFT, end = YTD*3*UP+XTD*1*LEFT) + self.play(ShowCreation(line1),ShowCreation(line2)) + + self.wait() + + text = TextMobject(r"$v$ is the sum of projections","on the orthonormal vectors") + text[0].move_to(DOWN+3.2*RIGHT) + text[1].move_to(1.5*DOWN+3.2*RIGHT) + self.play(Write(text)) + self.wait(2) + self.play(FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(text1), FadeOut(text2), FadeOut(text3), FadeOut(self.axes), FadeOut(line1), FadeOut(line2)) + self.play(FadeOut(text)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif Binary files differnew file mode 100644 index 0000000..7d8d2e1 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py new file mode 100644 index 0000000..afe4f9a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Column_Space.py @@ -0,0 +1,30 @@ +from manimlib.imports import * + +class Column_Space(Scene): + def construct(self): + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \end{array} \right)$") + A.move_to(2*UP) + A[1].set_color(color = DARK_BLUE) + A.scale(0.75) + + self.play(Write(A),run_time = 1) + + CS_A = TextMobject(r"Column Space of $A = x_{1}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 2 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 3 \\ 1 \\ 2 \end{array} \right)$",r"$ + x_{3}$",r"$\left( \begin{array}{c} 1 \\ 1 \\ 4 \\ 3 \end{array} \right)$") + CS_A.move_to(1.5*LEFT+1*DOWN) + CS_A[1].set_color(color = DARK_BLUE) + CS_A[3].set_color(color = DARK_BLUE) + CS_A[5].set_color(color = DARK_BLUE) + CS_A.scale(0.75) + + self.play(Write(CS_A),run_time = 2) + + arrow1 = Arrow(start = 1.25*UP,end = 0.25*DOWN+1.75*LEFT) + arrow2 = Arrow(start = 1.35*UP+0.5*RIGHT,end = 0.25*DOWN+0.5*RIGHT) + arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = 0.25*DOWN+2.9*RIGHT) + + Defn = TextMobject("Linear Combination of Columns of Matrix") + Defn.move_to(3*DOWN) + + self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow2), ShowCreation(arrow3),run_time = 1) + self.wait(1)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py new file mode 100644 index 0000000..b16a32a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_Row_Space.py @@ -0,0 +1,145 @@ +from manimlib.imports import * + +class Row_Space(Scene): + def construct(self): + + Heading = TextMobject("Row Space") + defn1 = TextMobject("Definition 1: Row Space of a matrix is the linear combination of the rows of that matrix.") + defn2 = TextMobject("Definition 2: It is a vector space generated by a linear combination of the columns of $A^{T}$.") + equivalent = TextMobject(r"Definition 1 $\equiv$ Definition 2") + + Heading.move_to(2*UP) + Heading.set_color(color = DARK_BLUE) + + defn1.move_to(UP) + defn1.scale(0.75) + + defn2.scale(0.75) + + equivalent.move_to(DOWN) + + self.play(Write(Heading)) + self.play(Write(defn1)) + self.play(Write(defn2)) + self.play(Write(equivalent)) + + self.wait(2) + self.play(FadeOut(Heading),FadeOut(defn1),FadeOut(defn2),ApplyMethod(equivalent.move_to,2*UP)) + + how = TextMobject("Let us see, How?") + how.move_to(UP) + self.play(Write(how)) + self.play(FadeOut(equivalent),FadeOut(how)) + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c c} 1 & 2 & 1 \\ 1 & 3 & 1 \\ 2 & 1 & 4 \\ 3 & 2 & 3 \end{array} \right)$") + A.move_to(2*UP+3*LEFT) + A[1].set_color(color = DARK_BLUE) + A.scale(0.80) + + self.play(Write(A)) + + rows = TextMobject(r"Rows of A $\rightarrow$", + r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$,", + r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$,", + r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$,", + r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") + rows.scale(0.75) + rows[1:5].set_color(DARK_BLUE) + self.play(Write(rows)) + + ac_defn1 = TextMobject("According to Definition 1 : ") + ac_defn1.move_to(DOWN) + + RS_A = TextMobject(r"Row Space of $A = x_{1}$", + r"$\left( \begin{array}{c c c} 1 & 2 & 1 \end{array} \right)$", + r"$+x_{2}$", + r"$ \left( \begin{array}{c c c} 1 & 3 & 1 \end{array} \right)$", + r"$ + x_{3}$", + r"$\left( \begin{array}{c c c} 2 & 1 & 4 \end{array} \right)$", + r"$+x_{4}$", + r"$ \left( \begin{array}{c c c} 3 & 2 & 3 \end{array} \right)$") + RS_A.move_to(DOWN+DOWN) + RS_A[6].move_to(2*DOWN+DOWN) + RS_A[7].move_to(2*DOWN+2*RIGHT+DOWN) + RS_A[1].set_color(color = DARK_BLUE) + RS_A[3].set_color(color = DARK_BLUE) + RS_A[5].set_color(color = DARK_BLUE) + RS_A[7].set_color(color = DARK_BLUE) + RS_A.scale(0.75) + + self.play(FadeOut(rows[0]),Transform(rows[1],RS_A[1]),Transform(rows[2],RS_A[3]),Transform(rows[3],RS_A[5]),Transform(rows[4],RS_A[7])) + self.play(FadeIn(ac_defn1), Write(RS_A)) + self.wait(1) + + self.play(FadeOut(rows[1]), FadeOut(rows[2]), FadeOut(rows[3]), FadeOut(rows[4]), FadeOut(RS_A), FadeOut(ac_defn1)) + + A_T = TextMobject(r"$A^{T} = $",r"$\left( \begin{array}{c c c c} 1 & 1 & 2 & 3 \\ 2 & 3 & 1 & 2 \\ 1 & 1 & 4 & 3 \end{array} \right)$") + A_T.move_to(2*UP+3*RIGHT) + A_T[1].set_color(color = DARK_BLUE) + A_T.scale(0.80) + + self.play(Write(A_T)) + + change1 = TextMobject(r"Rows of $A\equiv$ Columns of $A^{T}$") + change2 = TextMobject(r"Columns of $A\equiv$ Rows of $A^{T}$") + change2.move_to(DOWN) + + change3 = TextMobject(r"Row Space of $A$ = Linear Combination of",r"Rows","of",r"A") + change3.move_to(2*DOWN) + change3[1].set_color(DARK_BLUE) + change3[3].set_color(DARK_BLUE) + + self.play(Write(change1)) + self.play(Write(change2)) + self.play(Write(change3)) + + columns = TextMobject("Columns") + columns.scale(0.6) + columns.set_color(DARK_BLUE) + columns.move_to(2*DOWN+4.1*RIGHT) + + a = TextMobject(r"$A^{T}$") + a.set_color(DARK_BLUE) + a.move_to(1.95*DOWN+5.6*RIGHT) + + self.wait(0.5) + + self.play(Transform(change3[1],columns), Transform(change3[3],a)) + + equal = TextMobject(r"= Column Space($A^{T}$)") + equal.move_to(3*DOWN+0.5*RIGHT) + + self.play(Write(equal)) + + self.play(FadeOut(A_T), FadeOut(change1), FadeOut(change2), FadeOut(change3), FadeOut(A), FadeOut(equal)) + + ac_defn1.move_to(3*UP) + RS_A.move_to(1.5*UP) + RS_A[6].move_to(UP) + RS_A[7].move_to(UP+1.5*RIGHT) + + self.play(Write(RS_A),FadeIn(ac_defn1)) + + CS_AT = TextMobject(r"Row Space of $A = x_{1}$", + r"$\left( \begin{array}{c} 1 \\ 2 \\ 1 \end{array} \right)$", + r"$+x_{2}$", + r"$ \left( \begin{array}{c} 1 \\ 3 \\ 1 \end{array} \right)$", + r"$ + x_{3}$", + r"$\left( \begin{array}{c} 2 \\ 1 \\ 4 \end{array} \right)$", + r"$+x_{4}$", + r"$ \left( \begin{array}{c} 3 \\ 2 \\ 3 \end{array} \right)$") + CS_AT.move_to(1.5*DOWN) + CS_AT[1].set_color(color = DARK_BLUE) + CS_AT[3].set_color(color = DARK_BLUE) + CS_AT[5].set_color(color = DARK_BLUE) + CS_AT[7].set_color(color = DARK_BLUE) + CS_AT.scale(0.75) + + ac_defn2 = TextMobject("According to Definition 2 : ") + equivalent = TextMobject(r"Hence, Definition 1 $\equiv$ Definition 2") + equivalent.move_to(3*DOWN) + + self.play(Write(CS_AT),FadeIn(ac_defn2)) + self.play(Write(equivalent)) + + self.wait() diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file.txt b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file.txt new file mode 100644 index 0000000..5c48a13 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file.txt @@ -0,0 +1,3 @@ +file 'RN_Line.mp4' +file 'RN_Point.mp4' +file 'RN_SameDim.mp4' diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file1_RN_Theorem.py b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file1_RN_Theorem.py new file mode 100755 index 0000000..e54276c --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file1_RN_Theorem.py @@ -0,0 +1,97 @@ +from manimlib.imports import *
+class RN_Line(LinearTransformationScene):
+ def construct(self):
+
+ self.setup()
+ self.wait()
+
+ predim = TextMobject("Dimension of this vector space is 2")
+ predim.move_to(DOWN+4*LEFT)
+ predim.scale(0.75)
+ predim.add_background_rectangle()
+ self.play(Write(predim))
+ self.wait()
+ self.play(FadeOut(predim))
+
+ afterlt = TextMobject("After Linear transformation")
+ afterlt.move_to(DOWN+4*LEFT)
+ afterlt.scale(0.75)
+ afterlt.add_background_rectangle()
+
+ afterlt2 = TextMobject("Dimension of the vector space","changes to 1")
+ afterlt2[0].move_to(1.5*DOWN+4*LEFT)
+ afterlt2[1].move_to(2*DOWN+4*LEFT)
+ afterlt2.scale(0.75)
+ afterlt2.add_background_rectangle()
+ matrix = [[1,1],[1,1]]
+ self.apply_matrix(matrix)
+ self.play(Write(afterlt))
+ self.play(Write(afterlt2))
+ self.wait()
+ nullity = TextMobject("Hence, nullity = 1")
+ nullity.move_to(DOWN+4*LEFT)
+ self.play(FadeOut(afterlt),FadeOut(afterlt2),Write(nullity))
+ self.wait(1)
+ self.play(FadeOut(nullity))
+
+class RN_Point(LinearTransformationScene):
+ def construct(self):
+ self.setup()
+ self.wait()
+ predim = TextMobject("Another One")
+ predim.move_to(DOWN+4*LEFT)
+ predim.scale(0.75)
+ predim.add_background_rectangle()
+ self.play(Write(predim))
+ self.wait()
+ self.play(FadeOut(predim))
+ afterlt = TextMobject("After Linear transformation")
+ afterlt.move_to(DOWN+4*LEFT)
+ afterlt.scale(0.75)
+ afterlt.add_background_rectangle()
+ afterlt2 = TextMobject("Dimension of the vector space","changes to 0")
+ afterlt2[0].move_to(1.5*DOWN+4*LEFT)
+ afterlt2[1].move_to(2*DOWN+4*LEFT)
+ afterlt2.scale(0.75)
+ afterlt2.add_background_rectangle()
+ matrix = [[0,0],[0,0]]
+ self.apply_matrix(matrix)
+ self.play(Write(afterlt))
+ self.play(Write(afterlt2))
+ self.wait()
+ nullity = TextMobject("Hence, nullity = 2")
+ nullity.move_to(DOWN+4*LEFT)
+ self.play(FadeOut(afterlt),FadeOut(afterlt2),Write(nullity))
+ self.wait(1)
+ self.play(FadeOut(nullity))
+
+class RN_SameDim(LinearTransformationScene):
+ def construct(self):
+ self.setup()
+ self.wait()
+ predim = TextMobject("Let us look at another example")
+ predim.add_background_rectangle()
+ predim.move_to(DOWN+4*LEFT)
+ predim.scale(0.75)
+ self.play(Write(predim))
+ self.wait()
+ self.play(FadeOut(predim))
+ afterlt = TextMobject("After Linear transformation")
+ afterlt.move_to(DOWN+4*LEFT)
+ afterlt.scale(0.75)
+ afterlt.add_background_rectangle()
+ afterlt2 = TextMobject("Dimension of the vector space","remains to be 2")
+ afterlt2[0].move_to(1.5*DOWN+4*LEFT)
+ afterlt2[1].move_to(2*DOWN+4*LEFT)
+ afterlt2.scale(0.75)
+ afterlt2.add_background_rectangle()
+ matrix = [[1,1],[0,1]]
+ self.apply_matrix(matrix)
+ self.play(Write(afterlt))
+ self.play(Write(afterlt2))
+ self.wait()
+ nullity = TextMobject("Hence, nullity = 0")
+ nullity.move_to(DOWN+4*LEFT)
+ self.play(FadeOut(afterlt),FadeOut(afterlt2),Write(nullity))
+ self.wait(1)
+ self.play(FadeOut(nullity))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/README.md b/FSF-2020/linear-algebra/vector-spaces/README.md index e69de29..03f6a03 100644 --- a/FSF-2020/linear-algebra/vector-spaces/README.md +++ b/FSF-2020/linear-algebra/vector-spaces/README.md @@ -0,0 +1,9 @@ +# Contributer: Simran Chhattani
+My Github Account : <a href="https://github.com/simranchhattani">simranchhattani</a>
+<br/></br>
+## Sub-Topics Covered:
++ Vector Spaces
++ Basis of a Vector Space and Subspace
++ Polynomial and Function Vector Space
++ Inner Product Spaces
++ Dual of a Vector Space
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Straight_Line_through_Origin.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Straight_Line_through_Origin.py new file mode 100644 index 0000000..5790d2e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Straight_Line_through_Origin.py @@ -0,0 +1,48 @@ +from manimlib.imports import *
+from scipy import exp, sin, log,tan,cos
+class Straight_Line(GraphScene):
+ CONFIG = {
+ "x_min" : -4,
+ "x_max" : 4,
+ "y_min" : -4,
+ "y_max" : 4,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "x_labeled_nums" : list(np.arange(-4,5,1)),
+ "y_labeled_nums" : list(np.arange(-4,5,1)),
+ "graph_origin" : ORIGIN+0.7*DOWN,
+ "axes_color" : GREY,
+ "x_axis_width": 6,
+ "y_axis_height":6,
+ }
+ def construct(self):
+ self.setup_axes(animate=True)
+ line_1 = self.get_graph(lambda x : x, x_min=-3,x_max=3,color=YELLOW)
+ self.play(ShowCreation(line_1))
+ text1 = TextMobject("ax + by = 0",color=BLUE_B)
+ text1.shift(3*RIGHT+2*UP)
+ text1.scale(0.65)
+ dot = Dot(color=BLUE_B).shift(0.7*DOWN)
+ dot.scale(1.3)
+ self.play(ShowCreation(dot))
+ text2 = TextMobject("Line passing through the origin")
+ text2.scale(0.7)
+ text2.shift(3.5*UP)
+ self.play(ShowCreation(text1),ShowCreation(text2))
+ self.wait(1)
+ self.play(FadeOut(line_1),FadeOut(text2),FadeOut(text1))
+ text4=TextMobject("Line not passing through the origin")
+ text4.scale(0.7)
+ text4.shift(3.5*UP)
+ self.play(ShowCreation(text4))
+
+ line_2 = self.get_graph(lambda x : 2.5*x +1, x_min = -2, x_max=1, color = RED)
+ text3 = TextMobject(r"ax + by $\neq 0$",color=BLUE_B)
+ text3.scale(0.65)
+ self.play(ShowCreation(line_2))
+ text3.shift(1.5*RIGHT+2.2*UP)
+ self.play(ShowCreation(text3))
+ self.wait(1)
+
+
+
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Subspace_Example.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Subspace_Example.py new file mode 100644 index 0000000..ada173e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Subspace_Example.py @@ -0,0 +1,82 @@ +from manimlib.imports import *
+class Subspace_Example(Scene):
+ def construct(self):
+ sq = Square(side = 2, color=BLACK).shift(2*LEFT)
+ sq.set_fill(color=RED,opacity=350)
+ line1=Line(color=BLACK).shift(2*LEFT)
+ line1.rotate(np.pi/2)
+ line2=Line(color=BLACK).shift(2.5*LEFT+0.5*UP)
+ line2.scale(0.5)
+ line3=Line(color=BLACK).shift(+1.5*LEFT)
+ line3.scale(0.5)
+ a1=TextMobject(r"$a_1$",color=BLACK).scale(0.5).shift(3.4*LEFT+0.7*UP)
+ a2=TextMobject(r"$a_2$",color=BLACK).scale(0.5).shift(3.4*LEFT+0.3*DOWN)
+ a3=TextMobject(r"$a_3$",color=BLACK).scale(0.5).shift(0.7*LEFT+0.5*DOWN)
+ a4=TextMobject(r"$a_4$",color=BLACK).scale(0.5).shift(0.7*LEFT+0.5*UP)
+ big_rect=Rectangle().scale(3).shift(0.5*DOWN)
+ big_rect.set_fill(color=GREY,opacity=350)
+ vec_space=TextMobject("$Vector Space$").scale(0.77).shift(4.5*RIGHT+3.5*UP)
+ sub=TextMobject(r"$Subspace$",color=BLACK).scale(0.77).shift(3.8*RIGHT+2*UP)
+ self.play(ShowCreation(vec_space))
+ self.play(ShowCreation(big_rect),ShowCreation(sub))
+ self.play(ShowCreation(sq),ShowCreation(line1),ShowCreation(line2),ShowCreation(line3),ShowCreation(a1),ShowCreation(a2),ShowCreation(a3),ShowCreation(a4))
+ rec = Rectangle(color=BLACK).scale(0.5).shift(1*RIGHT)
+ rec.rotate(np.pi/2)
+ rec.set_fill(color=BLUE,opacity=350)
+ line4=Line(color=BLACK).shift(1*RIGHT).rotate(np.pi/2)
+ line5=Line(color=BLACK).scale(0.25).shift(0.75*RIGHT)
+ line6=Line(color=BLACK).scale(0.25).shift(0.5*DOWN+1.25*RIGHT)
+ b1=TextMobject(r"$b_1$",color=BLACK).scale(0.5).shift(0.3*RIGHT+0.5*UP)
+ b2=TextMobject(r"$b_2$",color=BLACK).scale(0.5).shift(0.3*RIGHT+0.5*DOWN)
+ b3=TextMobject(r"$b_3$",color=BLACK).scale(0.5).shift(1.67*RIGHT+0.8*DOWN)
+ b4=TextMobject(r"$b_4$",color=BLACK).scale(0.5).shift(1.67*RIGHT+0.5*UP)
+ self.play(ShowCreation(rec),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(b1),ShowCreation(b2),ShowCreation(b3),ShowCreation(b4))
+ self.wait(1)
+ text1=TextMobject(r"$a_1 + a_2 = a_3 + a_4$",color=BLACK).scale(0.5).shift(2*LEFT+1.5*DOWN)
+ text2=TextMobject(r"$b_1 + b_2 = b_3 + b_4$",color=BLACK).scale(0.5).shift(1.5*RIGHT+1.5*DOWN)
+ self.play(ShowCreation(text1),ShowCreation(text2))
+ self.wait(3)
+ self.play(FadeOut(text1),FadeOut(text2))
+ rec.shift(3*LEFT+2.01*DOWN)
+ line4.shift(3*LEFT+2*DOWN)
+ line5.shift(3*LEFT+2*DOWN)
+ line6.shift(3*LEFT+2*DOWN)
+ b1.shift(3.1*LEFT+2.1*DOWN)
+ b2.shift(3.1*LEFT+2.1*DOWN)
+ b3.shift(2.9*LEFT+2*DOWN)
+ b4.shift(2.9*LEFT+2.3*DOWN)
+ self.play(ShowCreation(rec),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(b1),ShowCreation(b2),ShowCreation(b3),ShowCreation(b4))
+ self.wait(2)
+
+ text3=TextMobject(r"$(a_1 + a_2) + (b_1 + b_2) = (a_3 + a_4) + (b_3 + b_4)$",color=BLACK).scale(0.5).shift(2.5*RIGHT+0.5*DOWN)
+ text3=TextMobject(r"$(a_1 + a_2) + (b_1 + b_2) = (a_3 + a_4) + (b_3 + b_4)$",color=BLACK).scale(0.5).shift(2.5*RIGHT+0.5*DOWN)
+ text4=TextMobject("Vector Addition",color=BLACK).scale(0.8).shift(2.5*RIGHT+0.5*UP)
+ self.play(ShowCreation(text3),ShowCreation(text4))
+ self.wait(3)
+ rec.set_fill(color=GREY,opacity=350)
+ self.play(FadeOut(text3),FadeOut(text4),FadeOut(line4),FadeOut(line5),FadeOut(line6),FadeOut(rec),FadeOut(b4),FadeOut(b3),FadeOut(b2),FadeOut(b1))
+ sq1=Square(color=BLACK).scale(0.5).shift(1.5*LEFT+1.5*UP)
+ sq1.set_fill(color=RED,opacity=350)
+ sq2=Square(color=BLACK).scale(0.5).shift(1.5*LEFT+1.5*DOWN)
+ sq2.set_fill(color=RED,opacity=350)
+ rec1=Rectangle(height=0.5,width=1,color=BLACK).shift(2.5*LEFT+1.2*UP)
+ rec1.set_fill(color=RED,opacity=350)
+ rec2=Rectangle(height=1.5,width=1,color=BLACK)
+ rec2.set_fill(color=RED,opacity=350).shift(2.5*LEFT+1.5*DOWN)
+ self.play(ShowCreation(sq1),ShowCreation(sq2),ShowCreation(rec1),ShowCreation(rec2))
+ a=TextMobject(r"$a_1$",color=BLACK).scale(0.5).shift(3.4*LEFT+1.2*UP)
+ b=TextMobject(r"$a_2$",color=BLACK).scale(0.5).shift(3.4*LEFT+1.4*DOWN)
+ c=TextMobject(r"$a_3$",color=BLACK).scale(0.5).shift(0.7*LEFT+1.4*DOWN)
+ d=TextMobject(r"$a_4$",color=BLACK).scale(0.5).shift(0.7*LEFT+1.4*UP)
+ self.play(ShowCreation(a),ShowCreation(b),ShowCreation(c),ShowCreation(d))
+ self.wait(2.3)
+ text4=TextMobject("Scalar Multiplication",color=BLACK).scale(0.8).shift(2.5*RIGHT+0.5*UP)
+ text5=TextMobject(r"$\implies 2(a_1 + a_2) = 2(a_3 + a_4)$",color=BLACK).scale(0.5).shift(2*RIGHT+0.5*DOWN)
+ text6=TextMobject(r"$(a_1 + a_1) + (a_2 + a_2) = (a_3 + a_3) + (a_4 +a_4)$",color=BLACK).scale(0.5).shift(2.5*RIGHT)
+ self.play(ShowCreation(text4),ShowCreation(text5),ShowCreation(text6))
+ self.wait(3)
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Unit_Circle.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Unit_Circle.py new file mode 100644 index 0000000..2973f08 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Unit_Circle.py @@ -0,0 +1,68 @@ +from manimlib.imports import *
+import numpy as np
+import math
+
+class Unit_Circle(GraphScene):
+ CONFIG = {
+ "x_min" : -3,
+ "x_max" : 3,
+ "y_min" : -3,
+ "y_max" : 3,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "x_labeled_nums" : list(np.arange(-3,4,1)),
+ "y_labeled_nums" : list(np.arange(-3,4,1)),
+ "graph_origin" : ORIGIN,
+ "axes_color" : GREY,
+ "x_axis_width": 6,
+ "y_axis_height":6,
+ }
+
+ def construct(self):
+ self.setup_axes(animate = True)
+ circle = Circle(radius=1,color=BLUE)
+ self.play(ShowCreation(circle))
+ dot1 = Dot(color=RED).scale(0.7)
+ dot1.shift(1*UP)
+ dot2 = Dot(color=RED).scale(0.7)
+ dot2.shift(1*LEFT)
+ dot3 = Dot(color=RED).scale(0.7)
+ dot3.shift(1*DOWN)
+ dot4 = Dot(color=RED).scale(0.7)
+ dot4.shift(1*RIGHT)
+ dot5= Dot(color=RED).scale(0.7)
+ dot6 = Dot(color=RED).scale(0.7)
+ dot5.shift(0.5*RIGHT+(math.sqrt(3)/2)*UP)
+ dot6.shift(0.5*LEFT+(math.sqrt(3)/2)*DOWN)
+ dot7 = Dot(color=RED).scale(0.7)
+ dot7.shift(math.sqrt(2)/2*RIGHT+math.sqrt(2)/2*UP)
+ dot8 = Dot(color=RED).scale(0.7)
+ dot8.shift(math.sqrt(2)/2*LEFT+math.sqrt(2)/2*UP)
+ dot9 = Dot(color=RED).scale(0.7)
+ dot9.shift(0.5*LEFT+(math.sqrt(3)/2)*UP)
+ dot10 = Dot(color=RED).scale(0.7)
+ dot10.shift(math.sqrt(3)/2*LEFT+0.5*UP)
+ dot11=Dot(color=RED).scale(0.7)
+ dot11.shift(math.sqrt(3)/2*RIGHT+0.5*UP)
+ dot12= Dot(color=RED).scale(0.7)
+ dot12.shift(math.sqrt(3)/2*LEFT+0.5*DOWN)
+ dot13=Dot(color=RED).scale(0.7)
+ dot13.shift(math.sqrt(2)/2*RIGHT+math.sqrt(2)/2*DOWN)
+ dot14=Dot(color=RED).scale(0.7)
+ dot14.shift(math.sqrt(2)/2*LEFT+math.sqrt(2)/2*DOWN)
+ dot15=Dot(color=RED).scale(0.7)
+ dot15.shift(math.sqrt(3)/2*RIGHT+0.5*DOWN)
+ dot16=Dot(color=RED).scale(0.7)
+ dot16.shift(0.5*RIGHT+(math.sqrt(3)/2)*DOWN)
+ self.play(ShowCreation(dot1),ShowCreation(dot2))
+ self.play(ShowCreation(dot3),ShowCreation(dot4))
+ self.play(ShowCreation(dot5),ShowCreation(dot6))
+ self.play(ShowCreation(dot7),ShowCreation(dot8))
+ self.play(ShowCreation(dot9),ShowCreation(dot10))
+ self.play(ShowCreation(dot11),ShowCreation(dot12))
+ self.play(ShowCreation(dot13),ShowCreation(dot14))
+ self.play(ShowCreation(dot15),ShowCreation(dot16))
+ self.wait(4)
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Straight_Line_Through_Origin.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Straight_Line_Through_Origin.gif Binary files differnew file mode 100644 index 0000000..b7695a4 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Straight_Line_Through_Origin.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Subspace_Example.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Subspace_Example.gif Binary files differnew file mode 100644 index 0000000..32b02be --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Subspace_Example.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Unit_Circle.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Unit_Circle.gif Binary files differnew file mode 100644 index 0000000..165d040 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Unit_Circle.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py new file mode 100644 index 0000000..70913eb --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/3D_Vector_Space.py @@ -0,0 +1,14 @@ +from manimlib.imports import *
+class ThreeDSpace(ThreeDScene):
+ def construct(self):
+ curve = ParametricFunction(
+ lambda x: np.array([
+ 0, -x , x]), color = YELLOW, t_min = -2, t_max = 2)
+ axes = ThreeDAxes()
+ axes.set_stroke(width=1,color=GOLD)
+ self.add(axes)
+ self.set_camera_orientation(phi = 70*DEGREES,theta =60*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.3)
+ self.play(ShowCreation(curve))
+ self.wait(6)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py new file mode 100644 index 0000000..70af123 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scaling.py @@ -0,0 +1,137 @@ +from manimlib.imports import *
+import numpy as np
+
+class vectorspace(GraphScene):
+ CONFIG={
+ "x_min": -7,
+ "x_max": 7,
+ "y_min": -7,
+ "y_max": 7,
+ "graph_origin": ORIGIN,
+ "x_axis_label":"$X$",
+ "y_axis_label":"$Y$",
+ "x_labeled_nums": list(np.arange(-7, 8,1)),
+ "y_labeled_nums": list(np.arange(-7, 8,1)),
+ "x_axis_width": 8,
+ "y_axis_height": 7,
+ "x_tick_frequency":1,
+ "axes_color": GREY,
+ "area_opacity": 3,
+ "num_rects": 10,
+ }
+ def construct(self):
+ XD = self.x_axis_width/(self.x_max- self.x_min)
+ YD = self.y_axis_height/(self.y_max- self.y_min)
+ a1=1*XD*RIGHT+2*YD*UP
+ a2=1*XD*RIGHT+1*YD*UP
+ vec1=Vector(direction=a1).set_color(RED_E)
+ vec1.shift(self.graph_origin)
+ vec2=Vector(direction=a2).set_color(YELLOW_E)
+ vec2.shift(self.graph_origin)
+ vec1_text=TextMobject(r"$\vec{a}$")
+ vec2_text=TextMobject(r"$\vec{b}$")
+ vec1_text=(vec1_text.shift(self.graph_origin+a1+0.2)).scale(.7)
+ vec2_text=(vec2_text.shift(self.graph_origin+a2+0.2)).scale(.7)
+ self.setup_axes(animate=True)
+ self.wait(2)
+ self.play(ShowCreation(vec1))
+ self.play(ShowCreation(vec1_text))
+ self.wait(.7)
+ self.play(ShowCreation(vec2))
+ self.play(ShowCreation(vec2_text))
+ self.wait(.7)
+ a=TextMobject(r"$\vec{a} = (1,2)$",color=RED_B).scale(.6)
+ a.shift(3*LEFT+2.7*UP)
+ b=TextMobject(r"$\vec{b} = (1,1)$",color=YELLOW_E).scale(.6)
+ b.shift(3*LEFT+2*UP)
+ self.play(ShowCreation(a))
+ self.play(ShowCreation(b))
+ self.wait(.5)
+ c=TextMobject(r"$2\cdot\vec{a} = 2\cdot(1,2) = (2,4)$",color=RED_B)
+ c.shift(3*LEFT+2.7*UP)
+ c.scale(.6)
+ self.play(Transform(a,c))
+ scaling1=TextMobject(r"Scaling vector $\vec{a}$ by 2 units",color=GOLD).scale(.5)
+ scaling1.shift(3.4*RIGHT+2.4*UP)
+ self.play(ShowCreation(scaling1))
+ a1=2*XD*RIGHT+4*YD*UP
+ self.play(FadeOut(vec1_text))
+ vec1_scaled=Vector(direction=a1).set_color(RED_E)
+ vec1_scaled.shift(self.graph_origin)
+ self.play(ShowCreation(vec1_scaled))
+ self.play(FadeOut(vec1))
+ vec1_scaled_text=TextMobject(r"$2\vec{a}$").scale(.7)
+ vec1_scaled_text.shift(self.graph_origin+a1+0.2)
+ self.play(ShowCreation(vec1_scaled_text))
+ self.play(FadeOut(scaling1))
+ d=TextMobject(r"$3\cdot\vec{b} = 3\cdot(1,1) = (3,3)$",color=YELLOW_E).scale(.6)
+ d.shift(3*LEFT+2*UP)
+ self.play(Transform(b,d))
+ scaling2=TextMobject(r"Scaling vector $\vec{b}$ by 3 units",color=GOLD).scale(.5)
+ scaling2.shift(3.4*RIGHT+2.4*UP)
+ self.play(ShowCreation(scaling2))
+ a2=3*XD*RIGHT+3*YD*UP
+ self.play(FadeOut(vec2_text))
+ vec2_2=Vector
+ vec2_scaled=Vector(direction=a2).set_color(YELLOW_E)
+ vec2_scaled.shift(self.graph_origin)
+ self.play(ShowCreation(vec2_scaled))
+ self.play(FadeOut(vec2))
+ vec2_scaled_text=TextMobject(r"$3\vec{b}$").scale(.7)
+ vec2_scaled_text.shift(self.graph_origin+a2+0.2)
+ self.play(ShowCreation(vec2_scaled_text))
+ self.wait(.7)
+ self.play(FadeOut(scaling2))
+ add = TextMobject("+").scale(.7)
+ add.shift(4.8*LEFT+2*UP)
+ self.play(ShowCreation(add))
+ self.wait(.5)
+ line = Line()
+ line.shift(3*LEFT+1.6*UP)
+ line.scale(1.8)
+ self.play(ShowCreation(line))
+ self.wait(1)
+ e = TextMobject(r"$\vec{c} = 2\cdot\vec{a} + 3\cdot\vec{b} = (5,7)$",color=GREEN_D).scale(.6)
+ e.shift(3*LEFT+1.3*UP)
+ self.play(ShowCreation(e))
+ self.wait(.5)
+ add1=TextMobject("Addition of the scaled vectors",color=GOLD).scale(.5)
+ add1.shift(4.1*RIGHT+2.4*UP)
+ self.play(ShowCreation(add1))
+ self.wait(.5)
+ self.play(FadeOut(vec1_scaled_text))
+ self.play(FadeOut(vec2_scaled_text))
+ self.play(FadeOut(vec1_scaled))
+ vec1_scaled2=Vector(direction=a1).set_color(RED_E)
+ vec1_scaled2.shift(self.graph_origin+3*RIGHT*XD+3*UP*YD)
+ self.play(ShowCreation(vec1_scaled2))
+ a3=5*XD*RIGHT+7*YD*UP
+ vec3=Vector(direction=a3).set_color(GREEN_C)
+ vec3.shift(self.graph_origin)
+ vec3_text=TextMobject(r"$\vec{c}$").scale(.7)
+ vec3_text.shift(self.graph_origin+a3+0.2)
+ self.play(ShowCreation(vec3))
+ self.wait(.5)
+ self.play(ShowCreation(vec3_text))
+ self.wait(1)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py new file mode 100644 index 0000000..4f5614d --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Space_As_Functions.py @@ -0,0 +1,62 @@ +from manimlib.imports import *
+from scipy import sin,cos
+class FunctionalVectorSpace(GraphScene):
+ CONFIG = {
+ "x_min": -5,
+ "x_max": 5,
+ "y_min": -5,
+ "y_max": 5,
+ "graph_origin": ORIGIN,
+ }
+ def construct(self):
+ self.setup_axes(animate = True)
+ curve1 = self.get_graph(lambda x : sin(x), x_min=-5,x_max=5,color=YELLOW_E)
+ curve2 = self.get_graph(lambda x : cos(x), x_min=-5,x_max=5,color=RED)
+ self.play(ShowCreation(curve1))
+ fx=TextMobject(r"$f(x)$",color=YELLOW_E).scale(0.7)
+ fx.shift(5*LEFT+0.7*UP)
+ self.play(ShowCreation(fx))
+ self.play(ShowCreation(curve2))
+ gx=TextMobject(r"$g(x)$",color=RED).scale(0.7)
+ gx.shift(5*LEFT+0.2*UP)
+ self.play(ShowCreation(gx))
+ self.wait(2)
+ scaling=TextMobject("Scaling f(x) by 2 units",color=GOLD).scale(0.65)
+ scaling.shift(3*LEFT+2.4*UP)
+ curve3 = self.get_graph(lambda x : 2*sin(x), x_min=-5,x_max=5,color=BLUE)
+ fx2=TextMobject(r"$2f(x)$",color=BLUE).scale(0.7)
+ fx2.shift(5*LEFT+1*UP)
+ self.play(Transform(curve1,curve3),FadeOut(fx),ShowCreation(fx2),ShowCreation(scaling))
+ self.wait(3)
+ hx = TextMobject(r"$h(x)$",color=PURPLE).scale(0.7)
+ hx.shift(4.9*LEFT+1.5*UP)
+ curve4 = self.get_graph(lambda x : 2*sin(x) + cos(x), x_min=-5,x_max=5,color=PURPLE)
+ self.play(ShowCreation(curve4),ShowCreation(hx))
+ self.play(FadeOut(curve2),FadeOut(curve1),FadeOut(fx2),FadeOut(gx),FadeOut(scaling))
+ hxn=TextMobject(r"$h(x)$",color=PURPLE).scale(0.7)
+ hxn.shift(3*RIGHT+2.4*UP)
+ equal = TextMobject("=").scale(0.7)
+ equal.shift(3.5*RIGHT+2.4*UP)
+ fx2n=TextMobject(r"$2f(x)$",color=BLUE).scale(0.7)
+ fx2n.shift(4.2*RIGHT+2.4*UP)
+ add=TextMobject("+").scale(0.7)
+ add.shift(4.8*RIGHT+2.4*UP)
+ gxn=TextMobject(r"$g(x)$",color=RED).scale(0.7)
+ gxn.shift(5.3*RIGHT+2.4*UP)
+ vector_add=TextMobject("Vector Addition",color=GOLD).scale(0.65)
+ vector_add.shift(3*UP+3*RIGHT)
+ self.play(ShowCreation(hxn),ShowCreation(equal),ShowCreation(fx2n),ShowCreation(add),ShowCreation(gxn),ShowCreation(vector_add))
+ self.wait(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/3D_Vector_Space.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/3D_Vector_Space.gif Binary files differnew file mode 100644 index 0000000..137546a --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/3D_Vector_Space.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Function_Vector_Space_Example.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Function_Vector_Space_Example.gif Binary files differnew file mode 100644 index 0000000..d9edf46 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Function_Vector_Space_Example.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Vector_Addition_and_Scalar_Multiplication.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Vector_Addition_and_Scalar_Multiplication.gif Binary files differnew file mode 100644 index 0000000..ed65f8a --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Vector_Addition_and_Scalar_Multiplication.gif |