summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/integrals-of-multivariable-functions/fubini's-theorem/file4_curvy_region.py
blob: 46134a78628e6c3007e657781007bffa087f06d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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