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中,求解线性方 ...
随机推荐
- home条 防止误碰
某些界面需要隐藏home条,防止误触导致页面返回 - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { return UIRectEd ...
- (0303)《计算机体系结构 量化研究方法》PDF
(01) https://blog.csdn.net/konghhhhh/article/details/106828402 存储器相关 (1) https://blog.csdn.net/iva_ ...
- Linux shell 获取路径、文件名、文件后缀
以 make 文件为例: file=/usr/bin/make [root@CentOs7]# echo ${file%*/} /usr/bin/make [root@CentOs7]# echo $ ...
- 无需联网,一键永久激活所有Windows/Office
对于 Windows 激活工具,大家可能了解不多,熟悉的比如小马激活工具,因为激活工具从来都是病毒高发区,各种工具混在一起,一不小心,电脑就中招了. 今天介绍一款不一样的. R@1n ReBirth ...
- 问题记录_IDEA启动报错:Failed to create JVM. JVM Path
问题记录_IDEA启动报错:Failed to create JVM. JVM Path 起因 下午写代码的时候感觉IDEA有点卡,不应该啊,我16G咋回卡呢,分配的内存也不小,于是又去加大内存分配, ...
- eval()
s='12*2'd=eval(s)#字符串运算函数print(d) 结果: 24
- windows下BAT实现守护进程
通过bat守护特定exe @echo off :start choice /t 5 /d y /n >nul tasklist|find /i "程序名称.exe" if E ...
- MxDraw云图平台 2022.08.24更新
SDK开发包下载地址: https://www.mxdraw.com/ndetail_30187.html 1. 增加对像扩展数据功能 2. 增加CAD GIS使用功能 https://www.mxd ...
- 百题计划-5 codeforces 651 div2 D. Odd-Even Subsequence 二分检查
https://codeforces.com/contest/1370/problem/D 二分检查 #include<bits/stdc++.h> using namespace std ...
- mysql 修改字符集相关操作
修改某个表字段的字符集 ALTER TABLE apply_info MODIFY member_name varchar(128) CHARACTER SET utf8mb4; 查看某个库的字符集类 ...