TRIG_TR10

This transformation separates trigonometric functions of sums into combinations of component-angle terms.

It uses identities such as:

\cos(a+b)=\cos(a)\cos(b)-\sin(a)\sin(b)

\sin(a+b)=\sin(a)\cos(b)+\cos(a)\sin(b)

The first option controls preferred decomposition order.

Excel Usage

=TRIG_TR10(expression, first)
  • expression (str, required): Expression with summed-angle sine/cosine terms (expression string).
  • first (bool, optional, default: true): Use first-pass preference for decomposition choices (true/false).

Returns (str): Transformed expression as a string, or an error message.

Example 1: Expands cosine of two-angle sum

Inputs:

expression
cos(a + b)

Excel formula:

=TRIG_TR10("cos(a + b)")

Expected output:

"-sin(a)*sin(b) + cos(a)*cos(b)"

Example 2: Expands sine of two-angle sum

Inputs:

expression
sin(a + b)

Excel formula:

=TRIG_TR10("sin(a + b)")

Expected output:

"sin(a)*cos(b) + sin(b)*cos(a)"

Example 3: Expands sine of three-angle sum

Inputs:

expression
sin(a + b + c)

Excel formula:

=TRIG_TR10("sin(a + b + c)")

Expected output:

"(-sin(a)*sin(b) + cos(a)*cos(b))*sin(c) + (sin(a)*cos(b) + sin(b)*cos(a))*cos(c)"

Example 4: Runs expansion with first option disabled

Inputs:

expression first
cos(x + y) false

Excel formula:

=TRIG_TR10("cos(x + y)", FALSE)

Expected output:

"-sin(x)*sin(y) + cos(x)*cos(y)"

Python Code

from sympy import sympify
from sympy.simplify.fu import TR10 as sympy_tr10

def trig_tr10(expression, first=True):
    """
    Expand sine and cosine of summed angles into separated component terms.

    See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR10

    This example function is provided as-is without any representation of accuracy.

    Args:
        expression (str): Expression with summed-angle sine/cosine terms (expression string).
        first (bool, optional): Use first-pass preference for decomposition choices (true/false). Default is True.

    Returns:
        str: Transformed expression as a string, or an error message.
    """
    try:
        expr_text = expression.replace("^", "**") if isinstance(expression, str) else expression
        expr_obj = sympify(expr_text)
        result = sympy_tr10(expr_obj, first=first)
        return str(result)
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Expression with summed-angle sine/cosine terms (expression string).
Use first-pass preference for decomposition choices (true/false).