TRIG_TR7
This transformation lowers cosine-squared terms to first-degree cosine at double angle using a power-reduction identity.
The identity used is:
\cos^2(x)=\frac{1+\cos(2x)}{2}
This is useful when preparing expressions for integration, simplification, or harmonics analysis.
Excel Usage
=TRIG_TR7(expression)
expression(str, required): Expression containing cosine-squared terms (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Reduces cosine squared to double-angle form
Inputs:
| expression |
|---|
| cos(x)^2 |
Excel formula:
=TRIG_TR7("cos(x)^2")
Expected output:
"cos(2*x)/2 + 1/2"
Example 2: Reduces cosine squared inside additive expression
Inputs:
| expression |
|---|
| cos(x)^2 + 1 |
Excel formula:
=TRIG_TR7("cos(x)^2 + 1")
Expected output:
"cos(2*x)/2 + 3/2"
Example 3: Reduces scaled cosine squared term
Inputs:
| expression |
|---|
| 3*cos(a)^2 |
Excel formula:
=TRIG_TR7("3*cos(a)^2")
Expected output:
"3*cos(2*a)/2 + 3/2"
Example 4: Reduces multiple cosine squared terms
Inputs:
| expression |
|---|
| cos(x)^2 + cos(y)^2 |
Excel formula:
=TRIG_TR7("cos(x)^2 + cos(y)^2")
Expected output:
"cos(2*x)/2 + cos(2*y)/2 + 1"
Python Code
from sympy import sympify
from sympy.simplify.fu import TR7 as sympy_tr7
def trig_tr7(expression):
"""
Apply power-reduction to cosine-squared terms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR7
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing cosine-squared terms (expression string).
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_tr7(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Expression containing cosine-squared terms (expression string).