Skip to content

Commit 1c4c2d0

Browse files
committed
fixing issues
1 parent 2590c90 commit 1c4c2d0

File tree

7 files changed

+462
-23
lines changed

7 files changed

+462
-23
lines changed

README.md

+102-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# adv-math
1+
# Advanced Math (adv-math)
22

33
Advanced Mathematical Operations Library for JavaScript
44

@@ -22,6 +22,7 @@ Advanced Mathematical Operations Library for JavaScript
2222
- [Equations](#equations)
2323
- [Parser](#parser)
2424
- [Random](#random)
25+
- [Expression Evaluator](#expression-evaluator)
2526
- [License](#license)
2627
- [Code of Conduct](#code-of-conduct)
2728
- [Contributing](#contributing)
@@ -34,6 +35,9 @@ Advanced Mathematical Operations Library for JavaScript
3435

3536
`adv-math` is a comprehensive JavaScript library that simplifies advanced mathematical calculations, covering a wide range of mathematical topics such as basic arithmetic, complex numbers, linear algebra, statistics, geometry, trigonometry, calculus, financial calculations, units and conversions, equation solvers, and math expression parsing. This library is designed to provide developers with powerful mathematical tools for various applications.
3637

38+
**New Feature:**
39+
- Added `Expression Evaluator` for evaluating complex mathematical expressions. See [Expression Evaluator](#expression-evaluator) below for details.
40+
3741

3842
## Installation
3943

@@ -76,8 +80,7 @@ The primary motive of this project is to simplify complex mathematical operation
7680
## Example Usage
7781

7882
Here's an overview of how to use some of the key modules in Advanced Math:
79-
80-
### Basic Math Operations
83+
### BasicMath
8184

8285
```javascript
8386
const { BasicMath } = require('adv-math');
@@ -86,7 +89,7 @@ const sum = BasicMath.add(5, 3); // 8
8689
const product = BasicMath.multiply(4, 6); // 24
8790
```
8891

89-
### Complex Numbers
92+
### ComplexNumber
9093

9194
```javascript
9295
const { ComplexNumber } = require('adv-math');
@@ -97,15 +100,26 @@ const num2 = new ComplexNumber(1, -1);
97100
const result = ComplexNumber.add(num1, num2); // (3, 2)
98101
```
99102

100-
### Linear Algebra
103+
### Matrix
101104

102105
```javascript
103-
const { Matrix, Vector } = require('adv-math');
106+
const { Matrix } = require('adv-math');
104107

105-
const matrix = new Matrix([[1, 2], [3, 4]]);
106-
const vector = new Vector([1, 2]);
108+
const matrix1 = new Matrix([[1, 2], [3, 4]]);
109+
const matrix2 = new Matrix([[5, 6], [7, 8]]);
107110

108-
const product = Matrix.multiply(matrix, vector); // [5, 11]
111+
const product = Matrix.multiply(matrix1, matrix2); // [[19, 22], [43, 50]]
112+
```
113+
114+
### Vector
115+
116+
```javascript
117+
const { Vector } = require('adv-math');
118+
119+
const vector1 = new Vector([1, 2, 3]);
120+
const vector2 = new Vector([4, 5, 6]);
121+
122+
const dotProduct = Vector.dot(vector1, vector2); // 32
109123
```
110124

111125
### Statistics
@@ -118,9 +132,86 @@ const mean = Statistics.mean(data); // 6
118132
const variance = Statistics.variance(data); // 8
119133
```
120134

121-
Please refer to the documentation for detailed usage instructions for each module.
135+
### Geometry
136+
137+
```javascript
138+
const { Geometry } = require('adv-math');
139+
140+
const area = Geometry.calculateArea(5); // Calculate the area of a circle with radius 5
141+
const perimeter = Geometry.calculatePerimeter(7); // Calculate the perimeter of a rectangle with width 7
142+
```
143+
144+
### Trigonometry
145+
146+
```javascript
147+
const { Trigonometry } = require('adv-math');
148+
149+
const sine = Trigonometry.sin(30); // Calculate the sine of 30 degrees
150+
const cosine = Trigonometry.cos(45); // Calculate the cosine of 45 degrees
151+
```
152+
153+
### Calculus
154+
155+
```javascript
156+
const { Calculus } = require('adv-math');
157+
158+
const derivative = Calculus.derivative('2 * x^2 + 3 * x', 'x'); // Calculate the derivative of the function
159+
const integral = Calculus.integral('4 * x^3 + 2 * x', 'x'); // Calculate the integral of the function
160+
```
161+
162+
### Financial
163+
164+
```javascript
165+
const { Financial } = require('adv-math');
166+
167+
const futureValue = Financial.futureValue(1000, 0.05, 5); // Calculate the future value of an investment
168+
const presentValue = Financial.presentValue(1500, 0.08, 3); // Calculate the present value of a sum of money
169+
```
170+
171+
### Units
172+
173+
```javascript
174+
const { Units } = require('adv-math');
175+
176+
const metersToFeet = Units.convert(5, 'meters', 'feet'); // Convert 5 meters to feet
177+
const poundsToKilograms = Units.convert(150, 'pounds', 'kilograms'); // Convert 150 pounds to kilograms
178+
```
122179

180+
### Equations
123181

182+
```javascript
183+
const { Equations } = require('adv-math');
184+
185+
const root = Equations.solveQuadratic(1, -3, 2); // Solve the quadratic equation x^2 - 3x + 2 = 0
186+
```
187+
188+
### Parser
189+
190+
```javascript
191+
const { Parser } = require('adv-math');
192+
193+
const expression = '2 + 3 * (4 - 1)';
194+
const result = Parser.parseExpression(expression); // Parse and evaluate the expression
195+
```
196+
197+
### Random
198+
199+
```javascript
200+
const { Random } = require('adv-math');
201+
202+
const randomInteger = Random.randomInt(1, 10); // Generate a random integer between 1 and 10
203+
const randomFloat = Random.randomFloat(0, 1); // Generate a random floating-point number between 0 and 1
204+
```
205+
206+
### Expression Evaluator
207+
208+
```javascript
209+
const { ExpressionEvaluator } = require('adv-math');
210+
211+
const expression = '2 + 3 * (4 - 1)';
212+
const result = ExpressionEvaluator.evaluateExpression(expression); // Evaluate the mathematical expression
213+
console.log('Result:', result); // Output: 11
214+
```
124215
## License
125216

126217
This project is licensed under the [MIT License](LICENSE).
@@ -150,4 +241,4 @@ For detailed documentation and usage examples, visit our [documentation](docs/).
150241

151242
## Happy Coding 🚀
152243

153-
We hope you find `adv-math` useful for your mathematical projects and applications. Happy coding!
244+
We hope you find `adv-math` useful for your mathematical projects and applications. Happy coding!

adv-math/README.md

+103-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# adv-math
1+
# Advanced Math (adv-math)
22

33
Advanced Mathematical Operations Library for JavaScript
44

@@ -22,6 +22,7 @@ Advanced Mathematical Operations Library for JavaScript
2222
- [Equations](#equations)
2323
- [Parser](#parser)
2424
- [Random](#random)
25+
- [Expression Evaluator](#expression-evaluator)
2526
- [License](#license)
2627
- [Code of Conduct](#code-of-conduct)
2728
- [Contributing](#contributing)
@@ -34,6 +35,9 @@ Advanced Mathematical Operations Library for JavaScript
3435

3536
`adv-math` is a comprehensive JavaScript library that simplifies advanced mathematical calculations, covering a wide range of mathematical topics such as basic arithmetic, complex numbers, linear algebra, statistics, geometry, trigonometry, calculus, financial calculations, units and conversions, equation solvers, and math expression parsing. This library is designed to provide developers with powerful mathematical tools for various applications.
3637

38+
**New Feature:**
39+
- Added `Expression Evaluator` for evaluating complex mathematical expressions. See [Expression Evaluator](#expression-evaluator) below for details.
40+
3741

3842
## Installation
3943

@@ -76,8 +80,7 @@ The primary motive of this project is to simplify complex mathematical operation
7680
## Example Usage
7781

7882
Here's an overview of how to use some of the key modules in Advanced Math:
79-
80-
### Basic Math Operations
83+
### BasicMath
8184

8285
```javascript
8386
const { BasicMath } = require('adv-math');
@@ -86,7 +89,7 @@ const sum = BasicMath.add(5, 3); // 8
8689
const product = BasicMath.multiply(4, 6); // 24
8790
```
8891

89-
### Complex Numbers
92+
### ComplexNumber
9093

9194
```javascript
9295
const { ComplexNumber } = require('adv-math');
@@ -97,15 +100,26 @@ const num2 = new ComplexNumber(1, -1);
97100
const result = ComplexNumber.add(num1, num2); // (3, 2)
98101
```
99102

100-
### Linear Algebra
103+
### Matrix
101104

102105
```javascript
103-
const { Matrix, Vector } = require('adv-math');
106+
const { Matrix } = require('adv-math');
104107

105-
const matrix = new Matrix([[1, 2], [3, 4]]);
106-
const vector = new Vector([1, 2]);
108+
const matrix1 = new Matrix([[1, 2], [3, 4]]);
109+
const matrix2 = new Matrix([[5, 6], [7, 8]]);
107110

108-
const product = Matrix.multiply(matrix, vector); // [5, 11]
111+
const product = Matrix.multiply(matrix1, matrix2); // [[19, 22], [43, 50]]
112+
```
113+
114+
### Vector
115+
116+
```javascript
117+
const { Vector } = require('adv-math');
118+
119+
const vector1 = new Vector([1, 2, 3]);
120+
const vector2 = new Vector([4, 5, 6]);
121+
122+
const dotProduct = Vector.dot(vector1, vector2); // 32
109123
```
110124

111125
### Statistics
@@ -118,9 +132,86 @@ const mean = Statistics.mean(data); // 6
118132
const variance = Statistics.variance(data); // 8
119133
```
120134

121-
Please refer to the documentation for detailed usage instructions for each module.
135+
### Geometry
136+
137+
```javascript
138+
const { Geometry } = require('adv-math');
139+
140+
const area = Geometry.calculateArea(5); // Calculate the area of a circle with radius 5
141+
const perimeter = Geometry.calculatePerimeter(7); // Calculate the perimeter of a rectangle with width 7
142+
```
143+
144+
### Trigonometry
122145

146+
```javascript
147+
const { Trigonometry } = require('adv-math');
148+
149+
const sine = Trigonometry.sin(30); // Calculate the sine of 30 degrees
150+
const cosine = Trigonometry.cos(45); // Calculate the cosine of 45 degrees
151+
```
152+
153+
### Calculus
154+
155+
```javascript
156+
const { Calculus } = require('adv-math');
157+
158+
const derivative = Calculus.derivative('2 * x^2 + 3 * x', 'x'); // Calculate the derivative of the function
159+
const integral = Calculus.integral('4 * x^3 + 2 * x', 'x'); // Calculate the integral of the function
160+
```
161+
162+
### Financial
163+
164+
```javascript
165+
const { Financial } = require('adv-math');
166+
167+
const futureValue = Financial.futureValue(1000, 0.05, 5); // Calculate the future value of an investment
168+
const presentValue = Financial.presentValue(1500, 0.08, 3); // Calculate the present value of a sum of money
169+
```
123170

171+
### Units
172+
173+
```javascript
174+
const { Units } = require('adv-math');
175+
176+
const metersToFeet = Units.convert(5, 'meters', 'feet'); // Convert 5 meters to feet
177+
const poundsToKilograms = Units.convert(150, 'pounds', 'kilograms'); // Convert 150 pounds to kilograms
178+
```
179+
180+
### Equations
181+
182+
```javascript
183+
const { Equations } = require('adv-math');
184+
185+
const root = Equations.solveQuadratic(1, -3, 2); // Solve the quadratic equation x^2 - 3x + 2 = 0
186+
```
187+
188+
### Parser
189+
190+
```javascript
191+
const { Parser } = require('adv-math');
192+
193+
const expression = '2 + 3 * (4 - 1)';
194+
const result = Parser.parseExpression(expression); // Parse and evaluate the expression
195+
```
196+
197+
### Random
198+
199+
```javascript
200+
const { Random } = require('adv-math');
201+
202+
const randomInteger = Random.randomInt(1, 10); // Generate a random integer between 1 and 10
203+
const randomFloat = Random.randomFloat(0, 1); // Generate a random floating-point number between 0 and 1
204+
```
205+
206+
### Expression Evaluator
207+
208+
```javascript
209+
const { ExpressionEvaluator } = require('adv-math');
210+
211+
const expression = '2 + 3 * (4 - 1)';
212+
const result = ExpressionEvaluator.evaluateExpression(expression); // Evaluate the mathematical expression
213+
console.log('Result:', result); // Output: 11
214+
```
124215
## License
125216

126217
This project is licensed under the [MIT License](LICENSE).
@@ -147,6 +238,7 @@ For detailed documentation and usage examples, visit our [documentation](docs/).
147238
- **Email:** [Pabitra Banerjee](mailto:[email protected])
148239
- **GitHub:** [PB2204](https://github.com/PB2204)
149240

241+
150242
## Happy Coding 🚀
151243

152-
We hope you find `adv-math` useful for your mathematical projects and applications. Happy coding!
244+
We hope you find `adv-math` useful for your mathematical projects and applications. Happy coding!

0 commit comments

Comments
 (0)