Subtracting item value from totals?

This can be broken down into a simple trio of equations:

a + b = 3
b + c = 5
a + c = 4

How can I get closer to the values? Please note: in real applications, I will have much more of these totals and variables. In particular, I want to find whether it is possible to usefully approach the cost of food products according to the lists of goods and the result of food receipts. I assume that if I can calculate the costs, there will be different accuracy ranges that I can expect, so additional information will know how likely it is that the approximation will be correct and in what range the price should be.

EDIT: I just don’t see it getting an answer that was convenient for me because I couldn’t formulate the question correctly in the first place.

+3
source share
7 answers

You are dealing with a system of linear equations to solve it:

http://www.codeproject.com/KB/cs/LinearEquationsSystemSoln.aspx

The main idea is to construct a matrix of coefficients in the equations and use the decomposition of LU or Gaussian Elimination to derive the values ​​of the variables. LAPACK can help.

Follow-up: LAPACK is a full-featured library for working with all types of linear algebras (and this is effective, while there are also GPU-based libraries such as CUBLAS, which runs on NVIDIA GPUs using CUDA).

, , .

, , , -, . , , ( ). , , , ( ). . : http://www.netlib.org/lapack/lug/node27.html. .

+3

, , , / . .

+3

, , , , .

, , ( ), , , , , .

+3

:

a+b=3 | a=3-b | a=3-(5-c) | a=c-2 | a=(4-a)-2 | 2a=2  | a=1   |       |
b+c=5 | b=5-c | b=5-c     | b=5-c | b=5-c     | b=5-c | b=5-c | b=5-3 | b=2
a+c=4 | c=4-a | c=4-a     | c=4-a | c=4-a     | c=4-a | c=4-1 | c=3   |
+1

| 1 1 0 ||a| |3|
| 0 1 1 ||b|=|5|
| 1 0 1 ||c| |4|

, , .

, , . , . , A T A x = A T b x, x = (a, b, c), b = ( 3,5,4), A - . , T .

, - , .

, , , a, b c .

+1
0

, , . - ; , , , . X, X .

This approach may fail if the product may have different prices for different receipts; a linear program may become impracticable, or there may be more subtle effects.

0
source

Source: https://habr.com/ru/post/1708429/


All Articles