extended_math 0.0.28

Library that add functionality of all maths sections that don't exist in dart:math

Currently this library is under heavy development! I appreciate any help in implementing any functionality of any section and hope this library will be helpful for developers and scientists.

Created under a MIT-style license.

Overview #

At the moment library have 4 sections:

Each section don't have full implementation yet. See here or dartdoc for which functionality are implemented.

Library also exports dart:math. So you don't need import it by yourself.

Sections are created according to Mathematics Subject Classification.

General mathematics #

Study of foundations of mathematics and logic.

Elementary algebra #

Have 2 class - QuadraticEquation and CubicEquation for solving equation expression.

import 'package:extended_math/extended_math.dart';

void main() {
  final q = QuadraticEquation(b: 2, c: 4);
  print(q); // 1x^2 + 2x + 4
  print(q.discriminant()); // -12
  print(q.calculate()); // {x1: -1.0 + -1.7320508075688772i, x2: -1.0 + 1.7320508075688772i} - all values are Complex
}

The same syntax available for CubicEquation:

import 'package:extended_math/extended_math.dart';

void main() {
  final q = CubicEquation(b: 2, c: 4, d: -30);
  print(q); // 1x^3 + 2x^2 + 4x + -30
  print(q.discriminant()); // 257.8888888888889
  print(q.calculate()); // {x1: 1.2128213086426722 + 0i, x2: -1.6064106543213361 + -2.305650223617183i, x3: -1.6064106543213361 + 2.305650223617183i}
}
  • computes hypot:
import 'package:extended_math/extended_math.dart';

void main(List<String> args) {
  final a = 3;
  final b = 4;
  print(hypot(3, 4)); // 5
}

Complex analysis #

Complex analysis, traditionally known as the theory of functions of a complex variable, is the branch of mathematical analysis that investigates functions of complex numbers.

You can freely multiplicate, add, subtract, divide complex number between each other, raw numbers (num, int, double) and Number, Integer, Double equivalent in this library. Also you can use power and root functions to complex number. Also you can compare one Complex number to other.

import 'package:extended_math/extended_math.dart';

void main() {
  final c = Complex(re: 3, im: 5);
  final c2 = Complex(im: 5);
  print(c); // 3 + 5i
  print(c2); // 0 + 5i
  print(c + c2); // 3 + 10i
  print(c / c2); // 1.0 + -0.6000000000000001i
  print(c * 3); // 9 + 15i
  print(c - Double(5.1)); // -2.0999999999999996 + 5i
  print(c.module); // 5.830951894845301
  print(c.argument); // 1.0303768265243125
  print(c.pow(2)); // -16 + 30i
  print(c.rootsOf(3)); // [1.6947707432797834 + 0.606106657133791i, 0.9260370715627757 + 1.5433951192712927i, -0.26273918171949434 + 1.7806126121333576i]
}

Discrete mathematics #

Discrete mathematics is the study of mathematical structures that are fundamentally discrete rather than continuous.

General algebraic systems #

A set with operations and relations defined on it. An algebraic system is one of the basic mathematical concepts and its general theory has been developed in depth.

Contains Number, Integer and Double analogs to Dart's types. They respond to scalar type of tensor and can be used in computations with tensors like Vector, Matrix, Tensor3 and Tensor4 and with each other.

Number #
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Number(5);
  final c2 = Number(3.6);
  print(c); // 5
  print(c.rootOf(4)); // 1.495348781277992
  print(c.toComplex()); // 5 + 0i
  print(c.toDouble()); // 5.0
  print(c * c2); // 18.0
}
Integer #

Contains all methods that have Number.

import 'package:extended_math/extended_math.dart';

void main() {
  final c = Integer(6);
  print(c); // 6
  print(c.factorizate()); // {2}
  print(c.isPrime()); // false
}
Double #

Contains all methods that have Number.

import 'package:extended_math/extended_math.dart';

void main() {
  final c = Double(6.283648723694762394);
  print(c); // 6.283648723694762394
  print(c.preciseTo(4)); // 6.2837
}

Linear algebra #

Linear algebra is the branch of mathematics concerning linear equations such as

a1x1 + ⋯ + anxn = b, linear functions such as (x1, …, xn) ↦ a1x1 + … + anxn, and their representations through matrices and vector spaces.

