Expand expressions and simplify inputs of functions by using identities (2024)

Expand expressions and simplify inputs of functions by using identities

collapse all in page

Syntax

expand(S)

expand(S,Name,Value)

Description

example

expand(S) multiplies all parentheses in S, and simplifies inputs to functions such as cos(x + y) by applying standard identities.

example

expand(S,Name,Value) uses additional options specified by one or more name-value pair arguments. For example, specifying 'IgnoreAnalyticConstraints' as true uses convenient identities to simplify the input.

Examples

collapse all

Expand Symbolic Expression

syms xp = (x - 2)*(x - 4);expand(p)
ans =x^2 - 6*x + 8

Expand Trigonometric Expression

Expand the trigonometric expression cos(x + y). Simplify the cos function input x + y to x or y by applying standard identities.

Expand Exponential Expression

Expand e(a+b)2. Simplify the exp function input, (a + b)^2, by applying standard identities.

syms a bf = exp((a + b)^2);expand(f)
ans =exp(a^2)*exp(b^2)*exp(2*a*b)

Expand Vector of Expressions

Expand expressions in a vector. Simplify the inputs to functions in the expressions by applying identities.

syms tV = [sin(2*t), cos(2*t)];expand(V)
ans =[ 2*cos(t)*sin(t), 2*cos(t)^2 - 1]

Expand Only Arithmetic and Suppress Expansion of Functions

By default, expand both expands terms raised to powers and expands functions by applying identities that simplify inputs to the functions. Expand only terms raised to powers and suppress expansion of functions by using 'ArithmeticOnly'.

Expand (sin(3*x) - 1)^2. By default, expand will expand the power ^2 and simplify the sin input 3*x to x.

syms xf = (sin(3*x) - 1)^2;expand(f)
ans =2*sin(x) + sin(x)^2 - 8*cos(x)^2*sin(x) - 8*cos(x)^2*sin(x)^2... + 16*cos(x)^4*sin(x)^2 + 1

Suppress expansion of functions, such as sin(3*x), by setting ArithmeticOnly to true.

expand(f, 'ArithmeticOnly', true)
ans =sin(3*x)^2 - 2*sin(3*x) + 1

Simplify Log Input by Removing Constraints

Simplify the input of log function calls. By default, expand does not simplify logarithm input because the identities used are not valid for complex values of variables.

syms a b cf = log((a*b/c)^2);expand(f)
ans =log((a^2*b^2)/c^2)

Apply identities to simplify the input of logarithms by setting 'IgnoreAnalyticConstraints' to true.

expand(f,'IgnoreAnalyticConstraints',true)
ans = 2*log(a) + 2*log(b) - 2*log(c)

Input Arguments

collapse all

SInput
number | vector | matrix | array | symbolic number | symbolic variable | symbolic array | symbolic function | symbolic expression

Input, specified as a number, vector, matrix, or array, or a symbolic number, variable, array, function, or expression.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: expand(S,'ArithmeticOnly',true)

ArithmeticOnlyExpand only algebraic expressions
false (default) | true

Expand only algebraic expressions, specified as the comma-separated pair consisting of 'ArithmeticOnly' and true or false. If the value is true, the function expands the arithmetic part of an expression without expanding trigonometric, hyperbolic, logarithmic, and special functions. This option does not prevent the expansion of powers and roots.

IgnoreAnalyticConstraintsUse convenient identities for simplification
false (default) | true

Use convenient identities for simplification, specified as the comma-separated pair consisting of 'IgnoreAnalyticConstraints' and true or false.

Setting 'IgnoreAnalyticConstraints' to true can give you simpler solutions, which could lead to results not generally valid. In other words, this option applies mathematical identities that are convenient, but the results might not hold for all values of the variables. In some cases, this option can let expand return simpler results that might not be equivalent to the initial expression. See Algorithms.

Algorithms

When you use 'IgnoreAnalyticConstraints', expand applies some of these rules.

  • log(a) + log(b)=log(a·b) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

    (a·b)c=ac·bc.

  • log(ab)=b·log(a) for all values of a and b. In particular, the following equality is valid for all values of a, b, and c:

    (ab)c=ab·c.

  • If f and g are standard mathematical functions and f(g(x))=x for all small positive numbers, f(g(x))=x is assumed to be valid for all complex x.

    • log(ex)=x

    • asin(sin(x))=x, acos(cos(x))=x, atan(tan(x))=x

    • asinh(sinh(x))=x, acosh(cosh(x))=x, atanh(tanh(x))=x

    • Wk(x·ex)=x for all values of k

Version History

Introduced before R2006a

See Also

Functions

  • collect | combine | factor | horner | numden | rewrite | simplify | simplifyFraction

Live Editor Tasks

  • Simplify Symbolic Expression

Topics

  • Choose Function to Rearrange Expression
  • Simplify Symbolic Expressions
  • Simplify Symbolic Expressions Using Live Editor Task

MATLAB-Befehl

Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:

 

Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.

Expand expressions and simplify inputs of functions by using identities (1)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本 (日本語)
  • 한국 (한국어)

Contact your local office

