2

I am trying to understand the concepts of programming from base. I encountered two examples.

case1: Find upper bound of f(n)=3n+8

Its very clear that f(n)->3 when n-> infinite. So 3n+8 should be less than or equal to 4n . So I can take c as 4.

case2: Find upper bound of f(n)=n^4 +100(n^2)+50

Here f(n) should be less than 2(n^4) for all n = 11. How they come up with n=11? I understand substitution will not be the better case.

It will be great, if someone explains the process of finding the upper bound.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
codeX
  • 4,842
  • 2
  • 31
  • 36

1 Answers1

2

It is a checking method, that is method by substitution or hit-and-trial method.

They checked for the condition when n^4 +100(n^2)+50 < 2*(n^4).

Or in other words, n^4 > (100 * n^2 + 50).

When you'll solve for it, the result will come out to be 11.

That is, for n >= 11. n^4 +100(n^2)+50 < 2*(n^4).

This isn't easy to calculate, you can search for it using Wolfram Alpha.

Also this can be solved using solving the inequality for the value of n.

n^4 > (100 * n^2 + 50)
n^4 - 100 * n^2 - 50 > 0
// find the roots for this equation and then 
// you'll be easily able to deduce the value of n using wavy-curve method.

Check here for how to solve an inequality using wavy-curve method, but for trying this you'll need to find the value for n which solves the given equation.

Am_I_Helpful
  • 18,735
  • 7
  • 49
  • 73
  • Thanks . But I cant understand this n^4 > (111 * n^2 + 50) . how you got 111 ? – codeX Aug 08 '15 at 08:03
  • Its hard to find the value of n by substituting often. Is there any other approach ? Or its the only way.. – codeX Aug 11 '15 at 11:34
  • 1
    @arunprakashpj - It's not hard in this case, just replace n^2 by t, then solve that qudratic equation. Then you'll have n^2 = t, find `n`. And, then use wavy-curve method to solve the inequality. Also, if you're a mathematician, you'll come to know much more better tricks. This is what I can do on my behalf. Also, there might be better methods used by mathematicians/better algorithm coders, but, I don't think generally you need to go that much deeper. Knowledge of mathematics upto high school/ undergraduation is enough.,as in my case too. – Am_I_Helpful Aug 11 '15 at 11:44
  • 1
    Fine ! Thanks for the help! – codeX Aug 12 '15 at 04:42
  • I answered a similar type of question on quora https://www.quora.com/How-do-I-find-upper-bound-for-f-n-3n+8-and-for-f-n-n-4+100n-2+50/answer/Nikhil-Balyan – cammando Mar 14 '17 at 19:43