diff options
author | Somnath Pandit | 2020-06-11 17:43:42 +0530 |
---|---|---|
committer | Somnath Pandit | 2020-06-11 17:43:42 +0530 |
commit | 1c8492c83d0b953c2e9f62f0ddb761c33b52b943 (patch) | |
tree | 51f0ccf1563b348eafddd48277ab746af112b59b /FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions | |
parent | dd85fa70fa196fac02b88b84bdac4587a76139b8 (diff) | |
download | FSF-mathematics-python-code-archive-1c8492c83d0b953c2e9f62f0ddb761c33b52b943.tar.gz FSF-mathematics-python-code-archive-1c8492c83d0b953c2e9f62f0ddb761c33b52b943.tar.bz2 FSF-mathematics-python-code-archive-1c8492c83d0b953c2e9f62f0ddb761c33b52b943.zip |
updated after review
Diffstat (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions')
6 files changed, 102 insertions, 24 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 index fe4d73a..5fa2146 100644 --- 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 @@ -1,8 +1,8 @@ -**file1_surface** -![file1_surface](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif) +**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_area_under_func** -![file2_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/file2_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) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_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/file2_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/file2_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/file2_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/file1_surface.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif Binary files differdeleted file mode 100644 index ae23a7b..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif +++ /dev/null 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..74c306d --- /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/file1_surface.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py index a794f46..cd4060b 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_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,16 @@ 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) 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) + 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 +73,26 @@ class SurfacesAnimation(ThreeDScene): ) - self.begin_ambient_camera_rotation(rate=0.07) + self.begin_ambient_camera_rotation(rate=0.08) 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)) + 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(FadeOut(surface)) self.wait(3) + + + def get_surface(self,axes, func, **kwargs): config = { @@ -101,9 +117,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 +125,90 @@ 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) + + self.play(ShowCreation(cuboids),run_time=6) + # self.add(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 +245,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 +312,3 @@ class SurfacesAnimation(ThreeDScene): return axes - -#uploaded by Somnath Pandit.FSF2020_Double_Integral |