Expand expressions and simplify inputs of functions by using identities (2024)

FAQs

How to use simplify in Matlab? ›

S = simplify( expr ) performs algebraic simplification of expr . If expr is a symbolic vector or matrix, this function simplifies each element of expr . S = simplify( expr , Name,Value ) performs algebraic simplification of expr using additional options specified by one or more Name,Value pair arguments.

What is the expand function in Matlab? ›

expand( sigObj ) converts the representation of the signal that corresponds to the Simulink. sdi. Signal object sigObj from a single signal with nonscalar sample values to a set of signals with scalar sample values: one signal, called a channel, for each element in the multidimensional sample values.

What is the symbolic toolbox expand? ›

expand (Symbolic Math Toolbox) Symbolic expansion. expand(S) writes each element of a symbolic expression S as a product of its factors. expand is most often used only with polynomials, but also expands trigonometric, exponential, and logarithmic functions.

What is the subs function in Matlab? ›

subs replaces the values in the symbolic function formula, but it does not replace input arguments of the function. formula(f) ans = a + y.

What is an example of simplify in math? ›

For example, 1/2 (x + 4) can be simplified as x/2 + 2. Let us take one more example to understand it. Example: Simplify the expression: 3/4x + y/2 (4x + 7). By using the distributive property, the given expression can be written as 3/4x + y/2 (4x) + y/2 (7).

How to solve expressions in MATLAB? ›

S = solve( eqn , var ) solves the equation eqn for the variable var . If you do not specify var , the symvar function determines the variable to solve for. For example, solve(x + 1 == 2, x) solves the equation x + 1 = 2 for x.

How do you expand a function? ›

Expanding expressions (or multiplying out) is the process by which you use the distributive property to remove parentheses from an algebraic expression. To do this, you need to multiply out the parentheses by multiplying everything outside of the parentheses by everything inside the parentheses.

What is expansion of function? ›

In mathematics, a series expansion is a technique that expresses a function as an infinite sum, or series, of simpler functions. It is a method for calculating a function that cannot be expressed by just elementary operators (addition, subtraction, multiplication and division).

How to create a mathematical function in MATLAB? ›

Create Symbolic Functions
  1. syms f(x,y) Assign a mathematical expression to f . ...
  2. f(x, y) = x^2*y. Find the value of f at (3,2) . ...
  3. ans = 18. Symbolic functions accept array inputs. ...
  4. ans = [ 3, 16, 45, 96, 175] ...
  5. dfx(x,y) = 2*x*y.

Can MATLAB do symbolic math? ›

You can create, run, and share symbolic math code. In the MATLAB® Live Editor, you can get next-step suggestions for symbolic workflows. The toolbox provides functions in common mathematical areas such as calculus, linear algebra, algebraic and differential equations, equation simplification, and equation manipulation.

How to write a summation in MATLAB? ›

S = sum( A , "all" ) returns the sum of all elements of A . S = sum( A , dim ) returns the sum along dimension dim . For example, if A is a matrix, then sum(A,2) returns a column vector containing the sum of each row. S = sum( A , vecdim ) sums the elements of A based on the dimensions specified in the vector vecdim .

How to convert symbolic to function in MATLAB? ›

ht = matlabFunction( f ) converts the symbolic expression or function f to a MATLAB® function with handle ht . If there is an equivalent MATLAB function operating on the double data type for the symbolic expression or function, then the converted function can be used without Symbolic Math Toolbox™.

How to calculate derivative in MATLAB? ›

Df = diff( f , var ) differentiates f with respect to the differentiation parameter var . var can be a symbolic scalar variable, such as x , a symbolic function, such as f(x) , or a derivative function, such as diff(f(t),t) . Df = diff( f , var , n ) computes the n th derivative of f with respect to var .

What is a function file in MATLAB? ›

MATLAB® program files can contain code for more than one function. In a function file, the first function in the file is called the main function. This function is visible to functions in other files, or you can call it from the command line.

What is simplify fraction in MATLAB? ›

simplifyFraction( expr ) simplifies the rational expression expr such that the numerator and denominator have no divisors in common. simplifyFraction( expr ,'Expand',true) expands the numerator and denominator of the resulting simplified fraction as polynomials without factorization.

How does downsample work in MATLAB? ›

y = downsample( x , n ) decreases the sample rate of x by keeping the first sample and then every n th sample after the first. If x is a matrix, the function treats each column as a separate sequence. y = downsample( x , n , phase ) specifies the number of samples by which to offset the downsampled sequence.

How do you simplify a matrix expression? ›

Steps to Simplify Matrix Expressions

Step 1: Substitute the given matrices into the expression. Step 2: Multiply any matrices by any scalars from the expression. Step 3: Compute the addition/subtraction as required.

How do you simplify a variable? ›

Simplifying Variable Expressions Involving Multiple Operations
  1. First, do the computation inside parentheses.
  2. Second, evaluate any exponents.
  3. Third, multiply and divide in order from left to right.
  4. Finally, add and subtract in order from left to right.
Mar 19, 2024

References

Top Articles
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 6263

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.