Trig Identities
Overview
Trigonometric identities are the algebraic backbone of many symbolic math workflows, from equation solving to signal analysis and geometric simplification. This category focuses on trigonometric transformation and simplification, where equivalent expressions are rewritten into forms that are easier to evaluate, compare, or manipulate. In practical data and engineering pipelines, these rewrites reduce expression complexity, expose cancellation opportunities, and improve numerical robustness in downstream steps.
The unifying ideas are equivalence-preserving rewrites, canonical forms, and complexity-aware simplification. Many identities are local (for example, reciprocal or angle-sum rewrites), but their value comes from composing them into a global strategy that lowers operation count and reveals structure. Typical identities include reciprocal and quotient forms, Pythagorean relations such as \sin^2(x)+\cos^2(x)=1, and product/sum conversions such as
\sin(a+b)=\sin(a)\cos(b)+\cos(a)\sin(b),\qquad \cos(a+b)=\cos(a)\cos(b)-\sin(a)\sin(b).
Implementation is powered by SymPy, especially its trigonometric expansion and simplification stack in the core expansion API, Fu-rule transformations, and trigsimp. SymPy is a symbolic mathematics library designed to represent expressions exactly, apply mathematically valid rewrites, and search for structurally simpler forms under configurable strategies.
The category includes one direct expansion tool and one high-level Fu strategy tool. TRIG_EXPAND applies angle-sum and related identities to expand compact trig expressions into additive/multiplicative components, which is useful when preparing expressions for term matching, factoring, or manual inspection. TRIG_FU runs the broader Fu et al. rule pipeline to seek lower-complexity equivalent forms, often compressing expressions that would otherwise require many manual steps. Together, these two tools provide opposite but complementary directions: expansion for structural visibility and Fu simplification for compactness.
The reciprocal/ratio normalization rules standardize trig function families into consistent representations. TRIG_TR1 rewrites secant and cosecant to reciprocal cosine and sine, while TRIG_TR2 rewrites tangent and cotangent as sine/cosine ratios. These transformations are especially helpful before algebraic cancellation, common-denominator work, and rational-function style simplification because they remove mixed-function notation and expose shared factors.
The angle and power identity tools target common symbolic bottlenecks in medium-to-large expressions. TRIG_TR3 canonicalizes signs and periodic shifts in arguments, TRIG_TR4 evaluates special-angle values, TRIG_TR5 and TRIG_TR6 swap between \sin^2 and \cos^2 forms via Pythagorean identities, and TRIG_TR7 applies power-reduction for \cos^2. TRIG_TR10 expands sums inside sine/cosine arguments, making latent structure explicit for later collection. In contrast, TRIG_TR8 converts products to sums and TRIG_TR9 converts sums to products, enabling movement between spectral-style and factored-style representations depending on the analysis goal.
At the top level, TRIG_TRIGSIMP performs generalized trigonometric simplification by selecting among established trigsimp methods, including matching, Groebner-based, combined, and Fu-driven approaches. This makes it the most flexible endpoint when expression form is unknown or mixed, while the individual TR rules remain ideal for controlled, deterministic rewrite steps in reproducible pipelines. A practical workflow is to apply targeted rules first for transparency, then finish with TRIG_TRIGSIMP to consolidate residual complexity.
TRIG_EXPAND
This function expands trigonometric expressions by applying angle-sum and related expansion identities. It is useful for converting compact forms into additive and multiplicative components.
For example, one key identity is:
\sin(a+b)=\sin(a)\cos(b)+\cos(a)\sin(b)
The deep option controls whether expansion recursively traverses nested subexpressions.
Excel Usage
=TRIG_EXPAND(expression, deep)
expression(str, required): Trigonometric expression to expand (expression string).deep(bool, optional, default: true): Apply expansion recursively to nested terms (true/false).
Returns (str): Expanded expression as a string, or an error message.
Example 1: Expands sine of a sum
Inputs:
| expression |
|---|
| sin(a + b) |
Excel formula:
=TRIG_EXPAND("sin(a + b)")
Expected output:
"sin(a)*cos(b) + sin(b)*cos(a)"
Example 2: Expands cosine of a sum
Inputs:
| expression |
|---|
| cos(a + b) |
Excel formula:
=TRIG_EXPAND("cos(a + b)")
Expected output:
"-sin(a)*sin(b) + cos(a)*cos(b)"
Example 3: Expands trig factor inside a larger product
Inputs:
| expression |
|---|
| sin(x + y)*(x + y) |
Excel formula:
=TRIG_EXPAND("sin(x + y)*(x + y)")
Expected output:
"(x + y)*(sin(x)*cos(y) + sin(y)*cos(x))"
Example 4: Disables deep recursion when requested
Inputs:
| expression | deep |
|---|---|
| sin((a + b) + c) | false |
Excel formula:
=TRIG_EXPAND("sin((a + b) + c)", FALSE)
Expected output:
"(-sin(b)*sin(c) + cos(b)*cos(c))*sin(a) + (sin(b)*cos(c) + sin(c)*cos(b))*cos(a)"
Python Code
Show Code
from sympy import sympify, expand_trig as sympy_expand_trig
def trig_expand(expression, deep=True):
"""
Expand trigonometric compound-angle expressions into component terms.
See: https://docs.sympy.org/latest/modules/core.html
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Trigonometric expression to expand (expression string).
deep (bool, optional): Apply expansion recursively to nested terms (true/false). Default is True.
Returns:
str: Expanded 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_expand_trig(expr_obj, deep=deep)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_FU
This function applies the Fu et al. trigonometric transformation strategy to rewrite expressions into compact equivalent forms. It explores multiple transformation rules and prefers lower-complexity outcomes.
It commonly exploits identities such as:
\sin^2(x)+\cos^2(x)=1
and sum/product transformations to reduce expression complexity.
Excel Usage
=TRIG_FU(expression)
expression(str, required): Trigonometric expression to simplify with Fu rules (expression string).
Returns (str): Fu-simplified expression as a string, or an error message.
Example 1: Simplifies Pythagorean identity with Fu
Inputs:
| expression |
|---|
| sin(x)^2 + cos(x)^2 |
Excel formula:
=TRIG_FU("sin(x)^2 + cos(x)^2")
Expected output:
"1"
Example 2: Combines weighted sine and cosine into shifted sine
Inputs:
| expression |
|---|
| sqrt(3)*cos(x)/2 + sin(x)/2 |
Excel formula:
=TRIG_FU("sqrt(3)*cos(x)/2 + sin(x)/2")
Expected output:
"sin(x + pi/3)"
Example 3: Simplifies exact trigonometric angle value
Inputs:
| expression |
|---|
| cos(4*pi/9) |
Excel formula:
=TRIG_FU("cos(4*pi/9)")
Expected output:
"sin(pi/18)"
Example 4: Simplifies tangent expression with constants
Inputs:
| expression |
|---|
| tan(7pi/18)+tan(5pi/18)-sqrt(3)tan(5pi/18)tan(7pi/18) |
Excel formula:
=TRIG_FU("tan(7*pi/18)+tan(5*pi/18)-sqrt(3)*tan(5*pi/18)*tan(7*pi/18)")
Expected output:
"-sqrt(3)"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import fu as sympy_fu
def trig_fu(expression):
"""
Simplify trigonometric expressions using the Fu transformation pipeline.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.fu
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Trigonometric expression to simplify with Fu rules (expression string).
Returns:
str: Fu-simplified 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_fu(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR1
This transformation rewrites reciprocal trigonometric functions into explicit reciprocal forms built from sine and cosine.
It applies identities:
\sec(x)=\frac{1}{\cos(x)},\quad \csc(x)=\frac{1}{\sin(x)}
This normalized form can make further simplification steps easier.
Excel Usage
=TRIG_TR1(expression)
expression(str, required): Expression containing sec and csc terms (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Rewrites secant to reciprocal cosine
Inputs:
| expression |
|---|
| sec(x) |
Excel formula:
=TRIG_TR1("sec(x)")
Expected output:
"1/cos(x)"
Example 2: Rewrites cosecant to reciprocal sine
Inputs:
| expression |
|---|
| csc(x) |
Excel formula:
=TRIG_TR1("csc(x)")
Expected output:
"1/sin(x)"
Example 3: Rewrites mixed secant and cosecant sum
Inputs:
| expression |
|---|
| 2*csc(x) + sec(x) |
Excel formula:
=TRIG_TR1("2*csc(x) + sec(x)")
Expected output:
"1/cos(x) + 2/sin(x)"
Example 4: Rewrites reciprocal functions in nested expression
Inputs:
| expression |
|---|
| sec(x + y) + csc(x - y) |
Excel formula:
=TRIG_TR1("sec(x + y) + csc(x - y)")
Expected output:
"1/cos(x + y) + 1/sin(x - y)"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR1 as sympy_tr1
def trig_tr1(expression):
"""
Rewrite secant and cosecant into reciprocal cosine and sine forms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR1
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing sec and csc 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_tr1(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
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
Show 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
TRIG_TR2
This transformation replaces tangent and cotangent with explicit sine/cosine ratios.
It uses:
\tan(x)=\frac{\sin(x)}{\cos(x)},\quad \cot(x)=\frac{\cos(x)}{\sin(x)}
Converting to a common basis helps later algebraic simplification.
Excel Usage
=TRIG_TR2(expression)
expression(str, required): Expression containing tan and cot terms (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Rewrites tangent as sine over cosine
Inputs:
| expression |
|---|
| tan(x) |
Excel formula:
=TRIG_TR2("tan(x)")
Expected output:
"sin(x)/cos(x)"
Example 2: Rewrites cotangent as cosine over sine
Inputs:
| expression |
|---|
| cot(x) |
Excel formula:
=TRIG_TR2("cot(x)")
Expected output:
"cos(x)/sin(x)"
Example 3: Simplifies nested tangent ratio structure
Inputs:
| expression |
|---|
| tan(tan(x) - sin(x)/cos(x)) |
Excel formula:
=TRIG_TR2("tan(tan(x) - sin(x)/cos(x))")
Expected output:
"0"
Example 4: Rewrites mixed tangent and cotangent expression
Inputs:
| expression |
|---|
| tan(a) + cot(b) |
Excel formula:
=TRIG_TR2("tan(a) + cot(b)")
Expected output:
"sin(a)/cos(a) + cos(b)/sin(b)"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR2 as sympy_tr2
def trig_tr2(expression):
"""
Rewrite tangent and cotangent into sine-cosine ratio forms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR2
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing tan and cot 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_tr2(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR3
This transformation applies induced trigonometric identities that normalize signs and argument structure, especially for negative arguments and periodic shifts.
Typical rules include odd/even behavior:
\sin(-x)=-\sin(x),\quad \cos(-x)=\cos(x)
These rewrites can expose additional simplification opportunities.
Excel Usage
=TRIG_TR3(expression)
expression(str, required): Trigonometric expression for sign and induced-identity normalization (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Normalizes odd sine sign
Inputs:
| expression |
|---|
| sin(-x) |
Excel formula:
=TRIG_TR3("sin(-x)")
Expected output:
"-sin(x)"
Example 2: Normalizes even cosine sign
Inputs:
| expression |
|---|
| cos(-x) |
Excel formula:
=TRIG_TR3("cos(-x)")
Expected output:
"cos(x)"
Example 3: Simplifies induced shift expression
Inputs:
| expression |
|---|
| cos(y - x*(y - x)) |
Excel formula:
=TRIG_TR3("cos(y - x*(y - x))")
Expected output:
"cos(x*(x - y) + y)"
Example 4: Normalizes mixed negative trig arguments
Inputs:
| expression |
|---|
| sin(-a) + cos(-b) |
Excel formula:
=TRIG_TR3("sin(-a) + cos(-b)")
Expected output:
"-sin(a) + cos(b)"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR3 as sympy_tr3
def trig_tr3(expression):
"""
Normalize trig signs and induced odd/even identity forms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR3
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Trigonometric expression for sign and induced-identity normalization (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_tr3(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR4
This transformation identifies and evaluates trigonometric values at common special angles exactly, using symbolic constants.
Examples include:
\sin\left(\frac{\pi}{6}\right)=\frac{1}{2},\quad \cos\left(\frac{\pi}{3}\right)=\frac{1}{2}
It is useful for converting unevaluated trig calls at known angles into exact algebraic forms.
Excel Usage
=TRIG_TR4(expression)
expression(str, required): Expression containing trig values at special angles (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Evaluates sine at pi over six
Inputs:
| expression |
|---|
| sin(pi/6) |
Excel formula:
=TRIG_TR4("sin(pi/6)")
Expected output:
"1/2"
Example 2: Evaluates cosine at pi over four
Inputs:
| expression |
|---|
| cos(pi/4) |
Excel formula:
=TRIG_TR4("cos(pi/4)")
Expected output:
"sqrt(2)/2"
Example 3: Evaluates tangent at pi over three
Inputs:
| expression |
|---|
| tan(pi/3) |
Excel formula:
=TRIG_TR4("tan(pi/3)")
Expected output:
"sqrt(3)"
Example 4: Evaluates a sum of special-angle trig terms
Inputs:
| expression |
|---|
| cos(pi/3) + sin(pi/6) |
Excel formula:
=TRIG_TR4("cos(pi/3) + sin(pi/6)")
Expected output:
"1"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR4 as sympy_tr4
def trig_tr4(expression):
"""
Evaluate exact trigonometric values at standard special angles.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR4
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing trig values at special angles (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_tr4(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR5
This transformation rewrites powers of sine into expressions involving cosine.
The base identity is:
\sin^2(x)=1-\cos^2(x)
It can be applied to higher even powers and controlled with maximum power and power-handling options.
Excel Usage
=TRIG_TR5(expression, max_power, use_pow)
expression(str, required): Expression containing sine powers to rewrite (expression string).max_power(int, optional, default: 4): Maximum exponent power to target for rewriting (count).use_pow(bool, optional, default: false): Apply power-focused behavior where supported (true/false).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Rewrites sine squared identity
Inputs:
| expression |
|---|
| sin(x)^2 |
Excel formula:
=TRIG_TR5("sin(x)^2")
Expected output:
"1 - cos(x)**2"
Example 2: Rewrites sine to the fourth power
Inputs:
| expression |
|---|
| sin(x)^4 |
Excel formula:
=TRIG_TR5("sin(x)^4")
Expected output:
"(1 - cos(x)**2)**2"
Example 3: Uses custom maximum power threshold
Inputs:
| expression | max_power |
|---|---|
| sin(x)^6 | 6 |
Excel formula:
=TRIG_TR5("sin(x)^6", 6)
Expected output:
"(1 - cos(x)**2)**3"
Example 4: Rewrites sine powers inside a larger expression
Inputs:
| expression |
|---|
| sin(x)^2 + sin(y)^2 |
Excel formula:
=TRIG_TR5("sin(x)^2 + sin(y)^2")
Expected output:
"-cos(x)**2 - cos(y)**2 + 2"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR5 as sympy_tr5
def trig_tr5(expression, max_power=4, use_pow=False):
"""
Replace even powers of sine using a cosine-based identity.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR5
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing sine powers to rewrite (expression string).
max_power (int, optional): Maximum exponent power to target for rewriting (count). Default is 4.
use_pow (bool, optional): Apply power-focused behavior where supported (true/false). Default is False.
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_tr5(expr_obj, max=max_power, pow=use_pow)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR6
This transformation rewrites powers of cosine into expressions involving sine.
The base identity is:
\cos^2(x)=1-\sin^2(x)
It can be applied to higher even powers and controlled with maximum power and power-handling options.
Excel Usage
=TRIG_TR6(expression, max_power, use_pow)
expression(str, required): Expression containing cosine powers to rewrite (expression string).max_power(int, optional, default: 4): Maximum exponent power to target for rewriting (count).use_pow(bool, optional, default: false): Apply power-focused behavior where supported (true/false).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Rewrites cosine squared identity
Inputs:
| expression |
|---|
| cos(x)^2 |
Excel formula:
=TRIG_TR6("cos(x)^2")
Expected output:
"1 - sin(x)**2"
Example 2: Rewrites cosine to the fourth power
Inputs:
| expression |
|---|
| cos(x)^4 |
Excel formula:
=TRIG_TR6("cos(x)^4")
Expected output:
"(1 - sin(x)**2)**2"
Example 3: Uses custom maximum power threshold
Inputs:
| expression | max_power |
|---|---|
| cos(x)^6 | 6 |
Excel formula:
=TRIG_TR6("cos(x)^6", 6)
Expected output:
"(1 - sin(x)**2)**3"
Example 4: Rewrites cosine powers inside a larger expression
Inputs:
| expression |
|---|
| cos(x)^2 + cos(y)^2 |
Excel formula:
=TRIG_TR6("cos(x)^2 + cos(y)^2")
Expected output:
"-sin(x)**2 - sin(y)**2 + 2"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR6 as sympy_tr6
def trig_tr6(expression, max_power=4, use_pow=False):
"""
Replace even powers of cosine using a sine-based identity.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR6
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression containing cosine powers to rewrite (expression string).
max_power (int, optional): Maximum exponent power to target for rewriting (count). Default is 4.
use_pow (bool, optional): Apply power-focused behavior where supported (true/false). Default is False.
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_tr6(expr_obj, max=max_power, pow=use_pow)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
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
Show 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
TRIG_TR8
This transformation applies product-to-sum identities to rewrite products of trigonometric terms into additive forms.
Representative identities include:
\cos(a)\cos(b)=\frac{\cos(a-b)+\cos(a+b)}{2}
\sin(a)\cos(b)=\frac{\sin(a+b)+\sin(a-b)}{2}
The first option controls preferred conversion ordering.
Excel Usage
=TRIG_TR8(expression, first)
expression(str, required): Expression with trig products to convert (expression string).first(bool, optional, default: true): Use first-pass preference for conversion choices (true/false).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Converts cosine-cosine product to sum
Inputs:
| expression |
|---|
| cos(2)*cos(3) |
Excel formula:
=TRIG_TR8("cos(2)*cos(3)")
Expected output:
"cos(5)/2 + cos(1)/2"
Example 2: Converts cosine-sine product to sum
Inputs:
| expression |
|---|
| cos(2)*sin(3) |
Excel formula:
=TRIG_TR8("cos(2)*sin(3)")
Expected output:
"sin(5)/2 + sin(1)/2"
Example 3: Converts sine-sine product to cosine difference form
Inputs:
| expression |
|---|
| sin(2)*sin(3) |
Excel formula:
=TRIG_TR8("sin(2)*sin(3)")
Expected output:
"-cos(5)/2 + cos(1)/2"
Example 4: Runs conversion with first option disabled
Inputs:
| expression | first |
|---|---|
| cos(a)*cos(b) | false |
Excel formula:
=TRIG_TR8("cos(a)*cos(b)", FALSE)
Expected output:
"cos(a - b)/2 + cos(a + b)/2"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR8 as sympy_tr8
def trig_tr8(expression, first=True):
"""
Convert products of sine and cosine terms into sum or difference forms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR8
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression with trig products to convert (expression string).
first (bool, optional): Use first-pass preference for conversion 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_tr8(expr_obj, first=first)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TR9
This transformation applies sum-to-product identities to rewrite additive trigonometric expressions as products.
A standard identity is:
\cos(a)+\cos(b)=2\cos\left(\frac{a+b}{2}\right)\cos\left(\frac{a-b}{2}\right)
Product forms can reveal structure for factoring and further simplification.
Excel Usage
=TRIG_TR9(expression)
expression(str, required): Expression with trig sums to convert (expression string).
Returns (str): Transformed expression as a string, or an error message.
Example 1: Converts cosine sum to product
Inputs:
| expression |
|---|
| cos(1) + cos(2) |
Excel formula:
=TRIG_TR9("cos(1) + cos(2)")
Expected output:
"2*cos(1/2)*cos(3/2)"
Example 2: Partially converts mixed sine and cosine sum
Inputs:
| expression |
|---|
| cos(1) + 2sin(1) + 2sin(2) |
Excel formula:
=TRIG_TR9("cos(1) + 2*sin(1) + 2*sin(2)")
Expected output:
"cos(1) + 4*sin(3/2)*cos(1/2)"
Example 3: Converts symbolic cosine sum
Inputs:
| expression |
|---|
| cos(a) + cos(b) |
Excel formula:
=TRIG_TR9("cos(a) + cos(b)")
Expected output:
"2*cos(a/2 - b/2)*cos(a/2 + b/2)"
Example 4: Converts sine sum to product
Inputs:
| expression |
|---|
| sin(a) + sin(b) |
Excel formula:
=TRIG_TR9("sin(a) + sin(b)")
Expected output:
"2*sin(a/2 + b/2)*cos(a/2 - b/2)"
Python Code
Show Code
from sympy import sympify
from sympy.simplify.fu import TR9 as sympy_tr9
def trig_tr9(expression):
"""
Convert sums of sine or cosine terms into product forms.
See: https://docs.sympy.org/latest/modules/simplify/fu.html#sympy.simplify.fu.TR9
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Expression with trig sums to convert (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_tr9(expr_obj)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
TRIG_TRIGSIMP
This function simplifies trigonometric expressions by applying known identities and structural rewrites. It can reduce combinations of sine, cosine, tangent, and related functions into more compact equivalent forms.
Common identities used in simplification include:
\sin^2(x) + \cos^2(x) = 1
and angle/ratio rewrites such as \tan(x)=\frac{\sin(x)}{\cos(x)}.
The method option controls which simplification strategy SymPy applies.
Excel Usage
=TRIG_TRIGSIMP(expression, inverse, trigsimp_method)
expression(str, required): Trigonometric expression to simplify (expression string).inverse(bool, optional, default: false): Allow aggressive inverse-function cancellation (true/false).trigsimp_method(str, optional, default: “matching”): Simplification strategy name.
Returns (str): Simplified expression as a string, or an error message.
Example 1: Simplifies sine-cosine Pythagorean identity
Inputs:
| expression |
|---|
| sin(x)^2 + cos(x)^2 |
Excel formula:
=TRIG_TRIGSIMP("sin(x)^2 + cos(x)^2")
Expected output:
"1"
Example 2: Simplifies tangent as sine over cosine ratio
Inputs:
| expression | trigsimp_method |
|---|---|
| sin(x)/cos(x) | matching |
Excel formula:
=TRIG_TRIGSIMP("sin(x)/cos(x)", "matching")
Expected output:
"tan(x)"
Example 3: Allows inverse cancellation when requested
Inputs:
| expression | inverse |
|---|---|
| asin(sin(x)) | true |
Excel formula:
=TRIG_TRIGSIMP("asin(sin(x))", TRUE)
Expected output:
"x"
Example 4: Uses Fu strategy to simplify expression
Inputs:
| expression | trigsimp_method |
|---|---|
| sqrt(6)cos(x) + sqrt(2)sin(x) | fu |
Excel formula:
=TRIG_TRIGSIMP("sqrt(6)*cos(x) + sqrt(2)*sin(x)", "fu")
Expected output:
"2*sqrt(2)*sin(x + pi/3)"
Python Code
Show Code
from sympy import sympify, trigsimp as sympy_trigsimp
def trig_trigsimp(expression, inverse=False, trigsimp_method='matching'):
"""
Simplify a trigonometric expression using identity transformations.
See: https://docs.sympy.org/latest/modules/simplify/simplify.html#sympy.simplify.trigsimp.trigsimp
This example function is provided as-is without any representation of accuracy.
Args:
expression (str): Trigonometric expression to simplify (expression string).
inverse (bool, optional): Allow aggressive inverse-function cancellation (true/false). Default is False.
trigsimp_method (str, optional): Simplification strategy name. Valid options: Matching, Groebner, Combined, Fu, Old. Default is 'matching'.
Returns:
str: Simplified 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_trigsimp(expr_obj, inverse=inverse, method=trigsimp_method)
return str(result)
except Exception as e:
return f"Error: {str(e)}"Online Calculator