[VA] SRC #008  2021 is here !

01052021, 07:07 PM
Post: #21




RE: [VA] SRC #008  2021 is here !
Hello!
(01052021 06:32 PM)Valentin Albillo Wrote: ... and last but not least, AChan finally saw the light and actually refrained from posting solutions using everything but HP calcs... This may be due to the fact that most older HP calcs (which are the ones I  as well as many others  prefer) can't handle the 3digit exponents of puzzle #1 :) Regards Max 

01052021, 07:42 PM
(This post was last modified: 01052021 11:45 PM by Albert Chan.)
Post: #22




RE: [VA] SRC #008  2021 is here !
(01052021 06:32 PM)Valentin Albillo Wrote: Code:


01052021, 10:57 PM
Post: #23




RE: [VA] SRC #008  2021 is here !
I chose #2 only and I chose this one not because it’s hard but because it’s easy. :)
Incidentally I got the same result when solving this equation for x on my HP50g: \[e^{3x+x\cdot e^{x}}= 2021+\frac{2^{3+ \sqrt{2}}}{30+3^{3}\cdot 2^{\sqrt{2}}}\] Not nearly as beautiful as Valentín’s integral, but at least easier to key in. 

01062021, 01:20 PM
Post: #24




RE: [VA] SRC #008  2021 is here !
(01042021 04:16 PM)Albert Chan Wrote: Post #10, we transform I by using substitution: y = pi/2x, dy = dx Another way is made use of symmetry. Code:


01062021, 02:54 PM
(This post was last modified: 01062021 02:55 PM by Gene.)
Post: #25




RE: [VA] SRC #008  2021 is here !
Couple of solutions:
4/2021 = 1/506 + 1/348128 + 1/16362016 4/2021 = 1/506 + 1/348458 + 1/15664771 Using Egyptian fractions. HP41C program in the Test Stat rom. Program originally in the PPCCJ. Form is a series of 1/N fractions where each N must be different. 

01062021, 07:06 PM
Post: #26




RE: [VA] SRC #008  2021 is here !
(01022021 04:09 PM)Nihotte(lma) Wrote: I'm coming back on the second point. I didn't want to stay on a halffailure... Code:


01062021, 10:49 PM
Post: #27




RE: [VA] SRC #008  2021 is here !
Another way to calculate I, simpler and faster
Code:


01072021, 09:37 PM
(This post was last modified: 01092021 01:38 AM by Valentin Albillo.)
Post: #28




