当前位置:网站首页>[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;
}
边栏推荐
- Vue force cleaning browser cache
- - Oui. Env. Fichier XXX, avec constante, mais non spécifié
- Jielizhi, production line assembly link [chapter]
- 时间复杂度与空间复杂度
- Iota in golang
- Selectively inhibiting learning bias for active sampling
- Write some suggestions to current and future doctoral students to sort out and share
- Record the accidental success and failure of uploading large files
- 回顾数据脱敏系统
- Multi table operation - one to one, one to many and many to many
猜你喜欢

S32Kxxx bootloader之UDS bootloader

GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速

【QT】Qt 使用MSVC2017找不到编译器的解决办法

SQL数据分析之子查询的综合用法和案例题【耐心整理】
![[QT] qtcreator uninstall and installation (abnormal state)](/img/66/1b96326d87bca2a790a6694f38e79e.png)
[QT] qtcreator uninstall and installation (abnormal state)

牛客-练习赛101-推理小丑

Write some suggestions to current and future doctoral students to sort out and share

SQL Server Installation Guide

How to solve the image pop-up problem when pycharm calls Matplotlib to draw

Pytorch learning record
随机推荐
Halcon knowledge: an attempt of 3D reconstruction
LDR6035智能蓝牙音响可对手机设备持续充放电方案
Write some suggestions to current and future doctoral students to sort out and share
cookie、session、tooken
Is it safe to choose mobile phone for stock trading account opening in Beijing?
Shell custom function
毕业季 | 华为专家亲授面试秘诀:如何拿到大厂高薪offer?
[QT] QT cannot find a solution to the compiler using msvc2017
Openvino model performance evaluation tool DL workbench
Huawei HMS core joins hands with hypergraph to inject new momentum into 3D GIS
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
vs2015 AdminDeployment. xml
记录一下大文件上传偶然成功偶然失败问题
数据库--SqlServer详解
PyTorch学习记录
How excel opens CSV files with more than one million lines
const // It is a const object... class nullptr_ t
启牛学院开户安全的吗?开户怎么开?
const // It is a const object...class nullptr_t
Shell process control