西西河

主题:【讨论】给大家出一道初中数学题 -- 迷途笨狼

共:💬66 🌺34 新:
全看分页树展 · 主题 跟帖
家园 跑了一次494

不知道这个误差能不能有显式的分析

def con1(x,y):

——return y<np.sqrt(1-x**2)

def con3(x,y):

——return y>(np.sqrt(4-x**2)-np.sqrt(2))

num=0

total = 10**6

for i in range(total):

——x = 2*np.random.rand(1)-1

——y = 2*np.random.rand(1)-1

——if con1(x,y) and con2(x,y):

———— num+=1

S = 2*num/total*(40**2)

print(S,num)

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河