Hi
Two new things recently added to the latest version of Physics available on Maplesoft's R&D Physics webpage are worth mentioning outside the framework of Physics.

  • automaticsimplification. This means that after "Physics:-Setup(automaticsimplification=true)", the output corresponding to every single input (literally) gets automatically simplified in size before being returned to the screen. This is fantastically convenient for interactive work in most situations.

  • Add Physics:-Library:-Assume, to perform the same operations one typically performs with the  assume command, but without the side effect that the variables get redefined. So the variables do not get redefined, they only receive assumptions.

This new Assume implements the concept of an "extended assuming". It permits re-using expressions involving the variables being assumed, expressions that were entered before the assumptions were placed, as well as reusing all the expressions computed while the variables had assumptions, even after removing the variable's assumptions. None of this is possible when placing assumptions using the standard assume. The new routine also permits placing assumptions on global variables that have special meaning, that cannot be redefined, e.g. the cartesian, cylindrical or spherical coordinates sets, or the coordinates of a coordinate spacetime system within the Physics package, etc.

Examples:

 

with(Physics):

This is Physics from today:

Physics:-Version()[2]

`2014, December 9, 16:51 hours`

(1.1)
• 

Automatic simplification is here. At this point automaticsimplification is OFF by default.

Setup(automaticsimplification)

[automaticsimplification = false]

(1.2)

Hence, for instance, if you input the following expression, the computer just echoes your input:

Physics:-`*`(a, c)+Physics:-`*`(a, d)+Physics:-`*`(b, c)+Physics:-`*`(b, d)

a*c+a*d+b*c+b*d

(1.3)

There is however some structure behind (1.3) and, in most situations, it is convenient to have these structures
apparent, in part because they frequently provide hints on how to proceed ahead, but also because a more
compact expression is, roughly speaking, simpler to understand. To see this
automaticsimplification in action,
turn it ON:

Setup(automaticsimplification = true)

[automaticsimplification = true]

(1.4)

Recall this same expression (you could input it with the equation label (1.3) as well) 

Physics:-`*`(a, c)+Physics:-`*`(a, d)+Physics:-`*`(b, c)+Physics:-`*`(b, d)

(c+d)*(a+b)

(1.5)

What happened: this output, as everything else after you set automaticsimplification = true and with no
exceptions, is now further processed with simplify/size before being returned. And enjoy computing with frankly
shorter expressions all around! And no need anymore for "simplify(%, size)" every three or four input lines.

Another  example, typical in computer algebra where expressions become uncomfortably large and difficult to
read: convert the following input to 2D math input mode first, in order to compare what is being entered with the
automatically simplified output on the screen

-Physics:-`*`(Physics:-`*`(Physics:-`*`(3, sin(x)^(1/2)), cos(x)^2), sin(x)^m)+Physics:-`*`(Physics:-`*`(Physics:-`*`(3, sin(x)^(1/2)), cos(x)^2), cos(x)^n)+Physics:-`*`(Physics:-`*`(Physics:-`*`(4, sin(x)^(1/2)), cos(x)^4), sin(x)^m)-Physics:-`*`(Physics:-`*`(Physics:-`*`(4, sin(x)^(1/2)), cos(x)^4), cos(x)^n)

-4*(cos(x)^n-sin(x)^m)*sin(x)^(1/2)*cos(x)^2*(cos(x)^2-3/4)

(1.6)

You can turn automaticsimplification OFF the same way

Setup(automaticsimplification = false)

[automaticsimplification = false]

(1.7)
• 

New Library:-Assume facility; welcome to the world of "extended assuming" :)

 

Consider a generic variable, x. Nothing is known about it

about(x)

x:

  nothing known about this object

 

Each variable has associated a number that depends on the session, and the computer (internally) uses this
number to refer to the variable.

addressof(x)

18446744078082181054

(1.8)

When using the assume  command to place assumptions on a variable, this number, associated to it, changes,
for example:

assume(0 < x and x < Physics:-`*`(Pi, 1/2))

addressof(x)

18446744078179060574

(1.9)

