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.
 

1. Why is Desmos considered to be insanely fast?

Desmos is considered to be insanely fast because it uses advanced algorithms and optimized code to quickly render and update graphs in real time. This allows for a smooth and seamless experience for users, even when working with complex equations or large data sets.

2. How does Desmos achieve such fast performance?

Desmos utilizes a combination of client-side and server-side processing to achieve its fast performance. Client-side processing offloads some of the computational heavy lifting to the user's device, while server-side processing handles more complex calculations and data management.

3. Does Desmos prioritize speed over accuracy?

No, Desmos does not prioritize speed over accuracy. While it is known for its fast performance, it also has built-in error checking and precision settings to ensure accurate graphing and calculations.

4. Are there any limitations to Desmos' speed?

Desmos may experience slower performance when working with extremely large data sets or complex equations. Additionally, the speed may also depend on the user's device and internet connection.

5. Can Desmos' speed be improved even further?

Desmos is constantly working on improving its speed and performance. It regularly releases updates and optimizations to enhance its speed and efficiency. Additionally, users can also improve speed by utilizing the offline mode feature and reducing the number of graphs and data being displayed.

Similar threads

  • STEM Academic Advising
Replies
3
Views
774
  • Computing and Technology
Replies
12
Views
5K
Replies
2
Views
6K
Back
Top