less_retarded_wiki/approximation.md
2022-10-04 16:29:34 +02:00

2.6 KiB

Approximation

Approximating means calculating or representing something with lesser than best possible precision -- estimating -- purposefully allowing some margin of error in results and using simpler mathematical models than the most accurate ones: this is typically done in order to save resources (CPU cycles, memory etc.) and reduce complexity so that our projects and analysis stay manageable. Simulating real world on a computer is always an approximation as we cannot capture the infinitely complex and fine nature of the real world with a machine of limited resources, but even withing this we need to consider how much, in what ways and where to simplify.

Using approximations however doesn't have to imply decrease in precision of the final result -- approximations very well serve optimization. E.g. approximate metrics help in heuristic algorithms such as A*. Another use of approximations in optimization is as a quick preliminary check for the expensive precise algorithms: e.g. using bounding spheres helps speed up collision detection (if bounding spheres of two objects don't collide, we know they can't possibly collide and don't have to expensively check this).

Example of approximations:

  • Distances: instead of expensive Euclidean distance (sqrt(dx^2 + dy^2)) we may use Chebyshev distance (dx + dy) or Taxicab distance (max(dx,dy)).
  • Engineering approximations ("guesstimations"): e.g. sin(x) = x for "small" values of x or pi = 3 (integer instead of float).
  • Physics engines: complex triangle meshes are approximated with simple analytical shapes such as spheres, cuboids and capsules or at least convex hulls which are much easier and faster to deal with. They also approximate relativistic physics with Newtonian.
  • Real time graphics engines, on the other hand, normally approximate all shapes with triangle meshes.
  • Ray tracing neglects indirect lighting. Computer graphics in general is about approximating the solution of the rendering equation.
  • Real numbers are practically always approximated with floating point or fixed point (rational numbers).
  • Numerical methods offer generality and typically yield approximate solutions while their precision vs speed can be adjusted via parameters such as number of iterations.
  • Taylor series approximates given mathematical function and can be used to e.g. estimate solutions of differential equations.