All object have common type TensorBase. Each object have shape, dimension properties and lerp (constructs tensor that is linear interpolated between this tensor and other tensor) method. Also all tensors can be multiplicated (by default is used hadamard product algorithm), added, subtracted, divided (not all tensors can be divided by tensor) by each other and compared to each other.

Every tensor can transform their values with map method, test each value with every, any method and reduce tensor to some value.

Vector #

Vector class have various methods to work with self:

  • get, sets values:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Vector(<num>[3, 5]);
  print(c); // [3, 5]
  print(c.itemAt(1)); // 3
  c.insert(4, position: 2);
  print(c); // [3, 4]
  print(c[0]); // 3
  c[0] = 2;
  print(c); // [2, 4]
}
  • computes norm (norm is a function that assigns a strictly positive length or size to each vector in a vector space—except for the zero vector, which is assigned a length of zero):
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Vector(<num>[3, 5]);
  print(c); // [3, 5]
  print(c.norm(6)); // 5.03814503530901
  print(c.euclideanNorm()); // 5.830951894845301
  print(c.maxNorm()); // 5
}
  • computes dot product, hadamard and cross product of two vectors:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Vector(<num>[3, 5, 4]);
  final c2 = Vector(<num>[1, 9.5, 4.78]);
  print(c.dot(c2)); // 69.62
  print(c.cross(c2)); // [-14.099999999999998, 10.34, 23.5]

  print(c.hadamard(c2)); // [3, 47.5, 19.12]
  // or
  print(c * c2); // [3, 47.5, 19.12]
}
  • computes angle between two vectors, length of vector:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Vector(<num>[3, 5, 4]);
  final c2 = Vector(<num>[1, 9.5, 4.78]);
  print(c.angleBetween(c2)); // 0.3982483416991972
  print(c.angleBetween(c2, degrees: true)); // 22.817949177415088
  print(c.length); // 7.0710678118654755
}
  • checks for unit, orthogonal and orthonormal vectors:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Vector(<num>[3, 5, 4]);
  final c2 = Vector(<num>[1, 9.5, 4.78]);
  print(c.isUnit()); // false
  print(c.isOrthogonalTo(c2)); // false
  print(c.isOrthonormalWith(c2)); // false
}
Matrix #

Matrix is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns.

Matrix have various methods for work with self:

  • get, change or remove columns/rows/values:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c); // [[4, 6], [7.4, 0.687]]
  print(c.rowAt(1)); // [4, 6]
  c.replaceRow(1, <num>[6, 1]);
  print(c.rowAt(1)); // [6, 1]

  print(c.columnAt(2)); // [1, 0.687]
  c.replaceColumn(2, <num>[7, 7]);
  print(c.columnAt(2)); // [7, 7]

  print(c.itemAt(1, 2)); // 7
  c.setItem(1, 2, 56);
  print(c.itemAt(1, 2)); // 56
}
  • matrix, hadamard product:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  final c2 = Matrix(<List<num>>[<num>[6, 3], <num>[1.2, 9]]);
  print(c * c2); // [[24, 18], [8.88, 6.183000000000001]]
  print(c.matrixProduct(c2)); // [[31.2, 66], [45.2244, 28.383000000000003]]
}
  • transposition:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.transpose()); // [[4, 7.4], [6, 0.687]]
}
  • computes frobenius norm:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.frobeniusNorm()); // 10.355287007128291
}
  • checks for diagonal, square, identity matrix:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.isDiagonal()); // false
  print(c.isSquare()); // true
  print(c.isIdentity()); // false
}
  • gets diagonals (main and collateral) as Vector:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.mainDiagonal()); // [4, 0.687]
  print(c.collateralDiagonal()); // [4, 0.687]
}
  • gets submatrix:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.submatrix(1, 1, 1, 1)); // [[4]]
}
  • perform gaussian elimination:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.gaussian()); // [[4, 6], [0.0, -10.413000000000002]]
}
  • gets trace, computes rank, condition (from singular value decomposition):
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.trace()); // 4.687
  print(c.rank()); // 2
  print(c.condition()); // 2.0977787840767292
}
  • computes singular value decomposition, qr decomposition:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Matrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.svd()); // {values: [[9.347549513876027, 0.0], [0.0, 4.455927185854372]], leftVectors: [[0.689976140659287, 0.7238321112805896], [0.7238321112805896, -0.689976140659287]], rightVectors: [[0.8682769932446228, -0.49607969420454756], [0.49607969420454756, 0.8682769932446228]]}
  print(c.qr()); // {Q: [[0.47551703436547405, 0.8797065135761271], [0.8797065135761271, -0.47551703436547416]], R: [[8.411896337925237, 3.4574605810196437], [0, 4.951558878847681]]}
}
  • computes norm, infinityNorm and spectralNorm:
