multiplying two different numbers by two special numbers to get into max limit

13 Views Asked by At

i need some algorithm and all i can think of is manually try all possible multiplications and compare each to result.

problem:

-all numbers are decimal

-we have number Y and number X which are known

-we have number Z which is also known

-we have number Ym and Xm that we wanna find

relationship between them:

Y * Ym + X * Xm = Z

by multiplying two known by two different numbers and then adding these two results we need to get as close (or exact) to number Z

example:

1 * Ym + 3 * Xm = 14

1 * 2 = 2

3 * 4 = 12

2 + 12 = 14

Ym = 2 and Xm = 4

but these are small and integers

how can one determine Ym and Xm in most elegant or easy way?