News for hackers. Stuff that matters.
Re:My resignation letter as R7RS-large chair by dxbydt on Thursday August 17, 2023 @01:06PM (#37164856)
I used it just the other day to work an aime problem for my middle schooler.

scheme@(guile-user) [5]> (exp (* (atan 1) -2))

$9 = 0.20787957635076193

scheme@(guile-user) [5]> (expt 0+1i 0+1i)

$10 = 0.20787957635076193+0.0i

a problem c/c++/java/js/python/rust/go can't handle after decades of progress. even my favorite R can't work this problem. scheme ftw.

Re:My resignation letter as R7RS-large chair by fn-mote on Thursday August 17, 2023 @01:37PM (#37165351)
I think this is probably because you did not know how to type a complex number in R. The coefficient of i is not optional.

    > exp(-2 * atan(1))
    [1] 0.2078796
    > 1i ** 1i
    [1] 0.2078796+0i
Re:My resignation letter as R7RS-large chair by vinaypai on Thursday August 17, 2023 @01:32PM (#37165275)
What's the "aime problem" and why can't c/c++/java/js/python/rust/go handle it?
Re:My resignation letter as R7RS-large chair by dqv on Thursday August 17, 2023 @01:37PM (#37165349)
I did a little googol and found out it's like an accelerated math thing https://artofproblemsolving.com/wiki/index.php/American_Invi...
Re:My resignation letter as R7RS-large chair by vinaypai on Thursday August 17, 2023 @02:15PM (#37165817)
Okay, I was just wondering if there's something non-obvious here. I guess OP is just woefully misguided about languages other than scheme or "these languages can't handle it" means something more like "I don't know how to use those languages".
Re:My resignation letter as R7RS-large chair by mlyle on Thursday August 17, 2023 @10:16PM (#37170740)
Decent complex types and library calls to do exponentiation, etc, don't always come for free in any given language environment. It's nice that it "just works" in many scheme environments (but this is not the only language runtime where this is true and it's not something that you can't work around).
Re:My resignation letter as R7RS-large chair by vinaypai on Thursday August 17, 2023 @10:59PM (#37170971)
The example the OP cited doesn't involve complex numbers. Atan(1) is pi/4.
Re:My resignation letter as R7RS-large chair by mlyle on Thursday August 17, 2023 @11:09PM (#37171022)
Sigh.

1i is an imaginary number. We are discussing the difficulty in calculating i^i, not whether a language can do atan(1).

Re:My resignation letter as R7RS-large chair by mlyle on Thursday August 17, 2023 @05:34PM (#37168434)
To be clear, it's a competitive exam and one of the primary feeders into the USA Math Olympiad team.

Many problems are quite challenging.

Re:My resignation letter as R7RS-large chair by dxbydt on Thursday August 17, 2023 @08:51PM (#37170262)
yeah it looks like everybody's focused on the mechanics of the computation and not appreciating the math i.e. why the two expressions compute to the same value.
Re:My resignation letter as R7RS-large chair by mlyle on Friday August 18, 2023 @10:29AM (#37176133)
We are not in an algebra II class. We are talking about the merits of scheme. You posted a relatively opaque comment and made a relatively unfounded assertion about whether other languages could do it.

It might have been better for you to have been a little more direct-- "I like that exponentiation of complex types just works in Scheme; I don't think that works in other languages!"

I'm not sure why you think scheme is unique in being able to do this-- indeed, it's one of the examples of std::pow on cppreference:

https://en.cppreference.com/w/cpp/numeric/complex/pow

> std::cout << "i^i = " << std::pow(i, i) << '\n';

> i^i = (0.207880,0.000000)

I also hope it wasn't a way to humblebrag that you have a kid in middle school that knows math that lots of other people around here don't (having forgotten it from alg2/precalc or just having trouble reading your comment).

Re:My resignation letter as R7RS-large chair by satya71 on Thursday August 17, 2023 @01:23PM (#37165144)
Hmm. Python 3.11 (didn't test in earlier)

>>> from math import atan, exp

>>> exp(atan(1)*-2)

0.20787957635076193

>>> 1j*1j

(0.20787957635076193+0j)

Re:My resignation letter as R7RS-large chair by dxbydt on Thursday August 17, 2023 @01:31PM (#37165259)
thank you. i tested this on lc playground and yeah it does work.
Re:My resignation letter as R7RS-large chair by dragonwriter on Thursday August 17, 2023 @01:49PM (#37165499)
As well as python noted in a sibling, Ruby handles this quite well out-of-the box.

Is your complaint just that some popular languages don’t have complex numbers as part of the core/stdlib?

Re:My resignation letter as R7RS-large chair by johncowan on Saturday August 19, 2023 @04:12PM (#37192670)
The issue is that lots of languages don't make complex numbers part of what Lispers call the numeric tower, fully integrated into numeric operations, even if there is a complex library. Here's Guy Steele's 3-part smoke test for early Common Lisp implementations:

1. At the REPL, if you type `T` (true), and you get back `T`, the test passes.

2. Define factorial. Then type `(/ (factorial 100) (factorial 99))`. If you get back 100, the test passes.

3. Type `(atanh -2)`. If you get a complex number, the test passes. If you get the correct complex number [namely -0.5493061443340549+1.5707963267948966i] extra credit. Far too many non-Lisp languages return NaN or throw an exception.