5-Dimensional Monte Carlo Integration

Consider a 5-dimensional space with dimensions A , B , C , D , E A,B,C,D,E . A hypercube is parametrized in the following way:

0 A 1 0 B 1 0 C 1 0 D 1 0 E 1 0 \leq A \leq 1 \\ 0 \leq B \leq 1 \\ 0 \leq C \leq 1 \\ 0 \leq D \leq 1 \\ 0 \leq E \leq 1

What fraction of the hypercube's volume consists of points satisfying all of the following criteria simultaneously?:

A B 2 B s i n ( C ) e D 3 2 A E 1 2 A \geq B^2 \\ B \leq sin(C) \\ e^D \geq \frac{3}{2} \\ A E \geq \frac{1}{2}

Details and Assumptions:
- The constant e e is Euler's Number
- Give your answer as a number between 0 0 and 1 1


The answer is 0.04185.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

João Areias
Jun 11, 2018

This is a simple aplication of the monte-carlo simulation the idea is to just generate a lot of random points and see which ones fit your criteria. Here is my implementation of the solution, I also added some a nice plots to see how the ratio converges. I'm doing 10 simulations with 10000000 points each which gives me 100000000 points to get a good aproximation and allows me to estimate the error by calculating the standard deviation of the outputs, from that I got this as a final result:

Mean: 0.041853749999999995 Standard deviation: 6.970503927263917e-05

Here is my code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from tqdm import tqdm
import matplotlib.pyplot as plt
import numpy as np


def monte_carlo_simulation(runs=1001):
    plt.ylabel('Ratio')
    plt.xlabel('Runs')

    positive = 0.
    pbar = tqdm(range(1, runs + 1))
    # Start from 1 so it's easier to graph since i doesn't really metter
    for i in pbar:
        point = np.random.rand(5)
        # Testing for conditions posed
        if (
                point[0] >= point[1] ** 2 and
                point[1] <= np.sin(point[2]) and
                np.exp(point[3]) >= 3 / 2 and
                point[0] * point[4] >= 1 / 2):
            # Adds point to positive test
            positive += 1

        if i % 1000 == 0:
            # Plot calculated ratio every 1000 runs
            plt.plot(i, positive / i, 'ro')

    plt.plot(runs, positive / runs, 'ro')
    plt.show()

    return positive / runs


if __name__ == "__main__":
    data = []
    for i in range(1, 11):
        x = monte_carlo_simulation(10000000)
        print(f"Test {i}: {x}")
        data.append(x)

    print(f"Mean: {np.mean(data)} \t Standard deviation: {np.std(data)}")

And here are 2 of my plots:

The problem has a closed form solution.

FullSimplify [ Reduce [ a b 2 b sin ( c ) e d 3 2 a e 1 2 0 a 1 0 b 1 0 c 1 0 d 1 0 e 1 ] ] \text{FullSimplify}\left[ \\ \ \ \text{Reduce}\left[a\geq b^2\land b\leq \sin (c)\land e^d\geq \frac{3}{2}\land a\ e\geq \frac{1}{2}\land 0\leq a\leq 1\land \\ \ \ \ \ 0\leq b\leq 1\land 0\leq c\leq 1\land 0\leq d\leq 1\land 0\leq e\leq 1\right]\right] \Longrightarrow log ( 3 2 ) d 1 ( ( e 1 ( ( a = 1 2 e 1 ( ( c 1 ( ( b = 0 c 0 ) ( b < sin ( 1 ) b > 0 c sin 1 ( b ) ) ) ) ( b = sin ( 1 ) c = 1 ) ) ) ( 1 a 2 e ( ( a < 1 ( ( c 1 ( ( b = 0 2 a > 1 c 0 ) ( b > 0 a sin 2 ( 1 ) c sin 1 ( b ) b < sin ( 1 ) ) ) ) ( a sin 2 ( 1 ) b = sin ( 1 ) c = 1 ) ) ) ( a < sin 2 ( 1 ) 2 a > 1 a b b > 0 c 1 c sin 1 ( b ) ) ) ) ) ) ( 2 a = 1 c 1 e = 1 ( ( b = 0 c 0 ) ( b 1 2 b > 0 c sin 1 ( b ) ) ) ) ) \log \left(\frac{3}{2}\right)\leq d\leq 1\land \\ \left(\left(e\leq 1\land \left(\left(a=1\land 2 e\geq 1\land \left(\left(c\leq 1\land \left((b=0\land c\geq 0)\lor \left(b<\sin (1)\land b>0\land \\ c\geq \sin ^{-1}(b)\right)\right)\right)\lor (b=\sin (1)\land c=1)\right)\right)\lor \\ \left(\frac{1}{a}\leq 2 e\land \left(\left(a<1\land \left(\left(c\leq 1\land \left((b=0\land 2 a>1\land c\geq 0)\lor \left(b>0\land a\geq \sin ^2(1)\land c\geq \sin ^{-1}(b)\land b<\sin (1)\right)\right)\right)\lor \\ \left(a\geq \sin ^2(1)\land b=\sin (1)\land c=1\right)\right)\right)\lor \left(a<\sin ^2(1)\land \\ 2 a>1\land \sqrt{a}\geq b\land b>0\land c\leq 1\land c\geq \sin ^{-1}(b)\right)\right)\right)\right)\right)\lor \\ \left(2 a=1\land c\leq 1\land e=1\land \left((b=0\land c\geq 0)\lor \left(b\leq \frac{1}{\sqrt{2}}\land b>0\land c\geq \sin ^{-1}(b)\right)\right)\right)\right)

Eliminate clauses where a variable is only equal to a value as z z f ( x ) d x \int_z^z f(x) \, dx is 0 0 .

log ( 3 2 ) d 1 sin 1 ( b ) c 1 1 2 a e 1 ( ( 1 2 < a < sin 2 ( 1 ) 0 < b a ) ( sin 2 ( 1 ) < a < 1 0 < b < sin ( 1 ) ) ) 1 36 ( log ( 3 2 ) 1 ) ( 3 π 2 + 20 2 18 + cos ( 3 ) + 36 log ( ( 2 2 ) cot ( 1 2 ) ) + 9 cos ( 1 ) ( 4 log ( sin ( 1 ) ) 5 ) ) 0.041878431746397186653. \log \left(\frac{3}{2}\right)\leq d\leq 1\land \sin ^{-1}(b)\leq c\leq 1\land \frac{1}{2 a}\leq e\leq 1\land \left(\left(\frac{1}{2}<a<\sin ^2(1)\land 0<b\leq \sqrt{a}\right)\lor \left(\sin ^2(1)<a<1\land 0<b<\sin (1)\right)\right) \Longrightarrow \\ \frac{1}{36} \left(\log \left(\frac{3}{2}\right)-1\right) \left(3 \pi \sqrt{2}+20 \sqrt{2}-18+\cos (3)+36 \log \left(-\left(\sqrt{2}-2\right) \cot \left(\frac{1}{2}\right)\right)+9 \cos (1) (4 \log (\sin (1))-5)\right) \approx \\ 0.041878431746397186653.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...