Modul:Math
Modul zur Berechnung mathematischer Funktionen, welche nicht im WP-Standard enthalten sind. Bei erlaubten Argumenten wird das Ergebnis zurückgegeben, ansonsten eine leere Zeichenkette.
Zurzeit implementiert:
- Math.sinh: Sinus hyperbolicus
- Math.cosh: Kosinus hyperbolicus
- Math.tanh: Tangens hyperbolicus
- Math.coth: Kotangens hyperbolicus
- Math.arsinh: Area Sinus hyperbolicus
- Math.arcosh: Area Kosinus hyperbolicus
- Math.artanh: Area Tangens hyperbolicus
- Math.arcoth: Area Kotangens hyperbolicus
-- to catch wrong input, the code doesn't use math.sinh and math.cosh directly
local function sinh(x)
-- Sinus hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
local value = (math.exp (x) - math.exp (0 - x)) / 2
if value then
return value, true
else
return 0, false
end
end
local function cosh(x)
-- Cosinus hyperbolicus
x = tonumber(x) or false;
if not x then return 1, false; end
local value = (math.exp (x) + math.exp (0 - x)) / 2
if value then
return value, true
else
return 1, false
end
end
local function tanh(x)
-- Tangens hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
local s = sinh(x);
local c = cosh(x);
if c ~= 0 then
local value = s / c
if value then
return value, true
else
return 0, false
end
else
return 0, false
end
end
local function coth(x)
-- Kotangens hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
local s = sinh(x);
local c = cosh(x);
if s ~= 0 then
local value = c / s;
if value then
return value, true
else
return 0, false
end
else
return 0, false
end
end
local function arsinh(x)
-- Area sinus hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
local value = math.ln (x + math.sqrt(x * x + 1))
if value then
return value, true
else
return 0, false
end
end
local function arcosh(x)
-- Area Kosinus hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
if x <= 1 then return 0, false; end
local value = math.ln (x + math.sqrt(x * x - 1))
if value then
return value, true
else
return 0, false
end
end
local function artanh(x)
-- Area tangens hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
if math.abs(x) >= 1 then return 0, false; end
local value = math.ln ((1+x)/(1-x)) / 2
if value then
return value, true
else
return 0, false
end
end
local function arcoth(x)
-- Area Kotangens hyperbolicus
x = tonumber(x) or false;
if not x then return 0, false; end
if math.abs(x) <= 1 then return 0, false; end
local value = math.ln ((x+1)/(x-1)) / 2
if value then
return value, true
else
return 0, false
end
end
local Math = { };
function Math.sinh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = sinh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.cosh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = cosh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.tanh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = tanh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.coth( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = coth(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.arsinh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = arsinh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.arcosh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = arcosh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.artanh( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = artanh(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
function Math.arcoth( frame )
local data = tonumber(frame.args[1]) or false;
if data then
local value, isOk = arcoth(data);
if isOk then
return tostring(value);
else
return "" -- error
end
else
return "" -- error
end
end
return Math
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.