loganmatic
Advanced tools
Comparing version 1.1.4 to 1.1.5
"use strict"; | ||
var piValue = "3.1415926535897932384626433832795"; | ||
var Calculator = (function () { | ||
function Calculator() { | ||
this.EulerNumber = this.createEulerNumber(); | ||
this.Pi = parseFloat(piValue); | ||
} | ||
Calculator.prototype.createEulerNumber = function (n) { | ||
if (n === void 0) { n = 9999; } | ||
var sumStart = 0; | ||
var emptyValue = 0; | ||
for (var k = sumStart; k < n + 1; k++) { | ||
var series = Math.pow(1, k) / this.factorial(k); | ||
emptyValue += series; | ||
} | ||
return emptyValue; | ||
}; | ||
Calculator.prototype.newtonMethod = function (valueA, valueB, valueC, valueD, checkedYes) { | ||
var derivedValueA = valueA * 3; | ||
var derivedValueB = valueB * 2; | ||
var derivedValueC = valueC * 1; | ||
var delta = Math.pow(derivedValueB, 2) - 4 * derivedValueA * derivedValueC; | ||
var answer1 = (-derivedValueB + Math.pow(delta, (1 / 2))) / (2 * derivedValueA); | ||
var answer2 = (-derivedValueB - Math.pow(delta, (1 / 2))) / (2 * derivedValueA); | ||
var criticalPoint1 = answer1 * 1000; | ||
var criticalPoint2 = answer2 * 1000; | ||
if (answer1 < 0 && answer2 < 0) { | ||
criticalPoint1 = criticalPoint2 * -1; | ||
} | ||
else if (answer1 > 0 && answer2 > 0) { | ||
criticalPoint1 = criticalPoint2 * -1; | ||
} | ||
function generateCriticalPointInterval(min, max) { | ||
return Math.random() * (max - min + 1) + min; | ||
} | ||
var criticalPoint3; | ||
if (answer1 > answer2) { | ||
if (Number(answer1) - Number(answer2) > 1) { | ||
criticalPoint3 = generateCriticalPointInterval(Math.ceil(Number(answer2) + 0.2), Number(answer1)); | ||
} | ||
else { | ||
criticalPoint3 = generateCriticalPointInterval(Number(answer2) + 0.2, Number(answer1)); | ||
} | ||
} | ||
else { | ||
if (Number(answer2) - Number(answer1) > 1) { | ||
criticalPoint3 = generateCriticalPointInterval(Math.ceil(Number(answer1) + 0.2), Number(answer2)); | ||
} | ||
else { | ||
criticalPoint3 = generateCriticalPointInterval(Number(answer1) + 0.2, Number(answer2)); | ||
} | ||
} | ||
if (delta < 0) { | ||
criticalPoint1 = -10000; | ||
criticalPoint2 = 9000; | ||
} | ||
var firstRootCritical = []; | ||
var iterations = 100000; | ||
for (var index = 0; index < iterations; index++) { | ||
criticalPoint1 = | ||
criticalPoint1 - | ||
(Number(valueA) * Math.pow(criticalPoint1, 3) + | ||
Number(valueB) * Math.pow(criticalPoint1, 2) + | ||
Number(valueC) * criticalPoint1 + | ||
Number(valueD)) / | ||
(Number(derivedValueA) * Math.pow(criticalPoint1, 2) + | ||
Number(derivedValueB) * criticalPoint1 + | ||
Number(derivedValueC)); | ||
var functionValue1 = (Number(valueA) * Math.pow(criticalPoint1, 3) + | ||
Number(valueB) * Math.pow(criticalPoint1, 2) + | ||
Number(valueC) * criticalPoint1 + | ||
Number(valueD)).toFixed(10); | ||
criticalPoint2 = | ||
criticalPoint2 - | ||
(Number(valueA) * Math.pow(criticalPoint2, 3) + | ||
Number(valueB) * Math.pow(criticalPoint2, 2) + | ||
Number(valueC) * criticalPoint2 + | ||
Number(valueD)) / | ||
(Number(derivedValueA) * Math.pow(criticalPoint2, 2) + | ||
Number(derivedValueB) * criticalPoint2 + | ||
Number(derivedValueC)); | ||
var functionValue2 = (Number(valueA) * Math.pow(criticalPoint2, 3) + | ||
Number(valueB) * Math.pow(criticalPoint2, 2) + | ||
Number(valueC) * criticalPoint2 + | ||
Number(valueD)).toFixed(10); | ||
criticalPoint3 = | ||
criticalPoint3 - | ||
(Number(valueA) * Math.pow(criticalPoint3, 3) + | ||
Number(valueB) * Math.pow(criticalPoint3, 2) + | ||
Number(valueC) * criticalPoint3 + | ||
Number(valueD)) / | ||
(Number(derivedValueA) * Math.pow(criticalPoint3, 2) + | ||
Number(derivedValueB) * criticalPoint3 + | ||
Number(derivedValueC)); | ||
if (parseFloat(functionValue1) === 0.0 && | ||
parseFloat(functionValue2) === 0.0) { | ||
firstRootCritical.push(criticalPoint1, criticalPoint2, criticalPoint3); | ||
break; | ||
} | ||
} | ||
if (firstRootCritical[0].toFixed(7) == firstRootCritical[1].toFixed(7)) { | ||
if (checkedYes) { | ||
return { | ||
value: [firstRootCritical[0]], | ||
msg: "It has only 1 real root in X = ".concat(firstRootCritical[0].toFixed(4)), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [firstRootCritical[0]], | ||
msg: "It has only 1 real root in X = ".concat(firstRootCritical[0]), | ||
}; | ||
} | ||
} | ||
else if (firstRootCritical[0].toFixed(4) == firstRootCritical[2].toFixed(4)) { | ||
this.newtonMethod(valueA, valueB, valueC, valueD, checkedYes); | ||
} | ||
else if (firstRootCritical[1].toFixed(4) == firstRootCritical[2].toFixed(4)) { | ||
this.newtonMethod(valueA, valueB, valueC, valueD, checkedYes); | ||
} | ||
else { | ||
if (checkedYes) { | ||
return { | ||
value: [ | ||
firstRootCritical[0], | ||
firstRootCritical[1], | ||
firstRootCritical[2], | ||
], | ||
msg: "X1 \u2245 ".concat(firstRootCritical[0].toFixed(4), ", X2 \u2245 ").concat(firstRootCritical[1].toFixed(4), ", X3 \u2245 ").concat(firstRootCritical[2].toFixed(4)), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [ | ||
firstRootCritical[0], | ||
firstRootCritical[1], | ||
firstRootCritical[2], | ||
], | ||
msg: "X1 \u2245 ".concat(firstRootCritical[0], ", X2 \u2245 ").concat(firstRootCritical[1], ", X3 \u2245 ").concat(firstRootCritical[2]), | ||
}; | ||
} | ||
} | ||
return { | ||
value: [firstRootCritical[0]], | ||
msg: "X1 = ".concat(firstRootCritical[0]), | ||
}; | ||
}; | ||
Calculator.prototype.ruffiniDevice = function (valueA, valueB, valueC, valueD, raizes, checkedYes) { | ||
var first = valueA * raizes[0]; | ||
var secondCoefficient = Number(first) + Number(valueB); | ||
var second = secondCoefficient * raizes[0]; | ||
var thirdCoefficient = Number(second) + Number(valueC); | ||
var third = thirdCoefficient * raizes[0]; | ||
var fourthCoefficient = Number(third) + Number(valueD); | ||
if (fourthCoefficient == 0) { | ||
var delta = Math.pow(secondCoefficient, 2) - 4 * valueA * thirdCoefficient; | ||
if (delta < 0) { | ||
return { | ||
value: [0], | ||
msg: "It has only 1 real root in X = ".concat(raizes[0]), | ||
}; | ||
} | ||
else { | ||
var answer1 = (-secondCoefficient + Math.pow(delta, (1 / 2))) / (2 * valueA); | ||
var answer2 = (-secondCoefficient - Math.pow(delta, (1 / 2))) / (2 * valueA); | ||
if (delta === 0) { | ||
if (answer1 == raizes[0]) { | ||
return { | ||
value: [0], | ||
msg: "The value of X1 = 0 | X1 = X2 = X3", | ||
}; | ||
} | ||
else { | ||
if (checkedYes) { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 is equal to: ".concat(answer1.toFixed(2), " | X2 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 is equal to: ".concat(answer1, " | X2 = X3"), | ||
}; | ||
} | ||
} | ||
} | ||
else { | ||
if (answer1 == raizes[0]) { | ||
if (checkedYes) { | ||
return { | ||
value: [raizes[0], answer2], | ||
msg: "The value of X1 = ".concat(raizes[0], " and X2 = ").concat(answer2.toFixed(2), " | X1 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [raizes[0], answer2], | ||
msg: "The value of X1 = ".concat(raizes[0], " and X2 = ").concat(answer2, " | X1 = X3"), | ||
}; | ||
} | ||
} | ||
else if (answer2 == raizes[0]) { | ||
if (checkedYes) { | ||
return { | ||
value: [raizes[0], answer1], | ||
msg: "The value of X1 = ".concat(raizes[0], " and X2 it's the same as: ").concat(answer1.toFixed(2), " | X1 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [raizes[0], answer1], | ||
msg: "The value of X1 = ".concat(raizes[0], " and X2 it's the same as: ").concat(answer1, " | X1 = X3"), | ||
}; | ||
} | ||
} | ||
else { | ||
if (checkedYes) { | ||
return { | ||
value: [raizes[0], answer1, answer2], | ||
msg: "The value of X1 = ".concat(raizes[0], ", X2 it's the same as: ").concat(answer1.toFixed(2), " and The value of X3 it's the same as: ").concat(answer2.toFixed(2)), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [raizes[0], answer1, answer2], | ||
msg: "The value of X1 = ".concat(raizes[0], ", X2 it's the same as: ").concat(answer1, " and The value of X3 it's the same as: ").concat(answer2), | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (fourthCoefficient != 0) { | ||
return this.newtonMethod(valueA, valueB, valueC, valueD, checkedYes); | ||
} | ||
else { | ||
return { | ||
value: null, | ||
msg: "Vish, I don't know what happened HEHEHE", | ||
}; | ||
} | ||
}; | ||
Calculator.prototype.absoluteValue = function (number) { | ||
if (number < 0) { | ||
return -number; | ||
} | ||
else { | ||
return number; | ||
} | ||
}; | ||
Calculator.prototype.factorial = function (valueToCalculate) { | ||
if (valueToCalculate === 0) { | ||
return 1; | ||
} | ||
var result = 1; | ||
for (var i = 1; i <= valueToCalculate; i++) { | ||
result *= i; | ||
} | ||
return result; | ||
}; | ||
Calculator.prototype.squareRoot = function (valueToCalculate) { | ||
return Math.pow(valueToCalculate, (1 / 2)); | ||
}; | ||
Calculator.prototype.cubicRoot = function (valueToCalculate) { | ||
var convertToPositive = this.absoluteValue(valueToCalculate); | ||
var result = Math.pow(convertToPositive, (1 / 3)); | ||
if (valueToCalculate < 0) { | ||
return result * -1; | ||
} | ||
else { | ||
return result; | ||
} | ||
}; | ||
Calculator.prototype.factor = function (valueToCalculate) { | ||
if (typeof valueToCalculate !== "number") { | ||
return console.log("This is not an integer"); | ||
} | ||
var factoredNumbers = []; | ||
for (var y = 2; y < valueToCalculate; y++) { | ||
while (valueToCalculate % y === 0) { | ||
valueToCalculate /= y; | ||
factoredNumbers.push(y); | ||
} | ||
} | ||
if (factoredNumbers.length === 0) { | ||
factoredNumbers.push(valueToCalculate); | ||
} | ||
return factoredNumbers; | ||
}; | ||
Calculator.prototype.sine = function (valueToCalculate) { | ||
var n; | ||
if (this.absoluteValue(valueToCalculate) > 5 && | ||
this.absoluteValue(valueToCalculate) <= 30) { | ||
n = 100; | ||
} | ||
else if (this.absoluteValue(valueToCalculate) > 30) { | ||
n = 40; | ||
} | ||
else { | ||
n = 200; | ||
} | ||
var startSum = 0; | ||
var emptyValue = 0; | ||
for (var k = startSum; k < n + 1; k++) { | ||
var series = (Math.pow((-1), k) * Math.pow(valueToCalculate, (2 * k + 1))) / | ||
this.factorial(2 * k + 1); | ||
emptyValue += series; | ||
} | ||
if (this.absoluteValue(emptyValue) < 0.00000001) { | ||
return 0; | ||
} | ||
else { | ||
return emptyValue; | ||
} | ||
}; | ||
Calculator.prototype.cosine = function (valueToCalculate) { | ||
var n; | ||
if (this.absoluteValue(valueToCalculate) > 5 && | ||
this.absoluteValue(valueToCalculate) <= 30) { | ||
n = 100; | ||
} | ||
else if (this.absoluteValue(valueToCalculate) > 30) { | ||
n = 40; | ||
} | ||
else { | ||
n = 200; | ||
} | ||
var startSum = 0; | ||
var emptyValue = 0; | ||
for (var k = startSum; k < n + 1; k++) { | ||
var series = (Math.pow((-1), k) * Math.pow(valueToCalculate, (2 * k))) / this.factorial(2 * k); | ||
emptyValue += series; | ||
} | ||
if (this.absoluteValue(emptyValue) < 0.00000001) { | ||
return 0; | ||
} | ||
else { | ||
return emptyValue; | ||
} | ||
}; | ||
Calculator.prototype.gcd = function (valuesToCalculate) { | ||
var mdcValue = valuesToCalculate[0]; | ||
for (var i = 1; i < valuesToCalculate.length; i++) { | ||
var a = mdcValue; | ||
var b = valuesToCalculate[i]; | ||
var rest = void 0; | ||
while (b !== 0) { | ||
rest = a % b; | ||
a = b; | ||
b = rest; | ||
} | ||
mdcValue = a; | ||
} | ||
return this.absoluteValue(mdcValue); | ||
}; | ||
Calculator.prototype.lcm = function (valuesToCalculate) { | ||
var mmcValue = valuesToCalculate[0]; | ||
for (var i = 1; i < valuesToCalculate.length; i++) { | ||
var a = mmcValue; | ||
var b = valuesToCalculate[i]; | ||
var rest = void 0; | ||
var mdcValue = a; | ||
while (b !== 0) { | ||
rest = a % b; | ||
a = b; | ||
b = rest; | ||
} | ||
mmcValue = (mdcValue * valuesToCalculate[i]) / a; | ||
} | ||
return this.absoluteValue(mmcValue); | ||
}; | ||
Calculator.prototype.randomNumberBetween = function (min, max) { | ||
var timestamp = Date.now(); | ||
return min + (timestamp % (max - min + 1)); | ||
}; | ||
Calculator.prototype.linearEquation = function (a, b) { | ||
var numberA = Number(a); | ||
var numberB = Number(b); | ||
if (numberA === 0) { | ||
return { | ||
value: null, | ||
msg: "The value of 'a' cannot be 0", | ||
}; | ||
} | ||
var root = -numberB / numberA; | ||
return { | ||
value: root, | ||
msg: "The value of x is the same as: ".concat(root), | ||
}; | ||
}; | ||
Calculator.prototype.quadraticEquation = function (a, b, c) { | ||
var numberA = Number(a); | ||
var numberB = Number(b); | ||
var numberC = Number(c); | ||
if (Math.pow(numberB, 2) - 4 * numberA * numberC < 0) | ||
return { | ||
value: null, | ||
msg: "The equation does not have real roots", | ||
}; | ||
if (numberA === 0 && numberB === 0) { | ||
return { | ||
value: null, | ||
msg: "The values of 'a' and 'b' cannot be 0 at the same time", | ||
}; | ||
} | ||
else { | ||
var root1 = (-numberB + this.squareRoot(Math.pow(b, 2) - 4 * numberA * numberC)) / | ||
(2 * numberA); | ||
var root2 = (-numberB - this.squareRoot(Math.pow(b, 2) - 4 * numberA * numberC)) / | ||
(2 * numberA); | ||
if (root1 === root2) { | ||
return { | ||
value: [root1], | ||
msg: "It has only 1 real root in X = ".concat(root1), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [root1, root2], | ||
msg: "The value of X1 = ".concat(root1, " and X2 = ").concat(root2), | ||
}; | ||
} | ||
} | ||
}; | ||
Calculator.prototype.cubicEquation = function (a, b, c, d, approximate) { | ||
if (a === void 0) { a = 0; } | ||
if (b === void 0) { b = 0; } | ||
if (c === void 0) { c = 0; } | ||
if (d === void 0) { d = 0; } | ||
if (approximate === void 0) { approximate = false; } | ||
var checkedYes = approximate; | ||
var valueA = Number(a); | ||
var valueB = Number(b); | ||
var valueC = Number(c); | ||
var valueD = Number(d); | ||
if (valueD == 0) { | ||
var x1 = 0; | ||
var delta = Math.pow(valueB, 2) - 4 * valueA * valueC; | ||
if (delta < 0) { | ||
return { | ||
value: [0], | ||
msg: "It has only 1 real root in X = 0", | ||
}; | ||
} | ||
else { | ||
var answer1 = (-valueB + Math.pow(delta, (1 / 2))) / (2 * valueA); | ||
var answer2 = (-valueB - Math.pow(delta, (1 / 2))) / (2 * valueA); | ||
if (delta === 0) { | ||
if (answer1 == x1) { | ||
return { | ||
value: [0], | ||
msg: "The value of X1 = 0 | X1 = X2 = X3", | ||
}; | ||
} | ||
else { | ||
if (checkedYes) { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 is equal to: ".concat(answer1.toFixed(2), " | X2 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 is equal to: ".concat(answer1, " | X2 = X3"), | ||
}; | ||
} | ||
} | ||
} | ||
else { | ||
if (answer1 == x1) { | ||
if (checkedYes) { | ||
return { | ||
value: [0, answer2], | ||
msg: "The value of X1 = 0 and X2 = ".concat(answer2.toFixed(2), " | X1 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [0, answer2], | ||
msg: "The value of X1 = 0 and X2 = ".concat(answer2, " | X1 = X3"), | ||
}; | ||
} | ||
} | ||
else if (answer2 == x1) { | ||
if (checkedYes) { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 = ".concat(answer1.toFixed(2), " | X1 = X3"), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [0, answer1], | ||
msg: "The value of X1 = 0 and X2 is equal to: ".concat(answer1, " | X1 = X3"), | ||
}; | ||
} | ||
} | ||
else { | ||
if (checkedYes) { | ||
return { | ||
value: [0, answer1, answer2], | ||
msg: "The value of X1 = 0, X2 it's the same as: ".concat(answer1.toFixed(2), " and The value of X3 it's the same as: ").concat(answer2.toFixed(2)), | ||
}; | ||
} | ||
else { | ||
return { | ||
value: [0, answer1, answer2], | ||
msg: "The value of X1 = 0, X2 it's the same as: ".concat(answer1, " and The value of X3 it's the same as: ").concat(answer2), | ||
}; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else { | ||
var possibleRoots = []; | ||
if (valueD > 0) { | ||
for (var index = 1; index < Number(valueD) + 1; index++) { | ||
var isInteger = valueD % index; | ||
if (isInteger == 0) { | ||
possibleRoots.push(index); | ||
possibleRoots.push(-index); | ||
} | ||
} | ||
} | ||
else { | ||
for (var index = -1; index > Number(valueD) - 1; index--) { | ||
var isInteger = valueD % index; | ||
if (isInteger == 0) { | ||
possibleRoots.push(index); | ||
possibleRoots.push(-index); | ||
} | ||
} | ||
} | ||
var raizes_1 = []; | ||
possibleRoots.forEach(function (test) { | ||
var primeiraRaiz = Number(valueA) * Math.pow(test, 3) + | ||
Number(valueB) * Math.pow(test, 2) + | ||
Number(valueC) * test + | ||
Number(valueD); | ||
if (primeiraRaiz == 0) { | ||
raizes_1.push(test); | ||
} | ||
}); | ||
if (raizes_1.length === 0) { | ||
return this.newtonMethod(valueA, valueB, valueC, valueD, checkedYes); | ||
} | ||
return this.ruffiniDevice(valueA, valueB, valueC, valueD, raizes_1, checkedYes); | ||
} | ||
}; | ||
return Calculator; | ||
}()); | ||
module.exports = new Calculator(); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Main_1 = __importDefault(require("./Main")); | ||
var calculator = new Main_1.default(); | ||
exports.default = calculator; |
{ | ||
"name": "loganmatic", | ||
"version": "1.1.4", | ||
"description": "Biblioteca de matematica com algumas funções para facilitar calculos", | ||
"publisher": "Gabriel Logan", | ||
"main": "./dist/loganmatic.js", | ||
"types": "./types/loganmatic.d.ts", | ||
"scripts": { | ||
"test": "npx jest --coverage --verbose", | ||
"name": "loganmatic", | ||
"version": "1.1.5", | ||
"description": "Math library with some functions to facilitate calculations", | ||
"publisher": "Gabriel Logan", | ||
"main": "./dist/loganmatic.js", | ||
"types": "./types/loganmatic.d.ts", | ||
"scripts": { | ||
"test": "npx jest --coverage --verbose", | ||
"test:watch": "npx jest --watch", | ||
"build": "npx tsc", | ||
"build:types": "tsc -p tsconfig.types.json" | ||
}, | ||
"keywords": [ | ||
"matemática", | ||
"cálculo", | ||
"funções", | ||
"biblioteca" | ||
], | ||
"author": { | ||
"name": "Gabriel Logan", | ||
"url": "https://github.com/gabriel-logan/Math_Lib/" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/gabriel-logan/Math_Lib//issues" | ||
}, | ||
"homepage": "https://github.com/gabriel-logan/Math_Lib/#readme", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.2", | ||
"typescript": "^5.4.3" | ||
} | ||
"build": "npx tsc", | ||
"build:types": "tsc -p tsconfig.types.json" | ||
}, | ||
"keywords": [ | ||
"math", | ||
"calculation", | ||
"functions", | ||
"library", | ||
"mathematics", | ||
"algebra", | ||
"geometry", | ||
"trigonometry", | ||
"matematica", | ||
"calculo", | ||
"funcoes", | ||
"biblioteca", | ||
"equations", | ||
"equacoes" | ||
], | ||
"author": { | ||
"name": "Gabriel Logan", | ||
"url": "https://github.com/gabriel-logan/Math_Lib/" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/gabriel-logan/Math_Lib/issues" | ||
}, | ||
"homepage": "https://gabriel-logan.github.io/Math_Lib/typescript", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/jest": "^29.5.12", | ||
"@typescript-eslint/eslint-plugin": "^7.4.0", | ||
"@typescript-eslint/parser": "^7.4.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-prettier": "^5.1.3", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.2.5", | ||
"ts-jest": "^29.1.2", | ||
"typescript": "^5.4.3" | ||
} | ||
} |
@@ -1,171 +0,3 @@ | ||
import { ReturnTypesForEquation, ReturnTypesForEquation2upDegree } from "./types/loganmatic"; | ||
/** | ||
* @author - Gabriel Logan | ||
* @description - Program created as a math library in English | ||
* @example - import Mathematics from "loganmatic" | ||
* console.log(Mathematics.Pi) | ||
*/ | ||
declare class Calculator { | ||
EulerNumber: number; | ||
Pi: number; | ||
constructor(); | ||
/** | ||
* Method to calculate the absoluteValue value of a number | ||
* @param n - Precision of the euler number | ||
* @example Mathematics.createEulerNumber(99999); will create an euler number with 99999 sums, be careful | ||
* this can freeze your pc, very large numbers result in delay to find the value | ||
* @return - Euler Number | ||
*/ | ||
protected createEulerNumber(n?: number): number; | ||
/** | ||
* @param valueA | ||
* @param valueB | ||
* @param valueC | ||
* @param valueD | ||
* @param checkedYes | ||
*/ | ||
protected newtonMethod(valueA: number, valueB: number, valueC: number, valueD: number, checkedYes: boolean): { | ||
value: number[]; | ||
msg: string; | ||
}; | ||
/** | ||
* @param valueA | ||
* @param valueB | ||
* @param valueC | ||
* @param valueD | ||
* @param raizes | ||
* @param checkedYes | ||
*/ | ||
protected ruffiniDevice(valueA: number, valueB: number, valueC: number, valueD: number, raizes: number[], checkedYes: boolean): { | ||
value: number[]; | ||
msg: string; | ||
} | { | ||
value: null; | ||
msg: string; | ||
}; | ||
/** | ||
* Method for calculating the absoluteValue value of a number | ||
* @param number - The number to calculate the module | ||
* @example Matematics.absoluteValue(-4) | ||
* @return - The result = 4 | ||
*/ | ||
absoluteValue(number: number): number; | ||
/** | ||
* Method to calculate the factorial of a number | ||
* @param valueToCalculate - The number to calculate the factorial | ||
* @example Matematics.factorial(4) | ||
* @return - The result of the factorial which is 24 | ||
*/ | ||
factorial(valueToCalculate: number): number; | ||
/** | ||
* Method to calculate the square root of a number | ||
* @param valueToCalculate - The number to calculate the square root | ||
* @example Matematics.squareRoot(9) | ||
* @return - The result of the square root = 3 | ||
*/ | ||
squareRoot(valueToCalculate: number): number; | ||
/** | ||
* Method to calculate the cubic root of a number | ||
* @param valueToCalculate - The number to calculate the cubic root | ||
* @example Matematics.cubicRoot(8) | ||
* @return - The result of the cubic root = 2 | ||
*/ | ||
cubicRoot(valueToCalculate: number): number; | ||
/** | ||
* Method to factor a number | ||
* @param valueToCalculate - The number to be factored | ||
* @example Matematics.factor(100) | ||
* @return - An array with the factors of the number [2, 2, 5, 5] | ||
*/ | ||
factor(valueToCalculate: number): void | number[]; | ||
/** | ||
* Method to calculate the sine of a number | ||
* @param valueToCalculate - The number to calculate the sine | ||
* @example Matematics.sine(Matematics.Pi) | ||
* @return - The result = 0 because the sine of pi(180 degrees) = 0 | ||
*/ | ||
sine(valueToCalculate: number): number; | ||
/** | ||
* Method to calculate the cosine of a number | ||
* @param valueToCalculate - The number to calculate the cosine | ||
* @example Matematics.cosine(Matematics.Pi) | ||
* @return - The result = 0 because the cosine of pi(180 degrees) = 0 | ||
*/ | ||
cosine(valueToCalculate: number): number; | ||
/** | ||
* Method to calculate the gcd | ||
* @param valuesToCalculate - The numbers to calculate the gcd | ||
* @example Matematics.gcd([4,8]) | ||
* @return - The result = 4 because the gcd of 4 and 8 = 4 | ||
*/ | ||
gcd(valuesToCalculate: number[]): number; | ||
/** | ||
* Method to calculate the lcm | ||
* @param valuesToCalculate - The numbers to calculate the lcm | ||
* @example Matematics.lcm([4,8]) | ||
* @return - The result = 8 because the lcm of 4 and 8 = 8 | ||
*/ | ||
lcm(valuesToCalculate: number[]): number; | ||
/** | ||
* Method to generate a random number between two values | ||
* @param min - The minimum value | ||
* @param max - The maximum value | ||
* @example Matematics.randomNumberBetween(1, 10) | ||
* @return - A random number between 1 and 10 | ||
*/ | ||
randomNumberBetween(min: number, max: number): number; | ||
/** | ||
* Method to calculate the root of a first degree polynomial | ||
* @param a | ||
* @param b | ||
* @example Mathematics.linearEquation(a, b) | ||
* | ||
* a = term that accompanies the (x) | ||
* and b = independent term | ||
* | ||
* EX: ax + b = 0 or 2x + 3 = 0 | a=2 and b=3 | ||
* | ||
* Mathematics.linearEquation(2, 3) | ||
* @return - The result = x = -3/2 = -1.5 | ||
*/ | ||
linearEquation(a: number, b: number): ReturnTypesForEquation; | ||
/** | ||
* Method to calculate the root of a first-degree polynomial | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @example Mathematics.quadraticEquation(a, b, c) | ||
* | ||
* a = coefficient of (x^2) | ||
* b = coefficient of (x) | ||
* c = constant term | ||
* | ||
* EX: a(x^2) + b(x) + c = 0 | ||
* | ||
* 1(x^2) + 2(x) - 3 = 0 | a = 1, b = 2, c = -3 | ||
* | ||
* Mathematics.quadraticEquation(1, 2, -3) | ||
* @return - The result = [1, -3] | ||
*/ | ||
quadraticEquation(a: number, b: number, c: number): ReturnTypesForEquation2upDegree; | ||
/** | ||
* Method to calculate the root of a third-degree polynomial | ||
* @param a | ||
* @param b | ||
* @param c | ||
* @param d | ||
* @param [approximate=false] | ||
* @example Mathematics.cubicEquation(a, b, c, d) | ||
* | ||
* a = coefficient of (x^3) | ||
* b = coefficient of (x^2) | ||
* c = coefficient of (x) | ||
* d = constant term | ||
* | ||
* Mathematics.cubicEquation(1, 2, -3, 5) | ||
* @return - It has only 1 real root in X = -3.344171229347796 | ||
*/ | ||
cubicEquation(a?: number, b?: number, c?: number, d?: number, approximate?: boolean): ReturnTypesForEquation2upDegree; | ||
} | ||
declare const _default: Calculator; | ||
export = _default; | ||
import Calculator from "./Main"; | ||
declare const calculator: Calculator; | ||
export default calculator; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36428
9
866
1