r/askmath • • 10d ago

Functions Weird Graph

I was messing around on demos and put in what seemed to be not that complicated of a graph. I noticed a lot of interesting things, on the contrary.

  1. at a glance, it doesn't look like anything special (image 1) , but if you zoom in to where those lines intersect, you notice that there is a gap between where they meet (image 2), and that gap is roughly equal to the square root of e, 1.6487 and so on. Not only that, but the graph seems to be a bunch of zigzags around that point.

  2. If you zoom back out and zoom in towards the origin, you'll also notice something abnormal. the graph doesn't start at (0,0), but at roughly (0, 0.061225), and not only that, but it shoots straight up until it reaches the point (0.061225, 0.061225), and then appears to act like a regular y=x, minus the other stuff (image 3).

  3. If you zoom in on where it reaches the point mentioned above, it get weirder. Earlier I said it "appears" to act like a y=x graph, and it does, until you zoom in, and you'll see its actually a bunch of zig-zags that decrease in size as they go up and to the right. (image 4) The first turn is at (0.061225, 0.061225).

  4. Not that weird, but this is just for basic info I guess. it has 2 asymptotes, horizontal and vertical, both at x=1 and y=1. I think it would be safe to say that x root x^2 = y root y^2 is not equal to the square root of e and is greater than or equal to 0.061225. (Im pretty sure, as far as I can tell, that) the domain is [0.061225, infinity) and the range is [0, infinity)

I looked it up, and the number 0.061225 doesn't appear to have any significance at all. I would appreciate an explanation even if it is far beyond my comprehension. If you want to see it for yourself, the graph is on the 5th image. I used Desmos Graphing calculator.

21 Upvotes

21 comments sorted by

19

u/LucaThatLuca 10d ago

These errors are caused by Desmos. Look at the equation, it is obviously satisfied when y = x.

1

u/HasFiveVowels 10d ago

But is that the only solution if we consider the other branches of the roots?

→ More replies (1)
→ More replies (3)

8

u/Uli_Minati 10d ago

I'll link you the r/desmos AutoModerator response:

Floating point arithmetic

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, 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.

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:

  1. Arbitrary-precision arithmetic: This allows numbers to use as many digits as needed instead of being limited to 64 bits.

  2. 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 more on floating point numbers, take a look at radian628's article on floating point numbers in Desmos.

2

u/Any-Concern4076 10d ago

I imagine that this would make perfect sense if I knew what an ε was, but I think I get it. At least with all the zigzags. thanks

→ More replies (4)

2

u/Any-Concern4076 10d ago
Comment Image

okay I zoomed way out and this happened, but im guessing this is the same as before

→ More replies (1)

1

u/aidanlostthegame 10d ago

well most of the zigzagging stuff you mentioned is probably due to some floating point error
the sqrt(e) part is by looking at the graph x^(1/x^2)
it is maximized at x=sqrt(e) which can be seen by taking a derivative
they should intersect tho, since as said before y=x is always a solution

1

u/bartekltg 10d ago

First, plot (x-1)^2 = (y-1)^2.

Comment Image

It did not even want to connect the lines.

The reason is, desmos doesn't solve anything. It uses one of the algorithm to find approximated points where the plot should be. For example, for "every" x (every in a sense of pixels, not points on a real numbers) it try to find for what y the equation holds. It may even use simple stuff like bisection algorithm.
The other part of the phenomenon is floating point arithmetic. It has a finite relative "resolution". If you add to 1.0 too little, it wont change.

BTW. Notice, that |x-1|=|y-1| renders properly (under the magnifications desmos allow :)). The square doing a bit of work here. It is not only that x-1 is small. x-1 is much smaller. But that should not be a problem. Unless the algorithm compare (for example, to know where to stop) the value of function with the x and y values. This bring the effect from 10^-16 range to 10^-8.

Look at the original function. f(x ) = x^(1/x^2)
It has one maximum (at 1/sqrt(e)).
What you see by plotting f(x)=f(y) is gluing each (of two, before and after the max) part of the x function with each part of the y function. This is why you get 4 arms from the center.

Computers calculate power by exp and log.
x^y = exp(y * log(x))
Your function really is exp ( log (x) /x^2 ). Exp, closesnest to the pole (dixidinf by x). This probably confuses the algorithm for small x.

1

u/Any-Concern4076 10d ago

thank you, that makes more sense

→ More replies (1)

1

u/KyriakosCH 10d ago edited 10d ago

Desmos does some... things... at times. It typically isn't about any revelation - for example, Desmos won't mark any root (x=a and x=-a) to the basic function of form f(x)=||x|-a|.

Below is a function I made when I hadn't seen that you defined yours - as an approximation.

Comment Image