# Geometric mean bit hack

**URL:** <https://discourse.processing.org/t/geometric-mean-bit-hack/14366>\
**Category:** Gallery\
**Created:** [October 2, 2019, 8:40am UTC](https://discourse.processing.org/t/geometric-mean-bit-hack/14366 "2019-10-02T08:40:22Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![seanc4s](https://avatars.discourse-cdn.com/v4/letter/s/e19adc/32.png) [@seanc4s](https://discourse.processing.org/u/seanc4s)\
**Post date:** [October 14, 2019, 11:21pm UTC](https://discourse.processing.org/t/geometric-mean-bit-hack/14366/3 "2019-10-14T23:21:08Z")

</div>

Thanks for the link. Floating point bit hacks are very useful for experimenting with neural network activation functions. If you just want a little bit of nonlinarity for example you can multiply the approximate square root of a number by itself.  
Or if you want to convert 2 numbers from the Gaussian probability distribution to a number from the uniform distribution you can use atan2(x,y).

> [@Fast approximate square root](https://discourse.processing.org/t/fast-approximate-square-root/12074/9):
>
> Very approximate atan2(…). I didn’t check edge cases like atan2(0,0) etc. /\*\* \* Arctangent Bit Hack Version \* \* Move the mouse to change the direction of the eyes. \* The atan2() function computes the angle from each eye \* to the cursor. \*/ Eye e1, e2, e3; void setup() { size(640, 360); noStroke(); e1 = new Eye( 250, 16, 120); e2 = new Eye( 164, 185, 80); e3 = new Eye( 420, 230, 220); } void draw() { background(102); e1.update(mouseX, mouseY); e2.update(mou…

---

_[View the full topic](https://discourse.processing.org/t/geometric-mean-bit-hack/14366)._
