Cody

# Problem 45939. Estimate π from certain values of the zeta function

Solution 2877194

Submitted on 25 Aug 2020
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   Fail
n = 30; m = 2; y_correct = '1.00e-02'; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test1 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

2   Fail
n = 30; m = 8; y_correct = '7.22e-13'; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test2 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

3   Fail
n = 1; m = 20; y_correct = '4.77e-08'; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test3 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

4   Fail
n = 5:5:30; m = 2; y_correct = '5.67e-02 2.94e-02 1.98e-02 1.49e-02 1.20e-02 1.00e-02'; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test4 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

5   Fail
n = 10; m = 2:2:10; y_correct = ['2.94e-02'; '6.62e-05'; '2.54e-07'; '1.24e-09'; '6.92e-12']; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test5 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

6   Fail
n = [25 30]; m = [2 8]; y_correct = ['1.20e-02 1.00e-02'; '2.53e-12 7.22e-13']; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test6 (line 4) assert(isequal(PiByZeta(n,m),y_correct))

7   Fail
n = 1:5; m = 2:2:10; y_correct = ['2.20e-01 1.28e-01 9.04e-02 6.97e-02 5.67e-02'; ... '1.96e-02 4.61e-03 1.73e-03 8.26e-04 4.56e-04'; ... '2.86e-03 2.82e-04 5.67e-05 1.67e-05 6.25e-06'; ... '5.09e-04 2.13e-05 2.33e-06 4.27e-07 1.09e-07'; ... '9.94e-05 1.80e-06 1.08e-07 1.24e-08 2.14e-09']; assert(isequal(PiByZeta(n,m),y_correct))

Undefined function 'bernoulli' for input arguments of type 'double'. Error in PiByZeta (line 2) num2str(abs((factorial(m)/abs(bernoulli(m))/pow2(m-1)*sum(1./(1:n).^m)).^(1/m)-pi)/pi,'%10.2e'); Error in Test7 (line 8) assert(isequal(PiByZeta(n,m),y_correct))

### Community Treasure Hunt

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

Start Hunting!