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.
exactly. Passing the number 30 without conversion asks for sine of thirty radians.
Sine and cosine connect an angle with coordinates on the unit circle. SymPy’s trigonometric functions use radians. An exact angle such as preserves identities that may be obscured by an early decimal approximation.
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 . 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.
Your saved draft is open. To use the published code, select Restore example in Tools. Use Recover draft to bring back your code.
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.
Execution error
Technical error details
Your result
Python text output
Compare with the worked example
Executed from the published Python during the site build. Your own run appears above. Build environment ↗
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?
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?
Need a hint?
Hint 1
One full turn has two common numerical descriptions.
Hint 2
Multiply degrees by π/180.