summaryrefslogtreecommitdiff
path: root/FSF-2020/calculus-of-several-variables/multivariable-functions-and-paritial-derivatives/partial-derivatives/file6_clariant_rule.py
blob: b79f77c0a6e64f3bcdbdb2f70a0310914042c4e3 (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
from manimlib.imports import *

class ClariantRule(Scene):
    def construct(self):
        derivatives = TextMobject(r"$cos(x)y^3$",r"$-sin(x)y^3$", r"$3cos(x)y^2$", r"$-cos(x)y^3$", r"$-3sin(x)y^2$", r"$-3sin(x)y^2$", r"$6cos(x)y$")

        partial_derivatives = TextMobject(r"$\frac{\partial}{\partial x}$", r"$\frac{\partial}{\partial y}$")

        
        derivatives[0].move_to(2*UP).set_color(PURPLE)
        derivatives[1].move_to(3*LEFT).set_color(YELLOW_C)
        derivatives[2].move_to(3*RIGHT).set_color(BLUE_C)
        
        arrrow_1 = Arrow(derivatives[0].get_bottom(), derivatives[1].get_top())
        arrrow_1_lab = partial_derivatives[0].copy().scale(0.7)  
        arrrow_1_lab.move_to(2.5*LEFT+ 1.3*UP)

        arrrow_2 = Arrow(derivatives[0].get_bottom(), derivatives[2].get_top())
        arrrow_2_lab = partial_derivatives[1].copy().scale(0.7)  
        arrrow_2_lab.move_to(2.5*RIGHT+ 1.3*UP)

        self.play(Write(derivatives[0]))
        self.play(GrowArrow(arrrow_1), GrowArrow(arrrow_2), Write(arrrow_1_lab), Write(arrrow_2_lab))

        self.play(Write(derivatives[1]))
        self.play(Write(derivatives[2]))

        derivatives[3].move_to(2*DOWN + 4.5*LEFT).set_color(GREEN_C)
        derivatives[4].move_to(2*DOWN + 1.5*LEFT).set_color(PINK)
        derivatives[5].move_to(2*DOWN + 1.5*RIGHT).set_color(PINK)
        derivatives[6].move_to(2*DOWN + 4.5*RIGHT).set_color(ORANGE)

        arrrow_3 = Arrow(derivatives[1].get_bottom(), derivatives[3].get_top())
        arrrow_3_lab = partial_derivatives[0].copy().scale(0.7) 
        arrrow_3_lab.move_to(4.3*LEFT+ 0.8*DOWN)

        arrrow_4 = Arrow(derivatives[1].get_bottom(), derivatives[4].get_top())
        arrrow_4_lab = partial_derivatives[1].copy().scale(0.7)  
        arrrow_4_lab.move_to(1.6*LEFT+ 0.8*DOWN)

        arrrow_5 = Arrow(derivatives[2].get_bottom(), derivatives[5].get_top())
        arrrow_5_lab = partial_derivatives[0].copy().scale(0.7)  
        arrrow_5_lab.move_to(1.6*RIGHT+ 0.8*DOWN)

        arrrow_6 = Arrow(derivatives[2].get_bottom(), derivatives[6].get_top())
        arrrow_6_lab = partial_derivatives[1].copy().scale(0.7)  
        arrrow_6_lab.move_to(4.3*RIGHT+ 0.8*DOWN)

        self.play(GrowArrow(arrrow_3), GrowArrow(arrrow_4), Write(arrrow_3_lab), Write(arrrow_4_lab))
        self.play(Write(derivatives[3]), Write(derivatives[4]))

        self.play(GrowArrow(arrrow_5), GrowArrow(arrrow_6), Write(arrrow_5_lab), Write(arrrow_6_lab))
        self.play(Write(derivatives[5]), Write(derivatives[6]))
        
        brace1 = Brace(derivatives[4:6], DOWN, buff = SMALL_BUFF, color = RED_C)
        brace_t1 = brace1.get_text("Mixed partial derivatives are the same!")
        brace_t1.set_color(RED_C)

        self.play(GrowFromCenter(brace1), FadeIn(brace_t1))
        
        self.wait()