### 10.2.19 Rewriting sin, cos, tan in terms of half tangent

The halftan command rewrites the trigonometric functions in terms of tan(x/2) using the identities:

sin(x) =

2tan

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

+1

,  cos(x) =

1−tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

+1

,  tan(x) =

2tan

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

1−tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

.

- halftan takes expr, an expression containing trigonometric functions.
- halftan(expr) returns expr with any trigonometric functions replaced by the appropriate expression of tan(x/2).

#### Examples

halftan(sin(2*x)/(1+cos(2*x)))

2 tan

⎛
⎜
⎜
⎝

2
2

x

⎞
⎟
⎟
⎠

⎛
⎜
⎜
⎝

tan2

⎛
⎜
⎜
⎝

2
2

x

⎞
⎟
⎟
⎠

+1

⎞
⎟
⎟
⎠

⎛
⎜
⎜
⎜
⎜
⎜
⎝

1+

1−tan2

⎛
⎜
⎜
⎝

2
2

x

⎞
⎟
⎟
⎠

tan2

⎛
⎜
⎜
⎝

2
2

x

⎞
⎟
⎟
⎠

+1

⎞
⎟
⎟
⎟
⎟
⎟
⎠

normal(ans())

tan x |  |  |  |  |  |  |  |  |  |

halftan(sin(x)^2+cos(x)^2)

⎛
⎜
⎜
⎜
⎜
⎜
⎝

2 tan

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

+1

⎞
⎟
⎟
⎟
⎟
⎟
⎠

2

+

⎛
⎜
⎜
⎜
⎜
⎜
⎝

1−tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

tan2

⎛
⎜
⎜
⎝

x
2

⎞
⎟
⎟
⎠

+1

⎞
⎟
⎟
⎟
⎟
⎟
⎠

2

normal(ans())

1 |  |  |  |  |  |  |  |  |  |