Indeed, the variable x got redefined and renamed, it is not anymore the variable x referenced in (1.8).

about(x)

Originally x, renamed x~:

  is assumed to be: RealRange(Open(0),Open(1/2*Pi))

 


The semantics may seem confusing but that is what happened, you enter x and the computer thinks x~, not x 
anymore.This means two things:

1) all the equations/expressions, entered before placing the assumptions on x using assume, involve a variable x 
that is different than the one that exists after placing the assumptions, and so these previous expressions
cannot
be reused
. They involve a different variable.

2) Also, because, after placing the assumptions using assume, x refers to a different object, programs that depend
on the
x that existed before placing the assumptions will not recognize the new x redefined by assume .

 

For example, if x was part of a coordinate system and the spacetime metric g[mu, nu]depends on it, the new variable x
redefined within assume, being a different symbol, will not be recognized as part of the dependency of "g[mu,nu]." This
posed constant obstacles to working with curved spacetimes that depend on parameters or on coordinates that
have a restricted range. These problems are resolved entirely with this new
Library:-Assume, because it does not
redefine the variables. It only places assumptions on them, and in this sense it works like
assuming , not assume .
As another example, all the
Physics:-Vectors commands look for the cartesian, cylindrical or spherical coordinates
sets
[x, y, z], [rho, phi, z], [r, theta, phi] in order to determine how to proceed, but these variables disappear if you use
assume to place assumptions on them. For that reason, only assuming  was fully compatible with Physics, not assume.

 

To undo assumptions placed using the assume command one reassigns the variable x to itself:

x := 'x'

x

(1.10)

Check the numerical address: it is again equal to (1.8) 

addressof(x)

18446744078082181054

(1.11)

·All these issues get resolved with the new Library:-Assume, that uses all the implementation of the existing 
assume command but with a different approach: the variables being assumed do not get redefined, and hence:
a) you can reuse expressions/equations entered before placing the assumptions, you can also undo the
assumptions and reuse results obtained with assumptions. This is the concept of an
extended assuming. Also,
commands that depend on these assumed variables will all continue to work normally, before, during or after
placing the assumption, because
the variables do not get redefined.

Example:

about(x)

x:

  nothing known about this object

 

So this simplification attempt accomplishes nothing

simplify(arccos(cos(x)))

arccos(cos(x))

(1.12)

Let's assume now that 0 < x and x < (1/2)*Pi

Library:-Assume(0 < x and x < Physics:-`*`(Pi, 1/2))

{x::(RealRange(Open(0), Open((1/2)*Pi)))}

(1.13)

The new command echoes the internal format representing the assumption placed.

a) The address is still the same as (1.8)

addressof(x)

18446744078082181054

(1.14)

So the variable did not get redefined. The system however knows about the assumption - all the machinery of the
assume command is being used

about(x)

Originally x, renamed x:

  is assumed to be: RealRange(Open(0),Open(1/2*Pi))

 


Note that the renaming is to the variable itself - i.e. no renaming.

Hence, expressions entered before placing assumptions can be reused. For example, for (1.12), we now have

simplify(arccos(cos(x)))

x

(1.15)

To clear the assumptions on x, you can use either of Library:-Assume(x=x) or Library:-Assume(clear = {x, ...}) in
the case of many variables being cleared in one go, or in the case of a single variable being cleared:

Library:-Assume(clear = x)

about(x)

x:

  nothing known about this object

 


The implementation includes the additionally functionality, for that purpose add the keyword
additionally 
anywhere in the calling sequence. For example:

Library:-Assume(x::positive)

{x::(RealRange(Open(0), infinity))}

(1.16)

about(x)

Originally x, renamed x:

  is assumed to be: RealRange(Open(0),infinity)

 

Library:-Assume(additionally, x < 1)

{x::(RealRange(Open(0), Open(1)))}

(1.17)

Library:-Assume(x = x)

In summary, the new Library:-Assume command implements the concept of an extended assuming, that can be
turned ON and OFF at will at any moment without changing the variables involved.


Download AutomaticSimplificationAndAssume.mw

 

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft


Please Wait...