Work with functionsLesson 20 of 48 · 7 min

Use a trigonometric identity

Apply trigsimp and keep angle units explicit.

Maths refresher: Radians and the unit circle

A full turn is 2π radians or 360 degrees. On the unit circle, sine and cosine give coordinates whose squared lengths add to one.

sin⁡2θ+cos⁡2θ=1,30∘=π6\sin^2\theta+\cos^2\theta=1,\qquad30^\circ=\frac\pi6
Worked example

sin⁡(π/6)=1/2\sin(\pi/6)=1/2 exactly. Passing the number 30 without conversion asks for sine of thirty radians.

Maths prerequisite map ↗

Sine and cosine connect an angle with coordinates on the unit circle. SymPy’s trigonometric functions use radians. An exact angle such as π/6\pi/6 preserves identities that may be obscured by an early decimal approximation.

See the mathematics
θradius = 1
θradius = 1
θ=π6,sin⁡θ=12\theta=\frac\pi6,\quad\sin\theta=\frac12
Starter reference. On the unit circle, horizontal and vertical coordinates are cosine and sine. The right triangle has hypotenuse 1; angles are in radians.

trigsimp can recognise combinations of trigonometric functions. In the example, the Pythagorean identity reduces a sum of squares to one. This is a mathematical identity, unlike the empirical observation that a few numerical evaluations happen to match.

Convert degrees explicitly when needed by multiplying by π/180\pi/180. The plain number 30 means thirty radians to sin, not thirty degrees. Keep the angle unit attached to input descriptions, especially when connecting a symbolic expression to external data or a numerical array.

Will sp.sin(30) mean sine of thirty degrees?

Write a prediction (optional)

Exact angle conversion and numerical comparison

Select Run Python with the code unchanged.

Tools
About Python

Python and the course packages can load while you read. Each run starts with fresh user variables; imported modules stay loaded. Stop replaces the worker. Runtime details ↗

Ctrl+Enter or ⌘+Enter runs Python.

Compare with the worked example

Executed from the published Python during the site build. Your own run appears above. Build environment ↗

Identity simplified
11
Degree input converted to radians
π6\frac{\pi}{6}
Exact value at converted angle
12\frac{1}{2}
Approximate value treating the number as radians
−0.98803162-0.98803162
Worked text output
Identity simplified: 1
Degree input converted to radians: pi/6
Exact value at converted angle: 1/2
Approximate value treating the number as radians: -0.98803162

Read the starter result

Degree input converted to radians shows the exact angle. The Exact value at converted angle is one half. Treating the same number as radians gives a different angle.

Edit and compare

Replace degrees = 30 with degrees = 60 and trig = sp.sin with trig = sp.cos. Select Run Python. Compare Exact value at converted angle with Approximate value treating the number as radians. Which input represents a sixth of a full turn?

Return to the editor

Scope. Symbolic identities do not compensate for incorrect angle units or an unsuitable geometric model.

Try a fresh case

A table gives angles in degrees. What should happen before using SymPy sin?

Choose an answer
Need a hint?
Hint 1

One full turn has two common numerical descriptions.

Hint 2

Multiply degrees by π/180.

Your notesNotes save in this browser when storage is available.