RE: [VA] SRC #008  2021 is here !
Hi all: First of all, thanks to all of you for the warm welcome to my SRC #008 and the many contributions by Nihotte(lma), Vincent Weber, JF Garnier, robve, Dwight Sturrock, Albert Chan, StephenG1CMZ, Albert Chan (again), Gene, ijabbott, telemachos, Maximilian Hohmann, Gerson W. Barbosa and last but not least, Albert Chan, thanks a lot to all of you for your interest and your solutions and quite varied approaches These are my original solutions: 1) Let's partition 2021 into a set of positive integer numbers that add up to 2021. Find the set of such numbers whose product is maximum, and output that maximum in all its full glory. It's easy to see that only using just the terms 2 and 3 will produce the maximum product, because:
In general, for integer N = 3 * q + r, where q is the quotient and r is the reminder, the maximum products are:  if r = 0: Max. P = 3^{q} (no 2's, all are 3's)  if r = 1: Max. P = 2^{2}*3^{q1} (two 2's, the rest are 3's)  if r = 2: Max. P = 2*3^{q} (one 2, the rest are 3's) For real N all summands must be equal because of the ArithmeticGeometric Means inequality, and they must be as close to e = 2.718+ as possible, which is the reason behind the need for a majority of 3's in the integer N case, as 3 is the integer closer to e. Also, as I am so adamant in HP calcs being used to solve the questions I propose, you may wonder where do HP calcs intervene in my solution ? Well, to fulfill the "output that maximum in all its full glory" part of the task, that's where, and to that effect I've concocted this 5line (220byte) program for the HP71B, which exactly computes the 322 digits of the max. product P = 2*3^{673} in half a second using the excellent JF Garnier's Emu71 emulator: 1 DESTROY ALL @ OPTION BASE 0 @ DIM A(36) @ K=10^9 @ A(0)=2*3^13 @ P=0 2 FOR J=1 TO 110 @ MAT A=(729)*A @ FOR I=0 TO P @ A(I+1)=A(I+1)+A(I) DIV K 3 A(I)=MOD(A(I),K) @ NEXT I @ P=P+SGN(A(P+1)) @ NEXT J @ J=0 4 DISP STR$(A(P)); @ FOR I=P1 TO 0 STEP 1 @ J=J+1 @ IF J=5 THEN DISP @ J=0 5 A$=STR$(A(I)) @ DISP RPT$("0",9LEN(A$));A$; @ NEXT I @ DISP Line 1 initializes Lines 23 compute the 322digit product Lines 45 output the result >RUN 2532995521886826292328149655127793939711079 648569980904926813070890600257967555788084132 383052323458136675408253781974882864255212314 264505911807500659338824573345556963262198232 747186628808383273213581619626233679533487706 060253494981896112664520885716630483899029142 003916544644957076791520721759240671604739781 810307846 2) Numerically evaluate as accurately as possible this nice definite integral using your favorite HP calc (per standard notation, the  ...  vertical bars mean "absolute value"): and for extra points, see if you can symbolically recognize the resulting value. You'll need a sufficiently accurate value to do it, though ... The funny thing about this integral is that its value remains the same if you replace 2.021 by any positive real value !! This means that the integral's value is the same for 2.021 or 0.2021, 20.21, 2021, Pi, e, the Golden Ratio, your age, your phone number, etc. So it doesn't actually matter whether the "." in 2.021 is taken as the decimal point or as the thousands separator, as one of you wondered Let's compute it using Free42 Decimal for extra accuracy. We'll need this short 32step (60byte) program which defines a generalized version of the function to integrate (you can specify 2.021 or any other constant): LBL "SRC82" Y^X 1/X ABS MVAR "X" 2 X<>Y RCL "X" MVAR "Z" / STO ST T STOx ST T RCL "Z" X<>Y x Y^X SIN 2 RCL "Z" + ENTER RCL "X" COS LN ABS 1/X STOx ST T RCL/ ST Y RCL "X" Y^X + END and now, using the builtin Integrate application (the "S" are Integral symbols): [Sf(x)] > Select Sf(x) Program [SRC82] > Set Vars; Select Svar [X][Z] 2.021 [X] > X=2.021 [Z] > [LLIM][ULIM][ACC] [S] 0 [LLIM] > LLIM=0 [PI] [ULIM] > ULIM=3.14159265359 1E6 [ACC] > ACC=0.000001 [S] > Integrating > 2.46739926409 [+][SHOW] > 2.46740110027233423194... All that remains now is to symbolically recognize this value, for example using my IDENTIFY program (listing, description and examples here), and the result is Pi^{2}/4, which evaluates to 2.46740110027233965470... so we've got 15 correct digits. You may vary the 2.021 value above and recompute the integral, to check that indeed you get the same result. 3) Decompose 4/2021 into a sum of three fractions of the form 1/K where K is a positive integer. As we saw in (1) above, 2021 is a number of the form N = 3*m + 2 and for such numbers we have the algebraic identity: 4/(3*m + 2) = 1/(3*m + 2) + 1/(m + 1) + 1 /((m + 1) * (3*m + 2)) so we'll use this trivial program to ask for N (which must be of the form 3*m + 2) and output the resulting denominators: 1 DESTROY ALL @ INPUT N 2 IF MOD(N,3)#2 THEN DISP "Not of form 3*m+2" @ END 3 M=N DIV 3 @ DISP N;M+1;N*(M+1) >RUN ? 2021 2021 674 1362154 so: 4/2021 = 1/2021 + 1/674 + 1/1362154, and of course many other solutions are possible as well. As another example, using the program for 2027, which is a prime number and thus can't be factorized, we get: >RUN ? 2027 2027 676 1370252 so 4/2027 = 1/2027 + 1/676 + 1/1370252, and so on and so forth. Note that as the first summand fraction is 1/N, the remaining two add up to 3/N, thus we also have a decomposition of 3/N into two 1/K fractions. Thanks again for your interest and contributions. Best regards. V. Edited to include a slightly optimized version of the BASIC code (30 bytes shorter) All My Articles & other Materials here: Valentin Albillo's HP Collection 

01072021, 10:40 PM
Post: #29




RE: [VA] SRC #008  2021 is here !
(01072021 09:37 PM)Valentin Albillo Wrote: Can you explain why ? With the help of HP Prime emulator, here is the proof for k = 2: I = ∫(ln(sin(x)^2/2 + (cos(x)+sin(x)/sqrt(2))^2) / sin(2x), x = 0. .. pi) = ∫(ln(1+sin(2x)/sqrt(2)) / sin(2x), x = 0. .. pi) I = ∫(ln(1+sin(2y)/sqrt(2)) / sin(2y), y = pi/2. .. pi/2)  y = pi/2x, dy=dx = ∫(2*atanh(sin(2y)/sqrt(2)) / sin(2y), y = 0. .. pi/2)  ln((1+x)/(1x)) = 2*atanh(x) I = ∫(atanh(sin(z)/sqrt(2)) / sin(z), z = 0. .. pi)  z = 2*y, dz=2*dy = ∫(2*atanh(sin(z)/sqrt(2)) / sin(z), z = 0. .. pi/2)  sin(z) symmetry around pi/2 I = ∫(2*atanh(sqrt(2)*t/(1+t^2))/t, t = 0. .. 1)  t = tan(y/2), dt=(1+t^2)/2*dx CAS> series(atanh(√2*t/(1+t^2))/(√2),t,0,18,polynom) t 1/3*t^31/5*t^5+1/7*t^7+1/9*t^9 1/11*t^111/13*t^13+1/15*t^15+1/17*t^17 2*atanh(√(2)*t/(1+t*t))/t = √(8) * (1  t^2/3  t^4/5 + t^6/7 + t^8/9  t^10/11  t^12/13 + t^14/15 + t^16/17  ...) Integrate term by term, t from 0 to 1: I = √(8) * (1  1/3²  1/5² + 1/7² + 1/9²  1/11²  1/13² + 1/15² + 1/17²  ...) Cas> s1 := simplify(sum(1/(2k1)^2, k=1..inf)) // pi^2/8 Cas> s2 := simplify(sum(1/(8k1)^2 + 1/(8k+1)^2, k=1..inf)) // (√(2)*pi^2+2*pi^232)/32 Cas> simplify(sqrt(8) * (2  s1 + 2*s2)) // I = pi^2/4 I can proof s1 by hand, but not s2 (any help appreciated) 

01082021, 01:28 AM
Post: #30




RE: [VA] SRC #008  2021 is here !
(01062021 10:49 PM)Albert Chan Wrote: Let f(t) = ln((0.5+t+c^k)/(0.5+tc^k)), where c = 2^(1/k) Code:
For k=1, g(t) is simple enough that Wolfram Alpha can proof it (after a few seconds) I = ∫(ln((2+t)/(2t)*(2t+1))/t, t = 0 .. 1) = pi^2/4 

01082021, 09:04 AM
Post: #31




RE: [VA] SRC #008  2021 is here !
(01072021 09:37 PM)Valentin Albillo Wrote: ... I've concocted this unoptimized 5line (250byte) program for the HP71B, which exactly computes the 322 digits of the max. product P = 2*3^{673} in half a second using the excellent JF Garnier's Emu71 emulator Thanks :) Emu71/DOS is more than 20 years old but still going strong ! (01072021 10:40 PM)Albert Chan Wrote:(01072021 09:37 PM)Valentin Albillo Wrote: Yes, please Valentin; I was expecting to get an explanation or at least some indications. I used this effect to actually compute the integral on the HP32S with the value k=2 to replace the exponentiation operations with simple squaring, for a much faster computation. Also I computed the integral in two parts, from 0 to pi/2 and pi/2 to pi, since the pi/2 value causes a 0/0 limit of the function. The HP algorithm is robust when this kind of limit is at the edges, but not always when it is within the integration range especially when using high target accuracy (I used accuracy= 1E10). JF 

