三角恒等式 [英] Trigonometric identities

查看:77
本文介绍了三角恒等式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个同时包含正弦和余弦的表达式,并且想只使用正弦(或余弦)来写它,可能使用

I have an expression which has both sines and cosines and would like to write it using only sines (or cosines), possibly using the power-reduction formula.

我尝试使用SymPy,但无法使其重写"为所需的输出:

I tried to use SymPy but I cannot make it to "rewrite" to the desired output:

angle = symbols('angle')
print (sin(angle)**2).rewrite(sin, cos) # (1 - cos(2*angle))/2
print ((1 - cos(2*angle))/2).rewrite(cos, sin) # sin(angle)**2

有没有办法告诉Sympy仅使用正弦(或余弦)来重写这样的表达式?

Is there any way to tell Sympy to rewrite such expression using only sines (or cosines)?

推荐答案

The sympy.simplify.fu module defines a number of transformations based on trig identities:

TR0 - simplify expression
TR1 - sec-csc to cos-sin
TR2 - tan-cot to sin-cos ratio
TR2i - sin-cos ratio to tan
TR3 - angle canonicalization
TR4 - functions at special angles
TR5 - powers of sin to powers of cos
TR6 - powers of cos to powers of sin
TR7 - reduce cos power (increase angle)
TR8 - expand products of sin-cos to sums
TR9 - contract sums of sin-cos to products
TR10 - separate sin-cos arguments
TR10i - collect sin-cos arguments
TR11 - reduce double angles
TR12 - separate tan arguments
TR12i - collect tan arguments
TR13 - expand product of tan-cot
TRmorrie - prod(cos(x*2**i), (i, 0, k - 1)) -> sin(2**k*x)/(2**k*sin(x))
TR14 - factored powers of sin or cos to cos or sin power
TR15 - negative powers of sin to cot power
TR16 - negative powers of cos to tan power
TR22 - tan-cot powers to negative powers of sec-csc functions
TR111 - negative sin-cos-tan powers to csc-sec-cot

我从此线程 asmeurer的这篇文章.

import sympy as sy
from sympy import sin, cos
FU = sy.FU

angle = sy.symbols('angle')
expr = sin(angle)**2

print(FU['TR8'](expr))
# -cos(2*angle)/2 + 1/2

print(FU['TR5'](expr))
# -cos(angle)**2 + 1

这篇关于三角恒等式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