-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
316 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,17 @@ | ||
## 1.0.0 | ||
# 1.2.0 | ||
|
||
- Fix README | ||
- Moved integrating features to a separate package library `math_parser_integrate` | ||
|
||
|
||
# 1.1.0 | ||
|
||
- Custom variables support. | ||
- `MathFunctionX`deprecated. | ||
- `MathVariable` introduced. | ||
- You need to pass an instance of `MathVariableValues` instead of a num to the `calc()` function now | ||
|
||
|
||
# 1.0.0 | ||
|
||
- Initial version. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import 'package:math_parser/math_parser.dart'; | ||
import 'package:math_parser/integrate.dart'; | ||
|
||
/// Example function to calculate an expression from string | ||
void main() { | ||
// Parsing string to a MathNode | ||
final expression = MathNodeExpression.fromString( | ||
'((2x)^(e^3 + 4) + cos(3)x) / log[x + 3^2e](2 + (3x)^2)^5 * (2 + x)(x^2 + 3) + arcctg(x)', | ||
'((2x)^(e^3 + 4) + cos(3)x) / log[x_1*2 + 3^2e](2 + (3y)^2)^5 * (2 + y)(x^2 + 3) + arcctg(Θ)', | ||
variableNames: {'x', 'y', 'Θ', 'x_1'}, | ||
); | ||
// Display the parsed expression in human-readable form | ||
print(expression); | ||
|
||
// Evaluate the expression with `x = 20` and display result | ||
print(expression.calc(20)); | ||
// Evaluate the expression with `x = 20`, `y = 2`, `theta = 1/2` | ||
// and display result | ||
print(expression.calc( | ||
MathVariableValues({'x': 20, 'y': 2, 'Θ': 0.5, 'x_1': 3}), | ||
)); | ||
} | ||
|
||
/// Integrate library example | ||
void integrate() { | ||
print( | ||
MathNodeExpression.fromString('cos(x)') | ||
.definiteIntegralBySimpson(10, 0, 3.14), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/// Numerical methods for integrating extension | ||
/// | ||
/// Following methods available: | ||
/// - By rectangles (left, middle, right) | ||
/// - Simpson's method | ||
/// - By trapezoids | ||
/// | ||
/// In order to use the functionality import the `integrate.dart` file | ||
library math_parser_integrate; | ||
|
||
export 'src/extensions/integrate.dart'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// Math parsing error | ||
/// | ||
/// Errors must extends this class | ||
abstract class MathException implements Exception { | ||
/// Creates a new Math Exception | ||
const MathException(); | ||
} | ||
|
||
/// Undefined Variable Exception | ||
/// | ||
/// Thrown when there's a variable referenced in calculations which wasn't passed | ||
/// to the [MathNode.calc] function | ||
class UndefinedVariableException extends MathException { | ||
@override | ||
String toString() { | ||
return 'UndefinedVariableException: Variable "$name" was not defined in ' | ||
'the calc() function. Variable names are case-sensitive'; | ||
} | ||
|
||
/// The missing variable | ||
final String name; | ||
|
||
/// Created a new Undefined Variable Exception | ||
const UndefinedVariableException(this.name); | ||
} |
Oops, something went wrong.