Skip to content

IsQuadraticIrrational ​

True when xx is an irrational root of a quadratic with integer coefficients — exactly the numbers with an eventually periodic continued fraction.

✓ checked against that system · ! checked, with disagreements (hover a chip)Wolfram LanguageQuadraticIrrationalQ✓
IsQuadraticIrrational(x)whether xx is a quadratic irrational
Typed signatures
TypePackageApplies
(value) -> booleanmodularalways

Domain: The modular group

Details
  • Recognised structurally: a rational affine combination with exactly one irrational Sqrt term, at any rational scale — n\sqrt n, 323\sqrt2, 1+51+\sqrt5, (1+5)/2(1+\sqrt5)/2, 1−31-\sqrt3
  • A rational is not irrational, so it is False, not merely unrecognised
  • Wolfram calls this QuadraticIrrationalQ; the name here follows compute-engine's own Is… convention instead
  • Every quadratic irrational's continued fraction is eventually periodic (Lagrange's theorem), and conversely — see ContinuedFraction

Examples

Basic #
live ↗
InIsQuadraticIrrational(2)\mathrm{IsQuadraticIrrational}(\sqrt{2})OutTrue\mathrm{True}

the golden ratio

live ↗
InIsQuadraticIrrational(1+52)\mathrm{IsQuadraticIrrational}(\frac{1+\sqrt{5}}{2})OutTrue\mathrm{True}

a cube root is algebraic of degree 3

live ↗
InIsQuadraticIrrational(23)\mathrm{IsQuadraticIrrational}(\sqrt[3]{2})OutFalse\mathrm{False}

1+21+\sqrt2 is a root of a quadratic with integer coefficients

live ↗
InIsQuadraticIrrational(1+2)\mathrm{IsQuadraticIrrational}(1+\sqrt{2})OutTrue\mathrm{True}

2+3\sqrt2+\sqrt3 has degree 44, not 22

live ↗
InIsQuadraticIrrational(2+3)\mathrm{IsQuadraticIrrational}(\sqrt{2}+\sqrt{3})OutFalse\mathrm{False}
Scope #

transcendental

live ↗
InIsQuadraticIrrational(π)\mathrm{IsQuadraticIrrational}(π)OutFalse\mathrm{False}

rational once simplified

live ↗
InIsQuadraticIrrational(4)\mathrm{IsQuadraticIrrational}(\sqrt{4})OutFalse\mathrm{False}

a plain integer

live ↗
InIsQuadraticIrrational(5)\mathrm{IsQuadraticIrrational}(5)OutFalse\mathrm{False}

a rational multiple of a surd

live ↗
InIsQuadraticIrrational(32)\mathrm{IsQuadraticIrrational}(3\sqrt{2})OutTrue\mathrm{True}

a surd subtracted from a rational

live ↗
InIsQuadraticIrrational(1−3)\mathrm{IsQuadraticIrrational}(1-\sqrt{3})OutTrue\mathrm{True}

Rationals are not irrational at all

live ↗
InIsQuadraticIrrational(32)\mathrm{IsQuadraticIrrational}(\frac{3}{2})OutFalse\mathrm{False}

Threads over a list; the integer 22 is rational

live ↗
InIsQuadraticIrrational([2,3,2])\mathrm{IsQuadraticIrrational}(\bigl\lbrack\sqrt{2}, \sqrt{3}, 2\bigr\rbrack)Out[True,True,False]\bigl\lbrack\mathrm{True}, \mathrm{True}, \mathrm{False}\bigr\rbrack
live ↗
InIsQuadraticIrrational(s)\mathrm{IsQuadraticIrrational}(s)OutFalse\mathrm{False}
Possible issues #

a rational is not irrational

live ↗
InIsQuadraticIrrational(34)\mathrm{IsQuadraticIrrational}(\frac{3}{4})OutFalse\mathrm{False}
About
Examples14
Checked againstWolfram Language 14 agree
CrosswalkWolfram Language

See also: ContinuedFraction, Convergents