Number of digits of n!

  Рет қаралды 13,186

Prime Newtons

Prime Newtons

2 ай бұрын

In this video, I used the definition of logarithm and the factorial for real numbers to obtain the number of digits of any factorial. In particular, I found the number of digits for 1000!. The formula was adjusted to use the mid Reimann sum. I have not tested every number for this formula but It worked for the ones I tested. Please leave a comment in the comment section.

Пікірлер: 98
@ju5039
@ju5039 2 ай бұрын
Your talent to explain complex matters in a clear and direct manner is simply unmatched. Thank you for making these lectures.
@Jon60987
@Jon60987 2 ай бұрын
This is an awesome video. A nice follow up would be to take the left, right, and midpoint equations for number of digits, and then display some charts to show how accurate or how inaccurate each of the 3 equations are. As you were clear about, these are all approximations and not exact values. However, one of the other posts which gives a few values shows that you came up with some very nice approximations to the actual values. I found this to be a very impressive demonstration of using Riemann Sums in a way that I would not have come up with on my own.
@surendrakverma555
@surendrakverma555 2 ай бұрын
Very good lecture Sir. Thanks 👍
@allozovsky
@allozovsky 2 ай бұрын
But following the logic in the video, in order to "stick in the middle" we have to shift *both* limits of integration by one half, not just the upper one, so the final formula would be log₁₀(n!) ≈ [x·(ln(x)−1)/ln(10)] at [x₀; x₁] = [1.5; n+0.5] = [(n+0.5)·(ln(n+0.5)−1) − 1.5·(ln(1.5)−1)]/ln(10) ≈ [(n+0.5)·(ln(n+0.5)−1) + 0.8918]/ln(10) so the number of decimal digits of n! is log₁₀(n!) ≅ ⌊((n+0.5)·(ln(n+0.5)−1) + 0.8918)/ln(10)⌋ + 1 This minor change significantly decreases the number of errors (by roughly 2.5 to 3 times), but nevertheless errors still occur (at a rate of about 1.3%, that is ≈13 cases out of every 1000), but that's probably the best we can do with this approach.
@user-ud3cg2vp5s
@user-ud3cg2vp5s 2 ай бұрын
Amazing. May I ask? As u mentioned 5 doesn't work. Why?
@liammoore1066
@liammoore1066 2 ай бұрын
I believe it is just to do with that the fact that the integral of the Riemann summation is an approximation. I’m guessing that because 5! is one of the first numbers to add another digit (120) and it only passes 100 by 20 it probably failed due to this. Lmk if anyone else has thoughts on this I may be wrong.
@allozovsky
@allozovsky 2 ай бұрын
Neither the original nor the "shifted by one half" formula works for all natural numbers. For example, 96! has 150 decimal digits, but the shifted formula yields 151. And there are as much as 37 such whole numbers among the first one thousand. So it's rather a miracle that it did work for 1000!
@justrandomthings8158
@justrandomthings8158 2 ай бұрын
963/1000 doesn’t sound very miraculous but what do I know
@allozovsky
@allozovsky 2 ай бұрын
@@justrandomthings8158 We missed the nearest "wrong" number by 41, so we aimed well.
@liammoore1066
@liammoore1066 2 ай бұрын
Does anyone know why he chose to shift by 1/2? I didn’t understand that since the integral is an infinite amount of rectangles. Was it just so 1000 would work
@JesseBusman1996
@JesseBusman1996 2 ай бұрын
The ceil of log10 doesn't work to get the amount of digits of numbers like 10^n; for example ceil(log10(1000)) gives 3 digits which is wrong So I think it should be 1+floor(log10(n))
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
You're correct. I was blind sided by the fact that no factorial is 10^n.
@sanskarvirat2844
@sanskarvirat2844 2 ай бұрын
​@@PrimeNewtonsI laughed for quite a while. Good videos
@allozovsky
@allozovsky 2 ай бұрын
@@PrimeNewtons > no factorial is 10^n Objection! 9.4456089! = 10⁶ - we already know how to evaluate non-integer factorials. No *integer* factorial is 10ⁿ. *NB* this is supposed to be a joke, so that nobody in the comments gets confused.
@iqtrainer
@iqtrainer 2 ай бұрын
@@allozovskyYeah you are just negative and meaninglessly objecting everything. You def seem to be ill
@iqtrainer
@iqtrainer 2 ай бұрын
@@allozovskyYeah you are objecting again. Blah blah blah
@guyneljean-francois4150
@guyneljean-francois4150 2 ай бұрын
For the factorial of the small numbers, you could also rewrite the number as a product of primes (but for the huge numbers like 1000!, it would be boring). For example 5! = 5*4*3*2*1 = 5*3*2^3*1. log(5!)= log(5) +log(3)+3log(2) +log(1) = 2.079 and ceil(2.079) = 3 However for the numbers in the form of 10^n, the number of digits seems rather to be (1+n) instead of (log10^n).
@user-xn6jt6qu8m
@user-xn6jt6qu8m 2 ай бұрын
This is amazing. Please don't stop these videos
@futuregenerationinstitute9613
@futuregenerationinstitute9613 2 ай бұрын
Could you please drop another one showing parallelogram properties using diagonals and their formulas in terms of perimeter, area, and the side lengths. Thank you.
@adw1z
@adw1z 2 ай бұрын
Small point: in your summations, I believe the upper limit should be x and the dummy variable as n
@sammtanX
@sammtanX 2 ай бұрын
I thought about the same thing, but would it be different for the result of the integral?
@adw1z
@adw1z 2 ай бұрын
@@sammtanX yes same goes for the integral too, as we want it as a function of x like the LHS
@Arkapravo
@Arkapravo 2 ай бұрын
Very nice, you could have used Stirling's approximation directly
@guyneljean-francois4150
@guyneljean-francois4150 2 ай бұрын
Sterling's approximation could give you an estimate of the factorial of the number but not the number of digits. Then, you'll need to count after and in the case of the huge numbers like 1000, the calculator won't be able to display the calculus.
@Arkapravo
@Arkapravo 2 ай бұрын
@@guyneljean-francois4150hmmmm.... n^n becomes the nonsense bit. I agree with you.
@allozovsky
@allozovsky 2 ай бұрын
But you can use the logarithm of the approximation instead: log(n!) ≈ (n·ln(n) − n + ln(2πn)/2)/ln(10) That would give much smaller values. This is almost our formula from the video, but with a better correction term.
@hejjakaroly5850
@hejjakaroly5850 2 ай бұрын
@@allozovsky Yes, this formula is far more accurate. I didn't find a single error up to n = 1 000 000.
@allozovsky
@allozovsky 2 ай бұрын
@@hejjakaroly5850 So for any practical purposes (as though there may be any practical purpose in determining the number if decimal digits in a factorial) we may safely use this approximation.
@aminsheykh7057
@aminsheykh7057 2 ай бұрын
Your videos are amazing👍
@GURPARASSINGH-sg8sv
@GURPARASSINGH-sg8sv 2 ай бұрын
2:48 Vsuace reference I gotchu😂😂
@Orillians
@Orillians 2 ай бұрын
How?
@milindsarkar6961
@milindsarkar6961 Ай бұрын
Great sir. ❤
@temporarytemporary-fh2df
@temporarytemporary-fh2df 2 ай бұрын
Stirling formula calculates the exact number of digits and the exact frontmost digits it is super useful.
@johnka5407
@johnka5407 2 ай бұрын
The system with logarithms at the beginning doesn’t work for the powers of 10, ceiling(log(10)) is 1, but 10 has 2 digits. I think floor(log(x)) + 1 would be better.
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
I agree
@robot8324
@robot8324 2 ай бұрын
Thank you !❤
@guyneljean-francois4150
@guyneljean-francois4150 2 ай бұрын
Based upon my first comment, to be general, the number of digits of n is equal to (1+ floor(log(n) )
@KahlieNiven
@KahlieNiven Ай бұрын
The power of log (log, not love) will always amaze me. From quick calculations (from mind) I found number of digits between 1000 and 3000. (that not solves but helps to find coherent result). then formals. EDIT : 3 digits x 1000 +1 minus 100 >= 2901 > N > 2x900+something > 1800 (log_10 applied intuitively) ... 100x101..x999x1000 -> at least 2x900 digits. (I wasn't sure about the ways to write the log ... ln ? log_e ? log ? in france ln is log_e, log is log_10, log_a is obviously log_a.)
@vitotozzi1972
@vitotozzi1972 2 ай бұрын
Awesome!!!!
@sammtanX
@sammtanX 2 ай бұрын
the great thing is, if you put log_10(x!) = (x ln(x) - x + 1)/ln(10) in desmos, it will just show x = 1.
@allozovsky
@allozovsky 2 ай бұрын
Hm, makes perfect sense, though.
@Misteribel
@Misteribel Ай бұрын
6:30 you probably want to use the floor function and then add one. Otherwise, it won't work with numbers like 10, 10000 etc. For this exercise, though, the result is the same as we won't get an exact power of 10.
@yaronbracha4923
@yaronbracha4923 2 ай бұрын
I liked it !
@NormanicusDiabolicus
@NormanicusDiabolicus 2 ай бұрын
I really enjoy all your videos so clearly and lucidly explained. However, I cannot understand the logic used in this video. 1000! is clearly a product of 1000 discrete integer terms; yet you are employing an integration between two limits( n and 1) which is only valid for continuous functions. Using the gamma function is surely invalid for factorials of integers?
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
I claimed I was using the shifted gamma function, which is continuous.
@NormanicusDiabolicus
@NormanicusDiabolicus 2 ай бұрын
@@PrimeNewtons Yes , but 1000! is the product of discrete integers , so why is using the continuous gamma function valid? It's like using Integration of x between 1 and 100 to determine the sum of all consecutive integers from 1 to 100 , instead of 100(100+1)/2
@NormanicusDiabolicus
@NormanicusDiabolicus 2 ай бұрын
My replies have been deleted!!
@allozovsky
@allozovsky 2 ай бұрын
@@NormanicusDiabolicus Rather shadow banned by youtube (esp. if you comment contained a lot of digits and/or math symbols).
@allozovsky
@allozovsky 2 ай бұрын
Normally you still can find all your shadow banned comments intact in the Comments section of you youtube History.
@nothingbutmathproofs7150
@nothingbutmathproofs7150 2 ай бұрын
Very nice. At the bottom of the 2nd board I wouldn't have put an equal sign.
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
True
@boguslawszostak1784
@boguslawszostak1784 2 ай бұрын
In the 13th minute, you placed an equal sign between the first expression at the top of the board and the result obtained, but in the second row, it is not an equality but an approximation.
@SidneiMV
@SidneiMV 2 ай бұрын
Great!
@gp-ht7ug
@gp-ht7ug 2 ай бұрын
If you say that x! is continuous function, why don’t you use the integral of the Π(x) function for the factorial?
@jetstream_samm
@jetstream_samm 2 ай бұрын
what would you say, if there at answer was 2567.5 for example ?
@temporarytemporary-fh2df
@temporarytemporary-fh2df 2 ай бұрын
By doing so you'r just rewritung the stirling approx which i do prefer than using it blindly.
@chivalioum
@chivalioum 2 ай бұрын
Awesome
@chaosredefined3834
@chaosredefined3834 2 ай бұрын
But we can get an indication of if it will fail. Take the case of 5!. As you point out, we want log(5!), which is log(1) + log(2) + log(3) + log(4) + log(5). And we can ignore the 1, so we get log(2) + ... + log(5). At this point, you replace it with an integral, which is an approximation. But if we go for the integral of 1-5, it's going to be smaller. If we go for the integral of 2-6, it's going to be larger. You resolve this at the end by taking the midpoint (1.5 - 5.5). But our underestimate is 1.7577... and our overestimate is 2.3297.... Which tells us that log(5!) is between 1.7577... and 2.3297..., so we don't know what value floor(log(5!)) or ceil(log(5!)) will take (the floor is either 1 or 2, the ceil is either 2 or 3). Compare this to log(4!), which is between 1.1054... and 1.5899..., so we know it's always 1.(something), so floor(log(4!)) = 1, and ceil(log(4!)) = 2.
@allozovsky
@allozovsky 2 ай бұрын
@chaosredefined3834 > You resolve this at the end by taking the midpoint (1.5 - 5.5). But seems like with our "shifted" formula we are integrating from 1 to n+0.5, not from 1.5. Though there are no obvious reasons why it should work for all n (and in fact it does not).
@chaosredefined3834
@chaosredefined3834 2 ай бұрын
@@allozovsky He should have gone from 1.5 to 5.5. That's an error on his part, but the error will be minor.
@allozovsky
@allozovsky 2 ай бұрын
The "error" is actually equal to the value of the integral from 1 to 1.5, that is approximately 0.0470 - whether it is small or not is hard to tell, since we still have no measure to estimate it's impact.
@chaosredefined3834
@chaosredefined3834 2 ай бұрын
@@allozovsky Assuming that the logs are evenly distributed (which we don't know, but it's a reasonable assumption), it's an error of 1 in approximately 4.7% of cases. Fortunately, the estimate of logs in the other part is an error in the other direction, so it "should" be ok.
@allozovsky
@allozovsky 2 ай бұрын
A shifted formula will not overcome Stirling's approximation anyway, since the latter has a term depending on n, which presumably should provide a better accuracy. The shifted model is too rough.
@alexdefoc6919
@alexdefoc6919 2 ай бұрын
Hey, now we need to know how to find the first 2 digits or 3 to put it in scientific notation of x.yz * 10^2568
@lethalsub
@lethalsub 2 ай бұрын
Factorise 10, 2*5. 5 is the bigger factor. 1000//5=200, 1000//5**2=40, 1000//5**3=8, 1000//5**4=1, 200+40+8+1=249. 249 zeros at the end of 1000!.
@allozovsky
@allozovsky 2 ай бұрын
But neither the original nor the "shifted by one half" formula seems to work for all natural numbers. For example, 96! has 150 decimal digits, but the shifted formula yields 151. And there are as much as 37 such whole numbers among the first one thousand. So it's rather a miracle that it did work for 1000!
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
Looks like there's another adjustment to be made.
@allozovsky
@allozovsky 2 ай бұрын
@@PrimeNewtons Stirling's approximation (when we replace the "+1" term in the original formula by ln(2πn)/2) gives much better results, which is understandable, since now our correction term depends on n, which gives a better approximation.
@amirrozenmanmalach3771
@amirrozenmanmalach3771 2 ай бұрын
Why do you write the times 1? Does it have some reason?
@PrimeNewtons
@PrimeNewtons 2 ай бұрын
Just a habit
@WhiteGandalfs
@WhiteGandalfs 2 ай бұрын
When taking the simple integral, we arrive at about 2566 digits. When asking Wolfram Alpha about the exact product, it spits out 2568 digits. So this method demonstrated here (giving 2568) is a pretty exact one. That little correction appendix is the usual way how engineers tend to tackle such things :D
@povijarrro
@povijarrro 2 ай бұрын
Nice 1000 seconds long video about 1000!
@cyrusrosales3127
@cyrusrosales3127 2 ай бұрын
smart
@klementhajrullaj1222
@klementhajrullaj1222 2 ай бұрын
How many digits has 2^100?!
@cyberagua
@cyberagua 2 ай бұрын
But that's easy: floor[100×log(2)] + 1 = 31
@lubiemuze6368
@lubiemuze6368 2 ай бұрын
Three😂
@dirklutz2818
@dirklutz2818 2 ай бұрын
Fantastic lesson.
@robot8324
@robot8324 2 ай бұрын
Thank you !❤
Bernoulli's Inequality
12:13
Prime Newtons
Рет қаралды 8 М.
How to prove monotone sequences
15:29
Prime Newtons
Рет қаралды 6 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 21 МЛН
КАРМАНЧИК 2 СЕЗОН 7 СЕРИЯ ФИНАЛ
21:37
Inter Production
Рет қаралды 529 М.
How to find the 2319th digit of 1000!
24:31
Michael Penn
Рет қаралды 60 М.
Crack The Logarithm Code: No Calculator!
6:39
BriTheMathGuy
Рет қаралды 37 М.
The best A - A ≠ 0 paradox
24:48
Mathologer
Рет қаралды 392 М.
The strange cousin of the complex numbers -- the dual numbers.
19:14
What does the second derivative actually do in math and physics?
15:19
sqrt((96)(97)(98)(99)+1))
10:39
Prime Newtons
Рет қаралды 8 М.
|i Factorial| You Won't Believe The Outcome
8:24
BriTheMathGuy
Рет қаралды 343 М.
Mathematicians Use Numbers Differently From The Rest of Us
33:06
Veritasium
Рет қаралды 6 МЛН
Calculus at a Fifth Grade Level
19:06
Lukey B. The Physics G
Рет қаралды 8 МЛН
A Diophantine Equation  @drpkmath1234
14:11
Prime Newtons
Рет қаралды 11 М.
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 21 МЛН