import 'package:extended_math/extended_math.dart';

void main(List<String> args) {
  final m = SquareMatrix(<List<num>>[
    <num>[4, 12, -16],
    <num>[12, 37, -43],
    <num>[-16, -43, 98],
  ]);
  print(m.norm(3)); // 105.14932646039733
  print(m.infinityNorm()); // 157
  print(m.spectralNorm()); // 123.4772317901316
}

SquareMatrix and DiagonalMatrix are separated into own classes. They have specific methods that aren't be used by Matrix.

SquareMatrix #
  • computes determinant:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = SquareMatrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.determinant()); // -41.65200000000001
}
  • checks if this matrix is singular, symmetric, positive (semi)definite, negative (semi)definite, indefinite, orthogonal, upper triangle, lower triangle:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = SquareMatrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.isSingular()); // false
  print(c.isSymmetric()); // false
  print(c.isPositiveDefinite()); // false
  print(c.isPositiveSemiDefinite()); // false
  print(c.isNegativeDefinite()); // false
  print(c.isNegativeSemiDefinite()); // false
  print(c.isIndefinite()); // false
  print(c.isOrthogonal()); // false
  print(c.isUpperTriangle()); // false
  print(c.isLowerTriangle()); // false
}
  • inverse:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = SquareMatrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.inverse()); // [[-0.016493805819648516, 0.14405070584845864], [0.177662537213099, -0.09603380389897243]]
}
  • computes eigen decomposition, lu decomposition, cholesky decomposition:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = SquareMatrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.eigen()); // {9.20964828342645: [0.7550878197650748, -0.5786428772738614], -4.522648283426451: [0.6556236606792238, 0.821928287452503]}
  print(c.cholesky()); // null, because this marrix isn't positive definite
  print(c.lu()); // {upper: [[4, 6], [0.0, -10.413000000000002]], lower: [[1, 0], [1.85, 1]], pivote: [[1, 0], [0, 1]]}
}
  • solves linear expressions using gaussian elimination:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = SquareMatrix(<List<num>>[<num>[4, 6], <num>[7.4, 0.687]]);
  print(c.eliminate(<num>[1, 2])); // [0.2716076058772688, -0.014405070584845855] (x and y)
}
DiagonalMatrix #

Have the same methods as Matrix and SquareMatrix.

Tensor3 #

Have methods that are defined in TensorBase class.

Also can return layer of depth:

import 'package:extended_math/extended_math.dart';

void main() {
  final c = Tensor3(<List<List<num>>>[
    <List<num>>[
      <num>[4, 5]],
      <List<num>>[<num>[7, 1]
    ]
  ]);
  print(c.matrixAt(1)); // [[4], [7]]
}
Tensor4 #

Have methods thar are defined in TensorBase class.

Number theory #

This section doesn't provided yet (some functionality is in Integer class).

Applied mathematics #

Applied mathematics is the application of mathematical methods by different fields such as science, engineering, business, computer science, and industry.

Numerical analysis #

Numerical analysis is the study of algorithms that use numerical approximation (as opposed to symbolic manipulations) for the problems of mathematical analysis (as distinguished from discrete mathematics).

Secant method #

The secant method is a root-finding algorithm that uses a succession of roots of secant lines to better approximate a root of a function f.

import 'package:extended_math/extended_math.dart';

void main(List<String> args) {
  num equationFn(num value) {
    return pow(value, 3) - 18 * value - 83;
  }

  final p = SecantMethod(equationFn, 2, 10, 0.001);
  print(p.result()); // 5.705107053246152
}
Newton's method #

Newton's method, also known as the Newton–Raphson method, named after Isaac Newton and Joseph Raphson, is a root-finding algorithm which produces successively better approximations to the roots (or zeroes) of a real-valued function.

The most basic version starts with a single-variable function f defined for a real variable x, the function's derivative f ′, and an initial guess x0 for a root of f. If the function satisfies necessary assumptions and the initial guess is close, then a better approximation x1 is x1 = x0 − f(x0) / f′(x0).

