My maths are a bit rusty, so please excuse me if this is too trivial or has been asked before (very likely!)
I have a set of 20 liquids, each described by three characteristics (A, B and C). How can I mix them to obtain a desired value of A, B and C?
For instance:
- liquid 1 is 2A, 2B, 10C
- liquid 2 is 10A, 5B, 1C
- liquid 3 is 2A, 8B, 9C
…
- liquid 20 is 1A, 3B, 6C
We want a mixture where their linear combination makes 5A, 5B, 5C. We assume that, for instance, mixing liquid 1 with liquid 2 in ratio 1:1 would give us (6A, 3.5B, 5.5C)
I hesitated to post this in a programming forum, because I guess at some point there would be need to rank the different solutions according to how close they are to the target, but it looks to me like solving a set of linear equations (except we might have 0, or many answers…) Could you help me get started?
Best Answer
Never rusty I am going to divide the answer in two( i didn't get completely your question)
You have two liquids
oil=A(1)*t+B(1)*x+C(1)*z;
shampoo=A(2)*t+B(2)x+C(2)*z;
I suppose that you have a set of data for each equation
1) Supposing that you want a function for each liquid with specific values of A, B, C
You can run fminsearch or similar optimisation function(if you have access to Matlab or octave)
what you have to do is to combine the results in a single function you have to create a function that has the values of t,x,z for all your measures and depend on your wanted values A, B, C on this case a vector or a matrix:
if you run an optimisation, you will get the matrix values for each equation
2)
if you want a unique value of A, B, C you have to consider A, B, C on each equation the same.