01082021, 01:32 PM
Post: #32




RE: [VA] SRC #008  2021 is here !
I second these calls for an explanation of the inner workings of this ingenious and unexpected integral  but I have another request too: how, Valentin, did you discover or construct this integral?


01122021, 03:27 AM
Post: #33




RE: [VA] SRC #008  2021 is here !
Reposting this from Spence function thread, per Valentin Albillo's request.
(01112021 06:16 PM)Albert Chan Wrote:(01072021 09:37 PM)Valentin Albillo Wrote: 

01142021, 01:42 AM
Post: #34




RE: [VA] SRC #008  2021 is here !
Hi, all: Thanks for your interest in my SRC #008, some comments to your posts and some answers to your questions: Nihotte(lma) Wrote:I have tested several configurations but it seems to me that 673x3 + 2 gives the best result With a result of 2021 and 2,5329955 x 10^321 ... I'm coming back on the second point. I didn't want to stay on a halffailure... and for the whole integral it gives : [...] 2.467401102 You gave the first correct solution to Case 1 but forgot to also give the exact 322digit result as requested. Not bad ! And your value for the integral using the HP15C is correct as well, congratulations. JF Garnier Wrote:Using your great "Identifying Constants" program, I found the symbolic value, a nice surprise, that lead me to another conclusion about the expression to integrate :) Hehe, you got it, both the symbolic value (Pi^{2}/4) and the fact that the integral's value doesn't depend on the constant being 2.021 and thus you could use 2 instead to speed up the numerical integration using the HP32S no less. And thanks a lot for your kind comments and the link to my Article. robve Wrote:Thanks for posting. A good motivation to write some code on HP Prime. You did not mention that RPN is required... Indeed, the Prime is an HP calculator alright. And your fine solution is the very first one to give the full 322digit correct value for Case 1. Albert Chan Wrote:(many, many things spread over many, many posts) Thanks for your abundant, relentless and interesting approaches both numerical and theoretical, Albert, and most especially for using HP calculators to obtain them, as I requested. At least you did for your very first posts ... StephenG1CMZ Wrote:But if that "." is meant to be a thousands separator rather than decimal, representing the year 2021 rather than the year 2 , I get undef ... As you may have seen, the dot may be taken as the decimal separator or the thousands separator and it willl make no difference to the result ijabbott Wrote:Some clues: Splitting a 1 [...] Your detailed explanation mimics my original solution and is quite didactic for people who would like to understand the logic behind the result, well done. Maximilian Hohmann Wrote:This may be due to the fact that most older HP calcs (which are the ones I  as well as many others  prefer) can't handle the 3digit exponents of puzzle #1 :) Well, that shouldn't be a problem, many of my former Challenges and Short & Sweet Math Challenges did require multiprecision values. Remember for instance my "Sweet & Short Math Challenges #15: April 1st Spring Special", where I posted a 9line program for the HP71B which computed and printed in full the exact solution to the "Take 5" subchallenge, namely 2^{65536}3, which is a 19,729digit integer. There were RPL programs doing likewise, too. Gerson W. Barbosa Wrote:I chose #2 only and I chose this one not because it’s hard but because it’s easy. :) [...] Not nearly as beautiful as Valentín’s integral, but at least easier to key in. Hehe, Gerson, you're playing tricks here, your (very nice, by the way) expression evaluates to 2.4674011002718... while the correct value is Pi^{2}/4 = 2.4674011002723... (Very) close but no cigar ! Gene Wrote:Couple of solutions: [...] Using Egyptian fractions. HP41C program in the Test Stat rom. Very correct, if different from my original solution. And a very useful reference, thanks. Albert Chan Wrote:Can you explain why ? JF Garnier Wrote:Yes, please Valentin; I was expecting to get an explanation or at least some indications. EdS2 Wrote:I second these calls for an explanation of the inner workings of this ingenious and unexpected integral Thanks for your interest and well, my goal with these SRC's and Challenges is to show some interesting HPcalc programming techniques (mostly for the classic models), as well as some interesting, littleknown and even unexpected math topics, hopefully for the enjoyment of (at least some) MoHPC forum's readers. Also, if I can provide technical details or proofs which aren't too lengthy and/or complicated, I'll usually do it. For instance, this is not the first time I post a definite integral allegedly dependent on some parameter but actually being independent of it, such as the two integrals featured in my Short & Sweet Math Challenge #18: April 1st, 2007 Spring Special, namely: / Inf  I1 =  1/((1+x^{2})*(1+x^{4.012007})) .dx  / 0 and / Pi/2  I2 =  1/(1+Tan(x)^{4.012007}) .dx  / 0 which actually are one and the same upon a simple change of variables and their value is Pi/4. The proof of their being independent of the parameter (the 4.012007 value) is short enough that I did post my own proof of the fact in Message #54 in that thread. However, for the present integral the proof is not that easy or short, actually it's quite long and would require a lot of time and cumbersome math "typesetting" to post it here, which regrettably is beyond the scope of these SRC's. I'll give however a link to "some indications" for a very similar integral, which you can find here. The proof for the similar integral I posted (I don't have a link to the proof, sorry) essentially goes along the same lines. Also, if you think that an integral with a parameter whose value is independent of it is something quite unexpected, wait till you see the next integral I'll post in a future SRC, it's 10x as much ! Best regards to all and thanks for participating. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

