Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于开平方蒙特卡罗法例程 #6

Open
Floyed11 opened this issue Sep 20, 2023 · 4 comments
Open

关于开平方蒙特卡罗法例程 #6

Floyed11 opened this issue Sep 20, 2023 · 4 comments

Comments

@Floyed11
Copy link

Floyed11 commented Sep 20, 2023

截屏2023-09-20 18 49 05 来自书本P66

这个程序中,函数返回值的表达式具有特殊性,只适用于求2的平方根的情况。
可能🤔具有一定的迷惑性。
但其正确性是毋庸置疑的👍。


显然,系数2除以c(此时为2)的平方根的结果恰好为c(即2)的平方根

@ArcueidType
Copy link

因为这个是根据sqrt(x)在[0, 2]的定积分结果推出的表达式,只能得到sqrt(2),如果想得到其他平方根可以更换积分区间再同理倒推

@ArcueidType
Copy link

ArcueidType commented Sep 20, 2023

因为这个是根据sqrt(x)在[0, 2]的定积分结果推出的表达式,只能得到sqrt(2),如果想得到其他平方根可以更换积分区间再同理倒推

其实想求a的平方根就可以取区间[0, a],返回(3 * a * sum) / (2 * times)就是要求的结果

@litterqi
Copy link

好厉害😍😍😍

@realtyyyyy
Copy link

好厉害😍😍😍

雀氏厉害 @litterqi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants