Randomly throwing points

Consider the following python function

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
from random import random
from math import log

def compute(points):
   randomize = lambda: (random(), 3*random())
   isInside =  lambda x,y: y <= (x**3 - 1)/log(x)

   hits = 0.0
   for i in range(points):
      if isInside(*randomize()):
         hits += 1.0

   return 3.0*(hits/points)

Find the value of x x satisfying ln x = lim n c o m p u t e ( n ) \displaystyle \ln x = \lim_{n\to\infty} \mathtt{compute}(n) .


The answer is 4.

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.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...