My Math Forum (http://mymathforum.com/math-forums.php)
-   Algebra (http://mymathforum.com/algebra/)
-   -   optimal number of shares (http://mymathforum.com/algebra/49268-optimal-number-shares.html)

 get42n8 January 3rd, 2015 11:23 AM

optimal number of shares

here is a problem:
I have \$2000 I want to buy 2 different shares YYY (share price 109) and ZZZ (share price 14) what is the optimal number of YYY and ZZZ shares to buy to spend the most of \$2000 and have the remainder of that as close to zero as possible?

109y+14z=2000

what would be another equation in my Systems of equations? I cannot think of it.

 Timios January 3rd, 2015 12:10 PM

I am not sure that there is another equation.
My thinking is that one should maximize the 14 dollar shares. To do that, I would buy just one 109 dollar share. This would leave 1891 to spend on the 14 dollar shares.

1891÷14=135.0717...

If you buy 135 of these shares you will spend 1890 dollars.
This amount when added to the 109 dollars sums to 1999 dollars.

That's pretty darn close. But is there's an algebraic way to do it, I would like to become aware of it.

And if there is another combination that comes closer to 2000 dollars, I would be surprised.

 mathman January 3rd, 2015 12:11 PM

The only constraint you have is that x and y be non-negative integers and the left side cannot exceed the right side. By brute force try y between 0 and 18 to see what gets you the closest.

 soroban January 3rd, 2015 05:08 PM

Hello, get42n8!

Quote:
 I have \$2000. I want to buy 2 different shares YYY (\$109 each) and ZZZ (\$14 each). What is the optimal number of YYY and ZZZ shares to buy to spend the most of \$2000 and have the remainder of that as close to zero as possible? $109y+14z\:=\:2000$

There is no second equation.
This is a Diophantine equation, requiring integer solutions.

This can be solved by Modular Arithmetic,
but here is an algebraic solution.

Solve for $z\!:\;\; z \;=\;\dfrac{2000-109y}{14} \quad\Rightarrow\quad z\;=\;142 - 8y + \dfrac{12+3y}{14}$

Since $z$ is an integer, $3(4+y)$ must be a multiple of 14.
The first time this happens is: $\:y = 10$

Hence: $\:z \:= \: \dfrac{2000-109(10)}{14} \:=\:\dfrac{910}{14} \:=\:65$

Therefore: $\:\boxed{y \,=\,10,\;z\,=\,65}$

Check: $\:109(10) + 14(65) \:=\:2000$

 Timios January 3rd, 2015 08:35 PM

Good job, soroban!

$z \;=\;\dfrac{2000-109y}{14} \quad\Rightarrow\quad z\;=\;142 - 8y + \dfrac{12+3y}{14}$

 buiduchuy January 3rd, 2015 11:50 PM

Quote:
 Good job, soroban! Please help me to understand why $$z=\frac{2000−109y}{14}⇒z=142−8y+\frac{12+3 y}{14}$$
Because $$z = \frac{2000-109y}{14} = \frac{2000}{14} - \frac{109y}{14} \\ =142 + \frac{12}{14} - (8y - \frac{3y}{14}) \\ = 142 - 8y + \frac{12+3y}{14}$$

 talip January 5th, 2015 11:21 AM

This problem can be modeled as integer programming model as follows:
Min x
Subject to
109y+14z+x=2000
x,y,z >=0 and integer
In operations research area, there are some methods which can be ussed to solve these models. Also some softwares like Lindo solver can also be used.

 All times are GMT -8. The time now is 03:19 AM.