Here's a little puzzle that fits well between the years 2023 and 2024. A few years ago, this was a task
at the International Mathematical Olympiad. But don't worry; the problem is really not difficult to solve.
I've modified it slightly. Here's the exercise. The following system of linear equations is to be solved:
- x + yz = 2024
- xy + z = 2023
x, y, z should be natural numbers and >= 1.
I posted it here in the Soap Box because there is no place for it in other subforums. I wish the
interested members a lot of fun with the solution.
:thumbsup: :thumbsup:
Interesting "little" algebra problem. Reminds me a bit of high school. :eusa_clap:
Raymond,
Quote from: raymond on December 29, 2023, 01:03:02 PMInteresting "little" algebra problem. Reminds me a bit of high school. :eusa_clap:
Yes, indeed. Unfortunately we have 3 variables and only 2 equations; but there is additional information
about x, y, z. The standard methods (LU decomposition, Wilkinson orthogonalization, etc.) wo'nt work
here. You have to be creative. But once the right idea has been found, the solution is very simple.
I don't think it will be very long before the first correct solution is posted here. So let's wait a
little while longer.
"Extended Euclidean Algorithm" ?
Jack,
thank you for your answer.
Quote from: jack on December 29, 2023, 09:30:48 PM"Extended Euclidean Algorithm" ?
You can try that. But I don't think it will work. Incidentally, there is really only one solution.
Hi Gunther,
I failed to cheat :biggrin:
Genetic Algorithm is trapped in a local solution:
x 22,2193052890
y 90,0463773843 ec1 = 2023,998484
z 22,2305353835 ec2 = 2022,998485
interaccions = 12000000000;
But very nice to play with this 10 years old programs :thumbsup:
(specially because I will need to use them very soon :biggrin: )
Regards, HSE
HSE,
nice try, but wrong result.
As I have already written: You have to be creative.
I solved it by cheating :badgrin:
Jack,
Quote from: jack on December 30, 2023, 07:49:11 AMI solved it by cheating :badgrin:
why not? What's your cheating result?
x=674, y=2, z=675 my cheat https://youtu.be/fd12cV8ZFvA?si=jkIJjj-IvJvrBtyH (https://youtu.be/fd12cV8ZFvA?si=jkIJjj-IvJvrBtyH)
Okay. Check your PM.
My son was over for dinner with us yesterday. Lately, he has been playing with AI to create web pages for his employer. We couldn't resist feeding it this problem which only requires basic high school algebra and a half-ounce of analytical logic.
As I expected, it did have a basic knowledge of algebra but was totally lacking the required logic. After subtracting one equation from the other, it simply tried a "brute force" approach starting with x=1 and then iterating the y and z values to fit the equations. :eusa_boohoo:
Obviously, it NEVER got to a solution. So much for AI. :joking: :joking: :joking:
Hi Raymond,
Quote from: raymond on January 03, 2024, 06:00:37 AMObviously, it NEVER got to a solution. So much for AI.
It's a good trick :thumbsup:
The shame is AI don't know assembly :biggrin:
diophantine proc
local x_val:qword, y_val:qword, z_val:qword
mov r8, 2024
@@x:
mov r9, 2024
@@y:
mov r10, 2024
@@z:
mov rax, r9
mov rcx, r10
mul rcx
add rax, r8
cmp rax, 2024
jne noes
mov rax, r8
mov rcx, r9
mul rcx
add rax, r10
cmp rax, 2023
je solution
noes:
dec r10
jnz @@z
dec r9
jnz @@y
dec r8
jnz @@x
conout "This fail!",lf,lf
ret
solution:
mov x_val, r8
mov y_val, r9
mov z_val, r10
conout " x = ", str$(x_val),lf
conout " y = ", str$(y_val),lf
conout " z = ", str$(z_val),lf,lf
ret
diophantine endp
But process take almost
3 seconds here :undecided:
Quote from: HSE on January 03, 2024, 09:55:54 AMQuote from: raymond on January 03, 2024, 06:00:37 AMObviously, it NEVER got to a solution. So much for AI.
It's a good trick :thumbsup:
The shame is AI don't know assembly :biggrin:
I know you were kinda sorta joking, but really, what possible difference could that make, whether AI "knows" assembly? The language used to code a solution makes no difference; they could use COBOL for all that matters. The point is it hasn't a clue about how to go about solving this problem.
Like the man said, so much for AI. (Artificial ignorance in my book.) Given all the real problems needing solutions in the world, a complete waste of time.
BTW, looking at your code, I have no clue how that works. Do you mind explaining it?
Hi NoC,
Quote from: NoCforMe on January 03, 2024, 10:40:03 AMBTW, looking at your code, I have no clue how that works. Do you mind explaining it?
Code have 3 loops exploring values between 2024 and 1 for each variable. In inner loop results of equations are evaluated. Just that.
No macros, you can see :biggrin:
So, it's basically a brute force technique.
How about applying some of the logic that was shown in that YouTube video that Jack posted (https://masm32.com/board/index.php?msg=126036) here? Is that possible?
Quote from: NoCforMe on January 03, 2024, 11:02:17 AMSo, it's basically a brute force technique.
How about applying some of the logic that was shown in that YouTube video that Jack posted (https://masm32.com/board/index.php?msg=126036) here? Is that possible?
Yes. AI solution :biggrin:
No video... yet :rolleyes:
Here was my approach to solve it within minutes, using logic which AI does not have.
1st, as did AI. was to subtract the two equations.
1. x + yz = 2024
2. xy + z = 2023
______________
x + yz -xy - z = 1
2nd, group some unknowns together as follows (where AI is lacking):
(yz-z) - (xy-x) = 1
z(y-1) - x(y-1) = 1
(z-x)(y-1) = 1
Then it's a simple matter to observe that both components of the multiplication must be integral values based on the problem definition, AND, the only way for the equation to be true is if both are being equal to 1 (AI does not yet seem able to make such observations and deductions).
Therefore, y = 2
and, z = x+1
Replacing those values in the second equation (xy+z=2023),
2x + (x+1) = 3x+1 = 2023
3x = 2023-1 = 2022
x = 2022/3 = 674
and then z = x+1 = 675
:greenclp:
Hi!
I can sleep, but I have another solution:
ay + (1 + a) = 2023
Anyway some brute force, testing first 3 integer results for y sequence :biggrin: (is the second)
Loops solution take me 10 minutes, this hours. Perhaps, Raymond solution could take me weeks :biggrin:
Fantastic :thumbsup: (I hope to sleep now)
Later: Mmm, not so clear.
I solve " a = (2023-1)/(1+y) " for " y = 1, 2, 3, 4, etc " :thumbsup:
Raymond,
Quote from: raymond on January 03, 2024, 03:11:00 PMHere was my approach to solve it within minutes, using logic which AI does not have.
precisely. These are the right steps.
- Subtraction of both equations.
- A clever factorization.
- In the end, it's clear that both factors must be equal to -1.
None of this is witchcraft.
At uni we learned matrices xyzw way of solve things,is that possible Gunther?
Fastest way for humans to calculate things is autistic math talent,like in that Tom Cruise movie
@raymond
Now when you posted solution on the net you might have taught AI to solve it :biggrin: