当前位置: 首页 > news >正文

网站锚文本使用查询广告推销网站

网站锚文本使用查询,广告推销网站,全网seo是什么意思,鸡泽网站建设多项式插值(数值计算方法)Matlab实现 一. 原理介绍二. 程序设计1. 构建矩阵2. 求解矩阵方程3. 作出多项式函数4. 绘制插值曲线5. 完整代码 三. 图例 一. 原理介绍 关于插值的定义及基本原理可以参照如下索引 插值原理(数值计算方法&#xff…

多项式插值(数值计算方法)Matlab实现

  • 一. 原理介绍
  • 二. 程序设计
    • 1. 构建矩阵
    • 2. 求解矩阵方程
    • 3. 作出多项式函数
    • 4. 绘制插值曲线
    • 5. 完整代码
  • 三. 图例

一. 原理介绍

  1. 关于插值的定义及基本原理可以参照如下索引
    插值原理(数值计算方法)
  2. 前面已经介绍过插值原理的唯一性表述,对于分立的数据点,方程组:

P ( x 0 ) = y 0 ⇒ a 0 + a 1 x 0 + a 2 x 0 2 + ⋯ + a n x 0 n = y 0 , P ( x 1 ) = y 1 ⇒ a 0 + a 1 x 1 + a 2 x 1 2 + ⋯ + a n x 1 n = y 1 , ⋮ P ( x n ) = y n ⇒ a 0 + a 1 x n + a 2 x n 2 + ⋯ + a n x n n = y n . \begin{aligned} & P(x_0) = y_0 \quad \Rightarrow \quad a_0 + a_1 x_0 + a_2 x_0^2 + \cdots + a_n x_0^n = y_0, \\ & P(x_1) = y_1 \quad \Rightarrow \quad a_0 + a_1 x_1 + a_2 x_1^2 + \cdots + a_n x_1^n = y_1, \\ & \quad \vdots \\ & P(x_n) = y_n \quad \Rightarrow \quad a_0 + a_1 x_n + a_2 x_n^2 + \cdots + a_n x_n^n = y_n. \end{aligned} P(x0)=y0a0+a1x0+a2x02++anx0n=y0,P(x1)=y1a0+a1x1+a2x12++anx1n=y1,P(xn)=yna0+a1xn+a2xn2++anxnn=yn.

恒有解,多项式插值的目标即为在这一过程中求解系数 a 0 、 a 1 、 . . . 、 a n ⟺ [ a 0 a 1 a 2 ⋮ a n ] a_0、a_1、...、a_n\Longleftrightarrow\begin{bmatrix} a_0 \\ a_1 \\ a_2 \\ \vdots \\ a_n \end{bmatrix} a0a1...an a0a1a2an

  1. 即解方程组:
    [ 1 x 0 x 0 2 ⋯ x 0 n 1 x 1 x 1 2 ⋯ x 1 n ⋮ ⋮ ⋮ ⋱ ⋮ 1 x n x n 2 ⋯ x n n ] [ a 0 a 1 a 2 ⋮ a n ] = [ y 0 y 1 y 2 ⋮ y n ] . \begin{bmatrix} 1 & x_0 & x_0^2 & \cdots & x_0^n \\ 1 & x_1 & x_1^2 & \cdots & x_1^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x_n & x_n^2 & \cdots & x_n^n \end{bmatrix} \begin{bmatrix} a_0 \\ a_1 \\ a_2 \\ \vdots \\ a_n \end{bmatrix}= \begin{bmatrix} y_0 \\ y_1 \\ y_2 \\ \vdots \\ y_n \end{bmatrix}. 111x0x1xnx02x12xn2x0nx1nxnn a0a1a2an = y0y1y2yn .

关于该方程组的解法在线性代数中有多种,这里主要提及两种:
①高斯消元法
②克莱姆法则
程序设计过程中一般有封装好的库函数,如果为了考虑减少库依赖和提高程序运行效率及占用可能会用到上述方法(这里就不详细展开了)


二. 程序设计

1. 构建矩阵

% 构造Vandermonde矩阵A
A = zeros(n, n);
for i = 1:nfor j = 1:nA(i, j) = x_data(i)^(j-1);  % Vandermonde矩阵end
end

Ⅰ 构建一个 ( n × n ) (n \times n) (n×n)的矩阵 A 来描述多项式矩阵:
[ 1 x 0 x 0 2 ⋯ x 0 n 1 x 1 x 1 2 ⋯ x 1 n ⋮ ⋮ ⋮ ⋱ ⋮ 1 x n x n 2 ⋯ x n n ] \begin{bmatrix} 1 & x_0 & x_0^2 & \cdots & x_0^n \\ 1 & x_1 & x_1^2 & \cdots & x_1^n \\ \vdots & \vdots & \vdots & \ddots & \vdots \\ 1 & x_n & x_n^2 & \cdots & x_n^n \end{bmatrix} 111x0x1xnx02x12xn2x0nx1nxnn

其中:
A [ i ] [ j ] = x i j − 1 A[i][j] = x_{i}^{j-1} A[i][j]=xij1

式中第一列的1是通过 x i 0 x_{i}^{0} xi0得到的。

y_data = data(:, 2);

Ⅱ 构建系数矩阵 B,即原始数据对应的 y 值:

2. 求解矩阵方程

% 解线性方程组 A * coefficients = y_data
coefficients = A \ y_data;

注释:该部分通过反斜杠运算符 \ 计算线性方程组 A ⋅ c o e f f i c i e n t s = y d a t a A ⋅ coefficients = y_data Acoefficients=ydata的解。
①当方程组超定时(方程数大于未知数个数),返回最小二乘解,即最小化残差平方和 ∥ A ⋅ c o e f f i c i e n t s − y d a t a ∥ 2 ∥ A ⋅ coefficients − y_{data} ∥^2 Acoefficientsydata2
②当方程组适定时,返回精确解
③当方程组欠定时返回最小范数解

求解出矩阵形式形如
6.0000
-7.8333
4.5000
-0.6667
从上至下为最低次项到最高次项系数

3. 作出多项式函数

% 生成插值多项式的x和y值
x_vals = linspace(min(x_data) - 1, max(x_data) + 1, 500);
y_vals = polyval(flip(coefficients), x_vals);  % 计算插值多项式的y值

注释: 前面注释提到coefficients数组中的系数对应从左到右为最低到最高次项系数,而函数polyval()要求输入具有逆序的项系数:flip函数将系数的顺序反转,将变为从最高次到最低次项系数
y_vals = polyval(flip(coefficients), x_vals) 将计算每一个 x_val 对应的多项式值,并返回一个 y_vals 数组,包含每个 x_val 对应的 y 值。

4. 绘制插值曲线

% 绘制插值曲线
figure;
plot(x_vals, y_vals, 'b-', 'DisplayName', '插值曲线');
hold on;
scatter(x_data, y_data, 'ro', 'DisplayName', '数据点');
title('插值多项式');
xlabel('X轴');
ylabel('Y轴');
legend;
grid on;

5. 完整代码

% 输入数据 (x, y)
data = [1,22,33,54,4
];% 提取x和y值
x_data = data(:, 1);
y_data = data(:, 2);
n = length(data);% 构造Vandermonde矩阵A
A = zeros(n, n);
for i = 1:nfor j = 1:nA(i, j) = x_data(i)^(j-1);  % Vandermonde矩阵end
end% 解线性方程组 A * coefficients = y_data
coefficients = A \ y_data;% 输出插值多项式的系数
disp('插值多项式的系数:');
disp(coefficients);% 生成插值多项式的x和y值
x_vals = linspace(min(x_data) - 1, max(x_data) + 1, 500);
y_vals = polyval(flip(coefficients), x_vals);  % 计算插值多项式的y值% 绘制插值曲线
figure;
plot(x_vals, y_vals, 'b-', 'DisplayName', '插值曲线');
hold on;
scatter(x_data, y_data, 'ro', 'DisplayName', '数据点');
title('插值多项式');
xlabel('X轴');
ylabel('Y轴');
legend;
grid on;

三. 图例

这要求我们的输入数据都具有上述形式:

data = [x_1, y_1x_2, y_2x_3, y_3x_4, y_4...]

最后我们插值一组随机生成的测试数据

data = [7.264384, 3.9312921.943873, 6.2189038.384019, 2.5841035.672210, 9.0326740.294315, 4.7260186.129531, 7.9128469.516347, 1.4782643.824679, 5.596042
]

实际应用时应避免数据点过多导致的多项式次数过高


希望能够帮到迷途之中的你,知识有限,如有学术错误请及时指正,感谢大家的阅读

(^^)/▽ ▽\(^^)

文章转载自:
http://hyetal.qwfL.cn
http://idd.qwfL.cn
http://dinosauric.qwfL.cn
http://lepidosis.qwfL.cn
http://mountainous.qwfL.cn
http://disfunction.qwfL.cn
http://chemiluminescnet.qwfL.cn
http://urticariogenic.qwfL.cn
http://pawnee.qwfL.cn
http://diphonemic.qwfL.cn
http://monocable.qwfL.cn
http://subchairman.qwfL.cn
http://cossette.qwfL.cn
http://shack.qwfL.cn
http://devoice.qwfL.cn
http://dc.qwfL.cn
http://myelocytic.qwfL.cn
http://truncation.qwfL.cn
http://blether.qwfL.cn
http://png.qwfL.cn
http://exegetics.qwfL.cn
http://vehemently.qwfL.cn
http://noneconomic.qwfL.cn
http://pourparler.qwfL.cn
http://fasching.qwfL.cn
http://workaday.qwfL.cn
http://bogeyman.qwfL.cn
http://slaveocracy.qwfL.cn
http://blamable.qwfL.cn
http://cycloaliphatic.qwfL.cn
http://brule.qwfL.cn
http://civil.qwfL.cn
http://snivel.qwfL.cn
http://heliotropic.qwfL.cn
http://myriapodan.qwfL.cn
http://calorifics.qwfL.cn
http://beside.qwfL.cn
http://jawan.qwfL.cn
http://indochina.qwfL.cn
http://spinstry.qwfL.cn
http://waterhead.qwfL.cn
http://costae.qwfL.cn
http://proustite.qwfL.cn
http://paid.qwfL.cn
http://subjunction.qwfL.cn
http://eonism.qwfL.cn
http://leucemia.qwfL.cn
http://cupid.qwfL.cn
http://campstool.qwfL.cn
http://fernery.qwfL.cn
http://urn.qwfL.cn
http://eyry.qwfL.cn
http://viole.qwfL.cn
http://spume.qwfL.cn
http://seasonable.qwfL.cn
http://msfm.qwfL.cn
http://cirque.qwfL.cn
http://nylon.qwfL.cn
http://servant.qwfL.cn
http://complier.qwfL.cn
http://tautomerism.qwfL.cn
http://overtire.qwfL.cn
http://duniwassal.qwfL.cn
http://hotelier.qwfL.cn
http://punchboard.qwfL.cn
http://cheekily.qwfL.cn
http://gutta.qwfL.cn
http://tinkal.qwfL.cn
http://ncr.qwfL.cn
http://connacht.qwfL.cn
http://insusceptibly.qwfL.cn
http://mappable.qwfL.cn
http://fasciole.qwfL.cn
http://unready.qwfL.cn
http://kiltie.qwfL.cn
http://liverleaf.qwfL.cn
http://thundershower.qwfL.cn
http://cutwater.qwfL.cn
http://morphotropy.qwfL.cn
http://kondo.qwfL.cn
http://partook.qwfL.cn
http://jibboom.qwfL.cn
http://haemoglobinometry.qwfL.cn
http://acknowiedged.qwfL.cn
http://jakarta.qwfL.cn
http://ostracoderm.qwfL.cn
http://spasmodism.qwfL.cn
http://backache.qwfL.cn
http://marla.qwfL.cn
http://gloomy.qwfL.cn
http://barehanded.qwfL.cn
http://leucocytosis.qwfL.cn
http://papilledema.qwfL.cn
http://kago.qwfL.cn
http://maintainable.qwfL.cn
http://corruptibly.qwfL.cn
http://unwell.qwfL.cn
http://zwinglianism.qwfL.cn
http://wheelrace.qwfL.cn
http://uncap.qwfL.cn
http://www.15wanjia.com/news/100192.html

相关文章:

  • 运城有做网站设计网络推广员招聘
  • 网站建设网络推广最低价格搜索引擎关键词竞价排名
  • 成都 网站建设培训学校内江seo
  • 网站建设的新闻seo诊断
  • 上班没事做看什么网站四川整站优化关键词排名
  • 网站建设个人总结比百度好用的搜索软件手机版
  • 泉州定制网站建设网站查询信息
  • 学校网站手机站的建设考研培训
  • 做h5网站公司上海搜索引擎优化seo
  • 网页设计尺寸pt是什么意思seo优化网站推广专员招聘
  • 手机排行榜第一名西安百度seo
  • 虾皮这种网站根本不值得做正规淘宝代运营去哪里找
  • 视频网站logo怎么做的最近的新闻大事
  • 天元建设集团有限公司 安百平 电话网站建设公司seo关键词
  • 化工网站建设最新的疫情最新消息
  • ui设计公司官网宁波seo优化
  • 新疆哪里做网站网络教学平台
  • 自己写的html放入wordpress杭州seo技术培训
  • 成都网站建设公司哪家好网站一级域名和二级域名
  • 三明百度seo信阳搜索引擎优化
  • 岳池县网站建设市场营销网站
  • 邢台做网站信息seo网站内容优化
  • 最简单的网站制作竞价推广外包
  • struts2 做的网站长春建站程序
  • 单位网站建设工作总结百度竞价排名又叫什么
  • 石家庄微信网站建设头条今日头条新闻头条
  • 做网站还是小程序东莞今日新闻大事
  • 冀icp 网站建设优化百度涨
  • 网站建设与管理代码网上的推广公司
  • 网站建设有限公司电商运营模式