Julia – 12 – operazioni matematiche e funzioni elementari – 3

Continuo da qui, copio qui.

Precedenze tra operatori
Julia applies the following order of operations, from highest precedence to lowest:

Category       Operators
Syntax	       . followed by ::
Exponentiation ^
Fractions      //
Multiplication * / % & \
Bitshifts      << >> >>>
Addition       + - | ⊻
Syntax	       : .. followed by |>
Comparisons    > < >= <= == === != !== <:
Control flow   && followed by || followed by ?
Assignments    = += -= *= /= //= \= ^= ÷= %= |= &= ⊻= <<= >>= >>>=

For a complete list of every Julia operator’s precedence, see the top of this file.
Uh! 😁 Fantastico il linguaggio con cui è scritto Julia: Scheme, cioè Lisp (una variante del) 🚀

You can also find the numerical precedence for any given operator via the built-in function Base.operator_precedence, where higher numbers take precedence:

Conversioni numeriche
Julia supports three forms of numerical conversion, which differ in their handling of inexact conversions.

  • The notation T(x) or convert(T, x) converts x to a value of type T.
    ° If T is a floating-point type, the result is the nearest representable value, which could be positive or negative infinity.
    ° If T is an integer type, an InexactError is raised if x is not representable by T.
  • x % T converts an integer x to a value of integer type T congruent to x modulo 2^n, where n is the number of bits in T. In other words, the binary representation is truncated to fit.
  • The Rounding functions take a type T as an optional argument. For example, round(Int, x) is a shorthand for Int(round(x)).

The following examples show the different forms.

See Conversion and Promotion [prossimamente] for how to define your own conversions and promotions.

Funzioni di arrotondamento

Function	Description                    Return type
round(x)        round x to the nearest integer typeof(x)
round(T, x)     round x to the nearest integer T
floor(x)        round x towards -Inf           typeof(x)
floor(T, x)     round x towards -Inf           T
ceil(x)	        round x towards +Inf               typeof(x)
ceil(T, x)      round x towards +Inf           T
trunc(x)        round x towards zero           typeof(x)
trunc(T, x)     round x towards zero           T

Funzioni di divisione

Function    Description
div(x,y)    truncated division; quotient rounded towards zero
fld(x,y)    floored division; quotient rounded towards -Inf
cld(x,y)    ceiling division; quotient rounded towards +Inf
rem(x,y)    remainder; satisfies x == div(x,y)*y + rem(x,y); sign matches x
mod(x,y)    modulus; satisfies x == fld(x,y)*y + mod(x,y); sign matches y
mod1(x,y)   mod() with offset 1; returns r∈(0,y] for y>0 or r∈[y,0) for
            y<0, where mod(r, y) == mod(x, y)
mod2pi(x)   modulus with respect to 2pi; 0 <= mod2pi(x)   < 2pi
divrem(x,y) returns (div(x,y),rem(x,y))
fldmod(x,y) returns (fld(x,y),mod(x,y))
gcd(x,y...) greatest positive common divisor of x, y,...
lcm(x,y...) least positive common multiple of x, y,...

Potenze, logaritmi e radici

Function       Description
sqrt(x), √x    square root of x
cbrt(x), ∛x    cube root of x
hypot(x,y)     hypotenuse of right-angled triangle with
               other sides of length x and y
exp(x)         natural exponential function at x
expm1(x)       accurate exp(x)-1 for x near zero
ldexp(x,n)     x*2^n computed efficiently for integer values of n
log(x)         natural logarithm of x
log(b,x)       base b logarithm of x
log2(x)        base 2 logarithm of x
log10(x)       base 10 logarithm of x
log1p(x)       accurate log(1+x) for x near zero
exponent(x)    binary exponent of x
significand(x) binary significand (a.k.a. mantissa) of 
               a floating-point number x

For an overview of why functions like hypot(), expm1(), and log1p() are necessary and useful, see John D. Cook’s excellent pair of blog posts on the subject: expm1, log1p, erfc, and hypot.

Nota: codici Unicode U+221A, U+221B. Io li cerco (se costretto a usarli) da FileFormat.Info.

Funzioni trigonometriche e iperboliche
All the standard trigonometric and hyperbolic functions are also defined:

sin    cos    tan    cot    sec    csc
sinh   cosh   tanh   coth   sech   csch
asin   acos   atan   acot   asec   acsc
asinh  acosh  atanh  acoth  asech  acsch
sinc   cosc   atan2

These are all single-argument functions, with the exception of atan2, which gives the angle in radians between the x-axis and the point specified by its arguments, interpreted as x and y coordinates.

Additionally, sinpi(x) and cospi(x) are provided for more accurate computations of sin(pi*x) and cos(pi*x) respectively.

In order to compute trigonometric functions with degrees instead of radians, suffix the function with d. For example, sind(x) computes the sine of x where x is specified in degrees. The complete list of trigonometric functions with degree variants is:

sind   cosd   tand   cotd   secd   cscd
asind  acosd  atand  acotd  asecd  acscd

Funzioni speciali

Function   Description
gamma(x)   gamma function at x
lgamma(x)  accurate log(gamma(x)) for large x
lfact(x)   accurate log(factorial(x)) 
           for large x; same as lgamma(x+1) 
           for x > 1, zero otherwise
beta(x,y)  beta function at x,y
lbeta(x,y) accurate log(beta(x,y)) for large x or y


Post a comment or leave a trackback: Trackback URL.



Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: