summaryrefslogtreecommitdiff
path: root/FSF-2020/integrals-of-multivariable-functions/y_limit_dependent_on_x.py
blob: 4894ebf193b9bdc7cb805efbc80e0c557eec3c56 (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
103
104
105
106
107
108
109
110
111
112
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