计算极限
计算函数的极限f(x)=(x^ 3 + 5)/(x^ 4 + 7),x趋于零
syms x
limit((x^3 + 5)/(x^4 + 7))
limit((x - 3)/(x-1),1)
ans =
NaN
在编程和计算机科学中,NaN 是 "Not a Number" 的缩写,表示一个未定义或不可表示的数值结果。这种情况通常出现在涉及不确定或无意义的数学运算时。 例如,以下情况可能导致 NaN 的结果: 1.任何数除以零(0)。 2.无穷大除以无穷大。 3.无穷大减去无穷大。 4.0乘以无穷大。 不存在的数学运算结果,如负数的平方根(在实数范围内)。
验证极限的基本属性
syms x
f = (3*x + 5)/(x-3);
g = x^2 + 1;
l1 = limit(f, 4)
l2 = limit (g, 4)
lAdd = limit(f + g, 4)
lSub = limit(f - g, 4)
lMult = limit(f*g, 4)
lDiv = limit (f/g, 4)
l1 =
17
l2 =
17
lAdd =
34
lSub =
0
lMult =
289
lDiv =
1
左右限位
f = (x - 3)/abs(x-3);
ezplot(f,[-1,5])
%ezplot 函数绘制函数 f 在区间 [−1,5] 上的图像
l = limit(f,x,3,'left')
% x=3 处的左极限
r = limit(f,x,3,'right')
微分(导数)
syms t
f = 3*t^2 + 2*t^(-2);
diff(f)
基本规则的验证
syms x
y = exp(x)
diff(y)
y = x^9
diff(y)
y = sin(x)
diff(y)
y = tan(x)
diff(y)
y = cos(x)
diff(y)
y = log(x)
diff(y)
y = log10(x)
diff(y)
y = sin(x)^2
diff(y)
y = cos(3*x^2 + 2*x + 1)
diff(y)
y = exp(x)/sin(x)
diff(y)
y =
exp(x)
ans =
exp(x)
y =
x^9
ans =
9*x^8
y =
sin(x)
ans =
cos(x)
y =
tan(x)
ans =
tan(x)^2 + 1
y =
cos(x)
ans =
-sin(x)
y =
log(x)
ans =
1/x
y =
log(x)/log(10)
ans =
1/(x*log(10))
y =
sin(x)^2
ans =
2*cos(x)*sin(x)
y =
cos(3*x^2 + 2*x + 1)
ans =
-sin(3*x^2 + 2*x + 1)*(6*x + 2)
y =
exp(x)/sin(x)
ans =
exp(x)/sin(x) - (exp(x)*cos(x))/sin(x)^2
高阶导数
f = x*exp(-3*x);
diff(f, 2)
解微分方程
s = dsolve('Dy = 5*y')
积分
syms x n
int(cos(x))
int(exp(x))
int(log(x))
int(x^-1)
int(x^5*cos(5*x))
pretty(int(x^5*cos(5*x)))
int(x^-5)
int(sec(x)^2)
pretty(int(1 - 10*x + 9 * x^2))
int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2)
pretty(int((3 + 5*x -6*x^2 - 7*x^3)/2*x^2))
定积分
int(x, 4, 9)
计算在x轴和曲线y = x 3 -2x + 5以及纵坐标x = 1和x = 2之间所包围的面积
f = x^3 - 2*x +5;
a = int(f, 1, 2)
display('Area: '), disp(double(a));
多项式
p = [1 7 0 -5 9];
%p(x) = 1x^4 + 7x^3 + 0x^2 - 5x + 9
polyval(p,4)
%计算多项式 p(x) 在 x = 4 时的值
多项式的根
p = [1 7 0 -5 9];
r = roots(p)
多项式拟合
x = [1 2 3 4 5 6]; y = [5.5 43.1 128 290.7 498.4 978.67]; %data
p = polyfit(x,y,4) %得到多项式
% 计算一个较小范围内的 polyfit 估计值,
% 并根据实际数据绘制出估计值以供比
x2 = 1:.1:6;
y2 = polyval(p,x2);
plot(x,y,'o',x2,y2)
grid on
%开启图形窗口中网格显示