数值分析原理课程实验——牛顿(Newton)迭代法

牛顿(Newton)迭代法

方法概要

在这里插入图片描述

待求问题

在这里插入图片描述

程序流程

在这里插入图片描述

程序代码

/*Matlab函数
function Result = Newton(x0, e1, e2, N, f)
    n = 1;
    while n <= N
        F = subs(f, symvar(f), x0);
        DF = subs(diff(f), symvar(f), x0);
        if(abs(F) < e1)
            Result = double(x0);
            return;
        end
        if(abs(DF) < e2)
            Result = 'Iteration failed!';
            return;
        end
        x1 = x0-F/DF;
        Tol = abs(x1 - x0);
        if(Tol < e1)
            Result = double(x1);
            return;
        end
        n = n+1;
        x0 = x1;
    end
    Result = 'Iteration failed!';
end*/


/*C语言程序
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double x, e1, e2;
int n;

double f(double x) { return cos(x) - x; }
double df(double x) { return -sin(x) - 1; }

int main() {
    scanf("%lf%lf%lf%d", &x, &e1, &e2, &n);
    for (int i = 1; i <= n; i++) {
        double F = f(x), DF = df(x);
        if (fabs(F) < e1) {
            printf("%lf", x);
            return 0;
        }
        if (fabs(DF) < e2) {
            printf("Failed");
            return 0;
        }
        double x1 = x - F / DF;
        double tol = fabs(x - x1);
        if (tol < e1) {
            printf("%lf", x1);
            return 0;
        }
        x = x1;
    }
    printf("Failed");
    return 0;
}
*/

运行结果

在这里插入图片描述
在这里插入图片描述

高斯(Gauss)列主元消去法,原文链接:

https://blog.csdn.net/KissMoon_/article/details/116278197

拉格朗日(Lagrange)插值,原文链接:

https://blog.csdn.net/KissMoon_/article/details/116278449

四阶龙格-库塔(Runge-Kutta)方法,原文链接:

https://blog.csdn.net/KissMoon_/article/details/116278567

Newton/Gauss/Lagrange/Runge-Kutta实验内容+方法指导+Matlab脚本+Matlab函数+Matlab运行报告+C程序+实验报告,一键下载:

https://download.csdn.net/download/KissMoon_/18244419

凉梦空间

欢迎你进入我的个人博客网站参观交流:https://www.liangmeng.xyz

在这里插入图片描述

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

凉丶梦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值