Replies

This profile is from a federated server and may be incomplete. Browse more on the original instance.

cfbolz, to random
@cfbolz@mastodon.social avatar

I just learned that there are floating point numbers that have non-unique (positive) square roots:

>>>> s = {4.472135954999575e-155, 4.472135954999576e-155, 4.472135954999577e-155, 4.472135954999578e-155, 4.472135954999579e-155, 4.4721359549995795e-155, 4.47213595499958e-155}
>>>> len(s)
7
>>>> {x * x for x in s}
{2e-309}

(I suppose it's obvious in hindsight, but I still didn't expect it somehow)

mbr,
@mbr@mastodon.gamedev.place avatar

@cfbolz Yeah. the interval [1,4) maps to [1,2).

svat, to random
@svat@mathstodon.xyz avatar

Wrote up a quick post mentioning Don Knuth's latest toy program he put up on his website: https://shreevatsa.net/post/dek-partition-square/ (Mostly just some context and explaining what the problem is; for anyone who'd like to just read the actual program directly, I have a typeset version at: https://shreevatsa.github.io/knuth-literate-programs/programs/perfect-partition-square.pdf )

mbr,
@mbr@mastodon.gamedev.place avatar

@pervognsen @amonakov @svat Aside: "It's basically him just throwing up gang signs." Excellent.

adrian, to random
@adrian@discuss.systems avatar

I know how dumb this sounds, but I think it’s overwhelming how many more 64-bit numbers there are than 32-bit numbers. it’s, like, a lot.

mbr,
@mbr@mastodon.gamedev.place avatar

@adrian log2(2^64 - 2^32) = ~63.9999999997

mbr,
@mbr@mastodon.gamedev.place avatar

@adrian @shwestrick Humm. I don't know the space but let's spitball at 2^24 cores then each would need to perform 2^40 (x2 for ref and candidate) functions. Well that can be shaved down an order or two with NaNs and if the func is odd or even.

mbr, to random
@mbr@mastodon.gamedev.place avatar

I'd never noticed that a high percentage (~19.3%) of Warren's references in Hacker's Delight are just "personal communication with X". Random thought of the day.

mbr,
@mbr@mastodon.gamedev.place avatar

@amonakov I'm trying to remind myself of the "black magic" behind Guy Steele's software PDEP/PEXT

TomF, to random
@TomF@mastodon.gamedev.place avatar

Just got caught up on The Discourse of CPU design and this article: https://hackaday.com/2024/03/21/why-x86-needs-to-die/

Let me skip to the chase - it argues that x86 is shit because it's got variable-length encoding, is out-of-order, and does speculative execution. It then says ARM and RISC-V are much better.

Er... except they also do all those things in the fast chips. Which the writer clearly didn't know. So they're not just wrong, they're ignorant.

mbr,
@mbr@mastodon.gamedev.place avatar

@TomF Perhaps sampling error but every time I've landed on hackaday it's been a bad take. The last time was some person wanting to compute exp(x)-1, did a bunch of math and came with with a worse version (that only looked better with their example cases) when expm1 was sitting there all along.

grumpygamer, to random
@grumpygamer@mastodon.gamedev.place avatar

I think the root is my problem is I'm generating floats from n-m. I needs it to be blazing fast and it can't use any libs because I need 100% consistency across platforms.

mbr,
@mbr@mastodon.gamedev.place avatar

@TomF @grumpygamer @arghdos 16-bits to give some "space" so that the product with (m-n) doesn't round? Anyway I'd want to reorder the product and use an explicit FMA (assuming that's good for target device).

dpiponi, to random
@dpiponi@mathstodon.xyz avatar

Given a random number generator that generates points uniformly in the unit interval [0,1] can you generate uniformly distributed points in the unit circle using only algebraic functions? In a finite number of steps - so no rejection sampling, loops, recursion. No "almost always" finite either.

Just wondering about sitiations where it seems you can't avoid trig functions.

mbr,
@mbr@mastodon.gamedev.place avatar

@dpiponi In the case of LDS you can like this:

https://rene.ruhr/gfx/adoption/

Doesn't work for IID.

mbr,
@mbr@mastodon.gamedev.place avatar

@narain @BoydStephenSmithJr @dpiponi As an aside you can get a good approximation of normal dist with hardware popcount. Sorry this is poorly written.

https://marc-b-reynolds.github.io/distribution/2021/03/18/CheapGaussianApprox.html

mbr,
@mbr@mastodon.gamedev.place avatar

@modularformsboy @dpiponi This wouldn't be a good choice anyway. You can compute {sin(π x), cos(π x)} to very high accurate with few term using a minimax approximation. Add in the symmetry of the problem and you kill off the range reduction that would be needed for a "standard" sincospi function.

lritter, to random
@lritter@mastodon.gamedev.place avatar

interesting problem: progressively mapping a cosmically high number of unique strings of arbitrary length to an ordered set so that we can assign an index to each string, extract a substring from each index, and filter strings not in the set.

evidently, this approach requires compression. the compressed result is functionally equivalent to a regular expression, or a schema validation system.

mbr,
@mbr@mastodon.gamedev.place avatar

@lritter Huh. Today's XKCD:

https://xkcd.com/2934/

mbr, to random
@mbr@mastodon.gamedev.place avatar

On twitter @sebbbi mentions a cheap approximation of sin(π x) on [-1,1]

sin(π x)/4 ≈ x - x |x|

Normally if we want a two term approximation of an odd function we're stuck with the form:

a(x) = c₁ x + c₃ x³

but if we move away from pure polynomials then another two term form is possible:

b(x) = k₁ x + k₂ x |x|

and this generalizes to however many term odd/even function approximations (filling in otherwise skipped powers with one as abs which spit into two subexpressions w & w/o abs)

mbr,
@mbr@mastodon.gamedev.place avatar

@sebbbi As an example:

f(x) = 4 atan(x)/π on [-1,1]

the abs error approximated as forms a(x) and b(x). orange & blue respectively.

demofox, to random
@demofox@mastodon.gamedev.place avatar

Hey @mbr , I remember you did that LDS thing with integers where you had an integer representation of Phi.
How did you calculate that integer version of Phi?
Did you just multiply phi by the the maximum value the int could represent and convert to int (floor / round)?

mbr,
@mbr@mastodon.gamedev.place avatar

@demofox Yeap. And to get a maximum length sequence for the bit width you round to odd.

mbr, (edited )
@mbr@mastodon.gamedev.place avatar

@demofox So [0,N) where N is now not a power of two: t = NΦ, find 'd' which is the nearest integer to 't' which is coprime with N? 'd' is the additive constant and the iteration visits all the elements. Sounds right to me.

mbr,
@mbr@mastodon.gamedev.place avatar

@demofox Oh. General audience clarification: since Φ > 1 I should have explicitly stated using (Φ mod 1)...the fractional part.

  • All
  • Subscribed
  • Moderated
  • Favorites
  • JUstTest
  • InstantRegret
  • mdbf
  • osvaldo12
  • magazineikmin
  • cubers
  • rosin
  • thenastyranch
  • Youngstown
  • tacticalgear
  • slotface
  • khanakhh
  • kavyap
  • DreamBathrooms
  • provamag3
  • Durango
  • everett
  • ethstaker
  • modclub
  • anitta
  • cisconetworking
  • tester
  • ngwrru68w68
  • GTA5RPClips
  • normalnudes
  • megavids
  • Leos
  • lostlight
  • All magazines