Problem 47103. Estimate Pi by Monte Carlo method

Solution 3467968

Submitted on 29 Oct 2020 by Mehmet OZC
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
n = 1e+5; y_correct = 3.141120000000000; assert(abs(monte_carlo(n) - y_correct) < 1e-5)

2   Pass
n = 1e+7; y_correct = 3.141428400000000; assert(abs(monte_carlo(n) - y_correct) < 1e-7)

3   Pass
n = 5e+8; y_correct = 3.141558016000000; assert(abs(monte_carlo(n) - y_correct) < 1e-9)

Suggested Problems

More from this Author2

Community Treasure Hunt

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

Start Hunting!