"I'm doing algebra."

"So?"

"You don't understand. I'm doing algebra... with square roots... and divisions..."

"What? With square roots, you say, and divisions?"

"Correct!"

"Ew..."

"I know. My stomach turns too."

#algebra #SquareRoot #division

Happy Square Root Day (5ร—5=25), or as John Mastodon would call it: Square Toot Day!

https://en.wikipedia.org/wiki/Square_Root_Day

#SquareRootDay #SquareRoot #Math #Mathematics

Square Root Day - Wikipedia

A question[1] asked about a fast reciprocal square root implementation using binary floating point format magic number, following the famous trick in Quake 3, but extended to higher precisions.

The paper linked in the question is pretty good, I managed to grok the first part (finding magic exponent), but haven't found a good way to implement the second part (finding magic mantissa) yet (I'd need to implement minimisation of a function that has square roots, in high precision). Luckily the paper provides the magic mantissa to sufficiently many digits.

Using a float128 magic number, plus 5 iterations of Newton's method, gets an accurate reciprocal square root. Hooray!

However, it turns out to be pointless: it's both faster (about 2.3x in my test) and more accurate (denormalized numbers are handled correctly) to range-reduce float128 to float32, use the float32 trick, and use mixed precision Newton's method (ending with 2 iterations at float128).

But even that is pointless, unless perhaps if stopping early with an approximate result is the goal, because 1/sqrtf128(x) is 3.1x faster than my mixed precision implementation.

Everything tested with glibc on AMD 2700X CPU, with gcc version 12.2.0 (Debian 12.2.0-14).

#math #maths #SquareRoot #FloatingPoint

[1] https://math.stackexchange.com/questions/4785346/is-there-still-a-fast-invsqrt-magic-number-for-float128

Is there still a fast invsqrt magic number for float128?

template<class T,class U> T union_cast(U data){ union{U a;T b;}t{data}; return t.b; } float128_t quick_invsqrt_with_magic_num(int128_t mnum,float128_t X){ auto x= union_cast<

Mathematics Stack Exchange

I wrote a #C implementation of the #SquareRoot #sqrt #algorithm , in binary, with 64.0 integer input and 32.32 fixed point output.

https://mathr.co.uk/web/square-root.html#C-Implementation

Square Root :: mathr

Methods for finding square roots.

I implemented (in #Haskell) a #SquareRoot #sqrt #mathematics #algorithm I found on maths stackexchange, O(N^2) for N output digits but needs only addition, subtraction, shifts, and multiplying numbers by a single digit, and is simple to perform by hand with paper and pen.

https://mathr.co.uk/web/square-root.html

Square Root :: mathr

Methods for finding square roots.

Square roots explained Bob Ross style

YouTube
Can you please explain to a 14, 17 and 48 year old the reason why taking the square root of both sides does not work? #squareroot #equations