31

I was trying to calculate the following limit:

$$ \lim_{(x,y)\to (0,0)} \frac{(x^2+y^2)^2}{x^2+y^4} $$

and, feeding it into WolframAlpha, I obtain the following answer, stating the limit is $0$: enter image description here

However, when I try to calculate the limit when $x = 0$ and $y$ approaches 0, the limit is 1...

Is the answer given by WolframAlpha wrong? or am I?

Clement C.
  • 67,323
shaqed
  • 475
  • 2
    In general never trust so much any computer algebra system, they are so limited. – Masacroso Mar 09 '17 at 12:41
  • 9
    "they are so limited": are you kidding ? –  Mar 09 '17 at 12:58
  • 12
    @YvesDaoust I think the correct phrasing should be "They are not magic, and using them without knowing the underlying assumptions or caveats that come with them is likely to cause you some issue in specific scenarii." Computer algebra systems don't fool people. People fool people. – Clement C. Mar 09 '17 at 13:00
  • 12
    @ClementC.: IMO very mature CAS such as Mathematica are more reliable than the average mathematician, not counting their ability to perform bulky computations without getting tired. They embed large mathematical culture. (But I also fully agree with your comment.) –  Mar 09 '17 at 13:07
  • @YvesDaoust I concur. Just wanted to point out that if one expects CAS's to be omniscient, computationally unbounded magical oracles, well indeed one is in for a steep disappointment. But I'd rather trust them for many things than relying on my own skills. – Clement C. Mar 09 '17 at 13:42
  • 5
    @ClementC.: from the Mathematica documentation, I cannot guess if two-variables limits are supported at all. But if that wasn't the case, I would expect at least a warning message... –  Mar 09 '17 at 14:52
  • Relevant (for indexing purposes): http://mathematica.stackexchange.com/questions/25381/how-do-i-obtain-the-correct-double-limit – Clement C. Mar 09 '17 at 15:42
  • 3
    @YvesDaoust From what I gather from this thread, Mathematica (implicitly) does limits sequentially. So that it does not produce any message, but only gives the right answer when the limit is path-independent. – Clement C. Mar 09 '17 at 15:46
  • @ClementC.: that would mean the WA's answer is right, but silently answers another question :-) (By the way, by expliciting the order of the limits, you indeed get $0$ or $1$). –  Mar 09 '17 at 16:12
  • 1
    @YvesDaoust I think it depends on who you call a mathematician (i.e. who you're taking the average over) but it also hugely depends on who is using wolfram alpha. There are still quite a few things WA doesn't know how to evaluate correctly see e.g. http://math.stackexchange.com/questions/1888547/roughly-how-much-is-the-following-expression . Moreover if you don't know how to properly ask it's very easy to get nonsense back. – DRF Mar 10 '17 at 06:42
  • @DRF: See https://i.stack.imgur.com/bxUZ2.png, which is an explicit error of WA, because it uses a MATHEMATICALLY WRONG algorithm to evaluate limits. – user21820 Mar 11 '17 at 11:17
  • @ClementC.: I downvote based on the merit of the answer itself, and usually after leaving a comment to state what is wrong with it. Often I wait to see if it is amended, and if not then I might downvote. I admit I have a high standard, and expect an answer to be not misleading to the average student. If you disagree with my principle, sorry but I think it's better for students that way. – user21820 Mar 12 '17 at 00:36
  • I entered (without the quotes) the following: "limit (x^2+y^2)^2/(x^2+y^4) at (0,0)". I got the same Input Interpretation pod as shown in this post, and the result that the limit does not exist. Possibly a bug has been fixed, I'm not sure. – Daniel Lichtblau Sep 10 '17 at 15:45
  • @user21820 I have to wonder what was the explicit error, or the mathematically wrong (in all caps, no less) algorithm used by W|A to evaluate limits. – Daniel Lichtblau Sep 10 '17 at 15:56
  • @DanielLichtblau: I can without doubt tell you that there are people working on the algorithm behind WA that are paying attention to what people are saying on Math SE and other places about bugs in WA. At the very start, it gave the wrong answer on as simple a thing as "lim sin(1/x^2)/sin(1/x^2) as x to 0". When I pointed that out somewhere (can't recall whether on Math SE or through the WA bug reporting interface), I found to my horror that the programmer merely fixed that single instance by hard-coding the answer! This I knew because some other very similar limit was still wrong. – user21820 Sep 11 '17 at 09:03
  • @DanielLichtblau: Along the way, there was even one point in time when WA gave two contradictory answers, one saying the limit is 1 and another saying the limit did not exist. Clearly WA was confused! And as you can see from my PNG, it takes very little effort from a true mathematician to come up with creative inputs that WA gets wrong. I'll leave it as an exercise in creativity to you, because every example I state here will eventually be fixed by hard-coding some silly wrong criterion. How do I know it is wrong? It says "does not exist" for some limits that do... – user21820 Sep 11 '17 at 09:07
  • @DanielLichtblau: The limit I gave in my PNG actually exists, and you will be amused to prove this fact yourself. Limits of special form like in the question here can mathematically be analyzed, but in general any attempt to answer every limit question will lead to rubbish, because of Godel's incompleteness theorems. I note that WA now gives the right answer to the limit I gave, but it's clearly hard-coded in as it gives the wrong answer to a similar limit. Come to the Logic chat-room and ask me if you want to know some tricks to easily break WA no matter how hard they try to whack-a-mistake. – user21820 Sep 11 '17 at 09:25
  • @user21820 Re: "Along the way, there was even one point in time when WA gave two contradictory answers, one saying the limit is 1 and another saying the limit did not exist." Actually I still see that initially, because different pods appear asynchronously. But the one that gives a limit of 1 claims (more or less correctly) that it applies on a restricted domain wherein singularities have been removed. – Daniel Lichtblau Sep 11 '17 at 14:32
  • @DanielLichtblau: Ah so you see what I mean. But I easily can produce more examples where WA is currently wrong. I just don't want to state them here so that they have a harder time. – user21820 Sep 11 '17 at 14:34
  • @user21820 Re: "I can without doubt tell you that there are people working on the algorithm behind WA that are paying attention to what people are saying on Math SE and other places about bugs in WA." That is very likely correct. I know once upon a time it was the case, when I was the person working on this stuff. I suspect it remains that way. As for whether certain problematic examples become hard-coded, I rather doubt it, but since I'm not the developer I cannot be certain. – Daniel Lichtblau Sep 11 '17 at 14:35
  • @DanielLichtblau: You want to come to SBA's realm for a chat about this issue? I'm very interested to know more about what goes on in these places. I don't mean that single examples get hard-coded, but I'm sure that the programmers attempt to hard-code some algorithm for a class of expressions, and often get it wrong. – user21820 Sep 11 '17 at 14:46

3 Answers3

37

This limit is an excellent example to illustrate the power of the (two-)path test and apparently also an excellent example to see that you have to be very careful with how mathematical software deals with this type of problems.

However, when I try to calculate the limit when x = 0 and y approaches 0, the limit is 1...

I the Wolfram wrong ? or am I ?

You are right since, as you say: $$\lim_{x \to 0} \left( \lim_{y \to 0} \frac{\left(x^2+y^2\right)^2}{x^2+y^4} \right) =\lim_{x \to 0} x^2 =0 \quad \color{red}{\ne} \quad \lim_{y \to 0} \left( \lim_{x \to 0} \frac{\left(x^2+y^2\right)^2}{x^2+y^4} \right) =\lim_{y \to 0} \frac{y^4}{y^4} =1$$

WolframpAlpha does produce a decent plot where you can clearly see the parabola $x^2$ when you set $y=0$, but you can also see the 'line' at height $1$ when you set $x=0$.

enter image description here

StackTD
  • 27,903
  • 34
  • 63
26

This is only to complement the excellent answer of StackTD, who correctly shows that you are right — the limit does not exist (as one can find two different paths to the origin along which the limits of the function differ). The key message is:

Do not try limits in more than one variable with Mathematica or WolframAlpha.

(actually, I'd go further and suggest: Do not try limits in more than one real variable with Mathematica or WolframAlpha.)

See e.g. this thread on Mathematica.SE which goes at length into explaining one can possibly try and do it -- spoiler, it's complicated. Quoting a comment from there, by Jens:

With Limit, you're always restricted to a line in the larger space, and you can't make statements about the existence of the limit in the sense of the higher-dimensional space. For that you have to show the independence of the result on the direction of the line. If you intentionally set up a function to have different limits along different lines, I dont (sic) see what else you can do with Mathematica.

Clement C.
  • 67,323
  • 4
    One may add that there are functions for which the limit at a point does not exist, even though the limits along every straight line through that point exist, and they all agree. – Marc van Leeuwen Mar 10 '17 at 08:03
  • @MarcvanLeeuwen Can it happen even if we require that $f$ is defined and continuous on a punctured disk around $(0,0)$? That is, if $f:{ (x,y)\in\mathbb{R}^2 \mid 0 < x^2+y^2 < \epsilon^2} \to \mathbb{R}$ is continuous, can it happen that all limits along straight lines tending towards $(0,0)$ exist and agree, and still the 2-dimensional limit does not exist? – Jeppe Stig Nielsen Mar 10 '17 at 14:08
  • 1
    @JeppeStigNielsen Yes, try $\def\R{\Bbb R}f:\R^2\to\R$ defined by $f(x,y)=g(\frac y{x^2})$ for $x\neq0$ and $f(0,y)=0$, where $g:t\mapsto t\exp(-t^2)$ is a function that goes to$~0$ for $t=0$ and $t\to\pm\infty$. – Marc van Leeuwen Mar 10 '17 at 15:55
  • 2
    I might also mention the answer by Dan Lichtblau, since he happens to be the developer who wrote most of the Mathematica code that WolframAlpha uses to do this type of computation. – Mark McClure Mar 10 '17 at 16:46
  • To the downvoter: care to explain why? – Clement C. Mar 11 '17 at 15:13
10

Wolfram Alpha correctly evaluates

$$ \lim_{x\to0}\lim_{y\to0} \frac{(x^2+y^2)^2}{x^2+y^4}= 0 $$

and

$$ \lim_{y\to0}\lim_{x\to0} \frac{(x^2+y^2)^2}{x^2+y^4}= 1. $$

So one should question the meaning of a limit entered as $(x,y)\to(0,0)$.

  • 10
    A.k.a. "nowhere in the documentation is written that The limits are not evaluated sequentially, since the documentation of Mathematica only mentions single-variable limits." – Clement C. Mar 09 '17 at 16:23