www.jykt.net > MATLAB求级数1+1/2+1/3+1/4+L+1/n+l大于5时累加的...

MATLAB求级数1+1/2+1/3+1/4+L+1/n+l大于5时累加的...

a=0; i=1; while a

n=100; c=[1:n]; sn=sum(1./c);

s=sum(1./(1:100)) %结果是5.1874

应该是级数求和,比如:% By lyqmath clc; clear all; close all; syms n expr = 1/n; r = symsum(expr, n, 1, inf)结果 r = Inf >>

简单编写一个function函数: function [PI,e]=mypi(n) i=1:n; PI=4*sum((-1).^(i-1)*1./(2*i-1)); e=pi-PI; 命令窗口调用: >> [pi,e]=mypi(100) pi = 3.1316 e = 0.0100 >>

sum=0 n=1 while 1/(2*n-1)>1e-6 sum=sum+1/(2*n-1)*((-1)^(n-1)); n=n+1; end n sum*4

taylor()函数可用于任意点处任意次数的泰勒展开,参考代码及结果: >> syms x; >> taylor(1/x^2,5,5) ans = (3*(x - 5)^2)/625 - (2*x)/125 - (4*(x - 5)^3)/3125 + (x - 5)^4/3125 + 3/25

s=0; n=1; while 1 s1=s; s = (-1)^(n-1)* (1/ factorial(n)); n = n+1; if (abs(s1-s)

你好,很简单,只要用taylor函数就可以 syms x2 x1 d1 d2 L y=L^2/(L+x1*d1+x2*d2)^2; f = taylor(y) f = L^2/(L + d2*x2)^2 - (2*L^2*d1*x1)/(L + d2*x2)^3 + (3*L^2*d1^2*x1^2)/(L + d2*x2)^4 - (4*L^2*d1^3*x1^3)/(L + d2*x2)^5 + (5*L^2*d1^...

>> syms n; >> symsum(1/n^2,n,1,inf) ans = pi^2/6

网站地图

All rights reserved Powered by www.jykt.net

copyright ©right 2010-2021。
www.jykt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com