Why is Desmos so insanely fast?

In summary: I'm not sure what you're comparing. I tried it in Edge, which is supposed to be the same V8 engine, and it was 120 ms.
  • #1
h1a8
87
4
Why is Desmos (graphing calculator app for Android, ios, windows, etc) far faster than everything else in calculating?
I've done the same calculations in Mathematica, Maple, hp prime pro app on windows (ios and Android), various calculator apps on ios and Android, etc

This is one of the things I calculated.

$$
\sum_{x=1}^{1000000} \sqrt[3]{ e^{\sin{[\tan^{-1}{(\ln{3x^2+2x-3}) }] }}}
$$

Desmos gave an answer in LESS THAN A SECOND on a mid spec Android phone. It took Mathematica, Maple, etc with 12th generation i7 processor many seconds to compute. All other math program apps in Android and ios (including TI Nspire and many more) took longer. Is it in the code? Superior algorithm?
 
Last edited:
Technology news on Phys.org
  • #2
Maybe Desmos does the computation in the cloud, not on your phone.
 
  • Like
Likes jedishrfu
  • #3
Baluncore said:
Maybe Desmos does the computation in the cloud, not on your phone.
Thanks
That would make a lot of sense.
Any idea how I would post the expression in Latex form for this forum?

Edit: It still calculates the same speed while in airplane mode lol. I don't think it's the cloud.
 
  • #4
h1a8 said:
Edit: It still calculates the same speed while in airplane mode lol. I don't think it's the cloud.
Is the answer correct?
Single or double precision?
What answer does it return?

The LaTeX guide is at the bottom left of your post edit window.
Scroll down.
 
  • #5
Baluncore said:
Maybe Desmos does the computation in the cloud, not on your phone.
Exactly the opposite: Desmos does everything on the client.

And that's why it's fast - it doesn't send any data anywhere and wait for a busy server to get around to processing it, it just gets on with it locally. And contrary to the commonly held myth, modern JavaScript engines are really fast.
 
  • Like
Likes jedishrfu
  • #6
Baluncore said:
Is the answer correct?
Single or double precision?
What answer does it return?

The LaTeX guide is at the bottom left of your post edit window.
Scroll down.
Yes I check all others (mathematica, maple, etc)
The solution it gives is 1,395,279.57136

I looked at the guide. No dice. Keeps posting the actual code (probably wrong) I stead of the conversion.
 
  • #7
h1a8 said:
Keeps posting the actual code (probably wrong) I stead of the conversion.
Known bug that appears to be very hard to fix. However, if there's already ##\LaTeX## on the page (which there now is) then the code will render. You may need to refresh the page for it to work for you.
 
  • #8
I get the same; 1,395,279.571359562
in 0.206 sec on an old slow pentium.

There are quick-cuts, for example, avoid the cube root by dividing by three before computing the Exp. There may be others.
 
  • #9
I'm not sure what might be wrong with your Maple/Mathematica etc. set-ups but Wolfram Alpha turns it round in 112 ms ignoring network latency.
 
  • #10
Baluncore said:
Single or double precision?
All JavaScript results are IEEE 754 double precision (64 bit).
 
  • #11
pbuk said:
I'm not sure what might be wrong with your Maple/Mathematica etc. set-ups but Wolfram Alpha turns it round in 112 ms ignoring network latency.
How did you get the time 112 ms?
 
  • #12
h1a8 said:
How did you get the time 112 ms?
1689160432494.png

It's the "results" path that delivers the response: 118 ms this time. The rest of the time loading the page is downloading fonts, graphs etc.

Edit: I suppose it may have cached the calculations earlier, but this is in the right ballpark - here it is on my desktop (a bit newer i7 than @Baluncore's).
Code:
> node vs-desmos
Result is 1395279.5713595615 in 139 ms
JavaScript:
const f = () => {
  let sum = 0;
  for (let x = 1; x <= 1e6; ++x) {
    sum += Math.pow(
      Math.exp(Math.sin(Math.atan(Math.log(3 * x * x + 2 * x - 3)))),
      1 / 3
    );
  }
  return sum;
};
const start = performance.now();
const result = f();
const time = performance.now() - start;
console.log(`Result is ${result} in ${Math.round(time)} ms`);
 
  • #13
pbuk said:
(a bit newer i7 than Baluncore's)
My i7 was built in 2012, it still runs FreeBasic on 32 bit, Win 7.

Avoid cube root; Exp(x)^(1/3) = Exp( x/3 )
Avoid two transcendentals; Sin( Atan( x ) = Abs( x ) / Sqrt( x^2 + 1 )
 
  • #14
Baluncore said:
Avoid cube root; Exp(x)^(1/3) = Exp( x/3 )
Avoid two transcendentals; Sin( Atan( x ) = Abs( x ) / Sqrt( x^2 + 1 )
Premature optimization, but since you mentioned it:
  • Avoid cube root; 139 ms -> 57 ms.
  • Avoid two transcendentals; 57 ms -> 34 ms.
Why are we doing this?
 
  • #15
pbuk said:
Why are we doing this?
I was wondering if there was an opportunity for Desmos to do some unusual algebraic optimisation prior to the computation. I am not saying it does, just wondering if the example might collapse through some trapdoor in a benchmark.
 
  • Like
Likes pbuk
  • #16
Now here is something surprising:
  • The timing of 139 ms above is from Node JS v20.
  • I tried it in Edge, which is supposed to be the same V8 engine, and it was 120 ms. Chrome just the same.
  • Firefox 103 ms.
 

FAQ: Why is Desmos so insanely fast?

Why is Desmos so insanely fast?

Desmos is able to perform calculations quickly due to its use of advanced algorithms and optimized code. The developers have put a lot of effort into ensuring that the platform runs efficiently and smoothly.

What technology does Desmos use to achieve its speed?

Desmos utilizes a combination of technologies such as WebAssembly, WebGL, and other modern web technologies to deliver fast and responsive performance. These technologies allow Desmos to leverage the power of the user's device for complex calculations.

How does Desmos handle large datasets without slowing down?

Desmos is designed to handle large datasets efficiently by using techniques like data compression, lazy loading, and optimized data structures. This allows the platform to process and display large amounts of data without sacrificing speed.

Does Desmos sacrifice accuracy for speed?

No, Desmos does not sacrifice accuracy for speed. The platform is built to provide precise and reliable calculations while still delivering fast performance. The developers have ensured that speed and accuracy go hand in hand in Desmos.

Can I trust the results I get from Desmos, considering its speed?

Yes, you can trust the results you get from Desmos. The platform has been extensively tested and validated to ensure the accuracy of its calculations. The developers have implemented rigorous quality control measures to guarantee the reliability of the results produced by Desmos.

Similar threads

Replies
3
Views
975
Replies
12
Views
5K
Back
Top