Function reference · Algebra

sqcomp

Rewrites a quadratic as a square plus a constant.

In Notation it is sqcomp. In JavaScript it is completeSquare, which also returns the parts of a*(x+h)^2+k; see Results & output.

Notation

sqcomp(expr, variable)

Write it in an expression: nerdamer('sqcomp(x^2+6*x+1)'), or in the Playground.

nerdamer.sqcomp

nerdamer.completeSquare(expr: ExpressionInput, variable?: string): CompleteSquareResult

A method on the default import. Arguments can be strings, as in Notation.

import { completeSquare }

import { completeSquare } from 'nerdamer/algebra';
(expr: ExpressionInput, variable?: string): CompleteSquareResult

Import only this function, from nerdamer/algebra.

Examples

x^2+6*x+1 is (x+3)^2-8.

sqcomp(x^2+6*x+1)
// → -8+(3+x)^2
Open in Playground

Also called

completeSquare

← Back to Function reference