Skip to content

Instantly share code, notes, and snippets.

@antonio-catalano
Last active April 8, 2018 00:45
Show Gist options
  • Save antonio-catalano/93d6184df8a365a88ce182e6ce2a87cb to your computer and use it in GitHub Desktop.
Save antonio-catalano/93d6184df8a365a88ce182e6ce2a87cb to your computer and use it in GitHub Desktop.
Show that for three real number that satisfy 0 < x < y < z < π/2 , the following inequality holds: (x+y) sin(z) + (x-z) sin(y) < (y+z) sin(x)
import math
import random
count = 0
n = 1000000 #montecarlo simulation
for i in range (1000000):
z = float(random.uniform(0,(math.pi)/2)) #uniform distribution, it gives a random real number between (0, π/2)
y = float(random.uniform(0,z))
x = float(random.uniform(0,y))
side_1 = float((x+y) * math.sin(z) + (x-z) * math.sin(y))
side_2 = float((y+z) * math.sin(x))
if side_1 < side_2 : # inequality we want to prove
count = count + 1 # every time the inequality has proved, we add 1 to the variable "count"
print('The inequality has been true:', count, 'times')
print()
if count == n: # condition in order to prove the inequality
print (' "n" and "count" are equal so the inequality is almost certainly true')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment