From fe5e18510140b3e02f3f6f03ad449c218f1b8579 Mon Sep 17 00:00:00 2001 From: Purusharth S Date: Sat, 23 May 2020 18:57:11 +0530 Subject: add topic-name folder --- .../double-integrals/YlimitXdependent.gif | Bin 0 -> 1170435 bytes .../double-integrals/area_under_func.py | 73 +++++++ .../double-integrals/elementary_area.py | 144 +++++++++++++ .../double-integrals/non_rect_region.py | 154 ++++++++++++++ .../double-integrals/surface.py | 236 +++++++++++++++++++++ .../double-integrals/y_limit_dependent_on_x.py | 113 ++++++++++ 6 files changed, 720 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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/YlimitXdependent.gif new file mode 100644 index 0000000..a2bfd9d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif differ 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/area_under_func.py new file mode 100644 index 0000000..773840c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py @@ -0,0 +1,73 @@ +from manimlib.imports import * + + +class AreaUnderIntegral(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 5, + "y_min" : 0, + "y_max" : 6, + "Func":lambda x : 1+x**2*np.exp(-.15*x**2) + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + int_area_sym=TextMobject("$$\int_{a}^b f(x)dx$$").shift(2*UP) + area_mean_text = TextMobject(r"means area under the curve of $f(x)$ \\ in the region $a\leq x\leq b$").next_to(int_area_sym,DOWN) + + opening_text=VGroup(*[int_area_sym,area_mean_text]) + self.play(Write(opening_text),run_time=4) + self.wait(2) + self.play(FadeOut(opening_text)) + + self.setup_axes(animate=True) + func= self.get_graph(self.Func, x_min=0,x_max=5) + self.curve=func + + func_text = TextMobject(r"$y = f(x)$").next_to(func,UP) + min_lim = self.get_vertical_line_to_graph(1,func,DashedLine,color=YELLOW) + tick_a=TextMobject(r"$a$").next_to(min_lim,DOWN) + max_lim = self.get_vertical_line_to_graph(4,func,DashedLine,color=YELLOW) + tick_b=TextMobject(r"$b$").next_to(max_lim,DOWN) + + # area = self.get_area(func,1,4) + + self.play(ShowCreation(func), ShowCreation(func_text)) + + self.wait(2) + self.play(ShowCreation(min_lim),Write(tick_a), ShowCreation(max_lim),Write(tick_b),run_time=0.5) + + + approx_text=TextMobject(r"The area can be approximated as \\ sum of small rectangles").next_to(func,4*Y) + self.play(Write(approx_text)) + + rect_list = self.get_riemann_rectangles_list( + self.curve, 5, + max_dx = 0.25, + x_min = 1, + x_max = 4, + ) + flat_graph = self.get_graph(lambda t : 0) + rects = self.get_riemann_rectangles( flat_graph, x_min = 1, x_max = 4, dx = 0.5) + for new_rects in rect_list: + new_rects.set_fill(opacity = 0.8) + rects.align_submobjects(new_rects) + for alt_rect in rects[::2]: + alt_rect.set_fill(opacity = 0) + self.play(Transform( + rects, new_rects, + run_time = 1.5, + lag_ratio = 0.5 + )) + conclude_text=TextMobject(r"Making the rectangles infinitesimally thin \\ we get the real area under the curve.").next_to(func,4*Y) + self.play(Transform(approx_text,conclude_text)) + self.wait(3) + int_area_sym.next_to(self.curve,IN) + self.play(Transform(conclude_text,int_area_sym)) + + # self.play(ShowCreation(area)) + self.wait(3) + +#uploaded by Somnath Pandit.FSF2020_Double_Integral 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/elementary_area.py new file mode 100644 index 0000000..362b6f8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py @@ -0,0 +1,144 @@ +from manimlib.imports import * + +class ElementaryArea(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 2, + "y_min" : 0, + "y_max" : 2, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + # "x_labeled_nums": list(np.arange(0,3)), + # "y_labeled_nums": list(np.arange(0 ,3)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+3.5*LEFT+3.5*DOWN, + } + + def construct(self): + X = self.x_axis_width/(self.x_max- self.x_min) + Y = self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + self.setup_axes(animate=False) + + caption=TextMobject("The elementary area in ").to_edge(UP) + rect_text=TextMobject("Cartesian Coordinates").next_to(caption,DOWN,) + polar_text=TextMobject("Polar Coordinates").next_to(caption,DOWN,) + + self.add(caption) + self.play(Write(rect_text)) + self.get_rect_element() + # self.play(Write(polar_text)) + self.play(ReplacementTransform(rect_text,polar_text), + FadeOut(VGroup(self.dydx,self.rect_brace_gr))) + self.get_polar_element() + + + + def get_rect_element(self): + rect=Rectangle( + height=2, width=3,fill_color=BLUE_D, + fill_opacity=1, color=BLUE_D + ).scale(.75).move_to( + self.graph_origin+(RIGHT*self.X+UP*self.Y) + ) + dx_brace=Brace(rect, DOWN, buff = SMALL_BUFF) + dx_label=dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_gr=VGroup(dx_brace,dx_label) + + dy_brace=Brace(rect,RIGHT, buff = SMALL_BUFF) + dy_label=dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_gr=VGroup(dy_brace,dy_label) + + brace_gr=VGroup(dx_brace_gr,dy_brace_gr) + + dydx=TextMobject("$dxdy$",color=BLACK).next_to(rect,IN) + + self.play(FadeIn(rect)) + self.play(GrowFromCenter(brace_gr)) + self.play(GrowFromCenter(dydx)) + + self.rect=rect + self.rect_brace_gr=brace_gr + self.dydx=dydx + self.wait(2) + + + def get_polar_element(self): + X=self.X ;Y=self.Y + theta1=25*DEGREES + dtheta=TAU/12 + r_in=1.3*X ; r_out=1.9*X + + arc=AnnularSector( + arc_center=self.graph_origin, + inner_radius=r_in, + outer_radius=r_out , + angle= dtheta, + start_angle= theta1, + fill_opacity= 1, + stroke_width= 0, + color= BLUE_D, + ) + + + # # #getting braces + r_in_theta1=self.graph_origin+r_in*(np.cos(theta1)*RIGHT+np.sin(theta1)*UP) + dr_line=Line(r_in_theta1,r_in_theta1+RIGHT*(r_out-r_in)) + dr_brace=Brace(dr_line, DOWN, buff = SMALL_BUFF + ).rotate(theta1, about_point=r_in_theta1 + ) + dr_label=dr_brace.get_text("$dr$", buff = SMALL_BUFF) + dr_brace_gr=VGroup(dr_brace,dr_label) + + theta2=theta1+dtheta + r_out_theta2=self.graph_origin+r_out*( + np.cos(theta2)*RIGHT+np.sin(theta2)*UP + ) + rdt_line=Line(r_out_theta2,r_out_theta2 + +DOWN*(r_out*dtheta) + ) + rdt_brace=Brace(rdt_line, RIGHT, + buff = MED_SMALL_BUFF).rotate( + theta2-(dtheta/2), about_point=r_out_theta2 + ) + rdt_label=rdt_brace.get_text("$rd\\theta$",buff = SMALL_BUFF) + rdt_brace_gr=VGroup(rdt_brace,rdt_label) + + #getting label r and dtheta + r1=DashedLine(self.graph_origin,r_in_theta1).set_color(RED) + r2=DashedLine(self.graph_origin,r_out_theta2).set_color(RED) + r_brace=Brace(r1, DOWN, buff = SMALL_BUFF).rotate(theta1, about_point=self.graph_origin) + r_label=r_brace.get_text("$r$", buff = SMALL_BUFF) + r_brace_gr=VGroup(r_brace,r_label) + + dtheta_arc=Arc( + arc_center=self.graph_origin, + radius=.5*X, + angle= dtheta, + start_angle= theta1, + ) + dtheta_arc_label=TextMobject("$d\\theta$").move_to(.99*dtheta_arc.get_corner(UR)) + dtheta_label=VGroup(dtheta_arc,dtheta_arc_label) + + + rdrdt=TextMobject("$rdrd\\theta$",color=BLACK).next_to(arc,IN) + self.play(ReplacementTransform(self.rect,arc)) + self.wait() + self.play(ShowCreation(r1), + ShowCreation(r2) + ) + self.play(ShowCreation(r_brace_gr), + Write(dtheta_label) + ) + self.wait() + self.play(GrowFromCenter(rdt_brace_gr)) + self.wait(.5) + self.play(GrowFromCenter(dr_brace_gr)) + self.wait(.5) + self.play(GrowFromCenter(rdrdt)) + + self.wait(2) + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral 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/non_rect_region.py new file mode 100644 index 0000000..793a000 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py @@ -0,0 +1,154 @@ +from manimlib.imports import * + +class AreaUnderCurve(GraphScene): + CONFIG = { + "x_min" : -1, + "x_max" : 8, + "y_min" : -1, + "y_max" : 5, + "y_axis_label": "$y$", + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(-1, 9)), + "y_labeled_nums": list(np.arange(-1, 6)), + "y_axis_height":5.5, + "graph_origin": ORIGIN+4*LEFT+2.5*DOWN, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + sofar_text=TextMobject(r"So far we have integrated over \\ rectangular regions") + self.play(Write(sofar_text)) + self.play(sofar_text.to_edge,UP) + + self.setup_axes(animate=False) + + rect= self.get_graph( + lambda x : 3, + x_min = 0, + x_max = 5, + color = GREEN) + + rect_region = self.get_riemann_rectangles( + rect, + x_min = 0, + x_max = 5, + dx =.01, + start_color = GREEN, + end_color = GREEN, + fill_opacity = 0.75, + stroke_width = 0, + ) + + self.play(ShowCreation(rect_region)) + self.wait(.5) + + rect_int=TextMobject(r"Here the integration limits are set as").to_edge(UP) + rect_lim=TextMobject(r"$$\int_{x=0}^{5}\int_{y=0}^{3}$$").next_to(rect_int,DOWN) + const_text=TextMobject(r"$\longleftarrow $ \textsf the limits are\\ constant values").next_to(rect_lim,RIGHT) + + self.play(ReplacementTransform(sofar_text,rect_int)) + self.wait(1.5) + self.play(FadeIn(rect_lim)) + self.wait(2) + self.play(Write(const_text)) + self.wait(2) + self.play(FadeOut(rect_int), FadeOut(rect_lim),FadeOut(const_text)) + + + non_rect_text=TextMobject(r"Now we see how to integrate over \\ non-rectangular regions") + non_rect_text.to_edge(UP) + self.play(Write(non_rect_text)) + self.wait(1.5) + self.play(FadeOut(rect_region)) + + c1= self.get_graph( + lambda x : x**2/4, + x_min = 0, + x_max = 4, + color = RED) + + c1_region = self.get_riemann_rectangles( + c1, + x_min = 0, + x_max = 4, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity = 0.75, + stroke_width = 0, + ) + self.add(c1,c1_region) + # self.wait(2) + + c2= self.get_graph( + lambda x :12-2*x, + x_min = 4, + x_max = 6, + color = RED) + + c2_region = self.get_riemann_rectangles( + c2, + x_min = 4, + x_max = 6, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity = .75, + stroke_width = 0, + ) + self.add(c2_region,c2) + self.wait(1.5) + c=VGroup(*[c1,c2]) + + no_func_text=TextMobject(r"The whole region can't be expressed as\\ bounded by a single $f(x)$").next_to(c2,UP,buff=LARGE_BUFF) + + self.play(ReplacementTransform(non_rect_text,no_func_text)) + self.wait(1) + self.play(Indicate(c)) + self.wait(2) + + div_region_text=TextMobject(r"So the region is divided into two").next_to(c2,UP,buff=MED_LARGE_BUFF) + self.play(ReplacementTransform(no_func_text,div_region_text)) + + c2.set_color(YELLOW) + self.play(c2_region.set_color,YELLOW) + c1_text=TextMobject("$\dfrac{x^2}{4}$").next_to(c1,IN) + c2_text=TextMobject("$12-2x$").next_to(c2,IN+2*X) + c_text=VGroup(*[c1_text,c2_text]) + + self.play(FadeIn(c_text)) + self.wait(.4) + self.play(Indicate(c1),Indicate(c1_text)) + self.play(Indicate(c2),Indicate(c2_text)) + + easy_text=TextMobject(r"Now the limis can be set easily").next_to(c2,UP,buff=.5) + self.play(ReplacementTransform(div_region_text,easy_text)) + + c1_int=TextMobject(r"$$\int_{x=0}^{4}\int_{y=0}^{\dfrac{x^2}{4}}$$").next_to(c1,IN).shift(.5*(-X+1.3*Y)) + c2_int=TextMobject(r"$$\int_{x=4}^{6}\int_{y=0}^{12-2x}$$").next_to(c2,IN+X) + + self.play(ReplacementTransform(c1_text,c1_int),ReplacementTransform(c2_text,c2_int)) + self.wait(2) + + total_int=TextMobject(r"The total integraton= ").to_edge(UP) + plus=TextMobject("$$+$$").move_to(self.graph_origin+4*X+4.8*Y) + self.play(ReplacementTransform(easy_text,total_int)) + self.play(c2_region.set_color,BLUE) + self.play(c1_int.next_to,c1,.1*UP, c2_int.next_to,plus,RIGHT, FadeIn(plus)) + + region=VGroup(*[c1_region,c2_region]) + region.set_color(GREEN) + self.play(ShowCreation(region)) + self.wait(3) + + + +#uploaded by Somnath Pandit.FSF2020_Double_Integral + + + + + 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/surface.py new file mode 100644 index 0000000..a794f46 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py @@ -0,0 +1,236 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 8, + "y_min": 0, + "y_max": 8, + "z_min": 0, + "z_max": 6, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT + 5*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: 2+y/4+np.sin(x) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(distance=35, + phi=80 * DEGREES, + theta=-80 * 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) + + R=TextMobject("R").set_color(BLACK).scale(3) + 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.8, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.07) + self.play(Write(surface)) + # self.play(LaggedStart(ShowCreation(surface))) + + self.get_lines() + # self.play(FadeIn(self.axes.input_plane)) + self.wait(3) + + 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 + 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,"RED")) + + 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, 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,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), + ("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/y_limit_dependent_on_x.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py new file mode 100644 index 0000000..4894ebf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py @@ -0,0 +1,113 @@ +from manimlib.imports import * + +class YlimitXdependent(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 2, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,3)), + "x_axis_width": 3.5, + "y_axis_height": 6, + "graph_origin": ORIGIN+2.5*LEFT+3*DOWN, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate=False) + + line= self.get_graph( + lambda x : 2-2*x , + x_min = 0, + x_max = 1, + color = RED) + 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) + self.play(ShowCreation(line),Write(line_eqn)) + # self.show_area() + self.show_rects() + self.play(Write(caption)) + self.show_y_values_at_different_x() + + self.wait(.5) + + ################### + def show_area(self): + area = self.get_riemann_rectangles( + self.line, + x_min = 0, + x_max = 1, + dx =.0001, + start_color = BLUE, + end_color = BLUE, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def show_rects(self): + rects = self.get_riemann_rectangles( + self.line, + x_min = 0, + x_max = 1, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity =1, + stroke_width = 0, + ) + # self.play(ShowCreation(rects)) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + + def show_y_values_at_different_x(self): + rects=self.rects + rect = rects[len(rects)*1//10] + dx_brace = Brace(rect, DOWN, buff = 0) + dx_label = dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_group = VGroup(dx_brace,dx_label) + rp=int(len(rects)/10) + rects_subset = self.rects[3*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff = 0) + y = TexMobject("y=2-2x")#.rotate(PI/2) + y.next_to(brace, LEFT, SMALL_BUFF) + anims = [ + rect.set_fill, BLUE_E, 1, + dx_brace_group.next_to, rect, DOWN, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, BLUE, .75, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y, y), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y = y + + y = last_y + y_brace = last_brace + + +#uploaded by Somnath Pandit.FSF2020_Double_Integral -- cgit From 72005384492cc35cc6e4dfb8f9237485eebd49d6 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Mon, 25 May 2020 20:33:23 +0530 Subject: gif files added --- .../double-integrals/YlimitXdependent.gif | Bin 1170435 -> 0 bytes .../double-integrals/area_Under_func.gif | Bin 0 -> 1277788 bytes .../double-integrals/elementary_area.gif | Bin 0 -> 547368 bytes .../double-integrals/non_rect_region.gif | Bin 0 -> 2529511 bytes .../double-integrals/surface.gif | Bin 0 -> 3365528 bytes .../double-integrals/y_limit_dependent_on_x.gif | Bin 0 -> 1170435 bytes 6 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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/YlimitXdependent.gif deleted file mode 100644 index a2bfd9d..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/YlimitXdependent.gif and /dev/null differ 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 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif 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 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif 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 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif 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 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif differ 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 new file mode 100644 index 0000000..a2bfd9d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif differ -- cgit From a92ab419ce219a9bab4bbe03ea0f8be004e640ea Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 26 May 2020 14:38:07 +0530 Subject: renamed files --- .../double-integrals/area_Under_func.gif | Bin 1277788 -> 0 bytes .../double-integrals/area_under_func.py | 73 ------- .../double-integrals/elementary_area.gif | Bin 547368 -> 0 bytes .../double-integrals/elementary_area.py | 144 ------------- .../double-integrals/file1_surface.gif | Bin 0 -> 3365528 bytes .../double-integrals/file1_surface.py | 236 +++++++++++++++++++++ .../double-integrals/file2_area_under_func.gif | Bin 0 -> 1277788 bytes .../double-integrals/file2_area_under_func.py | 73 +++++++ .../file3_y_limit_dependent_on_x.gif | Bin 0 -> 1170435 bytes .../file3_y_limit_dependent_on_x.py | 113 ++++++++++ .../double-integrals/file4_non_rect_region.gif | Bin 0 -> 2529511 bytes .../double-integrals/file4_non_rect_region.py | 154 ++++++++++++++ .../double-integrals/file5_elementary_area.gif | Bin 0 -> 547368 bytes .../double-integrals/file5_elementary_area.py | 144 +++++++++++++ .../double-integrals/non_rect_region.gif | Bin 2529511 -> 0 bytes .../double-integrals/non_rect_region.py | 154 -------------- .../double-integrals/surface.gif | Bin 3365528 -> 0 bytes .../double-integrals/surface.py | 236 --------------------- .../double-integrals/y_limit_dependent_on_x.gif | Bin 1170435 -> 0 bytes .../double-integrals/y_limit_dependent_on_x.py | 113 ---------- 20 files changed, 720 insertions(+), 720 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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 deleted file mode 100644 index 223218b..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_Under_func.gif and /dev/null differ 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/area_under_func.py deleted file mode 100644 index 773840c..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/area_under_func.py +++ /dev/null @@ -1,73 +0,0 @@ -from manimlib.imports import * - - -class AreaUnderIntegral(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 5, - "y_min" : 0, - "y_max" : 6, - "Func":lambda x : 1+x**2*np.exp(-.15*x**2) - } - - def construct(self): - X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) - Y = UP*self.y_axis_height/(self.y_max- self.y_min) - - int_area_sym=TextMobject("$$\int_{a}^b f(x)dx$$").shift(2*UP) - area_mean_text = TextMobject(r"means area under the curve of $f(x)$ \\ in the region $a\leq x\leq b$").next_to(int_area_sym,DOWN) - - opening_text=VGroup(*[int_area_sym,area_mean_text]) - self.play(Write(opening_text),run_time=4) - self.wait(2) - self.play(FadeOut(opening_text)) - - self.setup_axes(animate=True) - func= self.get_graph(self.Func, x_min=0,x_max=5) - self.curve=func - - func_text = TextMobject(r"$y = f(x)$").next_to(func,UP) - min_lim = self.get_vertical_line_to_graph(1,func,DashedLine,color=YELLOW) - tick_a=TextMobject(r"$a$").next_to(min_lim,DOWN) - max_lim = self.get_vertical_line_to_graph(4,func,DashedLine,color=YELLOW) - tick_b=TextMobject(r"$b$").next_to(max_lim,DOWN) - - # area = self.get_area(func,1,4) - - self.play(ShowCreation(func), ShowCreation(func_text)) - - self.wait(2) - self.play(ShowCreation(min_lim),Write(tick_a), ShowCreation(max_lim),Write(tick_b),run_time=0.5) - - - approx_text=TextMobject(r"The area can be approximated as \\ sum of small rectangles").next_to(func,4*Y) - self.play(Write(approx_text)) - - rect_list = self.get_riemann_rectangles_list( - self.curve, 5, - max_dx = 0.25, - x_min = 1, - x_max = 4, - ) - flat_graph = self.get_graph(lambda t : 0) - rects = self.get_riemann_rectangles( flat_graph, x_min = 1, x_max = 4, dx = 0.5) - for new_rects in rect_list: - new_rects.set_fill(opacity = 0.8) - rects.align_submobjects(new_rects) - for alt_rect in rects[::2]: - alt_rect.set_fill(opacity = 0) - self.play(Transform( - rects, new_rects, - run_time = 1.5, - lag_ratio = 0.5 - )) - conclude_text=TextMobject(r"Making the rectangles infinitesimally thin \\ we get the real area under the curve.").next_to(func,4*Y) - self.play(Transform(approx_text,conclude_text)) - self.wait(3) - int_area_sym.next_to(self.curve,IN) - self.play(Transform(conclude_text,int_area_sym)) - - # self.play(ShowCreation(area)) - self.wait(3) - -#uploaded by Somnath Pandit.FSF2020_Double_Integral 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 deleted file mode 100644 index 5c9ac03..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.gif and /dev/null differ 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/elementary_area.py deleted file mode 100644 index 362b6f8..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/elementary_area.py +++ /dev/null @@ -1,144 +0,0 @@ -from manimlib.imports import * - -class ElementaryArea(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 2, - "y_min" : 0, - "y_max" : 2, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - # "x_labeled_nums": list(np.arange(0,3)), - # "y_labeled_nums": list(np.arange(0 ,3)), - "x_axis_width": 6, - "y_axis_height": 6, - "graph_origin": ORIGIN+3.5*LEFT+3.5*DOWN, - } - - def construct(self): - X = self.x_axis_width/(self.x_max- self.x_min) - Y = self.y_axis_height/(self.y_max- self.y_min) - self.X=X ;self.Y=Y - self.setup_axes(animate=False) - - caption=TextMobject("The elementary area in ").to_edge(UP) - rect_text=TextMobject("Cartesian Coordinates").next_to(caption,DOWN,) - polar_text=TextMobject("Polar Coordinates").next_to(caption,DOWN,) - - self.add(caption) - self.play(Write(rect_text)) - self.get_rect_element() - # self.play(Write(polar_text)) - self.play(ReplacementTransform(rect_text,polar_text), - FadeOut(VGroup(self.dydx,self.rect_brace_gr))) - self.get_polar_element() - - - - def get_rect_element(self): - rect=Rectangle( - height=2, width=3,fill_color=BLUE_D, - fill_opacity=1, color=BLUE_D - ).scale(.75).move_to( - self.graph_origin+(RIGHT*self.X+UP*self.Y) - ) - dx_brace=Brace(rect, DOWN, buff = SMALL_BUFF) - dx_label=dx_brace.get_text("$dx$", buff = SMALL_BUFF) - dx_brace_gr=VGroup(dx_brace,dx_label) - - dy_brace=Brace(rect,RIGHT, buff = SMALL_BUFF) - dy_label=dy_brace.get_text("$dy$", buff = SMALL_BUFF) - dy_brace_gr=VGroup(dy_brace,dy_label) - - brace_gr=VGroup(dx_brace_gr,dy_brace_gr) - - dydx=TextMobject("$dxdy$",color=BLACK).next_to(rect,IN) - - self.play(FadeIn(rect)) - self.play(GrowFromCenter(brace_gr)) - self.play(GrowFromCenter(dydx)) - - self.rect=rect - self.rect_brace_gr=brace_gr - self.dydx=dydx - self.wait(2) - - - def get_polar_element(self): - X=self.X ;Y=self.Y - theta1=25*DEGREES - dtheta=TAU/12 - r_in=1.3*X ; r_out=1.9*X - - arc=AnnularSector( - arc_center=self.graph_origin, - inner_radius=r_in, - outer_radius=r_out , - angle= dtheta, - start_angle= theta1, - fill_opacity= 1, - stroke_width= 0, - color= BLUE_D, - ) - - - # # #getting braces - r_in_theta1=self.graph_origin+r_in*(np.cos(theta1)*RIGHT+np.sin(theta1)*UP) - dr_line=Line(r_in_theta1,r_in_theta1+RIGHT*(r_out-r_in)) - dr_brace=Brace(dr_line, DOWN, buff = SMALL_BUFF - ).rotate(theta1, about_point=r_in_theta1 - ) - dr_label=dr_brace.get_text("$dr$", buff = SMALL_BUFF) - dr_brace_gr=VGroup(dr_brace,dr_label) - - theta2=theta1+dtheta - r_out_theta2=self.graph_origin+r_out*( - np.cos(theta2)*RIGHT+np.sin(theta2)*UP - ) - rdt_line=Line(r_out_theta2,r_out_theta2 - +DOWN*(r_out*dtheta) - ) - rdt_brace=Brace(rdt_line, RIGHT, - buff = MED_SMALL_BUFF).rotate( - theta2-(dtheta/2), about_point=r_out_theta2 - ) - rdt_label=rdt_brace.get_text("$rd\\theta$",buff = SMALL_BUFF) - rdt_brace_gr=VGroup(rdt_brace,rdt_label) - - #getting label r and dtheta - r1=DashedLine(self.graph_origin,r_in_theta1).set_color(RED) - r2=DashedLine(self.graph_origin,r_out_theta2).set_color(RED) - r_brace=Brace(r1, DOWN, buff = SMALL_BUFF).rotate(theta1, about_point=self.graph_origin) - r_label=r_brace.get_text("$r$", buff = SMALL_BUFF) - r_brace_gr=VGroup(r_brace,r_label) - - dtheta_arc=Arc( - arc_center=self.graph_origin, - radius=.5*X, - angle= dtheta, - start_angle= theta1, - ) - dtheta_arc_label=TextMobject("$d\\theta$").move_to(.99*dtheta_arc.get_corner(UR)) - dtheta_label=VGroup(dtheta_arc,dtheta_arc_label) - - - rdrdt=TextMobject("$rdrd\\theta$",color=BLACK).next_to(arc,IN) - self.play(ReplacementTransform(self.rect,arc)) - self.wait() - self.play(ShowCreation(r1), - ShowCreation(r2) - ) - self.play(ShowCreation(r_brace_gr), - Write(dtheta_label) - ) - self.wait() - self.play(GrowFromCenter(rdt_brace_gr)) - self.wait(.5) - self.play(GrowFromCenter(dr_brace_gr)) - self.wait(.5) - self.play(GrowFromCenter(rdrdt)) - - self.wait(2) - - - #uploaded by Somnath Pandit.FSF2020_Double_Integral 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 new file mode 100644 index 0000000..ae23a7b Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif differ 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/file1_surface.py new file mode 100644 index 0000000..a794f46 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.py @@ -0,0 +1,236 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 8, + "y_min": 0, + "y_max": 8, + "z_min": 0, + "z_max": 6, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT + 5*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: 2+y/4+np.sin(x) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(distance=35, + phi=80 * DEGREES, + theta=-80 * 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) + + R=TextMobject("R").set_color(BLACK).scale(3) + 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.8, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.07) + self.play(Write(surface)) + # self.play(LaggedStart(ShowCreation(surface))) + + self.get_lines() + # self.play(FadeIn(self.axes.input_plane)) + self.wait(3) + + 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 + 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,"RED")) + + 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, 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,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), + ("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/file2_area_under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif new file mode 100644 index 0000000..223218b Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif differ 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/file2_area_under_func.py new file mode 100644 index 0000000..773840c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.py @@ -0,0 +1,73 @@ +from manimlib.imports import * + + +class AreaUnderIntegral(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 5, + "y_min" : 0, + "y_max" : 6, + "Func":lambda x : 1+x**2*np.exp(-.15*x**2) + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + int_area_sym=TextMobject("$$\int_{a}^b f(x)dx$$").shift(2*UP) + area_mean_text = TextMobject(r"means area under the curve of $f(x)$ \\ in the region $a\leq x\leq b$").next_to(int_area_sym,DOWN) + + opening_text=VGroup(*[int_area_sym,area_mean_text]) + self.play(Write(opening_text),run_time=4) + self.wait(2) + self.play(FadeOut(opening_text)) + + self.setup_axes(animate=True) + func= self.get_graph(self.Func, x_min=0,x_max=5) + self.curve=func + + func_text = TextMobject(r"$y = f(x)$").next_to(func,UP) + min_lim = self.get_vertical_line_to_graph(1,func,DashedLine,color=YELLOW) + tick_a=TextMobject(r"$a$").next_to(min_lim,DOWN) + max_lim = self.get_vertical_line_to_graph(4,func,DashedLine,color=YELLOW) + tick_b=TextMobject(r"$b$").next_to(max_lim,DOWN) + + # area = self.get_area(func,1,4) + + self.play(ShowCreation(func), ShowCreation(func_text)) + + self.wait(2) + self.play(ShowCreation(min_lim),Write(tick_a), ShowCreation(max_lim),Write(tick_b),run_time=0.5) + + + approx_text=TextMobject(r"The area can be approximated as \\ sum of small rectangles").next_to(func,4*Y) + self.play(Write(approx_text)) + + rect_list = self.get_riemann_rectangles_list( + self.curve, 5, + max_dx = 0.25, + x_min = 1, + x_max = 4, + ) + flat_graph = self.get_graph(lambda t : 0) + rects = self.get_riemann_rectangles( flat_graph, x_min = 1, x_max = 4, dx = 0.5) + for new_rects in rect_list: + new_rects.set_fill(opacity = 0.8) + rects.align_submobjects(new_rects) + for alt_rect in rects[::2]: + alt_rect.set_fill(opacity = 0) + self.play(Transform( + rects, new_rects, + run_time = 1.5, + lag_ratio = 0.5 + )) + conclude_text=TextMobject(r"Making the rectangles infinitesimally thin \\ we get the real area under the curve.").next_to(func,4*Y) + self.play(Transform(approx_text,conclude_text)) + self.wait(3) + int_area_sym.next_to(self.curve,IN) + self.play(Transform(conclude_text,int_area_sym)) + + # self.play(ShowCreation(area)) + self.wait(3) + +#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 new file mode 100644 index 0000000..a2bfd9d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_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 new file mode 100644 index 0000000..4894ebf --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.py @@ -0,0 +1,113 @@ +from manimlib.imports import * + +class YlimitXdependent(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 2, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,3)), + "x_axis_width": 3.5, + "y_axis_height": 6, + "graph_origin": ORIGIN+2.5*LEFT+3*DOWN, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + self.setup_axes(animate=False) + + line= self.get_graph( + lambda x : 2-2*x , + x_min = 0, + x_max = 1, + color = RED) + 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) + self.play(ShowCreation(line),Write(line_eqn)) + # self.show_area() + self.show_rects() + self.play(Write(caption)) + self.show_y_values_at_different_x() + + self.wait(.5) + + ################### + def show_area(self): + area = self.get_riemann_rectangles( + self.line, + x_min = 0, + x_max = 1, + dx =.0001, + start_color = BLUE, + end_color = BLUE, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def show_rects(self): + rects = self.get_riemann_rectangles( + self.line, + x_min = 0, + x_max = 1, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity =1, + stroke_width = 0, + ) + # self.play(ShowCreation(rects)) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + + def show_y_values_at_different_x(self): + rects=self.rects + rect = rects[len(rects)*1//10] + dx_brace = Brace(rect, DOWN, buff = 0) + dx_label = dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_group = VGroup(dx_brace,dx_label) + rp=int(len(rects)/10) + rects_subset = self.rects[3*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff = 0) + y = TexMobject("y=2-2x")#.rotate(PI/2) + y.next_to(brace, LEFT, SMALL_BUFF) + anims = [ + rect.set_fill, BLUE_E, 1, + dx_brace_group.next_to, rect, DOWN, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, BLUE, .75, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y, y), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y = y + + y = last_y + y_brace = last_brace + + +#uploaded by Somnath Pandit.FSF2020_Double_Integral diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif new file mode 100644 index 0000000..c8e7c8c Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py new file mode 100644 index 0000000..793a000 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file4_non_rect_region.py @@ -0,0 +1,154 @@ +from manimlib.imports import * + +class AreaUnderCurve(GraphScene): + CONFIG = { + "x_min" : -1, + "x_max" : 8, + "y_min" : -1, + "y_max" : 5, + "y_axis_label": "$y$", + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(-1, 9)), + "y_labeled_nums": list(np.arange(-1, 6)), + "y_axis_height":5.5, + "graph_origin": ORIGIN+4*LEFT+2.5*DOWN, + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + sofar_text=TextMobject(r"So far we have integrated over \\ rectangular regions") + self.play(Write(sofar_text)) + self.play(sofar_text.to_edge,UP) + + self.setup_axes(animate=False) + + rect= self.get_graph( + lambda x : 3, + x_min = 0, + x_max = 5, + color = GREEN) + + rect_region = self.get_riemann_rectangles( + rect, + x_min = 0, + x_max = 5, + dx =.01, + start_color = GREEN, + end_color = GREEN, + fill_opacity = 0.75, + stroke_width = 0, + ) + + self.play(ShowCreation(rect_region)) + self.wait(.5) + + rect_int=TextMobject(r"Here the integration limits are set as").to_edge(UP) + rect_lim=TextMobject(r"$$\int_{x=0}^{5}\int_{y=0}^{3}$$").next_to(rect_int,DOWN) + const_text=TextMobject(r"$\longleftarrow $ \textsf the limits are\\ constant values").next_to(rect_lim,RIGHT) + + self.play(ReplacementTransform(sofar_text,rect_int)) + self.wait(1.5) + self.play(FadeIn(rect_lim)) + self.wait(2) + self.play(Write(const_text)) + self.wait(2) + self.play(FadeOut(rect_int), FadeOut(rect_lim),FadeOut(const_text)) + + + non_rect_text=TextMobject(r"Now we see how to integrate over \\ non-rectangular regions") + non_rect_text.to_edge(UP) + self.play(Write(non_rect_text)) + self.wait(1.5) + self.play(FadeOut(rect_region)) + + c1= self.get_graph( + lambda x : x**2/4, + x_min = 0, + x_max = 4, + color = RED) + + c1_region = self.get_riemann_rectangles( + c1, + x_min = 0, + x_max = 4, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity = 0.75, + stroke_width = 0, + ) + self.add(c1,c1_region) + # self.wait(2) + + c2= self.get_graph( + lambda x :12-2*x, + x_min = 4, + x_max = 6, + color = RED) + + c2_region = self.get_riemann_rectangles( + c2, + x_min = 4, + x_max = 6, + dx =.01, + start_color = BLUE, + end_color = BLUE, + fill_opacity = .75, + stroke_width = 0, + ) + self.add(c2_region,c2) + self.wait(1.5) + c=VGroup(*[c1,c2]) + + no_func_text=TextMobject(r"The whole region can't be expressed as\\ bounded by a single $f(x)$").next_to(c2,UP,buff=LARGE_BUFF) + + self.play(ReplacementTransform(non_rect_text,no_func_text)) + self.wait(1) + self.play(Indicate(c)) + self.wait(2) + + div_region_text=TextMobject(r"So the region is divided into two").next_to(c2,UP,buff=MED_LARGE_BUFF) + self.play(ReplacementTransform(no_func_text,div_region_text)) + + c2.set_color(YELLOW) + self.play(c2_region.set_color,YELLOW) + c1_text=TextMobject("$\dfrac{x^2}{4}$").next_to(c1,IN) + c2_text=TextMobject("$12-2x$").next_to(c2,IN+2*X) + c_text=VGroup(*[c1_text,c2_text]) + + self.play(FadeIn(c_text)) + self.wait(.4) + self.play(Indicate(c1),Indicate(c1_text)) + self.play(Indicate(c2),Indicate(c2_text)) + + easy_text=TextMobject(r"Now the limis can be set easily").next_to(c2,UP,buff=.5) + self.play(ReplacementTransform(div_region_text,easy_text)) + + c1_int=TextMobject(r"$$\int_{x=0}^{4}\int_{y=0}^{\dfrac{x^2}{4}}$$").next_to(c1,IN).shift(.5*(-X+1.3*Y)) + c2_int=TextMobject(r"$$\int_{x=4}^{6}\int_{y=0}^{12-2x}$$").next_to(c2,IN+X) + + self.play(ReplacementTransform(c1_text,c1_int),ReplacementTransform(c2_text,c2_int)) + self.wait(2) + + total_int=TextMobject(r"The total integraton= ").to_edge(UP) + plus=TextMobject("$$+$$").move_to(self.graph_origin+4*X+4.8*Y) + self.play(ReplacementTransform(easy_text,total_int)) + self.play(c2_region.set_color,BLUE) + self.play(c1_int.next_to,c1,.1*UP, c2_int.next_to,plus,RIGHT, FadeIn(plus)) + + region=VGroup(*[c1_region,c2_region]) + region.set_color(GREEN) + self.play(ShowCreation(region)) + self.wait(3) + + + +#uploaded by Somnath Pandit.FSF2020_Double_Integral + + + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif new file mode 100644 index 0000000..5c9ac03 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py new file mode 100644 index 0000000..362b6f8 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file5_elementary_area.py @@ -0,0 +1,144 @@ +from manimlib.imports import * + +class ElementaryArea(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 2, + "y_min" : 0, + "y_max" : 2, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + # "x_labeled_nums": list(np.arange(0,3)), + # "y_labeled_nums": list(np.arange(0 ,3)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+3.5*LEFT+3.5*DOWN, + } + + def construct(self): + X = self.x_axis_width/(self.x_max- self.x_min) + Y = self.y_axis_height/(self.y_max- self.y_min) + self.X=X ;self.Y=Y + self.setup_axes(animate=False) + + caption=TextMobject("The elementary area in ").to_edge(UP) + rect_text=TextMobject("Cartesian Coordinates").next_to(caption,DOWN,) + polar_text=TextMobject("Polar Coordinates").next_to(caption,DOWN,) + + self.add(caption) + self.play(Write(rect_text)) + self.get_rect_element() + # self.play(Write(polar_text)) + self.play(ReplacementTransform(rect_text,polar_text), + FadeOut(VGroup(self.dydx,self.rect_brace_gr))) + self.get_polar_element() + + + + def get_rect_element(self): + rect=Rectangle( + height=2, width=3,fill_color=BLUE_D, + fill_opacity=1, color=BLUE_D + ).scale(.75).move_to( + self.graph_origin+(RIGHT*self.X+UP*self.Y) + ) + dx_brace=Brace(rect, DOWN, buff = SMALL_BUFF) + dx_label=dx_brace.get_text("$dx$", buff = SMALL_BUFF) + dx_brace_gr=VGroup(dx_brace,dx_label) + + dy_brace=Brace(rect,RIGHT, buff = SMALL_BUFF) + dy_label=dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_gr=VGroup(dy_brace,dy_label) + + brace_gr=VGroup(dx_brace_gr,dy_brace_gr) + + dydx=TextMobject("$dxdy$",color=BLACK).next_to(rect,IN) + + self.play(FadeIn(rect)) + self.play(GrowFromCenter(brace_gr)) + self.play(GrowFromCenter(dydx)) + + self.rect=rect + self.rect_brace_gr=brace_gr + self.dydx=dydx + self.wait(2) + + + def get_polar_element(self): + X=self.X ;Y=self.Y + theta1=25*DEGREES + dtheta=TAU/12 + r_in=1.3*X ; r_out=1.9*X + + arc=AnnularSector( + arc_center=self.graph_origin, + inner_radius=r_in, + outer_radius=r_out , + angle= dtheta, + start_angle= theta1, + fill_opacity= 1, + stroke_width= 0, + color= BLUE_D, + ) + + + # # #getting braces + r_in_theta1=self.graph_origin+r_in*(np.cos(theta1)*RIGHT+np.sin(theta1)*UP) + dr_line=Line(r_in_theta1,r_in_theta1+RIGHT*(r_out-r_in)) + dr_brace=Brace(dr_line, DOWN, buff = SMALL_BUFF + ).rotate(theta1, about_point=r_in_theta1 + ) + dr_label=dr_brace.get_text("$dr$", buff = SMALL_BUFF) + dr_brace_gr=VGroup(dr_brace,dr_label) + + theta2=theta1+dtheta + r_out_theta2=self.graph_origin+r_out*( + np.cos(theta2)*RIGHT+np.sin(theta2)*UP + ) + rdt_line=Line(r_out_theta2,r_out_theta2 + +DOWN*(r_out*dtheta) + ) + rdt_brace=Brace(rdt_line, RIGHT, + buff = MED_SMALL_BUFF).rotate( + theta2-(dtheta/2), about_point=r_out_theta2 + ) + rdt_label=rdt_brace.get_text("$rd\\theta$",buff = SMALL_BUFF) + rdt_brace_gr=VGroup(rdt_brace,rdt_label) + + #getting label r and dtheta + r1=DashedLine(self.graph_origin,r_in_theta1).set_color(RED) + r2=DashedLine(self.graph_origin,r_out_theta2).set_color(RED) + r_brace=Brace(r1, DOWN, buff = SMALL_BUFF).rotate(theta1, about_point=self.graph_origin) + r_label=r_brace.get_text("$r$", buff = SMALL_BUFF) + r_brace_gr=VGroup(r_brace,r_label) + + dtheta_arc=Arc( + arc_center=self.graph_origin, + radius=.5*X, + angle= dtheta, + start_angle= theta1, + ) + dtheta_arc_label=TextMobject("$d\\theta$").move_to(.99*dtheta_arc.get_corner(UR)) + dtheta_label=VGroup(dtheta_arc,dtheta_arc_label) + + + rdrdt=TextMobject("$rdrd\\theta$",color=BLACK).next_to(arc,IN) + self.play(ReplacementTransform(self.rect,arc)) + self.wait() + self.play(ShowCreation(r1), + ShowCreation(r2) + ) + self.play(ShowCreation(r_brace_gr), + Write(dtheta_label) + ) + self.wait() + self.play(GrowFromCenter(rdt_brace_gr)) + self.wait(.5) + self.play(GrowFromCenter(dr_brace_gr)) + self.wait(.5) + self.play(GrowFromCenter(rdrdt)) + + self.wait(2) + + + #uploaded by Somnath Pandit.FSF2020_Double_Integral 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 deleted file mode 100644 index c8e7c8c..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.gif and /dev/null differ 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/non_rect_region.py deleted file mode 100644 index 793a000..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/non_rect_region.py +++ /dev/null @@ -1,154 +0,0 @@ -from manimlib.imports import * - -class AreaUnderCurve(GraphScene): - CONFIG = { - "x_min" : -1, - "x_max" : 8, - "y_min" : -1, - "y_max" : 5, - "y_axis_label": "$y$", - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(-1, 9)), - "y_labeled_nums": list(np.arange(-1, 6)), - "y_axis_height":5.5, - "graph_origin": ORIGIN+4*LEFT+2.5*DOWN, - } - - def construct(self): - X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) - Y = UP*self.y_axis_height/(self.y_max- self.y_min) - - sofar_text=TextMobject(r"So far we have integrated over \\ rectangular regions") - self.play(Write(sofar_text)) - self.play(sofar_text.to_edge,UP) - - self.setup_axes(animate=False) - - rect= self.get_graph( - lambda x : 3, - x_min = 0, - x_max = 5, - color = GREEN) - - rect_region = self.get_riemann_rectangles( - rect, - x_min = 0, - x_max = 5, - dx =.01, - start_color = GREEN, - end_color = GREEN, - fill_opacity = 0.75, - stroke_width = 0, - ) - - self.play(ShowCreation(rect_region)) - self.wait(.5) - - rect_int=TextMobject(r"Here the integration limits are set as").to_edge(UP) - rect_lim=TextMobject(r"$$\int_{x=0}^{5}\int_{y=0}^{3}$$").next_to(rect_int,DOWN) - const_text=TextMobject(r"$\longleftarrow $ \textsf the limits are\\ constant values").next_to(rect_lim,RIGHT) - - self.play(ReplacementTransform(sofar_text,rect_int)) - self.wait(1.5) - self.play(FadeIn(rect_lim)) - self.wait(2) - self.play(Write(const_text)) - self.wait(2) - self.play(FadeOut(rect_int), FadeOut(rect_lim),FadeOut(const_text)) - - - non_rect_text=TextMobject(r"Now we see how to integrate over \\ non-rectangular regions") - non_rect_text.to_edge(UP) - self.play(Write(non_rect_text)) - self.wait(1.5) - self.play(FadeOut(rect_region)) - - c1= self.get_graph( - lambda x : x**2/4, - x_min = 0, - x_max = 4, - color = RED) - - c1_region = self.get_riemann_rectangles( - c1, - x_min = 0, - x_max = 4, - dx =.01, - start_color = BLUE, - end_color = BLUE, - fill_opacity = 0.75, - stroke_width = 0, - ) - self.add(c1,c1_region) - # self.wait(2) - - c2= self.get_graph( - lambda x :12-2*x, - x_min = 4, - x_max = 6, - color = RED) - - c2_region = self.get_riemann_rectangles( - c2, - x_min = 4, - x_max = 6, - dx =.01, - start_color = BLUE, - end_color = BLUE, - fill_opacity = .75, - stroke_width = 0, - ) - self.add(c2_region,c2) - self.wait(1.5) - c=VGroup(*[c1,c2]) - - no_func_text=TextMobject(r"The whole region can't be expressed as\\ bounded by a single $f(x)$").next_to(c2,UP,buff=LARGE_BUFF) - - self.play(ReplacementTransform(non_rect_text,no_func_text)) - self.wait(1) - self.play(Indicate(c)) - self.wait(2) - - div_region_text=TextMobject(r"So the region is divided into two").next_to(c2,UP,buff=MED_LARGE_BUFF) - self.play(ReplacementTransform(no_func_text,div_region_text)) - - c2.set_color(YELLOW) - self.play(c2_region.set_color,YELLOW) - c1_text=TextMobject("$\dfrac{x^2}{4}$").next_to(c1,IN) - c2_text=TextMobject("$12-2x$").next_to(c2,IN+2*X) - c_text=VGroup(*[c1_text,c2_text]) - - self.play(FadeIn(c_text)) - self.wait(.4) - self.play(Indicate(c1),Indicate(c1_text)) - self.play(Indicate(c2),Indicate(c2_text)) - - easy_text=TextMobject(r"Now the limis can be set easily").next_to(c2,UP,buff=.5) - self.play(ReplacementTransform(div_region_text,easy_text)) - - c1_int=TextMobject(r"$$\int_{x=0}^{4}\int_{y=0}^{\dfrac{x^2}{4}}$$").next_to(c1,IN).shift(.5*(-X+1.3*Y)) - c2_int=TextMobject(r"$$\int_{x=4}^{6}\int_{y=0}^{12-2x}$$").next_to(c2,IN+X) - - self.play(ReplacementTransform(c1_text,c1_int),ReplacementTransform(c2_text,c2_int)) - self.wait(2) - - total_int=TextMobject(r"The total integraton= ").to_edge(UP) - plus=TextMobject("$$+$$").move_to(self.graph_origin+4*X+4.8*Y) - self.play(ReplacementTransform(easy_text,total_int)) - self.play(c2_region.set_color,BLUE) - self.play(c1_int.next_to,c1,.1*UP, c2_int.next_to,plus,RIGHT, FadeIn(plus)) - - region=VGroup(*[c1_region,c2_region]) - region.set_color(GREEN) - self.play(ShowCreation(region)) - self.wait(3) - - - -#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 deleted file mode 100644 index ae23a7b..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.gif and /dev/null differ 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/surface.py deleted file mode 100644 index a794f46..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/surface.py +++ /dev/null @@ -1,236 +0,0 @@ -from manimlib.imports import * - -class SurfacesAnimation(ThreeDScene): - - CONFIG = { - "axes_config": { - "x_min": 0, - "x_max": 8, - "y_min": 0, - "y_max": 8, - "z_min": 0, - "z_max": 6, - "a":1 ,"b": 6, "c":2 , "d":6, - "axes_shift":-3*OUT + 5*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: 2+y/4+np.sin(x) - } - - - def construct(self): - - self.setup_axes() - self.set_camera_orientation(distance=35, - phi=80 * DEGREES, - theta=-80 * 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) - - R=TextMobject("R").set_color(BLACK).scale(3) - 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.8, - fill_color=PINK, - stroke_width=0.8, - stroke_color=WHITE, - ) - - - self.begin_ambient_camera_rotation(rate=0.07) - self.play(Write(surface)) - # self.play(LaggedStart(ShowCreation(surface))) - - self.get_lines() - # self.play(FadeIn(self.axes.input_plane)) - self.wait(3) - - 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 - 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,"RED")) - - 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, 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,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), - ("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/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 deleted file mode 100644 index a2bfd9d..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.gif and /dev/null differ 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/y_limit_dependent_on_x.py deleted file mode 100644 index 4894ebf..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/y_limit_dependent_on_x.py +++ /dev/null @@ -1,113 +0,0 @@ -from manimlib.imports import * - -class YlimitXdependent(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 1, - "y_min" : 0, - "y_max" : 2, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(0,2)), - "y_labeled_nums": list(np.arange(0 ,3)), - "x_axis_width": 3.5, - "y_axis_height": 6, - "graph_origin": ORIGIN+2.5*LEFT+3*DOWN, - } - - def construct(self): - X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) - Y = UP*self.y_axis_height/(self.y_max- self.y_min) - - self.setup_axes(animate=False) - - line= self.get_graph( - lambda x : 2-2*x , - x_min = 0, - x_max = 1, - color = RED) - 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) - self.play(ShowCreation(line),Write(line_eqn)) - # self.show_area() - self.show_rects() - self.play(Write(caption)) - self.show_y_values_at_different_x() - - self.wait(.5) - - ################### - def show_area(self): - area = self.get_riemann_rectangles( - self.line, - x_min = 0, - x_max = 1, - dx =.0001, - start_color = BLUE, - end_color = BLUE, - fill_opacity = 1, - stroke_width = 0, - ) - self.play(ShowCreation(area)) - # self.transform_between_riemann_rects(self.rects,area) - self.area = area - - def show_rects(self): - rects = self.get_riemann_rectangles( - self.line, - x_min = 0, - x_max = 1, - dx =.01, - start_color = BLUE, - end_color = BLUE, - fill_opacity =1, - stroke_width = 0, - ) - # self.play(ShowCreation(rects)) - # self.transform_between_riemann_rects(self.area,rects) - self.rects=rects - - def show_y_values_at_different_x(self): - rects=self.rects - rect = rects[len(rects)*1//10] - dx_brace = Brace(rect, DOWN, buff = 0) - dx_label = dx_brace.get_text("$dx$", buff = SMALL_BUFF) - dx_brace_group = VGroup(dx_brace,dx_label) - rp=int(len(rects)/10) - rects_subset = self.rects[3*rp:5*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, LEFT, buff = 0) - y = TexMobject("y=2-2x")#.rotate(PI/2) - y.next_to(brace, LEFT, SMALL_BUFF) - anims = [ - rect.set_fill, BLUE_E, 1, - dx_brace_group.next_to, rect, DOWN, SMALL_BUFF - ] - if last_rect is not None: - anims += [ - last_rect.set_fill, None, 0, - # last_rect.set_fill, BLUE, .75, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_y, y), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(y) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_y = y - - y = last_y - y_brace = last_brace - - -#uploaded by Somnath Pandit.FSF2020_Double_Integral -- cgit From 774fda4a9da1a3a0f87ce8d365e206a7eff58551 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 16:41:12 +0530 Subject: modification and new files --- .../file3_y_limit_dependent_on_x.gif | Bin 1170435 -> 1165354 bytes .../file3_y_limit_dependent_on_x.py | 2 +- .../double-integrals/file6_doing_integration.gif | Bin 0 -> 6661372 bytes .../double-integrals/file6_doing_integration.py | 332 +++++++++++++++++++++ .../file7_int_process_of_example.gif | Bin 0 -> 6100824 bytes .../file7_int_process_of_example.py | 328 ++++++++++++++++++++ 6 files changed, 661 insertions(+), 1 deletion(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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 index a2bfd9d..dcfacb6 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_y_limit_dependent_on_x.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file3_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/file3_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/file6_doing_integration.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif new file mode 100644 index 0000000..cafed44 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif differ 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..34d1769 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.py @@ -0,0 +1,332 @@ +from manimlib.imports import * + +class IntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 8, + "y_min": 0, + "y_max": 8, + "z_min": 0, + "z_max": 6, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT + 5*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: 2+y/4+np.cos(x) + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + self.set_camera_orientation(distance=35, + phi=85 * DEGREES, + theta=-80 * 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) + + 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=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.08) + # self.play(Write(surface)) + self.add(surface) + + self.get_lines() + + self.show_process(axes) + + self.wait(2) + + + + 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=.5, + )) + plane.suspend_updating() + + self.play(Write(VGroup(graph,plane)),run_time=4) + graph.resume_updating() + plane.resume_updating() + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + + + 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_y_slice_plane(self, axes): + self.y_tracker=y_tracker + y=y_tracker.get_value() + curve_points=[ + axes.c2p(x,y,self.Func(x,y)) + for x in np.arange(axes.a,axes.b,0.01) + ] + base_points=[ + axes.c2p(x, y, 0) + for x in [ axes.b, axes.a,] + ] + plane_points= curve_points+base_points + plane = always_redraw(lambda: Polygon( + *plane_points, + stroke_width=.4, + fill_color=BLUE, + fill_opacity=0.2 + )) + plane.add_updater(lambda m: m.shift( + axes.c2p( + axes.a, + y_tracker.get_value(), + 1, + ) - plane.points[0] + )) + plane.y_tracker = y_tracker + + return plane ''' + + 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 + 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,"RED")) + + 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)) + 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 + + 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,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), + ("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 new file mode 100644 index 0000000..d48656b Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif differ 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..ab9337d --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.py @@ -0,0 +1,328 @@ +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.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)) + graph.resume_updating() + plane.resume_updating() + self.play( + ApplyMethod( + y_tracker.set_value, axes.d, + rate_func=linear, + run_time=6, + ) + ) + + + 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 + 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,"RED")) + + 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)) + 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,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=[ + + ("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 -- cgit From 3ed5bc5ee874d84982c443d3cbde0828f124de2c Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 17:10:21 +0530 Subject: Create README.md --- .../double-integrals/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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..fe4d73a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/README.md @@ -0,0 +1,21 @@ +**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) + +**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) + +**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) + -- cgit From dd85fa70fa196fac02b88b84bdac4587a76139b8 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Wed, 10 Jun 2020 22:21:44 +0530 Subject: update with upgrade --- .../double-integrals/file6_doing_integration.gif | Bin 6661372 -> 3349455 bytes .../double-integrals/file6_doing_integration.py | 141 ++++++++++++--------- .../file7_int_process_of_example.gif | Bin 6100824 -> 3031924 bytes .../file7_int_process_of_example.py | 62 +++++++-- 4 files changed, 132 insertions(+), 71 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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 index cafed44..7a9271b 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file6_doing_integration.gif differ 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 index 34d1769..5a8cec0 100644 --- 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 @@ -5,13 +5,13 @@ class IntegrationProcess(SpecialThreeDScene): 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": 4, "a":1 ,"b": 6, "c":2 , "d":6, - "axes_shift":-3*OUT + 5*LEFT, + "axes_shift":-3*OUT, "x_axis_config": { "tick_frequency": 1, # "include_tip": False, @@ -37,7 +37,7 @@ class IntegrationProcess(SpecialThreeDScene): "stroke_color": WHITE, "stroke_opacity": 0.5, }, - "Func": lambda x,y: 2+y/4+np.cos(x) + "Func": lambda x,y: 2+y/4+np.cos(x/1.4) } @@ -45,31 +45,34 @@ class IntegrationProcess(SpecialThreeDScene): self.setup_axes() axes=self.axes + + self.camera.frame_center.shift(axes.c2p(3,4,1.7)) self.set_camera_orientation(distance=35, - phi=85 * DEGREES, - theta=-80 * DEGREES, + 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) - fn_text.to_edge(TOP,buff=MED_SMALL_BUFF) + R=TextMobject("R").set_color(BLACK).scale(3) R.move_to(axes.input_plane,IN) self.add(R) - #get the surface + # get the surface surface= self.get_surface( axes, lambda x , y: self.Func(x,y) ) surface.set_style( - fill_opacity=0.75, + 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)) @@ -79,10 +82,10 @@ class IntegrationProcess(SpecialThreeDScene): self.add(surface) self.get_lines() - + self.show_process(axes) - self.wait(2) + self.wait(3) @@ -90,6 +93,7 @@ class IntegrationProcess(SpecialThreeDScene): 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(), @@ -107,24 +111,67 @@ class IntegrationProcess(SpecialThreeDScene): ], *[ axes.c2p(x, y(), 0) - for x in [ axes.b, axes.a,] + for x in [ axes.b, axes.a,] ], - stroke_width=0, + 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=.5, + 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.play(Write(VGroup(graph,plane)),run_time=4) - graph.resume_updating() - plane.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): @@ -142,35 +189,7 @@ class IntegrationProcess(SpecialThreeDScene): **config, ) return slice_curve - - '''def get_y_slice_plane(self, axes): - self.y_tracker=y_tracker - y=y_tracker.get_value() - curve_points=[ - axes.c2p(x,y,self.Func(x,y)) - for x in np.arange(axes.a,axes.b,0.01) - ] - base_points=[ - axes.c2p(x, y, 0) - for x in [ axes.b, axes.a,] - ] - plane_points= curve_points+base_points - plane = always_redraw(lambda: Polygon( - *plane_points, - stroke_width=.4, - fill_color=BLUE, - fill_opacity=0.2 - )) - plane.add_updater(lambda m: m.shift( - axes.c2p( - axes.a, - y_tracker.get_value(), - 1, - ) - plane.points[0] - )) - plane.y_tracker = y_tracker - - return plane ''' + def get_surface(self,axes, func, **kwargs): config = { @@ -195,9 +214,6 @@ class IntegrationProcess(SpecialThreeDScene): 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: @@ -207,13 +223,17 @@ class IntegrationProcess(SpecialThreeDScene): 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,"BLUE")) - # print (start,end) - pass - # self.play(ShowCreation(lines)) + lines.add(self.draw_lines(start,end,"WHITE")) self.add(lines) @@ -223,7 +243,10 @@ class IntegrationProcess(SpecialThreeDScene): 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) @@ -260,7 +283,7 @@ class IntegrationProcess(SpecialThreeDScene): 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 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 index d48656b..9fbdde8 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file7_int_process_of_example.gif differ 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 index ab9337d..f733761 100644 --- 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 @@ -113,7 +113,35 @@ class IntegrationProcess(SpecialThreeDScene): 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) @@ -138,8 +166,11 @@ class IntegrationProcess(SpecialThreeDScene): 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, @@ -148,6 +179,11 @@ class IntegrationProcess(SpecialThreeDScene): ) ) + 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() @@ -189,9 +225,6 @@ class IntegrationProcess(SpecialThreeDScene): 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: @@ -201,13 +234,17 @@ class IntegrationProcess(SpecialThreeDScene): 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,"BLUE")) - # print (start,end) - pass - # self.play(ShowCreation(lines)) + lines.add(self.draw_lines(start,end,"WHITE")) self.add(lines) @@ -217,9 +254,10 @@ class IntegrationProcess(SpecialThreeDScene): line=DashedLine(start,end,color=color) return line - - - #customize 3D axes + + +#------------------------------------------------------------ + #customize 3d axes def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): config = dict(self.axes_config) config.update(kwargs) @@ -256,7 +294,7 @@ class IntegrationProcess(SpecialThreeDScene): 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 -- cgit From 1c8492c83d0b953c2e9f62f0ddb761c33b52b943 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 11 Jun 2020 17:43:42 +0530 Subject: updated after review --- .../double-integrals/README.md | 8 +- .../double-integrals/file1_area_under_func.gif | Bin 0 -> 1277788 bytes .../double-integrals/file1_area_under_func.py | 73 +++++ .../double-integrals/file1_surface.gif | Bin 3365528 -> 0 bytes .../double-integrals/file1_surface.py | 236 ---------------- .../double-integrals/file2_area_under_func.gif | Bin 1277788 -> 0 bytes .../double-integrals/file2_area_under_func.py | 73 ----- .../file2_volume_under_surface.gif | Bin 0 -> 5460831 bytes .../double-integrals/file2_volume_under_surface.py | 314 +++++++++++++++++++++ 9 files changed, 391 insertions(+), 313 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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/file1_area_under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif new file mode 100644 index 0000000..223218b Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py new file mode 100644 index 0000000..773840c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_area_under_func.py @@ -0,0 +1,73 @@ +from manimlib.imports import * + + +class AreaUnderIntegral(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 5, + "y_min" : 0, + "y_max" : 6, + "Func":lambda x : 1+x**2*np.exp(-.15*x**2) + } + + def construct(self): + X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) + Y = UP*self.y_axis_height/(self.y_max- self.y_min) + + int_area_sym=TextMobject("$$\int_{a}^b f(x)dx$$").shift(2*UP) + area_mean_text = TextMobject(r"means area under the curve of $f(x)$ \\ in the region $a\leq x\leq b$").next_to(int_area_sym,DOWN) + + opening_text=VGroup(*[int_area_sym,area_mean_text]) + self.play(Write(opening_text),run_time=4) + self.wait(2) + self.play(FadeOut(opening_text)) + + self.setup_axes(animate=True) + func= self.get_graph(self.Func, x_min=0,x_max=5) + self.curve=func + + func_text = TextMobject(r"$y = f(x)$").next_to(func,UP) + min_lim = self.get_vertical_line_to_graph(1,func,DashedLine,color=YELLOW) + tick_a=TextMobject(r"$a$").next_to(min_lim,DOWN) + max_lim = self.get_vertical_line_to_graph(4,func,DashedLine,color=YELLOW) + tick_b=TextMobject(r"$b$").next_to(max_lim,DOWN) + + # area = self.get_area(func,1,4) + + self.play(ShowCreation(func), ShowCreation(func_text)) + + self.wait(2) + self.play(ShowCreation(min_lim),Write(tick_a), ShowCreation(max_lim),Write(tick_b),run_time=0.5) + + + approx_text=TextMobject(r"The area can be approximated as \\ sum of small rectangles").next_to(func,4*Y) + self.play(Write(approx_text)) + + rect_list = self.get_riemann_rectangles_list( + self.curve, 5, + max_dx = 0.25, + x_min = 1, + x_max = 4, + ) + flat_graph = self.get_graph(lambda t : 0) + rects = self.get_riemann_rectangles( flat_graph, x_min = 1, x_max = 4, dx = 0.5) + for new_rects in rect_list: + new_rects.set_fill(opacity = 0.8) + rects.align_submobjects(new_rects) + for alt_rect in rects[::2]: + alt_rect.set_fill(opacity = 0) + self.play(Transform( + rects, new_rects, + run_time = 1.5, + lag_ratio = 0.5 + )) + conclude_text=TextMobject(r"Making the rectangles infinitesimally thin \\ we get the real area under the curve.").next_to(func,4*Y) + self.play(Transform(approx_text,conclude_text)) + self.wait(3) + int_area_sym.next_to(self.curve,IN) + self.play(Transform(conclude_text,int_area_sym)) + + # self.play(ShowCreation(area)) + self.wait(3) + +#uploaded by Somnath Pandit.FSF2020_Double_Integral 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 deleted file mode 100644 index ae23a7b..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.gif and /dev/null differ 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/file1_surface.py deleted file mode 100644 index a794f46..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file1_surface.py +++ /dev/null @@ -1,236 +0,0 @@ -from manimlib.imports import * - -class SurfacesAnimation(ThreeDScene): - - CONFIG = { - "axes_config": { - "x_min": 0, - "x_max": 8, - "y_min": 0, - "y_max": 8, - "z_min": 0, - "z_max": 6, - "a":1 ,"b": 6, "c":2 , "d":6, - "axes_shift":-3*OUT + 5*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: 2+y/4+np.sin(x) - } - - - def construct(self): - - self.setup_axes() - self.set_camera_orientation(distance=35, - phi=80 * DEGREES, - theta=-80 * 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) - - R=TextMobject("R").set_color(BLACK).scale(3) - 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.8, - fill_color=PINK, - stroke_width=0.8, - stroke_color=WHITE, - ) - - - self.begin_ambient_camera_rotation(rate=0.07) - self.play(Write(surface)) - # self.play(LaggedStart(ShowCreation(surface))) - - self.get_lines() - # self.play(FadeIn(self.axes.input_plane)) - self.wait(3) - - 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 - 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,"RED")) - - 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, 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,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), - ("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/file2_area_under_func.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif deleted file mode 100644 index 223218b..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.gif and /dev/null differ 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/file2_area_under_func.py deleted file mode 100644 index 773840c..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_area_under_func.py +++ /dev/null @@ -1,73 +0,0 @@ -from manimlib.imports import * - - -class AreaUnderIntegral(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 5, - "y_min" : 0, - "y_max" : 6, - "Func":lambda x : 1+x**2*np.exp(-.15*x**2) - } - - def construct(self): - X = RIGHT*self.x_axis_width/(self.x_max- self.x_min) - Y = UP*self.y_axis_height/(self.y_max- self.y_min) - - int_area_sym=TextMobject("$$\int_{a}^b f(x)dx$$").shift(2*UP) - area_mean_text = TextMobject(r"means area under the curve of $f(x)$ \\ in the region $a\leq x\leq b$").next_to(int_area_sym,DOWN) - - opening_text=VGroup(*[int_area_sym,area_mean_text]) - self.play(Write(opening_text),run_time=4) - self.wait(2) - self.play(FadeOut(opening_text)) - - self.setup_axes(animate=True) - func= self.get_graph(self.Func, x_min=0,x_max=5) - self.curve=func - - func_text = TextMobject(r"$y = f(x)$").next_to(func,UP) - min_lim = self.get_vertical_line_to_graph(1,func,DashedLine,color=YELLOW) - tick_a=TextMobject(r"$a$").next_to(min_lim,DOWN) - max_lim = self.get_vertical_line_to_graph(4,func,DashedLine,color=YELLOW) - tick_b=TextMobject(r"$b$").next_to(max_lim,DOWN) - - # area = self.get_area(func,1,4) - - self.play(ShowCreation(func), ShowCreation(func_text)) - - self.wait(2) - self.play(ShowCreation(min_lim),Write(tick_a), ShowCreation(max_lim),Write(tick_b),run_time=0.5) - - - approx_text=TextMobject(r"The area can be approximated as \\ sum of small rectangles").next_to(func,4*Y) - self.play(Write(approx_text)) - - rect_list = self.get_riemann_rectangles_list( - self.curve, 5, - max_dx = 0.25, - x_min = 1, - x_max = 4, - ) - flat_graph = self.get_graph(lambda t : 0) - rects = self.get_riemann_rectangles( flat_graph, x_min = 1, x_max = 4, dx = 0.5) - for new_rects in rect_list: - new_rects.set_fill(opacity = 0.8) - rects.align_submobjects(new_rects) - for alt_rect in rects[::2]: - alt_rect.set_fill(opacity = 0) - self.play(Transform( - rects, new_rects, - run_time = 1.5, - lag_ratio = 0.5 - )) - conclude_text=TextMobject(r"Making the rectangles infinitesimally thin \\ we get the real area under the curve.").next_to(func,4*Y) - self.play(Transform(approx_text,conclude_text)) - self.wait(3) - int_area_sym.next_to(self.curve,IN) - self.play(Transform(conclude_text,int_area_sym)) - - # self.play(ShowCreation(area)) - self.wait(3) - -#uploaded by Somnath Pandit.FSF2020_Double_Integral 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 new file mode 100644 index 0000000..74c306d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py new file mode 100644 index 0000000..cd4060b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py @@ -0,0 +1,314 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 7, + "y_min": 0, + "y_max": 7, + "z_min": 0, + "z_max": 5, + "a":1 ,"b": 6, "c":2 , "d":6, + "axes_shift":-3*OUT + 5*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: 2+y/4+np.sin(x) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(distance=35, + phi=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) + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.8, + fill_color=PINK, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.08) + self.play(Write(surface)) + # self.add(surface) + + self.get_lines() + 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 = { + "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,"#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")) + + # 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) + 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 + + -- cgit From 70f35b9f0b2f01ca60416fb24e8f4618cdd93735 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Fri, 12 Jun 2020 18:41:59 +0530 Subject: more upgrade --- .../file2_volume_under_surface.gif | Bin 5460831 -> 6614909 bytes .../double-integrals/file2_volume_under_surface.py | 47 ++++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals') 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 index 74c306d..1455573 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py index cd4060b..38d41c6 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/double-integrals/file2_volume_under_surface.py @@ -49,11 +49,19 @@ class SurfacesAnimation(ThreeDScene): 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) + 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) @@ -73,7 +81,7 @@ class SurfacesAnimation(ThreeDScene): ) - self.begin_ambient_camera_rotation(rate=0.08) + self.begin_ambient_camera_rotation(rate=0.06) self.play(Write(surface)) # self.add(surface) @@ -81,14 +89,42 @@ class SurfacesAnimation(ThreeDScene): self.wait(1) self.add_fixed_in_frame_mobjects(riemann_sum_text) self.play(Write(riemann_sum_text)) - self.show_the_riemmann_sum( + + 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) @@ -203,8 +239,7 @@ class SurfacesAnimation(ThreeDScene): cuboid.set_stroke(stroke_color, width=stroke_width) cuboids.add(cuboid) - self.play(ShowCreation(cuboids),run_time=6) - # self.add(cuboids) + return cuboids #------------------------------------------------------- -- cgit