• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

matlab 求解 f(x)=x(x+1)(x+2)(x+3)(x+4)...(x+n-2)(x+n-1)(x+n)的导数;

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

matlab 求解 f(x)=x(x+1)(x+2)(x+3)(x+4)...(x+n-2)(x+n-1)(x+n)的导数;

问题的提出


问题

代码求解

    clc; clear; close all;
    filename=\'how10.txt\';
    syms x; % be careful performance issue.
    fileID = fopen(filename, \'w\');
    str="x";
    f=str2sym(str);
    fprintf(fileID,\'%s\r\n\',string(f));
    result=diff(f,x);
    fprintf(fileID,\'%s\r\n\',string(result));
    ff=matlabFunction(result);
    fprintf(fileID,\'%d\r\n\',1);
    fprintf(fileID,\'\r\n\');
    for i = 1:10
        newstr="*(x+"+int2str(i)+")";
        str=str+newstr;
        f=str2sym(str);
        fprintf(fileID,\'%s\r\n\',string(f));
        result=diff(f,x);
        fprintf(fileID,\'%s\r\n\',string(result));
        ff=matlabFunction(result);
        fprintf(fileID,\'%f\r\n\',ff(0));
        fprintf(fileID,\'\r\n\');
    end

代码输出

x 原函数
1 导函数
1

x*(x + 1) 原函数
2*x + 1 导函数
1.000000

x*(x + 1)(x + 2)
(x + 1)
(x + 2) + x*(x + 1) + x*(x + 2)
2.000000

x*(x + 1)(x + 2)(x + 3)
x*(x + 1)(x + 2) + x(x + 1)(x + 3) + x(x + 2)(x + 3) + (x + 1)(x + 2)*(x + 3)
6.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)
x
(x + 1)(x + 2)(x + 3) + x*(x + 1)(x + 2)(x + 4) + x*(x + 1)(x + 3)(x + 4) + x*(x + 2)(x + 3)(x + 4) + (x + 1)(x + 2)(x + 3)*(x + 4)
24.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)
x*(x + 1)(x + 2)(x + 3)(x + 4) + x(x + 1)(x + 2)(x + 3)(x + 5) + x(x + 1)(x + 2)(x + 4)(x + 5) + x(x + 1)(x + 3)(x + 4)(x + 5) + x(x + 2)(x + 3)(x + 4)(x + 5) + (x + 1)(x + 2)(x + 3)(x + 4)*(x + 5)
120.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)
x
(x + 1)(x + 2)(x + 3)(x + 4)(x + 5) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 6) + x*(x + 1)(x + 2)(x + 3)(x + 5)(x + 6) + x*(x + 1)(x + 2)(x + 4)(x + 5)(x + 6) + x*(x + 1)(x + 3)(x + 4)(x + 5)(x + 6) + x*(x + 2)(x + 3)(x + 4)(x + 5)(x + 6) + (x + 1)(x + 2)(x + 3)(x + 4)(x + 5)*(x + 6)
720.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)
(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 7) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 6)(x + 7) + x(x + 1)(x + 2)(x + 3)(x + 5)(x + 6)(x + 7) + x(x + 1)(x + 2)(x + 4)(x + 5)(x + 6)(x + 7) + x(x + 1)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7) + x(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)*(x + 7)
5040.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)
(x + 1)
(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 8) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 7)(x + 8) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 6)(x + 7)(x + 8) + x*(x + 1)(x + 2)(x + 3)(x + 5)(x + 6)(x + 7)(x + 8) + x*(x + 1)(x + 2)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8) + x*(x + 1)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8) + x*(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)
40320.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)
x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 9) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 8)(x + 9) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 7)(x + 8)(x + 9) + x(x + 1)(x + 2)(x + 3)(x + 4)(x + 6)(x + 7)(x + 8)(x + 9) + x(x + 1)(x + 2)(x + 3)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9) + x(x + 1)(x + 2)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9) + x(x + 1)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9) + x(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9) + (x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)*(x + 9)
362880.000000

x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10)
x
(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 10) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 9)(x + 10) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 8)(x + 9)(x + 10) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 7)(x + 8)(x + 9)(x + 10) + x*(x + 1)(x + 2)(x + 3)(x + 4)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10) + x*(x + 1)(x + 2)(x + 3)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10) + x*(x + 1)(x + 2)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10) + x*(x + 1)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10) + x*(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)(x + 10) + (x + 1)(x + 2)(x + 3)(x + 4)(x + 5)(x + 6)(x + 7)(x + 8)(x + 9)*(x + 10)
3628800.000000

分析代码结果

可以看出来
结果为


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DelphiXE中String、ANSIString、TBytes之间的转换发布时间:2022-07-18
下一篇:
转: 加壳原理与简单实现加壳(delphi源码)发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap