AngouriMath

Navigation

← Back to list of members

ScaleBy​(PeterO.​Numbers.​ERational,​AngouriMath.​Entity)

 Method (no overloads)

Summary

num / (a + b) becomes num * (a - b) / (a^2 - b^2), which clears a
square root out of a two-term denominator:
(5 - sqrt(3)) / (5 + sqrt(3)) is 14/11 - 5/11 * sqrt(3).

Remarks

The library already prefers a denominator without a surd -- 1/sqrt(2) has
always come back as sqrt(2)/2 -- so this extends an existing preference to
the binomial case. https://github.com/asc-community/AngouriMath/issues/205
Three conditions, and each is load-bearing. The denominator must be constant,
because multiplying numerator and denominator by a - b is only valid where
that is non-zero, and for a symbolic denominator it is not decidable -- rewriting
there would either lose a value or attach a condition to every such quotient.
a^2 - b^2 must fold to a rational, which is what says the root was
actually cleared: a conjugate does nothing for a cube root, where
1 - 2^(2/3) is no better than 1 + 2^(1/3). And it must be non-zero,
which rules out a = b and, since it is (a-b)(a+b), guarantees the
original denominator was non-zero too.
Terminates because the rewritten denominator is a rational and this rule requires
a surd in the denominator to fire at all.

Summary

p * value / q for a rational p/q, written so that the rational is
split across the quotient rather than left as a factor: a unit-numerator rational
carries its own weight in the complexity criteria, so (1/2) * value would
rate worse than value / 2 and hand back the comparison this is trying to win.

























Angouri © 2019-2023 · Project's repo · Site's repo · Octicons · Transparency · 1953 pages online