From 49ced9e502d4c0bb930731d37d1223d9b34d01d5 Mon Sep 17 00:00:00 2001 From: nishanpoojary Date: Wed, 1 Jul 2020 11:48:28 +0530 Subject: Added updated scalar-functions folder --- .../scalar-functions/Scalar_Function_Quiz.pdf | Bin 0 -> 87455 bytes .../scalar-functions/file1_scalar_functions.py | 50 ++++++ .../scalar-functions/file2_domain_range.py | 190 +++++++++++++++++++++ .../scalar-functions/file3_parabola_example.py | 47 +++++ .../scalar-functions/file4_level_curves.py | 118 +++++++++++++ .../scalar-functions/file5_level_surface.py | 78 +++++++++ .../file6_scalar_function_application.py | 140 +++++++++++++++ .../scalar-functions/file7_neural_nets.py | 177 +++++++++++++++++++ .../gifs/file1_scalar_functions.gif | Bin 0 -> 1408290 bytes .../scalar-functions/gifs/file2_domain_range.gif | Bin 0 -> 6625947 bytes .../gifs/file3_parabola_example.gif | Bin 0 -> 5660857 bytes .../scalar-functions/gifs/file4_level_curves.gif | Bin 0 -> 4096583 bytes .../scalar-functions/gifs/file5_level_surface.gif | Bin 0 -> 3796274 bytes .../gifs/file6_scalar_function_application.gif | Bin 0 -> 2236609 bytes .../scalar-functions/gifs/file7_neural_nets.gif | Bin 0 -> 95828 bytes 15 files changed, 800 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/Scalar_Function_Quiz.pdf create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file1_scalar_functions.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file2_domain_range.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file3_parabola_example.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file4_level_curves.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file5_level_surface.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file6_scalar_function_application.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/file7_neural_nets.py create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif create mode 100644 FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif (limited to 'FSF-2020') 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 new file mode 100644 index 0000000..6d94a2c Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/Scalar_Function_Quiz.pdf differ 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 new file mode 100644 index 0000000..bea9c7b Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file1_scalar_functions.gif differ 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 new file mode 100644 index 0000000..6801e4f Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file2_domain_range.gif differ 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 new file mode 100644 index 0000000..af9e536 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file3_parabola_example.gif differ 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 new file mode 100644 index 0000000..b4ac106 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file4_level_curves.gif differ 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 new file mode 100644 index 0000000..e4dc80d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file5_level_surface.gif differ 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 new file mode 100644 index 0000000..8bb176a Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file6_scalar_function_application.gif differ 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 new file mode 100644 index 0000000..9d24688 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/scalar-functions/gifs/file7_neural_nets.gif differ -- cgit