当前位置:网站首页>[template] adaptive Simpson integral
[template] adaptive Simpson integral
2022-07-02 00:07:00 【Hash table lentils】
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double a,b,c,d,L,R;
double f(double x)// Primitive function
{
return (c*x+d)/(a*x+b);
}
double simpson(double l,double r)// Three o'clock Simpson
{
double mid = (l+r)/2;
return (r-l)*(f(l)+f(r)+4*f(mid))/6;
}
double integral(double l,double r,double eps)// Adaptive Simpson
{
double mid = (l+r)/2;
double SL = simpson(l,mid),SR = simpson(mid,r),ST = simpson(l,r);
if(fabs(ST-SL-SR)<=(eps*15))
return SL+SR+(SL+SR-ST)/15;
else return integral(l,mid,eps/2)+integral(mid,r,eps/2);
}
int main()
{
cin>>a>>b>>c>>d>>L>>R;
printf("%.6lf",integral(L,R,1e-6));
return 0;
}
边栏推荐
- GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
- Why does blocprovider feel similar to provider?
- Regular expression collection
- 数据库--SqlServer详解
- Learn online case practice
- - Oui. Env. Fichier XXX, avec constante, mais non spécifié
- ADO. Net SqlCommand object
- 【CMake】Qt creator 里面的 cmake 配置
- mysql:insert ignore、insert和replace区别
- Which securities company is the best to open a stock account? Is there a security guarantee
猜你喜欢

Concurrentskiplistmap -- principle of table skipping

leetcode96不同的二叉搜索樹

leetcode96不同的二叉搜索树

Leetcode medium question sharing (5)

Relatively easy to understand PID understanding

Overview of edge calculation

Pytorch learning record
![[QT] qtcreator uninstall and installation (abnormal state)](/img/66/1b96326d87bca2a790a6694f38e79e.png)
[QT] qtcreator uninstall and installation (abnormal state)

使用VB.net将PNG图片转成icon类型图标文件

Learn online case practice
随机推荐
【QT】QtCreator卸载与安装(非正常状态)
LDR6035智能蓝牙音响可对手机设备持续充放电方案
Pytorch learning record
. env. XXX file, with constant, but undefined
Leetcode 96 différents arbres de recherche binaires
[QT] QT cannot find a solution to the compiler using msvc2017
Using multithreaded callable to query Oracle Database
Regular expression collection
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Which app is better and more secure for stock mobile account opening
Review data desensitization system
Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging
The difference between timer and scheduledthreadpoolexecutor
微信小程序缓存过期时间的相关设置(推荐)
Learn online case practice
挖财学堂开户打新债安全可靠嘛?
Soft exam information system project manager_ Compiled abbreviations of the top ten management processes to help memory recitation - -- software test advanced information system project manager 054
E-commerce RPA robot helps brand e-commerce to achieve high traffic
Shell process control
Asp .NetCore 微信订阅号自动回复之文本篇