Category talk:Wren-math: Difference between revisions

Content added Content deleted
(→‎Source code: Removed a constant which is now in the core library.)
(Bug fixes, restoration of static Math.min/max methods and addition of Math.atan.)
Line 14: Line 14:


// Hyperbolic trig functions.
// Hyperbolic trig functions.
static sinh(x) { (exp(x) - exp(-x))/2 } // sine
static sinh(x) { (x.exp - (-x).exp)/2 } // sine
static cosh(x) { (exp(x) + exp(-x))/2 } // cosine
static cosh(x) { (x.exp + (-x).exp)/2 } // cosine
static tanh(x) { sinh(x)/cosh(x) } // tangent
static tanh(x) { sinh(x)/cosh(x) } // tangent


Line 82: Line 82:
var sum = p[0]
var sum = p[0]
for (i in 0..7) sum = sum + p[i+1]/(x + i)
for (i in 0..7) sum = sum + p[i+1]/(x + i)
return 2.sqrt * Num.pi.sqrt * t.pow(x-0.5) * Math.exp(-t) * sum
return 2.sqrt * Num.pi.sqrt * t.pow(x-0.5) * (-t).exp * sum
}
}

// Static alternatives to instance methods in Num class.
// Clearer when both arguments are complex expressions.
static min(x, y) { (x < y) ? x : y }
static max(x, y) { (x > y) ? x : y }
static atan(x, y) { x.atan(y) }
}
}