01142021, 01:59 PM
Post: #35




RE: [VA] SRC #008  2021 is here !
Hi Valentin,
And not one word about my attempt to give a general, mathematical (albeit certainly flawed in many ways) solution for #1 ? Ok, ok, I didn't try to compute it for utmost precision with an HP calculator... but I gave it some thoughts. Just teasing Cheers, Vincent 

01142021, 06:51 PM
Post: #36




RE: [VA] SRC #008  2021 is here !
.
Hi, Vincent: (01142021 01:59 PM)Vincent Weber Wrote: And not one word about my attempt to give a general, mathematical (albeit certainly flawed in many ways) solution for #1 ? Matter of fact I couldn't read your message. I don't know what browser or app you used to format and post it, but this is how it does appear in my browser and yes, that infinitely long message is the one you posted ... ... . As you may see, it dwarfs all other messages in the thread, in fact it extends much beyond the limits of the browser's window and forces me to zoom a lot to be able to read all other messages which are scaled down to unreadable small text, while yours can't be scrolled horizontally any further but is cropped instead so I can't read it properly either, it's truncated. I considered asking you to remove it and repost it again properly formatted but I didn't want to ruffle any feathers and preferred to say nothing about the matter though this will probably affect the future creation of the thread's PDF as well, I'll have to edit it somehow. I do appreciate your continued interest in my productions, Vincent, but next time you'd like to post something in one of my threads, please make sure to format it properly, everyone else does. Thanks and regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

