I recently became familiar with the Power of Wolfram.

As a part of the problem I'm working o, I need to find which of the following is closer to $n^2-n$

$O(n \sqrt n)$ or $O(n \log n)$ or $O(n^2)$.

Maybe this is a very basic question, but I need to learn about it, and my challenge is how I can calculate it by using Wolfram Online?

  • 3
    $\begingroup$ O(f(x)) is an upper bound to the absolute value of f for large values of x. Therefore, as n Sqrt[n]< n^2-n and n log[n] < jn^2-n for large n, only O(n^2) is an upper bound to n^2-n $\endgroup$ – Daniel Huber Dec 19 '20 at 12:24
  • $\begingroup$ Have you seen `Series? $\endgroup$ – Michael E2 Dec 19 '20 at 14:05
  • $\begingroup$ Your function is not equal to O(nLog[n]) or O[n Sqrt[n]], but n^2-n = O[^2]. Read e.g.: en.wikipedia.org/wiki/Big_O_notation $\endgroup$ – Daniel Huber Dec 19 '20 at 15:42
Asymptotic[n^2 - n, n -> ∞]
(*    n^2    *)

From the documentation:

Asymptotic[expr, x->x0] computes the leading term in an asymptotic expansion for expr. Use SeriesTermGoal to specify more terms.

  • $\begingroup$ Wolfram|Alpha doesn't understand your query $\endgroup$ – Jessica Jung Dec 19 '20 at 17:27
  • 4
    $\begingroup$ @JessicaJung this forum is about Mathematica and the Wolfram language, not about Wolfram|Alpha. $\endgroup$ – Roman Dec 19 '20 at 18:12
  • $\begingroup$ @JessicaJung you can use the Wolfram Cloud to calculate this. It would satisfy, then, your question’s mention of using “Wolfram Online”, which can be best interpreted as being Wolfram Cloud or Mathematica Online, neither of which are Wolfram|Alpha. $\endgroup$ – CA Trevillian Dec 20 '20 at 15:33
  • $\begingroup$ @JessicaJung here's a useful alternative to Wolfram|Alpha: sandbox.open.wolframcloud.com/app/view/… that will open a Mathematica notebook in the cloud. You can then paste Roman's code and press Shift-Enter to get the result provided. $\endgroup$ – b3m2a1 Dec 20 '20 at 20:42
  • $\begingroup$ @b3m2a1 very nice I see it. but my problem is another things. for example how I can see for example compare arbitrary function like $n^2$ and $n^2 log n$ from $O$ notation? $\endgroup$ – Jessica Jung Dec 24 '20 at 5:08


I have only AsymptoticEqual.

AsymptoticEqual[n^2 - n, n^2, n -> \[Infinity]]

(* True *)

The sign in front of the n does not matter for that truth. This built-in is new in 12.0.0 and newer.

  • $\begingroup$ I honestly don't see what value this brings that Roman's answer didn't already provide $\endgroup$ – b3m2a1 Dec 20 '20 at 20:39
  • $\begingroup$ @b3m2a1 AsymptoticEqual[n^2 - n, n*Log[n], n -> ∞] return False is valuable. $\endgroup$ – cvgmt Dec 20 '20 at 23:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.