数值计算 - Richardson外推法求一阶导数(C++实现)

本文介绍了使用Richardson外推法来求解一阶导数的方法,并提供了C++实现代码,适用于数值计算场景。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

求导只需将 f 中的函数替换即可。

/*本程序使用理查森外推方法就求微分,程序的核心是运用G[i][j] =
 (pow(4, i) * G[i][j-1] - G[i-1][j-1])/(pow(4, i)-1)*/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
const double le = 1e-10;

////////////////////////////////////////////////////////////////////////////////////
template <typename T> T** Allocation2D(int m, int n){
	T **a;
	a = new T*[m];
	for(int i=0; i<m; i++)
		a[i] = new T[n];
	return a;
}

////////////////////////////////////////////////////////////////////////////////////
double f(double x);
void WaiTui(double t, double h);
void Clear(double **G, int m);
////////////////////////////////////////////////////////////////////////////////////
int main(){
	double t, h;
	cout<<"请输入所求值的导数:";
	cin>>t;
	cout<<"请输入步长的值:";
	cin>>h;
	WaiTui(t, h);
	return 0;
}

////////////////////////////////////////////////////////////////////////////////////
/********************************函数f = sin(x)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值