from manim import *
class S1(Scene):
    def construct(self):
        ques = MathTex("9^x","+","15^x","=","25^x").scale(3)
        self.play(FadeIn(ques),run_time = 2)
        self.wait()
        text1 = Tex("Dividing by $9^x$ on both sides").set_color(TEAL_A).to_edge(DOWN).scale(1)
        ques2 = MathTex("{","9^x" ,"\over"," {9^x}}","+","{","15^x","\over","{9^x}}","=","{","25^x","\over","{9^x}}").scale(3)
        self.play(ShowCreationThenFadeOut(text1))
        self.wait(2)
        self.play(ReplacementTransform(ques,ques2),run_time = 3)
        self.wait(4)
        ques3 = MathTex("1","+","{","15^x","\over","{9^x}}","=","{","25^x","\over","{9^x}}").scale(3)
        self.play(ReplacementTransform(ques2,ques3),run_time = 2)
        self.wait(4)
        ques4 = MathTex("1","+","\left({","15","\over","9}\\right)^x","=","\left({","25","\over","9}\\right)^x").scale(2.5)
        self.play(ReplacementTransform(ques3,ques4),run_time = 2)
        self.wait(4)
        ques5 = MathTex("1","+","\left({","5","\over","3}\\right)^x","=","\left({","5^2","\over","3^2}\\right)^x").scale(3)
        self.play(ReplacementTransform(ques4,ques5),run_time = 2)
        self.wait(4)
        quese = MathTex("1","+","\left({","5","\over","3}\\right)^x","=","\left({","5","\over","3}\\right)^{ 2x }").scale(3)
        self.play(ReplacementTransform(ques5,quese),run_time = 2)
        self.wait(4)
        property1 = MathTex("x^{a \cdot b}={(x^a)}^b ").set_color(GOLD).to_edge(DOWN)
        self.play(Create(property1))
        self.wait(4)
        self.remove(property1)
        self.wait(2)
        ques6 = MathTex("1","+","\left({","5","\over","3}\\right)^x","=","\left({","5","\over","3}\\right)^{ x^2 }").scale(3)
        self.play(ReplacementTransform(quese,ques6),run_time = 2)
        self.wait(4)
        self.play(ques6.animate(run_time = 2).shift(UP*1.85))
        self.wait(2)
        tex1 = Tex("Let t = $\left(5\over3\\right)^x$").set_color(GREEN_B).scale(2.5).next_to(ques6,DOWN,buff=1.5)
        self.play(Create(tex1),run_time = 2.5)
        self.wait(2.5)
        ques7 = MathTex("1","+","\left(t\\right)","=","\left(t\\right)^2").scale(3).move_to(ques6)
        self.play(ReplacementTransform(ques6,ques7),FadeOut(tex1),run_time = 2)
        self.wait(4)
        self.play(ques7.animate(run_time = 2).shift(UP))
        self.wait(2)
        property2 = Tex("Now let us solve this quadratic equation with \n $-b \pm \sqrt{ b^2-4ac } \over 2a$").set_color(RED_A).to_edge(DOWN)
        self.play(Create(property2))
        self.wait(4)
        # self.remove(property2)
        # self.wait(2)
        property3 = Tex("a = 1,b = -1,c = -1").set_color(BLUE_A).next_to(property2,UP)
        self.play(Create(property3))
        self.wait(4)
        # self.remove(property3)
        # self.wait(2)
        ques8 = MathTex("\implies {1 \pm \sqrt{ 1+4 }"," \over 2}").scale(2).set_color(PURPLE_A)
        self.play(Write(ques8),run_time = 2)
        self.wait(5)
        ques9 = Tex("t $\implies {1 \pm \sqrt{ 5 }\over 2}$").scale(2).set_color(PURPLE_A)
        self.play(ReplacementTransform(ques8,ques9),run_time = 2)
        self.wait(5)
        self.play(ques9.animate(run_time=2).shift(LEFT*1.5))
        text3 = Tex(
            """
            We Would take\n
            $+$ sign as $x$ is\n
            a real number so\n
            ${5\over3}^x$ can\n
            not be negative
            """
        )
        self.play(Write(text3.to_edge(RIGHT).set_color(YELLOW_A)),run_time = 2)
        self.wait(3)
        self.play(Indicate(text3))
        self.wait()
class S2(Scene):
    def construct(self):
        tex1 = Tex("t = $1+\sqrt5 \over 2$").to_edge(UL,buff=1).scale(2).shift(RIGHT*1.5)
        golden = Text("This is also known as golden ratio").scale(1).set_color(GOLD_A)
        self.play(FadeIn(tex1),run_time = 2)
        self.wait(2)
        self.play(Indicate(tex1),Write(golden),run_time=3)
        self.wait(3)
        self.remove(golden)
        self.wait()
        text2 = Text(
            """
            But we were not done yet
            we have to substitute the
            value of t to get x.
            """
        ).scale(1.5).set_color(PURPLE_A).shift(DOWN*1.2) 
        self.play(Create(text2))
        self.wait(2)
        self.play(FadeOut(text2))
        self.wait()
        tex2 = MathTex("\left({5\over3}\\right)^x = {1+\sqrt5 \over 2}").scale(2).shift(UP)
        self.play(ReplacementTransform(tex1,tex2),run_time = 3)
        self.wait(4)
        text3 = Tex(
           "Taking natural log $(ln)$ on both sides"
        ).scale(1.5).set_color(BLUE_A).to_edge(DOWN) 
        self.play(Create(text3))
        self.wait(2)
        self.play(FadeOut(text3))
        self.wait()
        tex3 = MathTex("log \left({5\over3}\\right)^x = log\left({1+\sqrt5 \over 2}\\right)").scale(2).shift(UP)
        self.play(ReplacementTransform(tex2,tex3),run_time = 3)
        self.wait(4)
        tex4 = MathTex("x \cdot log \left({5\over3}\\right) = log\left({1+\sqrt5 \over 2}\\right)").scale(2).shift(UP)
        self.play(ReplacementTransform(tex3,tex4),run_time = 2)
        self.wait(4)
        tex5 = MathTex("x  = {log\left({1+\sqrt5 \over 2}\\right)\over log \left({5\over3}\\right)}").scale(2).shift(UP)
        self.play(ReplacementTransform(tex4,tex5),run_time = 3)
        self.wait(4)
        text5 = Text("Answer").set_color_by_gradient(RED,BLUE_A,GREEN).scale(2).to_edge(DOWN)
        self.play(Indicate(tex5),Create(text5),run_time = 5)
        self.wait(2)