Math Is Fun Forum

  Discussion about math, puzzles, games and fun.   Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ • π ƒ -¹ ² ³ °

You are not logged in.

#1 2023-12-07 23:42:52

KerimF
Member
From: Aleppo-Syria
Registered: 2018-08-10
Posts: 240

One Equation with Two Unknowns

A librarian needed two different books.
The price of book (A) is $17.
The price of book (B) is $29.
How many books he bought if their total cost was $1000?

Kerim


Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.

Offline

#2 2023-12-08 01:35:16

Bob
Administrator
Registered: 2010-06-20
Posts: 10,623

Re: One Equation with Two Unknowns

hi Kerim

So 17A + 29B = 1000

If you set up a graph with A across and B up, then you would get a straight line, so an infinite number of points.

But A and B have to be + whole numbers, which greatly limits the possible solutions.  I haven't tried to find any yet but, given that neither 17 nor 29 divide into 1000 and are both primes, I suspect there is a single unique answer for this problem.  There's no guaranteed method for finding whole number solutions so I'd probably plot the graph, zoom in and have a look.

There's a graph plotter here: https://www.mathsisfun.com/data/grapher-equation.html

Enter the equation as 17x + 29y = 1000

The zoom slider lets you zoom out until the line appears. (It doesn't show with the default values on the axes.)

And you can drag the graph about to look closely at possible points.  The gradient is -17/29 so if you can spot a point you can probably show there are no more.

I've set up the graph and adjusted the zoom so that the scale shows 0.5 of a unit.  Then I dragged along the line looking for places where the graph hits a whole number corner of the grid.

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#3 2023-12-08 03:04:01

KerimF
Member
From: Aleppo-Syria
Registered: 2018-08-10
Posts: 240

Re: One Equation with Two Unknowns

Well done, Bob. I liked your method.

On my side, I used Excel. I varied y from 1 to int(1000/29)=34 and found out when (1000-19y)/17 became an integer.

Kerim


Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.

Offline

#4 2023-12-08 11:02:43

phrontister
Real Member
From: The Land of Tomorrow
Registered: 2009-07-12
Posts: 4,879

Re: One Equation with Two Unknowns

Hi Kerim;

Yes, I basically did the same as you in Excel.

Also, here's a Mathematica formula, with constraints that a & b are positive integers:

In[1]:= Reduce[17a+29b==1000&&a>0&&b>0,{a,b},Integers]

Out[1]= (a==23&&b==21)||(a==52&&b==4)

Last edited by phrontister (2023-12-08 17:43:45)


"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." - Ted Nelson

Offline

#5 2023-12-08 20:55:23

KerimF
Member
From: Aleppo-Syria
Registered: 2018-08-10
Posts: 240

Re: One Equation with Two Unknowns

phrontister wrote:

Also, here's a Mathematica formula, with constraints that a & b are positive integers:

It is always good to know how to use a math tool when it is available.
On my side, I see myself fortunate that I can still use Excel (a very old version) to solve various mathematical problems related to my designs (in electronics).

It happens that, since very long, I have no more the privilege, as most engineers in the world have, to download a tool/program, free or paid, for advanced math (besides other CAD) to save time in solving complex math problems. But, to me in the least, this is not bad at all, because I enjoy, since I was young (74-year now) playing with numbers, parameters, variables, formulas and equations. I also used, since after graduation, to write CPU then MCU codes in assembly language only for my various designed controllers (needed by the local consumers in every period of time) because I am also not allowed to download any high language compiler.
Anyway, being a rather old man, I expect losing, gradually with time, the last helper I still have, my human brain smile

About math tools, I recall I purchased a programmable TI calculator while studying for MS degree. It could be programmed to solve non-linear equations. At a final exam, I entered the non-linear equation, somehow complex, related to the given problem and let the calculator find out the answer. The professor didn't expect that a student could find the answer in the limited exam's time. He told me that what I did is like cheating. So, I gave him my calculator and ask him to use it, as I did, and have the answer.
He replied: "But I don't know how to use it". I went on saying: "Me too, I had no idea how to use it. But I spent enough time to learn its various functions to help me save time when necessary. This calculator cannot find out the equation of the problem. It can solve it only". He apologized and gave me the highest grade.


Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.

Offline

#6 2023-12-08 22:41:54

zetafunc
Moderator
Registered: 2014-05-21
Posts: 2,436
Website

Re: One Equation with Two Unknowns

Offline

#7 2023-12-08 23:39:16

Bob
Administrator
Registered: 2010-06-20
Posts: 10,623

Re: One Equation with Two Unknowns

Thanks zetafunc. Nice method up

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#8 2023-12-09 20:15:45

KerimF
Member
From: Aleppo-Syria
Registered: 2018-08-10
Posts: 240

Re: One Equation with Two Unknowns

zetafunc wrote:

Thank you for introducing this method which I am not familiar to.

Its crucial step is to find ‘p’ the inverse of Z (modulo n) which leads us to solve another equation with two unknowns as:
Z*p = n*q + 1 , where ‘p’ and ‘q’ are also natural numbers.

In this exercise it is:
12*p = 17*q + 1

And it is clearly simpler than the original one:
17*A + 29*B = 1000

I wonder if this will be the case always.

Kerim


Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.

Offline

#9 2023-12-09 21:18:15

Bob
Administrator
Registered: 2010-06-20
Posts: 10,623

Re: One Equation with Two Unknowns

I'd not met zetafunc's method before. As it can be made to simplify any such equation it should always work; although it could lead to 'no solutions' of course.  I'm going to explore it some more.

Bob


Children are not defined by school ...........The Fonz
You cannot teach a man anything;  you can only help him find it within himself..........Galileo Galilei
Sometimes I deliberately make mistakes, just to test you!  …………….Bob smile

Offline

#10 2023-12-10 01:18:14

KerimF
Member
From: Aleppo-Syria
Registered: 2018-08-10
Posts: 240

Re: One Equation with Two Unknowns

Bob wrote:

I'd not met zetafunc's method before. As it can be made to simplify any such equation it should always work; although it could lead to 'no solutions' of course.  I'm going to explore it some more.

Bob

You may like to solve for example:
107*A + 109*B = 10,000


Every living thing has no choice but to execute its pre-programmed instructions embedded in it (known as instincts).
But only a human may have the freedom and ability to oppose his natural robotic nature.
But, by opposing it, such a human becomes no more of this world.

Offline

#11 2023-12-10 04:44:14

zetafunc
Moderator
Registered: 2014-05-21
Posts: 2,436
Website

Re: One Equation with Two Unknowns

The linear Diophantine equation ax + by = c (where a, b, c are integers) has a solution if and only if c is a multiple of the greatest common divisor (aka the highest common factor) of a and b.

For example, 15x + 12y = 500 has no solutions because the GCD (or HCF) of 15 and 12 is 3, which doesn't divide 500.
And 17x + 29y = 1000 must have a solution in the integers because the GCD (or HCF) of 17 and 29 is 1, which divides 1000.

Also, once you've found a solution (x, y), then all the other solutions have the form

for an arbitrary integer k.

KerimF wrote:

You may like to solve for example:
107*A + 109*B = 10,000

You can extend this trick to find integer solutions to much more complicated equations (e.g. quadratics, cubics) but you'd need to do a bit more work. For example, you can take modulo 4 of both sides of the equation

to show that this doesn't have any integer solutions.

Offline

Board footer

Powered by FluxBB