matlab 求解 f(x)=x(x+1)(x+2)(x+3)(x+4)...(x+n-2)(x+n-1)(x+n)的导数;
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
分析代码结果
可以看出来
结果为
matlab 求解 f(x)=x(x+1)(x+2)(x+3)(x+4)...(x+n-2)(x+n-1)(x+n)的导数;的更多相关文章
- matlab 求解线性规划问题
线性规划 LP(Linear programming,线性规划)是一种优化方法,在优化问题中目标函数和约束函数均为向量变量的线性函数,LP问题可描述为: minf(x):待最小化的目标函数(如果问题本 ...
- fslove - Matlab求解多元多次方程组
fslove - Matlab求解多元多次方程组 简介: 之前看到网上的一些资料良莠不齐,各种转载之类的,根本无法解决实际问题,所以我打算把自己的学到的总结一下,以实例出发讲解fsolve. 示例如下 ...
- 用Matlab求解微分方程
用Matlab求解微分方程 解微分方程有两种解,一种是解析解,一种是数值解,这两种分别对应不同的解法 解析解 利用dsolve函数进行求解 syms x; s = dsolve('eq1,eq2,.. ...
- MATLAB求解代数方程、微分方程的一些常用指令
MATLAB版本:R2015b 1.求解符号矩阵的行列式.逆.特征值.特征向量 A = sym('[a11, a12; a21, a22]');deltaA = det(A)invA = inv(A) ...
- MATLAB求解二重积分案例
凯鲁嘎吉 - 博客园 http://www.cnblogs.com/kailugaji/ 定积分解决的是一维连续量求和的问题,而解决多维连续量的求和问题就要用到重积分了.重积分是建立在定积分的基础上的 ...
- yalmip + lpsolve + matlab 求解混合整数线性规划问题(MIP/MILP)
最近建立了一个网络流模型,是一个混合整数线性规划问题(模型中既有连续变量,又有整型变量).当要求解此模型的时候,发现matlab优化工具箱竟没有自带的可以求解这类问题的算法(只有bintprog求解器 ...
- MATLAB求解常微分方程:ode45函数与dsolve函数
ode45函数无法求出解析解,dsolve可以求出解析解(若有),但是速度较慢. 1. ode45函数 ①求一阶常微分方程的初值问题 [t,y] = ode45(@(t,y)y-2*t/y, ...
- MATLAB求解非线性方程组
matlab中有专门的solve函数来解决方程组的(a-x)^2+(b-y)^2=e^2(C-x)^2+(D-y)^2=v^2已知a,b,c,d,e,v 值求解 X,Y 请问用 matlab 如何写, ...
- matlab 求解 Ax=B 时所用算法
x = A\B; x = mldivide(A, B); matlab 在这里的求解与严格的数学意义是不同的, 如果 A 接近奇异,matlab 仍会给出合理的结果,但也会提示警告信息: 如果 A 为 ...
- [Matlab]求解线性方程组
转自:http://silencethinking.blog.163.com/blog/static/911490562008928105813169/ AX=B或XA=B在MATLAB中,求解线性方 ...
随机推荐
- debian 新安装备忘
change resource https://www.cnblogs.com/devzyh/p/12670194.html 安装sougou输入法,并配置好.重启. https://www.cnbl ...
- C# 通过程序执行svn更新或提交更改
实现方法: private static void RunBat(string program, string parm) { try { Process proc = new Process(); ...
- 微信支付模式二java
这个星期写了下微信支付模式二,在这里进行下整理 微信支付官方文档 1. 需要的配置..具体看下面的链接. https://pay.weixin.qq.com/wiki/doc/api/native.p ...
- python 安装redis,rediscluster
首先看下pip版本,过低版本会出问题 [root@test rpm]# pip -V pip 20.3.4 from /usr/lib/python2.7/site-packages/pip (pyt ...
- docker登录Ubuntu出现error storing credentials - err: exit status 1, out: `Cannot autolaunch D-Bus without X11 $DISPLAY`的解决方法
命令行登录docker时,在Ubuntu 18.04下可能会出现 error storing credentials - err: exit status 1, out: `Cannot autola ...
- selenium grid4.0+分布式的部署配置(hub/node方式)
一.grid安装 本文已jar包的方式讲解,访问并下载jar包:Releases · SeleniumHQ/selenium · GitHub 二.grid配置 假设主机:10.1.5.219,从机: ...
- Vue 数组响应
响应渲染 在Vue中,被渲染的数据都是响应式的,即Vue实例中进行改变页面中也会跟着改变: <body> <div id="app"> <p>{ ...
- 5.mysql的explain的分析
执行分析: 1.id 含义:表示查询的子句或者操作表的顺序 三种情况:id 相同,执行的顺序由上到下: id不同,id越大优先级越高,越先执行: id相同不相同同时存在: 2.select_type ...
- 如何在网页打开CAD,DWG文件,(在线CAD)在线CAD平台,H5前端显示CAD,网页CAD
简介 提示:目前提供两种在网页中浏览编辑CAD图纸方案,详细说明见:https://help.mxdraw.com/?pid=46 提示:MxDraw云图在线API教程:https://demo.mx ...
- 解决python 操作 hbase报错:TTransportException(type=4,message=’TSocket read 0 bytes’)
```text# 解决报错:hbase报错TTransportException(type=4,message='TSocket read 0 bytes')这种情况一般协议问题和服务端没开启,如果服 ...