InertForm - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Evaluation : Preventing Evaluation : InertForm Package : InertForm/SameStructure

InertForm

 SameStructure
 compare the value and structure of expressions

 Calling Sequence SameStructure( a, b )

Parameters

 a - anything b - anything

Description

 • The SameStructure command accepts two expressions, inert or otherwise, and compares their structure.  If they are the same in value and structure then this command returns true, otherwise false.
 • Structural equivalence is determined by replacing all numeric constants in both a and b with variables and ensuring that the resulting expressions are equal using Maple's default data-structure normalization.  Replacing constants removes the influence of most automatic simplifications like integer arithmetic and fraction reduction.

Package Usage

 • This function is part of the InertForm package, so it can be used in the short form SameStructure(..) only after executing the command with(InertForm). However, it can always be accessed through the long form of the command by using InertForm[SameStructure](..).

Examples

 > $\mathrm{with}\left(\mathrm{InertForm}\right):$

Equivalent fractions that are not reduced the same way return false.

 > $\mathrm{SameStructure}\left(\mathrm{%/}\left(2,4\right),\frac{1}{2}\right)$
 ${\mathrm{false}}$ (1)

Order of terms is not strict.

 > $\mathrm{SameStructure}\left(\mathrm{%+}\left(2,4\right),\mathrm{%+}\left(4,2\right)\right)$
 ${\mathrm{true}}$ (2)
 > $\mathrm{SameStructure}\left(\mathrm{%*}\left(2,4\right),\mathrm{%*}\left(4,2\right)\right)$
 ${\mathrm{true}}$ (3)
 > $\mathrm{SameStructure}\left(\mathrm{%*}\left(2,\mathrm{%*}\left(4,6\right)\right),\mathrm{%*}\left(\mathrm{%*}\left(4,6\right),2\right)\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{SameStructure}\left(\mathrm{%*}\left(6,\mathrm{%*}\left(4,2\right)\right),\mathrm{%*}\left(\mathrm{%*}\left(4,6\right),2\right)\right)$
 ${\mathrm{true}}$ (5)

Factored versus expanded matters.

 > $\mathrm{SameStructure}\left(\left(x+1\right)\left(y+2\right),xy+2x+y+2\right)$
 ${\mathrm{false}}$ (6)
 > $\mathrm{SameStructure}\left(\left(x+5\right)\left(x+3\right),{x}^{2}+8x+15\right)$
 ${\mathrm{false}}$ (7)

Separated multiplicative factors of -1 or 1 do not matter.

 > $\mathrm{SameStructure}\left(-1\mathrm{%+}\left(y,2\right),-y-2\right)$
 ${\mathrm{true}}$ (8)
 > $\mathrm{SameStructure}\left(-1\mathrm{%/}\left(y,2\right),-\frac{y}{2}\right)$
 ${\mathrm{true}}$ (9)
 > $\mathrm{SameStructure}\left(1\mathrm{%+}\left(y,2\right),y+2\right)$
 ${\mathrm{true}}$ (10)
 > $\mathrm{SameStructure}\left(\mathrm{%+}\left(-x,1\right),-\mathrm{%+}\left(x,-1\right)\right)$
 ${\mathrm{true}}$ (11)

Inert versions of function calls match non-inert equivalents.

 > $\mathrm{SameStructure}\left(\mathrm{%sin}\left(x\right),\mathrm{sin}\left(x\right)\right)$
 ${\mathrm{true}}$ (12)

Evaluation is not done on inert function calls.

 > $\mathrm{SameStructure}\left(\mathrm{%int}\left(x,x\right),\frac{{x}^{2}}{2}\right)$
 ${\mathrm{false}}$ (13)

An expression to the -1 power matches division.

 > $\mathrm{SameStructure}\left(\mathrm{%^}\left(y,-1\right),\mathrm{%/}\left(1,y\right)\right)$
 ${\mathrm{true}}$ (14)

The order of right-side and left-side matters for equations.

 > $\mathrm{SameStructure}\left(y=1-x,y=1-x\right)$
 ${\mathrm{true}}$ (15)
 > $\mathrm{SameStructure}\left(1-x=y,y=1-x\right)$
 ${\mathrm{false}}$ (16)
 > $\mathrm{SameStructure}\left(x+y=1,y=1-x\right)$
 ${\mathrm{false}}$ (17)

Compatibility

 • The InertForm[SameStructure] command was introduced in Maple 2018.
 • For more information on Maple 2018 changes, see Updates in Maple 2018.

 See Also