Cody

Problem 46066. Evaluate the logarithmic integral

Solution 2916958

Submitted on 6 Sep 2020 by Rafael S.T. Vieira
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
x = 0; y_correct = 0; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

2   Pass
x = 0.2; y_correct = -0.085126486728794; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

3   Pass
x = 0.5; y_correct = -0.378671043061088; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

4   Pass
x = 1; y = logarithmicIntegral(x); assert(isinf(y) && sign(y) == -1)

5   Pass
x = 2; y_correct = 1.045163780117493; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

6   Pass
x = 5; y_correct = 3.634588310032652; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

7   Pass
x = 8; y_correct = 5.253718299558931; assert(abs(logarithmicIntegral(x)-y_correct)<1e-8)

8   Pass
x = 3+2i; y_correct = 2.558790740400258 + 1.594445119241119i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

9   Pass
x = 3-0.2i; y_correct = 2.169086896211800 - 0.181703645882027i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

10   Pass
x = -0.3-2i; y_correct = 0.999726888286245 - 3.238096925989443i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

11   Pass
x = -5-3i; y_correct = 0.500720609942772 - 5.020802115037742i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

12   Pass
x = 0.3i; y_correct = 0.074754684076440 + 3.053886180297906i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

13   Pass
x = 0.4-2i; y_correct = 1.171012435933119 - 2.861745062394908i; y = logarithmicIntegral(x); assert(abs(real(y)-real(y_correct))<1e-8 && abs(imag(y)-imag(y_correct))<1e-8)

Suggested Problems

More from this Author46

Community Treasure Hunt

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

Start Hunting!