Is there a way to expand a trig function of an inverse trig function? I have a long expression f
that contains many such subexpressions, e.g.
sin(0.5 acot(x))**2
cos(0.5 acot(x))**2
sin(acot(x))
These expressions can be rewritten without trig functions, e.g.
1/2 - 1/2 * x / sp.sqrt(x**2 1)
I've tried trig_expand and trigsimp to no avail. I also can't find a way to directly substitute the analytical expressions in.
Any suggestions?
CodePudding user response:
There are various ways to do this. Some examples:
In [1]: sin(acot(x))
Out[1]:
1
───────────────
________
╱ 1
x⋅ ╱ 1 ──
╱ 2
╲╱ x
In [2]: sin(acot(x)/2)**2
Out[2]:
2⎛acot(x)⎞
sin ⎜───────⎟
⎝ 2 ⎠
In [3]: e = sin(acot(x)/2)**2
In [4]: e.rewrite(log)
Out[4]:
⎛ ⎛ ⎛ ⅈ⎞ ⎛ ⅈ⎞⎞⎞
⎜ⅈ⋅⎜log⎜1 - ─⎟ - log⎜1 ─⎟⎟⎟
2⎜ ⎝ ⎝ x⎠ ⎝ x⎠⎠⎟
sin ⎜───────────────────────────⎟
⎝ 4 ⎠
In [5]: e.rewrite(log).rewrite(exp)
Out[5]:
⎛ ⎛ _______ _______⎞ ⎞
⎜ ⎜ ╱ ⅈ ╱ ⅈ ⎟ ⎟
⎜ ⎜ 4 ╱ 1 - ─ 4 ╱ 1 ─ ⎟ ⎟
⎜ ⎜ ╲╱ x ╲╱ x ⎟ ⎟
⎜-ⅈ⋅⎜- ─────────── ───────────⎟ ⎟
⎜ ⎜ _______ _______⎟ ⎟
⎜ ⎜ ╱ ⅈ ╱ ⅈ ⎟ ⎟
⎜ ⎜ 4 ╱ 1 ─ 4 ╱ 1 - ─ ⎟ ⎟
⎜ ⎝ ╲╱ x ╲╱ x ⎠ ⎟
2⋅log⎜─────────────────────────────────⎟
⎝ 2 ⎠
ℯ
In [6]: e.rewrite(log).rewrite(exp).expand()
Out[6]:
_______ _______
╱ ⅈ ╱ ⅈ
╱ 1 - ─ ╱ 1 ─
╲╱ x 1 ╲╱ x
- ───────────── ─ - ─────────────
_______ 2 _______
╱ ⅈ ╱ ⅈ
4⋅ ╱ 1 ─ 4⋅ ╱ 1 - ─
╲╱ x ╲╱ x
In [7]: simplify(_)
Out[7]:
1 1
─ - ─────────────────────────
2 _______ _______
╱ ⅈ ╱ ⅈ
2⋅ ╱ 1 - ─ ⋅ ╱ 1 ─
╲╱ x ╲╱ x
Some cases will work differently if you declare x
as real or positive e.g. x = symbols('x', real=True)
.