Continuo da qui, copio qui.

**Semplificazione trigonometrica**

** Note**: SymPy follows Python’s naming conventions for inverse trigonometric functions, which is to append an `a`

to the front of the function’s name. For example, the inverse cosine, or arc cosine, is called `acos()`

.

Cosa abituale, nota forse inutile.

`trigsimp`

To simplify expressions using trigonometric identities, use `trigsimp()`

.

`trigsimp()`

also works with hyperbolic trig functions.

Much like `simplify()`

, `trigsimp()`

applies various trigonometric identities to the input expression, and then uses a heuristic to return the “best” one.

`expand_trig`

To expand trigonometric functions, that is, apply the sum or double angle identities, use `expand_trig()`

.

Because `expand_trig()`

tends to make trigonometric expressions larger, and `trigsimp()`

tends to make them smaller, these identities can be applied in reverse using `trigsimp()`

**Potenze**

Before we introduce the power simplification functions, a mathematical discussion on the identities held by powers is in order. There are three kinds of identities satisfied by exponents

Identity 1 is always true.

Identity 2 is not always true. For example, if `x=y=−1`

and `a=1/2`

, then

whereas

However, identity 2 is true at least if `x`

and `y`

are nonnegative and `a`

is real (it may also be true under other conditions as well). A common consequence of the failure of identity 2 is that

Identity 3 is not always true. For example, if `x=−1`

, `a=2`

, and `b=1/2`

, then

and

However, identity 3 is true when `b`

is an integer (again, it may also hold in other cases as well). Two common consequences of the failure of identity 3 are that

and that

To summarize

This is important to remember, because by default, SymPy will not perform simplifications if they are not true in general.

In order to make SymPy perform simplifications involving identities that are only true under certain assumptions, we need to put assumptions on our Symbols. We will undertake a full discussion of the assumptions system later, but for now, all we need to know are the following.

- By default, SymPy Symbols are assumed to be complex (elements of
`C`

). That is, a simplification will not be applied to an expression with a given Symbol unless it holds for all complex numbers.
- Symbols can be given different assumptions by passing the assumption to
`symbols()`

. For the rest of this section, we will be assuming that `x`

and `y`

are positive, and that `a`

and `b`

are real. We will leave `z`

, `t`

, and `c`

as arbitrary complex Symbols to demonstrate what happens in that case.

**Note**: In SymPy, `sqrt(x)`

is just a shortcut to `x**Rational(1, 2)`

. They are exactly the same object.

`powsimp`

`powsimp()`

applies identities 1 and 2 from above, from left to right.

Notice that `powsimp()`

refuses to do the simplification if it is not valid.

If you know that you want to apply this simplification, but you don’t want to mess with assumptions, you can pass the `force=True`

flag. This will force the simplification to take place, regardless of assumptions.

Note that in some instances, in particular, when the exponents are integers or rational numbers, and identity 2 holds, it will be applied automatically.

This means that it will be impossible to undo this identity with `powsimp()`

, because even if `powsimp()`

were to put the bases together, they would be automatically split apart again.

`expand_power_exp`

e `expand_power_base`

`expand_power_exp()`

e `expand_power_base()`

apply identities 1 and 2 from right to left, respectively.

As with `powsimp()`

, identity 2 is not applied if it is not valid.

And as with `powsimp()`

, you can force the expansion to happen without fiddling with assumptions by using `force=True`

.

As with identity 2, identity 1 is applied automatically if the power is a number, and hence cannot be undone with `expand_power_exp()`

.

`powdenest`

`powdenest()`

applies identity 3, from left to right.

As before, the identity is not applied if it is not true under the given assumptions.

And as before, this can be manually overridden with `force=True`

.