Inverse Problem, I have unknowns to solve it

73 views (last 30 days)
Abdolrazzagh
Abdolrazzagh on 17 Dec 2025 at 20:37
Edited: Torsten about 10 hours ago
I can make as many as equation I want with changing Kf, which it will give me A, B, C, D, F equal to the length of Kf, menas you can make it overdetermind
I want to find the values of A1,A2,A3,A4,A5, L and N
clc;
clear;
close all;
K1 = 60;
K2 = 40;
U1 = 30;
U2 = 20;
pt1 = 0;
pt2 = 0.4;
Kf = linspace(1, 3, 3);
Kf1 = 0;
Xl1 = 0.5;
Xl2 = 1-Xl1;
Uf1 = 0;
Uf2 = 0;
phi = Xl1 * pt1 + Xl2 * pt2;
[~,Kub_frame_1,~,Uub_frame_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf1,Uf1);
[~,Kub_frame_2,~,Uub_frame_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf1,Uf1);
Y1_Frame = Kub_frame_1 - (2*Uub_frame_1)/3;
Y2_Frame = Kub_frame_2 - (2*Uub_frame_2)/3;
[Cij_A_Frame] = Backus_average([Xl1,Xl2],[Uub_frame_1,Kub_frame_2],[Y1_Frame,Y2_Frame]);
Sij_A_Frame = inv(Cij_A_Frame);
Sig_D = zeros(6, 6, numel(Kf));
for i = 1:numel(Kf)
Kf2 = Kf(i);
[~,Kub_ud_1,~,Uub_ud_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf2,Uf2);
[~,Kub_ud_2,~,Uub_ud_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf2,Uf2);
Y1_Sat = Kub_ud_1 - (2*Uub_ud_1)/3;
Y2_Sat = Kub_ud_2 - (2*Uub_ud_2)/3;
[Cij_A_Ud] = Backus_average([Xl1,Xl2],[Uub_ud_1,Uub_ud_2],[Y1_Sat,Y2_Sat]);
Sij_star = inv(Cij_A_Ud);
Sig_D(:,:,i) = Sij_A_Frame - Sij_star;
end
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
kappa_f = 1./Kf;
kappa_a = trace(Sij_A_Frame);
%FinD A1,A2,A3,A4,A5, L and N
A = A1/((kappa_f - L) * phi + (kappa_a - N));
Unrecognized function or variable 'A1'.
B = A2/((kappa_f - L) * phi + (kappa_a - N));
C = A3/((kappa_f - L) * phi + (kappa_a - N));
D = A4/((kappa_f - L) * phi + (kappa_a - N));
F = A5/((kappa_f - L) * phi + (kappa_a - N));
function [Klb,Kub,Ulb,Uub]=Hashin_Shtrikhman_full(K,U,Vfr,P,Kf,Uf)
Umin=min(U);
Umax=max(U);
Kmin=min(K);
Kmax=max(K);
if P==0
Klb = 1./((1-P).*sum(Vfr./K));
elseif P>0
Klb = 1./((P./Kf)+((1-P).* sum (Vfr./K)));
end
Kub = ((P * (1./(Kf+((4/3)*Umax))) + (1-P) * sum(Vfr./(K+((4/3).*Umax))))^(-1)) - (4/3)*Umax;
Zmax =(Umax/6)*((9*Kmax+8*Umax)/(Kmax+2*Umax));
if P ==0
Zmin =(Umin/6)*((9*Kmin+8*Umin)/(Kmin+2*Umin));
elseif P>0
Zmin =(Uf/6)*((9*Kf+8*Uf)/(Kf+2*Uf));
end
Uub = (( (P/Zmax) + (1-P) * sum (Vfr./(U+Zmax)))^(-1))-Zmax;
Ulb = (( (P/Zmin) + (1-P) * sum (Vfr./(U+Zmin)))^(-1))-Zmin;
end
function [c]=Backus_average(VF,G,Y)
x = sum(VF.*G.*(Y+G)./(Y+2*G));
y = sum(VF.*G.*Y./(Y+2*G));
z = sum(VF.*Y./(Y+2*G));
u = sum(VF./(Y+2*G));
v = sum(VF./G);
w = sum(VF.*G);
A = 4*x + z*z/u;
B = 2*y + z*z/u;
E = 1/u;
F = z/u;
D = 1/v;
M = w;
c = zeros(6,6);
c(1,1) = A;
c(1,2) = B;
c(1,3) = F;
c(2,1) = B;
c(2,2) = A;
c(2,3) = F;
c(3,1) = F;
c(3,2) = F;
c(3,3) = E;
c(4,4) = D;
c(5,5) = D;
c(6,6) = M;
end

