def test_harmonic(): n = Symbol("n") assert harmonic(n, 0) == n assert harmonic(n, 1) == harmonic(n) assert harmonic(0, 1) == 0 assert harmonic(1, 1) == 1 assert harmonic(2, 1) == Rational(3, 2) assert harmonic(3, 1) == Rational(11, 6) assert harmonic(4, 1) == Rational(25, 12) assert harmonic(0, 2) == 0 assert harmonic(1, 2) == 1 assert harmonic(2, 2) == Rational(5, 4) assert harmonic(3, 2) == Rational(49, 36) assert harmonic(4, 2) == Rational(205, 144) assert harmonic(0, 3) == 0 assert harmonic(1, 3) == 1 assert harmonic(2, 3) == Rational(9, 8) assert harmonic(3, 3) == Rational(251, 216) assert harmonic(4, 3) == Rational(2035, 1728) assert harmonic(oo, -1) == S.NaN assert harmonic(oo, 0) == oo assert harmonic(oo, S.Half) == oo assert harmonic(oo, 1) == oo assert harmonic(oo, 2) == (pi**2)/6 assert harmonic(oo, 3) == zeta(3)
def test_harmonic(): n = Symbol("n") m = Symbol("m") assert harmonic(n, 0) == n assert harmonic(n).evalf() == harmonic(n) assert harmonic(n, 1) == harmonic(n) assert harmonic(1, n).evalf() == harmonic(1, n) assert harmonic(0, 1) == 0 assert harmonic(1, 1) == 1 assert harmonic(2, 1) == Rational(3, 2) assert harmonic(3, 1) == Rational(11, 6) assert harmonic(4, 1) == Rational(25, 12) assert harmonic(0, 2) == 0 assert harmonic(1, 2) == 1 assert harmonic(2, 2) == Rational(5, 4) assert harmonic(3, 2) == Rational(49, 36) assert harmonic(4, 2) == Rational(205, 144) assert harmonic(0, 3) == 0 assert harmonic(1, 3) == 1 assert harmonic(2, 3) == Rational(9, 8) assert harmonic(3, 3) == Rational(251, 216) assert harmonic(4, 3) == Rational(2035, 1728) assert harmonic(oo, -1) == S.NaN assert harmonic(oo, 0) == oo assert harmonic(oo, S.Half) == oo assert harmonic(oo, 1) == oo assert harmonic(oo, 2) == (pi**2) / 6 assert harmonic(oo, 3) == zeta(3) assert harmonic(0, m) == 0
def test_tangent_sequence(): a = tangent_sequence(20) for n, b in enumerate(a): if n == 0: assert b == 1 else: f = (-16)**(n + 1) - (-4)**(n + 1) assert b == f * zeta(-1 - 2 * n)
def test_CXX17CodePrinter(): assert CXX17CodePrinter().doprint(beta(x, y)) == 'std::beta(x, y)' assert CXX17CodePrinter().doprint(Ei(x)) == 'std::expint(x)' assert CXX17CodePrinter().doprint(zeta(x)) == 'std::riemann_zeta(x)' # Automatic rewrite assert CXX17CodePrinter().doprint(frac(x)) == 'x - std::floor(x)' assert CXX17CodePrinter().doprint( riemann_xi(x) ) == '(1.0/2.0)*std::pow(M_PI, -1.0/2.0*x)*x*(x - 1)*std::tgamma((1.0/2.0)*x)*std::riemann_zeta(x)'
def test_harmonic(): n = Symbol("n") m = Symbol("m") assert harmonic(n, 0) == n assert harmonic(n).evalf() == harmonic(n) assert harmonic(n, 1) == harmonic(n) assert harmonic(1, n).evalf() == harmonic(1, n) assert harmonic(0, 1) == 0 assert harmonic(1, 1) == 1 assert harmonic(2, 1) == Rational(3, 2) assert harmonic(3, 1) == Rational(11, 6) assert harmonic(4, 1) == Rational(25, 12) assert harmonic(0, 2) == 0 assert harmonic(1, 2) == 1 assert harmonic(2, 2) == Rational(5, 4) assert harmonic(3, 2) == Rational(49, 36) assert harmonic(4, 2) == Rational(205, 144) assert harmonic(0, 3) == 0 assert harmonic(1, 3) == 1 assert harmonic(2, 3) == Rational(9, 8) assert harmonic(3, 3) == Rational(251, 216) assert harmonic(4, 3) == Rational(2035, 1728) assert harmonic(oo, -1) is S.NaN assert harmonic(oo, 0) is oo assert harmonic(oo, S.Half) is oo assert harmonic(oo, 1) is oo assert harmonic(oo, 2) == (pi**2) / 6 assert harmonic(oo, 3) == zeta(3) assert harmonic(oo, Dummy(negative=True)) is S.NaN ip = Dummy(integer=True, positive=True) if (1 / ip <= 1) is True: #---------------------------------+ assert None, 'delete this if-block and the next line' #| ip = Dummy(even=True, positive=True) #--------------------+ assert harmonic(oo, 1 / ip) is oo assert harmonic(oo, 1 + ip) is zeta(1 + ip) assert harmonic(0, m) == 0
def test_zeta_printing_issue_14820(): assert octave_code(zeta(x)) == 'zeta(x)' assert octave_code(zeta( x, y)) == '% Not supported in Octave:\n% zeta\nzeta(x, y)'
def test_harmonic_limit_fail(): n = Symbol("n") m = Symbol("m") # For m > 1: assert limit(harmonic(n, m), n, oo) == zeta(m)
def test_CXX17CodePrinter(): assert CXX17CodePrinter().doprint(beta(x, y)) == "std::beta(x, y)" assert CXX17CodePrinter().doprint(Ei(x)) == "std::expint(x)" assert CXX17CodePrinter().doprint(zeta(x)) == "std::riemann_zeta(x)"
def test_zeta_printing_issue_14820(): assert octave_code(zeta(x)) == 'zeta(x)' assert octave_code(zeta(x, y)) == '% Not supported in Octave:\n% zeta\nzeta(x, y)'
def test_CXX17CodePrinter(): assert CXX17CodePrinter().doprint(beta(x, y)) == 'std::beta(x, y)' assert CXX17CodePrinter().doprint(Ei(x)) == 'std::expint(x)' assert CXX17CodePrinter().doprint(zeta(x)) == 'std::riemann_zeta(x)'