Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Test
- {
- static double func(double x) {
- return 1 / (Math.Pow(Math.Cosh(x),2));
- }
- static void monte_carlo() {
- double [] x = {2.7, 3.0, 3.3, 3.7, 4.0, 4.5, 4.9, 5.1};
- double [] y = {0.3, -0.2, -0.7, -1.0, -0.9, -0.5, 0.2, 1.3};
- double in_d = 0.0 , out_d = 0.0;
- for (int i = 0; i<8; i++){
- if (y[i]<func(x[i])){
- in_d += 1;
- }
- }
- Console.WriteLine(in_d/8*3);
- }
- public static void Main()
- {
- monte_carlo();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement