0
$\begingroup$

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?

$\endgroup$
3
  • 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$ Dec 19, 2020 at 12:24
  • $\begingroup$ Have you seen `Series? $\endgroup$
    – Michael E2
    Dec 19, 2020 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$ Dec 19, 2020 at 15:42

2 Answers 2

3
$\begingroup$
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.

$\endgroup$
5
  • $\begingroup$ Wolfram|Alpha doesn't understand your query $\endgroup$ Dec 19, 2020 at 17:27
  • 4
    $\begingroup$ @JessicaJung this forum is about Mathematica and the Wolfram language, not about Wolfram|Alpha. $\endgroup$
    – Roman
    Dec 19, 2020 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$ Dec 20, 2020 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, 2020 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$ Dec 24, 2020 at 5:08
1
$\begingroup$
$Version

12.0.0

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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