def test_trivial(self):
        G = y - x
        S = newton_iteration(G, 3)
        self.assertEqual(S, x)

        G = y - x**2
        S = newton_iteration(G, 3)
        self.assertEqual(S, x**2)
Beispiel #2
0
    def test_trivial(self):
        G = y - x
        S = newton_iteration(G,3)
        self.assertEqual(S,x)

        G = y - x**2
        S = newton_iteration(G,3)
        self.assertEqual(S,x**2)
    def test_n(self):
        # test if the solution is indeed given to the desired terms
        G = y - x**2
        S = newton_iteration(G, 0)
        self.assertEqual(S, 0)

        G = y - x**2
        S = newton_iteration(G, 3)
        self.assertEqual(S, x**2)
Beispiel #4
0
    def test_n(self):
        # test if the solution is indeed given to the desired terms
        G = y - x**2
        S = newton_iteration(G,0)
        self.assertEqual(S,0)

        G = y - x**2
        S = newton_iteration(G,3)
        self.assertEqual(S,x**2)
    def test_geometric(self):
        G = (1 - x) * y - 1
        S = newton_iteration(G, 9).truncate(x, 10)

        z = var('z')
        series = taylor(1 / (1 - z), z, 0, 9)
        series = R(series.subs({z: x}))
        self.assertEqual(S, series)
Beispiel #6
0
    def test_geometric(self):
        G = (1-x)*y - 1
        S = newton_iteration(G,9).truncate(x,10)

        z = var('z')
        series = taylor(1/(1-z),z,0,9)
        series = R(series.subs({z:x}))
        self.assertEqual(S,series)
    def test_cuberoot(self):
        # recenter cuberoot(x) at x+1
        G = (y + 1)**3 - (x + 1)
        S = newton_iteration(G, 9).truncate(x, 10) + 1

        z = var('z')
        series = taylor(z**(QQ(1) / QQ(3)), z, 1, 9)
        series = R(series.subs({z: x + 1}))
        self.assertEqual(S, series)
    def test_sqrt(self):
        # recenter sqrt(x) at x+1
        G = (y + 1)**2 - (x + 1)
        S = newton_iteration(G, 9).truncate(x, 10) + 1

        z = var('z')
        series = taylor(sqrt(z), z, 1, 9)
        series = R(series.subs({z: x + 1}))
        self.assertEqual(S, series)
Beispiel #9
0
    def test_cuberoot(self):
        # recenter cuberoot(x) at x+1
        G = (y+1)**3 - (x+1)
        S = newton_iteration(G,9).truncate(x,10) + 1

        z = var('z')
        series = taylor(z**(QQ(1)/QQ(3)),z,1,9)
        series = R(series.subs({z:x+1}))
        self.assertEqual(S,series)
Beispiel #10
0
    def test_sqrt(self):
        # recenter sqrt(x) at x+1
        G = (y+1)**2 - (x+1)
        S = newton_iteration(G,9).truncate(x,10) + 1

        z = var('z')
        series = taylor(sqrt(z),z,1,9)
        series = R(series.subs({z:x+1}))
        self.assertEqual(S,series)