The system of equations (64 equations -12 unknown) solution help

Regards, when programming an application I faced with the following system of equations
n1=i1*i5*i9
n2=i1*i5*i10
n3=i1*i5*i11
n4=i1*i5*i12
n5=i1*i6*i9
n6=i1*i6*i10
n7=i1*i6*i11
n8=i1*i6*i12
n9=i1*i7*i9
n10=i1*i7*i10
n11=i1*i7*i11
n12=i1*i7*i12
n13=i1*i8*i9
n14=i1*i8*i10
n15=i1*i8*i11
n16=i1*i8*i12
n17=i2*i5*i9
n18=i2*i5*i10
n19=i2*i5*i11
n20=i2*i5*i12
n21=i2*i6*i9
n22=i2*i6*i10
n23=i2*i6*i11
n24=i2*i6*i12
n25=i2*i7*i9
n26=i2*i7*i10
n27=i2*i7*i11
n28=i2*i7*i12
n29=i2*i8*i9
n30=i2*i8*i10
n31=i2*i8*i11
n32=i2*i8*i12
n33=i3*i5*i9
n34=i3*i5*i10
n35=i3*i5*i11
n36=i3*i5*i12
n37=i3*i6*i9
n38=i3*i6*i10
n39=i3*i6*i11
n40=i3*i6*i12
n41=i3*i7*i9
n42=i3*i7*i10
n43=i3*i7*i11
n44=i3*i7*i12
n45=i3*i8*i9
n46=i3*i8*i10
n47=i3*i8*i11
n48=i3*i8*i12
n49=i4*i5*i9
n50=i4*i5*i10
n51=i4*i5*i11
n52=i4*i5*i12
n53=i4*i6*i9
n54=i4*i6*i10
n55=i4*i6*i11
n56=i4*i6*i12
n57=i4*i7*i9
n58=i4*i7*i10
n59=i4*i7*i11
n60=i4*i7*i12
n61=i4*i8*i9
n62=i4*i8*i10
n63=i4*i8*i11
n64=i4*i8*i12
The system of equations resulting from these matrix, with permutation of all elements
i1 i5 i9
i2 i6 i10
i3 i7 i11
i4 i8 i12
In the above equations, n (n1, n2 ..., n64) are familiar values, while the i (i1, i2, ..., i12) are unknown values
After replace the unknowns by their logarithms i have next system
t1=log(i1)+log(i5)+log(i9)
t2=log(i1)+log(i5)+log(i10)
t3=log(i1)+log(i5)+log(i11)
t4=log(i1)+log(i5)+log(i12)
t5=log(i1)+log(i6)+log(i9)
t6=log(i1)+log(i6)+log(i10)
t7=log(i1)+log(i6)+log(i11)
t8=log(i1)+log(i6)+log(i12)
t9=log(i1)+log(i7)+log(i9)
t10=log(i1)+log(i7)+log(i10)
t11=log(i1)+log(i7)+log(i11)
t12=log(i1)+log(i7)+log(i12)
t13=log(i1)+log(i8)+log(i9)
t14=log(i1)+log(i8)+log(i10)
t15=log(i1)+log(i8)+log(i11)
t16=log(i1)+log(i8)+log(i12)
t17=log(i2)+log(i5)+log(i9)
t18=log(i2)+log(i5)+log(i10)
t19=log(i2)+log(i5)+log(i11)
t20=log(i2)+log(i5)+log(i12)
t21=log(i2)+log(i6)+log(i9)
t22=log(i2)+log(i6)+log(i10)
t23=log(i2)+log(i6)+log(i11)
t24=log(i2)+log(i6)+log(i12)
t25=log(i2)+log(i7)+log(i9)
t26=log(i2)+log(i7)+log(i10)
t27=log(i2)+log(i7)+log(i11)
t28=log(i2)+log(i7)+log(i12)
t29=log(i2)+log(i8)+log(i9)
t30=log(i2)+log(i8)+log(i10)
t31=log(i2)+log(i8)+log(i11)
t32=log(i2)+log(i8)+log(i12)
t33=log(i3)+log(i5)+log(i9)
t34=log(i3)+log(i5)+log(i10)
t35=log(i3)+log(i5)+log(i11)
t36=log(i3)+log(i5)+log(i12)
t37=log(i3)+log(i6)+log(i9)
t38=log(i3)+log(i6)+log(i10)
t39=log(i3)+log(i6)+log(i11)
t40=log(i3)+log(i6)+log(i12)
t41=log(i3)+log(i7)+log(i9)
t42=log(i3)+log(i7)+log(i10)
t43=log(i3)+log(i7)+log(i11)
t44=log(i3)+log(i7)+log(i12)
t45=log(i3)+log(i8)+log(i9)
t46=log(i3)+log(i8)+log(i10)
t47=log(i3)+log(i8)+log(i11)
t48=log(i3)+log(i8)+log(i12)
t49=log(i4)+log(i5)+log(i9)
t50=log(i4)+log(i5)+log(i10)
t51=log(i4)+log(i5)+log(i11)
t52=log(i4)+log(i5)+log(i12)
t53=log(i4)+log(i6)+log(i9)
t54=log(i4)+log(i6)+log(i10)
t55=log(i4)+log(i6)+log(i11)
t56=log(i4)+log(i6)+log(i12)
t57=log(i4)+log(i7)+log(i9)
t58=log(i4)+log(i7)+log(i10)
t59=log(i4)+log(i7)+log(i11)
t60=log(i4)+log(i7)+log(i12)
t61=log(i4)+log(i8)+log(i9)
t62=log(i4)+log(i8)+log(i10)
t63=log(i4)+log(i8)+log(i11)
t64=log(i4)+log(i8)+log(i12)
All variables are > 0
How to solve this system for (i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12)
Thanks in advance

