Cody

# Problem 45997. Evaluate the zeta function for complex arguments

Solution 2632075

Submitted on 30 Jun 2020 by Tim
• Size: 57
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
s = 2; z_correct = pi^2/6; assert(abs(zeta2(s)-z_correct)/z_correct < 1e-8)

2   Pass
s = 1; assert(isinf(zeta2(s)))

3   Pass
s = 1/2; z_correct = -1.460354508809587; assert(abs((zeta2(s)-z_correct)/z_correct) < 1e-8)

4   Pass
s = 0; z_correct = -0.5; assert(abs((zeta2(s)-z_correct)/z_correct) < 1e-8)

5   Pass
s = -1; z_correct = -1/12; assert(abs((zeta2(s)-z_correct)/z_correct) < 1e-8)

6   Pass
s = -2; z_correct = 0; assert(abs(zeta2(s)) < 1e-12)

7   Pass
s = 3+2*i; z_correct = 0.973041960418942 - 0.147695593000454i; assert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) < 1e-8) assert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) < 1e-8)

8   Pass
s = -1+2*i; z_correct = 0.168915669770846 - 0.070515988908259i; assert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) < 1e-8) assert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) < 1e-8)

9   Pass
s = 0.75-3*i; z_correct = 0.580900396083837 + 0.095281202690117i; assert(abs(real(zeta2(s))-real(z_correct))/real(z_correct) < 1e-8) assert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) < 1e-8)

10   Pass
s = 5+2*i; z_correct = 1.001916538615071 - 0.034217062736354i; assert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) < 1e-8) assert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) < 1e-8)

11   Pass
s = 0.5+14.13472514173469379*i; assert(abs(real(zeta2(s))) < 1e-12) assert(abs(imag(zeta2(s))) < 1e-12)

12   Pass
s = 0.5+21*i; z_correct = -0.005162064638102 - 0.024546964575122i; assert(abs((real(zeta2(s))-real(z_correct))/real(z_correct)) < 1e-8) assert(abs((imag(zeta2(s))-imag(z_correct))/imag(z_correct)) < 1e-8)

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!