Find Maximum n for Time Constraints: Solving Problems Using f(n) Microseconds

  • MHB
  • Thread starter evinda
  • Start date
  • Tags
    Maximum
In summary, we discussed finding the maximum problem size that can be solved in a given time for a function $f(n)$. We also considered using Stirling's approximation and various time measurements such as seconds, minutes, hours, days, months, years, and centuries. We found that for $f(n)=n!$, the maximum size $n$ that can be solved in 1 second is $n=9$. For $f(n)=\lg n$ at 1 century, we calculated it to be $2^{31536\cdot 10^{11}}$. We also discussed rounding to the nearest number of days, and whether or not to account for leap years.
  • #1
evinda
Gold Member
MHB
3,836
0
Hello! (Wave)

I am looking at the following exercise:
For each function $f(n)$ and for each time $t$ find the maximum size $n$ of the problem that can be solved in time $t$, assuming that the algorithm of the problem requires time $f(n)$ microseconds( 1 microsecond=$10^{-6}$ second)

Suppose that we have $f(n)=n!$ and want to fill the following array.

$$\begin{matrix}
\text{1 sec } & \text{1 min} & \text{1 hour } & \text{ 1 month } & \text{1 year} & \text{ 1 century} & \\
--- & --- & --- & --- & --- & --- &
\end{matrix}$$How can we find the desired values of $n$?

Do we have to use Stirling's approximation?Also we have to use the following relations, right? (Thinking)

  • 1 sec=$10^6$ ms
  • 1 minute=$60 \cdot 10^6$ ms
  • 1 hour=$3600 \cdot 10^6$ ms
  • 1 day=$24 \cdot 3600 \cdot 10^6$ ms
  • 1 month=$30 \cdot 24 \cdot 3600 \cdot 10^6$ ms
  • 1 year=$12 \cdot 30 \cdot 24 \cdot 3600 \cdot 10^6 $ ms
  • 1 century=$100 \cdot 12 \cdot 30 \cdot 24 \cdot 3600 \cdot 10^6$ ms
 
Physics news on Phys.org
  • #2
evinda said:
Hello! (Wave)

I am looking at the following exercise:
For each function $f(n)$ and for each time $t$ find the maximum size $n$ of the problem that can be solved in time $t$, assuming that the algorithm of the problem requires time $f(n)$ microseconds( 1 microsecond=$10^{-6}$ second)

Suppose that we have $f(n)=n!$ and want to fill the following array.

$$\begin{matrix}
\text{1 sec } & \text{1 min} & \text{1 hour } & \text{ 1 month } & \text{1 year} & \text{ 1 century} & \\
--- & --- & --- & --- & --- & --- &
\end{matrix}$$How can we find the desired values of $n$?

Do we have to use Stirling's approximation?Also we have to use the following relations, right? (Thinking)

  • 1 sec=$10^6$ ms
  • 1 minute=$60 \cdot 10^6$ ms
  • 1 hour=$3600 \cdot 10^6$ ms
  • 1 day=$24 \cdot 3600 \cdot 10^6$ ms
  • 1 month=$30 \cdot 24 \cdot 3600 \cdot 10^6$ ms
  • 1 year=$12 \cdot 30 \cdot 24 \cdot 3600 \cdot 10^6 $ ms
  • 1 century=$100 \cdot 12 \cdot 30 \cdot 24 \cdot 3600 \cdot 10^6$ ms

Hey! (Wave)

A year is 365.2425 days instead of 12x30=360 days. (Nerd)

I think that the easiest way to find the $n$ for $f(n)=n!$, is by simply iterating through $n$ and check when it reaches the required time.

For instance typing n! in Wolfram|Alpha gives us:
n! - Wolfram|Alpha Results
It shows $n!$ up to $n=10$.

From it we can tell that the maximum size $n$ that we can solve in 1 second is $n=9$. (Happy)
 
  • #3
I like Serena said:
Hey! (Wave)

A year is 365.2425 days instead of 12x30=360 days. (Nerd)

A ok.. And how many days do we consider that a month has? (Thinking)

I like Serena said:
I think that the easiest way to find the $n$ for $f(n)=n!$, is by simply iterating through $n$ and check when it reaches the required time.

For instance typing n! in Wolfram|Alpha gives us:
n! - Wolfram|Alpha Results
It shows $n!$ up to $n=10$.

From it we can tell that the maximum size $n$ that we can solve in 1 second is $n=9$. (Happy)

A ok... (Nod)
 
  • #4
evinda said:
A ok.. And how many days do we consider that a month has? (Thinking)

I think 30 days is fine for a month.
Of course the average duration of a month is 365.2425 / 12 = 30.3469 days. (Nerd)
 
  • #5
I found this: http://clrs.skanev.com/01/problems/01.html

For $f(n)=\lg n$ at $1$ century, shouldn't it be $2^{365 \cdot 24 \cdot 36 \cdot 10^{10}}=2^{31536 \cdot 10^{11}}$ ?

Or am I wrong? (Thinking)
 
  • #6
evinda said:
I found this: http://clrs.skanev.com/01/problems/01.html

For $f(n)=\lg n$ at $1$ century, shouldn't it be $2^{365 \cdot 24 \cdot 36 \cdot 10^{10}}=2^{31536 \cdot 10^{11}}$ ?

Or am I wrong? (Thinking)

He picked a different precision for a year.

He picked 365.24 days, accounting for leap years, and also for the non-leap year every century (and not accounting for the extra leap year every 4 centuries). (Wasntme)

He did pick 30 days for a month, and 365 days for a year.
So in each case he chose to round to the nearest number of days. (Smile)
 
  • #7
I like Serena said:
He picked a different precision for a year.