9 Comments

Why are you replacing with logarithm?
to get a linear system if that can help, i never before use matlab
You aren't really using 64 and 12 separately named variables rather than an array are you? If you are, make life easier on yourself and use arrays.
i not understood, how array can help me
It is important to realize that in general if you have more equations than unknowns, it is likely there will exist no solutions to all of them. In your particular case with 64 equations and only 12 unknowns to adjust you should be very suspicious about ever finding a simultaneous solution to all of them. In fact it is very easy to show that there will have to be heavy restrictions on the n-values to allow a solution to exist. For example you must have n1/n2 = n5/n6. If that isn't true there will be no general solution.
n1/n2 = n5/n6
is True
n(1,2..64) are standardized numbers
What do you mean by "standardized numbers"?
for example 1.25^n
22,4 28 35,5 45 . . .
The n's are a geometric progression? The ratio of successive elements of n are always the same? That is information that should have been given to us long ago! I have placed an answer below based on this assumption.

Sign in to comment.

Answers (5)

A matrix-vector equation of the form A*x=b (which you have) can be solved by
x=A\b

2 Comments

Can you show me how? I never before use matlab
Run the following lines of code to get the idea.
>> A=[2,1;1,2], b=[1;1] %Data for equation A*x=b
A =
2 1
1 2
b =
1
1
>> x=A\b %Solve
x =
0.3333
0.3333
>> A*x %Check
ans =
1.0000
1.0000

Sign in to comment.

% Look at this example
n1=i1*i5*i4
n2=i2*i5*i3
n3=i1*i5*i2
n4=i1*i4*i3
----------------------
Fi=[1 0 0 1 1;0 1 1 0 1;1 1 0 0 1;1 0 1 1 0]
y=[n1;n2;n3;n4]
out=Fi\y

16 Comments

