开平方根matlab,科学网—数值分析----平方根法matlab程序 - 殷春武的博文

%%%程序编写者  西北工业大学自动化学院    Email: yincwxa2013@mail.nwpu.edu.cn

%%  All rights reserved

clear

clc

a=input('输入对称正定矩阵a=')

b=input('输入自由项b=')

n=length(a(:,1));

for k=1:n

if (det(a(1:k,1:k))<=0)

input('矩阵不是正定矩阵,请重新运行程序')

end

end

%%%%%%%%%%%分解A=L*L'

for i=1:n

t=0;

for s=1:i-1

t=t+L(i,s)^2;

end

L(i,i)=sqrt(a(i,i)-t);

for k=i+1:n

tt=0;

for s=1:i-1

tt=tt+L(i,s)*L(k,s);

end

L(k,i)=(a(k,i)-tt)/L(i,i);

end

end

%%%%%%%%%%%%%%%分解AX=b为Ly=b  Lx=y

%%%%%%%%%%求y

for i=1:n

ttt=0;

for k=1:i-1

ttt=ttt+L(i,k)*y(k);

end

y(i)=(b(i)-ttt)/L(i,i);

end

%%%%%%%%%%求x

for i=n:-1:1

tttt=0;

for k=i+1:n

tttt=tttt+L(k,i)*x(k);

end

x(i)=(y(i)-tttt)/L(i,i);

end

x

转载本文请联系原作者获取授权,同时请注明本文来自殷春武科学网博客。

链接地址:http://blog.sciencenet.cn/blog-748007-751153.html

上一篇:数值分析-----牛顿插值法matlab程序

下一篇:数值分析----三对角方程组的追赶法matlab程序

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值