import 'package:extended_math/extended_math.dart';

void main() {
  // expression == x^3 - 18*x -83
  final n = NewtonsMethod(<num>[1, -18, -83], <int>[3, 1, 0]);
  print(n.upperLimit()); // 84.0
  print(n.lowerLimit()); // -84.0
  print(n.findSignChange()); // [5.040000000000064, 6.720000000000064]
  print(n.calculateFrom(10)); // 5.705115796346382
}

Probability distributions #

A probability distribution is a mathematical function that provides the probabilities of occurrence of different possible outcomes in an experiment.

Uniform distribution #

The continuous uniform distribution is a family of symmetric probability distributions such that for each member of the family, all intervals of the same length on the distribution's support are equally probable.

  • computes density, cumulative distribution function (CDF), moments (central and common):
import 'package:extended_math/extended_math.dart';

void main() {
  final c = UniformDistribution(3, l: -9, u: 45);
  print(c.density()); // 0.018518518518518517
  print(c.cdf()); // 0.2222222222222222
  print(c.centralMoment(3)); // 0
  print(c.moment(3)); // 18954.0
}

Numbers generator #

  • generates integer or double numbers in given range:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = NumbersGenerator();
  print(c.nextInt(10, from: 1)); // 3
  print(c.nextDouble(to: 10, from: 1)); // 4.825205248575396
}

Also it supports generating numbers as Iterable:

import 'package:extended_math/extended_math.dart';

void main() {
  final c = NumbersGenerator();
  print(c.intIterableSync(to: 5, from: 1).take(5)); // (2, 3, 1, 3, 8)
  print(c.doubleIterableSync(to: 5, from: 1).take(5)); // (3.3772583795670412, 3.2489709159796276, 4.761700666599024, 4.425092938268564, 1.1353964008448607)
}

Statistic #

Statistics is a branch of mathematics dealing with data collection, organization, analysis, interpretation and presentation.

Central tendency #

Class that can computes the mean value of a discrete set of numbers:

import 'package:extended_math/extended_math.dart';

void main() {
  final c = CentralTendency(Vector(<num>[8, 5, 3]));
  print(c.arithmetic()); // 5.333333333333333
  print(c.geometric()); // 4.932424148661106
  print(c.harmonic()); // 4.556962025316456
  print(c.quadratic()); // 5.715476066494082
  print(c.maximum()); // 8
  print(c.minimum()); // 3

  // It is common algorithm for all above means
  print(c.generalized(2)); // 5.715476068195464
}

Also you can provide weights of numbers in set:

import 'package:extended_math/extended_math.dart';

void main() {
  final c = CentralTendency(Vector(<num>[8, 5, 3]));
  print(c.arithmetic(weights: Vector(<num>[.25, .5, .25]))); // 5.25
  print(c.geometric(weights: Vector(<num>[.25, .5, .25]))); // 4.949232003839765
  print(c.harmonic(weights: Vector(<num>[.25, .5, .25]))); // 4.660194174757281
  print(c.quadratic()); // 5.715476066494082

  // It is common algorithm for all above means
  print(c.generalized(2)); // 5.715476068195464
}
  • computes mode and median:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = CentralTendency(Vector(<num>[2, 5, 3, -6, 5, 2]));
  print(c.mode()); // {2, 5}
  print(c.median()); // -1.5
}

Dispersion #

Dispersion (also called variability, scatter, or spread) is the extent to which a distribution is stretched or squeezed.[1] Common examples of measures of statistical dispersion are the variance, standard deviation, and interquartile range:

  • gets expected value (mean), standard deviation (population and sample), variance (population and sample) of set of random numbers:
import 'package:extended_math/extended_math.dart';

void main() {
  final c = Dispersion(Vector(<num>[8, 5, 3]));
  print(c.expectedValue()); // 5.333333333333333
  print(c.std()); // 2.054804667656325
  print(t.std(type: 'sample')); // 2.516611478423583
  print(c.variance()); // 4.222222222222221
  print(t.variance(type: 'sample')); // 6.333333333333333
}
  • computes interquartile range (IQR):
import 'package:extended_math/extended_math.dart';

