From 0e22a554e0e7da5d66f39e0d8e6fbeddc7ce0175 Mon Sep 17 00:00:00 2001 From: Choi Junho Date: Tue, 4 May 2021 23:37:56 +0900 Subject: [PATCH] Update --- README.md | 4 +-- package-lock.json | 2 +- package.json | 2 +- src/2d/circle/circle.js | 22 ++++++++-------- src/2d/hexagon/hexagon.js | 2 +- src/2d/oval/oval.js | 4 +-- src/2d/pentagon/pentagon.js | 6 ++--- src/2d/polygon/polygon.js | 12 ++++----- src/2d/rectangle/rectangle.js | 16 +++++------ src/2d/triangle/pytagoras_004.js | 24 ----------------- src/2d/triangle/triangle.js | 28 +++++++++++++++----- src/3d/cone/cone.js | 4 +-- src/3d/cube/cube.js | 10 +++---- src/3d/cylinder/cylinder.js | 4 +-- src/3d/polyhedron/polyhedron.js | 2 +- src/3d/pyramid/pyramid.js | 12 ++++----- src/3d/sphere/sphere.js | 4 +-- src/3d/tetrahedron/tetrahedron.js | 6 ++--- src/angle/angle.js | 2 +- src/calc/calc.js | 28 ++++++++++---------- src/calculus/calculus.js | 4 +-- src/equation/equation.js | 12 ++++----- src/matrix/matrix.js | 44 +++++++++++++++---------------- src/others/others.js | 4 +-- src/progress/progress.js | 40 ++++++++++++++-------------- src/vector/vector.js | 4 +-- 26 files changed, 146 insertions(+), 156 deletions(-) delete mode 100644 src/2d/triangle/pytagoras_004.js diff --git a/README.md b/README.md index f53bdac..902b463 100644 --- a/README.md +++ b/README.md @@ -28,9 +28,9 @@ For more information, contact minseo0388@daum.net or 129dot03@kakao.com. **Published as `Naesungmath` at npmjs.org** -**최신 안정화 버전은 `2.0.0` 입니다.** +**최신 안정화 버전은 `2.1.0` 입니다.** -**The latest stabilized version is `2.0.0`.** +**The latest stabilized version is `2.1.0`.** ### Update Notice diff --git a/package-lock.json b/package-lock.json index e1c7433..82844b2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "naesungmath", - "version": "1.0.0", + "version": "2.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 378efc4..7907beb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "naesungmath", - "version": "2.0.0", + "version": "2.1.0", "description": "Math and Science", "main": "/src/math.js", "scripts": { diff --git a/src/2d/circle/circle.js b/src/2d/circle/circle.js index beb3262..be3551e 100644 --- a/src/2d/circle/circle.js +++ b/src/2d/circle/circle.js @@ -9,7 +9,7 @@ * @return {number} Inscribed circle and triangle area formula * */ -exports.inscribedCircleTriangleArea = function (a, b, c, r) { +export function inscribedCircleTriangleArea(a, b, c, r) { return (((a + b + c) / 2) * r) } @@ -24,7 +24,7 @@ exports.inscribedCircleTriangleArea = function (a, b, c, r) { * @return {number} Inscribed circle and triangle area formula * */ -exports.circumscribedCircleTriangleArea_Side = function (a, b, c, r) { +export function circumscribedCircleTriangleArea_Side(a, b, c, r) { return (a * b * c / 4 / r) } @@ -39,7 +39,7 @@ exports.circumscribedCircleTriangleArea_Side = function (a, b, c, r) { * @return {number} Inscribed circle and triangle area formula * */ -exports.circumscribedCircleTriangleArea_Angle = function (a, b, c, r) { +export function circumscribedCircleTriangleArea_Angle(a, b, c, r) { return (2 * r * r * (Math.sin(a)) * (Math.sin(b)) * (Math.sin(c))) } @@ -51,7 +51,7 @@ exports.circumscribedCircleTriangleArea_Angle = function (a, b, c, r) { * @return {number} The area of circle * */ -exports.circleArea = function (r) { +export function circleArea(r) { return ((Math.PI) * (r ** 2)) } @@ -63,7 +63,7 @@ exports.circleArea = function (r) { * @return {number} The circumstance of circle * */ -exports.circlePerimeter = function (r) { +export function circlePerimeter(r) { return (2 * (Math.PI) * r) } @@ -75,7 +75,7 @@ exports.circlePerimeter = function (r) { * @return {number} The center angle of circumferential angle * */ -exports.circumference = function (a) { +export function circumference(a) { return (2 * a) } @@ -88,7 +88,7 @@ exports.circumference = function (a) { * @return {number} The center angle of sector form (radian) * */ -exports.circularSectorAngle = function (r, l) { +export function circularSectorAngle(r, l) { return (l / r) } @@ -101,7 +101,7 @@ exports.circularSectorAngle = function (r, l) { * @return {number} THe area of sector form * */ -exports.circularSectorArea_rt = function (r, t) { +export function circularSectorArea_rt(r, t) { return (0.5 * r * (t ** 2)) } @@ -114,7 +114,7 @@ exports.circularSectorArea_rt = function (r, t) { * @return {number} The area of sector form * */ -exports.circularSectorArea_rl = function (r, l) { +export function circularSectorArea_rl(r, l) { return (0.5 * r * l) } @@ -127,7 +127,7 @@ exports.circularSectorArea_rl = function (r, l) { * @return {number} The length of arc * */ -exports.arcLength = function (r, l) { +export function arcLength(r, l) { return (r * l) } @@ -139,6 +139,6 @@ exports.arcLength = function (r, l) { * @return {number} Convert degree to radian * */ -exports.degreeToRad = function (deg) { +export function degreeToRad(deg) { return deg * Math.PI / 180 } diff --git a/src/2d/hexagon/hexagon.js b/src/2d/hexagon/hexagon.js index 15a11a3..882a22a 100644 --- a/src/2d/hexagon/hexagon.js +++ b/src/2d/hexagon/hexagon.js @@ -7,6 +7,6 @@ * @return {number} The area of hexagon with on side a * */ -exports.hexagonArea = function (a) { +export function hexagonArea(a) { return ((3 * ((3) ^ 0.5)) / 2) * (a ** 2) } diff --git a/src/2d/oval/oval.js b/src/2d/oval/oval.js index edf738f..4710204 100644 --- a/src/2d/oval/oval.js +++ b/src/2d/oval/oval.js @@ -7,7 +7,7 @@ * @return {number} The area of eval * */ -exports.ovalArea = function (a, b) { +export function ovalArea(a, b) { return ((Math.PI) * a * b) } @@ -20,6 +20,6 @@ exports.ovalArea = function (a, b) { * @return {number} THe eccentricity of eval * */ -exports.evalEccentricity = function (a, b) { +export function evalEccentricity(a, b) { return ((1 - ((b ** 2) / (a ** 2))) ** 0.5) } diff --git a/src/2d/pentagon/pentagon.js b/src/2d/pentagon/pentagon.js index 736393e..067448f 100644 --- a/src/2d/pentagon/pentagon.js +++ b/src/2d/pentagon/pentagon.js @@ -6,7 +6,7 @@ * @return {number} The height of pentagon with side a * */ -exports.pentagonArea = function (a) { +export function pentagonArea(a) { return ((((a) ** 2) / 4) * ((25 + 10((5) ** 0.5)) ** 0.5)) } @@ -18,7 +18,7 @@ exports.pentagonArea = function (a) { * @return {number} The length of height of pentagon * */ -exports.pentagonHeight = function (a) { +export function pentagonHeight(a) { return (((25 + 10 * ((5) ** 0.5)) / 2) * (a)) } @@ -30,7 +30,7 @@ exports.pentagonHeight = function (a) { * @return {number} The length of digonal of pentagon * */ -exports.pentagonDiagonal = function (a) { +export function pentagonDiagonal(a) { // ������ ���ε� ������ ���̶� �ۼ�// return ((1 + ((5) ** 0.5) / 2) * (a)) } diff --git a/src/2d/polygon/polygon.js b/src/2d/polygon/polygon.js index 5b3c4ca..f77316c 100644 --- a/src/2d/polygon/polygon.js +++ b/src/2d/polygon/polygon.js @@ -6,7 +6,7 @@ * @return {number} The number of diagonal of polygon * */ -exports.polydiag = function (n) { +export function polydiag(n) { return (n * (n - 3) / 2) } @@ -18,7 +18,7 @@ exports.polydiag = function (n) { * @return {number} The sum of the polygons cabinet (degree) * */ -exports.polyAngleSumDeg = function (n) { +export function polyAngleSumDeg(n) { return (180 * (n - 2)) } @@ -30,7 +30,7 @@ exports.polyAngleSumDeg = function (n) { * @return {number} The sum of the polygons cabinet (radian) * */ -exports.polyAngleSumRad = function (n) { +export function polyAngleSumRad(n) { return ((Math.PI) * (n - 2)) } @@ -43,7 +43,7 @@ exports.polyAngleSumRad = function (n) { * @return {number} The area of regular polygons * */ -exports.polyarea = function (n, a) { +export function polyarea(n, a) { return n * (a ** 2) / (4 * (Math.tan(a / (Math.PI)))) } @@ -55,7 +55,7 @@ exports.polyarea = function (n, a) { * @return {number} The sum of cabinet of polygon (degree) * */ -exports.polyAngle_Deg = function (n) { +export function polyAngle_Deg(n) { return (180 * (n - 2) / n) } @@ -67,6 +67,6 @@ exports.polyAngle_Deg = function (n) { * @return {number} The sum of cabinet of polygon (radian) * */ -exports.polyAngle_Rad = function (n) { +export function polyAngle_Rad(n) { return ((Math.PI) * (n - 2) / n) } diff --git a/src/2d/rectangle/rectangle.js b/src/2d/rectangle/rectangle.js index 3d1dadd..5ad24f2 100644 --- a/src/2d/rectangle/rectangle.js +++ b/src/2d/rectangle/rectangle.js @@ -7,7 +7,7 @@ * @return {number} The area of parallelogram * */ -exports.parallelogramArea = function (a, h) { +export function parallelogramArea(a, h) { return (a * h) } /** @@ -19,7 +19,7 @@ exports.parallelogramArea = function (a, h) { * @return {number} THe area of rectangle with the side is a, b * */ -exports.rectangleArea = function (a, b) { +export function rectangleArea(a, b) { return (a * b) } /** @@ -31,7 +31,7 @@ exports.rectangleArea = function (a, b) { * @return {number} Pythagoras Theorem * */ -exports.rectangleDiagonal = function (a, b) { +export function rectangleDiagonal(a, b) { return (((a) ** 2 + (b) ** 2) ** 0.5) } /** @@ -43,7 +43,7 @@ exports.rectangleDiagonal = function (a, b) { * @return {number} The circumstance of rectangle with the side is a, b * */ -exports.rectanglePerimeter = function (a, b) { +export function rectanglePerimeter(a, b) { return ((a) * 2 + (b) * 2) } /** @@ -55,7 +55,7 @@ exports.rectanglePerimeter = function (a, b) { * @return {number} The area of rhombus with digonal a, b * */ -exports.rhombusArea = function (a, b) { +export function rhombusArea(a, b) { return (0.5 * (a) * (b)) } /** @@ -66,7 +66,7 @@ exports.rhombusArea = function (a, b) { * @return {number} Area of a square with one side a * */ -exports.square = function (a) { +export function square(a) { return (a ** 2) } /** @@ -79,7 +79,7 @@ exports.square = function (a) { * @return {number} The area of square * */ -exports.squareArea = function (a, b, t) { +export function squareArea(a, b, t) { return (0.5 * (a) * (b) * (Math.sin(t))) } /** @@ -92,6 +92,6 @@ exports.squareArea = function (a, b, t) { * @return {number} The area of trapezoid * */ -exports.trapezoidArea = function (a, b, h) { +export function trapezoidArea(a, b, h) { return (0.5 * (a + b) * h) } diff --git a/src/2d/triangle/pytagoras_004.js b/src/2d/triangle/pytagoras_004.js deleted file mode 100644 index 970c71f..0000000 --- a/src/2d/triangle/pytagoras_004.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 004 ��Ÿ���� ���� - * - * @author: Choi Minseo - * @param {number} a - * @param {number} b - * @return {number} The length of the hypotenuse when each side is a, b in a right triangle - * - */ -exports.pytagoras = function (a, b) { - return ((a * a + b * b) ** 0.5) -} -/** - * 004 ��Ÿ���� ���� - * - * @author: Choi Minseo - * @param {number} a - * @param {number} b - * @return {number} The length of the hypotenuse when each side is a, b in a right triangle - * - */ -exports.pytagoras = function (a, b) { - return ((a * a + b * b) ** 0.5) -} diff --git a/src/2d/triangle/triangle.js b/src/2d/triangle/triangle.js index 30cc091..4f7de1f 100644 --- a/src/2d/triangle/triangle.js +++ b/src/2d/triangle/triangle.js @@ -1,3 +1,16 @@ +/** + * 004 ��Ÿ���� ���� + * + * @author: Choi Minseo + * @param {number} a + * @param {number} b + * @return {number} The length of the hypotenuse when each side is a, b in a right triangle + * + */ + export function pytagoras(a, b) { + return ((a * a + b * b) ** 0.5) +} + /** * 008 ���� �ﰢ���� ���� * @@ -8,7 +21,7 @@ * @return {number} Area of triangle using angle * */ -exports.triangleAreaAngle = function (a, b, t) { +export function triangleAreaAngle(a, b, t) { return (0.5 * a * b * (Math.sin(t))) } /** @@ -20,7 +33,7 @@ exports.triangleAreaAngle = function (a, b, t) { * @return {number} Area of right triangle with each side a and b * */ -exports.rtria = function (a, b) { +export function rtria(a, b) { return (0.5 * a * b) } /** @@ -32,9 +45,10 @@ exports.rtria = function (a, b) { * @return {number} The length of an isosceles triangle with equal side a and base b * */ -exports.quadtria = function (a, b) { +export function quadtria(a, b) { return (a / 4 * (4 * b * b - a * a) ** 0.5) } + /** * 006 ����� ���� * @@ -45,7 +59,7 @@ exports.quadtria = function (a, b) { * @return {number} Heron's formula * */ -exports.heron = function (a, b, c) { +export function heron(a, b, c) { let cosTheta = ((a * a) + (b * b) - (c * c)) / (2 * a * b) let sinTheta = Math.sqrt(1 - (cosTheta ** 2)) return (a * b * sinTheta) / 2 @@ -75,7 +89,7 @@ exports.heron = function (a, b, c) { * @return {number} The center of gravity of the triangle using the coordinates of the vertices * */ -exports.centerGravity = function (a1, a2, b1, b2, c1, c2) { +export function centerGravity(a1, a2, b1, b2, c1, c2) { return ((a1 + b1 + c1) / 3)((a2 + b2 + c2) / 3) } /** @@ -86,7 +100,7 @@ exports.centerGravity = function (a1, a2, b1, b2, c1, c2) { * @return {number} a plus b * */ -exports.equilateralTriangleArea = function (a) { +export function equilateralTriangleArea(a) { return 3 ** 0.5 / 4 * a * a } /** @@ -98,6 +112,6 @@ exports.equilateralTriangleArea = function (a) { * @return {number} a plus b * */ -exports.equilateralTriangleHeight = function (a) { +export function equilateralTriangleHeight(a) { return (3 ^ 0.5 / 2 * a) } diff --git a/src/3d/cone/cone.js b/src/3d/cone/cone.js index b931dc4..180537b 100644 --- a/src/3d/cone/cone.js +++ b/src/3d/cone/cone.js @@ -7,7 +7,7 @@ * @return {number} The surface area of cone * */ -exports.coneArea = function (r, h) { +export function coneArea(r, h) { return (((Math.PI) * r * (((r ** 2) + (h ** 2)) ** 0.5)) + ((Math.PI) * (r ** 2))) } /** @@ -19,6 +19,6 @@ exports.coneArea = function (r, h) { * @return {number} The volume of cone * */ -exports.coneVolume = function (r, h) { +export function coneVolume(r, h) { return ((1 / 3) * (Math.PI) * (r ** 2) * h) } diff --git a/src/3d/cube/cube.js b/src/3d/cube/cube.js index 6bab290..b41dd64 100644 --- a/src/3d/cube/cube.js +++ b/src/3d/cube/cube.js @@ -6,7 +6,7 @@ * @return {number} The volume of cube * */ -exports.cubeVolume = function (a) { +export function cubeVolume(a) { return (a ** 3) } @@ -18,7 +18,7 @@ exports.cubeVolume = function (a) { * @return {number} The surface area of cube * */ -exports.cubeArea = function (a) { +export function cubeArea(a) { return (6 * (a ** 2)) } @@ -32,7 +32,7 @@ exports.cubeArea = function (a) { * @return {number} The volume of cuboid * */ -exports.cuboidVolume = function (a, b, c) { +export function cuboidVolume(a, b, c) { return (a * b * c) } @@ -46,7 +46,7 @@ exports.cuboidVolume = function (a, b, c) { * @return {number} The surface area of cuboid * */ -exports.cuboidArea = function (a, b, c) { +export function cuboidArea(a, b, c) { return (2 * ((a * b) + (b * c) + (c * a))) } @@ -60,6 +60,6 @@ exports.cuboidArea = function (a, b, c) { * @return {number} a plus b * */ -exports.cuboidDiagonal = function (a, b, c) { +export function cuboidDiagonal(a, b, c) { return (((a ** 2) + (b ** 2) + (c ** 2)) ** 0.5) } diff --git a/src/3d/cylinder/cylinder.js b/src/3d/cylinder/cylinder.js index 0290b96..0351019 100644 --- a/src/3d/cylinder/cylinder.js +++ b/src/3d/cylinder/cylinder.js @@ -7,7 +7,7 @@ * @return {number} The surface area of cylinder * */ -exports.cylinderArea = function (r, h) { +export function cylinderArea(r, h) { return ((2 * (Math.PI) * r * h) + (2 * (Math.PI) * (r ** 2))) } /** @@ -19,6 +19,6 @@ exports.cylinderArea = function (r, h) { * @return {number} The volume of cylinder * */ -exports.cylinderVolume = function (r, h) { +export function cylinderVolume(r, h) { return ((Math.PI) * (r ** 2) * h) } diff --git a/src/3d/polyhedron/polyhedron.js b/src/3d/polyhedron/polyhedron.js index 35100a7..c6a22af 100644 --- a/src/3d/polyhedron/polyhedron.js +++ b/src/3d/polyhedron/polyhedron.js @@ -8,7 +8,7 @@ * @return {number} Euler polyhedrob theroem * */ -exports.eulerPolyhedronTheorem = function (v, e, f) { +export function eulerPolyhedronTheorem(v, e, f) { if ((v - e + f) === 2) return true if ((v - e + f) !== 2) return false } diff --git a/src/3d/pyramid/pyramid.js b/src/3d/pyramid/pyramid.js index 1caf176..8e7ab0b 100644 --- a/src/3d/pyramid/pyramid.js +++ b/src/3d/pyramid/pyramid.js @@ -7,7 +7,7 @@ * @return {number} The volume of triangular cone * */ -exports.triangularPyramidVolume = function (a, h) { +export function triangularPyramidVolume(a, h) { return ((1 / 3) * a * h) } @@ -20,7 +20,7 @@ exports.triangularPyramidVolume = function (a, h) { * @return {number} The volume of square pyramid * */ -exports.squarePyramidVolume_ah = function (a, h) { +export function squarePyramidVolume_ah(a, h) { return ((1 / 3) * (a ** 2) * h) } @@ -33,7 +33,7 @@ exports.squarePyramidVolume_ah = function (a, h) { * @return {number} a plus b * */ -exports.squarePyramidVolume_ab = function (a, b) { +export function squarePyramidVolume_ab(a, b) { return ((1 / 3) * (a ** 2) * (((b ** 2) - ((a ** 2) / 2)) ** (0.5))) } @@ -46,7 +46,7 @@ exports.squarePyramidVolume_ab = function (a, b) { * @return {number} The volume of square pyramid * */ -exports.squarePyramidArea_ab = function (a, b) { +export function squarePyramidArea_ab(a, b) { return ((a * ((4 * (b ** 2) - (a ** 2)) ** (0.5))) + (a ** 2)) } @@ -59,7 +59,7 @@ exports.squarePyramidArea_ab = function (a, b) { * @return {number} The surface area of square pyramid * */ -exports.squarePyramidArea_ah = function (a, h) { +export function squarePyramidArea_ah(a, h) { return ((a * ((4 * (h ** 2) - (a ** 2)) ** (0.5))) + (a ** 2)) } @@ -72,6 +72,6 @@ exports.squarePyramidArea_ah = function (a, h) { * @return {number} The height of square pyramid * */ -exports.squarePyramidHeight = function (a, b) { +export function squarePyramidHeight(a, b) { return (((b ** 2) - ((a ** 2) / 2)) ** (0.5)) } diff --git a/src/3d/sphere/sphere.js b/src/3d/sphere/sphere.js index d5d3a65..b1248fe 100644 --- a/src/3d/sphere/sphere.js +++ b/src/3d/sphere/sphere.js @@ -6,7 +6,7 @@ * @return {number} The surface area of sphere * */ -exports.sphereArea = function (r) { +export function sphereArea(r) { return (4 * (Math.PI) * (r ** 2)) } /** @@ -17,6 +17,6 @@ exports.sphereArea = function (r) { * @return {number} THe volume of sphere * */ -exports.sphereVolume = function (r) { +export function sphereVolume(r) { return ((4 / 3) * (Math.PI) * (r ** 2)) } diff --git a/src/3d/tetrahedron/tetrahedron.js b/src/3d/tetrahedron/tetrahedron.js index aa2b3e5..77ca581 100644 --- a/src/3d/tetrahedron/tetrahedron.js +++ b/src/3d/tetrahedron/tetrahedron.js @@ -1,12 +1,12 @@ // 056 �����ü�� �ѳ��� ����// -exports.tetrahedronArea = function (a) { +export function tetrahedronArea(a) { return ((3 ** (0.5)) * (a ** 2)) } // 057 �����ü�� ���� ����// -exports.tetrahedronHeight = function (a) { +export function tetrahedronHeight(a) { return (((2 / 3) ** (0.5)) * a) } // 055 �����ü�� ���� ����// -exports.tetrahedronVolume = function (a) { +export function tetrahedronVolume(a) { return (((2 ** (0.5)) / 12) * (a ** 3)) } diff --git a/src/angle/angle.js b/src/angle/angle.js index 756f538..f7c0b5f 100644 --- a/src/angle/angle.js +++ b/src/angle/angle.js @@ -6,6 +6,6 @@ * @return {number} Convert radian to degree * */ -exports.radToDegree = function (rad) { +export function radToDegree(rad) { return rad * 180 / Math.PI } diff --git a/src/calc/calc.js b/src/calc/calc.js index 594b871..08caf3d 100644 --- a/src/calc/calc.js +++ b/src/calc/calc.js @@ -7,7 +7,7 @@ * @return {number} a + b * */ -exports.plus = function (a, b) { +export function plus(a, b) { return a + b } /** @@ -19,7 +19,7 @@ exports.plus = function (a, b) { */ exports.pi = Math.PI -exports.round = function (a) { +export function round(a) { return Math.round(a) } /** @@ -31,7 +31,7 @@ exports.round = function (a) { * @return {number} (a, b) * */ -exports.pow = function (a, b) { +export function pow(a, b) { return Math.pow(a, b) } /** @@ -43,7 +43,7 @@ exports.pow = function (a, b) { * @return {number} a ^ b * */ -exports.caret = function (a, b) { +export function caret(a, b) { return a ** b } /** @@ -55,7 +55,7 @@ exports.caret = function (a, b) { * @return {number} a / b * */ -exports.divide = function (a, b) { +export function divide(a, b) { return a / b } /** @@ -67,7 +67,7 @@ exports.divide = function (a, b) { * @return {number} gcd * */ -exports.gcd = function (a, b) { +export function gcd(a, b) { if (b === 0) { return a } else { @@ -82,7 +82,7 @@ exports.gcd = function (a, b) { * @return {number} IsInRange * */ -exports.isinrange = function (a, b) { +export function isinrange(a, b) { let g = function (x) { if (a <= x && x <= b) { return true @@ -101,7 +101,7 @@ exports.isinrange = function (a, b) { * @return {number} a - b * */ -exports.minus = function (a, b) { +export function minus(a, b) { return a - b } /** @@ -113,7 +113,7 @@ exports.minus = function (a, b) { * @return {number} a * b * */ -exports.multiply = function (a, b) { +export function multiply(a, b) { return a * b } /** @@ -125,7 +125,7 @@ exports.multiply = function (a, b) { * @return {number} Area of triangle given base and height * */ -exports.triangleAreaSide = function (a, h) { +export function triangleAreaSide(a, h) { return (0.5 * a * h) } /** @@ -136,7 +136,7 @@ exports.triangleAreaSide = function (a, h) { * @return {number} change a to radian * */ -exports.radian = function (a) { +export function radian(a) { return 2 * Math.PI * a } /** @@ -148,7 +148,7 @@ exports.radian = function (a) { * @return {number} random number from a to b * */ -exports.random = function (a, b) { +export function random(a, b) { var ranNum = Math.floor((Math.random() * b) + a) return ranNum } @@ -162,7 +162,7 @@ exports.random = function (a, b) { * */ -function Root() { // �Լ��ƴ� ������Ÿ���� +export function Root() { // �Լ��ƴ� ������Ÿ���� this.get = function (val, digit_) { let digit = digit_ || 10 return parseFloat((val ** 0.5).toFixed(digit)) @@ -181,6 +181,6 @@ exports.root = new Root() * @return {number} root a * */ -exports.sqrt = function (a) { +export function sqrt(a) { return Math.sqrt(a) } diff --git a/src/calculus/calculus.js b/src/calculus/calculus.js index 06e4b5a..fc44296 100644 --- a/src/calculus/calculus.js +++ b/src/calculus/calculus.js @@ -6,7 +6,7 @@ * @return {number} Diff * */ -exports.diff = function (f, density = 5) { +export function diff(f, density = 5) { let dx = 2 * (10 ** (-density)) let dy = (x) => f(x + (10 ** (-density))) - f(x - (10 ** (-density))) @@ -20,7 +20,7 @@ exports.diff = function (f, density = 5) { * @return {number} Integral * */ -exports.integral = function (f, density = 5) { +export function integral(f, density = 5) { let g = (a, b) => { let sum = 0 for (let k = a; k < b; k += 10 ** (-density)) { diff --git a/src/equation/equation.js b/src/equation/equation.js index fb6864b..9d14723 100644 --- a/src/equation/equation.js +++ b/src/equation/equation.js @@ -8,7 +8,7 @@ * @return {number} Root formula * */ -exports.rootFormula_plus = function (a, b, c) { +export function rootFormula_plus(a, b, c) { return ((-b + (((b ** 2) - (4 * a * c)) ** 0.5)) / (2 * a)) } @@ -22,7 +22,7 @@ exports.rootFormula_plus = function (a, b, c) { * @return {number} Root formula * */ -exports.rootFormula_minus = function (a, b, c) { +export function rootFormula_minus(a, b, c) { return ((-b - (((b ** 2) - (4 * a * c)) ** 0.5)) / (2 * a)) } @@ -36,7 +36,7 @@ exports.rootFormula_minus = function (a, b, c) { * @return {number} Root formula(even root) * */ -exports.rootFormula_EvenPlus = function (a, b, c) { +export function rootFormula_EvenPlus(a, b, c) { return ((-(0.5 * b) + ((((0.5 * b) ** 2) - (a * c)) ** 0.5)) / a) } @@ -50,7 +50,7 @@ exports.rootFormula_EvenPlus = function (a, b, c) { * @return {number} Root formula(even root) * */ -exports.rootFormula_EvenMinus = function (a, b, c) { +export function rootFormula_EvenMinus(a, b, c) { return ((-(0.5 * b) - ((((0.5 * b) ** 2) - (a * c)) ** 0.5)) / a) } @@ -65,7 +65,7 @@ exports.rootFormula_EvenMinus = function (a, b, c) { * @return {number} Relation of root and coefficient * */ -exports.rootAndCoefficient = function (a, b, c, type) { +export function rootAndCoefficient(a, b, c, type) { if (type === 1) return -(b / a) if (type === 2) return (b / c) } @@ -81,7 +81,7 @@ exports.rootAndCoefficient = function (a, b, c, type) { * @return {number} Root formula of cubic equation * */ -exports.cubicEquation_first = function (a, b, c, d) { +export function cubicEquation_first(a, b, c, d) { let x = (((0.5 * ((2 * (b ** 3) - (9 * a * b * c) + (27 * (a ** 2) * d) + (((2 * (b ** 3) - (9 * a * b * c) + (27 * (a ** 2) * d)) ** 2) - 4((b ** 2) - 3 * a * c) ** 3) ** 0.5))) ** (1 / 3))) let y = (((0.5 * ((2(b ** 3) - (9 * a * b * c) + (27 * (a ** 2) * d) - (((2 * (b ** 3) - (9 * a * b * c) + (27 * (a ** 2) * d)) ** 2) - 4((b ** 2) - 3 * a * c) ** 3) ** 0.5))) ** (1 / 3))) return -(b / (3 * a)) - ((1 / (3 * a)) * x) - ((1 / (3 * a)) * y) diff --git a/src/matrix/matrix.js b/src/matrix/matrix.js index d8e6a83..a8e565b 100644 --- a/src/matrix/matrix.js +++ b/src/matrix/matrix.js @@ -6,7 +6,7 @@ * @return {number} LUDecompostion of matrix * */ -exports.LUDecomposition = function (matrix) { +export function LUDecomposition(matrix) { if (matrix.length !== matrix[0].length) { console.log('��� ���� ũ�Ⱑ ���� ����') return @@ -58,7 +58,7 @@ exports.LUDecomposition = function (matrix) { * @return {number} Solves System of linear equations. * */ -exports.Cramer = function (mat) { +export function Cramer(mat) { let B = [] let X = [] @@ -102,7 +102,7 @@ exports.Cramer = function (mat) { * @return {number} LQDecomposition * */ -exports.LQDecomposition = function (mat, iterationCount = 1000) { +export function LQDecomposition(mat, iterationCount = 1000) { let AT = exports.transpose(mat) AT = exports.QRDecomposition(AT, iterationCount) @@ -122,7 +122,7 @@ exports.LQDecomposition = function (mat, iterationCount = 1000) { * @return {number} Determinant * */ -exports.determinant = function (matrix) { +export function determinant(matrix) { if (matrix.length !== matrix[0].length) { return } @@ -158,7 +158,7 @@ exports.determinant = function (matrix) { * @return {number} Finding Multiple Roots of Function. * */ -exports.Durand_Kerner = function (f, rootsNumber = 1, iterationCount = 15) { +export function Durand_Kerner(f, rootsNumber = 1, iterationCount = 15) { let roots = [] for (let i = 0; i < rootsNumber; i++) { roots.push(i + 1) @@ -186,7 +186,7 @@ exports.Durand_Kerner = function (f, rootsNumber = 1, iterationCount = 15) { * @return {number} Eigendecomposition of a matrix. * */ -exports.EigenVectorDecomposition = function (mat, iterationCount = 100) { +export function EigenVectorDecomposition(mat, iterationCount = 100) { let V = [] for (let i = 0; i < mat[0].length; i++) { V.push(exports.randomVector(mat.length, 1)) @@ -278,7 +278,7 @@ exports.EigenVectorDecomposition = function (mat, iterationCount = 100) { * @return {number} Gaussian elimination * */ -exports.gaussian = function (matrix, m, n) { +export function gaussian(matrix, m, n) { let X = [] for (let i = 0; i < matrix.length; i++) { X.push([]) @@ -313,7 +313,7 @@ exports.gaussian = function (matrix, m, n) { * @return {number} Gauss–Seidel method. * */ -exports.Gauss_Seidel = function (mat, iterationCount = 15) { +export function Gauss_Seidel(mat, iterationCount = 15) { let x = [] for (let i = 0; i < mat.length; i++) { @@ -343,7 +343,7 @@ exports.Gauss_Seidel = function (mat, iterationCount = 15) { * @return {number} houseHolder * */ -exports.houseHolder = function (mat) { +export function houseHolder(mat) { function SG(N) { if (N < 0) { return -1 @@ -404,7 +404,7 @@ exports.houseHolder = function (mat) { } } -exports.QRDecomposition = function (mat) { +export function QRDecomposition(mat) { function sqrtDotProduct(row1, row2) { let res = 0 for (let i = 0; i < row1.length; i++) { @@ -480,7 +480,7 @@ exports.QRDecomposition = function (mat) { * @return {number} IdentityMatrix * */ -exports.IdentityMatrix = function (n) { +export function IdentityMatrix(n) { let res = [] for (let i = 0; i < n; i++) { res.push([]) @@ -503,7 +503,7 @@ exports.IdentityMatrix = function (n) { * @return {number} InverseMatrix * */ -exports.InverseMatrix = function (A) { +export function InverseMatrix(A) { if (exports.determinant(A) === 0) { return null } @@ -542,7 +542,7 @@ exports.InverseMatrix = function (A) { * @return {number} Matrix subtraction of matrixA and matrixB * */ -exports.matrixAdd = function (matrixA, matrixB) { +export function matrixAdd(matrixA, matrixB) { if (matrixA.length !== matrixB.length || matrixA[0].length !== matrixB[0].length) { console.log('����� ũ�� ����ġ') return @@ -566,7 +566,7 @@ exports.matrixAdd = function (matrixA, matrixB) { * @return {matrix} Matrix product of matrixA and matrixB * */ -exports.matrixMultiply = function (matrixA, matrixB) { +export function matrixMultiply(matrixA, matrixB) { if (matrixA[0].length !== matrixB.length) { console.log('�߸��� ��İ� ������ ũ��') return @@ -597,7 +597,7 @@ exports.matrixMultiply = function (matrixA, matrixB) { * @return {number} Matrix scalar product * */ -exports.matrixScalaMultiplation = function (matrix, k) { +export function matrixScalaMultiplation(matrix, k) { let res = [] for (let i = 0; i < matrix.length; i++) { res.push([]) @@ -618,7 +618,7 @@ exports.matrixScalaMultiplation = function (matrix, k) { * @return {number} Matrix sum of matrixA and matrixB * */ -exports.matrixSub = function (matrixA, matrixB) { +export function atrixSub(matrixA, matrixB) { if (matrixA.length !== matrixB.length || matrixA[0].length !== matrixB[0].length) { console.log('����� ũ�� ����ġ') return @@ -641,7 +641,7 @@ exports.matrixSub = function (matrixA, matrixB) { * @return {number} normalization * */ -exports.normailze = function (row) { +export function normailze(row) { return exports.matrix_scala_multiplation(row, 1 / exports.sqrtDotProduct(row, row)) } @@ -654,7 +654,7 @@ exports.normailze = function (row) { * @return {matrix} outterProduct_matrix * */ -exports.outterProduct_matrix = function (u, v) { +export function outterProduct_matrix(u, v) { return exports.matrixmultiply(u, exports.transpose(v)) } @@ -666,7 +666,7 @@ exports.outterProduct_matrix = function (u, v) { * @return {number} SingularValueDecomposition * */ -exports.SingularValueDecomposition = function (mat, iterationCount = 2) { +export function SingularValueDecomposition(mat, iterationCount = 2) { let M = mat; let VT = []; let Sigma = []; @@ -696,7 +696,7 @@ exports.SingularValueDecomposition = function (mat, iterationCount = 2) { * @return {number} sqrtDotProduct * */ -exports.sqrtDotProduct = function (row1, row2) { +export function sqrtDotProduct(row1, row2) { let res = 0 for (let i = 0; i < row1.length; i++) { res += row1[i] * row2[i] @@ -713,7 +713,7 @@ exports.sqrtDotProduct = function (row1, row2) { * @return {number} trace * */ -exports.trace = function (matrix) { +export function trace(matrix) { let res = 0 for (let i = 0; i < matrix.length; i++) { res += matrix[i][i] @@ -729,7 +729,7 @@ exports.trace = function (matrix) { * @return {number} transpose * */ -exports.transpose = function (mat) { +export function transpose(mat) { let res = [] for (let i = 0; i < mat[0].length; i++) { diff --git a/src/others/others.js b/src/others/others.js index 7cae938..87008a5 100644 --- a/src/others/others.js +++ b/src/others/others.js @@ -7,7 +7,7 @@ * @return {random} * */ -exports.ACORN = function (seed = new Date().getTime(), moduloPower = 60, order = 10) { +export function ACORN(seed = new Date().getTime(), moduloPower = 60, order = 10) { let M = 2 ** moduloPower let temp = 0 + (seed.toString().split('').reverse().join('')) @@ -49,7 +49,7 @@ exports.ACORN = function (seed = new Date().getTime(), moduloPower = 60, order = * @return Newton's method * */ -exports.newtonsMethod = function (f, count, initx = 2) { +export function newtonsMethod(f, count, initx = 2) { function diff(f, x, density = 5) { const dx = 2 * (10 ** -density) const dy = f(x + (10 ** -density)) - f(x - (10 ** -density)) diff --git a/src/progress/progress.js b/src/progress/progress.js index 3731e34..6fcafba 100644 --- a/src/progress/progress.js +++ b/src/progress/progress.js @@ -8,7 +8,7 @@ * @return {number} Arithmetic progression */ -exports.arithmeticProgression = function (a, d, n) { +export function arithmeticProgression(a, d, n) { return (a + (n - 1) * d) } @@ -22,7 +22,7 @@ exports.arithmeticProgression = function (a, d, n) { * @return {number} Arithmetic progression */ -exports.arithmeticProgression_n = function (d, n, s) { +export function arithmeticProgression_n(d, n, s) { return (s - (n - 1) * d) } @@ -36,7 +36,7 @@ exports.arithmeticProgression_n = function (d, n, s) { * @return {number} Arithmetic progression */ -exports.arithmeticProgression_d = function (a, n, s) { +export function arithmeticProgression_d(a, n, s) { return ((s - a) / (n - 1)) } @@ -50,7 +50,7 @@ exports.arithmeticProgression_d = function (a, n, s) { * @return {number} Arithmetic progression */ -exports.arithmeticProgressionSum_Term = function (a1, an, n) { +export function arithmeticProgressionSum_Term(a1, an, n) { return (((a1 + an) / 2) * n) } @@ -64,7 +64,7 @@ exports.arithmeticProgressionSum_Term = function (a1, an, n) { * @return {number} Arithmetic progression */ -exports.arithmeticProgressionSum = function (a1, n, d) { +export function arithmeticProgressionSum(a1, n, d) { return ((((2 * a1) + ((n - 1) * d)) / 2) * n) } @@ -78,7 +78,7 @@ exports.arithmeticProgressionSum = function (a1, n, d) { * @return {number} Geometric progression */ -exports.geometricProgression_a = function (an, n, r) { +export function geometricProgression_a(an, n, r) { return (an / (r ** n)) } @@ -92,7 +92,7 @@ exports.geometricProgression_a = function (an, n, r) { * @return {number} Geometric progression */ -exports.geometricProgression_n = function (an, a, r) { +export function geometricProgression_n(an, a, r) { return Math.log(an / a) / Math.log(r) } @@ -106,7 +106,7 @@ exports.geometricProgression_n = function (an, a, r) { * @return {number} Geometric progression */ -exports.geometricProgress_r = function (an, a, n) { +export function geometricProgress_r(an, a, n) { return ((an / a) ** (1 / n)) } @@ -120,7 +120,7 @@ exports.geometricProgress_r = function (an, a, n) { * @return {number} Geometric progression */ -exports.geometricProgression_an = function (a, n, r) { +export function geometricProgression_an(a, n, r) { return (a * (r ** n)) } @@ -133,7 +133,7 @@ exports.geometricProgression_an = function (a, n, r) { * @param {number} n * @return {number} Sum of geometric progression */ -exports.geometricProgressionSum = function(a, r, n) { +export function geometricProgressionSum(a, r, n) { return a * (1 - (r**n)) / (1 - r) } @@ -145,7 +145,7 @@ exports.geometricProgressionSum = function(a, r, n) { * @param {number} r * @return {number} Sum of infinite geometric progression */ -exports.geometricProgressionInfinitySum = function (a, r) { +export function geometricProgressionInfinitySum(a, r) { return a / (1 - r) } @@ -157,7 +157,7 @@ exports.geometricProgressionInfinitySum = function (a, r) { * @param {number} k * @return {number} Sum of progress which number is consisted of consecutive numbers */ -exports.sigma = function (n, k) { +export function sigma(n, k) { return (((1 / 2) * n * (n + 1)) - ((1 / 2) * k * (k + 1))) } @@ -169,7 +169,7 @@ exports.sigma = function (n, k) { * @param {number} k * @return {number} Sum of progress which number is consisted of the squares of numbers */ -exports.sigmaSquare = function (n, k) { +export function sigmaSquare(n, k) { return (((1 / 6) * n * (n + 1) * ((2 * n) + 1)) - ((1 / 6) * k * (k + 1) * ((2 * k) + 1))) } @@ -181,7 +181,7 @@ exports.sigmaSquare = function (n, k) { * @param {number} k * @return {number} Sum of progress which number is consisted of the cubic number */ -exports.sigmaCube = function (n, k) { +export function sigmaCube(n, k) { return (((1 / 4) * (n ** 2) * ((n + 1) ** 2)) - ((1 / 4) * (k ** 2) * ((k + 1) ** 2))) } @@ -190,7 +190,7 @@ exports.sigmaCube = function (n, k) { * @param {number} x * @return {number} Infinite series (the denominator is n! and the numerator is x to the power of k) */ -exports.infiniteSeries_1 = function (x) { +export function infiniteSeries_1(x) { return (Math.E ** x) } @@ -199,7 +199,7 @@ exports.infiniteSeries_1 = function (x) { * @param {number} x * @return {number} Infinite series (The denominator is n! and the numerator is k times x to the power of k) */ -exports.infiniteSeries_2 = function (x) { +export function infiniteSeries_2(x) { return (x * (Math.E ** x)) } @@ -208,7 +208,7 @@ exports.infiniteSeries_2 = function (x) { * @param {number} x * @return {number} Infinite series (x to the power of k, |x| < 1) */ -exports.infiniteSeries_3 = function (x) { +export function infiniteSeries_3(x) { if (x > 1 || x < -1 || x == 1 || x == -1) { console.log('Check |x| < 1') } @@ -222,7 +222,7 @@ exports.infiniteSeries_3 = function (x) { * @param {number} x * @return {number} Infinite series (k times x to the power of k, |x| < 1) */ -exports.infiniteSeries_4 = function (x) { +export function infiniteSeries_4(x) { if (x > 1 || x < -1 || x == 1 || x == -1) { console.log('Check |x| < 1') } @@ -241,7 +241,7 @@ exports.infiniteSeries_4 = function (x) { * @return Taylor series * */ -exports.taylor = function (f, a, count) { +export function taylor(f, a, count) { let diffs = [(x) => f(a)] let taylors = [] let fact = [1] @@ -291,6 +291,6 @@ exports.taylor = function (f, a, count) { * @return {number} Maclaurin series * */ -exports.maclaurin = function (f, count) { +export function maclaurin(f, count) { return exports.taylor(f, 0, count) } diff --git a/src/vector/vector.js b/src/vector/vector.js index 45129c5..714e35c 100644 --- a/src/vector/vector.js +++ b/src/vector/vector.js @@ -1,12 +1,12 @@ /** - * 225 Ramdom vector + * 225 Random vector * * @author: DPS0340 * @param {string} len * @return {number} * */ -exports.randomVector = function (len, norm = 1) { +export function randomVector(len, norm = 1) { let x = [] let currentNorm = 0