此示例概述了符号数学工具箱,它为计算和分析数学提供了一套完整的工具。据/p>
这个例子包括据/p>
变量,表达式,功能和方程据/p>
替换和解决据/p>
简化和操纵据/p>
微积分(分化,集成,限制,系列)据/p>
微分方程据/p>
线性代数据/p>
图形据/p>
有关详细信息,请参阅据一种href="//www.tatmou.com/es/help/symbolic/getting-started-with-symbolic-math-toolbox.html" class="a">开始使用符号数学工具箱据/a>。有关记录和共享您的数学的更多详细信息据一种href="//www.tatmou.com/es/help/matlab/matlab_prog/create-live-scripts.html" class="a">在Live Editor中创建实时脚本据/a>。据/p>
MATLAB中的变量是默认的双精度。符号数学工具箱通过允许您以精确的符号形式表达数字来扩展它据一种href="//www.tatmou.com/es/help/symbolic/sym.html" class="a">
轶事据/code>使用可变精度使用据一种href="//www.tatmou.com/es/help/symbolic/vpa.html" class="a">
VPA.据/code>。据/p>
PI / 6 + PI / 4据/pre>
ANS = 1.3090.据/pre>
sym(pi / 6)+ sym(pi / 4)据/pre>
ans =.据D.一世v class="code_responsive">
VPA(PI / 6)+ VPA(PI / 4)据/pre>
ans =.据S.pan class="inlineequation">
符号变量可以用于数学表达式,函数和方程,包括三角,对数,指数和特殊功能。您可以创建符号表达式并对它们执行数学计算。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>y据/span>log(x)+ exp(y)据/pre>
ans =.据S.pan class="inlineequation">
您还可以创建分段功能。据/p>
Y(x)=分段(x <0,-1,x> 0,1)据/pre>
Y(x)=据D.一世v class="code_responsive">
创建和评估据一种href="//www.tatmou.com/es/help/symbolic/create-symbolic-functions.html" class="a">创建符号函数据/a>。找到价值据CO.D.E.Class="literal">F据/code>在据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">f(x)据/span>f(x)= x ^ 4-2 * x ^ 3 + 6 * x ^ 2-2 * x + 10据/pre>
f(x)=据S.pan class="inlineequation">
F(-5)据/pre>
ans =.据S.pan class="inlineequation">
找到行之间的交叉点据S.pan class="inlineequation">
和据S.pan class="inlineequation">
使用据一种href="//www.tatmou.com/es/help/symbolic/solve.html" class="a">
解决据/code>。使用==运算符等同行。据/p>
Syms.据S.pan style="color:#A020F0">y1.据/span>Y2.据/span>Y1 = x + 3;Y2 = 3 * x;解决(y1 == y2)据/pre>
ans =.据D.一世v class="code_responsive">
制作据一种href="//www.tatmou.com/es/help/symbolic/sym.assume.html" class="a">
认为据/code>在符号变量上。有4个解决方案金宝搏官方网站据S.pan class="inlineequation">
,两个真实和两个复杂。假如说据S.pan class="inlineequation">
是真实的据S.pan class="inlineequation">
,只有一个解决方案。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>解决(x ^ 4 == 1)据/pre>
ans =.据D.一世v class="code_responsive">
假设(x,据S.pan style="color:#A020F0">'真实的'据/span>)AccormeAlso(x> 0)假设(x)据/pre>
ans =.据S.pan class="inlineequation">
解决(x ^ 4 == 1)据/pre>
ans =.据S.pan class="inlineequation">
假设(x,据S.pan style="color:#A020F0">'清除'据/span>)据/pre>
符号数学工具箱支持使用表达式的任何部分使用的数学函数金宝app的评估据一种href="//www.tatmou.com/es/help/symbolic/subs.html" class="a"> 用符号变量进行替换。代替据S.pan class="inlineequation">
进入据S.pan class="inlineequation">
替换多个值。例如,评估据S.pan class="inlineequation">
通过代替据S.pan class="inlineequation">
。据/p>
subs据/code>。您可以替代数字值,其他符号变量或表达式,向量或矩阵。符号数学工具箱支持使用等式的方程和系统使用金宝app据一种href="//www.tatmou.com/es/help/symbolic/solve.html" class="a">
解决据/code>。它支持金宝app求解多元方程,解决不平等和解决假设。金宝搏官方网站通过使用可变精度算术,可以以高精度象征性地或数字地找到解决方案。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>XO.据/span>子(x ^ 2 + 1,x,xo-1)据/pre>
ans =.据S.pan class="inlineequation">
Syms.据S.pan style="color:#A020F0">一种据/span>B.据/span>C据/span>子(COS(a)+ sin(b) - exp(2 * c),[a b c],[pi / 2 pi / 4 -1])据/pre>
ans =.据D.一世v class="code_responsive">
创建和解决方程。找到零的据S.pan class="inlineequation"> 。据/p>
解决(9 * x ^ 2 - 1 == 0)据/pre>
ans =.据D.一世v class="code_responsive">
解决一般二次方程据S.pan class="inlineequation"> 并使用潜艇来评估该解决方案据S.pan class="inlineequation"> 。据/p>
eqn = a * x ^ 2 + b * x + c == 0;SOL =解决(EQN)据/pre>
sol =据D.一世v class="code_responsive">
潜艇(Sol,[A B C],[9 0 -1])据/pre>
ans =.据D.一世v class="code_responsive">
当需要精确的结果或高精度时,符号或具有可变精度算术的求解方程。图的图表据S.pan class="inlineequation"> 靠近它的根。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>f(x)据/span>假设(x> 0)f(x)= 6 * x ^ 7-2 * x ^ 6 + 3 * x ^ 3-8;Fplot(F)XLIM([ - 10 10])Ylim([ - 1e3 1e3])据/pre>
双层醇=根([6 -2 0 0 3 0 0 -8])据S.pan style="color:#228B22">%双精度据/span>
DOUBLESOL =.据S.pan class="emphasis">7×1复合物据/em>1.0240 + 0.0000i 0.7652 + 0.8319i 0.7652 - 0.8319i -0.8808 + 0.5043i -0.8808 - 0.5043i -0.2297 + 0.9677i -0.2297 - 0.9677i据/pre>
Symssol =解决(f)据S.pan style="color:#228B22">% 精确的。根对象存储零符号计算的零据/span>
Symssol =.据D.一世v class="code_responsive">
vpasol = vpasolve(f)据S.pan style="color:#228B22">%可变精度据/span>
vpasol =据D.一世v class="code_responsive">
符号数学工具箱支持金宝app据一种href="//www.tatmou.com/es/help/symbolic/formula-manipulation-and-simplification.html" class="a">公式操作和简化据/a>数学函数。大多数数学表达式可以用不同的方式表示,但是数学上等同的形式,并且符号数学工具箱支持许多操作,包括分解或扩展表达式,组合术语,重写或重新排列的表达式,并基于假设简化。金宝app据/p>
执行多项式乘法并简化结果,显示据S.pan class="inlineequation"> 简化了据S.pan class="inlineequation"> 。据/p>
简化((x-1)*(x + 1)*(x ^ 2 + x + 1)*(x ^ 2 + 1)*(x ^ 2 - x + 1)*(x ^ 4 - x ^ 2+ 1))据/pre>
ans =.据S.pan class="inlineequation">
例如,将三角识别应用于简化据S.pan class="inlineequation"> 。据/p>
结合(2 * SIN(x)* cos(x)+(1-cos(2 * x))/ 2 + cos(x)^ 2,据S.pan style="color:#A020F0">'sincos'据/span>)据/pre>
ans =.据S.pan class="inlineequation">
因子或扩大多变量多项式。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>y据/span>因子(y ^ 6-x ^ 6)据/pre>
ans =.据S.pan class="inlineequation">
f(x)=(x ^ 3 + 7);展开(f(y-1))据/pre>
ans =.据S.pan class="inlineequation">
找到功能组合物据S.pan class="inlineequation"> 。据/p>
f(x)= sqrt(log(x));g(x)= sqrt(1-x);h = compose(g,f,x)据/pre>
h(x)=据S.pan class="inlineequation">
符号数学工具箱具有一整套应用数学的微积分工具。它可以执行多变量符号集成和差异化。它可以生成,操纵和执行序列的计算。据/p>
找到衍生物据S.pan class="inlineequation"> 。据/p>
差异(SIN(x))据/pre>
ans =.据S.pan class="inlineequation">
找到衍生物据S.pan class="inlineequation"> 使用链规则。据/p>
差异(x ^ 2 + sin(2 * x ^ 4)+ 1,x)据/pre>
ans =.据S.pan class="inlineequation">
找到不定的积分据S.pan class="inlineequation"> 为了据S.pan class="inlineequation"> 。据/p>
int(exp(-x ^ 2/2),x)据/pre>
ans =.据D.一世v class="code_responsive">
找到明确的积分据S.pan class="inlineequation"> 为了据S.pan class="inlineequation"> 从据S.pan class="inlineequation"> 到据S.pan class="inlineequation"> 。据/em>
int(x * log(1 + x),0,1)据/pre>
ans =.据D.一世v class="code_responsive">
显示据S.pan class="inlineequation"> 在据S.pan class="inlineequation"> 通过计算泰勒系列扩展据S.pan class="inlineequation"> 为了据S.pan class="inlineequation"> 围绕据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>T =泰勒(SIN(x)/ x)据/pre>
t =据D.一世v class="code_responsive">
子(T,x,0)据/pre>
ans =.据S.pan class="inlineequation">
显示据S.pan class="inlineequation"> 是不连续的据S.pan class="inlineequation"> 通过表示左和右限制不等于。据S.pan class="inlineequation"> 。据/p>
限制(tan(x),x,pi / 2,据S.pan style="color:#A020F0">'剩下'据/span>)据/pre>
ans =.据S.pan class="inlineequation">
限制(tan(x),x,pi / 2,据S.pan style="color:#A020F0">'对'据/span>)据/pre>
ans =.据S.pan class="inlineequation">
限制(tan(x),x,pi / 2)据/pre>
ans =.据S.pan class="inlineequation">
符号数学工具箱可以分析解决系统据一种href="//www.tatmou.com/es/help/symbolic/solve-a-system-of-differential-equations.html" class="a">解决微分方程系统据/a>使用据CO.D.E.Class="literal">Dsolve.据/code>。据/p>
解决第一阶颂歌据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">一种据/span>B.据/span>Y(x)据/span>Dsolve(差异(y)== -a * y)据/pre>
ans =.据S.pan class="inlineequation">
用初始条件解决与相同的颂歌据S.pan class="inlineequation"> 。据/p>
Dsolve(差异(y)== -a * y,y(0)== b)据/pre>
ans =.据S.pan class="inlineequation">
解决耦合的一阶odes系统据S.pan class="inlineequation"> 和据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">x(t)据/span>y(t)据/span>z = dsolve(diff(x)== y,diff(y)== -x);disp([z.x; z.y])据/pre>
符号数学工具箱可以使用符号向量和矩阵。它可以计算据一种href="//www.tatmou.com/es/help/symbolic/eig.html" class="a">eig.据/code>
执行矩阵乘法据S.pan class="inlineequation"> 在哪里据S.pan class="inlineequation"> 和据S.pan class="inlineequation">
Syms.据S.pan style="color:#A020F0">一种据/span>B.据/span>C据/span>D.据/span>Syms.据S.pan style="color:#A020F0">X1据/span>X2据/span>x = [x1;x2];a = [a b;C D];b = a * x据/pre>
B =据D.一世v class="code_responsive">
找到A的决定因素。据/p>
DET(a)据/pre>
ans =.据S.pan class="inlineequation">
找到A的特征值。据/p>
lambda = eig(a)据/pre>
lambda =据D.一世v class="code_responsive">
符号数学工具箱支持2D和3D中的分析绘图。金宝app据/p>
fplot(tan(x))据/pre>
绘制参数曲线据S.pan class="inlineequation"> 和据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">T.据/span>x = t * sin(5 * t);Y = T * COS(5 * T);fplot(x,y)网格据S.pan style="color:#A020F0">在据/span>
绘制3D参数曲线据S.pan class="inlineequation"> 那据S.pan class="inlineequation"> 和据S.pan class="inlineequation"> 从据CO.D.E.Class="literal">[-10,10]据/code>用虚线红线。据/p>
Syms.据S.pan style="color:#A020F0">T.据/span>XT = EXP(ABS(T)/ 10)。* SIN(5 * ABS(T));yt = exp(abs(t)/ 10)。* cos(5 * abs(t));zt = t;h = fplot3(xt,yt,zt,[-10,10],据S.pan style="color:#A020F0">'--r'据/span>);据/pre>
绘制3D表面据S.pan class="inlineequation"> 。据/p>
Syms.据S.pan style="color:#A020F0">X据/span>y据/span>FSURF(SIN(x)+ cos(y))据/pre>
绘制同一表面的2D轮廓。据/p>
Fcontour(SIN(x)+ cos(y))据/pre>