当前位置:网站首页>【模板】自适应辛普森积分
【模板】自适应辛普森积分
2022-07-01 23:55:00 【哈希表扁豆】
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double a,b,c,d,L,R;
double f(double x)//原函数
{
return (c*x+d)/(a*x+b);
}
double simpson(double l,double r)//三点辛普森
{
double mid = (l+r)/2;
return (r-l)*(f(l)+f(r)+4*f(mid))/6;
}
double integral(double l,double r,double eps)//自适应辛普森
{
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;
}
边栏推荐
- [must] bm41 output the right view of the binary tree [medium +]
- Niuke - Practice 101 - reasoning clown
- 电商RPA机器人,助力品牌电商抢立流量高点
- 写给当前及未来博士研究生一些建议整理分享
- Key points of security agreement
- 【ES实战】ES上的安全性运行方式
- 深度学习 | 三个概念:Epoch, Batch, Iteration
- Openwrt enable kV roaming
- Digital transformation has a long way to go, so how to take the key first step
- Using SqlCommand objects in code
猜你喜欢
USB-IF协会与各种接口的由来
Key points of security agreement
[QT] qtcreator uninstall and installation (abnormal state)
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
使用uni-simple-router,动态传参 TypeError: Cannot convert undefined or null to object
【QT】QtCreator卸载与安装(非正常状态)
【CMake】Qt creator 里面的 cmake 配置
[embedded system course design] a single key controls the LED light
【ES实战】ES上的安全性运行方式
S32Kxxx bootloader之UDS bootloader
随机推荐
Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object
PostgreSQL source code (58) tuple splicing heap_ form_ Tuple analysis
Depth first search and breadth first search of graph traversal
【必会】BM41 输出二叉树的右视图【中等+】
深度学习 | 三个概念:Epoch, Batch, Iteration
[Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
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
ADO.NET之SqlDataAdpter对象
How excel opens CSV files with more than one million lines
2021 robocom world robot developer competition - preliminary competition of higher vocational group
golang中的iota
SQL optimization
Correlation - intra group correlation coefficient
cookie、session、tooken
起床困难综合症(按位贪心)
RPA教程01:EXCEL自动化从入门到实操
字典、哈希表、数组的概念
Is there a piece of code that makes you convinced by human wisdom
【QT】Qt 使用MSVC2017找不到编译器的解决办法
[cmake] cmake configuration in QT Creator