Get started with mathjs CDN

Apache-2.0 licensed

MathJS is a popular library for performing mathematical calculations.

Tags:
  • math
  • mathematics
  • functions
  • numeric
  • parser
  • expression
  • real
  • complex
  • matrix
  • unit

Stable version

Copied!

How to start using mathjs CDN


<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.jsdelivr.net/npm/mathjs@12.4.1/es5/math.js"></script>
</head>
<body>
    <script>
        const Math = math; // Assign MathJS to a variable for convenience

        // Perform some mathematical operations
        const a = b => Math.add(b, 5); // Define a function for adding 5 to a number
        const x = 3;
        const y = 7;

        // Perform some calculations
        const sum = a(x); // Add 5 to x
        const difference = Math.subtract(x, y); // Subtract y from x
        const product = Math.multiply(x, y); // Multiply x and y
        const quotient = Math.divide(product, sum); // Divide the product by the sum

        // Display the results
        console.log(`Sum: ${sum()}`);
        console.log(`Difference: ${difference}`);
        console.log(`Product: ${product}`);
        console.log(`Quotient: ${quotient.toFixed(2)}`);
    </script>
</body>
</html>
Copied!
Copied!
Copied!

All versions

0.12.0 0.12.1 0.13.0 0.14.0 0.15.0 0.16.0 0.17.0 0.17.1 0.18.0 0.18.1 0.19.0 0.20.0 0.21.0 0.21.1 0.22.0 0.23.0 0.24.0 0.24.1 0.25.0 0.26.0 0.27.0 1.0.0 1.0.1 1.1.0 1.1.1 1.2.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 10.0.0 10.0.1 10.0.2 10.1.0 10.1.1 10.2.0 10.3.0 10.4.0 10.4.1 10.4.2 10.4.3 10.5.0 10.5.1 10.5.2 10.5.3 10.6.0 10.6.1 10.6.2 10.6.3 10.6.4 11.0.0 11.0.1 11.1.0 11.10.0 11.10.1 11.11.0 11.11.1 11.11.2 11.12.0 11.2.0 11.2.1 11.3.0 11.3.1 11.3.2 11.3.3 11.4.0 11.5.0 11.5.1 11.6.0 11.7.0 11.8.0 11.8.1 11.8.2 11.9.0 11.9.1 12.0.0 12.1.0 12.2.0 12.2.1 12.3.0 12.3.1 12.3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