From a240c40156d5a05eb0ec95d2002241ab84ebca81 Mon Sep 17 00:00:00 2001 From: Purusharth S Date: Sat, 23 May 2020 18:32:54 +0530 Subject: add topic folders --- .../integrals-of-multivariable-functions/README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md new file mode 100644 index 0000000..e69de29 -- cgit 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 --- .../integrals-of-multivariable-functions/README.md | 1 + .../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 ++++++++++ 7 files changed, 721 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') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index e69de29..a321caf 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -0,0 +1 @@ +FSF2020--Somnath Pandit 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') 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 7e916bc0e70e242451a49896286e4928693c2663 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Mon, 25 May 2020 20:51:21 +0530 Subject: added fubini's theorem --- .../fubini's_theorem/SurfacesAnimation.gif | Bin 0 -> 3752052 bytes .../fubini's_theorem/surface1.py | 230 +++++++++++++++++++++ 2 files changed, 230 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif new file mode 100644 index 0000000..8c9fa0a Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py new file mode 100644 index 0000000..3d04bf4 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py @@ -0,0 +1,230 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -4, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+LEFT, + "x_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 5*(x**2-y**2)/((1e-4+x**2+y**2)**2) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(#distance=10, + phi=80 * DEGREES, + theta=35 * DEGREES, + ) + + fn_text=TextMobject("$z=\dfrac{x^2-y^2}{(x^2+y^2)^2}$").set_color(BLUE) + fn_text.to_corner(UR,buff=1) + self.add_fixed_in_frame_mobjects(fn_text) + + R=TextMobject("R").set_color(BLACK).scale(2).rotate(180*DEGREES , OUT) + R.move_to(self.axes.input_plane,IN) + self.add(R) + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.6, + fill_color=BLUE_E, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.2) + self.play(Write(surface)) + + self.get_lines() + self.wait(4) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), + axes.y_axis.n2p(axes.d)] + + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"YELLOW")) + + for start , end in zip(labels, + self.region_corners): + # lines.add(self.draw_lines(start,end,"BLUE")) + # print (start,end) + pass + self.play(ShowCreation(lines)) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("a", axes.a+.4), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c+.4), + ("d", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + -- cgit From 14402f0e37ee1a58e81f7e322f8b6d06e7cb797a Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Mon, 25 May 2020 21:03:23 +0530 Subject: renamed surafce1 gif in fubini's theorem --- .../fubini's_theorem/SurfacesAnimation.gif | Bin 3752052 -> 0 bytes .../fubini's_theorem/surface1.gif | Bin 0 -> 3752052 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif deleted file mode 100644 index 8c9fa0a..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/SurfacesAnimation.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif new file mode 100644 index 0000000..8c9fa0a Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif differ -- cgit From eca0130163ba0a8520d9a28565456078ee963e69 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Mon, 25 May 2020 21:18:37 +0530 Subject: added tag to surface1.py in fubini --- .../integrals-of-multivariable-functions/fubini's_theorem/surface1.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py index 3d04bf4..bad318f 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py @@ -227,4 +227,6 @@ class SurfacesAnimation(ThreeDScene): axis.add(axis.label) return axes - +#uploaded by Somnath Pandit.FSF2020_Fubini's Theorem + + -- cgit From 0a079186b73414908e7af909bb950dacb7ebac07 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 26 May 2020 03:08:39 +0530 Subject: added surface2 --- .../fubini's_theorem/surface1.py | 2 +- .../fubini's_theorem/surface2.gif | Bin 0 -> 2556585 bytes .../fubini's_theorem/surface2.py | 286 +++++++++++++++++++++ 3 files changed, 287 insertions(+), 1 deletion(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py index bad318f..a590a53 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py @@ -227,6 +227,6 @@ class SurfacesAnimation(ThreeDScene): axis.add(axis.label) return axes -#uploaded by Somnath Pandit.FSF2020_Fubini's Theorem +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif new file mode 100644 index 0000000..ac13f21 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py new file mode 100644 index 0000000..c998f3b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py @@ -0,0 +1,286 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -2, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+2*LEFT+2*DOWN, + "x_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: x*y/4 + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation( + distance=30, + phi=75 * DEGREES, + theta=20 * DEGREES, + ) + + fn_text=TextMobject("$z=xy$").set_color(BLUE).scale(1.5) + fn_text.to_corner(UR,buff=2) + self.add_fixed_in_frame_mobjects(fn_text) + + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=.5, + fill_color=BLUE_E, + stroke_width=0.2, + stroke_color=WHITE, + ) + #get boundary curves + c1=self.get_curve( + self.axes, lambda x: x**2/4 + ) + c1_label=TextMobject("$y=x^2$").next_to(c1,IN+OUT).shift(DOWN+RIGHT) + c1_label.rotate(PI) + c1_group=VGroup(c1,c1_label).set_color(ORANGE) + + c2=self.get_curve( + self.axes, lambda x: x + ).set_color(PINK) + c2_label=TextMobject("$y=x$").next_to(c2,IN+OUT) + c2_label.rotate(PI/2,about_point=(c2_label.get_corner(UL))) + c2_group=VGroup(c2,c2_label).set_color(YELLOW_E) + + + + self.add(c1,c2,c1_label,c2_label) + + self.begin_ambient_camera_rotation(rate=0.4) + self.get_region(self.axes,c1,c2) + self.play(Write(surface)) + self.get_lines() + self.wait(1) + self.stop_ambient_camera_rotation() + self.move_camera( + distance=20, + phi=10 * DEGREES, + theta=80 * DEGREES, + run_time=2.5 + ) + self.wait(2) + + + + def get_curve(self,axes, func, **kwargs): + config = { + "t_min": axes.x_min, + "t_max": axes.x_max, + } + config.update(kwargs) + return ParametricFunction( + lambda x : axes.c2p( + x, func(x),0 + ), + **config + ) + + def get_region(self,axes,curve1,curve2,**kwargs): + x_vals=np.arange(axes.x_min,axes.x_max,.1) + c1_points=[curve1.get_point_from_function(x) for x in x_vals] + c2_points=[curve2.get_point_from_function(x) for x in x_vals] + c2_points.reverse() + points=c1_points+c2_points + region=Polygon(*points, + stroke_width=0, + fill_color=PINK, + fill_opacity=.5 + ) + R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) + R.move_to(region,IN+RIGHT) + + self.play(Write(region)) + self.add(R) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), + axes.y_axis.n2p(axes.d)] + + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"YELLOW")) + + for start , end in zip(labels, + self.region_corners): + # lines.add(self.draw_lines(start,end,"BLUE")) + # print (start,end) + pass + self.play(ShowCreation(lines)) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + # axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("1", axes.b), + ] + tex_vals_y=[ + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + + -- 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 -------- .../fubini's-theorem/file1_surface1.gif | Bin 0 -> 3752052 bytes .../fubini's-theorem/file1_surface1.py | 232 +++++++++++++++++ .../fubini's-theorem/file2_surface2.gif | Bin 0 -> 2556585 bytes .../fubini's-theorem/file2_surface2.py | 286 +++++++++++++++++++++ .../fubini's_theorem/surface1.gif | Bin 3752052 -> 0 bytes .../fubini's_theorem/surface1.py | 232 ----------------- .../fubini's_theorem/surface2.gif | Bin 2556585 -> 0 bytes .../fubini's_theorem/surface2.py | 286 --------------------- 28 files changed, 1238 insertions(+), 1238 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 create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') 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 diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif new file mode 100644 index 0000000..8c9fa0a Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py new file mode 100644 index 0000000..a590a53 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.py @@ -0,0 +1,232 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -4, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+LEFT, + "x_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: 5*(x**2-y**2)/((1e-4+x**2+y**2)**2) + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation(#distance=10, + phi=80 * DEGREES, + theta=35 * DEGREES, + ) + + fn_text=TextMobject("$z=\dfrac{x^2-y^2}{(x^2+y^2)^2}$").set_color(BLUE) + fn_text.to_corner(UR,buff=1) + self.add_fixed_in_frame_mobjects(fn_text) + + R=TextMobject("R").set_color(BLACK).scale(2).rotate(180*DEGREES , OUT) + R.move_to(self.axes.input_plane,IN) + self.add(R) + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.6, + fill_color=BLUE_E, + stroke_width=0.8, + stroke_color=WHITE, + ) + + + self.begin_ambient_camera_rotation(rate=0.2) + self.play(Write(surface)) + + self.get_lines() + self.wait(4) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), + axes.y_axis.n2p(axes.d)] + + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"YELLOW")) + + for start , end in zip(labels, + self.region_corners): + # lines.add(self.draw_lines(start,end,"BLUE")) + # print (start,end) + pass + self.play(ShowCreation(lines)) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("a", axes.a+.4), + ("b", axes.b), + ] + tex_vals_y=[ + ("c", axes.c+.4), + ("d", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif new file mode 100644 index 0000000..ac13f21 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py new file mode 100644 index 0000000..c998f3b --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py @@ -0,0 +1,286 @@ +from manimlib.imports import * + +class SurfacesAnimation(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": -2, + "z_max": 4, + "a":0 ,"b": 4, "c":0 , "d":4, + "axes_shift":IN+2*LEFT+2*DOWN, + "x_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "y_axis_config": { + "tick_frequency": 1, + "include_tip": False, + }, + "z_axis_config": { + "tick_frequency": 1, + # "include_tip": False, + }, + "num_axis_pieces": 1, + }, + "default_graph_style": { + "stroke_width": 2, + "stroke_color": WHITE, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [LIGHT_GREY], + "stroke_width": 0.5, + "stroke_color": WHITE, + "stroke_opacity": 0.5, + }, + "Func": lambda x,y: x*y/4 + } + + + def construct(self): + + self.setup_axes() + self.set_camera_orientation( + distance=30, + phi=75 * DEGREES, + theta=20 * DEGREES, + ) + + fn_text=TextMobject("$z=xy$").set_color(BLUE).scale(1.5) + fn_text.to_corner(UR,buff=2) + self.add_fixed_in_frame_mobjects(fn_text) + + + #get the surface + surface= self.get_surface( + self.axes, lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=.5, + fill_color=BLUE_E, + stroke_width=0.2, + stroke_color=WHITE, + ) + #get boundary curves + c1=self.get_curve( + self.axes, lambda x: x**2/4 + ) + c1_label=TextMobject("$y=x^2$").next_to(c1,IN+OUT).shift(DOWN+RIGHT) + c1_label.rotate(PI) + c1_group=VGroup(c1,c1_label).set_color(ORANGE) + + c2=self.get_curve( + self.axes, lambda x: x + ).set_color(PINK) + c2_label=TextMobject("$y=x$").next_to(c2,IN+OUT) + c2_label.rotate(PI/2,about_point=(c2_label.get_corner(UL))) + c2_group=VGroup(c2,c2_label).set_color(YELLOW_E) + + + + self.add(c1,c2,c1_label,c2_label) + + self.begin_ambient_camera_rotation(rate=0.4) + self.get_region(self.axes,c1,c2) + self.play(Write(surface)) + self.get_lines() + self.wait(1) + self.stop_ambient_camera_rotation() + self.move_camera( + distance=20, + phi=10 * DEGREES, + theta=80 * DEGREES, + run_time=2.5 + ) + self.wait(2) + + + + def get_curve(self,axes, func, **kwargs): + config = { + "t_min": axes.x_min, + "t_max": axes.x_max, + } + config.update(kwargs) + return ParametricFunction( + lambda x : axes.c2p( + x, func(x),0 + ), + **config + ) + + def get_region(self,axes,curve1,curve2,**kwargs): + x_vals=np.arange(axes.x_min,axes.x_max,.1) + c1_points=[curve1.get_point_from_function(x) for x in x_vals] + c2_points=[curve2.get_point_from_function(x) for x in x_vals] + c2_points.reverse() + points=c1_points+c2_points + region=Polygon(*points, + stroke_width=0, + fill_color=PINK, + fill_opacity=.5 + ) + R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) + R.move_to(region,IN+RIGHT) + + self.play(Write(region)) + self.add(R) + + def get_surface(self,axes, func, **kwargs): + config = { + "u_min": axes.x_max, + "u_max": axes.x_min, + "v_min": axes.y_max, + "v_max": axes.y_min, + "resolution": (10,10), + } + + config.update(self.default_surface_config) + config.update(kwargs) + return ParametricSurface( + lambda x,y : axes.c2p( + x, y, func(x, y) + ), + **config + ) + + def get_lines(self): + axes = self.axes + labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), + axes.y_axis.n2p(axes.d)] + + + surface_corners=[] + for x,y,z in self.region_corners: + surface_corners.append([x,y,self.Func(x,y)]) + + lines=VGroup() + for start , end in zip(surface_corners, + self.region_corners): + lines.add(self.draw_lines(start,end,"YELLOW")) + + for start , end in zip(labels, + self.region_corners): + # lines.add(self.draw_lines(start,end,"BLUE")) + # print (start,end) + pass + self.play(ShowCreation(lines)) + + + def draw_lines(self,start,end,color): + start=self.axes.c2p(*start) + end=self.axes.c2p(*end) + line=DashedLine(start,end,color=color) + + return line + + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + + if include_numbers: + self.add_axes_numbers(axes) + + if include_labels: + self.add_axes_labels(axes) + + # Adjust axis orientation + axes.x_axis.rotate( + 90 * DEGREES, LEFT, + about_point=axes.c2p(0, 0, 0), + ) + axes.y_axis.rotate( + 90 * DEGREES, UP, + about_point=axes.c2p(0, 0, 0), + ) + + # Add xy-plane + input_plane = self.get_surface( + axes, lambda x, t: 0 + ) + input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + ) + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + # axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("1", axes.b), + ] + tex_vals_y=[ + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif deleted file mode 100644 index 8c9fa0a..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py deleted file mode 100644 index a590a53..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface1.py +++ /dev/null @@ -1,232 +0,0 @@ -from manimlib.imports import * - -class SurfacesAnimation(ThreeDScene): - - CONFIG = { - "axes_config": { - "x_min": 0, - "x_max": 4, - "y_min": 0, - "y_max": 4, - "z_min": -4, - "z_max": 4, - "a":0 ,"b": 4, "c":0 , "d":4, - "axes_shift":IN+LEFT, - "x_axis_config": { - "tick_frequency": 1, - "include_tip": False, - }, - "y_axis_config": { - "tick_frequency": 1, - "include_tip": False, - }, - "z_axis_config": { - "tick_frequency": 1, - # "include_tip": False, - }, - "num_axis_pieces": 1, - }, - "default_graph_style": { - "stroke_width": 2, - "stroke_color": WHITE, - }, - "default_surface_config": { - "fill_opacity": 0.5, - "checkerboard_colors": [LIGHT_GREY], - "stroke_width": 0.5, - "stroke_color": WHITE, - "stroke_opacity": 0.5, - }, - "Func": lambda x,y: 5*(x**2-y**2)/((1e-4+x**2+y**2)**2) - } - - - def construct(self): - - self.setup_axes() - self.set_camera_orientation(#distance=10, - phi=80 * DEGREES, - theta=35 * DEGREES, - ) - - fn_text=TextMobject("$z=\dfrac{x^2-y^2}{(x^2+y^2)^2}$").set_color(BLUE) - fn_text.to_corner(UR,buff=1) - self.add_fixed_in_frame_mobjects(fn_text) - - R=TextMobject("R").set_color(BLACK).scale(2).rotate(180*DEGREES , OUT) - R.move_to(self.axes.input_plane,IN) - self.add(R) - - #get the surface - surface= self.get_surface( - self.axes, lambda x , y: - self.Func(x,y) - ) - surface.set_style( - fill_opacity=0.6, - fill_color=BLUE_E, - stroke_width=0.8, - stroke_color=WHITE, - ) - - - self.begin_ambient_camera_rotation(rate=0.2) - self.play(Write(surface)) - - self.get_lines() - self.wait(4) - - def get_surface(self,axes, func, **kwargs): - config = { - "u_min": axes.x_max, - "u_max": axes.x_min, - "v_min": axes.y_max, - "v_max": axes.y_min, - "resolution": (10,10), - } - - config.update(self.default_surface_config) - config.update(kwargs) - return ParametricSurface( - lambda x,y : axes.c2p( - x, y, func(x, y) - ), - **config - ) - - def get_lines(self): - axes = self.axes - labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), - axes.y_axis.n2p(axes.d)] - - - surface_corners=[] - for x,y,z in self.region_corners: - surface_corners.append([x,y,self.Func(x,y)]) - - lines=VGroup() - for start , end in zip(surface_corners, - self.region_corners): - lines.add(self.draw_lines(start,end,"YELLOW")) - - for start , end in zip(labels, - self.region_corners): - # lines.add(self.draw_lines(start,end,"BLUE")) - # print (start,end) - pass - self.play(ShowCreation(lines)) - - - def draw_lines(self,start,end,color): - start=self.axes.c2p(*start) - end=self.axes.c2p(*end) - line=DashedLine(start,end,color=color) - - return line - - def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): - config = dict(self.axes_config) - config.update(kwargs) - axes = ThreeDAxes(**config) - axes.set_stroke(width=2) - - if include_numbers: - self.add_axes_numbers(axes) - - if include_labels: - self.add_axes_labels(axes) - - # Adjust axis orientation - axes.x_axis.rotate( - 90 * DEGREES, LEFT, - about_point=axes.c2p(0, 0, 0), - ) - axes.y_axis.rotate( - 90 * DEGREES, UP, - about_point=axes.c2p(0, 0, 0), - ) - - # Add xy-plane - input_plane = self.get_surface( - axes, lambda x, t: 0 - ) - input_plane.set_style( - fill_opacity=0.3, - fill_color=PINK, - stroke_width=.2, - stroke_color=WHITE, - ) - - axes.input_plane = input_plane - - self.region_corners=[ - input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] - - return axes - - - def setup_axes(self): - axes = self.get_three_d_axes(include_labels=True) - axes.add(axes.input_plane) - axes.scale(1) - # axes.center() - axes.shift(axes.axes_shift) - - self.add(axes) - self.axes = axes - - def add_axes_numbers(self, axes): - x_axis = axes.x_axis - y_axis = axes.y_axis - tex_vals_x = [ - ("a", axes.a+.4), - ("b", axes.b), - ] - tex_vals_y=[ - ("c", axes.c+.4), - ("d", axes.d) - ] - x_labels = VGroup() - y_labels = VGroup() - for tex, val in tex_vals_x: - label = TexMobject(tex) - label.scale(1) - label.next_to(x_axis.n2p(val), DOWN) - label.rotate(180 * DEGREES) - x_labels.add(label) - x_axis.add(x_labels) - x_axis.numbers = x_labels - - for tex, val in tex_vals_y: - label = TexMobject(tex) - label.scale(1) - label.next_to(y_axis.n2p(val), LEFT) - label.rotate(90 * DEGREES) - y_labels.add(label) - - y_axis.add(y_labels) - y_axis.numbers = y_labels - - return axes - - def add_axes_labels(self, axes): - x_label = TexMobject("x") - x_label.next_to(axes.x_axis.get_end(), RIGHT) - axes.x_axis.label = x_label - - y_label = TextMobject("y") - y_label.rotate(90 * DEGREES, OUT) - y_label.next_to(axes.y_axis.get_end(), UP) - axes.y_axis.label = y_label - - z_label = TextMobject("z") - z_label.rotate(90 * DEGREES, LEFT) - z_label.next_to(axes.z_axis.get_zenith(), LEFT) - axes.z_axis.label = z_label - for axis in axes: - axis.add(axis.label) - return axes - -#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem - - diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif deleted file mode 100644 index ac13f21..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py deleted file mode 100644 index c998f3b..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's_theorem/surface2.py +++ /dev/null @@ -1,286 +0,0 @@ -from manimlib.imports import * - -class SurfacesAnimation(ThreeDScene): - - CONFIG = { - "axes_config": { - "x_min": 0, - "x_max": 4, - "y_min": 0, - "y_max": 4, - "z_min": -2, - "z_max": 4, - "a":0 ,"b": 4, "c":0 , "d":4, - "axes_shift":IN+2*LEFT+2*DOWN, - "x_axis_config": { - "tick_frequency": 1, - "include_tip": False, - }, - "y_axis_config": { - "tick_frequency": 1, - "include_tip": False, - }, - "z_axis_config": { - "tick_frequency": 1, - # "include_tip": False, - }, - "num_axis_pieces": 1, - }, - "default_graph_style": { - "stroke_width": 2, - "stroke_color": WHITE, - }, - "default_surface_config": { - "fill_opacity": 0.5, - "checkerboard_colors": [LIGHT_GREY], - "stroke_width": 0.5, - "stroke_color": WHITE, - "stroke_opacity": 0.5, - }, - "Func": lambda x,y: x*y/4 - } - - - def construct(self): - - self.setup_axes() - self.set_camera_orientation( - distance=30, - phi=75 * DEGREES, - theta=20 * DEGREES, - ) - - fn_text=TextMobject("$z=xy$").set_color(BLUE).scale(1.5) - fn_text.to_corner(UR,buff=2) - self.add_fixed_in_frame_mobjects(fn_text) - - - #get the surface - surface= self.get_surface( - self.axes, lambda x , y: - self.Func(x,y) - ) - surface.set_style( - fill_opacity=.5, - fill_color=BLUE_E, - stroke_width=0.2, - stroke_color=WHITE, - ) - #get boundary curves - c1=self.get_curve( - self.axes, lambda x: x**2/4 - ) - c1_label=TextMobject("$y=x^2$").next_to(c1,IN+OUT).shift(DOWN+RIGHT) - c1_label.rotate(PI) - c1_group=VGroup(c1,c1_label).set_color(ORANGE) - - c2=self.get_curve( - self.axes, lambda x: x - ).set_color(PINK) - c2_label=TextMobject("$y=x$").next_to(c2,IN+OUT) - c2_label.rotate(PI/2,about_point=(c2_label.get_corner(UL))) - c2_group=VGroup(c2,c2_label).set_color(YELLOW_E) - - - - self.add(c1,c2,c1_label,c2_label) - - self.begin_ambient_camera_rotation(rate=0.4) - self.get_region(self.axes,c1,c2) - self.play(Write(surface)) - self.get_lines() - self.wait(1) - self.stop_ambient_camera_rotation() - self.move_camera( - distance=20, - phi=10 * DEGREES, - theta=80 * DEGREES, - run_time=2.5 - ) - self.wait(2) - - - - def get_curve(self,axes, func, **kwargs): - config = { - "t_min": axes.x_min, - "t_max": axes.x_max, - } - config.update(kwargs) - return ParametricFunction( - lambda x : axes.c2p( - x, func(x),0 - ), - **config - ) - - def get_region(self,axes,curve1,curve2,**kwargs): - x_vals=np.arange(axes.x_min,axes.x_max,.1) - c1_points=[curve1.get_point_from_function(x) for x in x_vals] - c2_points=[curve2.get_point_from_function(x) for x in x_vals] - c2_points.reverse() - points=c1_points+c2_points - region=Polygon(*points, - stroke_width=0, - fill_color=PINK, - fill_opacity=.5 - ) - R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) - R.move_to(region,IN+RIGHT) - - self.play(Write(region)) - self.add(R) - - def get_surface(self,axes, func, **kwargs): - config = { - "u_min": axes.x_max, - "u_max": axes.x_min, - "v_min": axes.y_max, - "v_max": axes.y_min, - "resolution": (10,10), - } - - config.update(self.default_surface_config) - config.update(kwargs) - return ParametricSurface( - lambda x,y : axes.c2p( - x, y, func(x, y) - ), - **config - ) - - def get_lines(self): - axes = self.axes - labels=[axes.x_axis.n2p(axes.a), axes.x_axis.n2p(axes.b), axes.y_axis.n2p(axes.c), - axes.y_axis.n2p(axes.d)] - - - surface_corners=[] - for x,y,z in self.region_corners: - surface_corners.append([x,y,self.Func(x,y)]) - - lines=VGroup() - for start , end in zip(surface_corners, - self.region_corners): - lines.add(self.draw_lines(start,end,"YELLOW")) - - for start , end in zip(labels, - self.region_corners): - # lines.add(self.draw_lines(start,end,"BLUE")) - # print (start,end) - pass - self.play(ShowCreation(lines)) - - - def draw_lines(self,start,end,color): - start=self.axes.c2p(*start) - end=self.axes.c2p(*end) - line=DashedLine(start,end,color=color) - - return line - - #customize 3D axes - def get_three_d_axes(self, include_labels=True, include_numbers=True, **kwargs): - config = dict(self.axes_config) - config.update(kwargs) - axes = ThreeDAxes(**config) - axes.set_stroke(width=2) - - if include_numbers: - self.add_axes_numbers(axes) - - if include_labels: - self.add_axes_labels(axes) - - # Adjust axis orientation - axes.x_axis.rotate( - 90 * DEGREES, LEFT, - about_point=axes.c2p(0, 0, 0), - ) - axes.y_axis.rotate( - 90 * DEGREES, UP, - about_point=axes.c2p(0, 0, 0), - ) - - # Add xy-plane - input_plane = self.get_surface( - axes, lambda x, t: 0 - ) - input_plane.set_style( - fill_opacity=0.3, - fill_color=PINK, - stroke_width=.2, - stroke_color=WHITE, - ) - - axes.input_plane = input_plane - - self.region_corners=[ - input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] - - return axes - - - def setup_axes(self): - axes = self.get_three_d_axes(include_labels=True) - # axes.add(axes.input_plane) - axes.scale(1) - # axes.center() - axes.shift(axes.axes_shift) - - self.add(axes) - self.axes = axes - - def add_axes_numbers(self, axes): - x_axis = axes.x_axis - y_axis = axes.y_axis - tex_vals_x = [ - ("1", axes.b), - ] - tex_vals_y=[ - ("1", axes.d) - ] - x_labels = VGroup() - y_labels = VGroup() - for tex, val in tex_vals_x: - label = TexMobject(tex) - label.scale(1) - label.next_to(x_axis.n2p(val), DOWN) - label.rotate(180 * DEGREES) - x_labels.add(label) - x_axis.add(x_labels) - x_axis.numbers = x_labels - - for tex, val in tex_vals_y: - label = TexMobject(tex) - label.scale(1) - label.next_to(y_axis.n2p(val), LEFT) - label.rotate(90 * DEGREES) - y_labels.add(label) - - y_axis.add(y_labels) - y_axis.numbers = y_labels - - return axes - - def add_axes_labels(self, axes): - x_label = TexMobject("x") - x_label.next_to(axes.x_axis.get_end(), RIGHT) - axes.x_axis.label = x_label - - y_label = TextMobject("y") - y_label.rotate(90 * DEGREES, OUT) - y_label.next_to(axes.y_axis.get_end(), UP) - axes.y_axis.label = y_label - - z_label = TextMobject("z") - z_label.rotate(90 * DEGREES, LEFT) - z_label.next_to(axes.z_axis.get_zenith(), LEFT) - axes.z_axis.label = z_label - for axis in axes: - axis.add(axis.label) - return axes - - #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem - - -- cgit From 58a5802578af41558b26ac1c09b2983552698b58 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Wed, 27 May 2020 03:20:12 +0530 Subject: new animation --- .../fubini's-theorem/file3_iteration_methods.gif | Bin 0 -> 1762897 bytes .../fubini's-theorem/file3_iteration_methods.py | 428 +++++++++++++++++++++ .../fubini's-theorem/iteration_methods_check.py | 226 +++++++++++ 3 files changed, 654 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif new file mode 100644 index 0000000..e73dd8e Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py new file mode 100644 index 0000000..662242a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py @@ -0,0 +1,428 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_limit,DOWN,buff=.5 + ).align_to( + caption_limit,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + + self.play(Write(caption_limit)) + self.get_rects() + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + + self.integral_setup(int_lim,first_y=True) + + + self.another_method_scene() + self.remove(self.area) + self.wait() + + c1_eqn_y=self.get_graph_label( + curve1, + label="x=\sqrt y", + x_val=.6, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + c2_eqn_y=self.get_graph_label( + curve2, + label="x=y", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.play( + ReplacementTransform(c1_eqn,c1_eqn_y), + ReplacementTransform(c2_eqn,c2_eqn_y) + ) + self.get_rects(base_y=True) + self.show_integral_values_at_different_y() + self.wait(1) + + int_lim_y=int_lim.copy() + int_lim_y.next_to(int_lim,DOWN) + equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) + self.add(equal,int_lim_y) + + self.integral_setup(int_lim_y,first_y=False) + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + def another_method_scene(self): + text=TextMobject(r"The other method\\ of iteration") + text.next_to(self.curve1,UP,buff=-1) + self.play(GrowFromCenter(text)) + self.wait(2) + self.play(LaggedStart(FadeOut(text),lag_ratio=2)) + + def integral_setup(self,ref_object,first_y=True): + if first_y: + area=self.get_area() + self.area=area + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + ref_object,RIGHT,buff=0) + ) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT), + ShowCreation(area),run_time=4 + ) + else: + area=self.get_area(base_y=True) + self.area=area + self.play( + FadeOut(self.y_brace_group), + Rotate(self.x_int,PI/2) + ) + self.play(ApplyMethod( + self.x_int.next_to, + ref_object,RIGHT,buff=0) + ) + self.play(ApplyMethod( + self.dy_label.next_to, + self.x_int,RIGHT), + ShowCreation(area),run_time=4 + ) + + def get_area(self,base_y=False): + if base_y: + area = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_area = area + else: + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.area = area + + # self.transform_between_riemann_rects(self.rects,area) + return area + + def get_rects(self,base_y=False): + if base_y: + rects = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_rects=rects + else: + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.rects=rects + # self.transform_between_riemann_rects(self.area,rects) + + return rects + + def show_integral_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)/20) + rects_subset = rects[6*rp:7*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + def show_integral_values_at_different_y(self): + rects=self.y_rects + rect = rects[len(rects)*1//10] + dy_brace = Brace(rect, LEFT, buff = 0) + dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_group = VGroup(dy_brace,dy_label) + rp=int(len(rects)/20) + rects_subset = rects[5*rp:6*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, DOWN, buff =.1) + x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) + x_int.next_to(brace, DOWN, SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dy_brace_group.next_to, rect, LEFT, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_x_int, x_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(x_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_x_int = x_int + + x_int = last_x_int + y_brace = last_brace + self.y_brace_group=VGroup(y_brace,dy_brace,rect) + self.x_int=x_int + self.dy_label=dy_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + def bounded_riemann_rectangles_y( + self, + graph1, + graph2, + y_min=None, + y_max=None, + dy=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + y_min = y_min if y_min is not None else self.y_min + y_max = y_max if y_max is not None else self.y_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + y_range = np.arange(y_min, y_max, dy) + colors = color_gradient([start_color, end_color], len(y_range)) + for y, color in zip(y_range, colors): + if input_sample_type == "left": + sample_input = y + elif input_sample_type == "right": + sample_input = y + dy + elif input_sample_type == "center": + sample_input = y + 0.5 * dy + else: + raise Exception("Invalid input sample type") + graph1_point = self.coords_to_point( + graph1(sample_input),sample_input + ) + dy_input=sample_input + width_scale_factor * dy + graph1_point_dy= self.coords_to_point( + graph1(dy_input),dy_input + ) + graph2_point = self.coords_to_point( + graph2(sample_input),sample_input + ) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dy, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py new file mode 100644 index 0000000..55f91d3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py @@ -0,0 +1,226 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.5, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_y_int,DOWN,buff=.5 + ).align_to( + caption_y_int,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + rects=self.get_rects() + + self.play(Write(caption_y_int)) + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + int_lim,RIGHT,buff=0)) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT)) + + self.show_area() + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + + def show_area(self): + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def get_rects(self): + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + return rects + + def show_integral_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[4*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem -- cgit From 8d57d47df8325601b70fa6611a68d8ed7dd56dc4 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Wed, 27 May 2020 03:26:24 +0530 Subject: checkpoint of file3 add --- .../fubini's-theorem/iteration_methods_check.gif | Bin 0 -> 465521 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif new file mode 100644 index 0000000..2e507f9 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif differ -- cgit From 6d2ae3ea9e4925cab7482cf56b7ed6da1d7314fb Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Wed, 27 May 2020 10:22:17 +0530 Subject: update file names --- .../fubini's-theorem/file3_iteration_methods.gif | Bin 1762897 -> 0 bytes .../fubini's-theorem/file3_iteration_methods.py | 428 --------------------- .../file3_iteration_methods_checkpoint.gif | Bin 0 -> 465521 bytes .../file3_iteration_methods_checkpoint.py | 226 +++++++++++ .../fubini's-theorem/file4_iteration_methods.gif | Bin 0 -> 1762897 bytes .../fubini's-theorem/file4_iteration_methods.py | 428 +++++++++++++++++++++ .../fubini's-theorem/iteration_methods_check.gif | Bin 465521 -> 0 bytes .../fubini's-theorem/iteration_methods_check.py | 226 ----------- 8 files changed, 654 insertions(+), 654 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif deleted file mode 100644 index e73dd8e..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py deleted file mode 100644 index 662242a..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py +++ /dev/null @@ -1,428 +0,0 @@ -from manimlib.imports import * - -class IterationMethods(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 1, - "y_min" : 0, - "y_max" : 1, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(0,2)), - "y_labeled_nums": list(np.arange(0 ,2)), - "x_axis_width": 6, - "y_axis_height": 6, - "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, - "area_color": PINK , - "area_opacity": .6, - } - - 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.intro_scene() - self.setup_axes(animate=True) - - - curve1= self.get_graph( - lambda x : x**2 , - x_min = 0, - x_max = 1, - color = ORANGE) - c1_eqn=self.get_graph_label( - curve1, - label="y=x^2", - x_val=.5, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - - curve2= self.get_graph( - lambda x : x , - x_min = 0, - x_max = 1, - color = YELLOW) - c2_eqn=self.get_graph_label( - curve2, - label="y=x", - x_val=.7, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.curve1=curve1 - self.curve2=curve2 - - caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) - int_lim=TextMobject( - "$$\\int_0^1$$" - ).next_to( - caption_limit,DOWN,buff=.5 - ).align_to( - caption_limit,LEFT - ) - - self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) - - self.play(Write(caption_limit)) - self.get_rects() - self.show_integral_values_at_different_x() - self.wait(1) - self.add(int_lim) - - self.integral_setup(int_lim,first_y=True) - - - self.another_method_scene() - self.remove(self.area) - self.wait() - - c1_eqn_y=self.get_graph_label( - curve1, - label="x=\sqrt y", - x_val=.6, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - c2_eqn_y=self.get_graph_label( - curve2, - label="x=y", - x_val=.7, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.play( - ReplacementTransform(c1_eqn,c1_eqn_y), - ReplacementTransform(c2_eqn,c2_eqn_y) - ) - self.get_rects(base_y=True) - self.show_integral_values_at_different_y() - self.wait(1) - - int_lim_y=int_lim.copy() - int_lim_y.next_to(int_lim,DOWN) - equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) - self.add(equal,int_lim_y) - - self.integral_setup(int_lim_y,first_y=False) - - self.wait(2) - - ################### - def intro_scene(self): - text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) - self.play(Write(text),run_time=4) - self.wait(2) - self.play(FadeOut(text)) - - def another_method_scene(self): - text=TextMobject(r"The other method\\ of iteration") - text.next_to(self.curve1,UP,buff=-1) - self.play(GrowFromCenter(text)) - self.wait(2) - self.play(LaggedStart(FadeOut(text),lag_ratio=2)) - - def integral_setup(self,ref_object,first_y=True): - if first_y: - area=self.get_area() - self.area=area - self.play(FadeOut(self.brace_group)) - self.play(ApplyMethod( - self.y_int.next_to, - ref_object,RIGHT,buff=0) - ) - - self.play(ApplyMethod( - self.dx_label.next_to, - self.y_int,RIGHT), - ShowCreation(area),run_time=4 - ) - else: - area=self.get_area(base_y=True) - self.area=area - self.play( - FadeOut(self.y_brace_group), - Rotate(self.x_int,PI/2) - ) - self.play(ApplyMethod( - self.x_int.next_to, - ref_object,RIGHT,buff=0) - ) - self.play(ApplyMethod( - self.dy_label.next_to, - self.x_int,RIGHT), - ShowCreation(area),run_time=4 - ) - - def get_area(self,base_y=False): - if base_y: - area = self.bounded_riemann_rectangles_y( - lambda x: x, - lambda x: np.sqrt(x), - y_min = 0, - y_max = 1, - dy =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.y_area = area - else: - area = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.area = area - - # self.transform_between_riemann_rects(self.rects,area) - return area - - def get_rects(self,base_y=False): - if base_y: - rects = self.bounded_riemann_rectangles_y( - lambda x: x, - lambda x: np.sqrt(x), - y_min = 0, - y_max = 1, - dy =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.y_rects=rects - else: - rects = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.rects=rects - # self.transform_between_riemann_rects(self.area,rects) - - return rects - - def show_integral_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)/20) - rects_subset = rects[6*rp:7*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, LEFT, buff =.1) - y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) - y_int.next_to(brace, LEFT, MED_SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_y_int, y_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(y_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_y_int = y_int - - y_int = last_y_int - y_brace = last_brace - self.brace_group=VGroup(y_brace,dx_brace,rect) - self.y_int=y_int - self.dx_label=dx_label - - def show_integral_values_at_different_y(self): - rects=self.y_rects - rect = rects[len(rects)*1//10] - dy_brace = Brace(rect, LEFT, buff = 0) - dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) - dy_brace_group = VGroup(dy_brace,dy_label) - rp=int(len(rects)/20) - rects_subset = rects[5*rp:6*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, DOWN, buff =.1) - x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) - x_int.next_to(brace, DOWN, SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 1, - dy_brace_group.next_to, rect, LEFT, SMALL_BUFF - ] - if last_rect is not None: - anims += [ - last_rect.set_fill, None, 0, - # last_rect.set_fill, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_x_int, x_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(x_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_x_int = x_int - - x_int = last_x_int - y_brace = last_brace - self.y_brace_group=VGroup(y_brace,dy_brace,rect) - self.x_int=x_int - self.dy_label=dy_label - - - def bounded_riemann_rectangles( - self, - graph1, - graph2, - x_min=None, - x_max=None, - dx=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - x_min = x_min if x_min is not None else self.x_min - x_max = x_max if x_max is not None else self.x_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - x_range = np.arange(x_min, x_max, dx) - colors = color_gradient([start_color, end_color], len(x_range)) - for x, color in zip(x_range, colors): - if input_sample_type == "left": - sample_input = x - elif input_sample_type == "right": - sample_input = x + dx - elif input_sample_type == "center": - sample_input = x + 0.5 * dx - else: - raise Exception("Invalid input sample type") - graph1_point = self.input_to_graph_point(sample_input, graph1) - graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) - graph2_point = self.input_to_graph_point(sample_input, graph2) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dx, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - - def bounded_riemann_rectangles_y( - self, - graph1, - graph2, - y_min=None, - y_max=None, - dy=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - y_min = y_min if y_min is not None else self.y_min - y_max = y_max if y_max is not None else self.y_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - y_range = np.arange(y_min, y_max, dy) - colors = color_gradient([start_color, end_color], len(y_range)) - for y, color in zip(y_range, colors): - if input_sample_type == "left": - sample_input = y - elif input_sample_type == "right": - sample_input = y + dy - elif input_sample_type == "center": - sample_input = y + 0.5 * dy - else: - raise Exception("Invalid input sample type") - graph1_point = self.coords_to_point( - graph1(sample_input),sample_input - ) - dy_input=sample_input + width_scale_factor * dy - graph1_point_dy= self.coords_to_point( - graph1(dy_input),dy_input - ) - graph2_point = self.coords_to_point( - graph2(sample_input),sample_input - ) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dy, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - - -#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif new file mode 100644 index 0000000..2e507f9 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py new file mode 100644 index 0000000..55f91d3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py @@ -0,0 +1,226 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.5, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_y_int,DOWN,buff=.5 + ).align_to( + caption_y_int,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + rects=self.get_rects() + + self.play(Write(caption_y_int)) + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + int_lim,RIGHT,buff=0)) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT)) + + self.show_area() + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + + def show_area(self): + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def get_rects(self): + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + return rects + + def show_integral_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[4*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif new file mode 100644 index 0000000..e73dd8e Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py new file mode 100644 index 0000000..662242a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py @@ -0,0 +1,428 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_limit,DOWN,buff=.5 + ).align_to( + caption_limit,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + + self.play(Write(caption_limit)) + self.get_rects() + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + + self.integral_setup(int_lim,first_y=True) + + + self.another_method_scene() + self.remove(self.area) + self.wait() + + c1_eqn_y=self.get_graph_label( + curve1, + label="x=\sqrt y", + x_val=.6, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + c2_eqn_y=self.get_graph_label( + curve2, + label="x=y", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.play( + ReplacementTransform(c1_eqn,c1_eqn_y), + ReplacementTransform(c2_eqn,c2_eqn_y) + ) + self.get_rects(base_y=True) + self.show_integral_values_at_different_y() + self.wait(1) + + int_lim_y=int_lim.copy() + int_lim_y.next_to(int_lim,DOWN) + equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) + self.add(equal,int_lim_y) + + self.integral_setup(int_lim_y,first_y=False) + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + def another_method_scene(self): + text=TextMobject(r"The other method\\ of iteration") + text.next_to(self.curve1,UP,buff=-1) + self.play(GrowFromCenter(text)) + self.wait(2) + self.play(LaggedStart(FadeOut(text),lag_ratio=2)) + + def integral_setup(self,ref_object,first_y=True): + if first_y: + area=self.get_area() + self.area=area + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + ref_object,RIGHT,buff=0) + ) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT), + ShowCreation(area),run_time=4 + ) + else: + area=self.get_area(base_y=True) + self.area=area + self.play( + FadeOut(self.y_brace_group), + Rotate(self.x_int,PI/2) + ) + self.play(ApplyMethod( + self.x_int.next_to, + ref_object,RIGHT,buff=0) + ) + self.play(ApplyMethod( + self.dy_label.next_to, + self.x_int,RIGHT), + ShowCreation(area),run_time=4 + ) + + def get_area(self,base_y=False): + if base_y: + area = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_area = area + else: + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.area = area + + # self.transform_between_riemann_rects(self.rects,area) + return area + + def get_rects(self,base_y=False): + if base_y: + rects = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_rects=rects + else: + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.rects=rects + # self.transform_between_riemann_rects(self.area,rects) + + return rects + + def show_integral_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)/20) + rects_subset = rects[6*rp:7*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + def show_integral_values_at_different_y(self): + rects=self.y_rects + rect = rects[len(rects)*1//10] + dy_brace = Brace(rect, LEFT, buff = 0) + dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_group = VGroup(dy_brace,dy_label) + rp=int(len(rects)/20) + rects_subset = rects[5*rp:6*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, DOWN, buff =.1) + x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) + x_int.next_to(brace, DOWN, SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dy_brace_group.next_to, rect, LEFT, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_x_int, x_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(x_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_x_int = x_int + + x_int = last_x_int + y_brace = last_brace + self.y_brace_group=VGroup(y_brace,dy_brace,rect) + self.x_int=x_int + self.dy_label=dy_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + def bounded_riemann_rectangles_y( + self, + graph1, + graph2, + y_min=None, + y_max=None, + dy=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + y_min = y_min if y_min is not None else self.y_min + y_max = y_max if y_max is not None else self.y_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + y_range = np.arange(y_min, y_max, dy) + colors = color_gradient([start_color, end_color], len(y_range)) + for y, color in zip(y_range, colors): + if input_sample_type == "left": + sample_input = y + elif input_sample_type == "right": + sample_input = y + dy + elif input_sample_type == "center": + sample_input = y + 0.5 * dy + else: + raise Exception("Invalid input sample type") + graph1_point = self.coords_to_point( + graph1(sample_input),sample_input + ) + dy_input=sample_input + width_scale_factor * dy + graph1_point_dy= self.coords_to_point( + graph1(dy_input),dy_input + ) + graph2_point = self.coords_to_point( + graph2(sample_input),sample_input + ) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dy, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif deleted file mode 100644 index 2e507f9..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py deleted file mode 100644 index 55f91d3..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/iteration_methods_check.py +++ /dev/null @@ -1,226 +0,0 @@ -from manimlib.imports import * - -class IterationMethods(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 1, - "y_min" : 0, - "y_max" : 1, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(0,2)), - "y_labeled_nums": list(np.arange(0 ,2)), - "x_axis_width": 6, - "y_axis_height": 6, - "graph_origin": ORIGIN+4*LEFT+3*DOWN, - "area_color": PINK , - "area_opacity": .6, - } - - 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.intro_scene() - self.setup_axes(animate=True) - - - curve1= self.get_graph( - lambda x : x**2 , - x_min = 0, - x_max = 1, - color = ORANGE) - c1_eqn=self.get_graph_label( - curve1, - label="y=x^2", - x_val=.5, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - - curve2= self.get_graph( - lambda x : x , - x_min = 0, - x_max = 1, - color = YELLOW) - c2_eqn=self.get_graph_label( - curve2, - label="y=x", - x_val=.5, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.curve1=curve1 - self.curve2=curve2 - - caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) - int_lim=TextMobject( - "$$\\int_0^1$$" - ).next_to( - caption_y_int,DOWN,buff=.5 - ).align_to( - caption_y_int,LEFT - ) - - self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) - rects=self.get_rects() - - self.play(Write(caption_y_int)) - self.show_integral_values_at_different_x() - self.wait(1) - self.add(int_lim) - self.play(FadeOut(self.brace_group)) - self.play(ApplyMethod( - self.y_int.next_to, - int_lim,RIGHT,buff=0)) - - self.play(ApplyMethod( - self.dx_label.next_to, - self.y_int,RIGHT)) - - self.show_area() - - self.wait(2) - - ################### - def intro_scene(self): - text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) - self.play(Write(text),run_time=4) - self.wait(2) - self.play(FadeOut(text)) - - - def show_area(self): - area = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity = 1, - stroke_width = 0, - ) - self.play(ShowCreation(area)) - # self.transform_between_riemann_rects(self.rects,area) - self.area = area - - def get_rects(self): - rects = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - # self.transform_between_riemann_rects(self.area,rects) - self.rects=rects - return rects - - def show_integral_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[4*rp:5*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, LEFT, buff =.1) - y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) - y_int.next_to(brace, LEFT, MED_SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_y_int, y_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(y_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_y_int = y_int - - y_int = last_y_int - y_brace = last_brace - self.brace_group=VGroup(y_brace,dx_brace,rect) - self.y_int=y_int - self.dx_label=dx_label - - - def bounded_riemann_rectangles( - self, - graph1, - graph2, - x_min=None, - x_max=None, - dx=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - x_min = x_min if x_min is not None else self.x_min - x_max = x_max if x_max is not None else self.x_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - x_range = np.arange(x_min, x_max, dx) - colors = color_gradient([start_color, end_color], len(x_range)) - for x, color in zip(x_range, colors): - if input_sample_type == "left": - sample_input = x - elif input_sample_type == "right": - sample_input = x + dx - elif input_sample_type == "center": - sample_input = x + 0.5 * dx - else: - raise Exception("Invalid input sample type") - graph1_point = self.input_to_graph_point(sample_input, graph1) - graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) - graph2_point = self.input_to_graph_point(sample_input, graph2) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dx, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - -#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem -- cgit From f516d1b082ed5e107e37e0c5a43916ca14816bef Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 10:19:46 +0530 Subject: draft submission --- .../fubini's-theorem/file2_surface2.gif | Bin 2556585 -> 3791121 bytes .../fubini's-theorem/file2_surface2.py | 16 +- .../file3.o_iteration_methods_checkpoint.gif | Bin 0 -> 465521 bytes .../file3.o_iteration_methods_checkpoint.py | 226 +++++++++++ .../fubini's-theorem/file3_iteration_methods.gif | Bin 0 -> 1762897 bytes .../fubini's-theorem/file3_iteration_methods.py | 428 +++++++++++++++++++++ .../file3_iteration_methods_checkpoint.gif | Bin 465521 -> 0 bytes .../file3_iteration_methods_checkpoint.py | 226 ----------- .../fubini's-theorem/file4_iteration_methods.gif | Bin 1762897 -> 0 bytes .../fubini's-theorem/file4_iteration_methods.py | 428 --------------------- 10 files changed, 664 insertions(+), 660 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif index ac13f21..37c4b1d 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py index c998f3b..3160fdb 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.py @@ -63,7 +63,7 @@ class SurfacesAnimation(ThreeDScene): surface.set_style( fill_opacity=.5, fill_color=BLUE_E, - stroke_width=0.2, + stroke_width=0.4, stroke_color=WHITE, ) #get boundary curves @@ -85,17 +85,18 @@ class SurfacesAnimation(ThreeDScene): self.add(c1,c2,c1_label,c2_label) - self.begin_ambient_camera_rotation(rate=0.4) + self.begin_ambient_camera_rotation(rate=0.24) self.get_region(self.axes,c1,c2) self.play(Write(surface)) self.get_lines() - self.wait(1) + self.wait(3.5) self.stop_ambient_camera_rotation() + self.wait(.5) self.move_camera( distance=20, phi=10 * DEGREES, theta=80 * DEGREES, - run_time=2.5 + run_time=3 ) self.wait(2) @@ -128,7 +129,7 @@ class SurfacesAnimation(ThreeDScene): R=TextMobject("R").set_color(PINK).scale(2).rotate(180*DEGREES , OUT) R.move_to(region,IN+RIGHT) - self.play(Write(region)) + self.play(ShowCreation(region)) self.add(R) def get_surface(self,axes, func, **kwargs): @@ -279,8 +280,11 @@ class SurfacesAnimation(ThreeDScene): axes.z_axis.label = z_label for axis in axes: axis.add(axis.label) - return axes + return axes #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif new file mode 100644 index 0000000..2e507f9 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py new file mode 100644 index 0000000..55f91d3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3.o_iteration_methods_checkpoint.py @@ -0,0 +1,226 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.5, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_y_int,DOWN,buff=.5 + ).align_to( + caption_y_int,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + rects=self.get_rects() + + self.play(Write(caption_y_int)) + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + int_lim,RIGHT,buff=0)) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT)) + + self.show_area() + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + + def show_area(self): + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity = 1, + stroke_width = 0, + ) + self.play(ShowCreation(area)) + # self.transform_between_riemann_rects(self.rects,area) + self.area = area + + def get_rects(self): + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + # self.transform_between_riemann_rects(self.area,rects) + self.rects=rects + return rects + + def show_integral_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[4*rp:5*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif new file mode 100644 index 0000000..e73dd8e Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py new file mode 100644 index 0000000..662242a --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py @@ -0,0 +1,428 @@ +from manimlib.imports import * + +class IterationMethods(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 1, + "y_min" : 0, + "y_max" : 1, + "x_tick_frequency" : 1, + "y_tick_frequency" : 1, + "x_labeled_nums": list(np.arange(0,2)), + "y_labeled_nums": list(np.arange(0 ,2)), + "x_axis_width": 6, + "y_axis_height": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "area_color": PINK , + "area_opacity": .6, + } + + 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.intro_scene() + self.setup_axes(animate=True) + + + curve1= self.get_graph( + lambda x : x**2 , + x_min = 0, + x_max = 1, + color = ORANGE) + c1_eqn=self.get_graph_label( + curve1, + label="y=x^2", + x_val=.5, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + + curve2= self.get_graph( + lambda x : x , + x_min = 0, + x_max = 1, + color = YELLOW) + c2_eqn=self.get_graph_label( + curve2, + label="y=x", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.curve1=curve1 + self.curve2=curve2 + + caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) + int_lim=TextMobject( + "$$\\int_0^1$$" + ).next_to( + caption_limit,DOWN,buff=.5 + ).align_to( + caption_limit,LEFT + ) + + self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) + + self.play(Write(caption_limit)) + self.get_rects() + self.show_integral_values_at_different_x() + self.wait(1) + self.add(int_lim) + + self.integral_setup(int_lim,first_y=True) + + + self.another_method_scene() + self.remove(self.area) + self.wait() + + c1_eqn_y=self.get_graph_label( + curve1, + label="x=\sqrt y", + x_val=.6, + direction=RIGHT, + buff=MED_LARGE_BUFF, + color=ORANGE, + ) + c2_eqn_y=self.get_graph_label( + curve2, + label="x=y", + x_val=.7, + direction=LEFT, + buff=MED_LARGE_BUFF, + color=YELLOW, + ) + self.play( + ReplacementTransform(c1_eqn,c1_eqn_y), + ReplacementTransform(c2_eqn,c2_eqn_y) + ) + self.get_rects(base_y=True) + self.show_integral_values_at_different_y() + self.wait(1) + + int_lim_y=int_lim.copy() + int_lim_y.next_to(int_lim,DOWN) + equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) + self.add(equal,int_lim_y) + + self.integral_setup(int_lim_y,first_y=False) + + self.wait(2) + + ################### + def intro_scene(self): + text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) + self.play(Write(text),run_time=4) + self.wait(2) + self.play(FadeOut(text)) + + def another_method_scene(self): + text=TextMobject(r"The other method\\ of iteration") + text.next_to(self.curve1,UP,buff=-1) + self.play(GrowFromCenter(text)) + self.wait(2) + self.play(LaggedStart(FadeOut(text),lag_ratio=2)) + + def integral_setup(self,ref_object,first_y=True): + if first_y: + area=self.get_area() + self.area=area + self.play(FadeOut(self.brace_group)) + self.play(ApplyMethod( + self.y_int.next_to, + ref_object,RIGHT,buff=0) + ) + + self.play(ApplyMethod( + self.dx_label.next_to, + self.y_int,RIGHT), + ShowCreation(area),run_time=4 + ) + else: + area=self.get_area(base_y=True) + self.area=area + self.play( + FadeOut(self.y_brace_group), + Rotate(self.x_int,PI/2) + ) + self.play(ApplyMethod( + self.x_int.next_to, + ref_object,RIGHT,buff=0) + ) + self.play(ApplyMethod( + self.dy_label.next_to, + self.x_int,RIGHT), + ShowCreation(area),run_time=4 + ) + + def get_area(self,base_y=False): + if base_y: + area = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_area = area + else: + area = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.001, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.area = area + + # self.transform_between_riemann_rects(self.rects,area) + return area + + def get_rects(self,base_y=False): + if base_y: + rects = self.bounded_riemann_rectangles_y( + lambda x: x, + lambda x: np.sqrt(x), + y_min = 0, + y_max = 1, + dy =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.y_rects=rects + else: + rects = self.bounded_riemann_rectangles( + self.curve1, + self.curve2, + x_min = 0, + x_max = 1, + dx =.01, + start_color = self.area_color, + end_color = self.area_color, + fill_opacity =self.area_opacity, + stroke_width = 0, + ) + self.rects=rects + # self.transform_between_riemann_rects(self.area,rects) + + return rects + + def show_integral_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)/20) + rects_subset = rects[6*rp:7*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, LEFT, buff =.1) + y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) + y_int.next_to(brace, LEFT, MED_SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_y_int, y_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(y_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_y_int = y_int + + y_int = last_y_int + y_brace = last_brace + self.brace_group=VGroup(y_brace,dx_brace,rect) + self.y_int=y_int + self.dx_label=dx_label + + def show_integral_values_at_different_y(self): + rects=self.y_rects + rect = rects[len(rects)*1//10] + dy_brace = Brace(rect, LEFT, buff = 0) + dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) + dy_brace_group = VGroup(dy_brace,dy_label) + rp=int(len(rects)/20) + rects_subset = rects[5*rp:6*rp] + + last_rect = None + for rect in rects_subset: + brace = Brace(rect, DOWN, buff =.1) + x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) + x_int.next_to(brace, DOWN, SMALL_BUFF) + anims = [ + rect.set_fill, self.area_color, 1, + dy_brace_group.next_to, rect, LEFT, SMALL_BUFF + ] + if last_rect is not None: + anims += [ + last_rect.set_fill, None, 0, + # last_rect.set_fill, self.area_color, self.area_opacity, + ReplacementTransform(last_brace, brace), + ReplacementTransform(last_x_int, x_int), + ] + else: + anims += [ + GrowFromCenter(brace), + Write(x_int) + ] + self.play(*anims) + # self.wait(.2) + + last_rect = rect + last_brace = brace + last_x_int = x_int + + x_int = last_x_int + y_brace = last_brace + self.y_brace_group=VGroup(y_brace,dy_brace,rect) + self.x_int=x_int + self.dy_label=dy_label + + + def bounded_riemann_rectangles( + self, + graph1, + graph2, + x_min=None, + x_max=None, + dx=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + x_min = x_min if x_min is not None else self.x_min + x_max = x_max if x_max is not None else self.x_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + x_range = np.arange(x_min, x_max, dx) + colors = color_gradient([start_color, end_color], len(x_range)) + for x, color in zip(x_range, colors): + if input_sample_type == "left": + sample_input = x + elif input_sample_type == "right": + sample_input = x + dx + elif input_sample_type == "center": + sample_input = x + 0.5 * dx + else: + raise Exception("Invalid input sample type") + graph1_point = self.input_to_graph_point(sample_input, graph1) + graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) + graph2_point = self.input_to_graph_point(sample_input, graph2) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dx, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + def bounded_riemann_rectangles_y( + self, + graph1, + graph2, + y_min=None, + y_max=None, + dy=0.01, + input_sample_type="center", + stroke_width=1, + stroke_color=BLACK, + fill_opacity=1, + start_color=None, + end_color=None, + show_signed_area=True, + width_scale_factor=1.001 + ): + y_min = y_min if y_min is not None else self.y_min + y_max = y_max if y_max is not None else self.y_max + if start_color is None: + start_color = self.default_riemann_start_color + if end_color is None: + end_color = self.default_riemann_end_color + rectangles = VGroup() + y_range = np.arange(y_min, y_max, dy) + colors = color_gradient([start_color, end_color], len(y_range)) + for y, color in zip(y_range, colors): + if input_sample_type == "left": + sample_input = y + elif input_sample_type == "right": + sample_input = y + dy + elif input_sample_type == "center": + sample_input = y + 0.5 * dy + else: + raise Exception("Invalid input sample type") + graph1_point = self.coords_to_point( + graph1(sample_input),sample_input + ) + dy_input=sample_input + width_scale_factor * dy + graph1_point_dy= self.coords_to_point( + graph1(dy_input),dy_input + ) + graph2_point = self.coords_to_point( + graph2(sample_input),sample_input + ) + + points = VGroup(*list(map(VectorizedPoint, [ + graph1_point, + graph1_point_dy, + graph2_point + ]))) + + rect = Rectangle() + rect.replace(points, stretch=True) + if graph1_point[1] < self.graph_origin[1] and show_signed_area: + fill_color = invert_color(color) + else: + fill_color = color + rect.set_fill(fill_color, opacity=fill_opacity) + rect.set_stroke(stroke_color, width=stroke_width) + rectangles.add(rect) + return rectangles + + +#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif deleted file mode 100644 index 2e507f9..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py deleted file mode 100644 index 55f91d3..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods_checkpoint.py +++ /dev/null @@ -1,226 +0,0 @@ -from manimlib.imports import * - -class IterationMethods(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 1, - "y_min" : 0, - "y_max" : 1, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(0,2)), - "y_labeled_nums": list(np.arange(0 ,2)), - "x_axis_width": 6, - "y_axis_height": 6, - "graph_origin": ORIGIN+4*LEFT+3*DOWN, - "area_color": PINK , - "area_opacity": .6, - } - - 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.intro_scene() - self.setup_axes(animate=True) - - - curve1= self.get_graph( - lambda x : x**2 , - x_min = 0, - x_max = 1, - color = ORANGE) - c1_eqn=self.get_graph_label( - curve1, - label="y=x^2", - x_val=.5, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - - curve2= self.get_graph( - lambda x : x , - x_min = 0, - x_max = 1, - color = YELLOW) - c2_eqn=self.get_graph_label( - curve2, - label="y=x", - x_val=.5, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.curve1=curve1 - self.curve2=curve2 - - caption_y_int=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) - int_lim=TextMobject( - "$$\\int_0^1$$" - ).next_to( - caption_y_int,DOWN,buff=.5 - ).align_to( - caption_y_int,LEFT - ) - - self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) - rects=self.get_rects() - - self.play(Write(caption_y_int)) - self.show_integral_values_at_different_x() - self.wait(1) - self.add(int_lim) - self.play(FadeOut(self.brace_group)) - self.play(ApplyMethod( - self.y_int.next_to, - int_lim,RIGHT,buff=0)) - - self.play(ApplyMethod( - self.dx_label.next_to, - self.y_int,RIGHT)) - - self.show_area() - - self.wait(2) - - ################### - def intro_scene(self): - text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) - self.play(Write(text),run_time=4) - self.wait(2) - self.play(FadeOut(text)) - - - def show_area(self): - area = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity = 1, - stroke_width = 0, - ) - self.play(ShowCreation(area)) - # self.transform_between_riemann_rects(self.rects,area) - self.area = area - - def get_rects(self): - rects = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - # self.transform_between_riemann_rects(self.area,rects) - self.rects=rects - return rects - - def show_integral_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[4*rp:5*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, LEFT, buff =.1) - y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) - y_int.next_to(brace, LEFT, MED_SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_y_int, y_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(y_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_y_int = y_int - - y_int = last_y_int - y_brace = last_brace - self.brace_group=VGroup(y_brace,dx_brace,rect) - self.y_int=y_int - self.dx_label=dx_label - - - def bounded_riemann_rectangles( - self, - graph1, - graph2, - x_min=None, - x_max=None, - dx=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - x_min = x_min if x_min is not None else self.x_min - x_max = x_max if x_max is not None else self.x_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - x_range = np.arange(x_min, x_max, dx) - colors = color_gradient([start_color, end_color], len(x_range)) - for x, color in zip(x_range, colors): - if input_sample_type == "left": - sample_input = x - elif input_sample_type == "right": - sample_input = x + dx - elif input_sample_type == "center": - sample_input = x + 0.5 * dx - else: - raise Exception("Invalid input sample type") - graph1_point = self.input_to_graph_point(sample_input, graph1) - graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) - graph2_point = self.input_to_graph_point(sample_input, graph2) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dx, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - -#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif deleted file mode 100644 index e73dd8e..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py deleted file mode 100644 index 662242a..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_iteration_methods.py +++ /dev/null @@ -1,428 +0,0 @@ -from manimlib.imports import * - -class IterationMethods(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 1, - "y_min" : 0, - "y_max" : 1, - "x_tick_frequency" : 1, - "y_tick_frequency" : 1, - "x_labeled_nums": list(np.arange(0,2)), - "y_labeled_nums": list(np.arange(0 ,2)), - "x_axis_width": 6, - "y_axis_height": 6, - "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, - "area_color": PINK , - "area_opacity": .6, - } - - 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.intro_scene() - self.setup_axes(animate=True) - - - curve1= self.get_graph( - lambda x : x**2 , - x_min = 0, - x_max = 1, - color = ORANGE) - c1_eqn=self.get_graph_label( - curve1, - label="y=x^2", - x_val=.5, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - - curve2= self.get_graph( - lambda x : x , - x_min = 0, - x_max = 1, - color = YELLOW) - c2_eqn=self.get_graph_label( - curve2, - label="y=x", - x_val=.7, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.curve1=curve1 - self.curve2=curve2 - - caption_limit=TextMobject(r"Observe the limits\\ of integration").to_corner(UR) - int_lim=TextMobject( - "$$\\int_0^1$$" - ).next_to( - caption_limit,DOWN,buff=.5 - ).align_to( - caption_limit,LEFT - ) - - self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) - - self.play(Write(caption_limit)) - self.get_rects() - self.show_integral_values_at_different_x() - self.wait(1) - self.add(int_lim) - - self.integral_setup(int_lim,first_y=True) - - - self.another_method_scene() - self.remove(self.area) - self.wait() - - c1_eqn_y=self.get_graph_label( - curve1, - label="x=\sqrt y", - x_val=.6, - direction=RIGHT, - buff=MED_LARGE_BUFF, - color=ORANGE, - ) - c2_eqn_y=self.get_graph_label( - curve2, - label="x=y", - x_val=.7, - direction=LEFT, - buff=MED_LARGE_BUFF, - color=YELLOW, - ) - self.play( - ReplacementTransform(c1_eqn,c1_eqn_y), - ReplacementTransform(c2_eqn,c2_eqn_y) - ) - self.get_rects(base_y=True) - self.show_integral_values_at_different_y() - self.wait(1) - - int_lim_y=int_lim.copy() - int_lim_y.next_to(int_lim,DOWN) - equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) - self.add(equal,int_lim_y) - - self.integral_setup(int_lim_y,first_y=False) - - self.wait(2) - - ################### - def intro_scene(self): - text=TextMobject(r"How different orders of \textbf{iterated integral}\\ works over the same region ?" ) - self.play(Write(text),run_time=4) - self.wait(2) - self.play(FadeOut(text)) - - def another_method_scene(self): - text=TextMobject(r"The other method\\ of iteration") - text.next_to(self.curve1,UP,buff=-1) - self.play(GrowFromCenter(text)) - self.wait(2) - self.play(LaggedStart(FadeOut(text),lag_ratio=2)) - - def integral_setup(self,ref_object,first_y=True): - if first_y: - area=self.get_area() - self.area=area - self.play(FadeOut(self.brace_group)) - self.play(ApplyMethod( - self.y_int.next_to, - ref_object,RIGHT,buff=0) - ) - - self.play(ApplyMethod( - self.dx_label.next_to, - self.y_int,RIGHT), - ShowCreation(area),run_time=4 - ) - else: - area=self.get_area(base_y=True) - self.area=area - self.play( - FadeOut(self.y_brace_group), - Rotate(self.x_int,PI/2) - ) - self.play(ApplyMethod( - self.x_int.next_to, - ref_object,RIGHT,buff=0) - ) - self.play(ApplyMethod( - self.dy_label.next_to, - self.x_int,RIGHT), - ShowCreation(area),run_time=4 - ) - - def get_area(self,base_y=False): - if base_y: - area = self.bounded_riemann_rectangles_y( - lambda x: x, - lambda x: np.sqrt(x), - y_min = 0, - y_max = 1, - dy =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.y_area = area - else: - area = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.001, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.area = area - - # self.transform_between_riemann_rects(self.rects,area) - return area - - def get_rects(self,base_y=False): - if base_y: - rects = self.bounded_riemann_rectangles_y( - lambda x: x, - lambda x: np.sqrt(x), - y_min = 0, - y_max = 1, - dy =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.y_rects=rects - else: - rects = self.bounded_riemann_rectangles( - self.curve1, - self.curve2, - x_min = 0, - x_max = 1, - dx =.01, - start_color = self.area_color, - end_color = self.area_color, - fill_opacity =self.area_opacity, - stroke_width = 0, - ) - self.rects=rects - # self.transform_between_riemann_rects(self.area,rects) - - return rects - - def show_integral_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)/20) - rects_subset = rects[6*rp:7*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, LEFT, buff =.1) - y_int = TexMobject("\\int_{x^2}^{x}dy")#.rotate(PI/2) - y_int.next_to(brace, LEFT, MED_SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 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, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_y_int, y_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(y_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_y_int = y_int - - y_int = last_y_int - y_brace = last_brace - self.brace_group=VGroup(y_brace,dx_brace,rect) - self.y_int=y_int - self.dx_label=dx_label - - def show_integral_values_at_different_y(self): - rects=self.y_rects - rect = rects[len(rects)*1//10] - dy_brace = Brace(rect, LEFT, buff = 0) - dy_label = dy_brace.get_text("$dy$", buff = SMALL_BUFF) - dy_brace_group = VGroup(dy_brace,dy_label) - rp=int(len(rects)/20) - rects_subset = rects[5*rp:6*rp] - - last_rect = None - for rect in rects_subset: - brace = Brace(rect, DOWN, buff =.1) - x_int = TexMobject("\\int_{y}^{\sqrt y}dx").rotate(-PI/2) - x_int.next_to(brace, DOWN, SMALL_BUFF) - anims = [ - rect.set_fill, self.area_color, 1, - dy_brace_group.next_to, rect, LEFT, SMALL_BUFF - ] - if last_rect is not None: - anims += [ - last_rect.set_fill, None, 0, - # last_rect.set_fill, self.area_color, self.area_opacity, - ReplacementTransform(last_brace, brace), - ReplacementTransform(last_x_int, x_int), - ] - else: - anims += [ - GrowFromCenter(brace), - Write(x_int) - ] - self.play(*anims) - # self.wait(.2) - - last_rect = rect - last_brace = brace - last_x_int = x_int - - x_int = last_x_int - y_brace = last_brace - self.y_brace_group=VGroup(y_brace,dy_brace,rect) - self.x_int=x_int - self.dy_label=dy_label - - - def bounded_riemann_rectangles( - self, - graph1, - graph2, - x_min=None, - x_max=None, - dx=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - x_min = x_min if x_min is not None else self.x_min - x_max = x_max if x_max is not None else self.x_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - x_range = np.arange(x_min, x_max, dx) - colors = color_gradient([start_color, end_color], len(x_range)) - for x, color in zip(x_range, colors): - if input_sample_type == "left": - sample_input = x - elif input_sample_type == "right": - sample_input = x + dx - elif input_sample_type == "center": - sample_input = x + 0.5 * dx - else: - raise Exception("Invalid input sample type") - graph1_point = self.input_to_graph_point(sample_input, graph1) - graph1_point_dx= self.input_to_graph_point(sample_input + width_scale_factor * dx, graph1) - graph2_point = self.input_to_graph_point(sample_input, graph2) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dx, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - - def bounded_riemann_rectangles_y( - self, - graph1, - graph2, - y_min=None, - y_max=None, - dy=0.01, - input_sample_type="center", - stroke_width=1, - stroke_color=BLACK, - fill_opacity=1, - start_color=None, - end_color=None, - show_signed_area=True, - width_scale_factor=1.001 - ): - y_min = y_min if y_min is not None else self.y_min - y_max = y_max if y_max is not None else self.y_max - if start_color is None: - start_color = self.default_riemann_start_color - if end_color is None: - end_color = self.default_riemann_end_color - rectangles = VGroup() - y_range = np.arange(y_min, y_max, dy) - colors = color_gradient([start_color, end_color], len(y_range)) - for y, color in zip(y_range, colors): - if input_sample_type == "left": - sample_input = y - elif input_sample_type == "right": - sample_input = y + dy - elif input_sample_type == "center": - sample_input = y + 0.5 * dy - else: - raise Exception("Invalid input sample type") - graph1_point = self.coords_to_point( - graph1(sample_input),sample_input - ) - dy_input=sample_input + width_scale_factor * dy - graph1_point_dy= self.coords_to_point( - graph1(dy_input),dy_input - ) - graph2_point = self.coords_to_point( - graph2(sample_input),sample_input - ) - - points = VGroup(*list(map(VectorizedPoint, [ - graph1_point, - graph1_point_dy, - graph2_point - ]))) - - rect = Rectangle() - rect.replace(points, stretch=True) - if graph1_point[1] < self.graph_origin[1] and show_signed_area: - fill_color = invert_color(color) - else: - fill_color = color - rect.set_fill(fill_color, opacity=fill_opacity) - rect.set_stroke(stroke_color, width=stroke_width) - rectangles.add(rect) - return rectangles - - -#uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem -- cgit From 624869428ba1be7a499b837dfff9d26793fc1c3b Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 11:19:24 +0530 Subject: update README --- .../integrals-of-multivariable-functions/README.md | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index a321caf..02914ad 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -1 +1,6 @@ FSF2020--Somnath Pandit + +**Topics:** + +1. Double Integral +2. Fubini's Theorem -- cgit From c0fe39d398631f5b8bb251d9b22033a1f1c4a8dd Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 11:47:13 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 02914ad..58b9c1a 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -3,4 +3,21 @@ FSF2020--Somnath Pandit **Topics:** 1. Double Integral + +![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?raw=true) + +![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?raw=true) + +![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?raw=true/file3_y_limit_dependent_on_x.gif) + +![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?raw=true) + +![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?raw=true) + 2. Fubini's Theorem + +![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif?raw=true) + +![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif?raw=true) + +![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif?raw=true) -- cgit From 848e6a16dc79e41b3242e934ec7df3954680a2ad Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 11:48:47 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 58b9c1a..c738f08 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -8,7 +8,7 @@ FSF2020--Somnath Pandit ![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?raw=true) -![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?raw=true/file3_y_limit_dependent_on_x.gif) +![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](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?raw=true) -- cgit From 788ce8d1cc33eff2f2f543fcacceb5a80e79d7ea Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 11:55:28 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index c738f08..80ecad8 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -2,22 +2,30 @@ FSF2020--Somnath Pandit **Topics:** -1. Double Integral +# Double Integral +**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?raw=true) +**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?raw=true) +**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?raw=true) +**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?raw=true) -2. Fubini's Theorem +# Fubini's Theorem +**file1_surface1** ![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif?raw=true) +**file2_surface2** ![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif?raw=true) +**file3_iteration_methods** ![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif?raw=true) -- cgit From 6f7c072b4e19fbdad05de3158b4d262417ded2c5 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 11:58:49 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 80ecad8..23e2423 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -5,27 +5,27 @@ FSF2020--Somnath Pandit # Double Integral **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?raw=true) +![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?raw=true) +![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?raw=true) +![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?raw=true) +![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) # Fubini's Theorem **file1_surface1** -![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif?raw=true) +![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) **file2_surface2** -![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif?raw=true) +![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) **file3_iteration_methods** -![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif?raw=true) +![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) -- cgit From a805f5b76f0a82a230acbc79f3dafce13e3b37be Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 28 May 2020 14:29:50 +0530 Subject: added curvy_region --- .../integrals-of-multivariable-functions/README.md | 5 + .../fubini's-theorem/file4_curvy_region.gif | Bin 0 -> 1282583 bytes .../fubini's-theorem/file4_curvy_region.py | 102 +++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 23e2423..0cd6968 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -29,3 +29,8 @@ FSF2020--Somnath Pandit **file3_iteration_methods** ![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) + +**file4_curvy_limits** +![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif new file mode 100644 index 0000000..b0620e5 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py new file mode 100644 index 0000000..46134a7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py @@ -0,0 +1,102 @@ +from manimlib.imports import * + +class CurvyRegion(GraphScene): + CONFIG = { + "x_min": 0, + "x_max": 8, + "y_min": 0, + "y_max": 6, + "graph_origin": ORIGIN+4.5*LEFT+3*DOWN, + "x_labeled_nums": np.arange(0, 9,2), + "y_labeled_nums": np.arange(0, 7,2), + "x_axis_width": 6, + "y_axis_height": 6, + } + + def construct(self): + XD = self.x_axis_width/(self.x_max- self.x_min) + YD = self.y_axis_height/(self.y_max- self.y_min) + self.X=XD*RIGHT ;self.Y=YD*UP + + sin_curve_points=[self.graph_origin+(2+.5*np.sin(2*y),y,0) + for y in np.arange(1,5,.005)] + + cos_curve_points=[self.graph_origin+( + 5+.5*np.cos(2*y),y,0) + for y in np.arange(1,5,.005)] + cos_curve_points.reverse() + + region=Polygon( + *sin_curve_points+cos_curve_points, + color=YELLOW, + stroke_width=1, + fill_color=BLUE_E, + fill_opacity=.75 + ) + + line=Line((1,0,0),(1,6,0),color=RED) + line.move_to(self.graph_origin+2.5*self.X,DOWN) + self.line=line + self.setup_axes(animate = False) + + self.add(region) + self.wait() + self.first_y_int_scene() + self.try_x_first_scene() + + + def first_y_int_scene(self): + talk=TextMobject(r"For doing the $y$ integration\\ first we need to set\\ proper $y$ limts").to_corner(UR,buff=LARGE_BUFF) + problem=TextMobject(r"But here we get\\ more than two $y$ values\\ for a single $x$ value" ).to_corner(UR,buff=LARGE_BUFF) + int_y=TextMobject("$$\\int_?^? dy$$").next_to(problem,DOWN,buff=.5) + + self.play(Write(talk)) + self.play(FadeIn(self.line)) + self.wait(2) + self.play(ReplacementTransform(talk,problem)) + self.play( + ApplyMethod(self.line.shift,3.7*self.X), + run_time=4 + ) + self.wait() + self.play(Write(int_y)) + self.wait(3) + self.play(FadeOut(VGroup(problem,int_y,self.line))) + + def try_x_first_scene(self): + try_text=TextMobject(r"But if we try to integrate\\ along $x$ first ...." ).to_corner(UR,buff=LARGE_BUFF) + good_limits=TextMobject(r"For one $y$ value we get\\ only \textbf{two} $x$ values $\dots$").to_corner(UR,buff=LARGE_BUFF) + limit_values= TextMobject(r"one Lower limit\\ one Upper limit ").next_to(good_limits,DOWN,buff=.5) + int_x=TextMobject("$$\\int_{f(y)}^{g(y)} dx$$").next_to(limit_values,DOWN) + + self.setup_line() + self.play(Write(try_text)) + self.play(FadeIn(self.line)) + self.wait() + self.play(ReplacementTransform(try_text,good_limits)) + self.wait() + self.play( + ApplyMethod(self.line.shift,3*self.Y), + run_time=4 + ) + self.play(Write(limit_values)) + self.wait() + self.show_functions() + self.play(Write(int_x)) + self.wait(3) + + def setup_line(self): + line=self.line.rotate(PI/2) + line.move_to(self.graph_origin+.5*self.X+1.5*self.Y,LEFT) + self.line=line + + def show_functions(self): + fy=TextMobject("$$f(y)$$") + gy=TextMobject("$$g(y)$$") + fy.move_to(self.graph_origin+2*self.X+3.3*self.Y) + gy.move_to(self.graph_origin+7*self.X+2*self.Y) + self.play(FadeIn(VGroup(fy,gy))) + + + #uploaded by Somnath Pandit.FSF2020_Fubini's_Theorem + -- 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 ++++++++++++++++++++ .../fubini's-theorem/file3_iteration_methods.gif | Bin 1762897 -> 1813461 bytes .../fubini's-theorem/file3_iteration_methods.py | 13 +- 8 files changed, 668 insertions(+), 7 deletions(-) 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') 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 diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif index e73dd8e..4e1611b 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py index 662242a..ad78a0b 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.py @@ -63,15 +63,13 @@ class IterationMethods(GraphScene): ).align_to( caption_limit,LEFT ) - + self.int_lim=int_lim self.play(ShowCreation(VGroup(curve1,curve2)),Write(VGroup(c2_eqn,c1_eqn))) self.play(Write(caption_limit)) self.get_rects() self.show_integral_values_at_different_x() self.wait(1) - self.add(int_lim) - self.integral_setup(int_lim,first_y=True) @@ -105,8 +103,9 @@ class IterationMethods(GraphScene): int_lim_y=int_lim.copy() int_lim_y.next_to(int_lim,DOWN) + self.int_lim_y=int_lim_y equal=TextMobject("$$=$$").next_to(int_lim_y,LEFT) - self.add(equal,int_lim_y) + self.add(equal) self.integral_setup(int_lim_y,first_y=False) @@ -139,7 +138,8 @@ class IterationMethods(GraphScene): self.play(ApplyMethod( self.dx_label.next_to, self.y_int,RIGHT), - ShowCreation(area),run_time=4 + ShowCreation(area), + Write(self.int_lim),run_time=4 ) else: area=self.get_area(base_y=True) @@ -155,7 +155,8 @@ class IterationMethods(GraphScene): self.play(ApplyMethod( self.dy_label.next_to, self.x_int,RIGHT), - ShowCreation(area),run_time=4 + ShowCreation(area), + Write(self.int_lim_y),run_time=4 ) def get_area(self,base_y=False): -- cgit From 5c7407ce38cc135e6f72d4bd690c8739bd619511 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 16:54:10 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 29 +--------------------- 1 file changed, 1 insertion(+), 28 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 0cd6968..25eb3c8 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -4,33 +4,6 @@ FSF2020--Somnath Pandit # Double Integral -**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) - # Fubini's Theorem -**file1_surface1** -![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) - -**file2_surface2** -![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) - -**file3_iteration_methods** -![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) - -**file4_curvy_limits** -![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) - - +# Line Integrals -- cgit From 7540f66931aa7fe35a432af5ccda59f7269b0c04 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 16:55:22 +0530 Subject: Create Animations.md --- .../fubini's-theorem/Animations.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md new file mode 100644 index 0000000..c1c6e8e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md @@ -0,0 +1,14 @@ + +**file1_surface1** +![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) + +**file2_surface2** +![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) + +**file3_iteration_methods** +![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) + +**file4_curvy_limits** +![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) + + -- cgit From 9d057283b06096be29f468dba9618828ccd14925 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 16:56:45 +0530 Subject: Rename Animations.md to README.md --- .../fubini's-theorem/Animations.md | 14 -------------- .../fubini's-theorem/README.md | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 14 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md deleted file mode 100644 index c1c6e8e..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/Animations.md +++ /dev/null @@ -1,14 +0,0 @@ - -**file1_surface1** -![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) - -**file2_surface2** -![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) - -**file3_iteration_methods** -![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) - -**file4_curvy_limits** -![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) - - diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md new file mode 100644 index 0000000..c1c6e8e --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/README.md @@ -0,0 +1,14 @@ + +**file1_surface1** +![file1_surface1](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file1_surface1.gif) + +**file2_surface2** +![file2_surface2](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file2_surface2.gif) + +**file3_iteration_methods** +![file3_iteration_methods](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file3_iteration_methods.gif) + +**file4_curvy_limits** +![file4_curvy_limits](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.gif) + + -- cgit From 5baeb584839361cd7b5c0eadbe15edbfb0e84a00 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Sun, 31 May 2020 17:04:19 +0530 Subject: Update README.md --- .../integrals-of-multivariable-functions/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 25eb3c8..221e78d 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -1,9 +1,9 @@ FSF2020--Somnath Pandit -**Topics:** +# **Topics:** -# Double Integral +## Double Integral -# Fubini's Theorem +## Fubini's Theorem -# Line Integrals +## Line Integrals -- 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') 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 29f26bf517b4cd42e75d41d2bdf3e77f0b04a514 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 2 Jun 2020 23:07:03 +0530 Subject: Scalar func sum method --- .../line-integral/file1_scalar_line_int_as_sum.gif | Bin 0 -> 1051018 bytes .../line-integral/file1_scalar_line_int_as_sum.py | 227 +++++++++++++++++++++ 2 files changed, 227 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif new file mode 100644 index 0000000..1984b08 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py new file mode 100644 index 0000000..e3f3574 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py @@ -0,0 +1,227 @@ +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "x_axis_width": 10, + "y_axis_height": 6 , + "x_tick_frequency": 2, + "y_tick_frequency": 2, + "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), + "a": 1 ,"b": 9, "n": 15, + } + + 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.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{path of intgration}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + self.construct_equation() + self.wait(2) + + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$f(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$f(x,y)$",ORANGE) + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.wait() + self.position_of_point_irrelevent() + self.multiply_with_function(dots) + + + + def multiply_with_function(self,dots): + index=-(len(self.points)//3) + dot=dots[index] + + + multiply_text=TexMobject("f(x_i,y_i)", "\\text{ is multiplied with }","\\Delta s_i") + multiply_text.set_color_by_tex_to_color_map({ + "f(x_i,y_i)":ORANGE , "\\Delta s_i": BLUE + }) + multiply_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$f(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR) + + sum_up_text=TextMobject("and "," summed ", "for all i' s") + sum_up_text.set_color_by_tex("summed",PURPLE) + sum_up_text.next_to(multiply_text,DOWN) + + dot.set_color(ORANGE).scale(1.2) + + self.play(FadeIn(VGroup( + point_coord,dot + ))) + self.play(Write(self.evaluate_text)) + self.play(Write(func_val)) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in dots ] + ))) + self.wait(2) + self.remove(point_coord) + self.get_ds(dots,index) + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(FadeOut(VGroup( + self.ds_brace, + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + func_val, RIGHT,buff=.2 + )) + self.play(Write(sum_up_text)) + + self.func_val=func_val + self.sum_text_group=VGroup(multiply_text,sum_up_text) + + def position_of_point_irrelevent(self): + pass + + + + def get_ds(self,dots,index): + p1= dots[index] + p2= dots[index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE) + sum_eqn.move_to(self.graph_origin+7*self.X+4*self.Y) + + line_integral_text=TextMobject("The Value of the line integral is").next_to(self.sum_text_group,IN) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup(self.func_val,self.ds_brace_label) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(self.sum_text_group)) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals + + + -- cgit From e531d1c5a95d57266de08d098bfea7bc4dde3fd7 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 2 Jun 2020 23:11:09 +0530 Subject: Update folder name and README --- .../line-integral/file1_scalar_line_int_as_sum.gif | Bin 1051018 -> 0 bytes .../line-integral/file1_scalar_line_int_as_sum.py | 227 --------------------- .../line-integrals/README.md | 11 + .../file1_scalar_line_int_as_sum.gif | Bin 0 -> 1051018 bytes .../line-integrals/file1_scalar_line_int_as_sum.py | 227 +++++++++++++++++++++ 5 files changed, 238 insertions(+), 227 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif deleted file mode 100644 index 1984b08..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py deleted file mode 100644 index e3f3574..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integral/file1_scalar_line_int_as_sum.py +++ /dev/null @@ -1,227 +0,0 @@ -from manimlib.imports import * - - -class LineIntegrationAsSum(GraphScene): - CONFIG = { - "x_min" : 0, - "x_max" : 10, - "y_min" : 0, - "y_max" : 6, - "graph_origin": ORIGIN+5*LEFT+3*DOWN, - "x_axis_width": 10, - "y_axis_height": 6 , - "x_tick_frequency": 2, - "y_tick_frequency": 2, - "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), - "a": 1 ,"b": 9, "n": 15, - } - - 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.X=X ;self.Y=Y - - self.setup_axes(animate=False) - - curve=self.get_graph( - self.Func, - x_min=self.a, - x_max=self.b, - ) - curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) - curve_label= self.get_graph_label( - curve, - label="\\text{path of intgration}", - x_val=4, - direction=UR, - buff=.6, - color=BLUE - ) - self.curve=curve - self.curve_label=curve_label - - self.play(ShowCreation(VGroup(curve,curve_label))) - self.wait(.6) - self.break_in_arcs() - self.show_the_sum() - self.construct_equation() - self.wait(2) - - - - def break_in_arcs(self): - - self.write_about_breaking() - - dl=0.8 - self.get_breakers(dl) - self.wait(2) - self.play(FadeOut(self.upto_break_text)) - self.dl=dl - - def write_about_breaking(self): - breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") - breaking_text.set_color_by_tex_to_color_map({ - "broken":RED,"subarcs": BLUE - }) - breaking_text.next_to(self.curve_label,DOWN) - breaking_text.align_to(self.curve_label,LEFT) - self.play( - Write(breaking_text) - ) - - self.upto_break_text=VGroup( - self.curve_label, - breaking_text, - ) - - def get_breakers(self,dl): - point=self.a - points=[] - while point<(self.b-dl) : - start=point - end=point+dl - points += [end] - breaker=Line( - self.input_to_graph_point(start,self.curve), - self.input_to_graph_point(end,self.curve), - stroke_width=2, - color=RED, - ) - breaker.rotate(PI/2).scale(.5) - - point=end - self.play(FadeIn(breaker),run_time=.2) - # self.add(breaker) - - del points[-1] - self.points=points - - - def show_the_sum(self): - at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") - at_any_points_text.set_color_by_tex_to_color_map({ - "point":YELLOW , "subarc": BLUE - }) - at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) - - evaluate_text=TextMobject("$f(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) - evaluate_text.set_color_by_tex("$f(x,y)$",ORANGE) - - self.at_any_points_text=at_any_points_text - self.evaluate_text=evaluate_text - - - dots=[] - for point in self.points: - - dot=Dot( - point=self.input_to_graph_point(point,self.curve), - radius= .7*DEFAULT_DOT_RADIUS, - stroke_width= 0, - fill_opacity= 1.0, - color= YELLOW, - ) - dots+=[dot] - - self.play( - Write(at_any_points_text), - FadeIn(VGroup(*dots)),run_time=1.5 - ) - self.wait() - self.position_of_point_irrelevent() - self.multiply_with_function(dots) - - - - def multiply_with_function(self,dots): - index=-(len(self.points)//3) - dot=dots[index] - - - multiply_text=TexMobject("f(x_i,y_i)", "\\text{ is multiplied with }","\\Delta s_i") - multiply_text.set_color_by_tex_to_color_map({ - "f(x_i,y_i)":ORANGE , "\\Delta s_i": BLUE - }) - multiply_text.to_edge(TOP,buff=MED_SMALL_BUFF) - - point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) - point_coord.next_to(dot,DL,buff=.01).scale(.8) - - func_val=TextMobject("$f(x_i,y_i)$",color=ORANGE) - func_val.next_to(dot,UR) - - sum_up_text=TextMobject("and "," summed ", "for all i' s") - sum_up_text.set_color_by_tex("summed",PURPLE) - sum_up_text.next_to(multiply_text,DOWN) - - dot.set_color(ORANGE).scale(1.2) - - self.play(FadeIn(VGroup( - point_coord,dot - ))) - self.play(Write(self.evaluate_text)) - self.play(Write(func_val)) - self.play(FadeIn(VGroup(*[ - dot.set_color(ORANGE).scale(1.4) - for dot in dots ] - ))) - self.wait(2) - self.remove(point_coord) - self.get_ds(dots,index) - self.play(GrowFromCenter(self.ds_brace_group)) - self.wait(2) - self.play(FadeOut(VGroup( - self.ds_brace, - self.at_any_points_text, - self.evaluate_text - ))) - self.play(Write(multiply_text)) - self.play(ApplyMethod( - self.ds_brace_label.next_to, - func_val, RIGHT,buff=.2 - )) - self.play(Write(sum_up_text)) - - self.func_val=func_val - self.sum_text_group=VGroup(multiply_text,sum_up_text) - - def position_of_point_irrelevent(self): - pass - - - - def get_ds(self,dots,index): - p1= dots[index] - p2= dots[index+1] - ds_brace=Brace(VGroup(p1,p2),DL) - ds_brace.move_to(p1,UR) - ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) - ds_brace_label.set_color(BLUE) - self.ds_brace=ds_brace - self.ds_brace_label=ds_brace_label - self.ds_brace_group=VGroup(ds_brace,ds_brace_label) - - - def construct_equation(self): - sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE) - sum_eqn.move_to(self.graph_origin+7*self.X+4*self.Y) - - line_integral_text=TextMobject("The Value of the line integral is").next_to(self.sum_text_group,IN) - approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) - multipled=VGroup(self.func_val,self.ds_brace_label) - self.play(FadeIn(sum_eqn)) - self.play(ApplyMethod( - multipled.next_to,sum_eqn,RIGHT - )) - self.wait() - self.play(FadeOut(self.sum_text_group)) - self.play(Write(line_integral_text)) - self.play(FadeIn(approx)) - - - -#uploaded by Somnath Pandit.FSF2020_Line Integrals - - - diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md new file mode 100644 index 0000000..b96c308 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -0,0 +1,11 @@ +** +![]() + +** +![]() + +** +![]() + +** +![]() diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif new file mode 100644 index 0000000..1984b08 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py new file mode 100644 index 0000000..e3f3574 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.py @@ -0,0 +1,227 @@ +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "x_axis_width": 10, + "y_axis_height": 6 , + "x_tick_frequency": 2, + "y_tick_frequency": 2, + "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), + "a": 1 ,"b": 9, "n": 15, + } + + 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.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{path of intgration}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + self.construct_equation() + self.wait(2) + + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$f(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$f(x,y)$",ORANGE) + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.wait() + self.position_of_point_irrelevent() + self.multiply_with_function(dots) + + + + def multiply_with_function(self,dots): + index=-(len(self.points)//3) + dot=dots[index] + + + multiply_text=TexMobject("f(x_i,y_i)", "\\text{ is multiplied with }","\\Delta s_i") + multiply_text.set_color_by_tex_to_color_map({ + "f(x_i,y_i)":ORANGE , "\\Delta s_i": BLUE + }) + multiply_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$f(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR) + + sum_up_text=TextMobject("and "," summed ", "for all i' s") + sum_up_text.set_color_by_tex("summed",PURPLE) + sum_up_text.next_to(multiply_text,DOWN) + + dot.set_color(ORANGE).scale(1.2) + + self.play(FadeIn(VGroup( + point_coord,dot + ))) + self.play(Write(self.evaluate_text)) + self.play(Write(func_val)) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in dots ] + ))) + self.wait(2) + self.remove(point_coord) + self.get_ds(dots,index) + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(FadeOut(VGroup( + self.ds_brace, + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + func_val, RIGHT,buff=.2 + )) + self.play(Write(sum_up_text)) + + self.func_val=func_val + self.sum_text_group=VGroup(multiply_text,sum_up_text) + + def position_of_point_irrelevent(self): + pass + + + + def get_ds(self,dots,index): + p1= dots[index] + p2= dots[index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE) + sum_eqn.move_to(self.graph_origin+7*self.X+4*self.Y) + + line_integral_text=TextMobject("The Value of the line integral is").next_to(self.sum_text_group,IN) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup(self.func_val,self.ds_brace_label) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(self.sum_text_group)) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals + + + -- cgit From a3318e22d7f309ec3955ad4f2c53f31797484fc1 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 2 Jun 2020 23:15:54 +0530 Subject: update README --- .../integrals-of-multivariable-functions/line-integrals/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md index b96c308..b7e1846 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -1,5 +1,5 @@ -** -![]() +**file1_scalar_line_int_as_sum** +![file1_scalar_line_int_as_sum](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif) ** ![]() -- cgit From 989ed38029bb9a7fb8e6d0124d544bd51555fb16 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Wed, 3 Jun 2020 21:35:07 +0530 Subject: new animation --- .../line-integrals/README.md | 7 +- .../file3_vector_line_int_as_sum.gif | Bin 0 -> 1670998 bytes .../line-integrals/file3_vector_line_int_as_sum.py | 326 +++++++++++++++++++++ 3 files changed, 331 insertions(+), 2 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md index b7e1846..bd7e520 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -4,8 +4,11 @@ ** ![]() -** -![]() + +**file3_vector_line_int_as_sum** +![file3_vector_line_int_as_sum](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif) + + ** ![]() diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif new file mode 100644 index 0000000..46b35bc Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py new file mode 100644 index 0000000..78294cc --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file3_vector_line_int_as_sum.py @@ -0,0 +1,326 @@ +from manimlib.imports import * + + +class LineIntegrationAsSum(GraphScene): + CONFIG = { + "x_min" : 0, + "x_max" : 10, + "y_min" : 0, + "y_max" : 6, + "graph_origin": ORIGIN+5*LEFT+3*DOWN, + "x_axis_width": 10, + "y_axis_height": 6 , + "x_tick_frequency": 2, + "y_tick_frequency": 2, + "Func":lambda x : 1+x**1.3*np.exp(-.12*(x-2)**2)*np.sin(x/4), + "a": 1 ,"b": 9, "n": 15, + } + + 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.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + curve=self.get_graph( + self.Func, + x_min=self.a, + x_max=self.b, + ) + curve.set_color([BLACK,BLUE,BLUE,BLUE,BLACK]) + curve_label= self.get_graph_label( + curve, + label="\\text{path of intgration}", + x_val=4, + direction=UR, + buff=.6, + color=BLUE + ) + self.curve=curve + self.curve_label=curve_label + + self.get_vector_field() + + + self.play(ShowCreation(VGroup(curve,curve_label))) + self.wait(.6) + self.break_in_arcs() + self.show_the_sum() + + self.wait(2) + + + def get_vector_field(self): + func = lambda v: np.array([ + v[0], # x + -v[1], # y + 0 # z + ]) + vector_field= VectorField( + func, + delta_x=1, + delta_y=1, + colors=[GREEN_A,GREEN_C], + length_func= lambda norm: .8*sigmoid(norm), + vector_config={ + "stroke_width": 2 + } + ) + + self.vector_field= vector_field + + + def break_in_arcs(self): + + self.write_about_breaking() + + dl=0.8 + self.get_breakers(dl) + self.wait(2) + self.play(FadeOut(self.upto_break_text)) + self.dl=dl + + def write_about_breaking(self): + breaking_text=TextMobject("\\texttt{..broken}"," into small", "subarcs") + breaking_text.set_color_by_tex_to_color_map({ + "broken":RED,"subarcs": BLUE + }) + breaking_text.next_to(self.curve_label,DOWN) + breaking_text.align_to(self.curve_label,LEFT) + self.play( + Write(breaking_text) + ) + + self.upto_break_text=VGroup( + self.curve_label, + breaking_text, + ) + + def get_breakers(self,dl): + point=self.a + points=[] + while point<(self.b-dl) : + start=point + end=point+dl + points += [end] + breaker=Line( + self.input_to_graph_point(start,self.curve), + self.input_to_graph_point(end,self.curve), + stroke_width=2, + color=RED, + ) + breaker.rotate(PI/2).scale(.5) + + point=end + self.play(FadeIn(breaker),run_time=.2) + # self.add(breaker) + + del points[-1] + self.points=points + + + def show_the_sum(self): + at_any_points_text=TextMobject("At any ","point", "in each ", "subarc") + at_any_points_text.set_color_by_tex_to_color_map({ + "point":YELLOW , "subarc": BLUE + }) + at_any_points_text.to_edge(TOP,buff=SMALL_BUFF) + + evaluate_text=TextMobject("$\\vec F(x,y)$ ", "is evaluated").next_to(at_any_points_text,DOWN) + evaluate_text.set_color_by_tex("$\\vec F(x,y)$",ORANGE) + + multiply_text=TextMobject("...is multiplied with ","$\\Delta s_i$") + multiply_text.set_color_by_tex("\\Delta s_i", BLUE) + multiply_text.next_to(at_any_points_text,DOWN) + + + + self.at_any_points_text=at_any_points_text + self.evaluate_text=evaluate_text + self.multiply_text=multiply_text + + dots=[] + for point in self.points: + + dot=Dot( + point=self.input_to_graph_point(point,self.curve), + radius= .7*DEFAULT_DOT_RADIUS, + stroke_width= 0, + fill_opacity= 1.0, + color= YELLOW, + ) + dots+=[dot] + + self.play( + Write(at_any_points_text), + FadeIn(VGroup(*dots)),run_time=1.5 + ) + self.dots=dots + + self.wait() + self.show_the_dot_product() + self.multiply_with_ds() + self.construct_equation() + + + def show_the_dot_product(self): + index=-(len(self.points)//3) + self.index=index + + dot=self.dots[index] + + + dot_prod_text=TextMobject("Dot Product of", "$\\vec F(x_i,y_i)$", "and","$\\vec T(x_i,y_i)$") + dot_prod_text.set_color_by_tex_to_color_map({ + "\\vec F(x_i,y_i)":ORANGE , + "\\vec T(x_i,y_i)": "#DC75CD" , + }) + dot_prod_text.to_edge(TOP,buff=SMALL_BUFF) + + + point_coord=TextMobject("$(x_i,y_i)$",color=YELLOW) + point_coord.next_to(dot,DL,buff=.01).scale(.8) + + func_val=TextMobject("$\\vec F(x_i,y_i)$",color=ORANGE) + func_val.next_to(dot,UR).scale(.8) + + self.dot_prod_text=dot_prod_text + self.func_val=func_val + + dot.set_color(ORANGE).scale(1.2) + + + self.play(FadeIn(VGroup(point_coord,dot))) + self.play(Write(self.evaluate_text)) + self.wait(1) + self.play(FadeOut(self.vector_field)) + self.get_vector_and_tangent() + self.dot_product() + + + self.wait(2) + self.remove(point_coord) + + + def get_vector_and_tangent(self): + dot=self.dots[self.index] + self.show_specific_vectors(dot) + self.play(Write(self.func_val)) + self.wait(1) + self.show_tangent(dot) + self.play(FadeIn(VGroup(*[ + dot.set_color(ORANGE).scale(1.4) + for dot in self.dots ] + ))) + + + def show_specific_vectors(self,dots): + for dot in dots: + vector=self.vector_field.get_vector(dot.get_center()) + vector.set_color(ORANGE) + + self.play(Write(vector),run_time=.2) + + + def show_tangent(self,dot): + tangent_sym=TextMobject("$\\vec T(x_i,y_i)$",color="#DC75CD").scale(.8) + x=dot.get_center() + angle=self.angle_of_tangent( + self.point_to_coords(x)[0], + self.curve, + dx=0.01 + ) + vect = Vector().rotate(angle,about_point=x) + vect.set_color("#DC75CD") + tangent=vect.next_to(x,DR,buff=0) + tangent_sym.next_to(tangent,DOWN,buff=.1) + self.play(Write(VGroup(tangent,tangent_sym))) + + self.tangent_sym=tangent_sym + + def dot_product(self): + + dot_sym=Dot().next_to(self.func_val,RIGHT) + + self.play(FadeOut(VGroup( + self.at_any_points_text, + self.evaluate_text + ))) + self.play(Write(self.dot_prod_text)) + self.play( + FadeIn(dot_sym), + ApplyMethod( + self.tangent_sym.next_to, + dot_sym, RIGHT + )) + + self.dot_sym=dot_sym + + def multiply_with_ds(self): + self.get_ds() + + self.play(GrowFromCenter(self.ds_brace_group)) + self.wait(2) + self.play(Write(self.multiply_text)) + self.play(ApplyMethod( + self.ds_brace_label.next_to, + self.tangent_sym, RIGHT,buff=.15 + )) + + + + def get_ds(self): + p1= self.dots[self.index] + p2= self.dots[self.index+1] + ds_brace=Brace(VGroup(p1,p2),DL) + ds_brace.move_to(p1,UR) + ds_brace_label=ds_brace.get_text("$\Delta s_i$", buff = .05) + ds_brace_label.set_color(BLUE) + self.ds_brace=ds_brace + self.ds_brace_label=ds_brace_label + self.ds_brace_group=VGroup(ds_brace,ds_brace_label) + + + def construct_equation(self): + sum_up_text=TextMobject("and"," summed ", "for all i' s") + sum_up_text.set_color_by_tex("summed",PURPLE_A) + sum_up_text.next_to(self.multiply_text,DOWN,buff=MED_SMALL_BUFF) + sum_up_text.shift(LEFT) + + sum_eqn=TextMobject("$$\\sum_i^{ } $$").set_color(PURPLE_A) + sum_eqn.move_to(self.graph_origin+6.5*self.X+4*self.Y) + + line_integral_text=TextMobject("The Value of the"," line ","integral is").to_edge(TOP,buff=MED_SMALL_BUFF) + line_integral_text.set_color_by_tex("line",BLUE_C) + approx=TextMobject("$\\approx$",color=RED).next_to(sum_eqn,LEFT) + multipled=VGroup( + self.func_val, + self.dot_sym, + self.tangent_sym, + self.ds_brace_label + ) + + + self.play(Write(sum_up_text)) + self.show_specific_vectors(self.dots) + self.play(FadeIn(sum_eqn)) + self.play(ApplyMethod( + multipled.next_to,sum_eqn,RIGHT + )) + self.wait() + self.play(FadeOut(VGroup( + self.dot_prod_text, + self.multiply_text, + sum_up_text + ))) + self.play(Write(line_integral_text)) + self.play(FadeIn(approx)) + + + +#uploaded by Somnath Pandit.FSF2020_Line Integrals + + + -- cgit From 9807fbcd45a04d79afcfef0f8f79d49a8626efaa Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 4 Jun 2020 03:42:07 +0530 Subject: New animation --- .../line-integrals/README.md | 4 +- .../line-integrals/file2_scalar_line_integral.gif | Bin 0 -> 4833220 bytes .../line-integrals/file2_scalar_line_integral.py | 422 +++++++++++++++++++++ 3 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md index bd7e520..871eeaa 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -1,8 +1,8 @@ **file1_scalar_line_int_as_sum** ![file1_scalar_line_int_as_sum](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file1_scalar_line_int_as_sum.gif) -** -![]() +**file2_scalar_line_integral** +![file2_scalar_line_integral](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif) **file3_vector_line_int_as_sum** diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif new file mode 100644 index 0000000..dc4477d Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py new file mode 100644 index 0000000..310cac0 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py @@ -0,0 +1,422 @@ +from manimlib.imports import * + +class LineIntegrationProcess(SpecialThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -4, + "x_max": 4, + "y_min": 0, + "y_max": 4, + "z_min": 0, + "z_max": 4, + "a":-3 ,"b": 3, "c":0 , "d":3.5, + "axes_shift":3*IN, + "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.2, + "stroke_color": WHITE, + "stroke_opacity": 0.75, + }, + "Func": lambda x,y: 1+x**2*y/15 + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=65 * DEGREES, + theta=-65 * DEGREES, + ) + + fn_text=TextMobject("$z=2+x^2y$").set_color(BLUE) + self.add_fixed_in_frame_mobjects(fn_text) + fn_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + + #get the surface + surface= self.get_surface( + lambda x , y: + self.Func(x,y) + ) + surface.set_style( + fill_opacity=0.5, + fill_color=BLUE_D, + stroke_width=0.5, + stroke_color=WHITE, + ) + + + # self.play(Write(surface)) + self.add(surface) + self.get_line_of_int(fn_text) + self.begin_ambient_camera_rotation(rate=-0.02) + self.get_field_values_on_line() + self.wait(1.5) + self.area=self.get_area() + area_text=TextMobject("Line"," Integral in the",r" scalar field\\"," means this" ,"area") + area_text.set_color_by_tex_to_color_map({ + "Line": PINK, "scalar":BLUE, "area":TEAL_A + }) + area_text.to_edge(TOP,buff=MED_SMALL_BUFF) + + self.remove(self.values_on_line_text) + self.add_fixed_in_frame_mobjects(area_text) + self.play(Write(area_text)) + self.play(Write(self.area),run_time=2) + self.play(FadeOut(surface)) + self.wait() + + self.stop_ambient_camera_rotation() + # self.get_lines() + + self.remove(axes,surface) + self.trasform_to_graphs() + self.wait(2) + + + + + def get_line_of_int(self,fn_text): + self.remove(fn_text) + + line_of_int_text=TextMobject(r"Line of integration is\\","$\\vec r(t)=\cos(t)\hat x+\sin(t)\hat y$") + line_of_int_text[1].set_color(PINK) + line_of_int_text.to_edge(TOP,buff=SMALL_BUFF) + + + line_of_int=(self.get_curve( + self.Func,on_surface=False + )) + line_of_int.set_style( + stroke_width=5, + stroke_color=PINK, + ) + + self.add_fixed_in_frame_mobjects(line_of_int_text) + self.play(Write(line_of_int_text)) + self.wait() + self.play(ShowCreation(line_of_int),run_time=3) + # self.add(line_of_int) + + self.line_of_int=line_of_int + self.line_of_int_text=line_of_int_text + + def get_field_values_on_line(self): + self.remove(self.line_of_int_text) + + values_on_line_text=TextMobject("Values"," of"," function","on the ","line") + values_on_line_text.set_color_by_tex_to_color_map({ + "Values":YELLOW, "function":BLUE,"line":PINK + }) + values_on_line_text.to_edge(TOP,buff=SMALL_BUFF) + + values_on_surface=(self.get_curve( + self.Func,on_surface=True + )) + values_on_surface.set_style( + stroke_width=5, + stroke_color=YELLOW, + ) + + self.add_fixed_in_frame_mobjects(values_on_line_text) + self.play(Write(values_on_line_text)) + # self.wait() + self.play(ShowCreation(values_on_surface),run_time=3) + # self.add(values_on_surface) + + self.values_on_surface=values_on_surface + self.values_on_line_text=values_on_line_text + + + def trasform_to_graphs(self): + on_surface_graph=(self.get_graph( + self.Func,on_surface=True + )) + on_surface_graph.set_style( + stroke_width=5, + stroke_color=YELLOW, + ) + + line_graph=(self.get_graph( + self.Func,on_surface=False + )) + line_graph.set_style( + stroke_width=5, + stroke_color=PINK, + ) + + self.on_surface_graph=on_surface_graph + self.line_graph=line_graph + graph_area=self.get_area(graph=True) + + into_graph=[ + ReplacementTransform( + self.values_on_surface, + on_surface_graph + ), + ReplacementTransform( + self.line_of_int, + line_graph + ), + ReplacementTransform( + self.area, + graph_area + ), + ] + + self.move_camera( + # distance=20, + phi=90 * DEGREES, + theta=-90 * DEGREES, + added_anims=into_graph, + run_time=2 + ) + + def get_area(self,graph=False): + axes=self.axes + if graph: + on_surface=self.on_surface_graph + on_base=self.line_graph + else: + on_surface=self.values_on_surface + on_base=self.line_of_int + area =Polygon( + *[ + on_surface.get_point_from_function(t) + for t in np.arange(0,PI,0.01) + ], + *[ + on_base.get_point_from_function(t) + for t in np.arange(PI,0,-0.01) + ], + stroke_width=0, + fill_color=TEAL_A, + fill_opacity=.6, + ) + + return area + + def get_curve(self,func,on_surface=False ,**kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": 0, + "t_max": PI, + }) + config.update(kwargs) + r=abs(self.axes.a) + curve=ParametricFunction( + lambda t: self.axes.c2p( + r*np.cos(t), + r*np.sin(t), + func(r*np.cos(t), r*np.sin(t))*bool(on_surface) + ), + **config, + ) + return curve + + + def get_surface(self, func, **kwargs): + axes=self.axes + config = { + "u_min": axes.a-.2, + "u_max": axes.b+.2, + "v_min": axes.c-.1, + "v_max": axes.d, + "resolution": ( + 2*(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_graph(self,func,on_surface=False ,**kwargs): + config = dict() + config.update(self.default_graph_style) + config.update({ + "t_min": 0, + "t_max": PI, + }) + config.update(kwargs) + slice_curve=ParametricFunction( + lambda t: self.axes.c2p( + 4*np.cos(t), + 0, + 2+func(3*np.cos(t), 3*np.sin(t))*bool(on_surface) + ), + **config, + ) + return slice_curve + + def get_lines(self): + pass + 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,"PINK")) + + 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) + self.axes=axes + + 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( + lambda x, t: 0 + ) + '''input_plane.set_style( + fill_opacity=0.3, + fill_color=PINK, + stroke_width=.2, + stroke_color=WHITE, + )''' + + axes.input_plane = input_plane + + self.region_corners=[ + input_plane.get_corner(pos) for pos in (DL,DR,UR,UL)] + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.add(axes.input_plane) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + + ("1", axes.b), + ("-1", axes.a), + ] + tex_vals_y=[ + + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + # label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + 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_Line_Integrals -- cgit From eaa80a0103a8f84a455c331e3a3684f5ce4382dd Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 4 Jun 2020 10:50:38 +0530 Subject: updated --- .../line-integrals/file2_scalar_line_integral.gif | Bin 4833220 -> 5612895 bytes .../line-integrals/file2_scalar_line_integral.py | 19 ++++++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif index dc4477d..71c97d6 100644 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py index 310cac0..eb5f4ab 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py @@ -52,9 +52,7 @@ class LineIntegrationProcess(SpecialThreeDScene): ) fn_text=TextMobject("$z=2+x^2y$").set_color(BLUE) - self.add_fixed_in_frame_mobjects(fn_text) - fn_text.to_edge(TOP,buff=MED_SMALL_BUFF) - + fn_text.to_corner(UR,buff=.8).shift(DOWN) #get the surface surface= self.get_surface( @@ -69,10 +67,11 @@ class LineIntegrationProcess(SpecialThreeDScene): ) - # self.play(Write(surface)) - self.add(surface) - self.get_line_of_int(fn_text) - self.begin_ambient_camera_rotation(rate=-0.02) + # self.play(Write(surface)) + self.add_fixed_in_frame_mobjects(fn_text) + self.play(Write(surface),Write(fn_text)) + self.get_line_of_int() + self.begin_ambient_camera_rotation(rate=-0.035) self.get_field_values_on_line() self.wait(1.5) self.area=self.get_area() @@ -86,7 +85,7 @@ class LineIntegrationProcess(SpecialThreeDScene): self.add_fixed_in_frame_mobjects(area_text) self.play(Write(area_text)) self.play(Write(self.area),run_time=2) - self.play(FadeOut(surface)) + self.play(FadeOut(VGroup(surface,fn_text))) self.wait() self.stop_ambient_camera_rotation() @@ -99,9 +98,7 @@ class LineIntegrationProcess(SpecialThreeDScene): - def get_line_of_int(self,fn_text): - self.remove(fn_text) - + def get_line_of_int(self): line_of_int_text=TextMobject(r"Line of integration is\\","$\\vec r(t)=\cos(t)\hat x+\sin(t)\hat y$") line_of_int_text[1].set_color(PINK) line_of_int_text.to_edge(TOP,buff=SMALL_BUFF) -- cgit From 1f5c1963da6ff76b58910063d31138f104759a1c Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Thu, 4 Jun 2020 17:35:27 +0530 Subject: new animation --- .../line-integrals/README.md | 4 +- .../line-integrals/file2_scalar_line_integral.py | 2 + .../line-integrals/file4_helix.gif | Bin 0 -> 1237895 bytes .../line-integrals/file4_helix.py | 245 +++++++++++++++++++++ 4 files changed, 249 insertions(+), 2 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md index 871eeaa..17077b6 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/README.md @@ -10,5 +10,5 @@ -** -![]() +**file4_helix** +![file4_helix](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py index eb5f4ab..996ead1 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file2_scalar_line_integral.py @@ -417,3 +417,5 @@ class LineIntegrationProcess(SpecialThreeDScene): #uploaded by Somnath Pandit.FSF2020_Line_Integrals + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif new file mode 100644 index 0000000..ceedb1f Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py new file mode 100644 index 0000000..50aeb33 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/line-integrals/file4_helix.py @@ -0,0 +1,245 @@ +from manimlib.imports import * + +class ParametricCurve(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": 0, + "x_max": 3, + "y_min": 0, + "y_max": 3, + "z_min": 0, + "z_max": 4, + "a":0 ,"b": 2, "c":0 , "d":2, + "axes_shift":2*IN+1.4*RIGHT+1.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, + }, + }, + + } + + + def construct(self): + + self.setup_axes() + + self.set_camera_orientation( + distance=25, + phi=60 * DEGREES, + theta=40 * DEGREES, + ) + + label=TextMobject("Helix",color=PURPLE).scale(1.6) + label.to_corner(UR,buff=2) + self.add_fixed_in_frame_mobjects(label) + + helix=self.get_helix( + radius=1.5, + t_min= 0, + t_max= 4*PI, + color=PURPLE + ) + parameter_label=TextMobject( + "Parametric equation: ", + color=TEAL + ).next_to(label,DOWN,buff=.3 + ) + parametric_eqn=TextMobject( + "$x=\cos$ (","t", + r")\\$y=\sin $(","t", + r")\\$z$=","t" + ).next_to(parameter_label,DOWN,buff=.1) + parametric_eqn.set_color_by_tex("t",RED) + self.parametric_eqn=parametric_eqn + + parametriztion=VGroup( + parameter_label, + parametric_eqn + ) + + + self.play(ShowCreation(helix),run_time=2) + self.begin_ambient_camera_rotation(.1) + self.wait(1) + self.add_fixed_in_frame_mobjects(parametriztion) + self.play(Write(parametriztion)) + self.wait(1) + self.stop_ambient_camera_rotation() + self.move_camera( + distance=20, + phi=85 * DEGREES, + # theta=-90 * DEGREES, + run_time=3 + ) + scale_axes=VGroup(self.axes,helix).scale(1.2) + self.show_the_parameter() + self.wait(2) + + + + def get_helix(self,radius=1, **kwargs): + config = { + "t_min": 0, + "t_max": 2*PI, + } + config.update(kwargs) + helix= ParametricFunction( + lambda t : self.axes.c2p( + radius*np.cos(t), + radius*np.sin(t), + t/4 + ), + **config + ) + + self.helix=helix + return helix + + def show_the_parameter(self): + t_tracker = ValueTracker(0) + t=t_tracker.get_value + + t_label = TexMobject( + "t = ",color=RED + ).next_to(self.parametric_eqn,DL,buff=.85) + + t_text = always_redraw( + lambda: DecimalNumber( + t(), + color=GOLD, + ).next_to(t_label, RIGHT, MED_SMALL_BUFF) + ) + t_text.suspend_updating() + + dot = Sphere( + radius= 1.5*DEFAULT_DOT_RADIUS, + stroke_width= 1, + fill_opacity= 1.0, + ) + dot.set_color(GOLD) + dot.add_updater(lambda v: v.move_to( + self.helix.get_point_from_function(PI*t()) + )) + + pi = TexMobject( + "\\pi ", + color=GOLD, + ).next_to(t_text,RIGHT,buff=-.3) + + group = VGroup(t_text,t_label,pi).scale(1.5) + + self.wait(1) + self.add_fixed_in_frame_mobjects(group) + t_text.resume_updating() + self.play(FadeIn(group)) + self.add(dot) + self.play( + t_tracker.set_value,2, + rate_func=linear, + run_time=5 + ) + + +#-------------------------------------------------------- + + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=1.5) + + 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), + ) + + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + axes.scale(1) + # axes.center() + axes.shift(axes.axes_shift) + self.add(axes) + self.axes = axes + + def add_axes_numbers(self, axes): + x_axis = axes.x_axis + y_axis = axes.y_axis + tex_vals_x = [ + ("1", axes.b), + ] + tex_vals_y=[ + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, LEFT) + z_label.next_to(axes.z_axis.get_zenith(), LEFT) + axes.z_axis.label = z_label + for axis in axes: + axis.add(axis.label) + return axes + + #uploaded by Somnath Pandit.FSF2020_Line_integrals + + + + + -- cgit From 16dd9a4ceb110a5f8b900ed83c4a27d99464940c Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Mon, 8 Jun 2020 17:26:02 +0530 Subject: new animation --- .../fundamental-theorem-of-line-integral/README.md | 5 + .../file1_grad_of_scalar_function.gif | Bin 0 -> 4012467 bytes .../grad_of_scalar_function.py | 304 +++++++++++++++++++++ 3 files changed, 309 insertions(+) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md new file mode 100644 index 0000000..6fcbe68 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md @@ -0,0 +1,5 @@ +**file1_grad_of_scalar_function** +![file1_grad_of_scalar_function](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif) + +** +![](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/ .gif) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif new file mode 100644 index 0000000..5a6e102 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py new file mode 100644 index 0000000..3a2c3f7 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py @@ -0,0 +1,304 @@ +from manimlib.imports import * + +class GradOfScalar(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "z_min": 0, + "z_max": 3, + "a":-3 ,"b": 3, "c":-3 , "d":3, + "axes_shift": ORIGIN+IN, + "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_vector_field_config": { + "delta_x": 1, + "delta_y": 1, + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "min_magnitude": 0, + "max_magnitude": 2, + "colors": [TEAL,GREEN,GREEN,GREEN,YELLOW,RED], + "length_func": lambda norm : norm*np.exp(-.38*norm)/2, + "opacity": 1.0, + "vector_config": { + "stroke_width":8 + }, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [BLUE_E], + "stroke_width": .5, + "stroke_color": WHITE, + "stroke_opacity": 0.75, + }, + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=70 * DEGREES, + theta=-135 * DEGREES, + ) + + scalar_fn_text=TexMobject("f(x,y,z)=","xy").set_color(BLUE) + scalar_fn_text.to_corner(UR,buff=.6) + + operator=TexMobject("\\vec\\nabla").next_to( + scalar_fn_text,LEFT,buff=.2 + ).set_color(GOLD) + grad_text=TexMobject(r"\dfrac{\partial f}{\partial x} \hat i+\dfrac{\partial f}{\partial y} \hat j+\dfrac{\partial f}{\partial z} \hat k").set_color(GOLD) + grad_text.next_to(scalar_fn_text,DOWN).scale(.9) + + VGroup(grad_text[0][1],grad_text[0][9],grad_text[0][17]).set_color(BLUE) + VGroup(grad_text[0][5:8],grad_text[0][13:16],grad_text[0][21:23]).set_color(WHITE) + + vector_field_text=TexMobject("\\vec F=y\hat i+x\hat j").set_color_by_gradient(*self.default_vector_field_config["colors"]) + vector_field_text.next_to(scalar_fn_text,DOWN) + + + #always generate the scalar field first + s_field1=self.get_scalar_field( + func= lambda u ,v : u*v/7 + ) + v_field1=self.get_vector_field( + lambda v: np.array([ + v[1], + v[0], + 0, + ]), + on_surface=True, + ) + + self.add_fixed_in_frame_mobjects(scalar_fn_text) + + self.begin_ambient_camera_rotation(rate=.2) + self.play(Write(s_field1)) + self.wait(1) + self.stop_ambient_camera_rotation() + + self.add_fixed_in_frame_mobjects(operator) + self.play(Write(operator),FadeOut(scalar_fn_text[1])) + self.add_fixed_in_frame_mobjects(grad_text) + self.play(Write(grad_text)) + self.wait(2) + + self.play(FadeOut(grad_text)) + self.add_fixed_in_frame_mobjects(vector_field_text) + show_vec_field=[ + FadeIn(v_field1), + Write(vector_field_text), + ] + + self.begin_ambient_camera_rotation(rate=.2) + self.move_camera( + # distance=20, + phi=60 * DEGREES, + added_anims=show_vec_field, + run_time=4.5 + ) + + self.wait(2) + self.stop_ambient_camera_rotation() + + fadeout= [FadeOut(s_field1)] + self.move_camera( + # distance=20, + phi=0 * DEGREES, + theta=-90 * DEGREES, + added_anims=fadeout, + run_time=2 + ) + self.wait(2) + + + + + + def get_scalar_field(self,func,**kwargs): + surface= self.get_surface( + lambda x , y: + func(x,y), + ) + + self.surface_points=self.get_points(func) + return surface + + def get_points(self,func): + axes=self.axes + dn=.5 + x_vals=np.arange(axes.a,axes.b,dn) + y_vals=np.arange(axes.c,axes.d,dn) + points=[] + for x_val in x_vals: + for y_val in y_vals: + points+=[axes.c2p(x_val,y_val,func(x_val,y_val)+.05)] + return points + + def get_vector_field(self,func,on_surface=True,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + self.vector_field=vector_field + + if on_surface: + vector_field1=self.get_vectors_on_surface() + + return vector_field1 + + + + def get_vectors_on_surface(self): + config = dict() + config.update(self.default_vector_field_config["vector_config"]) + vectors_on_surface = VGroup(*[ + self.vector_field.get_vector(point,**config) + for point in self.surface_points + ]) + + return vectors_on_surface + + + def get_surface(self, func, **kwargs): + axes=self.axes + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + 2*(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 + ) + + + +#------------------------------------------------------- + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + self.axes=axes + + 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), + ) + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + 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), + ("-1", axes.a), + ] + tex_vals_y=[ + + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + # label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + 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_Line_Integrals -- cgit From 4699b0b1a773db4376711c7d67e3d82a90d03f28 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 9 Jun 2020 12:50:17 +0530 Subject: update --- .../fundamental-theorem-of-line-integral/README.md | 4 +- .../file1_grad_of_scalar_function.py | 308 +++++++++++++++++++++ 2 files changed, 310 insertions(+), 2 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md index 6fcbe68..edd176f 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md @@ -1,5 +1,5 @@ **file1_grad_of_scalar_function** ![file1_grad_of_scalar_function](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif) -** -![](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/ .gif) +**file2_line_int_example** +![file2_line_int_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif) diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py new file mode 100644 index 0000000..c9f479c --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.py @@ -0,0 +1,308 @@ +from manimlib.imports import * + +class GradOfScalar(ThreeDScene): + + CONFIG = { + "axes_config": { + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "z_min": 0, + "z_max": 3, + "a":-3 ,"b": 3, "c":-3 , "d":3, + "axes_shift": ORIGIN+IN, + "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_vector_field_config": { + "delta_x": 1, + "delta_y": 1, + "x_min": -3, + "x_max": 3, + "y_min": -3, + "y_max": 3, + "min_magnitude": 0, + "max_magnitude": 2, + "colors": [TEAL,GREEN,GREEN,GREEN,YELLOW,RED], + "length_func": lambda norm : norm*np.exp(-.38*norm)/2, + "opacity": 1.0, + "vector_config": { + "stroke_width":8 + }, + }, + "default_surface_config": { + "fill_opacity": 0.5, + "checkerboard_colors": [BLUE_E], + "stroke_width": .5, + "stroke_color": WHITE, + "stroke_opacity": 0.75, + }, + } + + + def construct(self): + + self.setup_axes() + axes=self.axes + + self.set_camera_orientation(distance=35, + phi=70 * DEGREES, + theta=-135 * DEGREES, + ) + + scalar_fn_text=TexMobject("f(x,y,z)=","xy").set_color(BLUE) + scalar_fn_text.to_corner(UR,buff=.6) + + operator=TexMobject("\\vec\\nabla").next_to( + scalar_fn_text,LEFT,buff=.2 + ).set_color(GOLD) + grad_text=TexMobject(r"\dfrac{\partial f}{\partial x} \hat i+\dfrac{\partial f}{\partial y} \hat j+\dfrac{\partial f}{\partial z} \hat k").set_color(GOLD) + grad_text.next_to(scalar_fn_text,DOWN).scale(.9) + + VGroup(grad_text[0][1],grad_text[0][9],grad_text[0][17]).set_color(BLUE) + VGroup(grad_text[0][5:8],grad_text[0][13:16],grad_text[0][21:23]).set_color(WHITE) + + vector_field_text=TexMobject("\\vec F=y\hat i+x\hat j").set_color_by_gradient(*self.default_vector_field_config["colors"]) + vector_field_text.next_to(scalar_fn_text,DOWN) + + + #always generate the scalar field first + s_field1=self.get_scalar_field( + func= lambda u ,v : u*v/7 + ) + v_field1=self.get_vector_field( + lambda v: np.array([ + v[1], + v[0], + 0, + ]), + on_surface=True, + ) + + self.add_fixed_in_frame_mobjects(scalar_fn_text) + + self.begin_ambient_camera_rotation(rate=.2) + self.play(Write(s_field1)) + self.wait(1) + self.stop_ambient_camera_rotation() + + self.add_fixed_in_frame_mobjects(operator) + self.play(Write(operator),FadeOut(scalar_fn_text[1])) + self.add_fixed_in_frame_mobjects(grad_text) + self.play(Write(grad_text)) + self.wait(2) + + self.play(FadeOut(grad_text)) + self.add_fixed_in_frame_mobjects(vector_field_text) + show_vec_field=[ + FadeIn(v_field1), + Write(vector_field_text), + ] + + self.begin_ambient_camera_rotation(rate=.2) + self.move_camera( + # distance=20, + phi=60 * DEGREES, + added_anims=show_vec_field, + run_time=4.5 + ) + + self.wait(2) + self.stop_ambient_camera_rotation() + + fadeout= [FadeOut(s_field1)] + self.move_camera( + # distance=20, + phi=0 * DEGREES, + theta=-90 * DEGREES, + added_anims=fadeout, + run_time=2 + ) + self.wait(2) + + + + + + def get_scalar_field(self,func,**kwargs): + surface= self.get_surface( + lambda x , y: + func(x,y), + ) + + self.surface_points=self.get_points(func) + return surface + + def get_points(self,func): + axes=self.axes + dn=.5 + x_vals=np.arange(axes.a,axes.b,dn) + y_vals=np.arange(axes.c,axes.d,dn) + points=[] + for x_val in x_vals: + for y_val in y_vals: + points+=[axes.c2p(x_val,y_val,func(x_val,y_val)+.05)] + return points + + def get_vector_field(self,func,on_surface=True,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + self.vector_field=vector_field + + if on_surface: + vector_field=self.get_vectors_on_surface() + + return vector_field + + + + def get_vectors_on_surface(self): + config = dict() + config.update(self.default_vector_field_config["vector_config"]) + vectors_on_surface = VGroup(*[ + self.vector_field.get_vector(point,**config) + for point in self.surface_points + ]) + + return vectors_on_surface + + + def get_surface(self, func, **kwargs): + axes=self.axes + config = { + "u_min": axes.a, + "u_max": axes.b, + "v_min": axes.c, + "v_max": axes.d, + "resolution": ( + 2*(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 + ) + + + +#------------------------------------------------------- + #customize 3D axes + def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): + config = dict(self.axes_config) + config.update(kwargs) + axes = ThreeDAxes(**config) + axes.set_stroke(width=2) + self.axes=axes + + 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), + ) + + return axes + + + def setup_axes(self): + axes = self.get_three_d_axes(include_labels=True) + 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), + ("-1", axes.a), + ] + tex_vals_y=[ + + ("1", axes.d) + ] + x_labels = VGroup() + y_labels = VGroup() + for tex, val in tex_vals_x: + label = TexMobject(tex) + label.scale(1) + label.next_to(x_axis.n2p(val), DOWN) + # label.rotate(180 * DEGREES) + x_labels.add(label) + x_axis.add(x_labels) + x_axis.numbers = x_labels + + for tex, val in tex_vals_y: + label = TexMobject(tex) + label.scale(1) + label.next_to(y_axis.n2p(val), LEFT) + label.rotate(90 * DEGREES) + y_labels.add(label) + + y_axis.add(y_labels) + y_axis.numbers = y_labels + + return axes + + def add_axes_labels(self, axes): + x_label = TexMobject("x") + x_label.next_to(axes.x_axis.get_end(), RIGHT) + axes.x_axis.label = x_label + + y_label = TextMobject("y") + y_label.rotate(90 * DEGREES, OUT) + y_label.next_to(axes.y_axis.get_end(), UP) + axes.y_axis.label = y_label + + z_label = TextMobject("z") + z_label.rotate(90 * DEGREES, RIGHT) + 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_Fundamental_Theorem_of_Line_Integrals + + + + -- cgit From 9928ee6cdbc0d12c3ebef22bdd509c199e5b7949 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 9 Jun 2020 12:53:32 +0530 Subject: new file --- .../file2_line_int_example.gif | Bin 0 -> 1385308 bytes .../file2_line_int_example.py | 159 +++++++++++ .../grad_of_scalar_function.py | 304 --------------------- 3 files changed, 159 insertions(+), 304 deletions(-) create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif new file mode 100644 index 0000000..20ed081 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py new file mode 100644 index 0000000..6dabe49 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py @@ -0,0 +1,159 @@ +from manimlib.imports import * + + +class LineIntegration(GraphScene): + CONFIG = { + "x_min" : -1, + "x_max" : 2, + "y_min" : -1, + "y_max" : 2, + "graph_origin": ORIGIN+3*LEFT+1.5*DOWN, + "x_axis_width": 10, + "y_axis_height": 10 , + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "min_magnitude": 0, + "max_magnitude": .5, + "colors": [GREEN,BLUE,BLUE,TEAL], + "length_func": lambda norm : .4*sigmoid(norm), + "opacity": .75, + "vector_config": { + "stroke_width":2 + }, + }, + + "a": .45,"b": 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) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + + + vector_field=self.get_vector_field( + lambda v: np.array([ + v[1]-self.graph_origin[1], + v[0]-self.graph_origin[0], + 0, + ]) + ) + vector_field_text=TexMobject( + "\\vec F=y\hat i+x\hat j", + stroke_width=2 + ).to_corner(UR,buff=.75).scale(1.2) + + vector_field_text[0][0:3].set_color(TEAL), + self.add(vector_field,) + self.play(Write(vector_field_text)) + self.wait() + self.get_endpoints_of_curve() + self.wait(.6) + self.play( + vector_field_text.shift,5*LEFT, + + ) + vector_field.set_fill(opacity=.2) + self.show_line_integral() + self.wait(2) + + + + + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + self.vector_field= vector_field + + return vector_field + + + + def get_points(self): + dn=.1 + x_vals=np.arange(self.a,self.b,dn) + y_vals=np.arange(self.a,self.b,dn) + points=[] + for x_val in x_vals: + for y_val in y_vals: + points+=[self.coords_to_point(x_val,y_val)] + return points + + def get_endpoints_of_curve(self): + dots=[[1,1],[0,0]] + dot_labels= ["(1,1)","(0,0)"] + for dot,label in zip(dots,dot_labels): + dot=Dot(self.coords_to_point(*dot)).set_color(RED) + dot_label=TexMobject(label) + dot_label.next_to(dot,DR) + self.add(dot,dot_label) + self.end_points=dots + + def show_line_integral(self): + int_text=TexMobject( + "\\int_\\text{\\textbf{path}}\\vec F \\cdot d\\vec r= 1", + color=BLUE, + stroke_width=1.5 + ).scale(1.2) + int_text[0][0].set_color(RED_C) + int_text[0][5:7].set_color(TEAL) + int_text.to_edge(RIGHT+UP,buff=1) + + close_int=TexMobject("O").set_color(RED).scale(1.3) + close_int.move_to(int_text[0][0],OUT) + close_int_val=TexMobject("0",color=BLUE).scale(1.4) + close_int_val.move_to(int_text[0][-1],OUT) + + self.play(Write(int_text)) + + + self.show_method([[0,1]]) + self.play(Indicate(int_text)) + self.wait() + + self.show_method([[1,0]]) + self.play(Indicate(int_text)) + self.wait() + self.remove(int_text[0][-1]) + self.add(close_int) + + for i in range(2): + self.play(self.paths[i].rotate,PI) + self.play(Indicate(close_int)) + self.play(Write(close_int_val)) + self.wait() + + + def show_method(self,points): + points=points+self.end_points + paths=[] + for i in range(-1,len(points)-2): + path=Arrow( + self.coords_to_point(*points[i]), + self.coords_to_point(*points[i+1]), + buff=0 + ).set_color(BLUE) + paths+=VGroup(path) + self.play(GrowArrow(path),run_time=1.5) + + self.paths=paths + + + + + +#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py deleted file mode 100644 index 3a2c3f7..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/grad_of_scalar_function.py +++ /dev/null @@ -1,304 +0,0 @@ -from manimlib.imports import * - -class GradOfScalar(ThreeDScene): - - CONFIG = { - "axes_config": { - "x_min": -3, - "x_max": 3, - "y_min": -3, - "y_max": 3, - "z_min": 0, - "z_max": 3, - "a":-3 ,"b": 3, "c":-3 , "d":3, - "axes_shift": ORIGIN+IN, - "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_vector_field_config": { - "delta_x": 1, - "delta_y": 1, - "x_min": -3, - "x_max": 3, - "y_min": -3, - "y_max": 3, - "min_magnitude": 0, - "max_magnitude": 2, - "colors": [TEAL,GREEN,GREEN,GREEN,YELLOW,RED], - "length_func": lambda norm : norm*np.exp(-.38*norm)/2, - "opacity": 1.0, - "vector_config": { - "stroke_width":8 - }, - }, - "default_surface_config": { - "fill_opacity": 0.5, - "checkerboard_colors": [BLUE_E], - "stroke_width": .5, - "stroke_color": WHITE, - "stroke_opacity": 0.75, - }, - } - - - def construct(self): - - self.setup_axes() - axes=self.axes - - self.set_camera_orientation(distance=35, - phi=70 * DEGREES, - theta=-135 * DEGREES, - ) - - scalar_fn_text=TexMobject("f(x,y,z)=","xy").set_color(BLUE) - scalar_fn_text.to_corner(UR,buff=.6) - - operator=TexMobject("\\vec\\nabla").next_to( - scalar_fn_text,LEFT,buff=.2 - ).set_color(GOLD) - grad_text=TexMobject(r"\dfrac{\partial f}{\partial x} \hat i+\dfrac{\partial f}{\partial y} \hat j+\dfrac{\partial f}{\partial z} \hat k").set_color(GOLD) - grad_text.next_to(scalar_fn_text,DOWN).scale(.9) - - VGroup(grad_text[0][1],grad_text[0][9],grad_text[0][17]).set_color(BLUE) - VGroup(grad_text[0][5:8],grad_text[0][13:16],grad_text[0][21:23]).set_color(WHITE) - - vector_field_text=TexMobject("\\vec F=y\hat i+x\hat j").set_color_by_gradient(*self.default_vector_field_config["colors"]) - vector_field_text.next_to(scalar_fn_text,DOWN) - - - #always generate the scalar field first - s_field1=self.get_scalar_field( - func= lambda u ,v : u*v/7 - ) - v_field1=self.get_vector_field( - lambda v: np.array([ - v[1], - v[0], - 0, - ]), - on_surface=True, - ) - - self.add_fixed_in_frame_mobjects(scalar_fn_text) - - self.begin_ambient_camera_rotation(rate=.2) - self.play(Write(s_field1)) - self.wait(1) - self.stop_ambient_camera_rotation() - - self.add_fixed_in_frame_mobjects(operator) - self.play(Write(operator),FadeOut(scalar_fn_text[1])) - self.add_fixed_in_frame_mobjects(grad_text) - self.play(Write(grad_text)) - self.wait(2) - - self.play(FadeOut(grad_text)) - self.add_fixed_in_frame_mobjects(vector_field_text) - show_vec_field=[ - FadeIn(v_field1), - Write(vector_field_text), - ] - - self.begin_ambient_camera_rotation(rate=.2) - self.move_camera( - # distance=20, - phi=60 * DEGREES, - added_anims=show_vec_field, - run_time=4.5 - ) - - self.wait(2) - self.stop_ambient_camera_rotation() - - fadeout= [FadeOut(s_field1)] - self.move_camera( - # distance=20, - phi=0 * DEGREES, - theta=-90 * DEGREES, - added_anims=fadeout, - run_time=2 - ) - self.wait(2) - - - - - - def get_scalar_field(self,func,**kwargs): - surface= self.get_surface( - lambda x , y: - func(x,y), - ) - - self.surface_points=self.get_points(func) - return surface - - def get_points(self,func): - axes=self.axes - dn=.5 - x_vals=np.arange(axes.a,axes.b,dn) - y_vals=np.arange(axes.c,axes.d,dn) - points=[] - for x_val in x_vals: - for y_val in y_vals: - points+=[axes.c2p(x_val,y_val,func(x_val,y_val)+.05)] - return points - - def get_vector_field(self,func,on_surface=True,**kwargs): - config = dict() - config.update(self.default_vector_field_config) - config.update(kwargs) - vector_field= VectorField(func,**config) - self.vector_field=vector_field - - if on_surface: - vector_field1=self.get_vectors_on_surface() - - return vector_field1 - - - - def get_vectors_on_surface(self): - config = dict() - config.update(self.default_vector_field_config["vector_config"]) - vectors_on_surface = VGroup(*[ - self.vector_field.get_vector(point,**config) - for point in self.surface_points - ]) - - return vectors_on_surface - - - def get_surface(self, func, **kwargs): - axes=self.axes - config = { - "u_min": axes.a, - "u_max": axes.b, - "v_min": axes.c, - "v_max": axes.d, - "resolution": ( - 2*(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 - ) - - - -#------------------------------------------------------- - #customize 3D axes - def get_three_d_axes(self, include_labels=True, include_numbers=False, **kwargs): - config = dict(self.axes_config) - config.update(kwargs) - axes = ThreeDAxes(**config) - axes.set_stroke(width=2) - self.axes=axes - - 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), - ) - - return axes - - - def setup_axes(self): - axes = self.get_three_d_axes(include_labels=True) - 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), - ("-1", axes.a), - ] - tex_vals_y=[ - - ("1", axes.d) - ] - x_labels = VGroup() - y_labels = VGroup() - for tex, val in tex_vals_x: - label = TexMobject(tex) - label.scale(1) - label.next_to(x_axis.n2p(val), DOWN) - # label.rotate(180 * DEGREES) - x_labels.add(label) - x_axis.add(x_labels) - x_axis.numbers = x_labels - - for tex, val in tex_vals_y: - label = TexMobject(tex) - label.scale(1) - label.next_to(y_axis.n2p(val), LEFT) - label.rotate(90 * DEGREES) - y_labels.add(label) - - y_axis.add(y_labels) - y_axis.numbers = y_labels - - return axes - - def add_axes_labels(self, axes): - x_label = TexMobject("x") - x_label.next_to(axes.x_axis.get_end(), RIGHT) - axes.x_axis.label = x_label - - y_label = TextMobject("y") - y_label.rotate(90 * DEGREES, OUT) - y_label.next_to(axes.y_axis.get_end(), UP) - axes.y_axis.label = y_label - - z_label = TextMobject("z") - z_label.rotate(90 * DEGREES, RIGHT) - 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_Line_Integrals -- cgit From 976d88d42dbb1bb80c2ff68f683f011b84d86503 Mon Sep 17 00:00:00 2001 From: Somnath Pandit Date: Tue, 9 Jun 2020 17:12:12 +0530 Subject: new file and rename --- .../fundamental-theorem-of-line-integral/README.md | 8 +- .../file2_line_int_example.gif | Bin 1385308 -> 0 bytes .../file2_line_int_example.py | 159 ------------------- .../file2_line_int_independent_of_path.gif | Bin 0 -> 1403902 bytes .../file2_line_int_independent_of_path.py | 174 +++++++++++++++++++++ .../file3_line_int_example.gif | Bin 0 -> 1385308 bytes .../file3_line_int_example.py | 149 ++++++++++++++++++ 7 files changed, 329 insertions(+), 161 deletions(-) delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif delete mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif create mode 100644 FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md index edd176f..aa8c7f8 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/README.md @@ -1,5 +1,9 @@ **file1_grad_of_scalar_function** ![file1_grad_of_scalar_function](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file1_grad_of_scalar_function.gif) -**file2_line_int_example** -![file2_line_int_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif) +**file2_line_int_independent_of_path** +![file2_line_int_independent_of_path](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif) + +**file3_line_int_example** +![file3_line_int_example](https://github.com/panditsomnath10016git/FSF-mathematics-python-code-archive/blob/master/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif) + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif deleted file mode 100644 index 20ed081..0000000 Binary files a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.gif and /dev/null differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py deleted file mode 100644 index 6dabe49..0000000 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_example.py +++ /dev/null @@ -1,159 +0,0 @@ -from manimlib.imports import * - - -class LineIntegration(GraphScene): - CONFIG = { - "x_min" : -1, - "x_max" : 2, - "y_min" : -1, - "y_max" : 2, - "graph_origin": ORIGIN+3*LEFT+1.5*DOWN, - "x_axis_width": 10, - "y_axis_height": 10 , - "x_tick_frequency": 1, - "y_tick_frequency": 1, - "default_vector_field_config": { - "delta_x": .5, - "delta_y": .5, - "min_magnitude": 0, - "max_magnitude": .5, - "colors": [GREEN,BLUE,BLUE,TEAL], - "length_func": lambda norm : .4*sigmoid(norm), - "opacity": .75, - "vector_config": { - "stroke_width":2 - }, - }, - - "a": .45,"b": 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) - self.X=X ;self.Y=Y - - self.setup_axes(animate=False) - - - - - vector_field=self.get_vector_field( - lambda v: np.array([ - v[1]-self.graph_origin[1], - v[0]-self.graph_origin[0], - 0, - ]) - ) - vector_field_text=TexMobject( - "\\vec F=y\hat i+x\hat j", - stroke_width=2 - ).to_corner(UR,buff=.75).scale(1.2) - - vector_field_text[0][0:3].set_color(TEAL), - self.add(vector_field,) - self.play(Write(vector_field_text)) - self.wait() - self.get_endpoints_of_curve() - self.wait(.6) - self.play( - vector_field_text.shift,5*LEFT, - - ) - vector_field.set_fill(opacity=.2) - self.show_line_integral() - self.wait(2) - - - - - - def get_vector_field(self,func,**kwargs): - config = dict() - config.update(self.default_vector_field_config) - config.update(kwargs) - vector_field= VectorField(func,**config) - - self.vector_field= vector_field - - return vector_field - - - - def get_points(self): - dn=.1 - x_vals=np.arange(self.a,self.b,dn) - y_vals=np.arange(self.a,self.b,dn) - points=[] - for x_val in x_vals: - for y_val in y_vals: - points+=[self.coords_to_point(x_val,y_val)] - return points - - def get_endpoints_of_curve(self): - dots=[[1,1],[0,0]] - dot_labels= ["(1,1)","(0,0)"] - for dot,label in zip(dots,dot_labels): - dot=Dot(self.coords_to_point(*dot)).set_color(RED) - dot_label=TexMobject(label) - dot_label.next_to(dot,DR) - self.add(dot,dot_label) - self.end_points=dots - - def show_line_integral(self): - int_text=TexMobject( - "\\int_\\text{\\textbf{path}}\\vec F \\cdot d\\vec r= 1", - color=BLUE, - stroke_width=1.5 - ).scale(1.2) - int_text[0][0].set_color(RED_C) - int_text[0][5:7].set_color(TEAL) - int_text.to_edge(RIGHT+UP,buff=1) - - close_int=TexMobject("O").set_color(RED).scale(1.3) - close_int.move_to(int_text[0][0],OUT) - close_int_val=TexMobject("0",color=BLUE).scale(1.4) - close_int_val.move_to(int_text[0][-1],OUT) - - self.play(Write(int_text)) - - - self.show_method([[0,1]]) - self.play(Indicate(int_text)) - self.wait() - - self.show_method([[1,0]]) - self.play(Indicate(int_text)) - self.wait() - self.remove(int_text[0][-1]) - self.add(close_int) - - for i in range(2): - self.play(self.paths[i].rotate,PI) - self.play(Indicate(close_int)) - self.play(Write(close_int_val)) - self.wait() - - - def show_method(self,points): - points=points+self.end_points - paths=[] - for i in range(-1,len(points)-2): - path=Arrow( - self.coords_to_point(*points[i]), - self.coords_to_point(*points[i+1]), - buff=0 - ).set_color(BLUE) - paths+=VGroup(path) - self.play(GrowArrow(path),run_time=1.5) - - self.paths=paths - - - - - -#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals - - - diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif new file mode 100644 index 0000000..29c6d02 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py new file mode 100644 index 0000000..b9597b6 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file2_line_int_independent_of_path.py @@ -0,0 +1,174 @@ +from manimlib.imports import * + + +class LineIntegration(GraphScene): + CONFIG = { + "x_min" : -5, + "x_max" : 5, + "y_min" : -5, + "y_max" : 5, + "axes_color":BLACK, + "graph_origin": ORIGIN+1.2*DOWN, + "x_axis_width": 10, + "y_axis_height": 10 , + "x_axis_label": "", + "y_axis_label": "", + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .6, + "delta_y": .6, + "min_magnitude": 0, + "max_magnitude": .5, + "colors": [GREEN,BLUE,BLUE,TEAL], + "length_func": lambda norm : .45*sigmoid(norm), + "opacity": .75, + "vector_config": { + "stroke_width":1.5 + }, + }, + + "a": .45,"b": 2, + "path_color": PURPLE + } + + 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.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + + + vector_field=self.get_vector_field( + lambda v: np.array([ + v[1]-self.graph_origin[1], + v[0]-self.graph_origin[0], + 0, + ]) + ) + vector_field_text=TexMobject( + "\\vec F(x,y)","=y\hat i+x\hat j", + stroke_width=1.5 + ).to_edge(TOP,buff=.2) + + vector_field_text[0][0:2].set_color(TEAL) + + grad_f=TexMobject( + "\\vec\\nabla f(x,y)", + stroke_width=1.5 + ) + grad_f[0][2].set_color(LIGHT_BROWN) + grad_f.move_to(vector_field_text[0]) + + self.add(vector_field,) + self.play(Write(vector_field_text)) + self.wait() + self.play( + ReplacementTransform( + vector_field_text[0],grad_f + ) + ) + self.get_endpoints_of_curve() + self.wait(.6) + vector_field.set_fill(opacity=.4) + self.show_line_integral() + self.wait(2) + + + + + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + self.vector_field= vector_field + + return vector_field + + + + def get_endpoints_of_curve(self): + points=[[-3,0],[2,2]] + point_labels= ["P_i","P_f"] + for point,label in zip(points,point_labels): + dot=Dot(self.coords_to_point(*point)).set_color(RED) + dot_label=TexMobject(label) + dot_label.next_to(dot,DR,buff=.2) + self.play(FadeIn(VGroup(dot,dot_label))) + self.wait(.2) + + self.end_points=points + + def show_line_integral(self): + int_text=TexMobject( + r"\int_{P_i}^{P_f}\vec F \cdot d\vec r", + stroke_width=1.5, + ).scale(1.2) + int_text[0][0].set_color(self.path_color) + int_text[0][5:7].set_color(TEAL) + int_text.to_edge(RIGHT+UP,buff=1) + + int_value= TexMobject(r"=f(P_i)-f(P_f)", + stroke_width=1.5 + ).next_to(int_text,DOWN) + VGroup(int_value[0][1], + int_value[0][7] + ).set_color(LIGHT_BROWN) + + path_indepent_text=TextMobject( + r"Value of the Line Integral is\\ independent of Path",color=GOLD,stroke_width=2,).to_corner(DR,buff=1) + + path_indepent_text[0][-4:].set_color(self.path_color) + + + self.play(Write(VGroup( + int_text,int_value + )), + run_time=2 + ) + self.wait(1.5) + + + self.show_path([[0,1],[-1,2],[1,3]]) + self.play(Indicate(int_value)) + self.play(Uncreate(self.path)) + + self.show_path([[0,1]]) + self.play(Indicate(int_value)) + self.play(Uncreate(self.path)) + + self.show_path([[-1,1],[-1,-2],[-5,0],[-2,3.5],[1,1]]) + self.play(Indicate(int_value),run_time=2) + self.wait(.6) + + self.play(Write(path_indepent_text)) + + + + def show_path(self,points): + points=[self.end_points[0]]+points+[self.end_points[1]] + + path= VMobject() + path.set_points_smoothly([ + self.coords_to_point(*point) + for point in points + ]) + path.set_color(self.path_color) + self.play(ShowCreation(path),run_time=1.5) + + self.path=path + + + + + +#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif new file mode 100644 index 0000000..20ed081 Binary files /dev/null and b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.gif differ diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py new file mode 100644 index 0000000..71506a3 --- /dev/null +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fundamental-theorem-of-line-integral/file3_line_int_example.py @@ -0,0 +1,149 @@ +from manimlib.imports import * + + +class LineIntegration(GraphScene): + CONFIG = { + "x_min" : -1, + "x_max" : 2, + "y_min" : -1, + "y_max" : 2, + "graph_origin": ORIGIN+3*LEFT+1.5*DOWN, + "x_axis_width": 10, + "y_axis_height": 10 , + "x_tick_frequency": 1, + "y_tick_frequency": 1, + "default_vector_field_config": { + "delta_x": .5, + "delta_y": .5, + "min_magnitude": 0, + "max_magnitude": .5, + "colors": [GREEN,BLUE,BLUE,TEAL], + "length_func": lambda norm : .4*sigmoid(norm), + "opacity": .75, + "vector_config": { + "stroke_width":2 + }, + }, + + "a": .45,"b": 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) + self.X=X ;self.Y=Y + + self.setup_axes(animate=False) + + + + + vector_field=self.get_vector_field( + lambda v: np.array([ + v[1]-self.graph_origin[1], + v[0]-self.graph_origin[0], + 0, + ]) + ) + vector_field_text=TexMobject( + "\\vec F=y\hat i+x\hat j", + stroke_width=2 + ).to_corner(UR,buff=.75).scale(1.2) + + vector_field_text[0][0:3].set_color(TEAL), + self.add(vector_field,) + self.play(Write(vector_field_text)) + self.wait() + self.get_endpoints_of_curve() + self.wait(.6) + self.play( + vector_field_text.shift,5*LEFT, + + ) + vector_field.set_fill(opacity=.2) + self.show_line_integral() + self.wait(2) + + + + + + def get_vector_field(self,func,**kwargs): + config = dict() + config.update(self.default_vector_field_config) + config.update(kwargs) + vector_field= VectorField(func,**config) + + self.vector_field= vector_field + + return vector_field + + + + def get_endpoints_of_curve(self): + points=[[1,1],[0,0]] + point_labels= ["(1,1)","(0,0)"] + for point,label in zip(points,point_labels): + dot=Dot(self.coords_to_point(*point)).set_color(RED) + dot_label=TexMobject(label) + dot_label.next_to(dot,DR) + self.add(dot,dot_label) + self.end_points=points + + def show_line_integral(self): + int_text=TexMobject( + "\\int_\\text{\\textbf{path}}\\vec F \\cdot d\\vec r= 1", + color=BLUE, + stroke_width=1.5 + ).scale(1.2) + int_text[0][0].set_color(RED_C) + int_text[0][5:7].set_color(TEAL) + int_text.to_edge(RIGHT+UP,buff=1) + + close_int=TexMobject("O").set_color(RED).scale(1.3) + close_int.move_to(int_text[0][0],OUT) + close_int_val=TexMobject("0",color=BLUE).scale(1.4) + close_int_val.move_to(int_text[0][-1],OUT) + + self.play(Write(int_text)) + + + self.show_method([[0,1]]) + self.play(Indicate(int_text)) + self.wait() + + self.show_method([[1,0]]) + self.play(Indicate(int_text)) + self.wait() + self.remove(int_text[0][-1]) + self.add(close_int) + + for i in range(2): + self.play(self.paths[i].rotate,PI) + self.play(Indicate(close_int)) + self.play(Write(close_int_val)) + self.wait() + + + def show_method(self,points): + points=points+self.end_points + paths=[] + for i in range(-1,len(points)-2): + path=Arrow( + self.coords_to_point(*points[i]), + self.coords_to_point(*points[i+1]), + buff=0 + ).set_color(BLUE) + paths+=VGroup(path) + self.play(GrowArrow(path),run_time=1.5) + + self.paths=paths + + + + + +#uploaded by Somnath Pandit. FSF2020_Fundamental_Theorem_of_Line_Integrals + + + -- 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 --- .../integrals-of-multivariable-functions/README.md | 4 + .../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 +++++++-- 5 files changed, 136 insertions(+), 71 deletions(-) (limited to 'FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions') diff --git a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md index 221e78d..4de6c1d 100644 --- a/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md +++ b/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/README.md @@ -7,3 +7,7 @@ FSF2020--Somnath Pandit ## Fubini's Theorem ## Line Integrals + +## Fundamental Theorem of Line integrals + +## Vector Fields 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') 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') 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