当前位置:网站首页>[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;
}
边栏推荐
- .env.xxx 文件,加了常量,卻undefined
- [QT] qtcreator uninstall and installation (abnormal state)
- I would like to ask, which securities is better for securities account opening? Is it safe to open a mobile account?
- Jielizhi, production line assembly link [chapter]
- Concurrentskiplistmap -- principle of table skipping
- 2021 robocom world robot developer competition - preliminary competition of higher vocational group
- How excel opens CSV files with more than one million lines
- 回顾数据脱敏系统
- Pytorch learning record
- Correlation - intra group correlation coefficient
猜你喜欢

如何提升数据质量
![[QT] test whether QT can connect to the database](/img/63/32530c15995ef23bde8cadc3adfd11.png)
[QT] test whether QT can connect to the database

Graduation season is both a farewell and a new beginning

Leetcode96 different binary search trees

实例讲解将Graph Explorer搬上JupyterLab
![Jielizhi, production line assembly link [chapter]](/img/f8/20c41ffe9468d59bf25ea49f73751e.png)
Jielizhi, production line assembly link [chapter]

algolia 搜索需求,做的快自闭了...
![[embedded system course design] a single key controls the LED light](/img/c9/076618208bbab0b95faa5a7e644a07.png)
[embedded system course design] a single key controls the LED light

关联性——组内相关系数

牛客-练习赛101-推理小丑
随机推荐
[C #] dependency injection and Autofac
Halcon knowledge: an attempt of 3D reconstruction
Overview of edge calculation
Use pair to do unordered_ Key value of map
RPA教程01:EXCEL自动化从入门到实操
Windows10 install WSL (I) (wslregisterdistribution error)
LeetCode中等题题分享(5)
Jielizhi, production line assembly link [chapter]
Operate database transactions with jpatractionmanager
cookie、session、tooken
Write some suggestions to current and future doctoral students to sort out and share
Vue force cleaning browser cache
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
Which app is better and more secure for stock mobile account opening
SecurityUtils.getSubject().getPrincipal()为null的问题怎么解决
Which securities company is the best to open a stock account? Is there a security guarantee
cookie、session、tooken
golang中的iota
Linux CentOS7安装Oracle11g的超完美新手教程
【模板】自适应辛普森积分