void main() {
  const t = Vector(
    <num>[7, 7, 21, 25, 31, 31, 47, 75, 87, 115, 116, 119, 119, 155, 177]);
  print(Dispersion(t).iqr()); // 94
}

ShapeOfProbabilityDistribution #

The concept of the shape of a probability distribution arises in questions of finding an appropriate distribution to use to model the statistical properties of a population, given a sample from that population.

  • computes skewness, moment and kurtosis (normal and excess):
import 'package:extended_math/extended_math.dart';

void main() {
  const t = ShapeOfProbabilityDistribution(Vector(<num>[8, 5, 3]));
  print(t.moment(2)); // 4.222222222222222
  print(t.skewness()); // 0.23906314692954517
  print(t.kurtosis()); // 1.5
  print(t.kurtosis(excess: true)); // -1.5
}

Quantiles #

In statistics and probability quantiles are cut points dividing the range of a probability distribution into continuous intervals with equal probabilities, or dividing the observations in a sample in the same way.

Quantile #

Base class for all quantiles.

Quartile #

A quartile is a type of quantile.

import 'package:extended_math/extended_math.dart';

void main() {
  const t = Vector(
    <num>[7, 7, 21, 25, 31, 31, 47, 75, 87, 115, 116, 119, 119, 155, 177]);
  print(Quartile(t).all); // [25, 75, 119]
  print(Quartile(t, method: 'two').all); // [28.0, 75, 117.5]
  print(Quartile(t, method: 'three').all); // [26.5, 75, 118.25]
  print(Quartile(t).first); // 26.5
}
Percentile #

A percentile (or a centile) is a measure used in statistics indicating the value below which a given percentage of observations in a group of observations falls. For example, the 20th percentile is the value (or score) below which 20% of the observations may be found.

  • computes value and ordinal rank:
import 'package:extended_math/extended_math.dart';

