You can interactively simplify or rearrange symbolic expressions using the简化Symbolic Expressiontask in the Live Editor. For more information on Live Editor tasks, seeAdd Interactive Tasks to a Live Script。
This example shows you how to simplify or rearrange various symbolic expressions into the particular form you require by choosing the appropriate method.
简化the expression 。
First, go to theHometab, and create a live script by clickingNew Live Script。Define the symbolic variablex
和declare the expression as a symbolic expression.
symsx; expr = 1i*(exp(-1i*x) - exp(1i*x))/(exp(-1i*x) + exp(1i*x));
在里面Live Editortab, run the code by clickingRun储藏x
和expr.
进入当前的工作区。
Next, open the简化Symbolic Expressiontask by selectingTask > Simplify Symbolic Expression在里面Live Editortab. Select the symbolic expressionexpr.
from the workspace and specify the simplification method as简化
。选择Minimum
用于计算工作(最快计算时间)。
To get a simpler expression, change the computational effort toMedium
。
To experiment with simplifying symbolic expressions, you can repeat the previous steps for other symbolic expressions and simplification methods. You can run the following examples by adding the code to the existing live script or a new live script.
简化the polynomial fraction 。
将多项式分数声明为符号表达。
expr.2 = ((x^2 - 1)*(x + 1))/(x^2 - 2*x +1);
选择the symbolic expressionexpr.2
from the workspace and specify the simplification method as简化fraction
。
选择theExpandoption to return the numerator and denominator of the simplified fraction in expanded form.
改写the trigonometric function in terms of the sine function.
Declare as a symbolic expression.
expr.3 = tan(x);
选择the symbolic expressionexpr.3
from the workspace and specify the simplification method as改写
。Choosesin
to rewrite
in terms of the sine function.
Expand the expression using the logarithmic identities.
将对数表达声明为符号表达式。
expr.4 = log(x^3*exp(x)/2);
选择the symbolic expressionexpr.4
from the workspace and specify the simplification method asExpand
。By default, the symbolic variablex
inexpr.4
is complex when it is initially created. TheExpand
方法不简化输入表达式,因为对数身份对变量的复杂值无效。要应用方便但并不总是保持所有变量值,请选择Ignore analytic constraints选项。
简化the sum of two integral expressions: 。
首先,定义
和
as symbolic variables, and
和
as symbolic functions. Use the㈡
函数来表示积分。
symsabf(x)g(y)expr.5 = int(x*f(x),x,a,b) + int(g(y),y,a,b);
选择the symbolic expressionexpr.5
from the workspace and specify the simplification method asCombine
。Choose㈡
as the function to combine.
To view the code that a task used, clickat the bottom of the task window. The task displays the code block, which you can cut and paste to use or modify later in the existing script or a different program. For example:
由于底层代码现在是实时脚本的一部分,因此您可以继续使用任务创建的变量进行进一步处理。例如,定义函数
和
as
和
。Evaluate the integrals insimpleifiedexpr3.
by substituting these functions.