He picked 365.24 days, accounting for leap years, and also for the non-leap year every century (and not accounting for the extra leap year every 4 centuries). (Wasntme)

He did pick 30 days for a month, and 365 days for a year.
So in each case he chose to round to the nearest number of days. (Smile)

So could we agnore the leap years? (Thinking)
If so, would it be then as follows?

$\begin{matrix}
& 1 \text{ century }\\
- & -\\ \\
\lg n & 2^{31536 \cdot 10^{11}}\\ \\
\sqrt{n} & 994519296 \cdot 10^{22}\\ \\
n & 31536 \cdot 10^{11}\\ \\
n \lg n & 68610956750\\ \\
n^2 & 56156922\\ \\
n^3 & 146645\\ \\
2^n & 51\\ \\
n! & 17
\end{matrix}$
 
  • #8
evinda said:
So could we agnore the leap years? (Thinking)
If so, would it be then as follows?

$\begin{matrix}
& 1 \text{ century }\\
- & -\\ \\
\lg n & 2^{31536 \cdot 10^{11}}\\ \\
\sqrt{n} & 994519296 \cdot 10^{22}\\ \\
n & 31536 \cdot 10^{11}\\ \\
n \lg n & 68610956750\\ \\
n^2 & 56156922\\ \\
n^3 & 146645\\ \\
2^n & 51\\ \\
n! & 17
\end{matrix}$

Looks as if you have almost the same numbers as the web page you referred to.
So yes, I believe this is correct. (Smile)

I would write down that you consider a century to be 100 years of 365 days each.
This is a couple of days off, but I'm pretty sure that is not relevant for the problem. (Nerd)
 
  • #9
I like Serena said:
Looks as if you have almost the same numbers as the web page you referred to.
So yes, I believe this is correct. (Smile)

When we consider $f(n)=n \lg n$, how do we come to the number [m]68610956750[/m]?
Is it right? Because at the year, I found for $f(n)=n \cdot \lg n$ the result [m]797633893349[/m] which is bigger... :confused:
I like Serena said:
I would write down that you consider a century to be 100 years of 365 days each.
This is a couple of days off, but I'm pretty sure that is not relevant for the problem. (Nerd)

A ok... (Smile)
 
  • #10
evinda said:
When we consider $f(n)=n \lg n$, how do we come to the number [m]68610956750[/m]?
Is it right? Because at the year, I found for $f(n)=n \cdot \lg n$ the result [m]797633893349[/m] which is bigger... :confused:

Where is that number?
In the web page I see 797633893349, which is also what Wolfram|Alpha finds for me. (Wasntme)
 
  • #11
Not sure how you found your number, but the page you linked is just using the base-2 logarithm which is what $\mathrm{lg}$ commonly refers to (together with the leap year conventions and stuff)

Code:
> NSolve[n Log[2, n] == 365 * 24 * 3600 * 10^6, {n}]

{{n -> 7.97634*10^11}}
 
  • #12
I like Serena said:
Where is that number?
In the web page I see 797633893349, which is also what Wolfram|Alpha finds for me. (Wasntme)

Bacterius said:
Not sure how you found your number, but the page you linked is just using the base-2 logarithm which is what $\mathrm{lg}$ commonly refers to (together with the leap year conventions and stuff)

Code:
> NSolve[n Log[2, n] == 365 * 24 * 3600 * 10^6, {n}]

{{n -> 7.97634*10^11}}

I also used Wolfram and I found this:
n'*'log_2n'='100'*'365'*'24'*'3600'*'10'^'6 - Wolfram|Alphae'^''('ProductLog'('3153600000000000 log'('2')'')'')' - Wolfram|Alpha
:confused:
 
  • #13
Since when is 100*365*24*3600*10^6 a year? I think you got mixed up with centuries here... ;)
 
  • #14
Bacterius said:
Since when is 100*365*24*3600*10^6 a year? I think you got mixed up with centuries here... ;)

I was talking about the case [m] t=1 century [/m].
 
  • #15
evinda said:
I was talking about the case [m] t=1 century [/m].

Oh, okay, I must have misunderstood the last few posts then..
 
  • #16
How could I explain how we fill the table? (Thinking)
 

FAQ: Find Maximum n for Time Constraints: Solving Problems Using f(n) Microseconds

What is the purpose of finding the maximum size n?

The purpose of finding the maximum size n is to determine the largest possible value for n in a given situation or problem. This can help in optimizing resources, identifying limitations, and making informed decisions.

How is the maximum size n determined?

The maximum size n is determined by various factors such as available resources, constraints, and desired outcome. It may involve mathematical calculations, analysis of data, or experimentation depending on the specific context.

Can the maximum size n change over time?

Yes, the maximum size n can change over time. It may vary due to changes in the situation or problem, advancements in technology, or new information that becomes available. It is important to regularly reassess and update the maximum size n to ensure it remains accurate and relevant.

How does finding the maximum size n contribute to scientific research?

Finding the maximum size n is an essential aspect of scientific research as it helps in setting parameters, establishing boundaries, and determining the scope of a study. It also aids in identifying potential limitations and guiding the development of hypotheses and experimental designs.

Are there any limitations to finding the maximum size n?

Yes, there can be limitations to finding the maximum size n. It may not always be possible to accurately determine the maximum size n due to insufficient information or complex variables. Additionally, the maximum size n may only be applicable in a specific context and may not be generalizable to other situations.

Similar threads

Replies
5
Views
2K
Replies
15
Views
2K
Replies
2
Views
1K
Replies
20
Views
4K
Replies
6
Views
2K
Replies
7
Views
2K
Replies
6
Views
1K
Replies
1
Views
3K
Back
Top