Computational Complexity: ECE 3340 - David Mayerich
Computational Complexity: ECE 3340 - David Mayerich
𝑥𝑥 𝑥𝑥 2 𝑥𝑥 3 𝑥𝑥 4
𝑒𝑒 ≈ 1 + 𝑥𝑥 + + + + 𝑂𝑂(𝑥𝑥 5 )
2 3! 4!
𝑥𝑥 5 𝐶𝐶
𝐶𝐶 = 5 |𝑥𝑥|5
2 2
̶ doubling 𝑥𝑥 increases the error by a factor of 25 :
5 5
𝐶𝐶 2𝑥𝑥 = 𝐶𝐶𝐶 𝑥𝑥
• If we know how the function behaves, we can approximate and bound our
truncation error
Computational Complexity
• The same concepts apply to the time required to solve a numerical
problem
• How many operations are required for c = 𝑎𝑎 + 𝑏𝑏 where 𝑎𝑎, 𝑏𝑏 ∈ ℝ?
1 addition (FLOP)
• What if 𝑎𝑎, 𝑏𝑏 ∈ ℝ3 :
𝑎𝑎1 𝑏𝑏1
𝑎𝑎 = 𝑎𝑎2 , 𝑏𝑏 = 𝑏𝑏2
𝑎𝑎3 𝑏𝑏3
3 FLOPS
𝑂𝑂(𝑛𝑛)
𝑂𝑂(𝑛𝑛2 )
High Dimensionality – Distance
• Volume of a hypersphere and hypercube of radius 𝑟𝑟 = 1
• 1-dimensional (both are lines)
𝑉𝑉𝑠𝑠
𝑉𝑉𝑠𝑠 = 2 𝑉𝑉𝑐𝑐 = 2 = 1.000
𝑉𝑉𝑐𝑐
• 2-dimensional (circle and square)
𝑉𝑉𝑠𝑠
𝑉𝑉𝑠𝑠 = 𝜋𝜋𝑟𝑟 2 = 3.14 𝑉𝑉𝑐𝑐 = 𝑟𝑟 2 = 4 = 0.785
𝑉𝑉𝑐𝑐
• 3-dimensional (sphere and cube)
4 𝑉𝑉𝑠𝑠
𝑉𝑉𝑠𝑠 = 𝜋𝜋𝑟𝑟 3 = 4.19 𝑉𝑉𝑐𝑐 = 𝑟𝑟 3 = 8 = 0.524
3 𝑉𝑉𝑐𝑐
• As dimensions increase,
̶ less of the volume is in the center
̶ more of the volume is in the corners