gpt4 book ai didi

matlab - 使用matlab求和系列

转载 作者:太空宇宙 更新时间:2023-11-03 19:34:59 25 4
gpt4 key购买 nike

当我用matlab写这个的时候

syms x;
f=x^3-cos(x);
g=diff(f)

输出为

g =

3*x^2+sin(x)

现在我想生成求和序列作为
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

我用谷歌搜索并找到了“symsum”命令,但是当我编写以下命令时它没有完成我需要的任务

syms k
symsum(k^2, 0, 10)
symsum(1/k^2,1,Inf)

输出为

ans = 385

ans = pi^2/6

你们能指导我如何生成产生输出的系列吗
http://upload.wikimedia.org/math/e/1/c/e1c5e8954e1e68099d77ac15ffa765a7.png

这样当我给出命令 diff(Sk);它应该产生结果或类似的结果 enter image description here

例如在 Mathematica 中我可以这样做

SummationSeries with subscript

您的协助一定会有很大的帮助。

最佳答案

我查看了 symsum 函数的帮助,你有一个非常好的例子,试试这个:

syms x;
syms k real;
symsum(x^k/sym('k!'), k, 0, inf)

此命令评估系列 enter image description here , 并且实际计算为 enter image description here .如您所见,您必须指定序列的术语及其对“k”的依赖性。然后在 symsum 命令中,您必须指定要对从 0 到 inf 的“k”求和。

例如,您可以执行以下操作:

syms x;
syms k real;
ak = (-1)^k*x^(2*k+1)/sym('(2*k+1)!');
sum_ak = symsum(ak, k, 0, inf); % gives back sin(x)
dak = diff(ak,x);
sum_dak = symsum(dak, k, 0, inf); % should give back cos(x), but does not
A5 = symsum(ak, k, 0, 5); % add only the first values of the series
DA5 = symsum(dak, k, 0, 5); % add the derivated terms of the series

您可以声明多个符号变量 uk 并将它们相加:

syms x;
syms k real;
n = 5;
for i = 0:n
eval(['syms u',num2str(i),' real;']);
end

A = cell(1,n);
for i=1:n
A{i} = u0;
for j=1:i
eval(['A{i} = A{i} + u',num2str(j),';']);
end
end
A{3} % check the value of A{i}

希望对您有所帮助,

关于matlab - 使用matlab求和系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12875692/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com