## News:

Message to All Guests
NB: Posting URL's See here: Posted URL Change

## Diophantine linear equation system

Started by Gunther, December 29, 2023, 09:31:37 AM

#### Gunther

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.
You have to know the facts before you can distort them.

#### raymond

Interesting "little" algebra problem. Reminds me a bit of high school.
Whenever you assume something, you risk being wrong half the time.
http://www.ray.masmcode.com

#### Gunther

Raymond,

Quote from: raymond on December 29, 2023, 01:03:02 PMInteresting "little" algebra problem. Reminds me a bit of high school.

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.
You have to know the facts before you can distort them.

#### jack

"Extended Euclidean Algorithm" ?

#### Gunther

Jack,

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.
You have to know the facts before you can distort them.

#### HSE

Hi Gunther,

I failed to cheat

Genetic Algorithm is trapped in a local solution:

`x 22,2193052890 y 90,0463773843 ec1 = 2023,998484z 22,2305353835 ec2 = 2022,998485interaccions = 12000000000;`
But very nice to play with this 10 years old programs
(specially because I will need to use them very soon  )

Regards, HSE

Equations in Assembly: SmplMath

#### Gunther

HSE,

nice try, but wrong result.

As I have already written: You have to be creative.
You have to know the facts before you can distort them.

#### jack

I solved it by cheating

#### Gunther

Jack,

Quote from: jack on December 30, 2023, 07:49:11 AMI solved it by cheating

why not? What's your cheating result?
You have to know the facts before you can distort them.

#9

#### Gunther

You have to know the facts before you can distort them.

#### raymond

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.

Obviously, it NEVER got to a solution. So much for AI.
Whenever you assume something, you risk being wrong half the time.
http://www.ray.masmcode.com

#### HSE

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

The shame is AI don't know assembly

`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    retdiophantine endp`
But process take almost 3 seconds here
Equations in Assembly: SmplMath

#### NoCforMe

Quote from: HSE on January 03, 2024, 09:55:54 AM
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
The shame is AI don't know assembly
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?
Assembly language programming should be fun. That's why I do it.

#### HSE

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

Equations in Assembly: SmplMath