当前位置:网站首页>[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;
}
边栏推荐
- SQL数据分析之流程控制语句【if,case...when详解】
- Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
- What is the purpose of ERP project implementation plan?
- The difference between timer and scheduledthreadpoolexecutor
- Windows 7 install MySQL error: 1067
- Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging
- Windows 7 安装MYSQL 错误:1067
- 【模板】自适应辛普森积分
- 多表操作-一对一,一对多与多对多
- PWN attack and defense world cgpwn2
猜你喜欢

毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?

PyTorch学习记录

PyCharm调用matplotlib绘图时图像弹出问题怎么解决

. env. XXX file, with constant, but undefined

SQL数据分析之子查询的综合用法和案例题【耐心整理】

Leetcode96 different binary search trees

leetcode96不同的二叉搜索树
![[cmake] cmake configuration in QT Creator](/img/e3/1cf76f88eaddb5d32184523dfb049c.png)
[cmake] cmake configuration in QT Creator
![Jielizhi, production line assembly link [chapter]](/img/1d/d1736fad33c428e61f450aad512ce0.png)
Jielizhi, production line assembly link [chapter]

Windows10 install WSL (I) (wslregisterdistribution error)
随机推荐
Is it safe to choose mobile phone for stock trading account opening in Beijing?
二叉搜索树的创建,查找,添加,删除操作
E-commerce RPA robot helps brand e-commerce to achieve high traffic
Use vb Net to convert PNG pictures into icon type icon files
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
Relevant settings of wechat applet cache expiration time (recommended)
[QT] QT cannot find a solution to the compiler using msvc2017
I would like to ask, which securities is better for securities account opening? Is it safe to open a mobile account?
2021 robocom world robot developer competition - preliminary competition of higher vocational group
Various global files related to [.Net core] program
牛客-练习赛101-推理小丑
挖财学堂开户打新债安全可靠嘛?
【CMake】Qt creator 里面的 cmake 配置
多表操作-一对一,一对多与多对多
Chapter 6 data flow modeling
Asp .NetCore 微信订阅号自动回复之文本篇
【QT】Qt 使用MSVC2017找不到编译器的解决办法
SQL数据分析之窗口排序函数rank、dense_rank、raw_number与lag、lead窗口偏移函数【用法整理】
[QT] solve the problem that QT MSVC 2017 cannot compile
Which securities company is the best to open a stock account? Is there a security guarantee