def test_ray_derivative(self): # ray from x=-1 to infinity to the left gamma = ComplexRay(-1) self.assertAlmostEqual(gamma.derivative(0), 1) self.assertAlmostEqual(gamma.derivative(0.5), 4) self.assertAlmostEqual(gamma.derivative(0.75), 16) self.assertAlmostEqual(gamma.derivative(1), Infinity)
def test_equality(self): gamma0 = ComplexLine(-1, 0) gamma1 = ComplexLine(-1, 0) self.assertEqual(gamma0, gamma1) gamma0 = ComplexArc(1, 0, 0, pi) gamma1 = ComplexArc(1, 0, 0, pi) self.assertEqual(gamma0, gamma1) gamma0 = ComplexRay(-1) gamma1 = ComplexRay(-1) self.assertEqual(gamma0, gamma1)
def test_ray(self): # ray from x=-1 to infinity to the left gamma = ComplexRay(-1) self.assertAlmostEqual(gamma(0), -1) self.assertAlmostEqual(gamma(0.5), -2) self.assertAlmostEqual(gamma(0.75), -4) self.assertEqual(gamma(1), Infinity)
def test_rays(self): # test that analytic continuation to places at infinity work gammax = ComplexRay(-9) y0 = [-3.j, 3.j] gamma = RiemannSurfacePathPuiseux(self.X1, gammax, y0) y = gamma.get_y(0) self.assertAlmostEqual(y[0], -3.j) self.assertAlmostEqual(y[1], 3.j) # note: the infinity behavior may change in the future y = gamma.get_y(1) self.assertTrue(numpy.isnan(y[0])) self.assertTrue(numpy.isnan(y[1]))
def _path_to_infinite_place(self, P): r"""Returns a path to a place at an infintiy of the surface. A place at infinity is one where the `x`-projection of the place is the point `x = \infty` of the complex Riemann sphere. An infinite place is a type of discirminant place. Parameters ---------- P : Place The target infinite place. Returns ------- gamma : RiemannSurfacePath A path from the base place to the place at infinity. """ # determine a place Q from where we can reach the target place P. first, # pick an appropriate x-point over which a Q is chosen x0 = self.base_point if numpy.real(x0) < 0: xa = 5 * x0 # move away from the origin else: xa = -5 # arbitrary choice away from the origin # next, determine an appropriate y-part from where we can reach the # place at infinity p = P.puiseux_series center, coefficient, ramification_index = p.xdata ta = CC(xa / coefficient).nth_root(abs(ramification_index)) ta = ta if ramification_index > 0 else 1 / ta p.extend_to_t(ta) ya = complex(p.eval_y(ta)) # construct the place Q and compute the path going from P0 to Q Q = self.riemann_surface(xa, ya) gamma_P0_to_Q = self.path_to_place(Q) # construct the path going from Q to P xend = complex(gamma_P0_to_Q.get_x(1.0)) yend = array(gamma_P0_to_Q.get_y(1.0), dtype=complex) gamma_x = ComplexRay(xend) gamma_Q_to_P = RiemannSurfacePathPuiseux(self.riemann_surface, gamma_x, yend) gamma = gamma_P0_to_Q + gamma_Q_to_P return gamma
def test_ray(self): gamma = ComplexRay(1) self.assertEqual(gamma.x0, 1)