summaryrefslogtreecommitdiff
path: root/FSF-2020
diff options
context:
space:
mode:
Diffstat (limited to 'FSF-2020')
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical Points/example.py32
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical Points/motivation.py30
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical Points/theorem.py55
-rw-r--r--FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py70
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gifbin0 -> 1277788 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gifbin0 -> 547368 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gifbin0 -> 2529511 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gifbin0 -> 3365528 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif (renamed from FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif)bin1170435 -> 1170435 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gifbin0 -> 3752052 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py232
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gifbin0 -> 2556585 bytes
-rw-r--r--FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py286
13 files changed, 705 insertions, 0 deletions
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/example.py b/FSF-2020/approximations-and-optimizations/Critical Points/example.py
new file mode 100644
index 0000000..3a41be7
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical Points/example.py
@@ -0,0 +1,32 @@
+from manimlib.imports import*
+
+class ExampleAnimation(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ f_text = TextMobject("$f(x,y) = (y-x)(1-2x-3y)$").to_corner(UL)
+ d = Dot(np.array([0,0,0]), color = '#800000') #---- Critical Point
+ d_text = TextMobject("$(0.2,0.2)$",color = '#DC143C').scale(0.5).shift(0.2*UP) #----x = 0.2, y = 0.2
+ r_text=TextMobject("Critical Point",color = '#00FFFF').shift(0.3*DOWN).scale(0.6)
+
+ #----f(x,y) = (y-x)(1-2x-3y)
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ (v-u)*(1-2*u-3*v)
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [PURPLE_D, PURPLE_E],
+ resolution=(20, 20)).scale(1)
+
+ self.set_camera_orientation(phi = 75 * DEGREES)
+ self.begin_ambient_camera_rotation(rate=0.5)
+
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(1)
+ self.add(axes)
+ self.play(Write(f),Write(d))
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(d_text)
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(r_text)
+ self.wait(3)
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py b/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py
new file mode 100644
index 0000000..27354ef
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical Points/motivation.py
@@ -0,0 +1,30 @@
+from manimlib.imports import*
+
+class MotivationAnimation(Scene):
+ def construct(self):
+
+ r = Rectangle(height = 7,breadth = 2,color = BLUE, fill_opacity = 0.3).scale(0.6) #----metal strip
+ b = Brace(r,UP)
+ r_text = TextMobject("$x$ metres",color = YELLOW).shift(3*UP)
+ m_text = TextMobject("Metal Strip").shift(3*DOWN)
+ a = Arc(radius=2).rotate(1).shift(LEFT+0.5*UP)
+ a2 = Arc(radius=2).rotate(5).shift(0.7*LEFT+0.9*UP).scale(0.2)
+ START = [1,0,0]
+ END = [0,3,0]
+ l = Line(START,END,color = RED).shift(0.9*DOWN)
+ a2_text = TextMobject("$\\theta$",color = PINK).shift(1.6*UP+0.4*RIGHT)
+
+ group1 = VGroup(r_text,b,a,l,a2,a2_text)
+ f_text = TextMobject("$A = f(x,\\theta)$").shift(2*DOWN)
+
+ ring = Annulus(inner_radius = 0.7, outer_radius = 1, color = BLUE) #--bent metal strip
+
+ self.play(Write(r))
+ self.wait(1)
+ self.play(ShowCreation(m_text))
+ self.wait(1)
+ self.play(Write(group1))
+ self.wait(2)
+ self.play(FadeOut(group1))
+ self.wait(1)
+ self.play(ReplacementTransform(r,ring),ShowCreation(f_text))
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py b/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py
new file mode 100644
index 0000000..7c82aa9
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical Points/theorem.py
@@ -0,0 +1,55 @@
+from manimlib.imports import*
+
+class TheoremAnimation(ThreeDScene):
+ def construct(self):
+
+ axes = ThreeDAxes()
+
+ #----parabola: x**2+y**2
+ parabola1 = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ u**2+v**2
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [TEAL_E],
+ resolution = (20, 20)).scale(1)
+
+ #----parabola: -x**2-y**2
+ parabola2 = ParametricSurface(
+ lambda u, v: np.array([
+ u,
+ v,
+ -u**2-v**2
+ ]),v_min = -1, v_max = 1, u_min = -1, u_max = 1, checkerboard_colors = [PURPLE_E,PURPLE_E],
+ resolution = (20, 20)).scale(1)
+
+ self.set_camera_orientation(phi = 75 * DEGREES)
+ self.begin_ambient_camera_rotation(rate = 0.4)
+
+ d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point
+ r = Rectangle(fill_color = '#C0C0C0',fill_opacity = 0.3).move_to(ORIGIN) #----tangent plane
+
+ parabola1_text = TextMobject("Maximum with horizontal tangent plane").scale(0.7).to_corner(UL)
+
+ parabola2_text = TextMobject("Minimum with horizontal tangent plane").scale(0.7).to_corner(UL)
+
+ self.add(axes)
+ self.add_fixed_in_frame_mobjects(parabola2_text)
+ self.wait(1)
+ self.play(Write(parabola1))
+ self.wait(1)
+ self.play(ShowCreation(d))
+ self.wait(1)
+ self.play(ShowCreation(r))
+ self.wait(2)
+ self.play(FadeOut(parabola2_text),FadeOut(parabola1),FadeOut(r),FadeOut(d))
+
+ self.wait(1)
+ self.add_fixed_in_frame_mobjects(parabola1_text)
+ self.wait(1)
+ self.play(Write(parabola2))
+ self.wait(1)
+ self.play(ShowCreation(d))
+ self.wait(1)
+ self.play(ShowCreation(r))
+ self.wait(2)
diff --git a/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py b/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py
new file mode 100644
index 0000000..f9055e6
--- /dev/null
+++ b/FSF-2020/approximations-and-optimizations/Critical Points/types_of_cp.py
@@ -0,0 +1,70 @@
+from manimlib.imports import *
+
+class TypescpAnimation(ThreeDScene):
+ def construct(self):
+ axes = ThreeDAxes()
+
+ r_text = TextMobject("Relative Maximum at ORIGIN",color ='#87CEFA')
+ f_text = TextMobject("$f(x,y) = -x^2-y^2$").to_corner(UL)
+
+ #----graph of first function f(x,y) = -x**2-y**2
+ f = ParametricSurface(
+ lambda u, v: np.array([
+ 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)
+
+ r2_text = TextMobject("Saddle Point at ORIGIN",color ='#87CEFA')
+ f2_text = TextMobject("$f(x,y) = -x^2+y^2$").to_corner(UL)
+
+ #----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)
+
+ r3_text = TextMobject("Relative Minimum at ORIGIN",color ='#87CEFA')
+ f3_text = TextMobject("$f(x,y) = x^2+y^2$").to_corner(UL)
+
+ #----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)
+
+ self.set_camera_orientation(phi = 75 * DEGREES, theta = -45 * DEGREES )
+ d = Dot(np.array([0,0,0]), color = '#800000') #---- critical point
+
+ self.add_fixed_in_frame_mobjects(r_text)
+ self.wait(1)
+ self.play(FadeOut(r_text))
+ self.add(axes)
+ self.play(Write(f),Write(d))
+ self.add_fixed_in_frame_mobjects(f_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(f),FadeOut(f_text),FadeOut(d))
+
+ self.add_fixed_in_frame_mobjects(r2_text)
+ self.wait(1)
+ self.play(FadeOut(r2_text))
+ self.add(axes)
+ self.play(Write(f2),Write(d))
+ self.add_fixed_in_frame_mobjects(f2_text)
+ self.wait(2)
+ self.play(FadeOut(axes),FadeOut(f2),FadeOut(f2_text),FadeOut(d))
+
+ self.add_fixed_in_frame_mobjects(r3_text)
+ self.wait(1)
+ self.play(FadeOut(r3_text))
+ self.add(axes)
+ self.play(Write(f3),Write(d))
+ self.add_fixed_in_frame_mobjects(f3_text)
+ self.wait(2)
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif
new file mode 100644
index 0000000..223218b
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif
new file mode 100644
index 0000000..5c9ac03
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif
new file mode 100644
index 0000000..c8e7c8c
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif
new file mode 100644
index 0000000..ae23a7b
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif
Binary files differ
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/y_limit_dependent_on_x.gif
index a2bfd9d..a2bfd9d 100644
--- 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/y_limit_dependent_on_x.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif
new file mode 100644
index 0000000..8c9fa0a
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/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/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/surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif
new file mode 100644
index 0000000..ac13f21
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif
Binary files differ
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py
new file mode 100644
index 0000000..c998f3b
--- /dev/null
+++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py
@@ -0,0 +1,286 @@
+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.2,
+ 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.4)
+ self.get_region(self.axes,c1,c2)
+ self.play(Write(surface))
+ self.get_lines()
+ self.wait(1)
+ self.stop_ambient_camera_rotation()
+ self.move_camera(
+ distance=20,
+ phi=10 * DEGREES,
+ theta=80 * DEGREES,
+ run_time=2.5
+ )
+ 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(Write(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
+
+