--- 
title: Compass Math Helpers
crumb: Math
framework: compass
meta_description: Helper math functions.
layout: core
classnames:
  - reference
  - core
  - helpers
documented_functions:
  - "pi"
  - "sin"
  - "cos"
  - "tan"
  - "e"
  - "log"
  - "sqrt"
  - "pow"
---
%h1 Compass Math Helpers

:markdown
  Sass math functions are sufficient for most cases, but in those moments of extreme geekiness these additional functions can really come in handy.


#pi.helper
  %h3
    %a(href="#pi")
      pi()
  .details
    %p
      Returns the value of π.

#sin.helper
  %h3
    %a(href="#sin")
      sin(<span class="arg">$number</span>)
  .details
    %p
      Returns the sine of a number. If the number is unitless or has a unit of <code>deg</code>
      then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
      will be evaluated as radians. Degrees will first be converted to radians.
      If the number is any other unit, the units will be passed thru to the result,
      and the number will be treated as radians.

#cos.helper
  %h3
    %a(href="#cos")
      cos(<span class="arg">$number</span>)
  .details
    %p
      Returns the cosine of a number. If the number is unitless or has a unit of <code>deg</code>
      then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
      will be evaluated as radians. Degrees will first be converted to radians.
      If the number is any other unit, the units will be passed thru to the result,
      and the number will be treated as radians.

#tan.helper
  %h3
    %a(href="#tan")
      tan(<span class="arg">$number</span>)
  .details
    %p
      Returns the tangent of a number. If the number is unitless or has a unit of <code>deg</code>
      then it will return a unitless result. Unless the number has a unit of <code>deg</code> it
      will be evaluated as radians. Degrees will first be converted to radians.
      If the number is any other unit, the units will be passed thru to the result,
      and the number will be treated as radians.

#e.helper
  %h3
    %a(href="#e")
      e()
  .details
    %p
      Returns the value of <a href="http://en.wikipedia.org/wiki/E_(mathematical_constant)">e</a>.

#log.helper
  %h3
    %a(href="#log")
      log(<span class="arg">$number</span>, <span class="arg" data-default-value="e" title="Defaults to: e">$base</span>)
  .details
    %p
      Calculates the logarithm of a number to a base. Base defaults to <code>e</code>.

#sqrt.helper
  %h3
    %a(href="#sqrt")
      sqrt(<span class="arg">$number</span>)
  .details
    %p
      Calculates the square root of a number.

#pow.helper
  %h3
    %a(href="#pow")
      pow(<span class="arg">$number</span>, <span class="arg">$exponent</span>)
  .details
    %p
      Calculates the value of a number raised to the power of an exponent.
