diff options
Diffstat (limited to 'FSF-2020')
454 files changed, 22289 insertions, 282 deletions
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/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md new file mode 100644 index 0000000..903eaed --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/README.md @@ -0,0 +1,26 @@ +<h1><div align=”center”><b>SubTopic: Lagrange Multipliers</b></h1></div> +<br/></br> + +<tab>file1_Extrema_over_g(x,y) + +![file1_Extrema_over_g(x,y)](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file1_Extrema_over_g(x%2Cy)%3Dk.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3 + +![file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x%5E2%2By%5E2%2Bx%5E3-y%5E3.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file3_Geometric_Proof + +![file3_Geometric_Proof](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file4_Constraints_g_and_h + +![file4_Constraints_g_and_h](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif?raw=true) +<br/></br> +<br/></br> 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..9a9042f --- /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..b7adcc7 --- /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,45 @@ +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().scale(0.7).rotate(math.radians(180)) + label_x = TextMobject("$x$").shift(4*LEFT).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([ + 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.2) + + c = Circle(color='#FF00FF',fill_opacity=0.3).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) + + max_text = TextMobject("maximum over $g(x,y)=k$",color = '#FFA074').scale(0.6).shift(2.3*UP+2*LEFT) + min_text = TextMobject("minimum over $g(x,y)=k$",color = '#FFA074').shift([2.5,0.5,1]).scale(0.6).shift(0.5*UP) + label_f = TextMobject("$z=f(x,y)$",color=TEAL).scale(0.8).shift(3*UP+3*RIGHT) + label_g = TextMobject("g(x,y)=k",color = PURPLE).scale(0.5).shift(1.5*UP+0.8*LEFT) + + + 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.add_fixed_in_frame_mobjects(label_g) + 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) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif Binary files differnew file mode 100644 index 0000000..d8e03fd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py new file mode 100644 index 0000000..bbbf238 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file2_Constraint_circle_with_contour_plot_of_the_surface_x^2+y^2+x^3-y^3.py @@ -0,0 +1,72 @@ +from manimlib.imports import* +import math as m + +#---- contour plot of the surface with constraint circle +class ContourScene(ThreeDScene): + def construct(self): + axes = ThreeDAxes().scale(0.7).rotate(m.radians(180)).fade(0.6) + label_x = TextMobject("$x$").shift(4*LEFT).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift(3.2*DOWN+0.2*RIGHT).rotate(m.radians(180)).fade(0.4) #---- y axis + + #---- surface of the function f(x,y) = x^2+y^2+x^3-y^3 + 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,-0.5,2.5]).set_color(TEAL).fade(0.5) + + + #---- contour plots of the surface of the function + + c0 = Circle(color = '#800000').scale(0.5).shift([0,-0.5,0]) + c1 = Circle(color = '#800000').scale(1).shift([0,-0.5,0]) + c2 = Circle(color = '#800000').scale(1.5).shift([0,-0.5,0]) + c3 = Circle(color = '#800000').scale(2).shift([0,-0.5,0]) + c4 = Circle(color = '#800000').scale(2.5).shift([0,-0.5,0]) + + #---- constraint circle + circle = Circle(color='#FF00FF',fill_opacity=0.3).shift([-0.5,-1.2,1.5]).rotate(1.9,UP).scale(0.8) + circle2 = Circle(color='#FF00FF',fill_opacity=0.3).shift([0.74,0.95,1.5]).rotate(1.9,UP).scale(0.8) + + maxima = Dot(color = '#4169E1').shift([0.7,0.15,1.5]) #---- point of maxima + minima = Dot(color = '#4169E1').shift([0.8,1.7,1.5]) #---- point of minima + + min_text = TextMobject("minimum over $g(x,y)=k$",color = '#FFA074').scale(0.6).shift([-2,0.16,1.5]) + max_text = TextMobject("maximum over $g(x,y)=k$",color = '#FFA074').shift([-2.3,-2.6,1.5]).scale(0.6).shift(0.5*UP) + + + #---- labelling contour curves + label_c0 = TextMobject("1",color = '#FFA074').shift([0.2,0.1,0.5]).scale(0.5) + label_c1 = TextMobject("2",color = '#FFA074').shift([0.2,-0.6,0.5]).scale(0.5) + label_c2 = TextMobject("3",color = '#FFA074').shift([0.2,-1.1,0.5]).scale(0.5) + label_c3 = TextMobject("4",color = '#FFA074').shift([0.2,-1.6,0.5]).scale(0.5) + label_c4 = TextMobject("5",color = '#FFA074').shift([0.2,-2.1,0.5]).scale(0.5) + + + self.set_camera_orientation(phi=75 * DEGREES, theta = 45*DEGREES) + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.play(Write(surface)) + self.play(Write(circle)) + self.wait(1) + self.play(FadeOut(circle)) + self.wait(1) + self.move_camera(phi=0 * DEGREES, theta = 90*DEGREES) + self.wait(1) + self.play(Write(c0),Write(c1),Write(c2),Write(c3),Write(c4)) + self.play(FadeOut(surface)) + self.add_fixed_in_frame_mobjects(label_c0) + self.add_fixed_in_frame_mobjects(label_c1) + self.add_fixed_in_frame_mobjects(label_c2) + self.add_fixed_in_frame_mobjects(label_c3) + self.add_fixed_in_frame_mobjects(label_c4) + self.wait(1) + self.play(Write(circle2)) + self.wait(1) + self.play(Write(minima),Write(maxima)) + self.add_fixed_in_frame_mobjects(max_text) + self.add_fixed_in_frame_mobjects(min_text) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif Binary files differnew file mode 100644 index 0000000..e028a81 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.py new file mode 100644 index 0000000..2c1d668 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file3_Geometric_Proof.py @@ -0,0 +1,89 @@ +from manimlib.imports import* + +#---- visualization of geometric proof of Lagrange multiplier +class firstScene(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).set_color(GREEN).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 + a_dg = Arrow(color = '#FF00FF').scale(0.8).shift(3.2*DOWN+2.3*LEFT).rotate(-2) #---- f parallel to g + + b_dg = Arrow(color = '#00FFFF').rotate(1.1).shift(0.82*LEFT+0.15*UP) #---- f parallel to g + b_df = Arrow(color = '#FF00FF').scale(0.6).rotate(-2).shift(1.43*LEFT+1.1*DOWN) #---- f parallel to g + + + qd = Dot(color = '#800000').shift(1.2*LEFT+0.6*DOWN) + + 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) + + 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.wait(1) + self.add(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/file4_Constraints_g_and_h.gif b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif Binary files differnew file mode 100644 index 0000000..f1f7974 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.gif diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py new file mode 100644 index 0000000..a1396fc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Lagrange-Multipliers/file4_Constraints_g_and_h.py @@ -0,0 +1,52 @@ +from manimlib.imports import* +import math as m + + class Constraints(ThreeDScene): + def construct(self): + axes = ThreeDAxes().rotate(m.radians(75)) + label_x = TextMobject("$x$").shift([-5.5,1,0]).fade(0.4) #---- x axis + label_y = TextMobject("$y$").shift([1,5.5,0]).rotate(-4.5).fade(0.4) #---- y axis + + cylinder = ParametricSurface( + lambda u, v: np.array([ + np.cos(TAU * u), + np.sin(TAU * u), + 2 * (1-1.5*v) + ]),checkerboard_colors=[YELLOW_C,YELLOW_D,YELLOW_E]).shift([0.5,0.5,-0.13]).scale(1) + + plane = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u+v + ]),checkerboard_colors=[TEAL_C,TEAL_D,TEAL_E]).shift([0,0,0]).rotate(m.radians(-40),RIGHT).scale(4).fade(0.3) + + c = Circle(color='#FF00FF',fill_opacity=0.3).shift([0.7,-1.3,0.4]).rotate(2.5,UP).scale(1.32) + + f_text = TextMobject("$f(x,y)=x^2+y^2+z^2$",color = '#FFA074').scale(0.6).to_corner(UL) + g_text = TextMobject("$g(x,y)=x^2+y^2+1$",color = '#FFA074').scale(0.6).to_corner(UL) + h_text = TextMobject("$h(x,y)=x+y-z=1$",color = '#FFA074').scale(0.6).to_corner(UL) + + + + self.set_camera_orientation(phi=65*DEGREES,theta=95*DEGREES) + + self.add(axes) + self.add(label_x) + self.add(label_y) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + self.play(Write(c)) + self.wait(1) + self.play(FadeOut(f_text)) + self.wait(1) + self.add_fixed_in_frame_mobjects(g_text) + self.play(Write(cylinder)) + self.wait(1) + self.play(FadeOut(g_text)) + self.wait(1) + self.add_fixed_in_frame_mobjects(h_text) + self.play(Write(plane)) + self.wait(1) + self.play(FadeOut(h_text)) + self.wait(1) diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical_Points_mcq_questions.pdf b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Critical_Points_mcq_questions.pdf Binary files differindex 25c4e4d..25c4e4d 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Critical_Points_mcq_questions.pdf +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Critical_Points_mcq_questions.pdf diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Lagrange_Multipliers_mcq_questions.pdf b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Lagrange_Multipliers_mcq_questions.pdf Binary files differnew file mode 100644 index 0000000..3ba7d1c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Lagrange_Multipliers_mcq_questions.pdf diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Tangent_Plane_Approximations_mcq_questions.pdf b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Tangent_Plane_Approximations_mcq_questions.pdf Binary files differnew file mode 100644 index 0000000..2a77b15 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Tangent_Plane_Approximations_mcq_questions.pdf diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The_Second_Derivative_Test_MCQ.pdf b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/The_Second_Derivative_Test_mcq_questions.pdf Binary files differindex ca60cbf..ca60cbf 100644 --- a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/The_Second_Derivative_Test_MCQ.pdf +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/The_Second_Derivative_Test_mcq_questions.pdf diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Total_Differential_mcq_questions.pdf b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Total_Differential_mcq_questions.pdf Binary files differnew file mode 100644 index 0000000..b1a679d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/MCQ-Questions/Total_Differential_mcq_questions.pdf diff --git a/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/README.md b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/README.md new file mode 100644 index 0000000..2a274d0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/README.md @@ -0,0 +1,26 @@ +<h1><div align=”center”><b>SubTopic: Tangent Plane Approximations</b></h1></div> +<br/></br> + +<tab>file1_Tangent_Plane + +![file1_Tangent_Plane](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file1_Tangent_Plane.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file2_Tangent_plane_approximation_visualization + +![file2_Tangent_plane_approximation_visualization](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file3_Non_Differentiable_Function + +![file3_Non_Differentiable_Function](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file3_Non_Differentiable_Function.gif?raw=true) +<br/></br> +<br/></br> + +<tab>file4_Tangent_plane_at_extrema_and_saddle_point + +![file4_Tangent_plane_at_extrema_and_saddle_point](https://github.com/vnb09/FSF-mathematics-python-code-archive/blob/fsf_tasks/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.gif?raw=true) +<br/></br> +<br/></br> 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..8efdbd2 --- /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 tangentplane(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..6d5a67a --- /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..02576d9 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file2_Tangent_plane_approximation_visualization.py @@ -0,0 +1,85 @@ +from manimlib.imports import* +import math as m + +#---- tangent plane approximation visualization +class ApproximationScene(ThreeDScene): + def construct(self): + + axes = ThreeDAxes().scale(1.2).fade(0.7) + label_x= TextMobject("$x$").shift([5.4,-0.5,0]).fade(0.7) #---- x axis + label_y= TextMobject("$y$").shift([-0.5,5.2,0]).rotate(-4.5).fade(0.7) #---- 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]).shift([0,1,2.4]).scale(1.3) + + d1 = Dot([0.2,2.01,2.24],color = '#800000').rotate(1.1,LEFT) #---- point(x_0,y_0) + d1_copy = Dot([0.2,2.01,0],color = '#800000') #---- projection of point(x_0,y_0) on x-y plane + + d1_text = TextMobject("$f(x_0,y_0)$",color=ORANGE).scale(0.5).shift([0.2,2.01,2.3]) + d1_copy_text = TextMobject("$(x_0,y_0)$",color=ORANGE).scale(0.5).shift([0.2,2.01,0],4.1*DOWN) + + d2 = Dot([2,2.6,3.5],color = '#800000').rotate(1,LEFT) #---- point(x,y) + d2_copy = Dot([2,2.6,0],color = '#800000') #---- projection of point(x,y) on x-y plane + + d2_text = TextMobject("$f(x,y)$",color=ORANGE).scale(0.5).shift([0.8,1.4,1.5]) + d2_copy_text = TextMobject("$(x,y)$",color=ORANGE).scale(0.5).shift([0.8,1.4,0],2.4*DOWN) + + l1 = Line([0.2,2.01,2.21],[0.2,2.01,0],color= YELLOW).fade(0.2) + l2 = Line([2,2.6,3.4],[2,2.6,0],color= YELLOW).fade(0.2) + + t_plane = Rectangle(color = PURPLE, fill_opacity=0.3).scale(0.6).rotate(m.radians(45),LEFT).shift([1.1,2.5,3.1]) #---- tangent plane + t_text= TextMobject("Tangent Plane",color = PINK).scale(0.5).shift(0.3*RIGHT+2.6*UP).rotate(math.radians(5),LEFT) + + a1 = Line([0.2,2.01,0],[2,2.6,0],color ="#00FF7F") + a_x = Line([0.2,2.01,0],[2,2.01,0],color ="#9400D3") + a_y = Line([0.2,2.01,0],[0.2,2.6,0],color ="#8B4513") + a2 = Line([2,2.01,0],[2,2.6,0]) + a3 = Line([0.2,2.6,0],[2,2.6,0]) + + ax_text = TextMobject("$f_x (x_0 , y_0 )(x – x_0 ) $").scale(0.5).shift(DOWN+0.8*LEFT).rotate(0.4) + ay_text = TextMobject("$ f_y (x_0 , y_0 )(y – y_0 ) $").scale(0.5).shift(0.8*DOWN+2.7*RIGHT).rotate(-0.6) + a1_text = TextMobject("$f_x (x_0 , y_0 )(x – x_0 ) + f_y (x_0 , y_0 )(y – y_0 )$ ").scale(0.4).rotate(0.7).shift(1.7*DOWN+0.6*RIGHT) + + lines = VGroup(a1,a_y,a_x,a2,a3,d1_copy,d2_copy) + + + self.set_camera_orientation(phi = 60 * DEGREES, theta = 55 * 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(d2)) + self.add_fixed_in_frame_mobjects(d1_text) + self.wait(1) + self.play(Write(t_plane)) + self.add_fixed_in_frame_mobjects(t_text) + self.wait(1) + self.play(Write(d1)) + self.add_fixed_in_frame_mobjects(d2_text) + self.wait(1) + self.play(Write(l1),Write(d1_copy)) + self.add_fixed_in_frame_mobjects(d2_copy_text) + self.wait(1) + self.play(Write(l2),Write(d2_copy)) + self.add_fixed_in_frame_mobjects(d1_copy_text) + self.wait(2) + self.play(FadeOut(d1_text),FadeOut(d1_copy_text),FadeOut(d2_text),FadeOut(d2_copy_text),FadeOut(t_text)) + self.wait(1) + self.play(Write(a1),Write(a_x),Write(a_y),Write(a2),Write(a3)) + self.wait(1) + self.play(FadeOut(s),FadeOut(d1),FadeOut(d2),FadeOut(l1),FadeOut(l2),FadeOut(t_plane),FadeOut(label_x),FadeOut(label_y)) + self.wait(1) + lines.scale(2) + axes.scale(1.5) + self.wait(1) + self.add_fixed_in_frame_mobjects(ax_text) + self.add_fixed_in_frame_mobjects(ay_text) + self.add_fixed_in_frame_mobjects(a1_text) + 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..3fe7992 --- /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/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.py b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.py new file mode 100644 index 0000000..d129213 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/approximations-and-optimizations/Tangent-Plane-Approximations/file4_Tangent_plane_at_extrema_and_saddle_point.py @@ -0,0 +1,62 @@ +from manimlib.imports import* + +class TangenttoSurface(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + + #----graph of first function f(x,y) = -x**2-y**2 + f = ParametricSurface( + lambda u, v: np.array([ + u, + v, + -u**2-v**2 + ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [YELLOW_D, YELLOW_E], + resolution = (20, 20)).scale(1) + f_text = TextMobject("Tangent plane at relative maxima").to_corner(UL).scale(0.5) + + #----graph of second function f(x,y) = -x**2+y**2 + f2 = ParametricSurface( + lambda u, v: np.array([ + u, + v, + -u**2+v**2 + ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [RED_D, RED_E], + resolution = (20, 20)).scale(1) + f2_text = TextMobject("Tangent plane at saddle point").to_corner(UL).scale(0.5) + + #----graph of third function f(x,y) = x**2+y**2 + f3 = ParametricSurface( + lambda u, v: np.array([ + u, + v, + u**2+v**2 + ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [GREEN_D, GREEN_E], + resolution = (20, 20)).scale(1) + f3_text = TextMobject("Tangent plane at relative minima").to_corner(UL).scale(0.5) + + self.set_camera_orientation(phi = 75 * DEGREES, theta = -45 * DEGREES ) + d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point + + r = Rectangle(height = 2,breadth = 1,color = PURPLE).scale(0.5) + + self.begin_ambient_camera_rotation(rate = 0.3) + self.add(axes) + self.play(Write(f),Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f_text) + self.play(ShowCreation(r)) + self.wait(1) + self.play(FadeOut(r),FadeOut(f),FadeOut(d),FadeOut(f_text)) + self.wait(1) + self.play(Write(f2),Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f2_text) + self.play(ShowCreation(r)) + self.wait(1) + self.play(FadeOut(r),FadeOut(f2),FadeOut(d),FadeOut(f2_text)) + self.wait(1) + self.play(Write(f3),Write(d)) + self.wait(1) + self.add_fixed_in_frame_mobjects(f3_text) + self.play(ShowCreation(r)) + self.wait(1) diff --git a/FSF-2020/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..10786d6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/README.md @@ -0,0 +1,11 @@ +**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) + +**file3_curvature_interpretation.py** <br> +![file3_curvature_interpretation.py](https://github.com/saarthdeshpande/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_curvature_interpretation.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_arc_length.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif Binary files differnew file mode 100644 index 0000000..bbad112 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py new file mode 100644 index 0000000..7c970e5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file1_arc_length.py @@ -0,0 +1,123 @@ +from manimlib.imports import * + + +class arcl(MovingCameraScene): + def construct(self): + # self.setup() + 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 + + curve = FunctionGraph(curve_, x_min=-2, x_max=6, stroke_width = 2, color = BLUE).scale(0.1).move_to(ORIGIN) + lines = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN).shift(np.array([-4 + 0.1*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4)] + lines2 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN).shift(np.array([-4 + 0.125*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4, 9)] + # lines[0].rotate(-25*DEGREES).shift(np.array([-4,curve_(-2.5), 0])) + # lines[1].rotate(-25*DEGREES).shift(np.array([-3.78,curve_(-2.3), 0])) + # lines3 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 1.5*UP + 0.6*RIGHT).shift(np.array([-1 + 0.2*i, -1.5 - 0.2*i, 0])).rotate(30*DEGREES) for i in range(4)] + # lines2b = VGroup(*lines3).rotate(-8*DEGREES) + # lines4 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 1.6*UP + 0.5*RIGHT).shift(np.array([-1 + 0.18*i, -1.65 - 0.2*i, 0])).rotate(22*DEGREES) for i in range(4, 9)] + # lines5 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN + 7*RIGHT).shift(np.array([-4 + 0.1*i, curve_(-2.5 + 0.1*i), 0])).rotate(-25*DEGREES) for i in range(4)] + # lines6 = [Line(length = 0.05, color = RED).scale(0.2).move_to(ORIGIN +7.25*RIGHT).shift(np.array([-4 + 0.053*i, curve_(-2.5 + 0.1*i), 0])).rotate(-26*DEGREES) for i in range(4, 9)] + + # lc1 = [Line(length = 0.05, color = RED).scale(0.2).rotate((-25 + i*2) * DEGREES).shift(np.array([-1 + 0.125*i, curve_(-1.5 + 0.1*i), 0])) for i in range(2)] + # lc1b = VGroup(*lc1).shift(1.7*LEFT + 0.2*DOWN) + + text = TextMobject(r'$r(t) = \left\langle t, t^{3} - 2t, 0\right\rangle$ \\ $r\prime (t) = \left\langle 1, 3t^{2} - 2, 0\right\rangle$').scale(0.7).shift(3*UP + 4*RIGHT) + + # l = VGroup(*lines, *lines2, lines2b, *lines4, *lines5, *lines6, lc1b).shift(curve.get_center()) + l = VGroup(*lines, *lines2) + arc = Line(lines[3].get_center(), lines2[0].get_center() + np.array([0.005, 0 ,0]), color = GREEN_SCREEN).rotate(12*DEGREES) + arctext = TextMobject(r'$ds$', color = GREEN_SCREEN).scale(0.15).next_to(arc.get_center(), 0.001*DOWN + 0.01*RIGHT,buff = 0.01) + dy = Arrow(arc.get_start(), np.array([arc.get_start()[0], lines2[0].get_center()[1] + 0.01, 0]), color = YELLOW) + dx = Arrow(arc.get_start(), np.array([lines2[0].get_center()[0] - 0.01, arc.get_start()[1], 0]), color = BLUE) + dxt = DashedLine(dy.get_end(), dy.get_end() + np.array([0.13, 0 ,0])) + dyt = DashedLine(dx.get_end(), dx.get_end() + np.array([0, 0.3 ,0])) + dxtext = TextMobject(r'$dx$').scale(0.2).next_to(dx, RIGHT, buff = 0.01) + dytext = TextMobject(r'$dy$').scale(0.2).next_to(dy, LEFT, buff = 0.01) + formula = TextMobject(r"Consider a very small interval ", r'$ds$. \\', r"Using Pythagoras' theorem, \\", r'$ds$', r" = $\sqrt{(dx)^{2} + (dy)^{2}}$").scale(0.25).shift(5*LEFT + 0.5*UP) + formula.set_color_by_tex_to_color_map({ + "$ds$. \\": GREEN_SCREEN, + "$ds$": GREEN_SCREEN + }) + + formula2 = TextMobject(r'To compute the arc length \\ from $a$ to $b$, we need to \\ sum over all intervals ', r'$ds$').scale(0.25).shift(5.2*LEFT + 0.7*UP) + formula2.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) + + formula3 = TextMobject(r'$L = \int_{a}^{b} ds$ \\ $= \int_{a}^{b} \sqrt{(\frac{dx}{dt})^{2} + (\frac{dy}{dt})^{2} + (\frac{dz}{dt})^{2}}\quad dt$').scale(0.25).shift(5.2*LEFT + 0.1*UP) + + bl = DashedLine(lines2[4].get_center(), lines2[4].get_center() + np.array([1,0,0])) + blt = TextMobject(r'$b$').scale(0.5).next_to(bl.get_center(), DOWN, buff=0.1) + al = DashedLine(lines[0].get_center(), lines[0].get_center() + np.array([1,0,0])) + alt = TextMobject(r'$a$').scale(0.5).next_to(al.get_center(), UP, buff=0.1) + pts = VGroup(*[bl, blt, al, alt]) + + compute = TextMobject(r'To compute the arc length from \\ $t = -1.4$ to $t = -1.1$, \\ summation of small intervals $ds$ \\ is given by $L = \int_{-1.4}^{-1.1} ds$ \\').scale(0.7).shift(6.8*LEFT + 2.5*UP) + compute_ = TextMobject(r'L = $ \int_{-1.4}^{-1.1} \sqrt{(\frac{dx}{dt})^{2} + (\frac{dy}{dt})^{2} + (\frac{dz}{dt})^{2}}\quad dt$ \\ = $\int_{-1.4}^{-1.1} \sqrt{1^{2} + (3t^{2} - 2)^{2} + 0^{2}}\quad dt$').scale(0.7).shift(6.8*LEFT + -0.6*DOWN) + #compute = VGroup(*[compute, compute_]) + compute2 = TextMobject(r'$ = \int_{-1.4}^{-1.1} \sqrt{9t^{4} - 12t^{2} + 5}\quad dt$').scale(0.7).shift(6.8*LEFT + 0.7*DOWN) + compute3 = TextMobject(r'$L = 0.8693$').scale(0.7).shift(6.8*LEFT + 1.2*DOWN) + arclen = compute3.copy() + arclen = arclen.scale(0.8).next_to(arc.get_center(), RIGHT, buff = 0.1) + dsd = TextMobject(r'We can divide the curve \\ into multiple small arcs ', r'$ds$').scale(0.25).shift(5.2*LEFT + 0.2*UP) + dsd.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) + + # 13th sec, consider a v small interval ds, show Pythagoras + # reduce text size + # then show we can divide curve into small ds + # all red ds + # To compute arc length, we need to sum over all intervals ds + # a and b show and give dashes dy dx for first and last + # give dz in formula and show it's zero + # Zooom out, Remove red bars, draw yellow line + # Consider t = -1.4 to -1.1 + # at end show l = 0.693 near yellow line, smaller size + + ax1 = Vector((0,1,0), color = YELLOW) + ax1l = TextMobject(r'$y$').next_to(ax1, LEFT, buff = 0) + ax2 = Vector((1,0,0), color = BLUE) + ax2l = TextMobject(r'$x$').next_to(ax2, RIGHT, buff = 0) + ax = VGroup(*[ax1, ax1l, ax2, ax2l]).scale(0.6).shift(3*DOWN + 6*LEFT) + + self.play(FadeIn(curve), FadeIn(ax)) + self.play(ApplyMethod(curve.scale, 10), FadeIn(text)) + # self.play(FadeIn(l)) + self.wait(2) + self.play(FadeOut(text)) + self.play(self.camera_frame.set_width, 5, + self.camera_frame.move_to, 3.8*LEFT+0.4*DOWN, + ax.shift, UP, + ax.scale, 0.5, run_time = 4) + long = ArcBetweenPoints(lines[1].get_center() + 0.01, lines2[3].get_center(), color = YELLOW, angle = 10*DEGREES).rotate(180*DEGREES) + + + self.play(Write(formula),FadeIn(VGroup(*[arc, arctext, dy, dx, dxt, dyt, dxtext, dytext])), FadeIn(VGroup(*[lines[3], lines2[0]]))) + self.wait(2) + self.play(ReplacementTransform(formula, dsd), TransformFromCopy(VGroup(*[lines[3], lines2[0]]) , l)) + #Transform(l, VGroup(*[lines[3], lines2[0]])), ) + self.wait(2) + self.play(ReplacementTransform(dsd, formula2), FadeIn(pts)) + self.wait(3) + self.play(FadeIn(formula3)) + self.wait(2) + self.play(FadeOut(VGroup(*[formula3, l, pts, formula2, arc, arctext, dy, dx, dxt, dyt, dxtext, dytext]))) + self.play( + self.camera_frame.set_width, 15, + self.camera_frame.move_to, 3*LEFT, + ax.shift, DOWN + 3*LEFT, + ax.scale, 2.3, + run_time = 4) + text = text.shift(2*LEFT) + self.play(FadeIn(long), FadeIn(compute), FadeIn(text)) + self.wait(2) + self.play(FadeIn(compute_)) + self.wait(2) + self.play(FadeIn(compute2)) + self.wait(1) + self.play(FadeIn(compute3)) + self.wait(1) + self.play(TransformFromCopy(compute3, arclen)) + self.wait(2) + self.play(FadeOut(VGroup(*[ax, arclen, compute_, curve, text, compute, compute2, compute3, long]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif Binary files differnew file mode 100644 index 0000000..3f7ecd1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py new file mode 100644 index 0000000..05cad80 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file2_simple_visualization.py @@ -0,0 +1,91 @@ +from manimlib.imports import * + +class a(GraphScene): + CONFIG = { + "x_min": -3, + "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 vector\\changes with respect to the arc length.') + outro = TextMobject(r'The rate of change of unit tangent 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) + + circle = Circle(radius = 0.95, color = GRAY, fill_opacity = 0.2, fill_color = RED) + circle.set_stroke(width = 0.1) + + 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) + + arc = ArcBetweenPoints(dot1.get_center(), dot2.get_center(), color = GREEN_SCREEN, angle = 10*DEGREES).rotate(180*DEGREES) + + 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) + + 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 + + # parabola_x_out = FunctionGraph(curve, x_min=-2, x_max=6, stroke_width = 2, color = BLUE) + parabola_x_out = self.get_graph(curve) + + dot_x = Dot().rotate(PI/2).set_color(YELLOW_E) + alpha_x = ValueTracker(-2) + vector_x = self.get_tangent_vector(alpha_x.get_value(),parabola_x_out,scale=1.5) + dot_x.add_updater(lambda m: m.move_to(vector_x.get_center())) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(alpha_x.get_value()%1,parabola_x_out,scale=1.5) + ) + ) + + self.play(FadeIn(intro)) + self.wait(2) + self.play(FadeOut(intro)) + self.setup_axes(hideaxes=False) + self.play(ShowCreation(parabola_x_out), FadeIn(dots), FadeIn(ds), FadeIn(ds_text), FadeIn(arc)) + self.wait(2) + self.play(FadeOut(self.axes), FadeOut(arc), FadeOut(parabola_x_out),FadeIn(mid), FadeOut(dots), FadeOut(ds), FadeOut(ds_text)) + self.wait(3) + self.play(FadeOut(mid)) + self.play(FadeIn(self.axes), FadeIn(parabola_x_out), FadeIn(dots)) + self.add(vector_x) + self.play(alpha_x.increment_value, 1, run_time=8, rate_func=linear) + self.remove(vector_x) + self.play(FadeOut(VGroup(*[self.axes, dots, parabola_x_out]))) + self.play(FadeIn(outro)) + self.wait(3) + self.play(FadeOut(outro)) + self.wait(1) + + + + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_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/file3_circle_curvature.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_circle_curvature.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file3_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/file3_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/file4_curvature_interpretation.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif Binary files differnew file mode 100644 index 0000000..22a450a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py new file mode 100644 index 0000000..f10fa26 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file4_curvature_interpretation.py @@ -0,0 +1,114 @@ +from manimlib.imports import * + +class interpretation(ZoomedScene): + CONFIG = { + "zoomed_display_height": 3, + "zoomed_display_width": 3, + "zoom_factor": 0.15, + "zoomed_display_center": ORIGIN + 4*LEFT + DOWN, + } + def construct(self): + + tgt = Vector((1, 2, 0), color = YELLOW).shift(0.005*RIGHT + 0.007*DOWN) + dot = Dot(tgt.get_start(),color = RED) + curve = ParametricFunction( + lambda t: np.array([ + 2*(t**2), + 4*t, + 0 + ]), t_min = -5, t_max = 5 + ).scale(0.3).move_to(ORIGIN + 4*RIGHT).rotate(6*DEGREES) + + ds = ParametricFunction( + lambda t: np.array([ + 2*(t**2), + 4*t, + 0 + ]), t_min = 0, t_max = 0.05, color = GREEN_SCREEN + ).scale(0.9).shift(3.09*LEFT).rotate(-27.5*DEGREES).move_to(ORIGIN).shift(0.07*UP + 0.05*RIGHT).set_stroke(width=20) + + dsl = TextMobject(r'$ds$', color = GREEN_SCREEN).scale(0.2).next_to(ds, RIGHT, buff = 0) + + + tgtText = TextMobject(r'$r\prime (t) = \left\langle 1, 2, 0\right\rangle$').next_to(tgt, UP, buff = 0).scale(0.7) + tgt2 = DashedLine((0,0,0),(1, 2, 0), color = GRAY).shift(DOWN + 2*RIGHT) + circle = Circle(radius = 0.9, color = GREEN_SCREEN).shift(0.85*RIGHT + 0.38*DOWN) + circle.set_stroke(opacity = 1) + dl = DashedLine(circle.get_center(), dot.get_center()) + dltext = TextMobject(r'$R = 2.795$').scale(0.5).next_to(circle.get_center(), DOWN, buff = 0.1) + + main = TextMobject(r'r(t) = $\left\langle t^{2}, 2t, 0 \right\rangle\quad r\prime (t) = \left\langle 2t, 2, 0 \right\rangle\quad$ \\ $r\prime\prime (t) = \left\langle 2, 0, 0 \right\rangle$').scale(0.7).shift(3*UP + 3*LEFT) + main2 = TextMobject(r'Curvature at an arbitrary point \\ say r(t = 0.5) can be given as: \\ $\kappa = \frac{1}{R} = \frac{1}{2.795} = 0.357$').scale(0.7).shift(3.5*LEFT) + main3 = TextMobject(r'The ', 'tangent', r' and ', 'normal', r' vectors \\ can be represented as:').scale(0.7).shift(3.5*LEFT) + main3.set_color_by_tex_to_color_map({ + "tangent": YELLOW, + "normal": BLUE + }) + main4 = TextMobject(r'These vectors travel along \\ a small interval ', r'$ds$').scale(0.7).shift(1.5*UP + 3*LEFT) + main4.set_color_by_tex_to_color_map({ + "$ds$": GREEN_SCREEN + }) + + main5 = TextMobject(r'$\kappa = 0.357$').scale(0.7).shift(main.get_center() + np.array([2.4,-0.18,0])) + + nm = Vector((2, -1, 0), color = BLUE).shift(0.005*RIGHT + 0.007*DOWN) + nmText = TextMobject(r'$r\prime\prime (t) = \left\langle 2,0,0\right\rangle$').next_to(nm, DOWN+RIGHT, buff = 0).scale(0.7) + nm2 = DashedLine((0,0,0),(2, -1, 0), color = GRAY).shift(2*UP + RIGHT) + square = Square(fill_color = WHITE, fill_opacity = 0.2).rotate(63*DEGREES).shift(0.5*UP +1.5*RIGHT).scale(1.1) + square.set_stroke(width = 0.1) + square2 = Square(fill_color = PINK, fill_opacity = 0.2).scale(0.55).rotate(63*DEGREES).move_to((square.get_center() - dot.get_center()) / 2) + square2.set_stroke(width = 0.1) + arrow = CurvedArrow(square.get_center() + np.array([2,1,0]), square.get_center() + np.array([0.5,0,0])) + arrowText = TextMobject(r'$r\prime (t)\times r\prime\prime (t) = 4$').next_to(arrow.get_start(), DOWN+1*RIGHT, buff = 0).scale(0.7) + + text1 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\left|\frac{dT}{dt}\right|}{\left|\frac{ds}{dt}\right|}$').shift(UP+3*LEFT).scale(0.7) + text2 = TextMobject(r'$\left|\frac{dT}{ds}\right| = \frac{\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}\times\frac{r\prime (t)}{\left| r\prime (t)\right|}}{\left|r\prime (t)\right|}$').next_to(text1, DOWN, buff = 0.1).scale(0.7) + text3 = TextMobject(r'$= \frac{4}{(4t^{2} + 4)^{\frac{3}{2}}}$ \\ $= \frac{1}{2\sqrt{(1 + (0.5)^{2})^{3}}}$').next_to(text2, DOWN, buff = 0.1).scale(0.7) + text4 = TextMobject(r'$ = 0.357$').scale(0.7).next_to(text3, DOWN, buff = 0.2) + unit = VGroup(*[tgt, tgt2, nm, nm2]) + + tgt2text = TextMobject(r'$\frac{r\prime (t)}{\left| r\prime (t)\right|}$').shift(1.1*UP).scale(0.7).rotate(63*DEGREES ) + nm2text = TextMobject(r'$\frac{r\prime\prime (t)}{\left| r\prime (t)\right|}$').scale(0.7).shift(0.7*RIGHT+0.8*DOWN).rotate(-25*DEGREES) + unit2 = unit.copy().scale(0.5).shift(0.75*LEFT+0.25*DOWN) + + self.play(FadeIn(curve), FadeIn(main)) + self.wait(1) + self.play(ApplyMethod(curve.scale, 3), ApplyMethod(curve.shift, ORIGIN + 3.31*RIGHT)) + # self.wait(2) + self.play(FadeIn(main2), FadeIn(dot)) + self.play(FadeIn(circle), FadeIn(dl), FadeIn(dltext)) + self.wait() + self.play(ReplacementTransform(main2, main5), FadeIn(main3), FadeOut(circle), FadeOut(dl), FadeOut(dltext), FadeIn(VGroup(*[tgt, tgtText]))) + self.wait(1) + self.play(FadeIn(VGroup(*[nm, nmText]))) + self.wait(1) + self.remove(dot) + self.setup() + #self.camera_frame.set_width(4) + self.activate_zooming(animate = True) + self.play(FadeIn(ds), FadeIn(dsl), FadeOut(main3)) + self.wait(1) + self.play(FadeIn(main4)) + self.play(ApplyMethod(tgt.shift, 0.16*UP + 0.09*RIGHT), ApplyMethod(nm.shift, 0.16*UP + 0.09*RIGHT), run_time = 5) + self.wait(1) + self.play(FadeOut(ds), FadeOut(dsl), FadeOut(main4), FadeOut(self.zoomed_display, run_time = 1), FadeOut(self.zoomed_camera.frame, run_time = 1)) + # tgt = tgt.shift(0.16*DOWN + 0.08*LEFT) + # nm = nm.shift(0.16*DOWN + 0.08*LEFT) + self.play(ApplyMethod(tgt.shift, 0.16*DOWN + 0.09*LEFT, run_time = 1), ApplyMethod(nm.shift, 0.16*DOWN + 0.09*LEFT, run_time = 1)) + self.play(FadeIn(dot), FadeIn(VGroup(*[tgt2, nm2]))) + self.wait(1) + self.play(FadeIn(VGroup(*[square, arrow, arrowText]))) + self.wait(1) + self.play(FadeIn(unit2), FadeIn(square2)) + self.wait(1) + self.play(FadeIn(VGroup(*[tgt2text, nm2text]))) + self.wait(1) + self.play(FadeIn(text1)) + self.wait(1) + self.play(FadeIn(text2)) + self.wait(1) + self.play(FadeIn(text3)) + self.wait(1) + self.play(FadeIn(text4)) + self.wait(2) + self.play(FadeOut(VGroup(*[main, main5, square2, curve, dot, tgt2text, nm2text, text1, text2, text3, text4, tgt, tgtText,nm, nmText,tgt2, nm2,square, arrow, arrowText,unit2]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_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/file5_different_curvature_single_curve.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py new file mode 100644 index 0000000..0dc06bb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/arc-length-and-curvature/file5_different_curvature_single_curve.py @@ -0,0 +1,76 @@ +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, + 'x_tick_frequency': 20, + 'y_tick_frequency': 20 + } + + def construct(self): + + self.setup_axes() + def curve(x): + return 3 - (3653*x**2)/5292 + (277*x**3)/31752 + (13*x**4)/784 - (17*x**5)/5292 + (170*x**6)/63504 + + graph = FunctionGraph(curve, x_min=-2, x_max=6, stroke_width = 2, color = BLUE) + + tracker = ValueTracker(-2) + + text = TextMobject(r'$\because R_{1} > R_{2}$, the curvature at \\ point $P_{1}$ is less than that \\ at point $P_{2}$ as $\kappa = \frac{1}{R}$').shift(3.2*LEFT+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((2.9,-0.47, 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 + + circle1 = Circle(radius = 0.8, color = GREY, opacity = 0.2).shift(2.2*UP) + tgt1 = Line((-2,3,0), (2,3,0), color = GREY, opacity = 0.2).scale(0.4) + + r1 = Line(circle1.get_center(), circle1.get_center() + np.array([0,0.8,0]), color=GREEN_SCREEN) + r1label = TextMobject(r'$R_{1}$',color=WHITE).next_to(r1, RIGHT, buff = 0.1).scale(0.6) + + curvature1 = VGroup(*[circle1, tgt1, r1, r1label]) + + circle2 = Circle(radius = 0.2, color = GREY, opacity = 0.2).shift(0.3*DOWN + 2.9*RIGHT) + tgt2 = Line((4,-2,0), (6, -2, 0), color = GREY, opacity = 0.2).scale(0.5).shift(2.1*LEFT + 1.5*UP) + + r2 = Line(circle2.get_center(), circle2.get_center() - np.array([0,0.2,0]), color=GREEN_SCREEN) + r2label = TextMobject(r'$R_{2}$', color=WHITE).next_to(r2.get_start(), np.array([0,0,0]), buff = 0).scale(0.4) + + curvature2 = VGroup(*[circle2, tgt2, r2, r2label]) + + line = always_redraw(get_tangent_line) + + self.add(graph, line, dots, text) + self.wait(1.2) + self.play(tracker.set_value, 4, rate_func=smooth, run_time=10) + self.play(FadeIn(curvature1), FadeIn(curvature2)) + self.wait(2) + self.play(FadeOut(VGroup(*[curvature1, curvature2, 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..37d079e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/general-parametric-curves/file1_parametric_circle.py @@ -0,0 +1,81 @@ +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 + self.y_tick_frequency = 1.9 + self.x_tick_frequency = 1.4 + + axes = [] + + # self.setup_axes() + ax = Axes(y_tick_frequency = 1, x_axis_width = 10, y_axis_height = 10, y_min = -5, x_max = 5, y_max = 5, x_tick_frequency = 1, x_axis_label = "", y_axis_label = "", x_min = -5, ) + ax.scale(0.5).shift(3*LEFT) + axes.append(ax) + 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, + 2*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, + 2*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_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..7874f43 --- /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,15 @@ +**file1_tnb_creation.py**<br> +![file1_tnb_creation.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/file1_tnb_creation.gif) + + +**file2_tnb_basic.py** <br> +![file2_tnb_basic.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_basic.gif) + +**file3_tnb_frame_manim.py** <br> +![file3_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/file3_tnb_frame_manim.gif) + +**file4_fs1.py** <br> +![file4_fs1.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/file4_fs1.gif) + +**file5_fs2.py** <br> +![file5_fs2.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/file5_fs2.gif) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.gif Binary files differnew file mode 100644 index 0000000..eae8686 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.py new file mode 100644 index 0000000..80372ee --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file1_tnb_creation.py @@ -0,0 +1,66 @@ +from manimlib.imports import * + +class tnb(ThreeDScene): + def construct(self): + self.set_camera_orientation(phi = 75*DEGREES, theta=45*DEGREES) + + 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 + ) + + pointText = TextMobject(r'Consider an arbitrary point \\ on the given curve.').scale(0.8).shift(1.5*UP) + tgtText = TextMobject(r'Unit', ' tangent ', r'vector at \\ this point is given as:').scale(0.8).shift(1.5*UP) + tgtText.set_color_by_tex_to_color_map({ + "tangent": YELLOW + }) + normalText = TextMobject(r'Unit', ' normal ', r'vector at \\ this point is given as:').scale(0.8).shift(1.5*UP) + normalText.set_color_by_tex_to_color_map({ + "normal": BLUE + }) + planeText = TextMobject(r'$\overrightarrow{T}$ and $\overrightarrow{N}$ \\ prescribe a plane.').scale(0.8).shift(1.5*UP) + bnmText = TextMobject(r'The vector normal to this plane \\ is called the', ' binormal ', 'vector.').scale(0.8).shift(1.5*UP) + bnmText.set_color_by_tex_to_color_map({ + "binormal": GREEN_E + }) + + 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(2.1*RIGHT+2*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,4.86,0])).rotate(-15*DEGREES) + + + + helix = VGroup(*[helix1, helix2]) + self.play(FadeIn(helix)) + self.play(ApplyMethod(helix.scale, 4)) + self.add_fixed_in_frame_mobjects(pointText) + self.play(FadeIn(dot1), FadeIn(pointText)) + self.wait(2) + self.add_fixed_in_frame_mobjects(tgtText) + self.play(Write(tgt1), ReplacementTransform(pointText, tgtText)) + self.wait(2) + self.add_fixed_in_frame_mobjects(normalText) + self.play(Write(nm1), ReplacementTransform(tgtText, normalText)) + self.wait(2) + self.add_fixed_in_frame_mobjects(planeText) + self.play(FadeIn(plane1), ReplacementTransform(normalText, planeText)) + self.wait(2) + self.add_fixed_in_frame_mobjects(bnmText) + self.add_fixed_in_frame_mobjects(bnm1) + self.play(ReplacementTransform(planeText, bnmText), Write(bnm1)) + self.wait(2) + self.play(FadeOut(VGroup(*[helix, bnm1, bnmText, dot1, tgt1, nm1, plane1]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.gif Binary files differnew file mode 100644 index 0000000..67aaea2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.py new file mode 100644 index 0000000..c870210 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file2_tnb_basic.py @@ -0,0 +1,36 @@ +from manimlib.imports import * + +class tnb(ThreeDScene): + def construct(self): + 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) + f1 = TextMobject(r'$\overrightarrow{B}$ ', color = GREEN_E) + f2 = TextMobject(r' = $\overrightarrow{T}$', color = YELLOW).next_to(f1, RIGHT, buff=0.2) + f3 = TextMobject(r'$\times\overrightarrow{N}$', color = BLUE).next_to(f2, RIGHT, buff=0.1) + formula = VGroup(*[f1, f2, f3]).move_to(ORIGIN).shift(3*UP) + + # text = VGroup(*[t,n,b,frame]).move_to(ORIGIN).shift(3*UP) + curve = ParametricFunction( + lambda t: np.array([ + np.sin(TAU*t), + np.cos(TAU*t), + 0 + ]) + ).scale(2.5) + dot = Dot(color = RED).scale(1.5).shift(1.05*LEFT) + tgt = Arrow(dot.get_center(), (-2, 2, 0), color = YELLOW).shift(0.3*DOWN + 0.09*RIGHT) + normal = Arrow(tgt.get_start(), (1, 1, 0), color = BLUE).shift(0.2*LEFT + 0.05*DOWN) + binormal = Arrow(dot.get_center() - np.array([0,0,0.3]), (tgt.get_start()[0], tgt.get_start()[1],2), color = GREEN) + square = Square(color = DARK_BROWN, fill_color = WHITE, fill_opacity=0.3).move_to(tgt.get_start()).rotate(27*DEGREES).shift(UP+0.4*RIGHT).scale(1.2) + group = VGroup(*[dot, tgt, normal, square, binormal]).shift(np.array([-1.24,-1,0])) + + self.add_fixed_in_frame_mobjects(formula) + self.add(curve, group) + self.wait(1) + self.move_camera(phi = 75*DEGREES, theta=45*DEGREES, run_time = 2) + self.add_fixed_in_frame_mobjects(formula) + self.begin_ambient_camera_rotation(rate = 0.5) + self.wait(5) + self.play(FadeOut(VGroup(*[formula, curve, dot, tgt, normal, square, binormal]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.gif Binary files differnew file mode 100644 index 0000000..78e3aa3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py new file mode 100644 index 0000000..091c1e2 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file3_tnb_frame_manim.py @@ -0,0 +1,218 @@ +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) + + c1 = TextMobject(r'$r(t) = \left\langle\cos{t}, \sin{t}, 0.4t\right\rangle\quad r\prime (t) =\left\langle -\sin{t}, \cos{t}, 0.4\right\rangle$').next_to(text, DOWN, buff = 0.1).scale(0.7) + + + 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) + + t_tracker = ValueTracker(-2*np.pi/3) + t=t_tracker.get_value + + # t_label = TexMobject( + # "t = ",color=WHITE + # ).next_to(helix1,DOWN, buff=0.2).scale(0.6) + + cval1 = TextMobject(r'r(').next_to(c1, DOWN+16.5*LEFT, buff = 0.1).scale(0.7) + + t_text = always_redraw( + lambda: DecimalNumber( + t(), + color=WHITE, + ).next_to(cval1, RIGHT, buff=0.05).scale(0.7) + ).scale(0.6) + + + cval2 = always_redraw( + lambda: TextMobject(r') = $\left\langle$').scale(0.7).next_to(t_text, RIGHT, buff = 0.05) + ) + + cos = always_redraw( + lambda: DecimalNumber( + np.cos(t()), + color=WHITE, + ).next_to(cval2, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + sin = always_redraw( + lambda: DecimalNumber( + np.sin(t()), + color=WHITE, + ).next_to(cos, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + zpart = always_redraw( + lambda: DecimalNumber( + 0.4* t(), + color=WHITE, + ).next_to(sin, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + cvalend = always_redraw( + lambda: TextMobject(r' $\right\rangle$').next_to(zpart, RIGHT, buff = 0.2).scale(0.7) + ).scale(0.6) + + + valgroup = VGroup(*[cval1, cval2,cos,sin,zpart, cvalend]) + + rp1 = always_redraw( + lambda: TextMobject(r'$r\prime ($').scale(0.7).next_to(cvalend, RIGHT, buff = 0.6) + ) + + t_text2 = always_redraw( + lambda: DecimalNumber( + t(), + color=WHITE, + ).next_to(rp1, RIGHT, buff=0.05).scale(0.7) + ).scale(0.6) + + rp2 = always_redraw( + lambda: TextMobject(r') = $\left\langle$').scale(0.7).next_to(t_text2, RIGHT, buff = 0.05) + ) + + rps = always_redraw( + lambda: DecimalNumber( + -np.sin(t()), + color=WHITE, + ).next_to(rp2, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + + rpc = always_redraw( + lambda: DecimalNumber( + np.cos(t()), + color=WHITE, + ).next_to(rps, RIGHT, buff=0.1).scale(0.7) + ).scale(0.6) + + + const = always_redraw( + lambda: TextMobject(r'0.4 $\right\rangle$').next_to(rpc, RIGHT, buff = 0.2).scale(0.7) + ).scale(0.6).shift(0.1*DOWN) + + val2group = VGroup(*[rp1, rp2, rps, rpc, const]) + + #group = VGroup(t_text, t_text2).scale(1.5).move_to(ORIGIN).shift(3.7*DOWN) + + + 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, c1) + self.play(FadeIn(helix), FadeIn(text), FadeIn(c1)) + self.play(ApplyMethod(helix.scale, 4)) + self.add_fixed_in_frame_mobjects(bnm0, valgroup, val2group, t_text, t_text2) + self.play(FadeIn(point0), FadeIn(t_text), FadeIn(t_text2), FadeIn(valgroup), FadeIn(val2group)) + self.play(ApplyMethod(point0.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix1, run_time=5), t_tracker.set_value,-1.638*np.pi/3, rate_func=linear, run_time=5) + + self.add_fixed_in_frame_mobjects(bnm1) + self.play(FadeIn(point1)) + self.play(ApplyMethod(point1.set_color, GRAY, opacity = 0.1, run_time = 0.5), ApplyMethod(bnm1.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix2, run_time = 5), t_tracker.set_value,-1.33*np.pi/3, rate_func=linear, run_time=5) + + self.add_fixed_in_frame_mobjects(bnm2) + self.play(FadeIn(point2)) + self.play(ApplyMethod(point2.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix3, run_time=5), t_tracker.set_value,-np.pi/3, rate_func=linear, 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(FadeIn(point3)) + self.play(ApplyMethod(point3.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix4, run_time=5), t_tracker.set_value,-1.3*np.pi/6, rate_func=linear, run_time=5) + + self.add_fixed_in_frame_mobjects(bnm4) + self.play(FadeIn(point4)) + self.play(ApplyMethod(point4.set_color, GRAY, opacity = 0.1, run_time = 0.5), MoveAlongPath(helix_dot, helix5, run_time=5), t_tracker.set_value,0, rate_func=linear, run_time=5) + + self.add_fixed_in_frame_mobjects(bnm5) + self.play(FadeIn(point5)) + self.wait(2) + + self.play(FadeOut(VGroup(*[valgroup, val2group, t_text, t_text2, c1, text, helix, bnm1, point0, point1, point2, point3, point4, point5, helix_dot]))) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py new file mode 100644 index 0000000..f3f5a9c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file4_fs1.py @@ -0,0 +1,91 @@ +from manimlib.imports import * +class fs1(GraphScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN + } + def construct(self): + + text = TextMobject(r'$\frac{dT}{ds} = \kappa N$ \\ $\frac{dT}{ds}$ gives the direction of N, \\ while $\kappa$ gives its magnitude.').scale(0.7).shift(3*UP + 3*LEFT) + + self.setup_axes() + def curve_(x): + return x**3 - 2*x + + def nm(x): + return abs(6 * x / ((9*(x**4) - 6*(x**2) + 5)**1.5)) + + figure = self.get_graph(curve_) + + + dot = Dot().rotate(PI/2) + alpha = ValueTracker(0) + t2_ = ValueTracker(-2) + t2 = t2_.get_value + t = alpha.get_value + vector_x = self.get_tangent_vector(t(),figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) + + kappa = TextMobject(r'$\kappa = $').scale(0.7).shift(3*DOWN + 3*RIGHT) + + t_text = always_redraw( + lambda: DecimalNumber( + nm(t2()), + color=WHITE, + ).scale(0.7).next_to(kappa) + ).scale(0.6) + + self.play( + ShowCreation(figure), + GrowFromCenter(dot), + GrowArrow(vector_x), + GrowArrow(vector_y) + ) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(t(),figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + dot.add_updater(lambda m: m.move_to(vector_x.get_start())) + circle = Circle(radius = 2, color = GREEN_SCREEN). shift(2.63*RIGHT + 2.8*UP) + dot2 = Dot(np.array([2, curve_(2), 0]), color = WHITE).shift(2*DOWN + 2.5*RIGHT) + + self.add(vector_x, vector_y,dot, t_text, kappa, text) + self.play(t2_.set_value, 2, alpha.set_value, 1, run_time=18, rate_func=smooth) + self.play(FadeIn(dot2), FadeIn(circle)) + self.wait(2) + self.play(FadeOut(VGroup(*[self.axes, dot2, figure, circle, text, kappa, t_text]))) + + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=0.5): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * 0.7 + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion.copy()/6 + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + length = 6 * t / ((9*(t**4) - 6*(t**2) + 5)**1.5) + if coord_i[0] <= 0 and coord_i[0] > -0.5: + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(0).scale(2) + elif coord_i[0] > 0 and (coord_i[0] < 0.5 or coord_i[0] > 2.7): + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(0).scale(2) + elif coord_i[0] > 0: + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + else: + reference_line = Line(coord_i,coord_f).rotate(-PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = RED_C, buff=0) + return vector diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py new file mode 100644 index 0000000..31b9a85 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file5_torsion_intuition.py @@ -0,0 +1,119 @@ +from manimlib.imports import * + +class t(SpecialThreeDScene): + CONFIG = { + "axes_config": { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "z_min": -4, + "z_max": 4, + "x_axis_config": { + "tick_frequency": 100, + }, + "y_axis_config": { + "tick_frequency": 100, + }, + "z_axis_config": { + "tick_frequency": 100, + }, + "num_axis_pieces": 1, + } + } + def construct(self): + + text = TextMobject(r'Torsion can be intuitively \\ thought of as the measure \\ of "twisting" of a curve.').scale(0.7).shift(2.5*UP + 4.2*LEFT) + + + dot = Dot().rotate(PI/2) + f1 = ParametricFunction( + lambda t: np.array([ + 2*np.sin(TAU*t), + 2*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d1 = Dot(color = RED).next_to(f1.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.4*RIGHT) + t1 = self.get_torsion(2, 0.174) + t1 = "{:.2f}".format(t1) + t1 = TextMobject(fr'At the given point, $\tau = {t1}$').shift(3.5*DOWN).scale(0.7) + + f2 = ParametricFunction( + lambda t: np.array([ + 3*np.sin(TAU*t), + 3*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d2 = Dot(color = RED).next_to(f2.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 2.95*RIGHT) + t2 = self.get_torsion(3, 0.1765) + t2 = "{:.2f}".format(t2) + t2 = TextMobject(fr'At the given point, $\tau = {t2}$').shift(3.5*DOWN).scale(0.7) + + f3 = ParametricFunction( + lambda t: np.array([ + 4*np.sin(TAU*t), + 4*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d3 = Dot(color = RED).next_to(f3.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.2*UP + 3.45*RIGHT) + t3 = self.get_torsion(4, 0.179) + t3 = "{:.2f}".format(t3) + t3 = TextMobject(fr'At the given point, $\tau = {t3}$').shift(3.5*DOWN).scale(0.7) + + f4 = ParametricFunction( + lambda t: np.array([ + 1.5*np.sin(TAU*t), + 1.5*np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + d4 = Dot(color = RED).next_to(f4.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.215*UP + 2.128*RIGHT) + t4 = self.get_torsion(1.5, 0.173) + t4 = "{:.2f}".format(t4) + t4 = TextMobject(fr'At the given point, $\tau = {t4}$').shift(3.5*DOWN).scale(0.7) + + f5 = ParametricFunction( + lambda t: np.array([ + np.sin(TAU*t), + np.cos(TAU*t), + 2*t + ]), t_min = -2, t_max = 2, color = BLUE + ).scale(0.5) + + d5 = Dot(color = RED).next_to(f5.get_center(), 2*DOWN + LEFT, buff = 0).shift(1.3*UP + 1.858*RIGHT) + t5 = self.get_torsion(1, 0.17) + t5 = "{:.2f}".format(t5) + t5 = TextMobject(fr'At the given point, $\tau = {t5}$').shift(3.5*DOWN).scale(0.7) + + axes = ThreeDAxes(**self.axes_config) + self.set_camera_orientation(phi = 60*DEGREES, theta=45*DEGREES) + self.add_fixed_in_frame_mobjects(t1, text) + self.play(FadeIn(VGroup(*[f1, d1, t1, axes, text]))) + self.wait(2) + self.add_fixed_in_frame_mobjects(t2) + self.play(ReplacementTransform(d1, d2), ReplacementTransform(f1, f2), ReplacementTransform(t1, t2)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t3) + self.play(ReplacementTransform(d2, d3), ReplacementTransform(f2, f3), ReplacementTransform(t2, t3)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t4) + self.play(ReplacementTransform(d3, d4), ReplacementTransform(f3, f4), ReplacementTransform(t3, t4)) + self.wait(2) + self.add_fixed_in_frame_mobjects(t5) + self.play(ReplacementTransform(d4, d5), ReplacementTransform(f4, f5), ReplacementTransform(t4, t5)) + self.wait(2) + self.play(FadeOut(VGroup(*[d5, f5, t5, text, axes]))) + + def get_torsion(self, a, t): + rprime = np.array([a*np.cos(t), -a*np.sin(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([-a*np.sin(t), -a*np.cos(t), 0]) + n = rpp / np.dot(rpp, rpp) + b = np.cross(T, n) + dbdt = np.array([-2*np.sin(t), -2*np.cos(t), 0]) + tor = np.dot(dbdt, n) + + return tor diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py new file mode 100644 index 0000000..0c74685 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file6_fs2.py @@ -0,0 +1,90 @@ +from manimlib.imports import * + +class fs2(SpecialThreeDScene): + CONFIG = { + "x_min": -2, + "x_max": 2, + "y_min": -6, + "y_max": 6, + "graph_origin": ORIGIN + } + def construct(self): + axes = ThreeDAxes() + # text = TextMobject(r'$\frac{dB}{ds} = -\tau N$ \\ $\frac{dB}{ds}$ gives the direction of N, \\ while $\tau$ gives its magnitude.').scale(0.7).shift(3*UP + 3*LEFT) + self.set_camera_orientation(phi = 75*DEGREES, theta=135*DEGREES) + # self.move_camera(distance=0) + + # rprime = np.array([2*np.cos(t), -np.sin(t) - (2*np.sin(2*t)), 0]) + # t = rprime / np.sqrt(np.dot(rprime, rprime)) + # rpp = np.array([-2*np.sin(t), -np.cos(t) - (4*np.cos(2*t)), 0]) + # n = rpp / np.dot(rpp, rpp) + # b = np.cross(rprime, rpp) + text = TextMobject(r'$\frac{dB}{ds}$', r'$= -\tau$', r'$N$').shift(2*UP + 4*LEFT) + text.set_color_by_tex_to_color_map({ + r'$\frac{dB}{ds}$': YELLOW, + r'$N$': RED_C + }) + + dot = Dot().rotate(PI/2) + alpha = ValueTracker(0) + t = alpha.get_value + figure = ParametricFunction( + lambda t: np.array([ + np.sinh(t), + np.cosh(t), + 2*t + ]), t_min = -3, t_max = 3, color=BLUE + ).scale(0.5).move_to(ORIGIN) + vector_x = self.get_tangent_vector(t()%1, figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) + vector_x.add_updater( + lambda m: m.become( + self.get_tangent_vector(t()%1,figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + dot.add_updater(lambda m: m.move_to(vector_y.get_start())) + + + + self.add_fixed_in_frame_mobjects(text) + self.play(FadeIn(figure), FadeIn(axes), FadeIn(text)) + self.begin_ambient_camera_rotation(rate = 0.1) + self.wait(1) + self.add(vector_x, vector_y,dot) + self.play(alpha.increment_value, 0.999, run_time=20, rate_func=rush_from) + self.wait(1) + self.remove(figure, vector_x, vector_y,dot) + self.play(FadeOut(figure), FadeOut(axes), FadeOut(text)) + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion.copy() + coord_i = curve.point_from_proportion(proportion) + rprime = np.array([np.cosh(t), np.sinh(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + # b = (np.cross(T, n)[0] - 0.5, np.cross(T, n)[1], coord_i[2] + 1) + b = np.cross(T, n) + # coord_f = curve.point_from_proportion(proportion + dx) + coord_f = b + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * 1 + vector = Arrow(coord_i , coord_i + unit_vector, color = YELLOW, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + t = proportion.copy()/7 + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + length = np.sqrt(np.dot(rpp, rpp)) + length = 1/(1 + np.exp(-length)) + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_vector() * 0.7 + vector = Arrow(coord_i, coord_i + unit_vector, color = RED_C, buff=0) + return vector diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py new file mode 100644 index 0000000..698ca74 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/tnb-frame-and-serret-frenet-formulae/file7_fs3.py @@ -0,0 +1,194 @@ +from manimlib.imports import * + +class f(SpecialThreeDScene): + CONFIG = { + "axes_config": { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "z_min": -4, + "z_max": 4, + "x_axis_config": { + "tick_frequency": 100, + }, + "y_axis_config": { + "tick_frequency": 100, + }, + "z_axis_config": { + "tick_frequency": 100, + }, + "num_axis_pieces": 1, + } + } + def construct(self): + axes = ThreeDAxes(**self.axes_config) + text = TextMobject(r'$r(t) = \left\langle\sinh{t}, \cosh{t}, 2t\right\rangle$').scale(0.7).shift(3*UP + 3*LEFT) + self.set_camera_orientation(phi = 75*DEGREES, theta=225*DEGREES) + + + + figure = ParametricFunction( + lambda t: np.array([ + np.sinh(t), + np.cosh(t), + 2*t + ]), t_min = -3, t_max = 3, color=ORANGE + ).scale(0.5).move_to(ORIGIN) + + dot = Dot(color=RED) + alpha = ValueTracker(0) + t = alpha.get_value + + vector_x = self.get_binormal_vector(t()%1, figure,scale=2) + vector_y = self.get_normal_vector(t(),figure,scale=2) + vector_z = self.get_tangent_vector(t(), figure, scale=2) + + vector_x.add_updater( + lambda m: m.become( + self.get_binormal_vector(t()%1,figure,scale=2) + ) + ) + vector_y.add_updater( + lambda m: m.become( + self.get_normal_vector(t(),figure,scale=2) + ) + ) + vector_z.add_updater( + lambda m: m.become( + self.get_tangent_vector(t(),figure,scale=2) + ) + ) + dot.add_updater( + lambda m: m.move_to(vector_x.get_start()) + ) + def curvature(t): + r = np.array([np.sinh(t), np.cosh(t), 2*t]) + rp = np.array([np.cosh(t), np.sinh(t), 2]) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + cp = np.cross(rp, rpp) + k = cp / (np.dot(rp, rp)**1.5) + return abs(k[0]) + + def torsion(t): + r = np.array([np.sinh(t), np.cosh(t), 2*t]) + rp = np.array([np.cosh(t), np.sinh(t), 2]) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + dbdt = np.array([2*np.sinh(t), 2*np.cosh(t), 0]) + tor = np.dot(dbdt, n) + return tor + + + + k = curvature(0.3) + k = "{:.2f}".format(k) + tor = torsion(0.3) + tor = "{:.2f}".format(tor) + kt1 = TextMobject(rf'At the given point, \\ $\kappa =$ {k} \\').scale(0.7).shift(3*UP + 4*RIGHT) + kt2 = TextMobject('$\implies \kappa$',r'$T$',r' is scaled as:').scale(0.7).next_to(kt1, DOWN, buff=0.1) + kt2.set_color_by_tex_to_color_map({ + '$T$': YELLOW + }) + tbt1 = TextMobject(rf'At the given point, \\ $\tau =$ {tor} \\').scale(0.7).shift(3*UP + 4*RIGHT) + tbt2 = TextMobject(r'$\implies \tau$',r'$B$',r' is scaled as:').scale(0.7).next_to(tbt1, DOWN, buff=0.1) + tbt2.set_color_by_tex_to_color_map({ + '$B$': GREEN_E + }) + ft = TextMobject(r'$\frac{dN}{ds}$',r'$ = -\kappa$',r'$T$', r'$ + \tau$',r'$B$ \\', r'and is given as:').scale(0.7).shift(3*UP + 4*RIGHT) + ft.set_color_by_tex_to_color_map({ + r'$\frac{dN}{ds}$': GREEN_SCREEN, + '$T$': YELLOW, + r'$B$ \\': GREEN_E + }) + + self.add_fixed_in_frame_mobjects(text) + self.play(FadeIn(figure), FadeIn(axes), FadeIn(text)) + # self.begin_ambient_camera_rotation(rate = 0.13) + self.wait(1) + self.add(vector_x, vector_y,vector_z,dot) + self.play(alpha.increment_value, 0.3, run_time=10, rate_func=rush_from) + self.wait(1) + # self.stop_ambient_camera_rotation() + # self.move_camera(phi = 75*DEGREES, theta=225*DEGREES) + square = Rectangle(width=3.2, fill_color=WHITE, fill_opacity=0.3, color=RED_C).rotate(40*DEGREES).shift(0.8*DOWN+1.2*RIGHT) + mat = [[0.7, 0.3], [1.0, -0.7]] + square = square.apply_matrix(mat).rotate(17*DEGREES).shift(2.1*DOWN+RIGHT) + tl, nl, bl = TextMobject(r'$T$', color=YELLOW).shift(2.8*RIGHT+0.5*DOWN), TextMobject(r'$N$', color=BLUE).shift(RIGHT), TextMobject(r'$B$', color=GREEN_E).shift(0.6*LEFT+0.5*DOWN) + self.add_fixed_in_frame_mobjects(tl, nl, bl) + self.play(FadeIn(VGroup(*[tl, nl, bl]))) + self.wait(3) + self.add_fixed_in_frame_mobjects(square) + self.play(FadeIn(square), FadeOut(VGroup(*[tl, nl, bl]))) + self.wait(2) + self.add_fixed_in_frame_mobjects(kt1) + self.play(FadeIn(kt1)) + self.wait(2) + self.add_fixed_in_frame_mobjects(kt2) + self.play(FadeIn(kt2)) + self.wait(2) + kt = self.get_tangent_vector(0.3, figure, scale = -4*float(k)) + tb = self.get_binormal_vector(0.3, figure, scale = 2*float(tor)) + self.play( + ReplacementTransform(vector_z, kt) + ) + self.wait(3) + self.add_fixed_in_frame_mobjects(tbt1) + self.play(FadeOut(VGroup(*[kt1, kt2])), FadeIn(tbt1)) + self.wait(2) + self.add_fixed_in_frame_mobjects(tbt2) + self.play(FadeIn(tbt2)) + self.wait(2) + self.play( + ReplacementTransform(vector_x, tb) + ) + self.wait(2) + self.add_fixed_in_frame_mobjects(ft) + self.play(FadeOut(VGroup(*[tbt1, tbt2])), FadeIn(ft)) + self.wait(2) + dnds = Arrow(dot.get_center() + np.array([-0.1,-0.25,0]), np.array([-4,-1,2]), color=GREEN_SCREEN) + dndsl = TextMobject(r'$\frac{dN}{ds}$', color=GREEN_SCREEN).shift(2.5*LEFT + 1.2*UP) + self.add_fixed_in_frame_mobjects(dndsl) + self.play(FadeIn(dnds), FadeIn(dndsl)) + self.wait(5) + self.play(FadeOut(VGroup(*[square, dot,vector_y, dnds, dndsl, text, ft, tb, kt]))) + self.play(FadeOut(figure), FadeOut(axes)) + + + def get_binormal_vector(self, proportion, curve, dx=0.001, scale=1): + t = proportion + coord_i = curve.point_from_proportion(proportion) + rprime = np.array([np.cosh(t), np.sinh(t), 2]) + T = rprime / np.sqrt(np.dot(rprime, rprime)) + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + n = rpp / np.dot(rpp, rpp) + # b = (np.cross(T, n)[0] - 0.5, np.cross(T, n)[1], coord_i[2] + 1) + b = np.cross(T, n) + # coord_f = curve.point_from_proportion(proportion + dx) + coord_f = b + reference_line = Line(coord_i,coord_f) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i , coord_i + unit_vector, color = GREEN_E, buff=0) + return vector + + def get_normal_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + t = proportion.copy()/7 + rpp = np.array([np.sinh(t), np.cosh(t), 0]) + length = np.sqrt(np.dot(rpp, rpp)) + length = 1/(1 + np.exp(-length)) + reference_line = Line(coord_i,coord_f).rotate(PI/2).set_width(length).scale(2) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i, coord_i + unit_vector, color = BLUE, buff=0) + return vector + + def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1): + coord_i = curve.point_from_proportion(proportion) + coord_f = curve.point_from_proportion(proportion + dx) + reference_line = Line(coord_i,coord_f).scale(2) + if scale < 0: + reference_line = Line(coord_i,coord_f).scale(2).rotate(360*DEGREES) + unit_vector = reference_line.get_unit_vector() * scale + vector = Arrow(coord_i, coord_i + unit_vector, color = YELLOW, buff=0) + return vector 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..02678fd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/README.md @@ -0,0 +1,2 @@ +**file3_tangent_space_curve.py** <br> +![file3_tangent_space_curve.py](https://github.com/saarthdeshpande/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_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_non_differentiable.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py new file mode 100644 index 0000000..a91da6b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file2_non_differentiable.py @@ -0,0 +1,36 @@ +from manimlib.imports import * + +class nd(Scene): + def construct(self): + ld1 = Line().rotate(20*DEGREES) + pd1 = Dot(ld1.get_end(), fill_opacity = 0) + pd1.set_stroke(width = 0.5) + ld2 = Line().rotate(40*DEGREES).shift(1.4*UP + 1.7*RIGHT) + pd2 = Dot(ld2.get_start(), fill_opacity = 1, color = PURPLE) + t1 = TextMobject('A discontinuous function.').scale(0.7).shift(UP + 2*RIGHT) + + obj1 = VGroup(*[ld1, pd1, ld2, pd2]).shift(4*LEFT) + self.play(FadeIn(obj1), FadeIn(t1)) + self.wait(2) + + ld3 = ld2.copy().rotate(-60*DEGREES).shift(1.4*DOWN + 0.2*RIGHT) + pd3 = Dot(ld1.get_end(), fill_opacity = 1, color = PURPLE) + t2 = TextMobject('Graph containing a sharp corner.').scale(0.7).shift( 2*RIGHT) + + obj2 = VGroup(*[ld3, pd3]) + + self.play(Transform(VGroup(*[ld2, pd2]), obj2), ReplacementTransform(t1, t2)) + + self.wait(2) + + ld4 = Line().rotate(90*DEGREES) + pd4 = Dot(ld4.get_center(), color = PURPLE) + a1 = Arc(start_angle = -180*DEGREES, angle = 90*DEGREES).move_to(ld4.get_end()).rotate(-90*DEGREES).shift(0.5*(UP+RIGHT)) + a2 = Arc(start_angle = -180*DEGREES, angle = 90*DEGREES).move_to(ld4.get_start()).rotate(90*DEGREES).shift(0.5*(DOWN+LEFT)) + t3 = TextMobject('Graph with a vertical line.').scale(0.7).shift(2*RIGHT) + + obj3 = VGroup(*[ld4, pd4, a1, a2]).shift(3*LEFT) + + self.play(FadeOut(obj1), Transform(obj2, obj3), ReplacementTransform(t2, t3)) + self.wait(2) + self.play(FadeOut(obj2), FadeOut(t3)) diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.gif b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_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/file3_tangent_space_curve.gif diff --git a/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py new file mode 100644 index 0000000..c3aecc6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/geometry-of-planes-and-curves/velocity-and-differentiability/file3_tangent_space_curve.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class tangent(ThreeDScene): + def construct(self): + axes = ThreeDAxes() + text = TextMobject(r'Tangent', r' to the ', 'space curve', r' \\ at point ', r'$P_{1}$', ' is given by:').scale(0.7).shift(3*UP + 3.5*LEFT) + text.set_color_by_tex_to_color_map({ + "Tangent": YELLOW, + '$P_{1}$': RED, + 'space curve': BLUE + }) + text.bg=BackgroundRectangle(text,fill_opacity=1, color = BLACK) + text_gr =VGroup(text.bg,text) + 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, color = BLUE + ).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) + dotl = TextMobject(r'$P_{1}$', color = RED).scale(0.7).shift(2*DOWN + 5*LEFT) + self.add_fixed_in_frame_mobjects(text_gr, dotl) + self.play(FadeIn(axes),FadeIn(h), FadeIn(dot), FadeIn(dotl)) + self.wait(2) + self.play(FadeIn(tgtL), FadeIn(tgtR)) + self.begin_ambient_camera_rotation(rate=0.2) + self.play(FadeOut(dotl)) + self.wait(5) + self.play(FadeOut(axes), FadeOut(h), FadeOut(text_gr), 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..9115c78 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,14 @@ FSF2020--Somnath Pandit
+
+# **Topics:**
+
+## Double Integral
+Check the note [here](https://math.animations.fossee.in/contents/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals)
+## Fubini's Theorem
+Check the note [here](https://math.animations.fossee.in/contents/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem)
+## Line Integrals
+Check the note [here](https://math.animations.fossee.in/contents/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals)
+## Fundamental Theorem of Line integrals
+Check the note [here](https://math.animations.fossee.in/contents/calculus-of-several-variables/div,-grad,-curl-and-all-that/the-fundamental-theorem-of-line-integrals)
+## Vector Fields
+Check the note [here](https://math.animations.fossee.in/contents/calculus-of-several-variables/integrals-of-multivariable-functions/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..f86f7e3 --- /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](gifs/file1_area_under_func.gif) + +**file2_volume_under_surface** +![file2_volume_under_surface](gifs/file2_volume_under_surface.gif) + +**file3_y_limit_dependent_on_x** +![file3_y_limit_dependent_on_x](gifs/file3_y_limit_dependent_on_x.gif) + +**file4_non_rect_region** +![file4_non_rect_region](gifs/file4_non_rect_region.gif) + +**file5_elementary_area** +![file5_elementary_area](gifs/file5_elementary_area.gif) + +**file6_doing_integration** +![file6_doing_integration](gifs/file6_doing_integration.gif) + +**file7_int_process_of_example** +![file7_int_process_of_example](gifs/file7_int_process_of_example.gif) + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif Binary files differdeleted file mode 100644 index a2bfd9d..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif +++ /dev/null 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.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/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.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.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.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.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/gifs/file1_area_under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file1_area_under_func.gif Binary files differnew file mode 100644 index 0000000..223218b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file1_area_under_func.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file2_volume_under_surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/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/gifs/file2_volume_under_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file3_y_limit_dependent_on_x.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/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/gifs/file3_y_limit_dependent_on_x.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file4_non_rect_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file4_non_rect_region.gif Binary files differnew file mode 100644 index 0000000..c8e7c8c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file4_non_rect_region.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file5_elementary_area.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file5_elementary_area.gif Binary files differnew file mode 100644 index 0000000..5c9ac03 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file5_elementary_area.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file6_doing_integration.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/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/gifs/file6_doing_integration.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/file7_int_process_of_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/gifs/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/gifs/file7_int_process_of_example.gif 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..3aa9be2 --- /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](gifs/file1_surface1.gif) + +**file2_surface2** +![file2_surface2](gifs/file2_surface2.gif) + +**file3_iteration_methods** +![file3_iteration_methods](gifs/file3_iteration_methods.gif) + +**file4_curvy_limits** +![file4_curvy_limits](gifs/file4_curvy_region.gif) + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py new file mode 100644 index 0000000..a590a53 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py @@ -0,0 +1,232 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -4, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+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: 5*(x**2-y**2)/((1e-4+x**2+y**2)**2) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(#distance=10, + phi=80 * DEGREES, + theta=35 * DEGREES, + ) + + fn_text=TextMobject("$z=\dfrac{x^2-y^2}{(x^2+y^2)^2}$").set_color(BLUE) + fn_text.to_corner(UR,buff=1) + self.add_fixed_in_frame_mobjects(fn_text) + + R=TextMobject("R").set_color(BLACK).scale(2).rotate(180*DEGREES , OUT) + 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.6, + fill_color=BLUE_E, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.2) + self.play(Write(surface)) + + self.get_lines() + self.wait(4) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + 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 + 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,"YELLOW")) + + 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)) + + + 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 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=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 = [ + ("a", axes.a+.4), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c+.4), + ("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) + 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_Fubini's_Theorem + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py new file mode 100644 index 0000000..3160fdb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py @@ -0,0 +1,290 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -2, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+2*LEFT+2*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: x*y/4 + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation( + distance=30, + phi=75 * DEGREES, + theta=20 * DEGREES, + ) + + fn_text=TextMobject("$z=xy$").set_color(BLUE).scale(1.5) + fn_text.to_corner(UR,buff=2) + self.add_fixed_in_frame_mobjects(fn_text) + + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=.5, + fill_color=BLUE_E, + stroke_width=0.4, + stroke_color=WHITE, + ) + #get boundary curves + c1=self.get_curve( + self.axes, lambda x: x**2/4 + ) + c1_label=TextMobject("$y=x^2$").next_to(c1,IN+OUT).shift(DOWN+RIGHT) + c1_label.rotate(PI) + c1_group=VGroup(c1,c1_label).set_color(ORANGE) + + c2=self.get_curve( + self.axes, lambda x: x + ).set_color(PINK) + c2_label=TextMobject("$y=x$").next_to(c2,IN+OUT) + c2_label.rotate(PI/2,about_point=(c2_label.get_corner(UL))) + c2_group=VGroup(c2,c2_label).set_color(YELLOW_E) + + + + self.add(c1,c2,c1_label,c2_label) + + self.begin_ambient_camera_rotation(rate=0.24) + self.get_region(self.axes,c1,c2) + self.play(Write(surface)) + self.get_lines() + 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=3 + ) + self.wait(2) + + + + def get_curve(self,axes, func, **kwargs): + config = { + "t_min": axes.x_min, + "t_max": axes.x_max, + } + config.update(kwargs) + return ParametricFunction( + lambda x : axes.c2p( + x, func(x),0 + ), + **config + ) + + def get_region(self,axes,curve1,curve2,**kwargs): + x_vals=np.arange(axes.x_min,axes.x_max,.1) + c1_points=[curve1.get_point_from_function(x) for x in x_vals] + c2_points=[curve2.get_point_from_function(x) for x in x_vals] + c2_points.reverse() + points=c1_points+c2_points + region=Polygon(*points, + stroke_width=0, + fill_color=PINK, + fill_opacity=.5 + ) + R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) + R.move_to(region,IN+RIGHT) + + self.play(ShowCreation(region)) + self.add(R) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + 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 + 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,"YELLOW")) + + 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)) + + + 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=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), + ] + 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_Fubini's_Theorem + + + + + 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.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.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/gifs/file1_surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file1_surface1.gif Binary files differnew file mode 100644 index 0000000..8c9fa0a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file1_surface1.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file2_surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/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/gifs/file2_surface2.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file3.o_iteration_methods_checkpoint.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/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/gifs/file3.o_iteration_methods_checkpoint.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/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/gifs/file3_iteration_methods.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/file4_curvy_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/gifs/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/gifs/file4_curvy_region.gif 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..3cdddae --- /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](gifs/file1_grad_of_scalar_function.gif) + +**file2_line_int_independent_of_path** +![file2_line_int_independent_of_path](gifs/file2_line_int_independent_of_path.gif) + +**file3_line_int_example** +![file3_line_int_example](gifs/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.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..fd3d9b5 --- /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,317 @@ +from manimlib.imports import * + +class GradOfScalarFunc(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": 5, + "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": 3, + "colors": [TEAL,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": .2, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + } + + + 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)=","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").set_color(GOLD) + grad_text.next_to(scalar_fn_text,DOWN).scale(.9) + + VGroup( + grad_text[0][1], + grad_text[0][9] + ).set_color(BLUE) + VGroup( + grad_text[0][5:8], + grad_text[0][13:16] + ).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) + + + show_vects=[ + FadeIn(v_field1), + ] + + self.begin_ambient_camera_rotation(rate=.2) + self.move_camera( + # distance=20, + phi=60 * DEGREES, + added_anims=show_vects, + run_time=4.5 + ) + + self.play(FadeOut(grad_text)) + self.wait(2) + self.stop_ambient_camera_rotation() + + self.add_fixed_in_frame_mobjects(vector_field_text) + vector_field= [ + FadeOut(s_field1), + Write(vector_field_text), + ] + self.move_camera( + # distance=20, + phi=0 * DEGREES, + theta=-90 * DEGREES, + added_anims=vector_field, + 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) + vector_field.move_to(self.axes.c2p(0,0,0)) + self.vector_field=vector_field + + if on_surface: + vector_field=self.get_vectors_on_surface() + + return vector_field + + + + def get_vectors_on_surface(self): + vectors_on_surface = VGroup(*[ + self.vector_field.get_vector(point) + 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.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..b8f7cfa --- /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_f","P_i"] + 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.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/fundamental-theorem-of-line-integral/gifs/file1_grad_of_scalar_function.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/file1_grad_of_scalar_function.gif Binary files differnew file mode 100644 index 0000000..1fd2e15 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/file1_grad_of_scalar_function.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/file2_line_int_independent_of_path.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/file2_line_int_independent_of_path.gif Binary files differnew file mode 100644 index 0000000..8d375bb --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/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/gifs/file3_line_int_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/gifs/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/gifs/file3_line_int_example.gif 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..7e4299d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -0,0 +1,15 @@ +**file1_scalar_line_int_as_sum** +![file1_scalar_line_int_as_sum](gifs/file1_scalar_line_int_as_sum.gif) + +**file2_scalar_line_integral** +![file2_scalar_line_integral](gifs/file2_scalar_line_integral.gif) + + +**file3_vector_line_int_as_sum** +![file3_vector_line_int_as_sum](gifs/file3_vector_line_int_as_sum.gif) + +**file4_vector_line_integral** +![file4_vector_line_integral](gifs/file4_vector_line_integral.gif) + +**file5_helix** +![file5_helix](gifs/file5_helix.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..af32ebf --- /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) + + + self.play(FadeIn(VGroup( + point_coord,dot + ))) + self.play(Write(self.evaluate_text)) + self.play(Write(func_val)) + + 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)) + dot.set_color(ORANGE).scale(1.2) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in dots ] + ))) + 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.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..200f768 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py @@ -0,0 +1,427 @@ +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=60 * DEGREES, + theta=-60 * 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.move_camera( + # distance=20, + phi=90 * DEGREES, + # theta=-90 * DEGREES, + # added_anims=into_graph, + run_time=2 + ) + self.wait(2) + + 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.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_vector_line_integral.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_vector_line_integral.py new file mode 100644 index 0000000..6730820 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_vector_line_integral.py @@ -0,0 +1,374 @@ +from manimlib.imports import * + +class LineIntegrationProcess(GraphScene): + + CONFIG = { + "x_min" : -0, + "x_max" : 1, + "y_min" : -0, + "y_max" : 1, + "axes_color":WHITE, + "graph_origin": ORIGIN+6.3*LEFT+3*DOWN, + "x_axis_width": 5.5, + "y_axis_height": 5.5, + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "min_magnitude": 0, + "max_magnitude": 15, + "colors": [BLUE], + "length_func": lambda norm : norm/35, + "opacity": 1.0, + "vector_config": { + "stroke_width":2 + }, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + } + + + 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) + + fn_text=TexMobject( + r"\vec F = x^2\hat i-xy\hat j", + stroke_width=2.5 + ).set_color_by_gradient( + *self.default_vector_field_config["colors"] + ) + fn_text.to_edge(TOP,buff=.1).shift(2*LEFT) + + origin=self.graph_origin + v_field=self.get_vector_field( + lambda v: np.array([ + (v[0]-origin[0])**2, + -(v[0]-origin[0])*(v[1]-origin[1]), + 0, + ]), + x_min= -.001+origin[0], + x_max= 5.4+origin[0], + y_min= -0+origin[1], + y_max= 5.5+origin[1], + ) + + self.add(v_field, fn_text) + self.play(Write(fn_text)) + self.wait(2) + self.get_line_of_int() + self.get_dot_product_values() + self.wait(2) + self.remove(v_field,fn_text) + self.write_area_as_intgral_value() + 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_line_of_int(self): + line_of_int_text=TextMobject( + r"Line of integration is\\", + "$\\vec r(t)=\cos(t)\hat i+\sin(t)\hat j$" + ) + line_of_int_text[1].set_color(PINK) + line_of_int_text.to_corner(UR,buff=.8) + + + line_of_int= self.get_graph( + lambda x : np.sqrt(1-x**2), + x_min=1, + x_max=0, + ) + line_of_int.set_style( + stroke_width=3, + stroke_color=PINK, + ) + + self.play(Write(line_of_int_text)) + self.wait(.5) + self.play(ShowCreation(line_of_int),run_time=2) + # self.add(line_of_int) + + self.line_of_int=line_of_int + self.line_of_int_text=line_of_int_text + + + def get_dot_product_values(self): + t_tracker = ValueTracker(0) + self.t_tracker = t_tracker + self.get_vector_and_tangent() + self.get_dot_product_graph() + self.wait(1.5) + self.play(ApplyMethod( + self.t_tracker.set_value, PI/6, + rate_func=linear, + run_time=2.5, + ) + ) + self.wait(1) + self.play(ApplyMethod( + self.t_tracker.set_value, PI/2, + rate_func=linear, + run_time=4, + ) + ) + self.dot_prod_graph.suspend_updating() + + def get_vector_and_tangent(self): + vect_tangent_text=TextMobject( + "Get the"," vector",r" and\\"," tangent", + " on the"," line" + ) + vect_tangent_text.set_color_by_tex_to_color_map({ + "tangent": ORANGE, "vector": YELLOW, "line":PINK + }) + vect_tangent_text.to_corner(UR,buff=.8) + self.vect_tangent_text= vect_tangent_text + + self.play(FadeOut(self.axes)) + self.remove(self.line_of_int_text) + self.play(Write(vect_tangent_text)) + self.show_vector() + self.show_tangent() + self.wait(1.3) + + def show_vector(self): + t = self.t_tracker.get_value + vect_label=TextMobject( + "$\\vec F(x_i,y_i)$", + color=YELLOW, + stroke_width=2 + ).scale(.8) + + vector = always_redraw( lambda: + self.vector_field.get_vector( + self.coords_to_point( + np.cos(t()), np.sin(t()) + ), + stroke_width=6, + max_stroke_width_to_length_ratio= 8, + ).set_color(YELLOW), + ) + + vect_label.next_to(vector,RIGHT,buff=.1) + vector_group= VGroup(vector,vect_label) + + # self.add(vector_group) + self.play(Write(vector_group),run_time=1) + self.wait(.4) + + self.vect_label = vect_label + self.vector_group= vector_group + + def show_tangent(self): + tangent_label=TextMobject( + "$\\vec T(x_i,y_i)$", + color=ORANGE, + stroke_width=2 + ).scale(.8) + + t = self.t_tracker.get_value + + tangent = always_redraw(lambda: + Vector( + color=ORANGE, + stroke_width=6, + ).scale(1).next_to( + self.coords_to_point( + np.cos(t()), np.sin(t()) + ),DR,buff=-.1 + ).rotate( + self.angle_of_tangent( + np.cos(t()), + self.line_of_int, + dx=-0.00001 + ), + about_point=self.coords_to_point( + np.cos(t()), np.sin(t()) + ) + ) + ) + tangent_label.next_to(tangent,UP,buff=.1) + tangent_group=VGroup(tangent,tangent_label) + + # self.add(tangent_group) + self.play(Write(tangent_group)) + self.wait(.6) + + self.tangent_label=tangent_label + self.tangent_group=tangent_group + + def get_dot_product_graph(self): + t = self.t_tracker.get_value + + self.start_x= 1.3 ; self.end_x=2.3 + + t_axis= self.get_graph( + lambda x : 2.0/5, + x_min= self.start_x, + x_max= self.end_x, + ).set_style( + stroke_width=4, + ) + + dot_prod_axis= Vector(3*UP).next_to( + t_axis,LEFT,buff=-.1 + ).set_color(GREEN) + dot_prod_label=TexMobject( + "\\vec F","\\cdot","\\vec T", + stroke_width= 1.5, + ).next_to(dot_prod_axis,UP).scale(.8) + dot_prod_label[0].set_color(YELLOW) + dot_prod_label[2].set_color(ORANGE) + + dot_prod_graph_axes= VGroup(t_axis,dot_prod_axis) + + self.write_about_graph() + self.wait(1) + # self.add(dot_prod_graph_axes) + self.play(Write(dot_prod_graph_axes)) + self.show_the_parameter(t,t_axis) + self.wait(.6) + self.play(ReplacementTransform( + self.vect_label,dot_prod_label[0] + )) + self.play(ReplacementTransform( + self.tangent_label,dot_prod_label[1:3] + )) + self.show_graph_area(t_axis) + + self.dot_prod_graph_axes= dot_prod_graph_axes + self.dot_prod_label= dot_prod_label + + def write_about_graph(self): + graph_text=TextMobject( + "Graph",r" of the "," vector",r" $-$\\ ", + r"tangent",r" dot product\\", + " with the parameter ","$t$" + ) + graph_text.set_color_by_tex_to_color_map({ + "Graph":GREEN, "vector": YELLOW, + "tangent":ORANGE, "$t$":RED + }) + graph_text.to_corner(UR,buff=.5) + self.graph_text=graph_text + + self.remove(self.vect_tangent_text) + self.play(Write(graph_text),run_time=4) + + def show_the_parameter(self,t,t_axis): + t_dot=Dot(color=RED).next_to(t_axis,LEFT,buff=0) + t_dot.add_updater(lambda obj : + obj.move_to(self.c2g([t(),0]) + )) + t_text=TextMobject("$t$=").next_to(t_dot,UP,buff=.25) + t_val=always_redraw( + lambda: DecimalNumber( + t()/PI, + color=GOLD + ).next_to(t_text,RIGHT,buff=0).scale(.8) + ) + t_label=VGroup( + t_text,t_val + ).set_color(RED) + + + pi = TexMobject( + "\\pi ", + color=GOLD, + ).next_to(t_val,RIGHT,buff=0.05) + t_label.add(pi) + + t_label.add_updater(lambda label : + label.next_to(t_dot,UP) + ) + + t_group=VGroup(t_dot,t_label) + + # self.add(t_group) + self.play(Write(t_group)) + + self.t_group= t_group + + + def show_graph_area(self,t_axis): + t = self.t_tracker.get_value + dot_prod_graph= always_redraw(lambda: Polygon( + *[ + self.c2g([t,-2*np.cos(t)**2*np.sin(t)]) + for t in np.arange(0,t(),0.01) + ], + *[ + self.c2g([t,0]) + for t in [ t(),0 ] + ], + stroke_width=2.5, + fill_color=TEAL_D, + fill_opacity=.6, + )) + + self.add(dot_prod_graph) + + self.dot_prod_graph=dot_prod_graph + + def c2g(self,coord): + """ get points for the dot product graph + from its coordinates""" + + return self.coords_to_point( + self.start_x+coord[0]/(PI/2), + 2.0/5+coord[1]/2, + ) + + + def write_area_as_intgral_value(self): + area_text=TextMobject( + "Value of the "," line"," integral in the", + r"Vector field\\", + "is equal to this ","area" + ) + area_text.set_color_by_tex_to_color_map({ + "Vector field": BLUE, "line":PINK, "area":TEAL_C + }) + area_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + + self.play(FadeOut(VGroup( + self.line_of_int, + self.vector_group, + self.tangent_group, + self.t_group, + self.dot_prod_graph_axes, + self.dot_prod_label, + self.graph_text + ) + )) + area= self.dot_prod_graph.copy().scale(1.3) + area.next_to(area_text,DOWN,buff=1.5) + + # self.add(area_text) + self.play(Write(area_text),run_time=4) + self.play(ReplacementTransform( + self.dot_prod_graph, + area + )) + self.wait(.5) + + #uploaded by Somnath Pandit.FSF2020_Line_Integrals + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file5_helix.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file5_helix.py new file mode 100644 index 0000000..50aeb33 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file5_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/integrals-of-multivariable-functions/line-integrals/gifs/file1_scalar_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file1_scalar_line_int_as_sum.gif Binary files differnew file mode 100644 index 0000000..17ea3f0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file1_scalar_line_int_as_sum.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file2_scalar_line_integral.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file2_scalar_line_integral.gif Binary files differnew file mode 100644 index 0000000..f9a8f98 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file2_scalar_line_integral.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file3_vector_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/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/gifs/file3_vector_line_int_as_sum.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file4_vector_line_integral.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file4_vector_line_integral.gif Binary files differnew file mode 100644 index 0000000..1be7e1e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file4_vector_line_integral.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file5_helix.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/gifs/file5_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/gifs/file5_helix.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/README.md new file mode 100644 index 0000000..d8c0956 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/README.md @@ -0,0 +1,11 @@ +**file1_vector_fields** +![file1_vector_fields](gifs/file1_vector_fields.gif) + +**file2_grad_of_scalar_function** +![file2_grad_of_scalar_function](gifs/file2_grad_of_scalar_function.gif) + +**file3_constructing_vector_field** +![file3_constructing_vector_field](gifs/file3_constructing_vector_field.gif) + +**file4_slope_field** +![file4_slope_field](gifs/file4_slope_field.gif) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file1_vector_fields.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file1_vector_fields.py new file mode 100644 index 0000000..6b1b686 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file1_vector_fields.py @@ -0,0 +1,350 @@ +from manimlib.imports import * + +class VectorFields(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -4, + "x_max": 4, + "y_min": -4, + "y_max": 4, + "z_min": -3, + "z_max": 3, + "a":-4 ,"b": 4, "c":-4 , "d":4, + "axes_shift": ORIGIN+2*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": 10, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "min_magnitude": 0, + "max_magnitude": 4, + "colors": [BLUE,GREEN,ORANGE,RED], + "length_func": lambda norm : .45*sigmoid(norm), + "opacity": 1.0, + "vector_config": { + "stroke_width":3.5, + "max_tip_length_to_length_ratio": 0.35, + "max_stroke_width_to_length_ratio": 8, + }, + }, + + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=0 * DEGREES, + theta=-90 * DEGREES, + ) + self.move_camera(frame_center=axes.c2p(0,0,0)) + + self.show_2d_field() + self.wait(3) + + self.show_3d_field() + self.begin_ambient_camera_rotation(rate=-.3,) + self.wait(1.5) + 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), + ), + self.move_camera( + # distance=20, + phi=85 * DEGREES, + rate_func=linear, + run_time=8 + ) + self.wait(5) + + + def show_2d_field(self): + d2_field_text=TexMobject( + r"\vec F(x,y)=-y\hat i+x\hat j", + stroke_width=1.5 + ).set_color_by_gradient( + *self.default_vector_field_config["colors"] + ) + d2_field_text.to_corner(UR,buff=.5) + + d2_field = self.get_vector_field( + lambda v: np.array([ + -v[1], + v[0], + 0 + ]), + ) + self.add_fixed_in_frame_mobjects(d2_field_text) + # self.add(d2_field) + self.play(Write(d2_field_text)) + self.play(FadeIn(d2_field)) + + self.d2_field=d2_field + self.d2_field_text=d2_field_text + + def show_3d_field(self): + d3_field_text=TexMobject( + r"\vec F(x,y,z)=-y\hat i+x\hat j+0 \hat k", + stroke_width=1.5 + ).set_color_by_gradient( + *self.default_vector_field_config["colors"] + ) + d3_field_text.to_corner(UR,buff=.5) + + d3_field= self.get_vector_field( + lambda v: np.array([ + -v[1], + v[0], + 0 + # v[0]*v[2] + ]), + z_min=-2, + z_max= 2, + delta_x= 1, + delta_y= 1, + delta_z= 1, + length_func=lambda norm : .5*sigmoid(norm), + opacity= 1, + ThreeD=True + ) + + self.remove(self.d2_field,self.d2_field_text) + self.add_fixed_in_frame_mobjects(d3_field_text) + # self.add(d3_field) + self.play(Write(d3_field_text)) + self.play(FadeIn(d3_field)) + + def get_vector_field(self,func,ThreeD=False,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + if ThreeD: + vector_field= VectorField3D(func,**config) + else: + vector_field= VectorField(func,**config) + + vector_field.move_to(self.axes.c2p(0,0,0)) + self.vector_field=vector_field + + return vector_field + + + +#------------------------------------------------------- + #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( + -0 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 0 * 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, 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 + +#----------------------------------------------------------- + +class VectorField3D(VGroup): + CONFIG = { + "delta_x": 1, + "delta_y": 1, + "delta_z": 1, + "x_min": int(np.floor(-FRAME_WIDTH / 2)), + "x_max": int(np.ceil(FRAME_WIDTH / 2)), + "y_min": int(np.floor(-FRAME_HEIGHT / 2)), + "y_max": int(np.ceil(FRAME_HEIGHT / 2)), + "z_min":-1, + "z_max": 1, + "min_magnitude": 0, + "max_magnitude": 4, + "colors": DEFAULT_SCALAR_FIELD_COLORS, + # Takes in actual norm, spits out displayed norm + "length_func": lambda norm: 0.45 * sigmoid(norm), + "opacity": 1.0, + "vector_config": {}, + } + '''Position of the tip of vector to be fixed''' + def __init__(self, func, **kwargs): + VGroup.__init__(self, **kwargs) + self.func = func + self.rgb_gradient_function = get_rgb_gradient_function( + self.min_magnitude, + self.max_magnitude, + self.colors, + flip_alphas=False + ) + x_range = np.arange( + self.x_min, + self.x_max + self.delta_x, + self.delta_x + ) + y_range = np.arange( + self.y_min, + self.y_max + self.delta_y, + self.delta_y + ) + z_range = np.arange( + self.z_min, + self.z_max + self.delta_z, + self.delta_z + ) + for x, y, z in it.product(x_range, y_range, z_range): + point = x * RIGHT + y * UP + z * OUT + # print(point) + self.add(self.get_vector(point)) + self.set_opacity(self.opacity) + + def get_vector(self, point, **kwargs): + output = np.array(self.func(point)) + norm = get_norm(output) + if norm == 0: + output *= 0 + else: + output *= self.length_func(norm) / norm + # norm=np.linalg.norm(output) + vector_config = dict(self.vector_config) + vector_config.update(kwargs) + + vect = Vector( + output, + **vector_config + ) + vect_perp=vect.copy().rotate(PI/2, axis=output) + vect= VGroup(vect,vect_perp) + # vect= self.position_vector(vect,point,output,norm) + vect.shift(point) + fill_color = rgb_to_color( + self.rgb_gradient_function(np.array([norm]))[0] + ) + vect.set_color(fill_color) + return vect + + '''def position_vector(self,vect,point,output,norm): + theta,phi=self.get_theta_phi(output,norm) + vect.rotate(PI-phi, axis=RIGHT) + vect.rotate(theta, axis=IN) + # or apply rotation matrix? + return vect + + def get_theta_phi(self,output,norm): + if norm==0: + phi,theta=0,0 + else: + phi= np.arccos(output[-1]/norm) + if output[0]!=0: + theta= np.arccos(output[0]/(norm*np.sin(phi))) + else: + theta= 0 + return phi,theta''' + + + + #uploaded by Somnath Pandit. FSF2020_Vector_fields + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file2_grad_of_scalar_function.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file2_grad_of_scalar_function.py new file mode 100644 index 0000000..231b15c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file2_grad_of_scalar_function.py @@ -0,0 +1,320 @@ +from manimlib.imports import * + +class GradOfScalarFunc(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+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_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "min_magnitude": 0, + "max_magnitude": 2, + "colors": [BLUE,GREEN,GREEN,ORANGE,RED], + "length_func": lambda norm : .45*sigmoid(norm), + "opacity": 1.0, + "vector_config": { + "stroke_width":6 + }, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [BLUE_D], + "stroke_width": .5, + "stroke_color": WHITE, + "stroke_opacity": 0.2, + }, + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=80 * DEGREES, + theta=-80 * DEGREES, + ) + + scalar_fn_text=TexMobject("f(x,y)=","\cos(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( + r"\vec F&=-y\sin(xy)\hat i\\ &-x\sin(xy)\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_field=self.get_scalar_field( + func= lambda x ,y : np.cos(x*y/2), + dn=.25 + ) + v_field=self.get_vector_field( + lambda v: np.array([ + -(v[1]-axes.c2p(0,0,0)[1])*np.sin((v[0]-axes.c2p(0,0,0)[0])*(v[1]-axes.c2p(0,0,0)[1])), + -(v[0]-axes.c2p(0,0,0)[0])*np.sin((v[0]-axes.c2p(0,0,0)[0])*(v[1]-axes.c2p(0,0,0)[1])), + 0, + ]), + on_surface=True, + ) + + self.add_fixed_in_frame_mobjects(scalar_fn_text) + + self.begin_ambient_camera_rotation(rate=.2) + self.play(Write(s_field),run_time=2) + self.wait(4) + 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(1.5) + + self.play(FadeOut(grad_text)) + self.add_fixed_in_frame_mobjects(vector_field_text) + show_vec_field=[ + FadeIn(v_field), + Write(vector_field_text), + ] + # self.play(*show_vec_field,run_time=.5) + self.begin_ambient_camera_rotation(rate=.2) + self.move_camera( + # distance=20, + phi=50 * DEGREES, + added_anims=show_vec_field, + run_time=3 + ) + + self.wait(5) + self.stop_ambient_camera_rotation() + + fadeout= [FadeOut(s_field)] + # self.play(*fadeout) + 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,dn=.5): + surface= self.get_surface( + lambda x , y: + func(x,y), + ) + + self.surface_points=self.get_points(func,dn) + return surface + + def get_points(self,func,dn): + axes=self.axes + + 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) + vector_field.move_to(self.axes.c2p(0,0,0)) + self.vector_field=vector_field + + if on_surface: + vector_field=self.get_vectors_on_surface() + + return vector_field + + + + def get_vectors_on_surface(self): + vectors_on_surface = VGroup(*[ + self.vector_field.get_vector(point) + 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": ( + 4*(axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + 4*(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_Vector_fields + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py new file mode 100644 index 0000000..fc56306 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file3_constructing_vector_field.py @@ -0,0 +1,196 @@ +from manimlib.imports import * + + +class VectorFields(GraphScene): + CONFIG = { + "x_min" : -4, + "x_max" : 4, + "y_min" : -4, + "y_max" : 4, + "graph_origin": ORIGIN+2.5*LEFT, + "x_axis_width": 7, + "y_axis_height": 7, + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "min_magnitude": 0, + "max_magnitude": 4, + "colors": [GREEN,GREEN,YELLOW,RED], + "length_func": lambda n: n/2.5, + "opacity": .75, + "vector_config": { + "stroke_width":6, + "max_stroke_width_to_length_ratio":4 + }, + }, + + "a":-3.5 ,"b": 4, "c": -3.5 ,"d": 4, + } + + 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_function = lambda v: np.array([ + (v[0]-self.graph_origin[0])*(v[1]-self.graph_origin[1]), + -(v[0]-self.graph_origin[0]), + 0, + ]) + + vector_field=self.get_vector_field( + vector_function, + colors= [GREEN] + ) + + self.show_points() + self.wait(.5) + self.show_func_machine() + self.wait(1) + self.produce_vectors(vector_field) + self.wait(.5) + self.scale_down_vectors(vector_function) + self.wait(2) + + + + def show_points(self): + dn=1 + x_vals=np.arange(self.a,self.b,dn) + y_vals=np.arange(self.c,self.d,dn) + dots=VGroup() + for x_val in x_vals: + for y_val in y_vals: + dot=Dot( + self.coords_to_point(x_val,y_val), + radius=.05, + color=TEAL, + ) + dots.add(dot) + self.play(ShowCreation(dots, run_time=1)) + self.dots=dots + + def show_func_machine(self): + machine=RoundedRectangle( + height=2, + width=3.5, + color=PURPLE, + stroke_width=8 + ).to_edge(RIGHT, buff=.4) + + machine_label=TexMobject( + r"\vec F=xy\hat i-x\hat j", + stroke_width=1.5, + ).set_color_by_gradient( + *self.default_vector_field_config["colors"] + ).next_to(machine,IN) + + machine=VGroup(machine,machine_label) + self.add(machine) + + self.func_machine=machine + + + def produce_vectors(self,vector_field): + count,i=3,0 + self.run_time=1 + non_scaled_vectors=VGroup() + for dot in self.dots: + if i==count: + self.run_time=.05 + position=dot.get_center() + vect= vector_field.get_vector(position) + self.go_to_machine(dot) + self.take_vec_from_machine(vect,position) + non_scaled_vectors.add(vect) + i+=1 + + self.non_scaled_vectors=non_scaled_vectors + + def go_to_machine(self,dot): + if self.run_time>.5: + self.play(ApplyMethod( + dot.next_to, + self.func_machine,4*UP, + ), + run_time=self.run_time + ) + self.dot=dot + + def take_vec_from_machine(self,vect,position): + vect.next_to(self.func_machine,DOWN,buff=.1) + + if self.run_time>.5: + point_coord=TexMobject( + "(x_i,y_i)" + ).next_to(self.dot,RIGHT,buff= .01).scale(.75) + input_point=VGroup(point_coord, self.dot) + self.play( + ApplyMethod( + input_point.shift,DOWN, + run_time=self.run_time + )), + self.play( + FadeOut(input_point), + run_time=.2 + ) + self.play( + FadeIn(vect), + run_time=.4 + ) + else: + self.remove(self.dot) + self.add(vect) + self.wait(1.0/15) + + self.play( + vect.move_to,position, + run_time=self.run_time + ) + + def scale_down_vectors(self,vector_function): + scale_down_text=TextMobject( + r"Vectors are rescaled\\ for clarity\\ and \\", + r"colors are used to \\ indicate magnitudes", + stroke_width=1.2 + ) + scale_down_text[0][:7].set_color(BLUE) + scale_down_text[1].set_color_by_gradient( + *self.default_vector_field_config["colors"] + ) + scale_down_text.to_corner(UR).shift(DOWN) + scaled_vector_field= self.get_vector_field( + vector_function, + length_func= lambda norm : .75*sigmoid(norm) + ) + for vector in self.non_scaled_vectors: + scaled_vect= scaled_vector_field.get_vector(vector.get_center()) + vector.target= scaled_vect + + self.play(FadeOut(self.func_machine)) + self.play(Write(scale_down_text)) + self.wait(1.2) + self.play(LaggedStartMap( + MoveToTarget, self.non_scaled_vectors, + run_time=3 + )) + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + return vector_field + + + + + +#uploaded by Somnath Pandit. FSF2020_Vector_fields + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file4_slope_field.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file4_slope_field.py new file mode 100644 index 0000000..8ebb6f5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/file4_slope_field.py @@ -0,0 +1,247 @@ +from manimlib.imports import * + + +class SlopeFields(GraphScene): + CONFIG = { + "x_min" : -2, + "x_max" : 2, + "y_min" : -2, + "y_max" : 2, + "graph_origin": ORIGIN+2.5*LEFT, + "x_axis_width": 7, + "y_axis_height": 7, + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_slope_field_config": { + "delta_x": .2, + "delta_y": .2, + "opacity": 1, + "color": BLUE_A, + "slope_length_factor": .2, + "line_config": { + "stroke_width":2.5, + }, + }, + + "a":-1.9 ,"b": 2, "c": -1.9 ,"d": 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) + + slope_field=self.get_slope_field( + lambda x,y:-2.0*(x-self.graph_origin[0])*(y-self.graph_origin[1]), + x_min=self.graph_origin[0]+self.a, + x_max=self.graph_origin[0]+self.b, + y_min=self.graph_origin[1]+self.c, + y_max=self.graph_origin[1]+self.d, + color= GREEN_B + ) + + self.show_points() + self.wait(.5) + self.show_func_machine() + self.wait(1) + self.produce_slopes(slope_field) + # self.add(slope_field) + self.glimpse_of_solutions() + self.wait(2) + + + + + def show_points(self): + dn=1.0/5 + x_vals=np.arange(self.a,self.b,dn) + y_vals=np.arange(self.c,self.d,dn) + dots=VGroup() + for x_val in x_vals: + for y_val in y_vals: + dot=Dot( + self.coords_to_point(x_val,y_val), + radius=.04, + color=TEAL, + ) + dots.add(dot) + self.play(ShowCreation(dots, run_time=1)) + self.dots=dots + + def show_func_machine(self): + machine=RoundedRectangle( + height=3, + width=4, + color=PURPLE, + stroke_width=8 + ).to_edge(RIGHT, buff=.4) + + machine_label=TextMobject( + r"Line segment\\ with slope\\"," $y'=-2xy$", + stroke_width=1.2, + color=BLUE + ).next_to(machine,IN) + machine_label[1].set_color(GREEN) + machine=VGroup(machine, machine_label) + self.play(FadeIn(machine)) + + self.func_machine = machine + + + def produce_slopes(self,slope_field): + count,i=3,0 + self.run_time=1 + for dot in self.dots: + if i==count: + self.run_time=.05 + position=dot.get_center() + line= slope_field.get_slope(position) + self.go_to_machine(dot) + self.take_line_from_machine(line,position) + i+=1 + + def go_to_machine(self,dot): + if self.run_time>.5: + self.play(ApplyMethod( + dot.next_to, + self.func_machine,4*UP, + ), + run_time=self.run_time + ) + self.dot=dot + + def take_line_from_machine(self,vect,position): + + if self.run_time>.5: + vect.next_to(self.func_machine,DOWN,buff=.1) + self.play( + ApplyMethod( + self.dot.shift,DOWN, + run_time=self.run_time + )), + self.play( + FadeOut(self.dot), + run_time=.2 + ) + self.play( + FadeIn(vect), + run_time=.4 + ) + self.play( + ApplyMethod( + vect.move_to,position + ), + run_time=self.run_time + ) + else: + self.remove(self.dot) + self.add(vect) + vect.move_to(position) + + + def get_slope_field(self,func,**kwargs): + config = dict() + config.update(self.default_slope_field_config) + config.update(kwargs) + slope_field= SlopeField(func,**config) + + return slope_field + + def glimpse_of_solutions(self): + sol_text= TextMobject( + r"The solution curves\\ seem to be like...", + color= BLUE, + stroke_width=1.2 + ) + sol_text.to_corner(UR, buff=1) + condition_text= TextMobject( + r"for different\\ initial conditions", + color= GOLD, + stroke_width=1.1 + ) + condition_text.next_to(sol_text,DOWN,buff=1) + solution1 = self.get_graph( + lambda x : np.exp(-x**2), + x_min = self.a, + x_max = self.b, + color = PINK) + solution2 = self.get_graph( + lambda x : .5*np.exp(-x**2), + x_min = self.a, + x_max = self.b, + color = YELLOW) + solution3 = self.get_graph( + lambda x : 1.5*np.exp(-x**2), + x_min = self.a, + x_max = self.b, + color = BLUE) + solution4 = self.get_graph( + lambda x : -np.exp(-x**2), + x_min = self.a, + x_max = self.b, + color = RED_E) + + self.play(FadeOut(self.func_machine)) + self.play(Write(sol_text)) + self.wait(.6) + self.play(ShowCreation(solution1)) + self.play(Write(condition_text)) + self.play(ShowCreation(solution2)) + self.wait(.5) + self.play(ShowCreation(solution3)) + self.wait(.5) + self.play(ShowCreation(solution4)) + + +class SlopeField(VGroup): + CONFIG = { + "delta_x": 0.5, + "delta_y": 0.5, + "x_min": int(np.floor(-FRAME_WIDTH / 2)), + "x_max": int(np.ceil(FRAME_WIDTH / 2)), + "y_min": int(np.floor(-FRAME_HEIGHT / 2)), + "y_max": int(np.ceil(FRAME_HEIGHT / 2)), + "opacity": 1.0, + "color": WHITE, + "slope_length_factor": .25, + "line_config": {}, + } + + def __init__(self, func, **kwargs): + VGroup.__init__(self, **kwargs) + self.func = func + + x_range = np.arange( + self.x_min, + self.x_max + self.delta_x, + self.delta_x + ) + y_range = np.arange( + self.y_min, + self.y_max + self.delta_y, + self.delta_y + ) + for x, y in it.product(x_range, y_range): + point = x * RIGHT + y * UP + self.add(self.get_slope(point)) + self.set_opacity(self.opacity) + + def get_slope(self, point, **kwargs): + slope = self.func(*point[:2]) + line_config = dict(self.line_config) + line_config.update(kwargs) + line = Line(ORIGIN,self.slope_length_factor*RIGHT, **line_config) + line.move_to(point).rotate(np.arctan(slope/3.2)) + + line.set_color(self.color) + return line + + + + +#uploaded by Somnath Pandit. FSF2020_Vector_fields + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file1_vector_fields.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file1_vector_fields.gif Binary files differnew file mode 100644 index 0000000..96e50ac --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file1_vector_fields.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file2_grad_of_scalar_function.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file2_grad_of_scalar_function.gif Binary files differnew file mode 100644 index 0000000..c1ab66a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file2_grad_of_scalar_function.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file3_constructing_vector_field.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file3_constructing_vector_field.gif Binary files differnew file mode 100644 index 0000000..6a57cab --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file3_constructing_vector_field.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file4_slope_field.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file4_slope_field.gif Binary files differnew file mode 100644 index 0000000..c39ec54 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/vector-fields/gifs/file4_slope_field.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/README.md index e69de29..97a0fb7 100644 --- a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/README.md +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/README.md @@ -0,0 +1,9 @@ +# Contributer: Nishan Poojary
+Github Account : <a href="https://github.com/nishanpoojary">nishanpoojary</a>
+<br/></br>
+## Sub-Topics Covered:
++ Scalar Functions
++ Multivariable Functions
++ Multivariable Limits and Continuity
++ Partial Derivatives
++ Directonal Derivatives
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/README.md new file mode 100644 index 0000000..a62369d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/README.md @@ -0,0 +1,8 @@ +**file1_directional_deriv** +![file1_directional_deriv](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif) + +**file2_gradient** +![file2_gradient](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif) + +**file3_gradient_level_curves** +![file3_gradient_level_curves](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif) diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py new file mode 100644 index 0000000..677d821 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file1_directional_deriv.py @@ -0,0 +1,85 @@ +from manimlib.imports import *
+
+class GeomRepresen(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ -0.25*3*3*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/4,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.7,
+ resolution=(15, 32)).scale(1)
+
+ parabola_curve = ParametricFunction(
+ lambda u : np.array([
+ u,
+ -u,
+ -0.5*(u*u)+2
+ ]),color=PINK,t_min=-1.5,t_max=1.5,
+ )
+
+ circle = Circle(radius = 2.22 , color = BLACK, fill_color = BLUE_C, fill_opacity= 0.3, stroke_width=0.1)
+
+ plane = Polygon(np.array([2.5,-2.5,0]),np.array([-2.5,2.5,0]),np.array([-2.5,2.5,2.5]),np.array([2.5,-2.5,2.5]),np.array([2.5,-2.5,0]), color = BLACK, fill_color = PINK, fill_opacity= 0.2, stroke_width=0.1)
+
+ line = DashedLine(np.array([1,-1,0]), np.array([1,-1,1.5]), color = YELLOW_C)
+
+ tangent_line = Line(np.array([1.5,-1.5,1]), np.array([0.5,-0.5,2]), color = RED_C)
+
+ vector = Arrow(np.array([1,-1,0]), np.array([0.5,-0.5,0]), buff=0.01, color = GREEN_C)
+
+ dot1 =Sphere(radius=0.08).move_to(np.array([1,-1,0])).set_fill(YELLOW_C)
+ dot2 =Sphere(radius=0.08).move_to(np.array([1,-1,1.5])).set_fill(YELLOW_C)
+
+ dot1_lab = TextMobject(r"$P_0$").scale(0.6).move_to(np.array([1,-1,1.8])).set_color(RED_C)
+ dot2_lab = TextMobject(r"$(x_0,y_0)$").scale(0.6).move_to(np.array([1.6,-1,0])).set_color(PURPLE)
+ vector_lab = TextMobject(r"$\hat{u}$").scale(0.8).move_to(np.array([1.2,-0.5,0])).set_color(GREEN_C)
+ domain_lab = TextMobject(r"$D$").scale(0.6).move_to(np.array([1,1,0])).set_color(GREEN_C)
+ func_lab = TextMobject(r"$z = f(x,y)$").scale(0.6).move_to(1*UP + 2.8*RIGHT).set_color(BLUE_C)
+ directional_deriv_lab = TextMobject(r"Slope = $D_{\hat{u}}f(x_0,y_0)$").scale(0.6).move_to(2.2*UP + 1.5*RIGHT).set_color(YELLOW_C)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.set_camera_orientation(phi=65 * DEGREES, theta = 20*DEGREES)
+
+ self.play(ShowCreation(paraboloid))
+ self.add_fixed_in_frame_mobjects(func_lab)
+ self.wait()
+
+ #self.play(ShowCreation(circle))
+ self.bring_to_front(circle)
+ self.wait()
+ self.add_fixed_orientation_mobjects(domain_lab)
+ self.wait()
+
+ self.play(ShowCreation(plane), ShowCreation(parabola_curve))
+ self.play(ShowCreation(dot1), GrowArrow(line), ShowCreation(dot2))
+ self.add_fixed_orientation_mobjects(dot1_lab)
+ self.wait()
+ self.add_fixed_orientation_mobjects(dot2_lab)
+ self.wait()
+
+ self.play(ShowCreation(tangent_line))
+ self.add_fixed_in_frame_mobjects(directional_deriv_lab)
+ self.wait()
+
+ self.play(GrowArrow(vector))
+ self.add_fixed_orientation_mobjects(vector_lab)
+ self.wait()
+
+
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.wait(3)
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py new file mode 100644 index 0000000..e9fef50 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file2_gradient.py @@ -0,0 +1,103 @@ +from manimlib.imports import *
+
+class Gradient(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+
+ quadrant = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*np.cos(u)
+ ]),u_min=0,u_max=PI/3,v_min=0,v_max=PI/2,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ quadrant_curve = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*np.cos(u)
+ ]),u_min=34*DEGREES,u_max=38*DEGREES,v_min=0,v_max=PI/2,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+
+
+ dot1 =Sphere(radius=0.05).move_to(np.array([1,1,0])).set_fill(YELLOW_C)
+ dot2 =Sphere(radius=0.05).move_to(np.array([1,1,1.732])).set_fill(YELLOW_C)
+
+ dot1_line = DashedLine(np.array([1,1,1.732]), np.array([0,2,2]), color = WHITE)
+ dot1_lab = TextMobject(r"$P_0(x_0,y_0,z_0)$").move_to(np.array([0,2.1,2.2])).set_color(YELLOW_C).scale(0.6)
+ #dot2_line = Line(np.array([0.8,0.8,0]), np.array([1,0.6,0]), color = PINK)
+
+ positive_vector = Arrow(np.array([1,1,0]), np.array([0.5,0.5,0]), buff=0.001, color = BLUE_C)
+ positive_gradient = Arrow(np.array([1,1,1.732]), np.array([0.5,0.5,1.9362]), buff=0.001, color = BLUE_C)
+ positive_gradient_lab = TextMobject(r"$\nabla f$").move_to(np.array([0.5,0.3,0])).set_color(BLUE_C).scale(0.5)
+
+ negative_vector = Arrow(np.array([1,1,0]), np.array([1.5,1.5,0]), buff=0.001, color = RED_C)
+ negative_gradient = Arrow(np.array([1,1,1.732]), np.array([1.5,1.5,1.322]), buff=0.001, color = RED_C)
+ negative_gradient_lab = TextMobject(r"$-\nabla f$").move_to(np.array([1.6,1.6,0])).set_color(RED_C).scale(0.5)
+
+ positive_vector_line = DashedLine(np.array([0.8,0.8,0]), np.array([1,-2,0]), color = WHITE)
+ positive_vector_lab = TextMobject(r"Most Rapid increase in $f$").move_to(np.array([1.6,-3.6,0])).set_color(BLUE_C).scale(0.6)
+ negative_vector_line = DashedLine(np.array([1.2,1.2,0]), np.array([3,-1.5,0]), color = WHITE)
+ negative_vector_lab = TextMobject(r"Most Rapid decrease in $f$").move_to(np.array([3.6,-3,0])).set_color(RED_C).scale(0.6)
+
+
+
+ line1 = DashedLine(np.array([0.5,0.5,0]), np.array([0.5,0.5,1.9362]), color = BLUE_C)
+ line2 = DashedLine(np.array([1,1,0]), np.array([1,1,1.732]), color = YELLOW_C)
+ line3 = DashedLine(np.array([1.5,1.5,0]), np.array([1.5,1.5,1.322]), color = RED_C)
+
+ curve_vector1 = Arrow(np.array([1,1,0]), np.array([1.5,0.5,0]), buff=0.001, color = YELLOW_C)
+ curve_vector2 = Arrow(np.array([1,1,0]), np.array([0.5,1.5,0]), buff=0.001, color = YELLOW_C)
+
+ curve_vector1_line = DashedLine(np.array([1.2,0.8,0]), np.array([1,2.5,0]), color = WHITE)
+ curve_vector2_line = DashedLine(np.array([0.8,1.2,0]), np.array([1,2.5,0]), color = WHITE)
+ curve_vector_lab = TextMobject(r"Zero Change in $f$").move_to(np.array([0.7,3.6,0])).set_color(PINK).scale(0.6)
+
+ #square = Square(side_length = 0.5).rotate(45*DEGREES).move_to(np.array([1.025,0.975,0]))
+ line_x = Line(np.array([0.8,0.8,0]), np.array([1,0.6,0]), color = PINK)
+ line_y = Line(np.array([1.2,0.8,0]), np.array([1,0.6,0]), color = PINK)
+
+ ninety_degree = VGroup(line_x, line_y)
+
+ self.set_camera_orientation(phi=60* DEGREES, theta = 20*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(quadrant))
+ self.wait()
+ self.play(ShowCreation(dot1), ShowCreation(dot2))
+ self.wait()
+ self.play(GrowArrow(positive_vector), GrowArrow(positive_gradient))
+ self.wait()
+ self.play(GrowArrow(negative_vector), GrowArrow(negative_gradient))
+ self.wait()
+ self.play(GrowArrow(line1), GrowArrow(line2), GrowArrow(line3))
+ self.wait()
+ self.play(ShowCreation(quadrant_curve))
+ self.wait()
+ self.play(GrowArrow(curve_vector1), GrowArrow(curve_vector2), ShowCreation(ninety_degree))
+ self.wait()
+ self.play(GrowArrow(dot1_line))
+ self.add_fixed_orientation_mobjects(dot1_lab)
+ self.wait()
+ self.play(GrowArrow(curve_vector1_line), GrowArrow(curve_vector2_line))
+ self.add_fixed_orientation_mobjects(curve_vector_lab)
+ self.wait()
+ self.add_fixed_orientation_mobjects(positive_gradient_lab, negative_gradient_lab)
+ self.wait()
+ self.play(GrowArrow(positive_vector_line), GrowArrow(negative_vector_line))
+ self.add_fixed_orientation_mobjects(positive_vector_lab, negative_vector_lab)
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.wait(3)
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py new file mode 100644 index 0000000..a3b88e5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/file3_gradient_level_curves.py @@ -0,0 +1,107 @@ +from manimlib.imports import *
+
+class GradientLevelCurves(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ -u*u+2
+ ]),u_min=-1.414,u_max=1.414,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ plane_0 = Polygon(np.array([2,-2,0]),np.array([2,2,0]),np.array([-2,2,0]),np.array([-2,-2,0]),np.array([2,-2,0]), color = BLUE_E, fill_color = BLUE_E, fill_opacity = 0.3)
+ plane_0_lab = TextMobject("C = 0").move_to(0.4*UP+3.2*RIGHT).set_color(BLUE_E).scale(0.6)
+ circle_0 = Circle(radius = 1.414 , color = BLUE_E)
+ circle_0_lab = TextMobject("0").move_to(1.1*DOWN+1.1*RIGHT).set_color(BLUE_E).scale(0.6)
+
+ plane_0_5 = Polygon(np.array([2,-2,0.5]),np.array([2,2,0.5]),np.array([-2,2,0.5]),np.array([-2,-2,0.5]),np.array([2,-2,0.5]), color = GREEN_C, fill_color = GREEN_C, fill_opacity = 0.3)
+ plane_0_5_lab = TextMobject("C = 0.5").move_to(0.8*UP+3.4*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5 = Circle(radius = 1.224 , color = GREEN_C)
+ circle_0_5_lab = TextMobject("0.5").move_to(0.9*DOWN+0.9*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5_copy = circle_0_5.copy().move_to(np.array([0,0,0.5]))
+
+ plane_1 = Polygon(np.array([2,-2,1]),np.array([2,2,1]),np.array([-2,2,1]),np.array([-2,-2,1]),np.array([2,-2,1]), color = YELLOW_C, fill_color = YELLOW_C, fill_opacity = 0.3)
+ plane_1_lab = TextMobject("C = 1").move_to(1.2*UP+3.3*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1 = Circle(radius = 1 , color = YELLOW_C)
+ circle_1_lab = TextMobject("1").move_to(0.7*DOWN+0.7*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1_copy = circle_1.copy().move_to(np.array([0,0,1]))
+
+ plane_1_5 = Polygon(np.array([2,-2,1.5]),np.array([2,2,1.5]),np.array([-2,2,1.5]),np.array([-2,-2,1.5]),np.array([2,-2,1.5]), color = ORANGE, fill_color = ORANGE, fill_opacity = 0.3)
+ plane_1_5_lab = TextMobject("C = 1.5").move_to(1.7*UP+3.4*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5 = Circle(radius = 0.707 , color = ORANGE)
+ circle_1_5_lab = TextMobject("1.5").move_to(0.5*DOWN+0.5*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5_copy = circle_1_5.copy().move_to(np.array([0,0,1.5]))
+
+ plane_2 = Polygon(np.array([2,-2,2]),np.array([2,2,2]),np.array([-2,2,2]),np.array([-2,-2,2]),np.array([2,-2,2]), color = RED_C, fill_color = RED_C, fill_opacity = 0.3)
+ plane_2_lab = TextMobject("C = 2").move_to(2.1*UP+3.3*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2 = Dot().set_fill(RED_C)
+ circle_2_lab = TextMobject("2").move_to(0.2*DOWN+0.2*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2_copy = dot_2.copy().move_to(np.array([0,0,2]))
+
+ vector1 = Arrow(np.array([0.99,-0.99,0]), np.array([0.865,-0.865,0.5]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient1 = Arrow(np.array([0.99,-0.99,0]), np.array([0.865,-0.865,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector2 = Arrow(np.array([0.865,-0.865,0.5]), np.array([0.707,-0.707,1]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient2 = Arrow(np.array([0.865,-0.865,0]), np.array([0.707,-0.707,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector3 = Arrow(np.array([0.707,-0.707,1]), np.array([0.499,-0.499,1.5]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient3 = Arrow(np.array([0.707,-0.707,0]), np.array([0.499,-0.499,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+ vector4 = Arrow(np.array([0.499,-0.499,1.5]), np.array([0,0,2]), buff=0.01, color = RED_C).set_stroke(width=3)
+ gradient4 = Arrow(np.array([0.499,-0.499,0]), np.array([0,0,0]), buff=0.01, color = RED_C).set_stroke(width=3)
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=45 * DEGREES, theta = -20*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(Write(paraboloid))
+ self.wait()
+ self.play(ShowCreation(plane_0), ShowCreation(circle_0))
+ self.add_fixed_in_frame_mobjects(plane_0_lab)
+ self.wait()
+ self.play(ShowCreation(plane_0_5), ShowCreation(circle_0_5_copy), ShowCreation(circle_0_5))
+ self.add_fixed_in_frame_mobjects(plane_0_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1), ShowCreation(circle_1_copy), ShowCreation(circle_1))
+ self.add_fixed_in_frame_mobjects(plane_1_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1_5), ShowCreation(circle_1_5_copy), ShowCreation(circle_1_5))
+ self.add_fixed_in_frame_mobjects(plane_1_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_2), ShowCreation(dot_2_copy), ShowCreation(dot_2))
+ self.add_fixed_in_frame_mobjects(plane_2_lab)
+ self.wait()
+ self.move_camera(phi=60 * DEGREES, theta = 30*DEGREES,run_time=3)
+ self.play(FadeOut(plane_0), FadeOut(plane_0_lab), FadeOut(plane_0_5), FadeOut(plane_0_5_lab), FadeOut(plane_1), FadeOut(plane_1_lab), FadeOut(plane_1_5), FadeOut(plane_1_5_lab), FadeOut(plane_2), FadeOut(plane_2_lab))
+ self.play(FadeOut(circle_0_5_copy), FadeOut(circle_1_copy), FadeOut(circle_1_5_copy), FadeOut(dot_2_copy))
+
+ self.move_camera(phi=45 * DEGREES, theta = -20*DEGREES,run_time=3)
+ self.play(Write(vector1), Write(gradient1))
+ self.wait()
+ self.play(Write(vector2), Write(gradient2))
+ self.wait()
+ self.play(Write(vector3), Write(gradient3))
+ self.wait()
+ self.play(Write(vector4), Write(gradient4))
+ self.wait()
+ self.move_camera(phi=0 * DEGREES, theta = 0*DEGREES,run_time=3)
+ self.play(FadeOut(paraboloid))
+ self.play(FadeOut(vector1), FadeOut(vector2), FadeOut(vector3), FadeOut(vector4))
+ self.wait()
+ self.add_fixed_in_frame_mobjects(circle_0_lab, circle_0_5_lab, circle_1_lab, circle_1_5_lab,circle_2_lab)
+ self.wait(4)
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif Binary files differnew file mode 100644 index 0000000..39305d5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file1_directional_deriv.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif Binary files differnew file mode 100644 index 0000000..d96f330 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file2_gradient.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif Binary files differnew file mode 100644 index 0000000..f1bf06a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/directional-derivatives/gifs/file3_gradient_level_curves.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/Multivariable_Functions_Quiz.pdf b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/Multivariable_Functions_Quiz.pdf Binary files differnew file mode 100644 index 0000000..7895843 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/Multivariable_Functions_Quiz.pdf diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/README.md new file mode 100644 index 0000000..0e6e8d3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/README.md @@ -0,0 +1,17 @@ +**file1_multivar_func_examples** +![file1_multivar_func_examples](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file1_multivar_func_examples.gif) + +**file2_multivariable_func_respresentation** +![file2_multivariable_func_respresentation](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file2_multivariable_func_respresentation.gif) + +**file3_sphere** +![file3_sphere](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file3_sphere.gif) + +**file4_vectorvf_sine** +![file4_vectorvf_sine](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file4_vectorvf_sine.gif) + +**file5_vectorvf_helix** +![file5_vectorvf_helix](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file5_vectorvf_helix.gif) + +**file6_derivative_vectorvf** +![file6_derivative_vectorvf](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file6_derivative_vectorvf.gif) diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file1_multivar_func_examples.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file1_multivar_func_examples.py new file mode 100644 index 0000000..55b2b7e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file1_multivar_func_examples.py @@ -0,0 +1,167 @@ +from manimlib.imports import *
+
+class Examples1(GraphScene):
+ def construct(self):
+
+ rectangle = Rectangle(height = 3, width = 4, color = GREEN)
+ rectangle_area_func = TexMobject("Area", "=", "f(", "Length", ",", "Breadth", ")").scale(0.6)
+ rectangle_area_func[0].set_color(RED_C)
+ rectangle_area_func[2].set_color(ORANGE)
+ rectangle_area_func[3].set_color(YELLOW_C)
+ rectangle_area_func[5].set_color(BLUE_C)
+ rectangle_area_func[6].set_color(ORANGE)
+
+
+ rectangle_area = TexMobject("Area", "=", "Length", "\\times", "Breadth").scale(0.6)
+ rectangle_area[0].set_color(RED_C)
+ rectangle_area[2].set_color(YELLOW_C)
+ rectangle_area[4].set_color(BLUE_C)
+
+
+ square = Square(side_length = 5, color = PURPLE)
+ square_area_func = TexMobject("Area", "=", "f(", "Length", ")")
+ square_area_func[0].set_color(GREEN_C)
+ square_area_func[2].set_color(ORANGE)
+ square_area_func[3].set_color(BLUE_C)
+ square_area_func[4].set_color(ORANGE)
+
+ square_area = TexMobject("Area", "=", "Length^2")
+ square_area[0].set_color(GREEN_C)
+ square_area[2].set_color(BLUE_C)
+
+
+ circle = Circle(radius = 2, color = PINK)
+ circle_area_func = TexMobject("Area", "=", "f(", "r", ")")
+ circle_area_func[0].set_color(YELLOW_C)
+ circle_area_func[2].set_color(ORANGE)
+ circle_area_func[3].set_color(GREEN_C)
+ circle_area_func[4].set_color(ORANGE)
+
+ circle_area = TexMobject("Area", "=", "\\pi", "r^2")
+ circle_area[0].set_color(YELLOW_C)
+ circle_area[2].set_color(BLUE_C)
+ circle_area[3].set_color(GREEN_C)
+
+ radius = Line(ORIGIN,2*RIGHT, color = RED_C)
+
+
+
+ braces_rect1 = Brace(rectangle, LEFT)
+ eq_text1 = braces_rect1.get_text("Length").set_color(YELLOW_C)
+ braces_rect2 = Brace(rectangle, UP)
+ eq_text2 = braces_rect2.get_text("Breadth").set_color(BLUE_C)
+
+ braces_square = Brace(square, LEFT)
+ braces_square_text = braces_square.get_text("Length").set_color(BLUE_C)
+
+ radius_text = TexMobject("r", color = GREEN_C).next_to(radius,UP)
+
+
+
+ self.play(ShowCreation(rectangle))
+ self.wait(1)
+ self.play(GrowFromCenter(braces_rect1),Write(eq_text1),GrowFromCenter(braces_rect2),Write(eq_text2))
+ self.wait(1)
+ self.play(Write(rectangle_area_func))
+ self.wait(1)
+ self.play(Transform(rectangle_area_func, rectangle_area))
+ self.wait(1)
+ self.play(FadeOut(braces_rect1),FadeOut(eq_text1),FadeOut(braces_rect2),FadeOut(eq_text2),FadeOut(rectangle_area_func))
+
+
+ self.play(Transform(rectangle, square))
+ self.wait(1)
+ self.play(GrowFromCenter(braces_square),Write(braces_square_text))
+ self.wait(1)
+ self.play(Write(square_area_func))
+ self.wait(1)
+ self.play(Transform(square_area_func, square_area))
+ self.wait(1)
+ self.play(FadeOut(braces_square),FadeOut(braces_square_text),FadeOut(square_area_func))
+
+
+ self.play(Transform(rectangle, circle))
+ self.wait(1)
+ self.play(ShowCreation(radius),Write(radius_text))
+ self.wait(1)
+ self.play(FadeOut(radius_text),FadeOut(radius))
+ self.wait(1)
+ self.play(Write(circle_area_func))
+ self.wait(1)
+ self.play(Transform(circle_area_func, circle_area))
+ self.wait(1)
+ self.play(FadeOut(circle_area_func))
+
+
+
+class Examples2(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ rectangle_x_y_0 = Polygon(np.array([-1,-2,0]),np.array([-1,2,0]),np.array([1,2,0]),np.array([1,-2,0]),np.array([-1,-2,0]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+ rectangle_x_y_3 = Polygon(np.array([-1,-2,3]),np.array([-1,2,3]),np.array([1,2,3]),np.array([1,-2,3]),np.array([-1,-2,3]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+
+ rectangle_y_z_1 = Polygon(np.array([1,-2,3]),np.array([1,2,3]),np.array([1,2,0]),np.array([1,-2,0]),np.array([1,-2,3]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+ rectangle_y_z_minus_1 = Polygon(np.array([-1,-2,3]),np.array([-1,2,3]),np.array([-1,2,0]),np.array([-1,-2,0]),np.array([-1,-2,3]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+
+ rectangle_x_z_2 = Polygon(np.array([1,2,3]),np.array([-1,2,3]),np.array([-1,2,0]),np.array([1,2,0]),np.array([1,2,3]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+ rectangle_x_z_minus_2 = Polygon(np.array([1,-2,3]),np.array([-1,-2,3]),np.array([-1,-2,0]),np.array([1,-2,0]),np.array([1,-2,3]), color = RED_E, fill_color = RED_C, fill_opacity = 0.1)
+
+ box = VGroup(rectangle_x_y_0, rectangle_x_y_3, rectangle_y_z_1, rectangle_y_z_minus_1, rectangle_x_z_2, rectangle_x_z_minus_2)
+
+ braces_rectangle_x_y_0 = Line(np.array([1,2,0]), np.array([1,-2,0]), color = BLUE_C)
+ braces_rectangle_x_y_0_text = TextMobject("Length").set_color(BLUE_C).move_to(np.array([2,-1,0]))
+
+ braces_rectangle_y_z_1 = Line(np.array([1,2,0]), np.array([1,2,3]), color = YELLOW_C)
+ braces_rectangle_y_z_1_text = TextMobject("Height").set_color(YELLOW_C).move_to(np.array([2,3.8,2]))
+
+ braces_rectangle_x_z_2 = Line(np.array([1,2,3]), np.array([-1,2,3]), color = PURPLE)
+ braces_rectangle_x_z_2_text = TextMobject("Breadth").set_color(PURPLE).move_to(np.array([0,3.8,3.3]))
+
+ box_area_func = TexMobject("Area =", "f(", "Length", ",", "Breadth", ",", "Height", ")").move_to(4*LEFT+3.5*UP).scale(0.6)
+ box_area_func[0].set_color(GREEN_C)
+ box_area_func[1].set_color(ORANGE)
+ box_area_func[2].set_color(BLUE_C)
+ box_area_func[4].set_color(PURPLE)
+ box_area_func[6].set_color(YELLOW_C)
+ box_area_func[7].set_color(ORANGE)
+
+ box_area_func_2 = TexMobject("Area =", "Length", "\\times", "Breadth", "\\times", "Height").move_to(4*LEFT+3.5*UP).scale(0.6)
+ box_area_func_2[0].set_color(GREEN_C)
+ box_area_func_2[1].set_color(BLUE_C)
+ box_area_func_2[3].set_color(PURPLE)
+ box_area_func_2[5].set_color(YELLOW_C)
+
+
+ self.set_camera_orientation(phi=70 * DEGREES, theta = 45*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(box), ShowCreation(braces_rectangle_x_y_0))
+ self.add_fixed_orientation_mobjects(braces_rectangle_x_y_0_text)
+ self.play(ShowCreation(braces_rectangle_y_z_1))
+ self.add_fixed_orientation_mobjects(braces_rectangle_y_z_1_text)
+ self.play(ShowCreation(braces_rectangle_x_z_2))
+ self.add_fixed_orientation_mobjects(braces_rectangle_x_z_2_text)
+ self.wait(2)
+
+ self.move_camera(phi=60* DEGREES,theta=80*DEGREES)
+ self.add_fixed_in_frame_mobjects(box_area_func)
+ self.play(Write(box_area_func))
+ self.wait()
+
+
+ self.play(ReplacementTransform(box_area_func,box_area_func_2))
+ self.add_fixed_in_frame_mobjects(box_area_func_2)
+
+
+ self.wait(3)
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file2_multivariable_func_respresentation.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file2_multivariable_func_respresentation.py new file mode 100644 index 0000000..d10ff0a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file2_multivariable_func_respresentation.py @@ -0,0 +1,98 @@ +from manimlib.imports import *
+
+class MultivariableFunc(Scene):
+ def construct(self):
+
+ topic = TextMobject("Multivariable Functions")
+ topic.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ topic.scale(1.5)
+
+ self.play(Write(topic))
+ self.wait()
+ self.play(FadeOut(topic))
+
+
+ #circle = Circle()
+ #circle.scale(3)
+
+ scalar_function = TextMobject("Scalar Valued Function")
+ scalar_function.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ scalar_function.scale(1.5)
+ scalar_function.move_to(2.5*UP)
+
+ rectangle = Rectangle(height = 2, width = 4)
+ rectangle.set_color(PURPLE)
+
+ eqn1 = TextMobject(r"f(x,y) = $x^2y$")
+ eqn1.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE)
+
+
+
+ number1 = TextMobject("(2,1)")
+ number1.move_to(2.5*UP+ 4*LEFT)
+ number1.scale(1.2)
+ number1.set_color(ORANGE)
+
+ output1 = TextMobject("4")
+ output1.scale(1.5)
+ output1.set_color(BLUE_C)
+ output1.move_to(3*RIGHT)
+
+ eqn1_1 = TextMobject(r"f(2,1) = $2^2(1)$")
+ eqn1_1.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE)
+
+
+ self.play(Write(eqn1),ShowCreation(rectangle))
+ self.wait()
+ self.play(ApplyMethod(number1.move_to, 3*LEFT))
+ self.play(FadeOut(number1))
+ self.play(Transform(eqn1, eqn1_1))
+ self.wait()
+ self.play(ApplyMethod(output1.move_to, 2.5*DOWN+4*RIGHT))
+ self.wait()
+ self.play(Write(scalar_function))
+ self.play(FadeOut(output1), FadeOut(scalar_function), FadeOut(eqn1))
+
+
+ vector_function = TextMobject("Vector Valued Function")
+ vector_function.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ vector_function.scale(1.5)
+ vector_function.move_to(2.5*UP)
+
+
+ eqn2 = TextMobject(r"f(x,y,z) = $ \begin{bmatrix} x^2y \\ 2yz \end{bmatrix}$")
+ eqn2.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ number2 = TextMobject("(2,1,3)")
+ number2.move_to(2.5*UP+ 4*LEFT)
+ number2.scale(1.2)
+ number2.set_color(ORANGE)
+
+ output2 = TextMobject(r"$ \begin{bmatrix} 4 \\ 6 \end{bmatrix}$")
+ #output2.scale(1.5)
+ output2.set_color(BLUE_C)
+ output2.move_to(3*RIGHT)
+
+ #eqn2_1 = TextMobject(r"f(2,1,3) = $2^2(1) + 2(1)(3)$")
+ #eqn2_1.set_color(YELLOW)
+
+ #eqn2_2 = TextMobject(r"f(2,1,3) = $2 + 6$")
+ #eqn2_2.set_color(YELLOW)
+
+
+ self.play(Write(eqn2))
+
+ self.wait()
+ self.play(ApplyMethod(number2.move_to, 3*LEFT))
+ self.play(FadeOut(number2))
+
+ #self.play(Transform(eqn2, eqn2_1))
+ #self.wait(1)
+ #self.play(Transform(eqn2, eqn2_2))
+ #self.wait(1)
+
+ self.play(ApplyMethod(output2.move_to, 2.5*DOWN+4*RIGHT))
+ self.wait()
+ self.play(Write(vector_function))
+ self.play(FadeOut(output2),FadeOut(eqn2), FadeOut(vector_function), FadeOut(rectangle))
+ self.wait()
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py new file mode 100644 index 0000000..86239ae --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file3_sphere.py @@ -0,0 +1,177 @@ +from manimlib.imports import *
+
+class Sphere(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+ text3d = TextMobject(r"$f(x,y) \rightarrow Point(x,y,z)$")
+ text3d1 = TextMobject(r"$f(x,y) \rightarrow Point(x,y, \sqrt{r^2 - x^2 - y^2})$")
+ self.add_fixed_in_frame_mobjects(text3d)
+ text3d.scale(0.7)
+ text3d1.scale(0.7)
+ text3d.to_corner(UL)
+ text3d1.to_corner(UL)
+ text3d.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ text3d1.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ self.play(Write(text3d))
+ self.wait(1)
+
+ self.play(Transform(text3d,text3d1))
+ self.add_fixed_in_frame_mobjects(text3d1)
+ self.play(FadeOut(text3d))
+
+ sphere = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*np.cos(u)
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI,checkerboard_colors=[RED_D, RED_E],
+ resolution=(15, 32)).scale(1)
+
+
+ #Experiment with circles by changing difference value of u and v
+ '''
+ sphere_points = [np.array([2*np.sin(u*DEGREES)*np.cos(v*DEGREES), 2*np.sin(u*DEGREES)*np.sin(v*DEGREES), 2*np.cos(u*DEGREES)]) for u in range(0, 185, 5) for v in range(0, 365, 5)]
+
+ sphere_spheres = [Dot().move_to(pts) for pts in sphere_points]
+
+ sphere = VGroup(*sphere_spheres)
+ '''
+
+ self.set_camera_orientation(phi=75 * DEGREES, theta = 45*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ dot_x_y1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,0]))
+ dot_x_y_z1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,1.414]))
+ dot_x_y_z_1 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([-1,1,-1.414]))
+ line1 = DashedLine(np.array([-1,1,-1.414]), np.array([-1,1,1.414]), color = YELLOW_C)
+
+ point_x_y1 = TexMobject("(-1,1,0)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,0])).scale(0.5)
+ point_x_y_z1 = TexMobject("(-1,1,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
+ point_x_y_z1_2 = TexMobject("(-1,1,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
+ point_x_y_z1_3 = TexMobject("(-1,1,\\sqrt{4 - 1 - 1})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
+ point_x_y_z1_4 = TexMobject("(-1,1,\\sqrt{2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
+ point_x_y_z1_5 = TexMobject("(-1,1,1.414)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,1.414])).scale(0.5)
+
+ point_x_y_z_1 = TexMobject("(-1,1,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
+ point_x_y_z_1_2 = TexMobject("(-1,1,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
+ point_x_y_z_1_3 = TexMobject("(-1,1,\\sqrt{4 - 1 - 1})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
+ point_x_y_z_1_4 = TexMobject("(-1,1,\\sqrt{2})").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
+ point_x_y_z_1_5 = TexMobject("(-1,1,-1.414)").set_color(BLUE_C).move_to(np.array([-1.5,1.5,-1.414])).scale(0.5)
+
+
+ self.play(ShowCreation(dot_x_y1))
+ self.add_fixed_orientation_mobjects(point_x_y1)
+ self.play(ShowCreation(dot_x_y_z1), ShowCreation(dot_x_y_z_1), ShowCreation(line1))
+ self.add_fixed_orientation_mobjects(point_x_y_z1, point_x_y_z_1)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z1,point_x_y_z1_2), ReplacementTransform(point_x_y_z_1,point_x_y_z_1_2))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_2, point_x_y_z_1_2)
+
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z1_2,point_x_y_z1_3), ReplacementTransform(point_x_y_z_1_2,point_x_y_z_1_3))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_3, point_x_y_z_1_3)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z1_3,point_x_y_z1_4), ReplacementTransform(point_x_y_z_1_3,point_x_y_z_1_4))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_4, point_x_y_z_1_4)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z1_4,point_x_y_z1_5), ReplacementTransform(point_x_y_z_1_4,point_x_y_z_1_5))
+ self.add_fixed_orientation_mobjects(point_x_y_z1_5, point_x_y_z_1_5)
+
+
+
+ dot_x_y2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,0]))
+ dot_x_y_z2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,1.87]))
+ dot_x_y_z_2 = Dot().scale(0.75).set_fill(RED_C).move_to(np.array([0.5,-0.5,-1.87]))
+ line2 = DashedLine(np.array([0.5,-0.5,-1.87]), np.array([0.5,-0.5,1.87]), color = YELLOW_C)
+
+ point_x_y2 = TexMobject("(0.5,-0.5,0)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,0])).scale(0.5)
+ point_x_y_z2 = TexMobject("(0.5,-0.5,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
+ point_x_y_z2_2 = TexMobject("(0.5,-0.5,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
+ point_x_y_z2_3 = TexMobject("(0.5,-0.5,\\sqrt{4 - 0.25 - 0.25})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
+ point_x_y_z2_4 = TexMobject("(0.5,-0.5,\\sqrt{3.5})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
+ point_x_y_z2_5 = TexMobject("(0.5,-0.5,1.87)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,1.87])).scale(0.5)
+
+ point_x_y_z_2 = TexMobject("(0.5,-0.5,\\sqrt{r^2 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
+ point_x_y_z_2_2 = TexMobject("(0.5,-0.5,\\sqrt{4 - x^2 - y^2})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
+ point_x_y_z_2_3 = TexMobject("(0.5,-0.5,\\sqrt{4 - 0.25 - 0.25})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
+ point_x_y_z_2_4 = TexMobject("(0.5,-0.5,\\sqrt{3.5})").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
+ point_x_y_z_2_5 = TexMobject("(0.5,-0.5,-1.87)").set_color(BLUE_C).move_to(np.array([1.5,-1.5,-1.87])).scale(0.5)
+
+
+ self.play(ShowCreation(dot_x_y2))
+ self.add_fixed_orientation_mobjects(point_x_y2)
+ self.play(ShowCreation(dot_x_y_z2), ShowCreation(dot_x_y_z_2), ShowCreation(line2))
+ self.add_fixed_orientation_mobjects(point_x_y_z2, point_x_y_z_2)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z2,point_x_y_z2_2), ReplacementTransform(point_x_y_z_2,point_x_y_z_2_2))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_2, point_x_y_z_2_2)
+
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z2_2,point_x_y_z2_3), ReplacementTransform(point_x_y_z_2_2,point_x_y_z_2_3))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_3, point_x_y_z_2_3)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z2_3,point_x_y_z2_4), ReplacementTransform(point_x_y_z_2_3,point_x_y_z_2_4))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_4, point_x_y_z_2_4)
+ self.wait(0.5)
+ self.play(ReplacementTransform(point_x_y_z2_4,point_x_y_z2_5), ReplacementTransform(point_x_y_z_2_4,point_x_y_z_2_5))
+ self.add_fixed_orientation_mobjects(point_x_y_z2_5, point_x_y_z_2_5)
+
+ self.play(FadeOut(point_x_y1), FadeOut(point_x_y_z1_5), FadeOut(point_x_y_z_1_5), FadeOut(dot_x_y1), FadeOut(dot_x_y_z1), FadeOut(dot_x_y_z_1), FadeOut(line1))
+ self.play(FadeOut(point_x_y2), FadeOut(point_x_y_z2_5), FadeOut(point_x_y_z_2_5), FadeOut(dot_x_y2), FadeOut(dot_x_y_z2), FadeOut(dot_x_y_z_2), FadeOut(line2))
+
+
+
+
+ sphere_final = []
+
+ for u in range(0, 180, 15):
+ sphere_points1 = [np.array([2*np.sin(u*DEGREES)*np.cos(v*DEGREES), 2*np.sin(u*DEGREES)*np.sin(v*DEGREES), 2*np.cos(u*DEGREES)]) for v in range(0, 370, 10)]
+ sphere_dots1 = [Dot().scale(0.75).set_fill(RED_C).move_to(pts) for pts in sphere_points1]
+
+ sphere_points2 = [np.array([2*np.sin((u+5)*DEGREES)*np.cos(v*DEGREES), 2*np.sin((u+5)*DEGREES)*np.sin(v*DEGREES), 2*np.cos((u+5)*DEGREES)]) for v in range(0, 370, 10)]
+ sphere_dots2 = [Dot().scale(0.75).set_fill(RED_C).move_to(pts) for pts in sphere_points2]
+
+ sphere_points3 = [np.array([2*np.sin((u+10)*DEGREES)*np.cos(v*DEGREES), 2*np.sin((u+10)*DEGREES)*np.sin(v*DEGREES), 2*np.cos((u+10)*DEGREES)]) for v in range(0, 370, 10)]
+ sphere_dots3 = [Dot().scale(0.75).set_fill(RED_C).move_to(pts) for pts in sphere_points3]
+
+ sphere_final = sphere_final + sphere_dots1 + sphere_dots2 + sphere_dots3
+
+ sphere_dots = sphere_dots1 + sphere_dots2 + sphere_dots3
+
+ sphere_with_dots = VGroup(*sphere_dots)
+ self.play(ShowCreation(sphere_with_dots))
+
+ sphere_final_with_dots = VGroup(*sphere_final)
+
+
+ self.begin_ambient_camera_rotation(rate=0.5)
+ self.wait(3)
+ self.play(ReplacementTransform(sphere_final_with_dots, sphere))
+ self.wait(5)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file4_vectorvf_sine.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file4_vectorvf_sine.py new file mode 100644 index 0000000..06e225e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file4_vectorvf_sine.py @@ -0,0 +1,91 @@ +from manimlib.imports import *
+
+class SineVectors(GraphScene):
+ CONFIG = {
+ "x_min": 0,
+ "x_max": 10,
+ "y_min": -1,
+ "y_max": 1,
+ "graph_origin": ORIGIN+4*LEFT,
+ #"x_labeled_nums": list(range(-5, 6)),
+ #"y_labeled_nums": list(range(0, 5)),
+ }
+ 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)
+
+ self.setup_axes(animate = True)
+
+
+ sine1 = self.get_graph(lambda x : np.sin(x), x_min = 0, x_max = 1.575, color = GREEN)
+
+ point1 = Dot().shift(self.graph_origin+1*YTD*UP + 1.575*XTD*RIGHT)
+ point1_lab = TextMobject(r"$t = (\frac{\pi}{2})$")
+ point1_lab.scale(0.7)
+ point1_lab.next_to(point1, UP)
+
+ vector1 = Arrow(self.graph_origin, self.graph_origin+1*YTD*UP + 1.575*XTD*RIGHT, buff=0.1, color = RED)
+ vector1_lab = TextMobject(r"$r(\frac{\pi}{2})$", color = RED)
+ vector1_lab.move_to(self.graph_origin+1.5*XTD*RIGHT+ 0.5*YTD*UP)
+
+ self.play(GrowArrow(vector1),Write(vector1_lab))
+ self.play(ShowCreation(point1), Write(point1_lab))
+ self.play(ShowCreation(sine1))
+ self.wait(1)
+
+
+ sine2 = self.get_graph(lambda x : np.sin(x), x_min = 1.575, x_max = 3.15, color = GREEN)
+
+ point2 = Dot().shift(self.graph_origin+3.15*XTD*RIGHT)
+ point2_lab = TextMobject(r"$t = (\pi)$")
+ point2_lab.scale(0.7)
+ point2_lab.next_to(point2, UP+RIGHT)
+
+ vector2 = Arrow(self.graph_origin, self.graph_origin+3.15*XTD*RIGHT, buff=0.1, color = BLUE)
+ vector2_lab = TextMobject(r"$r(\pi)$", color = BLUE)
+ vector2_lab.move_to(self.graph_origin+1.5*XTD*RIGHT+ 0.15*YTD*UP)
+
+ self.play(GrowArrow(vector2),Write(vector2_lab))
+ self.play(ShowCreation(point2), Write(point2_lab))
+ self.play(ShowCreation(sine2))
+ self.wait(1)
+
+
+ sine3 = self.get_graph(lambda x : np.sin(x), x_min = 3.15, x_max = 4.725, color = GREEN)
+
+ point3 = Dot().shift(self.graph_origin+1*YTD*DOWN + 4.725*XTD*RIGHT)
+ point3_lab = TextMobject(r"$t = (\frac{3\pi}{2})$")
+ point3_lab.scale(0.7)
+ point3_lab.next_to(point3, DOWN)
+
+ vector3 = Arrow(self.graph_origin, self.graph_origin+1*YTD*DOWN + 4.725*XTD*RIGHT, buff=0.1, color = YELLOW_C)
+ vector3_lab = TextMobject(r"$r(\frac{3\pi}{2})$", color = YELLOW_C)
+ vector3_lab.move_to(self.graph_origin+2*XTD*RIGHT+ 0.7*YTD*DOWN)
+
+ self.play(GrowArrow(vector3),Write(vector3_lab))
+ self.play(ShowCreation(point3), Write(point3_lab))
+ self.play(ShowCreation(sine3))
+ self.wait(1)
+
+
+ sine4 = self.get_graph(lambda x : np.sin(x), x_min = 4.725, x_max = 6.3, color = GREEN)
+
+ point4 = Dot().shift(self.graph_origin+6.3*XTD*RIGHT)
+ point4_lab = TextMobject(r"$t = (2\pi)$")
+ point4_lab.scale(0.7)
+ point4_lab.next_to(point4, UP+RIGHT)
+
+ vector4 = Arrow(self.graph_origin, self.graph_origin+6.3*XTD*RIGHT, buff=0.1, color = PURPLE)
+ vector4_lab = TextMobject(r"$r(2\pi)$", color = PURPLE)
+ vector4_lab.move_to(self.graph_origin+4.5*XTD*RIGHT+ 0.15*YTD*DOWN)
+
+ self.play(GrowArrow(vector4),Write(vector4_lab))
+ self.play(ShowCreation(point4), Write(point4_lab))
+ self.play(ShowCreation(sine4))
+ self.wait(3)
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file5_vectorvf_helix.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file5_vectorvf_helix.py new file mode 100644 index 0000000..fc151ac --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file5_vectorvf_helix.py @@ -0,0 +1,92 @@ +from manimlib.imports import *
+
+class Helix(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+ helix1=ParametricFunction(
+ lambda u : np.array([
+ 1.5*np.cos(u),
+ 1.5*np.sin(u),
+ u/4
+ ]),color=PURPLE,t_min=-TAU,t_max=TAU,
+ )
+
+ helix2=ParametricFunction(
+ lambda u : np.array([
+ 2*np.cos(u),
+ 2*np.sin(u),
+ u/2
+ ]),color=GREEN_C,t_min=-TAU,t_max=TAU,
+ )
+
+ function = TexMobject("f(", "r", ",", "\\theta", ")", "=", "[", "r", "\\cos", "\\theta", ",", "r", "\\sin" ,"\\theta", ",", "h" ,"\\theta", "]" ).scale(0.6).to_corner(UL)
+ function.set_color_by_tex(r"\theta", BLUE_C)
+ function.set_color_by_tex(r"r", RED_C)
+ function.set_color_by_tex(r"\cos", GREEN_C)
+ function.set_color_by_tex(r"\sin", YELLOW_C)
+ function[0].set_color(ORANGE)
+ function[4].set_color(ORANGE)
+
+
+ self.add_fixed_in_frame_mobjects(function)
+
+ self.set_camera_orientation(phi=60*DEGREES, theta = 45*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+
+ dot1 = Dot().rotate(PI/2).set_color(RED_C)
+ alpha1 = ValueTracker(0)
+ vector1 = self.get_vector(alpha1.get_value(),helix1)
+ dot1.add_updater(lambda m: m.move_to(vector1.get_end()))
+ self.play(
+ ShowCreation(helix1),
+ GrowFromCenter(dot1),
+ GrowArrow(vector1)
+ )
+ vector1.add_updater(
+ lambda m: m.become(
+ self.get_vector(alpha1.get_value()%1,helix1)
+ )
+ )
+ self.add(vector1,dot1)
+ self.play(alpha1.increment_value, 1, run_time=10, rate_func=linear)
+
+
+ self.play(FadeOut(vector1), FadeOut(dot1))
+ self.play(ReplacementTransform(helix1, helix2))
+
+
+ dot2 = Dot().rotate(PI/2).set_color(RED_C)
+ alpha2 = ValueTracker(0)
+ vector2 = self.get_vector(alpha2.get_value(),helix2)
+ dot2.add_updater(lambda m: m.move_to(vector2.get_end()))
+ self.play(
+ ShowCreation(helix2),
+ GrowFromCenter(dot2),
+ GrowArrow(vector2)
+ )
+ vector2.add_updater(
+ lambda m: m.become(
+ self.get_vector(alpha2.get_value()%1,helix2)
+ )
+ )
+ self.add(vector2,dot2)
+ self.play(alpha2.increment_value, 1, run_time=10, rate_func=linear)
+ self.wait()
+
+
+
+ def get_vector(self, proportion, curve):
+ vector = Line(np.array([0,0,0]), curve.point_from_proportion(proportion), color = YELLOW_C, buff=0)
+ return vector
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file6_derivative_vectorvf.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file6_derivative_vectorvf.py new file mode 100644 index 0000000..466e389 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/file6_derivative_vectorvf.py @@ -0,0 +1,247 @@ +from manimlib.imports import *
+
+class Derivative(GraphScene):
+ CONFIG = {
+ "x_min": 0,
+ "x_max": 3,
+ "y_min": 0,
+ "y_max": 5,
+ "graph_origin": ORIGIN+6*LEFT+3*DOWN,
+ "x_axis_width": 6,
+ "x_labeled_nums": list(range(0, 4)),
+ "y_labeled_nums": list(range(0, 6)),
+ }
+ 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)
+
+ self.setup_axes(animate = True)
+
+ graph = self.get_graph(lambda x : x*x, x_min = 0.5, x_max = 2, color = GREEN)
+
+ point1 = Dot().shift(self.graph_origin+0.25*YTD*UP + 0.5*XTD*RIGHT)
+ point1_lab = TextMobject(r"$t = a$")
+ point1_lab.scale(0.7)
+ point1_lab.next_to(point1, RIGHT)
+
+ point2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+4*YTD*UP)
+ point2_lab = TextMobject(r"$t = b$")
+ point2_lab.scale(0.7)
+ point2_lab.next_to(point2, RIGHT)
+
+
+ vector1 = Arrow(self.graph_origin, self.graph_origin+1*YTD*UP + 1*XTD*RIGHT, buff=0.02, color = RED)
+ vector1_lab = TextMobject(r"$\vec r(t)$", color = RED)
+ vector1_lab.move_to(self.graph_origin+1.2*XTD*RIGHT+ 0.75*YTD*UP)
+ vector1_lab.scale(0.8)
+
+ vector2 = Arrow(self.graph_origin, self.graph_origin+2.25*YTD*UP + 1.5*XTD*RIGHT, buff=0.02, color = YELLOW_C)
+ vector2_lab = TextMobject(r"$\vec r(t + h)$", color = YELLOW_C)
+ vector2_lab.move_to(self.graph_origin+0.5*XTD*RIGHT+ 2*YTD*UP)
+ vector2_lab.scale(0.8)
+
+ vector3 = Arrow(self.graph_origin+1*YTD*UP + 1*XTD*RIGHT, self.graph_origin+2.25*YTD*UP + 1.5*XTD*RIGHT, buff=0.02, color = PINK)
+ vector3_lab = TextMobject(r"$\vec r(t + h) - \vec r(t)$", color = PINK)
+ vector3_lab.move_to(self.graph_origin+2*XTD*RIGHT+ 1.5*YTD*UP)
+ vector3_lab.scale(0.8)
+
+
+ self.play(ShowCreation(graph))
+ self.play(ShowCreation(point1), Write(point1_lab))
+ self.play(ShowCreation(point2), Write(point2_lab))
+
+ self.play(GrowArrow(vector1),Write(vector1_lab))
+ self.play(GrowArrow(vector2),Write(vector2_lab))
+ self.play(GrowArrow(vector3),Write(vector3_lab))
+ self.wait(1)
+
+ self.display_text()
+
+ self.play(ApplyMethod(vector3_lab.move_to,(self.graph_origin+2.3*XTD*RIGHT+ 2.2*YTD*UP)))
+
+ vector4 = Arrow(self.graph_origin+1*YTD*UP + 1*XTD*RIGHT, self.graph_origin+1*YTD*UP + 1.5*XTD*RIGHT, buff=0.02, color = PURPLE)
+ vector4_lab = TextMobject(r"$dx$", color = PURPLE)
+ vector4_lab.move_to(self.graph_origin+1.7*XTD*RIGHT+ 0.8*YTD*UP)
+ vector4_lab.scale(0.7)
+
+ vector5 = Arrow(self.graph_origin+1*YTD*UP + 1.5*XTD*RIGHT, self.graph_origin+2.25*YTD*UP + 1.5*XTD*RIGHT, buff=0.02, color = ORANGE)
+ vector5_lab = TextMobject(r"$dy$", color = ORANGE)
+ vector5_lab.move_to(self.graph_origin+1.7*XTD*RIGHT+ 1.4*YTD*UP)
+ vector5_lab.scale(0.7)
+
+ self.play(GrowArrow(vector4),Write(vector4_lab))
+ self.play(GrowArrow(vector5),Write(vector5_lab))
+ self.wait(2)
+
+
+
+ def display_text(self):
+ text1 = TextMobject(r"$\vec r(t)$",r"+", r"$\vec r(t + h) - \vec r(t)$")
+ text1[0].set_color(RED)
+ text1[2].set_color(PINK)
+ text1.scale(0.7)
+
+ text2 = TextMobject(r"$\vec r(t + h)$", color = YELLOW_C)
+ text2.scale(0.7)
+
+ text3 = TextMobject(r"$ \vec r(t + h) - \vec r(t)$", color = PINK)
+ text3.scale(0.7)
+
+ text4 = TextMobject(r"[", r"$x(t+h)$", r"$\vec i$", r"+", r"$y(t+h)$", r"$\vec j$", r"$] - [$", r"$x(t)$", r"$\vec i$", r"+", r"y(t)", r"$\vec j$", r"]")
+ text4.set_color_by_tex(r"\vec i", BLUE)
+ text4.set_color_by_tex(r"\vec j", GREEN)
+ text4[1].set_color(YELLOW_C)
+ text4[4].set_color(YELLOW_C)
+ text4[-6].set_color(RED)
+ text4[-3].set_color(RED)
+ text4.scale(0.7)
+
+ text5 = TextMobject(r"$[x(t+h) - x(t)]$", r"$\vec i$", r"+", r"$[y(t+h) + y(t)]$", r"$\vec j$")
+ text5.set_color_by_tex(r"\vec i", BLUE)
+ text5.set_color_by_tex(r"\vec j", GREEN)
+ text5[0].set_color(PURPLE)
+ text5[3].set_color(ORANGE)
+ text5.scale(0.7)
+
+ text6 = TextMobject(r"$\frac{[\vec r(t + h) - \vec r(t)]}{h}$", r"=", r"$\frac{[x(t+h) - x(t)]}{h}$", r"$\vec i$", r"+", r"$\frac{[y(t+h) + y(t)]}{h}$", r"$\vec j$")
+ text6.set_color_by_tex(r"\vec i", BLUE)
+ text6.set_color_by_tex(r"\vec j", GREEN)
+ text6[0].set_color(PINK)
+ text6[2].set_color(PURPLE)
+ text6[-2].set_color(ORANGE)
+ text6.scale(0.8)
+
+ text7 = TextMobject(r"$\lim_{h \rightarrow 0}$", r"$\frac{[\vec r(t + h) - \vec r(t)]}{h}$", r"=", r"$\lim_{h \rightarrow 0}$", r"$\frac{[x(t+h) - x(t)]}{h}$", r"$\vec i$", r"+", r"$\lim_{h \rightarrow 0}$", r"$\frac{[y(t+h) + y(t)]}{h}$", r"$\vec j$")
+ text7.set_color_by_tex(r"\vec i", BLUE)
+ text7.set_color_by_tex(r"\vec j", GREEN)
+ text7[1].set_color(PINK)
+ text7[4].set_color(PURPLE)
+ text7[-2].set_color(ORANGE)
+ text7.scale(0.6)
+
+ text8 = TextMobject(r"$\vec r'(t)$", r"=",r"$\vec x'(t)$", r"$\vec i$", r"+", r"$\vec y'(t)$", r"$\vec j$")
+ text8.set_color_by_tex(r"\vec i", BLUE)
+ text8.set_color_by_tex(r"\vec j", GREEN)
+ text8[0].set_color(PINK)
+ text8[2].set_color(PURPLE)
+ text8[5].set_color(ORANGE)
+ text8.scale(0.7)
+
+ text9 = TextMobject(r"$\frac{d \vec r}{dt}$", r"=", r"$\frac{d \vec x}{dt}$", r"$\vec i$", r"+", r"$\frac{d \vec y}{dt}$", r"$\vec j$")
+ text9.set_color_by_tex(r"\vec i", BLUE)
+ text9.set_color_by_tex(r"\vec j", GREEN)
+ text9[0].set_color(PINK)
+ text9[2].set_color(PURPLE)
+ text9[5].set_color(ORANGE)
+ text9.scale(0.7)
+
+
+ text10 = TextMobject(r"$d \vec r$", r"=", r"$\frac{d \vec x}{dt}dt$", r"$\vec i$", r"+", r"$\frac{d \vec y}{dt}dt$", r"$\vec j$")
+ text10.set_color_by_tex(r"\vec i", BLUE)
+ text10.set_color_by_tex(r"\vec j", GREEN)
+ text10[0].set_color(PINK)
+ text10[2].set_color(PURPLE)
+ text10[5].set_color(ORANGE)
+ text10.scale(0.7)
+
+ text11 = TextMobject(r"$d \vec r$", r"=", r"$x'(t)dt$", r"$\vec i$", r"+", r"$y'(t)dt$", r"$\vec j$")
+ text11.set_color_by_tex(r"\vec i", BLUE)
+ text11.set_color_by_tex(r"\vec j", GREEN)
+ text11[0].set_color(PINK)
+ text11[2].set_color(PURPLE)
+ text11[5].set_color(ORANGE)
+ text11.scale(0.7)
+
+ text12 = TextMobject(r"$d \vec r$", r"=", r"$dx$", r"$\vec i$", r"+", r"$dy$", r"$\vec j$")
+ text12.set_color_by_tex(r"\vec i", BLUE)
+ text12.set_color_by_tex(r"\vec j", GREEN)
+ text12[0].set_color(PINK)
+ text12[2].set_color(PURPLE)
+ text12[5].set_color(ORANGE)
+ text12.scale(0.7)
+
+
+ text1.move_to(1*UP+2.7*RIGHT)
+ text2.move_to(1*UP+2.7*RIGHT)
+ text3.move_to(1*UP+2.7*RIGHT)
+ text4.move_to(1*UP+2.7*RIGHT)
+ text5.move_to(1*UP+2.7*RIGHT)
+ text6.move_to(1*UP+2.7*RIGHT)
+ text7.move_to(1*UP+2.5*RIGHT)
+ text8.move_to(1*UP+2.7*RIGHT)
+ text9.move_to(1*UP+2.7*RIGHT)
+ text10.move_to(1*UP+2.7*RIGHT)
+ text11.move_to(1*UP+2.7*RIGHT)
+ text12.move_to(1*UP+2.7*RIGHT)
+
+ brace1 = Brace(text7[0:2], DOWN, buff = SMALL_BUFF)
+ brace2 = Brace(text7[3:6], UP, buff = SMALL_BUFF)
+ brace3 = Brace(text7[7:], DOWN, buff = SMALL_BUFF)
+ t1 = brace1.get_text(r"$\vec r'(t)$")
+ t1.set_color(PINK)
+
+ t2 = brace2.get_text(r"$\vec x'(t)$")
+ t2.set_color(PURPLE)
+
+ t3 = brace3.get_text(r"$\vec y'(t)$")
+ t3.set_color(ORANGE)
+
+
+ self.play(Write(text1))
+ self.play(Transform(text1, text2))
+ self.wait(1)
+
+ self.play(Transform(text1, text3))
+ self.wait(1)
+
+ self.play(Transform(text1, text4))
+ self.wait(1)
+
+ self.play(Transform(text1, text5))
+ self.wait(1)
+
+ self.play(Transform(text1, text6))
+ self.wait(1)
+
+ self.play(Transform(text1, text7))
+ self.wait(1)
+
+ self.play(
+ GrowFromCenter(brace1),
+ FadeIn(t1),
+ )
+ self.wait()
+ self.play(
+ ReplacementTransform(brace1.copy(),brace2),
+ ReplacementTransform(t1.copy(),t2)
+ )
+ self.wait()
+ self.play(
+ ReplacementTransform(brace2.copy(),brace3),
+ ReplacementTransform(t2.copy(),t3)
+ )
+ self.wait()
+
+ self.play(FadeOut(brace1), FadeOut(t1), FadeOut(brace2), FadeOut(t2), FadeOut(brace3), FadeOut(t3),)
+ self.wait()
+
+ self.play(Transform(text1, text8))
+ self.wait(1)
+
+ self.play(Transform(text1, text9))
+ self.wait(1)
+
+ self.play(Transform(text1, text10))
+ self.wait(1)
+
+ self.play(Transform(text1, text11))
+ self.wait(1)
+
+ self.play(Transform(text1, text12))
+ self.wait(1)
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file1_multivar_func_examples.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file1_multivar_func_examples.gif Binary files differnew file mode 100644 index 0000000..43c3a42 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file1_multivar_func_examples.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file2_multivariable_func_respresentation.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file2_multivariable_func_respresentation.gif Binary files differnew file mode 100644 index 0000000..8c4506c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file2_multivariable_func_respresentation.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file3_sphere.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file3_sphere.gif Binary files differnew file mode 100644 index 0000000..3e35ec8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file3_sphere.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file4_vectorvf_sine.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file4_vectorvf_sine.gif Binary files differnew file mode 100644 index 0000000..215459e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file4_vectorvf_sine.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file5_vectorvf_helix.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file5_vectorvf_helix.gif Binary files differnew file mode 100644 index 0000000..c3d37f6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file5_vectorvf_helix.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file6_derivative_vectorvf.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file6_derivative_vectorvf.gif Binary files differnew file mode 100644 index 0000000..9ea94e4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-functions/gifs/file6_derivative_vectorvf.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/Limits_and_Continuity_of_Multivariable_Function_Quiz.pdf b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/Limits_and_Continuity_of_Multivariable_Function_Quiz.pdf Binary files differnew file mode 100644 index 0000000..99918e5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/Limits_and_Continuity_of_Multivariable_Function_Quiz.pdf diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/README.md new file mode 100644 index 0000000..c01ddc5 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/README.md @@ -0,0 +1,14 @@ +**file1_epsilon_delta_defn** +![file1_epsilon_delta_defn](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file1_epsilon_delta_defn.gif) + +**file2_limit_approach_point** +![file2_limit_approach_point](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file2_limit_approach_point.gif) + +**file3_limit_approach_point_3d** +![file3_limit_approach_point_3d](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file3_limit_approach_point_3d.gif) + +**file4_limit_different_point** +![file4_limit_different_point](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file4_limit_different_point.gif) + +**file5_continuity_func** +![file5_continuity_func](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file5_continuity_func.gif) diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file1_epsilon_delta_defn.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file1_epsilon_delta_defn.py new file mode 100644 index 0000000..803c122 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file1_epsilon_delta_defn.py @@ -0,0 +1,179 @@ +from manimlib.imports import *
+
+class EpsilonDelta(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+
+ sphere = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ 3*np.cos(u)
+ ]),u_min=0,u_max=PI/4,v_min=PI/2,v_max=PI,checkerboard_colors=[RED_D, RED_E],
+ resolution=(15, 32)).scale(1)
+
+
+ cylinder_z = ParametricSurface(
+ lambda u, v: np.array([
+ 0.25*np.cos(TAU * v),
+ 1.8* (1 - u),
+ 0.25*np.sin(TAU * v)
+
+ ]),
+ checkerboard_colors=[YELLOW_C, YELLOW_E], resolution=(6, 32)).fade(0.2).rotate(PI/4).move_to(np.array([-0.65,0.65,2.54]))
+
+
+ cylinder_x = ParametricSurface(
+ lambda u, v: np.array([
+ 0.3*np.cos(TAU * v)-1,
+ 0.3*np.sin(TAU * v)+1,
+ 2.6*(1 - u)
+ ]),
+ checkerboard_colors=[BLUE_C, BLUE_E], resolution=(6, 32)).fade(0.2)
+
+
+ delta_circle = Circle(radius= 0.3, color = BLACK).shift(1*LEFT+1*UP).set_fill(GREEN_E, opacity = 0.5)
+
+ epsilon_circle = [np.array([0.25*np.cos(i*DEGREES),0,0.25*np.sin(i*DEGREES)]) for i in range(361)]
+
+ epsilon_circle_polygon = Polygon(*epsilon_circle, color = RED_E, fill_color = RED_E, fill_opacity = 0.5).rotate(PI/4).move_to(np.array([0,0,2.54]))
+
+
+ dot_circle = Dot().move_to(np.array([-1,1,0])).set_fill("#000080")
+
+ dot_surface = Dot().rotate(-PI/4).scale(1.5).move_to(np.array([-1.2,1.2,2.7])).set_fill("#000080")
+
+ dot_L_epsilon1 = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).rotate(PI/4).move_to(np.array([0,0,2.3]))
+
+ dot_L_epsilon2 = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).rotate(PI/4).move_to(np.array([0,0,2.8]))
+
+ dot_L = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#006400", fill_color = "#006400", fill_opacity = 1).rotate(PI/4).move_to(np.array([0,0,2.54]))
+
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.set_camera_orientation(phi=75*DEGREES,theta=135*DEGREES)
+ #self.set_camera_orientation(phi=80*DEGREES,theta=45*DEGREES)
+
+
+ self.play(ShowCreation(sphere),ShowCreation(delta_circle), ShowCreation(dot_circle))
+
+ temp_circle_center = TextMobject(r"$(a,b,0)$").scale(0.6).set_color(BLUE_C).move_to(1.7*LEFT+1.1*UP)
+ self.add_fixed_orientation_mobjects(temp_circle_center)
+ self.wait()
+
+ delta_lab = TextMobject(r"$\delta$", r"$-$", "disk").scale(0.5).move_to(0.6*LEFT+1.7*UP)
+ delta_lab[0].set_color(PINK).scale(1.3)
+ delta_lab[1].set_color(ORANGE)
+ delta_lab[2].set_color(GREEN_E)
+
+ self.add_fixed_orientation_mobjects(delta_lab)
+
+ self.play(ShowCreation(dot_surface))
+
+ temp_curve_circle_center = TextMobject(r"$(a,b,L)$").scale(0.6).set_color("#006400").move_to(np.array([-2,1,2.7]))
+ self.add_fixed_orientation_mobjects(temp_curve_circle_center)
+
+
+ self.wait()
+ self.play(ShowCreation(cylinder_x), FadeOut(dot_surface))
+ self.wait()
+
+ self.move_camera(phi=0* DEGREES,theta=135*DEGREES)
+ self.wait()
+
+ self.move_camera(phi=80* DEGREES,theta=225*DEGREES)
+ self.wait()
+
+ self.play(FadeOut(delta_lab), ShowCreation(cylinder_z))
+ self.wait()
+
+ self.play(FadeOut(temp_circle_center), FadeOut(temp_curve_circle_center),ShowCreation(epsilon_circle_polygon))
+
+ self.move_camera(phi=80* DEGREES,theta=325*DEGREES)
+
+ dot_L_epsilon1_lab = TextMobject(r"$L$", r"$-$", r"$\epsilon$").scale(0.6).move_to(np.array([-0.4,-0.4,2.3]))
+ dot_L_epsilon1_lab[0].set_color("#D4108A")
+ dot_L_epsilon1_lab[1].set_color("#006400")
+ dot_L_epsilon1_lab[2].set_color("#4DC8A1").scale(1.5)
+
+ dot_L_epsilon2_lab = TextMobject(r"$L$", r"$+$", r"$\epsilon$").scale(0.6).move_to(np.array([-0.4,-0.4,2.8]))
+ dot_L_epsilon2_lab[0].set_color("#D4108A")
+ dot_L_epsilon2_lab[1].set_color("#006400")
+ dot_L_epsilon2_lab[2].set_color("#4DC8A1").scale(1.5)
+
+ dot_L_lab = TextMobject(r"$L$").scale(0.6).set_color("#D4108A").move_to(np.array([-0.4,-0.4,2.54]))
+
+
+ self.play(ShowCreation(dot_L_epsilon1), ShowCreation(dot_L), ShowCreation(dot_L_epsilon2))
+ self.add_fixed_orientation_mobjects(dot_L_epsilon1_lab, dot_L_epsilon2_lab, dot_L_lab)
+ self.wait(4)
+
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES)
+ self.wait(2)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ '''
+
+
+
+
+
+
+
+
+
+
+
+ delta_lab = TextMobject(r"$\delta - disk$")
+ delta_lab.scale(0.5)
+ delta_lab.set_color(PINK)
+
+ self.play(ShowCreation(circle_center))
+ self.add_fixed_in_frame_mobjects(temp_circle_center)
+ temp_circle_center.move_to(1.5*RIGHT)
+ self.play(Write(temp_circle_center))
+
+ self.play(ShowCreation(curve_circle_center))
+ self.add_fixed_in_frame_mobjects(temp_curve_circle_center)
+ temp_curve_circle_center.move_to(1.9*UP+1*RIGHT)
+ self.play(Write(temp_curve_circle_center))
+
+
+ self.add_fixed_in_frame_mobjects(delta_lab)
+ delta_lab.move_to(0.4*DOWN+1.7*RIGHT)
+ self.play(Write(delta_lab))
+
+
+
+
+
+ self.begin_ambient_camera_rotation(rate=0.2)
+
+ self.play(ShowCreation(circle), ShowCreation(line1), ShowCreation(line2))
+ self.play(ShowCreation(line3), ShowCreation(line4))
+ self.wait(8)
+ '''
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file2_limit_approach_point.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file2_limit_approach_point.py new file mode 100644 index 0000000..57d1d45 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file2_limit_approach_point.py @@ -0,0 +1,66 @@ +from manimlib.imports import *
+
+class Limit(GraphScene):
+ CONFIG = {
+ "x_min": 0,
+ "x_max": 4,
+ "y_min": 0,
+ "y_max": 4,
+ "graph_origin": ORIGIN + 3* DOWN+4*LEFT,
+ "x_labeled_nums": list(range(0, 4)),
+ "y_labeled_nums": list(range(0, 5)),
+ }
+ def construct(self):
+ topic = TextMobject("Different paths of approach to limit point")
+ topic.scale(1.5)
+ topic.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ self.play(Write(topic))
+ self.wait(1)
+ self.play(FadeOut(topic))
+
+
+
+ XTD = self.x_axis_width/(self.x_max- self.x_min)
+ YTD = self.y_axis_height/(self.y_max- self.y_min)
+
+ self.setup_axes(animate = True)
+
+ y_x = self.get_graph(lambda x : x, x_min = -1, x_max = 4)
+ y_x_lab = self.get_graph_label(y_x, label = r"y = x")
+
+ y_xsquare = self.get_graph(lambda x : x*x, x_min = -1, x_max = 4)
+ y_xsquare_lab = self.get_graph_label(y_xsquare, label = r"y = x^2")
+
+ y_1 = self.get_graph(lambda x : 1, x_min = -1, x_max = 4)
+ y_1_lab = self.get_graph_label(y_1, label = r"y = 1")
+
+ y_2minusx = self.get_graph(lambda x : 2 - x, x_min = -1, x_max = 4, color = RED)
+ y_2minusx_lab = self.get_graph_label(y_2minusx, label = r"y = 2 - x")
+
+ limit_point = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP)
+ limit_point_lab = TextMobject(r"(1,1)")
+ limit_point_lab.next_to(limit_point, DOWN)
+
+ self.play(ShowCreation(limit_point))
+ self.play(Write(limit_point_lab))
+ self.wait(1)
+
+ self.play(ShowCreation(y_x))
+ self.play(Write(y_x_lab))
+ self.wait(1)
+
+ self.play(ShowCreation(y_xsquare))
+ self.play(Write(y_xsquare_lab))
+ self.wait(1)
+
+ self.play(ShowCreation(y_1))
+ self.play(Write(y_1_lab))
+ self.wait(1)
+
+ self.play(ShowCreation(y_2minusx))
+ self.play(Write(y_2minusx_lab))
+ self.wait(1)
+
+
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file3_limit_approach_point_3d.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file3_limit_approach_point_3d.py new file mode 100644 index 0000000..f1007a4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file3_limit_approach_point_3d.py @@ -0,0 +1,152 @@ +from manimlib.imports import *
+
+class Limit(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ text3d = TextMobject(r"$f(x,y) = \frac{x - y}{x - 1}$")
+ self.add_fixed_in_frame_mobjects(text3d)
+
+ text3d.to_corner(UL)
+
+ text3d.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.play(Write(text3d))
+ self.wait(1)
+
+ limit_func = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ (3*np.sin(u)*np.cos(v) - 3*np.sin(u)*np.sin(v))/2*(3*np.sin(u)*np.cos(v) - 1)
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ limit_y_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ u,
+ 0
+ ]),color=GREEN_D,t_min=-3,t_max=3,
+ )
+
+ limit_y_1 =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 1,
+ 1/2
+ ]),color=BLUE_D,t_min=-3,t_max=3,
+ )
+
+ limit_y_x_2 =ParametricFunction(
+ lambda u : np.array([
+ u,
+ u*u,
+ (u - u*u)/2*(u - 1)
+ ]),color=RED_D,t_min=-3,t_max=3,
+ )
+
+ limit_y_2_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 2 - u,
+ 1
+ ]),color=YELLOW_D,t_min=-3,t_max=3,
+ )
+
+ plane_y_x = Polygon(np.array([-3,-3,-3]),np.array([3,3,-3]),np.array([3,3,3]),np.array([-3,-3,3]),np.array([-3,-3,-3]), color = GREEN_C, fill_color = GREEN_C, fill_opacity = 0.1)
+ plane_y_x_text = TextMobject(r"$y = x$", color = GREEN_C).move_to(np.array([5,0,3]))
+
+ plane_y_1 = Polygon(np.array([-3,1,-3]),np.array([3,1,-3]),np.array([3,1,3]),np.array([-3,1,3]),np.array([-3,1,-3]), color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1)
+ plane_y_1_text = TextMobject(r"$y = 1$", color = BLUE_C).move_to(np.array([5,0,2.5]))
+
+
+ #Creating plane y = x^2
+ ######
+ y_x_2 = []
+ y_x_2.append(np.array([2, 4, -3]))
+ y_x_2.append(np.array([2, 4, 3]))
+ y_x_2_1 = [np.array([i, i*i, 3]) for i in np.arange(1.9,-2.1, -0.1)]
+
+ y_x_2 = y_x_2 + y_x_2_1
+
+ y_x_2.append(np.array([-2, 4, 3]))
+ y_x_2.append(np.array([-2, 4, -3]))
+
+ y_x_2_2 = [np.array([i, i*i, -3]) for i in np.arange(-2,2.1, 0.1)]
+
+ y_x_2 = y_x_2 + y_x_2_2
+ #y_x_2.append(np.array([-3, 9, 0]))
+
+ plane_y_x_2 = Polygon(*y_x_2, color = RED_C, fill_color = RED_C, fill_opacity = 0.1)
+ plane_y_x_2_text = TextMobject(r"$y = x^2$", color = RED_C).move_to(np.array([5,0,2]))
+
+ ######
+
+ plane_y_2_x = Polygon(np.array([-3,5,-3]),np.array([3,-1,-3]),np.array([3,-1,3]),np.array([-3,5,3]),np.array([-3,5,-3]), color = YELLOW_C, fill_color = YELLOW_C, fill_opacity = 0.1)
+ plane_y_2_x_text = TextMobject(r"$y = 2 - x$", color = YELLOW_C).move_to(np.array([5,0,1.5]))
+
+ line_1_1 = Line(np.array([1,1,-3]), np.array([1,1,3]), color = PINK)
+
+ point = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).move_to(np.array([1,1,0]))
+ point_text = TextMobject(r"$(1,1,0)$", color = WHITE).scale(0.7).move_to(np.array([1.8,1,0]))
+
+
+
+
+ self.set_camera_orientation(phi=70 * DEGREES, theta = -95*DEGREES)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(limit_func))
+ self.wait(2)
+
+ self.play(ShowCreation(plane_y_x))
+ self.add_fixed_orientation_mobjects(plane_y_x_text)
+ self.play(ShowCreation(limit_y_x))
+ self.wait()
+
+ self.play(ShowCreation(plane_y_1))
+ self.add_fixed_orientation_mobjects(plane_y_1_text)
+ self.play(ShowCreation(limit_y_1))
+ self.wait()
+
+ self.play(ShowCreation(plane_y_x_2))
+ self.add_fixed_orientation_mobjects(plane_y_x_2_text)
+ self.play(ShowCreation(limit_y_x_2))
+ self.wait()
+
+ self.play(ShowCreation(plane_y_2_x))
+ self.add_fixed_orientation_mobjects(plane_y_2_x_text)
+ self.play(ShowCreation(limit_y_2_x))
+ self.wait()
+
+ self.play(ShowCreation(line_1_1))
+ self.wait()
+
+ self.play(ShowCreation(point))
+ self.add_fixed_orientation_mobjects(point_text)
+ self.wait()
+
+ self.play(FadeOut(plane_y_x_text), FadeOut(plane_y_1_text), FadeOut(plane_y_x_2_text), FadeOut(plane_y_2_x_text))
+
+ self.move_camera(phi=0* DEGREES,theta=-95*DEGREES)
+ self.wait(2)
+ self.play(FadeOut(plane_y_x), FadeOut(plane_y_1), FadeOut(plane_y_x_2), FadeOut(plane_y_2_x))
+ self.wait(3)
+
+ self.move_camera(phi=75* DEGREES,theta=-95*DEGREES)
+ self.wait(3)
+
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file4_limit_different_point.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file4_limit_different_point.py new file mode 100644 index 0000000..0a43def --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file4_limit_different_point.py @@ -0,0 +1,115 @@ +from manimlib.imports import *
+
+class DifferentPoint(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ text3d = TextMobject(r"$f(x,y) = \frac{x^2 - y^2}{x^2 + y^2}$")
+ self.add_fixed_in_frame_mobjects(text3d)
+
+ text3d.to_corner(UL)
+
+ text3d.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.play(Write(text3d))
+ self.wait(1)
+
+ limit_func = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ (np.cos(v)*np.cos(v) - np.sin(v)*np.sin(v))
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ limit_func_copy1 = limit_func.copy()
+ limit_func_copy2 = limit_func.copy()
+
+ limit_func_x = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ (np.cos(v)*np.cos(v) - np.sin(v)*np.sin(v))
+ ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ limit_func_y = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ (np.cos(v)*np.cos(v) - np.sin(v)*np.sin(v))
+ ]),u_min=0,u_max=PI,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ limit_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ 1
+ ]),color="#006400",t_min=-3,t_max=3,
+ )
+
+ limit_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ -1
+ ]),color="#000080",t_min=-3,t_max=3,
+ )
+
+ plane_x = Polygon(np.array([-3,0,-2]),np.array([3,0,-2]),np.array([3,0,2]),np.array([-3,0,2]),np.array([-3,0,-2]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane_x_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(1.7*UP + 3.8*RIGHT)
+
+ plane_y = Polygon(np.array([0,-3,-2]),np.array([0,3,-2]),np.array([0,3,2]),np.array([0,-3,2]),np.array([0,-3,-2]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane_y_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(1.7*UP + 3.8*RIGHT)
+
+ origin_x = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).move_to(np.array([0,0,0]))
+ origin_x_text = TextMobject(r"$(0,0,0)$", color = RED_C).scale(0.7).move_to(np.array([-0.6,0,-0.5]))
+
+ origin_y = Polygon(*[np.array([0,0.05*np.cos(i*DEGREES),0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).move_to(np.array([0,0,0]))
+ origin_y_text = TextMobject(r"$(0,0,0)$", color = RED_C).scale(0.7).move_to(np.array([0,-0.6,-0.5]))
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(limit_func))
+
+ self.move_camera(phi=80* DEGREES,theta=105*DEGREES)
+
+ self.play(ShowCreation(plane_x))
+ self.add_fixed_in_frame_mobjects(plane_x_text)
+ self.wait()
+ self.play(ReplacementTransform(limit_func, limit_func_x))
+ self.play(FadeOut(plane_x), FadeOut(plane_x_text), ShowCreation(origin_x))
+ self.add_fixed_orientation_mobjects(origin_x_text)
+ self.play(ShowCreation(limit_x))
+
+ self.move_camera(phi=80* DEGREES,theta=15*DEGREES)
+ self.wait(3)
+
+ self.play(FadeOut(origin_x), FadeOut(origin_x_text), FadeOut(limit_x), ReplacementTransform(limit_func_x, limit_func_copy1))
+ self.play(ShowCreation(plane_y))
+ self.add_fixed_in_frame_mobjects(plane_y_text)
+ self.wait()
+ self.play(ReplacementTransform(limit_func_copy1, limit_func_y))
+ self.play(FadeOut(plane_y), FadeOut(plane_y_text), ShowCreation(origin_y))
+ self.add_fixed_orientation_mobjects(origin_y_text)
+ self.play(ShowCreation(limit_y))
+
+ self.move_camera(phi=80* DEGREES,theta=75*DEGREES)
+ self.wait(3)
+
+ self.play(FadeOut(origin_y), FadeOut(origin_y_text), FadeOut(limit_y), ReplacementTransform(limit_func_y, limit_func_copy2))
+ self.wait(2)
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file5_continuity_func.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file5_continuity_func.py new file mode 100644 index 0000000..99159a4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/file5_continuity_func.py @@ -0,0 +1,115 @@ +from manimlib.imports import *
+
+class Continuity(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ text3d = TextMobject(r"$f(x,y) = \frac{3x^2y}{x^2 + y^2}$")
+ self.add_fixed_in_frame_mobjects(text3d)
+
+ text3d.to_corner(UL)
+
+ text3d.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.play(Write(text3d))
+ self.wait(1)
+
+
+ continuity_func = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ 9*np.sin(u)*np.cos(v)*np.cos(v)*np.sin(v)
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ continuity_func_copy1 = continuity_func.copy()
+ continuity_func_copy2 = continuity_func.copy()
+
+ continuity_func_x = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ 9*np.sin(u)*np.cos(v)*np.cos(v)*np.sin(v)
+ ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ continuity_func_y = ParametricSurface(
+ lambda u, v: np.array([
+ 3*np.sin(u)*np.cos(v),
+ 3*np.sin(u)*np.sin(v),
+ 9*np.sin(u)*np.cos(v)*np.cos(v)*np.sin(v)
+ ]),u_min=0,u_max=PI,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ continuity_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ 0
+ ]),color="#006400",t_min=-3,t_max=3,
+ )
+
+ continuity_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ 0
+ ]),color="#000080",t_min=-3,t_max=3,
+ )
+
+ plane_x = Polygon(np.array([-3,0,-3]),np.array([3,0,-3]),np.array([3,0,3]),np.array([-3,0,3]),np.array([-3,0,-3]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane_x_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(1.7*UP + 3.8*RIGHT)
+
+ plane_y = Polygon(np.array([0,-3,-3]),np.array([0,3,-3]),np.array([0,3,3]),np.array([0,-3,3]),np.array([0,-3,-3]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane_y_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(1.7*UP + 3.8*RIGHT)
+
+ origin_x = Polygon(*[np.array([0.05*np.cos(i*DEGREES),0,0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#000080", fill_color = "#000080", fill_opacity = 1).move_to(np.array([0,0,0]))
+ origin_x_text = TextMobject(r"$(0,0,0)$", color = RED_C).scale(0.7).move_to(np.array([-0.6,0,-0.5]))
+
+ origin_y = Polygon(*[np.array([0,0.05*np.cos(i*DEGREES),0.05*np.sin(i*DEGREES)]) for i in range(361)], color = "#006400", fill_color = "#006400", fill_opacity = 1).move_to(np.array([0,0,0]))
+ origin_y_text = TextMobject(r"$(0,0,0)$", color = RED_C).scale(0.7).move_to(np.array([0,-0.6,-0.5]))
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(continuity_func))
+
+ self.move_camera(phi=80* DEGREES,theta=105*DEGREES)
+
+ self.play(ShowCreation(plane_x))
+ self.add_fixed_in_frame_mobjects(plane_x_text)
+ self.wait()
+ self.play(ReplacementTransform(continuity_func, continuity_func_x))
+ self.play(FadeOut(plane_x), FadeOut(plane_x_text))
+ self.play(ShowCreation(continuity_x), ShowCreation(origin_x))
+ self.add_fixed_orientation_mobjects(origin_x_text)
+
+ self.move_camera(phi=80* DEGREES,theta=15*DEGREES)
+ self.wait(3)
+
+ self.play(FadeOut(origin_x), FadeOut(origin_x_text), FadeOut(continuity_x), ReplacementTransform(continuity_func_x, continuity_func_copy1))
+ self.play(ShowCreation(plane_y))
+ self.add_fixed_in_frame_mobjects(plane_y_text)
+ self.wait()
+ self.play(ReplacementTransform(continuity_func_copy1, continuity_func_y))
+ self.play(FadeOut(plane_y), FadeOut(plane_y_text))
+ self.play(ShowCreation(continuity_y), ShowCreation(origin_y))
+ self.add_fixed_orientation_mobjects(origin_y_text)
+
+ self.move_camera(phi=80* DEGREES,theta=75*DEGREES)
+ self.wait(3)
+
+ self.play(FadeOut(origin_y), FadeOut(origin_y_text), FadeOut(continuity_y), ReplacementTransform(continuity_func_y, continuity_func_copy2))
+ self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file1_epsilon_delta_defn.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file1_epsilon_delta_defn.gif Binary files differnew file mode 100644 index 0000000..2378bcf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file1_epsilon_delta_defn.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file2_limit_approach_point.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file2_limit_approach_point.gif Binary files differnew file mode 100644 index 0000000..3abd596 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file2_limit_approach_point.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file3_limit_approach_point_3d.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file3_limit_approach_point_3d.gif Binary files differnew file mode 100644 index 0000000..3e87cdd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file3_limit_approach_point_3d.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file4_limit_different_point.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file4_limit_different_point.gif Binary files differnew file mode 100644 index 0000000..9a831e4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file4_limit_different_point.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file5_continuity_func.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file5_continuity_func.gif Binary files differnew file mode 100644 index 0000000..2a0a61f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/multivariable-limits-and-continuity/gifs/file5_continuity_func.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/README.md new file mode 100644 index 0000000..c62dd51 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/README.md @@ -0,0 +1,23 @@ +**file1_partial_deriv_gas_law** +![file1_partial_deriv_gas_law](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif) + +**file2_partial_deriv_hill** +![file2_partial_deriv_hill](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif) + +**file3_partial_deriv_defn** +![file3_partial_deriv_defn](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif) + +**file4_partial_deriv_example** +![file4_partial_deriv_example](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif) + +**file5_partial_deriv_func_2maximas** +![file5_partial_deriv_func_2maximas](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif) + +**file6_clariant_rule** +![file6_clariant_rule](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif) + +**file7_partial_deriv_clariant_rule** +![file7_partial_deriv_clariant_rule](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif) + +**file8_chain_rule** +![file8_chain_rule](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif) diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py new file mode 100644 index 0000000..3d35c97 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file1_partial_deriv_gas_law.py @@ -0,0 +1,88 @@ +from manimlib.imports import *
+
+class GasLaw(Scene):
+ def construct(self):
+ gas_law = TextMobject(r"$P$", r"$V$", r"=", r"$n$", r"$R$", r"$T$").scale(1.5)
+ gas_law[0].set_color(BLUE_C)
+ gas_law[1].set_color(GREEN_C)
+ gas_law[3].set_color(RED_C)
+ gas_law[4].set_color(ORANGE)
+ gas_law[5].set_color(YELLOW_C)
+
+ gas_law_trans = TexMobject("V", "=", "{n", "R", "T", "\\over", "P}").scale(1.5)
+ gas_law_trans[0].set_color(GREEN_C)
+ gas_law_trans[2].set_color(RED_C)
+ gas_law_trans[3].set_color(ORANGE)
+ gas_law_trans[4].set_color(YELLOW_C)
+ gas_law_trans[6].set_color(BLUE_C)
+
+ gas_law_func = TexMobject("V", "=", "f(", "n", ",", "T", ",", "P", ")").scale(1.5)
+ gas_law_func[0].set_color(GREEN_C)
+ gas_law_func[2].set_color(ORANGE)
+ gas_law_func[3].set_color(RED_C)
+ gas_law_func[5].set_color(YELLOW_C)
+ gas_law_func[7].set_color(BLUE_C)
+ gas_law_func[8].set_color(ORANGE)
+
+ partial_gas_law_func = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "{\\partial", "\\over", "\\partial", "P}", "f(", r"n", ",", r"T", ",", r"P", r")").scale(1.5)
+ partial_gas_law_func.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_func.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_func[1].set_color(GREEN_C)
+ partial_gas_law_func[10].set_color(ORANGE)
+ partial_gas_law_func[11].set_color(RED_C)
+ partial_gas_law_func[13].set_color(YELLOW_C)
+ partial_gas_law_func[15].set_color(BLUE_C)
+ partial_gas_law_func[16].set_color(ORANGE)
+
+ partial_gas_law_trans = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "{\\partial", "\\over", "\\partial", "P}", "{n", "R", "T", "\\over", "P}").scale(1.5)
+ partial_gas_law_trans.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans[1].set_color(GREEN_C)
+ partial_gas_law_trans[10].set_color(RED_C)
+ partial_gas_law_trans[11].set_color(ORANGE)
+ partial_gas_law_trans[12].set_color(YELLOW_C)
+
+ partial_gas_law_trans2 = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "n", "R", "T", "{\\partial", "\\over", "\\partial", "P}", "P^{-1}",).scale(1.5)
+ partial_gas_law_trans2.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans2.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans2[1].set_color(GREEN_C)
+ partial_gas_law_trans2[6].set_color(RED_C)
+ partial_gas_law_trans2[7].set_color(ORANGE)
+ partial_gas_law_trans2[8].set_color(YELLOW_C)
+ partial_gas_law_trans2[-1].set_color(BLUE_C)
+
+ partial_gas_law_trans3 = TexMobject("{\\partial", "V","\\over", "\\partial", "P}", r"=", "n", "R", "T", "P^{-2}",).scale(1.5)
+ partial_gas_law_trans3.set_color_by_tex("\\partial", PINK)
+ partial_gas_law_trans3.set_color_by_tex("P}", BLUE_C)
+
+ partial_gas_law_trans3[1].set_color(GREEN_C)
+ partial_gas_law_trans3[6].set_color(RED_C)
+ partial_gas_law_trans3[7].set_color(ORANGE)
+ partial_gas_law_trans3[8].set_color(YELLOW_C)
+ partial_gas_law_trans3[9].set_color(BLUE_C)
+
+ framebox = SurroundingRectangle(partial_gas_law_trans3, color = PURPLE, buff = 0.3)
+
+
+
+ self.play(Write(gas_law))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_func))
+ self.wait()
+ self.play(Transform(gas_law, gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_func))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans2))
+ self.wait()
+ self.play(Transform(gas_law, partial_gas_law_trans3))
+ self.wait()
+ self.play(ShowCreation(framebox))
+ self.wait()
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py new file mode 100644 index 0000000..bfb7687 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file2_partial_deriv_hill.py @@ -0,0 +1,122 @@ +from manimlib.imports import *
+
+class Hill(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ function = ParametricSurface(
+ lambda u, v: np.array([
+ 1.2*np.sin(u)*np.cos(v),
+ 1.2*np.sin(u)*np.sin(v),
+ -1.2*1.2*np.sin(u)*np.sin(u)*(1+0.5*np.sin(v)*np.sin(v))+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ func_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ 2 - u*u
+ ]),color=RED_E,t_min=-1.2,t_max=1.2,
+ )
+
+ func_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ 2 - 1.5*u*u
+ ]),color=PINK,t_min=-1.2,t_max=1.2,
+ )
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=45 * DEGREES, theta = -20*DEGREES)
+
+ self.add(axes)
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(function))
+ self.wait()
+
+ self.move_camera(phi=60 * DEGREES, theta = 45*DEGREES)
+ #self.play(ShowCreation(func_x))
+
+ text_x = TextMobject("Slope of the hill along", r"$x$", "axis", color = YELLOW_C).scale(0.6).move_to(2.7*UP + 3.5*RIGHT)
+ text_x[1].set_color(PINK)
+
+
+ slope_text_x = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_x[0].set_color(BLUE_E)
+ slope_text_x.set_color_by_tex("\\partial",YELLOW_C)
+ slope_text_x.set_color_by_tex("f",RED_E)
+ slope_text_x[5].set_color(PINK)
+
+ self.add_fixed_in_frame_mobjects(text_x, slope_text_x)
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),func_x,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(func_x),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,func_x,scale=1.5)
+ )
+ )
+
+ self.add(vector_x,dot_x)
+
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ #self.move_camera(phi=60 * DEGREES, theta = 0*DEGREES)
+ self.play(FadeOut(vector_x), FadeOut(dot_x), FadeOut(func_x), FadeOut(text_x), FadeOut(slope_text_x))
+
+ text_y = TextMobject("Slope of the hill along", r"$y$", "axis", color = YELLOW_C).scale(0.6).move_to(2.7*UP + 3.5*RIGHT)
+ text_y[1].set_color(RED_C)
+
+
+ slope_text_y = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_y[0].set_color(BLUE_E)
+ slope_text_y.set_color_by_tex("\\partial",YELLOW_C)
+ slope_text_y.set_color_by_tex("f",PINK)
+ slope_text_y[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text_y, slope_text_y)
+
+ dot_y = Dot().rotate(PI/2).set_color(BLUE_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),func_y,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(func_y),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,func_y,scale=1.5)
+ )
+ )
+
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+ self.play(FadeOut(vector_y), FadeOut(dot_y), FadeOut(func_y), FadeOut(text_y), FadeOut(slope_text_y))
+ self.wait(2)
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = ORANGE, buff=0)
+ return vector
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py new file mode 100644 index 0000000..a25ca56 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file3_partial_deriv_defn.py @@ -0,0 +1,218 @@ +from manimlib.imports import *
+
+class PartialDeriv(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy1 = paraboloid.copy()
+ paraboloid_copy2 = paraboloid.copy()
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_x_copy = paraboloid_x.copy()
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ parabola1 =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ -(u*u) + 2
+ ]),color="#006400",t_min=-2,t_max=2,
+ )
+ parabola2 =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ -(u*u) + 2
+ ]),color=BLUE_C,t_min=-2,t_max=2,
+ )
+
+ plane1 = Polygon(np.array([-2.2,0,-2.5]),np.array([2.2,0,-2.5]),np.array([2.2,0,2.5]),np.array([-2.2,0,2.5]),np.array([-2.2,0,-2.5]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane1_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(2*UP + 3.3*RIGHT)
+
+ plane2 = Polygon(np.array([0,-2.2,-2.5]),np.array([0,2.2,-2.5]),np.array([0,2.2,2.5]),np.array([0,-2.2,2.5]),np.array([0,-2.2,-2.5]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane2_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(2*UP + 3.2*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = YELLOW_C).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(PINK)
+
+ dot1 =Sphere(radius=0.08).move_to(np.array([-1,0,1]))
+ dot1.set_fill(RED)
+ line1 = Line(np.array([-1.55, 0,0]), np.array([-0.4, 0,2.2]), color = RED)
+ lab_x = TextMobject(r"$f(x_0,y_0)$", color = RED).scale(0.7)
+ para_lab_x = TextMobject(r"$f(x,y_0)$", color = "#006400").scale(0.7)
+ tangent_line_x = TextMobject("Tangent Line", color = RED_C, buff = 0.4).scale(0.6).move_to(np.array([1.7*RIGHT +1.8*UP]))
+
+
+ text1 = TextMobject(r"$\frac{\partial f}{\partial x}\vert_{(x_0,y_0)} = \frac{d}{dx}$", r"$f(x,y_0)$", r"$\vert_{x=x_0}$").scale(0.6)
+ brace1 = Brace(text1[1], DOWN, buff = SMALL_BUFF, color = GREEN)
+ t1 = brace1.get_text("Just depends on x")
+ t1.scale(0.6)
+ t1.set_color(GREEN)
+
+
+ dot2 =Sphere(radius=0.08).move_to(np.array([0,1,1]))
+ dot2.set_fill(RED)
+ line2 = Line(np.array([0, 1.55,0]), np.array([0, 0.4,2.2]), color = RED)
+ lab_y = TextMobject(r"$f(x_0,y_0)$", color = RED).scale(0.7)
+ para_lab_y = TextMobject(r"$f(x_0,y)$", color = BLUE_C).scale(0.7)
+ tangent_line_y = TextMobject("Tangent Line", color = RED_C, buff = 0.4).scale(0.6).move_to(np.array([1.7*RIGHT +1.8*UP]))
+
+ text2 = TextMobject(r"$\frac{\partial f}{\partial y}\vert_{(x_0,y_0)} = \frac{d}{dy}$", r"$f(x_0,y)$", r"$\vert_{y=y_0}$").scale(0.6)
+ brace2 = Brace(text2[1], DOWN, buff = SMALL_BUFF, color = GREEN)
+ t2 = brace2.get_text("Just depends on y")
+ t2.scale(0.6)
+ t2.set_color(GREEN)
+
+ text3 = TextMobject(r"$= \lim_{h \to 0} \frac{f(x_0+h,y_0) - f(x_0,y_0)}{h}$").scale(0.6)
+
+ dot3 =Sphere(radius=0.08).move_to(np.array([-1.22,0,0.5]))
+ dot3.set_fill(YELLOW_C)
+ line3 = Line(np.array([-1.44,0,0]), np.array([-0.6,0,2.2]), color = YELLOW_C)
+ lab_line3 = TextMobject(r"$f(x_0+h,y_0)$", color = YELLOW_C).scale(0.7)
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=80 * DEGREES, theta = 20*DEGREES)
+ #self.begin_ambient_camera_rotation(rate=0.3)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ #self.add_fixed_orientation_mobjects(axis[2])
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=110*DEGREES)
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES)
+
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane1_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+
+ lab_x.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_x.move_to(np.array([1.3*LEFT +1.6*UP]))
+ self.wait()
+ self.play(FadeOut(plane1), FadeOut(plane1_text))
+ self.play(ShowCreation(parabola1))
+ self.add_fixed_in_frame_mobjects(para_lab_x)
+ self.play(ShowCreation(dot1))
+ self.add_fixed_in_frame_mobjects(lab_x)
+ #self.play(ShowCreation(dot1))
+ self.wait()
+ self.play(ShowCreation(line1))
+ self.add_fixed_in_frame_mobjects(tangent_line_x)
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(text1, brace1, t1)
+ grp1 = VGroup(text1, brace1, t1)
+ grp1.move_to(3*UP+3*RIGHT)
+ self.play(Write(text1),GrowFromCenter(brace1), FadeIn(t1))
+ self.wait()
+ self.play(FadeOut(parabola1), FadeOut(line1), FadeOut(lab_x), FadeOut(para_lab_x), FadeOut(dot1), FadeOut(tangent_line_x),FadeOut(grp1))
+
+
+
+
+ #self.move_camera(phi=80* DEGREES,theta=20*DEGREES)
+
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy1))
+ self.wait()
+ self.play(ShowCreation(plane2))
+ self.add_fixed_in_frame_mobjects(plane2_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy1, paraboloid_y))
+
+ lab_y.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_y.move_to(np.array([1.3*LEFT +1.6*UP]))
+ self.wait()
+ self.play(FadeOut(plane2), FadeOut(plane2_text))
+ self.play(ShowCreation(parabola2))
+ self.add_fixed_in_frame_mobjects(para_lab_y)
+ self.play(ShowCreation(dot2))
+ self.add_fixed_in_frame_mobjects(lab_y)
+ self.wait()
+ self.play(ShowCreation(line2))
+ self.add_fixed_in_frame_mobjects(tangent_line_y)
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(text2, brace2, t2)
+ grp2 = VGroup(text2, brace2, t2)
+ grp2.move_to(3*UP+3*RIGHT)
+ self.play(Write(text2),GrowFromCenter(brace2), FadeIn(t2))
+ self.wait()
+ self.play(FadeOut(parabola2), FadeOut(line2), FadeOut(lab_y), FadeOut(para_lab_y), FadeOut(dot2), FadeOut(tangent_line_y), FadeOut(grp2))
+ self.wait()
+
+
+ #self.move_camera(phi=80* DEGREES,theta=105*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy2))
+ self.wait()
+
+
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane1_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy2, paraboloid_x_copy))
+
+ lab_x.move_to(np.array([1.8*RIGHT +1.15*UP]))
+ para_lab_x.move_to(np.array([1.3*LEFT +1.6*UP]))
+ lab_line3.move_to(np.array([2.4*RIGHT +0.5*UP]))
+ self.wait()
+ self.play(FadeOut(plane1), FadeOut(plane1_text))
+ self.play(ShowCreation(parabola1))
+ self.add_fixed_in_frame_mobjects(para_lab_x)
+ self.play(ShowCreation(dot1))
+ self.add_fixed_in_frame_mobjects(lab_x)
+ self.play(ShowCreation(dot3))
+ self.add_fixed_in_frame_mobjects(lab_line3)
+ self.wait()
+ self.play(ShowCreation(line1))
+ self.add_fixed_in_frame_mobjects(tangent_line_x)
+ self.play(ShowCreation(line3))
+ self.wait()
+
+
+ self.add_fixed_in_frame_mobjects(text1,text3)
+ text1.move_to(3*UP+3*RIGHT)
+ text3.next_to(text1, DOWN)
+ self.play(Write(text1),Write(text3))
+ self.wait()
+ self.play(FadeOut(parabola1), FadeOut(line1), FadeOut(lab_x), FadeOut(line3), FadeOut(lab_line3), FadeOut(para_lab_x), FadeOut(dot1), FadeOut(dot3), FadeOut(tangent_line_x), FadeOut(text1), FadeOut(text3))
+ self.wait()
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py new file mode 100644 index 0000000..5712a62 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file4_partial_deriv_example.py @@ -0,0 +1,246 @@ +from manimlib.imports import *
+
+class PartialDerivX(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy = paraboloid.copy()
+
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+
+ parabola =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ -(u*u) + 2
+ ]),color="#006400",t_min=-2,t_max=2,
+ )
+
+ plane = Polygon(np.array([-2.2,0,-2.5]),np.array([2.2,0,-2.5]),np.array([2.2,0,2.5]),np.array([-2.2,0,2.5]),np.array([-2.2,0,-2.5]), color = GREEN, fill_color = GREEN, fill_opacity = 0.2)
+ plane_text = TextMobject(r"$y = 0$", color = GREEN_C).move_to(2*UP + 3*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = PINK).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ line = Line(np.array([-2,0,0]), np.array([2,0,0]), color = RED_C)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=95*DEGREES)
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES)
+ self.play(ShowCreation(plane))
+ self.add_fixed_in_frame_mobjects(plane_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+ self.play(FadeOut(plane), FadeOut(plane_text))
+ self.play(ShowCreation(parabola), ShowCreation(line))
+
+ text1 = TextMobject("Moving small", r"$dx$", r"steps").scale(0.6).move_to(3*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, BLUE, PURPLE)
+
+ text2 = TextMobject("Observing change in function, keeping", r"$y$", r"constant").scale(0.6).move_to(2.6*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ slope_text = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text[0].set_color(BLUE_E)
+ slope_text.set_color_by_tex("\\partial",PINK)
+ slope_text.set_color_by_tex("f","#006400")
+ slope_text[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text1, text2)
+ self.wait()
+ self.add_fixed_in_frame_mobjects(slope_text)
+ #add_fixed_orientation_mobjects
+
+
+ dot = Dot().rotate(PI/2).set_color(RED_C)
+ alpha = ValueTracker(0)
+ vector = self.get_tangent_vector(alpha.get_value(),parabola,scale=1.5)
+ dot.add_updater(lambda m: m.move_to(vector.get_center()))
+ self.play(
+ ShowCreation(parabola),
+ GrowFromCenter(dot),
+ GrowArrow(vector)
+ )
+ vector.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha.get_value()%1,parabola,scale=1.5)
+ )
+ )
+ self.add(vector,dot)
+ self.play(alpha.increment_value, 1, run_time=10, rate_func=linear)
+ self.wait()
+
+
+ '''
+ for i in np.arange(-2,2,0.2):
+ self.play(ReplacementTransform(Line(np.array([i,0,0]), np.array([i,0,-i*i + 2]), color = GREEN_C), Line(np.array([i+0.2,0,0]), np.array([i+0.2,0,-(i+0.2)**2 + 2]), color = GREEN_C)))
+ #self.wait()
+ '''
+
+ self.wait()
+ self.play(FadeOut(parabola), FadeOut(line), FadeOut(vector), FadeOut(dot), FadeOut(text1), FadeOut(text2), FadeOut(slope_text),FadeOut(surface_eqn))
+
+ #self.move_camera(phi=80* DEGREES,theta= 0*DEGREES)
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy))
+ self.wait()
+
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = BLUE_E, buff=0)
+ return vector
+
+
+class PartialDerivY(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy = paraboloid.copy()
+
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ -2*2*np.sin(u)*np.sin(u)+2
+ ]),u_min=0,u_max=PI/2,v_min=PI/2,v_max=3*PI/2,checkerboard_colors=[PINK, PURPLE],
+ resolution=(15, 32)).scale(1)
+
+
+ parabola =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ -(u*u) + 2
+ ]),color=YELLOW_C,t_min=-2,t_max=2,
+ )
+
+ plane = Polygon(np.array([0,-2.2,-2.5]),np.array([0,2.2,-2.5]),np.array([0,2.2,2.5]),np.array([0,-2.2,2.5]),np.array([0,-2.2,-2.5]), color = BLUE, fill_color = BLUE, fill_opacity = 0.2)
+ plane_text = TextMobject(r"$x = 0$", color = BLUE_C).move_to(2*UP + 3*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = 2- x^2 -y^2$", color = PINK).scale(0.6).move_to(np.array([3*LEFT +3*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ line = Line(np.array([0,-2,0]), np.array([0,2,0]), color = RED_C)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 45*DEGREES)
+
+ self.play(Write(paraboloid))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+ #self.move_camera(phi=80* DEGREES,theta=5*DEGREES)
+ self.play(ShowCreation(plane))
+ self.add_fixed_in_frame_mobjects(plane_text)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_y))
+ self.play(FadeOut(plane), FadeOut(plane_text))
+ self.play(ShowCreation(parabola), ShowCreation(line))
+
+ text1 = TextMobject("Moving small", r"$dy$", r"steps").scale(0.6).move_to(3*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, BLUE, PURPLE)
+
+ text2 = TextMobject("Observing change in function, keeping", r"$x$", r"constant").scale(0.6).move_to(2.6*UP + 3.5*RIGHT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ slope_text = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "y}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text[0].set_color("#006400")
+ slope_text.set_color_by_tex("\\partial",PINK)
+ slope_text.set_color_by_tex("f",YELLOW_C)
+ slope_text[5].set_color(RED_C)
+
+ self.add_fixed_in_frame_mobjects(text1, text2)
+ self.wait()
+ self.add_fixed_in_frame_mobjects(slope_text)
+
+ dot = Dot().rotate(PI/2).set_color(RED_C)
+ alpha = ValueTracker(0)
+ vector = self.get_tangent_vector(alpha.get_value(),parabola,scale=1.5)
+ dot.add_updater(lambda m: m.move_to(vector.get_center()))
+ self.play(
+ ShowCreation(parabola),
+ GrowFromCenter(dot),
+ GrowArrow(vector)
+ )
+ vector.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha.get_value()%1,parabola,scale=1.5)
+ )
+ )
+ self.add(vector,dot)
+ self.play(alpha.increment_value, 1, run_time=10, rate_func=linear)
+ self.wait()
+
+ '''
+ for i in np.arange(-2,2,0.2):
+ self.play(ReplacementTransform(Line(np.array([0,i,0]), np.array([0,i,-i*i + 2]), color = BLUE_C), Line(np.array([0,i+0.2,0]), np.array([0,i+0.2,-(i+0.2)**2 + 2]), color = BLUE_C)))
+ #self.wait()
+ '''
+
+
+ self.wait()
+ self.play(FadeOut(parabola), FadeOut(line), FadeOut(vector), FadeOut(dot), FadeOut(text1), FadeOut(text2), FadeOut(slope_text),FadeOut(surface_eqn))
+
+ #self.move_camera(phi=80* DEGREES,theta= 90*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy))
+ self.wait()
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector, coord_i + unit_vector, color = "#006400", buff=0)
+ return vector
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py new file mode 100644 index 0000000..7bbb9a7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file5_partial_deriv_func_2maximas.py @@ -0,0 +1,227 @@ +from manimlib.imports import *
+
+class MaximaMinima(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_copy1 = paraboloid.copy()
+ paraboloid_copy2 = paraboloid.copy()
+
+ paraboloid_x = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=PI,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ paraboloid_y = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=PI/2,v_max=3*PI/2, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ parabola_x_out =ParametricFunction(
+ lambda u : np.array([
+ u,
+ 0,
+ (u*u )*np.exp(1-u*u)
+ ]),color=RED_E,t_min=-3.5,t_max=3.5,
+ )
+
+ parabola_y_out =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ (3*u*u)*np.exp(1-u*u)
+ ]),color=PINK,t_min=-3.5,t_max=3.5,
+ )
+
+ plane1 = Polygon(np.array([-3.5,0,-3]),np.array([3.5,0,-3]),np.array([3.5,0,3]),np.array([-3.5,0,3]),np.array([-3.5,0,-3]), color = RED_C, fill_color = RED_C, fill_opacity = 0.2)
+ plane_text_x = TextMobject(r"$y = 0$", color = RED_C).move_to(2*UP + 4.5*RIGHT)
+
+ plane2 = Polygon(np.array([0,-3.5,-3]),np.array([0,3.5,-3]),np.array([0,3.5,3]),np.array([0,-3.5,3]),np.array([0,-3.5,-3]), color = PINK, fill_color = PINK, fill_opacity = 0.2)
+ plane_text_y = TextMobject(r"$x = 0$", color = PINK).move_to(2*UP + 4.5*RIGHT)
+
+ surface_eqn = TextMobject("Surface", r"$z = (x^2 + 3y^2)e^{(1 - x^2 - y^2)}$", color = YELLOW_C).scale(0.6).move_to(np.array([3.5*LEFT +3.5*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 45*DEGREES)
+
+ self.add(axes)
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(paraboloid))
+
+
+ #self.move_camera(phi=60 * DEGREES, theta = 45*DEGREES,run_time=3)
+
+
+ plane_x = Polygon(np.array([-3.5,2,-3]),np.array([3.5,2,-3]),np.array([3.5,2,3]),np.array([-3.5,2,3]),np.array([-3.5,2,-3]), color = YELLOW_C, fill_color = YELLOW_A, fill_opacity = 0.2)
+
+ plane_y = Polygon(np.array([2,-3.5,-3]),np.array([2,3.5,-3]),np.array([2,3.5,3]),np.array([2,-3.5,3]),np.array([2,-3.5,-3]), color = GREEN_C, fill_color = GREEN_A, fill_opacity = 0.2)
+
+ text_x = TextMobject(r"$x$", "is fixed on this" ,"plane").scale(0.7).to_corner(UL)
+ text_y = TextMobject(r"$y$", "is fixed on this" ,"plane").scale(0.7).to_corner(UR)
+
+ text_x[0].set_color(RED_C)
+ text_y[0].set_color(PINK)
+ text_x[1].set_color(BLUE_C)
+ text_y[1].set_color(BLUE_C)
+ text_x[2].set_color(GREEN_C)
+ text_y[2].set_color(YELLOW_C)
+
+ self.add_fixed_in_frame_mobjects(text_x, text_y)
+
+ for i in range(2,-4,-1):
+
+ parabola_x =ParametricFunction(lambda u : np.array([u,i,(u*u + 3*i*i)*np.exp(1- u*u - i*i)]),color=RED_C,t_min=-3.5,t_max=3.5,)
+
+ parabola_y =ParametricFunction(lambda u : np.array([i,u,(i*i + 3*u*u)*np.exp(1- u*u - i*i)]),color=PINK,t_min=-3.5,t_max=3.5,)
+
+ if(i==2):
+ self.play(ShowCreation(plane_x), ShowCreation(plane_y))
+ parabola_copy_x = parabola_x.copy()
+ parabola_copy_y = parabola_y.copy()
+
+
+ self.play(ShowCreation(parabola_copy_x), ShowCreation(parabola_copy_y))
+ self.wait()
+ self.play(FadeOut(parabola_copy_x), FadeOut(parabola_copy_y))
+
+ else:
+ self.play(ApplyMethod(plane_x.move_to, np.array([0,i,0])),ReplacementTransform(parabola_copy_x, parabola_x),ApplyMethod(plane_y.move_to, np.array([i,0,0])),ReplacementTransform(parabola_copy_y, parabola_y))
+ self.play(FadeOut(parabola_x), FadeOut(parabola_y))
+ self.wait()
+
+ parabola_copy_x = parabola_x.copy()
+ parabola_copy_y = parabola_y.copy()
+
+ self.play(FadeOut(plane_x), FadeOut(plane_y), FadeOut(text_x), FadeOut(text_y))
+
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+
+ self.move_camera(phi=80 * DEGREES, theta = 95*DEGREES)
+
+ self.play(ShowCreation(plane1))
+ self.add_fixed_in_frame_mobjects(plane_text_x)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid, paraboloid_x))
+ self.play(FadeOut(plane1), FadeOut(plane_text_x))
+
+ line_x = Line(np.array([-3.5,0,0]), np.array([3.5,0,0]), color = YELLOW_E)
+
+ self.play(ShowCreation(parabola_x_out), ShowCreation(line_x))
+
+ slope_text_x = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "x}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_x[0].set_color(ORANGE)
+ slope_text_x.set_color_by_tex("\\partial",GREEN_E)
+ slope_text_x.set_color_by_tex("f",RED_E)
+ slope_text_x[5].set_color(YELLOW_E)
+
+ self.add_fixed_in_frame_mobjects(slope_text_x)
+
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),parabola_x_out,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(parabola_x_out),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,parabola_x_out,scale=1.5)
+ )
+ )
+ self.add(vector_x,dot_x)
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+ self.play(FadeOut(parabola_x_out), FadeOut(line_x), FadeOut(vector_x), FadeOut(dot_x), FadeOut(slope_text_x))
+
+ self.move_camera(phi=80* DEGREES,theta= 5*DEGREES)
+ self.play(ReplacementTransform(paraboloid_x, paraboloid_copy1))
+ self.wait()
+
+
+
+ self.play(ShowCreation(plane2))
+ self.add_fixed_in_frame_mobjects(plane_text_y)
+ self.wait()
+ self.play(ReplacementTransform(paraboloid_copy1, paraboloid_y))
+ self.play(FadeOut(plane2), FadeOut(plane_text_y))
+
+ line_y = Line(np.array([0,-3.5,0]), np.array([0,3.5,0]), color = GREEN_E)
+
+ self.play(ShowCreation(parabola_y_out), ShowCreation(line_y))
+
+ slope_text_y = TexMobject("Slope =", "{\\partial", "f", "\\over", "\\partial", "y}").scale(0.6).move_to(2*UP + 3.5*RIGHT)
+ slope_text_y[0].set_color(ORANGE)
+ slope_text_y.set_color_by_tex("\\partial",YELLOW_E)
+ slope_text_y.set_color_by_tex("f",PINK)
+ slope_text_y[5].set_color(GREEN_E)
+
+ self.add_fixed_in_frame_mobjects(slope_text_y)
+
+
+ dot_y = Dot().rotate(PI/2).set_color(GREEN_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),parabola_y_out,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(parabola_y_out),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,parabola_y_out,scale=1.5)
+ )
+ )
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+ self.play(FadeOut(parabola_y_out), FadeOut(line_y), FadeOut(vector_y), FadeOut(dot_y), FadeOut(slope_text_y))
+
+ self.move_camera(phi=60* DEGREES,theta= 45*DEGREES)
+ self.play(ReplacementTransform(paraboloid_y, paraboloid_copy2))
+ self.wait()
+
+
+
+
+
+
+
+
+
+ def get_tangent_vector(self, proportion, curve, dx=0.001, scale=1):
+ coord_i = curve.point_from_proportion(proportion)
+ coord_f = curve.point_from_proportion(proportion + dx)
+ reference_line = Line(coord_i,coord_f)
+ unit_vector = reference_line.get_unit_vector() * scale
+ vector = Line(coord_i - unit_vector , coord_i + unit_vector, color = ORANGE, buff=0)
+ return vector
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py new file mode 100644 index 0000000..b79f77c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py @@ -0,0 +1,64 @@ +from manimlib.imports import *
+
+class ClariantRule(Scene):
+ def construct(self):
+ derivatives = TextMobject(r"$cos(x)y^3$",r"$-sin(x)y^3$", r"$3cos(x)y^2$", r"$-cos(x)y^3$", r"$-3sin(x)y^2$", r"$-3sin(x)y^2$", r"$6cos(x)y$")
+
+ partial_derivatives = TextMobject(r"$\frac{\partial}{\partial x}$", r"$\frac{\partial}{\partial y}$")
+
+
+ derivatives[0].move_to(2*UP).set_color(PURPLE)
+ derivatives[1].move_to(3*LEFT).set_color(YELLOW_C)
+ derivatives[2].move_to(3*RIGHT).set_color(BLUE_C)
+
+ arrrow_1 = Arrow(derivatives[0].get_bottom(), derivatives[1].get_top())
+ arrrow_1_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_1_lab.move_to(2.5*LEFT+ 1.3*UP)
+
+ arrrow_2 = Arrow(derivatives[0].get_bottom(), derivatives[2].get_top())
+ arrrow_2_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_2_lab.move_to(2.5*RIGHT+ 1.3*UP)
+
+ self.play(Write(derivatives[0]))
+ self.play(GrowArrow(arrrow_1), GrowArrow(arrrow_2), Write(arrrow_1_lab), Write(arrrow_2_lab))
+
+ self.play(Write(derivatives[1]))
+ self.play(Write(derivatives[2]))
+
+ derivatives[3].move_to(2*DOWN + 4.5*LEFT).set_color(GREEN_C)
+ derivatives[4].move_to(2*DOWN + 1.5*LEFT).set_color(PINK)
+ derivatives[5].move_to(2*DOWN + 1.5*RIGHT).set_color(PINK)
+ derivatives[6].move_to(2*DOWN + 4.5*RIGHT).set_color(ORANGE)
+
+ arrrow_3 = Arrow(derivatives[1].get_bottom(), derivatives[3].get_top())
+ arrrow_3_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_3_lab.move_to(4.3*LEFT+ 0.8*DOWN)
+
+ arrrow_4 = Arrow(derivatives[1].get_bottom(), derivatives[4].get_top())
+ arrrow_4_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_4_lab.move_to(1.6*LEFT+ 0.8*DOWN)
+
+ arrrow_5 = Arrow(derivatives[2].get_bottom(), derivatives[5].get_top())
+ arrrow_5_lab = partial_derivatives[0].copy().scale(0.7)
+ arrrow_5_lab.move_to(1.6*RIGHT+ 0.8*DOWN)
+
+ arrrow_6 = Arrow(derivatives[2].get_bottom(), derivatives[6].get_top())
+ arrrow_6_lab = partial_derivatives[1].copy().scale(0.7)
+ arrrow_6_lab.move_to(4.3*RIGHT+ 0.8*DOWN)
+
+ self.play(GrowArrow(arrrow_3), GrowArrow(arrrow_4), Write(arrrow_3_lab), Write(arrrow_4_lab))
+ self.play(Write(derivatives[3]), Write(derivatives[4]))
+
+ self.play(GrowArrow(arrrow_5), GrowArrow(arrrow_6), Write(arrrow_5_lab), Write(arrrow_6_lab))
+ self.play(Write(derivatives[5]), Write(derivatives[6]))
+
+ brace1 = Brace(derivatives[4:6], DOWN, buff = SMALL_BUFF, color = RED_C)
+ brace_t1 = brace1.get_text("Mixed partial derivatives are the same!")
+ brace_t1.set_color(RED_C)
+
+ self.play(GrowFromCenter(brace1), FadeIn(brace_t1))
+
+ self.wait()
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py new file mode 100644 index 0000000..313c6cd --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file7_partial_deriv_clariant_rule.py @@ -0,0 +1,108 @@ +from manimlib.imports import *
+
+class ClariantRule(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ function = ParametricSurface(
+ lambda u, v: np.array([
+ 3.5*np.sin(u)*np.cos(v),
+ 3.5*np.sin(u)*np.sin(v),
+ 3.5*3.5*np.sin(u)*np.sin(u)*(1+2*np.sin(v)*np.sin(v))*np.exp(1 - 3.5*3.5*np.sin(u)*np.sin(u) )
+ ]),u_min=0,u_max=PI,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+
+ function_copy1 = function.copy()
+ function_copy2 = function.copy()
+
+ func_x =ParametricFunction(
+ lambda u : np.array([
+ u,
+ -1,
+ (u*u )*np.exp(1-u*u)
+ ]),color=RED_E,t_min=-3.5,t_max=3.5,
+ )
+
+ func_y =ParametricFunction(
+ lambda u : np.array([
+ 0,
+ u,
+ (3*u*u)*np.exp(1-u*u)
+ ]),color=PINK,t_min=-3.5,t_max=3.5,
+ )
+
+ plane_x = Polygon(np.array([-3.5,-1,-3]),np.array([3.5,-1,-3]),np.array([3.5,-1,3]),np.array([-3.5,-1,3]),np.array([-3.5,-1,-3]), color = YELLOW_E, fill_color = YELLOW_B, fill_opacity = 0.1)
+ plane_text_x = TextMobject(r"$y = -1$", color = YELLOW_C).move_to(np.array([5,0,2.7])).scale(0.7)
+
+ plane_y = Polygon(np.array([0,-3.5,-3]),np.array([0,3.5,-3]),np.array([0,3.5,3]),np.array([0,-3.5,3]),np.array([0,-3.5,-3]), color = GREEN_E, fill_color = GREEN_B, fill_opacity = 0.1)
+ plane_text_y = TextMobject(r"$x = 0$", color = GREEN_C).move_to(np.array([0,4,2.7])).scale(0.7)
+
+ surface_eqn = TextMobject("Surface", r"$z = (x^2 + 3y^2)e^{(1 - x^2 - y^2)}$", color = YELLOW_C).scale(0.6).move_to(np.array([4.6*LEFT+3.5*UP]))
+ surface_eqn[0].set_color(BLUE_C)
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 45*DEGREES)
+
+ self.add(axes)
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(ShowCreation(function))
+
+ self.add_fixed_in_frame_mobjects(surface_eqn)
+
+ self.play(ShowCreation(plane_x), ShowCreation(plane_y))
+ self.add_fixed_orientation_mobjects(plane_text_x, plane_text_y)
+
+ self.play(ShowCreation(func_x), ShowCreation(func_y))
+
+ dot_x = Dot().rotate(PI/2).set_color(YELLOW_E)
+ alpha_x = ValueTracker(0)
+ vector_x = self.get_tangent_vector(alpha_x.get_value(),func_x,scale=1.5)
+ dot_x.add_updater(lambda m: m.move_to(vector_x.get_center()))
+ self.play(
+ ShowCreation(func_x),
+ GrowFromCenter(dot_x),
+ GrowArrow(vector_x)
+ )
+ vector_x.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_x.get_value()%1,func_x,scale=1.5)
+ )
+ )
+ dot_y = Dot().rotate(PI/2).set_color(GREEN_E)
+ alpha_y = ValueTracker(0)
+ vector_y = self.get_tangent_vector(alpha_y.get_value(),func_y,scale=1.5)
+ dot_y.add_updater(lambda m: m.move_to(vector_y.get_center()))
+ self.play(
+ ShowCreation(func_y),
+ GrowFromCenter(dot_y),
+ GrowArrow(vector_y)
+ )
+ vector_y.add_updater(
+ lambda m: m.become(
+ self.get_tangent_vector(alpha_y.get_value()%1,func_y,scale=1.5)
+ )
+ )
+ self.add(vector_x,dot_x)
+
+ self.play(alpha_x.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.add(vector_y,dot_y)
+ self.play(alpha_y.increment_value, 1, run_time=10, rate_func=linear)
+
+ self.wait(2)
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py new file mode 100644 index 0000000..f50d2d1 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file8_chain_rule.py @@ -0,0 +1,60 @@ +from manimlib.imports import *
+
+class ChainRule(Scene):
+ def construct(self):
+
+ chain_rule = TextMobject(r"$\frac{dw}{dt}$", r"=", r"$\frac{\partial w}{\partial x}$", r"$\frac{dx}{dt}$", r"+", r"$\frac{\partial w}{\partial y}$", r"$\frac{dy}{dt}$").move_to(4*RIGHT).scale(0.8)
+
+ chain_rule[0].set_color(ORANGE)
+ chain_rule[2].set_color(GREEN_C)
+ chain_rule[3].set_color(RED_C)
+ chain_rule[5].set_color(YELLOW_C)
+ chain_rule[6].set_color(BLUE_C)
+
+ functions = TextMobject(r"$w =f(x,y)$",r"$x$", r"$y$", r"$t$")
+
+ functions[0].move_to(3.3*UP+1*LEFT).set_color(ORANGE)
+ functions[1].move_to(3.3*LEFT).set_color(PURPLE)
+ functions[2].move_to(1.3*RIGHT).set_color(PURPLE)
+ functions[3].move_to(3.3*DOWN+1*LEFT).set_color(WHITE)
+
+ partial_derivatives = TextMobject(r"$\frac{\partial w}{\partial x}$", r"$\frac{\partial w}{\partial y}$")
+
+ partial_derivatives[0].move_to(1.5*UP+3*LEFT).set_color(GREEN_C)
+ partial_derivatives[1].move_to(1.5*UP+1*RIGHT).set_color(YELLOW_C)
+
+ derivatives = TextMobject(r"$\frac{dx}{dt}$", r"$\frac{dy}{dt}$")
+
+ derivatives[0].move_to(1.5*DOWN+3*LEFT).set_color(RED_C)
+ derivatives[1].move_to(1.5*DOWN+1*RIGHT).set_color(BLUE_C)
+
+ line_f_x = Line(np.array([-1,3,0]), np.array([-3,0,0]), color = BLUE_C)
+ line_f_y = Line(np.array([-1,3,0]), np.array([1,0,0]), color = BLUE_C)
+ line_x_t = Line(np.array([-3,0,0]), np.array([-1,-3,0]), color = BLUE_C)
+ line_y_t = Line(np.array([1,0,0]), np.array([-1,-3,0]), color = BLUE_C)
+
+ dot_f = Dot().shift(np.array([-1,3,0])).set_color(BLUE_C)
+ dot_x = Dot().shift(np.array([-3,0,0])).set_color(BLUE_C)
+ dot_y = Dot().shift(np.array([1,0,0])).set_color(BLUE_C)
+ dot_t = Dot().shift(np.array([-1,-3,0])).set_color(BLUE_C)
+
+ variables = TextMobject("Dependent Variable","Intermediate Variables", "Dependent Variable").set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE).scale(0.7)
+ variables[0].move_to(3.3*UP+3.5*RIGHT)
+ variables[1].move_to(3.5*RIGHT)
+ variables[2].move_to(3.3*DOWN+3.5*RIGHT)
+
+ self.play(ShowCreation(dot_f), Write(functions[0]))
+ self.play(ShowCreation(dot_x), ShowCreation(line_f_x), Write(functions[1]), ShowCreation(dot_y), ShowCreation(line_f_y), Write(functions[2]))
+ self.play(Write(partial_derivatives[0]), Write(partial_derivatives[1]))
+ self.wait()
+
+ self.play(ShowCreation(dot_t), ShowCreation(line_x_t), ShowCreation(line_y_t), Write(functions[3]))
+ self.play(Write(derivatives[0]), Write(derivatives[1]))
+ self.wait()
+
+ self.play(Write(variables[0]), Write(variables[1]), Write(variables[2]))
+
+ self.play(FadeOut(variables))
+ self.play(Write(chain_rule))
+ self.wait()
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif Binary files differnew file mode 100644 index 0000000..8fdb80f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file1_partial_deriv_gas_law.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif Binary files differnew file mode 100644 index 0000000..3c758ff --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file2_partial_deriv_hill.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif Binary files differnew file mode 100644 index 0000000..c66b3fa --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file3_partial_deriv_defn.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif Binary files differnew file mode 100644 index 0000000..d2bf541 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file4_partial_deriv_example.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif Binary files differnew file mode 100644 index 0000000..db7f4f8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file5_partial_deriv_func_2maximas.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif Binary files differnew file mode 100644 index 0000000..8377827 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file6_clariant_rule.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif Binary files differnew file mode 100644 index 0000000..32d5e92 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file7_partial_deriv_clariant_rule.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif Binary files differnew file mode 100644 index 0000000..596b08d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/gifs/file8_chain_rule.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/README.md b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/README.md new file mode 100644 index 0000000..4339c30 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/README.md @@ -0,0 +1,20 @@ +**file1_scalar_function** +![file1_scalar_function](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif) + +**file2_domain_range** +![file2_domain_range](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif) + +**file3_parabola_example** +![file3_parabola_example](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif) + +**file4_level_curves** +![file4_non_rect_region](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif) + +**file5_level_surface** +![file5_level_surface](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif) + +**file6_scalar_function_application** +![file6_scalar_function_application](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif) + +**file7_neural_nets** +![file7_neural_nets](https://github.com/nishanpoojary/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif) diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/Scalar_Function_Quiz.pdf b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/Scalar_Function_Quiz.pdf Binary files differnew file mode 100644 index 0000000..6d94a2c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/Scalar_Function_Quiz.pdf diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file1_scalar_functions.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file1_scalar_functions.py new file mode 100644 index 0000000..1a6f4ed --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file1_scalar_functions.py @@ -0,0 +1,50 @@ +from manimlib.imports import *
+
+class ScalarFunction(Scene):
+ def construct(self):
+ circle = Circle(radius = 1.5, color = BLUE_E, fill_color = BLUE_C, fill_opacity = 0.1).move_to(2*LEFT)
+ dot_circle = Dot().shift(np.array([-1.5,0,0])).set_color(BLUE_E)
+ dot_circle_lab = TextMobject(r"$a$", color = BLUE_E).next_to(dot_circle, DOWN)
+
+ arrow = Arrow(np.array([3,-3,0]),np.array([3,3,0]))
+ line = Line(np.array([3,-1.5,0]),np.array([3,1.5,0]), color = RED_C)
+
+ dot0 = Dot().shift(np.array([3,0,0])).set_color(RED_E)
+ dot0_lab = TextMobject(r"$f(a)$", color = RED_E).scale(0.8).next_to(dot0, RIGHT)
+
+ dot1 = Dot().shift(np.array([3,-1.5,0])).set_color(RED_C)
+
+ dot2 = Dot().shift(np.array([3,1.5,0])).set_color(RED_C)
+ dot2_lab = TextMobject(r"$f(A)$", color = RED_C).scale(0.8).next_to(dot2, RIGHT)
+
+ arrow_f = Arrow(np.array([-1.5,0,0]),np.array([3,0,0]), color = YELLOW_C, buff = 0.1)
+
+ R = TextMobject(r"$\mathbb{R}$", color = WHITE).move_to(np.array([3,-3.3,0]))
+
+ A = TextMobject(r"$A$", color = BLUE_E).move_to(np.array([-2.5,-3.3,0]))
+
+ F = TextMobject(r"$f$", color = GREY).move_to(np.array([0,-2.9,0]))
+
+ F_center = TextMobject(r"$f$", color = YELLOW_C).move_to(np.array([0.8,0.5,0]))
+
+ arrow_R_A = Arrow(np.array([-2.3,-3.3,0]),np.array([2.7,-3.3,0]), color = GREY, buff = 0.1)
+
+ scalar_function = TextMobject(r"Scalar Valued Function", r"$f: A \rightarrow \mathbb{R}$", color = PURPLE).move_to(np.array([0,3.5,0]))
+ scalar_function[1].set_color(GREEN_C)
+
+
+
+ self.play(ShowCreation(circle))
+ self.play(ShowCreation(arrow))
+
+
+ self.play(ShowCreation(dot1), ShowCreation(dot2))
+ self.play(ShowCreation(dot_circle))
+ self.play(ShowCreation(dot_circle_lab), ShowCreation(dot2_lab))
+ self.play(ShowCreation(A), ShowCreation(R))
+ self.play(GrowArrow(arrow_f), ShowCreation(dot0), ShowCreation(dot0_lab), ShowCreation(F_center), GrowArrow(arrow_R_A), ShowCreation(F), Transform(circle.copy(), line.copy()))
+
+ self.play(Write(scalar_function))
+
+
+ self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file2_domain_range.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file2_domain_range.py new file mode 100644 index 0000000..1b54cb6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file2_domain_range.py @@ -0,0 +1,190 @@ +# Plotting Graphs
+from manimlib.imports import *
+
+class PlotGraphs(GraphScene):
+ CONFIG = {
+ "x_min": -5,
+ "x_max": 5,
+ "y_min": 0,
+ "y_max": 4,
+ "graph_origin": ORIGIN + 2.5* DOWN,
+ "x_labeled_nums": list(range(-5, 6)),
+ "y_labeled_nums": list(range(0, 5)),
+ }
+ def construct(self):
+
+ topic = TextMobject("Domain and Range")
+ topic.scale(2)
+ topic.set_color(YELLOW)
+ self.play(Write(topic))
+ self.play(FadeOut(topic))
+ self.wait(1)
+
+ scalar_func_R = TextMobject(r"Scalar Valued Functions in $R$").scale(1.5).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ self.play(Write(scalar_func_R))
+ self.play(FadeOut(scalar_func_R))
+ self.wait(1)
+
+
+ XTD = self.x_axis_width/(self.x_max- self.x_min)
+ YTD = self.y_axis_height/(self.y_max- self.y_min)
+
+ self.setup_axes(animate = True)
+
+ graphobj = self.get_graph(lambda x : np.sqrt(x + 4), x_min = -4, x_max = 5)
+ graph_lab = self.get_graph_label(graphobj, label = r"\sqrt{x + 4}")
+
+
+ rangeline1 = Arrow(self.graph_origin+2.2*YTD*UP+5*XTD*LEFT, self.graph_origin+4.1*YTD*UP+5*XTD*LEFT)
+ rangeline2 = Arrow(self.graph_origin+1.7*YTD*UP+5*XTD*LEFT, self.graph_origin+5*XTD*LEFT)
+ rangeline1.set_color(RED)
+ rangeline2.set_color(RED)
+
+ rangeMsg = TextMobject(r"Range: $y \geq 0$")
+ rangeMsg.move_to(self.graph_origin+2*YTD*UP+5*XTD*LEFT)
+ rangeMsg.scale(0.5)
+ rangeMsg.set_color(YELLOW)
+
+ domainline1 = Arrow(self.graph_origin+0.6*YTD*DOWN+1.2*XTD*LEFT, self.graph_origin+0.6*YTD*DOWN + 4*XTD*LEFT, buff = 0.1)
+ domainline2 = Arrow(self.graph_origin+0.6*YTD*DOWN+1.1*XTD*RIGHT, self.graph_origin+0.6*YTD*DOWN + 5.3*XTD*RIGHT, buff = 0.1)
+ domainline1.set_color(PINK)
+ domainline2.set_color(PINK)
+
+ domainMsg = TextMobject(r"Domain: $x \geq -4$")
+ domainMsg.move_to(self.graph_origin+0.6*YTD*DOWN)
+ domainMsg.scale(0.5)
+ domainMsg.set_color(GREEN)
+
+
+
+
+ self.play(ShowCreation(graphobj))
+ self.play(ShowCreation(graph_lab))
+ self.wait(1)
+ self.play(GrowArrow(rangeline1))
+ self.play(GrowArrow(rangeline2))
+ self.play(Write(rangeMsg))
+ self.wait(1)
+ self.play(GrowArrow(domainline1))
+ self.play(GrowArrow(domainline2))
+ self.play(Write(domainMsg))
+ self.wait(3)
+
+ self.wait(2)
+
+
+
+
+class PlotSineGraphs(GraphScene):
+ CONFIG = {
+ "x_min": -8,
+ "x_max": 8,
+ "y_min": -1,
+ "y_max": 1,
+ "graph_origin": ORIGIN,
+ "x_labeled_nums": list(range(-8, 9)),
+ "y_labeled_nums": list(range(-1, 2)),
+ }
+ 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)
+
+ self.setup_axes(animate = True)
+
+ sineobj = self.get_graph(lambda x : np.sin(x), x_min = -7, x_max = 8)
+ sine_lab = self.get_graph_label(sineobj, label = "\\sin(x)")
+
+
+ rangeline1 = Line(8*XTD*LEFT,1*YTD*UP+8*XTD*LEFT)
+ rangeline2 = Line(8*XTD*LEFT,1*YTD*DOWN+8*XTD*LEFT)
+ rangeline1.set_color(RED)
+ rangeline2.set_color(RED)
+
+ rangeMsg = TextMobject(r"Range: $-1 \leq y \leq 1$")
+ rangeMsg.move_to(1.1*YTD*UP+8.5*XTD*LEFT)
+ rangeMsg.scale(0.5)
+ rangeMsg.set_color(YELLOW)
+
+
+ domainline1 = Arrow(1.1*YTD*DOWN+2*XTD*LEFT, 1.1*YTD*DOWN + 8.5*XTD*LEFT)
+ domainline2 = Arrow(1.1*YTD*DOWN+2*XTD*RIGHT, 1.1*YTD*DOWN + 8.5*XTD*RIGHT)
+ domainline1.set_color(PINK)
+ domainline2.set_color(PINK)
+
+ domainMsg = TextMobject(r"Domain: $[-\infty, \infty]$")
+ domainMsg.move_to(1.1*YTD*DOWN)
+ domainMsg.scale(0.5)
+ domainMsg.set_color(GREEN)
+
+
+
+ self.play(ShowCreation(sineobj))
+ self.play(ShowCreation(sine_lab))
+ self.wait(1)
+ self.play(GrowArrow(rangeline1))
+ self.play(GrowArrow(rangeline2))
+ self.play(Write(rangeMsg))
+ self.wait(1)
+ self.play(GrowArrow(domainline1))
+ self.play(GrowArrow(domainline2))
+ self.play(Write(domainMsg))
+ self.wait(3)
+
+
+
+
+class Paraboloid(ThreeDScene):
+ def construct(self):
+
+ scalar_func_R2 = TextMobject(r"Scalar Valued Functions in $R^2$").scale(1.5).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ self.play(Write(scalar_func_R2))
+ self.play(FadeOut(scalar_func_R2))
+ self.wait(1)
+
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.sin(u)*np.cos(v),
+ 2*np.sin(u)*np.sin(v),
+ 2*2*np.sin(u)*np.sin(u)
+ ]),u_min=0,u_max=PI/2,v_min=0,v_max=2*PI,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ domain = Polygon(np.array([-5,-5,0]),np.array([5,-5,0]),np.array([5,5,0]),np.array([-5,5,0]),np.array([-5,-5,0]), color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.2)
+ domain_lab = TextMobject(r"$Domain: R^2$", color = YELLOW_C).scale(0.7).move_to(1*DOWN + 2*LEFT)
+
+ rangef = Line(np.array([0, 0,0]), np.array([0, 0,5]), color = RED_C)
+ rangef_lab = TextMobject(r"$Range: z \geq 0$", color = RED_C).scale(0.7).move_to(2*UP + 1.5*RIGHT)
+
+ func = TextMobject(r"$z = f(x,y) = x^2+y^2$").scale(0.7).move_to(3*UP + 4*LEFT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.set_camera_orientation(phi=60 * DEGREES, theta = 0*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.3)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+
+
+ self.add_fixed_in_frame_mobjects(func)
+ self.play(Write(paraboloid))
+ self.play(ShowCreation(domain))
+ self.add_fixed_in_frame_mobjects(domain_lab)
+ self.wait()
+ self.play(ShowCreation(rangef))
+ self.add_fixed_in_frame_mobjects(rangef_lab)
+ self.wait(5)
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file3_parabola_example.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file3_parabola_example.py new file mode 100644 index 0000000..63c16b3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file3_parabola_example.py @@ -0,0 +1,47 @@ +from manimlib.imports import *
+
+class Parabola(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ 2*np.cosh(u)*np.cos(v),
+ 2*np.cosh(u)*np.sin(v),
+ 2*np.sinh(u)
+ ]),v_min=0,v_max=TAU,u_min=0,u_max=2,checkerboard_colors=[YELLOW_D, YELLOW_E],#
+ resolution=(15, 32))
+
+ text3d = TextMobject(r"Plot of $f: \mathbb{R}^2 \rightarrow \mathbb{R}$", r"$z = f(x,y) = \sqrt{x^2 + y^2 - 4}$")
+ text3d[0].move_to(4*LEFT+2*DOWN)
+ text3d[1].next_to(text3d[0], DOWN)
+ text3d[0].set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ text3d[1].set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE)
+
+ #self.set_camera_orientation(phi=0 * DEGREES,theta=270*DEGREES)
+ self.move_camera(phi=110* DEGREES,theta=45*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+
+ self.play(ShowCreation(paraboloid))
+ self.add_fixed_in_frame_mobjects(text3d)
+ self.play(Write(text3d[0]))
+ self.play(Write(text3d[1]))
+ self.begin_ambient_camera_rotation(rate=0.2)
+ self.wait(3)
+ self.move_camera(phi=0 * DEGREES,theta=180*DEGREES,run_time=3)
+ self.wait(3)
+ self.move_camera(phi=110* DEGREES,theta=90*DEGREES,run_time=3)
+ self.wait(3)
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file4_level_curves.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file4_level_curves.py new file mode 100644 index 0000000..2b6f719 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file4_level_curves.py @@ -0,0 +1,118 @@ +from manimlib.imports import *
+
+class LevelCurves(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ paraboloid = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ -u*u+2
+ ]),u_min=-1.414,u_max=1.414,v_min=0,v_max=2*PI, color = BLUE_C, fill_color = BLUE_C, fill_opacity = 0.1,
+ resolution=(15, 32)).scale(1)
+
+ plane_0 = Polygon(np.array([2,-2,0]),np.array([2,2,0]),np.array([-2,2,0]),np.array([-2,-2,0]),np.array([2,-2,0]), color = BLUE_E, fill_color = BLUE_E, fill_opacity = 0.3)
+ plane_0_lab = TextMobject("C = 0").move_to(0.4*UP+3.2*RIGHT).set_color(BLUE_E).scale(0.6)
+ circle_0 = Circle(radius = 1.414 , color = BLUE_E)
+ circle_0_lab = TextMobject("0").move_to(1.1*DOWN+1.1*RIGHT).set_color(BLUE_E).scale(0.6)
+
+ plane_0_5 = Polygon(np.array([2,-2,0.5]),np.array([2,2,0.5]),np.array([-2,2,0.5]),np.array([-2,-2,0.5]),np.array([2,-2,0.5]), color = GREEN_C, fill_color = GREEN_C, fill_opacity = 0.3)
+ plane_0_5_lab = TextMobject("C = 0.5").move_to(0.8*UP+3.4*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5 = Circle(radius = 1.224 , color = GREEN_C)
+ circle_0_5_lab = TextMobject("0.5").move_to(0.9*DOWN+0.9*RIGHT).set_color(GREEN_C).scale(0.6)
+ circle_0_5_copy = circle_0_5.copy().move_to(np.array([0,0,0.5]))
+
+ plane_1 = Polygon(np.array([2,-2,1]),np.array([2,2,1]),np.array([-2,2,1]),np.array([-2,-2,1]),np.array([2,-2,1]), color = YELLOW_C, fill_color = YELLOW_C, fill_opacity = 0.3)
+ plane_1_lab = TextMobject("C = 1").move_to(1.2*UP+3.3*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1 = Circle(radius = 1 , color = YELLOW_C)
+ circle_1_lab = TextMobject("1").move_to(0.7*DOWN+0.7*RIGHT).set_color(YELLOW_C).scale(0.6)
+ circle_1_copy = circle_1.copy().move_to(np.array([0,0,1]))
+
+ plane_1_5 = Polygon(np.array([2,-2,1.5]),np.array([2,2,1.5]),np.array([-2,2,1.5]),np.array([-2,-2,1.5]),np.array([2,-2,1.5]), color = ORANGE, fill_color = ORANGE, fill_opacity = 0.3)
+ plane_1_5_lab = TextMobject("C = 1.5").move_to(1.7*UP+3.4*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5 = Circle(radius = 0.707 , color = ORANGE)
+ circle_1_5_lab = TextMobject("1.5").move_to(0.5*DOWN+0.5*RIGHT).set_color(ORANGE).scale(0.6)
+ circle_1_5_copy = circle_1_5.copy().move_to(np.array([0,0,1.5]))
+
+ plane_2 = Polygon(np.array([2,-2,2]),np.array([2,2,2]),np.array([-2,2,2]),np.array([-2,-2,2]),np.array([2,-2,2]), color = RED_C, fill_color = RED_C, fill_opacity = 0.3)
+ plane_2_lab = TextMobject("C = 2").move_to(2.1*UP+3.3*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2 = Dot().set_fill(RED_C)
+ circle_2_lab = TextMobject("2").move_to(0.2*DOWN+0.2*RIGHT).set_color(RED_C).scale(0.6)
+ dot_2_copy = dot_2.copy().move_to(np.array([0,0,2]))
+
+ level_curves_line1 = DashedLine(np.array([0,-1.414,0]),np.array([0,-2,1]), color = WHITE)
+ level_curves_line2 = DashedLine(np.array([0,-1.224,0.5]),np.array([0,-2,1]), color = WHITE)
+ level_curves_line3 = DashedLine(np.array([0,-1,1]),np.array([0,-2,1]), color = WHITE)
+ level_curves_line4 = DashedLine(np.array([0,-0.707,1.5]),np.array([0,-2,1]), color = WHITE)
+ level_curves_line5 = DashedLine(np.array([0,0,2]),np.array([0,-2,1]), color = WHITE)
+
+ level_curves = TextMobject("Level Curves").move_to(1.4*UP+3*LEFT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE).scale(0.8)
+
+
+ contour_line1 = DashedLine(np.array([0,-1.414,0]),np.array([0,-2,1]), color = WHITE)
+ contour_line2 = DashedLine(np.array([0,-1.224,0]),np.array([0,-2,1]), color = WHITE)
+ contour_line3 = DashedLine(np.array([0,-1,0]),np.array([0,-2,1]), color = WHITE)
+ contour_line4 = DashedLine(np.array([0,-0.707,0]),np.array([0,-2,1]), color = WHITE)
+ contour_line5 = DashedLine(np.array([0,0,0]),np.array([0,-2,1]), color = WHITE)
+
+ contours = TextMobject("Contours").move_to(1.4*UP+2.7*LEFT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE).scale(0.8)
+
+
+ topic = TextMobject("Contour Plot").move_to(3*UP+3*LEFT).set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE).scale(0.8)
+
+ self.set_camera_orientation(phi=80 * DEGREES, theta = 0*DEGREES)
+ #self.set_camera_orientation(phi=0 * DEGREES, theta = 0*DEGREES)
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(Write(paraboloid))
+ self.wait()
+ self.play(ShowCreation(plane_0), ShowCreation(circle_0))
+ self.add_fixed_in_frame_mobjects(plane_0_lab)
+ self.wait()
+ self.play(ShowCreation(plane_0_5), ShowCreation(circle_0_5_copy), ShowCreation(circle_0_5))
+ self.add_fixed_in_frame_mobjects(plane_0_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1), ShowCreation(circle_1_copy), ShowCreation(circle_1))
+ self.add_fixed_in_frame_mobjects(plane_1_lab)
+ self.wait()
+ self.play(ShowCreation(plane_1_5), ShowCreation(circle_1_5_copy), ShowCreation(circle_1_5))
+ self.add_fixed_in_frame_mobjects(plane_1_5_lab)
+ self.wait()
+ self.play(ShowCreation(plane_2), ShowCreation(dot_2_copy), ShowCreation(dot_2))
+ self.add_fixed_in_frame_mobjects(plane_2_lab)
+ self.wait()
+
+ self.move_camera(phi=60 * DEGREES, theta = 30*DEGREES,run_time=3)
+ self.play(FadeOut(plane_0), FadeOut(plane_0_lab), FadeOut(plane_0_5), FadeOut(plane_0_5_lab), FadeOut(plane_1), FadeOut(plane_1_lab), FadeOut(plane_1_5), FadeOut(plane_1_5_lab), FadeOut(plane_2), FadeOut(plane_2_lab))
+
+ self.play(GrowArrow(level_curves_line1), GrowArrow(level_curves_line2), GrowArrow(level_curves_line3), GrowArrow(level_curves_line4), GrowArrow(level_curves_line5))
+ self.add_fixed_in_frame_mobjects(level_curves)
+ self.wait()
+ self.play(FadeOut(level_curves_line1), FadeOut(level_curves_line2), FadeOut(level_curves_line3), FadeOut(level_curves_line4), FadeOut(level_curves_line5), FadeOut(level_curves))
+ self.play(FadeOut(circle_0_5_copy), FadeOut(circle_1_copy), FadeOut(circle_1_5_copy), FadeOut(dot_2_copy))
+ self.wait()
+
+ self.play(GrowArrow(contour_line1), GrowArrow(contour_line2), GrowArrow(contour_line3), GrowArrow(contour_line4), GrowArrow(contour_line5))
+ self.add_fixed_in_frame_mobjects(contours)
+ self.wait()
+ self.play(FadeOut(contour_line1), FadeOut(contour_line2), FadeOut(contour_line3), FadeOut(contour_line4), FadeOut(contour_line5), FadeOut(contours))
+
+
+ self.move_camera(phi=0 * DEGREES, theta = 0*DEGREES,run_time=3)
+ self.play(FadeOut(paraboloid))
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(circle_0_lab, circle_0_5_lab, circle_1_lab, circle_1_5_lab,circle_2_lab)
+ self.add_fixed_in_frame_mobjects(topic)
+ self.wait(3)
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file5_level_surface.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file5_level_surface.py new file mode 100644 index 0000000..8052676 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file5_level_surface.py @@ -0,0 +1,78 @@ +from manimlib.imports import *
+
+class LevelSurface(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ surface_0 = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ (u*u*np.cos(v)*np.cos(v))-(u*np.sin(v)/5)+0
+ ]),u_min=-1,u_max=1,v_min=0,v_max=2*PI,checkerboard_colors=[RED_C, RED_E],
+ resolution=(15, 32)).scale(1)
+
+ k_0 = TextMobject("K = 0", color = RED_C).scale(0.7)
+
+ surface_1 = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ (u*u*np.cos(v)*np.cos(v))-(u*np.sin(v)/5)+1
+ ]),u_min=-1,u_max=1,v_min=0,v_max=2*PI,checkerboard_colors=[GREEN_C, GREEN_E],
+ resolution=(15, 32)).scale(1)
+
+ k_1 = TextMobject("K = 1", color = GREEN_C).scale(0.7)
+
+ surface_2 = ParametricSurface(
+ lambda u, v: np.array([
+ u*np.cos(v),
+ u*np.sin(v),
+ (u*u*np.cos(v)*np.cos(v))-(u*np.sin(v)/5)+2
+ ]),u_min=-1,u_max=1,v_min=0,v_max=2*PI,checkerboard_colors=[YELLOW_C, YELLOW_E],
+ resolution=(15, 32)).scale(1)
+
+ k_2 = TextMobject("K = 2", color = YELLOW_C).scale(0.7)
+
+ func = TextMobject(r"$w = g(x,y,z)$", r"$= z - f(x,y)$", r"$z-x^2+y/5 = K$")
+ func.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.set_camera_orientation(phi=90 * DEGREES, theta = 90*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.3)
+
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(3.7*UP)
+
+ self.add_fixed_in_frame_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ self.play(Write(surface_0))
+ self.add_fixed_in_frame_mobjects(k_0)
+ k_0.move_to(np.array([1.4*RIGHT ]))
+
+ self.play(Write(surface_1))
+ self.add_fixed_in_frame_mobjects(k_1)
+ k_1.move_to(np.array([1.4*RIGHT + 1*UP]))
+
+ self.play(Write(surface_2))
+ self.add_fixed_in_frame_mobjects(k_2)
+ k_2.move_to(np.array([1.4*RIGHT + 2*UP]))
+ self.wait()
+
+ self.add_fixed_in_frame_mobjects(func)
+ func[0].move_to(np.array([4.5*LEFT + 3*UP]))
+ func[1].move_to(np.array([4.5*LEFT + 2.5*UP]))
+ func[2].move_to(np.array([4.5*LEFT + 2*UP]))
+
+ self.wait(3)
+ self.move_camera(phi=60 * DEGREES,run_time=3)
+ self.wait(2)
+
+
+
\ No newline at end of file diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file6_scalar_function_application.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file6_scalar_function_application.py new file mode 100644 index 0000000..3ccfad6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file6_scalar_function_application.py @@ -0,0 +1,140 @@ +from manimlib.imports import *
+
+class ScalarApplication(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+ self.add(axes)
+
+ axis = TextMobject(r"X",r"Y",r"Z")
+ axis[0].move_to(6*RIGHT)
+ axis[1].move_to(6*UP)
+ axis[2].move_to(np.array([0,0,3.7]))
+
+ self.add_fixed_orientation_mobjects(axis[2])
+ self.add_fixed_orientation_mobjects(axis[0])
+ self.add_fixed_orientation_mobjects(axis[1])
+
+ cube = Cube()
+ cube.set_fill(YELLOW_C, opacity = 0.2)
+ cube.scale(2)
+ self.set_camera_orientation(phi=0 * DEGREES,theta=270*DEGREES)
+ self.play(ShowCreation(cube))
+
+ dot = Sphere()
+ dot.scale(0.1)
+ dot.move_to(np.array([1,0.5,1]))
+ dot.set_fill(RED)
+
+ #dot = Dot(np.array([1,0.5,1]), color = RED)
+ temp_func = TextMobject("T(x,y,z)")
+ temp_func.next_to(dot,RIGHT)
+ temp_func.set_color(RED)
+ temp_func_trans = TextMobject("T(1,0.5,1)")
+ temp_func_trans.next_to(dot,RIGHT)
+ temp_func_trans.set_color(RED)
+ temp = TextMobject(r"$36 ^\circ$")
+ temp.next_to(dot,RIGHT)
+ temp.set_color(RED_E)
+
+
+ self.play(ShowCreation(dot))
+ self.play(ShowCreation(temp_func))
+ self.play(Transform(temp_func, temp_func_trans))
+ self.wait(1)
+ self.play(Transform(temp_func, temp))
+
+
+
+
+ dot1 = Sphere()
+ dot1.scale(0.1)
+ dot1.move_to(np.array([-1,-0.8,-1.5]))
+ dot1.set_fill(BLUE_E)
+ #dot1 = Dot(np.array([-1,-0.8,-1.5]), color = BLUE)
+ temp_func1 = TextMobject("T(x,y,z)")
+ temp_func1.next_to(dot1,LEFT)
+ temp_func1.set_color(BLUE)
+ temp_func_trans1 = TextMobject("T(-1,-0.8,-1.5)")
+ temp_func_trans1.next_to(dot1,LEFT)
+ temp_func_trans1.set_color(BLUE)
+ temp1 = TextMobject(r"$24 ^\circ$")
+ temp1.next_to(dot1,LEFT)
+ temp1.set_color(BLUE)
+
+ self.play(ShowCreation(dot1))
+ self.play(ShowCreation(temp_func1))
+ self.play(Transform(temp_func1, temp_func_trans1))
+ self.wait(1)
+ self.play(Transform(temp_func1, temp1))
+
+ self.play(FadeOut(temp_func))
+ self.play(FadeOut(temp_func1))
+
+
+ self.move_camera(phi=80* DEGREES,theta=45*DEGREES,run_time=3)
+
+ self.begin_ambient_camera_rotation(rate=0.2)
+ self.wait(4)
+ self.stop_ambient_camera_rotation()
+ self.wait(2)
+
+
+
+
+class AddTempScale(Scene):
+ def construct(self):
+ temp_scale = ImageMobject("tempscale.png")
+ temp_scale.scale(4)
+ temp_scale.move_to(2*RIGHT)
+ self.play(ShowCreation(temp_scale))
+
+
+ temp_func = TextMobject("T(x,y,z)")
+ temp_func.move_to(3*UP +2*LEFT)
+ temp_func.set_color(RED)
+ temp_func_trans = TextMobject("T(1,0.5,1)")
+ temp_func_trans.move_to(3*UP +2*LEFT)
+ temp_func_trans.set_color(RED)
+ temp = TextMobject(r"$36 ^\circ$")
+ temp.set_color(RED)
+ temp.move_to(3*UP +2*LEFT)
+ temp.scale(0.7)
+
+ self.play(ShowCreation(temp_func))
+ self.play(Transform(temp_func, temp_func_trans))
+ self.wait(1)
+ self.play(Transform(temp_func, temp))
+ self.play(ApplyMethod(temp_func.move_to, 1.8*UP +1.8*RIGHT))
+
+
+ temp_func1 = TextMobject("T(x,y,z)")
+ temp_func1.move_to(2*UP +2*LEFT)
+ temp_func1.set_color(BLUE)
+ temp_func_trans1 = TextMobject("T(-1,-0.8,-1.5)")
+ temp_func_trans1.move_to(2*UP +2*LEFT)
+ temp_func_trans1.set_color(BLUE)
+ temp1 = TextMobject(r"$24 ^\circ$")
+ temp1.set_color(BLUE)
+ temp1.move_to(2*UP +2*LEFT)
+ temp1.scale(0.7)
+
+ self.play(ShowCreation(temp_func1))
+ self.play(Transform(temp_func1, temp_func_trans1))
+ self.wait(1)
+ self.play(Transform(temp_func1, temp1))
+ self.play(ApplyMethod(temp_func1.move_to, 0.6*UP +1.8*RIGHT))
+
+
+
+ transtext = TextMobject("Scalar Function Transform:")
+ transtext.set_color(GREEN)
+ transtext1 = TextMobject(r"$\mathbb{R}^3 \rightarrow \mathbb{R}$")
+ transtext1.set_color(YELLOW_E)
+ transtext.move_to(3*UP +3*LEFT)
+ transtext1.next_to(transtext,DOWN)
+ self.play(Write(transtext))
+ self.play(Write(transtext1))
+ self.wait(2)
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file7_neural_nets.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file7_neural_nets.py new file mode 100644 index 0000000..eb6bf45 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file7_neural_nets.py @@ -0,0 +1,177 @@ +from manimlib.imports import *
+
+class SigmoidFunc(GraphScene):
+ CONFIG = {
+ "x_min": -4,
+ "x_max": 4,
+ "y_min": -1,
+ "y_max": 1,
+ "graph_origin": ORIGIN + 0.8*DOWN,
+ "x_labeled_nums": list(range(-4, 5)),
+ "y_labeled_nums": list(range(-1, 2)),
+ "y_axis_height": 4.5,
+ }
+ 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)
+
+ topic = TextMobject("Sigmoid Function")
+ topic.move_to(3.2*UP)
+ topic.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+
+ self.setup_axes(animate = True)
+ sigmoid_func = self.get_graph(lambda x : (1/(1 + np.exp(-x))), x_min = -4, x_max = 4)
+ sigmoid_lab = self.get_graph_label(sigmoid_func, label = r"\frac{1}{1 + e^{-z}}")
+
+
+
+
+ self.play(ShowCreation(sigmoid_func),Write(sigmoid_lab))
+ self.play(Write(topic))
+ self.wait(2)
+ self.play(FadeOut(sigmoid_func), FadeOut(sigmoid_lab))
+ self.wait(1)
+
+
+
+class NeuralNet(GraphScene):
+ def construct(self):
+
+ sigmoid_exp = TextMobject(r"g(z) = g($\theta^T$ X) = $\frac{1}{1 + e^{-z}}$")
+ sigmoid_exp.move_to(3*UP + 4*LEFT)
+ sigmoid_exp.scale(0.8)
+ sigmoid_exp.set_color(BLUE)
+ sigmoid_exp1 = TextMobject(r"Predict: 'y = 1'",r"When g(z) $\geq$ 0.5, z $\geq$ 0, $\theta^T$ X $\geq$ 0")
+ sigmoid_exp2 = TextMobject(r"Predict: 'y = 0'", r"When g(z) $\leq$ 0.5, z $\leq$ 0, $\theta^T$ X $\leq$ 0")
+ sigmoid_exp1.scale(0.5)
+ sigmoid_exp2.scale(0.5)
+ sigmoid_exp1.set_color(PURPLE)
+ sigmoid_exp2.set_color(PURPLE)
+
+ sigmoid_exp1[0].next_to(sigmoid_exp, 1.5*DOWN)
+ sigmoid_exp1[1].next_to(sigmoid_exp1[0], DOWN)
+ sigmoid_exp2[0].next_to(sigmoid_exp1[1], 1.5*DOWN)
+ sigmoid_exp2[1].next_to(sigmoid_exp2[0], DOWN)
+
+
+ self.play(Write(sigmoid_exp))
+ self.play(Write(sigmoid_exp1[0]), Write(sigmoid_exp1[1]))
+ self.play(Write(sigmoid_exp2[0]), Write(sigmoid_exp2[1]))
+ self.wait(2)
+
+
+ neuron1 = Circle()
+ neuron1.set_fill(YELLOW_A, opacity = 0.5)
+
+ neuron2 = Circle()
+ neuron2.set_fill(ORANGE, opacity = 0.5)
+
+ neuron3 = Circle()
+ neuron3.set_fill(GREEN_E, opacity = 0.5)
+
+ neuron1.move_to(2*UP+RIGHT)
+ neuron2.move_to(2*DOWN+RIGHT)
+ neuron3.move_to(4*RIGHT)
+
+ arrow1 = Arrow(neuron1.get_right(),neuron3.get_left(),buff=0.1)
+ arrow1.set_color(RED)
+ arrow2 = Arrow(neuron2.get_right(),neuron3.get_left(),buff=0.1)
+ arrow2.set_color(RED)
+
+ arrow3 = Arrow(neuron3.get_right(),7*RIGHT,buff=0.1)
+ arrow3.set_color(RED)
+
+
+ sign1 = TextMobject("+1")
+ sign1.move_to(2*UP+RIGHT)
+ sign1.scale(2)
+ sign2 = TextMobject(r"$x_1$")
+ sign2.move_to(2*DOWN+RIGHT)
+ sign2.scale(2)
+ sign3 = TextMobject(r"$h_{\theta}(x)$")
+ sign3.move_to(6*RIGHT+0.4*DOWN)
+ sign3.scale(0.7)
+ sign4 = TextMobject(r"$= g(10 - 20x_1)$")
+ sign4.next_to(sign3,DOWN)
+ sign4.scale(0.5)
+ sign5 = TextMobject(r"$= g(10 - 20x_1)$")
+ sign5.next_to(sign3,DOWN)
+ sign5.scale(0.5)
+ sign6 = TextMobject(r"$= g(10 - 20x_1)$")
+ sign6.next_to(sign3,DOWN)
+ sign6.scale(0.5)
+
+
+ weight1 = TextMobject("10")
+ weight1.next_to(arrow1,UP)
+ weight2 = TextMobject("-20")
+ weight2.next_to(arrow2,DOWN)
+
+ gate = TextMobject("NOT GATE")
+ gate.set_color_by_gradient(RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE)
+ gate.scale(1.5)
+ gate.move_to(3*RIGHT+3.5*UP)
+
+
+
+ truth_table = TextMobject(r"\begin{displaymath}\begin{array}{|c|c|} x & y\\ \hline 1 & 0 \\0 & 1 \\\end{array}\end{displaymath}")
+ truth_table.next_to(sigmoid_exp2[1], 3*DOWN)
+
+ values = TextMobject("1", "0")
+ values.scale(2)
+
+ sign4_trans1 = TextMobject(r"$= g(10 - 20(1))$")
+ sign4_trans2 = TextMobject(r"$= g(10 - 20(0))$")
+ sign4_trans1.next_to(sign3,DOWN)
+ sign4_trans2.next_to(sign3,DOWN)
+ sign4_trans1.scale(0.5)
+ sign4_trans2.scale(0.5)
+
+
+
+ output1 = TextMobject("y = 0")
+ output2 = TextMobject("y = 1")
+ output1.next_to(sign4,DOWN)
+ output2.next_to(sign4,DOWN)
+ output1.scale(1.5)
+ output2.scale(1.5)
+
+
+
+ self.play(ShowCreation(neuron1),ShowCreation(neuron2))
+ self.play(ShowCreation(neuron3))
+ self.play(ShowCreation(sign1),ShowCreation(sign2))
+ self.wait(1)
+
+ self.play(GrowArrow(arrow1))
+ self.play(GrowArrow(arrow2))
+ self.play(ShowCreation(weight1),ShowCreation(weight2))
+
+
+
+ self.play(GrowArrow(arrow3))
+ self.play(Write(sign3),Write(sign4))
+
+ self.play(Write(gate))
+ self.play(ShowCreation(truth_table))
+
+ self.play(ApplyMethod(values[0].move_to, 2*DOWN+RIGHT))
+ self.play(FadeOut(values[0]))
+ self.play(Transform(sign4,sign4_trans1))
+ self.play(Write(output1))
+ self.wait(1)
+ self.play(FadeOut(output1))
+ self.play(Transform(sign4, sign5))
+
+
+ self.play(ApplyMethod(values[1].move_to, 2*DOWN+RIGHT))
+ self.play(FadeOut(values[1]))
+ self.play(Transform(sign4,sign4_trans2))
+ self.play(Write(output2))
+ self.wait(1)
+ self.play(FadeOut(output2))
+ self.play(Transform(sign4, sign6))
+
+ self.wait(2)
+
+
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif Binary files differnew file mode 100644 index 0000000..bea9c7b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif Binary files differnew file mode 100644 index 0000000..6801e4f --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif Binary files differnew file mode 100644 index 0000000..9576b4a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif Binary files differnew file mode 100644 index 0000000..b4ac106 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif Binary files differnew file mode 100644 index 0000000..e4dc80d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif Binary files differnew file mode 100644 index 0000000..8bb176a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif Binary files differnew file mode 100644 index 0000000..a22f1b8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif 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..17fcde0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/README.md @@ -0,0 +1,4 @@ +**file1_flux@_various_points.py**
+![file1_flux@_various_points](file1_flux@_various_points.gif)
+**file2_different_valuesof_Div.py**
+![file2_different_valuesof_Div](file2_different_valuesof_Div.gif)
diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.gif Binary files differnew file mode 100644 index 0000000..6c32b94 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.py new file mode 100644 index 0000000..6727982 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file1_flux@_various_points.py @@ -0,0 +1,60 @@ +from manimlib.imports import * +def pendulum_vector_field_func(point): + #theta, omega = point[:2] + return np.array([ + 5*point[0]+point[1], + 3*point[1]+3*point[1], + 0, + ]) +class SF(Scene): + CONFIG = { + #"func": cylinder_flow_vector_field, + "flow_time": 5, + } + def initialize_vector_field(self): + self.vector_field = VectorField( + pendulum_vector_field_func, + ) + self.vector_field.sort(get_norm) + def construct(self): + # plane = NumberPlane(color=RED) + # plane.add(plane.get_axis_labels()) + # self.add(plane) + + A=TextMobject("The net flux through the green circular region is zero",tex_to_color_map={"green": GREEN}) + B=TextMobject("The net flux through the blue circular region is non-zero",tex_to_color_map={"blue": BLUE}) + + c1=Circle(color=GREEN, radius=1.5) + c1.shift(4*LEFT+2.2*UP) + c2=Circle(color=BLUE, radius=1.5) + + + + + self.play(ShowCreation(A)) + self.wait(0.5) + self.play(ApplyMethod(A.shift, (0.8*UP+0.2*LEFT))) + self.play(ShowCreation(B)) + # self.play(ApplyMethod(B.shift, (2*UP))) + self.wait(2) + self.play(FadeOut(A),FadeOut(B)) + self.initialize_vector_field() + field = self.vector_field + self.play(ShowCreation(field), run_time=4) + self.play(ShowCreation(c1)) + self.play(ShowCreation(c2)) + self.wait(1) + lines = StreamLines( + pendulum_vector_field_func, + virtual_time=3, + min_magnitude=0, + max_magnitude=2, + ) + self.add(AnimatedStreamLines( + lines, + line_anim_class=ShowPassingFlash + )) + self.wait(2) + phase_point = VectorizedPoint(1*UP+1*RIGHT) + self.add(move_along_vector_field(phase_point, pendulum_vector_field_func)) + self.wait(2) diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.gif Binary files differnew file mode 100644 index 0000000..477c311 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.py new file mode 100644 index 0000000..921047d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/divergence-gauss-theorem/file2_different_valuesof_Div.py @@ -0,0 +1,91 @@ +from manimlib.imports import * +class Div(Scene): + def construct(self): + one=TextMobject(r"Div$ \vec{F} < 0$ ").set_color(RED) + two=TextMobject(r"Div$ \vec{F} = 0$ ").set_color(BLUE) + three=TextMobject(r"Div$ \vec{F} > 0$ ").set_color(YELLOW) + + one.shift(2.3*DOWN) + two.shift(2.3*DOWN) + three.shift(2.3*DOWN) + + + a=Dot(color=RED) + a.shift(0.1*LEFT) + b=Dot(color=BLUE) + b.shift(0.1*LEFT) + c=Dot(color=YELLOW) + c.shift(0.1*LEFT) + + rot=[0*DEGREES,45*DEGREES,90*DEGREES,135*DEGREES,180*DEGREES,225*DEGREES,270*DEGREES,315*DEGREES] + rot2=[180*DEGREES,180*DEGREES,180*DEGREES,180*DEGREES,180*DEGREES,180*DEGREES,180*DEGREES,180*DEGREES] + shift=[RIGHT,0.7*RIGHT+0.7*UP,UP,0.7*LEFT+0.7*UP,LEFT,0.7*LEFT+0.7*DOWN,DOWN,0.7*RIGHT+0.7*DOWN] + shift2=[RIGHT,RIGHT+UP,RIGHT+DOWN,UP,DOWN,LEFT,LEFT+UP,LEFT+DOWN] + + + + u=[Vector(color=RED),Vector(color=RED),Vector(color=RED),Vector(color=RED), + Vector(color=RED),Vector(color=RED),Vector(color=RED),Vector(color=RED)] + + + [u[i].rotate(rot[i]) for i in range(8) ] + [u[i].rotate(rot2[i]) for i in range(8) ] + [u[i].shift(shift[i]) for i in range(8) ] + + + divone=VGroup(*u) + divone.shift(0.6*LEFT) + + + v=[Vector(color=BLUE),Vector(color=BLUE),Vector(color=BLUE),Vector(color=BLUE), + Vector(color=BLUE),Vector(color=BLUE),Vector(color=BLUE),Vector(color=BLUE)] + + + [v[i].rotate(45*DEGREES) for i in range(8)] + [v[i].shift(shift2[i]) for i in range(8) ] + + divtwo=VGroup(*v) + divtwo.shift(0.6*LEFT) + + + w=[Vector(color=YELLOW),Vector(color=YELLOW),Vector(color=YELLOW),Vector(color=YELLOW), + Vector(color=YELLOW),Vector(color=YELLOW),Vector(color=YELLOW),Vector(color=YELLOW)] + + + [w[i].rotate(rot[i]) for i in range(8)] + [w[i].shift(shift[i]) for i in range(8) ] + + + divthree=VGroup(*w) + divthree.shift(0.6*LEFT) + + + + + self.play(ShowCreation(a),ShowCreation(divone)) + self.play(ShowCreation(one)) + self.wait(1) + self.play(FadeOut(a),FadeOut(divone),FadeOut(one)) + + self.play(ShowCreation(b),ShowCreation(divtwo)) + self.play(ShowCreation(two)) + self.wait(1) + self.play(FadeOut(b),FadeOut(divtwo),FadeOut(two)) + + + self.play(ShowCreation(c),ShowCreation(divthree)) + self.play(ShowCreation(three)) + self.wait(1) + self.play(FadeOut(c),FadeOut(divthree),FadeOut(three)) + self.wait(0.5) + + + + + + + + + + + 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..97d6d10 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/README.md @@ -0,0 +1,6 @@ +**file1_flux_through_circle.py** +![file1_flux_through_circle](file1_flux_through_circle.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_circle.gif b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_circle.gif Binary files differnew file mode 100644 index 0000000..c00076b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_circle.gif diff --git a/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_circle.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_circle.py new file mode 100644 index 0000000..e418a96 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file1_flux_through_circle.py @@ -0,0 +1,43 @@ +from manimlib.imports import * +def pendulum_vector_field_func(point): + #theta, omega = point[:2] + return np.array([ + point[0], + point[1], + point[2], + ]) +class F2D(Scene): + CONFIG = { + # "func": cylinder_flow_vec or_field, + "flow_time": 5, + } + def initialize_vector_field(self): + self.vector_field = VectorField( + pendulum_vector_field_func, + ) + self.vector_field.sort(get_norm) + def construct(self): + # plane = NumberPlane(color=RED) + # plane.add(plane.get_axis_labels()) + # self.add(plane) + self.initialize_vector_field() + + field = self.vector_field + c1=Circle(radius=3,color=BLUE) + self.play(ShowCreation(field), run_time=7) + self.play(ShowCreation(c1)) + self.wait(3) + lines = StreamLines( + pendulum_vector_field_func, + virtual_time=3, + min_magnitude=0, + max_magnitude=2, + ) + self.add(AnimatedStreamLines( + lines, + line_anim_class=ShowPassingFlash + )) + self.wait(2) + phase_point = VectorizedPoint(1*UP+1*RIGHT) + self.add(move_along_vector_field(phase_point, pendulum_vector_field_func)) + self.wait(2) 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..001edb8 --- /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..146d955 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/flux/file4_cube_surface.py @@ -0,0 +1,196 @@ +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.rotate(PI,axis=OUT) + 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=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY)] + + + + + + [veclist1[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist1[i].rotate(PI/6,axis=OUT) for i in range(42)] + [veclist1[i].rotate(PI/8,axis=DOWN) for i in range(42)] + vectorfield1=VGroup(*veclist1) + [veclist1[i].shift(spaceloc[i]) for i in range(42)] + + + + + veclist2=[Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY)] + + + + + + [veclist2[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist2[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist2[i].rotate(PI/6,axis=OUT) for i in range(42)] + [veclist2[i].rotate(PI/8,axis=DOWN) for i in range(42)] + vectorfield2=VGroup(*veclist2) + [veclist2[i].shift(spaceloc[i]) for i in range(42)] + + + + veclist3=[Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY)] + + + + + + [veclist3[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist3[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist3[i].rotate(PI/6,axis=OUT) for i in range(42)] + [veclist3[i].rotate(PI/8,axis=DOWN) for i in range(42)] + vectorfield3=VGroup(*veclist3) + [veclist3[i].shift(spaceloc[i]) for i in range(42)] + + + + + veclist4=[Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY)] + + + + + + [veclist4[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist4[i].rotate(PI/4,axis=RIGHT) for i in range(42)] + [veclist4[i].rotate(PI/6,axis=OUT) for i in range(42)] + [veclist4[i].rotate(PI/8,axis=DOWN) for i in range(42)] + vectorfield4=VGroup(*veclist4) + [veclist4[i].shift(spaceloc[i]) for i in range(42)] + + + 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.3) + + + fv=[Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY),Vector(color=GREY),Vector(color=GREY),Vector(color=GREY), + Vector(color=GREY) + ] + + spaceloc2 = [[1.5,0.5,0.5],[1.5,1,0.5],[1.5,1.5,0.5], + [1.5,0.5,1],[1.5,1,1],[1.5,1.5,1], + [1.5,0.5,1.5],[1.5,1,1.5],[1.5,1.5,1.5] + ] + [fv[i].rotate(PI/4,axis=RIGHT) for i in range(9)] + [fv[i].rotate(PI/6,axis=OUT) for i in range(9)] + [fv[i].rotate(PI/8,axis=DOWN) for i in range(9)] + [fv[i].shift(spaceloc2[i]) for i in range(9)] + fvfield=VGroup(*fv) + fvfield.shift(2*DOWN) + fvfield.scale(1.3) + + flux=TextMobject("Flux through one side of the cube").set_color(GOLD) + flux.shift(3.5*UP+0.5*LEFT) + + + alll=[vectorfield1,vectorfield2,vectorfield3,vectorfield4,fvfield] + alllvectors=VGroup(*alll) + + + + self.set_camera_orientation(phi=70 * DEGREES,theta=-75*DEGREES) + self.play(ShowCreation(axes),ShowCreation(axis_label)) + self.begin_ambient_camera_rotation(rate=0.2) + self.play(ShowCreation(alllvectors)) + # self.add(fvfield) + + 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(5) + self.stop_ambient_camera_rotation() + self.wait(1) diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/Animation.py b/FSF-2020/calculus-of-several-variables/triple-and-surface-integrals/strokes-theorem/README.md index e69de29..e69de29 100644 --- a/FSF-2020/linear-algebra/linear-transformations/Linear Transformations (Linear Maps)/Animation.py +++ 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/intro-to-calculus/introderivative/derivative1.py b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative1.py new file mode 100644 index 0000000..79a6fc6 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative1.py @@ -0,0 +1,55 @@ +from manimlib.imports import * +class derivative1(GraphScene, Scene): + def setup(self): + GraphScene.setup(self) + CONFIG = { + "y_max" : 4, + "y_min" : -2, + "x_max" : 4, + "x_min" : -2, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+2*DOWN+4*LEFT, + "x_labeled_nums": list(range(-2,5)), + "y_labeled_nums": list(range(-2,5)), + "x_axis_label":"$x$", + "y_axis_label":r"$f(x)=y= 3-\frac { 3 }{ 2 } x$", + "x_axis_width": 5, + "y_axis_height": 5, + } + 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) + + text1 = TextMobject("") + text2 = TexMobject("{y}_{2}-{y}_{1}") + text2 = TexMobject("{x}_{2}-{x}_{1}") + text3 = TexMobject(r"m\quad =\frac { { y }_{ 2 }-{ y }_{ 1 } }{ { x }_{ 2 }-{ x }_{ 1 } }").move_to(np.array([3,0,0])) + text4 = TexMobject(r"m\quad =\frac { 3 }{ -2 }").move_to(np.array([3,0,0])) + text5 = TexMobject(r"m\quad =\quad -1.5").move_to(np.array([3,0,0])) + self.setup_axes() + graph_1 = self.get_graph(lambda x : 3-1.5*x, color = GREEN_SCREEN, x_min = -1, x_max = 3) + graph_2 = self.get_graph(lambda x : 3.1-1.5*x, color = ORANGE, x_min = 0, x_max = 2) + dot1 = Dot() + dot2 = SmallDot(self.graph_origin+1.7*RIGHT, color = PINK) + dot3 = SmallDot(self.graph_origin+2.5*UP, color = RED_B) + vec1 = Vector(2.5*DOWN, color = PINK).shift(self.graph_origin+2.5*UP) + vec2 = Vector(1.7*RIGHT, color = RED_B).shift(self.graph_origin) + brace1 = Brace(vec1, LEFT) + brace2 = Brace(vec2, DOWN) + br1text = brace1.get_text(r"${y}_{2}-{y}_{1}$").next_to(brace1, LEFT) + br2text = brace2.get_text(r"${x}_{2}-{x}_{1}$").next_to(brace2, DOWN) + self.play(ShowCreation(graph_1), ShowCreation(dot2), ShowCreation(dot3)) + self.play(MoveAlongPath(dot1, graph_2), ShowCreation(vec1), ShowCreation(vec2), run_time = 3) + self.wait(1) + self.play(ShowCreation(brace1), ShowCreation(brace2)) + self.play(ShowCreation(br1text), ShowCreation(br2text)) + self.wait(2) + self.play(GrowFromCenter(text3)) + self.wait(2.5) + self.play(ReplacementTransform(text3, text4)) + self.wait(2) + self.play(ReplacementTransform(text4, text5)) + self.wait(2) diff --git a/FSF-2020/calculus/intro-to-calculus/introderivative/derivative2.py b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative2.py new file mode 100644 index 0000000..d6aab15 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative2.py @@ -0,0 +1,78 @@ +from manimlib.imports import * +class derivative2(GraphScene, MovingCameraScene): + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + CONFIG = { + "y_max" : 100, + "y_min" : 0, + "x_max" : 10, + "x_min" : 0, + "y_tick_frequency" : 100, + "x_tick_frequency" : 10, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN, + "x_labeled_nums": None,#list(range(0,11)), + "y_labeled_nums": None,#list(range(0,101))[::10], + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 5, + "y_axis_height": 5, + "start_x" : 2, + "start_dx" : 6, + "df_color" : YELLOW, + "dx_color" : GREEN, + "secant_line_color" : MAROON_B, + "zoomed_camera_frame_starting_position": ORIGIN+2*DOWN+6*LEFT, + } + def construct(self): + self.setup() + self.camera_frame.save_state() + self.graph_origin = ORIGIN+2*DOWN+6*LEFT + self.setup_axes() + graph23 = self.get_graph(lambda x : x**2+7, color = GREEN_SCREEN, x_min = 0, x_max = 10) + graph24 = self.get_graph(lambda x : x**2+7, color = GREEN_SCREEN, x_min = 8, x_max = 2.01) + line_1 = DashedVMobject(Line(np.array([-5,-2,0]), np.array([-5,-1.42,0]))) + textdef = TextMobject("") + text1 = TexMobject("{ x }_{ 0 }").move_to(np.array([-5,-2.2,0])) + text2 = TextMobject("The line becomes tangential to the curve").move_to(self.graph_origin+RIGHT+0.5*UP).scale(0.01) + text3 = TexMobject(r"\frac { df }{ dx } =\frac { f({ x }_{ 0 }+h)-f({ x }_{ 0 }) }{ h-0 }").move_to(2*RIGHT) + text4 = TexMobject(r"\frac { df }{ dx } =\lim _{ h\rightarrow 0 }{ \frac { f({ x }_{ 0 }+h)-f({ x }_{ 0 }) }{ h } }").move_to(2*RIGHT) + squareobj = Square(side_length = 15).move_to(self.graph_origin+RIGHT+0.53*UP) + ss_group = self.get_secant_slope_group( + self.start_x, graph23, + dx = self.start_dx, + dx_label = "h", + df_label = "df", + df_line_color = self.df_color, + dx_line_color = self.dx_color, + secant_line_color = self.secant_line_color, + dot_df_top = True, + dot_dx_start = True, + dot_df_top_label = "Q", + dot_dx_start_label = "P", + secant_line_length = 8 + ) + self.play(ShowCreation(graph23)) + self.wait() + self.play(ShowCreation(ss_group.secant_line)) + self.add(text1) + self.play(ShowCreation(line_1)) + self.wait(3) + self.play(ShowCreation(ss_group.dx_line)) + self.play(ShowCreation(ss_group.dx_label)) + self.play(ShowCreation(ss_group.df_line)) + self.play(Write(ss_group.df_label)) + self.play(ShowCreation(ss_group.dot_df_top), ShowCreation(ss_group.dot_dx_start)) + self.play(ShowCreation(ss_group.dot_df_top_label), ShowCreation(ss_group.dot_dx_start_label)) + self.wait() + self.play(ShowCreation(text3)) + self.wait(2) + self.play(ReplacementTransform(text3, text4)) + self.animate_secant_slope_group_change(ss_group, target_dx = 0.01, run_time = 5) + self.wait(2) + self.play(self.camera_frame.set_width,0.2,self.camera_frame.move_to,squareobj,run_time = 2) + self.wait() + self.play(ShowCreation(text2)) + self.wait(3) diff --git a/FSF-2020/calculus/intro-to-calculus/introderivative/derivative3.py b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative3.py new file mode 100644 index 0000000..ebbacb1 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/introderivative/derivative3.py @@ -0,0 +1,57 @@ +from manimlib.imports import * +class derivative3(GraphScene, Scene): + def setup(self): + Scene.setup(self) + #ZoomedScene.setup(self) + CONFIG = { + "y_max" : 8, + "y_min" : 0, + "x_max" : 11, + "x_min" : 0, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+3*DOWN+6.5*LEFT, + "x_labeled_nums": list(range(0,12))[::1], + "y_labeled_nums": list(range(0,9))[::1], + "x_axis_label":"$t$", + "y_axis_label":"$s$", + "x_axis_width": 5, + "y_axis_height": 5, + } + 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) + + self.setup_axes() + graph_1 = self.get_graph(lambda x : -(x-2)**2+4, color = GOLD_A, x_min = 0, x_max = 1.5) + graph_2 = self.get_graph(lambda x : 1*x+2.25, color = GOLD_A, x_min = 1.5, x_max = 5) + graph_3 = self.get_graph(lambda x : 7.25, color = GOLD_A, x_min = 5, x_max = 8) + graph_4 = self.get_graph(lambda x : -3.625*x + 36.25, color = GOLD_A, x_min = 8, x_max = 10) + + self.y_max = 5 + self.x_max = 10 + self.x_min = 0 + self.y_min = -5 + self.x_labeled_nums = list(range(0,11)) + self.y_labeled_nums = list(range(-5,6))[::1] + self.x_axis_label = r"$t$" + self.y_axis_label = r"$v$" + self.y_tick_frequency = 1 + self.x_tick_frequency = 1 + self.graph_origin = ORIGIN+1*RIGHT + self.setup_axes() + graph_5 = self.get_graph(lambda x : 2*(x-2)+4, color = GREEN_SCREEN, x_min = 0, x_max = 1.5) + graph_6 = self.get_graph(lambda x : 3, color = GREEN_SCREEN, x_min = 1.5, x_max = 5) + graph_7 = self.get_graph(lambda x : 0, color = GREEN_SCREEN, x_min = 5, x_max = 8) + graph_8 = self.get_graph(lambda x : -3.625, color = GREEN_SCREEN, x_min = 8, x_max = 10) + line1 = DashedVMobject(Line(self.graph_origin+2.5*RIGHT, self.graph_origin+2.5*RIGHT+1.5*UP)) + line2 = DashedVMobject(Line(self.graph_origin+4*RIGHT, self.graph_origin+4*RIGHT+1.835*DOWN)) + self.play(ShowCreation(graph_1), ShowCreation(graph_5), run_time = 3) + self.play(ShowCreation(graph_2), ShowCreation(graph_6), run_time = 3) + self.add(line1) + self.play(ShowCreation(graph_3), ShowCreation(graph_7), run_time = 3) + self.add(line2) + self.play(ShowCreation(graph_4), ShowCreation(graph_8), run_time = 3) + self.wait(3) diff --git a/FSF-2020/calculus/intro-to-calculus/limit/Test1.py b/FSF-2020/calculus/intro-to-calculus/limit/Test1.py new file mode 100644 index 0000000..bd7d2a6 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/limit/Test1.py @@ -0,0 +1,34 @@ +from manimlib.imports import * +class Test1(GraphScene): + CONFIG = { + "y_max" : 5, + "y_min" : -5, + "x_max" : 5, + "x_min" : -5, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : BLUE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN, + "x_labeled_nums": list(range(-5,6)), + "y_labeled_nums": list(range(-5,6)), + "x_axis_label":"$x$", + "y_axis_label":"${ f }_{ 1 }(x)$" + } + def construct(self): + self.setup_axes() + cir1 = Circle(radius = 0.1, color = BLUE) + graph_1 = self.get_graph(lambda x : x+2, + color = GREEN, + x_min = -5, # Domain 1 + x_max = +1.9 + ) + graph_2 =self.get_graph(lambda x : x+2, + color = GREEN, + x_min = 2.1, # Domain 2 + x_max = 5 + ) + cir1.move_to(np.array([1,2,0])) + self.play(ShowCreation(graph_1)) + self.play(ShowCreation(cir1)) + self.play(ShowCreation(graph_2)) diff --git a/FSF-2020/calculus/intro-to-calculus/limit/Test2.py b/FSF-2020/calculus/intro-to-calculus/limit/Test2.py new file mode 100644 index 0000000..0efb565 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/limit/Test2.py @@ -0,0 +1,26 @@ +from manimlib.imports import * +class Test2(GraphScene): + CONFIG = { + "y_max" : 5, + "y_min" : -5, + "x_max" : 5, + "x_min" : -5, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : BLUE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN, + "x_labeled_nums": list(range(-5,6)), + "y_labeled_nums": list(range(-5,6)), + "x_axis_label":"$x$", + "y_axis_label":"${ f }_{ 1 }(x)$" + } + def construct(self): + self.setup_axes() + graph_1 = self.get_graph(lambda x : x+2, + color = GREEN, + x_min = -5, # Domain 1 + x_max = +5 + ) + self.play(ShowCreation(graph_1)) + self.wait() diff --git a/FSF-2020/calculus/intro-to-calculus/limit/limit1.py b/FSF-2020/calculus/intro-to-calculus/limit/limit1.py new file mode 100644 index 0000000..fe5cb1e --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/limit/limit1.py @@ -0,0 +1,105 @@ +from manimlib.imports import * +class limit1(GraphScene,MovingCameraScene): + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + CONFIG = { + "y_max" : 1, + "y_min" : 0, + "x_max" : 1, + "x_min" : -1, + "y_tick_frequency" : 0.2, + "x_tick_frequency" : 0.2, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+3*DOWN, + "x_labeled_nums": list(range(-1,2)), + "y_labeled_nums": list(range(0,2)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + 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) + + dot1 = SmallDot(np.array([0.025,-2.975,0])) + dot2 = SmallDot(np.array([-0.025,-2.975,0])) + sqr = Square(side_length = 15.0).move_to(np.array([0,-3,0])) + brline1 = DashedVMobject(Line(np.array([0.15,-3,0]), np.array([0.15,-2.85,0]))) + brline2 = DashedVMobject(Line(np.array([0.025,-3,0]), np.array([0.025,-2.975,0]))) + brline3 = DashedVMobject(Line(np.array([-0.15,-3,0]), np.array([-0.15,-2.85,0]))) + brline4 = DashedVMobject(Line(np.array([-0.025,-3,0]), np.array([-0.025,-2.975,0]))) + textdef = TextMobject("") + text003 = TextMobject("0.03").move_to(np.array([0.15,-3.05,0])).scale(0.1) + textazero1 = TexMobject(r"\approx 0").move_to(np.array([0.04,-3.05,0])).scale(0.1) + textazero2 = TexMobject(r"\approx 0").move_to(np.array([-0.04,-3.05,0])).scale(0.1) + textm003 = TextMobject("-0.03").move_to(np.array([-0.15,-3.05,0])).scale(0.1) + text2 = TextMobject("Let f(x) = |x|. We'll check neighbourhood of origin") + text3 = TextMobject("h has to be a very small number greater than 0").move_to(np.array([0,-3.3,0])).scale(0.2) + text4 = TextMobject("The point travels through range of neighbourhood").move_to(np.array([0,-3.3,0])).scale(0.19) + text5 = TextMobject("let h be equal to 0.03").move_to(np.array([0,-3.3,0])).scale(0.25) + text6 = TextMobject("Notice how the point never touches the origin").move_to(np.array([0,-3.3,0])).scale(0.2) + text7 = TextMobject("Green line shows the Right hand neighbourhood of origin").move_to(np.array([0,-3.3,0])).scale(0.17) + text8 = TextMobject("The point is approaching (0,0) for the values of x which are positive").move_to(np.array([0,-3.3,0])).scale(0.1) + text9 = TextMobject("Values of x are tending to 0 from positive side").move_to(np.array([0,-3.3,0])).scale(0.19) + text10 = TexMobject(r"\text {Notation for this is }",r"x\rightarrow { 0 }^{ + }").move_to(np.array([0,-3.3,0])).scale(0.25) + text11 = TextMobject("Similar case can be made for negative values of x").move_to(np.array([0,-3.3,0])).scale(0.19) + text12 = TextMobject("The point is approaching (0,0) for the values of x which are negative").move_to(np.array([0,-3.3,0])).scale(0.1) + text13 = TextMobject("Values of x are tending to 0 from negative side").move_to(np.array([0,-3.3,0])).scale(0.19) + text14 = TexMobject(r"\text {Notation for this is }",r"x\rightarrow { 0 }^{ - }").move_to(np.array([0,-3.3,0])).scale(0.25) + + + self.play(FadeIn(text2), run_time = 1.5) + self.wait(2.5) + self.setup_axes() + graph_1 = self.get_graph(lambda x : x, color = RED, x_min = 0, x_max = 1) + graph_2 = self.get_graph(lambda x : -x, color = RED, x_min = 0, x_max = -1) + graph_3 = self.get_graph(lambda x : x,color = RED, x_min = 0.005, x_max = 0.03) + graph_4 = self.get_graph(lambda x : x,color = GREEN_SCREEN, x_min = 0.03, x_max = 0.005) + graph_5 = self.get_graph(lambda x : -x,color = GREEN_SCREEN, x_min = -0.03, x_max = -0.005) + grp1 = VGroup(graph_1,graph_2) + grp2 = VGroup(brline2, textazero1) + grp3 = VGroup(textazero2, textm003, brline3, brline4) + self.play(ShowCreation(grp1)) + self.add(sqr) + self.play(ReplacementTransform(text2, text3)) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width,2.25,self.camera_frame.move_to,sqr,run_time = 2) + self.wait(2.5) + self.play(ReplacementTransform(text3, text4), ShowCreation(dot1)) + self.wait(2.5) + self.play(ReplacementTransform(text4, text5), ShowCreation(brline1), ShowCreation(text003)) + self.wait(2.5) + for i in range(0,3): + self.play(MoveAlongPath(dot1,graph_3), run_time = 0.5) + self.play(MoveAlongPath(dot1,graph_4), run_time = 0.5) + self.play(ReplacementTransform(text5, text6), ShowCreation(grp2)) + self.wait(2) + self.play(FadeOut(dot1)) + self.add(graph_4) + self.play(ReplacementTransform(text6, text7)) + self.wait(2.5) + self.play(ReplacementTransform(text7,text8)) + for i in range(0,3): + self.play(MoveAlongPath(dot1,graph_4), run_time = 0.7) + self.play(ReplacementTransform(text8, text9)) + self.wait(2.5) + self.play(ReplacementTransform(text9, text10)) + self.wait(2.5) + self.play(ShowCreation(grp3), ReplacementTransform(text10, text11), FadeOut(dot1)) + self.add(graph_5) + for i in range(0,3): + self.play(MoveAlongPath(dot2, graph_5), run_time = 0.7) + self.play(ReplacementTransform(text11, text12)) + self.wait(2.5) + self.play(ReplacementTransform(text12, text13)) + self.wait(2.5) + self.play(ReplacementTransform(text13, text14)) + self.wait(2) + self.play(FadeOut(dot2), ReplacementTransform(text14, textdef)) + self.wait(2) + self.play(Restore(self.camera_frame)) + + self.wait(2.5) diff --git a/FSF-2020/calculus/intro-to-calculus/limit/limit3.py b/FSF-2020/calculus/intro-to-calculus/limit/limit3.py new file mode 100644 index 0000000..a4f07d7 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/limit/limit3.py @@ -0,0 +1,95 @@ +from manimlib.imports import * +class limit3(GraphScene, MovingCameraScene): + def setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + CONFIG = { + "y_max" : 10, + "y_min" : 0, + "x_max" : 100, + "x_min" : 0, + "y_tick_frequency" : 1, + "x_tick_frequency" : 10, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+3*DOWN+4*LEFT, + "x_labeled_nums": list(range(0,101))[::10], + "y_labeled_nums": list(range(0,11)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + 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) + sqr1 = Square(side_length = 15).move_to(np.array([1,0.5,0])) + sqr2 = Square(side_length = 15).move_to(np.array([-4,-3,0])) + + textdef = TextMobject("") + text20 = TextMobject("f(x) is not defined at x=50").move_to(np.array([1,0.3,0])).scale(0.2) + text21 = TexMobject(r"\text {f(x) is not defined in interval }",r" (-\infty ,\quad 1]").move_to(np.array([-4,-3.2,0])).scale(0.18) + text22 = TextMobject("1").move_to(np.array([-3.9,-3.05,0])).scale(0.2) + text1 = TexMobject(r"\text {Let }" ,r"f\left( x \right) =\begin{cases} \sqrt { x-1 } ,x\in \quad (1,\infty )-50 \end{cases}") + text2 = TextMobject("Graph of f(x) is ") + text3 = TextMobject("Right hand neighbour of 50 will approximately be 50.000001").move_to(np.array([1,0.3,0])).scale(0.15) + text4 = TextMobject("Left hand neighbour of 50 will approximately be 49.999999").move_to(np.array([1,0.3,0])).scale(0.15) + text5 = TexMobject(r"\text {Hence R.H.L }", r"=\lim _{ x\rightarrow { 50 }^{ + } }{ \sqrt { 50.000001 - 1 } } \approx 7.000000071").move_to(np.array([1,0.3,0])).scale(0.13) + text6 = TexMobject(r"\text{Hence L.H.L }", r" = \lim _{ x\rightarrow { 50 }^{ - } }{ \sqrt { 49.999999-1 } }\approx 6.999999929").move_to(np.array([1,0.3,0])).scale(0.13) + text7 = TextMobject("7.000000071").move_to(np.array([1.9,0.25,0])).scale(0.1) + text8 = TextMobject("6.999999929").move_to(np.array([0.1,0.25,0])).scale(0.1) + text9 = TexMobject(r"6.999999929\quad \approx \quad 7.000000071 \quad \approx 7").move_to(np.array([1,0.25,0])).scale(0.2) + text10 = TexMobject(r"\text{Because LHL }" ,r"\approx" ,r"\text{ RHL, Limit exists at x=50 and equals 7").move_to(np.array([1,0.25,0])).scale(0.13) + text11 = TextMobject("There is no Left hand neighbour of x=1").move_to(np.array([-4,-3.2,0])).scale(0.22) + text12 = TexMobject(r"\therefore\quad \lim _{ x\rightarrow 0 }{ f(x) } \quad =\quad \lim _{ x\rightarrow { 0 }^{ + } }{ f(x) } ").move_to(np.array([-4,-3.2,0])).scale(0.25) + text13 = TexMobject(r"\text {R.H.L =}",r" \lim _{ x\rightarrow { 0 }^{ + } }{ \sqrt { 1.000000000001-1 } } \quad \approx 0").move_to(np.array([-4,-3.2,0])).scale(0.13) + text14 = TexMobject(r"\therefore \quad \lim _{ x\rightarrow 0 }{ f(x)\quad =\quad 0 }").move_to(np.array([-4,-3.2,0])).scale(0.13) + self.camera_frame.save_state() + self.play(ShowCreation(text1)) + self.wait(3) + self.play(ReplacementTransform(text1, text2)) + self.wait() + self.play(ReplacementTransform(text2, textdef)) + self.setup_axes() + self.setup() + graph_1 = self.get_graph(lambda x : (x-1)**(1/2),color = PINK, x_min = 1, x_max = 49.9) + graph_2 = self.get_graph(lambda x : (x-1)**(1/2),color = PINK, x_min = 50.1, x_max = 100) + graph_3 = self.get_graph(lambda x : (x-1)**(1/2),color = PINK, x_min = 1.05, x_max = 1.001) + dot1 = SmallDot(color = PURPLE_A) + cir = Circle(radius = 0.01, color = GREEN_SCREEN).move_to(np.array([1,0.5,0])) + grp1 = VGroup(graph_1, graph_2, cir) + grp2 = VGroup(text7, text8) + self.play(ShowCreation(grp1)) + self.wait(2) + self.play(self.camera_frame.set_width,2.25,self.camera_frame.move_to,sqr1,run_time = 2) + self.wait(1) + self.play(ShowCreation(text20)) + self.wait(2) + self.play(ReplacementTransform(text20, text3)) + self.wait(3) + self.play(ReplacementTransform(text3, text5)) + self.wait(3) + self.play(ReplacementTransform(text5, text7), ShowCreation(text4)) + self.wait(4) + self.play(ReplacementTransform(text4, text6)) + self.wait(3) + self.play(ReplacementTransform(text6, text8)) + self.wait(1.5) + self.play(ReplacementTransform(grp2, text9)) + self.wait(1.5) + self.play(ReplacementTransform(text9, text10)) + self.wait(3) + self.play(self.camera_frame.set_width,2.25,self.camera_frame.move_to,sqr2,run_time = 2) + self.play(ShowCreation(text21), ShowCreation(text22)) + self.play(MoveAlongPath(dot1, graph_3), run_time = 3) + self.wait(3) + self.play(ReplacementTransform(text21, text11)) + self.wait(3) + self.play(ReplacementTransform(text11, text12)) + self.wait(3) + self.play(ReplacementTransform(text12, text13)) + self.wait(2) + self.play(ReplacementTransform(text13, text14)) + self.wait(3) + self.play(ReplacementTransform(text14, textdef)) + self.wait(2) diff --git a/FSF-2020/calculus/intro-to-calculus/limit/limitdef.py b/FSF-2020/calculus/intro-to-calculus/limit/limitdef.py new file mode 100644 index 0000000..15f2845 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/limit/limitdef.py @@ -0,0 +1,73 @@ +from manimlib.imports import * +class limitdef(GraphScene, Scene): + CONFIG = { + "y_max" : 5, + "y_min" : 0, + "x_max" : 5, + "x_min" : -5, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+2*DOWN, + "x_labeled_nums": None,#list(range(-1,2)), + "y_labeled_nums": None,#list(range(0,2)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + def construct(self): + Ldot = MediumDot(self.graph_origin+2.1*UP).set_color(GREEN_SCREEN) + adot = MediumDot(self.graph_origin+3*RIGHT).set_color(PINK) + epline1 = DashedVMobject(Line(self.graph_origin+1*LEFT+2.5*UP, self.graph_origin+4*RIGHT+2.5*UP)) + epline2 = DashedVMobject(Line(self.graph_origin+1*LEFT+1.7*UP, self.graph_origin+4*RIGHT+1.7*UP)) + epline3 = DashedVMobject(Line(self.graph_origin+3.5*RIGHT+0.5*DOWN, self.graph_origin+3.5*RIGHT+2.5*UP)) + epline4 = DashedVMobject(Line(self.graph_origin+2.5*RIGHT+0.5*DOWN, self.graph_origin+2.5*RIGHT+2.5*UP)) + Lline = Line(self.graph_origin+2.1*UP, self.graph_origin+3*RIGHT+2.1*UP).set_color(GREEN_SCREEN) + aline = Line(self.graph_origin+3*RIGHT, self.graph_origin+3*RIGHT+2.1*UP).set_color(PINK) + vertical_rectangle = Rectangle(width = 1, height = 0.8, color = PINK, fill_opacity = 0.5, fill_color = LIGHT_PINK).move_to(self.graph_origin+3*RIGHT+2.1*UP) + horizontal_rectangle = Rectangle(width = 1, height = 0.8, color = GREEN_SCREEN, fill_opacity = 0.5, fill_color = GREEN).move_to(self.graph_origin+3*RIGHT+2.1*UP) + vec1 = Line(self.graph_origin+2.5*UP, self.graph_origin+2.1*UP) + vec2 = Line(self.graph_origin+2.1*UP, self.graph_origin+1.7*UP) + vec3 = Line(self.graph_origin+2.5*RIGHT, self.graph_origin+3*RIGHT) + vec4 = Line(self.graph_origin+3*RIGHT, self.graph_origin+3.5*RIGHT) + brace1 = Brace(vec1, LEFT) + brace2 = Brace(vec2, LEFT) + brace3 = Brace(vec3, DOWN) + brace4 = Brace(vec4, DOWN) + br1text = brace1.get_text(r"$\epsilon$").next_to(brace1, LEFT) + br2text = brace2.get_text(r"$\epsilon$").next_to(brace2, LEFT) + br3text = brace3.get_text(r"$\delta$").next_to(brace3, DOWN) + br4text = brace4.get_text(r"$\delta$").next_to(brace4, DOWN) + epgrp = VGroup(epline1, epline2, Ldot, adot, Lline, aline, epline4, epline3) + recgrp = VGroup(vertical_rectangle, horizontal_rectangle) + epbrgrp = VGroup(brace1, brace2, br1text, br2text) + delbrgrp = VGroup(brace3, brace4, br3text, br4text) + self.setup_axes() + graph_1 = self.get_graph(lambda x :0.1*(x+1)**2 +0.5, x_min = -5, x_max = 5) + graph_2 = self.get_graph(lambda x : 0.1*(x+1)**2 +0.5, x_min = 2.5, x_max = 3.5, color = YELLOW_A) + graph_2.shift(2.5*LEFT) + self.play(ShowCreation(graph_1)) + self.wait(2) + self.play(ShowCreation(epgrp), ShowCreation(horizontal_rectangle), ShowCreation(vertical_rectangle)) + self.wait(2) + self.play(ShowCreation(epbrgrp)) + self.play(ShowCreation(delbrgrp)) + self.wait(2) + self.play(FadeOut(recgrp)) + self.wait(2) + for i in range(0,1): + self.play(ApplyMethod(graph_2.shift, 2.5*RIGHT)) + self.wait(1) + self.play(ApplyMethod(graph_2.shift, 1.7*DOWN)) + self.play(ApplyMethod(graph_2.shift, 1.7*UP)) + self.wait(1) + self.play(ApplyMethod(graph_2.shift, 2.5*LEFT)) + self.play(ApplyMethod(graph_2.shift, 2.5*RIGHT)) + self.wait(1) + self.play(ApplyMethod(graph_2.shift, 1.7*DOWN)) + self.play(ApplyMethod(graph_2.shift, 1.7*UP)) + self.wait(1) + self.play(ApplyMethod(graph_2.shift, 2.5*LEFT)) + self.wait() diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/README.md b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/README.md new file mode 100644 index 0000000..a9ad0bb --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/README.md @@ -0,0 +1,18 @@ +rierect1.gif +![rierect1](https://user-images.githubusercontent.com/61246381/87141790-3ad90800-c2c1-11ea-86e4-af05cb93fa2d.gif) + + +rierect2.gif +![rierect2](https://user-images.githubusercontent.com/61246381/87141870-5ba15d80-c2c1-11ea-9307-40acc2884d77.gif) + + +rierect3.gif +![rierect3](https://user-images.githubusercontent.com/61246381/87141949-6e1b9700-c2c1-11ea-9433-4f6be752aa55.gif) + + +RiemannRectanglesAnimation. +![RiemannRectanglesAnimation](https://user-images.githubusercontent.com/61246381/87142531-4a0c8580-c2c2-11ea-8f5e-9e854eae6eec.gif) + + +mimi.gif +![mimi](https://user-images.githubusercontent.com/61246381/87142127-b3d85f80-c2c1-11ea-864e-627e41d87ea2.gif) diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/RiemannRectanglesAnimation.py b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/RiemannRectanglesAnimation.py new file mode 100644 index 0000000..a278c9d --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/RiemannRectanglesAnimation.py @@ -0,0 +1,64 @@ +from manimlib.imports import * +class RiemannRectanglesAnimation(GraphScene): + CONFIG = { + "y_max": 5, + "x_max": 6, + "x_min": 0, + "y_min": 0, + "x_axis_width": 5, + "y_axis_height": 5, + "init_dx":0.5, + "graph_origin": ORIGIN+2*DOWN+6*LEFT, + } + def construct(self): + self.setup_axes() + def func(x): + return 0.1*(x)*(x-3)*(x-7)+3 + + graph1=self.get_graph(func,x_min=0,x_max=6) + kwargs = { + "x_min" : 1.5, + "x_max" : 5.5, + "fill_opacity" : 0.75, + "stroke_width" : 0.25, + "input_sample_type": "right", + } + flat_rectangles1 = self.get_riemann_rectangles(self.get_graph(lambda x : 0),dx=self.init_dx,start_color=invert_color(PURPLE),end_color=invert_color(ORANGE),**kwargs) + riemann_rectangles_list1 = self.get_riemann_rectangles_list(graph1,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs) + self.add(graph1) + self.graph_origin = ORIGIN+2*DOWN+1*RIGHT + self.setup_axes() + graph2=self.get_graph(func,x_min=0,x_max=6) + kwargs = { + "x_min" : 1.5, + "x_max" : 5.5, + "fill_opacity" : 0.75, + "stroke_width" : 0.25, + "input_sample_type": "left", + } + flat_rectangles2 = self.get_riemann_rectangles(self.get_graph(lambda x : 0),dx=self.init_dx,start_color=invert_color(PURPLE),end_color=invert_color(ORANGE),**kwargs) + riemann_rectangles_list2 = self.get_riemann_rectangles_list(graph2,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs) + self.add(graph2) + text1 = TextMobject("Left Riemann sum").move_to(np.array([-3,-2.5,0])) + text2 = TextMobject("Right Riemann sum").move_to(np.array([4,-2.5,0])) + grp1 = VGroup(text1, text2) + text3 = TexMobject(r"n \rightarrow \infty").move_to(np.array([0, -3, 0])) + text4 = TextMobject("Left and Right Riemann sums are equal").move_to(np.array([0, -3, 0])) + text5 = TextMobject("Hence function is Riemann integrable and value of integral equals area covered").move_to(np.array([0, -3, 0])).scale(0.6) + grp2 = VGroup(text1, text2, text3) + # Show Riemann rectangles + self.play(ReplacementTransform(flat_rectangles1,riemann_rectangles_list1[0]), ReplacementTransform(flat_rectangles2, riemann_rectangles_list2[0])) + self.wait() + self.play(ShowCreation(grp1)) + for r in range(1,len(riemann_rectangles_list1)-5): + self.transform_between_riemann_rects(riemann_rectangles_list1[r-1],riemann_rectangles_list1[r],replace_mobject_with_target_in_scene = True,) + self.transform_between_riemann_rects(riemann_rectangles_list2[r-1],riemann_rectangles_list2[r],replace_mobject_with_target_in_scene = True,) + self.play(ShowCreation(text3)) + for r in range(len(riemann_rectangles_list1)-5,len(riemann_rectangles_list1)): + self.transform_between_riemann_rects(riemann_rectangles_list1[r-1],riemann_rectangles_list1[r],replace_mobject_with_target_in_scene = True,) + self.transform_between_riemann_rects(riemann_rectangles_list2[r-1],riemann_rectangles_list2[r],replace_mobject_with_target_in_scene = True,) + self.wait(2) + self.play(ReplacementTransform(grp2, text4)) + self.wait(2) + self.play(ReplacementTransform(text4, text5)) + self.wait(4) diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/mimi.py b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/mimi.py new file mode 100644 index 0000000..2471c87 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/mimi.py @@ -0,0 +1,53 @@ +class mimi(GraphScene): + CONFIG = { + "y_max": 5, + "x_max": 6, + "x_min": 0, + "y_min": 0, + "x_axis_width": 5, + "y_axis_height": 5, + "init_dx":0.5, + "graph_origin": ORIGIN+2*DOWN+6*LEFT, + } + def construct(self): + self.setup_axes() + def func(x): + return 0.1*(x)*(x-3)*(x-7)+3 + + graph=self.get_graph(func,x_min=0,x_max=6) + kwargs = { + "x_min" : 1.5, + "x_max" : 5.5, + "fill_opacity" : 0.5, + "stroke_width" : 0.25, + } + flat_rectangles = self.get_riemann_rectangles(self.get_graph(lambda x : 0),dx=self.init_dx,**kwargs) + riemann_rectangles_list = self.get_riemann_rectangles_list(graph,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs, input_sample_type = "right") + riemann_rectangles_list1 = self.get_riemann_rectangles_list(graph,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs, input_sample_type = "left") + self.add(graph) + self.play(ReplacementTransform(flat_rectangles,riemann_rectangles_list[0]), ReplacementTransform(flat_rectangles,riemann_rectangles_list1[0])) + #self.play(ReplacementTransform(flat_rectangles,riemann_rectangles_list1[0])) + self.wait(2) + kwargs = { + "x_min" : 3, + "x_max" : 3.5, + "fill_opacity" : 0.5, + "stroke_width" : 0.25, + } + riemann_rectangles_list2 = self.get_riemann_rectangles_list(graph,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs, input_sample_type = "right") + riemann_rectangles_list3 = self.get_riemann_rectangles_list(graph,8,max_dx=self.init_dx,power_base=2,start_color=PURPLE,end_color=ORANGE,**kwargs, input_sample_type = "left") + #self.play(FadeOut(riemann_rectangles_list[0]), FadeOut(riemann_rectangles_list1[0])) + self.play(ReplacementTransform(flat_rectangles,riemann_rectangles_list2[0]), ReplacementTransform(flat_rectangles,riemann_rectangles_list3[0]), FadeOut(riemann_rectangles_list[0]), FadeOut(riemann_rectangles_list1[0])) + minlim = self.get_vertical_line_to_graph(3,graph,DashedLine) + maxlim = self.get_vertical_line_to_graph(3.5,graph,DashedLine) + line2 = Line(self.graph_origin+2.5*RIGHT, self.graph_origin+2.9*RIGHT) + brace1 = Brace(minlim, LEFT) + brace2 = Brace(line2, DOWN) + brace3 = Brace(maxlim, RIGHT) + br1text = brace1.get_text(r"${M}_{i}$").next_to(brace1, LEFT) + br2text = brace2.get_text(r"$\Delta x$").next_to(brace2, DOWN) + br3text = brace3.get_text(r"${m}_{i}$").next_to(brace3, RIGHT) + text1 = TexMobject(r"\Delta x=(b-a)/n").shift(2*RIGHT) + grp3 = VGroup(br1text, br2text, br3text, brace1, brace2, brace3, text1) + self.play(ShowCreation(grp3)) + self.wait(5) diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect1.py b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect1.py new file mode 100644 index 0000000..748d766 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect1.py @@ -0,0 +1,31 @@ +from manimlib.imports import * +class rierect1(GraphScene): + CONFIG = { + "y_max" : 6, + "y_min" : 0, + "x_max" : 4, + "x_min" : 0, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+2*DOWN+4*LEFT, + "x_labeled_nums": None,#list(range(-1,2)), + "y_labeled_nums": None,#list(range(0,2)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + def construct(self): + self.setup_axes() + graph1 = self.get_graph(lambda x : (0.1*(1.5*x+1)**2 +0.5), x_min = 0, x_max = 4) + minlim = self.get_vertical_line_to_graph(1,graph1,DashedLine, color = PINK) + maxlim = self.get_vertical_line_to_graph(3,graph1,DashedLine,color = PINK) + x1 = TexMobject(r"{x}_{1}").next_to(minlim, DOWN) + x2 = TexMobject(r"{x}_{2}").next_to(maxlim, DOWN) + rie1 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.4, input_sample_type = "left", fill_opacity = 1, start_color = YELLOW, end_color = YELLOW) + #rie2 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.01, input_sample_type = "right", fill_opacity = 0.5, start_color = PINK, end_color = LIGHT_PINK) + group = VGroup(graph1, minlim, maxlim, x1, x2, rie1) + self.play(ShowCreation(group)) + self.wait(1.5) diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect2.py b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect2.py new file mode 100644 index 0000000..e300250 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect2.py @@ -0,0 +1,31 @@ +from manimlib.imports import * +class rierect2(GraphScene): + CONFIG = { + "y_max" : 6, + "y_min" : 0, + "x_max" : 4, + "x_min" : 0, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+2*DOWN+4*LEFT, + "x_labeled_nums": None,#list(range(-1,2)), + "y_labeled_nums": None,#list(range(0,2)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + def construct(self): + self.setup_axes() + graph1 = self.get_graph(lambda x : (0.1*(1.5*x+1)**2 +0.5), x_min = 0, x_max = 4) + minlim = self.get_vertical_line_to_graph(1,graph1,DashedLine, color = PINK) + maxlim = self.get_vertical_line_to_graph(3,graph1,DashedLine,color = PINK) + x1 = TexMobject(r"{x}_{1}").next_to(minlim, DOWN) + x2 = TexMobject(r"{x}_{2}").next_to(maxlim, DOWN) + rie1 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.1, input_sample_type = "left", fill_opacity = 1, start_color = YELLOW, end_color = YELLOW) + #rie2 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.01, input_sample_type = "right", fill_opacity = 0.5, start_color = PINK, end_color = LIGHT_PINK) + group = VGroup(graph1, minlim, maxlim, x1, x2, rie1) + self.play(ShowCreation(group)) + self.wait(1.5) diff --git a/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect3.py b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect3.py new file mode 100644 index 0000000..3542358 --- /dev/null +++ b/FSF-2020/calculus/intro-to-calculus/riemannintegrals/rierect3.py @@ -0,0 +1,31 @@ +from manimlib.imports import * +class rierect3(GraphScene): + CONFIG = { + "y_max" : 6, + "y_min" : 0, + "x_max" : 4, + "x_min" : 0, + "y_tick_frequency" : 1, + "x_tick_frequency" : 1, + "axes_color" : WHITE, + "num_graph_anchor_points": 3000, #this is the number of points that graph manim + "graph_origin" : ORIGIN+2*DOWN+4*LEFT, + "x_labeled_nums": None,#list(range(-1,2)), + "y_labeled_nums": None,#list(range(0,2)), + "x_axis_label":"$x$", + "y_axis_label":"$f(x)$", + "x_axis_width": 10, + "y_axis_height": 5, + } + def construct(self): + self.setup_axes() + graph1 = self.get_graph(lambda x : (0.1*(1.5*x+1)**2 +0.5), x_min = 0, x_max = 4) + minlim = self.get_vertical_line_to_graph(1,graph1,DashedLine, color = PINK) + maxlim = self.get_vertical_line_to_graph(3,graph1,DashedLine,color = PINK) + x1 = TexMobject(r"{x}_{1}").next_to(minlim, DOWN) + x2 = TexMobject(r"{x}_{2}").next_to(maxlim, DOWN) + rie1 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.01, input_sample_type = "left", fill_opacity = 1, start_color = YELLOW, end_color = YELLOW) + #rie2 = self.get_riemann_rectangles(graph1, x_min = 1, x_max = 3, dx = 0.01, input_sample_type = "right", fill_opacity = 0.5, start_color = PINK, end_color = LIGHT_PINK) + group = VGroup(graph1, minlim, maxlim, x1, x2, rie1) + self.play(ShowCreation(group)) + self.wait(1.5) 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..2fa4e04 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/README.md @@ -0,0 +1,20 @@ +### 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-a +![GIF4](gifs/file3.gif) + +### Fourier series for non-periodic functions-b +![GIF4a](gifs/file7.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..de94810 --- /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/gifs/file6.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file6.gif Binary files differnew file mode 100644 index 0000000..de94810 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file6.gif diff --git a/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.gif b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.gif Binary files differnew file mode 100644 index 0000000..ab4eed8 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/gifs/file7.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..fdb8719 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video1_DividingAToneIntoItsConstituents.py @@ -0,0 +1,83 @@ +from manimlib.imports import* +import numpy as np + +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..c87e58e --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video2_ColorsAnalogyForFourierSeries.py @@ -0,0 +1,146 @@ +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.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.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.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.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.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.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(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.wait(2) + 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..d35f8bf --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video3_seriesVSTransform.py @@ -0,0 +1,129 @@ +from manimlib.imports import * +import numpy as np + +class compare(GraphScene,MovingCameraScene): + 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 setup(self): + GraphScene.setup(self) + MovingCameraScene.setup(self) + 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(FadeOut(axes[0]),FadeOut(left),FadeOut(right),FadeOut(function)) + self.camera_frame.save_state() + self.play(self.camera_frame.set_width, 5,self.camera_frame.move_to, 3.5*RIGHT) + + + 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])) + + self.wait(0.5) + self.play(self.camera_frame.set_width, 14,self.camera_frame.move_to, 0) + + 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(FadeIn(axes[0]),FadeIn(left),FadeIn(right),FadeIn(function)) + 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.4).shift(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.4).shift(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.4).shift(5*RIGHT+2.2*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.4).shift(5*RIGHT+2.2*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])) + + + + self.wait(2) 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..fdf4bb3 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Fourier Transform/video4_FourierSeriesOfSquarePulse.py @@ -0,0 +1,97 @@ +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.5) + self.add(equation) + self.setup_axes(animate=True,scalee=1) + 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) + circleMark=Circle(radius=0.1,color=GREEN).shift(x_each_unit*RIGHT*0.47+UP*y_each_unit*1.1) + text=TextMobject("Gibbs","phenomenon").set_color_by_tex_to_color_map({"Gibbs":BLUE,"phenomenon":YELLOW}).scale(0.1).shift(RIGHT*x_each_unit*0.65+UP*y_each_unit*1.1) + self.wait(0.7) + self.play(ShowCreation(circleMark)) + self.play(Write(text)) + self.wait(0.5) + self.play(self.camera_frame.set_width,14,self.camera_frame.move_to,0,FadeOut(circleMark),FadeOut(text)) + 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..2fd400d --- /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/file4a_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/gifs/file4a_UniformConvergence.gif b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4a_UniformConvergence.gif Binary files differnew file mode 100644 index 0000000..e284b83 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Power Series/gifs/file4a_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..8680792 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,7 @@ 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) + 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 +103,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 +119,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..af4bdea 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,8 @@ 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) + 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..b75da59 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,15 @@ import math class uniformlyConvergent(Scene): def construct(self): - 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) + introText2.scale(0.7) introText3.scale(0.9) introText3.shift(DOWN) - 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(introText2)) self.play(FadeIn(introText3)) self.wait(2) @@ -45,7 +41,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 +54,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) + + ZoomedScene.setup(self) def construct(self): @@ -87,6 +86,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 +102,14 @@ 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(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/README.md b/FSF-2020/calculus/series-and-transformations/README.md index 4747205..0ca6397 100644 --- a/FSF-2020/calculus/series-and-transformations/README.md +++ b/FSF-2020/calculus/series-and-transformations/README.md @@ -4,10 +4,9 @@ GitHub Handle: <a href="https://github.com/GSri30/">GSri30</a> Sub-Topics Covered:
<ul>
- <li>Power Series
- <li>Taylor Series
- <li>Laplace Transformation
- <li>Fourier Transformation
- <li>z-Transform
- <li>Constant-Q transform
+ <li><a href="https://math.animations.fossee.in/contents/series-and-transformations/series/taylor-series">Taylor Series</a>
+ <li><a href="https://math.animations.fossee.in/contents/series-and-transformations/series/power-series">Power Series</a>
+ <li><a href="https://math.animations.fossee.in/contents/series-and-transformations/transformations/fourier-transform">Fourier Transformation</a>
+ <li><a href="https://math.animations.fossee.in/contents/series-and-transformations/transformations/laplace-transform">Laplace Transformation</a>
+ <li><a href="https://math.animations.fossee.in/contents/series-and-transformations/transformations/z-transform">Z-Transform</a>
</ul>
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..88eb772 --- /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/file2a_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..33dfa81 --- /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/file2a_TaylorExpansionGeneralForm.gif b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2a_TaylorExpansionGeneralForm.gif Binary files differnew file mode 100644 index 0000000..33dfa81 --- /dev/null +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/gifs/file2a_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..a0c7176 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,20 @@ 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]) + firstApprox=[self.get_graph(lambda x:1,color=BLUE)] secondApprox=[self.get_graph(lambda x:1,color=BLUE), @@ -124,16 +141,37 @@ 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(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 +208,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) @@ -182,16 +222,7 @@ class graphScene(GraphScene): self.play(FadeOut(self.axes),FadeOut(textFinal),FadeOut(secondGraph),FadeOut(trTextGrup),FadeOut(mainfunction),FadeOut(fx),FadeOut(coeff[0]),FadeOut(coeff[1]),FadeOut(coeff[2])) self.play(Write(finalFormula)) self.wait(2) - # self.play(ReplacementTransform(secondApprox[2],secondApprox[3])) - # self.wait(0.5) - # self.play(ReplacementTransform(secondApprox[3],secondApprox[4])) - # self.wait(0.5) - # self.play(ReplacementTransform(secondApprox[4],secondApprox[5])) - # self.wait(0.5) - # self.play(ReplacementTransform(secondApprox[0],secondApprox[0])) - # self.wait(0.5) - # self.play(ReplacementTransform(secondApprox[0],secondApprox[0])) - # self.wait(0.5) + 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..5be336b 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script2.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video2_TaylorExpansionGeneralForm.py @@ -7,7 +7,7 @@ class intro(Scene): equation=TextMobject("$f(x)=$","${ e }^{ -x^{ 2 } }$") equation.scale(2) equation.set_color_by_tex_to_color_map({"${ e }^{ -x^{ 2 } }$":RED}) - text=TextMobject("at $a=1$") + text=TextMobject("about $x=1$") text.scale(0.7) text.shift(DOWN) @@ -41,7 +41,7 @@ def formFormula(coeff_list,variable_list): return expansion,coeff_list -class graphScene(GraphScene): +class graphScene(GraphScene,MovingCameraScene): CONFIG = { "x_min": -8, "x_max": 8, @@ -55,10 +55,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("about $x=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) @@ -68,7 +83,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) @@ -79,29 +94,29 @@ class graphScene(GraphScene): self.wait(1.4) coeff=[TextMobject("$e^{-1}$"),TextMobject("$f'(x)$"),TextMobject("$\\frac { f''(x) }{ 2! } $")] - coeff[0].shift(3.33*UP+3.65*RIGHT) - coeff[0].scale(0.45) - coeff[1].shift(3.33*UP+4.13*RIGHT) - coeff[1].scale(0.275) - coeff[2].shift(3.33*UP+5.36*RIGHT) - coeff[2].scale(0.28) + coeff[0].shift(4.1*y_each_unit*UP+5.15*RIGHT*x_each_unit) + coeff[0].scale(0.3) + coeff[1].shift(4*y_each_unit*UP+5.7*RIGHT*x_each_unit) + coeff[1].scale(0.2) + coeff[2].shift(4*y_each_unit*UP+7.3*RIGHT*x_each_unit) + coeff[2].scale(0.18) for obj in coeff: obj.set_color(GOLD_A) - firstApprox=[self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5)] - secondApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5), - self.get_graph(lambda x:math.exp(-1)+3*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5), - self.get_graph(lambda x:math.exp(-1)-4*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5)] - thirdApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), - self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-0.1*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), - self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_max=5.5,x_min=-5.5), - self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+0.5*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5), - self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5)] + firstApprox=[self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-3,x_max=4)] + secondApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-3,x_max=4), + self.get_graph(lambda x:math.exp(-1)+3*(x-1)*math.exp(-1),color=BLUE,x_min=-3,x_max=4), + self.get_graph(lambda x:math.exp(-1)-4*(x-1)*math.exp(-1),color=BLUE,x_min=-3,x_max=4)] + thirdApprox=[self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=4,x_min=-3), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)-0.1*math.exp(-1)*(x-1)**2,color=BLUE,x_max=4,x_min=-3), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_max=4,x_min=-3), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+0.5*math.exp(-1)*(x-1)**2,color=BLUE,x_max=4,x_min=-3), + self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+2*math.exp(-1)*(x-1)**2,color=BLUE,x_max=4,x_min=-3)] - firstGraph=self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5) - secondGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-5.5,x_max=5.5) - thirdGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+math.exp(-1)*(x-1)**2,color=BLUE,x_max=5.5,x_min=-5.5) + firstGraph=self.get_graph(lambda x:math.exp(-1),color=BLUE,x_min=-3,x_max=4) + secondGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1),color=BLUE,x_min=-3,x_max=4) + thirdGraph=self.get_graph(lambda x:math.exp(-1)-2*(x-1)*math.exp(-1)+math.exp(-1)*(x-1)**2,color=BLUE,x_max=4,x_min=-3) bottomText1=TextMobject("Apply","$f(1)=T_{n}(1)$") bottomText2=TextMobject("This gives","$a_{ 0 }=e^{-1}$") @@ -135,16 +150,35 @@ 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(5*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText3.shift(5*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText4.shift(5*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText5.shift(5*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText6.shift(5.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText7.shift(5.7*RIGHT*x_each_unit+2.5*DOWN*y_each_unit) + bottomText8.shift(5.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.camera_frame.save_state() + self.play(self.camera_frame.set_width, 8, + self.camera_frame.move_to, x_each_unit*UP+x_each_unit*2*RIGHT, + ApplyMethod(trTextGrup.move_to,4*y_each_unit*UP+6.1*RIGHT*x_each_unit), + ApplyMethod(bottomText1.move_to,5.4*RIGHT*x_each_unit+2.5*DOWN*y_each_unit), + ApplyMethod(equation.shift,1.39*DOWN+2*RIGHT+RIGHT*x_each_unit*2), + ApplyMethod(text.shift,1.39*DOWN+2*RIGHT+RIGHT*x_each_unit*2),) + 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.25*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])) @@ -154,8 +188,6 @@ class graphScene(GraphScene): self.play(ReplacementTransform(firstApprox[0],secondApprox[1])) self.wait(0.5) self.play(ReplacementTransform(secondApprox[1],secondApprox[2])) - # self.wait(0.5) - # self.play(ReplacementTransform(secondApprox[2],secondApprox[0])) self.wait(1) self.play(ReplacementTransform(bottomText3,bottomText4),FadeOut(secondApprox[2])) self.wait(1) @@ -167,8 +199,6 @@ class graphScene(GraphScene): self.play(ReplacementTransform(secondGraph,thirdApprox[0])) self.wait(0.6) self.play(ReplacementTransform(thirdApprox[0],thirdApprox[1])) - # self.wait(0.6) - # self.play(ReplacementTransform(thirdApprox[1],thirdApprox[2])) self.wait(0.6) self.play(ReplacementTransform(thirdApprox[1],thirdApprox[3])) self.wait(0.6) @@ -181,10 +211,13 @@ 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(5.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, + self.camera_frame.move_to, 0) finalFormula=TextMobject("Hence","$T_{ n }(x)$","=","$f(1)+f'(1)(x-1)+\\frac { f''(1) }{ 2! }(x-1)^2+..+\\frac { { f }^{ n }(1) }{ n! } { (x-1) }^{ n }$") finalFormula.scale(0.8) @@ -192,4 +225,4 @@ class graphScene(GraphScene): self.play(FadeOut(self.axes),FadeOut(textFinal),FadeOut(thirdGraph),FadeOut(trTextGrup),FadeOut(mainfunction),FadeOut(fx),FadeOut(coeff[0]),FadeOut(coeff[1]),FadeOut(coeff[2])) self.play(Write(finalFormula)) - self.wait(2)
\ No newline at end of file + self.wait(2) 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..6b368da 100644 --- a/FSF-2020/calculus/series-and-transformations/Taylor Series/script4.py +++ b/FSF-2020/calculus/series-and-transformations/Taylor Series/video4_DivergentRemainder.py @@ -43,7 +43,6 @@ class graphScene(GraphScene): bottomText1=TextMobject("$R_{n}(x)=\\frac { d }{ dx } ($","area bounded","$)$") bottomText1.set_color_by_tex_to_color_map({"area bounded":ORANGE}) - #bottomText2.set_color_by_tex_to_color_map({"area bounded":BLUE}) arrow=TextMobject("$\downarrow$") arrow.scale(2.5) arrow.shift(ORIGIN+x_each_unit*RIGHT*9.5+UP*y_each_unit) @@ -56,12 +55,8 @@ class graphScene(GraphScene): increasingText.scale(0.4) bottomText1.scale(0.5) - #bottomText2.scale(0.5) - #bottomText3.scale(0.5) bottomText1.shift(3.5*LEFT+2*DOWN) - #bottomText2.shift(3.5*LEFT+2.4*DOWN) - #bottomText3.shift(3.5*LEFT+2.8*DOWN) dline=DashedLine(start=ORIGIN+8*y_each_unit*UP,end=ORIGIN+8*y_each_unit*DOWN) dline.shift(ORIGIN+x_each_unit*4*RIGHT) @@ -72,11 +67,9 @@ class graphScene(GraphScene): self.play(Write(dline)) self.wait(0.5) self.play(ShowCreation(area1),ShowCreation(area2),Write(bottomText1)) - # self.play(Write(bottomText2)) - # self.play(FadeIn(bottomText3)) self.play(Write(arrow)) self.wait(0.7) self.play(Write(increasingText)) self.play(FadeIn(followupText)) self.wait(2) -
\ No newline at end of file + 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/Gram-Schmidt-Orthonormalization-Process/README.md b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/README.md new file mode 100644 index 0000000..832aa5d --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/README.md @@ -0,0 +1,18 @@ +# Contributer: Archit Sangal +My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal) +<br/></br> + +## Sub-Topics Covered: ++ Gramm-Schmidt Orthogonalization Process + +#### Video 1: Introduction to Gram-Schmidt Orthogonalization Process +![GIF1](file7.gif) + +#### Video 2: Obtaining orthogonal vectors using projections +![GIF2](file8.gif) + +#### Video 3: Visual Explanation of how Gram-Schmidt Orthogonalization Process give mutually orthonormal vectors +![GIF3](file5.gif) + +#### Video 4: Example of Orthonormal Vectors which are different from standard basis +![GIF4](file6.gif)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file1_introduction.py b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file1_introduction.py new file mode 100644 index 0000000..ccd23c9 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file1_introduction.py @@ -0,0 +1,33 @@ +from manimlib.imports import * + +class Orthonormal(Scene): + def construct(self): + Centre = DOWN + arrow_1 = Arrow(start = Centre+ORIGIN,end = Centre+1.414*(UP+RIGHT)) + arrow_2 = Arrow(start = Centre+ORIGIN,end = Centre+2*UP) + arrow_1.scale(1.35) + arrow_2.scale(1.35) + text = TextMobject("This is a set of linearly independent vectors") + text.scale(0.75) + text.move_to(3*UP+3*LEFT) + text.set_color(PURPLE_E) + arrow_1.set_color(PURPLE_E) + arrow_2.set_color(PURPLE_E) + self.play(Write(text)) + self.play(ShowCreation(arrow_1), ShowCreation(arrow_2)) + self.wait(2) + text1 = TextMobject("After we apply Gram-Schmidt Orthogonalization Process to set of linearly independent vectors") + text1.scale(0.6) + text1.move_to(3*UP+2*LEFT) + text1.set_color(GREEN) + arrow_a = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+RIGHT)) + arrow_a.set_color(GREEN) + arrow_a.scale(2) + self.play(Transform(text,text1)) + self.wait(2) + self.play(Transform(arrow_1,arrow_a)) + arrow_b = Arrow(start = Centre+ORIGIN,end = Centre+0.707*(UP+LEFT)) + arrow_b.set_color(GREEN) + arrow_b.scale(2) + self.play(Transform(arrow_2,arrow_b)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file2_projections.py b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file2_projections.py new file mode 100755 index 0000000..dd4b8d4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file2_projections.py @@ -0,0 +1,79 @@ +from manimlib.imports import * + +class Projections(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) + + arrow_a = Arrow(start = ORIGIN, end = 4*XTD*RIGHT) + arrow_a.scale(1.2) + arrow_a.set_color(DARK_BLUE) + arrow_b = Arrow(start = ORIGIN, end = 2*YTD*UP+2*XTD*RIGHT) + arrow_b.scale(1.3) + arrow_b.set_color(DARK_BLUE) + self.play(ShowCreation(arrow_a), ShowCreation(arrow_b)) + + text = TextMobject(r"Consider 2 linearly independent vectors $a$ and $b$") + text.set_color(DARK_BLUE) + text.scale(0.6) + text.move_to(3*YTD*UP+5*XTD*LEFT) + text_a = TextMobject("a") + text_a.move_to(0.4*YTD*DOWN+3*XTD*RIGHT) + text_a.set_color(DARK_BLUE) + text_b = TextMobject("b") + text_b.move_to(1.5*YTD*UP+RIGHT*XTD) + text_b.set_color(DARK_BLUE) + + self.play(Write(text),Write(text_a), Write(text_b)) + self.wait() + + arrow_b_copy = Arrow(start = ORIGIN, end = 2*YTD*UP+2*XTD*RIGHT) + arrow_b_copy.scale(1.25) + + arrow_p = Arrow(start = ORIGIN, end = 2*XTD*RIGHT) + arrow_p.scale(1.5) + arrow_p.set_color(GOLD_E) + + text_p = TextMobject("p") + text_p.move_to(0.25*DOWN+RIGHT) + text_p.set_color(GOLD_E) + + self.play(FadeOut(text), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b)) + text = TextMobject(r"$p$ is the projection of $b$ on $a$") + text.set_color(GOLD_E) + text.move_to(3*UP+4*LEFT) + text.scale(0.8) + self.play(Write(text),Write(text_p)) + self.wait() + + self.play(FadeIn(text_a), FadeIn(text_b)) + + arrow_o = Arrow(start = 2*XTD*RIGHT, end = 2*YTD*UP+2*XTD*RIGHT) + arrow_o.scale(1.5) + arrow_o.set_color(GREEN_E) + + text_o = TextMobject("b-p") + text_o.move_to(UP*YTD+2.7*XTD*RIGHT) + text_o.set_color(GREEN_E) + + self.play(ShowCreation(arrow_o)) + self.play(FadeOut(text),Write(text_o)) + + text = TextMobject(r"Observe, ($b-p$) is orthogonal to $a$") + text.set_color(GREEN_E) + text.move_to(2*DOWN+4*LEFT) + text.scale(0.8) + self.play(Write(text)) + self.wait(2) + + self.play(FadeOut(self.axes), FadeOut(arrow_a), FadeOut(arrow_b), FadeOut(arrow_b_copy), FadeOut(arrow_o), FadeOut(text_a), FadeOut(text_b), FadeOut(text_o), FadeOut(text_p), FadeOut(text))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file3_orthonormal.py b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file3_orthonormal.py new file mode 100644 index 0000000..a74b641 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file3_orthonormal.py @@ -0,0 +1,335 @@ +from manimlib.imports import * + +class Algo(ThreeDScene): + def construct(self): + + axes = ThreeDAxes(x_min = -5,x_max=5,y_min=-3,y_max=3,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + + text = TextMobject(r"This is the vector $\beta_1 =\left[\begin{array}{c} 4\\0\\0 \end{array}\right]$") + text.set_color(GREEN) + text.scale(0.6) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + arrow_a = Arrow(start = ORIGIN, end = 4*RIGHT) + arrow_a.set_color(GREEN) + arrow_a.scale(1.15) + self.play(ShowCreation(arrow_a)) + + text_a = TextMobject(r"$\beta_1$") + text_a.move_to(0.4*DOWN+3*RIGHT) + text_a.set_color(GREEN) + text_a.scale(0.75) + self.play(Write(text_a)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Normalize $\beta_1$ to get $\alpha_1$") + text.set_color(DARK_BLUE) + text.scale(0.75) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + alpha_1 = Arrow(start = ORIGIN,end = RIGHT) + alpha_1.scale(1.9) + alpha_1.set_color(DARK_BLUE) + text_alpha_1 = TextMobject(r"$\alpha_1$") + text_alpha_1.move_to(0.4*DOWN+RIGHT) + text_alpha_1.set_color(DARK_BLUE) + text_alpha_1.scale(0.75) + self.play(Transform(text_a,text_alpha_1), Transform(arrow_a,alpha_1)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"Consider another vector $\beta_2=\left[\begin{array}{c} 2\\2\\0 \end{array}\right]$") + text1 = TextMobject(r"which is linearly independent to $\beta_1$") + text.set_color(GREEN) + text1.set_color(GREEN) + text.scale(0.6) + text1.scale(0.6) + text.move_to(3*UP+4*LEFT) + text1.move_to(2*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + + arrow_b = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b.scale(1.2) + arrow_b.set_color(GREEN) + text_b = TextMobject(r"$\beta_2$") + text_b.move_to(1.5*UP+RIGHT) + text_b.set_color(GREEN) + text_b.scale(0.75) + + self.play(ShowCreation(arrow_b), Write(text_b)) + self.wait() + + arrow_b_copy = Arrow(start = ORIGIN, end = 2*UP+2*RIGHT) + arrow_b_copy.scale(1.2) + + arrow_p = Arrow(start = ORIGIN, end = 2*RIGHT) + arrow_p.scale(1.35) + arrow_p.set_color(GOLD_E) + + text_p = TextMobject("p") + text_p.move_to(0.25*DOWN+RIGHT) + text_p.set_color(GOLD_E) + + self.play(FadeOut(text), FadeOut(text1), Transform(arrow_b_copy,arrow_p), FadeOut(text_a), FadeOut(text_b)) + text = TextMobject(r"$p$ is the projection of $\beta_2$ on $\alpha_1$") + text.set_color(GOLD_E) + text.move_to(3*UP+4*LEFT) + text.scale(0.8) + self.play(Write(text),Write(text_p)) + self.wait() + + self.play(FadeIn(text_b)) + + arrow_o = Arrow(start = 2*RIGHT, end = 2*UP+2*RIGHT) + arrow_o.scale(1.35) + arrow_o.set_color(PURPLE_E) + + text_o = TextMobject(r"$\beta_2-p$") + text_o.move_to(UP+2.7*RIGHT) + text_o.scale(0.75) + text_o.set_color(PURPLE_E) + + self.play(ShowCreation(arrow_o)) + self.play(FadeOut(text),Write(text_o)) + + text = TextMobject(r"$\beta_2-p$ is orthogonal to p") + text1 = TextMobject(r"(and hence orthogonal to $\alpha_1$ also)") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.7) + text1.scale(0.7) + text.move_to(3*UP+4*LEFT) + text1.move_to(2.5*UP+4*LEFT) + self.play(Write(text)) + self.play(Write(text1)) + self.wait(2) + + self.play(FadeOut(text_p), FadeIn(arrow_a), FadeOut(text), FadeOut(text1), FadeOut(arrow_b_copy), FadeOut(arrow_p), FadeOut(text_b), FadeOut(arrow_b)) + self.play(ApplyMethod(arrow_o.move_to,UP), ApplyMethod(text_o.move_to,RIGHT+UP)) + + text = TextMobject(r"Now, Normalize $\beta_2-p$") + text.set_color(DARK_BLUE) + text.scale(0.6) + text.move_to(3*UP+4*LEFT) + self.play(Write(text)) + + alpha_2 = Arrow(start = ORIGIN,end = UP) + alpha_2.scale(1.9) + alpha_2.set_color(DARK_BLUE) + text_alpha_2 = TextMobject(r"$\alpha_2$") + text_alpha_2.move_to(0.4*LEFT+UP) + text_alpha_2.set_color(DARK_BLUE) + text_alpha_2.scale(0.75) + self.play(Transform(text_o,text_alpha_2), Transform(arrow_o,alpha_2), FadeIn(text_a)) + self.wait() + self.play(FadeOut(text),FadeOut(text_a),FadeOut(text_o)) + + self.add(axes) + ############################################################################# + axis = TextMobject(r"$\alpha_1$",r"$\alpha_2$",r"$\alpha_3$",r"$\beta_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$",r"$\alpha_3$") + axis.scale(0.5) + axis[0].move_to(0.5*RIGHT+[0,0,-0.5]) + axis[1].move_to(0.5*UP+[0,0,-0.5]) + axis[2].move_to(np.array([0,0,0.5])) + axis[3].move_to(np.array([1,1,1.5])) + self.add_fixed_orientation_mobjects(axis[0]) + self.add_fixed_orientation_mobjects(axis[1]) + ############################################################################# + + self.move_camera(phi=70*DEGREES,theta=30*DEGREES,run_time=3) + xy_plane = Polygon(5*RIGHT+3*UP,-5*RIGHT+3*UP,-5*RIGHT-3*UP,5*RIGHT-3*UP) + xy_plane.set_color("#333333") + xy_plane.set_fill("#333333") + xy_plane.set_opacity(1) + xy_plane.fade(0.7) + self.play(ShowCreation(xy_plane)) + + #self.begin_ambient_camera_rotation(rate=0.1) + + line1 = Line(start = ORIGIN,end = 1*RIGHT) + line1.set_color(DARK_BLUE) + tip1 = Polygon(RIGHT,0.8*RIGHT-0.2*DOWN,0.8*RIGHT-0.2*UP) + tip1.set_opacity(1) + tip1.set_fill(DARK_BLUE) + tip1.set_color(DARK_BLUE) + + arrow2 = Line(start = ORIGIN,end = 1*UP) + arrow2.set_color(DARK_BLUE) + tip2 = Polygon(UP,0.8*UP-0.2*RIGHT,0.8*UP-0.2*LEFT) + tip2.set_opacity(1) + tip2.set_fill(DARK_BLUE) + tip2.set_color(DARK_BLUE) + arrow2.set_color(DARK_BLUE) + + self.play(ShowCreation(line1), ShowCreation(tip1), ShowCreation(arrow2), ShowCreation(tip2), FadeOut(arrow_a), FadeOut(arrow_o)) + self.wait() + + a_line = Line(start = ORIGIN,end = 2*UP+2*RIGHT+[0,0,2]) + a_line.set_color(GOLD_E) + a_tip = Polygon(2*UP+2*RIGHT+[0,0,2],2*UP+1.6*RIGHT+[0,0,1.8],1.6*UP+2*RIGHT+[0,0,1.8]) + a_tip.set_opacity(1) + a_tip.set_fill(GOLD_E) + a_tip.set_color(GOLD_E) + + a_line_c1 = Line(start = ORIGIN,end = 2*UP+2*RIGHT+[0,0,2]) + a_line_c1.set_color(GOLD_E) + a_tip_c1 = Polygon(2*UP+2*RIGHT+[0,0,2],2*UP+1.6*RIGHT+[0,0,1.8],1.6*UP+2*RIGHT+[0,0,1.8]) + a_tip_c1.set_opacity(1) + a_tip_c1.set_fill(GOLD_E) + a_tip_c1.set_color(GOLD_E) + + self.play(ShowCreation(a_line), ShowCreation(a_tip), ShowCreation(a_line_c1), ShowCreation(a_tip_c1)) + + text = TextMobject(r"Now, we have a vector $\beta_3=\left[\begin{array}{c} 2\\2\\2 \end{array}\right]$") + text.set_color(GOLD_E) + text.scale(0.7) + self.add_fixed_in_frame_mobjects(text) + self.add_fixed_orientation_mobjects(axis[3]) + text.move_to(3*(DOWN+RIGHT)) + self.play(Write(text)) + self.wait() + self.play(FadeOut(text)) + + p_line1 = Line(start = ORIGIN,end = 2*RIGHT) + p_line1.set_color(GOLD_E) + p_tip1 = Polygon(2*RIGHT,1.8*RIGHT+0.2*DOWN,1.8*RIGHT+0.2*UP) + + p_tip1.set_opacity(1) + p_tip1.set_fill(GOLD_E) + p_tip1.set_color(GOLD_E) + + self.play(Transform(a_line_c1,p_line1),Transform(a_tip_c1,p_tip1)) + + text = TextMobject(r"Take projection of $\beta_3$ on $\alpha_1$") + text.scale(0.6) + text.set_color(GOLD_E) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*(DOWN+RIGHT)) + self.play(Write(text)) + self.begin_ambient_camera_rotation(rate=0.05) + self.wait() + self.play(FadeOut(text)) + + o_line1 = Line(start = 2*RIGHT,end = 2*UP+2*RIGHT+[0,0,2]) + o_line1.set_color(GREEN_E) + o_tip1 = Polygon(2*UP+2*RIGHT+[0,0,2],1.8*UP+2*RIGHT+[0,0,1.8]+0.2*RIGHT,1.8*UP+2*RIGHT+[0,0,1.8]-0.2*RIGHT) + o_tip1.set_opacity(1) + o_tip1.set_fill(GREEN_E) + o_tip1.set_color(GREEN_E) + + a_line1 = Line(start = ORIGIN,end = 2*UP+[0,0,2]) + a_line1.set_color(GREEN_E) + a_tip1 = Polygon(2*UP+[0,0,2],1.8*UP+[0,0,1.8]+0.2*RIGHT,1.8*UP+[0,0,1.8]-0.2*RIGHT) + a_tip1.set_opacity(1) + a_tip1.set_fill(GREEN_E) + a_tip1.set_color(GREEN_E) + + a_line1_c1 = Line(start = ORIGIN,end = 2*UP+[0,0,2]) + a_line1_c1.set_color(GREEN_E) + a_tip1_c1 = Polygon(2*UP+[0,0,2],1.8*UP+[0,0,1.8]+0.2*RIGHT,1.8*UP+[0,0,1.8]-0.2*RIGHT) + a_tip1_c1.set_opacity(1) + a_tip1_c1.set_fill(GREEN_E) + a_tip1_c1.set_color(GREEN_E) + + text = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$)") + text.set_color(GREEN_E) + text.scale(0.6) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*(DOWN+RIGHT)) + self.play(Write(text)) + + self.play(ShowCreation(o_line1), ShowCreation(o_tip1)) + self.wait(2) + self.play(FadeOut(a_line_c1), FadeOut(a_tip_c1), + FadeOut(a_line), FadeOut(a_tip), FadeOut(axis[3]), + Transform(o_line1,a_line1), Transform(o_tip1,a_tip1)) + + self.wait() + self.play(FadeOut(text)) + + p_arrow2 = Line(start = ORIGIN,end = 2*UP) + p_arrow2.set_color(GOLD_E) + p_tip2 = Polygon(2*UP,1.8*UP+0.2*RIGHT,1.8*UP+0.2*LEFT) + p_tip2.set_opacity(1) + p_tip2.set_fill(GOLD_E) + p_tip2.set_color(GOLD_E) + p_arrow2.set_color(GOLD_E) + + last_a = Line(start = 2*UP,end = [0,2,2]) + last_a.set_color(PURPLE_E) + last_a_tip = Polygon([0,0,2],[0,0,1.8]+0.2*RIGHT,[0,0,1.8]+0.2*LEFT) + last_a_tip.move_to([0,2,2]) + last_a_tip.set_opacity(1) + last_a_tip.set_fill(PURPLE_E) + last_a_tip.set_color(PURPLE_E) + + self.wait(5) + text = TextMobject(r"Take projection on $\alpha_2$") + text.scale(0.6) + text.set_color(GOLD_E) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*(DOWN+RIGHT)) + self.play(Write(text)) + self.play(Transform(a_line1_c1,p_arrow2),Transform(a_tip1_c1,p_tip2)) + self.wait() + self.play(FadeOut(text)) + + text = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2$)") + text.set_color(PURPLE_E) + text.scale(0.6) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + #self.play(ShowCreation(o_line1), ShowCreation(o_tip1)) + self.wait(2) + self.play(ShowCreation(last_a_tip), ShowCreation(last_a)) + self.wait() + self.play(FadeOut(text)) + + larrow3 = Line(start = ORIGIN,end = [0,0,2]) + larrow3.set_color(PURPLE_E) + ltip3 = Polygon([0,0,2],[0,0,1.8]+0.2*RIGHT,[0,0,1.8]+0.2*LEFT) + ltip3.set_opacity(1) + ltip3.set_fill(PURPLE_E) + ltip3.set_color(PURPLE_E) + self.wait() + self.play(FadeOut(o_line1), FadeOut(o_tip1), FadeOut(a_line1_c1), FadeOut(a_tip1_c1), Transform(last_a,larrow3), Transform(last_a_tip,ltip3)) + + text = TextMobject(r"Normalize, the vector") + text1 = TextMobject(r"$\beta_3$-(projection of $\beta_3$ on $\alpha_1$ + projection of $\beta_3$ on $\alpha_2)$") + text.set_color(PURPLE_E) + text1.set_color(PURPLE_E) + text.scale(0.55) + text1.scale(0.55) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN+3*RIGHT) + text1.move_to(3.5*DOWN+3.25*RIGHT) + self.play(Write(text)) + self.add_fixed_in_frame_mobjects(text1) + self.play(Write(text1)) + + arrow3 = Line(start = ORIGIN,end = [0,0,1]) + arrow3.set_color(DARK_BLUE) + tip3 = Polygon([0,0,1],[0,0,0.8]-0.2*RIGHT,[0,0,0.8]-0.2*LEFT) + tip3.set_opacity(1) + tip3.set_fill(DARK_BLUE) + tip3.set_color(DARK_BLUE) + self.play(Transform(last_a,arrow3), Transform(last_a_tip,tip3)) + self.add_fixed_orientation_mobjects(axis[2]) + + self.wait() + self.play(FadeOut(text),FadeOut(text1)) + + text = TextMobject(r"These are the three orthonormal vectors $\alpha_1, \alpha_2, \alpha_3$") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + + self.wait(8) diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file4_Non_Standard_Basis.py b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file4_Non_Standard_Basis.py new file mode 100644 index 0000000..1d23aa2 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file4_Non_Standard_Basis.py @@ -0,0 +1,69 @@ +from manimlib.imports import * + +class NSB(ThreeDScene): + def construct(self): + + line1 = Line(start = ORIGIN,end = 1*RIGHT) + line1.set_color(DARK_BLUE) + tip1 = Polygon(RIGHT,0.9*RIGHT-0.1*DOWN,0.9*RIGHT-0.1*UP) + tip1.set_opacity(1) + tip1.set_fill(DARK_BLUE) + tip1.set_color(DARK_BLUE) + + arrow2 = Line(start = ORIGIN,end = 1*UP) + arrow2.set_color(DARK_BLUE) + tip2 = Polygon(UP,0.9*UP-0.1*RIGHT,0.9*UP-0.1*LEFT) + 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,1]) + arrow3.set_color(DARK_BLUE) + tip3 = Polygon([0,0,1],[0,0,0.9]-0.1*RIGHT,[0,0,0.9]-0.1*LEFT) + tip3.set_opacity(1) + tip3.set_fill(DARK_BLUE) + tip3.set_color(DARK_BLUE) + + axes = ThreeDAxes(x_min = -3,x_max=3,y_min=-3,y_max=3,z_min=-3,z_max=3) + self.play(ShowCreation(axes)) + self.move_camera(phi=70*DEGREES,theta=0*DEGREES,run_time=3) + self.begin_ambient_camera_rotation(rate=0.2) + + #matrix = [[1,0,0],[0,1,0],[0,0,1]] + matrix = [[0.70710678118,-0.57735026919,-0.57735026919],[0.70710678118,0.57735026919,0.57735026919],[0,-0.57735026919,0.57735026919]] + matrix1 = [[0.70710678118,0,0],[0.70710678118,1,0],[0,0,1]] + + matrix1 = [[0.70710678118,-0.70710678118,0],[0.70710678118,0.70710678118,0],[0,0,1]] + matrix2 = [[1,0,0],[0,0.70710678118,0.70710678118],[0,-0.70710678118,0.70710678118]] + + + line1.apply_matrix(matrix1) + tip1.apply_matrix(matrix1) + arrow2.apply_matrix(matrix1) + tip2.apply_matrix(matrix1) + arrow3.apply_matrix(matrix1) + tip3.apply_matrix(matrix1) + + line1.apply_matrix(matrix2) + tip1.apply_matrix(matrix2) + arrow2.apply_matrix(matrix2) + tip2.apply_matrix(matrix2) + arrow3.apply_matrix(matrix2) + tip3.apply_matrix(matrix2) + + self.play(ShowCreation(line1), + ShowCreation(tip1), + ShowCreation(arrow2), + ShowCreation(tip2), + ShowCreation(arrow3), + ShowCreation(tip3)) + + text = TextMobject(r"This is also a set of Orthonormal Vectors") + text.set_color(DARK_BLUE) + self.add_fixed_in_frame_mobjects(text) + text.scale(0.6) + text.move_to(3*DOWN+3.5*RIGHT) + self.play(Write(text)) + + self.wait(22) diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file5.gif b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file5.gif Binary files differnew file mode 100644 index 0000000..cdc0f2d --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file5.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file6.gif b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file6.gif Binary files differnew file mode 100644 index 0000000..e03f265 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file6.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file7.gif b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file7.gif Binary files differnew file mode 100644 index 0000000..19a13dd --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file7.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file8.gif b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file8.gif Binary files differnew file mode 100644 index 0000000..0ef4551 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Gram-Schmidt-Orthonormalization-Process/file8.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/README.md b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/README.md new file mode 100644 index 0000000..2a46424 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/README.md @@ -0,0 +1,30 @@ +# Contributer: Archit Sangal +My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal) +<br/></br> + +## Sub-Topics Covered: ++ Linear Transformations (Linear Maps) + +#### Video 1: Visually understanding linear transformation(using grid) +![GIF1](file12.gif) + +#### Video 2: Linear Transformation when form 1 is given +![GIF2](file11.gif) + +#### Video 3: Matrix Representation Of Linear Transformation +![GIF3](file9.gif) + +#### Video 4: Understand Linear Transformations visually +![GIF4](file13.gif) + +#### Video 5: Uniform Scaling +![GIF5](file14.gif) + +#### Fig.1 Horizontal Shear +![GIF6](file6_Horizontal_Shear_gif.gif) + +#### Fig.2 Vertical Shear +![GIF7](file7_Vertical_Shear_gif.gif) + +#### Video 6: Rotation by an angle of in anticlockwise direction +![GIF8](file10.gif)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file10.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file10.gif Binary files differnew file mode 100644 index 0000000..d996130 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file10.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file11.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file11.gif Binary files differnew file mode 100644 index 0000000..d8c64b7 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file11.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file12.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file12.gif Binary files differnew file mode 100644 index 0000000..92bdff6 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file12.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file13.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file13.gif Binary files differnew file mode 100644 index 0000000..ba6c156 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file13.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file14.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file14.gif Binary files differnew file mode 100644 index 0000000..fd9bc7b --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file14.gif 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..0182bd9 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file1_transformations.py @@ -0,0 +1,73 @@ +from manimlib.imports import * + +class text(Scene): + def construct(self): + text1 = TextMobject("For a grid, undergoing a linear transformation, all its 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) + text3 = TextMobject("Origin must remain where it was before transformation.") + text3.scale(0.9) + text1.move_to(ORIGIN+UP) + text2.move_to(ORIGIN) + text3.move_to(ORIGIN+DOWN) + self.play(Write(text1)) + self.play(Write(text2)) + self.play(Write(text3)) + self.wait() + self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3)) + +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) + # I have taken reference from purusharth's code + 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() + +class MoveOrigin(LinearTransformationScene): + + CONFIG = { + "show_basis_vectors": False, + } + def construct(self): + self.wait() + + dot = Dot(ORIGIN, color = YELLOW) + self.add_transformable_mobject(dot) + self.apply_nonlinear_transformation(self.func) + text = TextMobject("This is also not a linear transformation as the origin moves from its original position") + text.move_to(2*DOWN) + text.scale(0.5) + text.set_color(YELLOW) + text.add_background_rectangle() + self.play(Write(text)) + self.wait() + + def func(self, point): + matrix_transform = self.get_matrix_transformation([[1, -1], [1, 1]]) + return matrix_transform(point) + UP+ RIGHT diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py new file mode 100755 index 0000000..1f6badd --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file2_before_matrix.py @@ -0,0 +1,233 @@ +from manimlib.imports import * + +class Linear(GraphScene): + + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + + 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) + + self.setup_axes(animate = True) + heading = TextMobject(r"$T(x,y) = T(x+2y,x-y)$") + heading.move_to(UP*3+LEFT*4) + heading.scale(0.7) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(ORANGE) + before.move_to(3*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(self.graph_origin+1*XTD*RIGHT+1*YTD*UP) + dot2 = Dot().shift(self.graph_origin+2*XTD*RIGHT+1*YTD*UP) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + p1 = TextMobject(r"$P_1$") + p1.scale(0.75) + p1.set_color(ORANGE) + p1.move_to(self.graph_origin+1*XTD*RIGHT+1.5*YTD*UP) + p2 = TextMobject(r"$P_2$") + p2.set_color(ORANGE) + p2.scale(0.75) + p2.move_to(self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(YELLOW) + after.move_to(3*UP+4.5*RIGHT) + after.scale(0.5) + dot3 = Dot().shift(self.graph_origin+3*XTD*RIGHT+0*YTD*UP) + dot4 = Dot().shift(self.graph_origin+4*XTD*RIGHT+1*YTD*UP) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.7) + p3.set_color(YELLOW) + p3.move_to(self.graph_origin+3*XTD*RIGHT-1.1*YTD*UP) + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.7) + p4.set_color(YELLOW) + p4.move_to(self.graph_origin+4*XTD*RIGHT+1.5*YTD*UP) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + self.play(Transform(before,after), Transform(dot1,dot3), Transform(dot2,dot4), Transform(p2,p4), Transform(p1,p3)) + self.wait(3) + + +class withgrid(LinearTransformationScene): + def construct(self): + + heading = TextMobject(r"Now, imagine this happening for all the points") + heading.scale(0.5) + heading.move_to(UP*2.5+LEFT*4) + self.play(Write(heading)) + self.wait() + + before = TextMobject("Before Linear Transformation") + before.set_color(ORANGE) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(2*RIGHT+1*UP) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) + self.add_transformable_mobject(dot1_c) + self.add_transformable_mobject(dot2_c) + + p1 = TextMobject(r"$P_1$") + p1.scale(0.75) + p1.set_color(ORANGE) + p1.move_to(1*RIGHT+1.5*UP) + p2 = TextMobject(r"$P_2$") + p2.scale(0.75) + p2.set_color(ORANGE) + p2.move_to(2*RIGHT+1.5*UP) + + after = TextMobject("After applying Linear Transformation") + after.set_color(YELLOW) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + dot3 = Dot().shift(3*RIGHT+0*UP) + dot4 = Dot().shift(4*RIGHT+1*UP) + dot3.set_color(YELLOW) + dot4.set_color(YELLOW) + p3 = TextMobject(r"$T(P_1)$") + p3.scale(0.75) + p3.set_color(YELLOW) + p3.move_to(3*RIGHT-0.6*UP) + p4 = TextMobject(r"$T(P_2)$") + p4.scale(0.75) + p4.set_color(YELLOW) + p4.move_to(4*RIGHT+1.5*UP) + + self.play(Write(before), ShowCreation(dot1), ShowCreation(dot2),Write(p1), Write(p2)) + self.wait(3) + matrix = [[1,2],[1,-1]] + dot1.set_color(GREY) + dot2.set_color(GREY) + self.play(FadeIn(dot1),FadeIn(dot2)) + self.apply_matrix(matrix) + self.play(Transform(before,after), Transform(p2,p4), Transform(p1,p3)) + self.play(Transform(before,after)) + self.wait(3) + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right]) = \left[\begin{array}{c} x+2y \\ x-y\end{array}\right]$") + ending.move_to(UP*2+LEFT*4) + self.play(Transform(heading,ending)) + self.wait() + +from manimlib.imports import * +class ThreeDExplanation(ThreeDScene): + + def construct(self): + + text = TextMobject(r"$T(x,y) = (x+y,x-y,x+2y)$") + text.scale(0.75) + text.move_to(UP*2.5+LEFT*4) + text.move_to(-UP*3+LEFT*4) + self.add_fixed_in_frame_mobjects(text) + self.play(Write(text)) + self.wait() + + before = TextMobject("Before Linear Transformation") + self.add_fixed_in_frame_mobjects(before) + before.set_color(ORANGE) + before.move_to(3.5*UP+4*RIGHT) + before.scale(0.75) + + p1 = TextMobject(r"$P_1$") + p2 = TextMobject(r"$P_2$") + p3 = TextMobject(r"$P_3$") + p1.scale(0.75) + p2.scale(0.75) + p3.scale(0.75) + dot1 = Dot().shift(1*RIGHT+1*UP) + dot2 = Dot().shift(2*RIGHT+1*UP) + dot3 = Dot().shift(1*RIGHT+1*DOWN) + dot1.set_color(ORANGE) + dot2.set_color(ORANGE) + dot3.set_color(ORANGE) + self.play(ShowCreation(before)) + + p1.move_to(1*RIGHT+1*UP+[0,0,0.5]) + p2.move_to(2*RIGHT+1*UP+[0,0,0.5]) + p3.move_to(1*RIGHT-1*UP+[0,0,0.5]) + + dot1_c = Dot(radius = 0.05).shift(1*RIGHT+1*UP) + dot2_c = Dot(radius = 0.05).shift(0*RIGHT+2*UP) + dot3_c = Dot(radius = 0.05).shift(1*RIGHT-1*UP) + dot1_c.set_color(YELLOW) + dot2_c.set_color(YELLOW) + dot3_c.set_color(YELLOW) + + axes = ThreeDAxes(x_min = -7,x_max=7,y_min=-4,y_max=4,z_min=-4,z_max=4) + self.play(ShowCreation(axes)) + self.move_camera(distance = 100, phi=30*DEGREES,theta=45*DEGREES,run_time=3) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(1) + self.stop_ambient_camera_rotation() + + plane = NumberPlane() + self.add_fixed_orientation_mobjects(p1) + self.add_fixed_orientation_mobjects(p2) + self.add_fixed_orientation_mobjects(p3) + self.play(ShowCreation(dot1),ShowCreation(dot3),ShowCreation(dot2),ShowCreation(plane)) + + self.play(FadeOut(before)) + after = TextMobject("After applying Linear Transformation") + self.add_fixed_in_frame_mobjects(after) + after.set_color(YELLOW) + after.move_to(3.5*UP+3.5*RIGHT) + after.scale(0.75) + + self.play(FadeOut(p1),FadeOut(p2),FadeOut(p3)) + matrix = [[1,1],[1,-1],[2,1]] + self.play(FadeOut(dot1),FadeOut(dot2),FadeOut(dot3),ApplyMethod(plane.apply_matrix,matrix),ApplyMethod(dot1_c.apply_matrix,matrix),ApplyMethod(dot3_c.apply_matrix,matrix),ApplyMethod(dot2_c.apply_matrix,matrix)) + + p4 = TextMobject(r"$T(P_1)$") + p5 = TextMobject(r"$T(P_2)$") + p6 = TextMobject(r"$T(P_3)$") + p4.scale(0.75) + p5.scale(0.75) + p6.scale(0.75) + p4.move_to(2*RIGHT+0*UP+[0,0,3.5]) + p5.move_to(2*RIGHT-2*UP+[0,0,2.5]) + p6.move_to(0*RIGHT+2*UP+[0,0,1.5]) + self.add_fixed_orientation_mobjects(p5) + self.add_fixed_orientation_mobjects(p4) + self.add_fixed_orientation_mobjects(p6) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(3) + self.stop_ambient_camera_rotation() + + ending = TextMobject(r"$T(\left[\begin{array}{c}x \\ y\end{array}\right])$ = ",r"$\left[\begin{array}{c} x+y \\ x-y\\ x+2y \end{array}\right]$") #\begin{array}{c} x+y \\ x-y -- \\ x+2y -- \end{array}\right]$") + ending.scale(0.75) + ending.move_to(-UP*3+LEFT*4) + self.add_fixed_in_frame_mobjects(ending) + self.play(FadeOut(text),Write(ending)) + + self.play(FadeOut(plane)) + self.wait(2) + + self.begin_ambient_camera_rotation(rate=0.3) + self.wait(8) + self.stop_ambient_camera_rotation() diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py new file mode 100644 index 0000000..e828de4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file3_square.py @@ -0,0 +1,246 @@ +from manimlib.imports import * + +class Linear(GraphScene): + CONFIG = { + "x_min": -5, + "x_max": 5, + "y_min": -5, + "y_max": 5, + "graph_origin": ORIGIN, + "x_labeled_nums": list(range(-5, 6)), + "y_labeled_nums": list(range(-5, 6)), + "x_axis_width": 7, + "y_axis_height": 7, + } + def construct(self): + + text = TextMobject("T(x,y) = T(x+y,y)") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(3*UP+5*LEFT) + self.play(Write(text)) + + XTD = self.x_axis_width/(self.x_max- self.x_min) + YTD = self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate = True) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + a = TextMobject("(1,1)") + b = TextMobject("(3,1)") + c = TextMobject("(3,2)") + d = TextMobject("(1,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+0.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+3.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+3.4*RIGHT) + d.move_to(self.graph_origin+2.6*UP+0.6*RIGHT) + + square = Polygon(self.graph_origin+UP+RIGHT,self.graph_origin+UP+3*RIGHT,self.graph_origin+2*UP+3*RIGHT,self.graph_origin+2*UP+RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1), FadeOut(a), FadeOut(b), FadeOut(c), FadeOut(d), ApplyMethod(square.apply_matrix,[[1,1],[0,1]])) + + a = TextMobject("(2,1)") + b = TextMobject("(4,1)") + c = TextMobject("(3,2)") + d = TextMobject("(5,2)") + a.scale(0.5) + b.scale(0.5) + c.scale(0.5) + d.scale(0.5) + a.move_to(self.graph_origin+0.6*UP+1.6*RIGHT) + b.move_to(self.graph_origin+0.6*UP+4.4*RIGHT) + d.move_to(self.graph_origin+2.4*UP+5.4*RIGHT) + c.move_to(self.graph_origin+2.4*UP+2.6*RIGHT) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3+3*RIGHT) + + self.play(Write(text1), Write(a), Write(b), Write(c), Write(d)) + + self.wait(2) + +class grid(LinearTransformationScene): + def construct(self): + + text = TextMobject("Now, consider all the vectors.") + text.scale(0.75) + text.set_color(PURPLE) + text.move_to(2.5*UP+3*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.wait() + +class grid2(LinearTransformationScene): + CONFIG = { + "include_background_plane": True, + "include_foreground_plane": False, + "show_coordinates": True, + "show_basis_vectors": True, + "basis_vector_stroke_width": 3, + "i_hat_color": X_COLOR, + "j_hat_color": Y_COLOR, + "leave_ghost_vectors": True, + } + + def construct(self): + + text = TextMobject("Now, let us focus only on the standard basis") + text.scale(0.7) + text.set_color(PURPLE) + text.move_to(2.5*UP+3.5*LEFT) + self.play(Write(text)) + + text1 = TextMobject("Before Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + square = Polygon(UP+RIGHT,UP+3*RIGHT,2*UP+3*RIGHT,2*UP+RIGHT) + square.set_color(YELLOW) + + self.play(Write(text1), ShowCreation(square)) + self.wait(2) + self.play(FadeOut(text1)) + self.add_transformable_mobject(square) + + text1 = TextMobject("After Linear Transformation") + text1.scale(0.6) + text1.move_to(UP*3.5+3.5*RIGHT) + + matrix = [[1,1],[0,1]] + + self.apply_matrix(matrix) + self.play(Write(text1)) + + self.play(FadeOut(square), FadeOut(text1)) + + cor_x = TextMobject("(1,0)") + cor_y = TextMobject("(1,1)") + cor_x.scale(0.65) + cor_y.scale(0.65) + cor_y.move_to(1.25*RIGHT+1.5*UP) + cor_x.move_to(0.75*RIGHT-0.5*UP) + cor_x.set_color(GREEN) + cor_y.set_color(RED) + + x_cor = TextMobject(r"$\left[\begin{array}{c} 1\\0\end{array}\right]$") + x_cor.set_color(GREEN) + x_cor.scale(0.5) + y_cor = TextMobject(r"$\left[\begin{array}{c} 1\\1\end{array}\right]$") + x_cor.move_to(0.75*RIGHT-0.5*UP) + y_cor.move_to(1.25*RIGHT+1.5*UP) + y_cor.set_color(RED) + y_cor.scale(0.5) + + text1 = TextMobject(r"$T(\left[\begin{array}{c} x\\y \end{array}\right]) = $",r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text1.scale(0.7) + text1.set_color(PURPLE) + text1.move_to(1.5*UP+3*LEFT) + + text = TextMobject(r"$T(x,y) = (x+y,y)$") + text.scale(0.6) + text.set_color(PURPLE) + text.move_to(1.5*UP+3*LEFT) + + self.play(FadeIn(text),FadeIn(cor_x), FadeIn(cor_y)) + self.wait() + + self.play(Transform(text,text1), Transform(cor_x,x_cor), Transform(cor_y,y_cor)) + + text3 = TextMobject(r"$\left[\begin{array}{c} x+y\\y \end{array}\right]$") + text3.scale(0.7) + text3.set_color(PURPLE) + text3.move_to(1.5*DOWN+5*LEFT) + + equal = TextMobject("=") + equal.move_to(1.5*DOWN+3.5*LEFT) + + text3 = TextMobject("[") + text4 = TextMobject(r"$\begin{array}{c} (1)x\\(0)x \end{array}$") + text5 = TextMobject(r"$\begin{array}{c} + \\ + \end{array}$") + text6 = TextMobject(r"$\begin{array}{c} (1)y\\(1)y \end{array}$") + text7 = TextMobject("]") + text3.scale(2) + text4.scale(0.7) + text5.scale(0.7) + text6.scale(0.7) + text7.scale(2) + text4.set_color(GREEN) + text5.set_color(PURPLE) + text6.set_color(RED) + text3.move_to(1.5*DOWN+3*LEFT) + text4.move_to(1.5*DOWN+2.5*LEFT) + text5.move_to(1.5*DOWN+2*LEFT) + text6.move_to(1.5*DOWN+1.5*LEFT) + text7.move_to(1.5*DOWN+1*LEFT) + + text1[1].scale(1.2) + self.play(FadeOut(text1[0]), ApplyMethod(text1[1].move_to,1.5*DOWN+5*LEFT), FadeIn(text3), FadeIn(equal), FadeIn(text4), FadeIn(text5), FadeIn(text6), FadeIn(text7)) + + self.wait() + self.play(FadeOut(text1[1])) + + self.play(ApplyMethod(text3.move_to,1.5*DOWN+6*LEFT), + ApplyMethod(text4.move_to,1.5*DOWN+5.5*LEFT), + ApplyMethod(text5.move_to,1.5*DOWN+5*LEFT), + ApplyMethod(text6.move_to,1.5*DOWN+4.5*LEFT), + ApplyMethod(text7.move_to,1.5*DOWN+4*LEFT)) + + text10 = TextMobject("[") + text11 = TextMobject(r"$\begin{array}{c} 1\\0 \end{array}$") + text13 = TextMobject(r"$\begin{array}{c} 1\\1 \end{array}$") + text14 = TextMobject("]") + text10.scale(2) + text11.scale(0.7) + text13.scale(0.7) + text14.scale(2) + text11.set_color(GREEN) + text13.set_color(RED) + text10.move_to(1.5*DOWN+3*LEFT) + text11.move_to(1.5*DOWN+2.75*LEFT) + text13.move_to(1.5*DOWN+2.25*LEFT) + text14.move_to(1.5*DOWN+2*LEFT) + + self.play(FadeIn(text10), Transform(x_cor,text11), Transform(y_cor,text13), FadeIn(text14)) + + text15 = TextMobject(r"$\left[\begin{array}{c} x\\y \end{array}\right]$") + text15.scale(0.7) + text15.set_color(PURPLE) + text15.move_to(1.5*DOWN+1.5*LEFT) + + self.play(FadeIn(text15)) + self.play(FadeOut(text3), FadeOut(text4), FadeOut(text5), FadeOut(text7), FadeOut(text6)) + + text1[0].scale(1.2) + self.play(ApplyMethod(text1[0].move_to,1.5*DOWN+4.5*LEFT), FadeOut(equal)) + self.wait(2)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py new file mode 100644 index 0000000..577032d --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file4_Understand_Linear_Transformations_visually.py @@ -0,0 +1,193 @@ +from manimlib.imports import * + +class Rotation(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + 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) + + introText = TextMobject("Understanding Linear Transformations") + self.play(Write(introText)) + self.wait(1) + + introText1 = TextMobject("Visually ... ") + introText1.move_to(DOWN) + self.play(Write(introText1)) + self.wait(1) + self.play(FadeOut(introText), FadeOut(introText1)) + + Text1 = TextMobject("Let $\overrightarrow{v}$ be $2\hat{i}+3\hat{j}$") + Text2 = TextMobject("$\overrightarrow{v} = 2\hat{i}+3\hat{j}$") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + self.play(Write(Text1)) + self.wait() + self.play(Transform(Text1,Text2)) + + self.setup_axes(animate=True) + arrow_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*LEFT + 0.25*DOWN, end = self.graph_origin+2*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.25*UP) + self.play(ShowCreation(arrow_v)) + + Text_i = TextMobject("$\hat{i}$") + Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) + Text_i.scale(0.75) + Text_j = TextMobject("$\hat{j}$") + Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) + Text_j.scale(0.75) + + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) + self.play(ShowCreation(arrow_i), ShowCreation(arrow_j), Write(Text_i), Write(Text_j)) + + Text_2i = TextMobject("$2\hat{i}$") + Text_2i.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) + Text_3j = TextMobject("$3\hat{j}$") + Text_3j.move_to(self.graph_origin+1*XTD*LEFT+1.5*YTD*UP) + + arrow_2i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+2*XTD*RIGHT+ 0.25*RIGHT) + arrow_2i.set_color(YELLOW) + arrow_3j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+3*YTD*UP+0.25*UP) + arrow_3j.set_color(RED) + self.wait(0.5) + self.play(Transform(arrow_i,arrow_2i), Transform(arrow_j,arrow_3j), Transform(Text_i,Text_2i), Transform(Text_j,Text_3j)) + self.play(ApplyMethod(arrow_j.move_to,self.graph_origin+2*XTD*RIGHT+1.5*YTD*UP) , ApplyMethod(Text_j.move_to,self.graph_origin+2.5*XTD*RIGHT+1.5*YTD*UP+ 0.15*RIGHT + 0.25*UP)) + + new_Text_v = TextMobject("$\overrightarrow{v}$") + new_Text_v.move_to(self.graph_origin+0.5*XTD*RIGHT+1.5*YTD*UP) + self.play(Write(new_Text_v)) + + new_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + new_arrow_i.set_color(YELLOW) + new_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*YTD*UP+0.25*UP) + new_arrow_j.set_color(RED) + + new_Text_i = TextMobject("$\hat{i}$") + new_Text_i.move_to(self.graph_origin+0.5*XTD*RIGHT+0.5*YTD*DOWN) + new_Text_i.scale(0.75) + new_Text_j = TextMobject("$\hat{j}$") + new_Text_j.move_to(self.graph_origin+0.5*XTD*LEFT+0.5*YTD*UP) + new_Text_j.scale(0.75) + + self.wait(1) + + self.play(FadeOut(Text_i), + FadeOut(Text_j), + FadeOut(arrow_i), + FadeOut(arrow_j), + ShowCreation(new_arrow_i), + ShowCreation(new_arrow_j), + Write(new_Text_i), + Write(new_Text_j)) + + self.play(ApplyMethod(Text1.move_to,4*RIGHT)) + Text3 = TextMobject("Let the be a linear transformation function") + Text3.scale(0.5) + Text4 = TextMobject("$T$ which rotates the vectors by angle of $90^{\circ}$") + Text4.scale(0.5) + Text3.move_to(4*RIGHT+3*UP) + Text4.move_to(4*RIGHT+2.5*UP) + self.play(Write(Text3), Write(Text4)) + self.wait(2) + + Text6 = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + Text6.scale(0.75) + Text6.set_color(YELLOW) + Text6.move_to(self.graph_origin+1*XTD*RIGHT+1*YTD*DOWN) + Text7 = TextMobject(r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") + Text7.scale(0.75) + Text7.set_color(RED) + Text7.move_to(self.graph_origin+1*XTD*LEFT+1*YTD*UP) + + self.play(Transform(new_Text_i,Text6)) + self.play(Transform(new_Text_j,Text7)) + + Text5 = TextMobject(r"$\overrightarrow{v} = 2 $", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 0 \\ 1 \end{pmatrix}$") + Text5[1].set_color(YELLOW) + Text5[3].set_color(RED) + Text5.move_to(4*RIGHT) + + self.play(Transform(Text1, Text5)) + self.wait() + + arrow_modified_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*UP, end = self.graph_origin-(1*YTD*UP+0.25*UP)) + arrow_modified_i.set_color(YELLOW) + arrow_modified_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_modified_j.set_color(RED) + + yellow_i = TextMobject(r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$") + yellow_i.set_color(YELLOW).scale(0.75) + yellow_i.move_to(self.graph_origin + 1*XTD*DOWN + 1*YTD*LEFT) + + red_j = TextMobject(r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + red_j.set_color(RED).scale(0.75) + red_j.move_to(self.graph_origin + 1*XTD*UP + 1*YTD*RIGHT) + + Text8 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\begin{pmatrix} 0 \\ -1 \end{pmatrix}$", r"+3", r"$\begin{pmatrix} 1 \\ 0 \end{pmatrix}$") + Text8[1].set_color(YELLOW) + Text8[3].set_color(RED) + Text8.move_to(4*RIGHT+1.5*DOWN) + Text8.scale(0.75) + + new_Text__v = TextMobject("$\overrightarrow{v}_{transformed}$") + new_Text__v.scale(0.75) + arrow_modified_v = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT + 0.15*UP, end = self.graph_origin+2*XTD*DOWN+3*YTD*RIGHT+ 0.15*DOWN + 0.25*RIGHT) + self.play(Transform(arrow_v, arrow_modified_v), + Transform(new_arrow_i, arrow_modified_i), + Transform(new_arrow_j, arrow_modified_j), + Transform(new_Text_i,yellow_i), + Transform(new_Text_j,red_j), + FadeOut(new_Text_v), + ApplyMethod(new_Text__v.move_to,self.graph_origin+3*XTD*RIGHT+0.5*YTD*DOWN), + Write(Text8)) + + self.play(FadeOut(Text1), FadeOut(Text3), FadeOut(Text4), ApplyMethod(Text8.move_to,4*RIGHT+3*UP)) + + Text9 = TextMobject(r"$\overrightarrow{v}_{transformed} = 2 $", r"$\hat{i}_{transformed}$", r"+3", r"$\hat{j}_{transformed}$") + Text9[1].set_color(YELLOW) + Text9[3].set_color(RED) + Text9.move_to(4*RIGHT+2*UP) + Text9.scale(0.5) + + self.play(Write(Text9)) + + v_transformed = TextMobject(r"$\overrightarrow{v}_{transformed} \equiv T(\overrightarrow{v})$") + v_transformed.scale(0.75).move_to(4*RIGHT+UP) + i_transformed = TextMobject(r"$\hat{i}_{transformed} \equiv T(\hat{i})$") + i_transformed.set_color(YELLOW).scale(0.75).move_to(4*RIGHT) + j_transformed = TextMobject(r"$\hat{v}_{transformed} \equiv T(\hat{j})$") + j_transformed.set_color(RED).scale(0.75).move_to(4*RIGHT+DOWN) + + self.play(Write(v_transformed), Write(i_transformed), Write(j_transformed)) + self.wait(3) + + Text10 = TextMobject(r"$T(\overrightarrow{v}) = $", r"$\begin{pmatrix} 3 \\ -2 \end{pmatrix}$") + Text10[1].set_color(BLUE_E) + Text10.move_to(4*RIGHT+1*UP) + Text10.scale(0.75) + + self.play(Write(Text10), ApplyMethod(v_transformed.move_to,4*RIGHT+2*UP), FadeOut(i_transformed), FadeOut(j_transformed), FadeOut(Text9)) + self.wait(1) + + self.play(FadeOut(self.axes), + FadeOut(arrow_v), + FadeOut(new_arrow_i), + FadeOut(new_arrow_j), + FadeOut(new_Text_i), + FadeOut(new_Text_i), + FadeOut(new_Text_j), + FadeOut(new_Text__v), + FadeOut(Text10), + FadeOut(v_transformed), + FadeOut(Text8)) diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py new file mode 100644 index 0000000..a7856a5 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file5_Uniform_Scaling.py @@ -0,0 +1,91 @@ +from manimlib.imports import * + +class Scaling(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + 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) + + introText = TextMobject("Scaling") + self.play(Write(introText)) + self.wait(1) + self.play(FadeOut(introText)) + + introText = TextMobject("Uniform Scaling") + self.play(Write(introText)) + self.wait(1) + self.play(FadeOut(introText)) + + Text1 = TextMobject("Let $\overrightarrow{v}$ be $3\hat{i}+3\hat{j}$") + Text2 = TextMobject("$\overrightarrow{v} = 3\hat{i}+3\hat{j}$") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + self.play(Write(Text1)) + self.wait() + self.play(Transform(Text1,Text2)) + + self.setup_axes(animate=True) + arrow_v = Arrow(stroke_width = 4, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+3*XTD*RIGHT+3*YTD*UP+ 0.15*RIGHT + 0.15*UP) + vector_v = TextMobject(r"$\vec{v}$") + vector_v.move_to(self.graph_origin + 1*XTD*RIGHT + 2*YTD*UP ) + self.play(ShowCreation(arrow_v),Write(vector_v)) + scaling_factor = TextMobject(r"Scaling Factor = $\frac{4}{3}$") + scaling_factor.scale(0.75) + scaled_vector = TextMobject(r"$T(\vec{v}) = \frac{4}{3} \left[ \begin{array} {c} 3 \\ 3 \end{array} \right] = \left[ \begin{array} {c} 4 \\ 4 \end{array} \right]$") + scaled_vector.set_color(DARK_BLUE) + scaled_vector.scale(0.75) + scaling_factor.move_to(4*RIGHT) + scaled_vector.move_to(4*RIGHT+DOWN) + self.play(Write(scaling_factor)) + self.wait() + self.play(Write(scaled_vector)) + + transformed_arrow_v = Arrow(stroke_width = 2, start = self.graph_origin + 0.15*LEFT + 0.15*DOWN, end = self.graph_origin+4*XTD*RIGHT+4*YTD*UP+ 0.15*RIGHT + 0.15*UP) + transformed_arrow_v.set_color(DARK_BLUE) + transformed_vector_v = TextMobject(r"$T(\vec{v})$") + transformed_vector_v.move_to(self.graph_origin + 4.5*XTD*RIGHT + 4.5*YTD*UP ) + transformed_vector_v.set_color(DARK_BLUE) + self.play(ShowCreation(transformed_arrow_v), Write(transformed_vector_v)) + + self.wait() + + represent_text1 = TextMobject("Representation of scaling") + represent_text2 = TextMobject("of vectors in point form") + represent_text1.move_to(4*RIGHT+3*UP) + represent_text2.move_to(4*RIGHT+2*UP) + self.play(Write(represent_text1), Write(represent_text2)) + + dot_init = Dot(self.graph_origin+3*XTD*RIGHT+3*YTD*UP) + dot_trans = Dot(self.graph_origin+4*XTD*RIGHT+4*YTD*UP) + + self.play(ApplyMethod(vector_v.move_to,self.graph_origin+2.5*XTD*RIGHT+2.5*YTD*UP), + ApplyMethod(transformed_vector_v.move_to,self.graph_origin+4.5*XTD*RIGHT+4.5*YTD*UP), + ShowCreation(dot_init), + Transform(arrow_v,dot_init), + Transform(transformed_arrow_v,dot_trans)) + + self.wait(2) + + self.play(FadeOut(dot_init), + FadeOut(arrow_v), + FadeOut(transformed_arrow_v), + FadeOut(represent_text1), + FadeOut(represent_text2), + FadeOut(self.axes), + FadeOut(scaling_factor), + FadeOut(scaled_vector), + FadeOut(transformed_vector_v), + FadeOut(vector_v), + FadeOut(Text1))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py new file mode 100644 index 0000000..91f098e --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear.py @@ -0,0 +1,53 @@ +from manimlib.imports import * + +class Hori_Shear(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + 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) + + Text1 = TextMobject("Before"," Horizontal") + Text1[0].set_color(YELLOW) + Text2 = TextMobject("Shear Transformation") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + + self.setup_axes(animate=False) + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) + arrow_i.set_color(YELLOW) + arrow_j.set_color(YELLOW) + + square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) + self.wait(1) + + Text3 = TextMobject("After"," Horizontal") + Text3[0].set_color(RED) + Text4 = TextMobject("Shear Transformation") + + Text3.move_to(4*RIGHT+2*UP) + Text4.move_to(4*RIGHT+1*UP) + + trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) + trans_arrow_i.set_color(RED) + trans_arrow_j.set_color(RED) + + rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+4*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), Transform(square,rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) + self.wait(1)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif Binary files differnew file mode 100644 index 0000000..9bef1b6 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file6_Horizontal_Shear_gif.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py new file mode 100644 index 0000000..718e4e0 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear.py @@ -0,0 +1,52 @@ +from manimlib.imports import * + +class Ver_Shear(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "graph_origin" : ORIGIN+3.5*LEFT, + "x_axis_width" : 7, + "y_axis_height" : 7 + #"x_labeled_nums" : list(range(-5,6)), + #"y_labeled_nums" : list(range(-5,6)), + } + + 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) + + Text1 = TextMobject("Before"," Vertical") + Text1[0].set_color(YELLOW) + Text2 = TextMobject("Shear Transformation") + + Text1.move_to(4*RIGHT+2*UP) + Text2.move_to(4*RIGHT+1*UP) + + self.setup_axes(animate=False) + arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*LEFT, end = self.graph_origin+1*XTD*RIGHT+ 0.25*RIGHT) + arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+0.25*UP) + arrow_i.set_color(YELLOW) + arrow_j.set_color(YELLOW) + + square = Polygon(self.graph_origin,self.graph_origin+2*XTD*RIGHT, self.graph_origin+2*XTD*RIGHT+2*YTD*UP, self.graph_origin+2*YTD*UP) + square.set_color(DARK_BLUE) + self.play(ShowCreation(square), Write(Text1), Write(Text2), ShowCreation(arrow_i), ShowCreation(arrow_j)) + self.wait(1) + + Text3 = TextMobject("After"," Vertical") + Text3[0].set_color(RED) + Text4 = TextMobject("Shear Transformation") + + Text3.move_to(4*RIGHT+2*UP) + Text4.move_to(4*RIGHT+1*UP) + + trans_arrow_i = Arrow(stroke_width = 3, start = self.graph_origin + 0.15*DOWN + 0.15*LEFT, end = self.graph_origin+1*XTD*UP+1*YTD*RIGHT+0.25*UP+0.25*RIGHT) + trans_arrow_j = Arrow(stroke_width = 3, start = self.graph_origin + 0.25*DOWN, end = self.graph_origin+1*XTD*UP+ 0.25*UP) + trans_arrow_i.set_color(RED) + trans_arrow_j.set_color(RED) + + rhombus = Polygon(self.graph_origin,self.graph_origin+2*XTD*UP, self.graph_origin+2*XTD*RIGHT+4*YTD*UP, self.graph_origin+2*XTD*RIGHT+2*YTD*UP) + self.play(Transform(arrow_i,trans_arrow_i), Transform(arrow_j,trans_arrow_j), FadeOut(square), ShowCreation(rhombus), Transform(Text1,Text3), Transform(Text2,Text4)) + self.wait(1)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif Binary files differnew file mode 100644 index 0000000..7ca323f --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file7_Vertical_Shear_gif.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_linear_transformation.py new file mode 100755 index 0000000..01a0cef --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file8_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/Linear-Transformations-(Linear-Maps)/file9.gif b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file9.gif Binary files differnew file mode 100644 index 0000000..017e0c7 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Linear-Transformations-(Linear-Maps)/file9.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/README.md b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/README.md new file mode 100644 index 0000000..e287fa1 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/README.md @@ -0,0 +1,15 @@ +# Contributer: Archit Sangal +My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal) +<br/></br> + +## Sub-Topics Covered: ++ Orthonormal Bases + +#### Video 1: Example of Orthonormal bases +![GIF1](file4.gif) + +#### Video 2: Adding the projections of a vector on orthonormal basis will produce the same vector +![GIF2](file5.gif) + +#### Video 3: Relating the example and the property +![GIF3](file6.gif)
\ No newline at end of file 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..a5d96f5 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file1_orthogonal.py @@ -0,0 +1,40 @@ +from manimlib.imports import *
+
+class Orthogonal(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+ self.play(ShowCreation(axes))
+ self.move_camera(phi=60*DEGREES,theta=45*DEGREES,run_time=3)
+
+ text = TextMobject(r"$\hat{i}$",r"$\hat{j}$",r"$\hat{k}$")
+ text[0].move_to(0.7*DOWN+0.8*LEFT)
+ text[1].move_to(0.75*DOWN+0.7*RIGHT)
+ text[2].move_to(0.75*UP+0.4*RIGHT)
+ self.add_fixed_in_frame_mobjects(text)
+ self.play(Write(text))
+
+ line1 = Line(start = ORIGIN,end = RIGHT)
+ line1.set_color(DARK_BLUE)
+ tip1 = Polygon(-0.95*LEFT,-0.8*LEFT-0.1*DOWN,-0.8*LEFT-0.1*UP)
+ tip1.set_opacity(1)
+ tip1.set_fill(DARK_BLUE)
+ tip1.set_color(DARK_BLUE)
+
+ arrow2 = Line(start = ORIGIN,end = UP)
+ arrow2.set_color(DARK_BLUE)
+ tip2 = Polygon(0.95*UP,0.8*UP-0.1*RIGHT,0.8*UP-0.1*LEFT)
+ 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,1])
+ arrow3.set_color(DARK_BLUE)
+ tip3 = Polygon([0,0,0.95],[0,0,0.8]-0.1*RIGHT,[0,0,0.8]-0.1*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()
diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file2_sum_of_projections_part1.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file2_sum_of_projections_part1.py new file mode 100755 index 0000000..141e99b --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file2_sum_of_projections_part1.py @@ -0,0 +1,133 @@ +from manimlib.imports import *
+class LinearTrans(LinearTransformationScene):
+ CONFIG = {
+ "show_basis_vectors": True,
+ "basis_vector_stroke_width": 1,
+ "leave_ghost_vectors": False,
+ "show_coordinates": True,
+ }
+
+ def construct(self):
+
+ self.setup()
+
+ matrix = [[0.6,-0.8],[0.8,0.6]]
+ self.apply_matrix(matrix)
+
+ self.wait(2)
+ orthonormal = TextMobject(r"These are 2 orthonormal vectors($v_1$ and $v_2$)")
+ orthonormal.scale(0.7)
+ orthonormal.move_to(DOWN+LEFT*3.5)
+ orthonormal.add_background_rectangle()
+ v1 = TextMobject(r"$v_1$")
+ v1.scale(0.75)
+ v1.set_color(X_COLOR)
+ v1.move_to(0.75*UP+RIGHT)
+ v1.add_background_rectangle()
+ v2 = TextMobject(r"$v_2$")
+ v2.scale(0.75)
+ v2.set_color(Y_COLOR)
+ v2.move_to(0.75*UP+LEFT*1.25)
+ v2.add_background_rectangle()
+ self.play(Write(orthonormal))
+ self.play(Write(v1),Write(v2))
+ self.wait()
+ self.play(FadeOut(orthonormal), FadeOut(v1), FadeOut(v2))
+
+ arrow = Arrow(start = ORIGIN,end = 3*RIGHT+UP)
+ arrow.scale(1.2)
+ arrow.set_color(BLUE)
+ arrow.apply_matrix(matrix)
+ text3 = TextMobject("v")
+ text3.move_to(3.2*UP+1.2*RIGHT)
+ text3.add_background_rectangle()
+ self.play(ShowCreation(arrow),Write(text3))
+ self.wait()
+ v_cor = TextMobject("(1 , 3)")
+ v_cor.move_to(3.2*UP+1.3*RIGHT)
+ v_cor.set_color(BLUE)
+ v_cor.scale(0.75)
+ v_cor.add_background_rectangle()
+ self.play(Transform(text3,v_cor))
+
+ line1 = DashedLine(start = 1*UP+3*RIGHT, end = 3*RIGHT)
+ line2 = DashedLine(start = 1*UP+3*RIGHT, end = UP)
+ line1.apply_matrix(matrix)
+ line2.apply_matrix(matrix)
+ self.play(ShowCreation(line1),ShowCreation(line2),run_time = 2)
+
+ v1 = Arrow(start = ORIGIN,end = 3*RIGHT+UP)
+ v1.scale(1.2)
+ v1.set_color(BLUE)
+ v1.apply_matrix(matrix)
+ arrow1 = Arrow(start = ORIGIN,end = 3*RIGHT)
+ arrow1.scale(1.2)
+ arrow1.set_color("#6B8E23")
+ arrow1.apply_matrix(matrix)
+ self.play(Transform(v1,arrow1))
+ v1_cor = TextMobject(r"$<v,v_1> v_1$")
+ v1_cor.move_to(2.5*UP+3*RIGHT)
+ v1_cor.scale(0.75)
+ v1_cor.add_background_rectangle()
+ self.play(Write(v1_cor))
+ self.wait(0.5)
+ text1 = TextMobject("(1.8 , 2.4)")
+ text1.move_to(2.1*UP+2.5*RIGHT)
+ text1.scale(0.75)
+ text1.set_color("#6B8E23")
+ text1.add_background_rectangle()
+ self.play(Transform(v1_cor,text1))
+
+ v2 = Arrow(start = ORIGIN,end = 3*RIGHT+UP)
+ v2.scale(1.2)
+ v2.set_color("#8b0000")
+ v2.apply_matrix(matrix)
+ arrow2 = Arrow(start = ORIGIN,end = UP)
+ arrow2.scale(2.1)
+ arrow2.set_color("#8b0000")
+ arrow2.apply_matrix(matrix)
+ self.wait(0.5)
+ self.play(Transform(v2,arrow2))
+ self.wait(0.5)
+ v2_cor = TextMobject(r"$<v,v_2> v_2$")
+ v2_cor.move_to(0.75*UP+2.5*LEFT)
+ v2_cor.scale(0.75)
+ v2_cor.add_background_rectangle()
+ self.play(Write(v2_cor))
+ self.wait(0.5)
+ text2 = TextMobject("(-0.8 , 0.6)")
+ text2.move_to(0.75*UP+1.75*LEFT)
+ text2.scale(0.75)
+ text2.set_color("#8b0000")
+ text2.add_background_rectangle()
+ self.play(Transform(v2_cor,text2))
+
+ self.wait()
+
+ self.play(ApplyMethod(v2.move_to,1.4*RIGHT+2.7*UP),FadeOut(v1_cor),FadeOut(v2_cor),FadeOut(v_cor))
+
+ self.wait()
+
+ ending = TextMobject(r"$v = <v,v_1> v_1 + <v,v_2> v_2$")
+ ending.scale(0.7)
+ ending.move_to(DOWN)
+ ending.add_background_rectangle()
+ self.play(Write(ending))
+ self.wait()
+ self.play(FadeOut(ending))
+
+ ending = TextMobject(r"$\left[ \begin{array} {c} 1\\ 3 \end{array}\right] = \left[ \begin{array} {c}1.8 \\ 2.4 \end{array}\right] + \left[ \begin{array} {c} -0.8\\ 0.6 \end{array}\right]$")
+ ending.scale(0.7)
+ ending.move_to(DOWN)
+ ending.add_background_rectangle()
+ self.play(Write(ending))
+ self.wait()
+ self.play(FadeOut(ending))
+
+ ending = TextMobject(r"$v$ is the sum of projections on the orthonormal vectors")
+ ending.scale(0.7)
+ ending.move_to(DOWN)
+ ending.add_background_rectangle()
+ self.play(Write(ending))
+ self.wait()
+ self.play(FadeOut(ending))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file3_sum_of_projections_part2.py b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file3_sum_of_projections_part2.py new file mode 100644 index 0000000..2899286 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file3_sum_of_projections_part2.py @@ -0,0 +1,181 @@ +from manimlib.imports import * +class ThreeDExplanation(ThreeDScene): + + def construct(self): + + basis = TextMobject(r"Set of Orthonormal Basis - $\left(\begin{array}{c}\frac{1}{\sqrt{2}}\\\frac{1}{\sqrt{2}}\\0\end{array}\right),\left(\begin{array}{c}\frac{-1}{\sqrt{2}}\\\frac{1}{\sqrt{2}}\\0\end{array}\right),\left(\begin{array}{c}0\\0\\1\end{array}\right)$") + basis.scale(0.75) + basis.move_to(UP*1.5) + self.play(Write(basis)) + v = TextMobject(r"$v_1$",r"$v_2$",r"$v_3$") + v[0].move_to(UP*0.5+RIGHT*0.75) + v[1].move_to(UP*0.5+RIGHT*2.5) + v[2].move_to(UP*0.5+RIGHT*4) + eq = TextMobject(r"$v = \left(\begin{array}{c}3\\4\\5\end{array}\right)$") + eq1 = TextMobject(r"$<v,v_1> = \frac{3}{\sqrt{2}} + \frac{4}{\sqrt{2}} + 0 = \frac{7}{\sqrt{2}}$") + eq2 = TextMobject(r"$<v,v_2> = \frac{-3}{\sqrt{2}} + \frac{4}{\sqrt{2}} + 0 =\frac{1}{\sqrt{2}}$") + eq3 = TextMobject(r"$<v,v_3> = 0 + 0 + 5 =5$") + eq.move_to(4*LEFT+DOWN) + eq1.move_to(0.5*DOWN+2*RIGHT) + eq2.move_to(1.5*DOWN+2*RIGHT) + eq3.move_to(2.5*DOWN+2*RIGHT) + self.play(Write(v)) + self.play(Write(eq)) + self.play(Write(eq1)) + self.play(Write(eq2)) + self.play(Write(eq3)) + self.wait() + self.play(FadeOut(basis), FadeOut(eq), FadeOut(v), FadeOut(eq1), FadeOut(eq2), FadeOut(eq3)) + self.wait() + + text = TextMobject("These are the 3 mutually orthonormal basis of the set(", r"$v_1$, ", r"$v_2$, ", r"$v_3$",")") + text[1].set_color(DARK_BLUE) + text[2].set_color(RED) + text[3].set_color(YELLOW) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text)) + self.wait() + + axes = ThreeDAxes(x_min = -6,x_max=6,y_min=-6,y_max=6,z_min=-6,z_max=6) + self.play(ShowCreation(axes)) + self.move_camera(distance = 100, phi=45*DEGREES,theta=45*DEGREES,run_time=5) + self.begin_ambient_camera_rotation(rate=0.1) + + xy_plane = Polygon(6*RIGHT+6*UP,-6*RIGHT+6*UP,-6*RIGHT-6*UP,6*RIGHT-6*UP) + xy_plane.set_color("#333333") + xy_plane.set_fill("#333333") + xy_plane.set_opacity(1) + xy_plane.fade(0.7) + self.play(ShowCreation(xy_plane)) + + dashedline1 = DashedLine(start = -6*(UP+RIGHT), end = 6*(UP+RIGHT)) + dashedline2 = DashedLine(start = -6*(UP+LEFT), end = 6*(UP+LEFT)) + dashedline3 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = 3.5*UP+3.5*RIGHT) + dashedline4 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = 0.5*UP+0.5*LEFT) + dashedline5 = DashedLine(start = 4*UP+3*RIGHT+[0,0,5], end = [0,0,5]) + + self.play(ShowCreation(dashedline1), ShowCreation(dashedline2)) + + line1 = Line(start = ORIGIN,end = 0.707*RIGHT + 0.707*UP) + line1.set_color(DARK_BLUE) + tip1 = Polygon(0.707*RIGHT + 0.707*UP, 0.707*RIGHT + 0.607*UP, 0.607*RIGHT + 0.707*UP) + tip1.set_opacity(1) + tip1.set_fill(DARK_BLUE) + tip1.set_color(DARK_BLUE) + self.play(ShowCreation(line1), ShowCreation(tip1)) + + line2 = Line(start = ORIGIN,end = 0.707*LEFT + 0.707*UP) + line2.set_color(RED) + tip2 = Polygon(0.707*LEFT + 0.707*UP, 0.707*LEFT + 0.607*UP, 0.607*LEFT + 0.707*UP) + tip2.set_opacity(1) + tip2.set_fill(RED) + tip2.set_color(RED) + + self.play(ShowCreation(line2), ShowCreation(tip2)) + + line3 = Line(start = ORIGIN,end = [0,0,1]) + line3.set_color(YELLOW) + tip3 = Polygon([0,0,1],[0,0,0.8]-0.2*RIGHT,[0,0,0.8]-0.2*LEFT) + tip3.set_opacity(1) + tip3.set_fill(YELLOW) + tip3.set_color(YELLOW) + self.play(ShowCreation(line3), ShowCreation(tip3)) + self.wait() + + self.play(FadeOut(text)) + + text = TextMobject("Take the projection of ", r"$v$", " on the mutually orthonormal vectors") + text[1].set_color(GOLD_E) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text)) + self.wait(2) + + a_line = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + a_line.set_color(GOLD_E) + a_tip = Polygon(3.92*UP+2.94*RIGHT+[0,0,4.9],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + a_tip.set_opacity(1) + a_tip.set_fill(GOLD_E) + a_tip.set_color(GOLD_E) + + self.play(ShowCreation(a_line), ShowCreation(a_tip)) + self.stop_ambient_camera_rotation() + self.move_camera(distance = 100, phi=45*DEGREES,theta=135*DEGREES,run_time=5) + + self.play(ShowCreation(dashedline3),ShowCreation(dashedline4),ShowCreation(dashedline5)) + self.wait() + + pv1 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv1.set_color(GOLD_E) + pv1tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv1tip.set_opacity(1) + pv1tip.set_fill(GOLD_E) + pv1tip.set_color(GOLD_E) + + v1_p = Line(start = ORIGIN,end = 3.5*RIGHT + 3.5*UP) + v1_p.set_color(BLUE_E) + v1_p_tip = Polygon(3.5*RIGHT + 3.5*UP, 3.5*RIGHT + 3.4*UP, 3.4*RIGHT + 3.5*UP) + v1_p_tip.set_opacity(1) + v1_p_tip.set_fill(BLUE_E) + v1_p_tip.set_color(BLUE_E) + + pv2 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv2.set_color(GOLD_E) + pv2tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv2tip.set_opacity(1) + pv2tip.set_fill(GOLD_E) + pv2tip.set_color(GOLD_E) + + v2_p = Line(start = ORIGIN,end = 0.5*LEFT + 0.5*UP) + v2_p.set_color(RED_E) + v2_p_tip = Polygon(0.5*LEFT + 0.5*UP, 0.5*LEFT + 0.4*UP, 0.4*LEFT + 0.5*UP) + v2_p_tip.set_opacity(1) + v2_p_tip.set_fill(RED_E) + v2_p_tip.set_color(RED_E) + + pv3 = Line(start = ORIGIN,end = 4*UP+3*RIGHT+[0,0,5]) + pv3.set_color(GOLD_E) + pv3tip = Polygon(4*UP+3*RIGHT+[0,0,5],3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*UP+0.1*LEFT,3.6*UP+2.7*RIGHT+[0,0,4.5]+0.1*DOWN+0.1*RIGHT) + pv3tip.set_opacity(1) + pv3tip.set_fill(GOLD_E) + pv3tip.set_color(GOLD_E) + + v3_p = Line(start = ORIGIN,end = [0,0,5]) + v3_p.set_color(YELLOW_E) + v3_p_tip = Polygon([0,0,5.15],[0,0,4.8]+0.2*RIGHT,[0,0,4.8]+0.2*LEFT) + v3_p_tip.set_opacity(1) + v3_p_tip.set_fill(YELLOW_E) + v3_p_tip.set_color(YELLOW_E) + + #self.stop_ambient_camera_rotation() + self.play(Transform(pv1,v1_p), + Transform(pv1tip,v1_p_tip), + Transform(pv2,v2_p), + Transform(pv2tip,v2_p_tip), + Transform(pv3,v3_p), + Transform(pv3tip,v3_p_tip)) + self.play(FadeOut(dashedline1), + FadeOut(dashedline2), + FadeOut(dashedline3), + FadeOut(dashedline4), + FadeOut(dashedline5), + FadeOut(line1), + FadeOut(tip1), + FadeOut(line2), + FadeOut(tip2), + FadeOut(line3), + FadeOut(tip3), + FadeOut(text)) + + text = TextMobject(r"$v$ is the sum of projections on the orthonormal vectors") + text.set_color(GOLD_E) + text.scale(0.75) + self.add_fixed_in_frame_mobjects(text) + text.move_to(3*DOWN) + self.play(Write(text), ApplyMethod(pv2.move_to,(3.5*RIGHT + 3.5*UP+3*RIGHT+4*UP)/2), ApplyMethod(pv2tip.move_to,(3.1*RIGHT + 3.9*UP))) + self.play(ApplyMethod(pv3.move_to,3*RIGHT + 4*UP + [0,0,2.5]), ApplyMethod(pv3tip.move_to,(3*RIGHT + 4*UP + [0,0,4.8]))) + + self.wait(3)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file4.gif b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file4.gif Binary files differnew file mode 100644 index 0000000..4891350 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file4.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file5.gif b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file5.gif Binary files differnew file mode 100644 index 0000000..d7eb0bc --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file5.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file6.gif b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file6.gif Binary files differnew file mode 100644 index 0000000..1df6413 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/Orthonormal-Basis/file6.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/README.md b/FSF-2020/linear-algebra/linear-transformations/README.md index 692201e..067755e 100644 --- a/FSF-2020/linear-algebra/linear-transformations/README.md +++ b/FSF-2020/linear-algebra/linear-transformations/README.md @@ -1,9 +1,10 @@ # Contributer: Archit Sangal
-My Github Account : <a href="https://github.com/architsangal">architsangal</a>
+My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal). These code were written during the course of FOSSEE Summer Fellowship 2020 under the FLOSS: Mathematics using Python.
<br/></br>
+
## Sub-Topics Covered:
-+ Vector Space Homomorphisms (Linear Maps)
++ Linear Transformations (Linear Maps)
+ The Four Fundamental Subspaces
+ Rank-Nullity Theorem
+ Orthonormal basis
-+ Gramm-Schmidt Orthogonalization Process
++ Gramm-Schmidt Orthogonalization Process
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/README.md b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/README.md new file mode 100644 index 0000000..6c90bf4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/README.md @@ -0,0 +1,30 @@ +# Contributer: Archit Sangal +My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal) +<br/></br> + +## Sub-Topics Covered: ++ The Four Fundamental Subspaces + +#### Video 1: Writing System of linear equations in form of Ax=b +![GIF1](file11.gif) + +#### Video 2: Column Space is same as the image of Linear Transformation +![GIF2](file14.gif) + +#### Video 3: Existance of Solution w.r.t. vector b +![GIF3](file17.gif) + +#### Video 4: Null Space (Visually) +![GIF4](file12.gif) + +#### Video 5: Definition 1 is equivalent to Definition 2 +![GIF5](file13.gif) + +#### Video 6: Relation between Row Space and Null Space +![GIF6](file16.gif) + +#### Fig. 1 Naming of the left null space +![GIF7](file10_Left_Null_Space_pSv8iio_d5Sy9qS.gif) + +#### Video 7: Left Null Space(Visually) +![GIF8](file15.gif)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_Left_Null_Space_pSv8iio_d5Sy9qS.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_Left_Null_Space_pSv8iio_d5Sy9qS.gif Binary files differnew file mode 100644 index 0000000..3f50635 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file10_Left_Null_Space_pSv8iio_d5Sy9qS.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file11.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file11.gif Binary files differnew file mode 100644 index 0000000..8f74202 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file11.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file12.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file12.gif Binary files differnew file mode 100644 index 0000000..aa7403b --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file12.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file13.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file13.gif Binary files differnew file mode 100644 index 0000000..34b54c7 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file13.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file14.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file14.gif Binary files differnew file mode 100644 index 0000000..b77791b --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file14.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file15.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file15.gif Binary files differnew file mode 100644 index 0000000..8bb24bf --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file15.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file16.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file16.gif Binary files differnew file mode 100644 index 0000000..87e0026 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file16.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file17.gif b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file17.gif Binary files differnew file mode 100644 index 0000000..eec819a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file17.gif diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file18_NOT_in_lecture_note_Column_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file18_NOT_in_lecture_note_Column_Space.py new file mode 100644 index 0000000..afe4f9a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file18_NOT_in_lecture_note_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/file1_Axb.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Axb.py new file mode 100755 index 0000000..95d1021 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file1_Axb.py @@ -0,0 +1,77 @@ +from manimlib.imports import *
+
+class Axb(Scene):
+
+ def construct(self):
+
+ text0 = TextMobject("Linear System Of Equations")
+ text1 = TextMobject(r"$x_{1}+x_{2}+x_{3} =b_{1}$")
+ text2 = TextMobject(r"$x_{1}+2x_{2}+x_{3} =b_{2}$")
+ text3 = TextMobject(r"$x_{1}+x_{2}+3x_{3} =b_{3}$")
+ text0.move_to(UP*2+LEFT*2)
+ text0.set_color(DARK_BLUE)
+ text1.move_to(UP)
+ text2.move_to(ORIGIN)
+ text3.move_to(DOWN)
+
+ text0.scale(0.75)
+ text1.scale(0.75)
+ text2.scale(0.75)
+ text3.scale(0.75)
+ self.play(Write(text0))
+ self.play(Write(text1))
+ self.play(Write(text2))
+ self.play(Write(text3))
+ self.play(ApplyMethod(text0.move_to,3*UP+LEFT*2), ApplyMethod(text1.move_to,2.5*UP), ApplyMethod(text2.move_to,2*UP), ApplyMethod(text3.move_to,1.5*UP))
+
+ A = TextMobject(r"$\left( \begin{array}{c c c} 1 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 3 \end{array}\right) \left[ \begin{array} {c} x_{1} \\ x_{2} \\ x_{3} \end{array}\right] =$", r"$\left[ \begin{array}{c} x_{1}+x_{2}+x_{3} \\ x_{1}+2x_{2}+x_{3} \\ x_{1}+x_{2}+3x_{3} \end{array}\right]$")
+ A.scale(0.75)
+ self.play(FadeIn(A))
+
+ textA = TextMobject("A")
+ textx = TextMobject("x")
+ textb = TextMobject("Ax")
+
+ textA.move_to(DOWN+3*LEFT)
+ textx.move_to(1.1*DOWN+0.5*LEFT)
+ textb.move_to(DOWN-2*LEFT)
+
+ self.play(Write(textA), Write(textx), Write(textb))
+
+ circle1 = Circle(radius = 0.24)
+ circle2 = Circle(radius = 0.24)
+ square = Square(side_length = 0.6)
+
+ circle1.move_to(UP*0.5+LEFT*3.05)
+ circle2.move_to(UP*0.4+LEFT*0.5)
+ square.move_to(UP*0.4+RIGHT*1.3)
+
+ self.play(FadeIn(circle1), FadeIn(circle2),FadeIn(square))
+
+ self.play(ApplyMethod(circle1.move_to,UP*0.5+LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,UP*0.4+RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,UP*0.5+LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,UP*0.4+RIGHT*3.1))
+
+ self.play(ApplyMethod(circle1.move_to,LEFT*3.05), ApplyMethod(circle2.move_to,UP*0.4+LEFT*0.5), ApplyMethod(square.move_to,RIGHT*1.3))
+ self.play(ApplyMethod(circle1.move_to,LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,RIGHT*3.1))
+
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*3.05), ApplyMethod(circle2.move_to,UP*0.4+LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*1.3))
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*2.45), ApplyMethod(circle2.move_to,LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*2.2))
+ self.play(ApplyMethod(circle1.move_to,0.4*DOWN+LEFT*1.85), ApplyMethod(circle2.move_to,DOWN*0.5+LEFT*0.5), ApplyMethod(square.move_to,0.4*DOWN+RIGHT*3.1))
+
+ self.play(FadeOut(circle1), FadeOut(circle2), FadeOut(square))
+ self.play(FadeOut(A[0]), ApplyMethod(A[1].move_to,2*LEFT),ApplyMethod(textb.move_to,DOWN+1.7*LEFT), FadeOut(textx), FadeOut(textA))
+ b = TextMobject(r"$=\left[ \begin{array}{c} b_{1} \\ b_{2} \\ b_{3} \end{array}\right]$")
+ b.move_to(RIGHT)
+ textB = TextMobject("b")
+ textB.move_to(1.2*DOWN+1.1*RIGHT)
+ self.play(FadeIn(b),FadeIn(textB))
+
+ self.wait()
+
+ self.play(FadeOut(text0), FadeOut(text1), FadeOut(text2), FadeOut(text3))
+
+ axb = TextMobject("Ax = b")
+ self.play(FadeIn(axb), FadeOut(textb), FadeOut(textB), FadeOut(b), FadeOut(A[1]))
+
+ self.wait()
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py new file mode 100644 index 0000000..70547cb --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file2_CSasImage.py @@ -0,0 +1,169 @@ +from manimlib.imports import * + +class Column_Space(Scene): + def construct(self): + + A = TextMobject(r"$A = $",r"$\left( \begin{array}{c c} 1 & 2 \\ 3 & 4 \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 \\ 3 \end{array} \right)$",r"$+x_{2}$",r"$ \left( \begin{array}{c} 2 \\ 4\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.scale(0.75) + + self.play(Write(CS_A),run_time = 2) + + arrow1 = Arrow(start = 1.25*UP,end = (0.25*DOWN+1.75*LEFT+0.25*DOWN+1.2*RIGHT)/2) + arrow3 = Arrow(start = 1.25*UP+0.75*RIGHT,end = (0.25*DOWN+2.9*RIGHT+0.25*DOWN)/2) + + arrow1.scale(1.5) + arrow3.scale(1.5) + + Defn = TextMobject("Linear Combination of Columns of Matrix") + Defn.move_to(3*DOWN) + + self.play(Write(Defn), ShowCreation(arrow1), ShowCreation(arrow3),run_time = 1) + self.wait(1) + +class solution(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"Consider the vector space $R^2$") + o.move_to(2*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + A = TextMobject(r"Let $A$ be ",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r". $A$ denotes the matrix the of this linear transformation.") + A.move_to(2*DOWN) + A.scale(0.75) + A.add_background_rectangle() + self.play(Write(A)) + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + self.play(FadeOut(A)) + + o = TextMobject(r"This is the transformed vector space") + o.move_to(2*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + texti = TextMobject(r"$\left[\begin{array}{c}1\\1\end{array}\right]$") + textj = TextMobject(r"$\left[\begin{array}{c}-1\\-1\end{array}\right]$") + texti.set_color(GREEN) + textj.set_color(RED) + texti.scale(0.7) + textj.scale(0.7) + texti.move_to(1.35*RIGHT+0.5*UP) + textj.move_to(-(1.5*RIGHT+0.5*UP)) + + text1 = TextMobject("[") + text2 = TextMobject(r"$\begin{array}{c} 1 \\ 1 \end{array}$") + text3 = TextMobject(r"$\begin{array}{c} -1 \\ -1 \end{array}$") + text4 = TextMobject("]") + + text2.set_color(GREEN) + text3.set_color(RED) + + text1.scale(2) + text4.scale(2) + text2.scale(0.7) + text3.scale(0.7) + + text1.move_to(2.5*UP+6*LEFT) + text2.move_to(2.5*UP+5.75*LEFT) + text3.move_to(2.5*UP+5.25*LEFT) + text4.move_to(2.5*UP+5*LEFT) + + self.play(Write(texti), Write(textj)) + self.wait() + self.play(FadeIn(text1), Transform(texti,text2), Transform(textj,text3), FadeIn(text4)) + self.wait() + + o = TextMobject(r"Now, you can observe the Image of Linear Transformation") + o1 = TextMobject(r"and Column Space(i.e. span of columns of matrix $A$) are same") + o.move_to(2.5*DOWN) + o1.move_to(3*DOWN) + o.scale(0.75) + o1.scale(0.75) + o.add_background_rectangle() + o1.add_background_rectangle() + self.play(Write(o)) + self.play(Write(o1)) + self.wait() + self.play(FadeOut(o),FadeOut(o1)) + +class solution2nd(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + arrow1 = Arrow(start = ORIGIN,end = 2*DOWN+RIGHT) + arrow2 = Arrow(start = ORIGIN,end = UP+LEFT) + arrow3 = Arrow(start = ORIGIN,end = 3*UP+4*RIGHT) + arrow1.set_color(YELLOW) + arrow2.set_color(ORANGE) + arrow3.set_color(PURPLE) + arrow1.scale(1.3) + arrow2.scale(1.5) + arrow3.scale(1.1) + + self.play(ShowCreation(arrow1), ShowCreation(arrow2), ShowCreation(arrow3)) + + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + o = TextMobject(r"Consider any vector in the original vector space $R^2$") + o.move_to(2.5*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + A = TextMobject(r"Let the matrix the of this linear transformation be $A$ =",r"$\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$",r" again.") + A.move_to(2*DOWN) + A.scale(0.75) + A.add_background_rectangle() + self.play(Write(A)) + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + self.play(FadeOut(A)) + + o = TextMobject(r"This is the transformed vector space") + o.move_to(2*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o = TextMobject(r"Each and every vector of original vector space $R^2$ will transform") + o1 = TextMobject(r"to this new vector space which is spanned by $\mathbf{CS}(A)$") + o.move_to(2.5*DOWN) + o1.move_to(3*DOWN) + o.scale(0.75) + o1.scale(0.75) + o.add_background_rectangle() + o1.add_background_rectangle() + self.play(Write(o)) + self.play(Write(o1)) + self.wait() + self.play(FadeOut(o)) + self.play(FadeOut(o1))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py new file mode 100644 index 0000000..eb310f3 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file3_solution.py @@ -0,0 +1,77 @@ +from manimlib.imports import * +class solution(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$ (before Linear Transformation)") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + A = TextMobject(r"Consider the matrix the of this linear transformation $A$ = $\left[\begin{array}{c c} 1 & -1 \\ 1 & -1 \end{array}\right]$") + A.move_to(3*DOWN) + A.scale(0.75) + A.add_background_rectangle() + self.play(Write(A)) + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + self.play(FadeOut(A)) + + o = TextMobject(r"This is the transformed vector space") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + arrow2 = Arrow(start = ORIGIN, end = 2*DOWN+2*LEFT) + arrow2.set_color(PURPLE) + arrow2.scale(1.2) + self.play(ShowCreation(arrow2)) + self.wait() + + o1 = TextMobject("If the ","vector b"," lies in the transformed vector space") + o2 = TextMobject("(the line) then the solution exist") + o1.move_to(2.5*DOWN+2*RIGHT) + o1[1].set_color(PURPLE) + o2.move_to(3*DOWN+2.5*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow2)) + + arrow1 = Arrow(start = ORIGIN, end = 2*UP+RIGHT) + arrow1.set_color(ORANGE) + arrow1.scale(1.3) + self.play(ShowCreation(arrow1)) + self.wait() + + o1 = TextMobject("If the ","vector b"," does lies in the transformed") + o2 = TextMobject("vector space then the does not solution exist") + o1.move_to(2.5*DOWN+2*RIGHT) + o1[1].set_color(ORANGE) + o2.move_to(3*DOWN+2.5*RIGHT) + o1.scale(0.75) + o2.scale(0.75) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + self.play(FadeOut(o1), FadeOut(o2)) + + self.play(FadeOut(arrow1)) +
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py new file mode 100644 index 0000000..3c52677 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file4_null_space.py @@ -0,0 +1,91 @@ +from manimlib.imports import * +class null_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a particular vector $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + o1 = TextMobject("Notice, entire set of vectors which belongs to the vector") + o2 = TextMobject(r"subspace(Linear Span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$) transforms to zero") + o1.move_to(2*DOWN+2.5*RIGHT) + o2.move_to(2.75*DOWN+2.5*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait() + + self.play(FadeOut(o1), FadeOut(o2)) + + o = TextMobject(r"Hence, the vector space formed by linear span of $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$ is the null space of $A$") + o.move_to(3*DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait(2) + self.play(FadeOut(o), FadeOut(arrow), FadeOut(arrow1), FadeOut(arrow2), FadeOut(arrow3), FadeOut(arrow4), FadeOut(arrow5), FadeOut(arrow6), FadeOut(arrow7)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py new file mode 100644 index 0000000..5259eb4 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file5_Row_Space_part_1.py @@ -0,0 +1,68 @@ +from manimlib.imports import * +class LS(Scene): + def construct(self): + text1 = TextMobject(r"Consider a matrix $A =$") + text2 = TextMobject(r"[") + text3 = TextMobject(r"$\begin{array}{c c} 1 & -2\end{array}$") + text4 = TextMobject(r"$\begin{array}{c c} 1 & -1\end{array}$") + text5 = TextMobject(r"]") + + text2.scale(2) + text5.scale(2) + + text1.set_color(DARK_BLUE) + text2.set_color(DARK_BLUE) + text3.set_color(PURPLE) + text4.set_color(YELLOW) + text5.set_color(DARK_BLUE) + + text1.move_to(3.5*LEFT+3*UP+2*RIGHT) + text2.move_to(0.75*LEFT+3*UP+2*RIGHT) + text3.move_to(3.25*UP+2*RIGHT) + text4.move_to(2.75*UP+2*RIGHT) + text5.move_to(0.75*RIGHT+3*UP+2*RIGHT) + + self.play(FadeIn(text1), FadeIn(text2), FadeIn(text3), FadeIn(text4), FadeIn(text5)) + self.wait() + + ttext1 = TextMobject(r"$A^T =$") + ttext2 = TextMobject(r"[") + ttext3 = TextMobject(r"$\begin{array}{c} 1 \\ -2\end{array}$") + ttext4 = TextMobject(r"$\begin{array}{c} 1 \\ -1\end{array}$") + ttext5 = TextMobject(r"]") + + ttext2.scale(2) + ttext5.scale(2) + + ttext1.set_color(DARK_BLUE) + ttext2.set_color(DARK_BLUE) + ttext3.set_color(PURPLE) + ttext4.set_color(YELLOW) + ttext5.set_color(DARK_BLUE) + + ttext1.move_to(2*LEFT+1.5*UP+2*RIGHT) + ttext2.move_to(1*LEFT+1.5*UP+2*RIGHT) + ttext3.move_to(0.5*LEFT+1.5*UP+2*RIGHT) + ttext4.move_to(0.5*RIGHT+1.5*UP+2*RIGHT) + ttext5.move_to(1*RIGHT+1.5*UP+2*RIGHT) + + self.play(FadeIn(ttext1), FadeIn(ttext2), FadeIn(ttext3), FadeIn(ttext4), FadeIn(ttext5)) + + rtext = TextMobject(r"Row Space of $A$ = Column Space of $A^T = a_1$",r"$\left[\begin{array}{c} 1 \\ -2\end{array}\right]$",r"$+a_2$",r"$\left[\begin{array}{c} 1 \\ -1\end{array}\right]$") + rtext[1].set_color(PURPLE) + rtext[3].set_color(YELLOW) + rtext.move_to(2*DOWN+1.5*LEFT) + rtext.scale(0.75) + + self.play(Write(rtext)) + self.wait() + + arrow1 = Arrow(start = 1.5*RIGHT+UP, end = 1.25*(DOWN+RIGHT)) + arrow2 = Arrow(start = 2.5*RIGHT+UP, end = 1.25*DOWN+3.25*RIGHT) + arrow1.scale(1.25) + arrow2.scale(1.25) + arrow1.set_color(PURPLE) + arrow2.set_color(YELLOW) + + self.play(ShowCreation(arrow1), ShowCreation(arrow2)) + self.wait(2) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.py new file mode 100644 index 0000000..b16a32a --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file6_Row_Space_part_2.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-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py new file mode 100644 index 0000000..c81d370 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file7_Row_space_Orthogonal_Complements.py @@ -0,0 +1,150 @@ +from manimlib.imports import * +class row_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow.set_color(YELLOW) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow1.set_color(YELLOW) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow2.set_color(YELLOW) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow3.set_color(YELLOW) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow4.set_color(YELLOW) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow5.set_color(YELLOW) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow6.set_color(YELLOW) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + arrow7.set_color(YELLOW) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(PURPLE) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(PURPLE) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(PURPLE) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(PURPLE) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(PURPLE) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(PURPLE) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(PURPLE) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(PURPLE) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + self.add_transformable_mobject(rarrow) + self.add_transformable_mobject(rarrow1) + self.add_transformable_mobject(rarrow2) + self.add_transformable_mobject(rarrow3) + self.add_transformable_mobject(rarrow4) + self.add_transformable_mobject(rarrow5) + self.add_transformable_mobject(rarrow6) + self.add_transformable_mobject(rarrow7) + + o1 = TextMobject("Notice, entire set of vectors which belong to the null space of $A$ transforms to zero") + o2 = TextMobject(r"and entire set of vectors which belong to the row space of $A$ transforms to column space of $A$.") + o1.move_to(2.5*DOWN) + o2.move_to(3.5*DOWN) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + self.wait() + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait(3) + + self.play(FadeOut(o1), FadeOut(o2))
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py new file mode 100755 index 0000000..fd05e75 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file8_Left_Null_Space.py @@ -0,0 +1,26 @@ +from manimlib.imports import * + +class Left_Null_Space(Scene): + def construct(self): + + A = TextMobject(r"Left Null Space of A") + A.move_to(3*UP) + defn = TextMobject(r"It is a vector space that consists of all the solution $x$ to the equation $A^{T}x=0$") + defn.move_to(2*UP) + defn.scale(0.75) + eqn1 = TextMobject(r"$A^{T}x=0 \cdots (i)$") + eqn1.move_to(UP) + self.play(Write(A), Write(defn), Write(eqn1),run_time=1) + statement = TextMobject(r"Taking transpose of eqn $(i)$") + eqn = TextMobject(r"$(A^{T}x)^{T}=0$") + eqn.move_to(DOWN) + eqn2 = TextMobject(r"$x^{T}(A^{T})^{T}=0$") + eqn2.move_to(DOWN) + eqn3 = TextMobject(r"$x^{T}A=0$") + eqn3.move_to(DOWN) + self.play(Write(statement),Write(eqn),run_time=1) + self.wait(0.5) + self.play(Transform(eqn,eqn2),run_time=1) + self.wait(0.5) + self.play(Transform(eqn,eqn3),run_time=1) + self.wait(0.5)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py new file mode 100644 index 0000000..61285be --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Four-Fundamental-Subspaces/file9_left_null_space.py @@ -0,0 +1,186 @@ +from manimlib.imports import * +class row_space(LinearTransformationScene): + def construct(self): + + self.setup() + self.wait() + + o = TextMobject(r"This is the original vector space $R^2$(before Linear Transformation)") + o.move_to(DOWN) + o.scale(0.75) + o.add_background_rectangle() + self.play(Write(o)) + self.wait() + self.play(FadeOut(o)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a $\left(\begin{array}{c} 1 \\ 1 \end{array}\right)$i.e. the null space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + arrow = Arrow(start = ORIGIN, end = UP+RIGHT) + arrow.set_color(YELLOW) + arrow1 = Arrow(start = ORIGIN, end = 2*(UP+RIGHT)) + arrow1.set_color(YELLOW) + arrow2 = Arrow(start = ORIGIN, end = 3*(UP+RIGHT)) + arrow2.set_color(YELLOW) + arrow3 = Arrow(start = ORIGIN, end = 4*(UP+RIGHT)) + arrow3.set_color(YELLOW) + arrow4 = Arrow(start = ORIGIN, end = DOWN+LEFT) + arrow4.set_color(YELLOW) + arrow5 = Arrow(start = ORIGIN, end = 2*(DOWN+LEFT)) + arrow5.set_color(YELLOW) + arrow6 = Arrow(start = ORIGIN, end = 3*(DOWN+LEFT)) + arrow6.set_color(YELLOW) + arrow7 = Arrow(start = ORIGIN, end = 4*(DOWN+LEFT)) + arrow7.set_color(YELLOW) + + arrow.scale(1.5) + arrow1.scale(1.2) + arrow2.scale(1.15) + arrow3.scale(1.1) + arrow4.scale(1.5) + arrow5.scale(1.2) + arrow6.scale(1.15) + arrow7.scale(1.1) + + self.play(ShowCreation(arrow), + ShowCreation(arrow1), + ShowCreation(arrow2), + ShowCreation(arrow3), + ShowCreation(arrow4), + ShowCreation(arrow5), + ShowCreation(arrow6), + ShowCreation(arrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + o1 = TextMobject("Consider a set of vectors which are linear") + o2 = TextMobject(r"span of a vector $\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$i.e. the row space.") + o1.move_to(2*DOWN+3*RIGHT) + o2.move_to(2.75*DOWN+3*RIGHT) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(PURPLE) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(PURPLE) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(PURPLE) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(PURPLE) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(PURPLE) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(PURPLE) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(PURPLE) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(PURPLE) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) + + self.add_transformable_mobject(arrow) + self.add_transformable_mobject(arrow1) + self.add_transformable_mobject(arrow2) + self.add_transformable_mobject(arrow3) + self.add_transformable_mobject(arrow4) + self.add_transformable_mobject(arrow5) + self.add_transformable_mobject(arrow6) + self.add_transformable_mobject(arrow7) + + self.add_transformable_mobject(rarrow) + self.add_transformable_mobject(rarrow1) + self.add_transformable_mobject(rarrow2) + self.add_transformable_mobject(rarrow3) + self.add_transformable_mobject(rarrow4) + self.add_transformable_mobject(rarrow5) + self.add_transformable_mobject(rarrow6) + self.add_transformable_mobject(rarrow7) + + matrix = [[1,-1],[1,-1]] + self.apply_matrix(matrix) + self.wait(3) + + o1 = TextMobject("Consider a set of vectors which are linear span of a vector") + o2 = TextMobject(r"$\left(\begin{array}{c} 1 \\ -1 \end{array}\right)$ which is orthogonal to column space i.e. Left Null Space") + o1.move_to(2*DOWN) + o2.move_to(2.75*DOWN) + o1.scale(0.7) + o2.scale(0.7) + o1.add_background_rectangle() + o2.add_background_rectangle() + self.play(Write(o1)) + self.play(Write(o2)) + + rarrow = Arrow(start = ORIGIN, end = -UP+RIGHT) + rarrow.set_color(YELLOW) + rarrow1 = Arrow(start = ORIGIN, end = 2*(-UP+RIGHT)) + rarrow1.set_color(YELLOW) + rarrow2 = Arrow(start = ORIGIN, end = 3*(-UP+RIGHT)) + rarrow2.set_color(YELLOW) + rarrow3 = Arrow(start = ORIGIN, end = 4*(-UP+RIGHT)) + rarrow3.set_color(YELLOW) + rarrow4 = Arrow(start = ORIGIN, end = -DOWN+LEFT) + rarrow4.set_color(YELLOW) + rarrow5 = Arrow(start = ORIGIN, end = 2*(-DOWN+LEFT)) + rarrow5.set_color(YELLOW) + rarrow6 = Arrow(start = ORIGIN, end = 3*(-DOWN+LEFT)) + rarrow6.set_color(YELLOW) + rarrow7 = Arrow(start = ORIGIN, end = 4*(-DOWN+LEFT)) + rarrow7.set_color(YELLOW) + + rarrow.scale(1.5) + rarrow1.scale(1.2) + rarrow2.scale(1.15) + rarrow3.scale(1.1) + rarrow4.scale(1.5) + rarrow5.scale(1.2) + rarrow6.scale(1.15) + rarrow7.scale(1.1) + + self.play(ShowCreation(rarrow), + ShowCreation(rarrow1), + ShowCreation(rarrow2), + ShowCreation(rarrow3), + ShowCreation(rarrow4), + ShowCreation(rarrow5), + ShowCreation(rarrow6), + ShowCreation(rarrow7), + ) + + self.wait(2) + self.play(FadeOut(o1), FadeOut(o2)) diff --git a/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/README.md b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/README.md new file mode 100644 index 0000000..9d49b4f --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/README.md @@ -0,0 +1,9 @@ +# Contributer: Archit Sangal +My Github Account : <a href="https://github.com/architsangal">architsangal</a> (https://github.com/architsangal) +<br/></br> + +## Sub-Topics Covered: ++ The Rank-Nullity Theorem + +#### Video 1: Visually understanding linear transformation(using grid) +![GIF1](file2.gif)
\ No newline at end of file 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/linear-transformations/The-Rank-Nullity-Theorem/file2.gif b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file2.gif Binary files differnew file mode 100644 index 0000000..46efc66 --- /dev/null +++ b/FSF-2020/linear-algebra/linear-transformations/The-Rank-Nullity-Theorem/file2.gif 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/Dual-Spaces/Basis_of_a_dual_vector_space.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py new file mode 100644 index 0000000..630670e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Basis_of_a_dual_vector_space.py @@ -0,0 +1,126 @@ +from manimlib.imports import *
+class DualVectorSpace(ZoomedScene):
+
+ def construct(self):
+ c1 = Ellipse(radius = 2,color=BLUE)
+ c2 = Ellipse(radius = 2,color=YELLOW)
+ c1.rotate(np.pi/2)
+ c2.rotate(np.pi/2)
+ c1.shift(2*LEFT+0.6*UP)
+ c2.shift(2*RIGHT+0.6*UP)
+ c1.scale(2)
+ c2.scale(2)
+ self.play(ShowCreation(c1))
+ self.play(ShowCreation(c2))
+ dot1 = SmallDot(color=BLUE).shift(2*LEFT+2*UP)
+ dot2 = SmallDot(color=BLUE).shift(2*LEFT+1.5*UP)
+ dot3 = SmallDot(color=BLUE).shift(2*LEFT+1*UP)
+ dot4 = SmallDot(color=BLUE).shift(2*LEFT+0.5*UP)
+ dot5 = SmallDot(color=BLUE).shift(2*LEFT)
+ dot6 = SmallDot(color=BLUE).shift(2*LEFT+0.5*DOWN)
+ dot7 = SmallDot(color=BLUE).shift(2*LEFT+1*DOWN)
+ text1 = TextMobject(r"$V$").scale(0.6).shift(3*UP+2*LEFT)
+ text2 = TextMobject(r"$V^* = \{T:V\rightarrow F\}$").scale(0.6).shift(3*UP+2.5*RIGHT)
+ self.play(ShowCreation(dot1),ShowCreation(dot2),ShowCreation(dot3),ShowCreation(dot4),ShowCreation(dot5),ShowCreation(dot6),ShowCreation(dot7))
+ v1 = TextMobject(r"$v_1$").scale(0.5).shift(2.2*LEFT+2*UP)
+ v2 = TextMobject(r"$v_2$").scale(0.5).shift(2.2*LEFT+1.5*UP)
+ v3 = TextMobject(r"$v_3$").scale(0.5).shift(2.2*LEFT+1*UP)
+ v4 = TextMobject(r"$v_4$").scale(0.5).shift(2.2*LEFT+0.5*UP)
+ v5 = TextMobject(r"$v_5$").scale(0.5).shift(2.2*LEFT)
+ v6 = TextMobject(r"$v_6$").scale(0.5).shift(2.2*LEFT+0.5*DOWN)
+ v7 = TextMobject(r"$v_7$").scale(0.5).shift(2.2*LEFT+1*DOWN)
+ self.play(ShowCreation(v1),ShowCreation(v2),ShowCreation(v3),ShowCreation(v4),ShowCreation(v5),ShowCreation(v6),ShowCreation(v7))
+ self.play(ShowCreation(text1))
+ dot9 = SmallDot(color=YELLOW).shift(2*RIGHT+2*UP)
+ dot10 = SmallDot(color=YELLOW).shift(2*RIGHT+1.5*UP)
+ dot11 = SmallDot(color=YELLOW).shift(2*RIGHT+1*UP)
+ dot12 = SmallDot(color=YELLOW).shift(2*RIGHT+0.5*UP)
+ dot13 = SmallDot(color=YELLOW).shift(2*RIGHT)
+ dot14 = SmallDot(color=YELLOW).shift(2*RIGHT+0.5*DOWN)
+ dot15 = SmallDot(color=YELLOW).shift(2*RIGHT+1*DOWN)
+ self.play(ShowCreation(dot9),ShowCreation(dot10),ShowCreation(dot11),ShowCreation(dot12),ShowCreation(dot13),ShowCreation(dot14),ShowCreation(dot15))
+ v9 = TextMobject(r"${T_1}$").scale(0.5).shift(2.2*RIGHT+2*UP)
+ v10 = TextMobject(r"${T_2}$").scale(0.5).shift(2.2*RIGHT+1.5*UP)
+ v11 = TextMobject(r"${T_3}$").scale(0.5).shift(2.2*RIGHT+1*UP)
+ v12 = TextMobject(r"${T_4}$").scale(0.5).shift(2.2*RIGHT+0.5*UP)
+ v13 = TextMobject(r"${T_5}$").scale(0.5).shift(2.2*RIGHT)
+ v14 = TextMobject(r"${T_6}$").scale(0.5).shift(2.2*RIGHT+0.5*DOWN)
+ v15 = TextMobject(r"${T_7}$").scale(0.5).shift(2.2*RIGHT+1*DOWN)
+ self.play(ShowCreation(v9),ShowCreation(v10),ShowCreation(v11),ShowCreation(v12),ShowCreation(v13),ShowCreation(v14),ShowCreation(v15))
+ self.play(ShowCreation(text2))
+ line1 = Line(start=dot1,end=dot9,stroke_width=0.95)
+ line2 = Line(start=dot2,end=dot10,stroke_width=0.95)
+ line3 = Line(start=dot3,end=dot11,stroke_width=0.95)
+ line4 = Line(start=dot4,end=dot12,stroke_width=0.95)
+ line5 = Line(start=dot5,end=dot13,stroke_width=0.95)
+ line6 = Line(start=dot6,end=dot14,stroke_width=0.95)
+ line7 = Line(start=dot7,end=dot15,stroke_width=0.95)
+ self.play(ShowCreation(line1),ShowCreation(line2),ShowCreation(line3),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(line7))
+ self.wait(1.5)
+ rect1 = Rectangle(stroke_width=0.5,width=1,height=1.9).set_fill(color=BLUE,opacity=0.3)
+ vgroup1 = VGroup(dot3,dot4,v3,v4)
+ rect1.surround(vgroup1)
+ self.play(ShowCreation(rect1))
+ text3 = TextMobject(r"Basis of $V$ = $\{v_3, v_4\}$").shift(4.6*LEFT+1*UP).scale(0.5)
+ self.play(ShowCreation(text3))
+ self.wait(1.5)
+ rect2 = Rectangle(stroke_width=0.5,width=1,height=1.7).set_fill(color=YELLOW,opacity=0.3)
+ vgroup2 = VGroup(dot11,dot12,v11,v12)
+ rect2.surround(vgroup2)
+ self.play(ShowCreation(rect2))
+ text4 = TextMobject(r"Basis of $V^*$ = $\{{T_3},{T_4} \}$").shift(4.6*RIGHT+1*UP).scale(0.5)
+ self.play(ShowCreation(text4))
+ self.wait(2.5)
+ v9.move_to(3*LEFT+3*UP).scale(1.2).set_color(YELLOW)
+ colon = TextMobject(":").shift(3*UP+2.6*LEFT)
+ vgroup3 = VGroup(line1,line2,line3,line4,line5,line6,line7)
+ vgroup4 = VGroup(v10,v11,v12,v13,v14,v15,rect1,rect2,text3,text4,c2)
+ vgroup5 = VGroup(dot9,dot10,dot11,dot12,dot13,dot14,dot15)
+ text5 = TextMobject(r"$F$").scale(0.6).shift(3*UP+2*RIGHT)
+ dot9 = SmallDot(color=GREEN).shift(2*RIGHT+2*UP)
+ dot10 = SmallDot(color=GREEN).shift(2*RIGHT+1.5*UP)
+ dot11 = SmallDot(color=GREEN).shift(2*RIGHT+1*UP)
+ dot12 = SmallDot(color=GREEN).shift(2*RIGHT+0.5*UP)
+ dot13 = SmallDot(color=GREEN).shift(2*RIGHT)
+ dot14 = SmallDot(color=GREEN).shift(2*RIGHT+0.5*DOWN)
+ dot15 = SmallDot(color=GREEN).shift(2*RIGHT+1*DOWN)
+ f1 = TextMobject(r"${f_1}$").scale(0.5).shift(2.2*RIGHT+2*UP)
+ f2 = TextMobject(r"${f_2}$").scale(0.5).shift(2.2*RIGHT+1.5*UP)
+ f3 = TextMobject(r"${f_3}$").scale(0.5).shift(2.2*RIGHT+1*UP)
+ f4 = TextMobject(r"${f_4}$").scale(0.5).shift(2.2*RIGHT+0.5*UP)
+ f5 = TextMobject(r"${f_5}$").scale(0.5).shift(2.2*RIGHT)
+ f6 = TextMobject(r"${f_6}$").scale(0.5).shift(2.2*RIGHT+0.5*DOWN)
+ f7 = TextMobject(r"${f_7}$").scale(0.5).shift(2.2*RIGHT+1*DOWN)
+ vgroup6 = VGroup(f1,f2,f3,f4,f5,f6,f7)
+ arrow = Arrow(stroke_width=1.6).scale(1.5).shift(3*UP)
+ c3 = Ellipse(radius = 2,color=GREEN)
+ c3.rotate(np.pi/2)
+ c3.shift(2*RIGHT+0.6*UP)
+ c3.scale(2)
+ self.play(ShowCreation(v9))
+ self.wait(1.5)
+ self.play(ShowCreation(arrow),ShowCreation(colon),Transform(text2,text5),FadeOut(vgroup3),FadeOut(vgroup4),FadeOut(vgroup5))
+ self.play(ShowCreation(vgroup5),ShowCreation(vgroup6),ShowCreation(c3))
+ self.wait(0.7)
+ self.play(ShowCreation(vgroup3))
+ self.wait(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py new file mode 100644 index 0000000..d79ec3e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_Basis_Example.py @@ -0,0 +1,97 @@ +from manimlib.imports import *
+import numpy as np
+
+class Dual_Basis(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": 10,
+ "y_axis_height": 10,
+ "x_tick_frequency":1,
+ "axes_color": GREY,
+ "area_opacity": 3,
+ "num_rects": 10,
+ }
+ def construct(self):
+ self.setup_axes(animate = True)
+ XD = self.x_axis_width/(self.x_max- self.x_min)
+ YD = self.y_axis_height/(self.y_max- self.y_min)
+ a1=2*XD*RIGHT+1*YD*UP
+ a2=3*XD*RIGHT+1*YD*UP
+ vec1=Vector(direction=a1,stroke_width=2).set_color(RED_E)
+ vec1.shift(self.graph_origin)
+ v1_label=TextMobject(r"$v_1$")
+ v1_label=(v1_label.shift(self.graph_origin+a1+0.1)).scale(.6)
+ self.play(ShowCreation(vec1),ShowCreation(v1_label))
+ text1=TextMobject(r"\text{$v_1$}",r"\text{$= (2,1)$}").scale(.6)
+ text1[0].set_color(RED_E)
+ text1.shift(5*LEFT+3.5*UP)
+ self.play(ShowCreation(text1))
+ self.wait(1.5)
+ vec2=Vector(direction=a2,stroke_width=2).set_color(YELLOW_E)
+ vec2.shift(self.graph_origin)
+ v2_label=TextMobject(r"$v_2$")
+ v2_label=(v2_label.shift(self.graph_origin+a2+0.1)).scale(.6)
+ self.play(ShowCreation(vec2),ShowCreation(v2_label))
+ text2=TextMobject(r"\text{$v_2$}",r"\text{$= (3,1)$}").scale(.6)
+ text2[0].set_color(YELLOW_E)
+ text2.shift(5*LEFT+3*UP)
+ self.play(ShowCreation(text2))
+ self.wait(1.5)
+ text3=TextMobject(r"\text{${T_2}$}",r"\text{$(v_1)$}",r"\text{$= 0$}").scale(.6)
+ text3[0].set_color(BLUE)
+ text3[1].set_color(RED_E)
+ text3.shift(4.94*LEFT+2.5*UP)
+ self.play(ShowCreation(text3))
+ self.wait(1.5)
+ text4=TextMobject(r"\text{${T_2}$}",r"\text{$= x - 2y$}").scale(.6)
+ text4[0].set_color(BLUE)
+ text4.shift(4.9*LEFT+2*UP)
+ self.play(ShowCreation(text4))
+ self.wait(1.5)
+ line1 = self.get_graph(lambda x : x/2, x_min = -5,x_max=5,color=BLUE)
+ v1_dual_label = TextMobject(r"${T_2}$").scale(.6).shift(3.9*RIGHT+1.85*UP)
+ self.play(ShowCreation(line1),ShowCreation(v1_dual_label))
+ self.wait(1.5)
+ text5=TextMobject(r"\text{${T_1}$}",r"\text{$(v_2)$}",r"\text{$= 0$}").scale(.6)
+ text5[1].set_color(YELLOW_E)
+ text5[0].set_color(PINK)
+ text5.shift(4.94*LEFT+1.5*UP)
+ self.play(ShowCreation(text5))
+ self.wait(1.5)
+ line2 = self.get_graph(lambda x : x/3, x_min = -5,x_max=5,color=PINK)
+ v2_dual_label = TextMobject(r"${T_1}$").scale(.6).shift(3.9*RIGHT+1.3*UP)
+ self.play(ShowCreation(line2),ShowCreation(v2_dual_label))
+ self.wait(1.5)
+ text6=TextMobject(r"\text{${T_1}$}",r"\text{$= - x + 3y$}").scale(.6)
+ text6[0].set_color(PINK)
+ text6.shift(4.76*LEFT+1*UP)
+ self.play(ShowCreation(text6))
+ self.wait(3)
+ text7 = TextMobject(r"\text{B =}",r"\text{$[$}",r"\text{$v_1,$}",r"\text{$v_2$}",r"\text{$]$}",r"\text{=}",r"\text{$[(2,1), (3,1)]$}").scale(0.6).shift(3*UP+4.5*LEFT)
+ text7[2].set_color(RED_E)
+ text7[3].set_color(YELLOW_E)
+ self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3),FadeOut(text4),FadeOut(text5),FadeOut(text6))
+ self.play(ShowCreation(text7))
+ self.wait(0.7)
+ text8 = TextMobject(r"\text{B$^* =$}",r"\text{$[$}",r"\text{${T_1}$,}",r"\text{${T_2} $}",r"\text{$]$}",r"\text{=}",r"\text{$[-x + 3y, x - 2y]$}").scale(0.6).shift(2.3*UP+4.1*LEFT)
+ text8[3].set_color(BLUE)
+ text8[2].set_color(PINK)
+ self.play(ShowCreation(text8))
+ self.wait(3)
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py new file mode 100644 index 0000000..a6f501e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Dual_of_a_Cube.py @@ -0,0 +1,38 @@ +from manimlib.imports import *
+class Duality(ThreeDScene):
+
+
+ def construct(self):
+ axes = ThreeDAxes()
+ self.set_camera_orientation(phi = 65*DEGREES,theta =80*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.09)
+ cube = Cube(stroke_width=5,color=WHITE).scale(2)
+ cube.set_opacity(0.2)
+ self.play(ShowCreation(cube))
+ dot1= Dot(color=RED).scale(0.85).shift([2,0,0])
+ self.play(ShowCreation(dot1))
+ dot2= Dot(color=YELLOW).scale(0.85).shift([-2,0,0])
+ self.play(ShowCreation(dot2))
+ dot3= Dot(color=BLUE).scale(0.85).shift([0,-2,0])
+ self.play(ShowCreation(dot3))
+ dot4= Dot(color=GREEN).scale(0.85).shift([0,2,0])
+ self.play(ShowCreation(dot4))
+ dot5= Dot(color=ORANGE).scale(0.85).shift([0,0,2])
+ self.play(ShowCreation(dot5))
+ dot6= Dot(color=PINK).scale(0.85).shift([0,0,-2])
+ self.play(ShowCreation(dot6))
+ line1 = Line(start=[0,0,2],end=[2,0,0],stroke_width=2.5,color=BLACK)
+ line2 = Line(start=[0,0,2],end=[-2,0,0],stroke_width=2.5,color=BLACK)
+ line3 = Line(start=[0,0,2],end=[0,-2,0],stroke_width=2.5,color=BLACK)
+ line4 = Line(start=[0,0,2],end=[0,2,0],stroke_width=2.5,color=BLACK)
+ line5 = Line(start=[2,0,0],end=[0,0,-2],stroke_width=2.5,color=BLACK)
+ line6 = Line(start=[-2,0,0],end=[0,0,-2],stroke_width=2.5,color=BLACK)
+ line7 = Line(start=[0,-2,0],end=[0,0,-2],stroke_width=2.5,color=BLACK)
+ line8 = Line(start=[0,2,0],end=[0,0,-2],stroke_width=2.5,color=BLACK)
+ line9 = Line(start=[0,2,0],end=[-2,0,0],stroke_width=2.5,color=BLACK)
+ line10 = Line(start=[-2,0,0],end=[0,-2,0],stroke_width=2.5,color=BLACK)
+ line11 = Line(start=[0,-2,0],end=[2,0,0],stroke_width=2.5,color=BLACK)
+ line12 = Line(start=[2,0,0],end=[0,2,0],stroke_width=2.5,color=BLACK)
+ self.play(ShowCreation(line1),ShowCreation(line2),ShowCreation(line3),ShowCreation(line4),ShowCreation(line5),ShowCreation(line6),ShowCreation(line7),ShowCreation(line8),ShowCreation(line9),ShowCreation(line10),ShowCreation(line11),ShowCreation(line12))
+ self.wait(10)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py new file mode 100644 index 0000000..693017e --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Duality_in_Sets.py @@ -0,0 +1,25 @@ +from manimlib.imports import *
+import numpy as np
+class Duality_in_sets(Scene):
+ def construct(self):
+ circle1 = Circle(radius=0.4,color=BLACK).shift(2.3*LEFT)
+ circle1.set_fill(color=RED,opacity=200)
+ rect1=Rectangle(height=2,width=2,color=GREY).shift(2*LEFT)
+ rect1.set_fill(color=DARK_BLUE,opacity=1)
+ text1 = TextMobject("S").scale(0.7).shift(0.9*UP+0.7*LEFT)
+ text2 = TextMobject("X",color=BLACK,stroke_width=0.5).scale(0.5).shift(2.3*LEFT)
+ self.play(ShowCreation(rect1),ShowCreation(text1),ShowCreation(circle1),ShowCreation(text2))
+ circle2 = Circle(radius=0.4,color=BLACK).shift(1.7*RIGHT)
+ circle2.set_fill(color=BLACK,opacity=200)
+ rect2=Rectangle(height=2,width=2,color=GREY).shift(2*RIGHT)
+ rect2.set_fill(color=DARK_BLUE,opacity=1)
+ text3 = TextMobject("S").scale(0.7).shift(0.9*UP+3.3*RIGHT)
+ text4 = TextMobject(r"X$^c$",color=BLACK,stroke_width=0.2).scale(0.5).shift(2.55*RIGHT+0.6*UP)
+ text5 = TextMobject(r"\text{The subset}",r"\text{X$^c$}",r"\text{is the dual of subset}",r"\text{X}").scale(0.6).shift(2.7*UP+0.5*LEFT)
+ text5[1].set_color(GREY)
+ text5[3].set_color(GREY)
+ self.play(ShowCreation(rect2),ShowCreation(circle2),ShowCreation(text3),ShowCreation(text4))
+ self.wait(2)
+ self.play(ShowCreation(text5))
+ self.wait(3)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py new file mode 100644 index 0000000..6edc918 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/Linear_Functional.py @@ -0,0 +1,29 @@ +from manimlib.imports import *
+import numpy as np
+class LinearFunctional(Scene):
+ def construct(self):
+ big_box=Rectangle().scale(2.7)
+ box = Rectangle(height=2,width=2,color=DARK_GREY).set_fill(color=PURPLE,opacity=350)
+ arrow1 = Arrow(color=RED).shift(1.8*LEFT+0.5*UP)
+ arrow2 = Arrow(color=RED).shift(1.8*LEFT+0.5*DOWN)
+ arrow3 = Arrow(color=GREEN).shift(0.5*UP+1.8*RIGHT)
+ arrow4 = Arrow(color=GREEN).shift(0.5*DOWN+1.8*RIGHT)
+ Linear = TextMobject("LINEAR",color=BLACK).scale(0.5).shift(0.2*UP)
+ Functional = TextMobject("FUNCTIONAL",color=BLACK).scale(0.5).shift(0.2*DOWN)
+ u = TextMobject(r"$\vec{u}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*UP)
+ v = TextMobject(r"$\vec{v}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*DOWN)
+ f1 = TextMobject(r"$f_1$",color=YELLOW).scale(0.7).shift(2.8*RIGHT+0.5*UP)
+ f2 = TextMobject(r"$f_2$",color=YELLOW).scale(0.7).shift(2.8*RIGHT+0.5*DOWN)
+ text = TextMobject(r"The Linear Functional is a function that takes $\vec{u}, \vec{v} \in$ V as inputs and gives the output $f_1, f_2\in$ F.").scale(0.55).shift(2*DOWN)
+ self.play(ShowCreation(big_box))
+ self.play(ShowCreation(box))
+ self.play(ShowCreation(Linear),ShowCreation(Functional))
+ self.wait(2)
+ self.play(ShowCreation(arrow1),ShowCreation(u))
+ self.play(ShowCreation(arrow3),ShowCreation(f1))
+ self.wait(0.7)
+ self.play(ShowCreation(arrow2),ShowCreation(v))
+ self.play(ShowCreation(arrow4),ShowCreation(f2))
+ self.wait(1)
+ self.play(ShowCreation(text))
+ self.wait(4)
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Basis_of_a_dual_vector_space.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Basis_of_a_dual_vector_space.mp4 Binary files differnew file mode 100644 index 0000000..b96f541 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Basis_of_a_dual_vector_space.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_Basis_Example.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_Basis_Example.mp4 Binary files differnew file mode 100644 index 0000000..c93be25 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_Basis_Example.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_of_a_Cube.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_of_a_Cube.mp4 Binary files differnew file mode 100644 index 0000000..ebfb564 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Dual_of_a_Cube.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Duality_in_Sets.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Duality_in_Sets.mp4 Binary files differnew file mode 100644 index 0000000..86cc693 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Duality_in_Sets.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Linear_functional.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Linear_functional.mp4 Binary files differnew file mode 100644 index 0000000..d41fada --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Dual-Spaces/gifs4/Linear_functional.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py new file mode 100644 index 0000000..ac74792 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Scalar_Multiplication.py @@ -0,0 +1,62 @@ +from manimlib.imports import *
+from scipy import exp
+class FunctionScalarMultiplication(GraphScene):
+ CONFIG = {
+ "x_min" : -5,
+ "x_max" : 5,
+ "y_min" : -5,
+ "y_max" : 5,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color":LIGHT_GRAY,
+ "graph_origin": ORIGIN,
+ }
+ def construct(self):
+ self.setup_axes(animate = True)
+ curve1 = self.get_graph(lambda x : 1/3*(x**2)+1, x_min=-2,x_max=2.5,color=ORANGE)
+ curve2 = self.get_graph(lambda x : 2*(1/3*(x**2)+1), x_min=-2,x_max=2.5,color=GOLD)
+ fx= TextMobject("$f(x)$").scale(0.6).shift(1.25*UP + 2.2*LEFT)
+ gx= TextMobject("$2 \cdot f(x)$").scale(0.6).shift(0.5*UP + 2.1*LEFT)
+ f1 = self.get_vertical_line_to_graph(-2,curve1,color=YELLOW)
+ f2 = self.get_vertical_line_to_graph(-1.5,curve1,color=YELLOW)
+ f3 = self.get_vertical_line_to_graph(-1,curve1,color=YELLOW)
+ f4 = self.get_vertical_line_to_graph(-0.5,curve1,color=YELLOW)
+ f5 = self.get_vertical_line_to_graph(0,curve1,color=YELLOW)
+ f6 = self.get_vertical_line_to_graph(0.5,curve1,color=YELLOW)
+ f7 = self.get_vertical_line_to_graph(1,curve1,color=YELLOW)
+ f8 = self.get_vertical_line_to_graph(1.5,curve1,color=YELLOW)
+ f9 = self.get_vertical_line_to_graph(2,curve1,color=YELLOW)
+ f10 = self.get_vertical_line_to_graph(2.5,curve1,color=YELLOW)
+ self.play(ShowCreation(curve1),ShowCreation(fx))
+ self.wait(1.5)
+ self.play(ShowCreation(f1),ShowCreation(f2),ShowCreation(f3),ShowCreation(f4),ShowCreation(f5),ShowCreation(f6),ShowCreation(f7),ShowCreation(f8),ShowCreation(f9),ShowCreation(f10))
+ self.wait(1.7)
+ line1=Line(color=YELLOW).shift(5*LEFT+1.8*UP).scale(0.5)
+ line1.rotate(np.pi/2)
+ scalar = TextMobject("2 x").scale(0.65).shift(5.5*LEFT+1.9*UP)
+ equal = TextMobject("=").scale(0.65).shift(4.5*LEFT+1.9*UP)
+ line2=Line(color=BLUE).shift(4*LEFT+2.3*UP)
+ line2.rotate(np.pi/2)
+ self.play(ShowCreation(line1),ShowCreation(scalar),ShowCreation(equal),ShowCreation(line2))
+ g1 = self.get_vertical_line_to_graph(-2,curve2,color=BLUE)
+ g2 = self.get_vertical_line_to_graph(-1.5,curve2,color=BLUE)
+ g3 = self.get_vertical_line_to_graph(-1,curve2,color=BLUE)
+ g4 = self.get_vertical_line_to_graph(-0.5,curve2,color=BLUE)
+ g5 = self.get_vertical_line_to_graph(0,curve2,color=BLUE)
+ g6 = self.get_vertical_line_to_graph(0.5,curve2,color=BLUE)
+ g7 = self.get_vertical_line_to_graph(1,curve2,color=BLUE)
+ g8 = self.get_vertical_line_to_graph(1.5,curve2,color=BLUE)
+ g9 = self.get_vertical_line_to_graph(2,curve2,color=BLUE)
+ g10 = self.get_vertical_line_to_graph(2.5,curve2,color=BLUE)
+ self.play(ShowCreation(g1),ShowCreation(g2),ShowCreation(g3),ShowCreation(g4),ShowCreation(g5),ShowCreation(g6),ShowCreation(g7),ShowCreation(g8),ShowCreation(g9),ShowCreation(g10))
+ self.wait(2)
+ fx2=TextMobject("2$\cdot f(x)$").scale(0.6).shift(2.6*UP+2.3*LEFT)
+ self.play(ShowCreation(curve2),ShowCreation(fx2))
+ self.wait(1.5)
+ self.play(FadeOut(curve1),FadeOut(fx))
+ sc_mult=TextMobject("$(2 f(x)) = 2f(x)$",color=GOLD).scale(0.65).shift(0.65*UP + 5*LEFT)
+ rect = Rectangle(height=0.5,width=2)
+ rect.surround(sc_mult)
+ self.play(ShowCreation(sc_mult),ShowCreation(rect))
+ self.wait(3)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py new file mode 100644 index 0000000..5ce0e11 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Function_Space_Addition.py @@ -0,0 +1,89 @@ +from manimlib.imports import *
+from scipy import sin,exp
+class FunctionalVectorSpace(GraphScene):
+ CONFIG = {
+ "x_min" : -5,
+ "x_max" : 5,
+ "y_min" : -5,
+ "y_max" : 5,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color":LIGHT_GRAY,
+ "graph_origin": ORIGIN,
+
+
+ }
+ def construct(self):
+ self.setup_axes(animate = True)
+ curve1 = self.get_graph(lambda x : exp(x) + 0.5, x_min=-2,x_max=2.5,color=ORANGE)
+ curve2 = self.get_graph(lambda x : 1/3*(x**2)+1, x_min=-2,x_max=2.5,color=DARK_BLUE)
+ curve3 = self.get_graph(lambda x : 1/3*(x**2)+1 + exp(x) + 0.5, x_min=-2,x_max=2.5,color=BLACK)
+ fx= TextMobject("$f(x)$").scale(0.6).shift(1.25*UP + 2.1*LEFT)
+ gx= TextMobject("$g(x)$").scale(0.6).shift(0.5*UP + 2.1*LEFT)
+ f1 = self.get_vertical_line_to_graph(-2,curve1,color=YELLOW)
+ f2 = self.get_vertical_line_to_graph(-1.5,curve1,color=YELLOW)
+ f3 = self.get_vertical_line_to_graph(-1,curve1,color=YELLOW)
+ f4 = self.get_vertical_line_to_graph(-0.5,curve1,color=YELLOW)
+ f5 = self.get_vertical_line_to_graph(0,curve1,color=YELLOW)
+ f6 = self.get_vertical_line_to_graph(0.5,curve1,color=YELLOW)
+ f7 = self.get_vertical_line_to_graph(1,curve1,color=YELLOW)
+ f8 = self.get_vertical_line_to_graph(1.5,curve1,color=YELLOW)
+ f9 = self.get_vertical_line_to_graph(2,curve1,color=YELLOW)
+ f10 = self.get_vertical_line_to_graph(2.5,curve1,color=YELLOW)
+
+ self.play(ShowCreation(curve1),ShowCreation(gx))
+ self.wait(1.2)
+ self.play(ShowCreation(curve2),ShowCreation(fx))
+ self.wait(1.2)
+ self.play(ShowCreation(f1),ShowCreation(f2),ShowCreation(f3),ShowCreation(f4),ShowCreation(f5),ShowCreation(f6),ShowCreation(f7),ShowCreation(f8),ShowCreation(f9),ShowCreation(f10))
+ self.wait(1.7)
+ g1 = self.get_vertical_line_to_graph(-2,curve2,color=BLUE)
+ g2 = self.get_vertical_line_to_graph(-1.5,curve2,color=BLUE)
+ g3 = self.get_vertical_line_to_graph(-1,curve2,color=BLUE)
+ g4 = self.get_vertical_line_to_graph(-0.5,curve2,color=BLUE)
+ g5 = self.get_vertical_line_to_graph(0,curve2,color=BLUE)
+ g6 = self.get_vertical_line_to_graph(0.5,curve2,color=BLUE)
+ g7 = self.get_vertical_line_to_graph(1,curve2,color=BLUE)
+ g8 = self.get_vertical_line_to_graph(1.5,curve2,color=BLUE)
+ g9 = self.get_vertical_line_to_graph(2,curve2,color=BLUE)
+ g10 = self.get_vertical_line_to_graph(2.5,curve2,color=BLUE)
+ self.play(ShowCreation(g1),ShowCreation(g2),ShowCreation(g3),ShowCreation(g4),ShowCreation(g5),ShowCreation(g6),ShowCreation(g7),ShowCreation(g8),ShowCreation(g9),ShowCreation(g10))
+ line1=Line(color=BLUE).shift(5*LEFT+2.3*UP).scale(0.25)
+ line1.rotate(np.pi/2)
+ line2=Line(color=YELLOW).shift(6*LEFT+2.5*UP).scale(0.5)
+ line2.rotate(np.pi/2)
+ line3=Line(color=PURPLE_B).shift(4*LEFT+2.7*UP).scale(0.75)
+ line3.rotate(np.pi/2)
+ add=TextMobject("+").shift(2.4*UP+5.5*LEFT).scale(0.7)
+ equal=TextMobject("=").shift(2.4*UP+4.5*LEFT).scale(0.7)
+ self.play(ShowCreation(line2),ShowCreation(line1),ShowCreation(add),ShowCreation(equal),ShowCreation(line3))
+ self.wait(2)
+ self.play(FadeOut(curve1),FadeOut(curve2))
+ self.wait(3)
+ h1 = self.get_vertical_line_to_graph(-2,curve3,color=PURPLE_B)
+ h2 = self.get_vertical_line_to_graph(-1.5,curve3,color=PURPLE_B)
+ h3 = self.get_vertical_line_to_graph(-1,curve3,color=PURPLE_B)
+ h4 = self.get_vertical_line_to_graph(-0.5,curve3,color=PURPLE_B)
+ h5 = self.get_vertical_line_to_graph(0,curve3,color=PURPLE_B)
+ h6 = self.get_vertical_line_to_graph(0.5,curve3,color=PURPLE_B)
+ h7 = self.get_vertical_line_to_graph(1,curve3,color=PURPLE_B)
+ h8 = self.get_vertical_line_to_graph(1.5,curve3,color=PURPLE_B)
+ h9 = self.get_vertical_line_to_graph(2,curve3,color=PURPLE_B)
+ h10 = self.get_vertical_line_to_graph(2.5,curve3,color=PURPLE_B)
+
+ line1.shift(1*LEFT+0.9*UP)
+ equal.shift(0.3*LEFT+0.2*UP)
+ f=TextMobject("$f(x)$").scale(0.5).shift(5.6*LEFT+3.2*UP)
+ g=TextMobject("$g(x)$").scale(0.5).shift(5.6*LEFT+2.4*UP)
+ fg=TextMobject("$(f + g)(x)$").scale(0.5).shift(2.85*UP+3.3*LEFT)
+ self.play(FadeOut(add),ShowCreation(equal),ShowCreation(line1),ShowCreation(f),ShowCreation(g),ShowCreation(fg),FadeOut(fx),FadeOut(gx))
+ self.wait(1.7)
+ self.play(ShowCreation(h1),ShowCreation(h2),ShowCreation(h3),ShowCreation(h4),ShowCreation(h5),ShowCreation(h6),ShowCreation(h7),ShowCreation(h8),ShowCreation(h9),ShowCreation(h10))
+ curve3 = self.get_graph(lambda x : 1/3*(x**2)+1 + exp(x) + 0.5, x_min=-2,x_max=2.5,color=RED_A)
+ fgx=TextMobject("$(f + g)(x)$").scale(0.5).shift(1.65*UP+2.4*LEFT)
+ self.play(ShowCreation(curve3),ShowCreation(fgx))
+ sum=TextMobject("$(f + g)(x) = f(x) + g(x)$",color=GOLD).scale(0.65).shift(0.8*UP + 5*LEFT)
+ rect = Rectangle(height=0.5,width=2)
+ rect.surround(sum)
+ self.play(ShowCreation(sum),ShowCreation(rect))
+ self.wait(3)
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py new file mode 100644 index 0000000..97c0e09 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/Integral_Properties.py @@ -0,0 +1,77 @@ +from manimlib.imports import *
+from scipy import sin
+class Integral_Properties(GraphScene):
+ CONFIG = {
+ "x_min" : 0,
+ "x_max" : 5,
+ "y_min" : 0,
+ "y_max" : 6,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color":LIGHT_GRAY,
+ "x_labeled_nums" : list(range(6)),
+ "y_labeled_nums" : list(range(6))
+ }
+ def construct(self):
+ self.setup_axes(animate=False)
+ curve1 = self.get_graph(lambda x : sin(x), x_min=0,x_max=2.5,color=RED)
+ curve2 = self.get_graph(lambda x : x, x_min=0,x_max=2.5,color=DARK_BLUE)
+ curve3 = self.get_graph(lambda x : sin(x) + x, x_min=0,x_max=2.5,color=GREEN)
+ fx = TextMobject(r"$f(x)$").scale(0.5).shift(1*RIGHT+1.8*DOWN)
+ gx = TextMobject(r"$g(x)$").scale(0.5).shift(1*RIGHT)
+ sum = TextMobject(r"$f(x) + g(x)$").scale(0.5).shift(1.3*RIGHT+0.6*UP)
+ area1 = self.get_area(curve1,0,2.5)
+ area2 = self.get_area(curve2,0,2.5)
+ area3 = self.get_area(curve3,0,2.5)
+ area2.set_fill(color=PURPLE)
+ area3.set_fill(color=ORANGE)
+ text1=TextMobject(r"$\int_{0}^{2.5}$ f(x) dx = Area under the curve f(x)",color=BLUE_C).scale(0.7).shift(2.7*RIGHT+3*UP)
+ text2=TextMobject(r"$\int_{0}^{2.5}$ g(x) dx = Area under the curve g(x)",color=PURPLE_B).scale(0.7).shift(2.7*RIGHT+2.4*UP)
+ text3=TextMobject(r"Area under the curve f(x) + g(x) = $\int_{0}^{2.5} (f(x) + g(x)) dx$",color=ORANGE).scale(0.7).shift(2.7*RIGHT+1.8*UP)
+ text4=TextMobject(r"\text{$\int_{0}^{2.5}$ (f(x) + g(x)) dx}",r"\text{ = }",r"\text{ $\int_{0}^{2.5}$ f(x) dx }",r"\text{+}",r"\text{$\int_{0}^{2.5}$ g(x) dx}").scale(0.62).shift(2.7*RIGHT+2.7*UP)
+ text4[0].set_color(ORANGE)
+ text4[2].set_color(BLUE_C)
+ text4[4].set_color(PURPLE_B)
+ self.play(ShowCreation(curve1), ShowCreation(fx))
+ self.wait(1.2)
+ self.play(ShowCreation(curve2),ShowCreation(gx))
+ self.wait(1.2)
+ self.play(ShowCreation(area1))
+ self.play(ShowCreation(text1))
+ self.wait(1.5)
+ self.play(ShowCreation(area2))
+ self.play(ShowCreation(text2))
+ self.wait(1.5)
+ self.play(ShowCreation(curve3),ShowCreation(sum))
+ self.play(ShowCreation(area3))
+ self.play(ShowCreation(text3))
+ self.wait(2)
+ self.play(FadeOut(text1),FadeOut(text2),FadeOut(text3))
+ self.wait(1)
+ self.play(ShowCreation(text4))
+ self.wait(3)
+ self.play(FadeOut(curve1),FadeOut(curve2),FadeOut(area1),FadeOut(area2))
+ self.wait(1.5)
+ self.play(FadeOut(text4),FadeOut(area2),FadeOut(curve2),FadeOut(gx),FadeOut(curve3),FadeOut(sum),FadeOut(area3),ShowCreation(curve1),ShowCreation(fx))
+ self.wait(1.5)
+ self.play(ShowCreation(area1),ShowCreation(text1))
+ self.wait(1.5)
+ curve4 = self.get_graph(lambda x : 2*sin(x), x_min=0,x_max=2.5,color=RED)
+ area4 = self.get_area(curve4,0,2.5)
+ area4.set_fill(color=YELLOW)
+ fx2 = TextMobject(r"$2f(x)$").scale(0.7).shift(1*RIGHT+1.2*DOWN)
+ scalar_mul=TextMobject(r"$\int_{0}^{2.5} ( 2f(x) ) dx$ = 2 $\times$ Area under the curve f(x)",color=YELLOW).scale(0.7).shift(2.7*RIGHT+2.4*UP)
+ self.play(ShowCreation(curve4),ShowCreation(fx2))
+ self.wait(1)
+ self.play(ShowCreation(area4))
+ self.wait(2)
+ self.play(ShowCreation(scalar_mul))
+ self.wait(2)
+ text5=TextMobject(r"\text{$\int_{0}^{2.5}$ (2 f(x)) dx}",r"\text{ = }",r"\text{2 $\int_{0}^{2.5}$ f(x) dx }").scale(0.67).shift(2.7*RIGHT+2.7*UP)
+ text5[0].set_color(YELLOW)
+ text5[2].set_color(BLUE_C)
+ self.play(FadeOut(text1),FadeOut(scalar_mul))
+ self.wait(1)
+ self.play(ShowCreation(text5))
+ self.wait(3)
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Addition_of_Functions.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Addition_of_Functions.gif Binary files differnew file mode 100644 index 0000000..6c42b74 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Addition_of_Functions.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Function_Space_Example.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Function_Space_Example.gif Binary files differnew file mode 100644 index 0000000..996a9de --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Function_Space_Example.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Scalar_Multiplicaton_of_Functions.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Scalar_Multiplicaton_of_Functions.gif Binary files differnew file mode 100644 index 0000000..8fff2c8 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Function-and-Polynomial-Spaces/gifs3/Scalar_Multiplicaton_of_Functions.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Conjugate_Symmetry_and_Positivity_of_Inner_Product.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Conjugate_Symmetry_and_Positivity_of_Inner_Product.py new file mode 100644 index 0000000..1d84842 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Conjugate_Symmetry_and_Positivity_of_Inner_Product.py @@ -0,0 +1,141 @@ +from manimlib.imports import *
+VECTORS = [[0, 2],
+ [1, 1],
+ [0, -2],
+ [1, -1],
+ [2, -2],
+ [2, 2],
+ [2, 2],
+ [-2, -1],
+ [3, 4]]
+class Scene1(LinearTransformationScene):
+ CONFIG = {
+ "include_background_plane": True,
+ "include_foreground_plane": False,
+ "show_coordinates": True,
+ "show_basis_vectors": False,
+ "basis_vector_stroke_width": 3,
+ }
+ def construct(self):
+ text1 = TextMobject(r"\text{$u$}",r"\text{ = $0 + 2i$, }",r"\text{$v$}",r"\text{ = $1 + i$}").scale(0.6).shift(3.5*UP+4*LEFT)
+ text1[0].set_color(YELLOW)
+ text1[2].set_color(RED)
+ text1.add_background_rectangle()
+ self.play(ShowCreation(text1))
+ text2 = TextMobject(r"\text{$\overline{u}$}",r"\text{ = $0 - 2i$, }",r"\text{$\overline{v}$}",r"\text{ = $1 - i$}").scale(0.6).shift(3*UP+4*LEFT)
+ text2[0].set_color(YELLOW)
+ text2[2].set_color(RED)
+ text2.add_background_rectangle()
+ self.play(ShowCreation(text2))
+ self.wait(2)
+ v1 = self.add_vector(VECTORS[0],color = YELLOW, stroke_width = 3.5)
+ u = TextMobject(r"$u$",color=YELLOW).shift(0.3*LEFT+2*UP).scale(0.6)
+ self.play(ShowCreation(u))
+ v1b = self.add_vector(VECTORS[2],color = YELLOW, stroke_width = 3.5)
+ ub = TextMobject(r"$\overline{u}$",color=YELLOW).shift(2*DOWN+0.3*LEFT).scale(0.6)
+ self.play(ShowCreation(ub))
+ self.wait(2)
+ v2 = self.add_vector(VECTORS[1],color = RED, stroke_width = 3.5)
+ v = TextMobject(r"$v$",color=RED).shift(1.2*RIGHT+1*UP).scale(0.6)
+ self.play(ShowCreation(v))
+ v2b = self.add_vector(VECTORS[3],color = RED, stroke_width = 3.5)
+ vb = TextMobject(r"$\overline{v}$",color=RED).shift(1.2*RIGHT+1*DOWN).scale(0.6)
+ self.play(ShowCreation(vb))
+ text3 = TextMobject(r"\text{$<u, v>$}",r"\text{ = }",r"\text{$\overline{u}$",r"\text{$\cdot$}",r"\text{$v$}",r"\text{ = }",r"\text{$2 - 2i$}").shift(2.5*UP+3.7*LEFT).scale(0.6)
+ text3[0].set_color(BLUE)
+ text3[2].set_color(YELLOW)
+ text3[4].set_color(RED)
+ text3.add_background_rectangle()
+ self.play(ShowCreation(text3))
+ self.wait(2)
+ text4 = TextMobject(r"\text{$<\overline{u, v}>$",r"\text{ = }",r"\text{$\overline{u}$",r"\text{$\cdot$}",r"\text{$v$}",r"\text{ = }",r"\text{$2 + 2i$}").shift(2*UP+3.7*LEFT).scale(0.6)
+ text4[0].set_color(BLUE)
+ text4[2].set_color(YELLOW)
+ text4[4].set_color(RED)
+ text4.add_background_rectangle()
+ line = Line(stroke_width = 1.5).scale(0.33).shift(2.2*UP+3.54*LEFT)
+ self.play(ShowCreation(text4),ShowCreation(line))
+ self.wait(2)
+ self.play(FadeOut(v1),FadeOut(v1b),FadeOut(v2),FadeOut(v2b),FadeOut(u),FadeOut(ub),FadeOut(v),FadeOut(vb))
+ v3 = self.add_vector(VECTORS[4],color = BLUE, stroke_width = 3.5)
+ uv = TextMobject(r"$\overline{u}\cdot v$",color=BLUE).shift(2.4*RIGHT+2.1*DOWN).scale(0.6)
+ self.play(ShowCreation(uv))
+ v3b = self.add_vector(VECTORS[5],color = BLUE, stroke_width = 3.5)
+ uvb = TextMobject(r"$\overline{\overline{u}\cdot v}$",color=BLUE).shift(2.4*RIGHT+2.1*UP).scale(0.6)
+ self.play(ShowCreation(uvb))
+ self.wait(2)
+ text5 = TextMobject(r"\text{$<v, u>$}",r"\text{ = }",r"\text{$\overline{v}$",r"\text{$\cdot$}",r"\text{$u$}",r"\text{ = }",r"\text{$2 + 2i$}").shift(1.5*UP+3.7*LEFT).scale(0.6)
+ text5[0].set_color(MAROON_B)
+ text5[2].set_color(RED)
+ text5[4].set_color(YELLOW)
+ text5.add_background_rectangle()
+ self.play(ShowCreation(text5))
+ self.wait(2)
+ v4 = self.add_vector(VECTORS[5],color = MAROON_B, stroke_width = 3.5)
+ vu = TextMobject(r"$\overline{v}\cdot u$",color=MAROON_B).shift(1.3*RIGHT+2.1*UP).scale(0.6)
+ self.play(ShowCreation(vu))
+ self.play(FadeOut(uvb))
+ self.wait(2)
+ text6 = TextMobject(r"\text{$<\overline{u, v}>$",r"\text{ = }",r"\text{$<v, u>$").scale(0.6).shift(0.8*UP+4.2*LEFT)
+ text6[0].set_color(BLUE)
+ text6[2].set_color(MAROON_B)
+ text6.add_background_rectangle()
+ self.play(ShowCreation(text6))
+ rect = Rectangle(height = 0.7,width = 3.5)
+ rect.surround(text6)
+ self.play(ShowCreation(rect))
+ self.wait(3)
+ self.play(FadeOut(line),FadeOut(text1),FadeOut(text2),FadeOut(text3),FadeOut(text4),FadeOut(text5),FadeOut(text6),FadeOut(v4),FadeOut(vu),FadeOut(v3),FadeOut(uv),FadeOut(rect),FadeOut(v3b))
+
+ text7 = TextMobject(r"\text{$u$}",r"\text{ = $(1 + i) > 0$}").scale(0.6).shift(3.5*UP+4.5*LEFT)
+ text7[0].set_color(YELLOW)
+ text7.add_background_rectangle()
+ self.play(ShowCreation(text7))
+ v5 = self.add_vector(VECTORS[1],color = YELLOW, stroke_width = 3.5)
+ u = TextMobject(r"$u$",color=YELLOW).shift(1.2*RIGHT+1*UP).scale(0.6)
+ self.play(ShowCreation(u))
+ self.wait(1.5)
+ text8 = TextMobject(r"\text{$<u, u>$}",r"\text{ = $(0 + 2i) > 0$ }").scale(0.6).shift(2.7*UP+4*LEFT)
+ text8[0].set_color(GREEN)
+ text8.add_background_rectangle()
+ rect1 = Rectangle(height = 0.55, width = 3.3)
+ rect1.surround(text8)
+ self.play(ShowCreation(text8),ShowCreation(rect1))
+ self.wait(2)
+ v6 = self.add_vector(VECTORS[0],color = GREEN, stroke_width = 3.5)
+ uu = TextMobject(r"$<u, u>$",color=GREEN).shift(0.8*LEFT+1.9*UP).scale(0.6)
+ self.play(ShowCreation(uu))
+ text9 = TextMobject(r"\text{$v$}",r"\text{ = $(-2 - i) < 0$}").scale(0.6).shift(1.5*UP+4.4*LEFT)
+ text9[0].set_color(RED)
+ text9.add_background_rectangle()
+ self.play(ShowCreation(text9))
+ self.wait(1.5)
+ v7 = self.add_vector(VECTORS[7],color = RED, stroke_width = 3.5)
+ v = TextMobject(r"$v$",color=RED).shift(2.2*LEFT+1*DOWN).scale(0.6)
+ self.play(ShowCreation(v))
+ self.wait(1.5)
+ text10 = TextMobject(r"\text{$<v, v>$}",r"\text{ = $(3 + 4i) > 0$ }").scale(0.6).shift(0.7*UP+4*LEFT)
+ text10[0].set_color(BLUE)
+ text10.add_background_rectangle()
+ rect2 = Rectangle(height=0.55,width=3.3)
+ rect2.surround(text10)
+ self.play(ShowCreation(text10),ShowCreation(rect2))
+ self.wait(2)
+ v8 = self.add_vector(VECTORS[8],color = BLUE, stroke_width = 3.5)
+ vv = TextMobject(r"$<v, v>$",color=BLUE).shift(2.1*RIGHT+3.8*UP).scale(0.6)
+ self.play(ShowCreation(vv))
+ self.wait(4)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_Product_Example.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_Product_Example.py new file mode 100644 index 0000000..97b9696 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_Product_Example.py @@ -0,0 +1,182 @@ +from manimlib.imports import *
+from scipy import sin,cos
+class Inner_Product_Space_Example(GraphScene):
+ CONFIG = {
+ "x_min" : 0,
+ "x_max" : 5,
+ "y_min" : 0,
+ "y_max" : 6,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color":LIGHT_GRAY,
+ "x_labeled_nums" : list(range(6)),
+ "y_labeled_nums" : list(range(6))
+ }
+ def construct(self):
+ self.setup_axes(animate=True)
+ text = TextMobject(r"$f(x), g(x), h(x) \in C[0, 2]$",color=GOLD).scale(0.5).shift(3.5*UP+5.5*LEFT)
+ fx = TextMobject(r"$f(x)$ = sin(x)",color=GOLD).scale(0.5).shift(3*UP+6*LEFT)
+ gx = TextMobject(r"$g(x)$ = x",color=GOLD).scale(0.5).shift(2.5*UP+6.25*LEFT)
+ hx = TextMobject(r"$h(x)$ = 1.4",color=GOLD).scale(0.5).shift(2*UP+6.2*LEFT)
+
+ curve1 = self.get_graph(lambda x : sin(x), x_min=0,x_max=2,color=RED)
+ curve2 = self.get_graph(lambda x : x, x_min=0,x_max=2,color=DARK_BLUE)
+ curve3 = self.get_graph(lambda x : 1.4, x_min=0,x_max=2,color=GREEN)
+ text1 = TextMobject(r"$f(x)$").scale(0.5).shift(1.7*DOWN)
+
+ text2 = TextMobject(r"$g(x)$").scale(0.5).shift(0.34*DOWN)
+ text3 = TextMobject(r"$h(x)$").scale(0.5).shift(1.1*DOWN)
+
+
+ self.play(ShowCreation(text))
+ self.play(ShowCreation(curve1),ShowCreation(text1),ShowCreation(fx))
+ self.wait(1)
+ self.play(ShowCreation(curve2),ShowCreation(text2),ShowCreation(gx))
+ self.wait(1)
+ self.play(ShowCreation(curve3),ShowCreation(text3),ShowCreation(hx))
+ self.wait(2)
+ curve4 = self.get_graph(lambda x : sin(x) + x, x_min=0,x_max=2,color=YELLOW)
+ text4 = TextMobject(r"$f(x) + g(x)$").scale(0.5).shift(0.5*UP+0.5*RIGHT)
+ self.wait(1.5)
+
+ self.play(ShowCreation(curve4),ShowCreation(text4),FadeOut(curve2),FadeOut(text2),FadeOut(curve1),FadeOut(text1))
+ self.wait(1.5)
+ text5 = TextMobject(r"\text{$<f(x) + g(x), h(x)>$ = ",r"\text{$\int_{0}^{2} (f(x) + g(x))h(x)$ $dx$}",r"\text{= 4.78}").scale(0.57).shift(3.3*RIGHT+3.5*UP)
+ text5[1].set_color(ORANGE)
+ self.play(ShowCreation(text5))
+
+ curve5 = self.get_graph(lambda x : (sin(x) + x)*1.6, x_min=0,x_max=2,color=ORANGE)
+ text6 = TextMobject(r"$(f(x) + g(x))\cdot h(x)$").scale(0.5).shift(2.2*UP+0.72*RIGHT)
+ area1 = self.get_area(curve5,0,2)
+ area1.set_color(ORANGE)
+ self.wait(1)
+ self.play(FadeOut(curve4),FadeOut(text4),FadeOut(curve3),FadeOut(text3),ShowCreation(curve5),ShowCreation(text6),ShowCreation(area1))
+ self.wait(2)
+ text7 = TextMobject(r"\text{$<f(x), h(x)>$ = ",r"\text{$\int_{0}^{2} (f(x)h(x)$ $dx$}",r"\text{= 1.98}").scale(0.57).shift(4.5*RIGHT+3*UP)
+ text7[1].set_color(BLUE)
+ self.play(ShowCreation(text7))
+ self.wait(1.5)
+ curve6 = self.get_graph(lambda x : (sin(x))*1.6, x_min=0,x_max=2,color=BLUE)
+ text8 = TextMobject(r"$f(x)\cdot h(x)$").scale(0.5).shift(0.9*DOWN+0.3*RIGHT)
+ area2 = self.get_area(curve6,0,2)
+ self.play(ShowCreation(curve6),ShowCreation(text8),ShowCreation(area2))
+ self.wait(1.5)
+ text9 = TextMobject(r"\text{$<g(x), h(x)>$ = ",r"\text{$\int_{0}^{2} (g(x)h(x)$ $dx$}",r"\text{= 2.8}").scale(0.57).shift(4.5*RIGHT+2.5*UP)
+ text9[1].set_color(MAROON_B)
+ self.play(ShowCreation(text9))
+ self.wait(1.5)
+ curve7 = self.get_graph(lambda x : x*1.6, x_min=0,x_max=2,color=MAROON_B)
+ text10 = TextMobject(r"$g(x)\cdot h(x)$").scale(0.5).shift(0.3*RIGHT+0.78*UP)
+ area3 = self.get_area(curve7,0,2)
+ area3.set_color(MAROON_B)
+ self.play(ShowCreation(curve7),ShowCreation(text10),ShowCreation(area3))
+ self.wait(2.6)
+ curve8 = self.get_graph(lambda x : (sin(x))*1.6 + x*1.6, x_min=0,x_max=2,color=RED_C)
+ area4 = self.get_area(curve8,0,2)
+ area4.set_color(RED_C)
+ text11 = TextMobject(r"$f(x)h(x) + g(x)h(x)$").scale(0.5).shift(2.2*UP + 0.76*RIGHT)
+ self.play(FadeOut(curve6),FadeOut(text8),FadeOut(curve7),FadeOut(text10),FadeOut(area2),FadeOut(area3),ShowCreation(curve8),ShowCreation(area4))
+ self.wait(1)
+ self.play(Transform(text6,text11))
+ self.wait(1.7)
+ text12 = TextMobject(r"$<f(x) + g(x), h(x)>$ = $<f(x), h(x)>$ + $<g(x), h(x)>$").scale(0.465).shift(0.7*UP+4*RIGHT)
+ rect1 = Rectangle(height=0.5)
+ rect1.surround(text12)
+ self.play(ShowCreation(text12),ShowCreation(rect1))
+ self.wait(3)
+ self.play(FadeOut(text6),FadeOut(text5),FadeOut(text7),FadeOut(text9),FadeOut(text12),FadeOut(rect1),FadeOut(curve8),FadeOut(area4),FadeOut(text11),FadeOut(curve5),FadeOut(area1))
+
+ curve2.set_color(ORANGE)
+ self.play(ShowCreation(curve1),ShowCreation(text1))
+ self.wait(1)
+ self.play(ShowCreation(curve2),ShowCreation(text2))
+ self.wait(2)
+ curve9 = self.get_graph(lambda x : 2*sin(x), x_min=0,x_max=2,color=GREEN)
+ text13 = TextMobject(r"$2f(x)$").scale(0.5).shift(0.75*DOWN)
+ self.play(Transform(curve1,curve9),Transform(text1,text13))
+ self.wait(1.5)
+
+ text14 = TextMobject(r"\text{$<2f(x), g(x)>$ = ",r"\text{$\int_{0}^{2} (2f(x))g(x)$ $dx$}",r"\text{= 3.48}").scale(0.57).shift(4*RIGHT+3.5*UP)
+ text14[1].set_color(YELLOW)
+ self.play(ShowCreation(text14))
+ self.wait(2.2)
+ curve10 = self.get_graph(lambda x : 2*sin(x)*x, x_min=0,x_max=2,color=YELLOW)
+ text15 = TextMobject(r"$2f(x)\cdot g(x)$").scale(0.5).shift(0.35*RIGHT+1.03*UP)
+ area5 = self.get_area(curve10,0,2)
+ area5.set_color(YELLOW)
+ self.play(ShowCreation(area5),ShowCreation(curve10),ShowCreation(text15),FadeOut(curve1),FadeOut(text1),FadeOut(curve2),FadeOut(text2))
+ self.wait(2)
+ text16 = TextMobject(r"\text{$<f(x), g(x)>$ = ",r"\text{$\int_{0}^{2} f(x)g(x)$ $dx$}",r"\text{= 1.74}").scale(0.57).shift(3.8*RIGHT+2.9*UP)
+ text16[1].set_color(TEAL)
+ self.play(ShowCreation(text16))
+ self.wait(1.7)
+ curve11 = self.get_graph(lambda x : sin(x)*x, x_min=0,x_max=2,color=TEAL)
+ area6 = self.get_area(curve11,0,2)
+ area6.set_color(TEAL)
+ text17 = TextMobject(r"$f(x)\cdot g(x)$").scale(0.5).shift(0.4*RIGHT+0.7*DOWN)
+ self.play(ShowCreation(curve11),ShowCreation(text17),ShowCreation(area6))
+ self.wait(2)
+
+ text18 = TextMobject(r"\text{$2 <f(x), g(x)>$ = ",r"\text{$2 \int_{0}^{2} f(x)g(x)$ $dx$}",r"\text{= 3.48}").scale(0.57).shift(4*RIGHT+2.3*UP)
+ text18[1].set_color(DARK_BLUE)
+ self.play(ShowCreation(text18))
+ self.wait(2)
+ curve12 = self.get_graph(lambda x : 2*sin(x)*x, x_min=0,x_max=2,color=DARK_BLUE)
+ area7 = self.get_area(curve12,0,2)
+ area7.set_color(DARK_BLUE)
+ text19 = TextMobject(r"= $2( f(x)\cdot g(x) )$").scale(0.5).shift(1.89*RIGHT+1.03*UP)
+ self.play(ShowCreation(curve12),ShowCreation(area7),ShowCreation(text19),FadeOut(text17),FadeOut(area6),FadeOut(curve11))
+
+ self.wait(2.5)
+ text20 = TextMobject(r"$<2f(x), g(x)>$ = $2<f(x), g(x)>$").scale(0.57).shift(0.6*DOWN+4*RIGHT)
+ rect2 = Rectangle(height=0.5)
+ rect2.surround(text20)
+ self.play(ShowCreation(text20),ShowCreation(rect2))
+ self.wait(3)
+
+ self.play(FadeOut(text14),FadeOut(text15),FadeOut(text19),FadeOut(text16),FadeOut(text18),FadeOut(rect2),FadeOut(curve10),FadeOut(area5),FadeOut(curve12),FadeOut(area7),FadeOut(text20))
+ curve1 = self.get_graph(lambda x : sin(x), x_min=0,x_max=2,color=YELLOW)
+ text1 = TextMobject(r"$f(x)$").scale(0.5).shift(1.77*DOWN)
+ self.play(ShowCreation(curve1),ShowCreation(text1))
+ self.wait(1.5)
+ self.play(ShowCreation(curve2),ShowCreation(text2))
+ self.wait(1.7)
+ text21 = TextMobject(r"\text{$<f(x), g(x)>$ = ",r"\text{$\int_{0}^{2} f(x)g(x)$ $dx$}",r"\text{= 1.74}").scale(0.57).shift(3.5*RIGHT+3*UP)
+ text21[1].set_color(GREEN)
+ self.play(ShowCreation(text21))
+ self.wait(2)
+ curve13 = self.get_graph(lambda x : sin(x)*x, x_min=0,x_max=2,color=GREEN)
+ area8 = self.get_area(curve13,0,2)
+ area8.set_color(GREEN)
+ text22 = TextMobject(r"$f(x)\cdot g(x)$").scale(0.5).shift(0.32*RIGHT+0.7*DOWN)
+ self.play(ShowCreation(curve13),ShowCreation(area8),ShowCreation(text22),FadeOut(curve1),FadeOut(text1),FadeOut(curve2),FadeOut(text2))
+ self.wait(2.2)
+ curve14 = self.get_graph(lambda x : sin(x)*x, x_min=0,x_max=2,color=RED)
+ area9 = self.get_area(curve14,0,2)
+ area9.set_color(RED)
+ self.play(ShowCreation(curve14),ShowCreation(area9))
+ text23 = TextMobject(r"= $\overline{f(x)\cdot g(x)}$").scale(0.5).shift(0.7*DOWN+1.7*RIGHT)
+ self.play(ShowCreation(text23))
+ self.wait(2)
+ text24 = TextMobject(r"For all the real functions").scale(0.5).shift(2*RIGHT+2*UP)
+ text25 = TextMobject(r"$<\overline{f(x), g(x)}>$ = $<f(x), g(x)>$").scale(0.5).shift(2*RIGHT+1.4*UP)
+ rect3 = Rectangle(height=0.7)
+ rect3.surround(text25)
+ self.play(ShowCreation(text24),ShowCreation(text25),ShowCreation(rect3))
+ self.wait(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_product.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_product.py new file mode 100644 index 0000000..e1344f7 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Inner_product.py @@ -0,0 +1,28 @@ +from manimlib.imports import *
+import numpy as np
+class InnerProduct(Scene):
+ def construct(self):
+ big_box=Rectangle().scale(2.7)
+ box = Rectangle(height=2,width=2,color=DARK_GREY).set_fill(color=BLUE_B,opacity=350)
+ arrow1 = Arrow(color=RED).shift(1.8*LEFT+0.5*UP)
+ arrow2 = Arrow(color=RED).shift(1.8*LEFT+0.5*DOWN)
+ arrow3 = Arrow(color=GREEN).shift(1.8*RIGHT)
+ Inner = TextMobject("INNER",color=BLACK).scale(0.65).shift(0.2*UP)
+ Product = TextMobject("PRODUCT",color=BLACK).scale(0.65).shift(0.2*DOWN)
+ u = TextMobject(r"$\vec{u}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*UP)
+ v = TextMobject(r"$\vec{v}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*DOWN)
+ scalar = TextMobject("(Scalar)").scale(0.55).shift(3.3*RIGHT+0.4*DOWN)
+ u.v = TextMobject(r"$<\vec{u}, \vec{v}>$",color=YELLOW).scale(0.7).shift(3.3*RIGHT)
+ V = TextMobject("V").scale(0.7).shift(2*UP+3.8*RIGHT)
+ text = TextMobject(r"The Inner Product is an operation that takes $\vec{u}, \vec{v} \in$ V as inputs and gives a scalar as an output.").scale(0.55).shift(2*DOWN)
+ self.play(ShowCreation(big_box),ShowCreation(V))
+ self.play(ShowCreation(box))
+ self.play(ShowCreation(Product),ShowCreation(Inner))
+ self.wait(2)
+ self.play(ShowCreation(arrow1),ShowCreation(u))
+ self.play(ShowCreation(arrow2),ShowCreation(v))
+ self.wait(1.5)
+ self.play(ShowCreation(arrow3),ShowCreation(scalar),ShowCreation(u.v))
+ self.wait(1)
+ self.play(ShowCreation(text))
+ self.wait(10)
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Instances_of_Topological_Spaces.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Instances_of_Topological_Spaces.py new file mode 100644 index 0000000..2b3cf14 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Instances_of_Topological_Spaces.py @@ -0,0 +1,36 @@ +from manimlib.imports import *
+class InnerProduct(Scene):
+ def construct(self):
+
+ circle1 = Circle(color=DARK_GREY).scale(3.7)
+ circle1.set_fill(color=GOLD,opacity=350)
+ square1 = Square(color=DARK_GREY).scale(2.5)
+ square1.set_fill(color=DARK_BLUE,opacity=350)
+ square2=Square(color=DARK_GREY).scale(1.6).shift(0.2*DOWN)
+ square2.rotate(np.pi/4).set_fill(color=YELLOW,opacity=350)
+ square3 = Square(color=DARK_GREY).scale(1).shift(0.3*DOWN)
+ square3.set_fill(color=BLACK,opacity=350)
+ circle2 = Circle(color=DARK_GREY).scale(0.5).shift(0.45*DOWN)
+ circle2.set_fill(color=MAROON_A,opacity=350)
+ text1 = TextMobject("Topological Spaces",color=BLACK).scale(0.5).shift(3*UP)
+ text2 = TextMobject("Metric Spaces",color=BLACK).scale(0.5).shift(2.2*UP)
+ text3 = TextMobject("Normed",color=BLACK).scale(0.44).shift(1.4*UP)
+ text4 = TextMobject("Vector Spaces",color=BLACK).scale(0.44).shift(1.17*UP)
+ text5 = TextMobject("Inner Product",color=WHITE).scale(0.37).shift(0.5*UP)
+ text6 = TextMobject("Spaces",color=WHITE).scale(0.37).shift(0.27*UP)
+ text7 = TextMobject("Dot",color=BLACK).scale(0.37).shift(0.3*DOWN)
+ text8 = TextMobject("Product",color=BLACK).scale(0.32).shift(0.5*DOWN)
+
+
+
+
+ self.play(ShowCreation(circle1),ShowCreation(text1))
+ self.wait(1.5)
+ self.play(ShowCreation(square1),ShowCreation(text2))
+ self.wait(1.5)
+ self.play(ShowCreation(square2),ShowCreation(text3),ShowCreation(text4))
+ self.wait(1.5)
+ self.play(ShowCreation(square3),ShowCreation(text5),ShowCreation(text6))
+ self.wait(1.5)
+ self.play(ShowCreation(circle2),ShowCreation(text7),ShowCreation(text8))
+ self.wait(4)
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Interpretation_of_Norm_as_Length.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Interpretation_of_Norm_as_Length.py new file mode 100644 index 0000000..23c568d --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Interpretation_of_Norm_as_Length.py @@ -0,0 +1,42 @@ +from manimlib.imports import *
+import numpy as np
+class Interpretation_of_norm_as_length(GraphScene):
+ CONFIG = {
+ "x_min" : 0,
+ "x_max" : 5,
+ "y_min" : 0,
+ "y_max" : 5,
+ "y_tick_frequency" : 1,
+ "x_tick_frequency" : 1,
+ "axes_color":LIGHT_GRAY,
+ "x_axis_width": 5,
+ "y_axis_height":5,
+ "graph_origin" : ORIGIN + 2*DOWN + 2*LEFT,
+ "enclude_zero_label": False
+
+ }
+ def construct(self):
+ self.setup_axes(animate=False)
+ dot = Dot().scale(0.5)
+ self.play(ShowCreation(dot))
+ origin = TextMobject(r"(0, 0)").scale(0.5).shift(2.5*LEFT+2.2*DOWN)
+ line1 = self.get_graph(lambda x : x, x_min=0,x_max=2,color=WHITE)
+ line2 = Line().rotate(np.pi/2).shift(1*DOWN)
+ text1 = TextMobject(r"$(v_1, 0)$").scale(0.5).shift(2.2*DOWN+0.2*RIGHT)
+ text2 = TextMobject(r"$(0, v_2)$").scale(0.5).shift(2.5*LEFT)
+ text3 = TextMobject(r"$(v_1, v_2)$").scale(0.5).shift(0.5*RIGHT)
+ text4 = TextMobject(r"$| v_1 |$",color=RED_B).scale(0.5).shift(1*LEFT+2.3*DOWN)
+ text5 = TextMobject(r"$| v_2 |$",color=RED_B).scale(0.5).shift(0.3*RIGHT+1*DOWN)
+ text6 = TextMobject(r"$\sqrt{{v_1}^2 + {v_2}^2}$",color=RED_B).scale(0.5).rotate(np.pi/4).shift(1.3*LEFT+1*DOWN)
+ line3 = Line(color=YELLOW).shift(1*LEFT+2*DOWN)
+ self.play(ShowCreation(line1),ShowCreation(line2),ShowCreation(text1),ShowCreation(text2),ShowCreation(text3),ShowCreation(origin))
+ self.wait(1.5)
+ self.play(ShowCreation(line3),ShowCreation(text4))
+ self.wait(1.5)
+ line2 = Line(color=YELLOW).rotate(np.pi/2).shift(1*DOWN)
+ self.play(ShowCreation(line2),ShowCreation(text5))
+ self.wait(1.5)
+ line1 = self.get_graph(lambda x : x, x_min=0,x_max=2,color=YELLOW)
+ self.play(ShowCreation(text6),ShowCreation(line1))
+ self.wait(4)
+
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Linearity_of_Inner_Product.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Linearity_of_Inner_Product.py new file mode 100644 index 0000000..e1344f7 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Linearity_of_Inner_Product.py @@ -0,0 +1,28 @@ +from manimlib.imports import *
+import numpy as np
+class InnerProduct(Scene):
+ def construct(self):
+ big_box=Rectangle().scale(2.7)
+ box = Rectangle(height=2,width=2,color=DARK_GREY).set_fill(color=BLUE_B,opacity=350)
+ arrow1 = Arrow(color=RED).shift(1.8*LEFT+0.5*UP)
+ arrow2 = Arrow(color=RED).shift(1.8*LEFT+0.5*DOWN)
+ arrow3 = Arrow(color=GREEN).shift(1.8*RIGHT)
+ Inner = TextMobject("INNER",color=BLACK).scale(0.65).shift(0.2*UP)
+ Product = TextMobject("PRODUCT",color=BLACK).scale(0.65).shift(0.2*DOWN)
+ u = TextMobject(r"$\vec{u}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*UP)
+ v = TextMobject(r"$\vec{v}$",color=YELLOW).scale(0.7).shift(2.8*LEFT+0.5*DOWN)
+ scalar = TextMobject("(Scalar)").scale(0.55).shift(3.3*RIGHT+0.4*DOWN)
+ u.v = TextMobject(r"$<\vec{u}, \vec{v}>$",color=YELLOW).scale(0.7).shift(3.3*RIGHT)
+ V = TextMobject("V").scale(0.7).shift(2*UP+3.8*RIGHT)
+ text = TextMobject(r"The Inner Product is an operation that takes $\vec{u}, \vec{v} \in$ V as inputs and gives a scalar as an output.").scale(0.55).shift(2*DOWN)
+ self.play(ShowCreation(big_box),ShowCreation(V))
+ self.play(ShowCreation(box))
+ self.play(ShowCreation(Product),ShowCreation(Inner))
+ self.wait(2)
+ self.play(ShowCreation(arrow1),ShowCreation(u))
+ self.play(ShowCreation(arrow2),ShowCreation(v))
+ self.wait(1.5)
+ self.play(ShowCreation(arrow3),ShowCreation(scalar),ShowCreation(u.v))
+ self.wait(1)
+ self.play(ShowCreation(text))
+ self.wait(10)
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Projection-in-3D-space.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Projection-in-3D-space.py new file mode 100644 index 0000000..e99202f --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Projection-in-3D-space.py @@ -0,0 +1,31 @@ +from manimlib.imports import *
+class ThreeDSpace(ThreeDScene):
+
+ def construct(self):
+ axes = ThreeDAxes()
+ axes.set_stroke(width=1,color=GOLD)
+ self.add(axes)
+ self.set_camera_orientation(phi = 70*DEGREES,theta =110*DEGREES)
+ line1 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [0.5,2,2])
+ self.play(ShowCreation(line1))
+ self.wait(1)
+ line2 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [2,2,-1])
+ self.play(ShowCreation(line2))
+ self.wait(1)
+ line3 = Line(opacity=350,start=axes.c2p(0.5,2,2) ,end=axes.c2p(0.5,1.14,-0.17))
+ self.play(ShowCreation(line3))
+ self.wait(1)
+ line4 = Line(color=RED,opacity=350,start = ORIGIN,end=[0.5,1.14,-0.145])
+ self.play(ShowCreation(line4))
+ self.wait(2)
+ text1 = TextMobject(r"\text{Projection on }",r"\text{$\vec{v}$}",r"\text{ onto }",r"\text{$\vec{u}$}",r"\text{ = }",r"\text{$ |\vec{v}|cos\theta$,}").scale(0.6).shift(4*LEFT+3.5*UP)
+ text1[1].set_color(YELLOW)
+ text1[3].set_color(BLUE)
+ text1[5].set_color(RED)
+ text2 = TextMobject(r"\text{where $\theta$ is the angle between the vectors.}").scale(0.6).shift(4*LEFT+3*UP)
+ self.add_fixed_in_frame_mobjects(text1)
+ self.add_fixed_in_frame_mobjects(text2)
+ self.play(ShowCreation(text1),ShowCreation(text2))
+ self.wait(3)
+
+
diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Vector_Projection.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Vector_Projection.py new file mode 100644 index 0000000..b1724c1 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/Vector_Projection.py @@ -0,0 +1,43 @@ +from manimlib.imports import *
+VECTORS = [[3,1],
+ [1,3],
+ [1.96,0.65]]
+class Projection(LinearTransformationScene):
+ CONFIG = {
+ "include_background_plane": True,
+ "include_foreground_plane": False,
+ "show_coordinates": False,
+ "show_basis_vectors": False,
+ "basis_vector_stroke_width": 3,
+ }
+ def construct(self):
+ v1 = self.add_vector(VECTORS[0],color = YELLOW, stroke_width = 3.5)
+ u = TextMobject(r"$\vec{u}$",color=YELLOW).scale(0.65).shift(3.2*RIGHT,1*UP)
+ self.play(ShowCreation(u))
+ self.wait(0.7)
+ v2 = self.add_vector(VECTORS[1],color = RED, stroke_width = 3.5)
+ v = TextMobject(r"$\vec{v}$",color=RED).scale(0.65).shift(1.2*RIGHT,3*UP)
+ self.play(ShowCreation(v))
+ self.wait(0.7)
+ angle = Arc(radius=0.6).scale(0.5)
+ theta = TextMobject(r"$\theta$").scale(0.65).shift(0.5*UP+0.5*RIGHT).rotate(np.pi/6)
+ self.play(ShowCreation(angle),ShowCreation(theta))
+ self.wait(1)
+ line1 = Line().scale(1.25).rotate(np.pi/(2)).shift(1.8*UP+1.47*RIGHT)
+ line1.rotate(np.pi/8)
+ self.play(ShowCreation(line1))
+ self.wait(1.3)
+ v3 = self.add_vector(VECTORS[2],color = BLUE, stroke_width = 3.5)
+ text1 = TextMobject(r"$\vec{v}$cos$\theta$",color=BLUE).scale(0.55).shift(1.25*RIGHT+0.26*UP).rotate(np.pi/9)
+ self.play(ShowCreation(text1))
+ self.wait(2)
+ text2 = TextMobject(r"\text{Projection on }",r"\text{$\vec{v}$}",r"\text{ onto }",r"\text{$\vec{u}$}",r"\text{ = }",r"\text{$ |\vec{v}|cos\theta$}").scale(0.6).shift(4*RIGHT+3*UP)
+ text2[1].set_color(RED)
+ text2[3].set_color(YELLOW)
+ text2[5].set_color(BLUE)
+ text2.add_background_rectangle()
+ self.play(ShowCreation(text2))
+ self.wait(4)
+
+
+
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Conjugate_Symmetry_and_Positivity_of_Inner_Product.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Conjugate_Symmetry_and_Positivity_of_Inner_Product.mp4 Binary files differnew file mode 100644 index 0000000..6b44c55 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Conjugate_Symmetry_and_Positivity_of_Inner_Product.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/InnerProduct.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/InnerProduct.gif Binary files differnew file mode 100644 index 0000000..55b6546 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/InnerProduct.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Inner_Product_Space_Example.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Inner_Product_Space_Example.mp4 Binary files differnew file mode 100644 index 0000000..edecd88 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Inner_Product_Space_Example.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Instances_of_Topological_Spaces.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Instances_of_Topological_Spaces.gif Binary files differnew file mode 100644 index 0000000..82d5c75 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Instances_of_Topological_Spaces.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Interpretation_of_norm_as_length.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Interpretation_of_norm_as_length.gif Binary files differnew file mode 100644 index 0000000..9eda7c5 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Interpretation_of_norm_as_length.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Linerity_of_Inner_Product.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Linerity_of_Inner_Product.mp4 Binary files differnew file mode 100644 index 0000000..a1e7b29 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Linerity_of_Inner_Product.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection.gif b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection.gif Binary files differnew file mode 100644 index 0000000..c32fd6b --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection.gif diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection_of_vectors_in-3D_plane.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection_of_vectors_in-3D_plane.mp4 Binary files differnew file mode 100644 index 0000000..bdca5f9 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Inner-Product_Spaces/gifs2/Projection_of_vectors_in-3D_plane.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Basis of a Vector Space and its Subspace.docx b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Basis of a Vector Space and its Subspace.docx Binary files differnew file mode 100644 index 0000000..0dbfc4f --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Basis of a Vector Space and its Subspace.docx diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Dual of a Space MCQ Questions.docx b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Dual of a Space MCQ Questions.docx Binary files differnew file mode 100644 index 0000000..1731a8f --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Dual of a Space MCQ Questions.docx diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Inner Product Space MCQ Questions.docx b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Inner Product Space MCQ Questions.docx Binary files differnew file mode 100644 index 0000000..80ee81c --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Inner Product Space MCQ Questions.docx diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Polynomial and Function Spaces MCQ Questions.docx b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Polynomial and Function Spaces MCQ Questions.docx Binary files differnew file mode 100644 index 0000000..7904fd1 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Polynomial and Function Spaces MCQ Questions.docx diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Vector Spaces MCQ Questions.docx b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Vector Spaces MCQ Questions.docx Binary files differnew file mode 100644 index 0000000..338b6f3 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/MCQ/Vector Spaces MCQ Questions.docx diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Basis.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Basis.py new file mode 100644 index 0000000..6d2edc8 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Basis.py @@ -0,0 +1,174 @@ +from manimlib.imports import *
+
+
+VECTORS = [[1, 2],
+ [-4, 2],
+ [-3, -3],
+ [3,-2],
+ [3,3],
+ [-2,1],
+ [-1,-3]]
+
+class Scene1(LinearTransformationScene):
+
+ CONFIG = {
+ "include_background_plane": True,
+ "include_foreground_plane": False,
+ "show_coordinates": False,
+ "show_basis_vectors": True,
+ "basis_vector_stroke_width": 3,
+
+ }
+ def construct(self):
+ self.setup()
+ ihat, jhat = self.get_basis_vectors()
+ labels = self.get_basis_vector_labels()
+ self.add(ihat, jhat)
+ self.add(*labels)
+
+ self.show_vector_as_basis_sum()
+ self.wait(2)
+
+ def show_vector_as_basis_sum(self):
+ text1 = TextMobject(r"Vector Space $\mathbb{R}^2$}").scale(0.8).shift(3*UP)
+ text1.add_background_rectangle()
+ self.play(ShowCreation(text1))
+ text2 = TextMobject(r"$\mathbb{R}^2$",color=BLUE_E).scale(0.8).shift(6.5*LEFT+3.5*UP)
+ text3 = TextMobject(r"\text{Basis Vectors:}",r"\text{$\hat{i}$}",r"\text{,}",r"\text{$\hat{j}$}").scale(0.7).shift(2*UP+2.5*RIGHT)
+ text3[1].set_color(GREEN_C)
+ text3[3].set_color(RED_C)
+
+ self.wait(2)
+ self.play(Transform(text1,text2))
+ self.wait(1)
+ self.play(ShowCreation(text3))
+ self.wait(1.7)
+ self.play(FadeOut(text3))
+
+ for i in range(len(VECTORS)):
+ v = self.add_vector(VECTORS[i], stroke_width = 3,color=YELLOW_D)
+
+ linei = Line(start = ORIGIN, end = VECTORS[i][0]*RIGHT)
+ linei.set_color(GREEN_C)
+ linej = Line(start = linei.get_end(),
+ end = linei.get_end() + VECTORS[i][1]*UP)
+ linej.set_color(RED_C)
+ self.play(ShowCreation(linei))
+ self.play(ShowCreation(linej))
+ vlabel = self.get_vector_label(v, str(VECTORS[i][0]) +
+ r"\imath" + "+" +
+ str(VECTORS[i][1]) +
+ r"\jmath", at_tip = True)
+ self.play(ShowCreation(vlabel))
+
+ self.play(FadeOut(linei),FadeOut(linej))
+ self.wait(1)
+ dot = Dot(v.get_end(), fill_color = v.get_stroke_color())
+ self.play(ShowCreation(dot),FadeOut(v),FadeOut(vlabel))
+ self.wait(0.3)
+
+class Scene2(LinearTransformationScene):
+ CONFIG = {
+ "num_vectors" : 16,
+ "start_color" : GREY,
+ "end_color" : YELLOW_D,
+ "include_background_plane": True,
+ "include_foreground_plane": False,
+ }
+
+ def get_vectors(self):
+ return [
+ Vector([x, y], stroke_width = 3.5)
+ for x in np.arange(-int(FRAME_X_RADIUS), int(FRAME_X_RADIUS)+0.5, 0.5)
+ for y in np.arange(-int(FRAME_Y_RADIUS), int(FRAME_Y_RADIUS)+0.5, 0.5)
+ ]
+
+ def lock_in_faded_grid(self, dimness=0.7, axes_dimness=0.5):
+ plane = self.add_plane()
+ axes = plane.get_axes()
+ plane.fade(dimness)
+ axes.set_color(WHITE)
+ axes.fade(axes_dimness)
+ self.add(axes)
+
+ def construct(self):
+ self.lock_in_faded_grid()
+
+ vectors = self.get_vectors()
+ colors = Color(self.start_color).range_to(
+ self.end_color, len(vectors)
+ )
+ for vect, color in zip(vectors, colors):
+ vect.set_color(color)
+
+ vector_group = VGroup(*vectors)
+ self.play(
+ ShowCreation(
+ vector_group,
+ run_time = 3
+ )
+ )
+
+ self.wait(1)
+
+ vectors.sort(key=lambda v: v.get_length())
+ def v_to_dot(vector):
+ return Dot(vector.get_end(), fill_color = vector.get_stroke_color())
+ self.wait()
+ rate_functions = [
+ squish_rate_func(smooth, float(x)/(len(vectors)+2), 1)
+ for x in range(len(vectors))
+ ]
+ self.play(*[
+ Transform(v, v_to_dot(v), rate_func = rf, run_time = 3)
+ for v, rf in zip(vectors, rate_functions)
+ ])
+ self.wait(2)
+ self.play_final_animation(vectors, rate_functions)
+ self.wait(2)
+
+ text1 = TextMobject(" Basis is the minimum information required to ").shift(3.1*UP).scale(0.8)
+ text2 = TextMobject("generate the whole space.").scale(0.8).shift(2.6*UP)
+
+ text1.add_background_rectangle()
+ text2.add_background_rectangle()
+
+
+
+ self.play(ShowCreation(text1),ShowCreation(text2))
+
+ self.play(ShowCreation(self.get_basis_vectors()))
+ self.wait(3)
+
+ def play_final_animation(self, vectors, rate_functions):
+
+ h_line = Line(
+ FRAME_X_RADIUS*RIGHT, FRAME_X_RADIUS*LEFT,
+ stroke_width = 0.5,
+ color = BLUE_E
+ )
+ v_line = Line(
+ FRAME_Y_RADIUS*UP, FRAME_Y_RADIUS*DOWN,
+ stroke_width = 0.5,
+ color = BLUE_E
+ )
+ line_pairs = [
+ VGroup(h_line.copy().shift(y), v_line.copy().shift(x))
+ for v in vectors
+ for x, y, z in [v.get_center()]
+ ]
+ plane = NumberPlane()
+
+ self.play(
+ ShowCreation(plane),
+ *[
+ Transform(v, p, rate_func = rf)
+ for v, p, rf in zip(vectors, line_pairs, rate_functions)
+ ]
+ )
+ self.remove(*vectors)
+
+
+
+
+
\ No newline at end of file diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Intersection_of_Subspaces.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Intersection_of_Subspaces.py new file mode 100644 index 0000000..ec82daa --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Intersection_of_Subspaces.py @@ -0,0 +1,52 @@ +from manimlib.imports import *
+class ThreeDSpace(ThreeDScene):
+
+
+ def construct(self):
+ axes = ThreeDAxes()
+ self.set_camera_orientation(phi = 80*DEGREES,theta =110*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.09)
+
+
+
+
+ cube = Cube(stroke_width=5,color=WHITE).shift([1.5,1.5,1.5]).scale(1.5)
+ cube.set_fill(TEAL)
+
+ cube.set_opacity(0.4)
+
+
+ plane1 = Polygon([0,0,3],[3,0,3],[3,3,0],[0,3,0])
+ plane1.set_opacity(0.65)
+ plane1.set_fill(PURPLE)
+ plane1.set_color(PURPLE)
+
+
+ plane2 = Polygon([0,3,3],[3,3,3],[3,0,0],[0,0,0])
+ plane2.set_opacity(0.7)
+ plane2.set_fill(RED)
+ plane2.set_color(RED)
+ line = Line(color=YELLOW,set_opacity=100).shift([1.5,1.5,1.5]).scale(1.5)
+
+ vgroup = VGroup(plane1,plane2,line,cube)
+ vgroup.shift([-1,-1,-1])
+
+ dot = Dot(color=BLACK).shift([0.5,0.5,0.5]).scale(1)
+ text = TextMobject(r"\text{The}",r"\text{line}",r"\text{representing the intersection of the two planes is a Subspace.}",opacity = 0.6).scale(0.7).shift(3*UP)
+ text[1].set_color(YELLOW)
+ self.add_fixed_in_frame_mobjects(text)
+ self.play(ShowCreation(text))
+
+
+ self.play(ShowCreation(cube))
+ self.play(ShowCreation(plane1))
+ self.play(ShowCreation(plane2))
+
+ self.play(ShowCreation(line),ShowCreation(dot))
+
+
+ self.wait(15)
+
+
+
+
\ No newline at end of file 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_Non_Example.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Subspace_Non_Example.py new file mode 100644 index 0000000..115a722 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/Subspace_Non_Example.py @@ -0,0 +1,25 @@ +from manimlib.imports import *
+class ThreeDSpace(ThreeDScene):
+
+
+ def construct(self):
+ axes = ThreeDAxes()
+ self.add(axes)
+ self.set_camera_orientation(phi = 80*DEGREES,theta =110*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.09)
+ plane1 = Polygon([-1.5,1.5,-1.5],[1.5,1.5,-1.5],[1.5,-1.5,1.5],[-1.5,-1.5,1.5])
+ plane1.set_opacity(0.65)
+ plane1.set_fill(GREEN)
+ plane1.set_color(GREEN)
+
+
+ plane2 = Polygon([-1.5,1.5,1.5],[1.5,1.5,1.5],[1.5,-1.5,-1.5],[-1.5,-1.5,-1.5])
+ plane2.set_opacity(0.7)
+ plane2.set_fill(MAROON_A)
+ plane2.set_color(MAROON_A)
+ line = Line(color=YELLOW,set_opacity=100,start=[1.5,1.2,1.2],end=[-1.5,1.2,1.2])
+
+
+ self.play(ShowCreation(plane1),ShowCreation(plane2),ShowCreation(line))
+ self.wait(10)
+
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/Basis_generating_the_whole_2D_space.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Basis_generating_the_whole_2D_space.mp4 Binary files differnew file mode 100644 index 0000000..9a43846 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Basis_generating_the_whole_2D_space.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Intersection_of_Subspaces.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Intersection_of_Subspaces.mp4 Binary files differnew file mode 100644 index 0000000..d43bfbe --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Intersection_of_Subspaces.mp4 diff --git a/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Linear-Dependence-and-Independence.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Linear-Dependence-and-Independence.mp4 Binary files differnew file mode 100644 index 0000000..c44801f --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Linear-Dependence-and-Independence.mp4 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_Non_Example.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Subspace_Non_Example.mp4 Binary files differnew file mode 100644 index 0000000..390f4cf --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/gifs/Subspace_Non_Example.mp4 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/Subspaces/linear_dependence_and_independence.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/linear_dependence_and_independence.py new file mode 100644 index 0000000..b092777 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Subspaces/linear_dependence_and_independence.py @@ -0,0 +1,293 @@ +from manimlib.imports import *
+class Linear_Dependence(ThreeDScene):
+
+ def construct(self):
+
+ axes = ThreeDAxes()
+ axes.set_stroke(width=1,color=GOLD)
+ self.add(axes)
+ self.set_camera_orientation(phi = 70*DEGREES,theta =110*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.05)
+ self.wait(0.5)
+ text1 = TextMobject(r"Consider 3 linearly dependent vectors in $\mathbb{R}^3$").scale(0.5).shift(2.5*UP+4*LEFT)
+ line1 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-1,1,1])
+ self.add_fixed_in_frame_mobjects(text1)
+ self.play(ShowCreation(text1))
+ self.play(ShowCreation(line1))
+ self.wait(1)
+ line2 = Line(color = RED,opacity=350,start = ORIGIN,end = [1,0.5,0.5])
+ self.play(ShowCreation(line2))
+ self.wait(1)
+ line3 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0.5,1,1])
+ self.play(ShowCreation(line3))
+ self.wait(1)
+ text2 = TextMobject("Scaling the Vectors").scale(0.5).shift(2.5*UP+4.5*LEFT)
+ text3 = TextMobject(r"\text{and}",r"\text{Adding}",r"\text{them}").scale(0.5).shift(2*UP+4.5*LEFT)
+ text3[1].set_color(GREEN)
+
+
+ line4 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-2,2,2])
+ line5 = Line(color = RED,opacity = 350,start = ORIGIN,end = [3,1.5,1.5])
+ line6 = Line(color = BLUE,opacity = 350,start = ORIGIN,end = [-0.5,-1,-1])
+ self.wait(1.1)
+ self.play(FadeOut(text1))
+ self.add_fixed_in_frame_mobjects(text2)
+ self.play(ShowCreation(text2))
+ self.wait(0.7)
+ self.play(Transform(line1,line4))
+ self.wait(0.5)
+ self.play(Transform(line2,line5))
+ self.wait(0.5)
+ self.play(Transform(line3,line6))
+
+ self.wait(1.5)
+
+ line7 = Line(color = RED,opacity = 350,start = [-2,2,2],end = [1,3.5,3.5])
+ line8 = Line(color = BLUE,opacity = 350,start = [1,3.5,3.5],end = [0.5,2.5,2.5])
+ line9 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0.5,2.5,2.5])
+
+ self.add_fixed_in_frame_mobjects(text3)
+ self.play(ShowCreation(text3))
+ self.wait(0.7)
+ self.play(FadeOut(line2),ShowCreation(line7))
+ self.play(FadeOut(line3),ShowCreation(line8))
+ self.wait(0.7)
+ self.play(ShowCreation(line9))
+ self.wait(1.2)
+
+
+ plane = Polygon([-4,4,4],[4,4,4],[4,-4,-4],[-4,-4,-4])
+ plane.set_opacity(0.4)
+ plane.set_fill(DARK_BLUE)
+ plane.set_color(DARK_BLUE)
+ self.play(ShowCreation(plane))
+ self.wait(1.2)
+ text4 = TextMobject("Linearly Combinations").scale(0.65).shift(3.5*UP+4*RIGHT)
+
+ text5 = TextMobject(r"\text{$\vec{z_1}$}",r"\text{=}",r"\text{2}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{3}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-1)}",r"\text{$\vec{w}$}",).scale(0.55).shift(2.5*UP+3.9*RIGHT)
+ text5[0].set_color(GREEN)
+ text5[3].set_color(YELLOW)
+ text5[6].set_color(RED)
+ text5[9].set_color(BLUE)
+ self.add_fixed_in_frame_mobjects(text5)
+ self.add_fixed_in_frame_mobjects(text4)
+ self.play(ShowCreation(text4),ShowCreation(text5))
+ self.wait(3.8)
+ bunch1 = VGroup(line7,line8,line9)
+ line10 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-0.5,0.5,0.5])
+ line11 = Line(color=RED,opacity=350,start=ORIGIN,end=[2,1,1])
+ line12 = Line(color = BLUE,opacity = 350,start = ORIGIN,end = [-1.5,-3,-3])
+ line13 = Line(color = RED,opacity = 350,start = [-0.5,0.5,0.5],end = [1.5,1.5,1.5])
+ line14 = Line(color = BLUE,opacity = 350,start = [1.5,1.5,1.5],end = [0,-1.5,-1.5])
+ line15 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0,-1.5,-1.5])
+ bunch2 = VGroup(line13,line14,line15,line10)
+ self.play(FadeOut(line1),Transform(bunch1,bunch2))
+ self.wait(1.2)
+ text6 = TextMobject(r"\text{$\vec{z_2}$}",r"\text{=}",r"\text{0.5}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-3)}",r"\text{$\vec{w}$}",).scale(0.55).shift(2*UP+4*RIGHT)
+ text6[0].set_color(GREEN)
+ text6[3].set_color(YELLOW)
+ text6[6].set_color(RED)
+ text6[9].set_color(BLUE)
+
+ self.add_fixed_in_frame_mobjects(text6)
+ self.play(ShowCreation(text6))
+ self.wait(2.8)
+ bunch3 = VGroup(line10,bunch1)
+
+ line16 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-2,2,2])
+ line17 = Line(color=RED,opacity=350,start=ORIGIN,end=[1,0.5,0.5])
+
+ line18 = Line(color = RED,opacity = 350,start = [-2,2,2],end = [-1,2.5,2.5])
+
+ line19 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [-1,2.5,2.5])
+ bunch4 = VGroup(line16,line18,line19)
+ self.play(Transform(bunch3,bunch4))
+ self.wait(1.2)
+ text7 = TextMobject(r"\text{$\vec{z_3}$}",r"\text{=}",r"\text{(-2)}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(0)}",r"\text{$\vec{w}$}",).scale(0.55).shift(1.5*UP+4*RIGHT)
+ text7[0].set_color(GREEN)
+ text7[3].set_color(YELLOW)
+ text7[6].set_color(RED)
+ text7[9].set_color(BLUE)
+ self.add_fixed_in_frame_mobjects(text7)
+ self.play(ShowCreation(text7))
+
+ self.wait(5)
+ self.play(FadeOut(text2),FadeOut(text3))
+ text8 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}",).scale(0.55).shift(0.8*UP+4*RIGHT)
+ text8[0].set_color(GREEN)
+ text8[3].set_color(YELLOW)
+ text8[6].set_color(RED)
+ text8[9].set_color(BLUE)
+ rect1 = Rectangle(height=0.7,stroke_width=1.2)
+ rect1.surround(text8)
+ self.add_fixed_in_frame_mobjects(rect1)
+ self.add_fixed_in_frame_mobjects(text8)
+ self.play(ShowCreation(text8))
+ text9 = TextMobject(r"\text{All the}",r"\text{linear combinations}",r"\text{of linearly dependent vectors}",r"\text{$\vec{u},$}",r"\text{$\vec{v},$}",r"\text{and}",r"\text{$\vec{w}$}",r"\text{spans}").scale(0.5).shift(2.5*DOWN)
+ text9[1].set_color(GREEN)
+ text9[3].set_color(YELLOW)
+ text9[4].set_color(RED)
+ text9[6].set_color(BLUE)
+ text9.add_background_rectangle()
+ text10 = TextMobject(r"this entire plane (and not the entire $\mathbb{R}^3 )$.").scale(0.5).shift(3*DOWN)
+ text10.add_background_rectangle()
+ self.wait(2)
+ self.add_fixed_in_frame_mobjects(text10)
+
+ self.add_fixed_in_frame_mobjects(text9)
+ self.play(ShowCreation(text9),ShowCreation(text10))
+ self.wait(7)
+
+class Linear_Independence(ThreeDScene):
+
+ def construct(self):
+
+ axes = ThreeDAxes()
+ axes.set_stroke(width=1,color=GOLD)
+ self.add(axes)
+ self.set_camera_orientation(phi = 70*DEGREES,theta =110*DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.1)
+ self.wait(0.5)
+ text1 = TextMobject(r"Consider 3 linearly independent vectors in $\mathbb{R}^3$").scale(0.5).shift(2.5*UP+4*LEFT)
+ self.add_fixed_in_frame_mobjects(text1)
+ self.play(ShowCreation(text1))
+ line1 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-1,1,1])
+ self.play(ShowCreation(line1))
+ self.wait(0.7)
+ line2 = Line(color = RED,opacity=350,start = ORIGIN,end = [1,0.5,0.5])
+ self.play(ShowCreation(line2))
+ self.wait(0.7)
+ line3 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0,-1,-2])
+ self.play(ShowCreation(line3))
+ self.wait(0.7)
+
+ self.wait(1)
+ self.play(FadeOut(text1))
+ text2 = TextMobject("Scaling the Vectors").scale(0.5).shift(2.5*UP+5*LEFT)
+ self.add_fixed_in_frame_mobjects(text2)
+ self.play(ShowCreation(text2))
+ self.wait(0.7)
+ line4 = Line(color = YELLOW,opacity=350,start = ORIGIN,end = [-0.5,0.5,0.5])
+ self.play(Transform(line1,line4))
+ self.wait(0.7)
+ line5 = Line(color = RED,opacity=350,start = ORIGIN,end = [2,1,1])
+ self.play(Transform(line2,line5))
+ self.wait(0.7)
+ line6 = Line(color = BLUE,opacity=350,start = ORIGIN,end = [0,-1.5,-3])
+ self.play(Transform(line3,line6))
+ self.wait(1.7)
+ text3 = TextMobject(r"\text{and}",r"\text{Adding}",r"\text{them}").scale(0.5).shift(2*UP+5*LEFT)
+ text3[1].set_color(GREEN)
+
+ line7 = Line(color = RED,opacity = 350,start = [-0.5,0.5,0.5],end = [1.5,1.5,1.5])
+ line8 = Line(color = BLUE,opacity = 350,start = [1.5,1.5,1.5],end = [1.5,0,-1.5])
+ line9 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [1.5,0,-1.5])
+ self.add_fixed_in_frame_mobjects(text3)
+ self.play(ShowCreation(text3))
+ self.wait(0.7)
+ self.play(FadeOut(line2),ShowCreation(line7))
+ self.play(FadeOut(line3),ShowCreation(line8))
+ self.wait(0.7)
+ self.play(ShowCreation(line9))
+ self.wait(1.5)
+ plane = Polygon([-4,4,4],[4,4,4],[4,-4,-4],[-4,-4,-4])
+ plane.set_opacity(0.3)
+ plane.set_fill(DARK_BLUE)
+ plane.set_color(DARK_BLUE)
+ self.play(ShowCreation(plane))
+ self.wait(1.2)
+ text4 = TextMobject("Linearly Combinations").scale(0.65).shift(3.5*UP+4*RIGHT)
+ self.add_fixed_in_frame_mobjects(text4)
+ self.play(ShowCreation(text4))
+ self.wait(0.7)
+ text5 = TextMobject(r"\text{$\vec{z_1}$}",r"\text{=}",r"\text{0.5}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{2}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{1.5}",r"\text{$\vec{w}$}").scale(0.55).shift(2.5*UP+3.8*RIGHT)
+ text5[0].set_color(GREEN)
+ text5[3].set_color(YELLOW)
+ text5[6].set_color(RED)
+ text5[9].set_color(BLUE)
+ self.add_fixed_in_frame_mobjects(text5)
+
+ self.play(ShowCreation(text5))
+ self.wait(3.8)
+ bunch1 = VGroup(line7,line8,line9)
+ line10 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[-3,3,3])
+
+ line11 = Line(color = BLUE,opacity = 350,start = [-3,3,3],end = [-2,3.5,3.5])
+
+
+ line12 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [-2,3.5,3.5])
+ bunch2 = VGroup(line10,line11,line12)
+ self.play(FadeOut(line1),Transform(bunch1,bunch2))
+ self.wait(1.2)
+
+ text6 = TextMobject(r"\text{$\vec{z_2}$}",r"\text{=}",r"\text{3}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{1}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{0}",r"\text{$\vec{w}$}").scale(0.55).shift(2*UP+3.6*RIGHT)
+ text6[0].set_color(GREEN)
+ text6[3].set_color(YELLOW)
+ text6[6].set_color(RED)
+ text6[9].set_color(BLUE)
+
+ self.add_fixed_in_frame_mobjects(text6)
+ self.play(ShowCreation(text6))
+ self.wait(2.8)
+ bunch3 = VGroup(line10,bunch1)
+
+ line13 = Line(color=YELLOW,opacity=350,start=ORIGIN,end=[2.5,-2.5,-2.5])
+ line14 = Line(color=RED,opacity=350,start=[2.5,-2.5,-2.5],end=[0.5,-3.5,-3.5])
+
+ line15 = Line(color = BLUE,opacity = 350,start = [0.5,-3.5,-3.5],end = [0.5,-0.5,2.5])
+
+ line16 = Line(color = GREEN,opacity = 350,start = ORIGIN,end = [0.5,-0.5,2.5])
+ bunch4 = VGroup(line13,line14,line15,line16)
+ self.play(Transform(bunch3,bunch4))
+ self.wait(1.2)
+ text7 = TextMobject(r"\text{$\vec{z_3}$}",r"\text{=}",r"\text{(-2.5)}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{(-2)}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{(-3)}",r"\text{$\vec{w}$}").scale(0.55).shift(1.5*UP+4.2*RIGHT)
+ text7[0].set_color(GREEN)
+ text7[3].set_color(YELLOW)
+ text7[6].set_color(RED)
+ text7[9].set_color(BLUE)
+ self.add_fixed_in_frame_mobjects(text7)
+ self.play(ShowCreation(text7))
+ self.play(FadeOut(text3),FadeOut(text2))
+ self.wait(1.2)
+ text8 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}").scale(0.55).shift(0.8*UP+3.6*RIGHT)
+ text8[0].set_color(GREEN)
+ text8[3].set_color(YELLOW)
+ text8[6].set_color(RED)
+ text8[9].set_color(BLUE)
+ rect1 = Rectangle(height=0.7,stroke_width=1.2)
+ rect1.surround(text8)
+ self.add_fixed_in_frame_mobjects(rect1)
+ self.add_fixed_in_frame_mobjects(text8)
+ self.play(ShowCreation(text8))
+ self.wait(1.7)
+ self.play(FadeOut(plane))
+ self.wait(1.5)
+ text9 = TextMobject(r"\text{All the}",r"\text{linear combinations}",r"\text{of linearly independent vectors}",r"\text{$\vec{u},$}",r"\text{$\vec{v},$}",r"\text{and}",r"\text{$\vec{w}$}",r"\text{spans}").scale(0.5).shift(2.5*DOWN)
+ text9[1].set_color(GREEN)
+ text9[3].set_color(YELLOW)
+ text9[4].set_color(RED)
+ text9[6].set_color(BLUE)
+ text9.add_background_rectangle()
+ text10 = TextMobject("not only the plane but the entire 3-D space.").scale(0.5).shift(3*DOWN)
+ text10.add_background_rectangle()
+ self.add_fixed_in_frame_mobjects(text9)
+
+ self.add_fixed_in_frame_mobjects(text10)
+ self.play(ShowCreation(text9),ShowCreation(text10))
+ self.wait(2.3)
+
+ self.play(FadeOut(text5),FadeOut(text6),FadeOut(text7))
+ self.wait(0.6)
+ text9 = TextMobject(r"\text{$\vec{z}$}",r"\text{=}",r"\text{a}",r"\text{$\vec{u}$}",r"\text{+}",r"\text{b}",r"\text{$\vec{v}$}",r"\text{+}",r"\text{c}",r"\text{$\vec{w}$}",r"\text{= 0}").scale(0.55).shift(2.6*UP+3.9*RIGHT)
+ text9[0].set_color(GREEN)
+ text9[3].set_color(YELLOW)
+ text9[6].set_color(RED)
+ text9[9].set_color(BLUE)
+ text10 = TextMobject("only when a = b = c = 0.").scale(0.55).shift(2.2*UP+3.9*RIGHT)
+ self.play(FadeOut(text8),FadeOut(rect1))
+ self.wait(0.7)
+ self.add_fixed_in_frame_mobjects(text9)
+ self.add_fixed_in_frame_mobjects(text10)
+
+ self.play(ShowCreation(text9),ShowCreation(text10))
+ self.wait(5)
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_Scalar_Multiplication.py b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scalar_Multiplication.py new file mode 100644 index 0000000..12c9bce --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/Vector_Addition_and_Scalar_Multiplication.py @@ -0,0 +1,177 @@ +from manimlib.imports import *
+VECTORS = [[1, 2],
+ [1, 1],
+ [2, 2],
+ [3, 4]]
+class Scene1(LinearTransformationScene):
+ CONFIG = {
+ "include_background_plane": True,
+ "include_foreground_plane": False,
+ "show_coordinates": True,
+ "show_basis_vectors": False,
+ "basis_vector_stroke_width": 3,
+ }
+ def construct(self):
+ self.write_stuff()
+ v1 = self.add_vector(VECTORS[0],color = YELLOW, stroke_width = 3.5)
+ line1 = Line(start = ORIGIN, end = VECTORS[0][0]*RIGHT)
+ line1.set_color(RED_B)
+ line2 = Line(start = line1.get_end(), end = line1.get_end() + VECTORS[0][1]*UP)
+ line2.set_color(GREEN_D)
+ self.play(ShowCreation(line1))
+ self.play(ShowCreation(line2))
+ self.wait(0.5)
+ text1 = TextMobject("(1, 2)",color=YELLOW).scale(0.6).shift(2*UP + 1.5*RIGHT)
+ self.play(ShowCreation(text1))
+ text2 = TextMobject(r"$\vec{a}$",color = YELLOW).scale(0.8).shift(2*UP + 1.2*RIGHT)
+ text3 = TextMobject(r"\text{$\vec{a}$}",r"\text{=}",r"\text{(1, 2)}").scale(0.7).shift(5.1*LEFT + 2.5*UP)
+ text3[0].set_color(YELLOW)
+ text3[2].set_color(YELLOW)
+ self.wait(1)
+ self.play(Transform(text1,text2),FadeOut(line1),FadeOut(line2))
+ self.wait(0.5)
+ self.play(ShowCreation(text3))
+ self.wait(1)
+
+
+ v2 = self.add_vector(VECTORS[1],color = BLUE, stroke_width = 3.5)
+ line3 = Line(start = ORIGIN, end = VECTORS[1][0]*RIGHT)
+ line3.set_color(RED_B)
+ line4 = Line(start = line3.get_end(), end = line3.get_end() + VECTORS[1][1]*UP)
+ line4.set_color(GREEN_D)
+ self.play(ShowCreation(line3))
+ self.play(ShowCreation(line4))
+ self.wait(0.5)
+ text4 = TextMobject("(2, 2)",color=BLUE).scale(0.6).shift(1*UP + 1.5*RIGHT)
+ self.play(ShowCreation(text4))
+ text5 = TextMobject(r"$\vec{b}$",color = BLUE).scale(0.8).shift(1*UP + 1.2*RIGHT)
+ text6 = TextMobject(r"\text{$\vec{b}$}",r"\text{=}",r"\text{(1, 1)}").scale(0.7).shift(5.1*LEFT + 1.8*UP)
+ text6[0].set_color(BLUE)
+ text6[2].set_color(BLUE)
+ self.wait(1)
+ self.play(Transform(text4,text5),FadeOut(line3),FadeOut(line4))
+ self.wait(0.5)
+ self.play(ShowCreation(text6))
+ self.wait(2)
+
+
+
+ text7 = TextMobject(r"\text{Scaling}",r"\text{ $\vec{b}$ }",r"\text{by 2 units}",color = GOLD).scale(0.7).shift(2.8*UP+4*RIGHT)
+ text7[1].set_color(BLUE)
+ self.play(ShowCreation(text7))
+ self.play(FadeOut(text4))
+ v3 = self.add_vector(VECTORS[2],color = BLUE, stroke_width = 3.5)
+ line7 = Line(start = ORIGIN, end = VECTORS[2][0]*RIGHT)
+ line7.set_color(RED_B)
+ line8 = Line(start = line7.get_end(), end = line7.get_end() + VECTORS[2][1]*UP)
+ line8.set_color(GREEN_D)
+ self.play(FadeOut(v2))
+ self.play(ShowCreation(line7))
+ self.play(ShowCreation(line8))
+
+
+ self.wait(0.5)
+
+ text8 = TextMobject("(2, 2)",color=BLUE).scale(0.6).shift(2.5*RIGHT + 2*UP)
+ text9 = TextMobject(r"$2\vec{b}$",color = BLUE).scale(0.8).shift(2*UP + 2.3*RIGHT)
+ self.play(ShowCreation(text8))
+ self.wait(1)
+ self.play(Transform(text8,text9),FadeOut(line7),FadeOut(line8))
+ self.wait(1)
+ text10 = TextMobject(r"\text{$2\vec{b}$}",r"\text{=}",r"\text{(2, 2)}").scale(0.7).shift(5.1*LEFT + 1.8*UP)
+ text10[0].set_color(BLUE)
+ text10[2].set_color(BLUE)
+ self.play(Transform(text6,text10))
+ self.wait(1)
+ self.play(FadeOut(text7))
+ self.wait(1.5)
+
+
+
+ text11 = TextMobject(r"Addition of vectors",color = GOLD).scale(0.7).shift(2.8*UP+5*RIGHT)
+ self.play(ShowCreation(text11))
+ v1.move_to(3*UP+2.5*RIGHT)
+ self.play(ShowCreation(v1),FadeOut(text8),FadeOut(text1))
+ v4 = self.add_vector(VECTORS[3],color = ORANGE, stroke_width = 3.5)
+ line7 = Line(start = ORIGIN, end = VECTORS[3][0]*RIGHT)
+ line7.set_color(RED_B)
+ line8 = Line(start = line7.get_end(), end = line7.get_end() + VECTORS[3][1]*UP)
+ line8.set_color(GREEN_D)
+ self.play(ShowCreation(line7))
+ self.play(ShowCreation(line8))
+ text12 = TextMobject("(3, 4)",color=ORANGE).scale(0.6).shift(3.5*RIGHT + 3.8*UP)
+ text13 = TextMobject(r"$\vec{c}$",color = ORANGE).scale(0.8).shift(3.7*UP + 3.3*RIGHT)
+ self.play(ShowCreation(text12))
+ self.wait(1)
+ self.play(Transform(text12,text13),FadeOut(line7),FadeOut(line8))
+ self.wait(1)
+ add = TextMobject("+").scale(0.8).shift(6.2*LEFT + 1.8*UP)
+ line_1= Line().shift(1.5*UP+5.1*LEFT).scale(1.5)
+ line_2= Line().shift(0.8*UP+5.1*LEFT).scale(1.5)
+
+ text14=TextMobject(r"\text{$\vec{c}$}",r"\text{=}",r"\text{$\vec{a}$}",r"\text{+}",r"\text{$2\vec{b}$}",r"\text{=}",r"\text{(3, 4)}").scale(0.7).shift(1.2*UP+5.1*LEFT)
+ text14[0].set_color(ORANGE)
+ text14[2].set_color(YELLOW)
+ text14[4].set_color(BLUE)
+ text14[6].set_color(ORANGE)
+
+
+ self.play(ShowCreation(add),ShowCreation(line_1))
+ self.play(ShowCreation(text14),ShowCreation(line_2))
+ self.wait(3)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ def write_stuff(self):
+ self.text = []
+ text = self.text
+
+ text.append(TexMobject(r"\text{Consider the Vector Space }",
+ r"{\mathbb{R}^2}"))
+ self.add_title(text[0], 0.7, animate = True)
+ text.append(TexMobject(r"{\mathbb{R}^2}",
+ tex_to_color_map = {r"{\mathbb{R}^2}": BLUE_E}))
+ text[1].shift(6.5*LEFT+3.5*UP)
+ self.wait(0.5)
+ self.play(Transform(text[0], text[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.mp4 b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Vector_Addition_and_Scalar_Multiplication.mp4 Binary files differnew file mode 100644 index 0000000..8acbb81 --- /dev/null +++ b/FSF-2020/linear-algebra/vector-spaces/Vector-Spaces/Vector-Spaces/gifs/Vector_Addition_and_Scalar_Multiplication.mp4 |