summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_application.py129
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_domain_range.py132
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves.mp4bin0 -> 726339 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves2.mp4bin0 -> 2088849 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_neural_nets.py177
-rw-r--r--FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_parabola_example.py35
6 files changed, 473 insertions, 0 deletions
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_application.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_application.py
new file mode 100644
index 0000000..56b3e53
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_application.py
@@ -0,0 +1,129 @@
+from manimlib.imports import *
+
+class ScalarApplication(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes() # creates a 3D Axis
+
+ cube = Cube()
+ cube.set_fill(YELLOW_E, opacity = 0.1)
+ cube.scale(2)
+ self.set_camera_orientation(phi=0 * DEGREES,theta=270*DEGREES)
+ self.play(ShowCreation(cube),ShowCreation(axes))
+
+ 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/scalar_function_domain_range.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_domain_range.py
new file mode 100644
index 0000000..9b1ca7b
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_domain_range.py
@@ -0,0 +1,132 @@
+# 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)
+
+
+ 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 = Line(self.graph_origin+0.6*YTD*DOWN+1.2*XTD*LEFT, self.graph_origin+0.6*YTD*DOWN + 4*XTD*LEFT)
+ domainline2 = Arrow(self.graph_origin+0.6*YTD*DOWN+1.1*XTD*RIGHT, self.graph_origin+0.6*YTD*DOWN + 5.3*XTD*RIGHT)
+ 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)
+
+
+ \ No newline at end of file
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves.mp4 b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves.mp4
new file mode 100644
index 0000000..6af2670
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves.mp4
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves2.mp4 b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves2.mp4
new file mode 100644
index 0000000..b21ae25
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_level_curves2.mp4
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_neural_nets.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_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/scalar_function_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/scalar_function_parabola_example.py b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_parabola_example.py
new file mode 100644
index 0000000..74dc063
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/Scalar Functions/scalar_function_parabola_example.py
@@ -0,0 +1,35 @@
+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}$", "z = f(x,y)")
+ self.add_fixed_in_frame_mobjects(text3d)
+ 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)
+ self.play(ShowCreation(paraboloid))
+ 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