01142021, 10:18 PM
Post: #37




RE: [VA] SRC #008  2021 is here !
Hi Valentin,
My bad ! I posted this using my phone, not realizing how bad the formatting would be. I have deleted the original post. Now that the challenge is over, please find below my original text without the code tags, for your kind consideration. Many thanks and best regards, Vincent First, let's fix the number of numbers the sum is composed of. Let's try the simplest case  2 numbers. There are x and 2021x. The product is maximum when the derivative of x*(2021x) is 0, so when 2021xx=0, or x=2021/2. This is not an integer, ok, but then I got the intuition that the product is maximized when the numbers are as close to each other as possible. So let's try with 3 numbers. They are x,y,and (2021xy). The product is maximized when both x and y partial derivatives are zero, so when 20212xy=0 and 2021x2y=0. This simple system leads to x=y=2021/3. Again, noninteger, but confirms the intution that the numbers need to be equal ! So I was bald engouh to take this intuition for granted for any number of numbers So now, what this number of numbers should be ? Well if x is this number, then 2021/x is each equal number contributing to the sum, and the product is (2021/x)^x, which is also equal to e^(x.ln(2021/x)). Composition derivation leads to a derivative of (ln(2021/x)+x.2021/x^2*x/2021)*...= (Ln(2021/x)1)*... ("..." being the original product function which is never going to be zero). Which leads to an optimal number of numbers of x=2021/e = 743.48... non integer of course.So each number should ideally be equal to e=2.718... the closest integer that comes to mind is obviously 3. You can fit 673 times 3 in 2021. 3×673=2019, remains 2. As for the product, 3^673*2=2.53E321, which is, well, quite a lot maybe not as much as you expected though , Valentin ? I could write a stupid brute force algorithm for the fast free42, trying every single possibility, but I am too lazy for that 