void main() {
  const t = Vector(
    <num>[7, 7, 21, 25, 31, 31, 47, 75, 87, 115, 116, 119, 119, 155, 177]);
  final p = Percentile(t, 33);
  print(p.ordinalRank()); // 5
  print(p.value()); // 31
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0.0.28 #

  • Add NewtonsMethod to Numerical analysis.
  • Update README.

0.0.27 #

  • Remove internal method that don't touch main functionality.
  • Add Numerical analysis section with SecantMethod for finding root of function.

0.0.26 #

  • Change signature of intIterableSync() and doubleIterableSync() of NumbersGenerator - now they can generate infinite count of numbers.
  • Replace calculate() with getter all in Quartile class.
  • Make Integer constructor const.
  • Add to Vector [] and []= operators that behave like Lists operators.
  • Change hadamardProduct() to hadamard() in Vector class.
  • Change hadamardProduct() to hadamard() in Matrix class.
  • Improve docs.

0.0.25 #

  • Removed data dependency due to package version of Dart SDK restriction.
  • Add UnaryOperations section with hypot().
  • Change signature of insert() of Vector and add add().
  • Add norm(), infinityNorm(), spectralNorm() and condition() to Matrix.
  • Library also exports dart:math;

0.0.24 #

  • Add iqr() method to Dispersion class.
  • Add Quantile, Quartile and Percentile classes.
  • Improved README.

0.0.23 #

  • Replace setItem() by insert() of Vector class.
  • Rename dotProduct() by dot(), crossProduct() by cross() of Vector class.
  • Small fix of style and internal values in classes.
  • Make most constructors of classes as const.
  • Rename ContinuousUniformDistributions to UniformDistribution and add to it skewness and excessKurtosis constants.
  • Change std() and variance() of TheoryOfProbabilityDistributions to calculate sample and population types.
  • Add ShapeOfProbabilityDistribution and skewness(), kurtosis(), moment() to it.
  • Move TheoryOfProbabilityDistributions class to Dispersion class.
  • Change README.

0.0.22 #

  • Move Mean class to CentralTendency.
  • Add median(), mode(), minimum(), maximum() methods to CentralTendency class.
  • Fix setItem() of Vector class.
  • Add subvector(), insert() to Vector class.

0.0.21 #

  • Fix rootOf() method of Number class to accept positive integer of double number as degree.
  • Some small fix in the code, that don't touch functionality.
  • Completely rewrite README to give more information about package.
  • Rename UniformDistributions into ContinuousUniformDistributions class.

0.0.20 #

  • Add UniformDistributions class.
  • Change some lines of code in Mean class.

0.0.19 #

  • Moves isUpperTriangular() method to SquareMatrix class.
  • Add isLowerTriangular(), cholesky(), isIndefinite(), lu() method to SquareMatrix class.
  • Add qr() method to Matrix class.
  • Add isPositiveDefinite(), isPositiveSemiDefinite(), isNegativeDefinite() and isNegativeSemiDefinite() methods to SquareMatrix class.
  • Fix inverse() method of SquareMatrix class.
  • Rename eigenDecomposition() to eigen() method of SquareMatrix class.

0.0.18 #

  • Add lerp() method to TensorBase class.
  • Add condition() method to Matrix class.
  • Fix eliminate() method of SquareMatrix class.
  • Add toComplex() method to Number class;
  • Add some internal helper methods.

0.0.17 #

  • Add reduce(), any(), every(), map(), toList() methods to TensorBase class.
  • Add TensorBase.generate constructor and to its subclasses.
  • Rename transform() method of Vactor and Matrix to map().
  • Add statistic subsection with Mean class.
  • Add itemAt() and setItem() methods to Tensor3 and Tensor4 classes.

0.0.16+1 #

  • Fix preciseTo() method of Double class.

0.0.16 #

  • Add Tensor3 class for work with three-dimensional tensors.
  • Remove VectorBase, MatrixBase classes.
  • Add TensorException class.

0.0.15 #

  • Moves functionality of CompositeNumber class to Integer class.

0.0.14+1 #

  • Downgrade required Dart SDK to 2.1.0-dev.9.4.

0.0.14 #

  • Remove Complex.toComplex() constructor.
  • Rewrite calculate() method of EquationBase class to calculate complex roots.
  • Change return object of eigenDecomposition() method of SquareMatrix class.
  • Fix calculate() method of CubicEquation class.
  • Allow * and / operators of Complex class for work with real numbers.
  • Create CopyableMixin which extends MatrixBase, VectorBase and Complex classes.
  • Add isReal(), conjugate() and toReal() methods to Complex class.
  • Change rootsOf() method of Complex class to return all roots.
  • Add Number, Integer and Double classes in subsuction of discrete mathematics.
  • Implement *, /, + and - operators for new types.
  • Small changes in README.

0.0.13 #

  • Rename multiplyByMatrix() to matrixProduct() of MatrixBase class.
  • Fix gaussian() method.
  • Add eigenDecomposition() method to SquareMatrix class.
  • Add svd() method to MatrixBase class.

0.0.12 #

  • Add swapRows(), swapColumns(), submatrix(), gaussian(), rank() and isUpperTriangle() methods to MatrixBase class.
  • Distinct insert(Row/Column)() to (replace/append)(Row/Column)() methods of MatrixBase class.
  • Split toMatrix() mathod of VectorBase class to toMatrix(Row/Column)() methods.
  • Move / operator to SquareMatrix class from MatrixBase.
  • Removes _multiplyByVector() method from MatrixBase class.
  • Change methods for work with rows and columns of matrix to work with self instance.
  • Set data to private and create getter with the same name which returns copy of data.
  • Add CONTRIBUTING.md.

0.0.11 #

  • Removes overridden multiplyByVector() method in DiagonalMatrix class.
  • Change multiplyByVector() and multiplyBy() methods to private methods.
  • Comment eigenDecomposition() and svd() methods of SquareMatrix class - they aren't finished.
  • Rename I class to Complex class.
  • Implement rootOf() and pow() methods of Complex class.

0.0.10 #

  • Fix QuadraticEquation's and CubicEquation's calculate() method.
  • Fix factorizate() method of CompositeNumber class.
  • Implement *, /, + and - operators for complex number I.
  • Add module, argument getters to I class.
  • Changed double type of elements to num type.
  • Override == operator for MatrixBase, VectorBase and Complex classes.

0.0.9 #

  • Override *, /, + and - operators of VectorBase class.
  • Removes add() and subtract() methods of VectorBase class.
  • Override *, /, + and - operators of MatrixBase class.
  • Removes add() and subtract() methods of MatrixBase class.

0.0.8 #

  • Unit number_theory and linear_algebra into discrete_mathematics.
  • Add Probability theory subsection with NumbersGenerator class.
  • Correct title in LICENSE.

0.0.7 #

  • Add Complex analysis, General and Number theory sections.
  • Implement QuadraticEquation and CubicEquation classes of General section.
  • Implement CompositeNumber of Number theory section.
  • Add eliminate() method to SquareMatrix class.

0.0.6 #

  • Add rowAsVector(), columnAsVector() methods to MatrixBase class.
  • Override multiplyByVector() and inverse() methods in DiagonalMatrix class.
  • Add isSymmetric() and isOrthogonal() methods to SquareMatrix class.
  • Add hadamardProduct(), transform(), isUnit(), isOrthogonalTo(), isOrthonormalWith() methods to VectorBase class.

0.0.5 #

  • Inner refactoring of support methods.
  • Create DiagonalMatrix class.
  • Add isSquare(), isDiagonal(), isIdentity(), mainDiagonal(), toSquareMatrix() and toDiagonalMatrix() methods to MatrixBase class.
  • Add length getter and crossProduct() method to VectorBase class.

0.0.4 #

  • Add frobeniusNorm() method to MatrixBase class.
  • Add norm(), euclideanNorm(), maxNorm() and angleBetween() methods to VectorBase class.
  • Fix dot() method of VectorBase class.

0.0.3 #

  • Add isIdentity(), replaceRow() and replaceColumn methods to MatrixBase class.
  • Add inverse(), isSingular() and isNotSingular() methods to SquareMatrix class.
  • Fix getDeterminant() method.
  • Small changes in classes with access to items of matrices and vectors.

0.0.2 #

  • Add and implement add(), subtract() methods to Vector class.
  • Add SquareMatrix class.
  • Implement getDeterminant() methods of SquareMatrix class.
  • Add identity() constructor for matrices.
  • Move generate() constructor from Matrix class to MatrixBase and add to it identity parameter.

0.0.1 #

  • Add Vector, Matrix and Tensor classes for working with according objects of linear algebra.
  • Implements addition, subtraction, multiplication methods of Vector and Matrix.

example/extended_math_example.dart

import 'package:extended_math/extended_math.dart';

void main() {
  final v1 = Vector(<double>[1, 2, 3]);
  final v2 = Vector(<double>[4, 5, 6]);
  // Multiply vectors
  final double res = v1.dot(v2);
  // Add vectors
  final Vector res1 = v1 + v2;

  final v5 = Vector(<double>[6, 3]);
  final v6 = Vector(<double>[5, 13]);
  // Gets angle between two vectors
  print(v5.angleBetween(v6));

  final v3 = SquareMatrix(<List<double>>[
    <double>[9, 3, 5], 
    <double>[-6, -9, 7], 
    <double>[-1, -8, 1]
  ]);
  // Gets determinant of matrix
  final double det = v3.determinant();

  // Computes eigenvalues and eigenvectors of square matrix
  final Map<num, Vector> result = v3.eigen();

  final m = Matrix(<List<double>>[
    <double>[2, -1, 5],
    <double>[0, 2, 1],
    <double>[3, 1, 1]
  ]);
  // Computes Frobenius norm of matrix
  print(m.frobeniusNorm());

  final c = Complex(re: -4);
  final c2 = Complex(re: -4);
  // Gets root of complex number
  final r = c.rootsOf(2);
  // Divides complex numbers
  print(c / c2);
  // Gets pow of complex number
  print(Complex(re: 2).pow(2));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  extended_math: ^0.0.28

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:extended_math/extended_math.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
60
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
78
Learn more about scoring.

We analyzed this package on Sep 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:extended_math/extended_math.dart.

Health suggestions

Fix lib/src/applied_mathematics/statistic/central_tendency.dart. (-0.50 points)

Analysis of lib/src/applied_mathematics/statistic/central_tendency.dart reported 1 hint:

line 146 col 20: Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions.

Fix lib/src/discrete_mathematics/general_algebraic_systems/number/integer.dart. (-0.50 points)

Analysis of lib/src/discrete_mathematics/general_algebraic_systems/number/integer.dart reported 1 hint:

line 17 col 20: Set literals weren't supported until version 2.2, but this code is required to be able to run on earlier versions.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev.9.4 <3.0.0
meta ^1.1.6 1.1.7
quiver ^2.0.0 2.0.5
Transitive dependencies
matcher 0.12.5
path 1.6.4
stack_trace 1.9.3
Dev dependencies
test ^1.5.3