diff options
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals')
17 files changed, 877 insertions, 22 deletions
diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md new file mode 100644 index 0000000..5fa2146 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md @@ -0,0 +1,21 @@ +**file1_area_under_func** +![file1_area_under_func](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif) + +**file2_volume_under_surface** +![file2_volume_under_surface](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif) + +**file3_y_limit_dependent_on_x** +![file3_y_limit_dependent_on_x](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif) + +**file4_non_rect_region** +![file4_non_rect_region](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif) + +**file5_elementary_area** +![file5_elementary_area](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif) + +**file6_doing_integration** +![file6_doing_integration](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif) + +**file7_int_process_of_example** +![file7_int_process_of_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif) + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif Binary files differindex 223218b..223218b 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py index 773840c..773840c 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif Binary files differnew file mode 100644 index 0000000..1455573 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py index a794f46..38d41c6 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py @@ -5,11 +5,11 @@ class SurfacesAnimation(ThreeDScene): CONFIG = { "axes_config": { "x_min": 0, - "x_max": 8, + "x_max": 7, "y_min": 0, - "y_max": 8, + "y_max": 7, "z_min": 0, - "z_max": 6, + "z_max": 5, "a":1 ,"b": 6, "c":2 , "d":6, "axes_shift":-3*OUT + 5*LEFT, "x_axis_config": { @@ -46,13 +46,24 @@ class SurfacesAnimation(ThreeDScene): self.setup_axes() self.set_camera_orientation(distance=35, phi=80 * DEGREES, - theta=-80 * DEGREES, + theta=-100 * DEGREES, ) - fn_text=TextMobject("$z=f(x,y)$").set_color(PINK) + 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) @@ -70,13 +81,54 @@ class SurfacesAnimation(ThreeDScene): ) - self.begin_ambient_camera_rotation(rate=0.07) + self.begin_ambient_camera_rotation(rate=0.06) self.play(Write(surface)) - # self.play(LaggedStart(ShowCreation(surface))) + # self.add(surface) self.get_lines() - # self.play(FadeIn(self.axes.input_plane)) + 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 = { @@ -101,9 +153,6 @@ class SurfacesAnimation(ThreeDScene): 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: @@ -112,23 +161,89 @@ 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,"#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")) - for start , end in zip(labels, - self.region_corners): - # lines.add(self.draw_lines(start,end,"BLUE")) - # print (start,end) - pass + # 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) @@ -165,7 +280,7 @@ class SurfacesAnimation(ThreeDScene): axes.input_plane = input_plane self.region_corners=[ - input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] return axes @@ -232,5 +347,3 @@ class SurfacesAnimation(ThreeDScene): return axes - -#uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif Binary files differnew file mode 100644 index 0000000..dcfacb6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py index 4894ebf..f755495 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py @@ -29,7 +29,7 @@ class YlimitXdependent(GraphScene): line_eqn=TextMobject("2x+y=2").move_to(self.graph_origin+.8*X+Y).rotate(np.arctan(-2)) self.line=line - caption=TextMobject(r"See the value of $y$ \\ is changing with $x$").move_to(self.graph_origin+1.2*X+1.8*Y) + caption=TextMobject(r"The value of $y$ is\\ changing with $x$").move_to(self.graph_origin+1.2*X+1.8*Y) self.play(ShowCreation(line),Write(line_eqn)) # self.show_area() self.show_rects() diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif Binary files differindex c8e7c8c..c8e7c8c 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py index 793a000..793a000 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif Binary files differindex 5c9ac03..5c9ac03 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py index 362b6f8..362b6f8 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif Binary files differnew file mode 100644 index 0000000..7a9271b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py new file mode 100644 index 0000000..5a8cec0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py @@ -0,0 +1,355 @@ +from manimlib.imports import * + +class IntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 7, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 4, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 2+y/4+np.cos(x/1.4) + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.camera.frame_center.shift(axes.c2p(3,4,1.7)) + self.set_camera_orientation(distance=35, + phi= 80 * DEGREES, + theta= -80 * DEGREES, + gamma = 0 * DEGREES + ) + + fn_text=TextMobject("$z=f(x,y)$").set_color(PINK) + self.add_fixed_in_frame_mobjects(fn_text) + + + R=TextMobject("R").set_color(BLACK).scale(3) + R.move_to(axes.input_plane,IN) + self.add(R) + + # get the surface + surface= self.get_surface( + axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=.65, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + fn_text.next_to(surface,UP,buff=MED_LARGE_BUFF) + slice_curve=(self.get_y_slice_graph( + axes,self.Func,5,color=YELLOW)) + + + self.begin_ambient_camera_rotation(rate=0.08) + # self.play(Write(surface)) + self.add(surface) + + self.get_lines() + + self.show_process(axes) + + self.wait(3) + + + + def show_process(self,axes): + y_tracker = ValueTracker(axes.c) + self.y_tracker=y_tracker + y=y_tracker.get_value + + graph = always_redraw( + lambda: self.get_y_slice_graph( + axes, self.Func, y(), + stroke_color=YELLOW, + stroke_width=4, + ) + ) + graph.suspend_updating() + + + plane = always_redraw(lambda: Polygon( + *[ + axes.c2p(x,y(),self.Func(x,y())) + for x in np.arange(axes.a,axes.b,0.01) + ], + *[ + axes.c2p(x, y(), 0) + for x in [ axes.b, axes.a,] + ], + stroke_width=2, + fill_color=BLUE_D, + fill_opacity=.4, + )) + + plane_side1 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.a,y,self.Func(axes.a,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.a, y, 0) + for y in [ y(),axes.c, ] + ], + stroke_width=2.5, + fill_color=BLUE_C, + fill_opacity=.2, + )) + plane_side2 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.b,y,self.Func(axes.b,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.b, y, 0) + for y in [y(),axes.c,] + ], + stroke_width=2.5, + fill_color=BLUE_E, + fill_opacity=.45, + )) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + self.play(Write(VGroup(graph,plane)),run_time=2) + self.add(plane.copy(),plane_side1,plane_side2) + + + plane_side1.resume_updating() + plane_side2.resume_updating() + + self.move_camera( + distance=30, + phi= 85 * DEGREES, + theta= -10 * DEGREES, + run_time=1.5 + ) + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + + + def get_y_slice_graph(self, axes, func, y, **kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": axes.a, + "t_max": axes.b, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda x: axes.c2p( + x, y, func(x, y) + ), + **config, + ) + return slice_curve + + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"RED")) + + labels=[ + (axes.a,0,0), + (axes.b,0,0), + (0,axes.d,0), + (0,axes.c,0) + ] + self.region_corners[-1]=self.region_corners[0] + for start , end in zip(labels, + self.region_corners): + lines.add(self.draw_lines(start,end,"WHITE")) + self.add(lines) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + +#------------------------------------------------------------ + #customize 3d axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, RIGHT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.5, + fill_color=TEAL, + stroke_width=0, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("a", axes.a), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c), + ("d", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1.5) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + z_label.next_to(axes.z_axis.get_zenith(), RIGHT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif Binary files differnew file mode 100644 index 0000000..9fbdde8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py new file mode 100644 index 0000000..f733761 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py @@ -0,0 +1,366 @@ +from manimlib.imports import * + +class IntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 5, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 3, + "a":0 ,"b":4 , "c":0 , "d":6, + "axes_shift":1.5*IN+2*LEFT+4*DOWN, + "x_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 2*(1+(x+y)/10) + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + self.set_camera_orientation(#distance=35, + phi=60 * DEGREES, + theta=10 * DEGREES, + ) + + fn_text=TextMobject("$z=(1+x+y)$").set_color(PINK) + self.add_fixed_in_frame_mobjects(fn_text) + fn_text.to_edge(TOP,buff=.1) + self.fn_text=fn_text + + R=TextMobject("R").set_color(BLACK).scale(3).rotate(PI/2) + R.move_to(axes.input_plane,IN) + self.add(R) + + #get the surface + surface= self.get_surface( + axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.75, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + slice_curve=(self.get_y_slice_graph( + axes,self.Func,5,color=YELLOW)) + + + self.begin_ambient_camera_rotation(rate=0.04) + # self.play(Write(surface)) + self.add(surface) + + self.get_lines() + + self.show_process(axes) + + self.wait() + + + + def show_process(self,axes): + y_tracker = ValueTracker(axes.c) + self.y_tracker=y_tracker + y=y_tracker.get_value + graph = always_redraw( + lambda: self.get_y_slice_graph( + axes, self.Func, y(), + stroke_color=YELLOW, + stroke_width=4, + ) + ) + graph.suspend_updating() + + plane = always_redraw(lambda: Polygon( + *[ + axes.c2p(x,y(),self.Func(x,y())) + for x in np.arange(axes.a,axes.b,0.01) + ], + *[ + axes.c2p(x, y(), 0) + for x in [ axes.b, axes.a,] + ], + stroke_width=0, + fill_color=BLUE_E, + fill_opacity=.65, + )) + plane_side1 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.a,y,self.Func(axes.a,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.a, y, 0) + for y in [ y(),axes.c, ] + ], + stroke_width=2.5, + fill_color=BLUE_C, + fill_opacity=.2, + )) + plane_side2 = always_redraw(lambda: Polygon( + *[ + axes.c2p(axes.b,y,self.Func(axes.b,y)) + for y in np.arange(axes.c,y(),0.01) + ], + *[ + axes.c2p(axes.b, y, 0) + for y in [y(),axes.c,] + ], + stroke_width=2.5, + fill_color=BLUE_E, + fill_opacity=.45, + )) + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + first_x_text=TextMobject("First the $x$ integration..",color=YELLOW) + first_x_text.to_corner(UR,buff=1.1) + + x_func=TextMobject("$\\frac 3 2 + y$",color=BLUE) + '''x_func.next_to(self.fn_text,DOWN) + x_func.align_to(self.fn_text,LEFT)''' + x_func.to_edge(LEFT,buff=1) + + then_y_text=TextMobject("Then the $y$ integration..",color=YELLOW) + then_y_text.to_corner(UR,buff=1.1) + + self.add_fixed_in_frame_mobjects(first_x_text) + self.play(Write(first_x_text)) + self.add_fixed_in_frame_mobjects(x_func) + self.play( + Write(VGroup(graph,plane,x_func)), + run_time=3 + ) + + self.wait() + self.remove(first_x_text) + self.add_fixed_in_frame_mobjects(then_y_text) + self.play(Write(then_y_text)) + self.add(plane.copy(),plane_side1,plane_side2) + graph.resume_updating() + plane.resume_updating() + plane_side1.resume_updating() + plane_side2.resume_updating() + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + + graph.suspend_updating() + plane.suspend_updating() + plane_side1.suspend_updating() + plane_side2.suspend_updating() + + + def get_y_slice_graph(self, axes, func, y, **kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": axes.a, + "t_max": axes.b, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda x: axes.c2p( + x, y, func(x, y) + ), + **config, + ) + return slice_curve + + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + (axes.y_max - axes.y_min) // axes.y_axis.tick_frequency, + (axes.x_max - axes.x_min) // axes.x_axis.tick_frequency, + ), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"RED")) + + labels=[ + (axes.a,0,0), + (axes.b,0,0), + (0,axes.d,0), + (0,axes.c,0) + ] + self.region_corners[-1]=self.region_corners[0] + for start , end in zip(labels, + self.region_corners): + lines.add(self.draw_lines(start,end,"WHITE")) + self.add(lines) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + +#------------------------------------------------------------ + #customize 3d axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=TEAL, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UL,UR)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + + ("1", axes.b), + ] + tex_vals_y=[ + + ("2", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif Binary files differdeleted file mode 100644 index ae23a7b..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif +++ /dev/null diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif Binary files differdeleted file mode 100644 index a2bfd9d..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif +++ /dev/null |