math_parser 1.2.0 copy "math_parser: ^1.2.0" to clipboard
math_parser: ^1.2.0 copied to clipboard

outdated

Process math expressions, convert them to machine-readable form, and calculate them.

example/math_parser_example.dart

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_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`, `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),
  );
}
11
likes
0
pub points
81%
popularity

Publisher

verified publishersominemo.com

Process math expressions, convert them to machine-readable form, and calculate them.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

More

Packages that depend on math_parser