Accepted Answer

Torsten
Torsten 39 minutes ago
Edited: Torsten 38 minutes ago
L and N cannot be estimated separately.
As long as phi is a single scalar value , L*phi + N must be treated as only one parameter that replaces L*phi + N. Otherwise, you do overfitting.
I didn't do that in the code below, but it should be easy for you to modify it accordingly.
clc;
clear;
close all;
K1 = 60;
K2 = 40;
U1 = 30;
U2 = 20;
pt1 = 0;
pt2 = 0.4;
Kf = linspace(1, 3, 3);
Kf1 = 0;
Xl1 = 0.5;
Xl2 = 1-Xl1;
Uf1 = 0;
Uf2 = 0;
phi = Xl1 * pt1 + Xl2 * pt2;
[~,Kub_frame_1,~,Uub_frame_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf1,Uf1);
[~,Kub_frame_2,~,Uub_frame_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf1,Uf1);
Y1_Frame = Kub_frame_1 - (2*Uub_frame_1)/3;
Y2_Frame = Kub_frame_2 - (2*Uub_frame_2)/3;
[Cij_A_Frame] = Backus_average([Xl1,Xl2],[Uub_frame_1,Kub_frame_2],[Y1_Frame,Y2_Frame]);
Sij_A_Frame = inv(Cij_A_Frame);
Sig_D = zeros(6, 6, numel(Kf));
for i = 1:numel(Kf)
Kf2 = Kf(i);
[~,Kub_ud_1,~,Uub_ud_1] = Hashin_Shtrikhman_full(K1,U1,1,pt1,Kf2,Uf2);
[~,Kub_ud_2,~,Uub_ud_2] = Hashin_Shtrikhman_full(K2,U2,1,pt2,Kf2,Uf2);
Y1_Sat = Kub_ud_1 - (2*Uub_ud_1)/3;
Y2_Sat = Kub_ud_2 - (2*Uub_ud_2)/3;
[Cij_A_Ud] = Backus_average([Xl1,Xl2],[Uub_ud_1,Uub_ud_2],[Y1_Sat,Y2_Sat]);
Sij_star = inv(Cij_A_Ud);
Sig_D(:,:,i) = Sij_A_Frame - Sij_star;
end
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
kappa_f = 1./Kf;
kappa_a = trace(Sij_A_Frame);
x = [A,B,C,D,F];
y = @(A1,A2,A3,A4,A5,L,N)[A1./((kappa_f - L) * phi + (kappa_a - N)),...
A2./((kappa_f - L) * phi + (kappa_a - N)),...
A3./((kappa_f - L) * phi + (kappa_a - N)),...
A4./((kappa_f - L) * phi + (kappa_a - N)),...
A5./((kappa_f - L) * phi + (kappa_a - N))];
fy = @(p)y(p(1),p(2),p(3),p(4),p(5),p(6),p(7));
F = @(p) fy(p) - x;
sol = lsqnonlin(F,[7 6 5 4 3 2 1])
Local minimum found. Optimization completed because the size of the gradient is less than the value of the optimality tolerance.
sol = 1×7
0.0360 0.0360 0.0981 -0.0222 0.3554 33.9358 8.5194
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%FinD A1,A2,A3,A4,A5, L and N
%A = A1/((kappa_f - L) * phi + (kappa_a - N));
%B = A2/((kappa_f - L) * phi + (kappa_a - N));
%C = A3/((kappa_f - L) * phi + (kappa_a - N));
%D = A4/((kappa_f - L) * phi + (kappa_a - N));
%F = A5/((kappa_f - L) * phi + (kappa_a - N));
function [Klb,Kub,Ulb,Uub]=Hashin_Shtrikhman_full(K,U,Vfr,P,Kf,Uf)
Umin=min(U);
Umax=max(U);
Kmin=min(K);
Kmax=max(K);
if P==0
Klb = 1./((1-P).*sum(Vfr./K));
elseif P>0
Klb = 1./((P./Kf)+((1-P).* sum (Vfr./K)));
end
Kub = ((P * (1./(Kf+((4/3)*Umax))) + (1-P) * sum(Vfr./(K+((4/3).*Umax))))^(-1)) - (4/3)*Umax;
Zmax =(Umax/6)*((9*Kmax+8*Umax)/(Kmax+2*Umax));
if P ==0
Zmin =(Umin/6)*((9*Kmin+8*Umin)/(Kmin+2*Umin));
elseif P>0
Zmin =(Uf/6)*((9*Kf+8*Uf)/(Kf+2*Uf));
end
Uub = (( (P/Zmax) + (1-P) * sum (Vfr./(U+Zmax)))^(-1))-Zmax;
Ulb = (( (P/Zmin) + (1-P) * sum (Vfr./(U+Zmin)))^(-1))-Zmin;
end
function [c]=Backus_average(VF,G,Y)
x = sum(VF.*G.*(Y+G)./(Y+2*G));
y = sum(VF.*G.*Y./(Y+2*G));
z = sum(VF.*Y./(Y+2*G));
u = sum(VF./(Y+2*G));
v = sum(VF./G);
w = sum(VF.*G);
A = 4*x + z*z/u;
B = 2*y + z*z/u;
E = 1/u;
F = z/u;
D = 1/v;
M = w;
c = zeros(6,6);
c(1,1) = A;
c(1,2) = B;
c(1,3) = F;
c(2,1) = B;
c(2,2) = A;
c(2,3) = F;
c(3,1) = F;
c(3,2) = F;
c(3,3) = E;
c(4,4) = D;
c(5,5) = D;
c(6,6) = M;
end
  4 Comments
