主要内容

简化Symbolic Expressions Using Live Editor Task

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.

简化a Symbolic Expression

简化the expression i e - i x - e i x e - i x + e i x

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储藏xexpr.进入当前的工作区。

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.

简化a Polynomial Fraction

简化the polynomial fraction ( x 2 - 1 ) ( x + 1 ) x 2 - 2 x + 1

将多项式分数声明为符号表达。

expr.2 = ((x^2 - 1)*(x + 1))/(x^2 - 2*x +1);

选择the symbolic expressionexpr.2from the workspace and specify the simplification method as简化fraction

选择theExpandoption to return the numerator and denominator of the simplified fraction in expanded form.

重写一个表达式完全不同rent Form

改写the trigonometric function 晒黑 ( x ) in terms of the sine function.

Declare 晒黑 ( x ) as a symbolic expression.

expr.3 = tan(x);

选择the symbolic expressionexpr.3from the workspace and specify the simplification method as改写。Choosesinto rewrite 晒黑 ( x ) in terms of the sine function.

Expand a Logarithmic Expression

Expand the expression l o g ( x 3 e x 2 ) using the logarithmic identities.

将对数表达声明为符号表达式。

expr.4 = log(x^3*exp(x)/2);

选择the symbolic expressionexpr.4from the workspace and specify the simplification method asExpand。By default, the symbolic variablexinexpr.4is complex when it is initially created. TheExpand方法不简化输入表达式,因为对数身份对变量的复杂值无效。要应用方便但并不总是保持所有变量值,请选择Ignore analytic constraints选项。

简化the Sum of Two Integral Expressions

简化the sum of two integral expressions: a b x f ( x ) d x + a b g ( y ) d y

首先,定义 a b as symbolic variables, and f ( x ) g ( y ) 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.5from the workspace and specify the simplification method asCombine。Chooseas 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:

由于底层代码现在是实时脚本的一部分,因此您可以继续使用任务创建的变量进行进一步处理。例如,定义函数 f ( x ) g ( x ) as f ( x ) = x g ( x ) = cos ( x ) 。Evaluate the integrals insimpleifiedexpr3.by substituting these functions.

See Also

Live Editor Tasks

Functions

相关话题