[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 75 KB, 720x720, 1695304411637657.jpg [View same] [iqdb] [saucenao] [google]
15767215 No.15767215 [Reply] [Original]

this picture makes /sci/ seethe

>> No.15767306

>>15767215
From the way this question is worded, it seems like applying this function twice to negative numbers should return the original negative number. From that point it's really easy:

[math]f(x) = \begin{cases}
-x & \text{if } x>=0\\
x & \text{if } x<0
\end{cases}[/math]

>> No.15767312

>>15767215
Filthy codeniggers.

>> No.15767314

>>15767306
is the negative of -3 equal to -3?

>> No.15767327

>>15767314
yes. negative numbers are not the additive inverse of a number, they are strictly numbers smaller than zero. I'm not a mathbro myself so I might be wrong on this though.

>> No.15767336

>>15767327
is -3 not the additive inverse of 3? what planet are you on

>> No.15767343 [DELETED] 

>>15767336
What he's trying to tell you is that "x's negative" implies -abs(x) rather than -x. You should have said "its additive inverse".

>> No.15767351

>>15767336
What he's trying to tell you is that "x's negative" implies x can only be positive. You should have said "its additive inverse".

>> No.15767358

>>15767351
so what he's saying is -(-3) doesn't exist. cool

>> No.15767359

>>15767343
>>15767351
you got my intention right on the first one, why did you change your post? if x is a positive, it's negative is -x. if x is a negative, then it's negative is x. Pretty sure that's consistent with the formal definition of negative numbers, but mathbros please fact check me.

>> No.15767360

>>15767215
f(x) = ix
in python:
>>> f = lambda x: 1j * x
>>> f(f(3))
>>> -3

>> No.15767362

>>15767360
ix is not a float

>> No.15767370

>>15767362
oh I'm sorry, I didn't get that I was supposed to implement floating point arithmetic from zero because of a badly formulated question. your thread is shit and you are dumb.

>> No.15767372

>>15767215
choose any well-known non-sign bit in the floating point representation such that flipping the value of the bit never results in an invalid floating point representation. in practice, any non-major and non-minor bit of the significand is basically guaranteed to be such a bit.

if the bit is 0, return the number with the bit flipped to 1
if the bit is 1, return the number with the bit flipped to 0 and the sign bit inverted

child's play

>> No.15767375

>>15767359
"if x is white, it's negative is black. if x is black, its negative is black."
what kind of logic is that?

>> No.15767381

>>15767375
there's a reason we use both "negatives" and "additive inverse". next time word your question better if this wasn't your intention.

>> No.15767382

>>15767370
it's obvious from "works with floating-point numbers". you are mentally deficient

>> No.15767386

>>15767372
doesn't work, there is not such "extra" bit

>> No.15767393

>>15767359
>if x is a negative, then it's negative is x
If x is negative, "the negative of x" is nonsensical babble. A positive number is not a "negative" of a negative number.

>> No.15767399

>>15767386
the floating point representation has 32 bits for singlw precision and at least half a dozen of these are clearly safe choices

>> No.15767420

>>15767382
imaginary numbers are a layer of abstraction above numerical types on all normal programming languages. what you want people to do is to create a new standard is that what you're asking? why not be more clear about what you want instead of communicating through dumb gotchas? the code I presented works with floating point numbers so it solves the stated problem, your thread is shit and you are a dumb faggot.

>> No.15767437

>>15767399
show me the solution

>> No.15767457

>>15767420
You don't know what a float even is, do you? It's not just a convenient type in your favorite language, there's circuitry inside your cpu dedicated to floating point arithmetic. Unfortunately for you, it doesn't work with complex numbers and other such faggotry.

>> No.15767545

f(x) = -y if x = f(y) and y > 0

>> No.15767661

>>15767393
meds

>> No.15767674
File: 222 KB, 1301x1536, xor.png [View same] [iqdb] [saucenao] [google]
15767674

>>15767386
You don't need any extra bit. Just flip a mantisa bit every time, and flip the sign only when that bit is 1. After two calls the mantisa returns to the original value and the sign will be flipped only once.

>> No.15767716
File: 367 KB, 1548x4064, RipImaginaryNumber.png [View same] [iqdb] [saucenao] [google]
15767716

>It seems that I have no choice but to submit to the devil with imaginary number by answering f(x)=xi and kowtow to Xijinping, for how else can one discrete step be done in two without adding internal state?
Hold the line and don't lose faith, Chuds. God intend us to graph functions out as they should be on paper, not to consume poisoned 3D renditions and worship the animator. And on this day of our lord, I have just the sermon to perform, to rid the devil that dare come out on Sunday and to bear witness to the story on how the unyielding chuds on that prevails the devil: >>/sci/thread/14823211#p14824619.. Behold:
The idea is pretty simple, we break all float number into even and odd numbers, for odd number we add 1 to be even, for even number we switch the sign by -x then add again to be odd.
First we divide number into two with mod(ceil(x)/2,1), even has remainder zero and odd has remainder 0.5, we can *2 to make it 0 and 1s. We would name it s(x) as it switches on and off. Notice the negative are flipped, so we are going to use abs(x) instead of x.
s(abs(x)) for odd number, we multiply that with x+sign(x) so it isn't not flipped, just incremented to opposite state.
s(abs(x)+1) for even number, we multiply that with -x+sign(x) so sign is flipped, and incremented back to original value, notice we add twice, because previous x+1 is now -x-1.
add them together, we have the full function, f(x)=s(abs(x))(x+sign(x))+s(abs(x)+1)(-x+sign(x)). And it shaped like a windmill and it will blow away the jews and their brain disease. Graphing program tried to sabotage me with heretical interpolation of adding vertical line of discontinuity and suggest f(3)=0 but i checked f(3)=4 is real result.
Finally f(f(x))=-x. Have a blessed Sunday.

>> No.15767799

>>15767716
>all that math
there's no way you don't lose some precision along the way. try again, chuddie

>> No.15767835

>>15767312
Shut up, the posters in the previous thread all but solved this problem. This thread wouldn't exist if not for your selective autism.

>No you can't use computer science to solve this, you have to use Pure Maths
>What's that? You suggest a function that works from reals to reals? Well fuck you filthy codenigger because OP said it has to work with floats
>No your solution that works with floats is invalid because floats are not pure math lmao, you fucking codenigger.
>Your solution implements floats artificially and is compliant to the floating point format instead of using the float defined by your language? Well that's cheating, languages have a monopoly and scientific copyright over what is a float you shit eating codenigger, learn some computers lmao.
>Your solution uses the features of your particular language's floating point format? Too bad i only recogonise solutions that don't exist codenigger, better luck next time
>Okay okay i'll maybe concede that your solution works for all floats, well ALL floats. That includes +-infinity and +-NaN lmao, which are valid floats according to the format but they are not math numbers so you lose you stupid codenigger? Concede already, you can't win against my circular definitions.
>What? You binded the Infinities and NaNs in a loop? Now all other solutions are both valid floats and valid numbers and compliant by the question because you can still map loops of 4 values as 2^32-4 is still divisible by 4? Haha too bad for you I still will not concede because now i want you to spend hours of your time making a function to abide by my arbitrary restrictions because i am too retarded to see how that works and is completely logically consistent.
>What? Modular arithmetic? Woah woah there codenigger, that's not real maths now, is it? Real maths is what i say it is and today i declare modular arithmetic to not be maths. Seethe because you're so low iq haha, you can't comprehend my logic.

>> No.15767899

>>15767312
>>15767835

>You code overflows lmao! Nevermind that many languages don't care and discard the last bit, you solution has to work with EVERY language, even one i pull out of my ass, or design right now just to make your solution impossible. I already said i will not accept any solution whether it's language reliant or language specific.
>What? You can make the float not overflow by subtracting 3*(2^30) instead of adding 2^30 when the bit value is greater than or equal to 3*(2^30)? Well now that's not done with floating point operations is it? Nevermind that OP said it has to work with floats and not employ FLOPS, i will make another arbitrary distinction because why not? Also nevermind that the specifics of FLOPS implementation vary and are imprecise by design, making this problem impossible while my totally arbitrary restriction is followed.
>01000001000010000000000000000000 is the negative of 11000001000010000000000000000000? Seethe because i don't actually care about the IEEE 754 format, output in one random implementation of this by some dev were 8.5 and -8.499999, not very equal are they? I will not accept your answer until your solution works with every single compiler and language and gives the exact same output i want in decimals. Oh and remember my genius brainfart from before that you can't make your own implementations of the format either to unify the outputs across all machines and platforms, even ignoring that it would take a lot of effort from even the best of programmers, you simply are not allowed to do that anyway
>Why can't you codeniggers figure anything out?? Go back to >>>/g/

There, there's your every single argument. Im sure you see nothing wrong in any of this

>> No.15767903

>>15767899
inb4 that retard tries to argue with me for a minor brainfart --> language independent* not reliant

>> No.15767913

>>15767215
f(x)=i*x

>> No.15767925

>>15767674
Too bad for you mr.codenigger hater doesn't acknowledge valid solutions like that (see >>15767899). It's "bitfuckery" and hence somehow invalid, you're stupid just like the other posters who suggested same or similar methods which totally work but aren't solutions according to mr.codenigger hater, who is the complete authority in the field of pulling arbitrary restrictions out of his ass.

Better luck next time

>> No.15767932

>>15767835
>>15767899
>>15767925
>insane and seething
The preils of being a codenigger. Imagine shitting out paragraphs of seethe.

>> No.15767936

>>15767215
In general, the solution to f^n(x) = -x is f(x) = e^(i*pi/n)*x

>> No.15767937

>>15767835
those are all valid concerns, plus there exists a solution that fits all of those criteria but you're just too stupid to see it
>the specifics of FLOPS implementation vary and are imprecise by design
incorrect. the specifics of floating point arithmetic is very precisely defined and all existing hardware must follow it to a tee.

>> No.15767942

>>15767937
quote from >>15767899
also keep seething

>> No.15767946

>>15767932
>Seethe is outlining every argument he ever gave and how fucking ridiculous and conflicting his standards are

Sounds about right for your delusional fantasy world. You should return their schizo, the people of your world need their science pioneer, revolutionary, president, inventor, influencer and what not. You wouldn't want to make them wait

>> No.15767955

>>15767946
Sorry, you're gonna have to shit out at least 2-3 more paragraphs to show me how wrong I am and how totally not mad you are. Get your codenigger fingers ready.

>> No.15767986

My 1/x ->-1/x solution
Was not only superior, but my original work. Your lame ass solutions were plagiated from shitoverflow.

I WON
MIC DROP

>> No.15768000

>plus there exists a solution that fits all of those criteria but you're just too stupid to see it

Okay then, tell me your solution that works for all reals, and floats(which it also simultaneously shouldn't because floats are not pure maths and instead codenigger fuckery), and uses strictly FLOPS. Works for every single language and prints the exact same number with opposite sign for every single compiler. Go ahead im waiting.

>floating point arithmetic is very precisely defined and all existing hardware must follow it to a tee

it's imprecise by design, multiple values can round to the same float making a 4 cycle mapping (quintessential to the question), extremely difficult and shoddy in implementation at best if not outright impossible. No one in the fucking world knows Floating point formats that well, and if you do, i invite you to teach us all. All Hardware manufacturers have to follow the specifications but freedoms are afforded. There are multiple allowed formats for rounding a number if the value lies midway to two nearest numbers. You may round up or to the nearest even least significant bit etc. Only someone as delusional as you will believe it's complete reliable and consistent at the bit scale.

>> No.15768001

>>15767312
You better watch your tone. Is always fools like you who end getting all kinds of malware, spyware and ransomware. Not only those that delete data, but those that download illegal stuff and threaten to call the cops on you. Who is going to believe you are innocent?

>> No.15768013

>>15768001
Stupid codenigger ape.

>> No.15768029

>>15768000
also, tell me 1 reason why anyone should abide by your restrictions even if possible or even extremely easy. The other poster's solutions completely fit the given question and you're dragging the argument to get a challenge answer while denouncing everyone else. Make a separate thread and ask people your challenge question politely and nobody will be mad at your autism, but you have to do it in this thread and just call other valid answers wrong to indulge yourself.

>> No.15768032

>>15767799
>all that math
You want to do bit representation of float numbers? It is far simpler--just flip any mantisa bit, and flip sign bit if that mantisa bit is 0. Things are already MODed and 0&1ed.
Imaginary tard have to shuffle values in two float numbers of a COMPLEX number, which is not allowed. This is the second L of the day and I hope you recover.
Now if you will excuse me, I am going to grill as offering to God for his continued blessing and I have no time to waste.

>> No.15768040

>>15767215
f(x) = -abs(x)

>> No.15768063
File: 131 KB, 781x1000, 1694409815079072.jpg [View same] [iqdb] [saucenao] [google]
15768063

>>15767215
Allow me to clarify the question:
1. Your solution must work with floating point numbers. If you don't know what that means, this is what the function signature should look like
>C/C++/C#/Java
float f(float x)
>Python
def f(x : float) -> float:
2. Your function can't use globals or have internal state, as that would make the solution trivial.
3. Your function must satisfy the following relation, exactly and without loss of precision:
f(f(x)) == -x
If your function fails to pass this test for a real number, it is invalid.
4. Your function must be defined over its domain, i.e. every floating point number from -3.402823466e38 to 3.402823466e38
This means it can't map a real number to infinity or NaN.
5. You get bonus points for creating functions that you can define mathematically in LaTeX. Plot it for double bonus
6. You get bonus points for only using floating point operations.

There. Keep in mind explaining how the solution works and actually posting working code is not the same thing.

>> No.15768067

>>15768063
Dumb codemonkey.

>> No.15768128

>>15768000
>tell me your solution
I'd rather watch people in these threads pull their hair out trying to cheat the question
>multiple values can round to the same float
you do realize the number you see on the screen when you printf("%f") is only a limited precision conversion to a base 10 format, right??
>extremely difficult and shoddy in implementation
incorrect. you'll see how precise and understandable floating point arithmetic really is once you pass a numerical computing course.
>No one in the fucking world knows Floating point formats that well
so this is your chance to get familiar with the format. if you can't figure out how it works, sucks for you friend
>All Hardware manufacturers have to follow the specifications but freedoms are afforded. There are multiple allowed formats for rounding a number if the value lies midway to two nearest numbers. You may round up or to the nearest even least significant bit etc. Only someone as delusional as you will believe it's complete reliable and consistent at the bit scale.
rounding behaviour of floating point numbers is clearly defined. i can link you resources so you can read about the technical details

this last part of your post suggests you might be in the beginning of your journey as a programmer/computer scientist. i suggest you don't take everything you see in coding tutorials at face value, including statements "floating point numbers are imprecise" or "floating point arithmetic is unpredictable".

>> No.15768174

>>15768063
>>Python
>def f(x : float) -> float:
lmao
>2. Your function can't use globals or have internal state, as that would make the solution trivial.
thats called a "pure" function
>This means it can't map a real number to infinity or NaN.
now this is definitely making up new rules. am i allowed to map numbers to negative zero?

>> No.15768187

>>15768174
>lmao
?
>am i allowed to map numbers to negative zero?
0 is a number isn't it?

>> No.15768205

>>15768029
i accepted your solution in the previous thread, it worked fine and checked off most of the criteria listed here >>15768063 so great job
honestly i reposted the shitty OP verbaitim to recreate the chaos from the last thread but now i feel bad cause you're taking it way too seriously, lol

>> No.15768214
File: 101 KB, 871x1211, 1695400770093262.png [View same] [iqdb] [saucenao] [google]
15768214

>>15768187
>?
it made me think you were one of guys i was arguing with in the last thread
>0 is a number isn't it?
can my function distinguish between positive and negative zero? because thats obviously not something you can do mathematically, only with floats.
>>15768000
>multiple values can round to the same float making a 4 cycle mapping (quintessential to the question), extremely difficult and shoddy in implementation at best if not outright impossible
multiplying by a power of 2 always results in a valid float without rounding, as long as you dont overflow.

>> No.15768256

>can my function distinguish between positive and negative zero? because thats obviously not something you can do mathematically, only with floats.
you're right. i think you have to. it doesn't make sense mathematically, but i guess it's close enough that we can make that exception.

does it work for subnormal numbers?

>> No.15768262

>>15768214
>>15768256

>> No.15768268

>>15768256
>i think you have to.
you think correctly. the problem is actually impossible if you arent allowed to map numbers onto at least one of: +/- zero, +/- inf, or +/- NaN.

>> No.15768279

>>15768256
also, whats a subnormal number?

>> No.15768308

>>15768279
subnormal *float. below [math]2^{-126}[/math] the exponent field is all 0. i'm not sure how they behave in regard to multiplication, that's why i asked.

>> No.15768376

>>15768308
interesting. i wouldnt expect them to behave differently, but i dont know.

>> No.15768421
File: 42 KB, 461x169, file.png [View same] [iqdb] [saucenao] [google]
15768421

>>15768214

>> No.15768448
File: 10 KB, 715x199, file.png [View same] [iqdb] [saucenao] [google]
15768448

>>15767215
0. If 0 is unsigned, let f(0) be 0.
1. Enumerate every floating point number.
2. Let the function send the smallest positive number to the second smallest positive number.
3. Let the function send the second smallest number to the largest negative number.
4. Let the function send the largest negative number to the second largest negative number.
5. Let the function send the second largest negative number to the smallest positive number.
6. If there are numbers left, return to step 2.
Picrel is how this function would work if there were only nine floating point numbers including unsigned 0.

>> No.15768466

>>15768448
nice. this should be easy to implement working with the bit representation.

>> No.15768504

>>15768448
what do you do if you return to step 2 but theres only 2 numbers left?

>> No.15768560

after thinking about this for literally days, i realized something interesting: if you change the requirement from floats to ints, there no solutions!

>> No.15768600

>>15768308
The only different is that subnormals don't have a leading, and implicit, bit set to 1 in the mantisa, is 0 for them.

>> No.15768618

>>15768504
Then it's over. However, I expect a reasonable implementation to have an upper bound that's a large power of 2 (so it's divisible by 4).

>> No.15768628

solution was posted in last thread

>> No.15768643

>>15767913
floating point numbers

>> No.15768661

>>15767215
where did you find that Kurisu image OP?
it's much more higher quality than the other YSBATST images

>> No.15768769

>>15767215
Hey. I'm the guy who though a list of floats is the same as floats from last thread. Just wanted to add that I'm trans and had my first trans vagina sex today. It was amazing!

>> No.15768790

>>15767799
This is correct, because >>15767716
> can *2 to make it 0 and 1s
loses bits.

>> No.15768835

>>15768790
You lose bits even before calculation happens. https://floating-point-gui.de/basic/

>> No.15768859

>>15768835
Yeah I know. Just saying that the Anon I quoted was right with his "so much math" argument.

>> No.15768862

>>15768835
Can't lose what you never had. Losing bits is not the same as rounding to machine precision before a computation.

>> No.15768867

>>15763958

>> No.15769993

bump

>> No.15770046

f(x)=-|x|

>> No.15770057
File: 84 KB, 900x900, 1684086558065683.jpg [View same] [iqdb] [saucenao] [google]
15770057

>>15767215

>> No.15770074 [DELETED] 
File: 17 KB, 800x600, smooth_brain.jpg [View same] [iqdb] [saucenao] [google]
15770074

>>15770046

>> No.15770425

>>15767215
Convert it bit wise to int (change the pointer, but the bytes remain the same)

Add 0x8000
Return as float (pointer, do not do a int>float conversion)

:)

>> No.15770435

>>15770425
its 0x80 00 00 00
but my point still stands

gm

>> No.15770455

>>15770425
Doesnt work
For example f(f(18374838377372882838474.38474828))
breaks

>> No.15770483
File: 132 KB, 2119x537, file.png [View same] [iqdb] [saucenao] [google]
15770483

>>15770455
well i would expect it wouldnt work for that number considering thats not a valid float.

>> No.15770646 [DELETED] 
File: 598 KB, 1080x2340, Screenshot_20230925_144459_Samsung Internet.jpg [View same] [iqdb] [saucenao] [google]
15770646

>>15767215
>>15767306
>>15767312
>>15767314
>>15767327
>>15767336
>>15767351
>>15767358
>>15767359
>>15767360
>>15767362
>>15767370
>>15767372
>>15767375
>>15767381
>>15767382
>>15767386
>>15767393
>>15767399
>>15767420
>>15767437
>>15767457
>>15767545
>>15767661
>>15767674
>>15767716
>>15767799
>>15767835
>>15767899
>>15767903
>>15767913
>>15767925
>>15767932
>>15767936
>>15767937
>>15767942
>>15767946
>>15767955
>>15767986
>>15768000
>>15768001
>>15768013
>>15768029
>>15768032
>>15768040
>>15768063
>>15768067
>>15768128
>>15768174
>>15768187
>>15768205
>>15768214
>>15768256
>>15768262
>>15768268
>>15768279
>>15768308
>>15768376
>>15768421
>>15768448
>>15768466
>>15768504
>>15768560
>>15768600
>>15768618
>>15768628
>>15768643
>>15768661
>>15768769
>>15768790
>>15768835
>>15768859
>>15768862
>>15768867
>>15769993
>>15770046
>>15770057
>>15770074
>>15770425
>>15770435
>>15770455
>>15770483

PythonChads WON
Phoneposters WON
/qa/ WON
ScriptMonkeys WON

CNiles LOST
Mathfags LOST
Theorycels LOST
OP LOST

>> No.15770689

>>15768560
Well, for one, considering the integer range is [math]-2^{n-1}[/math] to [math]2^{n-1}-1[/math] where [math]n[/math] is the number of bits, it would be impossible to represent [math]2^{n-1}[/math] so we would have to exclude [math]-2^{n-1}[/math] from its domain.
But I just had an idea. Technically, there exists a function that satisfies [math]f(f(x))=x[/math] for [math]2^n-3[/math] integers, and only fails for 2. The function is deterministic and will always fail/succeed on the same inputs.
Here is the idea: What if we introduce non-determinism? We already have a function that satisfies the desired property for MOST integers and fails only for some. If we could somehow "distribute" the error over its whole domain probabilisticly, we would have a function that works MOST of the time. It wouldn't necessarily fail on only two specific integers. Then re-rolling the function will increase the probability of success.
I do feel, however, that this approach might not work on this specific problem because of the fact that [math]f[/math] needs to be invoked twice, on its own output, and that would make the each roll non-independent from the last, which affects attempts to reduce error. Further, I don't know how we would even go about distributing the error over the function domain.
Thoughts?

>> No.15770758

>>15770646
kys

>> No.15770914 [DELETED] 

>>15770689
I would define it in the range [math][-2^{n-1}+2,\quad2^{n-1}-2 ][/math], and leave it as undefined behavior for the three remaining cases that don't complete a cycle.

>> No.15770942

>>15770455
It is trivial to extend this to 64 bit, but the op says float and not double precision float