Task

Show how to use the following math constants and functions in your language   (if not available, note it):

   e   (base of the natural logarithm)
   



π


{\displaystyle \pi }


   square root
   logarithm   (any base allowed)
   exponential   (ex )
   absolute value   (a.k.a. "magnitude")
   floor   (largest integer less than or equal to this number--not the same as truncate or int)
   ceiling   (smallest integer not less than this number--not the same as round up)
   power   (xy )


Related task

   Trigonometric Functions


/* NetRexx */
options replace format comments java crossref symbols nobinary utf8
 
numeric digits 30
 
x = 2.5
y = 3
pad = 40
say
say 'Java Math constants & functions:'
say Rexx('  Euler''s number (e):').left(pad)                    Math.E
say Rexx('  Pi:').left(pad)                                     Math.PI
say Rexx('  Square root of' x':').left(pad)                     Math.sqrt(x)
say Rexx('  Log(e) of' x':').left(pad)                          Math.log(x)
say Rexx('  Log(e) of e:').left(pad)                            Math.log(Math.E)
say Rexx('  Log(10) of' x':').left(pad)                         Math.log10(x)
say Rexx('  Log(10) of 10:').left(pad)                          Math.log10(10)
say Rexx('  Exponential (e**x) of' x':').left(pad)              Math.exp(x)
say Rexx('  Exponential (e**x) of log(e)' x':').left(pad)       Math.exp(Math.log(x))
say Rexx('  Abs of' x':').left(pad)                             Math.abs(x.todouble)
say Rexx('  Abs of' (-x)':').left(pad)                          Math.abs((-x).todouble)
say Rexx('  Floor of' x':').left(pad)                           Math.floor(x)
say Rexx('  Floor of' (-x)':').left(pad)                        Math.floor((-x))
say Rexx('  Ceiling of' x':').left(pad)                         Math.ceil(x)
say Rexx('  Ceiling of' (-x)':').left(pad)                      Math.ceil((-x))
say Rexx(' ' x 'to the power of' y':').left(pad)                Math.pow(x, y)
say Rexx(' ' x 'to the power of' 1 / y':').left(pad)            Math.pow(x, 1 / y)
say Rexx('  10 to the power of log10' x':').left(pad)           Math.pow(10, Math.log10(x))
 
-- Extras
say Rexx('  Cube root of' x':').left(pad)                       Math.cbrt(x)
say Rexx('  Hypotenuse of' 3 'x' 4 'right triangle:').left(pad) Math.hypot(3, 4) 
say Rexx('  Max of' (-x) '&' x':').left(pad)                    Math.max((-x).todouble, x)
say Rexx('  Min of' (-x) '&' x':').left(pad)                    Math.min((-x).todouble, x)
say Rexx('  Signum of' x':').left(pad)                          Math.signum((x).todouble)
say Rexx('  Signum of' x '-' x':').left(pad)                    Math.signum((x - x).todouble)
say Rexx('  Signum of' (-x)':').left(pad)                       Math.signum((-x).todouble)
 
say
say 'NetRexx built-in support for numeric data:'
say Rexx('  Abs of' x':').left(pad)                        x.abs()
say Rexx('  Abs of' (-x)':').left(pad)                     (-x).abs()
say Rexx('  Sign of' x':').left(pad)                       x.sign()
say Rexx('  Sign of' x '-' x':').left(pad)                 (x - x).sign()
say Rexx('  Sign of' (-x)':').left(pad)                    (-x).sign()
say Rexx('  Max of' (-x) '&' x':').left(pad)               (-x).max(x)
say Rexx('  Min of' (-x) '&' x':').left(pad)               (-x).min(x)
say Rexx('  Truncate' x 'by' y':').left(pad)               x.trunc(y)
say Rexx('  Format (with rounding)' x 'by' y':').left(pad) x.format(y, 0)
 