Math

Math-expressions

A module for generating random mathematical expressions. Great for creating various simulators, where you'll have to wiggle your brain. You can see my application as an example.

Generating an expression with addition

GET https://shadify.dev/api/math/add
  • Generating an expression with subtraction
GET https://shadify.dev/api/math/sub
  • Generating an expression with multiplication
GET https://shadify.dev/api/math/mul
  • Generating an expression with division
GET https://shadify.dev/api/math/div

The following parameters are available for the above endpoints:

ParameterDescription
min-first, max-firstOptional

Parameters that change the range of generated numbers only for the first number present in the expression.

The default value for min-first is 1, for max-first it is 99.
min-second, max-secondOptional

Parameters that change the range of generated numbers only for the second number present in the expression. These parameters do not affect expressions with division, because the second number is chosen randomly from the list of possible divisors of the first number.

The default value for min-second is 1, for max-second it is 99.
negativeOptional

The number 0/1 which enables/disables the possibility of generating a result with a negative value for expressions with subtraction. Initially, when generating an expression with subtraction, the first number is always greater than the second number. To change this behavior, use this parameter.

Default value is 0.

Returned response:

{
    "first": 17,
    "second": 56,
    "operation": "+",
    "expression": "17 + 56",
    "answer": 73
}

Generating a quadratic equation

Quadratic-equation

Quadratic equation is an equation of the form ax2 + bx + c = 0, where the coefficients a, b and c are arbitrary numbers.

GET https://shadify.dev/api/math/quad
ParameterDescription
min-a, max-aOptional

Minimum and maximum values of the coefficient A.

The default value for min-a is 1, for max-a it is 20.
min-b, max-bOptional

Minimum and maximum values of the coefficient B.

The default value for min-b is 1, for max-b it is 40.
min-c, max-cOptional

Minimum and maximum values of the coefficient C.

The default value for min-c is 1, for max-c it is 20.

Returned response:

{
    "equation": "1x^2 + 14x + 24 = 0",
    "a": 1,
    "b": 14,
    "c": 24,
    "discriminant": 100,
    "x1": "-12.000",
    "x2": "-2.000"
}