拉格朗日 优美典范

%syms: good lagrange 朗格朗日好样的; %两种方式1:x=x0, eval(f1); 2:使用{x,y},{x,y} subs替换函数,属性-值的花括号(元组对)即可;
syms x1 x2 x3 x4 x x5 x6
exp = (x-x2)*(x-x3)*(x-x4)/((x1-x2)*(x1-x3)*(x1-x4))
f1 = subs(exp, {x,x1,x2,x3,x4},{0,-2,-1,1,2})
f2 = subs(exp, {x,x1,x2,x3,x4},{0,-1,-2,1,2})
f3 = subs(exp, {x,x1,x2,x3,x4},{0,1,-2,-1,2})
f4 = subs(exp, {x,x1,x2,x3,x4},{0,2,-2,-1,1})
% changed to 1~4
f1 = subs(exp, {x,x1,x2,x3,x4},{3,1,2,4,5})
f2 = subs(exp, {x,x1,x2,x3,x4},{3,2,1,4,5})
f3 = subs(exp, {x,x1,x2,x3,x4},{3,4,1,2,5})
f4 = subs(exp, {x,x1,x2,x3,x4},{3,5,1,2,4})
% gap2
f1 = subs(exp, {x,x1,x2,x3,x4},{0,-4,-2,2,4})
f2 = subs(exp, {x,x1,x2,x3,x4},{0,-2,-4,2,4})
f3 = subs(exp, {x,x1,x2,x3,x4},{0,2,-4,-2,4})
f4 = subs(exp, {x,x1,x2,x3,x4},{0,4,-4,-2,2})

%middle gap 2 - 0;
f1 = subs(exp, {x,x1,x2,x3,x4},{0,-3,-2,2,3})
f2 = subs(exp, {x,x1,x2,x3,x4},{0,-2,-3,2,3})
f3 = subs(exp, {x,x1,x2,x3,x4},{0,2,-3,-2,3})
f4 = subs(exp, {x,x1,x2,x3,x4},{0,3,-3,-2,2})
%middle gap 2 -  -1;
f1 = subs(exp, {x,x1,x2,x3,x4},{-1,-3,-2,2,3})
f2 = subs(exp, {x,x1,x2,x3,x4},{-1,-2,-3,2,3})
f3 = subs(exp, {x,x1,x2,x3,x4},{-1,2,-3,-2,3})
f4 = subs(exp, {x,x1,x2,x3,x4},{-1,3,-3,-2,2})

%middle gap 3 - 0;
f1 = subs(exp, {x,x1,x2,x3,x4},{0,-4,-3,3,4})
f2 = subs(exp, {x,x1,x2,x3,x4},{0,-3,-4,3,4})
f3 = subs(exp, {x,x1,x2,x3,x4},{0,3,-4,-3,4})
f4 = subs(exp, {x,x1,x2,x3,x4},{0,4,-4,-3,3})

!](https://img-blog.csdnimg.cn/7ef9263085a9445b8a09c0ce87db642f.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6aOe5Yeh5Y-v5pyf,size_20,color_FFFFFF,t_70,g_se,x_16)
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值