01142021, 10:49 PM
(This post was last modified: 01152021 09:16 AM by Albert Chan.)
Post: #38




RE: [VA] SRC #008  2021 is here !
(01142021 10:18 PM)Vincent Weber Wrote: Well if x is this number, then 2021/x is each equal number contributing to the sum, and the product is (2021/x)^x ... Instead of letting x = number of products, it may be better letting x = base. P = x ^ (2021/x) ln(P) = (2021/x) * ln(x) ln(P)/2021 = ln(x)/x We like to maximize P, so find the local extremum. 0 = (x*(1/x)  ln(x)*1) / x^2 → 1 = ln(x) → x = e Quote:e=2.718... the closest integer that comes to mind is obviously 3 The safer way is not going for closest integer, but actually check value of ln(x)/x 3^2 > 2^3 2 ln(3) > 3 ln(2) ln(3)/3 > ln(2)/2 = ln(4)/4 This showed ln(x)/x maximized when x=e, and we should pack as many 3's as possible. (with the exception of N mod 3 = 1, since 3+1 > 3×1) 2021 = 3*673 + 2 → P = 3^673 * 2 

01152021, 12:50 AM
Post: #39




RE: [VA] SRC #008  2021 is here !
.
Hi, Vincent: (01142021 10:18 PM)Vincent Weber Wrote: My bad ! I posted this using my phone, not realizing how bad the formatting would be. I have deleted the original post. That sort of explains it. Thanks for deleting the post, that will make generating a properly formatted PDF much easier. Quote:Now that the challenge is over, please find below my original text without the code tags, for your kind consideration. But of course, my pleasure. Let's see: Quote:First, let's fix the number of numbers the sum is composed of. Let's try the simplest case  2 numbers. There are x and 2021x. The product is maximum when the derivative of x*(2021x) is 0, so when 2021xx=0, or x=2021/2. This is not an integer, ok, but then I got the intuition that the product is maximized when the numbers are as close to each other as possible. Totally correct, and a logical intuition. Quote:So let's try with 3 numbers. They are x,y,and (2021xy). Again, quite correct and indeed reinforces said intuition. Quote:So I was bald engouh to take this intuition for granted for any number of numbers Very plausible, the previous cases are motivation enough to hypothesize that if the intuition was correct for the cases N=2 and N=3 it's reasonable to assume that it might also be true for general N and see where that leads us. So far so good. Quote:So now, what this number of numbers should be ? Well if x is this number, then 2021/x is each equal number contributing to the sum, and the product is (2021/x)^x, which is also equal to e^(x.ln(2021/x)). Composition derivation leads to a derivative of Correct reasoning, nihil obstat. Quote:So each number should ideally be equal to e=2.718... the closest integer that comes to mind is obviously 3. You can fit 673 times 3 in 2021. 3×673=2019, remains 2. As for the product, 3^673*2=2.53E321, which is, well, quite a lot maybe not as much as you expected though , Valentin ? The reasoning is crystalclear and the conclusion, correct. And I did expect exactly as much from you, Vincent Congratulations are in order and I'm glad I finally got to see your original message, it's been an interesting read for me and I'm sure that many other readers of this thread will find it very interesting (and enlightening!) as well. Thanks again for your fine contribution, it sure helps a lot to achieve my stated main goal for these SRC's. Hope you enjoyed it all and I fully expect to see you participate in the next one ! Best regards. V. All My Articles & other Materials here: Valentin Albillo's HP Collection 

01152021, 06:24 AM
(This post was last modified: 01152021 06:25 AM by Vincent Weber.)
Post: #40




RE: [VA] SRC #008  2021 is here !
Many thanks, Valentin, for your kind words ! Much appreciated.
Many thanks also to Albert, for rightfully pointing that rounding to the closest integer is not good enough, that indeed needs to be tested. Best regards, Vincent 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)