Abdolrazzagh
Abdolrazzagh 15 minutes ago
I am afarid to let you know this L*phi + N making one unkown is wrong as we are changing the equation in this case.
However, the first one is correct, Why this solution is highlt depended n the intial guess, is there anyway to make this to not dependent on the initial guess, Also why lsqnonlin, and not fmincon?
Torsten
Torsten 12 minutes ago
Edited: Torsten 9 minutes ago
Every combination of L and N that makes LN = L*phi + N solves the fitting task. You must consider L*phi + N as one constant as long as phi is a constant that is equally valid for A, B, C, D and F.
"lsqnonlin" is especially suited for least-squares problems - that's why I chose it. If you want to set constraints on the parameters, you will have to use "fmincon" instead.

Sign in to comment.

More Answers (2)

Abdolrazzagh
Abdolrazzagh 2 minutes ago
What if we only solve
A1./((kappa_f - L) * phi + (kappa_a - N)
treating L and N as the unknowns with three equations? Once we have L and N, we can calculate the other variables.
Obviously, this approach should also work if we change the equation to
A2./((kappa_f - L) * phi + (kappa_a - N)
The calculated values of L and N should be similar in both cases or if I use the other cases.
but the problem they do not as I tried,
I have seem you are mathematician or wotks with mathematic. could you plese give your opinion and why it happens? (ajavid@cougarnet.uh.edu) if we can have an online meeting to clearify this problem and solve (would be appriciated)

Walter Roberson
Walter Roberson on 17 Dec 2025 at 21:55
A = squeeze(Sig_D(1,1,:)).';
B = squeeze(Sig_D(1,1,:)).';
C = squeeze(Sig_D(3,3,:)).';
D = squeeze(Sig_D(1,3,:)).';
F = squeeze(Sig_D(4,4,:)).';
each of those is a row vector with the same number of elements as Kf has
%FinD A1,A2,A3,A4,A5, L and N
A = A1/((kappa_f - L) * phi + (kappa_a - N));
B = A2/((kappa_f - L) * phi + (kappa_a - N));
C = A3/((kappa_f - L) * phi + (kappa_a - N));
D = A4/((kappa_f - L) * phi + (kappa_a - N));
F = A5/((kappa_f - L) * phi + (kappa_a - N));
In each case, A, B, C, D, F are known, but A1, A2, A3, A4, A5, L and N are unknown. These should instead be equations expressing that the left hand side is equal to the right hand side.
Notice though that the right hand sides all involve division by the same factor. So if you were to do something like
TEMP = ((kappa_f - L) * phi + (kappa_a - N));
then you would have
A == A1/TEMP
B == A2/TEMP
C == A3/TEMP
D == A4/TEMP
F == A5/TEMP
At this point we need to pause and ask whether the / operator is really the one intended, or if instead the ./ operator is intended, which in turn revolves around the expected size of TEMP and the expected size of A1 and so on.
We see that TEMP is constructed in part from kappa_f and kappa_f is constructed from 1./Kf and Kf is a row vector -- so kappa_f is a row vector and so TEMP must be a row vector. The A B etc. are all row vectors, so we have row_vector == UNKNOWN / row_vector . Experimentally, scalar / row_vector fails, and row_vector / row_vector yields a scalar rather than a row vector, so we deduce that the stated / operations must have been intended to be ./ operations. Unfortunately, we still cannot deduce whether the operation is row_vector == scalar ./ row_vector or if it is row_vector == row_vector ./ row_vector. However, if we rearrange to row_vector .* TEMP where TEMP is a row vector, then we can see that the result must be a row vector. This leads to
A1 = A .* TEMP;
A2 = B .* TEMP;
A3 = C .* TEMP;
A4 = D .* TEMP;
A5 = F .* TEMP;
Now we have a problem: TEMP is defined in terms of the underfined variables L and N, There are 5(*3) equations in 5(*3) unknowns excluding L and N... so there just are not equations to be able to deduce L or N. There is also not enough information to be able to deduce the expected size of L and N.
So... the system is not solvable.
  9 Comments
Abdolrazzagh
Abdolrazzagh 1 minute ago
forget everything
consider we have this five equations
A(i) = SA/((Kf(i) - L) * phi + (Ka - N));
B(i) = SB/((Kf(i) - L) * phi + (Ka - N));
C(i) = SC/((Kf(i) - L) * phi + (Ka - N));
F(i) = SF/((Kf(i) - L) * phi + (Ka - N));
D(i) = SD/((Kf(i) - L) * phi + (Ka - N));
phi,Ka are known, single value and constant.
SA, SB, SC, SF,SD, L, N are our 7 unknowns, they are scalar and single value, across the equations they all are constant and the do not change with varing Kf
if we vary Kf from 1:3,3 we have
3 values for each A, B, C, F, D
15 equations and 7 unkowns:
A(Kf = 1) = S_A/((Kf(1) - L) * phi + (Ka - N));.
A(Kf = 2) = S_A/((Kf(2) - L) * phi + (Ka - N));
A(Kf = 3) = S_A/((Kf(3) - L) * phi + (Ka - N));
.
.
.
D(Kf = 3) = S_D/((Kf(3) - L) * phi + (Ka - N));
if we vary Kf from 1:5,5 we have
5 values for each A, B, C, F, D
25 equations and 7 unkowns
...
if we vary Kf from 1:20,20 we have
20 values for each A, B, C, F, D
100 equations and 7 unkowns
...
and we have A_measured, B_measured, C_measured, F_measured, D_measured
which they are inputs
I want to calculate these 7 unkowns with many equations that I have, which works for all equations
I want in final
coditions:
measured - predicted = 10^-12
Torsten
Torsten about 1 hour ago
Edited: Torsten 29 minutes ago
That's what the code does.
Of course, you cannot guarantee the precision of the fit (error < 1e-12).
And it's not possible to get independent fits for L and N. We discussed the reason already.

Sign in to comment.

Products


Release

R2025a

Community Treasure Hunt

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

Start Hunting!