Nerdamer: Algebra & Other Symbolic Functions
This section covers various algebraic manipulation tools, number theory functions, and transforms provided by Nerdamer.js through JS Calc.
Factoring Polynomials: factor()
Symbolically factors a polynomial expression.
Syntax: factor(polynomial)
Examples:
> factor(x^2 - 1)
(x-1)*(x+1)
> factor(a^3 - b^3)
(a-b)(a^2+ab+b^2)
> factor(x^2 + 5x + 6)
(x+2)*(x+3)
Expanding Expressions: expand()
Expands polynomial expressions.
Syntax: expand(expression)
Examples:
> expand((x+y)^3)
3*x*y^2+3*x^2*y+x^3+y^3 // equivalent to x^3+3x^2y+3xy^2+y^3
> expand((a-2)(a+3)(a-1))
-7*a+a^3+6 // equivalent to a^3-7*a+6
Partial Fractions: partfrac()
Performs partial fraction decomposition on a rational expression.
Syntax: partfrac(rationalExpression, variable)
Examples:
> partfrac(1/(x^3-x), x)
(1/2)(x-1)^(-1)-x^(-1)+(1/2)(x+1)^(-1)
// equivalent to 1/(2*(x-1)) - 1/x + 1/(2*(x+1))
> partfrac( (5x-3)/(x^2-2x-3), x )
2*(1+x)^(-1)+3*(-3+x)^(-1)
// equivalent to 2/(x+1)+3/(x-3)
Polynomial Roots: roots()
Finds the roots (solutions) of a polynomial equation (where the expression is implicitly set to zero).
Syntax: roots(polynomial_expression [, variable])
* If variable
is omitted, Nerdamer attempts to determine it (usually the most common variable or if only one is present).
Examples:
> roots(x^2-4)
2, -2
> roots(a^3+8, a)
(88063572/50843527)*i+1, (-88063572/50843527)*i+1, -2
// equivalent to -2, 1-1.7320508075688772i, 1+1.7320508075688772i
Greatest Common Divisor: gcd()
Finds the greatest common divisor (GCD) of two expressions, which can be numbers or symbolic polynomials.
Syntax: gcd(expression1, expression2)
Examples:
> gcd(18, 12)
6
> gcd(x^2-1, x^2+2x+1)
1+x
Least Common Multiple: lcm()
Finds the least common multiple (LCM) of two expressions.
Syntax: lcm(expression1, expression2)
Examples:
> lcm(4, 6)
12
> lcm(x-1, x+1)
(-1+x)*(1+x)
Primality Test: isPrime()
Tests if an integer expression evaluates to a prime number.
Syntax: isPrime(integerExpression)
* The expression must evaluate to a definite integer.
Examples:
> isPrime(7)
true
> isPrime(10)
false
> x=3
> isPrime(x^2+x+41) // 3^2+3+41 = 53
true
isPrime(x)
(ifx
is an undefined symbol) will result in an error.
Polynomial Coefficients: coeffs()
Extracts the coefficients of a polynomial with respect to a specified variable, usually in ascending order of power.
Syntax: coeffs(polynomial, variable)
Examples:
> coeffs(2*x^3 - x + 7, x)
7, -1, 0, 2 // Coefficients for x^0, x^1, x^2, x^3
> coeffs(at^2 + bt + c, t)
c, b, a
Polynomial Degree: deg()
Returns the degree of a polynomial with respect to a specified variable.
Syntax: deg(polynomial, variable)
Examples:
> deg(4y^5 - 2y^2, y)
5
> deg(x^2 + xy + y, x) // Degree with respect to x
2
Expression Simplification: simplify()
Attempts to simplify a given mathematical expression. Simplification can be complex and results may vary based on the expression.
Syntax: simplify(expression)
Examples:
> simplify(x+x+y+y-x)
2*y + x
> simplify(sin(x)^2+cos(x)^2)
1
> simplify((x^2-1)/(x-1))
1+x
Complete the Square: sqcomp()
Completes the square for a quadratic expression with respect to a variable. Works best when coefficients (other than the variable of completion) are numerical.
Syntax: sqcomp(expression, variable)
Examples:
> sqcomp(x^2+2x+5, x)
(1+x)^2+4
> sqcomp(y^2-6y+10, y)
(-3+y)^2+1
> sqcomp(ay^2+by+c, y)
ax^2+bx+c // May return original if a,b,c are symbolic
Laplace Transform: laplace()
Computes the Laplace Transform of an expression. It's common for CAS to leave factorial(n) unexpanded for small n in symbolic output, or to use negative exponents.
Syntax: laplace(expression, time_variable, frequency_variable)
Examples:
> laplace(t^2, t, s)
factorial(2)*s^(-3) // equivalent to 2/s^3 or 2*s^(-3)
> laplace(exp(a*t), t, s)
(-a+s)^(-1) // equivalent to (s-a)^(-1) or 1/(s-a)
- CSP Note: Complex transforms may be affected by browser Content Security Policy.
Inverse Laplace Transform: ilt()
Computes the Inverse Laplace Transform of an expression.
Syntax: ilt(expression, frequency_variable, time_variable)
Examples:
> ilt(1/s^2, s, t)
t
> ilt(a/(s^2+a^2), s, t)
sin(a*t)
- CSP Note: Complex transforms may be affected by browser Content Security Policy.