当前位置:网站首页>[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;
}
边栏推荐
- RPA教程01:EXCEL自动化从入门到实操
- LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
- 【QT】QtCreator卸载与安装(非正常状态)
- cookie、session、tooken
- 求逆序数的三个方法
- Resumption of attack and defense drill
- const // It is a const object... class nullptr_ t
- Door level modeling - after class exercises
- 使用htaccess文件禁止目录里的脚本执行权限
- Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
猜你喜欢
Download the online video m3u8 tutorial
PyCharm调用matplotlib绘图时图像弹出问题怎么解决
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
下载在线视频 m3u8使用教程
RPA教程01:EXCEL自动化从入门到实操
数据库--SqlServer详解
使用 pair 做 unordered_map 的键值
Material design component - use bottomsheet to show extended content (I)
Windows installation WSL (II)
- Oui. Env. Fichier XXX, avec constante, mais non spécifié
随机推荐
记录一下大文件上传偶然成功偶然失败问题
SQL Server Installation Guide
数据库--SqlServer详解
The essence of software architecture
Using uni simple router, dynamically pass parameters typeerror: cannot convert undefined or null to object
Is it safe to buy funds in a securities account? Where can I buy funds
vue 强制清理浏览器缓存
使用VB.net将PNG图片转成icon类型图标文件
ERP项目施行计划的目的是什么?
Multi table operation - one to one, one to many and many to many
Material design component - use bottomsheet to show extended content (I)
Algolia's search needs are almost closed
Learn online case practice
[QT] test whether QT can connect to the database
Flow control statement of SQL data analysis [if, case... When detailed]
Is it safe for qiniu college to open an account? How to open an account?
RPA tutorial 01: Excel automation from introduction to practice
Window sorting functions rank and deny for SQL data analysis_ rank、raw_ Number and lag, lead window offset function [usage sorting]
在证券账户上买基金安全吗?哪里可以买基金
Qt5.12.9 migration tutorial based on Quanzhi H3