i geting this
Fi =
1 0 0 1 1
0 1 1 0 1
1 1 0 0 1
1 0 1 1 0
y =
i1*i4*i5
i2*i3*i5
i1*i2*i5
i1*i3*i4
Warning: System is rank deficient. Solution is not unique.
out =
i1*i2*i5 + i1*i3*i4 - i1*i4*i5 - i2*i3*i5
i1*i4*i5 - i1*i3*i4 + i2*i3*i5
i1*i3*i4 - i1*i4*i5
2*i1*i4*i5 - i1*i3*i4 - i1*i2*i5 + i2*i3*i5
0
i not understand matrix Fi. How you form it
no,
n1=4;
n2=3;
n3=10;
n4=5;
y=[n1;n2;n3;n4]
% n1,n2,n3, and n4 are constants
If you have a system
a1*x+b1*y=c1
a2*x+b2*y=c2
Fi=[a1 b1;a2 b2]
y=[c1;c2]
you can write your system as
Fi*v=y ; with unknown variable v=[x;y]
The solution is given by least square method
v=Fi\y
for the first line you have n1=i1+i5+i9 which means the first line of Fi will be
[ 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 ...
this line contains 64 elements
like this ?
syms i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12
t1=log(i1)+log(i5)+log(i9)
t2=log(i1)+log(i5)+log(i10)
t3=log(i1)+log(i5)+log(i11)
t4=log(i1)+log(i5)+log(i12)
t5=log(i1)+log(i6)+log(i9)
t6=log(i1)+log(i6)+log(i10)
t7=log(i1)+log(i6)+log(i11)
t8=log(i1)+log(i6)+log(i12)
t9=log(i1)+log(i7)+log(i9)
t10=log(i1)+log(i7)+log(i10)
t11=log(i1)+log(i7)+log(i11)
t12=log(i1)+log(i7)+log(i12)
t13=log(i1)+log(i8)+log(i9)
t14=log(i1)+log(i8)+log(i10)
t15=log(i1)+log(i8)+log(i11)
t16=log(i1)+log(i8)+log(i12)
t17=log(i2)+log(i5)+log(i9)
t18=log(i2)+log(i5)+log(i10)
t19=log(i2)+log(i5)+log(i11)
t20=log(i2)+log(i5)+log(i12)
t21=log(i2)+log(i6)+log(i9)
t22=log(i2)+log(i6)+log(i10)
t23=log(i2)+log(i6)+log(i11)
t24=log(i2)+log(i6)+log(i12)
t25=log(i2)+log(i7)+log(i9)
t26=log(i2)+log(i7)+log(i10)
t27=log(i2)+log(i7)+log(i11)
t28=log(i2)+log(i7)+log(i12)
t29=log(i2)+log(i8)+log(i9)
t30=log(i2)+log(i8)+log(i10)
t31=log(i2)+log(i8)+log(i11)
t32=log(i2)+log(i8)+log(i12)
t33=log(i3)+log(i5)+log(i9)
t34=log(i3)+log(i5)+log(i10)
t35=log(i3)+log(i5)+log(i11)
t36=log(i3)+log(i5)+log(i12)
t37=log(i3)+log(i6)+log(i9)
t38=log(i3)+log(i6)+log(i10)
t39=log(i3)+log(i6)+log(i11)
t40=log(i3)+log(i6)+log(i12)
t41=log(i3)+log(i7)+log(i9)
t42=log(i3)+log(i7)+log(i10)
t43=log(i3)+log(i7)+log(i11)
t44=log(i3)+log(i7)+log(i12)
t45=log(i3)+log(i8)+log(i9)
t46=log(i3)+log(i8)+log(i10)
t47=log(i3)+log(i8)+log(i11)
t48=log(i3)+log(i8)+log(i12)
t49=log(i4)+log(i5)+log(i9)
t50=log(i4)+log(i5)+log(i10)
t51=log(i4)+log(i5)+log(i11)
t52=log(i4)+log(i5)+log(i12)
t53=log(i4)+log(i6)+log(i9)
t54=log(i4)+log(i6)+log(i10)
t55=log(i4)+log(i6)+log(i11)
t56=log(i4)+log(i6)+log(i12)
t57=log(i4)+log(i7)+log(i9)
t58=log(i4)+log(i7)+log(i10)
t59=log(i4)+log(i7)+log(i11)
t60=log(i4)+log(i7)+log(i12)
t61=log(i4)+log(i8)+log(i9)
t62=log(i4)+log(i8)+log(i10)
t63=log(i4)+log(i8)+log(i11)
t64=log(i4)+log(i8)+log(i12)
Fi=[1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1]
t1=1
t2=2
t3=3
t4=4
t5=5
t6=6
t7=7
t8=8
t9=9
t10=10
t11=11
t12=12
t13=13
t14=14
t15=15
t16=16
t17=17
t18=18
t19=19
t20=20
t21=21
t22=22
t23=23
t24=24
t25=25
t26=26
t27=27
t28=28
t29=29
t30=30
t31=31
t32=32
t33=33
t34=34
t35=35
t36=36
t37=37
t38=38
t39=39
t40=40
t41=41
t42=42
t43=43
t44=44
t45=45
t46=46
t47=47
t48=48
t49=49
t50=50
t51=51
t52=52
t53=53
t54=54
t55=55
t56=56
t57=57
t58=58
t59=59
t60=60
t61=61
t62=62
t63=63
t64=64
y=[t1;t2;t3;t4;t5;t6;t7;t8;t9;t10;t11;t12;t13;t14;t15;t16;t17;t18;t19;t20;t21;t22;t23;t24;t25;t26;t27;t28;t29;t30;t31;t32;t33;t34;t35;t36;t37;t38;t39;t40;t41;t42;t43;t44;t45;t46;t47;t48;t49;t50;t51;t52;t53;t54;t55;t56;t57;t58;t59;t60;t61;t62;t63;t64]
out=Fi\y
Fi is a matrix 64x12, to make it easy to find, using regexp and regexprep I've found idx from your post.
idx=[ 1 5 9
1 5 10
1 5 11
1 5 12
1 6 9
1 6 10
1 6 11
1 6 12
1 7 9
1 7 10
1 7 11
1 7 12
1 8 9
1 8 10
1 8 11
1 8 12
2 5 9
2 5 10
2 5 11
2 5 12
2 6 9
2 6 10
2 6 11
2 6 12
2 7 9
2 7 10
2 7 11
2 7 12
2 8 9
2 8 10
2 8 11
2 8 12
3 5 9
3 5 10
3 5 11
3 5 12
3 6 9
3 6 10
3 6 11
3 6 12
3 7 9
3 7 10
3 7 11
3 7 12
3 8 9
3 8 10
3 8 11
3 8 12
4 5 9
4 5 10
4 5 11
4 5 12
4 6 9
4 6 10
4 6 11
4 6 12
4 7 9
4 7 10
4 7 11
4 7 12
4 8 9
4 8 10
4 8 11
4 8 12]
Fi=zeros(64);
for k=1:64
Fi(k,idx(k,:))=1
end
does i need to replece this line
Fi=[1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1; 1 1 1]
with this
idx=[ 1 5 9
1 5 10
.
.
.
Fi=zeros(64);
for k=1:64
Fi(k,idx(k,:))=1
end
You don't need to use syms, I show you how to find Fi (it's done, look at above comment). you have just to build the vector y=[t1;t2;...;t64]; then
Sol=Fi\y
ok, i delete
syms i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12
but i getting results as
NaN
That means, your solutions can't be determined. With a matrix Fi formed essentially by zeros!
Can you check my code, is all written exactly as you said
t1=log(i1)+log(i5)+log(i9)
t2=log(i1)+log(i5)+log(i10)
t3=log(i1)+log(i5)+log(i11)
t4=log(i1)+log(i5)+log(i12)
t5=log(i1)+log(i6)+log(i9)
t6=log(i1)+log(i6)+log(i10)
t7=log(i1)+log(i6)+log(i11)
t8=log(i1)+log(i6)+log(i12)
t9=log(i1)+log(i7)+log(i9)
t10=log(i1)+log(i7)+log(i10)
t11=log(i1)+log(i7)+log(i11)
t12=log(i1)+log(i7)+log(i12)
t13=log(i1)+log(i8)+log(i9)
t14=log(i1)+log(i8)+log(i10)
t15=log(i1)+log(i8)+log(i11)
t16=log(i1)+log(i8)+log(i12)
t17=log(i2)+log(i5)+log(i9)
t18=log(i2)+log(i5)+log(i10)
t19=log(i2)+log(i5)+log(i11)
t20=log(i2)+log(i5)+log(i12)
t21=log(i2)+log(i6)+log(i9)
t22=log(i2)+log(i6)+log(i10)
t23=log(i2)+log(i6)+log(i11)
t24=log(i2)+log(i6)+log(i12)
t25=log(i2)+log(i7)+log(i9)
t26=log(i2)+log(i7)+log(i10)
t27=log(i2)+log(i7)+log(i11)
t28=log(i2)+log(i7)+log(i12)
t29=log(i2)+log(i8)+log(i9)
t30=log(i2)+log(i8)+log(i10)
t31=log(i2)+log(i8)+log(i11)
t32=log(i2)+log(i8)+log(i12)
t33=log(i3)+log(i5)+log(i9)
t34=log(i3)+log(i5)+log(i10)
t35=log(i3)+log(i5)+log(i11)
t36=log(i3)+log(i5)+log(i12)
t37=log(i3)+log(i6)+log(i9)
t38=log(i3)+log(i6)+log(i10)
t39=log(i3)+log(i6)+log(i11)
t40=log(i3)+log(i6)+log(i12)
t41=log(i3)+log(i7)+log(i9)
t42=log(i3)+log(i7)+log(i10)
t43=log(i3)+log(i7)+log(i11)
t44=log(i3)+log(i7)+log(i12)
t45=log(i3)+log(i8)+log(i9)
t46=log(i3)+log(i8)+log(i10)
t47=log(i3)+log(i8)+log(i11)
t48=log(i3)+log(i8)+log(i12)
t49=log(i4)+log(i5)+log(i9)
t50=log(i4)+log(i5)+log(i10)
t51=log(i4)+log(i5)+log(i11)
t52=log(i4)+log(i5)+log(i12)
t53=log(i4)+log(i6)+log(i9)
t54=log(i4)+log(i6)+log(i10)
t55=log(i4)+log(i6)+log(i11)
t56=log(i4)+log(i6)+log(i12)
t57=log(i4)+log(i7)+log(i9)
t58=log(i4)+log(i7)+log(i10)
t59=log(i4)+log(i7)+log(i11)
t60=log(i4)+log(i7)+log(i12)
t61=log(i4)+log(i8)+log(i9)
t62=log(i4)+log(i8)+log(i10)
t63=log(i4)+log(i8)+log(i11)
t64=log(i4)+log(i8)+log(i12)
idx=[ 1 5 9
1 5 10
1 5 11
1 5 12
1 6 9
1 6 10
1 6 11
1 6 12
1 7 9
1 7 10
1 7 11
1 7 12
1 8 9
1 8 10
1 8 11
1 8 12
2 5 9
2 5 10
2 5 11
2 5 12
2 6 9
2 6 10
2 6 11
2 6 12
2 7 9
2 7 10
2 7 11
2 7 12
2 8 9
2 8 10
2 8 11
2 8 12
3 5 9
3 5 10
3 5 11
3 5 12
3 6 9
3 6 10
3 6 11
3 6 12
3 7 9
3 7 10
3 7 11
3 7 12
3 8 9
3 8 10
3 8 11
3 8 12
4 5 9
4 5 10
4 5 11
4 5 12
4 6 9
4 6 10
4 6 11
4 6 12
4 7 9
4 7 10
4 7 11
4 7 12
4 8 9
4 8 10
4 8 11
4 8 12]
Fi=zeros(64);
for k=1:64
Fi(k,idx(k,:))=1
end
t1=1
t2=2
t3=3
t4=4
t5=5
t6=6
t7=7
t8=8
t9=9
t10=10
t11=11
t12=12
t13=13
t14=14
t15=15
t16=16
t17=17
t18=18
t19=19
t20=20
t21=21
t22=22
t23=23
t24=24
t25=25
t26=26
t27=27
t28=28
t29=29
t30=30
t31=31
t32=32
t33=33
t34=34
t35=35
t36=36
t37=37
t38=38
t39=39
t40=40
t41=41
t42=42
t43=43
t44=44
t45=45
t46=46
t47=47
t48=48
t49=49
t50=50
t51=51
t52=52
t53=53
t54=54
t55=55
t56=56
t57=57
t58=58
t59=59
t60=60
t61=61
t62=62
t63=63
t64=64
y=[t1;t2;t3;t4;t5;t6;t7;t8;t9;t10;t11;t12;t13;t14;t15;t16;t17;t18;t19;t20;t21;t22;t23;t24;t25;t26;t27;t28;t29;t30;t31;t32;t33;t34;t35;t36;t37;t38;t39;t40;t41;t42;t43;t44;t45;t46;t47;t48;t49;t50;t51;t52;t53;t54;t55;t56;t57;t58;t59;t60;t61;t62;t63;t64]
out=Fi\y
Sorry there is an error in Fi, the initialization is Fi=zeros(64,12)
Use instead
Fi=zeros(64,12); % this line that causes a problem
for k=1:64
Fi(k,idx(k,:))=1
end
out =
16.0000
32.0000
48.0000
64.0000
-12.0000
-8.0000
-4.0000
0
-3.0000
-2.0000
-1.0000
0
finaly
but not a good solution, if i include this in any equation above i will not get the correct result
You have 64 equations for 12 unknowns variables, Least square method minimize the error, but don't make it zero. More you have equations, more there is a chance that the error will be bigger

Sign in to comment.

shorter example but similar:
a+c+e = 14
a+c+f = 11
a+d+e = 13
a+d+f = 10
b+c+e = 13
b+c+f = 10
b+d+e = 12
b+d+f = 9
...has 27 solutions keeping the variables > 0 ; (a,b,c,d,e,f):
1: 2,1,3,2,9,6
2: 2,1,4,3,8,5
...
26: 7,6,3,2,4,1
27: 8,7,2,1,4,1
how ?

6 Comments

I don't know what that second set of numbers is. In the first set, you have 8 measurements, and 6 variables. So you have
y = Ax
with
y = [14;11;13;10;13;10;12;9];
and A = the rows with each row being the coefficients for [a,b,c,d,e,f]. If the variable is missing for that measurement, put a zero in for it. So each row should have 6 coefficients. So in that example, A is
A = [1, 0, 1, 0, 1, 0;... % Only a, c, and e present.
1, 0, 1, 0, 0, 1;... % Only a, c, and f present.
1, 0, 0, 0, 1, 1, 0;... % Only a, d, e present.
etc. down to the last row:
0, 1, 0, 1, 0, 1]; % Only b, d, and f present.
To get the coefficients of the fit
yFitted = alpha(1) * a + alpha(2) * b + alpha(3) * c + alpha(4) * d + alpha(5) * e + alpha(6) * f, you use alpha = A\y.
shorter example but similar:
I don't see the similarity, really. You should probably post this as a new question.
has 27 solutions keeping the variables > 0 ; (a,b,c,d,e,f):
That can only be true if you also insist that a...f are positive integers. Otherwise, there would be either only one or infinite least squares solutions. You didn't insist on integer-valued solutions in your first example, which makes it very different from your originally posted question.
If your question is how to find the 27 solutions, you will probably have to enumerate all of the integer solutions and do exhaustive search. A quick analysis of your equations shows that b,d,f can be at most 7, a,c can be at most 8, and e can be at most 10. To get all combinations needed for the search,
P=uint8(1:7);
Q=uint8(1:8);
R=uint8(1:10);
[b,d,f,a,c,e]=ndgrid(P,P,P,Q,Q,R);
When I do the search, I find 28 solutions, by the way. Not 27.
%Let us make it shorter
  • a+c+e = 14
  • a+c+d = 11
  • a+d+e = 13
  • a+b+e = 10
% This can be written
  • 1*a+0*b+1*c+0*d+1*e=14
  • 1*a+0*b+1*c+1*d+0*e=11
  • 1*a+0*b+0*c+1*d+1*e=13
  • 1*a+1*b+0*c+0*d+1*e=10
%or
Fi*u=y
%with
Fi=[1 0 1 0 1
1 0 1 1 0
1 0 0 1 1
1 1 0 0 1]
y=[14;11;13;10]
The solution is
sol=Fi\y
The solution is sol=Fi\y
No, that won't work. The solutions have to be strictly positive integers and this yeilds sol(5)=0. It also wouldn't locate multiple integer solutions, as the OP requested.
Why do they have to be all positive? Just because he said "All variables are > 0" doesn't mean the coefficients of the regression have to be positive. And I think that if you have more equations (i.e. measurements or observations) than variables, that the "solution" is just a normal run-of-the-mill regression formula, not an exact solution for every single equation, which all of us agree is impossible (unless the numbers just happen to work out that way).
Why do they have to be all positive? Just because he said "All variables are > 0" doesn't mean the coefficients of the regression have to be positive.
I'm not sure what distinction you're drawing between "variables" and "coefficients of the regression". They seem one and the same to me.
Also, like I said, I ran a search for all integer solutions a,b,c,d,e,f>0 and I got 28 solutions. That's very close to the number of solutions, 27, that the OP said s/he was looking for.

Sign in to comment.

Are you saying the n's are a geometric progression? Why didn't you tell us that at the beginning? This information is essential to solving your problem! If that is what are now saying, the solutions to your equation can be characterized in the following manner.
Let r be the constant ratio between any two successive n's. Then the solutions are:
i1 = a
i2 = a*r^16
i3 = a*r^32
i4 = a*r^48
i5 = b
i6 = b*r^4
i7 = b*r^8
i8 = b*r^12
i9 = c
i10 = c*r
i11 = c*r^2
i12 = c*r^3
where a, b, and c are any numbers such that a*b*c = n1.
In other words there are just two degrees of freedom in the solutions for any given geometric progression of n's.

1 Comment

i use something similar to this as solutions for a few months, and i need a couple hours to find proper solutions, now i wondering is it possible to find all solutions,including a,b,c and then just to check them

Sign in to comment.

This is one example on what i worked yesterdey, and i need 3h to get a1,a2,a3,a4,b1,b2,b3,c1,c2
a1 b1 c1
a2 b2 c2
a3 b3
a4
a1*b1*c1=22,4
a1*b1*c2=28
a1*b2*c1=35,5
a1*b2*c2=45
a1*b3*c1=56
a1*b3*c2=71
a2*b1*c1=90
a2*b1*c2=112
a2*b2*c1=140
a2*b2*c2=180
a2*b3*c1=224
a2*b3*c2=280
a3*b1*c1=355
a3*b1*c2=450
a3*b2*c1=560
a3*b2*c2=710
a3*b3*c1=900
a3*b3*c2=1120
a4*b1*c1=1400
a4*b1*c2=1800
a4*b2*c1=2240
a4*b2*c2=2800
a4*b3*c1=3550
a4*b3*c2=4500
a1=0,305
b1=0,263
c1=0,253
a1*b1*c1=0,02
then i use n
n1*t1=0,02*1120=22,4
n2*t1 =28
n3*t1 =35,5
is it possible to do this in matlab faster? If yes, how ?

2 Comments

There can be no solution to that problem! Just take the first four equations:
a1*b1*c1=22,4
a1*b1*c2=28
a1*b2*c1=35,5
a1*b2*c2=45
Divide the second equation by the first and obtain
c2/c1 = 28/22.4 = 1.25
Divide the fourth equation by the third and get
c2/c1 = 45/35.5 =1.2676
Close but no cigar!
Ok, but if we look at example above
a+c+e = 14
a+c+f = 11
a+d+e = 13
a+d+f = 10
b+c+e = 13
b+c+f = 10
b+d+e = 12
b+d+f = 9
...has 27 solutions keeping the variables > 0 ; (a,b,c,d,e,f):
1: 2,1,3,2,9,6
2: 2,1,4,3,8,5
...
26: 7,6,3,2,4,1
27: 8,7,2,1,4,1
Divide the second equation by the first and obtain
11/14=0,786
Divide the fourth equation by the third and get
10/13=0,77
and last two
9/12=0,75
i start new question with real numbers, with my real problem at

Sign in to comment.

Asked:

on 20 Jan 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!