For a second I thought that I had forgotten how to do basic integration - but it seems like Desmos is simply hallucinating a finite value here even though the integral is divergent.
Very interesting read! But it is mentioned that the system usually fails when a function behaves erratically, has discontinuities or oscillates in a complicated way. My example is smooth, continuous and monotonically decreasing on (1, +∞). I think they should consider implementing symbolic integration for simple integrands like this one and fall back to numerical integration if the antiderivative cannot be computed in a reasonable amount of time.
It's probably because the integral diverges hella slowly. According to wolframalpha (my beloved), by 1010 it's still only a bit over 3.5. To my knowledge, when desmos computes an integral like this, it's not actually doing the integral like a human would, it instead takes some sample points and extrapolates based off those
the solution to that integral is ln(ln(infinity)) - lnln(x0). if instead of infinity you use a very large float that evaluates to (m-1)ln2 +lnln2 - lnlnx0 (where m is the number of exponent bits). In the case of doubles (whose maximum value is what you are reffering to, aka 22^10) that evaluates to just 6.93.
In Desmos and many computational systems, numbers are represented using floating point arithmetic, which can't precisely represent all real numbers. This leads to tiny rounding errors. For example, √5 is not represented as exactly √5: it uses a finite decimal approximation. This is why doing something like (√5)^2-5 yields an answer that is very close to, but not exactly 0. If you want to check for equality, you should use an appropriate ε value. For example, you could set ε=10^-9 and then use {|a-b|<ε} to check for equality between two values a and b.
There are also other issues related to big numbers. For example, (2^53+1)-2^53 evaluates to 0 instead of 1. This is because there's not enough precision to represent 2^53+1 exactly, so it rounds to 2^53. These precision issues stack up until 2^1024 - 1; any number above this is undefined.
Floating point errors are annoying and inaccurate. Why haven't we moved away from floating point?
TL;DR: floating point math is fast. It's also accurate enough in most cases.
There are some solutions to fix the inaccuracies of traditional floating point math:
Arbitrary-precision arithmetic: This allows numbers to use as many digits as needed instead of being limited to 64 bits.
Computer algebra system (CAS): These can solve math problems symbolically before using numerical calculations. For example, a CAS would know that (√5)^2 equals exactly 5 without rounding errors.
The main issue with these alternatives is speed. Arbitrary-precision arithmetic is slower because the computer needs to create and manage varying amounts of memory for each number. Regular floating point is faster because it uses a fixed amount of memory that can be processed more efficiently. CAS is even slower because it needs to understand mathematical relationships between values, requiring complex logic and more memory. Plus, when CAS can't solve something symbolically, it still has to fall back on numerical methods anyway.
So floating point math is here to stay, despite its flaws. And anyways, the precision that floating point provides is usually enough for most use-cases.
For example, (253+1)-253 evaluates to 0 instead of 1. This is because there's not enough precision to represent 253+1 exactly, so it rounds to 253. These precision issues stack up until 21024 - 1; any number above this is undefined.
Q1) What is meant by “not enough precision” here? Q2) Also I don’t understand how it could know what 253 even is, but when it comes to (253+1)-253, it suddenly doesn’t know?
I mean, double variables are essentially just taking inspiration from the exponential notation
Like you have some bits that represent number A and some bits that represent number B, then the number is just written as A * 2B
but obviously you lose out on precision because as it goes for doubles, you get 52 bits for mantissa, 1 for sign, 10 for exponent and 1 for exponent's sign (which means you can get to numbers like -1e50)
You can google "IEEE754" or ask AI or whatever if you want more info on it
For example, (253+1)-253 evaluates to 0 instead of 1. This is because there's not enough precision to represent 253+1 exactly, so it rounds to 253. These precision issues stack up until 21024 - 1; any number above this is undefined.
Q1) What is meant by “not enough precision” here? Q2) Also I don’t understand how it could know what 253 even is, but when it comes to (253+1)-253, it suddenly doesn’t know?
In the second case it just shifts the number so it can fit only the most significant digits within the mantissa bits, cutting off those digits with low significance to preserve space, the exponent part basically tells by how much you want to shift the number to get its rough approximation, but not exact one
2. It's the reason of that approximation, you're trying to add a bit to a number that's too small to be significant enough for the computer to consider it being worth saving, then the order of operations also matters in this case because if you did (253-253)+1 instead, it should do fine because the most significant digit gets way smaller and thus the need for approximation disappears
Also if you go above 21023-1, it won't be undefined, it will either output infinity or overflow into negatives depending on the compiler
Thank you so much! I just have one followup that I think is crucial to why I’m so confused: what is a “significant” digit and how does the computer decide what’s significant and what’s not?
Basically significant digits are whatever is the most on the left side
Like in case of number 12345, the 3 most significant digits are 123 so rounding it to the 3 most significant digits would look like 12300, since we basically don't care about the numbers after it
Wow, it baffles me how log can slow down such a huge fuckin value, but letting it still increase. 2{1024} has 309 digits, but then you do log(log(x)) and you're left with a mere 709.78 (apologies for error) 6.565
The abbreviation log x is often used when the intended base can be inferred based on the context or discipline, or when the base is indeterminate or immaterial. Common logarithms (base 10), historically used in logarithm tables and slide rules, are a basic tool for measurement and computation in many areas of science and engineering; in these contexts log x still often means the base ten logarithm.[10] In mathematics log x usually refers to the natural logarithm (base e).[11] In computer science and information theory, log often refers to binary logarithms (base 2).[12]
I deleted my comment, because I don't want to get downvoted to oblivion. My statement was that the function 1/(x*ln(x)) converges with the limit x -> +inf = 0. Not that the integral of said function converges, just that it was plausible, because the function does converge.
The integral evaluates to ln(ln(x)), that function grows much slower than its input values do, meaning that any floating point inaccuracy would cause big problems for evaluating it
this is not quite right. other systems, like ti's integral calculation, calculates it correctly, yet it still uses some sort of arithmetic system that has inaccuracy. the problem with what desmos is doing is probably a problem with how its calculating the integral. so it's the integral algorithm thats the problem, not the inaccuracies.
they probably had to do this because they wanted desmos to be fast, so they had to sacrifice accuracy
I know, I own a "non-CAS" calculator myself, but the fact is that it's imposible to conclude that an integral diverges purely with a numerical analysis, so it must be doing something other than pure Riemann sums, which I believe is what Desmos does.
yep. there are caveats associated with any numerical integration scheme. the question, as the lead desmos dev said, is why desmos fails on more types of integrals than other numerical integration schemes
65
u/AlexRLJones Apr 13 '25
Some discussion on integration in Desmos by the lead calculator engineer that might give you some insights as to why it gives a wrong answer here: https://x.com/shapeoperator/status/1447950028648206340
275
u/Immortal_ceiling_fan Apr 13 '25
It's probably because the integral diverges hella slowly. According to wolframalpha (my beloved), by 1010 it's still only a bit over 3.5. To my knowledge, when desmos computes an integral like this, it's not actually doing the integral like a human would, it instead takes some sample points and extrapolates based off those
32
u/Ki0212 Apr 13 '25
It’s probably doing it till 21024
8
u/qwqwqwerty-7 Apr 13 '25
Just wanna verify, the correct answer is undefined, right? Since it approaches infinity. Correct me if I'm wrong
3
u/mydadbeatsmesendhelp Apr 13 '25
I heard that lot of calculators use the Taylor polynom of the original function to calculate it's integral. Maybe that is the case here too.
0
u/[deleted] Apr 13 '25
[deleted] — view deleted comment
14
u/[deleted] Apr 13 '25
[removed] — view removed comment